Jpp
JBuild.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 
11 #include "JDAQ/JDAQEvent.hh"
12 #include "JDetector/JDetector.hh"
16 #include "JTrigger/JHit.hh"
17 #include "JTrigger/JHitL0.hh"
18 #include "JTrigger/JHitL1.hh"
19 #include "JTrigger/JHitL2.hh"
20 #include "JTrigger/JHitR1.hh"
21 #include "JTrigger/JHitR2.hh"
22 #include "JTrigger/JBuildL0.hh"
23 #include "JTrigger/JBuildL1.hh"
24 #include "JTrigger/JBuildL2.hh"
25 
27 #include "JSupport/JSupport.hh"
28 
29 #include "Jeep/JParser.hh"
30 #include "Jeep/JMessage.hh"
31 
32 
33 namespace {
34 
35  /**
36  * Process event.
37  *
38  * \param build hit builder
39  * \param router module router
40  * \param event event
41  * \param h1 histogram
42  */
43  template<class JBuild_t>
44  inline void process(const JBuild_t& build,
45  const JDETECTOR::JModuleRouter& router,
47  TH1& h1)
48  {
49  using namespace std;
50 
51  typedef typename JBuild_t::value_type value_type;
52 
53  vector<value_type> data;
54 
55  build(event, router, back_inserter(data));
56 
57  h1.Fill((double) data.size());
58  }
59 }
60 
61 
62 /**
63  * \file
64  *
65  * Example program to test JTRIGGER::JBuildL0, JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit building with DAQ events.
66  * \author mdejong
67  */
68 int main(int argc, char **argv)
69 {
70  using namespace std;
71  using namespace JPP;
72  using namespace KM3NETDAQ;
73 
74  JMultipleFileScanner<JDAQEvent> inputFile;
75  JLimit_t& numberOfEvents = inputFile.getLimit();
76  string outputFile;
77  string detectorFile;
78  JTriggerParameters parameters;
79  int debug;
80 
81  try {
82 
83  JParser<> zap("Example program to test hit building with DAQ events.");
84 
85  zap['f'] = make_field(inputFile);
86  zap['o'] = make_field(outputFile) = "build.root";
87  zap['n'] = make_field(numberOfEvents) = JLimit::max();
88  zap['a'] = make_field(detectorFile);
89  zap['@'] = make_field(parameters) = JPARSER::initialised();
90  zap['d'] = make_field(debug) = 0;
91 
92  zap(argc, argv);
93  }
94  catch(const exception &error) {
95  FATAL(error.what() << endl);
96  }
97 
98  cout.tie(&cerr);
99 
100 
101  JDetector detector;
102 
103  try {
104  load(detectorFile, detector);
105  }
106  catch(const JException& error) {
107  FATAL(error);
108  }
109 
110  const JModuleRouter router(detector);
111 
112 
113  TFile out(outputFile.c_str(), "recreate");
114 
115  const Int_t N = 5000;
116 
117  TH1D h0("L0", NULL, N, -0.5, (Double_t) N - 0.5);
118  TH1D h1("L1", NULL, N, -0.5, (Double_t) N - 0.5);
119  TH1D h2("L2", NULL, N, -0.5, (Double_t) N - 0.5);
120 
121  // test compilation for various template specialisations
122 
123  {
124  JBuildL0<double> buildL0;
125  JBuildL1<double> buildL1(parameters);
126  JBuildL2<double> buildL2(parameters.L2);
127  }
128  {
129  JBuildL0<JHitL0> buildL0;
130  JBuildL1<JHitL1> buildL1(parameters);
131  JBuildL2<JHitL2> buildL2(parameters.L2);
132  }
133  {
134  JBuildL0<JHitR0> buildL0;
135  JBuildL1<JHitR1> buildL1(parameters);
136  JBuildL2<JHitR2> buildL2(parameters.L2);
137  }
138 
139  // primitive data types correspond to hit times [ns]
140 
141  JBuildL0<double> buildL0;
142  JBuildL1<double> buildL1(parameters);
143  JBuildL2<double> buildL2(parameters.L2);
144 
145 
146  while (inputFile.hasNext()) {
147 
148  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
149 
150  const JDAQEvent* tev = inputFile.next();
151 
152  process(buildL0, router, *tev, h0);
153  process(buildL1, router, *tev, h1);
154  process(buildL2, router, *tev, h2);
155  }
156  NOTICE(endl);
157 
158  out.Write();
159  out.Close();
160 }
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:34
JHitL2.hh
JTriggerParameters.hh
JMessage.hh
JTRIGGER::JTriggerParameters
Data structure for all trigger parameters.
Definition: JTriggerParameters.hh:116
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
std::vector< value_type >
event
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
Definition: JVoltageOptimizer_utils.hh:26
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
JTRIGGER::JTriggerParameters::L2
JL2Parameters L2
L2 processing.
Definition: JTriggerParameters.hh:327
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JBuildL1.hh
JBuildL0.hh
debug
int debug
debug level
Definition: JSirene.cc:59
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
JHit.hh
JModuleRouter.hh
JHitR1.hh
JMultipleFileScanner.hh
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JBuildL2.hh
JParser.hh
JDetectorToolkit.hh
JDETECTOR::JModuleRouter
Router for direct addressing of module data in detector data structure.
Definition: JModuleRouter.hh:34
JHitL1.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
main
int main(int argc, char **argv)
Definition: JBuild.cc:68
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDAQEvent.hh
JDetector.hh
JHitL0.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JHitR2.hh