14 #include "CLHEP/Random/RandGauss.h" 59 fWaveformFile = p.
get<std::string>(
"WaveformFile");
78 "%-10s ... %-10s ... %-10s ... %-10s\n",
"Ch. Number",
"Pedestal",
"High Gain",
"Low Gain"));
80 msg += Form(
"%-10d ... %-10d ... %-10g ... %-10g\n",
93 for (
size_t i = 0; i !=
fWaveform.size(); ++i)
102 for (
size_t i = 0; i !=
fWaveform.size(); ++i)
110 double Cumulative = 0, SPEArea = 0;
111 for (
size_t i = 0; i !=
fWaveform.size(); ++i) {
113 SPEArea += Cumulative;
121 double AmpSoFar = 0, Cumulative = 0;
122 for (
size_t i = 0; i !=
fWaveform.size(); ++i) {
124 if (Cumulative > AmpSoFar) AmpSoFar = Cumulative;
155 return std::numeric_limits<optdata::TimeSlice_t>::max();
168 std::ifstream WaveformFile(fWaveformFile.c_str());
172 <<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
175 std::vector<double> PEWaveform;
176 if (WaveformFile.is_open()) {
177 while (WaveformFile.good()) {
178 getline(WaveformFile, line);
179 PEWaveform.push_back(
fPERescale * strtod(line.c_str(), NULL));
183 throw cet::exception(
"OpDigiProperties") <<
"No Waveform File: Unable to open file\n";
185 WaveformFile.close();
202 mf::LogWarning(
"OpDigiProperties") <<
"Using empirical table of gain for each PMT...";
203 std::string FullPath;
204 cet::search_path sp(
"FW_SEARCH_PATH");
208 <<
"Unable to find high gain spread file in " << sp.to_string() <<
"\n";
211 <<
"OpDigiProperties opening high gain spread file at " << FullPath.c_str();
212 std::ifstream HighGainFile(FullPath.c_str());
213 if (HighGainFile.is_open()) {
215 while (HighGainFile.good()) {
216 getline(HighGainFile, line);
221 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
226 <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
229 <<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
230 std::ifstream LowGainFile(FullPath.c_str());
231 if (LowGainFile.is_open()) {
233 while (LowGainFile.good()) {
234 getline(LowGainFile, line);
239 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
244 <<
"Unable to find low gain spread file in " << sp.to_string() <<
"\n";
247 <<
"OpDigiProperties opening low gain spread file at " << FullPath.c_str();
248 std::ifstream GainSpreadFile(FullPath.c_str());
249 if (GainSpreadFile.is_open()) {
251 while (GainSpreadFile.good()) {
252 getline(GainSpreadFile, line);
257 throw cet::exception(
"OpDigiProperties") <<
"Unable to open file!\n";
262 txt +=
" Generating gain for each pmt.\n";
263 txt += Form(
" High gain mean: %g ADC/p.e.\n",
fHighGainMean);
264 txt += Form(
" Low gain mean: %g ADC/p.e.\n",
fLowGainMean);
266 txt += Form(
" Intrinsic gain spread : %g \n",
fGainSpread);
287 throw cet::exception(
"OpDigiProperties") <<
"Low gain missing for some channels!\n";
289 throw cet::exception(
"OpDigiProperties") <<
"High gain missing for some channels!\n";
291 throw cet::exception(
"OpDigiProperties") <<
"Gain spread missing for some channels!\n";
296 std::string FullPath;
299 cet::search_path sp(
"FW_SEARCH_PATH");
303 <<
"Unable to find PMT waveform file in " << sp.to_string() <<
"\n";
314 std::ifstream WaveformFile(fWaveformFile.c_str());
318 <<
"OpDigiProperties opening OpDet waveform at " << fWaveformFile.c_str();
321 std::vector<double> PEWaveform;
322 if (WaveformFile.is_open()) {
327 getline(WaveformFile, line);
328 double Amp = strtod(line.c_str(), NULL);
329 PEWaveform.push_back(Amp);
330 if (Amp > MaxAmp) MaxAmp = Amp;
336 throw cet::exception(
"OpDigiProperties_module") <<
"Waveform amplitude <=0!\n";
338 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
339 PEWaveform[i] = PEWaveform[i] / MaxAmp;
342 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
343 PEWaveform[i] = PEWaveform[i] / Charge;
347 throw cet::exception(
"No Waveform File") <<
"Unable to open file\n";
349 WaveformFile.close();
356 <<
" OpDigiProperties using analytical function for WF generation.";
362 "10^(22)*x^[1]*[0]*exp(-x/[2])/TMath::Factorial([1])",
377 for (
unsigned short i = 0; i < PEWaveform.size(); ++i) {
378 double Value =
fAnalyticalSPE->Integral(i * SamplingDuration, (i + 1) * SamplingDuration) /
380 PEWaveform[i] = Value;
381 if (PEWaveform[i] > MaxAmp) MaxAmp = PEWaveform[i];
386 if (MaxAmp <= 0)
throw cet::exception(
"OpDigiProperties_module") <<
"Waveform amplitude <=0!\n";
389 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
390 PEWaveform[i] = PEWaveform[i] / MaxAmp;
391 if (PEWaveform[i] < 1.
e-4) PEWaveform[i] = 0;
395 for (
unsigned short i = 0; i < PEWaveform.size(); i++) {
396 PEWaveform[i] = PEWaveform[i] / Charge;
std::vector< double > fHighGainArray
art::ServiceHandle< geo::Geometry const > fGeometry
OpDigiProperties(fhicl::ParameterSet const &pset)
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.
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
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)
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