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

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

34 {
35  fNsamples= Ntot;
36  presample= Nsamp1;
37  endsample= Nsamp2;
38  nsigcut= (double) cut;
39  fNum_samp_bef_max= Nbef;
40  fNum_samp_aft_max= Naft;
41  level1= ((double) niv1)/100.;
42  level2= ((double) niv2)/100.;
43  level3= ((double) niv3)/100.;
44  nevlasers= nevl;
45  slidingmean=0.0;
46  nslide=NSlide;
47  for(int k=0;k<nevlasers;k++)
48  status[k]=0;
49  for(int k=0;k<nevlasers;k++)
50  status[k+nevlasers]=0;
51 
52  nevmtq0=0; nevmtq1=0;
53 }
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 56 of file TMatacq.cc.

57 {
58 }

Member Function Documentation

int TMatacq::compute_trise ( )

Definition at line 331 of file TMatacq.cc.

References error.

Referenced by EcalMatacqAnalyzer::endJob().

332 {
333  int error;
334  trise= 0.;
335 
336  double t20= interpolate(ampl*level2);
337  if(t20 < 0.) {
338  error= (int) -t20;
339  return error;
340  }
341  double t80= interpolate(ampl*level3);
342  if(t80 < 0.) {
343  error= (int) -t80;
344  return error;
345  }
346  trise= t80 - t20;
347 
348  return 0;
349 }
double trise
Definition: TMatacq.h:28
double interpolate(double)
Definition: TMatacq.cc:355
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 469 of file TMatacq.cc.

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

470 {
471  FILE *fmatacq;
472  char filename[80];
473  sprintf(filename,"badevtsMatacq%d.dat",gRunNumber);
474  fmatacq = fopen(filename, "w");
475  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
476 
477  int nevbad=0;
478  for(Int_t i=0;i<nevmtq0+nevmtq1;i++) {
479  if(comp_trise[i] < meantrise - 3.*sigtrise) {
480  nevbad++;
481  fprintf(fmatacq,"%d \n",status[i]);
482  status[i]=-1;
483  }
484  if(comp_trise[i] > meantrise + 3.*sigtrise) {
485  nevbad++;
486  fprintf(fmatacq,"%d \n",status[i]);
487  status[i]=-1;
488  }
489  }
490 
491  int iret=fclose(fmatacq);
492  printf(" Closing file : %d\n",iret);
493  return nevbad;
494 }
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 202 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().

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

References ntuplemaker::status.

386 {
387  if(anevt < 2*nevlasers) {
388  if(anevt < nevlasers) {
389  nevmtq0++;
390  status[nevmtq0-1]= anevt;
392  comp_peak[nevmtq0-1]= pkval;
393  } else {
394  nevmtq1++;
395  status[nevmtq0+nevmtq1-1]= anevt;
398  }
399  } else {
400  if(anevt < 3*nevlasers) {
401  nevmtq0++;
402  status[nevmtq0-1]= anevt;
404  comp_peak[nevmtq0-1]= pkval;
405  } else {
406  nevmtq1++;
407  status[nevmtq0+nevmtq1-1]= anevt;
410  }
411  }
412 }
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 128 of file TMatacq.cc.

References gen::k, and NMAXSAMP.

Referenced by EcalMatacqAnalyzer::endJob().

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

References gen::k, NMAXSAMP, NSPARAB, hitfit::return, and lumiQTWidget::t.

19 {
20  for(int k=0;k<NMAXSAMP;k++)
21  bong[k]=0.;
22 
23  for(int k=0;k<=100;k++)
24  bing[k]=0;
25 
26  for(int k=0;k<NSPARAB;k++)
27  t[k]= (double) k;
28 
29  return ;
30 }
#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]
#define NSPARAB
Definition: TMatacq.h:7
double TMatacq::interpolate ( double  amplx)
private

Definition at line 355 of file TMatacq.cc.

References gen::k, and slope.

356 {
357  double T;
358  int kmax= (int) pkval - firstsample;
359 
360  int bin_low=0;
361  for(Int_t k=0;k<kmax;k++)
362  if(0. < bong[k] && bong[k] < amplx) {
363  bin_low=k;
364  }
365  if(bin_low == 0) return -301.;
366  int bin_high=0;
367  for(Int_t k=kmax;k>=0;k--)
368  if(bong[k] > amplx) {
369  bin_high=k;
370  }
371  if(bin_high == 0) return -302.;
372  if(bin_high < bin_low) return -303.;
373 
374 
375  if(bin_low == bin_high) {
376  T= (double) bin_high;
377  } else {
378  double slope= (bong[bin_high]-bong[bin_low])/((double) (bin_high-bin_low));
379  T= (double) bin_high - (bong[bin_high] - amplx)/slope;
380  }
381 
382  return T;
383 }
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 496 of file TMatacq.cc.

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

497 {
498  FILE *fmatacq;
499  char filename[80];
500  int i;
501  double ss;
502  sprintf(filename,"runiterMatacq%d.pedestal",gRunNumber);
503  fmatacq = fopen(filename, "w");
504  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
505 
506  int nevmtqgood=0;
507  double sumtrise=0.; double sumtrise2=0.;
508  int timestop= timestart+3;
509  double mintrise=10000.;
510  double maxtrise=0.;
511  for(i=0;i<nevmtq0;i++) {
512  if(status[i] >= 0) {
513  nevmtqgood++;
514  if(comp_trise[i] > maxtrise) {
515  maxtrise=comp_trise[i];
516  }
517  if(comp_trise[i] < mintrise) {
518  mintrise= comp_trise[i];
519  }
520  sumtrise+=comp_trise[i];
521  sumtrise2+=comp_trise[i]*comp_trise[i];
522  }
523  }
524  meantrise= sumtrise/((double) nevmtqgood);
525  ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise);
526  if(ss < 0.) ss=0.;
527  sigtrise=sqrt(ss);
528  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
529  nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
530 
531  nevmtqgood=0;
532  sumtrise=0.; sumtrise2=0.;
533  mintrise=10000.;
534  maxtrise=0.;
535  for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) {
536  if(status[i] >= 0) {
537  nevmtqgood++;
538  if(comp_trise[i] > maxtrise) {
539  maxtrise=comp_trise[i];
540  }
541  if(comp_trise[i] < mintrise) {
542  mintrise= comp_trise[i];
543  }
544  sumtrise+=comp_trise[i];
545  sumtrise2+=comp_trise[i]*comp_trise[i];
546  }
547  }
548  meantrise= sumtrise/((double) nevmtqgood);
549  ss= (sumtrise2/((double) nevmtqgood) - meantrise*meantrise);
550  if(ss < 0.) ss=0.;
551  sigtrise=sqrt(ss);
552  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
553  nevmtqgood,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
554 
555  int iret=fclose(fmatacq);
556  printf(" Closing file : %d\n",iret);
557 }
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 414 of file TMatacq.cc.

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

415 {
416  FILE *fmatacq;
417  char filename[80];
418  int i;
419  double ss;
420  sprintf(filename,"runMatacq%d.pedestal",gRunNumber);
421  fmatacq = fopen(filename, "w");
422  if(fmatacq == NULL) printf("Error while opening file : %s\n",filename);
423 
424  double sumtrise=0.; double sumtrise2=0.;
425  int timestop= timestart+3;
426  double mintrise=10000.;
427  double maxtrise=0.;
428  for(i=0;i<nevmtq0;i++) {
429  if(comp_trise[i] > maxtrise) {
430  maxtrise=comp_trise[i];
431  }
432  if(comp_trise[i] < mintrise) {
433  mintrise= comp_trise[i];
434  }
435  sumtrise+=comp_trise[i];
436  sumtrise2+=comp_trise[i]*comp_trise[i];
437  }
438  meantrise= sumtrise/((double) nevmtq0);
439  ss= (sumtrise2/((double) nevmtq0) - meantrise*meantrise);
440  if(ss < 0.) ss=0.;
441  sigtrise=sqrt(ss);
442  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
443  nevmtq0,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
444 
445  sumtrise=0.; sumtrise2=0.;
446  mintrise=10000.;
447  maxtrise=0.;
448  for(i=nevmtq0;i<nevmtq0+nevmtq1;i++) {
449  if(comp_trise[i] > maxtrise) {
450  maxtrise=comp_trise[i];
451  }
452  if(comp_trise[i] < mintrise) {
453  mintrise= comp_trise[i];
454  }
455  sumtrise+=comp_trise[i];
456  sumtrise2+=comp_trise[i]*comp_trise[i];
457  }
458  meantrise= sumtrise/((double) nevmtq1);
459  ss= (sumtrise2/((double) nevmtq1) - meantrise*meantrise);
460  if(ss < 0.) ss=0.;
461  sigtrise=sqrt(ss);
462  fprintf(fmatacq, "%d %d %d %d %f %f %f %f\n",
463  nevmtq1,color,timestart,timestop,meantrise,sigtrise,mintrise,maxtrise);
464 
465  int iret=fclose(fmatacq);
466  printf(" Closing file : %d\n",iret);
467 }
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 60 of file TMatacq.cc.

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

Referenced by EcalMatacqAnalyzer::endJob().

61 {
62  using namespace std;
63 
64  // std::cout << "Entering rawPulseAnalysis" << std::endl;
65 
66  int k,ithr;
67  double dsum=0.,dsum2=0.;
68 
69  // std::cout << "calling init" << std::endl;
70  init();
71  // std::cout << ".......done" << std::endl;
72 
73  if(Nsamp != fNsamples) {
74  printf("found different number of samples fNsamples=%d Nsamp=%d\n",fNsamples,Nsamp);
75  return 100;
76  }
77 
78  for(k=0;k<presample;k++) {
79  dsum+= adc[k];
80  dsum2+= adc[k]*adc[k];
81  }
82  bl=dsum/((double) presample);
83  double ss= (dsum2/((double) presample)-bl*bl);
84  if(ss<0.) ss=0.;
85  sigbl=sqrt(ss);
86  for(ithr=0,k=presample;k<endsample;k++) {
87  if(adc[k] > (bl+nsigcut*sigbl) && ithr == 0) {
88  ithr=1; firstsample=k;
89  }
90  }
91 
92  if(ithr == 0) return 101;
93 
94  for(ithr=0,k=firstsample;k<Nsamp;k++) {
95  if(adc[k] < (bl+nsigcut*sigbl) && ithr == 0) {
96  ithr=1; lastsample=k;
97  }
98  }
99  if(ithr == 0) lastsample= Nsamp;
100 
102 
103  val_max=0.; samplemax=0;
104  for (Int_t is=firstsample;is<lastsample;is++) {
105  bong[is-firstsample]= adc[is] - bl;
106  if(bong[is-firstsample] > val_max) {
108  }
109  }
110  if(samplemax == 0) return 103;
111  if(samplemax > lastsample) return 104;
112  if(samplemax < firstsample) return 105;
113 
114 
115  int endslide=samplemax -nslide;
116  int beginslide=nslide;
117  int islidingmean=0;
118  slidingmean=0.0;
119 
120  for(int i=beginslide;i<endslide;i++) {
121  slidingmean+= adc[i];
122  islidingmean+=1;
123  }
124  if( islidingmean!=0) slidingmean/=double(islidingmean);
125 
126  return 0;
127 }
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:18
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().