CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TMatacq Class Reference

#include <TMatacq.h>

Inheritance diagram for TMatacq:

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
 

Detailed Description

Definition at line 9 of file TMatacq.h.

Constructor & Destructor Documentation

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 32 of file TMatacq.cc.

References gen::k, and ntuplemaker::status.

33 {
34  fNsamples= Ntot;
35  presample= Nsamp1;
36  endsample= Nsamp2;
37  nsigcut= (double) cut;
38  fNum_samp_bef_max= Nbef;
39  fNum_samp_aft_max= Naft;
40  level1= ((double) niv1)/100.;
41  level2= ((double) niv2)/100.;
42  level3= ((double) niv3)/100.;
43  nevlasers= nevl;
44  slidingmean=0.0;
45  nslide=NSlide;
46  for(int k=0;k<nevlasers;k++)
47  status[k]=0;
48  for(int k=0;k<nevlasers;k++)
49  status[k+nevlasers]=0;
50 
51  nevmtq0=0; nevmtq1=0;
52 }
int fNum_samp_bef_max
Definition: TMatacq.h:15
int endsample
Definition: TMatacq.h:18
int fNum_samp_aft_max
Definition: TMatacq.h:16
int status[1200]
Definition: TMatacq.h:33
double nsigcut
Definition: TMatacq.h:20
int nslide
Definition: TMatacq.h:36
double level1
Definition: TMatacq.h:21
double level2
Definition: TMatacq.h:21
int fNsamples
Definition: TMatacq.h:14
double slidingmean
Definition: TMatacq.h:35
int k[5][pyjets_maxn]
double level3
Definition: TMatacq.h:21
int nevlasers
Definition: TMatacq.h:32
int nevmtq0
Definition: TMatacq.h:32
int nevmtq1
Definition: TMatacq.h:32
int presample
Definition: TMatacq.h:18
TMatacq::~TMatacq ( )
virtual

Definition at line 55 of file TMatacq.cc.

56 {
57 }

Member Function Documentation

int TMatacq::compute_trise ( )

Definition at line 330 of file TMatacq.cc.

References relativeConstraints::error.

Referenced by EcalMatacqAnalyzer::endJob().

331 {
332  int error;
333  trise= 0.;
334 
335  double t20= interpolate(ampl*level2);
336  if(t20 < 0.) {
337  error= (int) -t20;
338  return error;
339  }
340  double t80= interpolate(ampl*level3);
341  if(t80 < 0.) {
342  error= (int) -t80;
343  return error;
344  }
345  trise= t80 - t20;
346 
347  return 0;
348 }
double trise
Definition: TMatacq.h:28
double interpolate(double)
Definition: TMatacq.cc:354
double level2
Definition: TMatacq.h:21
double ampl
Definition: TMatacq.h:26
double level3
Definition: TMatacq.h:21
int TMatacq::countBadPulses ( Int_t  )

Definition at line 468 of file TMatacq.cc.

References lut2db_cfg::filename, i, NULL, and ntuplemaker::status.

469 {
470  FILE *fmatacq;
471  char filename[80];
472  sprintf(filename,"badevtsMatacq%d.dat",gRunNumber);
473  fmatacq = fopen(filename, "w");
474  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
475 
476  int nevbad=0;
477  for(Int_t i=0;i<nevmtq0+nevmtq1;i++) {
478  if(comp_trise[i] < meantrise - 3.*sigtrise) {
479  nevbad++;
480  fprintf(fmatacq,"%d \n",status[i]);
481  status[i]=-1;
482  }
483  if(comp_trise[i] > meantrise + 3.*sigtrise) {
484  nevbad++;
485  fprintf(fmatacq,"%d \n",status[i]);
486  status[i]=-1;
487  }
488  }
489 
490  int iret=fclose(fmatacq);
491  printf(" Closing file : %d\n",iret);
492  return nevbad;
493 }
int i
Definition: DBlmapReader.cc:9
double meantrise
Definition: TMatacq.h:30
int status[1200]
Definition: TMatacq.h:33
#define NULL
Definition: scimark2.h:8
double sigtrise
Definition: TMatacq.h:30
double comp_trise[1200]
Definition: TMatacq.h:34
tuple filename
Definition: lut2db_cfg.py:20
int nevmtq0
Definition: TMatacq.h:32
int nevmtq1
Definition: TMatacq.h:32
int TMatacq::doFit ( )

Definition at line 201 of file TMatacq.cc.

References a, b, trackerHits::c, python.connectstrParser::f1, python.connectstrParser::f2, python.connectstrParser::f3, i, j, NSPARAB, create_public_lumi_plots::width, and detailsBasic3DVector::y.

Referenced by EcalMatacqAnalyzer::endJob().

202 {
203  int testneg=0;
204  ampl=0.; timeatmax=0.;
205  int heresamplemax= samplemax-firstsample;
206 
207  int beginfit= heresamplemax - fNum_samp_bef_max;
208  int endfit= heresamplemax + fNum_samp_aft_max;
209 
210  int nval= endfit-beginfit +1;
211  if(nval != NSPARAB) return 201;
212  for(int kn=beginfit;kn<=endfit;kn++) {
213  if(bong[kn] <= 0) testneg=1;
214  }
215  if(testneg == 1) return 202;
216 
217  for(int i=0;i<nval;i++) {
218  val[i]= bong[beginfit+i];
219  fv1[i]= 1.;
220  fv2[i]= (double) (i);
221  fv3[i]= ((double)(i))*((double)(i));
222  }
223 
224  TVectorD y(nval,val);
225  TVectorD f1(nval,fv1);
226  TVectorD f2(nval,fv2);
227  TVectorD f3(nval,fv3);
228 
229  double bj[3];
230  bj[0]= f1*y; bj[1]=f2*y; bj[2]= f3*y;
231  TVectorD b(3,bj);
232 
233  double aij[9];
234  aij[0]= f1*f1; aij[1]=f1*f2; aij[2]=f1*f3;
235  aij[3]= f2*f1; aij[4]=f2*f2; aij[5]=f2*f3;
236  aij[6]= f3*f1; aij[7]=f3*f2; aij[8]=f3*f3;
237  TMatrixD a(3,3,aij);
238 
239  double det1;
240  a.InvertFast(&det1);
241 
242  TVectorD c= a*b;
243 
244  double *par= c.GetMatrixArray();
245  if(par[2] != 0.) {
246  timeatmax= -par[1]/(2.*par[2]);
247  ampl= par[0]-par[2]*(timeatmax*timeatmax);
248  }
249 
250  if(ampl <= 0.) {
251  ampl=bong[heresamplemax];
252  return 203;
253  }
254 
255  if((int)timeatmax > NSPARAB)
256  return 204;
257  if((int)timeatmax < 0)
258  return 205;
259 
260  timeatmax+= (beginfit + firstsample);
261 
262  int tplus[3], tminus[3];
263  double xampl[3];
264  xampl[0]=0.2*ampl;
265  xampl[1]=0.5*ampl;
266  xampl[2]=0.8*ampl;
267 
268  int hitplus[3];
269  int hitminus[3];
270  double width[3];
271 
272  for(int i=0;i<3;i++){
273  hitplus[i]=0;
274  hitminus[i]=0;
275  width[i]=0.0;
276  tplus[i]=firstsample+lastsample;
277  tminus[i]=0;
278  }
279 
280  // calculate first estimate of half width
281  int im = heresamplemax;
282  int iplusbound = firstsample+lastsample-im;
283 
284  for(int j=0;j<3;j++){
285 
286  for(int i=1;i<im;i++){
287 
288 
289  if (bong[im-i]<xampl[j] && bong[im-i+1]>xampl[j]) {
290  tminus[j]=im-i;
291  hitminus[j]++;
292  i=im;
293  }
294  }
295 
296 
297  for(int i=0;i<iplusbound;i++){
298 
299  if (bong[im+i]>xampl[j] && bong[im+i+1]<xampl[j]){
300  tplus[j]=im+i;
301  hitplus[j]++;
302  i=iplusbound;
303  }
304  }
305 
306  // interpolate to get a better estimate
307 
308  double slopeplus = double( bong[tplus[j] +1] - bong[tplus[j] ] );
309  double slopeminus = double( bong[tminus[j]+1] - bong[tminus[j]] );
310 
311 
312  double timeminus=double(tminus[j])+0.5;
313  if(slopeminus!=0) timeminus=tminus[j]+(xampl[j]-double(bong[tminus[j]]))/slopeminus;
314 
315 
316  double timeplus=double(tplus[j])+0.5;
317  if(slopeplus!=0) timeplus=tplus[j]+(xampl[j]-double(bong[tplus[j]]))/slopeplus;
318 
319  width[j]=timeplus-timeminus;
320 
321  }
322 
323  width20=width[0];
324  width50=width[1];
325  width80=width[2];
326 
327  return 0;
328 }
int i
Definition: DBlmapReader.cc:9
int fNum_samp_bef_max
Definition: TMatacq.h:15
double bong[NMAXSAMP]
Definition: TMatacq.h:22
double fv1[NSPARAB]
Definition: TMatacq.h:24
int fNum_samp_aft_max
Definition: TMatacq.h:16
int samplemax
Definition: TMatacq.h:18
double fv3[NSPARAB]
Definition: TMatacq.h:24
double val[NSPARAB]
Definition: TMatacq.h:23
double width20
Definition: TMatacq.h:29
int j
Definition: DBlmapReader.cc:9
double width50
Definition: TMatacq.h:29
double fv2[NSPARAB]
Definition: TMatacq.h:24
double ampl
Definition: TMatacq.h:26
double width80
Definition: TMatacq.h:29
double timeatmax
Definition: TMatacq.h:26
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
int firstsample
Definition: TMatacq.h:18
int lastsample
Definition: TMatacq.h:18
#define NSPARAB
Definition: TMatacq.h:7
void TMatacq::enterdata ( Int_t  anevt)

Definition at line 384 of file TMatacq.cc.

References ntuplemaker::status.

385 {
386  if(anevt < 2*nevlasers) {
387  if(anevt < nevlasers) {
388  nevmtq0++;
389  status[nevmtq0-1]= anevt;
391  comp_peak[nevmtq0-1]= pkval;
392  } else {
393  nevmtq1++;
394  status[nevmtq0+nevmtq1-1]= anevt;
397  }
398  } else {
399  if(anevt < 3*nevlasers) {
400  nevmtq0++;
401  status[nevmtq0-1]= anevt;
403  comp_peak[nevmtq0-1]= pkval;
404  } else {
405  nevmtq1++;
406  status[nevmtq0+nevmtq1-1]= anevt;
409  }
410  }
411 }
double trise
Definition: TMatacq.h:28
int status[1200]
Definition: TMatacq.h:33
double comp_peak[1200]
Definition: TMatacq.h:34
double pkval
Definition: TMatacq.h:27
double comp_trise[1200]
Definition: TMatacq.h:34
int nevlasers
Definition: TMatacq.h:32
int nevmtq0
Definition: TMatacq.h:32
int nevmtq1
Definition: TMatacq.h:32
int TMatacq::findPeak ( )

Definition at line 127 of file TMatacq.cc.

References gen::k, and NMAXSAMP.

Referenced by EcalMatacqAnalyzer::endJob().

128 {
129  int k; int nbinf=0; int jfind=0;
130  int nbsup= 0;
131  double thres= val_max*level1;
132 
133  for(k=0,jfind=0;k<NMAXSAMP;k++) {
134  if(jfind == 0) {
135  if(bong[k] > thres) {
136  nbinf=k; jfind=1;
137  }
138  }
139  }
140  if(jfind == 0) nbinf=0;
141 
142  for(k=NMAXSAMP,jfind=0;k>nbinf;k--) {
143  if(jfind == 0) {
144  if(bong[k] > thres) {
145  nbsup=k; jfind=1;
146  }
147  }
148  }
149  if(nbsup == 0) nbsup=nbinf;
150 
151  double sumpkval=1.;
152  pkval= 0.;
153  sigpkval=0.5;
154  if(nbsup == nbinf) {
155  return 301;
156  } else {
157  if(nbinf > 4) nbinf-=3;
158  else nbinf=1;
159  if(nbsup < NMAXSAMP-4) nbsup+=3;
160  else nbsup=NMAXSAMP;
161 
162  for(k=0;k<nbinf;k++)
163  bong[k]=0.;
164  for(k=nbsup;k<NMAXSAMP;k++)
165  bong[k]=0.;
166 
167  for(k=0,jfind=0;k<NMAXSAMP;k++) {
168  if(bong[k] > 0.) jfind++;
169  }
170  if(jfind == 0) {
171  return 302;
172  } else if(jfind == 1) {
173  return 303;
174  } else {
175 
176  for(k=0;k<NMAXSAMP;k++) {
177  if(k < 100)
178  bing[k+1]= (int) bong[k];
179  }
180 
181  TMarkov *peak = new TMarkov();
182 
183  peak -> peakFinder(&bing[0]);
184  pkval= peak -> getPeakValue(0);
185  sigpkval= peak -> getPeakValue(1);
186 
187  delete peak;
188 
189  sumpkval= 0.0;
190 
191  if(sumpkval > 1000.)
192  sumpkval=10.;
193 
194  pkval+= (firstsample -1);
195  }
196  }
197 
198  return 0;
199 }
#define NMAXSAMP
Definition: TMatacq.h:6
double bong[NMAXSAMP]
Definition: TMatacq.h:22
int bing[101]
Definition: TMatacq.h:19
double val_max
Definition: TMatacq.h:25
double level1
Definition: TMatacq.h:21
Definition: TMarkov.h:6
int k[5][pyjets_maxn]
double pkval
Definition: TMatacq.h:27
double sigpkval
Definition: TMatacq.h:27
int firstsample
Definition: TMatacq.h:18
double TMatacq::getAmpl ( )
inline

Definition at line 70 of file TMatacq.h.

References ampl.

Referenced by EcalMatacqAnalyzer::endJob().

70 {return ampl;}
double ampl
Definition: TMatacq.h:26
double TMatacq::getBaseLine ( )
inline

Definition at line 64 of file TMatacq.h.

References bl.

Referenced by EcalMatacqAnalyzer::endJob().

64 {return bl;}
double bl
Definition: TMatacq.h:25
double TMatacq::getFwhm ( )
inline

Definition at line 74 of file TMatacq.h.

References width50.

Referenced by EcalMatacqAnalyzer::endJob().

74 {return width50;}
double width50
Definition: TMatacq.h:29
int TMatacq::getPt1 ( )
inline

Definition at line 60 of file TMatacq.h.

References firstsample.

60 {return firstsample;}
int firstsample
Definition: TMatacq.h:18
int TMatacq::getPt2 ( )
inline

Definition at line 61 of file TMatacq.h.

References lastsample.

61 {return lastsample;}
int lastsample
Definition: TMatacq.h:18
int TMatacq::getPtm ( )
inline

Definition at line 62 of file TMatacq.h.

References samplemax.

62 {return samplemax;}
int samplemax
Definition: TMatacq.h:18
double TMatacq::getsigBaseLine ( )
inline

Definition at line 65 of file TMatacq.h.

References sigbl.

Referenced by EcalMatacqAnalyzer::endJob().

65 {return sigbl;}
double sigbl
Definition: TMatacq.h:25
double TMatacq::getsigTimpeak ( )
inline

Definition at line 68 of file TMatacq.h.

References sigpkval.

Referenced by EcalMatacqAnalyzer::endJob().

68 {return sigpkval;}
double sigpkval
Definition: TMatacq.h:27
double TMatacq::getSlide ( )
inline

Definition at line 77 of file TMatacq.h.

References slidingmean.

Referenced by EcalMatacqAnalyzer::endJob().

77 {return slidingmean;}
double slidingmean
Definition: TMatacq.h:35
double TMatacq::getTimax ( )
inline

Definition at line 71 of file TMatacq.h.

References timeatmax.

Referenced by EcalMatacqAnalyzer::endJob().

71 {return timeatmax;}
double timeatmax
Definition: TMatacq.h:26
double TMatacq::getTimpeak ( )
inline

Definition at line 67 of file TMatacq.h.

References pkval.

Referenced by EcalMatacqAnalyzer::endJob().

67 {return pkval;}
double pkval
Definition: TMatacq.h:27
double TMatacq::getTrise ( )
inline

Definition at line 73 of file TMatacq.h.

References trise.

Referenced by EcalMatacqAnalyzer::endJob().

73 {return trise;}
double trise
Definition: TMatacq.h:28
double TMatacq::getWidth20 ( )
inline

Definition at line 75 of file TMatacq.h.

References width20.

Referenced by EcalMatacqAnalyzer::endJob().

75 {return width20;}
double width20
Definition: TMatacq.h:29
double TMatacq::getWidth80 ( )
inline

Definition at line 76 of file TMatacq.h.

References width80.

Referenced by EcalMatacqAnalyzer::endJob().

76 {return width80;}
double width80
Definition: TMatacq.h:29
void TMatacq::init ( )

Definition at line 17 of file TMatacq.cc.

References gen::k, NMAXSAMP, NSPARAB, reco::return(), and edmStreamStallGrapher::t.

18 {
19  for(int k=0;k<NMAXSAMP;k++)
20  bong[k]=0.;
21 
22  for(int k=0;k<=100;k++)
23  bing[k]=0;
24 
25  for(int k=0;k<NSPARAB;k++)
26  t[k]= (double) k;
27 
28  return ;
29 }
#define NMAXSAMP
Definition: TMatacq.h:6
double bong[NMAXSAMP]
Definition: TMatacq.h:22
int bing[101]
Definition: TMatacq.h:19
double t[NSPARAB]
Definition: TMatacq.h:23
int k[5][pyjets_maxn]
return(e1-e2)*(e1-e2)+dp *dp
#define NSPARAB
Definition: TMatacq.h:7
double TMatacq::interpolate ( double  amplx)
private

Definition at line 354 of file TMatacq.cc.

References gen::k, and slope.

355 {
356  double T;
357  int kmax= (int) pkval - firstsample;
358 
359  int bin_low=0;
360  for(Int_t k=0;k<kmax;k++)
361  if(0. < bong[k] && bong[k] < amplx) {
362  bin_low=k;
363  }
364  if(bin_low == 0) return -301.;
365  int bin_high=0;
366  for(Int_t k=kmax;k>=0;k--)
367  if(bong[k] > amplx) {
368  bin_high=k;
369  }
370  if(bin_high == 0) return -302.;
371  if(bin_high < bin_low) return -303.;
372 
373 
374  if(bin_low == bin_high) {
375  T= (double) bin_high;
376  } else {
377  double slope= (bong[bin_high]-bong[bin_low])/((double) (bin_high-bin_low));
378  T= (double) bin_high - (bong[bin_high] - amplx)/slope;
379  }
380 
381  return T;
382 }
double bong[NMAXSAMP]
Definition: TMatacq.h:22
static const double slope[3]
int k[5][pyjets_maxn]
double pkval
Definition: TMatacq.h:27
int firstsample
Definition: TMatacq.h:18
long double T
void TMatacq::printitermatacqData ( Int_t  ,
Int_t  ,
Int_t   
)

Definition at line 495 of file TMatacq.cc.

References lut2db_cfg::filename, i, NULL, mathSSE::sqrt(), contentValuesCheck::ss, and ntuplemaker::status.

496 {
497  FILE *fmatacq;
498  char filename[80];
499  int i;
500  double ss;
501  sprintf(filename,"runiterMatacq%d.pedestal",gRunNumber);
502  fmatacq = fopen(filename, "w");
503  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
504 
505  int nevmtqgood=0;
506  double sumtrise=0.; double sumtrise2=0.;
507  int timestop= timestart+3;
508  double mintrise=10000.;
509  double maxtrise=0.;
510  for(i=0;i<nevmtq0;i++) {
511  if(status[i] >= 0) {
512  nevmtqgood++;
513  if(comp_trise[i] > maxtrise) {
514  maxtrise=comp_trise[i];
515  }
516  if(comp_trise[i] < mintrise) {
517  mintrise= comp_trise[i];
518  }
519  sumtrise+=comp_trise[i];
520  sumtrise2+=comp_trise[i]*comp_trise[i];
521  }
522  }
523  meantrise= sumtrise/((double) nevmtqgood);
524  ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise);
525  if(ss < 0.) ss=0.;
526  sigtrise=sqrt(ss);
527  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
528  nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
529 
530  nevmtqgood=0;
531  sumtrise=0.; sumtrise2=0.;
532  mintrise=10000.;
533  maxtrise=0.;
534  for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) {
535  if(status[i] >= 0) {
536  nevmtqgood++;
537  if(comp_trise[i] > maxtrise) {
538  maxtrise=comp_trise[i];
539  }
540  if(comp_trise[i] < mintrise) {
541  mintrise= comp_trise[i];
542  }
543  sumtrise+=comp_trise[i];
544  sumtrise2+=comp_trise[i]*comp_trise[i];
545  }
546  }
547  meantrise= sumtrise/((double) nevmtqgood);
548  ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise);
549  if(ss < 0.) ss=0.;
550  sigtrise=sqrt(ss);
551  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
552  nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
553 
554  int iret=fclose(fmatacq);
555  printf(" Closing file : %d\n",iret);
556 }
int i
Definition: DBlmapReader.cc:9
double meantrise
Definition: TMatacq.h:30
int status[1200]
Definition: TMatacq.h:33
#define NULL
Definition: scimark2.h:8
T sqrt(T t)
Definition: SSEVec.h:48
double sigtrise
Definition: TMatacq.h:30
double comp_trise[1200]
Definition: TMatacq.h:34
tuple filename
Definition: lut2db_cfg.py:20
int nevmtq0
Definition: TMatacq.h:32
int nevmtq1
Definition: TMatacq.h:32
void TMatacq::printmatacqData ( Int_t  ,
Int_t  ,
Int_t   
)

Definition at line 413 of file TMatacq.cc.

References lut2db_cfg::filename, i, NULL, mathSSE::sqrt(), and contentValuesCheck::ss.

414 {
415  FILE *fmatacq;
416  char filename[80];
417  int i;
418  double ss;
419  sprintf(filename,"runMatacq%d.pedestal",gRunNumber);
420  fmatacq = fopen(filename, "w");
421  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
422 
423  double sumtrise=0.; double sumtrise2=0.;
424  int timestop= timestart+3;
425  double mintrise=10000.;
426  double maxtrise=0.;
427  for(i=0;i<nevmtq0;i++) {
428  if(comp_trise[i] > maxtrise) {
429  maxtrise=comp_trise[i];
430  }
431  if(comp_trise[i] < mintrise) {
432  mintrise= comp_trise[i];
433  }
434  sumtrise+=comp_trise[i];
435  sumtrise2+=comp_trise[i]*comp_trise[i];
436  }
437  meantrise= sumtrise/((double) nevmtq0);
438  ss= (sumtrise2/((double) nevmtq0) - meantrise*meantrise);
439  if(ss < 0.) ss=0.;
440  sigtrise=sqrt(ss);
441  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
442  nevmtq0,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
443 
444  sumtrise=0.; sumtrise2=0.;
445  mintrise=10000.;
446  maxtrise=0.;
447  for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) {
448  if(comp_trise[i] > maxtrise) {
449  maxtrise=comp_trise[i];
450  }
451  if(comp_trise[i] < mintrise) {
452  mintrise= comp_trise[i];
453  }
454  sumtrise+=comp_trise[i];
455  sumtrise2+=comp_trise[i]*comp_trise[i];
456  }
457  meantrise= sumtrise/((double) nevmtq1);
458  ss= (sumtrise2/((double) nevmtq1) - meantrise*meantrise);
459  if(ss < 0.) ss=0.;
460  sigtrise=sqrt(ss);
461  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
462  nevmtq1,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
463 
464  int iret=fclose(fmatacq);
465  printf(" Closing file : %d\n",iret);
466 }
int i
Definition: DBlmapReader.cc:9
double meantrise
Definition: TMatacq.h:30
#define NULL
Definition: scimark2.h:8
T sqrt(T t)
Definition: SSEVec.h:48
double sigtrise
Definition: TMatacq.h:30
double comp_trise[1200]
Definition: TMatacq.h:34
tuple filename
Definition: lut2db_cfg.py:20
int nevmtq0
Definition: TMatacq.h:32
int nevmtq1
Definition: TMatacq.h:32
int TMatacq::rawPulseAnalysis ( Int_t  Nsamp,
Double_t *  adc 
)

Definition at line 59 of file TMatacq.cc.

References i, init, gen::k, NMAXSAMP, mathSSE::sqrt(), and contentValuesCheck::ss.

Referenced by EcalMatacqAnalyzer::endJob().

60 {
61  using namespace std;
62 
63  // std::cout << "Entering rawPulseAnalysis" << std::endl;
64 
65  int k,ithr;
66  double dsum=0.,dsum2=0.;
67 
68  // std::cout << "calling init" << std::endl;
69  init();
70  // std::cout << ".......done" << std::endl;
71 
72  if(Nsamp != fNsamples) {
73  printf("found different number of samples fNsamples=%d Nsamp=%d\n",fNsamples,Nsamp);
74  return 100;
75  }
76 
77  for(k=0;k<presample;k++) {
78  dsum+= adc[k];
79  dsum2+= adc[k]*adc[k];
80  }
81  bl=dsum/((double) presample);
82  double ss= (dsum2/((double) presample)-bl*bl);
83  if(ss<0.) ss=0.;
84  sigbl=sqrt(ss);
85  for(ithr=0,k=presample;k<endsample;k++) {
86  if(adc[k] > (bl+nsigcut*sigbl) && ithr == 0) {
87  ithr=1; firstsample=k;
88  }
89  }
90 
91  if(ithr == 0) return 101;
92 
93  for(ithr=0,k=firstsample;k<Nsamp;k++) {
94  if(adc[k] < (bl+nsigcut*sigbl) && ithr == 0) {
95  ithr=1; lastsample=k;
96  }
97  }
98  if(ithr == 0) lastsample= Nsamp;
99 
101 
102  val_max=0.; samplemax=0;
103  for (Int_t is=firstsample;is<lastsample;is++) {
104  bong[is-firstsample]= adc[is] - bl;
105  if(bong[is-firstsample] > val_max) {
107  }
108  }
109  if(samplemax == 0) return 103;
110  if(samplemax > lastsample) return 104;
111  if(samplemax < firstsample) return 105;
112 
113 
114  int endslide=samplemax -nslide;
115  int beginslide=nslide;
116  int islidingmean=0;
117  slidingmean=0.0;
118 
119  for(int i=beginslide;i<endslide;i++) {
120  slidingmean+= adc[i];
121  islidingmean+=1;
122  }
123  if( islidingmean!=0) slidingmean/=double(islidingmean);
124 
125  return 0;
126 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
#define NMAXSAMP
Definition: TMatacq.h:6
double bong[NMAXSAMP]
Definition: TMatacq.h:22
int endsample
Definition: TMatacq.h:18
double sigbl
Definition: TMatacq.h:25
double bl
Definition: TMatacq.h:25
int samplemax
Definition: TMatacq.h:18
double val_max
Definition: TMatacq.h:25
void init()
Definition: TMatacq.cc:17
double nsigcut
Definition: TMatacq.h:20
int nslide
Definition: TMatacq.h:36
T sqrt(T t)
Definition: SSEVec.h:48
int fNsamples
Definition: TMatacq.h:14
double slidingmean
Definition: TMatacq.h:35
int k[5][pyjets_maxn]
int firstsample
Definition: TMatacq.h:18
int lastsample
Definition: TMatacq.h:18
int presample
Definition: TMatacq.h:18

Member Data Documentation

double TMatacq::ampl
private

Definition at line 26 of file TMatacq.h.

Referenced by getAmpl().

int TMatacq::bing[101]
private

Definition at line 19 of file TMatacq.h.

double TMatacq::bl
private

Definition at line 25 of file TMatacq.h.

Referenced by getBaseLine().

double TMatacq::bong[NMAXSAMP]
private

Definition at line 22 of file TMatacq.h.

double TMatacq::comp_peak[1200]
private

Definition at line 34 of file TMatacq.h.

double TMatacq::comp_trise[1200]
private

Definition at line 34 of file TMatacq.h.

int TMatacq::endsample
private

Definition at line 18 of file TMatacq.h.

int TMatacq::firstsample
private

Definition at line 18 of file TMatacq.h.

Referenced by getPt1().

int TMatacq::fNsamples
private

Definition at line 14 of file TMatacq.h.

int TMatacq::fNum_samp_aft_max
private

Definition at line 16 of file TMatacq.h.

int TMatacq::fNum_samp_bef_max
private

Definition at line 15 of file TMatacq.h.

double TMatacq::fv1[NSPARAB]
private

Definition at line 24 of file TMatacq.h.

double TMatacq::fv2[NSPARAB]
private

Definition at line 24 of file TMatacq.h.

double TMatacq::fv3[NSPARAB]
private

Definition at line 24 of file TMatacq.h.

int TMatacq::lastsample
private

Definition at line 18 of file TMatacq.h.

Referenced by getPt2().

double TMatacq::level1
private

Definition at line 21 of file TMatacq.h.

double TMatacq::level2
private

Definition at line 21 of file TMatacq.h.

double TMatacq::level3
private

Definition at line 21 of file TMatacq.h.

double TMatacq::meantrise
private

Definition at line 30 of file TMatacq.h.

int TMatacq::nevlasers
private

Definition at line 32 of file TMatacq.h.

int TMatacq::nevmtq0
private

Definition at line 32 of file TMatacq.h.

int TMatacq::nevmtq1
private

Definition at line 32 of file TMatacq.h.

double TMatacq::nsigcut
private

Definition at line 20 of file TMatacq.h.

int TMatacq::nslide
private

Definition at line 36 of file TMatacq.h.

double TMatacq::pkval
private

Definition at line 27 of file TMatacq.h.

Referenced by getTimpeak().

int TMatacq::presample
private

Definition at line 18 of file TMatacq.h.

int TMatacq::samplemax
private

Definition at line 18 of file TMatacq.h.

Referenced by getPtm().

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

Definition at line 30 of file TMatacq.h.

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

Definition at line 23 of file TMatacq.h.

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

Definition at line 23 of file TMatacq.h.

double TMatacq::val_max
private

Definition at line 25 of file TMatacq.h.

double TMatacq::width20
private

Definition at line 29 of file TMatacq.h.

Referenced by getWidth20().

double TMatacq::width50
private

Definition at line 29 of file TMatacq.h.

Referenced by getFwhm().

double TMatacq::width80
private

Definition at line 29 of file TMatacq.h.

Referenced by getWidth80().