Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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 "JROOT/JManager.hh"
#include "JPhysics/JDispersion.hh"
#include "JTrigger/JPMTSelector.hh"
#include "JTools/JCombinatorics.hh"
#include "JMath/JMathToolkit.hh"
#include "JNanobeacon.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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 31 of file JCalibrateNB.cc.

31 {
32
34 JLimit_t& numberOfEvents = inputFiles.getLimit();
35 string detectorFile;
36 string outFile;
38 double depth;
39 double wavelength;
40 JPMTSelector selector;
41 JPMTSelector default_pmts;
42
43 default_pmts.push_back(JPMTIdentifier_t(-1,0));
44 default_pmts.push_back(JPMTIdentifier_t(-1,3));
45 default_pmts.push_back(JPMTIdentifier_t(-1,4));
46
47 try {
48
49 JParser<> zap;
50
51 zap['f'] = make_field(inputFiles );
52 zap['a'] = make_field(detectorFile );
53 zap['n'] = make_field(numberOfEvents ) = JLimit::max();
54 zap['o'] = make_field(outFile ) = "out.root";
55 zap['h'] = make_field(depth , "detector depth [m]" ) = 2500.0;
56 zap['l'] = make_field(wavelength , "LED wavelength [nm]") = 400.0;
57 zap['T'] = make_field(selector ) = default_pmts; // for example '-1 0 -1 3 -1 4', to select PMTs 0, 3 and 4 on every DOM
58
59 zap(argc,argv);
60 }
61 catch(const exception &error) {
62 ERROR(error.what() << endl);
63 }
64
65 typedef JHitL0 JHit_t;
66 typedef vector<JHit_t> JHitBuffer;
67
68 JBuildL0<JHit_t> builder;
69
70 JHitBuffer triggerBuffer;
71 JHitBuffer snapshotBuffer;
72
73 load(detectorFile , detector);
74
75 JModuleRouter moduleRouter(detector);
76
77 JDispersion jd (0.1 * depth);
78
79 double cw = getSpeedOfLight() / jd.getIndexOfRefractionGroup(wavelength);
80
81 int num_of_floors = getNumberOfFloors(detector);
82 JCombinatorics c(num_of_floors);
83 int npairs = c.getNumberOfPairs();
85
86 JManager < int, TH2D >* timeDifferences;
87 timeDifferences = new JManager < int, TH2D > ( new TH2D("%", "", npairs, 0.5, npairs+0.5, 501, -250.5, 250.5) );
88
89 while(inputFiles.hasNext()){
90
91 JDAQEvent* event = inputFiles.next();
92
93 triggerBuffer .clear();
94 snapshotBuffer.clear();
95
96 builder(*event, moduleRouter, true , back_inserter(snapshotBuffer));
97 builder(*event, moduleRouter, false , back_inserter( triggerBuffer));
98
99 JHitBuffer::iterator __end = partition(triggerBuffer.begin(), triggerBuffer.end(), selector);
100 if(triggerBuffer.begin() != __end){
101
102 sort(triggerBuffer.begin(), __end, less<JHit>());
103 JHitBuffer::iterator triggeredHit = triggerBuffer.begin();
104
105 if( moduleRouter.hasModule( triggeredHit -> getModuleID() ) ){
106 const JModule& triggeredModule = moduleRouter.getModule( triggeredHit -> getModuleID() );
107
108 for(JHitBuffer::const_iterator snapshotHit = snapshotBuffer.begin(); snapshotHit != snapshotBuffer.end(); ++snapshotHit){
109
110 if( moduleRouter.hasModule( snapshotHit -> getModuleID() ) ){
111 const JModule& snapshotModule = moduleRouter.getModule( snapshotHit -> getModuleID() );
112
113 if( triggeredModule.getString() == snapshotModule.getString() ){
114
115 //double ToF = triggeredHit->getDistance(*snapshotHit) / cw;
116 double Dt = snapshotHit->getT() - triggeredHit->getT();
117 double ToF = getDistance( triggeredHit->getPosition(), snapshotHit->getPosition() ) / cw;
118 //indexes are pairs running from 0-17 between 0-152, while floors are 1-18 and bins are 1-153
119 int xbin = c.getIndex( triggeredModule.getFloor()-1 , snapshotModule.getFloor()-1 ) + 1;
120 if( triggeredModule.getFloor() < snapshotModule.getFloor() ){
121 (*timeDifferences)[triggeredModule.getString()]->Fill(xbin,Dt-ToF);
122 }
123 }
124 } else {
125 FATAL("JModuleRouter trying to access non existing identifier: " << snapshotHit->getModuleID() );
126 }
127 }
128
129 } else {
130 FATAL("JModuleRouter trying to access non existing identifier: " << triggeredHit->getModuleID() );
131 }
132 }
133 }
134 TFile output(outFile.c_str() , "recreate") ;
135 timeDifferences -> Write(output);
136}
#define FATAL(A)
Definition JMessage.hh:67
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Definition JModule.hh:75
Utility class to parse command line options.
Definition JParser.hh:1698
Implementation of dispersion for water in deep sea.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
Auxiliary class to convert pair of indices to unique index and back.
Template L0 hit builder.
Definition JBuildL0.hh:38
Data structure for L0 hit.
Definition JHitL0.hh:31
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
bool comparepair(const pair_type &A, const pair_type &B)
const double getSpeedOfLight()
Get speed of light.
Depth.
Definition JHead.hh:980
Detector file.
Definition JHead.hh:227
Auxiliary class to set-up Hit.
Definition JSirene.hh:58
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary data structure for set of PMT identifiers.