Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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"
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 */
31int 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
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);
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(), 0.0);
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}
int main(int argc, char **argv)
string outputFile
Data structure for detector geometry and calibration.
General purpose messaging.
#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:72
Direct access to module in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
ROOT TTree parameter settings of various packages.
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
const JPMT & getPMT(const int index) const
Get PMT.
Definition JModule.hh:172
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
File router for fast addressing of summary data.
void update(const JDAQHeader &header)
Update router.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
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
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
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128