#include <TMatacq.h>
Public Member Functions | |
int | compute_trise () |
int | countBadPulses (Int_t) |
int | doFit () |
void | enterdata (Int_t) |
int | findPeak () |
double | getAmpl () |
double | getBaseLine () |
double | getFwhm () |
int | getPt1 () |
int | getPt2 () |
int | getPtm () |
double | getsigBaseLine () |
double | getsigTimpeak () |
double | getSlide () |
double | getTimax () |
double | getTimpeak () |
double | getTrise () |
double | getWidth20 () |
double | getWidth80 () |
void | init () |
void | printitermatacqData (Int_t, Int_t, Int_t) |
void | printmatacqData (Int_t, Int_t, Int_t) |
int | rawPulseAnalysis (Int_t, Double_t *) |
TMatacq (int, int, int, int, int, int, int, int, int, int, int) | |
virtual | ~TMatacq () |
Private Member Functions | |
double | interpolate (double) |
Private Attributes | |
double | ampl |
int | bing [101] |
double | bl |
double | bong [NMAXSAMP] |
double | comp_peak [1200] |
double | comp_trise [1200] |
int | endsample |
int | firstsample |
int | fNsamples |
int | fNum_samp_aft_max |
int | fNum_samp_bef_max |
double | fv1 [NSPARAB] |
double | fv2 [NSPARAB] |
double | fv3 [NSPARAB] |
int | lastsample |
double | level1 |
double | level2 |
double | level3 |
double | meantrise |
int | nevlasers |
int | nevmtq0 |
int | nevmtq1 |
double | nsigcut |
int | nslide |
double | pkval |
int | presample |
int | samplemax |
double | sigbl |
double | sigpkval |
double | sigtrise |
double | slidingmean |
int | status [1200] |
double | t [NSPARAB] |
double | timeatmax |
double | trise |
double | val [NSPARAB] |
double | val_max |
double | width20 |
double | width50 |
double | width80 |
TMatacq::TMatacq | ( | int | Ntot, |
int | Nsamp1, | ||
int | Nsamp2, | ||
int | cut, | ||
int | Nbef, | ||
int | Naft, | ||
int | niv1, | ||
int | niv2, | ||
int | niv3, | ||
int | nevl, | ||
int | NSlide | ||
) |
Definition at line 33 of file TMatacq.cc.
References gen::k, and ntuplemaker::status.
{ fNsamples= Ntot; presample= Nsamp1; endsample= Nsamp2; nsigcut= (double) cut; fNum_samp_bef_max= Nbef; fNum_samp_aft_max= Naft; level1= ((double) niv1)/100.; level2= ((double) niv2)/100.; level3= ((double) niv3)/100.; nevlasers= nevl; slidingmean=0.0; nslide=NSlide; for(int k=0;k<nevlasers;k++) status[k]=0; for(int k=0;k<nevlasers;k++) status[k+nevlasers]=0; nevmtq0=0; nevmtq1=0; }
TMatacq::~TMatacq | ( | ) | [virtual] |
Definition at line 56 of file TMatacq.cc.
{ }
int TMatacq::compute_trise | ( | ) |
Definition at line 331 of file TMatacq.cc.
References error.
Referenced by EcalMatacqAnalyzer::endJob().
int TMatacq::countBadPulses | ( | Int_t | ) |
Definition at line 469 of file TMatacq.cc.
References lut2db_cfg::filename, i, NULL, and ntuplemaker::status.
{ FILE *fmatacq; char filename[80]; sprintf(filename,"badevtsMatacq%d.dat",gRunNumber); fmatacq = fopen(filename, "w"); if(fmatacq == NULL) printf("Error while opening file : %s\n",filename); int nevbad=0; for(Int_t i=0;i<nevmtq0+nevmtq1;i++) { if(comp_trise[i] < meantrise - 3.*sigtrise) { nevbad++; fprintf(fmatacq,"%d \n",status[i]); status[i]=-1; } if(comp_trise[i] > meantrise + 3.*sigtrise) { nevbad++; fprintf(fmatacq,"%d \n",status[i]); status[i]=-1; } } int iret=fclose(fmatacq); printf(" Closing file : %d\n",iret); return nevbad; }
int TMatacq::doFit | ( | ) |
Definition at line 202 of file TMatacq.cc.
References a, b, trackerHits::c, validate-o2o-wbm::f1, validate-o2o-wbm::f2, connectstrParser::f3, i, j, NSPARAB, tablePrinter::width, and detailsBasic3DVector::y.
Referenced by EcalMatacqAnalyzer::endJob().
{ int testneg=0; ampl=0.; timeatmax=0.; int heresamplemax= samplemax-firstsample; int beginfit= heresamplemax - fNum_samp_bef_max; int endfit= heresamplemax + fNum_samp_aft_max; int nval= endfit-beginfit +1; if(nval != NSPARAB) return 201; for(int kn=beginfit;kn<=endfit;kn++) { if(bong[kn] <= 0) testneg=1; } if(testneg == 1) return 202; for(int i=0;i<nval;i++) { val[i]= bong[beginfit+i]; fv1[i]= 1.; fv2[i]= (double) (i); fv3[i]= ((double)(i))*((double)(i)); } TVectorD y(nval,val); TVectorD f1(nval,fv1); TVectorD f2(nval,fv2); TVectorD f3(nval,fv3); double bj[3]; bj[0]= f1*y; bj[1]=f2*y; bj[2]= f3*y; TVectorD b(3,bj); double aij[9]; aij[0]= f1*f1; aij[1]=f1*f2; aij[2]=f1*f3; aij[3]= f2*f1; aij[4]=f2*f2; aij[5]=f2*f3; aij[6]= f3*f1; aij[7]=f3*f2; aij[8]=f3*f3; TMatrixD a(3,3,aij); double det1; a.InvertFast(&det1); TVectorD c= a*b; double *par= c.GetMatrixArray(); if(par[2] != 0.) { timeatmax= -par[1]/(2.*par[2]); ampl= par[0]-par[2]*(timeatmax*timeatmax); } if(ampl <= 0.) { ampl=bong[heresamplemax]; return 203; } if((int)timeatmax > NSPARAB) return 204; if((int)timeatmax < 0) return 205; timeatmax+= (beginfit + firstsample); int tplus[3], tminus[3]; double xampl[3]; xampl[0]=0.2*ampl; xampl[1]=0.5*ampl; xampl[2]=0.8*ampl; int hitplus[3]; int hitminus[3]; double width[3]; for(int i=0;i<3;i++){ hitplus[i]=0; hitminus[i]=0; width[i]=0.0; tplus[i]=firstsample+lastsample; tminus[i]=0; } // calculate first estimate of half width int im = heresamplemax; int iplusbound = firstsample+lastsample-im; for(int j=0;j<3;j++){ for(int i=1;i<im;i++){ if (bong[im-i]<xampl[j] && bong[im-i+1]>xampl[j]) { tminus[j]=im-i; hitminus[j]++; i=im; } } for(int i=0;i<iplusbound;i++){ if (bong[im+i]>xampl[j] && bong[im+i+1]<xampl[j]){ tplus[j]=im+i; hitplus[j]++; i=iplusbound; } } // interpolate to get a better estimate double slopeplus = double( bong[tplus[j] +1] - bong[tplus[j] ] ); double slopeminus = double( bong[tminus[j]+1] - bong[tminus[j]] ); double timeminus=double(tminus[j])+0.5; if(slopeminus!=0) timeminus=tminus[j]+(xampl[j]-double(bong[tminus[j]]))/slopeminus; double timeplus=double(tplus[j])+0.5; if(slopeplus!=0) timeplus=tplus[j]+(xampl[j]-double(bong[tplus[j]]))/slopeplus; width[j]=timeplus-timeminus; } width20=width[0]; width50=width[1]; width80=width[2]; return 0; }
void TMatacq::enterdata | ( | Int_t | anevt | ) |
Definition at line 385 of file TMatacq.cc.
References ntuplemaker::status.
{ if(anevt < 2*nevlasers) { if(anevt < nevlasers) { nevmtq0++; status[nevmtq0-1]= anevt; comp_trise[nevmtq0-1]= trise; comp_peak[nevmtq0-1]= pkval; } else { nevmtq1++; status[nevmtq0+nevmtq1-1]= anevt; comp_trise[nevmtq0+nevmtq1-1]= trise; comp_peak[nevmtq0+nevmtq1-1]= pkval; } } else { if(anevt < 3*nevlasers) { nevmtq0++; status[nevmtq0-1]= anevt; comp_trise[nevmtq0-1]= trise; comp_peak[nevmtq0-1]= pkval; } else { nevmtq1++; status[nevmtq0+nevmtq1-1]= anevt; comp_trise[nevmtq0+nevmtq1-1]= trise; comp_peak[nevmtq0+nevmtq1-1]= pkval; } } }
int TMatacq::findPeak | ( | ) |
Definition at line 128 of file TMatacq.cc.
References gen::k, and NMAXSAMP.
Referenced by EcalMatacqAnalyzer::endJob().
{ int k; int nbinf=0; int jfind=0; int nbsup= 0; double thres= val_max*level1; for(k=0,jfind=0;k<NMAXSAMP;k++) { if(jfind == 0) { if(bong[k] > thres) { nbinf=k; jfind=1; } } } if(jfind == 0) nbinf=0; for(k=NMAXSAMP,jfind=0;k>nbinf;k--) { if(jfind == 0) { if(bong[k] > thres) { nbsup=k; jfind=1; } } } if(nbsup == 0) nbsup=nbinf; double sumpkval=1.; pkval= 0.; sigpkval=0.5; if(nbsup == nbinf) { return 301; } else { if(nbinf > 4) nbinf-=3; else nbinf=1; if(nbsup < NMAXSAMP-4) nbsup+=3; else nbsup=NMAXSAMP; for(k=0;k<nbinf;k++) bong[k]=0.; for(k=nbsup;k<NMAXSAMP;k++) bong[k]=0.; for(k=0,jfind=0;k<NMAXSAMP;k++) { if(bong[k] > 0.) jfind++; } if(jfind == 0) { return 302; } else if(jfind == 1) { return 303; } else { for(k=0;k<NMAXSAMP;k++) { if(k < 100) bing[k+1]= (int) bong[k]; } TMarkov *peak = new TMarkov(); peak -> peakFinder(&bing[0]); pkval= peak -> getPeakValue(0); sigpkval= peak -> getPeakValue(1); delete peak; sumpkval= 0.0; if(sumpkval > 1000.) sumpkval=10.; pkval+= (firstsample -1); } } return 0; }
double TMatacq::getAmpl | ( | ) | [inline] |
Definition at line 70 of file TMatacq.h.
References ampl.
Referenced by EcalMatacqAnalyzer::endJob().
{return ampl;}
double TMatacq::getBaseLine | ( | ) | [inline] |
Definition at line 64 of file TMatacq.h.
References bl.
Referenced by EcalMatacqAnalyzer::endJob().
{return bl;}
double TMatacq::getFwhm | ( | ) | [inline] |
Definition at line 74 of file TMatacq.h.
References width50.
Referenced by EcalMatacqAnalyzer::endJob().
{return width50;}
int TMatacq::getPt1 | ( | ) | [inline] |
int TMatacq::getPt2 | ( | ) | [inline] |
int TMatacq::getPtm | ( | ) | [inline] |
double TMatacq::getsigBaseLine | ( | ) | [inline] |
Definition at line 65 of file TMatacq.h.
References sigbl.
Referenced by EcalMatacqAnalyzer::endJob().
{return sigbl;}
double TMatacq::getsigTimpeak | ( | ) | [inline] |
Definition at line 68 of file TMatacq.h.
References sigpkval.
Referenced by EcalMatacqAnalyzer::endJob().
{return sigpkval;}
double TMatacq::getSlide | ( | ) | [inline] |
Definition at line 77 of file TMatacq.h.
References slidingmean.
Referenced by EcalMatacqAnalyzer::endJob().
{return slidingmean;}
double TMatacq::getTimax | ( | ) | [inline] |
Definition at line 71 of file TMatacq.h.
References timeatmax.
Referenced by EcalMatacqAnalyzer::endJob().
{return timeatmax;}
double TMatacq::getTimpeak | ( | ) | [inline] |
Definition at line 67 of file TMatacq.h.
References pkval.
Referenced by EcalMatacqAnalyzer::endJob().
{return pkval;}
double TMatacq::getTrise | ( | ) | [inline] |
Definition at line 73 of file TMatacq.h.
References trise.
Referenced by EcalMatacqAnalyzer::endJob().
{return trise;}
double TMatacq::getWidth20 | ( | ) | [inline] |
Definition at line 75 of file TMatacq.h.
References width20.
Referenced by EcalMatacqAnalyzer::endJob().
{return width20;}
double TMatacq::getWidth80 | ( | ) | [inline] |
Definition at line 76 of file TMatacq.h.
References width80.
Referenced by EcalMatacqAnalyzer::endJob().
{return width80;}
void TMatacq::init | ( | ) |
double TMatacq::interpolate | ( | double | amplx | ) | [private] |
Definition at line 355 of file TMatacq.cc.
{ double T; int kmax= (int) pkval - firstsample; int bin_low=0; for(Int_t k=0;k<kmax;k++) if(0. < bong[k] && bong[k] < amplx) { bin_low=k; } if(bin_low == 0) return -301.; int bin_high=0; for(Int_t k=kmax;k>=0;k--) if(bong[k] > amplx) { bin_high=k; } if(bin_high == 0) return -302.; if(bin_high < bin_low) return -303.; if(bin_low == bin_high) { T= (double) bin_high; } else { double slope= (bong[bin_high]-bong[bin_low])/((double) (bin_high-bin_low)); T= (double) bin_high - (bong[bin_high] - amplx)/slope; } return T; }
void TMatacq::printitermatacqData | ( | Int_t | , |
Int_t | , | ||
Int_t | |||
) |
Definition at line 496 of file TMatacq.cc.
References lut2db_cfg::filename, i, NULL, mathSSE::sqrt(), and ntuplemaker::status.
{ FILE *fmatacq; char filename[80]; int i; double ss; sprintf(filename,"runiterMatacq%d.pedestal",gRunNumber); fmatacq = fopen(filename, "w"); if(fmatacq == NULL) printf("Error while opening file : %s\n",filename); int nevmtqgood=0; double sumtrise=0.; double sumtrise2=0.; int timestop= timestart+3; double mintrise=10000.; double maxtrise=0.; for(i=0;i<nevmtq0;i++) { if(status[i] >= 0) { nevmtqgood++; if(comp_trise[i] > maxtrise) { maxtrise=comp_trise[i]; } if(comp_trise[i] < mintrise) { mintrise= comp_trise[i]; } sumtrise+=comp_trise[i]; sumtrise2+=comp_trise[i]*comp_trise[i]; } } meantrise= sumtrise/((double) nevmtqgood); ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise); if(ss < 0.) ss=0.; sigtrise=sqrt(ss); fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise); nevmtqgood=0; sumtrise=0.; sumtrise2=0.; mintrise=10000.; maxtrise=0.; for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) { if(status[i] >= 0) { nevmtqgood++; if(comp_trise[i] > maxtrise) { maxtrise=comp_trise[i]; } if(comp_trise[i] < mintrise) { mintrise= comp_trise[i]; } sumtrise+=comp_trise[i]; sumtrise2+=comp_trise[i]*comp_trise[i]; } } meantrise= sumtrise/((double) nevmtqgood); ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise); if(ss < 0.) ss=0.; sigtrise=sqrt(ss); fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise); int iret=fclose(fmatacq); printf(" Closing file : %d\n",iret); }
void TMatacq::printmatacqData | ( | Int_t | , |
Int_t | , | ||
Int_t | |||
) |
Definition at line 414 of file TMatacq.cc.
References lut2db_cfg::filename, i, NULL, and mathSSE::sqrt().
{ FILE *fmatacq; char filename[80]; int i; double ss; sprintf(filename,"runMatacq%d.pedestal",gRunNumber); fmatacq = fopen(filename, "w"); if(fmatacq == NULL) printf("Error while opening file : %s\n",filename); double sumtrise=0.; double sumtrise2=0.; int timestop= timestart+3; double mintrise=10000.; double maxtrise=0.; for(i=0;i<nevmtq0;i++) { if(comp_trise[i] > maxtrise) { maxtrise=comp_trise[i]; } if(comp_trise[i] < mintrise) { mintrise= comp_trise[i]; } sumtrise+=comp_trise[i]; sumtrise2+=comp_trise[i]*comp_trise[i]; } meantrise= sumtrise/((double) nevmtq0); ss= (sumtrise2/((double) nevmtq0) - meantrise*meantrise); if(ss < 0.) ss=0.; sigtrise=sqrt(ss); fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtq0,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise); sumtrise=0.; sumtrise2=0.; mintrise=10000.; maxtrise=0.; for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) { if(comp_trise[i] > maxtrise) { maxtrise=comp_trise[i]; } if(comp_trise[i] < mintrise) { mintrise= comp_trise[i]; } sumtrise+=comp_trise[i]; sumtrise2+=comp_trise[i]*comp_trise[i]; } meantrise= sumtrise/((double) nevmtq1); ss= (sumtrise2/((double) nevmtq1) - meantrise*meantrise); if(ss < 0.) ss=0.; sigtrise=sqrt(ss); fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtq1,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise); int iret=fclose(fmatacq); printf(" Closing file : %d\n",iret); }
int TMatacq::rawPulseAnalysis | ( | Int_t | Nsamp, |
Double_t * | adc | ||
) |
Definition at line 60 of file TMatacq.cc.
References i, init, gen::k, NMAXSAMP, and mathSSE::sqrt().
Referenced by EcalMatacqAnalyzer::endJob().
{ using namespace std; // std::cout << "Entering rawPulseAnalysis" << std::endl; int k,ithr; double dsum=0.,dsum2=0.; // std::cout << "calling init" << std::endl; init(); // std::cout << ".......done" << std::endl; if(Nsamp != fNsamples) { printf("found different number of samples fNsamples=%d Nsamp=%d\n",fNsamples,Nsamp); return 100; } for(k=0;k<presample;k++) { dsum+= adc[k]; dsum2+= adc[k]*adc[k]; } bl=dsum/((double) presample); double ss= (dsum2/((double) presample)-bl*bl); if(ss<0.) ss=0.; sigbl=sqrt(ss); for(ithr=0,k=presample;k<endsample;k++) { if(adc[k] > (bl+nsigcut*sigbl) && ithr == 0) { ithr=1; firstsample=k; } } if(ithr == 0) return 101; for(ithr=0,k=firstsample;k<Nsamp;k++) { if(adc[k] < (bl+nsigcut*sigbl) && ithr == 0) { ithr=1; lastsample=k; } } if(ithr == 0) lastsample= Nsamp; if(lastsample > firstsample+NMAXSAMP) lastsample= firstsample+NMAXSAMP; val_max=0.; samplemax=0; for (Int_t is=firstsample;is<lastsample;is++) { bong[is-firstsample]= adc[is] - bl; if(bong[is-firstsample] > val_max) { val_max= bong[is-firstsample]; samplemax=is; } } if(samplemax == 0) return 103; if(samplemax > lastsample) return 104; if(samplemax < firstsample) return 105; int endslide=samplemax -nslide; int beginslide=nslide; int islidingmean=0; slidingmean=0.0; for(int i=beginslide;i<endslide;i++) { slidingmean+= adc[i]; islidingmean+=1; } if( islidingmean!=0) slidingmean/=double(islidingmean); return 0; }
double TMatacq::ampl [private] |
int TMatacq::bing[101] [private] |
double TMatacq::bl [private] |
Definition at line 25 of file TMatacq.h.
Referenced by getBaseLine().
double TMatacq::bong[NMAXSAMP] [private] |
double TMatacq::comp_peak[1200] [private] |
double TMatacq::comp_trise[1200] [private] |
int TMatacq::endsample [private] |
int TMatacq::firstsample [private] |
int TMatacq::fNsamples [private] |
int TMatacq::fNum_samp_aft_max [private] |
int TMatacq::fNum_samp_bef_max [private] |
double TMatacq::fv1[NSPARAB] [private] |
double TMatacq::fv2[NSPARAB] [private] |
double TMatacq::fv3[NSPARAB] [private] |
int TMatacq::lastsample [private] |
double TMatacq::level1 [private] |
double TMatacq::level2 [private] |
double TMatacq::level3 [private] |
double TMatacq::meantrise [private] |
int TMatacq::nevlasers [private] |
int TMatacq::nevmtq0 [private] |
int TMatacq::nevmtq1 [private] |
double TMatacq::nsigcut [private] |
int TMatacq::nslide [private] |
double TMatacq::pkval [private] |
Definition at line 27 of file TMatacq.h.
Referenced by getTimpeak().
int TMatacq::presample [private] |
int TMatacq::samplemax [private] |
double TMatacq::sigbl [private] |
Definition at line 25 of file TMatacq.h.
Referenced by getsigBaseLine().
double TMatacq::sigpkval [private] |
Definition at line 27 of file TMatacq.h.
Referenced by getsigTimpeak().
double TMatacq::sigtrise [private] |
double TMatacq::slidingmean [private] |
Definition at line 35 of file TMatacq.h.
Referenced by getSlide().
int TMatacq::status[1200] [private] |
double TMatacq::t[NSPARAB] [private] |
double TMatacq::timeatmax [private] |
Definition at line 26 of file TMatacq.h.
Referenced by getTimax().
double TMatacq::trise [private] |
Definition at line 28 of file TMatacq.h.
Referenced by getTrise().
double TMatacq::val[NSPARAB] [private] |
double TMatacq::val_max [private] |
double TMatacq::width20 [private] |
Definition at line 29 of file TMatacq.h.
Referenced by getWidth20().
double TMatacq::width50 [private] |
double TMatacq::width80 [private] |
Definition at line 29 of file TMatacq.h.
Referenced by getWidth80().