Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
JMermaid.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH1D.h"
9 
10 #include "JTools/JRange.hh"
11 
12 #include "JROOT/JRootToolkit.hh"
13 
14 #include "JDAQ/JDAQEventIO.hh"
15 #include "JDetector/JDetector.hh"
18 
20 #include "JSupport/JSupport.hh"
21 
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 
26 /**
27  * \file
28  *
29  * Example program to monitor event duration.
30  * \author mdejong
31  */
32 int main(int argc, char **argv)
33 {
34  using namespace std;
35  using namespace JPP;
36  using namespace KM3NETDAQ;
37 
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  string outputFile;
41  string detectorFile;
42  double T_ns;
43  int qaqc;
44  int debug;
45 
46  try {
47 
48  JParser<> zap("Example program to monitor event duration.");
49 
50  zap['f'] = make_field(inputFile);
51  zap['o'] = make_field(outputFile) = "mermaid.root";
52  zap['a'] = make_field(detectorFile);
53  zap['n'] = make_field(numberOfEvents) = JLimit::max();
54  zap['T'] = make_field(T_ns, "Time limit for event duration [ns]") = 10.0e3;
55  zap['Q'] = make_field(qaqc) = 0;
56  zap['d'] = make_field(debug) = 2;
57 
58  zap(argc, argv);
59  }
60  catch(const exception& error) {
61  FATAL(error.what() << endl);
62  }
63 
64 
66 
67  try {
68  load(detectorFile, detector);
69  }
70  catch(const JException& error) {
71  FATAL(error);
72  }
73 
74  const JDAQHitRouter router(detector);
75 
76  TH1D h1("h1", NULL, 100, 0.0, 10.0e3);
77 
78  size_t N = 0;
79 
80  while (inputFile.hasNext()) {
81 
82  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
83 
84  JDAQEvent* event = inputFile.next();
85 
86  JTimeRange tx = JTimeRange::DEFAULT_RANGE();
87 
88  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
89  tx.include(getTime(*hit, router.getPMT(*hit)));
90  }
91 
92  h1.Fill(tx.getLength());
93 
94  if (tx.getLength() >= T_ns) {
95  N += 1;
96  }
97  }
98  STATUS(endl);
99 
100  TFile out(outputFile.c_str(), "recreate");
101 
102  out << h1;
103 
104  out.Write();
105  out.Close();
106 
107  NOTICE("Number of event with duration beyond " << FIXED(9,0) << T_ns << " [ns] " << N << endl);
108 
109  QAQC(N << endl);
110 
111  return 0;
112 }
Direct access to PMT data in detector data structure for DAQ hits.
string outputFile
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
Definition: JMermaid.cc:32
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define QAQC(A)
QA/QC output macro.
Definition: JMessage.hh:100
int qaqc
QA/QC file descriptor.
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Auxiliary class to define a range between two values.
ROOT TTree parameter settings of various packages.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
const JPMT & getPMT(const JDAQKeyHit &hit) const
Get PMT parameters.
Detector data structure.
Definition: JDetector.hh:96
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
range_type & include(argument_type x)
Include given value to range.
Definition: JRange.hh:397
T getLength() const
Get length (difference between upper and lower limit).
Definition: JRange.hh:289
Template const_iterator.
Definition: JDAQEvent.hh:68
double getTime(const Hit &hit)
Get true time of hit.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Detector file.
Definition: JHead.hh:227
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45