3 #ifndef PDWaveform_module 4 #define PDWaveform_module 30 #include "art_root_io/TFileService.h" 32 #include "canvas/Persistency/Common/FindManyP.h" 40 #include "TLorentzVector.h" 46 #include "TPaveLabel.h" 47 #include "TPaveText.h" 50 #include "TInterpreter.h" 56 #include "TSpectrum.h" 69 #pragma link C++ class vector<vector<int> >+; 160 if( fSSP_wfm_verbose ){
161 std::cout <<
" fSSP_m1=" << fSSP_m1 <<
std::endl;
162 std::cout <<
" fSSP_m2=" << fSSP_m2 <<
std::endl;
163 std::cout <<
" fSSP_i1=" << fSSP_i1 <<
std::endl;
164 std::cout <<
" fSSP_i2=" << fSSP_i2 <<
std::endl;
165 std::cout <<
" fSSP_disc_width=" << fSSP_disc_width <<
std::endl;
166 std::cout <<
" fSSP_readout_pretrigger=" << fSSP_readout_pretrigger <<
std::endl;
167 std::cout <<
" fSSP_corrchan1="<< fSSP_corrchan1 <<
std::endl;
168 std::cout <<
" fSSP_corrchan2="<< fSSP_corrchan2 <<
std::endl;
169 std::cout <<
" fSSP_win="<< fSSP_win <<
std::endl;
170 std::cout <<
" fSSP_smoothing="<< fSSP_smoothing <<
std::endl;
180 PDchanMean = tFileService->make<TH2F>(
"Mean vs. Channel",
"Mean vs. Channel",288,0.,288.,1000,1000.,2000.);
181 PDchanMax = tFileService->make<TH2F>(
"Max vs. Channel",
"Max vs. Channel",288.,0.,288.,2500,1500.,4000.);
182 PDchanMaxPed = tFileService->make<TH2F>(
"Max - Pedestal vs. Channel",
"Max - Pedestal vs. Channel",288.,0.,288.,2500,0,2500.);
183 PDchanPED = tFileService->make<TH2F>(
"PedVals vs. Channel",
"PedVals vs. Channel",288,0.,288.,1000,1000.,2000.);
184 PDchanRMS = tFileService->make<TH2F>(
"RMS vs. Channel",
"RMS vs. Channel",288,0.,288.,100,0.,10.);
185 PDchanRMSwide = tFileService->make<TH2F>(
"Coarse RMS vs. Channel",
"Coarse RMS vs. Channel",288,0.,288.,100,0.,100.);
186 PDchanFFT = tFileService->make<TH2F>(
"FFTFreq vs. Channel",
"FFTFreq vs. Channel",288,0.,288.,1000,0.,75.);
187 PDCalibInt = tFileService->make<TH2F>(
"Integral_cal_int",
"Integral Calibration by Channel",288,0,288.,100000,0.0,1000000.0);
188 PDtrigs = tFileService->make<TH1I>(
"Triggers vs. Channel",
"Triggers vs. Channel",288.,0.,288.);
189 PDPEDhist = tFileService->make<TH1F>(
"Pedestal vs. Channel",
"Pedestal vs. Channel",288.,0.,288.);
190 PDchanThres = tFileService->make<TH1F>(
"Threshold vs. Channel",
"Threshold vs. Channel",288,0.,288.);
194 for(
int i=0;i<288;i++){
196 Form(
"Raw Persistence Traces Channel %d",i),2000.,0.,2000.,1000.,1350.,4000.);
198 Form(
"Pedestal Substracted Persistence Traces Channel %d",i),2000.,0.,2000.,1000.,0.,2000.);
199 PDchanPEDRough[i] = tFileService->make<TH2F>(Form(
"ped_calc_trace_chan_%d",i),
200 Form(
"Wave Form Fraction for Pedestal %d",i),40.,0.,40.,1000.,1500.,2500.);
201 PDchanWaveInt[i] = tFileService->make<TH1F>(Form(
"wave_integrals_pedsub_chan_%d",i),
202 Form(
"Pedestal Subtracted Wave Integrals Channel %d",i),100000,0.0,1000000.0);
203 PDchanCurPeak[i] = tFileService->make<TH2F>(Form(
"current_peak_%d",i),
204 Form(
"current_peak_%d",i),1500,0.0,1500.0,1000,0.0,10000.0);
209 std::cout <<
"Finalizing Histograms." <<
std::endl;
210 for(
int i=0;i<288;i++) {
223 <<
"-------------------- Photodetector waveforms -------------------";
228 auto RawSSP =
event.getHandle< std::vector<raw::OpDetWaveform> >(itag1);
231 try { RawSSP->size(); }
236 std::vector< art::Ptr<raw::OpDetWaveform> > RawPulses;
240 double tschan1=0.0, tschan2=0.0, ampchan1=0.0,ampchan2=0.0;
243 for(
auto const & RawPulse : RawPulses) {
251 long int ADCval,sum=0,sum2=0,
N=0,ADCMax=0;
252 double sumthres=0,sumpedsub=0;
253 int nBins = PDdigit.size();
255 TH1F WfmHist(
"Waveform",
"Waveform",nBins,0,nBins),
256 WfmFFT(
"WfmFFT",
"WfmFFT",nBins,0,nBins);
257 TH1F *
htemp =
new TH1F(
"htemp",
"htemp",nBins,0,nBins);
296 for (
size_t i = 0; i < PDdigit.size(); i++) htemp->SetBinContent(i+1,PDdigit.at(i));
299 for (
size_t i = 0; i < PDdigit.size(); i++) {
302 ADCval = PDdigit.at(i);
303 if(
fSSP_peak) htemp->SetBinContent(i+1,ADCval);
309 WfmHist.SetBinContent(i+1,ADCval);
314 if(i < static_cast<unsigned int>(
fSSP_i1)) {
325 TSpectrum *peakloc =
new TSpectrum(
fSSP_nump);
327 double *peaks = peakloc->GetPositionX();
330 for(
int j=0;j<nfound;j++){
331 bool goodpeak =
true;
332 for(
int k=0;
k<nfound;
k++){
333 int peakpos1 = htemp->GetXaxis()->FindBin(peaks[j]);
334 int peakpos2 = htemp->GetXaxis()->FindBin(peaks[
k]);
335 if((TMath::Abs(peakpos1-peakpos2)<
fSSP_win) && (k!=j)){
336 if((htemp->GetBinContent(htemp->GetXaxis()->FindBin(peaks[j])) < htemp->GetBinContent(htemp->GetXaxis()->FindBin(peaks[k]))) && (
fSSP_peak==1)) goodpeak=
false;
345 int intbin = htemp->GetXaxis()->FindBin(peaks[j]);
346 std::vector <int>
base;
348 double basemean = TMath::Mean(base.begin(),base.end());
349 double basestddev = TMath::StdDev(base.begin(),base.end());
351 if(((basemean+(
fSSP_rarenum*basestddev)) < (htemp->GetBinContent(intbin))) && (basestddev < 4.0))
for(
int m=intbin-static_cast<int>(
fSSP_disc_width);
m<intbin+
fSSP_win;
m++) sumpedsub += (htemp->GetBinContent(
m))-basemean;
355 PDchanCurPeak[CurChannel]->Fill(htemp->GetBinContent(intbin)-basemean,sumpedsub);
363 float rms = sqrt((
float)sum2/(
float)
N - mean*mean );
368 float thres = sumthres/
static_cast<float>(
fSSP_i1);
375 if (event.
event()%1==0){
376 WfmHist.FFT(&WfmFFT,
"MAG");
377 WfmFFT.Scale(1.0/(
float)
N);
378 for (
int freqBin = 2 ; freqBin < nBins/2 ; freqBin++){
381 PDchanFFT->Fill(CurChannel,((
float)freqBin+0.5)*75.0/1000.0,WfmFFT.GetBinContent(freqBin));
385 if(ADCMax-thres > 100.0){
388 ampchan1=(ADCMax-thres);
392 ampchan2=(ADCMax-thres);
394 if(tschan1 != 0.0 && tschan2 != 0.0 && (
abs(tschan1-tschan2) < 100.0
E-9)){
412 #endif // PDonlinemonitor_module Store parameters for running LArG4.
EventNumber_t event() const
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
EDAnalyzer(fhicl::ParameterSet const &pset)
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
static int max(int a, int b)
#define MF_LOG_INFO(category)
Definition of data types for geometry description.
Declaration of signal hit object.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.