44 int main(
int argc,
char **argv)
48 using namespace KM3NETDAQ;
55 int numberOfTimeslices;
57 double binWidth_min_timeEvolution;
58 JROOTClassSelector selector;
63 JParser<> zap(
"Example program to search for out of sync shifts around integral timeslices evolving over time.");
68 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
70 zap[
'N'] =
make_field(numberOfTimeslices) = 40;
72 zap[
'M'] =
make_field(binWidth_min_timeEvolution) = 2;
73 zap[
'C'] =
make_field(selector) =
"", getROOTClassSelection<JDAQTimesliceTypes_t>();
78 catch(
const exception& error) {
79 FATAL(error.what() << endl);
89 const int WR = 0x80000000;
91 MASK[808969848] = 0x00000020;
92 MASK[809544061] = 0x00000080;
93 MASK[808432835] = 0x00004000;
99 load(detectorFile, detector);
101 catch(
const JException& error) {
105 const JDAQHitRouter router(detector);
110 JBuildL0<hit_type> buildL0;
111 JBuildL1<hit_type> buildL1(TMax_ns,
true);
116 JSinglePointer< JTreeScannerInterface<JDAQTimeslice> > ps;
120 if (selector ==
"") {
122 if ((ps =
new JTreeScanner< JAssertConversion<JDAQTimesliceSN, JDAQTimeslice> >(inputFile))->getEntries() != 0 ||
123 (ps =
new JTreeScanner< JAssertConversion<JDAQTimesliceL2, JDAQTimeslice> >(inputFile))->getEntries() != 0 ||
124 (ps =
new JTreeScanner< JAssertConversion<JDAQTimesliceL1, JDAQTimeslice> >(inputFile))->getEntries() != 0 ||
125 (ps =
new JTreeScanner< JAssertConversion<JDAQTimeslice, JDAQTimeslice> >(inputFile))->getEntries() != 0 ||
126 (ps =
new JTreeScanner< JAssertConversion<JDAQTimesliceL0, JDAQTimeslice> >(inputFile))->getEntries() != 0) {
128 FATAL(
"No timeslice data." << endl);
131 NOTICE(
"Selected class " << ps->getClassName() << endl);
137 ps->configure(inputFile);
143 const Double_t ymin = -(numberOfTimeslices + 0.5);
144 const Double_t ymax = +(numberOfTimeslices + 0.5);
145 const Int_t ny = (Int_t) (ymax - ymin);
147 const Double_t xmin = inputFile.getLimit().min()*
getFrameTime()*1e-9;
148 const Double_t xmax = min(inputFile.getLimit().max(), ps->getEntries())*
getFrameTime()*1e-9;
149 const Int_t nx = (Int_t) ((xmax - xmin) / (60*binWidth_min_timeEvolution)) + 1;
151 JManager_t manager(
new TH2D(
"M2D_%",
";time [s];shift [timeslices]", nx, xmin, xmax, ny, ymin, ymax));
157 for (JTreeScanner<JDAQEvent> in(inputFile.getFilename(), inputFile.getLimit()); in.hasNext(); ) {
159 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
168 t0 +=
getTime(*hit, router.getPMT(*hit));
174 buffer[
event->getFrameIndex()].push_back(t0);
179 while (ps->hasNext()) {
181 STATUS(
"event: " << setw(10) << ps->getCounter() <<
'\r');
DEBUG(endl);
185 map_type::const_iterator p = buffer.lower_bound(timeslice->
getFrameIndex() - numberOfTimeslices);
186 map_type::const_iterator q = buffer.upper_bound(timeslice->
getFrameIndex() + numberOfTimeslices);
188 int number_of_events = 0;
190 for (map_type::const_iterator i = p; i != q; ++i) {
191 number_of_events += i->second.size();
194 if (number_of_events == 0) {
198 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
202 if ((frame->getStatus() & ~MASK[frame->getModuleID()] & ~WR) == 0) {
206 buildL1(*frame, router.getModule(frame->getModuleID()), back_inserter(data));
208 TH2D* h2 = manager[frame->getModuleID()];
212 const double t1 = *hit + frame->getFrameIndex() *
getFrameTime();
214 for (map_type::const_iterator i = p; i != q; ++i) {
215 for (map_type::mapped_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
217 const double t0 = *j;
221 if ( abs(timeFromInt)*
getFrameTime() < binWidth_ns/2. ){
Utility class to parse command line options.
Direct access to PMT data in detector data structure for DAQ hits.
Auxiliary class to manage set of histograms.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
Dynamic ROOT object management.
Auxiliary class for a type holder.
double getTime(const Hit &hit)
Get true time of hit.
Data structure for detector geometry and calibration.
int getFrameIndex() const
Get frame index.
JLimit JLimit_t
Type definition of limit.
Scanning of objects from a single file according a format that follows from the extension of each fil...
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getFrameTime()
Get frame time duration.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
General purpose messaging.
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])