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" );
163 std::string msg(Form(
"%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
179 std::ifstream WaveformFile (fWaveformFile.c_str());
182 mf::LogInfo(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
185 std::vector<double> PEWaveform;
186 if (WaveformFile.is_open())
188 while ( WaveformFile.good() )
190 getline (WaveformFile, line);
191 PEWaveform.push_back(
fPERescale * strtod( line.c_str(), NULL ) );
194 else throw cet::exception(
"OpDigiProperties") <<
"No Waveform File: Unable to open file\n";
196 WaveformFile.close();
211 mf::LogWarning(
"OpDigiProperties")<<
"Using empirical table of gain for each PMT...";
212 std::string FullPath;
213 cet::search_path sp(
"FW_SEARCH_PATH");
216 throw cet::exception(
"OpDigiProperties") <<
"Unable to find high gain spread file in " << sp.to_string() <<
"\n";
218 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening high gain spread file at " << FullPath.c_str();
219 std::ifstream HighGainFile(FullPath.c_str());
220 if(HighGainFile.is_open()) {
222 while ( HighGainFile.good() ){
223 getline(HighGainFile, 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 LowGainFile(FullPath.c_str());
234 if(LowGainFile.is_open()) {
236 while ( LowGainFile.good() ){
237 getline(LowGainFile, line);
240 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
244 throw cet::exception(
"OpDigiProperties") <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
246 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
247 std::ifstream GainSpreadFile(FullPath.c_str());
248 if(GainSpreadFile.is_open()) {
250 while ( GainSpreadFile.good() ){
251 getline(GainSpreadFile, line);
254 }
else throw cet::exception(
"OpDigiProperties")<<
"Unable to open file!\n";
260 txt+=
" Generating gain for each pmt.\n";
262 txt+=Form(
" Low gain mean: %g ADC/p.e.\n",
fLowGainMean);
264 txt+=Form(
" Intrinsic gain spread : %g \n",
fGainSpread);
283 throw cet::exception(
"OpDigiProperties")<<
"Low gain missing for some channels!\n";
285 throw cet::exception(
"OpDigiProperties")<<
"High gain missing for some channels!\n";
287 throw cet::exception(
"OpDigiProperties")<<
"Gain spread missing for some channels!\n";
292 std::string FullPath;
295 cet::search_path sp(
"FW_SEARCH_PATH");
298 throw cet::exception(
"OpDigiProperties") <<
"Unable to find PMT waveform file in " << sp.to_string() <<
"\n";
308 std::ifstream WaveformFile (fWaveformFile.c_str());
311 mf::LogWarning(
"OpDigiProperties")<<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
314 std::vector<double> PEWaveform;
315 if (WaveformFile.is_open())
321 getline (WaveformFile, line);
322 double Amp=strtod(line.c_str(),NULL);
323 PEWaveform.push_back(Amp);
324 if(Amp>MaxAmp) MaxAmp=Amp;
328 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
329 for(
unsigned short i=0; i<PEWaveform.size(); i++){ PEWaveform[i]=PEWaveform[i]/MaxAmp; }
331 else throw cet::exception(
"No Waveform File") <<
"Unable to open file\n";
333 WaveformFile.close();
338 mf::LogWarning(
"OpDigiProperties")<<
" OpDigiProperties using analytical function for WF generation.";
344 "10^(22)*x^[1]*[0]*exp(-x/[2])/TMath::Factorial([1])",
357 for(
unsigned short i = 0; i<PEWaveform.size(); ++i){
359 (i+1) * SamplingDuration) / SamplingDuration;
361 if(PEWaveform[i]>MaxAmp) MaxAmp=PEWaveform[i];
365 if(MaxAmp<=0)
throw cet::exception(
"OpDigiProperties_module")<<
"Waveform amplitude <=0!\n";
366 for(
unsigned short i=0; i<PEWaveform.size(); i++) {
367 PEWaveform[i]=PEWaveform[i]/MaxAmp;
368 if(PEWaveform[i]<1.
e-4) PEWaveform[i]=0;
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