CMS 3D CMS Logo

EcalLaserAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * \class EcalLaserAnalyzer
3  *
4  * primary author: Julie Malcles - CEA/Saclay
5  * author: Gautier Hamel De Monchenault - CEA/Saclay
6  */
7 
8 #include <TAxis.h>
9 #include <TH1.h>
10 #include <TProfile.h>
11 #include <TTree.h>
12 #include <TChain.h>
13 #include <TFile.h>
14 #include <TMath.h>
15 
17 
18 #include <sstream>
19 #include <iostream>
20 #include <fstream>
21 #include <iomanip>
22 
25 
28 
31 
39 
40 #include <vector>
41 
54 
55 //========================================================================
57  //========================================================================
58  : iEvent(0),
59 
60  // Framework parameters with default values
61 
62  _nsamples(iConfig.getUntrackedParameter<unsigned int>("nSamples", 10)),
63  _presample(iConfig.getUntrackedParameter<unsigned int>("nPresamples", 2)),
64  _firstsample(iConfig.getUntrackedParameter<unsigned int>("firstSample", 1)),
65  _lastsample(iConfig.getUntrackedParameter<unsigned int>("lastSample", 2)),
66  _nsamplesPN(iConfig.getUntrackedParameter<unsigned int>("nSamplesPN", 50)),
67  _presamplePN(iConfig.getUntrackedParameter<unsigned int>("nPresamplesPN", 6)),
68  _firstsamplePN(iConfig.getUntrackedParameter<unsigned int>("firstSamplePN", 7)),
69  _lastsamplePN(iConfig.getUntrackedParameter<unsigned int>("lastSamplePN", 8)),
70  _timingcutlow(iConfig.getUntrackedParameter<unsigned int>("timingCutLow", 2)),
71  _timingcuthigh(iConfig.getUntrackedParameter<unsigned int>("timingCutHigh", 9)),
72  _timingquallow(iConfig.getUntrackedParameter<unsigned int>("timingQualLow", 3)),
73  _timingqualhigh(iConfig.getUntrackedParameter<unsigned int>("timingQualHigh", 8)),
74  _ratiomincutlow(iConfig.getUntrackedParameter<double>("ratioMinCutLow", 0.4)),
75  _ratiomincuthigh(iConfig.getUntrackedParameter<double>("ratioMinCutHigh", 0.95)),
76  _ratiomaxcutlow(iConfig.getUntrackedParameter<double>("ratioMaxCutLow", 0.8)),
77  _presamplecut(iConfig.getUntrackedParameter<double>("presampleCut", 5.0)),
78  _niter(iConfig.getUntrackedParameter<unsigned int>("nIter", 3)),
79  _fitab(iConfig.getUntrackedParameter<bool>("fitAB", false)),
80  _alpha(iConfig.getUntrackedParameter<double>("alpha", 1.5076494)),
81  _beta(iConfig.getUntrackedParameter<double>("beta", 1.5136036)),
82  _nevtmax(iConfig.getUntrackedParameter<unsigned int>("nEvtMax", 200)),
83  _noise(iConfig.getUntrackedParameter<double>("noise", 2.0)),
84  _chi2cut(iConfig.getUntrackedParameter<double>("chi2cut", 10.0)),
85  _ecalPart(iConfig.getUntrackedParameter<std::string>("ecalPart", "EB")),
86  _docorpn(iConfig.getUntrackedParameter<bool>("doCorPN", false)),
87  _fedid(iConfig.getUntrackedParameter<int>("fedID", -999)),
88  _saveallevents(iConfig.getUntrackedParameter<bool>("saveAllEvents", false)),
89  _qualpercent(iConfig.getUntrackedParameter<double>("qualPercent", 0.2)),
90  _debug(iConfig.getUntrackedParameter<int>("debug", 0)),
91  nCrys(NCRYSEB),
92  nPNPerMod(NPNPERMOD),
93  nMod(NMODEE),
94  nSides(NSIDES),
95  runType(-1),
96  runNum(0),
97  fedID(-1),
98  dccID(-1),
99  side(2),
100  lightside(2),
101  iZ(1),
102  phi(-1),
103  eta(-1),
104  event(0),
105  color(-1),
106  pn0(0),
107  pn1(0),
108  apdAmpl(0),
109  apdAmplA(0),
110  apdAmplB(0),
111  apdTime(0),
112  pnAmpl(0),
113  pnID(-1),
114  moduleID(-1),
115  channelIteratorEE(0)
116 
117 //========================================================================
118 
119 {
120  // Initialization from cfg file
121 
122  resdir_ = iConfig.getUntrackedParameter<std::string>("resDir");
123  pncorfile_ = iConfig.getUntrackedParameter<std::string>("pnCorFile");
124 
125  digiCollection_ = iConfig.getParameter<std::string>("digiCollection");
126  digiPNCollection_ = iConfig.getParameter<std::string>("digiPNCollection");
127  digiProducer_ = iConfig.getParameter<std::string>("digiProducer");
128 
129  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
130  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
131 
132  // Geometrical constants initialization
133 
134  if (_ecalPart == "EB") {
135  nCrys = NCRYSEB;
136  } else {
137  nCrys = NCRYSEE;
138  }
139  iZ = 1;
140  if (_fedid <= 609)
141  iZ = -1;
143  nMod = modules.size();
144  nRefChan = NREFCHAN;
145 
146  for (unsigned int j = 0; j < nCrys; j++) {
147  iEta[j] = -1;
148  iPhi[j] = -1;
149  iModule[j] = 10;
150  iTowerID[j] = -1;
151  iChannelID[j] = -1;
152  idccID[j] = -1;
153  iside[j] = -1;
154  wasTimingOK[j] = true;
155  wasGainOK[j] = true;
156  }
157 
158  for (unsigned int j = 0; j < nMod; j++) {
159  int ii = modules[j];
160  firstChanMod[ii - 1] = 0;
161  isFirstChanModFilled[ii - 1] = 0;
162  }
163 
164  // Quality check flags
165 
166  isGainOK = true;
167  isTimingOK = true;
168 
169  // PN linearity corrector
170 
172 
173  // Objects dealing with pulses
174 
176  _presample,
177  _firstsample,
178  _lastsample,
187 
188  // Object dealing with MEM numbering
189 
190  Mem = new TMem(_fedid);
191 
192  // Objects needed for npresample calculation
193 
194  Delta01 = new TMom();
195  Delta12 = new TMom();
196 }
197 
198 //========================================================================
200  //========================================================================
201 
202  // do anything here that needs to be done at destruction time
203  // (e.g. close files, deallocate resources etc.)
204 }
205 
206 //========================================================================
208  //========================================================================
209 
210  // Create temporary files and trees to save adc samples
211  //======================================================
212 
213  ADCfile = resdir_;
214  ADCfile += "/APDSamplesLaser.root";
215 
216  APDfile = resdir_;
217  APDfile += "/APDPNLaserAllEvents.root";
218 
219  ADCFile = new TFile(ADCfile.c_str(), "RECREATE");
220 
221  for (unsigned int i = 0; i < nCrys; i++) {
222  std::stringstream name;
223  name << "ADCTree" << i + 1;
224  ADCtrees[i] = new TTree(name.str().c_str(), name.str().c_str());
225 
226  ADCtrees[i]->Branch("ieta", &eta, "eta/I");
227  ADCtrees[i]->Branch("iphi", &phi, "phi/I");
228  ADCtrees[i]->Branch("side", &side, "side/I");
229  ADCtrees[i]->Branch("dccID", &dccID, "dccID/I");
230  ADCtrees[i]->Branch("towerID", &towerID, "towerID/I");
231  ADCtrees[i]->Branch("channelID", &channelID, "channelID/I");
232  ADCtrees[i]->Branch("event", &event, "event/I");
233  ADCtrees[i]->Branch("color", &color, "color/I");
234  ADCtrees[i]->Branch("adc", &adc, "adc[10]/D");
235  ADCtrees[i]->Branch("pn0", &pn0, "pn0/D");
236  ADCtrees[i]->Branch("pn1", &pn1, "pn1/D");
237 
238  ADCtrees[i]->SetBranchAddress("ieta", &eta);
239  ADCtrees[i]->SetBranchAddress("iphi", &phi);
240  ADCtrees[i]->SetBranchAddress("side", &side);
241  ADCtrees[i]->SetBranchAddress("dccID", &dccID);
242  ADCtrees[i]->SetBranchAddress("towerID", &towerID);
243  ADCtrees[i]->SetBranchAddress("channelID", &channelID);
244  ADCtrees[i]->SetBranchAddress("event", &event);
245  ADCtrees[i]->SetBranchAddress("color", &color);
246  ADCtrees[i]->SetBranchAddress("adc", adc);
247  ADCtrees[i]->SetBranchAddress("pn0", &pn0);
248  ADCtrees[i]->SetBranchAddress("pn1", &pn1);
249 
250  nevtAB[i] = 0;
251  }
252 
253  // Define output results filenames and shape analyzer object (alpha,beta)
254  //=====================================================================
255 
256  // 1) AlphaBeta files
257 
258  doesABTreeExist = true;
259 
260  std::stringstream nameabinitfile;
261  nameabinitfile << resdir_ << "/ABInit.root";
262  alphainitfile = nameabinitfile.str();
263 
264  std::stringstream nameabfile;
265  nameabfile << resdir_ << "/AB.root";
266  alphafile = nameabfile.str();
267 
268  FILE* test;
269  if (_fitab)
270  test = fopen(alphainitfile.c_str(), "r");
271  else
272  test = fopen(alphafile.c_str(), "r");
273  if (test == nullptr) {
274  doesABTreeExist = false;
275  _fitab = true;
276  };
277  delete test;
278 
279  TFile* fAB = nullptr;
280  TTree* ABInit = nullptr;
281  if (doesABTreeExist) {
282  fAB = new TFile(nameabinitfile.str().c_str());
283  }
284  if (doesABTreeExist && fAB) {
285  ABInit = (TTree*)fAB->Get("ABCol0");
286  }
287 
288  // 2) Shape analyzer
289 
290  if (doesABTreeExist && fAB && ABInit && ABInit->GetEntries() != 0) {
291  shapana = new TShapeAnalysis(ABInit, _alpha, _beta, 5.5, 1.0);
292  doesABTreeExist = true;
293  } else {
294  shapana = new TShapeAnalysis(_alpha, _beta, 5.5, 1.0);
295  doesABTreeExist = false;
296  _fitab = true;
297  }
299 
300  if (doesABTreeExist && fAB)
301  fAB->Close();
302 
303  // 2) APD file
304 
305  std::stringstream nameapdfile;
306  nameapdfile << resdir_ << "/APDPN_LASER.root";
307  resfile = nameapdfile.str();
308 
309  // Laser events counter
310 
311  laserEvents = 0;
312 }
313 
314 //========================================================================
316  //========================================================================
317 
318  ++iEvent;
319 
320  // retrieving DCC header
321 
323  const EcalRawDataCollection* DCCHeader = nullptr;
324  try {
325  e.getByLabel(eventHeaderProducer_, eventHeaderCollection_, pDCCHeader);
326  DCCHeader = pDCCHeader.product();
327  } catch (std::exception& ex) {
328  std::cerr << "Error! can't get the product retrieving DCC header" << eventHeaderCollection_.c_str() << " "
329  << eventHeaderProducer_.c_str() << std::endl;
330  }
331 
332  //retrieving crystal data from Event
333 
335  const EBDigiCollection* EBDigi = nullptr;
337  const EEDigiCollection* EEDigi = nullptr;
338 
339  if (_ecalPart == "EB") {
340  try {
341  e.getByLabel(digiProducer_, digiCollection_, pEBDigi);
342  EBDigi = pEBDigi.product();
343  } catch (std::exception& ex) {
344  std::cerr << "Error! can't get the product retrieving EB crystal data " << digiCollection_.c_str() << std::endl;
345  }
346  } else if (_ecalPart == "EE") {
347  try {
348  e.getByLabel(digiProducer_, digiCollection_, pEEDigi);
349  EEDigi = pEEDigi.product();
350  } catch (std::exception& ex) {
351  std::cerr << "Error! can't get the product retrieving EE crystal data " << digiCollection_.c_str() << std::endl;
352  }
353  } else {
354  std::cout << " Wrong ecalPart in cfg file " << std::endl;
355  return;
356  }
357 
358  // retrieving crystal PN diodes from Event
359 
361  const EcalPnDiodeDigiCollection* PNDigi = nullptr;
362  try {
363  e.getByLabel(digiProducer_, pPNDigi);
364  PNDigi = pPNDigi.product();
365  } catch (std::exception& ex) {
366  std::cerr << "Error! can't get the product " << digiPNCollection_.c_str() << std::endl;
367  }
368 
369  // retrieving electronics mapping
370 
372  const EcalElectronicsMapping* TheMapping = nullptr;
373  try {
374  c.get<EcalMappingRcd>().get(ecalmapping);
375  TheMapping = ecalmapping.product();
376  } catch (std::exception& ex) {
377  std::cerr << "Error! can't get the product EcalMappingRcd" << std::endl;
378  }
379 
380  // ============================
381  // Decode DCCHeader Information
382  // ============================
383 
384  for (EcalRawDataCollection::const_iterator headerItr = DCCHeader->begin(); headerItr != DCCHeader->end();
385  ++headerItr) {
386  // Get run type and run number
387 
388  int fed = headerItr->fedId();
389  if (fed != _fedid && _fedid != -999)
390  continue;
391 
392  runType = headerItr->getRunType();
393  runNum = headerItr->getRunNumber();
394  event = headerItr->getLV1();
395 
396  dccID = headerItr->getDccInTCCCommand();
397  fedID = headerItr->fedId();
398  lightside = headerItr->getRtHalf();
399 
400  // Check fed corresponds to the DCC in TCC
401 
402  if (600 + dccID != fedID)
403  continue;
404 
405  // Cut on runType
406 
409  return;
410 
411  // Retrieve laser color and event number
412 
413  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
414  color = settings.wavelength;
415  if (color < 0)
416  return;
417 
418  std::vector<int>::iterator iter = find(colors.begin(), colors.end(), color);
419  if (iter == colors.end()) {
420  colors.push_back(color);
421  std::cout << " new color found " << color << " " << colors.size() << std::endl;
422  }
423  }
424 
425  // Cut on fedID
426 
427  if (fedID != _fedid && _fedid != -999)
428  return;
429 
430  // Count laser events
431 
432  laserEvents++;
433 
434  // ======================
435  // Decode PN Information
436  // ======================
437 
438  TPNFit* pnfit = new TPNFit();
440 
441  double chi2pn = 0;
442  unsigned int samplemax = 0;
443  int pnGain = 0;
444 
445  std::map<int, std::vector<double> > allPNAmpl;
446  std::map<int, std::vector<double> > allPNGain;
447 
448  // Loop on PNs digis
449 
450  for (EcalPnDiodeDigiCollection::const_iterator pnItr = PNDigi->begin(); pnItr != PNDigi->end(); ++pnItr) {
451  EcalPnDiodeDetId pnDetId = EcalPnDiodeDetId((*pnItr).id());
452 
453  if (_debug == 1)
454  std::cout << "-- debug -- Inside PNDigi - pnID=" << pnDetId.iPnId() << ", dccID=" << pnDetId.iDCCId()
455  << std::endl;
456 
457  // Skip MEM DCC without relevant data
458 
459  bool isMemRelevant = Mem->isMemRelevant(pnDetId.iDCCId());
460  if (!isMemRelevant)
461  continue;
462 
463  // Loop on PN samples
464 
465  for (int samId = 0; samId < (*pnItr).size(); samId++) {
466  pn[samId] = (*pnItr).sample(samId).adc();
467  pnG[samId] = (*pnItr).sample(samId).gainId();
468  if (samId == 0)
469  pnGain = pnG[samId];
470  if (samId > 0)
471  pnGain = int(TMath::Max(pnG[samId], pnGain));
472  }
473 
474  if (pnGain != 1)
475  std::cout << "PN gain different from 1" << std::endl;
476 
477  // Calculate amplitude from pulse
478 
479  PNPulse->setPulse(pn);
481  samplemax = PNPulse->getMaxSample();
482  chi2pn = pnfit->doFit(samplemax, &pnNoPed[0]);
483  if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
484  pnAmpl = 0.;
485  else
486  pnAmpl = pnfit->getAmpl();
487 
488  // Apply linearity correction
489 
490  double corr = 1.0;
491  if (_docorpn)
493  pnAmpl *= corr;
494 
495  // Fill PN ampl vector
496 
497  allPNAmpl[pnDetId.iDCCId()].push_back(pnAmpl);
498 
499  if (_debug == 1)
500  std::cout << "-- debug -- Inside PNDigi - PNampl=" << pnAmpl << ", PNgain=" << pnGain << std::endl;
501  }
502 
503  // ===========================
504  // Decode EBDigis Information
505  // ===========================
506 
507  int adcGain = 0;
508 
509  if (EBDigi) {
510  // Loop on crystals
511  //===================
512 
513  for (EBDigiCollection::const_iterator digiItr = EBDigi->begin(); digiItr != EBDigi->end(); ++digiItr) {
514  // Retrieve geometry
515  //===================
516 
517  EBDetId id_crystal(digiItr->id());
518  EBDataFrame df(*digiItr);
519  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
520 
521  int etaG = id_crystal.ieta(); // global
522  int phiG = id_crystal.iphi(); // global
523 
524  std::pair<int, int> LocalCoord = MEEBGeom::localCoord(etaG, phiG);
525 
526  int etaL = LocalCoord.first; // local
527  int phiL = LocalCoord.second; // local
528 
529  int strip = elecid_crystal.stripId();
530  int xtal = elecid_crystal.xtalId();
531 
532  int module = MEEBGeom::lmmod(etaG, phiG);
533  int tower = elecid_crystal.towerId();
534 
535  int apdRefTT = MEEBGeom::apdRefTower(module);
536 
537  std::pair<int, int> pnpair = MEEBGeom::pn(module);
538  unsigned int MyPn0 = pnpair.first;
539  unsigned int MyPn1 = pnpair.second;
540 
541  int lmr = MEEBGeom::lmr(etaG, phiG);
542  unsigned int channel = MEEBGeom::electronic_channel(etaL, phiL);
543  assert(channel < nCrys);
544 
545  setGeomEB(etaG, phiG, module, tower, strip, xtal, apdRefTT, channel, lmr);
546 
547  if (_debug == 1)
548  std::cout << "-- debug -- Inside EBDigi - towerID:" << towerID << " channelID:" << channelID
549  << " module:" << module << " modules:" << modules.size() << std::endl;
550 
551  // APD Pulse
552  //===========
553 
554  // Loop on adc samples
555 
556  for (unsigned int i = 0; i < (*digiItr).size(); ++i) {
557  EcalMGPASample samp_crystal(df.sample(i));
558  adc[i] = samp_crystal.adc();
559  adcG[i] = samp_crystal.gainId();
560  adc[i] *= adcG[i];
561  if (i == 0)
562  adcGain = adcG[i];
563  if (i > 0)
564  adcGain = TMath::Max(adcG[i], adcGain);
565  }
566 
568 
569  // Quality checks
570  //================
571 
572  if (adcGain != 1)
573  nEvtBadGain[channel]++;
574  if (!APDPulse->isTimingQualOK())
575  nEvtBadTiming[channel]++;
576  nEvtTot[channel]++;
577 
578  // Associate PN ampl
579  //===================
580 
581  int mem0 = Mem->Mem(lmr, 0);
582  int mem1 = Mem->Mem(lmr, 1);
583 
584  if (allPNAmpl[mem0].size() > MyPn0)
585  pn0 = allPNAmpl[mem0][MyPn0];
586  else
587  pn0 = 0;
588  if (allPNAmpl[mem1].size() > MyPn1)
589  pn1 = allPNAmpl[mem1][MyPn1];
590  else
591  pn1 = 0;
592 
593  // Fill if Pulse is fine
594  //=======================
595 
596  if (APDPulse->isPulseOK() && lightside == side) {
597  ADCtrees[channel]->Fill();
598 
601 
602  if (nevtAB[channel] < _nevtmax && _fitab) {
603  if (doesABTreeExist)
604  shapana->putAllVals(channel, adc, eta, phi);
605  else
607  nevtAB[channel]++;
608  }
609  }
610  }
611 
612  } else if (EEDigi) {
613  // Loop on crystals
614  //===================
615 
616  for (EEDigiCollection::const_iterator digiItr = EEDigi->begin(); digiItr != EEDigi->end(); ++digiItr) {
617  // Retrieve geometry
618  //===================
619 
620  EEDetId id_crystal(digiItr->id());
621  EEDataFrame df(*digiItr);
622  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
623 
624  int etaG = id_crystal.iy();
625  int phiG = id_crystal.ix();
626 
627  int iX = (phiG - 1) / 5 + 1;
628  int iY = (etaG - 1) / 5 + 1;
629 
630  int tower = elecid_crystal.towerId();
631  int ch = elecid_crystal.channelId() - 1;
632 
633  int module = MEEEGeom::lmmod(iX, iY);
634  if (module >= 18 && side == 1)
635  module += 2;
636  int lmr = MEEEGeom::lmr(iX, iY, iZ);
637  int dee = MEEEGeom::dee(lmr);
638  int apdRefTT = MEEEGeom::apdRefTower(lmr, module);
639 
640  std::pair<int, int> pnpair = MEEEGeom::pn(dee, module);
641  unsigned int MyPn0 = pnpair.first;
642  unsigned int MyPn1 = pnpair.second;
643 
644  int hashedIndex = 100000 * eta + phi;
645  if (channelMapEE.count(hashedIndex) == 0) {
648  }
649  unsigned int channel = channelMapEE[hashedIndex];
650  assert(channel < nCrys);
651 
652  setGeomEE(etaG, phiG, iX, iY, iZ, module, tower, ch, apdRefTT, channel, lmr);
653 
654  if (_debug == 1)
655  std::cout << "-- debug -- Inside EEDigi - towerID:" << towerID << " channelID:" << channelID
656  << " module:" << module << " modules:" << modules.size() << std::endl;
657 
658  // APD Pulse
659  //===========
660 
661  if ((*digiItr).size() > 10)
662  std::cout << "SAMPLES SIZE > 10!" << (*digiItr).size() << std::endl;
663 
664  // Loop on adc samples
665 
666  for (unsigned int i = 0; i < (*digiItr).size(); ++i) {
667  EcalMGPASample samp_crystal(df.sample(i));
668  adc[i] = samp_crystal.adc();
669  adcG[i] = samp_crystal.gainId();
670  adc[i] *= adcG[i];
671 
672  if (i == 0)
673  adcGain = adcG[i];
674  if (i > 0)
675  adcGain = TMath::Max(adcG[i], adcGain);
676  }
677 
679 
680  // Quality checks
681  //================
682 
683  if (adcGain != 1)
684  nEvtBadGain[channel]++;
685  if (!APDPulse->isTimingQualOK())
686  nEvtBadTiming[channel]++;
687  nEvtTot[channel]++;
688 
689  // Associate PN ampl
690  //===================
691 
692  int mem0 = Mem->Mem(lmr, 0);
693  int mem1 = Mem->Mem(lmr, 1);
694 
695  if (allPNAmpl[mem0].size() > MyPn0)
696  pn0 = allPNAmpl[mem0][MyPn0];
697  else
698  pn0 = 0;
699  if (allPNAmpl[mem1].size() > MyPn1)
700  pn1 = allPNAmpl[mem1][MyPn1];
701  else
702  pn1 = 0;
703 
704  // Fill if Pulse is fine
705  //=======================
706 
707  if (APDPulse->isPulseOK() && lightside == side) {
708  ADCtrees[channel]->Fill();
709 
712 
713  if (nevtAB[channel] < _nevtmax && _fitab) {
714  if (doesABTreeExist)
715  shapana->putAllVals(channel, adc, eta, phi);
716  else
718  nevtAB[channel]++;
719  }
720  }
721  }
722  }
723 }
724 // analyze
725 
726 //========================================================================
728  //========================================================================
729 
730  // Adjust channel numbers for EE
731  //===============================
732 
733  if (_ecalPart == "EE") {
734  nCrys = channelMapEE.size();
736  }
737 
738  // Set presamples number
739  //======================
740 
741  double delta01 = Delta01->getMean();
742  double delta12 = Delta12->getMean();
743  if (delta12 > _presamplecut) {
744  _presample = 2;
745  if (delta01 > _presamplecut)
746  _presample = 1;
747  }
748 
751 
752  // Get alpha and beta
753  //======================
754 
755  if (_fitab) {
756  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
757  std::cout << "\t+=+ Analyzing data: getting (alpha, beta) +=+" << std::endl;
758  TFile* fAB = nullptr;
759  TTree* ABInit = nullptr;
760  if (doesABTreeExist) {
761  fAB = new TFile(alphainitfile.c_str());
762  }
763  if (doesABTreeExist && fAB) {
764  ABInit = (TTree*)fAB->Get("ABCol0");
765  }
766  shapana->computeShape(alphafile, ABInit);
767  std::cout << "\t+=+ .................................... done +=+" << std::endl;
768  std::cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
769  }
770 
771  // Don't do anything if there is no events
772  //=========================================
773 
774  if (laserEvents == 0) {
775  ADCFile->Close();
776  std::stringstream del;
777  del << "rm " << ADCfile;
778  system(del.str().c_str());
779  std::cout << " No Laser Events " << std::endl;
780  return;
781  }
782 
783  // Set quality flags for gains and timing
784  //=========================================
785 
786  double BadGainEvtPercentage = 0.0;
787  double BadTimingEvtPercentage = 0.0;
788 
789  int nChanBadGain = 0;
790  int nChanBadTiming = 0;
791 
792  for (unsigned int i = 0; i < nCrys; i++) {
793  if (nEvtTot[i] != 0) {
794  BadGainEvtPercentage = double(nEvtBadGain[i]) / double(nEvtTot[i]);
795  BadTimingEvtPercentage = double(nEvtBadTiming[i]) / double(nEvtTot[i]);
796  }
797  if (BadGainEvtPercentage > _qualpercent) {
798  wasGainOK[i] = false;
799  nChanBadGain++;
800  }
801  if (BadTimingEvtPercentage > _qualpercent) {
802  wasTimingOK[i] = false;
803  nChanBadTiming++;
804  }
805  }
806 
807  double BadGainChanPercentage = double(nChanBadGain) / double(nCrys);
808  double BadTimingChanPercentage = double(nChanBadTiming) / double(nCrys);
809 
810  if (BadGainChanPercentage > _qualpercent)
811  isGainOK = false;
812  if (BadTimingChanPercentage > _qualpercent)
813  isTimingOK = false;
814 
815  // Analyze adc samples to get amplitudes
816  //=======================================
817 
818  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
819  std::cout << "\t+=+ Analyzing laser data: getting APD, PN, APD/PN, PN/PN +=+" << std::endl;
820 
821  if (!isGainOK)
822  std::cout << "\t+=+ ............................ WARNING! APD GAIN WAS NOT 1 +=+" << std::endl;
823  if (!isTimingOK)
824  std::cout << "\t+=+ ............................ WARNING! TIMING WAS BAD +=+" << std::endl;
825 
826  APDFile = new TFile(APDfile.c_str(), "RECREATE");
827 
828  int ieta, iphi, channelID, towerID, flag;
829 
830  for (unsigned int i = 0; i < nCrys; i++) {
831  std::stringstream name;
832  name << "APDTree" << i + 1;
833 
834  APDtrees[i] = new TTree(name.str().c_str(), name.str().c_str());
835 
836  //List of branches
837 
838  APDtrees[i]->Branch("event", &event, "event/I");
839  APDtrees[i]->Branch("color", &color, "color/I");
840  APDtrees[i]->Branch("iphi", &iphi, "iphi/I");
841  APDtrees[i]->Branch("ieta", &ieta, "ieta/I");
842  APDtrees[i]->Branch("side", &side, "side/I");
843  APDtrees[i]->Branch("dccID", &dccID, "dccID/I");
844  APDtrees[i]->Branch("towerID", &towerID, "towerID/I");
845  APDtrees[i]->Branch("channelID", &channelID, "channelID/I");
846  APDtrees[i]->Branch("apdAmpl", &apdAmpl, "apdAmpl/D");
847  APDtrees[i]->Branch("apdTime", &apdTime, "apdTime/D");
848  if (_saveallevents)
849  APDtrees[i]->Branch("adc", &adc, "adc[10]/D");
850  APDtrees[i]->Branch("flag", &flag, "flag/I");
851  APDtrees[i]->Branch("flagAB", &flagAB, "flagAB/I");
852  APDtrees[i]->Branch("pn0", &pn0, "pn0/D");
853  APDtrees[i]->Branch("pn1", &pn1, "pn1/D");
854 
855  APDtrees[i]->SetBranchAddress("event", &event);
856  APDtrees[i]->SetBranchAddress("color", &color);
857  APDtrees[i]->SetBranchAddress("iphi", &iphi);
858  APDtrees[i]->SetBranchAddress("ieta", &ieta);
859  APDtrees[i]->SetBranchAddress("side", &side);
860  APDtrees[i]->SetBranchAddress("dccID", &dccID);
861  APDtrees[i]->SetBranchAddress("towerID", &towerID);
862  APDtrees[i]->SetBranchAddress("channelID", &channelID);
863  APDtrees[i]->SetBranchAddress("apdAmpl", &apdAmpl);
864  APDtrees[i]->SetBranchAddress("apdTime", &apdTime);
865  if (_saveallevents)
866  APDtrees[i]->SetBranchAddress("adc", adc);
867  APDtrees[i]->SetBranchAddress("flag", &flag);
868  APDtrees[i]->SetBranchAddress("flagAB", &flagAB);
869  APDtrees[i]->SetBranchAddress("pn0", &pn0);
870  APDtrees[i]->SetBranchAddress("pn1", &pn1);
871  }
872 
873  for (unsigned int iref = 0; iref < nRefChan; iref++) {
874  for (unsigned int imod = 0; imod < nMod; imod++) {
875  int jmod = modules[imod];
876 
877  std::stringstream nameref;
878  nameref << "refAPDTree" << imod << "_" << iref;
879 
880  RefAPDtrees[iref][jmod] = new TTree(nameref.str().c_str(), nameref.str().c_str());
881 
882  RefAPDtrees[iref][jmod]->Branch("eventref", &eventref, "eventref/I");
883  RefAPDtrees[iref][jmod]->Branch("colorref", &colorref, "colorref/I");
884  if (iref == 0)
885  RefAPDtrees[iref][jmod]->Branch("apdAmplA", &apdAmplA, "apdAmplA/D");
886  if (iref == 1)
887  RefAPDtrees[iref][jmod]->Branch("apdAmplB", &apdAmplB, "apdAmplB/D");
888 
889  RefAPDtrees[iref][jmod]->SetBranchAddress("eventref", &eventref);
890  RefAPDtrees[iref][jmod]->SetBranchAddress("colorref", &colorref);
891  if (iref == 0)
892  RefAPDtrees[iref][jmod]->SetBranchAddress("apdAmplA", &apdAmplA);
893  if (iref == 1)
894  RefAPDtrees[iref][jmod]->SetBranchAddress("apdAmplB", &apdAmplB);
895  }
896  }
897 
898  assert(colors.size() <= nColor);
899  unsigned int nCol = colors.size();
900 
901  // Declare PN stuff
902  //===================
903 
904  for (unsigned int iM = 0; iM < nMod; iM++) {
905  unsigned int iMod = modules[iM] - 1;
906 
907  for (unsigned int ich = 0; ich < nPNPerMod; ich++) {
908  for (unsigned int icol = 0; icol < nCol; icol++) {
909  PNFirstAnal[iMod][ich][icol] = new TPN(ich);
910  PNAnal[iMod][ich][icol] = new TPN(ich);
911  }
912  }
913  }
914 
915  // Declare function for APD ampl fit
916  //===================================
917 
919  double chi2;
920 
921  for (unsigned int iCry = 0; iCry < nCrys; iCry++) {
922  for (unsigned int icol = 0; icol < nCol; icol++) {
923  // Declare APD stuff
924  //===================
925 
926  APDFirstAnal[iCry][icol] = new TAPD();
927  IsThereDataADC[iCry][icol] = 1;
928  std::stringstream cut;
929  cut << "color==" << colors[icol];
930  if (ADCtrees[iCry]->GetEntries(cut.str().c_str()) < 10)
931  IsThereDataADC[iCry][icol] = 0;
932  }
933 
934  unsigned int iMod = iModule[iCry] - 1;
935  double alpha, beta;
936 
937  // Loop on events
938  //================
939 
940  Long64_t nbytes = 0, nb = 0;
941  for (Long64_t jentry = 0; jentry < ADCtrees[iCry]->GetEntriesFast(); jentry++) {
942  nb = ADCtrees[iCry]->GetEntry(jentry);
943  nbytes += nb;
944 
945  // Get back color
946 
947  unsigned int iCol = 0;
948  for (unsigned int i = 0; i < nCol; i++) {
949  if (color == colors[i]) {
950  iCol = i;
951  i = colors.size();
952  }
953  }
954 
955  // Retreive alpha and beta
956 
957  std::vector<double> abvals = shapana->getVals(iCry);
958  alpha = abvals[0];
959  beta = abvals[1];
960  flagAB = int(abvals[4]);
961  iphi = iPhi[iCry];
962  ieta = iEta[iCry];
963  towerID = iTowerID[iCry];
964  channelID = iChannelID[iCry];
965 
966  // Amplitude calculation
967 
970 
971  apdAmpl = 0;
972  apdAmplA = 0;
973  apdAmplB = 0;
974  apdTime = 0;
975 
976  if (APDPulse->isPulseOK()) {
978  chi2 = pslsfit->doFit(&adcNoPed[0]);
979 
980  if (chi2 < 0. || chi2 == 102 || chi2 == 101) {
981  apdAmpl = 0;
982  apdTime = 0;
983  flag = 0;
984  } else {
985  apdAmpl = pslsfit->getAmpl();
986  apdTime = pslsfit->getTime();
987  flag = 1;
988  }
989  } else {
990  apdAmpl = 0;
991  apdTime = 0;
992  flag = 0;
993  }
994 
995  if (_debug == 1)
996  std::cout << "-- debug test -- apdAmpl=" << apdAmpl << ", apdTime=" << apdTime << std::endl;
997  double pnmean;
998  if (pn0 < 10 && pn1 > 10) {
999  pnmean = pn1;
1000  } else if (pn1 < 10 && pn0 > 10) {
1001  pnmean = pn0;
1002  } else
1003  pnmean = 0.5 * (pn0 + pn1);
1004 
1005  if (_debug == 1)
1006  std::cout << "-- debug test -- pn0=" << pn0 << ", pn1=" << pn1 << std::endl;
1007 
1008  // Fill PN stuff
1009  //===============
1010 
1011  if (firstChanMod[iMod] == iCry && IsThereDataADC[iCry][iCol] == 1) {
1012  for (unsigned int ichan = 0; ichan < nPNPerMod; ichan++) {
1013  PNFirstAnal[iMod][ichan][iCol]->addEntry(pnmean, pn0, pn1);
1014  }
1015  }
1016 
1017  // Fill APD stuff
1018  //================
1019 
1020  if (APDPulse->isPulseOK()) {
1021  APDFirstAnal[iCry][iCol]->addEntry(apdAmpl, pnmean, pn0, pn1, apdTime);
1022  APDtrees[iCry]->Fill();
1023 
1024  // Fill reference trees
1025  //=====================
1026 
1027  if (apdRefMap[0][iMod + 1] == iCry || apdRefMap[1][iMod + 1] == iCry) {
1028  apdAmplA = 0.0;
1029  apdAmplB = 0.0;
1030  eventref = event;
1031  colorref = color;
1032 
1033  for (unsigned int ir = 0; ir < nRefChan; ir++) {
1034  if (apdRefMap[ir][iMod + 1] == iCry) {
1035  if (ir == 0)
1036  apdAmplA = apdAmpl;
1037  else if (ir == 1)
1038  apdAmplB = apdAmpl;
1039  RefAPDtrees[ir][iMod + 1]->Fill();
1040  }
1041  }
1042  }
1043  }
1044  }
1045  }
1046 
1047  delete pslsfit;
1048 
1049  ADCFile->Close();
1050 
1051  // Remove temporary file
1052  //=======================
1053  std::stringstream del;
1054  del << "rm " << ADCfile;
1055  system(del.str().c_str());
1056 
1057  // Create output trees
1058  //=====================
1059 
1060  resFile = new TFile(resfile.c_str(), "RECREATE");
1061 
1062  for (unsigned int iColor = 0; iColor < nCol; iColor++) {
1063  std::stringstream nametree;
1064  nametree << "APDCol" << colors[iColor];
1065  std::stringstream nametree2;
1066  nametree2 << "PNCol" << colors[iColor];
1067 
1068  restrees[iColor] = new TTree(nametree.str().c_str(), nametree.str().c_str());
1069  respntrees[iColor] = new TTree(nametree2.str().c_str(), nametree2.str().c_str());
1070 
1071  restrees[iColor]->Branch("iphi", &iphi, "iphi/I");
1072  restrees[iColor]->Branch("ieta", &ieta, "ieta/I");
1073  restrees[iColor]->Branch("side", &side, "side/I");
1074  restrees[iColor]->Branch("dccID", &dccID, "dccID/I");
1075  restrees[iColor]->Branch("moduleID", &moduleID, "moduleID/I");
1076  restrees[iColor]->Branch("towerID", &towerID, "towerID/I");
1077  restrees[iColor]->Branch("channelID", &channelID, "channelID/I");
1078  restrees[iColor]->Branch("APD", &APD, "APD[6]/D");
1079  restrees[iColor]->Branch("Time", &Time, "Time[6]/D");
1080  restrees[iColor]->Branch("APDoPN", &APDoPN, "APDoPN[6]/D");
1081  restrees[iColor]->Branch("APDoPNA", &APDoPNA, "APDoPNA[6]/D");
1082  restrees[iColor]->Branch("APDoPNB", &APDoPNB, "APDoPNB[6]/D");
1083  restrees[iColor]->Branch("APDoAPDA", &APDoAPDA, "APDoAPDA[6]/D");
1084  restrees[iColor]->Branch("APDoAPDB", &APDoAPDB, "APDoAPDB[6]/D");
1085  restrees[iColor]->Branch("flag", &flag, "flag/I");
1086 
1087  respntrees[iColor]->Branch("side", &side, "side/I");
1088  respntrees[iColor]->Branch("moduleID", &moduleID, "moduleID/I");
1089  respntrees[iColor]->Branch("pnID", &pnID, "pnID/I");
1090  respntrees[iColor]->Branch("PN", &PN, "PN[6]/D");
1091  respntrees[iColor]->Branch("PNoPN", &PNoPN, "PNoPN[6]/D");
1092  respntrees[iColor]->Branch("PNoPNA", &PNoPNA, "PNoPNA[6]/D");
1093  respntrees[iColor]->Branch("PNoPNB", &PNoPNB, "PNoPNB[6]/D");
1094 
1095  restrees[iColor]->SetBranchAddress("iphi", &iphi);
1096  restrees[iColor]->SetBranchAddress("ieta", &ieta);
1097  restrees[iColor]->SetBranchAddress("side", &side);
1098  restrees[iColor]->SetBranchAddress("dccID", &dccID);
1099  restrees[iColor]->SetBranchAddress("moduleID", &moduleID);
1100  restrees[iColor]->SetBranchAddress("towerID", &towerID);
1101  restrees[iColor]->SetBranchAddress("channelID", &channelID);
1102  restrees[iColor]->SetBranchAddress("APD", APD);
1103  restrees[iColor]->SetBranchAddress("Time", Time);
1104  restrees[iColor]->SetBranchAddress("APDoPN", APDoPN);
1105  restrees[iColor]->SetBranchAddress("APDoPNA", APDoPNA);
1106  restrees[iColor]->SetBranchAddress("APDoPNB", APDoPNB);
1107  restrees[iColor]->SetBranchAddress("APDoAPDA", APDoAPDA);
1108  restrees[iColor]->SetBranchAddress("APDoAPDB", APDoAPDB);
1109  restrees[iColor]->SetBranchAddress("flag", &flag);
1110 
1111  respntrees[iColor]->SetBranchAddress("side", &side);
1112  respntrees[iColor]->SetBranchAddress("moduleID", &moduleID);
1113  respntrees[iColor]->SetBranchAddress("pnID", &pnID);
1114  respntrees[iColor]->SetBranchAddress("PN", PN);
1115  respntrees[iColor]->SetBranchAddress("PNoPN", PNoPN);
1116  respntrees[iColor]->SetBranchAddress("PNoPNA", PNoPNA);
1117  respntrees[iColor]->SetBranchAddress("PNoPNB", PNoPNB);
1118  }
1119 
1120  // Set Cuts for PN stuff
1121  //=======================
1122 
1123  for (unsigned int iM = 0; iM < nMod; iM++) {
1124  unsigned int iMod = modules[iM] - 1;
1125 
1126  for (unsigned int ich = 0; ich < nPNPerMod; ich++) {
1127  for (unsigned int icol = 0; icol < nCol; icol++) {
1128  PNAnal[iMod][ich][icol]->setPNCut(PNFirstAnal[iMod][ich][icol]->getPN().at(0),
1129  PNFirstAnal[iMod][ich][icol]->getPN().at(1));
1130  }
1131  }
1132  }
1133 
1134  // Build ref trees indexes
1135  //========================
1136  for (unsigned int imod = 0; imod < nMod; imod++) {
1137  int jmod = modules[imod];
1138  if (RefAPDtrees[0][jmod]->GetEntries() != 0 && RefAPDtrees[1][jmod]->GetEntries() != 0) {
1139  RefAPDtrees[0][jmod]->BuildIndex("eventref");
1140  RefAPDtrees[1][jmod]->BuildIndex("eventref");
1141  }
1142  }
1143 
1144  // Final loop on crystals
1145  //=======================
1146 
1147  for (unsigned int iCry = 0; iCry < nCrys; iCry++) {
1148  unsigned int iMod = iModule[iCry] - 1;
1149 
1150  // Set cuts on APD stuff
1151  //=======================
1152 
1153  for (unsigned int iCol = 0; iCol < nCol; iCol++) {
1154  std::vector<double> lowcut;
1155  std::vector<double> highcut;
1156  double cutMin;
1157  double cutMax;
1158 
1159  cutMin = APDFirstAnal[iCry][iCol]->getAPD().at(0) - 2.0 * APDFirstAnal[iCry][iCol]->getAPD().at(1);
1160  if (cutMin < 0)
1161  cutMin = 0;
1162  cutMax = APDFirstAnal[iCry][iCol]->getAPD().at(0) + 2.0 * APDFirstAnal[iCry][iCol]->getAPD().at(1);
1163 
1164  lowcut.push_back(cutMin);
1165  highcut.push_back(cutMax);
1166 
1167  cutMin = APDFirstAnal[iCry][iCol]->getTime().at(0) - 2.0 * APDFirstAnal[iCry][iCol]->getTime().at(1);
1168  cutMax = APDFirstAnal[iCry][iCol]->getTime().at(0) + 2.0 * APDFirstAnal[iCry][iCol]->getTime().at(1);
1169  lowcut.push_back(cutMin);
1170  highcut.push_back(cutMax);
1171 
1172  APDAnal[iCry][iCol] = new TAPD();
1173  APDAnal[iCry][iCol]->setAPDCut(APDFirstAnal[iCry][iCol]->getAPD().at(0),
1174  APDFirstAnal[iCry][iCol]->getAPD().at(1));
1175  APDAnal[iCry][iCol]->setAPDoPNCut(APDFirstAnal[iCry][iCol]->getAPDoPN().at(0),
1176  APDFirstAnal[iCry][iCol]->getAPDoPN().at(1));
1177  APDAnal[iCry][iCol]->setAPDoPN0Cut(APDFirstAnal[iCry][iCol]->getAPDoPN0().at(0),
1178  APDFirstAnal[iCry][iCol]->getAPDoPN0().at(1));
1179  APDAnal[iCry][iCol]->setAPDoPN1Cut(APDFirstAnal[iCry][iCol]->getAPDoPN1().at(0),
1180  APDFirstAnal[iCry][iCol]->getAPDoPN1().at(1));
1181  APDAnal[iCry][iCol]->setTimeCut(APDFirstAnal[iCry][iCol]->getTime().at(0),
1182  APDFirstAnal[iCry][iCol]->getTime().at(1));
1183  APDAnal[iCry][iCol]->set2DAPDoAPD0Cut(lowcut, highcut);
1184  APDAnal[iCry][iCol]->set2DAPDoAPD1Cut(lowcut, highcut);
1185  }
1186 
1187  // Final loop on events
1188  //=======================
1189 
1190  Long64_t nbytes = 0, nb = 0;
1191  for (Long64_t jentry = 0; jentry < APDtrees[iCry]->GetEntriesFast(); jentry++) {
1192  nb = APDtrees[iCry]->GetEntry(jentry);
1193  nbytes += nb;
1194 
1195  double pnmean;
1196  if (pn0 < 10 && pn1 > 10) {
1197  pnmean = pn1;
1198  } else if (pn1 < 10 && pn0 > 10) {
1199  pnmean = pn0;
1200  } else
1201  pnmean = 0.5 * (pn0 + pn1);
1202 
1203  // Get back color
1204  //================
1205 
1206  unsigned int iCol = 0;
1207  for (unsigned int i = 0; i < nCol; i++) {
1208  if (color == colors[i]) {
1209  iCol = i;
1210  i = colors.size();
1211  }
1212  }
1213 
1214  // Fill PN stuff
1215  //===============
1216 
1217  if (firstChanMod[iMod] == iCry && IsThereDataADC[iCry][iCol] == 1) {
1218  for (unsigned int ichan = 0; ichan < nPNPerMod; ichan++) {
1219  PNAnal[iMod][ichan][iCol]->addEntry(pnmean, pn0, pn1);
1220  }
1221  }
1222 
1223  // Get ref amplitudes
1224  //===================
1225 
1226  if (_debug == 1)
1227  std::cout << "-- debug test -- Last Loop event:" << event << " apdAmpl:" << apdAmpl << std::endl;
1228  apdAmplA = 0.0;
1229  apdAmplB = 0.0;
1230 
1231  for (unsigned int iRef = 0; iRef < nRefChan; iRef++) {
1232  RefAPDtrees[iRef][iMod + 1]->GetEntryWithIndex(event);
1233  }
1234 
1235  if (_debug == 1)
1236  std::cout << "-- debug test -- Last Loop apdAmplA:" << apdAmplA << " apdAmplB:" << apdAmplB
1237  << ", event:" << event << ", eventref:" << eventref << std::endl;
1238 
1239  // Fill APD stuff
1240  //===============
1241 
1242  APDAnal[iCry][iCol]->addEntry(apdAmpl, pnmean, pn0, pn1, apdTime, apdAmplA, apdAmplB);
1243  }
1244 
1245  moduleID = iMod + 1;
1246 
1247  if (moduleID >= 20)
1248  moduleID -= 2; // Trick to fix endcap specificity
1249 
1250  // Get final results for APD
1251  //===========================
1252 
1253  for (unsigned int iColor = 0; iColor < nCol; iColor++) {
1254  std::vector<double> apdvec = APDAnal[iCry][iColor]->getAPD();
1255  std::vector<double> apdpnvec = APDAnal[iCry][iColor]->getAPDoPN();
1256  std::vector<double> apdpn0vec = APDAnal[iCry][iColor]->getAPDoPN0();
1257  std::vector<double> apdpn1vec = APDAnal[iCry][iColor]->getAPDoPN1();
1258  std::vector<double> timevec = APDAnal[iCry][iColor]->getTime();
1259  std::vector<double> apdapd0vec = APDAnal[iCry][iColor]->getAPDoAPD0();
1260  std::vector<double> apdapd1vec = APDAnal[iCry][iColor]->getAPDoAPD1();
1261 
1262  for (unsigned int i = 0; i < apdvec.size(); i++) {
1263  APD[i] = apdvec.at(i);
1264  APDoPN[i] = apdpnvec.at(i);
1265  APDoPNA[i] = apdpn0vec.at(i);
1266  APDoPNB[i] = apdpn1vec.at(i);
1267  APDoAPDA[i] = apdapd0vec.at(i);
1268  APDoAPDB[i] = apdapd1vec.at(i);
1269  Time[i] = timevec.at(i);
1270  }
1271 
1272  // Fill APD results trees
1273  //========================
1274 
1275  iphi = iPhi[iCry];
1276  ieta = iEta[iCry];
1277  dccID = idccID[iCry];
1278  side = iside[iCry];
1279  towerID = iTowerID[iCry];
1280  channelID = iChannelID[iCry];
1281 
1282  if (!wasGainOK[iCry] || !wasTimingOK[iCry] || IsThereDataADC[iCry][iColor] == 0) {
1283  flag = 0;
1284  } else
1285  flag = 1;
1286 
1287  restrees[iColor]->Fill();
1288  }
1289  }
1290 
1291  // Get final results for PN
1292  //==========================
1293 
1294  for (unsigned int iM = 0; iM < nMod; iM++) {
1295  unsigned int iMod = modules[iM] - 1;
1296 
1297  side = iside[firstChanMod[iMod]];
1298 
1299  for (unsigned int ch = 0; ch < nPNPerMod; ch++) {
1300  pnID = ch;
1301  moduleID = iMod + 1;
1302 
1303  if (moduleID >= 20)
1304  moduleID -= 2; // Trick to fix endcap specificity
1305 
1306  for (unsigned int iColor = 0; iColor < nCol; iColor++) {
1307  std::vector<double> pnvec = PNAnal[iMod][ch][iColor]->getPN();
1308  std::vector<double> pnopnvec = PNAnal[iMod][ch][iColor]->getPNoPN();
1309  std::vector<double> pnopn0vec = PNAnal[iMod][ch][iColor]->getPNoPN0();
1310  std::vector<double> pnopn1vec = PNAnal[iMod][ch][iColor]->getPNoPN1();
1311 
1312  for (unsigned int i = 0; i < pnvec.size(); i++) {
1313  PN[i] = pnvec.at(i);
1314  PNoPN[i] = pnopnvec.at(i);
1315  PNoPNA[i] = pnopn0vec.at(i);
1316  PNoPNB[i] = pnopn1vec.at(i);
1317  }
1318 
1319  // Fill PN results trees
1320  //========================
1321 
1322  respntrees[iColor]->Fill();
1323  }
1324  }
1325  }
1326 
1327  // Remove temporary files
1328  //========================
1329  if (!_saveallevents) {
1330  APDFile->Close();
1331  std::stringstream del2;
1332  del2 << "rm " << APDfile;
1333  system(del2.str().c_str());
1334 
1335  } else {
1336  APDFile->cd();
1337  APDtrees[0]->Write();
1338 
1339  APDFile->Close();
1340  resFile->cd();
1341  }
1342 
1343  // Save results
1344  //===============
1345 
1346  for (unsigned int i = 0; i < nCol; i++) {
1347  restrees[i]->Write();
1348  respntrees[i]->Write();
1349  }
1350 
1351  resFile->Close();
1352 
1353  std::cout << "\t+=+ .................................................. done +=+" << std::endl;
1354  std::cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
1355 }
1356 
1358  int etaG, int phiG, int module, int tower, int strip, int xtal, int apdRefTT, int channel, int lmr) {
1359  side = MEEBGeom::side(etaG, phiG);
1360 
1361  assert(module >= *min_element(modules.begin(), modules.end()) &&
1362  module <= *max_element(modules.begin(), modules.end()));
1363 
1364  eta = etaG;
1365  phi = phiG;
1366  channelID = 5 * (strip - 1) + xtal - 1;
1367  towerID = tower;
1368 
1369  std::vector<int> apdRefChan = ME::apdRefChannels(module, lmr);
1370  for (unsigned int iref = 0; iref < nRefChan; iref++) {
1371  if (channelID == apdRefChan[iref] && towerID == apdRefTT && apdRefMap[iref].count(module) == 0) {
1372  apdRefMap[iref][module] = channel;
1373  }
1374  }
1375 
1376  if (isFirstChanModFilled[module - 1] == 0) {
1377  firstChanMod[module - 1] = channel;
1378  isFirstChanModFilled[module - 1] = 1;
1379  }
1380 
1381  iEta[channel] = eta;
1382  iPhi[channel] = phi;
1383  iModule[channel] = module;
1384  iTowerID[channel] = towerID;
1385  iChannelID[channel] = channelID;
1386  idccID[channel] = dccID;
1387  iside[channel] = side;
1388 }
1389 
1391  int etaG, int phiG, int iX, int iY, int iZ, int module, int tower, int ch, int apdRefTT, int channel, int lmr) {
1392  side = MEEEGeom::side(iX, iY, iZ);
1393 
1394  assert(module >= *min_element(modules.begin(), modules.end()) &&
1395  module <= *max_element(modules.begin(), modules.end()));
1396 
1397  eta = etaG;
1398  phi = phiG;
1399  channelID = ch;
1400  towerID = tower;
1401 
1402  std::vector<int> apdRefChan = ME::apdRefChannels(module, lmr);
1403  for (unsigned int iref = 0; iref < nRefChan; iref++) {
1404  if (channelID == apdRefChan[iref] && towerID == apdRefTT && apdRefMap[iref].count(module) == 0) {
1405  apdRefMap[iref][module] = channel;
1406  }
1407  }
1408 
1409  if (isFirstChanModFilled[module - 1] == 0) {
1410  firstChanMod[module - 1] = channel;
1411  isFirstChanModFilled[module - 1] = 1;
1412  }
1413 
1414  iEta[channel] = eta;
1415  iPhi[channel] = phi;
1416  iModule[channel] = module;
1417  iTowerID[channel] = towerID;
1418  iChannelID[channel] = channelID;
1419  idccID[channel] = dccID;
1420  iside[channel] = side;
1421 }
1422 
EcalLaserAnalyzer::_fedid
int _fedid
Definition: EcalLaserAnalyzer.h:92
DeadROC_duringRun.runNum
runNum
Definition: DeadROC_duringRun.py:21
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
NCRYSEE
#define NCRYSEE
Definition: EcalABAnalyzer.h:33
TMom::addEntry
void addEntry(double val)
Definition: TMom.cc:88
EcalLaserAnalyzer::pn
double pn[50]
Definition: EcalLaserAnalyzer.h:181
EcalLaserAnalyzer::resfile
std::string resfile
Definition: EcalLaserAnalyzer.h:119
TAPDPulse::getAdcWithoutPedestal
double * getAdcWithoutPedestal()
Definition: TAPDPulse.cc:237
EcalLaserAnalyzer::PNFirstAnal
TPN * PNFirstAnal[22][2][nColor]
Definition: EcalLaserAnalyzer.h:196
TAPD::getAPDoAPD1
std::vector< double > getAPDoAPD1()
Definition: TAPD.cc:241
EcalElectronicsId.h
EcalLaserAnalyzer::nEvtBadTiming
int nEvtBadTiming[1700]
Definition: EcalLaserAnalyzer.h:225
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
EcalLaserAnalyzer::EcalLaserAnalyzer
EcalLaserAnalyzer(const edm::ParameterSet &iConfig)
Definition: EcalLaserAnalyzer.cc:56
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
EcalLaserAnalyzer::adcNoPed
double * adcNoPed
Definition: EcalLaserAnalyzer.h:192
TAPD::getAPD
std::vector< double > getAPD()
Definition: TAPD.cc:216
PulseFitWithFunction.h
EcalLaserAnalyzer::_presamplePN
unsigned int _presamplePN
Definition: EcalLaserAnalyzer.h:72
EcalLaserAnalyzer::apdRefMap
std::map< int, unsigned int > apdRefMap[2]
Definition: EcalLaserAnalyzer.h:171
colors
Definition: colors.py:1
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalLaserAnalyzer::_ratiomaxcutlow
double _ratiomaxcutlow
Definition: EcalLaserAnalyzer.h:81
EcalLaserAnalyzer::Time
double Time[6]
Definition: EcalLaserAnalyzer.h:210
TPNPulse.h
TPNFit
Definition: TPNFit.h:8
EcalLaserAnalyzer::APDFile
TFile * APDFile
Definition: EcalLaserAnalyzer.h:160
TPNPulse::setPulse
bool setPulse(double *)
Definition: TPNPulse.cc:45
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
TMem.h
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
TPN::getPNoPN0
std::vector< double > getPNoPN0()
Definition: TPN.cc:98
TAPDPulse::setPresamples
void setPresamples(int)
Definition: TAPDPulse.cc:251
MEEBGeom::electronic_channel
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:326
TPN
Definition: TPN.h:8
EcalLaserAnalyzer::pnAmpl
double pnAmpl
Definition: EcalLaserAnalyzer.h:187
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
modules
Definition: ZHLTMatchFilter.cc:17
EcalLaserAnalyzer::wasTimingOK
bool wasTimingOK[1700]
Definition: EcalLaserAnalyzer.h:229
EcalLaserAnalyzer::_niter
unsigned int _niter
Definition: EcalLaserAnalyzer.h:83
EBDetId
Definition: EBDetId.h:17
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
EcalLaserAnalyzer::channelID
int channelID
Definition: EcalLaserAnalyzer.h:141
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
EcalLaserAnalyzer::side
int side
Definition: EcalLaserAnalyzer.h:144
EBDataFrame
Definition: EBDataFrame.h:11
ME::apdRefChannels
static std::vector< int > apdRefChannels(ME::LMMid ilmmod, ME::LMRid ilmr)
Definition: ME.cc:545
TShapeAnalysis::putAllVals
void putAllVals(int, double *, int, int)
Definition: TShapeAnalysis.cc:185
EcalLaserAnalyzer::eventref
int eventref
Definition: EcalLaserAnalyzer.h:189
EcalLaserAnalyzer::pnG
int pnG[50]
Definition: EcalLaserAnalyzer.h:182
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalLaserAnalyzer::_nevtmax
unsigned int _nevtmax
Definition: EcalLaserAnalyzer.h:87
EcalLaserAnalyzer::idccID
int idccID[1700]
Definition: EcalLaserAnalyzer.h:218
EcalDetIdCollections.h
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
EcalLaserAnalyzer::_ratiomincutlow
double _ratiomincutlow
Definition: EcalLaserAnalyzer.h:79
EcalLaserAnalyzer::eta
int eta
Definition: EcalLaserAnalyzer.h:175
EcalPnDiodeDetId::iPnId
int iPnId() const
get the PnId
Definition: EcalPnDiodeDetId.h:46
TPNCor.h
MEEBGeom::lmr
static int lmr(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:110
CollectionTags_cfi.EBDigi
EBDigi
Definition: CollectionTags_cfi.py:27
cms::cuda::assert
assert(be >=bs)
EcalLaserAnalyzer::nRefChan
unsigned int nRefChan
Definition: EcalLaserAnalyzer.h:128
edm::SortedCollection
Definition: SortedCollection.h:49
TPN::getPN
std::vector< double > getPN()
Definition: TPN.cc:90
EcalLaserAnalyzer::_ratiomincuthigh
double _ratiomincuthigh
Definition: EcalLaserAnalyzer.h:80
EcalLaserAnalyzer::iEvent
int iEvent
Definition: EcalLaserAnalyzer.h:63
TAPDPulse.h
EcalLaserAnalyzer::~EcalLaserAnalyzer
~EcalLaserAnalyzer() override
Definition: EcalLaserAnalyzer.cc:199
NCRYSEB
#define NCRYSEB
Definition: EcalABAnalyzer.h:30
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalLaserAnalyzer::_timingquallow
unsigned int _timingquallow
Definition: EcalLaserAnalyzer.h:77
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
PulseFitWithFunction::init
virtual void init(int, int, int, int, double, double)
Definition: PulseFitWithFunction.cc:37
edmStreamStallGrapher.getTime
def getTime(line)
Definition: edmStreamStallGrapher.py:179
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
MEEBGeom::pn
static std::pair< int, int > pn(int ilmmod)
Definition: MEEBGeom.cc:447
EcalLaserAnalyzer::nMod
unsigned int nMod
Definition: EcalLaserAnalyzer.h:130
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
EcalLaserAnalyzer::Delta12
TMom * Delta12
Definition: EcalLaserAnalyzer.h:101
ME::lmmodFromDcc
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
Definition: ME.cc:574
TAPD.h
EcalLaserAnalyzer::APD
double APD[6]
Definition: EcalLaserAnalyzer.h:210
EcalLaserAnalyzer::pn0
double pn0
Definition: EcalLaserAnalyzer.h:180
EcalLaserAnalyzer::digiCollection_
std::string digiCollection_
Definition: EcalLaserAnalyzer.h:107
EcalLaserAnalyzer::wasGainOK
bool wasGainOK[1700]
Definition: EcalLaserAnalyzer.h:228
MEEEGeom::apdRefTower
static int apdRefTower(int ilmr, int ilmmod)
Definition: MEEEGeom.cc:1208
EcalLaserAnalyzer::apdAmplB
double apdAmplB
Definition: EcalLaserAnalyzer.h:185
EcalLaserAnalyzer::digiPNCollection_
std::string digiPNCollection_
Definition: EcalLaserAnalyzer.h:108
TShapeAnalysis::getVals
std::vector< double > getVals(int)
Definition: TShapeAnalysis.cc:439
TAPDPulse
Definition: TAPDPulse.h:7
EcalLaserAnalyzer::isFirstChanModFilled
unsigned int isFirstChanModFilled[22]
Definition: EcalLaserAnalyzer.h:220
TPN::getPNoPN
std::vector< double > getPNoPN()
Definition: TPN.cc:94
EcalLaserAnalyzer::_lastsamplePN
unsigned int _lastsamplePN
Definition: EcalLaserAnalyzer.h:74
EcalElectronicsId::towerId
int towerId() const
get the tower id
Definition: EcalElectronicsId.h:33
EcalLaserAnalyzer::digiProducer_
std::string digiProducer_
Definition: EcalLaserAnalyzer.h:109
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalDCCHeaderBlock::LASER_GAP
Definition: EcalDCCHeaderBlock.h:42
EcalLaserAnalyzer::_docorpn
bool _docorpn
Definition: EcalLaserAnalyzer.h:91
EcalLaserAnalyzer::_timingcutlow
unsigned int _timingcutlow
Definition: EcalLaserAnalyzer.h:75
TAPD::getAPDoPN
std::vector< double > getAPDoPN()
Definition: TAPD.cc:220
MEEBGeom::side
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:105
EcalRawDataCollections.h
EcalLaserAnalyzer::PNAnal
TPN * PNAnal[22][2][nColor]
Definition: EcalLaserAnalyzer.h:197
MakerMacros.h
EcalLaserAnalyzer::runNum
int runNum
Definition: EcalLaserAnalyzer.h:136
EcalLaserAnalyzer::beginJob
void beginJob() override
Definition: EcalLaserAnalyzer.cc:207
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
EcalLaserAnalyzer::_timingcuthigh
unsigned int _timingcuthigh
Definition: EcalLaserAnalyzer.h:76
TMem::Mem
int Mem(int, int)
Definition: TMem.cc:41
TAPDPulse::setPulse
bool setPulse(double *)
Definition: TAPDPulse.cc:86
EcalElectronicsId::channelId
int channelId() const
so far for EndCap only :
Definition: EcalElectronicsId.cc:71
TAPD::getTime
std::vector< double > getTime()
Definition: TAPD.cc:232
TPNPulse::getAdcWithoutPedestal
double * getAdcWithoutPedestal()
Definition: TPNPulse.cc:89
EcalLaserAnalyzer::_qualpercent
double _qualpercent
Definition: EcalLaserAnalyzer.h:94
PulseFitWithFunction::getAmpl
double getAmpl()
Definition: PulseFitWithFunction.h:52
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
EcalLaserAnalyzer::_nsamplesPN
unsigned int _nsamplesPN
Definition: EcalLaserAnalyzer.h:71
PVValHelper::eta
Definition: PVValidationHelpers.h:69
TAPD::setAPDoPNCut
void setAPDoPNCut(double, double)
Definition: TAPD.cc:142
EcalLaserAnalyzer::_presample
unsigned int _presample
Definition: EcalLaserAnalyzer.h:68
EcalMappingRcd.h
EcalLaserAnalyzer::APDoPNB
double APDoPNB[6]
Definition: EcalLaserAnalyzer.h:210
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
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
EcalLaserAnalyzer::Delta01
TMom * Delta01
Definition: EcalLaserAnalyzer.h:100
EcalLaserAnalyzer::PNoPNA
double PNoPNA[6]
Definition: EcalLaserAnalyzer.h:210
NSIDES
#define NSIDES
Definition: EcalLaserAnalyzer.h:44
EcalLaserAnalyzer::event
int event
Definition: EcalLaserAnalyzer.h:176
EcalLaserAnalyzer::apdTime
double apdTime
Definition: EcalLaserAnalyzer.h:186
EcalLaserAnalyzer::channelMapEE
std::map< unsigned int, unsigned int > channelMapEE
Definition: EcalLaserAnalyzer.h:169
EcalLaserAnalyzer::APDFirstAnal
TAPD * APDFirstAnal[1700][nColor]
Definition: EcalLaserAnalyzer.h:200
TAPDPulse::isTimingQualOK
bool isTimingQualOK()
Definition: TAPDPulse.cc:145
EcalLaserAnalyzer::dccID
int dccID
Definition: EcalLaserAnalyzer.h:143
EcalLaserAnalyzer::nEvtBadGain
int nEvtBadGain[1700]
Definition: EcalLaserAnalyzer.h:224
NREFCHAN
#define NREFCHAN
Definition: EcalLaserAnalyzer.h:45
MEGeom.h
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
EcalLaserAnalyzer::RefAPDtrees
TTree * RefAPDtrees[2][22]
Definition: EcalLaserAnalyzer.h:162
MEEEGeom::pn
static std::pair< int, int > pn(int dee, int ilmod)
Definition: MEEEGeom.cc:574
EcalLaserAnalyzer::laserEvents
int laserEvents
Definition: EcalLaserAnalyzer.h:149
EcalLaserAnalyzer::phi
int phi
Definition: EcalLaserAnalyzer.h:175
EEDetId
Definition: EEDetId.h:14
EcalLaserAnalyzer::iZ
int iZ
Definition: EcalLaserAnalyzer.h:146
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDCCHeaderBlock::LASER_POWER_SCAN
Definition: EcalDCCHeaderBlock.h:27
EcalDCCHeaderBlock::EcalDCCEventSettings
Definition: EcalDCCHeaderBlock.h:64
MEEEGeom::dee
static int dee(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:292
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
TAPD::setAPDCut
void setAPDCut(double, double)
Definition: TAPD.cc:141
EcalLaserAnalyzer::apdAmpl
double apdAmpl
Definition: EcalLaserAnalyzer.h:183
TShapeAnalysis.h
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
NPNPERMOD
#define NPNPERMOD
Definition: EcalLaserAnalyzer.h:38
TShapeAnalysis::set_presample
void set_presample(int)
Definition: TShapeAnalysis.cc:145
EcalLaserAnalyzer::flag
int flag
Definition: EcalLaserAnalyzer.h:207
TAPD::setAPDoPN1Cut
void setAPDoPN1Cut(double, double)
Definition: TAPD.cc:144
TPNFit.h
EcalPnDiodeDetId::iDCCId
int iDCCId() const
get the DCCId
Definition: EcalPnDiodeDetId.h:44
edm::ParameterSet
Definition: ParameterSet.h:47
TMom
Definition: TMom.h:7
EcalLaserAnalyzer::eventHeaderProducer_
std::string eventHeaderProducer_
Definition: EcalLaserAnalyzer.h:111
Event.h
TPNFit::getAmpl
double getAmpl()
Definition: TPNFit.h:31
PVValHelper::phi
Definition: PVValidationHelpers.h:68
TAPDPulse::isPulseOK
bool isPulseOK()
Definition: TAPDPulse.cc:162
TPN::addEntry
void addEntry(double, double, double)
Definition: TPN.cc:33
EcalLaserAnalyzer::iModule
unsigned int iModule[1700]
Definition: EcalLaserAnalyzer.h:217
EcalLaserAnalyzer::APDoPNA
double APDoPNA[6]
Definition: EcalLaserAnalyzer.h:210
EBDigiCollection
Definition: EcalDigiCollections.h:56
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalLaserAnalyzer::iEta
int iEta[1700]
Definition: EcalLaserAnalyzer.h:216
EEDigiCollection
Definition: EcalDigiCollections.h:69
EcalLaserAnalyzer::nPNPerMod
unsigned int nPNPerMod
Definition: EcalLaserAnalyzer.h:127
EcalLaserAnalyzer::firstChanMod
unsigned int firstChanMod[22]
Definition: EcalLaserAnalyzer.h:219
EcalLaserAnalyzer::alphainitfile
std::string alphainitfile
Definition: EcalLaserAnalyzer.h:116
EcalLaserAnalyzer::APDPulse
TAPDPulse * APDPulse
Definition: EcalLaserAnalyzer.h:97
EcalLaserAnalyzer::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: EcalLaserAnalyzer.cc:315
TShapeAnalysis::computeShape
void computeShape(std::string namefile, TTree *)
Definition: TShapeAnalysis.cc:205
TPNCor::getPNCorrectionFactor
double getPNCorrectionFactor(double val0, int gain)
Definition: TPNCor.cc:64
EcalElectronicsMapping.h
EcalLaserAnalyzer::shapana
TShapeAnalysis * shapana
Definition: EcalLaserAnalyzer.h:121
EcalLaserAnalyzer::PN
double PN[6]
Definition: EcalLaserAnalyzer.h:210
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
EcalLaserAnalyzer::channelIteratorEE
int channelIteratorEE
Definition: EcalLaserAnalyzer.h:208
EcalLaserAnalyzer::Mem
TMem * Mem
Definition: EcalLaserAnalyzer.h:99
EcalLaserAnalyzer::isGainOK
bool isGainOK
Definition: EcalLaserAnalyzer.h:232
EcalLaserAnalyzer::PNoPN
double PNoPN[6]
Definition: EcalLaserAnalyzer.h:210
EcalLaserAnalyzer::_timingqualhigh
unsigned int _timingqualhigh
Definition: EcalLaserAnalyzer.h:78
EcalLaserAnalyzer::fedID
int fedID
Definition: EcalLaserAnalyzer.h:142
ME.h
PulseFitWithFunction::getTime
double getTime()
Definition: PulseFitWithFunction.h:53
EcalLaserAnalyzer::restrees
TTree * restrees[nColor]
Definition: EcalLaserAnalyzer.h:165
EcalLaserAnalyzer::PNPulse
TPNPulse * PNPulse
Definition: EcalLaserAnalyzer.h:98
TMem
Definition: TMem.h:7
EcalLaserAnalyzer::_ecalPart
std::string _ecalPart
Definition: EcalLaserAnalyzer.h:90
EcalLaserAnalyzer::ADCFile
TFile * ADCFile
Definition: EcalLaserAnalyzer.h:157
Max
T Max(T a, T b)
Definition: MathUtil.h:44
TAPD::addEntry
void addEntry(double, double, double, double, double, double, double)
Definition: TAPD.cc:42
EcalLaserAnalyzer::APDtrees
TTree * APDtrees[1700]
Definition: EcalLaserAnalyzer.h:161
edm::EventSetup
Definition: EventSetup.h:57
EcalLaserAnalyzer::iTowerID
int iTowerID[1700]
Definition: EcalLaserAnalyzer.h:218
TPNFit::init
void init(int, int, int)
Definition: TPNFit.cc:24
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
TShapeAnalysis
Definition: TShapeAnalysis.h:10
EcalLaserAnalyzer::flagAB
int flagAB
Definition: EcalLaserAnalyzer.h:207
get
#define get
TAPD
Definition: TAPD.h:8
EcalLaserAnalyzer::apdAmplA
double apdAmplA
Definition: EcalLaserAnalyzer.h:184
EcalLaserAnalyzer::_firstsample
unsigned int _firstsample
Definition: EcalLaserAnalyzer.h:69
TAPDPulse::getDelta
double getDelta(int, int)
Definition: TAPDPulse.cc:116
EcalLaserAnalyzer::adc
double adc[10]
Definition: EcalLaserAnalyzer.h:178
EcalLaserAnalyzer::ADCtrees
TTree * ADCtrees[1700]
Definition: EcalLaserAnalyzer.h:158
MEEBGeom::apdRefTower
static int apdRefTower(int ilmmod)
Definition: MEEBGeom.cc:490
TMom::getMean
double getMean()
Definition: TMom.cc:121
EcalMGPASample
Definition: EcalMGPASample.h:22
EcalLaserAnalyzer
Definition: EcalLaserAnalyzer.h:47
TMem::isMemRelevant
bool isMemRelevant(int)
Definition: TMem.cc:30
EcalLaserAnalyzer::eventHeaderCollection_
std::string eventHeaderCollection_
Definition: EcalLaserAnalyzer.h:110
EcalLaserAnalyzer::_fitab
bool _fitab
Definition: EcalLaserAnalyzer.h:84
MEEEGeom::lmmod
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
Definition: MEEEGeom.cc:112
NMODEE
#define NMODEE
Definition: EcalLaserAnalyzer.h:42
EcalLaserAnalyzer::APDoAPDB
double APDoAPDB[6]
Definition: EcalLaserAnalyzer.h:210
MEEEGeom::lmr
static int lmr(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:254
TPNFit::doFit
double doFit(int, double *)
Definition: TPNFit.cc:39
TPNCor
Definition: TPNCor.h:7
EcalLaserAnalyzer::setGeomEB
void setGeomEB(int etaG, int phiG, int module, int tower, int strip, int xtal, int apdRefTT, int channel, int lmr)
Definition: EcalLaserAnalyzer.cc:1357
TAPD::getAPDoPN0
std::vector< double > getAPDoPN0()
Definition: TAPD.cc:224
TAPD::setTimeCut
void setTimeCut(double, double)
Definition: TAPD.cc:145
std
Definition: JetResolutionObject.h:76
EcalLaserAnalyzer::color
int color
Definition: EcalLaserAnalyzer.h:177
EcalLaserAnalyzer.h
EcalMappingRcd
Definition: EcalMappingRcd.h:15
EcalLaserAnalyzer::_beta
double _beta
Definition: EcalLaserAnalyzer.h:86
EcalLaserAnalyzer::APDoAPDA
double APDoAPDA[6]
Definition: EcalLaserAnalyzer.h:210
EcalLaserAnalyzer::_debug
int _debug
Definition: EcalLaserAnalyzer.h:95
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
EcalLaserAnalyzer::ADCfile
std::string ADCfile
Definition: EcalLaserAnalyzer.h:117
PulseFitWithFunction
Definition: PulseFitWithFunction.h:26
EcalLaserAnalyzer::isTimingOK
bool isTimingOK
Definition: EcalLaserAnalyzer.h:233
EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength
short wavelength
Definition: EcalDCCHeaderBlock.h:67
PulseFitWithFunction::doFit
virtual double doFit(double *)
Definition: PulseFitWithFunction.cc:60
TShapeAnalysis::set_nch
void set_nch(int)
Definition: TShapeAnalysis.cc:146
TAPD::set2DAPDoAPD1Cut
void set2DAPDoAPD1Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:181
EcalLaserAnalyzer::pn1
double pn1
Definition: EcalLaserAnalyzer.h:180
EcalLaserAnalyzer::setGeomEE
void setGeomEE(int etaG, int phiG, int iX, int iY, int iZ, int module, int tower, int ch, int apdRefTT, int channel, int lmr)
Definition: EcalLaserAnalyzer.cc:1390
EcalLaserAnalyzer::towerID
int towerID
Definition: EcalLaserAnalyzer.h:140
MEEBGeom::lmmod
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:90
EcalLaserAnalyzer::IsThereDataADC
int IsThereDataADC[1700][nColor]
Definition: EcalLaserAnalyzer.h:203
EcalLaserAnalyzer::adcG
int adcG[10]
Definition: EcalLaserAnalyzer.h:179
TMom.h
EcalLaserAnalyzer::APDoPN
double APDoPN[6]
Definition: EcalLaserAnalyzer.h:210
EcalDCCHeaderBlock::LASER_DELAY_SCAN
Definition: EcalDCCHeaderBlock.h:28
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
TPN::setPNCut
void setPNCut(double, double)
Definition: TPN.cc:70
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MEEBGeom::localCoord
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
Exception.h
TShapeAnalysis::set_const
void set_const(int, int, int, int, int, double, double)
Definition: TShapeAnalysis.cc:135
EcalLaserAnalyzer::iside
int iside[1700]
Definition: EcalLaserAnalyzer.h:218
EcalLaserAnalyzer::pncorfile_
std::string pncorfile_
Definition: EcalLaserAnalyzer.h:106
EcalLaserAnalyzer::PNoPNB
double PNoPNB[6]
Definition: EcalLaserAnalyzer.h:210
TAPD::getAPDoAPD0
std::vector< double > getAPDoAPD0()
Definition: TAPD.cc:236
EcalLaserAnalyzer::nEvtTot
int nEvtTot[1700]
Definition: EcalLaserAnalyzer.h:226
TPN.h
MEEEGeom::side
static int side(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:1155
EcalElectronicsId::stripId
int stripId() const
get the tower id
Definition: EcalElectronicsId.h:35
EcalLaserAnalyzer::APDfile
std::string APDfile
Definition: EcalLaserAnalyzer.h:118
EcalLaserAnalyzer::doesABTreeExist
bool doesABTreeExist
Definition: EcalLaserAnalyzer.h:103
EcalLaserAnalyzer::nColor
Definition: EcalLaserAnalyzer.h:60
EcalLaserAnalyzer::nevtAB
unsigned int nevtAB[1700]
Definition: EcalLaserAnalyzer.h:122
ParameterSet.h
EcalLaserAnalyzer::runType
int runType
Definition: EcalLaserAnalyzer.h:135
EcalLaserAnalyzer::_saveallevents
bool _saveallevents
Definition: EcalLaserAnalyzer.h:93
EcalLaserAnalyzer::pnCorrector
TPNCor * pnCorrector
Definition: EcalLaserAnalyzer.h:153
TAPD::setAPDoPN0Cut
void setAPDoPN0Cut(double, double)
Definition: TAPD.cc:143
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
EcalLaserAnalyzer::pnNoPed
double * pnNoPed
Definition: EcalLaserAnalyzer.h:193
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TPN::getPNoPN1
std::vector< double > getPNoPN1()
Definition: TPN.cc:102
TAPD::getAPDoPN1
std::vector< double > getAPDoPN1()
Definition: TAPD.cc:228
event
Definition: event.py:1
EEDataFrame
Definition: EEDataFrame.h:12
edm::Event
Definition: Event.h:73
EcalLaserAnalyzer::resFile
TFile * resFile
Definition: EcalLaserAnalyzer.h:164
EcalLaserAnalyzer::resdir_
std::string resdir_
Definition: EcalLaserAnalyzer.h:105
TPNPulse::getMaxSample
int getMaxSample()
Definition: TPNPulse.cc:70
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
EcalElectronicsId::xtalId
int xtalId() const
get the channel id
Definition: EcalElectronicsId.h:37
EcalLaserAnalyzer::iPhi
int iPhi[1700]
Definition: EcalLaserAnalyzer.h:216
ecalpyutils::hashedIndex
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
EcalLaserAnalyzer::_lastsample
unsigned int _lastsample
Definition: EcalLaserAnalyzer.h:70
EcalLaserAnalyzer::pnID
int pnID
Definition: EcalLaserAnalyzer.h:207
EcalLaserAnalyzer::nCrys
unsigned int nCrys
Definition: EcalLaserAnalyzer.h:126
cuy.ii
ii
Definition: cuy.py:590
EcalLaserAnalyzer::endJob
void endJob() override
Definition: EcalLaserAnalyzer.cc:727
EcalLaserAnalyzer::_firstsamplePN
unsigned int _firstsamplePN
Definition: EcalLaserAnalyzer.h:73
EcalLaserAnalyzer::alphafile
std::string alphafile
Definition: EcalLaserAnalyzer.h:115
EcalLaserAnalyzer::_noise
double _noise
Definition: EcalLaserAnalyzer.h:88
EcalLaserAnalyzer::_chi2cut
double _chi2cut
Definition: EcalLaserAnalyzer.h:89
EcalLaserAnalyzer::colorref
int colorref
Definition: EcalLaserAnalyzer.h:190
EcalLaserAnalyzer::_nsamples
unsigned int _nsamples
Definition: EcalLaserAnalyzer.h:67
EcalLaserAnalyzer::_presamplecut
double _presamplecut
Definition: EcalLaserAnalyzer.h:82
EcalLaserAnalyzer::iChannelID
int iChannelID[1700]
Definition: EcalLaserAnalyzer.h:218
EcalLaserAnalyzer::_alpha
double _alpha
Definition: EcalLaserAnalyzer.h:85
TAPD::set2DAPDoAPD0Cut
void set2DAPDoAPD0Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:173
EcalLaserAnalyzer::respntrees
TTree * respntrees[nColor]
Definition: EcalLaserAnalyzer.h:166
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
EcalLaserAnalyzer::lightside
int lightside
Definition: EcalLaserAnalyzer.h:145
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
EcalLaserAnalyzer::APDAnal
TAPD * APDAnal[1700][nColor]
Definition: EcalLaserAnalyzer.h:201
EcalLaserAnalyzer::moduleID
int moduleID
Definition: EcalLaserAnalyzer.h:207
TPNPulse
Definition: TPNPulse.h:7