Jpp
Functions
Detector.hh File Reference
#include "JDetector/JDetector.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JTools/JQuantile.hh"
#include <tuple>

Go to the source code of this file.

Functions

JDetector loadDetector (string detectorFile)
 Loads the content of a detector file in a JDetector object. More...
 
vector< double > getDetFile_t0_differences (int strNr, JDetector detector, int ref_pmt, int tgt_pmt)
 Loops over the floors in the string chosen by the user. More...
 
vector< tuple< double, double, double > > get_t0_offsets_vs_depth (int strNr, const JDetector &detector)
 
double get_PMT_distance (JPMT src_pmt, JPMT tgt_pmt)
 Calculate the distance between two JPMTs in the detector. More...
 
void Print_Detector (JDetector &detector, int strNr)
 Prints the t0 of all the PMTs in a DU. More...
 

Function Documentation

◆ loadDetector()

JDetector loadDetector ( string  detectorFile)
inline

Loads the content of a detector file in a JDetector object.

Author
rgruiz
Parameters
detectorFileThe name of a .detx
Returns
a JDetector object with the information of the file name

Definition at line 28 of file Detector.hh.

28  {
29 
30  JDetector detector;
31 
32  try {
33 
34  load(detectorFile, detector);
35 
36  }
37 
38  catch(const JException& error) {
39 
40  cerr << "FATAL ERROR. Could not open detector file '" << detectorFile << "'." << endl ;
41 
42  exit(1) ;
43 
44  }
45 
46  return detector ;
47 
48 }

◆ getDetFile_t0_differences()

vector<double> getDetFile_t0_differences ( int  strNr,
JDetector  detector,
int  ref_pmt,
int  tgt_pmt 
)
inline

Loops over the floors in the string chosen by the user.

At each iteration "i" this function calculates: dt = t0_tgt[i+1] - t0_ref[i] where t0_tgt is the t0 of the target PMT and t0_ref is the t0 of the reference PMT (the closest to the nanobeacon). The result is stored in a vector of dimension nFloors - 1 and this vector is returned.

Parameters
detectorThe name of a .detx
strNrString number
ref_pmtnumber of reference pmt
tgt_pmtnumber of target pmt
Returns
a JDetector object with the information of the file name

Definition at line 66 of file Detector.hh.

66  {
67 
68  int nFloors = getNumberOfFloors(detector) ;
69 
70  vector<double> T0_diff (nFloors - 1) ;
71 
72  for (int i=1 ; i< nFloors ; i++) {
73 
74  T0_diff[i-1] = detector.getModule(JModuleLocation(strNr , i+1 )).getPMT(tgt_pmt).getT0() - detector.getModule(JModuleLocation(strNr , i )).getPMT(ref_pmt).getT0() ;
75 
76  }
77 
78  return T0_diff ;
79 
80 }

◆ get_t0_offsets_vs_depth()

vector< tuple <double , double , double> > get_t0_offsets_vs_depth ( int  strNr,
const JDetector detector 
)
inline

Definition at line 83 of file Detector.hh.

83  {
84 
85  int nFloors = getNumberOfFloors(detector) ;
86 
87  vector< tuple <double , double , double> > t0_vs_depth (nFloors) ;
88 
89  JTOOLS::JQuantile Q ("") ;
90 
91  for (int i = 1 ; i<nFloors+1 ; i++){
92 
93  JModule module = detector.getModule(JModuleLocation(strNr , i)) ;
94 
95  double depth = module.getPosition().getZ() ;
96 
97  JTOOLS::JQuantile q ("") ;
98 
99  for (int j = 0 ; j < getNumberOfPMTs(module) ; j++){
100 
101  JPMT pm = module.getPMT(j) ;
102 
103  q.put(pm.getT0()) ;
104 
105  }
106 
107  tuple < double , double , double > t (depth , q.getMean() , q.getSTDev()) ;
108 
109  t0_vs_depth[i-1] = t ;
110 
111  Q.put(q.getMean()) ;
112 
113  }
114 
115  for (auto & t: t0_vs_depth){
116 
117  get<1>(t) -= Q.getMean() ;
118 
119  }
120 
121  return t0_vs_depth ;
122 
123 }

◆ get_PMT_distance()

double get_PMT_distance ( JPMT  src_pmt,
JPMT  tgt_pmt 
)
inline

Calculate the distance between two JPMTs in the detector.

Parameters
src_pmtOne pmt
tgt_pmtOther pmt
Returns
distance between both JPMTs

Definition at line 133 of file Detector.hh.

133  {
134 
135  const JPosition3D pmt1_pos = src_pmt.getPosition() ;
136 
137  const JPosition3D pmt2_pos = tgt_pmt.getPosition() ;
138 
139  const JVector3D dist(pmt1_pos - pmt2_pos) ;
140 
141  return dist.getLength() ;
142 
143 }

◆ Print_Detector()

void Print_Detector ( JDetector detector,
int  strNr 
)
inline

Prints the t0 of all the PMTs in a DU.

Parameters
detectorA JDetector
strNrThe DU number

Definition at line 152 of file Detector.hh.

152  {
153 
154  int nFloors = 18 ;
155 
156  int nPMTs = 31 ;
157 
158  JModuleRouter moduleRouter(detector) ;
159 
160  for(int i=1 ; i < nFloors ; i++){
161 
162  JModule dom = detector.getModule(JModuleLocation(strNr , i+1)) ;
163 
164  for(int j=0 ; j < nPMTs ; j++){
165 
166  cout <<dom.getPMT(j).getT0() << endl;
167 
168  }
169 
170  }
171 
172 }
JGEOMETRY3D::JVector3D::getZ
double getZ() const
Get z position.
Definition: JVector3D.hh:114
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
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
JDETECTOR::getNumberOfFloors
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
Definition: JDetectorToolkit.hh:414
JDETECTOR::JModuleLocation
Logical location of module.
Definition: JModuleLocation.hh:36
JGEOMETRY3D::JVector3D
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
JDETECTOR::JModule::getPMT
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JDETECTOR::JModule
Data structure for a composite optical module.
Definition: JModule.hh:49
JDETECTOR::JPMT
Data structure for PMT geometry and calibration.
Definition: JPMT.hh:53
JDETECTOR::getNumberOfPMTs
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
Definition: JDetectorToolkit.hh:348
JTOOLS::JQuantile
Quantile calculator.
Definition: JQuantile.hh:34
JDETECTOR::JModuleRouter
Router for direct addressing of module data in detector data structure.
Definition: JModuleRouter.hh:34
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JGEOMETRY3D::JPosition3D::getPosition
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
JLANG::JException
General exception.
Definition: JException.hh:40