Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCalibrateNB.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "JDAQ/JDAQEventIO.hh"
4 #include "Jeep/JParser.hh"
5 #include "JSupport/JSupport.hh"
8 #include "JTrigger/JHitL0.hh"
9 #include "JTrigger/JBuildL0.hh"
10 #include "JDetector/JDetector.hh"
13 #include "JGizmo/JManager.hh"
14 #include "JPhysics/JDispersion.hh"
15 
16 #include "TH1.h"
17 #include "TH2.h"
18 #include "TFile.h"
19 
20 using namespace std;
21 using namespace JPP;
22 using namespace JDETECTOR;
23 using namespace KM3NETDAQ;
24 
25 int main(int argc , char** argv){
26 
28  JLimit_t& numberOfEvents = inputFiles.getLimit();
29  string detectorFile;
30  string outFile;
32  double depth;
33  double wavelength;
34 
35  try {
36 
37  JParser<> zap;
38 
39  zap['f'] = make_field(inputFiles );
40  zap['a'] = make_field(detectorFile );
41  zap['n'] = make_field(numberOfEvents ) = JLimit::max();
42  zap['o'] = make_field(outFile ) = "out.root";
43  zap['h'] = make_field(depth , "detector depth [m]" ) = 2500.0;
44  zap['l'] = make_field(wavelength , "LED wavelength [nm]") = 400.0;
45 
46  zap(argc,argv);
47  }
48  catch(const exception &error) {
49  ERROR(error.what() << endl);
50  }
51 
52  typedef JHitL0 JHit_t;
53  typedef vector<JHit_t> JHitBuffer;
54 
55  JBuildL0<JHit_t> builder;
56 
57  JHitBuffer triggerBuffer;
58  JHitBuffer snapshotBuffer;
59 
60  load(detectorFile , detector);
61 
62  JModuleRouter moduleRouter(detector);
63 
64  JDispersion jd (0.1 * depth);
65 
66  double cw = getSpeedOfLight() / jd.getIndexOfRefractionGroup(wavelength);
67 
68  JManager < string , TH1D >* timeDifferences;
69  timeDifferences = new JManager <string , TH1D> (new TH1D("%" , "" , 501 , -250.5 , 250.5));
70 
71  while(inputFiles.hasNext()){
72 
73  JDAQEvent* event = inputFiles.next();
74 
75  triggerBuffer .clear();
76  snapshotBuffer.clear();
77 
78  builder(*event, moduleRouter, true , back_inserter(snapshotBuffer));
79  builder(*event, moduleRouter, false , back_inserter( triggerBuffer));
80 
81  sort(triggerBuffer.begin(),triggerBuffer.end(),less<JHit>());
82 
83  JHitBuffer::const_iterator triggeredHit = triggerBuffer.begin();
84 
85  int triggeredString = moduleRouter.getModule( triggeredHit -> getModuleID() ).getString() ;
86  int triggeredFloor = moduleRouter.getModule( triggeredHit -> getModuleID() ).getFloor() ;
87 
88  for(JHitBuffer::const_iterator snapshotHit = snapshotBuffer.begin(); snapshotHit != snapshotBuffer.end(); ++snapshotHit){
89 
90  int snapshotString = moduleRouter.getModule( snapshotHit -> getModuleID() ).getString() ;
91  int snapshotFloor = moduleRouter.getModule( snapshotHit -> getModuleID() ).getFloor() ;
92 
93  double ToF = triggeredHit->getDistance(*snapshotHit) / cw;
94  double Dt = snapshotHit->getT() - triggeredHit->getT();
95 
96  (*timeDifferences)[MAKE_STRING("S" + to_string(triggeredString) + "F" + to_string(triggeredFloor) + "_S" + to_string(snapshotString) + "F" + to_string(snapshotFloor)).c_str()]->Fill(Dt-ToF);
97  }
98  }
99 
100  TFile output(outFile.c_str() , "recreate") ;
101  timeDifferences -> Write(output);
102 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1493
virtual const pointer_type & next()
Get next element.
ROOT TTree parameter settings.
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
const JModule & getModule(const JObjectID &id) const
Get module parameters.
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
Detector data structure.
Definition: JDetector.hh:80
Implementation of dispersion for water in deep sea.
Definition: JDispersion.hh:26
Router for direct addressing of module data in detector data structure.
Dynamic ROOT object management.
Data structure for detector geometry and calibration.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
Basic data structure for L0 hit.
Auxiliary class to manage set of compatible ROOT objects (e.g.
Definition: JManager.hh:42
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
#define ERROR(A)
Definition: JMessage.hh:66
Support methods.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
virtual bool hasNext()
Check availability of next element.
int getString() const
Get string number.
Definition: JLocation.hh:134
virtual double getIndexOfRefractionGroup(const double lambda) const
Index of refraction for group velocity.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Data structure for L0 hit.
Definition: JHitL0.hh:27
std::string to_string(const T &value)
Convert value to string.
Template L0 hit builder.
Definition: JBuildL0.hh:35
int main(int argc, char *argv[])
Definition: Main.cpp:15