All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DriftEstimatorPMTRatio_tool.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 /// File: DriftEstimatorPMTRatio_tool.cc
3 ///
4 /// Base class: DriftEstimatorBase.hh
5 ///
6 /// Tool description: this tool estimates the drift coordinate
7 /// from the ratio between the #PE reconstructed for the
8 /// uncoated/coated PMTs. It requires a calibration curve
9 /// (speficied in the CalibrationFile fhicl parameter).
10 /// Once the drift has been estimated, the photon propagation
11 /// time is calculated using the VUV and VIS light group velocities
12 ///
13 /// Created by Fran Nicolas, June 2022
14 ////////////////////////////////////////////////////////////////////////
15 
16 #include "fhiclcpp/types/Atom.h"
17 #include "art/Utilities/ToolMacros.h"
18 #include "art/Utilities/make_tool.h"
19 #include "art/Utilities/ToolConfigTable.h"
20 #include "art/Framework/Services/Registry/ServiceHandle.h"
23 
24 #include <vector>
25 #include <string>
26 
27 #include "DriftEstimatorBase.hh"
29 
30 //ROOT includes
31 #include "TProfile.h"
32 #include "TFile.h"
33 
34 namespace lightana
35 {
37 
38  public:
39 
40  //Configuration parameters
41  struct Config {
42 
43  fhicl::Atom<std::string> CalibrationFile {
44  fhicl::Name("CalibrationFile"),
45  fhicl::Comment("Filepath to the calibration ROOT file")
46  };
47 
48  fhicl::Atom<double> VGroupVUV {
49  fhicl::Name("VGroupVUV"),
50  fhicl::Comment("Group velocity for VUV photons")
51  };
52 
53  fhicl::Atom<double> VGroupVIS {
54  fhicl::Name("VGroupVIS"),
55  fhicl::Comment("Group velocity for VIS photons")
56  };
57 
58  };
59 
60  // Default constructor
61  explicit DriftEstimatorPMTRatio(art::ToolConfigTable<Config> const& config);
62 
63  // Method giving the estimated drift coordinate
64  double GetDriftPosition(std::vector<double> PE_v) override;
65 
66  // Method giving the photon propagation
67  double GetPropagationTime(double drift) override;
68 
69  // Method giving the photon propagation from PE vector
70  double PEToPropagationTime(std::vector<double> PE_v);
71 
72  private:
73  double Interpolate(double val);
74 
75  // Input filepah with calibration curve
76  std::string fCalibrationFile;
77 
78  // Scintillation light group velocities
79  double fVGroupVUV;
80  double fVGroupVIS;
81  double fVGroupVUV_I;
82 
83  //Geo properties
86  double fKinkDistance;
87 
88  // Vectors with calibration variables
89  std::vector<double> fPMTRatioCal;
90  std::vector<double> fDriftCal;
91  int fNCalBins;
94 
95  // PDS mapping
97 
98  };
99 
100  DriftEstimatorPMTRatio::DriftEstimatorPMTRatio(art::ToolConfigTable<Config> const& config)
101  : fCalibrationFile { config().CalibrationFile() },
102  fVGroupVUV { config().VGroupVUV() },
103  fVGroupVIS { config().VGroupVIS() }
104  {
105 
106  // Open input file
107  std::string file_name;
108  cet::search_path sp("FW_SEARCH_PATH");
109  if ( !sp.find_file(fCalibrationFile, file_name) )
110  throw cet::exception("DriftEstimatorPMTRatio") << "Calibration file " <<
111  fCalibrationFile << " not found in FW_SEARCH_PATH\n";
112 
113  TFile* input_file = TFile::Open(file_name.c_str(), "READ");
114  TProfile * hProf_Calibration = (TProfile*)input_file->Get("PMTRatioCalibrationProfile");
115 
116  //Fill calibration variables
117  fNCalBins = hProf_Calibration->GetNbinsX();
118  for (int ix=1; ix<=fNCalBins; ix++){
119  fPMTRatioCal.push_back( hProf_Calibration->GetBinCenter(ix) );
120  fDriftCal.push_back( hProf_Calibration->GetBinContent(ix) );
121  }
122  fPMTRatio_MinVal = hProf_Calibration->GetBinCenter(1);
123  fPMTRatio_MaxVal = hProf_Calibration->GetBinCenter(fNCalBins);
124 
125  input_file->Close();
126 
127  geo::GeometryCore const& geom = *(lar::providerFrom<geo::Geometry>());
128 
129  fDriftDistance = geom.TPC(0.0).DriftDistance();
130  fVISLightPropTime = fDriftDistance/fVGroupVIS;
131  fKinkDistance = 0.5*fDriftDistance*(1-fVGroupVUV/fVGroupVIS);
132 
133  fVGroupVUV_I = 1./fVGroupVUV;
134  }
135 
136  double DriftEstimatorPMTRatio::GetDriftPosition(std::vector<double> PE_v){
137 
138  double coatedPE=0, uncoatedPE=0;
139 
140  for(size_t oc=0; oc<PE_v.size(); oc++){
141  if( fPDSMap.pdType(oc)=="pmt_coated" ) coatedPE+=PE_v[oc];
142  else if( fPDSMap.pdType(oc)=="pmt_uncoated" ) uncoatedPE+=PE_v[oc];
143  }
144 
145  double pmtratio=1.;
146  if(coatedPE!=0)
147  pmtratio = 4*uncoatedPE/coatedPE;
148 
149  double drift_distance;
150  if(pmtratio<=fPMTRatioCal[0])
151  drift_distance=fDriftCal[0];
152  else if(pmtratio>=fPMTRatioCal[fNCalBins-1])
153  drift_distance=fDriftCal[fNCalBins-1];
154  else
155  drift_distance=Interpolate(pmtratio);
156 
157  return drift_distance;
158  }
159 
161 
162  // drift is here the X coordinate
163  // cathode: x=0 cm, PDS: x=200 cm
164  if(std::abs(drift) > fKinkDistance)
165  return (fDriftDistance-std::abs(drift)) * fVGroupVUV_I ;
166  else
167  return std::abs(drift) * fVGroupVUV_I + fVISLightPropTime;
168  }
169 
170  double DriftEstimatorPMTRatio::PEToPropagationTime(std::vector<double> PE_v){
171 
172  double _drift = GetDriftPosition(PE_v);
173 
174  return GetPropagationTime(_drift);
175  }
176 
178 
179  size_t upix = std::upper_bound(fPMTRatioCal.begin(), fPMTRatioCal.end(), val)-fPMTRatioCal.begin();
180 
181  double slope = ( fDriftCal[upix]-fDriftCal[upix] ) / ( fPMTRatioCal[upix]-fPMTRatioCal[upix-1] );
182 
183  return fDriftCal[upix-1] + slope * ( val - fPMTRatioCal[upix-1] );
184  }
185 
186 }
187 
188 DEFINE_ART_CLASS_TOOL(lightana::DriftEstimatorPMTRatio)
Utilities related to art service access.
double PEToPropagationTime(std::vector< double > PE_v)
double GetPropagationTime(double drift) override
T abs(T value)
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production file_name
BEGIN_PROLOG vertical distance to the surface Name
Description of geometry of one entire detector.
double DriftDistance() const
Definition: TPCGeo.h:155
double GetDriftPosition(std::vector< double > PE_v) override
DriftEstimatorPMTRatio(art::ToolConfigTable< Config > const &config)
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::string pdType(size_t ch) const override
art framework interface to geometry description