Jpp  17.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JRandomL1.cc File Reference

Example program to test JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit coincidence building with random data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TProfile.h"
#include "TRandom3.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorSimulator.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JK40DefaultSimulator.hh"
#include "JDetector/JPMTDefaultSimulator.hh"
#include "JDetector/JCLBDefaultSimulator.hh"
#include "JTrigger/JHit.hh"
#include "JTrigger/JFrame.hh"
#include "JTrigger/JTimeslice.hh"
#include "JTrigger/JSuperFrame2D.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JHitL1.hh"
#include "JTrigger/JBuildL1.hh"
#include "JTrigger/JBuildL2.hh"
#include "JTimeslice/JRandomTimeslice.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

Example program to test JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit coincidence building with random data.

Author
mdejong

Definition in file JRandomL1.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 42 of file JRandomL1.cc.

43 {
44  using namespace std;
45  using namespace JPP;
46 
47  typedef JOption<JK40DefaultSimulator> JK40DefaultSimulator_t;
48 
49  string outputFile;
50  Long64_t numberOfEvents;
51  JPMTParametersMap pmtParameters;
52  JK40DefaultSimulator_t k40Simulator = JK40DefaultSimulator::getInstance();
53  UInt_t seed;
54  double Tmax_ns;
55  int debug;
56 
57  try {
58 
59  JParser<> zap("Example program to test hit coincidence building with random data.");
60 
61  zap['o'] = make_field(outputFile) = "randomL2.root";
62  zap['n'] = make_field(numberOfEvents);
63  zap['P'] = make_field(pmtParameters) = JPARSER::initialised();
64  zap['B'] = make_field(k40Simulator) = JPARSER::initialised();
65  zap['S'] = make_field(seed) = 0;
66  zap['T'] = make_field(Tmax_ns) = 20.0; // [ns]
67  zap['d'] = make_field(debug) = 0;
68 
69  zap(argc, argv);
70  }
71  catch(const exception &error) {
72  FATAL(error.what() << endl);
73  }
74 
75  gRandom->SetSeed(seed);
76 
77  using namespace KM3NETDAQ;
78 
79 
81 
82  detector.push_back(getModule<JKM3NeT_t>(1001));
83 
85 
86  simbad.reset(new JPMTDefaultSimulator(pmtParameters, detector));
87  simbad.reset(new JCLBDefaultSimulator());
88  simbad.reset(k40Simulator.clone());
89 
90 
91  TFile out(outputFile.c_str(), "recreate");
92 
93  TProfile hn("hn", NULL, 31, 0.5, +31.5);
94  TProfile hc("hc", NULL, 21, -1.05, +1.05);
95  TProfile ht("ht", NULL, 20, 0.5, +20.5);
96 
97 
98  const JModuleRouter moduleRouter(detector);
99 
100  typedef double hit_type;
101  typedef vector <hit_type> JFrameL1_t;
102  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
103  typedef JBuildL1 <hit_type> JBuildL1_t;
104 
105 
106  const JBuildL1_t buildL1(JBuildL1Parameters((hit_type) Tmax_ns, true));
107  JSuperFrame2D_t buffer;
108 
109 
110  for (int event_count = 0; event_count < numberOfEvents; ++event_count) {
111 
112  STATUS("event: " << setw(10) << event_count << '\r'); DEBUG(endl);
113 
114  const int frame_index = 1;
115 
116  const JDAQChronometer chronometer(detector.getID(), 1, event_count, JDAQUTCExtended(getTimeOfFrame(frame_index)));
117 
118  JRandomTimeslice timeslice(chronometer, simbad);
119 
120  for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
121 
122  if (moduleRouter.hasModule(super_frame->getModuleID())) {
123 
124  // calibration
125 
126  const JModule& module = detector.getModule(moduleRouter.getAddress(super_frame->getModuleID()));
127 
128  buffer(*super_frame, module);
129 
130  JFrameL1_t dataL1;
131 
132  buildL1(buffer, back_inserter(dataL1));
133 
134 
135  if (!dataL1.empty()) {
136 
137  JBuildL2<hit_type> buildL2(JL2Parameters(1, Tmax_ns, -1.0));
138 
139  JFrameL1_t d1(dataL1);
140  JFrameL1_t d2;
141 
142  for (int i = 1; i <= hn.GetNbinsX(); ++i) {
143 
144  buildL2.numberOfHits = (int) hn.GetBinCenter(i);
145 
146  d2.clear();
147 
148  buildL2(buffer, d1, back_inserter(d2));
149 
150  hn.Fill((double) buildL2.numberOfHits, (double) d2.size() / (double) dataL1.size());
151 
152  d1.swap(d2);
153  }
154  }
155 
156 
157  if (!dataL1.empty()) {
158 
159  JBuildL2<hit_type> buildL2(JL2Parameters(2, Tmax_ns, -1.0));
160 
161  JFrameL1_t d1(dataL1);
162  JFrameL1_t d2;
163 
164  for (int i = 1; i <= hc.GetNbinsX(); ++i) {
165 
166  buildL2.ctMin = hc.GetBinCenter(i);
167 
168  d2.clear();
169 
170  buildL2(buffer, d1, back_inserter(d2));
171 
172  hc.Fill(buildL2.ctMin, (double) d2.size() / (double) dataL1.size());
173 
174  d1.swap(d2);
175  }
176  }
177 
178 
179  if (!dataL1.empty()) {
180 
181  JBuildL2<hit_type> buildL2(JL2Parameters(2, 0.0, -1.0));
182 
183  JFrameL1_t d1(dataL1);
184  JFrameL1_t d2;
185 
186  for (int i = ht.GetNbinsX(); i != 0; --i) {
187 
188  buildL2.TMaxLocal_ns = ht.GetBinCenter(i);
189 
190  d2.clear();
191 
192  buildL2(buffer, d1, back_inserter(d2));
193 
194  ht.Fill(buildL2.TMaxLocal_ns, (double) d2.size() / (double) dataL1.size());
195 
196  d1.swap(d2);
197  }
198  }
199  }
200  }
201  }
202  NOTICE(endl);
203 
204  out.Write();
205  out.Close();
206 
207 }
Utility class to parse command line options.
Definition: JParser.hh:1517
Data structure for a composite optical module.
Definition: JModule.hh:68
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Auxiliary class to handle optional I/O.
Definition: JParser.hh:123
string outputFile
Data structure for UTC time.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
Definition: JDAQClock.hh:185
Template L2 builder.
Definition: JBuildL2.hh:45
Detector file.
Definition: JHead.hh:226
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define NOTICE(A)
Definition: JMessage.hh:64
Auxiliary class for map of PMT parameters.
Template L1 hit builder.
Definition: JBuildL1.hh:85
#define FATAL(A)
Definition: JMessage.hh:67
Data structure for L2 parameters.
Auxiliary data structure for L1 build parameters.
Definition: JBuildL1.hh:37
2-dimensional frame with time calibrated data from one optical module.
do set_variable DETECTOR_TXT $WORKDIR detector
Timeslice with random data.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62