Jpp
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

◆ computeMedianCorrection()

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 }

◆ Update_Detector()

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 }
c_water_genhen
double c_water_genhen()
Definition: Physics.hh:25
std::vector< double >
JDETECTOR::JCalibration::getT0
double getT0() const
Get time offset.
Definition: JDetector/JCalibration.hh:83
JTOOLS::j
int j
Definition: JPolint.hh:634
JDETECTOR::JDetector::getModule
const JModule & getModule(const JModuleAddress &address) const
Get module parameters.
Definition: JDetector.hh:183
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JDETECTOR::JPMTRouter
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:33
JDETECTOR::JModuleLocation
Logical location of module.
Definition: JModuleLocation.hh:36
get_PMT_distance
double get_PMT_distance(JPMT src_pmt, JPMT tgt_pmt)
Calculate the distance between two JPMTs in the detector.
Definition: Detector.hh:133
JDETECTOR::JModule::getPMT
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
NBPulse
Analyzes the signal of a nanobeacon in a PMT.
Definition: NBPulse.hh:33
JDETECTOR::getNumberOfModules
int getNumberOfModules(const JDetector &detector)
Get number of modules.
Definition: JDetectorToolkit.hh:432
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition: JObjectID.hh:55
NBPulse::getPeakTime
double getPeakTime()
Get the arrival time of the nanobeacon pulse.
Definition: NBPulse.hh:554
JDETECTOR::JPMT
Data structure for PMT geometry and calibration.
Definition: JPMT.hh:53
std::pair
Definition: JSTDTypes.hh:15
JLANG::JObjectID
Auxiliary class for object identification.
Definition: JObjectID.hh:27
JDETECTOR::getNumberOfPMTs
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
Definition: JDetectorToolkit.hh:348
JDETECTOR::JCalibration::setT0
void setT0(const double t0)
Set time offset.
Definition: JDetector/JCalibration.hh:94
JDETECTOR::JModuleLocation::getLocation
const JModuleLocation & getLocation() const
Get location.
Definition: JModuleLocation.hh:68
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
computeMedianCorrection
double computeMedianCorrection(JDetector *det, vector< SuperPMT * > srcs, vector< SuperPMT * > tgts)
It uses the pmts from a source module and from a target module.
Definition: JInterDomCal_utils.hh:23