Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JUTCProfile.cc File Reference

Example program to histogram UTC profiles. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to histogram UTC profiles.

Author
mdejong

Definition in file JUTCProfile.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file JUTCProfile.cc.

68 {
69  using namespace std;
70  using namespace JPP;
71  using namespace KM3NETDAQ;
72 
73  JMultipleFileScanner<> inputFile;
74  JLimit_t& numberOfEvents = inputFile.getLimit();
75  string outputFile;
76  int debug;
77 
78  try {
79 
80  JParser<> zap("Example program to histogram UTC profiles.");
81 
82  zap['f'] = make_field(inputFile);
83  zap['o'] = make_field(outputFile) = "profile.root";
84  zap['n'] = make_field(numberOfEvents) = JLimit::max();
85  zap['d'] = make_field(debug) = 1;
86 
87  zap(argc, argv);
88  }
89  catch(const exception& error) {
90  FATAL(error.what() << endl);
91  }
92 
93 
94  cout.tie(&cerr);
95 
97 
98  counter_type N = in.getEntries();
99 
100  if (N > numberOfEvents.getUpperLimit()) {
101  N = numberOfEvents.getUpperLimit();
102  }
103 
104  if (N == 0) {
105  FATAL("Number of time slices in file(s) " << N << endl);
106  }
107 
108  const Long64_t NX = in.getEntry(N-1)->getFrameIndex() - in.getEntry(0)->getFrameIndex() + 1;
109  const Double_t xmin = (Double_t) in.getEntry( 0 )->getFrameIndex() - 0.5;
110  const Double_t xmax = (Double_t) in.getEntry(N-1)->getFrameIndex() + 0.5;
111 
112 
113  TFile out(outputFile.c_str(), "recreate");
114 
115  TH1D h0("UTC", NULL, NX, xmin, xmax);
116  TH1D h1("!utc", NULL, NX, xmin, xmax);
117  TH1D h2("dt", NULL, 1001, -500.5, +500.5);
118 
119 
120  const int frame_index = in.getEntry(0)->getFrameIndex();
121  const JUTCTime_t t0 = getTime(in.getEntry(0)->getTimesliceStart());
122 
123  for (in.rewind(); in.hasNext() && in.getCounter() != numberOfEvents.getUpperLimit(); ) {
124 
125  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
126 
127  JDAQTimeslice* timeslice = in.next();
128 
129  const Double_t x = timeslice->getFrameIndex();
130  const JDAQUTCExtended utc = timeslice->getTimesliceStart();
131 
132  const JUTCTime_t t1 = t0 + getTime(timeslice->getFrameIndex() - frame_index);
133 
134  h0.Fill(x, getTime(utc) - t0);
135 
136  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
137 
138  if (utc != frame->getTimesliceStart()) {
139  h1.Fill(x);
140  }
141 
142  h2.Fill(getTime(frame->getTimesliceStart()) - t1);
143  }
144  }
145  STATUS(endl);
146 
147  out.Write();
148  out.Close();
149 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1500
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
#define STATUS(A)
Definition: JMessage.hh:63
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
Long64_t counter_type
Type definition for counter.
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Data structure for UTC time.
Template definition for direct access of elements in ROOT TChain.
int getFrameIndex() const
Get frame index.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Data time slice.
int debug
debug level
Definition: JSirene.cc:66
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62