Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JCalibrateNB.cc File Reference
#include <iostream>
#include "JDAQ/JDAQEventIO.hh"
#include "Jeep/JParser.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JBuildL0.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JGizmo/JManager.hh"
#include "JPhysics/JDispersion.hh"
#include "TH1.h"
#include "TH2.h"
#include "TFile.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JCalibrateNB.cc.

25  {
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.
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.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
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
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
virtual bool hasNext()
Check availability of next element.
General purpose class for object reading from a list of file names.
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