66 #include "StFcsWaveformFitMaker.h"
70 #include "StMessMgr.h"
71 #include "StEvent/StEventTypes.h"
72 #include "StEvent/StFcsHit.h"
73 #include "StFcsDbMaker/StFcsDb.h"
74 #include "StFcsDbMaker/StFcsDbPulse.h"
83 #include "TGraphAsymmErrors.h"
84 #include "TGraphAsymmErrorsWithReset.h"
91 StFcsWaveformFitMaker::StFcsWaveformFitMaker(
const char* name) :
StMaker(name) {
92 mChWaveData.SetClass(
"TGraphAsymmErrors");
102 mEnergySumScale[0] = 1.226;
103 mEnergySumScale[1] = 1.195;
104 mEnergySumScale[2] = 1.29;
108 for( UShort_t i=0; i<7; ++i ){
115 mH2F_AdcTbAkio[i] = 0;
116 mH2F_AdcTbMine[i] = 0;
117 mH2F_SumFitvSumWin[i] = 0;
118 mH2F_APeakvMPeak[i] = 0;
119 mH1F_PeakStart[i] = 0;
123 mH2F_AdcTbValidPeak[i] = 0;
125 mH1F_NPeaksFiltered[i] = 0;
127 mH1F_Res0Zoom[i] = 0;
128 mH1F_Sum8Res0[i] = 0;
129 mH1F_Sum8Res0Zoom[i] = 0;
131 mH1F_FitRes0Zoom[i] = 0;
132 mH2F_Sum8vFit[i] = 0;
136 StFcsWaveformFitMaker::~StFcsWaveformFitMaker() {
139 for( UShort_t i=0; i<7; ++i ){
141 delete mH2_Dep0DepMod[i];
142 delete mH2_Sum8Dep0[i];
143 delete mH2_Sum8DepMod[i];
196 if( filename.size()==0 ){
return;}
198 mOutFile =
new TFile(filename.c_str(),
"RECREATE");
206 if( mEnergySelect[0]==0 ){mEnergySelect[0]=1; mEnergySelect[1]=1; mEnergySelect[2]=1; }
209 if( mEnergySelect[0]!=10 || mEnergySelect[0]!=11 ){ mEnergySelect[0]=10;}
210 if( mEnergySelect[1]!=10 || mEnergySelect[1]!=11 ){ mEnergySelect[1]=10;}
211 if( mEnergySelect[2]!=10 || mEnergySelect[2]!=11 ){ mEnergySelect[2]=10;}
214 if( mEnergySelect[0]!=12 ){ mEnergySelect[0]=12; }
215 if( mEnergySelect[1]!=12 ){ mEnergySelect[1]=12; }
216 if( mEnergySelect[2]!=12 ){ mEnergySelect[2]=12; }
219 if( mEnergySelect[0]!=12 ){ mEnergySelect[0]=12; }
220 if( mEnergySelect[1]!=12 ){ mEnergySelect[1]=12; }
221 if( mEnergySelect[2]!=12 ){ mEnergySelect[2]=12; }
224 if( mEnergySelect[0]==0 ){ mEnergySelect[0]=1; mEnergySelect[1]=1; mEnergySelect[2]=1; mFitDrawOn=0; }
227 if( mEnergySelect[0]!=13 ){ mEnergySelect[0]=13; }
228 if( mEnergySelect[1]!=13 ){ mEnergySelect[1]=13; }
229 if( mEnergySelect[2]!=13 ){ mEnergySelect[2]=13; }
232 if( mEnergySelect[0]!=13 ){ mEnergySelect[0]=13; }
233 if( mEnergySelect[1]!=13 ){ mEnergySelect[1]=13; }
234 if( mEnergySelect[2]!=1 ){ mEnergySelect[2]=1; }
237 if( mEnergySelect[0]!=13 ){ mEnergySelect[0]=13; }
238 if( mEnergySelect[1]!=13 ){ mEnergySelect[1]=13; }
239 if( mEnergySelect[2]!=1 ){ mEnergySelect[2]=1; }
246 if(mFitDrawOn>=1) mHitIdx=0;
250 int StFcsWaveformFitMaker::Init()
253 mCanvas=
new TCanvas(
"FCSWaveFormFit",
"FCSWaveFormFit",10,10,2000,2000);
254 gStyle->SetOptStat(0);
257 sprintf(file,
"%s.pdf[",mFilename);
258 mCanvas->Print(file);
262 mTime=
new TH1F(
"FitTime",
"FitTime;msec",1000,0,1000);
264 if(mFilter && mFilter[0]==
'0'){
265 mTimeIntg[0]=
new TH2F(
"Noboth",
"No both; PeakTB; Integral",100,47.0,54.0,400,0.0,2000);
266 mTimeIntg[1]=
new TH2F(
"NoFall",
"No Fall; PeakTB; Integral",100,47.0,54.0,400,0.0,2000);
267 mTimeIntg[2]=
new TH2F(
"NoRise",
"No Rise; PeakTB; Integral",100,47.0,54.0,400,0.0,2000);
268 mTimeIntg[3]=
new TH2F(
"Accepted",
"Accepted; PeakTB; Integral",100,47.0,54.0,400,0.0,2000);
271 for( UShort_t i=0; i<7; ++i ){
272 std::stringstream ss;
276 mH2_Dep0DepMod[i]=
new TH2F( (
"H2_Dep0DepMod_"+ss.str()).c_str(), (
"Sum Dep0 vs DepMod "+ss.str()).c_str(),100,0,1000,100,0,1000);
277 mH2_Sum8Dep0[i]=
new TH2F( (
"H2_Sum8Dep0_"+ss.str()).c_str(), (
"Sum 8 vs Dep0 "+ss.str()).c_str(),100,0,1000,100,0,1000);
278 mH2_Sum8DepMod[i]=
new TH2F( (
"H2_Sum8DepMod_"+ss.str()).c_str(), (
"Sum 8 vs DepMod "+ss.str()).c_str(),100,0,1000,100,0,1000);
283 mH2F_AdcTbAkio[i] =
new TH2F( (
"H2_AdcTbAkio_"+ss.str()).c_str(),
"Akio Peaks Adc vs. Tb",102,-1.5,100.5,4097,-0.5,4096.5);
284 mH2F_AdcTbMine[i] =
new TH2F( (
"H2_AdcTbMine_"+ss.str()).c_str(),
"My Peaks Adc vs. Tb",102,-1.5,100.5,4097,-0.5,4096.5);
285 mH2F_SumFitvSumWin[i] =
new TH2F( (
"H2_SumFitvSumWin_"+ss.str()).c_str(),
"Fitted Sum vs. Peak Window Sum",100,0,2000,100,0,2000);
286 mH2F_APeakvMPeak[i] =
new TH2F( (
"H2_APeakvMPeak_"+ss.str()).c_str(),
"Peak Locations Akio v. Mine",80,-0.5,79.5,80,-0.5,79.5);
287 mH1F_PeakStart[i] =
new TH1F( (
"H1_PeakStart_"+ss.str()).c_str(),
"PeakWindow start times",102,-1.5,100.5);
288 mH1F_PeakEnd[i] =
new TH1F( (
"H1_PeakEnd_"+ss.str()).c_str(),
"PeakWindow end time",102,-1.5,100.5);
291 mH2F_NOvsId[i] =
new TH2F( (
"H2_NOvsId_"+ss.str()).c_str(),
"Number of overlaps vs. Ch Id", 748,-0.5,747.5, 11,-0.5,10.5);
297 mH1F_NPeaks[i] =
new TH1F( (
"H1_NPeaks_"+ss.str()).c_str(),
"Number of peaks from finder", 11,-0.5,10.5);
298 mH1F_NPeaksFiltered[i] =
new TH1F( (
"H1_NPeaksFiltered_"+ss.str()).c_str(),
"Number of peaks from finder when a valid peak was found", 11,-0.5,10.5);
300 mH2F_AdcTbValidPeak[i] =
new TH2F( (
"H2_AdcTbValidPeak_"+ss.str()).c_str(),
"Valid Peaks Adc vs. Tb",102,-1.5,100.5,4097,-0.5,4096.5);
303 mH1F_NPeaks[i] =
new TH1F( (
"H1_NPeaks_"+ss.str()).c_str(),
"Number of peaks from finder", 11,-0.5,10.5);
304 mH1F_NPeaksFiltered[i] =
new TH1F( (
"H1_NPeaksFiltered_"+ss.str()).c_str(),
"Number of peaks from finder when a valid peak was found", 11,-0.5,10.5);
305 mH1F_Res0[i] =
new TH1F( (
"H1_Res0_"+ss.str()).c_str(),
"All ADC sums", 100,0,2000 );
306 mH1F_Res0Zoom[i] =
new TH1F( (
"H1_Res0Zoom_"+ss.str()).c_str(),
"All ADC sums", 201,-0.5,200.5 );
309 mH1F_Sum8Res0[i] =
new TH1F( (
"H1_Sum8Res0_"+ss.str()).c_str(),
"All ADC sums using sum 8", 100,0,2000 );
310 mH1F_Sum8Res0Zoom[i] =
new TH1F( (
"H1_Sum8Res0Zoom_"+ss.str()).c_str(),
"All ADC sums using sum 8", 201,-0.5,200.5 );
313 mH1F_FitRes0[i] =
new TH1F( (
"H1_FitRes0_"+ss.str()).c_str(),
"All ADC sums using fitting", 100,0,2000 );
314 mH1F_FitRes0Zoom[i] =
new TH1F( (
"H1_FitRes0Zoom_"+ss.str()).c_str(),
"All ADC sums using fitting", 201,-0.5,200.5 );
315 mH2F_Sum8vFit[i] =
new TH2F((
"H2_Sum8vFit_"+ss.str()).c_str(),
"sum 8 vs fit sum", 100,0,2000, 100,0,2000);
320 mH1_PeakTiming =
new TH1F(
"H1_PeakTiming",
"Timing to just find peak",200,0,5);
323 mH1_NPeaksAkio =
new TH1F(
"H1_NPeaksAkio",
"Number of peaks from current method", 11,-0.5,10.5);
324 mH1_NPeaksFilteredAkio =
new TH1F(
"H1_NPeaksFilteredAkio",
"Number of peaks from current method when a valid peak is found", 11,-0.5,10.5);
327 mH2_NPeakvsPeakXdiff =
new TH2F(
"H2_NPeakvsPeakXdiff",
"NPeak vs. Peak X difference", 41,-20.5,20.5, 11,-0.5,10.5);
328 mH2_NPeakvsPeakYratio =
new TH2F(
"H2_NPeakvsPeakYratio",
"NPeak vs. Peak Y ratio", 100,0,10, 11,-0.5,10.5);
329 mH1_VOverlap =
new TH1F(
"H1_VOverlap",
"Peak Compare values",4,-0.5,3.5 );
330 mH2_NOvsNPeaks =
new TH2F(
"H2_NOvsNPeaks",
"Number of Overlapping peaks vs. Number of Peaks", 11,-0.5,10.5, 11,-0.5,10.5);
331 mH2_VvsNOverlap =
new TH2F(
"H2_VvsNOverlap",
"Value of Comparison vs. Peak index", 21,-10.5,10.5, 4,-0.5,3.5);
337 mH2_HeightvsSigma =
new TH2F(
"H2_HeightvsSigma",
"Fitted Peak Height vs. Sigma;Sigma;Height", 31,-0.5,30.5, 4000,-0.5,3999.5);
338 mH2_HeightvsSigmaTrig =
new TH2F(
"H2_HeightvsSigmaTrig",
"Fitted Peak Height vs. Sigma Triggered Xing;Sigma;Height", 31,-0.5,30.5, 4000,-0.5,3999.5);
339 mH1_ChiNdf =
new TH1F(
"H1_ChiNdf",
"Chi^2/NDF for all fits;Chi^2/NDF", 50,-0.5,99.5);
340 mH2_HeightvsChiNdf =
new TH2F(
"H2_HeightvsChiNdf",
"Peak Height TXing vs. Chi^2/NDF;Chi^2/NDF;Height", 50,-0.5,99.5, 500,-0.5,499.5);
341 mH2_MeanvsChiNdf =
new TH2F(
"H2_MeanvsChiNdf",
"Peak Mean TXing vs. Chi^2/NDF;Chi^2/NDF;Mean", 50,-0.5,99.5, 21,39.5,60.5 );
342 mH2_SigmavsChiNdf =
new TH2F(
"H2_SigmavsChiNdf",
"Peak Sigma TXing vs. Chi^2/NDF;Chi^2/NDF;Sigma", 50,-0.5,99.5, 21,-0.5,20.5 );
345 mH1_PeakTimingGaus =
new TH1F(
"H1_PeakTimingGaus",
"gausFit timing;msec", 1000,0,1000 );
346 mH1_PeakTimingPuls =
new TH1F(
"H1_PeakTimingPuls",
"PulseFit timing;msec", 1000,0,1000 );
347 mH2_PeakTimingCompare =
new TH2F(
"H2_PeakTimingCompare",
"PulseFit vs. gausFit;ms;ms", 200,0,6, 200,0,6 );
350 return StMaker::Init();
353 int StFcsWaveformFitMaker::InitRun(
int runNumber) {
354 LOG_DEBUG <<
"StFcsWaveformFitMaker initializing run" << endm;
355 mDb =
static_cast<StFcsDb*
>(GetDataSet(
"fcsDb"));
357 LOG_ERROR <<
"StFcsWaveformFitMaker initializing failed due to no StFcsDb" << endm;
360 mDbPulse =
static_cast<StFcsDbPulse*
>(GetDataSet(
"fcsPulse"));
362 LOG_ERROR <<
"StFcsWaveformFitMaker initializing failed due to no StFcsDbPulse" << endm;
369 return StMaker::InitRun(runNumber);
375 sprintf(file,
"%s.pdf]",mFilename);
376 mCanvas->Print(file);
379 printf(
"WFFit Time Mean=%f RMS=%f\n",mTime->GetMean(),mTime->GetRMS());
380 TCanvas *c=
new TCanvas(
"FCSWFFTime",
"FCSWFFTime",10,10,800,800);
381 gStyle->SetOptStat(111110);
382 gStyle->SetLabelSize(0.02,
"xy");
385 c->SaveAs(mMeasureTime);
388 if(mFilter && mFilter[0]==
'0'){
389 TCanvas *c=
new TCanvas(
"Stage0",
"Stage0",10,10,800,800);
390 gStyle->SetOptStat(111110);
391 gStyle->SetLabelSize(0.02,
"xy");
393 c->cd(1)->SetLogy(); mTimeIntg[0]->Draw(
"colz");
394 c->cd(2)->SetLogy(); mTimeIntg[1]->Draw(
"colz");
395 c->cd(3)->SetLogy(); mTimeIntg[2]->Draw(
"colz");
396 c->cd(4)->SetLogy(); mTimeIntg[3]->Draw(
"colz");
397 c->SaveAs(
"stage0.png");
403 for( UShort_t i=0; i<7; ++i ){
405 if( mH2_Dep0DepMod[i]!=0 ){mH2_Dep0DepMod[i]->Write();}
406 if( mH2_Sum8Dep0[i]!=0 ) {mH2_Sum8Dep0[i]->Write();}
407 if( mH2_Sum8DepMod[i]!=0 ){mH2_Sum8DepMod[i]->Write();}
413 if( mH2F_APeakvMPeak[i]!=0 ) { mH2F_APeakvMPeak[i]->Write();}
423 if( mH1F_Res0Zoom[i]!=0 ) { mH1F_Res0Zoom[i]->Write();}
425 if( mH1F_Sum8Res0Zoom[i]!=0 ) { mH1F_Sum8Res0Zoom[i]->Write();}
427 if( mH1F_FitRes0Zoom[i]!=0 ) { mH1F_FitRes0Zoom[i]->Write();}
428 if( mH2F_Sum8vFit[i]!=0 ) { mH2F_Sum8vFit[i]->Write();}
431 if( mTime!=0 ){ mTime->Write(); }
464 LOG_DEBUG <<
"StFcsWaveformFitMaker Make!!!" << endm;
469 if (event) mFcsCollection =
event->fcsCollection();
470 if(!mFcsCollection) {
471 LOG_WARN <<
"StFcsWaveformFitMaker did not find fcsCollection in StEvent" << endm;
475 if(mEnergySelect[0]==0)
return kStOK;
480 for(
int det=0; det<kFcsNDet; det++) {
481 StSPtrVecFcsHit& hits = mFcsCollection->hits(det);
483 int nhit=hits.size();
484 for(
int i=0; i<nhit; i++){
485 memset(res,0,
sizeof(res));
486 auto start=std::chrono::high_resolution_clock::now();
490 AnaPed( hits[i], res[6], res[7] );
491 mDb->
setPedestal(hits[i]->ehp(), hits[i]->ns(), hits[i]->dep(), hits[i]->channel(), res[6] );
494 mDb->
getName(hits[i]->ehp(), hits[i]->ns(), hits[i]->dep(), hits[i]->channel(),name);
495 LOG_DEBUG << name <<
" Pedestal ("<<mPedMax<<
"-"<<mPedMin<<
"+1)="<< res[6] <<std::endl;
500 float integral = hits[i]->adcSum();
502 integral =
analyzeWaveform(mEnergySelect[ehp],hits[i],res,func,res[6]);
503 hits[i]->setAdcSum(integral);
504 hits[i]->setFitPeak(res[2]);
505 hits[i]->setFitSigma(res[3]);
506 hits[i]->setFitChi2(res[4]);
507 hits[i]->setNPeak(res[5]);
510 float gain = mDb->
getGain(hits[i]);
512 hits[i]->setEnergy(integral*gain*gaincorr);
513 if(GetDebug()>0){ printf(
"det=%1d id=%3d integ=%10.2f peak=%8.2f, sig=%8.4f chi2=%8.2f npeak=%2d ped=%8.2f pedrms=%4.2f\n",
514 det,hits[i]->
id(),integral,res[2],res[3],res[4],
int(res[5]),res[6],res[7]); }
516 auto stop=std::chrono::high_resolution_clock::now();
517 long long usec = chrono::duration_cast<chrono::microseconds>(stop-start).count();
519 mTime->Fill(
float(usec)/1000.0);
522 auto startg = std::chrono::high_resolution_clock::now();
524 auto stopg = std::chrono::high_resolution_clock::now();
525 long long usecg = chrono::duration_cast<chrono::microseconds>(stopg-startg).count();
526 auto startp = std::chrono::high_resolution_clock::now();
528 auto stopp = std::chrono::high_resolution_clock::now();
529 long long usecp = chrono::duration_cast<chrono::microseconds>(stopp-startp).count();
533 if( usecp>200000.0 ){ std::cout <<
getGraph()->GetName() << std::endl; }
543 if(mFitDrawOn) mHitIdx++;
544 return (TGraphAsymmErrors*)gae;
549 if(mHitIdx>0) {idx=mHitIdx-1;}
552 TGraphAsymmErrors* gae = (TGraphAsymmErrors*)
mChWaveData.ConstructedAt(idx);
559 for( Int_t i=0; i<
mChWaveData.GetEntriesFast(); ++i ){
562 TGraphAsymmErrors* gae = (TGraphAsymmErrors*)
mChWaveData.At(i);
565 if( det0>=0 && det0==det ){
566 if( id0>=0 && id0==
id ){
571 LOG_ERROR <<
"Unable to find det:"<<det <<
" id:"<<
id <<
" in graph array" << std::endl;
577 for(
int i=0; i<n; ++i){
578 gae->SetPoint(i,tb[i],adc[i]);
586 double *t = g->GetX();
587 double *a = g->GetY();
592 int NValues = hist->GetNbinsX();
594 for(
int i=1; i<=NValues; ++i ){
595 double adc = hist->GetBinContent(i);
596 gae->SetPoint(i-1,hist->GetBinCenter(i),adc);
604 int n = hit->nTimeBin();
606 mDb->
getName(hit->detectorId(),hit->id(),mDetName);
607 gae->SetName(mDetName);
609 for(
int i=0; i<n; i++){
610 int tb=hit->timebin(i);
613 gae->SetPoint(j,tb,adc);
617 if(tb>=mMaxTB)
break;
624 float StFcsWaveformFitMaker::AnaPed( TGraphAsymmErrors* g,
float& ped,
float& pedstd )
627 double *t = g->GetX();
628 double *a = g->GetY();
631 for(
int i=0; i<n; i++){
633 if(mPedMin<=tb1 && tb1<=mPedMax){
638 ped = float(p)/(mPedMax-mPedMin+1.0);
639 pedstd = sqrt( ( sumsq-((
double(p)*
double(p))/(mPedMax-mPedMin+1.0)) )/(mPedMax-mPedMin) );
643 float StFcsWaveformFitMaker::AnaPed(
StFcsHit*
hit,
float& ped,
float& pedstd )
646 int n = hit->nTimeBin();
648 for(
int i=0; i<n; i++){
649 int tb=hit->timebin(i);
650 if(mPedMin<=tb && tb<=mPedMax ){
651 int adc = hit->adc(i);
655 if(tb>=mPedMax)
break;
657 ped = p/(mPedMax-mPedMin+1.0);
658 pedstd = sqrt( ( sumsq-((p*p)/(mPedMax-mPedMin+1.0)) )/(mPedMax-mPedMin) );
663 if(func)
delete func;
667 case 1: integral =
sum8(g, res);
break;
668 case 2: integral =
sum16(g, res);
break;
669 case 3: integral =
highest(g, res);
break;
670 case 4: integral =
highest3(g, res);
break;
671 case 10: integral =
gausFit(g, res, func, ped);
break;
673 case 12: integral =
PulseFit1(g,res,func,ped);
break;
674 case 13: integral =
PulseFit2(g,res,func,ped);
break;
675 case 14: integral =
PulseFitAll(g,res,func,ped);
break;
680 LOG_WARN <<
"Unknown fit/sum method select=" << select << endm;
684 if(mFilter && mFilter[0]==
'0'){
686 if(integral>0 && res[2]>47.0 && res[2]<54.0){
690 for(
int i=0; i<g->GetN()-1; i++){
697 if(GetDebug()) printf(
"AAA t0=%4d t1=%4d a0=%4d a1=%4d dt=%4d da=%5d ",t0,t1,a0,a1,dt,da);
698 if(t0==mCenterTB-3 && dt==1){
701 if(GetDebug()) printf(
"R");
703 else {
if(GetDebug()) printf(
"X");}
705 if(t0==mCenterTB+3 && dt==1){
708 if(GetDebug()) printf(
"F");
710 else {
if(GetDebug()) printf(
"X");}
712 if(GetDebug()) printf(
"\n");
714 printf(
"BBB Intg=%8.2f peak=%6.2f Raise/Fall=%1d\n",integral,res[2],peak);
715 if(peak<3 && integral>50 && res[2]>49) flag=1;
716 mTimeIntg[peak]->Fill(res[2],integral);
720 TString dname(mDetName);
721 if(integral>50 && dname.Contains(mFilter)) flag=1;
723 if(mFitDrawOn && flag && mFilename && mPage<=mMaxPage) {
724 printf(
"hit:%u det=%s func=%p mFitDrawOn=%d mFilter=%s mFilename=%s mPage=%d mMaxPage=%d integral=%f\n",
725 mHitIdx,mDetName,(
void*)func,mFitDrawOn,mFilter,mFilename,mPage,mMaxPage,integral);
731 int det = 0;
int ch=0;
735 if( sumdep0>sumdepmod ){std::cout <<
" - StFcsWaveformFitMaker::analyzeWaveform|SumDep0:"<<sumdep0 <<
"|SumDepMod:"<<sumdepmod << endl;}
736 mH2_Dep0DepMod[det/2]->Fill(sumdepmod,sumdep0);
737 mH2_Sum8Dep0[det/2]->Fill(sumdep0,integral);
738 mH2_Sum8DepMod[det/2]->Fill(sumdepmod,integral);
741 int det0 = 0;
int ch0=0;
744 mH1F_Res0Zoom[det0]->Fill(res[0]);
746 mH1F_Res0Zoom[6]->Fill(res[0]);
768 int min = mCenterTB-3;
769 int max = mCenterTB+4;
771 double *t = g->GetX();
772 double *a = g->GetY();
775 for(
int i=0; i<n; i++){
777 if(tb>=min && tb<=max) {
783 if( fabs(res[7]) > 0.000001 ){ sum -= res[6]*8; }
785 if(sum>0) res[2]=tsum/sum;
790 int min = mCenterTB-3-4;
791 int max = mCenterTB+4+4;
793 double *t = g->GetX();
794 double *a = g->GetY();
797 for(
int i=0; i<n; i++){
799 if(tb>=min && tb<=max) {
804 if( fabs(res[7]) > 0.000001 ){ sum -= res[6]*16; }
806 if(sum>0) res[2]=tsum/sum;
811 int min = mCenterTB-3;
812 int max = mCenterTB+4;
814 double *t = g->GetX();
815 double *a = g->GetY();
818 for(
int i=0; i<n; i++){
820 if(tb>=min && tb<=max) {
829 if( fabs(res[7]) > 0.000001 ){ maxadc -= res[6]; }
841 int min = mCenterTB-3;
842 int max = mCenterTB+4;
844 double *t = g->GetX();
845 double *a = g->GetY();
846 float sum=0, tsum=0, maxadc=0;
848 for(
int i=0; i<n; i++){
850 if(tb>=min && tb<=max) {
858 for(
int i=0; i<n; i++){
860 if(tb>=min && tb<=max && tb>=maxtb-1 && tb<=maxtb+1) {
866 if( fabs(res[7]) > 0.000001 ){ sum -= res[6]*3; }
869 if(sum>0) res[2]= tsum/sum;
878 if(GetDebug()>2) sprintf(Opt,
" ");
879 if(GetDebug()>3) sprintf(Opt,
"V ");
881 int trgmin = mCenterTB-4.5;
882 int trgmax = mCenterTB+5.5;
884 double *t = g->GetX();
885 double *a = g->GetY();
891 double adc0,adc1,adc2;
893 if(mFilter && GetDebug()>0){
894 TString dname(mDetName);
895 if(! dname.Contains(mFilter))
return res[0];
896 printf(
"%s mMinTB=%d mMaxTB=%d : ",
897 mDetName,mMinTB+8,mMaxTB-20);
898 for(
int i=1; i<n-1; i++){
900 if(tb1>=mMinTB+8 && tb1<=mMaxTB-20){
901 printf(
"%4d ",
int(a[i]));
907 for(
int i=1; i<n-1; i++){
909 if(tb1>=mMinTB && tb1<=mMaxTB){
911 if(adc1-ped<mMinAdc)
continue;
913 if(tb1-tb0>1.1) {adc0 = 0;}
914 else {adc0 = a[i-1];}
916 if(tb2-tb1>1.1) {adc2 = 0;}
917 else {adc2 = a[i+1];}
920 if( (adc1>adc0 || tb1==mMinTB) && adc1>=adc2){
921 para[1+npeak*3+1] = adc1;
922 para[1+npeak*3+2] = tb1;
923 para[1+npeak*3+3] = mDbPulse->
GSigma();
924 double dt = fabs(tb1 - mCenterTB);
925 if(trgmin<tb1 && tb1<trgmax && dt < mindt) {
929 if(GetDebug()>1) printf(
"peak npeak=%2d tb=%4.0lf adc=%5.0lf\n",npeak,tb1,adc1);
947 auto start=std::chrono::high_resolution_clock::now();
949 auto stop=std::chrono::high_resolution_clock::now();
950 long long usec = chrono::duration_cast<chrono::microseconds>(stop-start).count();
957 npeakidx = npeak<=4?npeak:5;
958 mypeakidx = myNpeaks<=4?myNpeaks:5;
961 for(
int i=0; i<g->GetN(); ++i ){
973 if(npeak>0 && npeak<mMaxPeak){
976 func = mDbPulse->
createPulse(mMinTB,mMaxTB,2+npeak*3);
977 func->SetLineColor(6);
978 func->SetParameters(para);
979 func->FixParameter(0,npeak);
980 func->FixParameter(1,ped);
981 for(
int i=0; i<npeak; i++){
982 func->SetParLimits(1+i*3+1,0.0,40000.0);
984 func->SetParLimits(j,para[j]-2.0,para[j]+2.0);
985 func->SetParLimits(1+i*3+3,0.5,10.0);
988 TFitResultPtr result = g->Fit(func,Opt,
"",mMinTB,mMaxTB);
990 res[1] = func->GetParameter(trgx*3 + 2);
991 res[2] = func->GetParameter(trgx*3 + 3);
992 res[3] = func->GetParameter(trgx*3 + 4);
993 res[4] = func->GetChisquare()/func->GetNDF();
1000 res[4] = func->GetChisquare()/func->GetNDF();
1004 }
else if(npeak>=mMaxPeak){
1008 LOG_INFO << Form(
"%s Finding too many peaks npeak=%d. Skip fitting. Taking Sum8",mDetName,npeak)<<endm;
1015 if( npeakidx==mypeakidx){
1016 Double_t peakloc = 0;
1018 mH2F_APeakvMPeak[npeakidx]->Fill(peakloc,res[2]);
1027 const int MAXPAD=4*4;
1029 LOG_WARN<<
"Found no TGraphAsymmErrors at mHitIdx="<<mHitIdx<<endm;
1042 if(mPad==0) { mCanvas->Clear(); mCanvas->Divide(4,4);}
1045 gg->SetTitle(mDetName);
1048 func->SetLineColor(kRed);
1049 func->SetLineWidth(2);
1050 func->DrawCopy(
"LSAME");
1057 sprintf(post,
"_D%dC%d",det,ch);
1059 ana->SetLineColor(kBlue);
1060 ana->SetMarkerColor(kBlue);
1061 ana->SetMarkerStyle(4);
1062 ana->SetMarkerSize(0.5);
1067 sprintf(file,
"%s.pdf",mFilename);
1072 printf(
"Saving pdf with [%s] mPage=%d mPad=%d\n",file,mPage,mPad);
1073 mCanvas->Print(file);
1075 if(mPage==mMaxPage){ mPad=-9999; mFitDrawOn=0; mHitIdx=0; }
1078 if(mFitDrawOn==2) mHitIdx=0;
1085 for( UInt_t i=0; i<mHitIdx; ++i ){
1088 TGraphAsymmErrors* ggdraw = (TGraphAsymmErrors*)
mChWaveData.At(i);
1090 if( det>=0 && det==static_cast<int>(detid) ){
1091 if(
id>=0 &&
id==static_cast<int>(ch) ){
1092 ggdraw->Draw(
"APL");
1093 ggdraw->SetLineColor(kBlack);
1094 ggdraw->SetMarkerColor(kBlack);
1095 ggdraw->SetMarkerStyle(4);
1096 ggdraw->SetMarkerSize(0.5);
1097 ggdraw->GetXaxis()->SetTitle(
"timebin");
1098 ggdraw->GetYaxis()->SetTitle(
"ADC");
1104 sprintf(post,
"_D%dC%d",det,ch);
1106 ana->
GetData()->SetLineColor(kBlue);
1107 ana->
GetData()->SetMarkerColor(kBlue);
1108 ana->
GetData()->SetMarkerStyle(4);
1109 ana->
GetData()->SetMarkerSize(0.5);
1122 for( UInt_t i=0; i<mHitIdx; ++i ){
1125 TGraphAsymmErrors* ggdraw = (TGraphAsymmErrors*)
mChWaveData.At(i);
1127 if( det>=0 && det==static_cast<int>(detid) ){
1128 if(
id>=0 &&
id==static_cast<int>(ch) ){
1130 sprintf(post,
"_D%dC%d",detid,ch);
1131 ggdraw->SetTitle(post);
1132 ggdraw->Draw(
"APL");
1133 ggdraw->SetLineColor(kBlack);
1134 ggdraw->SetMarkerColor(kBlack);
1135 ggdraw->SetMarkerStyle(4);
1136 ggdraw->SetMarkerSize(0.5);
1137 ggdraw->GetXaxis()->SetTitle(
"timebin");
1138 ggdraw->GetYaxis()->SetTitle(
"ADC");
1141 ana->
GetData()->SetLineColor(kBlue);
1142 ana->
GetData()->SetMarkerColor(kBlue);
1143 ana->
GetData()->SetMarkerStyle(4);
1144 ana->
GetData()->SetMarkerSize(0.5);
1147 int npeaks = ana->
NPeaks();
1150 if( compidx<npeaks ){
1151 int trigfitidx = compidx;
1154 Double_t xmin = mCenterTB - mDbPulse->
TBPerRC()/2;
1155 Double_t xmax = mCenterTB + mDbPulse->
TBPerRC()/2;
1157 int prexing = 3*mDbPulse->
TBPerRC();
1158 int postxing = 2*mDbPulse->
TBPerRC();
1159 bool foundtrigidx =
false;
1160 std::vector<int> validpeakidx;
1161 for(
int i=0; i<ana->
NPeaks(); ++i ){
1163 if( !foundtrigidx && trigfitidx==i ){ foundtrigidx =
true; trigfitidx = validpeakidx.size(); }
1164 if( !validpeakidx.empty() && validpeakidx.back()!=(i-1) ){ LOG_ERROR <<
"StFcsWaveformFitMaker::dualFit: Found indices are not linear" << endm; }
1165 validpeakidx.push_back(i);
1167 if( xmax < ana->GetPeak(i).mEndX ){ xmax = ana->
GetPeak(i).
mEndX; }
1170 if( !foundtrigidx ){ LOG_ERROR <<
"StFcsWaveformFitMaker::dualFit: Unable to find a matching triggered crossing possibly due to improper use of function" << endm; }
1172 npeaks = validpeakidx.size();
1173 if( npeaks>0 && npeaks<mMaxPeak ){
1174 TF1* func_PulseFit = mDbPulse->
createPulse(xmin,xmax,2+npeaks*3);
1175 ana->
SetFitPars(func_PulseFit,validpeakidx.front(),validpeakidx.back());
1176 if( func_PulseFit->GetParameter(0)==0 ){ LOG_ERROR <<
"StFcsWaveformFitMaker::drawDualFit: Unable to set function parameters, bad peak indicies" << endl; }
1178 TFitResultPtr result = ggdraw->Fit(func_PulseFit,
"BNRQ");
1180 func_PulseFit->SetLineColor(kBlack);
1181 func_PulseFit->SetLineWidth(1);
1182 func_PulseFit->SetBit(kCanDelete);
1183 func_PulseFit->Draw(
"same");
1188 float gausres[8] = {0};
1189 gausFit( ggdraw , gausres, func_gaus );
1191 func_gaus->SetLineColor(kGreen);
1192 func_gaus->SetLineWidth(1);
1193 func_gaus->SetBit(kCanDelete);
1194 func_gaus->SetParameter(1,0.5);
1195 func_gaus->Draw(
"same");
1203 if( fabs(res[7]) < 0.000001 ){AnaPed( g, res[6], res[7] ); }
1204 LOG_DEBUG <<
"Pedestal ("<<mPedMax<<
"-"<<mPedMin<<
"+1)=" << res[6]<<
" +- "<<res[7] << endm;
1205 return gausFit(g, res, func, res[6]);
1209 const int MAXPAD = 16;
1210 int NumDrawnPad[MAXPAD]={0};
1212 Double_t MinY[MAXPAD] = {0};
1213 Double_t MaxY[MAXPAD] = {0};
1218 if( det<2 ){MaxDrawPad=6;}
1219 else if( det>1 && det<4 ){MaxDrawPad=4;}
1220 else{ LOG_ERROR<<
"StFcsWaveformFitMaker::drawRegion(): This function only works for det<4"<<endm;
return; }
1222 if( mCanvas==0 ){ mCanvas =
new TCanvas(
"mCanvas",
"FCSWaveFormFit",10,10,2000,2000); }
1228 mCanvas->Divide(4,4);
1231 for(
unsigned int iCh=0; iCh<mHitIdx; ++iCh ){
1232 TGraphAsymmErrors* gTemp = (TGraphAsymmErrors*)
mChWaveData.ConstructedAt(iCh);
1233 if( gTemp->GetN()==0 ){
continue;}
1237 if( det!=Chdet ){
continue;}
1240 if( !(col_low<=col && col<=col_high) || !(row_low<=row && row<=row_high) ){
continue;}
1243 TPad* padTemp = (TPad*)mCanvas->cd( mPad-- );
1245 int color = 100-((
static_cast<double>(NumDrawnPad[mPad])/static_cast<double>(MaxDrawPad))*(100-51));
1246 gTemp->SetLineColor(color);
1247 gTemp->SetMarkerColor(color);
1248 gTemp->SetMarkerStyle(NumDrawnPad[mPad]+24);
1249 gTemp->SetMarkerSize(0.5);
1251 if( NumDrawnPad[mPad]==0 ){
1254 MinY[mPad]=padTemp->GetUymin();
1255 MaxY[mPad]=padTemp->GetUymax();
1259 Double_t YminNew=5000; Double_t YmaxNew=-5;
1261 if( YminNew<MinY[mPad] ){MinY[mPad]=YminNew;}
1262 if( YmaxNew>MaxY[mPad] ){MaxY[mPad]=YmaxNew;}
1263 ((TGraphAsymmErrors*)padTemp->GetListOfPrimitives()->At(1))->GetYaxis()->SetRangeUser(MinY[mPad],MaxY[mPad]);
1266 if( (++NumDrawnPad[mPad]) > MaxDrawPad ){LOG_WARN <<
"StFcsWaveformFitMaker::drawRegion(): Drawing too many on one pad"<<endm;}
1268 std::stringstream SS_name;
1269 SS_name <<
"Det"<<det <<
"_Cl"<<col_low <<
"Rl"<<row_low <<
"_Ch"<<col_high <<
"Rh"<<row_high <<
"_Event"<<
event <<
".png";
1270 mCanvas->SaveAs( SS_name.str().c_str() );
1288 if( det>1 && det<4 )
1303 for(
unsigned int iCh=0; iCh<mHitIdx; ++iCh ){
1304 TGraphAsymmErrors* gTemp = (TGraphAsymmErrors*)
mChWaveData.At(iCh);
1305 std::cout <<
"|Index:"<<iCh<<
"|Name:"<<gTemp->GetName()<<
"|Size:"<<gTemp->GetN() << std::endl;
1310 std::cout <<
"StFcsWaveformFitMaker Internal State" << std::endl
1311 <<
" - mMeasureTime:" << mMeasureTime << std::endl
1312 <<
" - mEnergySelect[ecal,hcal,pres]:" <<
"["<<mEnergySelect[0] <<
"," << mEnergySelect[1] <<
"," << mEnergySelect[2] <<
"]" << std::endl
1313 <<
" - mEnergySumScale[ecal,hcal,pres]:" <<
"["<<mEnergySumScale[0] <<
"," << mEnergySumScale[1] <<
"," << mEnergySumScale[2] <<
"]" << std::endl
1314 <<
" - mCenterTB:" << mCenterTB << std::endl
1315 <<
" - mMinTB:" << mMinTB << std::endl
1316 <<
" - mMaxTB:" << mMaxTB << std::endl
1317 <<
" - mError:" << mError << std::endl
1318 <<
" - mErrorSaturated:" << mErrorSaturated << std::endl
1319 <<
" - mAdcSaturation:" << mAdcSaturation << std::endl
1320 <<
" - mPedMin:" << mPedMin << std::endl
1321 <<
" - mPedMax:" << mPedMax << std::endl
1322 <<
" - mMinAdc:" << mMinAdc << std::endl
1323 <<
" - mTail:" << mTail << std::endl
1324 <<
" - mMaxPeak:" << mMaxPeak << std::endl
1325 <<
" - mMaxPage:" << mMaxPage << std::endl
1326 <<
" - mSkip:" << mSkip << std::endl
1327 <<
" - mFilename:" << mFilename << std::endl
1329 <<
" - mFitDrawOn:" << mFitDrawOn << std::endl
1344 int det0 = 0;
int ch0=0;
1348 if( compidx==npeaks ){ res[0] = 0;
return res[0]; }
1349 func = mDbPulse->
createPulse(mMinTB,mMaxTB,2+npeaks*3);
1351 TFitResultPtr result = gae->Fit(func,
"BNRQ");
1352 for(
int i=0; i<npeaks; ++i ){
1353 mH2_HeightvsSigma->Fill( func->GetParameter(1+i*3+3),func->GetParameter(1+i*3+1) );
1356 res[1] = func->GetParameter(compidx*3 + 2);
1357 res[2] = func->GetParameter(compidx*3 + 3);
1358 res[3] = func->GetParameter(compidx*3 + 4);
1359 res[4] = func->GetChisquare()/func->GetNDF();
1375 if( compidx==npeaks ){ res[0] = 0; }
1376 else if( npeaks<=1 ){
1381 res[0] =
sum8(gae,res);
1383 if( det0==0 || det0==1 ){res[0]/=mEnergySumScale[0];}
1384 if( det0==2 || det0==3 ){res[0]/=mEnergySumScale[1];}
1385 if( det0==4 || det0==5 ){res[0]/=mEnergySumScale[2];}
1388 res[3] = mDbPulse->
GSigma();
1398 for( Int_t i=0; i<npeaks; ++i ){
1399 if( i==compidx ){
continue; }
1406 int numoverlaps = 0;
1407 for( Int_t i=0; i<npeaks; ++i ){
1408 if( i==compidx ){
continue; }
1413 if( comp!=0 ){ ++numoverlaps; }
1417 if( numoverlaps>0 ){
1419 auto start=std::chrono::high_resolution_clock::now();
1420 func = mDbPulse->
createPulse(mMinTB,mMaxTB,2+npeaks*3);
1423 TFitResultPtr result = gae->Fit(func,
"BNRQ");
1424 res[1] = func->GetParameter(compidx*3 + 2);
1425 res[2] = func->GetParameter(compidx*3 + 3);
1426 res[3] = func->GetParameter(compidx*3 + 4);
1427 res[4] = func->GetChisquare()/func->GetNDF();
1430 auto stop=std::chrono::high_resolution_clock::now();
1431 long long usec = chrono::duration_cast<chrono::microseconds>(stop-start).count();
1439 res[0] =
sum8(gae,res);
1441 if( det0==0 || det0==1 ){res[0]/=mEnergySumScale[0];}
1442 if( det0==2 || det0==3 ){res[0]/=mEnergySumScale[1];}
1443 if( det0==4 || det0==5 ){res[0]/=mEnergySumScale[2];}
1446 res[3] = mDbPulse->
GSigma();
1453 mH1F_Res0Zoom[det0]->Fill(res[0]);
1455 mH1F_Res0Zoom[6]->Fill(res[0]);
1456 float sum8res[8] = {0};
1457 sum8( gae ,sum8res );
1459 mH1F_Sum8Res0Zoom[det0]->Fill(sum8res[0]);
1461 mH1F_Sum8Res0Zoom[6]->Fill(sum8res[0]);
1462 float savesum8 = sum8res[0];
1471 func = mDbPulse->
createPulse(mMinTB,mMaxTB,2+npeaks*3);
1473 TFitResultPtr result = gae->Fit(func,
"BNRQ");
1474 sum8res[5] = npeaks;
1475 sum8res[1] = func->GetParameter(compidx*3 + 2);
1476 sum8res[2] = func->GetParameter(compidx*3 + 3);
1477 sum8res[3] = func->GetParameter(compidx*3 + 4);
1478 sum8res[4] = func->GetChisquare()/func->GetNDF();
1481 mH1F_FitRes0Zoom[det0]->Fill(sum8res[0]);
1483 mH1F_FitRes0Zoom[6]->Fill(sum8res[0]);
1485 mH2F_Sum8vFit[det0]->Fill(sum8res[0],savesum8);
1486 mH2F_Sum8vFit[6]->Fill(sum8res[0],savesum8);
1490 mH1F_FitRes0Zoom[det0]->Fill(res[0]);
1492 mH1F_FitRes0Zoom[6]->Fill(res[0]);
1493 mH2F_Sum8vFit[det0]->Fill(res[0],savesum8);
1494 mH2F_Sum8vFit[6]->Fill(res[0],savesum8);
1513 int det0 = 0;
int ch0=0;
1520 if( compidx==npeaks ){ res[0] = 0; }
1521 else if( (
mTest==8?(npeaks<1):(npeaks<=1)) ){
1523 res[0] =
sum8(gae,res);
1525 if( det0==0 || det0==1 ){res[0]/=mEnergySumScale[0];}
1526 if( det0==2 || det0==3 ){res[0]/=mEnergySumScale[1];}
1527 if( det0==4 || det0==5 ){res[0]/=mEnergySumScale[2];}
1530 res[3] = mDbPulse->
GSigma();
1536 int trigfitidx = compidx;
1537 std::vector<int> validindex =
NPeaksPrePost(trigfitidx,xmin,xmax);
1538 npeaks = validindex.size();
1543 if( ((
mTest==8)?(npeaks>=1 && npeaks<mMaxPeak):(npeaks>1)) ){
1544 auto start=std::chrono::high_resolution_clock::now();
1545 func = mDbPulse->
createPulse(xmin,xmax,2+npeaks*3);
1547 if( func->GetParameter(0)==0 ){ LOG_ERROR <<
"StFcsWaveformFitMaker::PulseFit2: Unable to set function parameters, bad peak indicies" << endl; }
1549 TFitResultPtr result = gae->Fit(func,
"BNRQ");
1551 res[1] = func->GetParameter(trigfitidx*3 + 2);
1552 res[2] = func->GetParameter(trigfitidx*3 + 3);
1553 res[3] = func->GetParameter(trigfitidx*3 + 4);
1554 res[4] = func->GetChisquare()/func->GetNDF();
1557 auto stop=std::chrono::high_resolution_clock::now();
1558 long long usec = chrono::duration_cast<chrono::microseconds>(stop-start).count();
1564 res[0] =
sum8(gae,res);
1566 if( det0==0 || det0==1 ){res[0]/=mEnergySumScale[0];}
1567 if( det0==2 || det0==3 ){res[0]/=mEnergySumScale[1];}
1568 if( det0==4 || det0==5 ){res[0]/=mEnergySumScale[2];}
1571 res[3] = mDbPulse->
GSigma();
1579 mH1F_Res0Zoom[det0]->Fill(res[0]);
1581 mH1F_Res0Zoom[6]->Fill(res[0]);
1582 float sum8res[8] = {0};
1583 sum8( gae ,sum8res );
1585 mH1F_Sum8Res0Zoom[det0]->Fill(sum8res[0]);
1587 mH1F_Sum8Res0Zoom[6]->Fill(sum8res[0]);
1588 float savesum8 = sum8res[0];
1597 TFitResultPtr result = gae->Fit(testfunc,
"BNRQ");
1599 sum8res[1] = testfunc->GetParameter(compidx*3 + 2);
1600 sum8res[2] = testfunc->GetParameter(compidx*3 + 3);
1601 sum8res[3] = testfunc->GetParameter(compidx*3 + 4);
1602 sum8res[4] = testfunc->GetChisquare()/testfunc->GetNDF();
1605 mH1F_FitRes0Zoom[det0]->Fill(sum8res[0]);
1607 mH1F_FitRes0Zoom[6]->Fill(sum8res[0]);
1609 mH2F_Sum8vFit[det0]->Fill(sum8res[0],savesum8);
1610 mH2F_Sum8vFit[6]->Fill(sum8res[0],savesum8);
1615 mH1F_Res0Zoom[det0]->Fill(res[0]);
1617 mH1F_Res0Zoom[6]->Fill(res[0]);
1619 float gausres[8] = {0};
1620 gausFit( gae , gausres, testfunc );
1622 mH1F_FitRes0Zoom[det0]->Fill(gausres[0]);
1624 mH1F_FitRes0Zoom[6]->Fill(gausres[0]);
1626 mH2F_Sum8vFit[det0]->Fill(gausres[0],res[0]);
1627 mH2F_Sum8vFit[6]->Fill(gausres[0],res[0]);
1644 int det0 = 0;
int ch0=0;
1648 if( compidx==npeaks || npeaks==0 ){
1649 res[0] =
sum8(gae,res);
1651 if( det0==0 || det0==1 ){res[0]/=mEnergySumScale[0];}
1652 if( det0==2 || det0==3 ){res[0]/=mEnergySumScale[1];}
1653 if( det0==4 || det0==5 ){res[0]/=mEnergySumScale[2];}
1656 res[3] = mDbPulse->
GSigma();
1664 func = mDbPulse->
createPulse(xmin,xmax,2+npeaks*3);
1666 if( func->GetParameter(0)==0 ){ LOG_ERROR <<
"StFcsWaveformFitMaker::PulseFitAll: Unable to set function parameters, bad peak indicies" << endl; }
1667 TFitResultPtr result = gae->Fit(func,
"BNRQ");
1669 res[1] = func->GetParameter(compidx*3 + 2);
1670 res[2] = func->GetParameter(compidx*3 + 3);
1671 res[3] = func->GetParameter(compidx*3 + 4);
1672 res[4] = func->GetChisquare()/func->GetNDF();
1682 if( fabs(res[7]) < 0.000001 ){AnaPed( gae, res[6], res[7] ); }
1688 if( fabs(res[7]) < 0.000001 ){AnaPed( gae, res[6], res[7] ); }
1707 if( value<=0 ){
return ceil( static_cast<double>(value+(Nvals*PadNums))/static_cast<double>(Nvals) );}
1708 else{
return GenericPadPos(value-(Nvals*PadNums), Nvals, PadNums); }
1719 else if( 1<det && det<=3 ){
1723 else{ LOG_ERROR <<
"StFcsWaveformFitMaker::PadNum4x4: This only works for Ecal and Hcal" << endm;
return 0;}
1726 return 4*(padrow-1)+padcol;
1734 unsigned int result = 0;
1740 if( xdiff<10.0 ){ result |= 1<<0; }
1741 if( yratio<2.0 ){ result |= 1<<1; }
1748 xmin = mCenterTB - mDbPulse->
TBPerRC()/2;
1749 xmax = mCenterTB + mDbPulse->
TBPerRC()/2;
1751 int prexing = 3*mDbPulse->
TBPerRC();
1752 int postxing = 2*mDbPulse->
TBPerRC();
1753 bool foundtrigidx =
false;
1754 std::vector<int> valididx;
1760 if( !foundtrigidx && trigidx==i ){ foundtrigidx =
true; trigidx = valididx.size(); }
1761 if( !valididx.empty() && valididx.back()!=(i-1) ){ LOG_ERROR <<
"StFcsWaveformFitMaker::NPeaksPrePost: Found indices are not linear" << endm; }
1762 valididx.push_back(i);
1767 if( !foundtrigidx ){ LOG_ERROR <<
"StFcsWaveformFitMaker::NPeaksPrePost: Unable to find a matching triggered crossing possibly due to improper use of function" << endm; }
int getColumnNumber(int det, int id) const
get the row number for the channel
virtual TGraphAsymmErrors * GetData() const
Overwrite from PeakAna to type convert for StFcsWaveformFitMaker.
void setPedestal(int ehp, int ns, int dep, int ch, float ped)
get Pedestal
static Int_t getYMinMax(TGraphAsymmErrors *gae, Double_t &Ymin, Double_t &Ymax, Double_t xmin=-5, Double_t xmax=2000)
Finds minimum and maximum y-values in a TGraph and returns index for max y.
static int SumDep0Mod(TGraphAsymmErrors *gdata, int Start, int ped=0)
Test my modified sum method to DEP board.
float getGainCorrection(int det, int id) const
get the gain for the channel for 8 timebin sum
TF1 * createPulse(double xlow=0, double xhigh=1, int npars=5)
Function to create pulse shape for FCS, 5 parameters is minimum.
int getRowNumber(int det, int id) const
maximum number of id
const PeakWindow & GetPeak(UInt_t peakidx) const
Int_t FoundPeakIndex() const
void SetSearchWindow(Double_t peak, Double_t width)
Sets peak search parameters.
void SetTunnelThreshold(Double_t value)
virtual void SetData(TGraph *graph)
sets new data for PeakAna
virtual void Clear(Option_t *option="")
User defined functions.
void getName(int det, int id, char name[])
get the DEP/ch id
static double sqrt2pi()
sqrt(2*TMath::Pi)
Double_t PeakEnd()
Found Signal ending x-value.
void AnalyzeForPedestal()
Analyze graph data to determine baseline internally.
static void setTGraphAsymmErrors(TGraphAsymmErrors *gae, const int &i, const double &adc, double Yerr, double YerrSat)
Figure out and set the errors on FCS pulse data stored in a TGraphAsymmErrors object.
void SetBaseline(Double_t base, Double_t sigma)
Double_t mPeakX
x-value of peak position as determined by SetPeak()
void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
Sets the absolute range of the data.
void SetDebug(UInt_t level)
void SetTunnelScale(Double_t value)
static int PadNum4x4(int det, int col, int row)
Function that gives pad number when drawing a specific detector id.
virtual StFcsPulseAna * DrawCopy(Option_t *opt="", const char *name_postfix="_copy", TGraph *graph=0) const
Clone and draw, see PeakAna::Draw() for options.
Double_t PeakStart()
Found Signal starting x-value.
float getGain(int det, int id) const
get sampling fraction
Int_t SumWindow()
Sum the ADC in the peak defined by mFoundPeak and subtract the baseline.
void SetBaselineSigmaScale(Double_t scale)
Double_t BaselineSigma() const
void SetFitPars(TF1 *&func, int start=-1, int end=-1)
Set the parameters of an external TF1 function that has the form of StFcsDbPulse::multiPulseShape(), optionally only set fit paramaters for peaks from index start up to and including end.
void SetContinuity(Double_t val)
static int SumDep0(TGraphAsymmErrors *gdata, int Start, int ped=0)
Test of sum method in DEP board.
Double_t mStartX
x value for start of the peak window
void setDbPulse(StFcsDbPulse *p)
virtual Int_t AnalyzeForPeak()
Overwritten from PeakAna to process peak tunneling after finding all peaks.
Double_t Baseline() const
bool ValidPeakIdx() const
Double_t mEndX
x value for end of the peak window
Double_t BaselineSigmaScale() const
Double_t mPeakY
y-value at mP_Peak
static void getFromName(const char name[], int &det, int &id)
Get Name of a channel.
void setTail(int tail)
Sets the variables needed by the sum of xexp functions that describe the tail of the pulse shape...
void SetTunnelSigma(Double_t value)