11 #include "messagefacility/MessageLogger/MessageLogger.h"
14 #include "CLHEP/Random/RandGauss.h"
30 fTimeEnd = p.get<
double >(
"TimeEnd" );
35 fQE = p.get<
double>(
"QE");
60 fWaveformFile = p.get< std::string >(
"WaveformFile" );
78 std::string
msg(Form(
"%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
79 for(
unsigned int i=0;i<
fGeometry->NOpChannels();++i) {
82 mf::LogInfo(__FUNCTION__)<<msg.c_str();
106 double Cumulative=0,
SPEArea=0;
107 for(
size_t i=0; i!=
fWaveform.size(); ++i)
118 double AmpSoFar=0, Cumulative=0;
119 for(
size_t i=0; i!=
fWaveform.size(); ++i)
122 if(Cumulative>AmpSoFar) AmpSoFar=Cumulative;
153 if( time_ns/1.e3 > (
fTimeEnd-
fTimeBegin))
return std::numeric_limits<optdata::TimeSlice_t>::max();
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();
188 for(
unsigned int i=0;i<
fGeometry->NOpChannels();++i)
197 mf::LogWarning(
"OpDigiProperties")<<
"Using empirical table of gain for each PMT...";
198 std::string FullPath;
199 cet::search_path sp(
"FW_SEARCH_PATH");
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);
251 mf::LogWarning(
"OpDigiProperties")<<txt.c_str();
252 for(
unsigned int i=0;i<
fGeometry->NOpChannels();++i) {
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";
278 std::string FullPath;
281 cet::search_path sp(
"FW_SEARCH_PATH");
284 throw cet::exception(
"OpDigiProperties") <<
"Unable to find PMT waveform file in " << sp.to_string() <<
"\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
art::ServiceHandle< geo::Geometry const > fGeometry
OpDigiProperties(fhicl::ParameterSet const &pset)
std::vector< double > GenAnalyticalWF()
double GetSPEAmplitude()
Utility function ... To be verified (Kazu 08/05/13)
std::vector< double > fLowGainArray
BEGIN_PROLOG xarapuca_vuv SBNDDecoOpHitFinderXArapuca SPEArea
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)
std::vector< double > fWaveform
optdata::ADC_Count_t fPedFlucAmp
double HighGainMean() const noexcept
Returns set mean gain value for HIGH gain.
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)
double LowGainMean() const noexcept
Returns set mean gain value for LOW gain.
optdata::ADC_Count_t fSaturationScale
std::string fWaveformFile