CMS 3D CMS Logo

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)
 
 ~TMatacq () override
 

Private Member Functions

double interpolate (double)
 

Private Attributes

double ampl
 
int bing [101]
 
double bl
 
double bong [100]
 
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 [16]
 
double fv2 [16]
 
double fv3 [16]
 
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 [16]
 
double timeatmax
 
double trise
 
double val [16]
 
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 31 of file TMatacq.cc.

References dqmdumpme::k, and mps_update::status.

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

Definition at line 55 of file TMatacq.cc.

55 {}

Member Function Documentation

int TMatacq::compute_trise ( )

Definition at line 353 of file TMatacq.cc.

References relativeConstraints::error, createfilelist::int, and HiCaloJetParameters_cff::interpolate.

Referenced by EcalMatacqAnalyzer::endJob().

353  {
354  int error;
355  trise = 0.;
356 
357  double t20 = interpolate(ampl * level2);
358  if (t20 < 0.) {
359  error = (int)-t20;
360  return error;
361  }
362  double t80 = interpolate(ampl * level3);
363  if (t80 < 0.) {
364  error = (int)-t80;
365  return error;
366  }
367  trise = t80 - t20;
368 
369  return 0;
370 }
double trise
Definition: TMatacq.h:25
double interpolate(double)
Definition: TMatacq.cc:372
double level2
Definition: TMatacq.h:18
double ampl
Definition: TMatacq.h:23
double level3
Definition: TMatacq.h:18
int TMatacq::countBadPulses ( Int_t  )

Definition at line 490 of file TMatacq.cc.

References corrVsCorr::filename, mps_fire::i, and mps_update::status.

490  {
491  FILE *fmatacq;
492  char filename[80];
493  sprintf(filename, "badevtsMatacq%d.dat", gRunNumber);
494  fmatacq = fopen(filename, "w");
495  if (fmatacq == nullptr)
496  printf("Error while opening file : %s\n", filename);
497 
498  int nevbad = 0;
499  for (Int_t i = 0; i < nevmtq0 + nevmtq1; i++) {
500  if (comp_trise[i] < meantrise - 3. * sigtrise) {
501  nevbad++;
502  fprintf(fmatacq, "%d \n", status[i]);
503  status[i] = -1;
504  }
505  if (comp_trise[i] > meantrise + 3. * sigtrise) {
506  nevbad++;
507  fprintf(fmatacq, "%d \n", status[i]);
508  status[i] = -1;
509  }
510  }
511 
512  int iret = fclose(fmatacq);
513  printf(" Closing file : %d\n", iret);
514  return nevbad;
515 }
double meantrise
Definition: TMatacq.h:27
int status[1200]
Definition: TMatacq.h:30
double sigtrise
Definition: TMatacq.h:27
double comp_trise[1200]
Definition: TMatacq.h:31
int nevmtq0
Definition: TMatacq.h:29
int nevmtq1
Definition: TMatacq.h:29
int TMatacq::doFit ( )

Definition at line 219 of file TMatacq.cc.

References a, b, HltBtagPostValidation_cff::c, DeadROC_duringRun::f1, DeadROC_duringRun::f2, mps_fire::i, dqmiolumiharvest::j, NSPARAB, heppy_batch::val, and ApeEstimator_cff::width.

Referenced by EcalMatacqAnalyzer::endJob().

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

Definition at line 403 of file TMatacq.cc.

References mps_update::status.

403  {
404  if (anevt < 2 * nevlasers) {
405  if (anevt < nevlasers) {
406  nevmtq0++;
407  status[nevmtq0 - 1] = anevt;
408  comp_trise[nevmtq0 - 1] = trise;
409  comp_peak[nevmtq0 - 1] = pkval;
410  } else {
411  nevmtq1++;
412  status[nevmtq0 + nevmtq1 - 1] = anevt;
413  comp_trise[nevmtq0 + nevmtq1 - 1] = trise;
414  comp_peak[nevmtq0 + nevmtq1 - 1] = pkval;
415  }
416  } else {
417  if (anevt < 3 * nevlasers) {
418  nevmtq0++;
419  status[nevmtq0 - 1] = anevt;
420  comp_trise[nevmtq0 - 1] = trise;
421  comp_peak[nevmtq0 - 1] = pkval;
422  } else {
423  nevmtq1++;
424  status[nevmtq0 + nevmtq1 - 1] = anevt;
425  comp_trise[nevmtq0 + nevmtq1 - 1] = trise;
426  comp_peak[nevmtq0 + nevmtq1 - 1] = pkval;
427  }
428  }
429 }
double trise
Definition: TMatacq.h:25
int status[1200]
Definition: TMatacq.h:30
double comp_peak[1200]
Definition: TMatacq.h:31
double pkval
Definition: TMatacq.h:24
double comp_trise[1200]
Definition: TMatacq.h:31
int nevlasers
Definition: TMatacq.h:29
int nevmtq0
Definition: TMatacq.h:29
int nevmtq1
Definition: TMatacq.h:29
int TMatacq::findPeak ( )

Definition at line 136 of file TMatacq.cc.

References TMarkov::getPeakValue(), createfilelist::int, dqmdumpme::k, NMAXSAMP, and TMarkov::peakFinder().

Referenced by EcalMatacqAnalyzer::endJob().

136  {
137  int k;
138  int nbinf = 0;
139  int jfind = 0;
140  int nbsup = 0;
141  double thres = val_max * level1;
142 
143  for (k = 0, jfind = 0; k < NMAXSAMP; k++) {
144  if (jfind == 0) {
145  if (bong[k] > thres) {
146  nbinf = k;
147  jfind = 1;
148  }
149  }
150  }
151  if (jfind == 0)
152  nbinf = 0;
153 
154  for (k = NMAXSAMP, jfind = 0; k > nbinf; k--) {
155  if (jfind == 0) {
156  if (bong[k] > thres) {
157  nbsup = k;
158  jfind = 1;
159  }
160  }
161  }
162  if (nbsup == 0)
163  nbsup = nbinf;
164 
165  double sumpkval = 1.;
166  pkval = 0.;
167  sigpkval = 0.5;
168  if (nbsup == nbinf) {
169  return 301;
170  } else {
171  if (nbinf > 4)
172  nbinf -= 3;
173  else
174  nbinf = 1;
175  if (nbsup < NMAXSAMP - 4)
176  nbsup += 3;
177  else
178  nbsup = NMAXSAMP;
179 
180  for (k = 0; k < nbinf; k++)
181  bong[k] = 0.;
182  for (k = nbsup; k < NMAXSAMP; k++)
183  bong[k] = 0.;
184 
185  for (k = 0, jfind = 0; k < NMAXSAMP; k++) {
186  if (bong[k] > 0.)
187  jfind++;
188  }
189  if (jfind == 0) {
190  return 302;
191  } else if (jfind == 1) {
192  return 303;
193  } else {
194  for (k = 0; k < NMAXSAMP; k++) {
195  if (k < 100)
196  bing[k + 1] = (int)bong[k];
197  }
198 
199  TMarkov *peak = new TMarkov();
200 
201  peak->peakFinder(&bing[0]);
202  pkval = peak->getPeakValue(0);
203  sigpkval = peak->getPeakValue(1);
204 
205  delete peak;
206 
207  sumpkval = 0.0;
208 
209  if (sumpkval > 1000.)
210  sumpkval = 10.;
211 
212  pkval += (firstsample - 1);
213  }
214  }
215 
216  return 0;
217 }
double getPeakValue(int i) const
Definition: TMarkov.h:24
#define NMAXSAMP
Definition: TMatacq.h:6
double bong[100]
Definition: TMatacq.h:19
int bing[101]
Definition: TMatacq.h:16
double val_max
Definition: TMatacq.h:22
double level1
Definition: TMatacq.h:18
Definition: TMarkov.h:6
void peakFinder(int *)
Definition: TMarkov.cc:105
double pkval
Definition: TMatacq.h:24
double sigpkval
Definition: TMatacq.h:24
int firstsample
Definition: TMatacq.h:15
double TMatacq::getAmpl ( )
inline

Definition at line 67 of file TMatacq.h.

References ampl.

Referenced by EcalMatacqAnalyzer::endJob().

67 { return ampl; }
double ampl
Definition: TMatacq.h:23
double TMatacq::getBaseLine ( )
inline

Definition at line 61 of file TMatacq.h.

References bl.

Referenced by EcalMatacqAnalyzer::endJob().

61 { return bl; }
double bl
Definition: TMatacq.h:22
double TMatacq::getFwhm ( )
inline

Definition at line 71 of file TMatacq.h.

References width50.

Referenced by EcalMatacqAnalyzer::endJob().

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

Definition at line 57 of file TMatacq.h.

References firstsample.

57 { return firstsample; }
int firstsample
Definition: TMatacq.h:15
int TMatacq::getPt2 ( )
inline

Definition at line 58 of file TMatacq.h.

References lastsample.

58 { return lastsample; }
int lastsample
Definition: TMatacq.h:15
int TMatacq::getPtm ( )
inline

Definition at line 59 of file TMatacq.h.

References samplemax.

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

Definition at line 62 of file TMatacq.h.

References sigbl.

Referenced by EcalMatacqAnalyzer::endJob().

62 { return sigbl; }
double sigbl
Definition: TMatacq.h:22
double TMatacq::getsigTimpeak ( )
inline

Definition at line 65 of file TMatacq.h.

References sigpkval.

Referenced by EcalMatacqAnalyzer::endJob().

65 { return sigpkval; }
double sigpkval
Definition: TMatacq.h:24
double TMatacq::getSlide ( )
inline

Definition at line 74 of file TMatacq.h.

References slidingmean.

Referenced by EcalMatacqAnalyzer::endJob().

74 { return slidingmean; }
double slidingmean
Definition: TMatacq.h:32
double TMatacq::getTimax ( )
inline

Definition at line 68 of file TMatacq.h.

References timeatmax.

Referenced by EcalMatacqAnalyzer::endJob().

68 { return timeatmax; }
double timeatmax
Definition: TMatacq.h:23
double TMatacq::getTimpeak ( )
inline

Definition at line 64 of file TMatacq.h.

References pkval.

Referenced by EcalMatacqAnalyzer::endJob().

64 { return pkval; }
double pkval
Definition: TMatacq.h:24
double TMatacq::getTrise ( )
inline

Definition at line 70 of file TMatacq.h.

References trise.

Referenced by EcalMatacqAnalyzer::endJob().

70 { return trise; }
double trise
Definition: TMatacq.h:25
double TMatacq::getWidth20 ( )
inline

Definition at line 72 of file TMatacq.h.

References width20.

Referenced by EcalMatacqAnalyzer::endJob().

72 { return width20; }
double width20
Definition: TMatacq.h:26
double TMatacq::getWidth80 ( )
inline

Definition at line 73 of file TMatacq.h.

References width80.

Referenced by EcalMatacqAnalyzer::endJob().

73 { return width80; }
double width80
Definition: TMatacq.h:26
void TMatacq::init ( )

Definition at line 17 of file TMatacq.cc.

References dqmdumpme::k, NMAXSAMP, NSPARAB, and OrderedSet::t.

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

Definition at line 372 of file TMatacq.cc.

References createfilelist::int, dqmdumpme::k, and slope.

372  {
373  double T;
374  int kmax = (int)pkval - firstsample;
375 
376  int bin_low = 0;
377  for (Int_t k = 0; k < kmax; k++)
378  if (0. < bong[k] && bong[k] < amplx) {
379  bin_low = k;
380  }
381  if (bin_low == 0)
382  return -301.;
383  int bin_high = 0;
384  for (Int_t k = kmax; k >= 0; k--)
385  if (bong[k] > amplx) {
386  bin_high = k;
387  }
388  if (bin_high == 0)
389  return -302.;
390  if (bin_high < bin_low)
391  return -303.;
392 
393  if (bin_low == bin_high) {
394  T = (double)bin_high;
395  } else {
396  double slope = (bong[bin_high] - bong[bin_low]) / ((double)(bin_high - bin_low));
397  T = (double)bin_high - (bong[bin_high] - amplx) / slope;
398  }
399 
400  return T;
401 }
double bong[100]
Definition: TMatacq.h:19
static const double slope[3]
double pkval
Definition: TMatacq.h:24
int firstsample
Definition: TMatacq.h:15
long double T
void TMatacq::printitermatacqData ( Int_t  ,
Int_t  ,
Int_t   
)

Definition at line 517 of file TMatacq.cc.

References corrVsCorr::filename, mps_fire::i, mathSSE::sqrt(), contentValuesCheck::ss, and mps_update::status.

517  {
518  FILE *fmatacq;
519  char filename[80];
520  int i;
521  double ss;
522  sprintf(filename, "runiterMatacq%d.pedestal", gRunNumber);
523  fmatacq = fopen(filename, "w");
524  if (fmatacq == nullptr)
525  printf("Error while opening file : %s\n", filename);
526 
527  int nevmtqgood = 0;
528  double sumtrise = 0.;
529  double sumtrise2 = 0.;
530  int timestop = timestart + 3;
531  double mintrise = 10000.;
532  double maxtrise = 0.;
533  for (i = 0; i < nevmtq0; i++) {
534  if (status[i] >= 0) {
535  nevmtqgood++;
536  if (comp_trise[i] > maxtrise) {
537  maxtrise = comp_trise[i];
538  }
539  if (comp_trise[i] < mintrise) {
540  mintrise = comp_trise[i];
541  }
542  sumtrise += comp_trise[i];
543  sumtrise2 += comp_trise[i] * comp_trise[i];
544  }
545  }
546  meantrise = sumtrise / ((double)nevmtqgood);
547  ss = (sumtrise2 / ((double)nevmtqgood) - meantrise * meantrise);
548  if (ss < 0.)
549  ss = 0.;
550  sigtrise = sqrt(ss);
551  fprintf(fmatacq,
552  "%d %d %d %d %f %f %f %f\n",
553  nevmtqgood,
554  color,
555  timestart,
556  timestop,
557  meantrise,
558  sigtrise,
559  mintrise,
560  maxtrise);
561 
562  nevmtqgood = 0;
563  sumtrise = 0.;
564  sumtrise2 = 0.;
565  mintrise = 10000.;
566  maxtrise = 0.;
567  for (i = nevmtq0; i < nevmtq0 + nevmtq1; i++) {
568  if (status[i] >= 0) {
569  nevmtqgood++;
570  if (comp_trise[i] > maxtrise) {
571  maxtrise = comp_trise[i];
572  }
573  if (comp_trise[i] < mintrise) {
574  mintrise = comp_trise[i];
575  }
576  sumtrise += comp_trise[i];
577  sumtrise2 += comp_trise[i] * comp_trise[i];
578  }
579  }
580  meantrise = sumtrise / ((double)nevmtqgood);
581  ss = (sumtrise2 / ((double)nevmtqgood) - meantrise * meantrise);
582  if (ss < 0.)
583  ss = 0.;
584  sigtrise = sqrt(ss);
585  fprintf(fmatacq,
586  "%d %d %d %d %f %f %f %f\n",
587  nevmtqgood,
588  color,
589  timestart,
590  timestop,
591  meantrise,
592  sigtrise,
593  mintrise,
594  maxtrise);
595 
596  int iret = fclose(fmatacq);
597  printf(" Closing file : %d\n", iret);
598 }
double meantrise
Definition: TMatacq.h:27
int status[1200]
Definition: TMatacq.h:30
T sqrt(T t)
Definition: SSEVec.h:19
double sigtrise
Definition: TMatacq.h:27
double comp_trise[1200]
Definition: TMatacq.h:31
int nevmtq0
Definition: TMatacq.h:29
int nevmtq1
Definition: TMatacq.h:29
void TMatacq::printmatacqData ( Int_t  ,
Int_t  ,
Int_t   
)

Definition at line 431 of file TMatacq.cc.

References corrVsCorr::filename, mps_fire::i, mathSSE::sqrt(), and contentValuesCheck::ss.

431  {
432  FILE *fmatacq;
433  char filename[80];
434  int i;
435  double ss;
436  sprintf(filename, "runMatacq%d.pedestal", gRunNumber);
437  fmatacq = fopen(filename, "w");
438  if (fmatacq == nullptr)
439  printf("Error while opening file : %s\n", filename);
440 
441  double sumtrise = 0.;
442  double sumtrise2 = 0.;
443  int timestop = timestart + 3;
444  double mintrise = 10000.;
445  double maxtrise = 0.;
446  for (i = 0; i < nevmtq0; i++) {
447  if (comp_trise[i] > maxtrise) {
448  maxtrise = comp_trise[i];
449  }
450  if (comp_trise[i] < mintrise) {
451  mintrise = comp_trise[i];
452  }
453  sumtrise += comp_trise[i];
454  sumtrise2 += comp_trise[i] * comp_trise[i];
455  }
456  meantrise = sumtrise / ((double)nevmtq0);
457  ss = (sumtrise2 / ((double)nevmtq0) - meantrise * meantrise);
458  if (ss < 0.)
459  ss = 0.;
460  sigtrise = sqrt(ss);
461  fprintf(
462  fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtq0, color, timestart, timestop, meantrise, sigtrise, mintrise, maxtrise);
463 
464  sumtrise = 0.;
465  sumtrise2 = 0.;
466  mintrise = 10000.;
467  maxtrise = 0.;
468  for (i = nevmtq0; i < nevmtq0 + nevmtq1; i++) {
469  if (comp_trise[i] > maxtrise) {
470  maxtrise = comp_trise[i];
471  }
472  if (comp_trise[i] < mintrise) {
473  mintrise = comp_trise[i];
474  }
475  sumtrise += comp_trise[i];
476  sumtrise2 += comp_trise[i] * comp_trise[i];
477  }
478  meantrise = sumtrise / ((double)nevmtq1);
479  ss = (sumtrise2 / ((double)nevmtq1) - meantrise * meantrise);
480  if (ss < 0.)
481  ss = 0.;
482  sigtrise = sqrt(ss);
483  fprintf(
484  fmatacq, "%d %d %d %d %f %f %f %f\n", nevmtq1, color, timestart, timestop, meantrise, sigtrise, mintrise, maxtrise);
485 
486  int iret = fclose(fmatacq);
487  printf(" Closing file : %d\n", iret);
488 }
double meantrise
Definition: TMatacq.h:27
T sqrt(T t)
Definition: SSEVec.h:19
double sigtrise
Definition: TMatacq.h:27
double comp_trise[1200]
Definition: TMatacq.h:31
int nevmtq0
Definition: TMatacq.h:29
int nevmtq1
Definition: TMatacq.h:29
int TMatacq::rawPulseAnalysis ( Int_t  Nsamp,
Double_t *  adc 
)

Definition at line 57 of file TMatacq.cc.

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

Referenced by EcalMatacqAnalyzer::endJob().

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

Member Data Documentation

double TMatacq::ampl
private

Definition at line 23 of file TMatacq.h.

Referenced by getAmpl().

int TMatacq::bing[101]
private

Definition at line 16 of file TMatacq.h.

double TMatacq::bl
private

Definition at line 22 of file TMatacq.h.

Referenced by getBaseLine().

double TMatacq::bong[100]
private

Definition at line 19 of file TMatacq.h.

double TMatacq::comp_peak[1200]
private

Definition at line 31 of file TMatacq.h.

double TMatacq::comp_trise[1200]
private

Definition at line 31 of file TMatacq.h.

int TMatacq::endsample
private

Definition at line 15 of file TMatacq.h.

int TMatacq::firstsample
private

Definition at line 15 of file TMatacq.h.

Referenced by getPt1().

int TMatacq::fNsamples
private

Definition at line 11 of file TMatacq.h.

int TMatacq::fNum_samp_aft_max
private

Definition at line 13 of file TMatacq.h.

int TMatacq::fNum_samp_bef_max
private

Definition at line 12 of file TMatacq.h.

double TMatacq::fv1[16]
private

Definition at line 21 of file TMatacq.h.

double TMatacq::fv2[16]
private

Definition at line 21 of file TMatacq.h.

double TMatacq::fv3[16]
private

Definition at line 21 of file TMatacq.h.

int TMatacq::lastsample
private

Definition at line 15 of file TMatacq.h.

Referenced by getPt2().

double TMatacq::level1
private

Definition at line 18 of file TMatacq.h.

double TMatacq::level2
private

Definition at line 18 of file TMatacq.h.

double TMatacq::level3
private

Definition at line 18 of file TMatacq.h.

double TMatacq::meantrise
private

Definition at line 27 of file TMatacq.h.

int TMatacq::nevlasers
private

Definition at line 29 of file TMatacq.h.

int TMatacq::nevmtq0
private

Definition at line 29 of file TMatacq.h.

int TMatacq::nevmtq1
private

Definition at line 29 of file TMatacq.h.

double TMatacq::nsigcut
private

Definition at line 17 of file TMatacq.h.

int TMatacq::nslide
private

Definition at line 33 of file TMatacq.h.

double TMatacq::pkval
private

Definition at line 24 of file TMatacq.h.

Referenced by getTimpeak().

int TMatacq::presample
private

Definition at line 15 of file TMatacq.h.

int TMatacq::samplemax
private

Definition at line 15 of file TMatacq.h.

Referenced by getPtm().

double TMatacq::sigbl
private

Definition at line 22 of file TMatacq.h.

Referenced by getsigBaseLine().

double TMatacq::sigpkval
private

Definition at line 24 of file TMatacq.h.

Referenced by getsigTimpeak().

double TMatacq::sigtrise
private

Definition at line 27 of file TMatacq.h.

double TMatacq::slidingmean
private

Definition at line 32 of file TMatacq.h.

Referenced by getSlide().

int TMatacq::status[1200]
private
double TMatacq::t[16]
private

Definition at line 20 of file TMatacq.h.

double TMatacq::timeatmax
private

Definition at line 23 of file TMatacq.h.

Referenced by getTimax().

double TMatacq::trise
private

Definition at line 25 of file TMatacq.h.

Referenced by getTrise().

double TMatacq::val[16]
private
double TMatacq::val_max
private

Definition at line 22 of file TMatacq.h.

double TMatacq::width20
private

Definition at line 26 of file TMatacq.h.

Referenced by getWidth20().

double TMatacq::width50
private

Definition at line 26 of file TMatacq.h.

Referenced by getFwhm().

double TMatacq::width80
private

Definition at line 26 of file TMatacq.h.

Referenced by getWidth80().