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

Example program to test JTRIGGER::JBuildL0, JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit building with DAQ events. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JTrigger/JHit.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JHitL1.hh"
#include "JTrigger/JHitL2.hh"
#include "JTrigger/JHitR1.hh"
#include "JTrigger/JHitR2.hh"
#include "JTrigger/JBuildL0.hh"
#include "JTrigger/JBuildL1.hh"
#include "JTrigger/JBuildL2.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.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::JBuildL0, JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit building with DAQ events.

Author
mdejong

Definition in file JBuild.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file JBuild.cc.

69 {
70  using namespace std;
71  using namespace JPP;
72  using namespace KM3NETDAQ;
73 
75  JLimit_t& numberOfEvents = inputFile.getLimit();
76  string outputFile;
77  string detectorFile;
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);
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 
100 
101  try {
102  load(detectorFile, detector);
103  }
104  catch(const JException& error) {
105  FATAL(error);
106  }
107 
108  const JModuleRouter router(detector);
109 
110 
111  TFile out(outputFile.c_str(), "recreate");
112 
113  const Int_t N = 5000;
114 
115  TH1D h0("L0", NULL, N, -0.5, (Double_t) N - 0.5);
116  TH1D h1("L1", NULL, N, -0.5, (Double_t) N - 0.5);
117  TH1D h2("L2", NULL, N, -0.5, (Double_t) N - 0.5);
118 
119  // test compilation for various template specialisations
120 
121  {
122  JBuildL0<double> buildL0;
123  JBuildL1<double> buildL1(parameters);
124  JBuildL2<double> buildL2(parameters.L2);
125  }
126  {
127  JBuildL0<JHitL0> buildL0;
128  JBuildL1<JHitL1> buildL1(parameters);
129  JBuildL2<JHitL2> buildL2(parameters.L2);
130  }
131  {
132  JBuildL0<JHitR0> buildL0;
133  JBuildL1<JHitR1> buildL1(parameters);
134  JBuildL2<JHitR2> buildL2(parameters.L2);
135  }
136 
137  // primitive data types correspond to hit times [ns]
138 
139  JBuildL0<double> buildL0;
140  JBuildL1<double> buildL1(parameters);
141  JBuildL2<double> buildL2(parameters.L2);
142 
143 
144  while (inputFile.hasNext()) {
145 
146  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
147 
148  const JDAQEvent* tev = inputFile.next();
149 
150  process(buildL0, router, *tev, h0);
151  process(buildL1, router, *tev, h1);
152  process(buildL2, router, *tev, h2);
153  }
154  NOTICE(endl);
155 
156  out.Write();
157  out.Close();
158 }
Utility class to parse command line options.
Definition: JParser.hh:1517
General exception.
Definition: JException.hh:23
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:102
#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.
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Template specialisation of L1 builder for JHitL1 data type.
Definition: JBuildL1.hh:197
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Template L2 builder.
Definition: JBuildL2.hh:45
Template specialisation of L0 builder for JHitR0 data type.
Definition: JBuildL0.hh:174
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
Template specialisation of L2 builder for JHitL2 data type.
Definition: JBuildL2.hh:226
#define NOTICE(A)
Definition: JMessage.hh:64
Template specialisation of L1 builder for JHitR1 data type.
Definition: JBuildL1.hh:284
Template L1 hit builder.
Definition: JBuildL1.hh:85
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
Template specialisation of L2 builder for JHitR2 data type.
Definition: JBuildL2.hh:339
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
Template L0 hit builder.
Definition: JBuildL0.hh:35
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62