Jpp
JDAQHitRouter.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 #include "TH2D.h"
10 
11 #include "JTools/JRange.hh"
12 
13 #include "JDAQ/JDAQEvent.hh"
14 #include "JDetector/JDetector.hh"
17 
19 #include "JSupport/JSupport.hh"
20 
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 
25 /**
26  * \file
27  *
28  * Example program to histogram string and floor hits.
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 
37  JMultipleFileScanner<JDAQEvent> inputFile;
38  JLimit_t& numberOfEvents = inputFile.getLimit();
39  string outputFile;
40  string detectorFile;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to histogram string and floor hits.");
46 
47  zap['f'] = make_field(inputFile);
48  zap['o'] = make_field(outputFile) = "router.root";
49  zap['a'] = make_field(detectorFile);
50  zap['n'] = make_field(numberOfEvents) = JLimit::max();
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 
61 
62  cout.tie(&cerr);
63 
64 
65  JDetector detector;
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 
77  typedef JTOOLS::JRange<int> JRange_t;
78 
79  const JRange_t string(detector.begin(), detector.end(), &JModule::getString);
80  const JRange_t floor (detector.begin(), detector.end(), &JModule::getFloor);
81 
82  NOTICE("String " << string.getLowerLimit() << " - " << string.getUpperLimit() << endl);
83  NOTICE("Floor " << floor .getLowerLimit() << " - " << floor .getUpperLimit() << endl);
84 
85 
86  TFile out(outputFile.c_str(), "recreate");
87 
88  TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
89  TH2D h2("h2", NULL,
90  string.getLength() + 1,
91  string.getLowerLimit() - 0.5,
92  string.getUpperLimit() + 0.5,
93  floor.getLength() + 1,
94  floor.getLowerLimit() - 0.5,
95  floor.getUpperLimit() + 0.5);
96 
97 
98  while (inputFile.hasNext()) {
99 
100  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
101 
102  JDAQEvent* event = inputFile.next();
103 
104  JTimeRange tx = JTimeRange::DEFAULT_RANGE;
105 
106  typedef JDAQTriggeredHit JHit_t;
107 
108  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
109 
110  const JPMTChannel& channel = router.getPMTChannel(*hit);
111 
112  h2.Fill((double) channel.getString(), (double) channel.getFloor());
113 
114  tx.include(getTime(*hit, router.getPMT(*hit)));
115  }
116 
117  h1.Fill(tx.getLength() * 1.0e-3);
118  }
119  STATUS(endl);
120 
121  out.Write();
122  out.Close();
123 }
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:34
JMessage.hh
JDAQHitRouter.hh
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
JTOOLS::JRange< int >
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JTOOLS::JTimeRange
JRange< double > JTimeRange
Type definition for time range.
Definition: JTools/JTimeRange.hh:19
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQTriggeredHit
DAQ triggered hit.
Definition: JDAQTriggeredHit.hh:25
JRange.hh
debug
int debug
debug level
Definition: JSirene.cc:59
KM3NETDAQ::JDAQEvent::const_iterator
Template const_iterator.
Definition: JDAQEvent.hh:69
KM3NETDAQ::JDAQTriggerCounter::next
JTriggerCounter_t next()
Increment trigger counter.
Definition: JDAQTriggerCounter.hh:120
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
JAANET::getTime
double getTime(const Hit &hit)
Get true time of hit.
Definition: JAAnetToolkit.hh:87
JMultipleFileScanner.hh
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JParser.hh
JDetectorToolkit.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
main
int main(int argc, char **argv)
Definition: JDAQHitRouter.cc:31
JDAQEvent.hh
JDetector.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37