Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/JDAQEventIO.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 
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 
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 
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 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1493
General exception.
Definition: JException.hh:23
Direct access to PMT data in detector data structure for DAQ hits.
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:28
ROOT TTree parameter settings.
range_type include(argument_type x)
Include given value to range.
Definition: JRange.hh:399
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
Template const_iterator.
Definition: JDAQEvent.hh:68
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Data structure for detector geometry and calibration.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
T getLength() const
Get length (difference between upper and lower limit).
Definition: JRange.hh:302
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:130
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
#define NOTICE(A)
Definition: JMessage.hh:64
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:61
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JRange< Double_t > JRange_t
Definition: JFitToT.hh:34
int getString() const
Get string number.
Definition: JLocation.hh:134
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
const JPMT & getPMT(const JDAQKeyHit &hit) const
Get PMT parameters.
JPMTChannel getPMTChannel(const JDAQKeyHit &hit) const
Get PMT channel.
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
int main(int argc, char *argv[])
Definition: Main.cpp:15