Jpp  18.2.1
the software that should make you happy
 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 "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

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 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Auxiliary class to convert pair of indices to unique index and back.
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:68
Depth.
Definition: JHead.hh:980
Detector data structure.
Definition: JDetector.hh:89
Implementation of dispersion for water in deep sea.
Definition: JDispersion.hh:26
Router for direct addressing of module data in detector data structure.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
virtual bool hasNext() override
Check availability of next element.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define ERROR(A)
Definition: JMessage.hh:66
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
#define FATAL(A)
Definition: JMessage.hh:67
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
int getString() const
Get string number.
Definition: JLocation.hh:134
const double getSpeedOfLight()
Get speed of light.
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.
Data structure for L0 hit.
Definition: JHitL0.hh:27
virtual const pointer_type & next() override
Get next element.
Auxiliary class to set-up Hit.
Definition: JSirene.hh:57
bool comparepair(const pair_type &A, const pair_type &B)
Definition: JNanobeacon.hh:10
Template L0 hit builder.
Definition: JBuildL0.hh:35
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for set of PMT identifiers.
Definition: JPMTSelector.hh:25