Jpp  debug
the software that should make you happy
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/JDetectorSupportkit.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 94 of file JRandomL1.cc.

95 {
96  using namespace std;
97  using namespace JPP;
98 
99  string outputFile;
100  Long64_t numberOfEvents;
101  JPMTParametersMap pmtParameters;
102  JK40DefaultSimulator_t k40Simulator;
103  UInt_t seed;
104  double Tmax_ns;
105  int debug;
106 
107  try {
108 
109  JParser<> zap("Example program to test hit coincidence building with random data.");
110 
111  zap['o'] = make_field(outputFile) = "randomL2.root";
112  zap['n'] = make_field(numberOfEvents);
113  zap['P'] = make_field(pmtParameters) = JPARSER::initialised();
114  zap['B'] = make_field(k40Simulator) = JPARSER::initialised();
115  zap['S'] = make_field(seed) = 0;
116  zap['T'] = make_field(Tmax_ns) = 20.0; // [ns]
117  zap['d'] = make_field(debug) = 0;
118 
119  zap(argc, argv);
120  }
121  catch(const exception &error) {
122  FATAL(error.what() << endl);
123  }
124 
125  gRandom->SetSeed(seed);
126 
127  using namespace KM3NETDAQ;
128 
129 
131 
132  detector.push_back(getModule<JKM3NeT_t>(1001));
133 
135 
136  simbad.reset(new JPMTDefaultSimulator(pmtParameters, detector));
137  simbad.reset(new JCLBDefaultSimulator());
138  simbad.reset(k40Simulator.clone());
139 
140 
141  TFile out(outputFile.c_str(), "recreate");
142 
143  TProfile hn("hn", NULL, 31, 0.5, +31.5);
144  TProfile hc("hc", NULL, 21, -1.05, +1.05);
145  TProfile ht("ht", NULL, 20, 0.5, +20.5);
146 
147 
148  const JModuleRouter moduleRouter(detector);
149 
150  typedef double hit_type;
151  typedef vector <hit_type> JFrameL1_t;
152  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
153  typedef JBuildL1 <hit_type> JBuildL1_t;
154 
155 
156  const JBuildL1_t buildL1(JBuildL1Parameters((hit_type) Tmax_ns, true));
157  JSuperFrame2D_t buffer;
158 
159 
160  for (int event_count = 0; event_count < numberOfEvents; ++event_count) {
161 
162  STATUS("event: " << setw(10) << event_count << '\r'); DEBUG(endl);
163 
164  const int frame_index = 1;
165 
166  const JDAQChronometer chronometer(detector.getID(), 1, event_count, JDAQUTCExtended(getTimeOfFrame(frame_index)));
167 
168  JRandomTimeslice timeslice(chronometer, simbad);
169 
170  for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
171 
172  if (moduleRouter.hasModule(super_frame->getModuleID())) {
173 
174  // calibration
175 
176  const JModule& module = detector.getModule(moduleRouter.getAddress(super_frame->getModuleID()));
177 
178  buffer(*super_frame, module);
179 
180  JFrameL1_t dataL1;
181 
182  buildL1(buffer, back_inserter(dataL1));
183 
184 
185  if (!dataL1.empty()) {
186 
187  JBuildL2<hit_type> buildL2(JL2Parameters(1, Tmax_ns, -1.0));
188 
189  JFrameL1_t d1(dataL1);
190  JFrameL1_t d2;
191 
192  for (int i = 1; i <= hn.GetNbinsX(); ++i) {
193 
194  buildL2.numberOfHits = (int) hn.GetBinCenter(i);
195 
196  d2.clear();
197 
198  buildL2(buffer, d1, back_inserter(d2));
199 
200  hn.Fill((double) buildL2.numberOfHits, (double) d2.size() / (double) dataL1.size());
201 
202  d1.swap(d2);
203  }
204  }
205 
206 
207  if (!dataL1.empty()) {
208 
209  JBuildL2<hit_type> buildL2(JL2Parameters(2, Tmax_ns, -1.0));
210 
211  JFrameL1_t d1(dataL1);
212  JFrameL1_t d2;
213 
214  for (int i = 1; i <= hc.GetNbinsX(); ++i) {
215 
216  buildL2.ctMin = hc.GetBinCenter(i);
217 
218  d2.clear();
219 
220  buildL2(buffer, d1, back_inserter(d2));
221 
222  hc.Fill(buildL2.ctMin, (double) d2.size() / (double) dataL1.size());
223 
224  d1.swap(d2);
225  }
226  }
227 
228 
229  if (!dataL1.empty()) {
230 
231  JBuildL2<hit_type> buildL2(JL2Parameters(2, 0.0, -1.0));
232 
233  JFrameL1_t d1(dataL1);
234  JFrameL1_t d2;
235 
236  for (int i = ht.GetNbinsX(); i != 0; --i) {
237 
238  buildL2.TMaxLocal_ns = ht.GetBinCenter(i);
239 
240  d2.clear();
241 
242  buildL2(buffer, d1, back_inserter(d2));
243 
244  ht.Fill(buildL2.TMaxLocal_ns, (double) d2.size() / (double) dataL1.size());
245 
246  d1.swap(d2);
247  }
248  }
249  }
250  }
251  }
252  NOTICE(endl);
253 
254  out.Write();
255  out.Close();
256 
257 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Detector data structure.
Definition: JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Definition: JModule.hh:75
Auxiliary class for map of PMT parameters.
Utility class to parse command line options.
Definition: JParser.hh:1714
Template L1 hit builder.
Definition: JBuildL1.hh:90
Template L2 builder.
Definition: JBuildL2.hh:49
2-dimensional frame with time calibrated data from one optical module.
Data structure for UTC time.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
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
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Auxiliary data structure for L1 build parameters.
Definition: JBuildL1.hh:38
Data structure for L2 parameters.
Timeslice with random data.