Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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 
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 getModuleID() const
Get module identifier.
#define STATUS(A)
Definition: JMessage.hh:63
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.
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:226
#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:67
#define FATAL(A)
Definition: JMessage.hh:67
bool getPMTStatus(const JStatus &status)
Test status of PMT.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62