Jpp  debug
the software that should make you happy
Functions
JDAQSnapshot.cc File Reference

Program to plot snapshot data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JTriggerToolkit.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JSummaryFileRouter.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

Program to plot snapshot data.

Author
mdejong

Definition in file JDAQSnapshot.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JDAQSnapshot.cc.

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 
61 
62  if (detectorFile != "") {
63 
64  try {
65  load(detectorFile, detector);
66  }
67  catch(const JException& error) {
68  FATAL(error);
69  }
70  }
71 
72  const JModuleRouter router(detector);
73 
74 
75  JSummaryFileRouter summary(inputFile, 0.0);
76 
77  TFile out(outputFile.c_str(), "recreate");
78 
79  TH1D h0("h0", NULL, 250, -0.5, 499.5);
80  TH1D h1("h1", NULL, 250, -0.5, 499.5);
81 
82  while (inputFile.hasNext()) {
83 
84  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
85 
86  JDAQEvent* event = inputFile.next();
87 
88  summary.update(*event);
89 
90  int number_of_hits = 0;
91 
92  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event->begin<JDAQSnapshotHit>(); hit != event->end<JDAQSnapshotHit>(); ++hit) {
93 
94  if (summary.hasSummaryFrame(hit->getModuleID())) {
95 
96  const JDAQSummaryFrame& frame = summary.getSummaryFrame(hit->getModuleID());
97 
98  JStatus status;
99 
100  if (router.hasModule(frame.getModuleID())) {
101  status = router.getModule(frame.getModuleID()).getPMT(hit->getPMT()).getStatus();
102  }
103 
104  if (getPMTStatus(frame, status, hit->getPMT()) &&
105  getDAQStatus(frame, status)) {
106  ++number_of_hits;
107  }
108  }
109  }
110 
111  DEBUG("Number of snapshot hits " << event->size<JDAQSnapshotHit>() << ' ' << number_of_hits << endl);
112 
113  h0.Fill((double) event->size<JDAQSnapshotHit> ());
114  h1.Fill((double) number_of_hits);
115  }
116  STATUS(endl);
117 
118  out.Write();
119  out.Close();
120 }
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
Detector data structure.
Definition: JDetector.hh:96
Router for direct addressing of module data in detector data structure.
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1714
Object reading from a list of files.
virtual const pointer_type & next() override
Get next element.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
File router for fast addressing of summary data.
Template const_iterator.
Definition: JDAQEvent.hh:68
int getModuleID() const
Get module identifier.
Data storage class for rate measurements of all PMTs in one module.
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).
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
Auxiliary class for handling status.
Definition: JStatus.hh:39
int getStatus() const
Get status.
Definition: JStatus.hh:63
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45