Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JInterDomCal_utils.hh File Reference
#include "Detector.hh"
#include "NBRun.hh"
#include "Physics.hh"

Go to the source code of this file.

Functions

double computeMedianCorrection (JDetector *det, vector< SuperPMT * > srcs, vector< SuperPMT * > tgts)
 It uses the pmts from a source module and from a target module. More...
 
JDetector Update_Detector (JDetector detector, const vector< SuperModule * > &SuperMods)
 Produces a new detector file by updating the existing t0s of the PMTs. More...
 

Function Documentation

double computeMedianCorrection ( JDetector det,
vector< SuperPMT * >  srcs,
vector< SuperPMT * >  tgts 
)
inline

It uses the pmts from a source module and from a target module.

Author
rgruiz For each possible pair source-target, it computes the a factor that needs to be added to the t0s of all the PMTs in the target module. Finally it computes the median
Parameters
detdetector with old t0s
srcsSUPERPMTs of the emitter DOM
tgtsSUPERPMTs of the receiver DOM
Returns
Median correction factor

Definition at line 23 of file JInterDomCal_utils.hh.

23  {
24 
25  double c_w = c_water_genhen() ;
26 
27  //double c_w = c_water(470 , 3000);
28 
29  vector<double> corrections ;
30 
31  const JPMTRouter pmtRouter(*det);
32 
33  for (auto & src : srcs){
34 
35  JPMT src_pmt = src->getPMT() ;
36 
37  NBPulse* src_pulse = src->getNBPulse() ;
38 
39  for(auto & tgt : tgts){
40 
41  JPMT tgt_pmt = tgt->getPMT() ;
42 
43  NBPulse* tgt_pulse = tgt->getNBPulse() ;
44 
45  double distance = get_PMT_distance(src_pmt , tgt_pmt) ;
46 
47  double t_flight = distance / c_w ;
48 
49  double delta_traw = tgt_pulse->getPeakTime() - src_pulse->getPeakTime() ;
50 
51  double delta_t0 = t_flight - delta_traw ;
52 
53  double delta_t0_old = pmtRouter.getPMT(JObjectID(tgt_pmt.getID())).getT0() - pmtRouter.getPMT(JObjectID(src_pmt.getID())).getT0() ;
54 
55  corrections.push_back(delta_t0 - delta_t0_old) ;
56 
57  }
58 
59  }
60 
61  sort (corrections.begin() , corrections.end()) ;
62 
63  int index = int(0.5*corrections.size()) ;
64 
65  return corrections[index] ;
66 
67 }
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:33
Analyzes the signal of a nanobeacon in a PMT.
Definition: NBPulse.hh:33
double get_PMT_distance(JPMT src_pmt, JPMT tgt_pmt)
Calculate the distance between two JPMTs in the detector.
Definition: Detector.hh:133
int getID() const
Get identifier.
Definition: JObjectID.hh:54
Data structure for PMT geometry and calibration.
Definition: JPMT.hh:52
Auxiliary class for object identification.
Definition: JObjectID.hh:27
double getPeakTime()
Get the arrival time of the nanobeacon pulse.
Definition: NBPulse.hh:554
double c_water_genhen()
Definition: Physics.hh:25
JDetector Update_Detector ( JDetector  detector,
const vector< SuperModule * > &  SuperMods 
)
inline

Produces a new detector file by updating the existing t0s of the PMTs.

Parameters
detectorOld detector
SuperModsThe SuperModules used to calibrate the detector
Returns
calibrated detector

Definition at line 76 of file JInterDomCal_utils.hh.

76  {
77 
78  JDetector new_det = detector ;
79 
80  for(auto & sm : SuperMods){
81 
82  JModuleLocation tgt_loc = sm->getDom().getLocation() ;
83 
84  if(sm->get_good_sources().size()>0){
85 
86  pair < SuperModule* , vector < SuperPMT* > > src = sm->get_closest_good_source();
87 
88  vector < SuperPMT* > srcs = src.first->get_ref_pmts() ;
89 
90  vector < SuperPMT* > tgts = src.second ;
91 
92  double correction = computeMedianCorrection(&new_det , srcs , tgts) ;
93 
94  int nPMTs = getNumberOfPMTs(detector)/getNumberOfModules(detector) ;
95 
96  for(int j=0 ; j < nPMTs ; j++){
97 
98  new_det.getModule(tgt_loc).getPMT(j).setT0(new_det.getModule(tgt_loc).getPMT(j).getT0() + correction ) ;
99 
100  }
101 
102  }
103 
104  }
105 
106  return new_det;
107 
108 }
const JModuleLocation & getLocation() const
Get location.
Detector data structure.
Definition: JDetector.hh:77
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:141
const JModule & getModule(const JModuleAddress &address) const
Get module parameters.
Definition: JDetector.hh:180
void setT0(const double t0)
Set time offset.
double computeMedianCorrection(JDetector *det, vector< SuperPMT * > srcs, vector< SuperPMT * > tgts)
It uses the pmts from a source module and from a target module.
int getNumberOfModules(const JDetector &detector)
Get number of modules.
Logical location of module.
double getT0() const
Get time offset.