16 #include "CLHEP/Random/RandGaussQ.h" 59 double Cumulative=0, SPEArea=0;
63 SPEArea += Cumulative;
71 double AmpSoFar=0, Cumulative=0;
75 if(Cumulative>AmpSoFar) AmpSoFar=Cumulative;
122 fQE = p.
get<
double>(
"QE");
147 fWaveformFile = p.
get< std::string >(
"WaveformFile" );
165 std::string msg(Form(
"%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
181 std::ifstream WaveformFile (fWaveformFile.c_str());
184 mf::LogInfo(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
187 std::vector<double> PEWaveform;
188 if (WaveformFile.is_open())
190 while ( WaveformFile.good() )
192 getline (WaveformFile, line);
193 PEWaveform.push_back(
fPERescale * strtod( line.c_str(), NULL ) );
196 else throw cet::exception(
"OpDigiProperties") <<
"No Waveform File: Unable to open file\n";
198 WaveformFile.close();
213 mf::LogWarning(
"OpDigiProperties")<<
"Using empirical table of gain for each PMT...";
214 std::string FullPath;
215 cet::search_path sp(
"FW_SEARCH_PATH");
218 throw cet::exception(
"OpDigiProperties") <<
"Unable to find high gain spread file in " << sp.to_string() <<
"\n";
220 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening high gain spread file at " << FullPath.c_str();
221 std::ifstream HighGainFile(FullPath.c_str());
222 if(HighGainFile.is_open()) {
224 while ( HighGainFile.good() ){
225 getline(HighGainFile, line);
228 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
232 throw cet::exception(
"OpDigiProperties") <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
234 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
235 std::ifstream LowGainFile(FullPath.c_str());
236 if(LowGainFile.is_open()) {
238 while ( LowGainFile.good() ){
239 getline(LowGainFile, line);
242 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
246 throw cet::exception(
"OpDigiProperties") <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
248 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
249 std::ifstream GainSpreadFile(FullPath.c_str());
250 if(GainSpreadFile.is_open()) {
252 while ( GainSpreadFile.good() ){
253 getline(GainSpreadFile, line);
256 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
262 txt+=
" Generating gain for each pmt.\n";
264 txt+=Form(
" Low gain mean: %g ADC/p.e.\n",
fLowGainMean);
266 txt+=Form(
" Intrinsic gain spread : %g \n",
fGainSpread);
285 throw cet::exception(
"OpDigiProperties")<<
"Low gain missing for some channels!\n";
287 throw cet::exception(
"OpDigiProperties")<<
"High gain missing for some channels!\n";
289 throw cet::exception(
"OpDigiProperties")<<
"Gain spread missing for some channels!\n";
294 std::string FullPath;
297 cet::search_path sp(
"FW_SEARCH_PATH");
300 throw cet::exception(
"OpDigiProperties") <<
"Unable to find PMT waveform file in " << sp.to_string() <<
"\n";
310 std::ifstream WaveformFile (fWaveformFile.c_str());
313 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
316 std::vector<double> PEWaveform;
317 if (WaveformFile.is_open())
324 getline (WaveformFile, line);
325 double Amp=strtod(line.c_str(),NULL);
326 PEWaveform.push_back(Amp);
327 if(Amp>MaxAmp) MaxAmp=Amp;
332 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
333 if(!
fChargeNormalized)
for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/MaxAmp; }
334 else for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/Charge; }
336 else throw cet::exception(
"No Waveform File") <<
"Unable to open file\n";
338 WaveformFile.close();
343 mf::LogWarning(
"OpDigiProperties")<<
" OpDigiProperties using analytical function for WF generation.";
349 "10^(22)*x^[1]*[0]*exp(-x/[2])/TMath::Factorial([1])",
363 for(
unsigned short i = 0; i<PEWaveform.size(); ++i){
365 (i+1) * SamplingDuration) / SamplingDuration;
367 if(PEWaveform[i]>MaxAmp) MaxAmp=PEWaveform[i];
372 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
375 for(
unsigned short i=0; i<PEWaveform.size(); i++) {
376 PEWaveform[i]=PEWaveform[i]/MaxAmp;
377 if(PEWaveform[i]<1.
e-4) PEWaveform[i]=0;
380 else for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/Charge; }
double HighGainMean() const
Returns set mean gain value for HIGH gain.
std::vector< double > fHighGainArray
void reconfigure(fhicl::ParameterSet const &p)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
#define DEFINE_ART_SERVICE(svc)
art::ServiceHandle< geo::Geometry > fGeometry
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
Returns set mean gain value for LOW gain.
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
OpDigiProperties(fhicl::ParameterSet const &pset, art::ActivityRegistry ®)
std::vector< double > fWaveform
optdata::ADC_Count_t fPedFlucAmp
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...
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)
art framework interface to geometry description
optdata::ADC_Count_t fSaturationScale
cet::coded_exception< error, detail::translate > exception
std::string fWaveformFile