Jpp  debug
the software that should make you happy
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

◆ main()

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 
95 
96  counter_type N = in.getEntries();
97 
98  if (N > numberOfEvents.getUpperLimit()) {
99  N = numberOfEvents.getUpperLimit();
100  }
101 
102  if (N == 0) {
103  FATAL("Number of time slices in file(s) " << N << endl);
104  }
105 
106  const Long64_t NX = in.getEntry(N-1)->getFrameIndex() - in.getEntry(0)->getFrameIndex() + 1;
107  const Double_t xmin = (Double_t) in.getEntry( 0 )->getFrameIndex() - 0.5;
108  const Double_t xmax = (Double_t) in.getEntry(N-1)->getFrameIndex() + 0.5;
109 
110 
111  TFile out(outputFile.c_str(), "recreate");
112 
113  TH1D h0("UTC", NULL, NX, xmin, xmax);
114  TH1D h1("!utc", NULL, NX, xmin, xmax);
115  TH1D h2("dt", NULL, 1001, -500.5, +500.5);
116 
117 
118  const int frame_index = in.getEntry(0)->getFrameIndex();
119  const JUTCTime_t t0 = getTime(in.getEntry(0)->getTimesliceStart());
120 
121  for (in.rewind(); in.hasNext() && in.getCounter() != numberOfEvents.getUpperLimit(); ) {
122 
123  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
124 
125  JDAQTimeslice* timeslice = in.next();
126 
127  const Double_t x = timeslice->getFrameIndex();
128  const JDAQUTCExtended utc = timeslice->getTimesliceStart();
129 
130  const JUTCTime_t t1 = t0 + getTime(timeslice->getFrameIndex() - frame_index);
131 
132  h0.Fill(x, getTime(utc) - t0);
133 
134  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
135 
136  if (utc != frame->getTimesliceStart()) {
137  h1.Fill(x);
138  }
139 
140  h2.Fill(getTime(frame->getTimesliceStart()) - t1);
141  }
142  }
143  STATUS(endl);
144 
145  out.Write();
146  out.Close();
147 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Utility class to parse command line options.
Definition: JParser.hh:1714
Template definition for direct access of elements in ROOT TChain.
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
int getFrameIndex() const
Get frame index.
Data structure for UTC time.
const double xmax
Definition: JQuadrature.cc:24
const double xmin
Definition: JQuadrature.cc:23
double getTime(const Hit &hit)
Get true time of hit.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Long64_t counter_type
Type definition for counter.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45