17 #include "CLHEP/Random/RandGauss.h" 78 std::string msg(Form(
"%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
106 double Cumulative=0, SPEArea=0;
107 for(
size_t i=0; i!=
fWaveform.size(); ++i)
110 SPEArea += Cumulative;
118 double AmpSoFar=0, Cumulative=0;
119 for(
size_t i=0; i!=
fWaveform.size(); ++i)
122 if(Cumulative>AmpSoFar) AmpSoFar=Cumulative;
165 std::ifstream WaveformFile (fWaveformFile.c_str());
168 mf::LogInfo(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
171 std::vector<double> PEWaveform;
172 if (WaveformFile.is_open())
174 while ( WaveformFile.good() )
176 getline (WaveformFile, line);
177 PEWaveform.push_back(
fPERescale * strtod( line.c_str(), NULL ) );
180 else throw cet::exception(
"OpDigiProperties") <<
"No Waveform File: Unable to open file\n";
182 WaveformFile.close();
197 mf::LogWarning(
"OpDigiProperties")<<
"Using empirical table of gain for each PMT...";
202 throw cet::exception(
"OpDigiProperties") <<
"Unable to find high gain spread file in " << sp.
to_string() <<
"\n";
204 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening high gain spread file at " << FullPath.c_str();
205 std::ifstream HighGainFile(FullPath.c_str());
206 if(HighGainFile.is_open()) {
208 while ( HighGainFile.good() ){
209 getline(HighGainFile, line);
212 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
216 throw cet::exception(
"OpDigiProperties") <<
"Unable to find low gain spread file in " << sp.
to_string() <<
"\n";
218 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
219 std::ifstream LowGainFile(FullPath.c_str());
220 if(LowGainFile.is_open()) {
222 while ( LowGainFile.good() ){
223 getline(LowGainFile, line);
226 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
230 throw cet::exception(
"OpDigiProperties") <<
"Unable to find low gain spread file in " << sp.
to_string() <<
"\n";
232 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
233 std::ifstream GainSpreadFile(FullPath.c_str());
234 if(GainSpreadFile.is_open()) {
236 while ( GainSpreadFile.good() ){
237 getline(GainSpreadFile, line);
240 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
246 txt+=
" Generating gain for each pmt.\n";
248 txt+=Form(
" Low gain mean: %g ADC/p.e.\n",
fLowGainMean);
250 txt+=Form(
" Intrinsic gain spread : %g \n",
fGainSpread);
269 throw cet::exception(
"OpDigiProperties")<<
"Low gain missing for some channels!\n";
271 throw cet::exception(
"OpDigiProperties")<<
"High gain missing for some channels!\n";
273 throw cet::exception(
"OpDigiProperties")<<
"Gain spread missing for some channels!\n";
294 std::ifstream WaveformFile (fWaveformFile.c_str());
297 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
300 std::vector<double> PEWaveform;
301 if (WaveformFile.is_open())
308 getline (WaveformFile, line);
309 double Amp=strtod(line.c_str(),NULL);
310 PEWaveform.push_back(Amp);
311 if(Amp>MaxAmp) MaxAmp=Amp;
316 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
317 if(!
fChargeNormalized)
for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/MaxAmp; }
318 else for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/Charge; }
320 else throw cet::exception(
"No Waveform File") <<
"Unable to open file\n";
322 WaveformFile.close();
327 mf::LogWarning(
"OpDigiProperties")<<
" OpDigiProperties using analytical function for WF generation.";
333 "10^(22)*x^[1]*[0]*exp(-x/[2])/TMath::Factorial([1])",
347 for(
unsigned short i = 0; i<PEWaveform.size(); ++i){
349 (i+1) * SamplingDuration) / SamplingDuration;
351 if(PEWaveform[i]>MaxAmp) MaxAmp=PEWaveform[i];
356 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
359 for(
unsigned short i=0; i<PEWaveform.size(); i++) {
360 PEWaveform[i]=PEWaveform[i]/MaxAmp;
361 if(PEWaveform[i]<1.
e-4) PEWaveform[i]=0;
364 else for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/Charge; }
std::vector< double > fHighGainArray
std::string to_string() const
art::ServiceHandle< geo::Geometry const > fGeometry
OpDigiProperties(fhicl::ParameterSet const &pset)
void msg(const char *fmt,...)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< double > GenAnalyticalWF()
double GetSPEAmplitude()
Utility function ... To be verified (Kazu 08/05/13)
std::vector< double > fLowGainArray
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
double LowGainMean() const noexcept
Returns set mean gain value for LOW gain.
art framework interface to geometry description
double GetSPECumulativeArea()
Utility function ... To be verified (Kazu 08/05/13)
double fGainSpread_PMT2PMT
std::vector< double > WaveformInit(std::string WaveformFile)
double GetSPECumulativeAmplitude()
Utility function ... To be verified (Kazu 08/05/13)
std::vector< double > GenEmpiricalWF(std::string WaveformFile)
T get(std::string const &key) const
static int max(int a, int b)
std::vector< double > fWaveform
#define DEFINE_ART_SERVICE(svc)
optdata::ADC_Count_t fPedFlucAmp
void line(double t, double *p, double &x, double &y, double &z)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double LowGain(optdata::Channel_t ch) const
Generate & return LOW gain value for an input channel using mean & spread for this channel...
std::string find_file(std::string const &filename) const
double HighGain(optdata::Channel_t ch) const
Generate & return HIGH gain value for an input channel using mean & spread for this channel...
std::string fGainSpreadFile
std::vector< optdata::ADC_Count_t > fPedMeanArray
optdata::TimeSlice_t GetTimeSlice(double time_ns)
std::vector< double > fGainSpreadArray
std::string fHighGainFile
optdata::ADC_Count_t fADCBaseline
double GetSPEArea()
Utility function ... To be verified (Kazu 08/05/13)
optdata::ADC_Count_t fSaturationScale
cet::coded_exception< error, detail::translate > exception
double HighGainMean() const noexcept
Returns set mean gain value for HIGH gain.
std::string fWaveformFile