Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQSnapshot.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 "JDAQ/JDAQEventIO.hh"
12 #include "JDetector/JDetector.hh"
16 
18 #include "JSupport/JSupport.hh"
20 
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 
25 /**
26  * \file
27  *
28  * Program to plot snapshot data.
29  * \author mdejong
30  */
31 int main(int argc, char **argv)
32 {
33  using namespace std;
34  using namespace JPP;
35  using namespace KM3NETDAQ;
36 
38  string outputFile;
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  string detectorFile;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Program to plot snapshot data.");
46 
47  zap['f'] = make_field(inputFile, "input file.");
48  zap['o'] = make_field(outputFile, "output file.") = "snapshot.root";
49  zap['n'] = make_field(numberOfEvents) = JLimit::max();
50  zap['a'] = make_field(detectorFile, "detector file.") = "";
51  zap['d'] = make_field(debug) = 2;
52 
53  zap(argc, argv);
54  }
55  catch(const exception& error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  cout.tie(&cerr);
61 
63 
64  if (detectorFile != "") {
65 
66  try {
67  load(detectorFile, detector);
68  }
69  catch(const JException& error) {
70  FATAL(error);
71  }
72  }
73 
74  const JModuleRouter router(detector);
75 
76 
77  JSummaryFileRouter summary(inputFile, 0.0);
78 
79  TFile out(outputFile.c_str(), "recreate");
80 
81  TH1D h0("h0", NULL, 250, -0.5, 499.5);
82  TH1D h1("h1", NULL, 250, -0.5, 499.5);
83 
84  while (inputFile.hasNext()) {
85 
86  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
87 
88  JDAQEvent* event = inputFile.next();
89 
90  summary.update(*event);
91 
92  int number_of_hits = 0;
93 
94  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event->begin<JDAQSnapshotHit>(); hit != event->end<JDAQSnapshotHit>(); ++hit) {
95 
96  if (summary.hasSummaryFrame(hit->getModuleID())) {
97 
98  const JDAQSummaryFrame& frame = summary.getSummaryFrame(hit->getModuleID());
99 
100  JStatus status;
101 
102  if (router.hasModule(frame.getModuleID())) {
103  status = router.getModule(frame.getModuleID()).getPMT(hit->getPMT()).getStatus();
104  }
105 
106  if (getPMTStatus(frame, status, hit->getPMT()) &&
107  getDAQStatus(frame, status)) {
108  ++number_of_hits;
109  }
110  }
111  }
112 
113  DEBUG("Number of snapshot hits " << event->size<JDAQSnapshotHit>() << ' ' << number_of_hits << endl);
114 
115  h0.Fill((double) event->size<JDAQSnapshotHit> ());
116  h1.Fill((double) number_of_hits);
117  }
118  STATUS(endl);
119 
120  out.Write();
121  out.Close();
122 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
DAQ key hit.
Definition: JDAQKeyHit.hh:19
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
int getModuleID() const
Get module identifier.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
#define STATUS(A)
Definition: JMessage.hh:63
void update(const JDAQHeader &header)
Update router.
Detector data structure.
Definition: JDetector.hh:89
Template const_iterator.
Definition: JDAQEvent.hh:68
Router for direct addressing of module data in detector data structure.
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
string outputFile
Data structure for detector geometry and calibration.
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Data storage class for rate measurements of all PMTs in one module.
Auxiliary class for handling status.
Definition: JStatus.hh:37
File router for fast addressing of summary data.
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
bool hasModule(const JObjectID &id) const
Has module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
JTriggerCounter_t next()
Increment trigger counter.