16 #include "CLHEP/Random/RandGauss.h" 61 fWaveformFile = p.
get<std::string>(
"WaveformFile");
83 "%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
85 msg += Form(
"%-10d ... %-10d ... %-10g ... %-10g\n",
98 for (
size_t i = 0; i !=
fWaveform.size(); ++i)
107 for (
size_t i = 0; i !=
fWaveform.size(); ++i)
115 double Cumulative = 0, SPEArea = 0;
116 for (
size_t i = 0; i !=
fWaveform.size(); ++i) {
118 SPEArea += Cumulative;
126 double AmpSoFar = 0, Cumulative = 0;
127 for (
size_t i = 0; i !=
fWaveform.size(); ++i) {
129 if (Cumulative > AmpSoFar) AmpSoFar = Cumulative;
160 return std::numeric_limits<optdata::TimeSlice_t>::max();
173 std::ifstream WaveformFile(fWaveformFile.c_str());
177 <<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
180 std::vector<double> PEWaveform;
181 if (WaveformFile.is_open()) {
182 while (WaveformFile.good()) {
183 getline(WaveformFile, line);
184 PEWaveform.push_back(
fPERescale * strtod(line.c_str(), NULL));
188 throw cet::exception(
"OpDigiProperties") <<
"No Waveform File: Unable to open file\n";
190 WaveformFile.close();
207 mf::LogWarning(
"OpDigiProperties") <<
"Using empirical table of gain for each PMT...";
208 std::string FullPath;
209 cet::search_path sp(
"FW_SEARCH_PATH");
213 <<
"Unable to find high gain spread file in " << sp.to_string() <<
"\n";
216 <<
"OpDigiProperties opening high gain spread file at " << FullPath.c_str();
217 std::ifstream HighGainFile(FullPath.c_str());
218 if (HighGainFile.is_open()) {
220 while (HighGainFile.good()) {
221 getline(HighGainFile, line);
226 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
231 <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
234 <<
"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);
244 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
249 <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
252 <<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
253 std::ifstream GainSpreadFile(FullPath.c_str());
254 if (GainSpreadFile.is_open()) {
256 while (GainSpreadFile.good()) {
257 getline(GainSpreadFile, line);
262 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
267 txt +=
" Generating gain for each pmt.\n";
268 txt += Form(
" High gain mean: %g ADC/p.e.\n",
fHighGainMean);
269 txt += Form(
" Low gain mean: %g ADC/p.e.\n",
fLowGainMean);
271 txt += Form(
" Intrinsic gain spread : %g \n",
fGainSpread);
292 throw cet::exception(
"OpDigiProperties") <<
"Low gain missing for some channels!\n";
294 throw cet::exception(
"OpDigiProperties") <<
"High gain missing for some channels!\n";
296 throw cet::exception(
"OpDigiProperties") <<
"Gain spread missing for some channels!\n";
301 std::string FullPath;
304 cet::search_path sp(
"FW_SEARCH_PATH");
308 <<
"Unable to find PMT waveform file in " << sp.to_string() <<
"\n";
319 std::ifstream WaveformFile(fWaveformFile.c_str());
323 <<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
326 std::vector<double> PEWaveform;
327 if (WaveformFile.is_open()) {
332 getline(WaveformFile, line);
333 double Amp = strtod(line.c_str(), NULL);
334 PEWaveform.push_back(Amp);
335 if (Amp > MaxAmp) MaxAmp = Amp;
341 throw cet::exception(
"OpDigiProperties_module") <<
"Waveform amplitude <=0!\n";
343 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
344 PEWaveform[i] = PEWaveform[i] / MaxAmp;
347 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
348 PEWaveform[i] = PEWaveform[i] / Charge;
352 throw cet::exception(
"No Waveform File") <<
"Unable to open file\n";
354 WaveformFile.close();
361 <<
" OpDigiProperties using analytical function for WF generation.";
367 "10^(22)*x^[1]*[0]*exp(-x/[2])/TMath::Factorial([1])",
382 for (
unsigned short i = 0; i < PEWaveform.size(); ++i) {
383 double Value =
fAnalyticalSPE->Integral(i * SamplingDuration, (i + 1) * SamplingDuration) /
385 PEWaveform[i] = Value;
386 if (PEWaveform[i] > MaxAmp) MaxAmp = PEWaveform[i];
391 if (MaxAmp <= 0)
throw cet::exception(
"OpDigiProperties_module") <<
"Waveform amplitude <=0!\n";
394 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
395 PEWaveform[i] = PEWaveform[i] / MaxAmp;
396 if (PEWaveform[i] < 1.
e-4) PEWaveform[i] = 0;
400 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
401 PEWaveform[i] = PEWaveform[i] / Charge;
std::vector< double > fHighGainArray
OpDigiProperties(fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< double > GenAnalyticalWF()
double GetSPECumulativeAmplitude() const
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
std::vector< double > fLowGainArray
double LowGainMean() const noexcept
Returns set mean gain value for LOW gain.
double fGainSpread_PMT2PMT
std::vector< double > WaveformInit(std::string WaveformFile)
std::vector< double > GenEmpiricalWF(std::string WaveformFile)
T get(std::string const &key) const
std::vector< double > fWaveform
double GetSPEArea() const
Utility functions.
optdata::ADC_Count_t fPedFlucAmp
double GetSPEAmplitude() const
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...
unsigned int fNOpChannels
std::string fGainSpreadFile
std::vector< optdata::ADC_Count_t > fPedMeanArray
double GetSPECumulativeArea() const
optdata::TimeSlice_t GetTimeSlice(double time_ns)
std::vector< double > fGainSpreadArray
std::string fHighGainFile
optdata::ADC_Count_t fADCBaseline
art framework interface to geometry description
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