CMS 3D CMS Logo

EcalPerEvtLaserAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * \class EcalPerEvtLaserAnalyzer
3  *
4  * primary author: Julie Malcles - CEA/Saclay
5  * author: Gautier Hamel De Monchenault - CEA/Saclay
6  */
7 
8 #include <TFile.h>
9 #include <TTree.h>
10 
12 
13 #include <sstream>
14 #include <iostream>
15 #include <iomanip>
16 #include <ctime>
17 
20 
23 
29 
32 
37 
38 #include <vector>
39 
42 
43 using namespace std;
44 
45 //========================================================================
47  //========================================================================
48  : iEvent(0),
49 
50  // framework parameters with default values
51  _nsamples(iConfig.getUntrackedParameter<unsigned int>("nSamples", 10)),
52  _presample(iConfig.getUntrackedParameter<unsigned int>("nPresamples", 3)),
53  _firstsample(iConfig.getUntrackedParameter<unsigned int>("firstSample", 1)),
54  _lastsample(iConfig.getUntrackedParameter<unsigned int>("lastSample", 2)),
55  _samplemin(iConfig.getUntrackedParameter<unsigned int>("sampleMin", 3)),
56  _samplemax(iConfig.getUntrackedParameter<unsigned int>("sampleMax", 9)),
57  _nsamplesPN(iConfig.getUntrackedParameter<unsigned int>("nSamplesPN", 50)),
58  _presamplePN(iConfig.getUntrackedParameter<unsigned int>("nPresamplesPN", 6)),
59  _firstsamplePN(iConfig.getUntrackedParameter<unsigned int>("firstSamplePN", 7)),
60  _lastsamplePN(iConfig.getUntrackedParameter<unsigned int>("lastSamplePN", 8)),
61  _timingcutlow(iConfig.getUntrackedParameter<unsigned int>("timingCutLow", 3)),
62  _timingcuthigh(iConfig.getUntrackedParameter<unsigned int>("timingCutHigh", 7)),
63  _niter(iConfig.getUntrackedParameter<unsigned int>("nIter", 3)),
64  _fedid(iConfig.getUntrackedParameter<unsigned int>("fedID", 0)),
65  _tower(iConfig.getUntrackedParameter<unsigned int>("tower", 1)),
66  _channel(iConfig.getUntrackedParameter<unsigned int>("channel", 1)),
67  _ecalPart(iConfig.getUntrackedParameter<std::string>("ecalPart", "EB")),
68  nCrys(NCRYSEB),
69  nTT(NTTEB),
70  nSides(NSIDES),
71  IsFileCreated(0),
72  nCh(0),
73  runType(-1),
74  runNum(0),
75  dccID(-1),
76  lightside(2),
77  doesRefFileExist(0),
78  ttMat(-1),
79  peakMat(-1),
80  peak(-1),
81  evtMat(-1),
82  colMat(-1)
83 //========================================================================
84 
85 {
86  //now do what ever initialization is needed
87 
88  resdir_ = iConfig.getUntrackedParameter<std::string>("resDir");
89  refalphabeta_ = iConfig.getUntrackedParameter<std::string>("refAlphaBeta");
90 
91  digiCollection_ = iConfig.getParameter<std::string>("digiCollection");
92  digiPNCollection_ = iConfig.getParameter<std::string>("digiPNCollection");
93  digiProducer_ = iConfig.getParameter<std::string>("digiProducer");
94 
95  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
96  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
97 
98  // Define geometrical constants
99 
100  if (_ecalPart == "EB") {
101  nCrys = NCRYSEB;
102  nTT = NTTEB;
103  } else {
104  nCrys = NCRYSEE;
105  nTT = NTTEE;
106  }
107 }
108 
109 //========================================================================
111  //========================================================================
112 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 }
116 
117 //========================================================================
119  //========================================================================
120 
121  // Define temporary files' names
122 
123  stringstream namefile1;
124  namefile1 << resdir_ << "/ADCSamples.root";
125 
126  ADCfile = namefile1.str();
127 
128  // Create temporary file and trees to save adc samples
129 
130  ADCFile = new TFile(ADCfile.c_str(), "RECREATE");
131 
132  stringstream name;
133  name << "ADCTree";
134 
135  ADCtrees = new TTree(name.str().c_str(), name.str().c_str());
136 
137  ADCtrees->Branch("iphi", &phi, "phi/I");
138  ADCtrees->Branch("ieta", &eta, "eta/I");
139  ADCtrees->Branch("dccID", &dccID, "dccID/I");
140  ADCtrees->Branch("event", &event, "event/I");
141  ADCtrees->Branch("color", &color, "color/I");
142  ADCtrees->Branch("adc", &adc, "adc[10]/D");
143  ADCtrees->Branch("ttrigMatacq", &ttrig, "ttrig/D");
144  ADCtrees->Branch("peakMatacq", &peak, "peak/D");
145  ADCtrees->Branch("pn0", &pn0, "pn0/D");
146  ADCtrees->Branch("pn1", &pn1, "pn1/D");
147 
148  ADCtrees->SetBranchAddress("ieta", &eta);
149  ADCtrees->SetBranchAddress("iphi", &phi);
150  ADCtrees->SetBranchAddress("dccID", &dccID);
151  ADCtrees->SetBranchAddress("event", &event);
152  ADCtrees->SetBranchAddress("color", &color);
153  ADCtrees->SetBranchAddress("adc", adc);
154  ADCtrees->SetBranchAddress("ttrigMatacq", &ttrig);
155  ADCtrees->SetBranchAddress("peakMatacq", &peak);
156  ADCtrees->SetBranchAddress("pn0", &pn0);
157  ADCtrees->SetBranchAddress("pn1", &pn1);
158 
159  IsFileCreated = 0;
160  nCh = nCrys;
161 }
162 
163 //========================================================================
165  //========================================================================
166 
167  ++iEvent;
168 
169  // retrieving DCC header
171  const EcalRawDataCollection* DCCHeader = nullptr;
172  try {
173  e.getByLabel(eventHeaderProducer_, eventHeaderCollection_, pDCCHeader);
174  DCCHeader = pDCCHeader.product();
175  } catch (std::exception& ex) {
176  std::cerr << "Error! can't get the product retrieving DCC header" << eventHeaderCollection_.c_str() << std::endl;
177  }
178 
179  // retrieving crystal data from Event
181  const EBDigiCollection* EBDigi = nullptr;
183  const EEDigiCollection* EEDigi = nullptr;
184 
185  if (_ecalPart == "EB") {
186  try {
187  e.getByLabel(digiProducer_, digiCollection_, pEBDigi);
188  EBDigi = pEBDigi.product();
189  } catch (std::exception& ex) {
190  std::cerr << "Error! can't get the product retrieving EB crystal data " << digiCollection_.c_str() << std::endl;
191  }
192  } else {
193  try {
194  e.getByLabel(digiProducer_, digiCollection_, pEEDigi);
195  EEDigi = pEEDigi.product();
196  } catch (std::exception& ex) {
197  std::cerr << "Error! can't get the product retrieving EE crystal data " << digiCollection_.c_str() << std::endl;
198  }
199  }
200 
201  // retrieving crystal PN diodes from Event
203  const EcalPnDiodeDigiCollection* PNDigi = nullptr;
204  try {
205  e.getByLabel(digiProducer_, digiPNCollection_, pPNDigi);
206  PNDigi = pPNDigi.product();
207  } catch (std::exception& ex) {
208  std::cerr << "Error! can't get the product " << digiPNCollection_.c_str() << std::endl;
209  }
210 
211  // retrieving electronics mapping
213  const EcalElectronicsMapping* TheMapping = nullptr;
214  try {
215  c.get<EcalMappingRcd>().get(ecalmapping);
216  TheMapping = ecalmapping.product();
217  } catch (std::exception& ex) {
218  std::cerr << "Error! can't get the product EcalMappingRcd" << std::endl;
219  }
220 
221  // ====================================
222  // Decode Basic DCCHeader Information
223  // ====================================
224 
225  for (EcalRawDataCollection::const_iterator headerItr = DCCHeader->begin(); headerItr != DCCHeader->end();
226  ++headerItr) {
227  // Get run type and run number
228 
229  int fed = headerItr->fedId();
230 
231  if (fed != _fedid && _fedid != -999)
232  continue;
233 
234  runType = headerItr->getRunType();
235  runNum = headerItr->getRunNumber();
236  event = headerItr->getLV1();
237  dccID = headerItr->getDccInTCCCommand();
238  fedID = headerItr->fedId();
239 
240  // take event only if the fed corresponds to the DCC in TCC
241  if (600 + dccID != fedID)
242  continue;
243 
244  // Cut on runType
246  return;
247 
248  // Define output results files' names
249 
250  if (IsFileCreated == 0) {
251  stringstream namefile2;
252  namefile2 << resdir_ << "/APDAmpl_Run" << runNum << "_" << _fedid << "_" << _tower << "_" << _channel << ".root";
253  resfile = namefile2.str();
254 
255  // Get Matacq ttrig
256 
257  stringstream namefile;
258  namefile << resdir_ << "/Matacq-Run" << runNum << ".root";
259 
260  doesRefFileExist = 0;
261 
262  FILE* test;
263  test = fopen(namefile.str().c_str(), "r");
264  if (test)
265  doesRefFileExist = 1;
266 
267  if (doesRefFileExist == 1) {
268  matacqFile = new TFile((namefile.str().c_str()));
269  matacqTree = (TTree*)matacqFile->Get("MatacqShape");
270 
271  matacqTree->SetBranchAddress("event", &evtMat);
272  matacqTree->SetBranchAddress("color", &colMat);
273  matacqTree->SetBranchAddress("peak", &peakMat);
274  matacqTree->SetBranchAddress("ttrig", &ttMat);
275  }
276 
277  IsFileCreated = 1;
278  }
279 
280  // Retrieve laser color and event number
281 
282  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
283  int color = settings.wavelength;
284 
285  vector<int>::iterator iter = find(colors.begin(), colors.end(), color);
286  if (iter == colors.end()) {
287  colors.push_back(color);
288  cout << " new color found " << color << " " << colors.size() << endl;
289  }
290  }
291 
292  // cut on fedID
293 
294  if (fedID != _fedid && _fedid != -999)
295  return;
296 
297  // ======================
298  // Decode PN Information
299  // ======================
300 
301  TPNFit* pnfit = new TPNFit();
303 
304  double chi2pn = 0;
305  double ypnrange[50];
306  double dsum = 0.;
307  double dsum1 = 0.;
308  double bl = 0.;
309  double bl1 = 0.;
310  double val_max = 0.;
311  unsigned int samplemax = 0;
312  unsigned int k;
313 
314  std::vector<double> allPNAmpl;
315 
316  for (EcalPnDiodeDigiCollection::const_iterator pnItr = PNDigi->begin(); pnItr != PNDigi->end();
317  ++pnItr) { // Loop on PNs
318 
319  for (int samId = 0; samId < (*pnItr).size(); samId++) { // Loop on PN samples
320  pn[samId] = (*pnItr).sample(samId).adc();
321  }
322 
323  for (dsum = 0., k = 0; k < _presamplePN; k++) {
324  dsum += pn[k];
325  }
326  bl = dsum / ((double)_presamplePN);
327 
328  for (val_max = 0., k = 0; k < _nsamplesPN; k++) {
329  ypnrange[k] = pn[k] - bl;
330 
331  if (ypnrange[k] > val_max) {
332  val_max = ypnrange[k];
333  samplemax = k;
334  }
335  }
336 
337  chi2pn = pnfit->doFit(samplemax, &ypnrange[0]);
338 
339  if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
340  pnAmpl = 0.;
341  else
342  pnAmpl = pnfit->getAmpl();
343 
344  allPNAmpl.push_back(pnAmpl);
345  }
346 
347  // ===========
348  // Get Matacq
349  // ===========
350 
351  ttrig = -1.;
352  peak = -1.;
353 
354  if (doesRefFileExist == 1) {
355  // FIXME
356  if (color == 0)
357  matacqTree->GetEntry(event - 1);
358  else if (color == 3)
359  matacqTree->GetEntry(matacqTree->GetEntries("color==0") + event - 1);
360  ttrig = ttMat;
361  peak = peakMat;
362  }
363 
364  // ===========================
365  // Decode EBDigis Information
366  // ===========================
367 
368  double yrange[10];
369  int adcGain = 0;
370  int side = 0;
371 
372  if (EBDigi) {
373  for (EBDigiCollection::const_iterator digiItr = EBDigi->begin(); digiItr != EBDigi->end();
374  ++digiItr) { // Loop on crystals
375 
376  EBDetId id_crystal(digiItr->id());
377  EBDataFrame df(*digiItr);
378 
379  int etaG = id_crystal.ieta(); // global
380  int phiG = id_crystal.iphi(); // global
381 
382  int etaL; // local
383  int phiL; // local
384  std::pair<int, int> LocalCoord = MEEBGeom::localCoord(etaG, phiG);
385 
386  etaL = LocalCoord.first;
387  phiL = LocalCoord.second;
388 
389  eta = etaG;
390  phi = phiG;
391 
392  side = MEEBGeom::side(etaG, phiG);
393 
394  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
395 
396  int towerID = elecid_crystal.towerId();
397  // int channelID=elecid_crystal.channelId()-1; // FIXME so far for endcap only
398  int strip = elecid_crystal.stripId();
399  int xtal = elecid_crystal.xtalId();
400  int channelID = 5 * (strip - 1) + xtal - 1; // FIXME
401 
402  int module = MEEBGeom::lmmod(etaG, phiG);
403 
404  std::pair<int, int> pnpair = MEEBGeom::pn(module);
405  unsigned int MyPn0 = pnpair.first;
406  unsigned int MyPn1 = pnpair.second;
407 
408  unsigned int channel = MEEBGeom::electronic_channel(etaL, phiL);
409  assert(channel < nCrys);
410 
411  double adcmax = 0.0;
412 
413  if (towerID != int(_tower) || channelID != int(_channel) || dccID != int(_fedid - 600))
414  continue;
415  else
416  channelNumber = channel;
417 
418  for (unsigned int i = 0; i < (*digiItr).size(); ++i) { // Loop on adc samples
419 
420  EcalMGPASample samp_crystal(df.sample(i));
421  adc[i] = samp_crystal.adc();
422  adcG[i] = samp_crystal.gainId();
423 
424  if (i == 0)
425  adcGain = adcG[i];
426  if (i > 0)
427  adcGain = TMath::Max(adcG[i], adcGain);
428 
429  if (adc[i] > adcmax) {
430  adcmax = adc[i];
431  }
432  }
433 
434  for (dsum = 0., dsum1 = 0., k = 0; k < _presample; k++) {
435  dsum += adc[k];
436  if (k < _presample - 1)
437  dsum1 += adc[k];
438  }
439 
440  bl = dsum / ((double)_presample);
441  bl1 = dsum1 / ((double)_presample - 1);
442 
443  for (val_max = 0., k = 0; k < _nsamples; k++) {
444  yrange[k] = adc[k] - bl;
445  if (yrange[k] > val_max) {
446  val_max = yrange[k];
447  samplemax = k;
448  }
449  }
450 
451  if (samplemax == 4 || samplemax == 5) {
452  val_max = val_max + bl - bl1;
453  for (k = 0; k < _nsamples; k++) {
454  yrange[k] = yrange[k] + bl - bl1;
455  }
456  }
457 
458  for (unsigned int k = 0; k < _nsamples; k++) {
459  adc[k] = yrange[k];
460  }
461 
462  pn0 = allPNAmpl[MyPn0];
463  pn1 = allPNAmpl[MyPn1];
464 
465  if (samplemax >= _timingcutlow && samplemax <= _timingcuthigh && lightside == side)
466  ADCtrees->Fill();
467  }
468 
469  } else {
470  for (EEDigiCollection::const_iterator digiItr = EEDigi->begin(); digiItr != EEDigi->end();
471  ++digiItr) { // Loop on crystals
472 
473  EEDetId id_crystal(digiItr->id());
474  EEDataFrame df(*digiItr);
475 
476  phi = id_crystal.ix() - 1;
477  eta = id_crystal.iy() - 1;
478  side = 0; // FIXME
479 
480  // Recover the TT id and the electronic crystal numbering from EcalElectronicsMapping
481 
482  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
483 
484  int towerID = elecid_crystal.towerId();
485  int channelID = elecid_crystal.channelId() - 1;
486 
487  int module = MEEEGeom::lmmod(phi, eta);
488 
489  std::pair<int, int> pnpair = MEEEGeom::pn(module, _fedid);
490  unsigned int MyPn0 = pnpair.first;
491  unsigned int MyPn1 = pnpair.second;
492 
493  unsigned int channel = MEEEGeom::crystal(phi, eta);
494  assert(channel < nCrys);
495 
496  double adcmax = 0.0;
497 
498  if (towerID != int(_tower) || channelID != int(_channel) || dccID != int(_fedid - 600))
499  continue;
500  else
501  channelNumber = channel;
502 
503  for (unsigned int i = 0; i < (*digiItr).size(); ++i) { // Loop on adc samples
504 
505  EcalMGPASample samp_crystal(df.sample(i));
506  adc[i] = samp_crystal.adc();
507  adcG[i] = samp_crystal.gainId();
508 
509  if (i == 0)
510  adcGain = adcG[i];
511  if (i > 0)
512  adcGain = TMath::Max(adcG[i], adcGain);
513 
514  if (adc[i] > adcmax) {
515  adcmax = adc[i];
516  }
517  }
518 
519  for (dsum = 0., dsum1 = 0., k = 0; k < _presample; k++) {
520  dsum += adc[k];
521  if (k < _presample - 1)
522  dsum1 += adc[k];
523  }
524 
525  bl = dsum / ((double)_presample);
526  bl1 = dsum1 / ((double)_presample - 1);
527 
528  for (val_max = 0., k = 0; k < _nsamples; k++) {
529  yrange[k] = adc[k] - bl;
530  if (yrange[k] > val_max) {
531  val_max = yrange[k];
532  samplemax = k;
533  }
534  }
535 
536  if (samplemax == 4 || samplemax == 5) {
537  val_max = val_max + bl - bl1;
538  for (k = 0; k < _nsamples; k++) {
539  yrange[k] = yrange[k] + bl - bl1;
540  }
541  }
542 
543  for (unsigned int k = 0; k < _nsamples; k++) {
544  adc[k] = yrange[k];
545  }
546 
547  pn0 = allPNAmpl[MyPn0];
548  pn1 = allPNAmpl[MyPn1];
549 
550  if (samplemax >= _timingcutlow && samplemax <= _timingcuthigh && lightside == side)
551  ADCtrees->Fill();
552  }
553  }
554 
555 } // analyze
556 
557 //========================================================================
559  //========================================================================
560 
561  assert(colors.size() <= nColor);
562  unsigned int nCol = colors.size();
563 
564  ADCtrees->Write();
565 
566  cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
567  cout << "\t+=+ Analyzing laser data: getting per event +=+" << endl;
568  cout << "\t+=+ APD Amplitudes and ADC samples +=+" << endl;
569  cout << "\t+=+ for fed:" << _fedid << ", tower:" << _tower << ", and channel:" << _channel << endl;
570 
571  // Define temporary tree to save APD amplitudes
572 
573  APDFile = new TFile(resfile.c_str(), "RECREATE");
574 
575  int ieta, iphi, channelID, towerID, flag;
576  double alpha, beta;
577 
578  colors.push_back(color);
579 
580  for (unsigned int i = 0; i < nCol; i++) {
581  stringstream name1;
582  name1 << "headerCol" << colors[i];
583 
584  header[i] = new TTree(name1.str().c_str(), name1.str().c_str());
585 
586  header[i]->Branch("alpha", &alpha, "alpha/D");
587  header[i]->Branch("beta", &beta, "beta/D");
588  header[i]->Branch("iphi", &iphi, "iphi/I");
589  header[i]->Branch("ieta", &ieta, "ieta/I");
590  header[i]->Branch("dccID", &dccID, "dccID/I");
591  header[i]->Branch("towerID", &towerID, "towerID/I");
592  header[i]->Branch("channelID", &channelID, "channelID/I");
593 
594  header[i]->SetBranchAddress("alpha", &alpha);
595  header[i]->SetBranchAddress("beta", &beta);
596  header[i]->SetBranchAddress("iphi", &iphi);
597  header[i]->SetBranchAddress("ieta", &ieta);
598  header[i]->SetBranchAddress("dccID", &dccID);
599  header[i]->SetBranchAddress("towerID", &towerID);
600  header[i]->SetBranchAddress("channelID", &channelID);
601  }
602 
603  stringstream name2;
604  name2 << "APDTree";
605  APDtrees = new TTree(name2.str().c_str(), name2.str().c_str());
606 
607  //List of branches
608 
609  APDtrees->Branch("event", &event, "event/I");
610  APDtrees->Branch("color", &color, "color/I");
611  APDtrees->Branch("adc", &adc, "adc[10]/D");
612  APDtrees->Branch("peakMatacq", &peak, "peak/D");
613  APDtrees->Branch("ttrigMatacq", &ttrig, "ttrig/D");
614  APDtrees->Branch("apdAmpl", &apdAmpl, "apdAmpl/D");
615  APDtrees->Branch("apdTime", &apdTime, "apdTime/D");
616  APDtrees->Branch("flag", &flag, "flag/I");
617  APDtrees->Branch("pn0", &pn0, "pn0/D");
618  APDtrees->Branch("pn1", &pn1, "pn1/D");
619 
620  APDtrees->SetBranchAddress("event", &event);
621  APDtrees->SetBranchAddress("color", &color);
622  APDtrees->SetBranchAddress("adc", adc);
623  APDtrees->SetBranchAddress("peakMatacq", &peak);
624  APDtrees->SetBranchAddress("ttrigMatacq", &ttrig);
625  APDtrees->SetBranchAddress("apdAmpl", &apdAmpl);
626  APDtrees->SetBranchAddress("apdTime", &apdTime);
627  APDtrees->SetBranchAddress("flag", &flag);
628  APDtrees->SetBranchAddress("pn0", &pn0);
629  APDtrees->SetBranchAddress("pn1", &pn1);
630 
631  // Retrieve alpha and beta for APD amplitudes calculation
632 
633  TFile* alphaFile = new TFile(refalphabeta_.c_str());
634  TTree* alphaTree[2];
635 
636  Double_t alphaRun, betaRun;
637  int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
638 
639  for (unsigned int i = 0; i < nCol; i++) {
640  stringstream name3;
641  name3 << "ABCol" << i;
642  alphaTree[i] = (TTree*)alphaFile->Get(name3.str().c_str());
643  alphaTree[i]->SetBranchStatus("*", false);
644  alphaTree[i]->SetBranchStatus("alpha", true);
645  alphaTree[i]->SetBranchStatus("beta", true);
646  alphaTree[i]->SetBranchStatus("iphi", true);
647  alphaTree[i]->SetBranchStatus("ieta", true);
648  alphaTree[i]->SetBranchStatus("dccID", true);
649  alphaTree[i]->SetBranchStatus("towerID", true);
650  alphaTree[i]->SetBranchStatus("channelID", true);
651  alphaTree[i]->SetBranchStatus("flag", true);
652 
653  alphaTree[i]->SetBranchAddress("alpha", &alphaRun);
654  alphaTree[i]->SetBranchAddress("beta", &betaRun);
655  alphaTree[i]->SetBranchAddress("iphi", &iphiRun);
656  alphaTree[i]->SetBranchAddress("ieta", &ietaRun);
657  alphaTree[i]->SetBranchAddress("dccID", &dccIDRun);
658  alphaTree[i]->SetBranchAddress("towerID", &towerIDRun);
659  alphaTree[i]->SetBranchAddress("channelID", &channelIDRun);
660  alphaTree[i]->SetBranchAddress("flag", &flagRun);
661  }
662 
664 
665  double chi2;
666 
667  for (unsigned int icol = 0; icol < nCol; icol++) {
668  IsThereDataADC[icol] = 1;
669  stringstream cut;
670  cut << "color==" << colors.at(icol);
671  if (ADCtrees->GetEntries(cut.str().c_str()) < 10)
672  IsThereDataADC[icol] = 0;
673  IsHeaderFilled[icol] = 0;
674  }
675 
676  // Define submodule and channel number inside the submodule (as Patrice)
677 
678  Long64_t nbytes = 0, nb = 0;
679  for (Long64_t jentry = 0; jentry < ADCtrees->GetEntriesFast(); jentry++) { // Loop on events
680  nb = ADCtrees->GetEntry(jentry);
681  nbytes += nb;
682 
683  int iCry = channelNumber;
684 
685  // get back color
686 
687  unsigned int iCol = 0;
688  for (unsigned int i = 0; i < nCol; i++) {
689  if (color == colors[i]) {
690  iCol = i;
691  i = colors.size();
692  }
693  }
694 
695  alphaTree[iCol]->GetEntry(iCry);
696 
697  flag = flagRun;
698  iphi = iphiRun;
699  ieta = ietaRun;
700  towerID = towerIDRun;
701  channelID = channelIDRun;
702  alpha = alphaRun;
703  beta = betaRun;
704 
705  if (IsHeaderFilled[iCol] == 0) {
706  header[iCol]->Fill();
707  IsHeaderFilled[iCol] = 1;
708  }
709  // Amplitude calculation
710 
711  apdAmpl = 0;
712  apdTime = 0;
713 
714  pslsfit->init(_nsamples, _firstsample, _lastsample, _niter, alphaRun, betaRun);
715  chi2 = pslsfit->doFit(&adc[0]);
716 
717  if (chi2 < 0. || chi2 == 102 || chi2 == 101) {
718  apdAmpl = 0;
719  apdTime = 0;
720 
721  } else {
722  apdAmpl = pslsfit->getAmpl();
723  apdTime = pslsfit->getTime();
724  }
725 
726  APDtrees->Fill();
727  }
728 
729  alphaFile->Close();
730 
731  ADCFile->Close();
732 
733  APDFile->Write();
734  APDFile->Close();
735 
736  // Remove unwanted files
737 
738  stringstream del;
739  del << "rm " << ADCfile;
740  system(del.str().c_str());
741 
742  cout << "\t+=+ .................................................. done +=+" << endl;
743  cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
744 }
745 
DeadROC_duringRun.runNum
runNum
Definition: DeadROC_duringRun.py:21
EcalPerEvtLaserAnalyzer::_fedid
int _fedid
Definition: EcalPerEvtLaserAnalyzer.h:62
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
NCRYSEE
#define NCRYSEE
Definition: EcalABAnalyzer.h:33
EcalPerEvtLaserAnalyzer::iEvent
int iEvent
Definition: EcalPerEvtLaserAnalyzer.h:45
EcalPerEvtLaserAnalyzer::resfile
std::string resfile
Definition: EcalPerEvtLaserAnalyzer.h:80
EcalElectronicsId.h
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
PulseFitWithFunction.h
colors
Definition: colors.py:1
EcalPerEvtLaserAnalyzer::resdir_
std::string resdir_
Definition: EcalPerEvtLaserAnalyzer.h:67
NTTEE
#define NTTEE
Definition: EcalPerEvtLaserAnalyzer.h:30
edm::Handle::product
T const * product() const
Definition: Handle.h:70
TPNFit
Definition: TPNFit.h:8
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
MEEBGeom::electronic_channel
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:326
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
EcalPerEvtLaserAnalyzer::_nsamplesPN
unsigned int _nsamplesPN
Definition: EcalPerEvtLaserAnalyzer.h:55
EBDetId
Definition: EBDetId.h:17
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
MEEEGeom::crystal
static int crystal(CrysCoord ix, CrysCoord iy)
Definition: MEEEGeom.cc:372
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
EBDataFrame
Definition: EBDataFrame.h:11
EcalPerEvtLaserAnalyzer::pnAmpl
double pnAmpl
Definition: EcalPerEvtLaserAnalyzer.h:138
EcalPerEvtLaserAnalyzer::pn1
double pn1
Definition: EcalPerEvtLaserAnalyzer.h:134
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalDetIdCollections.h
EcalPerEvtLaserAnalyzer::_nsamples
unsigned int _nsamples
Definition: EcalPerEvtLaserAnalyzer.h:49
EcalPerEvtLaserAnalyzer::ttMat
double ttMat
Definition: EcalPerEvtLaserAnalyzer.h:122
CollectionTags_cfi.EBDigi
EBDigi
Definition: CollectionTags_cfi.py:27
EcalPerEvtLaserAnalyzer::eventHeaderProducer_
std::string eventHeaderProducer_
Definition: EcalPerEvtLaserAnalyzer.h:73
MEEBGeom.h
EcalPerEvtLaserAnalyzer::refalphabeta_
std::string refalphabeta_
Definition: EcalPerEvtLaserAnalyzer.h:68
cms::cuda::assert
assert(be >=bs)
EcalPerEvtLaserAnalyzer::ttrig
double ttrig
Definition: EcalPerEvtLaserAnalyzer.h:133
edm::SortedCollection
Definition: SortedCollection.h:49
EcalPerEvtLaserAnalyzer::runNum
int runNum
Definition: EcalPerEvtLaserAnalyzer.h:98
NTTEB
#define NTTEB
Definition: EcalPerEvtLaserAnalyzer.h:25
EcalPerEvtLaserAnalyzer::_presample
unsigned int _presample
Definition: EcalPerEvtLaserAnalyzer.h:50
EcalPerEvtLaserAnalyzer::color
int color
Definition: EcalPerEvtLaserAnalyzer.h:129
EcalPerEvtLaserAnalyzer::adc
double adc[10]
Definition: EcalPerEvtLaserAnalyzer.h:130
NCRYSEB
#define NCRYSEB
Definition: EcalABAnalyzer.h:30
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
PulseFitWithFunction::init
virtual void init(int, int, int, int, double, double)
Definition: PulseFitWithFunction.cc:37
EcalPerEvtLaserAnalyzer::_firstsamplePN
unsigned int _firstsamplePN
Definition: EcalPerEvtLaserAnalyzer.h:57
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
EcalPerEvtLaserAnalyzer::adcG
int adcG[10]
Definition: EcalPerEvtLaserAnalyzer.h:131
MEEBGeom::pn
static std::pair< int, int > pn(int ilmmod)
Definition: MEEBGeom.cc:447
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalPerEvtLaserAnalyzer::channelNumber
int channelNumber
Definition: EcalPerEvtLaserAnalyzer.h:103
EcalPerEvtLaserAnalyzer::header
TTree * header[2]
Definition: EcalPerEvtLaserAnalyzer.h:115
edm::Handle
Definition: AssociativeIterator.h:50
EcalPerEvtLaserAnalyzer::digiCollection_
std::string digiCollection_
Definition: EcalPerEvtLaserAnalyzer.h:69
EcalPerEvtLaserAnalyzer::pn
double pn[50]
Definition: EcalPerEvtLaserAnalyzer.h:135
EcalElectronicsId::towerId
int towerId() const
get the tower id
Definition: EcalElectronicsId.h:33
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalDCCHeaderBlock::LASER_GAP
Definition: EcalDCCHeaderBlock.h:42
EcalPerEvtLaserAnalyzer::_firstsample
unsigned int _firstsample
Definition: EcalPerEvtLaserAnalyzer.h:51
MEEBGeom::side
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:105
EcalPerEvtLaserAnalyzer::matacqFile
TFile * matacqFile
Definition: EcalPerEvtLaserAnalyzer.h:108
EcalRawDataCollections.h
MakerMacros.h
EcalPerEvtLaserAnalyzer::_timingcutlow
unsigned int _timingcutlow
Definition: EcalPerEvtLaserAnalyzer.h:59
test
Definition: SmallWORMDict.h:13
EcalDCCHeaderBlock::LASER_STD
Definition: EcalDCCHeaderBlock.h:26
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
CollectionTags_cfi.EEDigi
EEDigi
Definition: CollectionTags_cfi.py:28
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EcalElectronicsId::channelId
int channelId() const
so far for EndCap only :
Definition: EcalElectronicsId.cc:71
PulseFitWithFunction::getAmpl
double getAmpl()
Definition: PulseFitWithFunction.h:52
EcalPerEvtLaserAnalyzer::ADCfile
std::string ADCfile
Definition: EcalPerEvtLaserAnalyzer.h:78
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
nTT
#define nTT
Definition: TMEGeom.h:6
EcalMappingRcd.h
EcalPerEvtLaserAnalyzer::_channel
unsigned int _channel
Definition: EcalPerEvtLaserAnalyzer.h:64
EcalPerEvtLaserAnalyzer.h
EcalDigiCollections.h
edm::ESHandle< EcalElectronicsMapping >
EcalElectronicsMapping::getElectronicsId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
Definition: EcalElectronicsMapping.cc:324
EcalPerEvtLaserAnalyzer::ADCFile
TFile * ADCFile
Definition: EcalPerEvtLaserAnalyzer.h:111
NSIDES
#define NSIDES
Definition: EcalLaserAnalyzer.h:44
dqmdumpme.k
k
Definition: dqmdumpme.py:60
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
MEEEGeom::pn
static std::pair< int, int > pn(int dee, int ilmod)
Definition: MEEEGeom.cc:574
EcalPerEvtLaserAnalyzer::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: EcalPerEvtLaserAnalyzer.cc:164
EEDetId
Definition: EEDetId.h:14
EcalPerEvtLaserAnalyzer::IsHeaderFilled
int IsHeaderFilled[nColor]
Definition: EcalPerEvtLaserAnalyzer.h:120
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDCCHeaderBlock::EcalDCCEventSettings
Definition: EcalDCCHeaderBlock.h:64
EcalPerEvtLaserAnalyzer::~EcalPerEvtLaserAnalyzer
~EcalPerEvtLaserAnalyzer() override
Definition: EcalPerEvtLaserAnalyzer.cc:110
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
TPNFit.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
TPNFit::getAmpl
double getAmpl()
Definition: TPNFit.h:31
EcalPerEvtLaserAnalyzer::phi
int phi
Definition: EcalPerEvtLaserAnalyzer.h:127
EcalPerEvtLaserAnalyzer::APDFile
TFile * APDFile
Definition: EcalPerEvtLaserAnalyzer.h:114
EcalPerEvtLaserAnalyzer::matacqTree
TTree * matacqTree
Definition: EcalPerEvtLaserAnalyzer.h:109
EBDigiCollection
Definition: EcalDigiCollections.h:32
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalPerEvtLaserAnalyzer::dccID
int dccID
Definition: EcalPerEvtLaserAnalyzer.h:99
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
EcalPerEvtLaserAnalyzer::pn0
double pn0
Definition: EcalPerEvtLaserAnalyzer.h:134
EEDigiCollection
Definition: EcalDigiCollections.h:45
EcalPerEvtLaserAnalyzer::apdAmpl
double apdAmpl
Definition: EcalPerEvtLaserAnalyzer.h:136
EcalPerEvtLaserAnalyzer::doesRefFileExist
int doesRefFileExist
Definition: EcalPerEvtLaserAnalyzer.h:118
EcalPerEvtLaserAnalyzer::nCrys
unsigned int nCrys
Definition: EcalPerEvtLaserAnalyzer.h:85
EcalElectronicsMapping.h
EcalPerEvtLaserAnalyzer::IsFileCreated
int IsFileCreated
Definition: EcalPerEvtLaserAnalyzer.h:89
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
EcalPerEvtLaserAnalyzer::EcalPerEvtLaserAnalyzer
EcalPerEvtLaserAnalyzer(const edm::ParameterSet &iConfig)
Definition: EcalPerEvtLaserAnalyzer.cc:46
PulseFitWithFunction::getTime
double getTime()
Definition: PulseFitWithFunction.h:53
MEEEGeom.h
Max
T Max(T a, T b)
Definition: MathUtil.h:44
edm::EventSetup
Definition: EventSetup.h:57
EcalPerEvtLaserAnalyzer::digiProducer_
std::string digiProducer_
Definition: EcalPerEvtLaserAnalyzer.h:71
EcalPerEvtLaserAnalyzer::nColor
Definition: EcalPerEvtLaserAnalyzer.h:42
TPNFit::init
void init(int, int, int)
Definition: TPNFit.cc:24
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EcalPerEvtLaserAnalyzer::APDtrees
TTree * APDtrees
Definition: EcalPerEvtLaserAnalyzer.h:116
EcalPerEvtLaserAnalyzer::eta
int eta
Definition: EcalPerEvtLaserAnalyzer.h:127
module
Definition: vlib.h:198
EcalPerEvtLaserAnalyzer::digiPNCollection_
std::string digiPNCollection_
Definition: EcalPerEvtLaserAnalyzer.h:70
get
#define get
EcalPerEvtLaserAnalyzer::_niter
unsigned int _niter
Definition: EcalPerEvtLaserAnalyzer.h:61
EcalMGPASample
Definition: EcalMGPASample.h:22
EcalPerEvtLaserAnalyzer::_ecalPart
std::string _ecalPart
Definition: EcalPerEvtLaserAnalyzer.h:65
EcalPerEvtLaserAnalyzer::evtMat
int evtMat
Definition: EcalPerEvtLaserAnalyzer.h:123
MEEEGeom::lmmod
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
Definition: MEEEGeom.cc:112
EcalPerEvtLaserAnalyzer::peakMat
double peakMat
Definition: EcalPerEvtLaserAnalyzer.h:122
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalPerEvtLaserAnalyzer::_timingcuthigh
unsigned int _timingcuthigh
Definition: EcalPerEvtLaserAnalyzer.h:60
TPNFit::doFit
double doFit(int, double *)
Definition: TPNFit.cc:39
EcalPerEvtLaserAnalyzer::nCh
unsigned int nCh
Definition: EcalPerEvtLaserAnalyzer.h:93
std
Definition: JetResolutionObject.h:76
EcalMappingRcd
Definition: EcalMappingRcd.h:15
PulseFitWithFunction
Definition: PulseFitWithFunction.h:26
EcalPerEvtLaserAnalyzer::IsThereDataADC
int IsThereDataADC[nColor]
Definition: EcalPerEvtLaserAnalyzer.h:119
EcalPerEvtLaserAnalyzer::colMat
int colMat
Definition: EcalPerEvtLaserAnalyzer.h:123
EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength
short wavelength
Definition: EcalDCCHeaderBlock.h:67
EcalPerEvtLaserAnalyzer::ADCtrees
TTree * ADCtrees
Definition: EcalPerEvtLaserAnalyzer.h:112
PulseFitWithFunction::doFit
virtual double doFit(double *)
Definition: PulseFitWithFunction.cc:60
MEEBGeom::lmmod
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:90
EcalPerEvtLaserAnalyzer::fedID
int fedID
Definition: EcalPerEvtLaserAnalyzer.h:100
EcalPerEvtLaserAnalyzer::beginJob
void beginJob() override
Definition: EcalPerEvtLaserAnalyzer.cc:118
ecaldqm::towerID
EcalLogicID towerID(EcalElectronicsId const &)
Definition: LogicIDTranslation.cc:37
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
EcalPerEvtLaserAnalyzer::_presamplePN
unsigned int _presamplePN
Definition: EcalPerEvtLaserAnalyzer.h:56
MEEBGeom::localCoord
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
Exception.h
EcalPerEvtLaserAnalyzer::_lastsample
unsigned int _lastsample
Definition: EcalPerEvtLaserAnalyzer.h:52
EcalPerEvtLaserAnalyzer::lightside
int lightside
Definition: EcalPerEvtLaserAnalyzer.h:101
EcalElectronicsId::stripId
int stripId() const
get the tower id
Definition: EcalElectronicsId.h:35
ParameterSet.h
EcalPerEvtLaserAnalyzer
Definition: EcalPerEvtLaserAnalyzer.h:33
EcalPerEvtLaserAnalyzer::runType
int runType
Definition: EcalPerEvtLaserAnalyzer.h:97
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
event
Definition: event.py:1
EEDataFrame
Definition: EEDataFrame.h:12
EcalPerEvtLaserAnalyzer::_tower
unsigned int _tower
Definition: EcalPerEvtLaserAnalyzer.h:63
edm::Event
Definition: Event.h:73
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
EcalElectronicsId::xtalId
int xtalId() const
get the channel id
Definition: EcalElectronicsId.h:37
EcalPerEvtLaserAnalyzer::peak
double peak
Definition: EcalPerEvtLaserAnalyzer.h:122
EcalPerEvtLaserAnalyzer::eventHeaderCollection_
std::string eventHeaderCollection_
Definition: EcalPerEvtLaserAnalyzer.h:72
EcalPerEvtLaserAnalyzer::endJob
void endJob() override
Definition: EcalPerEvtLaserAnalyzer.cc:558
EcalPerEvtLaserAnalyzer::apdTime
double apdTime
Definition: EcalPerEvtLaserAnalyzer.h:137
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
EcalPerEvtLaserAnalyzer::_lastsamplePN
unsigned int _lastsamplePN
Definition: EcalPerEvtLaserAnalyzer.h:58
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
EcalPerEvtLaserAnalyzer::nTT
unsigned int nTT
Definition: EcalPerEvtLaserAnalyzer.h:86