CMS 3D CMS Logo

EcnaAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalCorrelatedNoiseAnalysisModules
4 // Class: EcnaAnalyzer
5 // // class EcnaAnalyzer
6 // EcnaAnalyzer.cc
7 // CalibCalorimetry/EcalCorrelatedNoiseAnalysisModules/src/EcnaAnalyzer.cc
8 
9 // Description: <one line class summary>
10 
11 // Implementation:
12 // <Notes on implementation>
13 
14 //
15 // Original Author: Bernard Fabbro
16 // Created: Fri Jun 2 10:27:01 CEST 2006
17 // $Id: EcnaAnalyzer.cc,v 1.4 2013/04/05 20:17:20 wmtan Exp $
18 //
19 // Update: 21/07/2011
20 
21 // CMSSW include files
22 
23 //#include <signal.h>
24 
26 #include <vector>
28 
29 //--------------------------------------
30 // EcnaAnalyzer.cc
31 // Class creation: 02 June 2006
32 // Documentation: see EcnaAnalyzer.h
33 //--------------------------------------
34 //
35 // constants, enums and typedefs
36 //
37 
38 //
39 // static data member definitions
40 //
41 
42 //
43 // Constructor and destructor
44 //
46  : verbosity_(pSet.getUntrackedParameter("verbosity", 1U)),
47  nChannels_(0),
48  iEvent_(0),
49  fMyEBNumbering(&fMyEcnaEBObjectManager, "EB"),
50  fMyEBEcal(&fMyEcnaEBObjectManager, "EB"),
51  fMyEENumbering(&fMyEcnaEEObjectManager, "EE"),
52  fMyEEEcal(&fMyEcnaEEObjectManager, "EE") {
53  // now do what ever initialization is needed
54 
55  std::unique_ptr<TEcnaParPaths> myPathEB = std::make_unique<TEcnaParPaths>(&fMyEcnaEBObjectManager);
56  std::unique_ptr<TEcnaParPaths> myPathEE = std::make_unique<TEcnaParPaths>(&fMyEcnaEEObjectManager);
57 
58  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-constructor> Check path for resultsq Root files.";
59 
60  if (myPathEB->GetPathForResultsRootFiles() == kFALSE) {
61  edm::LogError("ecnaAnal") << "*EcnaAnalyzer-constructor> *** ERROR *** Path for result files not found.";
62  throw cms::Exception("Calibration") << "*EcnaAnalyzer-constructor> *** ERROR *** Path for result files not found.";
63  } else {
64  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-constructor> Path for result files found = "
65  << myPathEB->ResultsRootFilePath();
66  }
67 
68  if (myPathEE->GetPathForResultsRootFiles() == kFALSE) {
69  edm::LogError("ecnaAnal") << "*EcnaAnalyzer-constructor> *** ERROR *** Path for result files not found.";
70  throw cms::Exception("Calibration") << "*EcnaAnalyzer-constructor> *** ERROR *** Path for result files not found.";
71  } else {
72  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-constructor> Path for result files found = "
73  << myPathEE->ResultsRootFilePath();
74  }
75 
76  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-constructor> Parameter initialization.";
77 
78  fTTBELL = '\007';
79  fOutcomeError = kFALSE;
80 
81  //==========================================================================================
82  //.................................. Get parameter values from python file
83  eventHeaderProducer_ = pSet.getParameter<std::string>("eventHeaderProducer");
84  digiProducer_ = pSet.getParameter<std::string>("digiProducer");
85 
86  eventHeaderCollection_ = pSet.getParameter<std::string>("eventHeaderCollection");
87  eventHeaderToken_ = consumes<EcalRawDataCollection>(edm::InputTag(digiProducer_, eventHeaderCollection_));
88 
89  EBdigiCollection_ = pSet.getParameter<std::string>("EBdigiCollection");
90  EEdigiCollection_ = pSet.getParameter<std::string>("EEdigiCollection");
91  EBdigiToken_ = consumes<EBDigiCollection>(edm::InputTag(digiProducer_, EBdigiCollection_));
92  EEdigiToken_ = consumes<EEDigiCollection>(edm::InputTag(digiProducer_, EEdigiCollection_));
93 
94  sAnalysisName_ = pSet.getParameter<std::string>("sAnalysisName");
95  sNbOfSamples_ = pSet.getParameter<std::string>("sNbOfSamples");
96  sFirstReqEvent_ = pSet.getParameter<std::string>("sFirstReqEvent");
97  sLastReqEvent_ = pSet.getParameter<std::string>("sLastReqEvent");
98  sReqNbOfEvts_ = pSet.getParameter<std::string>("sReqNbOfEvts");
99  sStexName_ = pSet.getParameter<std::string>("sStexName");
100  sStexNumber_ = pSet.getParameter<std::string>("sStexNumber");
101 
102  fAnalysisName = sAnalysisName_.Data();
103  fNbOfSamples = atoi(sNbOfSamples_.Data());
104  fFirstReqEvent = atoi(sFirstReqEvent_.Data());
105  fLastReqEvent = atoi(sLastReqEvent_.Data());
106  fReqNbOfEvts = atoi(sReqNbOfEvts_.Data());
107  fStexName = sStexName_.Data();
108  fStexNumber = atoi(sStexNumber_.Data());
109 
110  //------------------------------- ERRORS in requested evts numbers
111  if (fFirstReqEvent < 1) {
112  fOutcomeError = AnalysisOutcome("ERR_FNEG");
113  }
114 
116  fOutcomeError = AnalysisOutcome("ERR_LREQ");
117  }
118 
119  if (fOutcomeError == kTRUE)
120  return;
121  //===========================================================================================
122 
123  std::fill(fRunTypeCounter.begin(), fRunTypeCounter.end(), 0);
124  std::fill(fMgpaGainCounter.begin(), fMgpaGainCounter.end(), 0);
125  std::fill(fFedIdCounter.begin(), fFedIdCounter.end(), 0);
126 
127  fEvtNumber = 0;
128  fEvtNumberMemo = -1;
129  fRecNumber = 0;
130 
131  fDeeDS5Memo1 = 0;
132  fDeeDS5Memo2 = 0;
133 
136 
137  fMemoCutOK = 0;
138  fTreatedFedOrder = 0;
139  fNbOfTreatedStexs = 0;
140 
141  //-------------- Fed
142  if (fStexName == "SM") {
144  } // EB: FED Unit = SM
145  if (fStexName == "Dee") {
147  } // EE: FED Unit = Data Sector
148 
149  fFedDigiOK = std::vector<Int_t>(fMaxFedUnitCounter, 0);
150  fFedNbOfTreatedEvents = std::vector<Int_t>(fMaxFedUnitCounter, 0);
151  fFedStatus = std::vector<Int_t>(fMaxFedUnitCounter, 0);
152  fFedStatusOrder = std::vector<Int_t>(fMaxFedUnitCounter, 0);
153 
154  if (fStexName != "Dee") {
155  fDeeNumberString = std::vector<std::string>(fMaxFedUnitCounter, "SM");
156  } else {
157  fDeeNumberString = {"Sector1 Dee4",
158  "Sector2 Dee4",
159  "Sector3 Dee4",
160  "Sector4 Dee4",
161  "Sector5 Dee4-Dee3",
162  "Sector6 Dee3",
163  "Sector7 Dee3",
164  "Sector8 Dee3",
165  "Sector9 Dee3",
166  "Sector1 Dee1",
167  "Sector2 Dee1",
168  "Sector3 Dee1",
169  "Sector4 Dee1",
170  "Sector5 Dee1-Dee2",
171  "Sector6 Dee2",
172  "Sector7 Dee2",
173  "Sector8 Dee2",
174  "Sector9 Dee2"};
175  }
176  //............................... arrays fSMFromFedDcc and fESFromFedTcc
177  //
178  // FED-TCC: 1 2 3 4 5 6 7 8 9
179  // Dee: 3 3 3 4 4 4 4 4-3 3
180  // DS: 7 8 9 1 2 3 4 5 6
181  // ES: 7 8 9 1 2 3 4 5 6 (ES = DS)
182  //
183  // FED-TCC: 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
184  // 26 27
185  // SM: 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
186  // 35 36 SM: -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14
187  // -15 -16 -17 -18
188  //
189  // FED-TCC: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
190  // 44 45
191  // SM: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
192  // 17 18
193  //
194  // FED-TCC: 46 47 48 49 50 51 52 53 54
195  // Dee: 2 2 2 1 1 1 1 1-2 2
196  // DS: 7 8 9 1 2 3 4 5 6
197  // ES: 16 17 18 10 11 12 13 14 15 (ES = DS + 9)
198 
199  const Int_t MaxSMAndDS = fMyEBEcal.MaxSMInEB() + fMyEEEcal.MaxDSInEE();
200 
201  fSMFromFedTcc = std::vector<Int_t>(MaxSMAndDS, -1);
202  fESFromFedTcc = std::vector<Int_t>(MaxSMAndDS, -1);
203 
204  for (Int_t nFedTcc = 1; nFedTcc <= 3; nFedTcc++) {
205  fESFromFedTcc[nFedTcc - 1] = nFedTcc + 6;
206  } // Dee3, ES 7,8,9
207  for (Int_t nFedTcc = 4; nFedTcc <= 9; nFedTcc++) {
208  fESFromFedTcc[nFedTcc - 1] = nFedTcc - 3;
209  } // Dee4, ES 1,2,3,4,5; Dee3, DS 5,6
210 
211  for (Int_t nFedTcc = 10; nFedTcc <= 27; nFedTcc++) {
212  fSMFromFedTcc[nFedTcc - 1] = nFedTcc + 9;
213  } // EB- SM 19 to 36
214  for (Int_t nFedTcc = 28; nFedTcc <= 45; nFedTcc++) {
215  fSMFromFedTcc[nFedTcc - 1] = nFedTcc - 27;
216  } // EB+ SM 1 to 18
217 
218  for (Int_t nFedTcc = 46; nFedTcc <= 48; nFedTcc++) {
219  fESFromFedTcc[nFedTcc - 1] = nFedTcc - 30;
220  } // Dee2, ES 16,17,18
221  for (Int_t nFedTcc = 49; nFedTcc <= 54; nFedTcc++) {
222  fESFromFedTcc[nFedTcc - 1] = nFedTcc - 39;
223  } // Dee1, ES 10,11,12,13,14; Dee2, ES 14,15
224 
225  //............................... Nb of treated events for "AdcPeg12" and
226  //"AdcSPeg12" analysis
227  //-------------- Stex
228  if (fStexName == "SM") {
230  } // EB: Stex = SM
231  if (fStexName == "Dee") {
233  } // EE: Stex = Dee
234 
235  fStexNbOfTreatedEvents = std::vector<Int_t>(fMaxTreatedStexCounter, 0);
236 
237  fTimeFirst = std::vector<time_t>(fMaxTreatedStexCounter, 0);
238  fTimeLast = std::vector<time_t>(fMaxTreatedStexCounter, 0);
239 
240  fMemoDateFirstEvent = std::vector<Int_t>(fMaxTreatedStexCounter, 0);
241 
242  Int_t MaxCar = fgMaxCar;
243  fDateFirst = std::vector<TString>(fMaxTreatedStexCounter);
244  for (Int_t i = 0; i < fMaxTreatedStexCounter; i++) {
245  fDateFirst[i].Resize(MaxCar);
246  fDateFirst[i] = "*1st event date not found*";
247  }
248 
249  MaxCar = fgMaxCar;
250  fDateLast = std::vector<TString>(fMaxTreatedStexCounter);
251  for (Int_t i = 0; i < fMaxTreatedStexCounter; i++) {
252  fDateLast[i].Resize(MaxCar);
253  fDateLast[i] = "*last event date not found*";
254  }
255 
258 
261 
262  //.......................... counters of events for GetSampleAdcValues
264 
266 
267  //----------------------------------- Analysis name codes
268  //------------------------------------------
269  //
270  // AnalysisName RunType Gain DBLS (Dynamic
271  // BaseLine Substraction)
272  //
273  // AdcAny any run type 0 no
274  //
275  // AdcPed1 fPEDESTAL_STD 3 No
276  // AdcPed6 fPEDESTAL_STD 2 No
277  // AdcPed12 fPEDESTAL_STD 1 No
278  //
279  // AdcPeg12 fPEDESTAL_GAP 1 No
280  //
281  // AdcLaser fLASER_STD 0 No
282  // AdcPes12 fPEDSIM 0 No
283  //
284  // AdcPhys fPHYSICS_GLOBAL 0 No
285  //
286  //
287  // AdcSPed1 fPEDESTAL_STD 3 Yes
288  // AdcSPed6 fPEDESTAL_STD 2 Yes
289  // AdcSPed12 fPEDESTAL_STD 1 Yes
290  //
291  // AdcSPeg12 fPEDESTAL_GAP 1 Yes
292  //
293  // AdcSLaser fLASER_STD 0 Yes
294  // AdcSPes12 fPEDSIM 0 Yes
295  //
296  //--------------------------------------------------------------------------------------------------
297 
298  //................ Run type list
299 
300  fLASER_STD = 4;
301  fPEDESTAL_STD = 9;
302  fPHYSICS_GLOBAL = 13;
303  fPEDESTAL_GAP = 18;
304  fPEDSIM = 24;
305 
306  fANY_RUN = 25;
307 
308  //................ Chozen run type from analysis name
309  fChozenRunTypeNumber = fANY_RUN; // default
310  if (fAnalysisName == "AdcAny") {
312  }
313  if (fAnalysisName == "AdcPed1" || fAnalysisName == "AdcPed6" || fAnalysisName == "AdcPed12" ||
314  fAnalysisName == "AdcSPed1" || fAnalysisName == "AdcSPed6" || fAnalysisName == "AdcSPed12") {
316  }
317  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12") {
319  }
320  if (fAnalysisName == "AdcLaser" || fAnalysisName == "AdcSLaser") {
322  }
323  if (fAnalysisName == "AdcPhys") {
325  }
326  if (fAnalysisName == "AdcPes12 " || fAnalysisName == "AdcSPes12 ") {
328  }
329 
330  //................ Gains from analysis name
331  fChozenGainNumber = 0; // default => event always accepted if fChozenGainNumber = 0 ( see
332  // USER's Analysis cut in ::analyze(...) )
333  if (fAnalysisName == "AdcAny") {
334  fChozenGainNumber = 0;
335  }
336  if (fAnalysisName == "AdcPed1" || fAnalysisName == "AdcSPed1") {
337  fChozenGainNumber = 3;
338  }
339  if (fAnalysisName == "AdcPed6" || fAnalysisName == "AdcSPed6") {
340  fChozenGainNumber = 2;
341  }
342  if (fAnalysisName == "AdcPed12" || fAnalysisName == "AdcSPed12") {
343  fChozenGainNumber = 1;
344  }
345  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12") {
346  fChozenGainNumber = 0;
347  }
348  if (fAnalysisName == "AdcLaser" || fAnalysisName == "AdcSLaser") {
349  fChozenGainNumber = 0;
350  }
351  if (fAnalysisName == "AdcPes12 " || fAnalysisName == "AdcSPes12 ") {
352  fChozenGainNumber = 0;
353  }
354  if (fAnalysisName == "AdcPhys") {
355  fChozenGainNumber = 0;
356  }
357 
358  //............... Flag for Dynamic BaseLine Substraction from analysis name
359  fDynBaseLineSub = "no"; // default
360  if (fAnalysisName == "AdcAny" || fAnalysisName == "AdcPed1" || fAnalysisName == "AdcPed6" ||
361  fAnalysisName == "AdcPed12" || fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcLaser" ||
362  fAnalysisName == "AdcPhys" || fAnalysisName == "AdcPes12 ") {
363  fDynBaseLineSub = "no";
364  }
365  if (fAnalysisName == "AdcSPed1" || fAnalysisName == "AdcSPed6" || fAnalysisName == "AdcSPed12" ||
366  fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcSLaser" || fAnalysisName == "AdcSPes12 ") {
367  fDynBaseLineSub = "yes";
368  }
369 
370  //....................... Index range for ECNA init and for loop on
371  // GetSampleAdcValues calls
372  if (fStexNumber == 0) {
373  if (fStexName == "SM") {
374  fSMIndexBegin = 0;
378  fDeeIndexBegin = 0;
379  fDeeIndexStop = 0;
380  }
381  if (fStexName == "Dee") {
382  fSMIndexBegin = 0;
383  fSMIndexStop = 0;
384  fDeeIndexBegin = 0;
388  }
389  } else {
390  if (fStexName == "SM") {
395  fDeeIndexBegin = 0;
396  fDeeIndexStop = 0;
397  }
398  if (fStexName == "Dee") {
399  fSMIndexBegin = 0;
400  fSMIndexStop = 0;
405  }
406  }
407 
408  //......... DATA DEPENDENT PARAMETERS
409  fRunNumber = 0;
410 
411  fRunTypeNumber = -1;
412  fMgpaGainNumber = -1;
413 
414  fFedId = -1;
415  fFedTcc = -1;
416 
417  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fAnalysisName = " << fAnalysisName;
418  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fNbOfSamples = " << fNbOfSamples;
419  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fFirstReqEvent = " << fFirstReqEvent;
420  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fLastReqEvent = " << fLastReqEvent;
421  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fReqNbOfEvts = " << fReqNbOfEvts;
422  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fStexName = " << fStexName;
423  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fStexNumber = " << fStexNumber;
424  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fChozenRunTypeNumber = "
426  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> fChozenGainNumber = "
427  << fChozenGainNumber << std::endl;
428 
429  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer::EcnaAnalyzer-constructor> Init done. ";
430 }
431 // end of constructor
432 
434  // do anything here that needs to be done at destruction time
435  // (e.g. close files, deallocate resources etc.)
436 
437  //..................................... format numerical values
438  edm::LogVerbatim("ecnaAnal") << "EcnaAnalyzer::~EcnaAnalyzer()> destructor is going to be executed." << std::endl;
439 
440  if (fOutcomeError == kTRUE)
441  return;
442 
443  //-------------------------------------------------------------------------------
444 
445  //....................................................... EB (SM)
446  if (fMyCnaEBSM.empty() && fStexName == "SM") {
447  edm::LogVerbatim("ecnaAnal") << "\n!EcnaAnalyzer-destructor> **** ERROR **** fMyCnaEBSM is empty"
448  << ". !===> ECNA HAS NOT BEEN INITIALIZED."
449  << "\n Last event run type = " << runtype(fRunTypeNumber)
450  << ", fRunTypeNumber = " << fRunTypeNumber
451  << ", last event Mgpa gain = " << gainvalue(fMgpaGainNumber)
452  << ", fMgpaGainNumber = " << fMgpaGainNumber
453  << ", last event fFedId(+601) = " << fFedId + 601 << std::endl;
454  } else {
455  for (Int_t iSM = fSMIndexBegin; iSM < fSMIndexStop; iSM++) {
456  if (fMyCnaEBSM[iSM].get() != nullptr) {
457  //........................................ register dates 1 and 2
458  fMyCnaEBSM[iSM]->StartStopDate(fDateFirst[iSM], fDateLast[iSM]);
459  fMyCnaEBSM[iSM]->StartStopTime(fTimeFirst[iSM], fTimeLast[iSM]);
460 
461  //........................................ Init .root file
462  fMyCnaEBSM[iSM]->GetReadyToCompute();
463  fMyCnaEBSM[iSM]->SampleValues();
464 
465  //........................................ write the sample values in
466  //.root file
467  if (fMyCnaEBSM[iSM]->WriteRootFile() == kFALSE) {
468  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer-destructor> PROBLEM with write ROOT file for SM" << iSM + 1
469  << fTTBELL;
470  }
471  } else {
472  edm::LogVerbatim("ecnaAnal")
473  << "*EcnaAnalyzer-destructor> Calculations and writing on file already done for SM " << iSM + 1;
474  }
475  }
476  }
477  //....................................................... EE (Dee)
478 
479  if (fMyCnaEEDee.empty() && fStexName == "Dee") {
480  edm::LogVerbatim("ecnaAnal") << "\n!EcnaAnalyzer-destructor> **** ERROR **** fMyCnaEEDee is empty"
481  << ". !===> ECNA HAS NOT BEEN INITIALIZED."
482  << "\n Last event run type = " << runtype(fRunTypeNumber)
483  << ", fRunTypeNumber = " << fRunTypeNumber
484  << ", last event Mgpa gain = " << gainvalue(fMgpaGainNumber)
485  << ", fMgpaGainNumber = " << fMgpaGainNumber
486  << ", last event fFedId(+601) = " << fFedId + 601 << std::endl;
487  } else {
488  for (Int_t iDee = fDeeIndexBegin; iDee < fDeeIndexStop; iDee++) {
489  if (fMyCnaEEDee[iDee].get() != nullptr) {
490  //........................................ register dates 1 and 2
491  fMyCnaEEDee[iDee]->StartStopDate(fDateFirst[iDee], fDateLast[iDee]);
492  fMyCnaEEDee[iDee]->StartStopTime(fTimeFirst[iDee], fTimeLast[iDee]);
493 
494  //........................................ Init .root file
495  fMyCnaEEDee[iDee]->GetReadyToCompute();
496  fMyCnaEEDee[iDee]->SampleValues();
497 
498  //........................................ write the sample values in
499  //.root file
500  if (fMyCnaEEDee[iDee]->WriteRootFile() == kFALSE) {
501  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer-destructor> PROBLEM with write ROOT file for Dee" << iDee + 1
502  << " " << fTTBELL;
503  }
504  } else {
505  edm::LogVerbatim("ecnaAnal")
506  << "*EcnaAnalyzer-destructor> Calculations and writing on file already done for Dee " << iDee + 1;
507  }
508  }
509  }
510  edm::LogVerbatim("ecnaAnal") << std::endl;
511 
512  //-----------------------------------------------------------------------------------
513 
514  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> Status of events returned by GetSampleAdcValues(): ";
515 
516  for (Int_t i0Stex = fStexIndexBegin; i0Stex < fStexIndexStop; i0Stex++) {
517  edm::LogVerbatim("ecnaAnal") << fStexName << i0Stex + 1 << "> Status OK: " << fBuildEventDistribGood[i0Stex]
518  << " / ERROR(S): " << fBuildEventDistribBad[i0Stex];
519  if (fBuildEventDistribBad[i0Stex] > 0) {
520  edm::LogVerbatim("ecnaAnal") << " <=== SHOULD BE EQUAL TO ZERO ! " << fTTBELL;
521  }
522  edm::LogVerbatim("ecnaAnal") << std::endl;
523  }
524 
525  edm::LogVerbatim("ecnaAnal") << "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
526 
527  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> Run types seen in event headers before selection:";
528 
529  for (Int_t i = 0; i < fMaxRunTypeCounter; i++) {
530  edm::LogVerbatim("ecnaAnal") << " => " << std::setw(10) << fRunTypeCounter[i] << " event header(s) with run type "
531  << runtype(i);
532  }
533 
534  edm::LogVerbatim("ecnaAnal") << "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
535 
536  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> Mgpa gains seen in event headers before selection:";
537 
538  for (Int_t i = 0; i < fMaxMgpaGainCounter; i++) {
539  edm::LogVerbatim("ecnaAnal") << " => " << std::setw(10) << fMgpaGainCounter[i] << " event header(s) with gain "
540  << gainvalue(i);
541  }
542 
543  edm::LogVerbatim("ecnaAnal") << "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
544 
545  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> Numbers of selected events for each FED:";
546 
547  for (Int_t i = 0; i < fMaxFedIdCounter; i++) {
548  edm::LogVerbatim("ecnaAnal") << " => FedId " << i + 601 << ": " << std::setw(10) << fFedIdCounter[i] << " events";
549  }
550 
551  edm::LogVerbatim("ecnaAnal") << "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
552 
553  if (fStexNumber > 0) {
554  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> fDateFirst = " << fDateFirst[fStexNumber - 1]
555  << "\n fDateLast = " << fDateLast[fStexNumber - 1]
556  << std::endl;
557  }
558 
559  edm::LogVerbatim("ecnaAnal") << "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
560 
561  Int_t n0 = 0;
562  CheckMsg(n0);
563 
564  edm::LogVerbatim("ecnaAnal") << "*EcnaAnalyzer-destructor> End of execution.";
565 }
566 // end of destructor
567 
568 //
569 // member functions
570 //
571 
572 // ------------ method called to produce the data ------------
574  //..................................... format numerical values
575  std::cout << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
576  std::cout << std::setprecision(3) << std::setw(6);
577  std::cout.setf(std::ios::dec, std::ios::basefield);
578  std::cout.setf(std::ios::fixed, std::ios::floatfield);
579  std::cout.setf(std::ios::left, std::ios::adjustfield);
580  std::cout.setf(std::ios::right, std::ios::adjustfield);
581 
582  fRecNumber++;
583 
584  Int_t iFreq = (fLastReqEvent - fFirstReqEvent + 1) / 5;
585  if (iFreq <= 0) {
586  iFreq = 10000;
587  }
588 
589  Int_t MaxSMAndDS = fMyEBEcal.MaxSMInEB() + fMyEEEcal.MaxDSInEE();
590 
591  //********************************************* EVENT TREATMENT
592  //********************************
593  const edm::Handle<EcalRawDataCollection> &pEventHeader = iEvent.getHandle(eventHeaderToken_);
594  const EcalRawDataCollection *myEventHeader = nullptr;
595  if (pEventHeader.isValid()) {
596  myEventHeader = pEventHeader.product();
597  } else {
598  edm::LogError("ecnaAnal") << "Error! can't get the product " << eventHeaderCollection_.c_str();
599  }
600  //........... Decode myEventHeader infos
601  for (EcalRawDataCollection::const_iterator headerItr = myEventHeader->begin(); headerItr != myEventHeader->end();
602  ++headerItr) {
603  //===> fRunNumber, fRunTypeNumber, fMgpaGainNumber, fFedId, fEvtNumber
604  // will be used in AnalysisOutcome(...) below
605  fRunNumber = (Int_t)headerItr->getRunNumber();
606  if (fRunNumber <= 0) {
607  fRunNumber = (Int_t)iEvent.id().run();
608  }
609  fRunTypeNumber = (Int_t)headerItr->getRunType();
610  fMgpaGainNumber = (Int_t)headerItr->getMgpaGain();
611  fFedId = (Int_t)headerItr->fedId() - 601; // 1st Fed = 601, FedId = Fed number - 1
612  fEvtNumber = (Int_t)headerItr->getLV1();
613  if (fEvtNumber <= 0) {
614  fEvtNumber = (Int_t)iEvent.id().event();
615  }
616 
617  if (fEvtNumber != fEvtNumberMemo) {
619 
620  //============================================
621  // cmsRun INTERRUPTION if analysis complete
622  // or if fCurrentEventNumber >= LastReqEvent
623  //============================================
624  if (AnalysisOutcome("EVT") == kTRUE) {
625  return;
626  }
627 
628  // no interruption => event has to be analyzed
629 
631 
632  if (fRecNumber == 1 || fRecNumber == 50 || fRecNumber == 100 || fRecNumber == 500 || fRecNumber == 1000 ||
633  fRecNumber % iFreq == 0) {
634  Int_t n1 = 1;
635  CheckMsg(n1);
636  }
637 
639  return; // skip events before fFirstReqEvent
640  }
641 
642  //.................. Increment Run type and MgpaGain counters
645  }
648  }
649 
650  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User's analysis cut
651  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 
655  return;
656 
657  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
658 
659  if (fMemoCutOK == 0) {
660  fMemoCutOK = 1;
661  }
662 
663  //---- Accelerating selection with "FED-TCC" number [ from
664  // headerItr->getDccInTCCCommand() ]
665  // Arrays fSMFromFedTcc[] and fESFromFedTcc[] are initialised in Init()
666 
667  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
668  fAnalysisName == "AdcAny") {
669  fFedTcc = (Int_t)headerItr->getDccInTCCCommand();
670 
671  if (fFedTcc >= 1 && fFedTcc <= MaxSMAndDS) {
672  if (fStexName == "SM") {
673  if (fFedTcc < 10 || fFedTcc > 45)
674  return;
675 
676  if (fSMFromFedTcc[fFedTcc - 1] >= 1 && fSMFromFedTcc[fFedTcc - 1] <= fMyEBEcal.MaxSMInEB() &&
678  return;
679  }
680 
681  if (fStexName == "Dee") {
682  if (fFedTcc >= 10 && fFedTcc <= 45)
683  return;
684 
685  if (fESFromFedTcc[fFedTcc - 1] >= 1 && fESFromFedTcc[fFedTcc - 1] <= fMyEEEcal.MaxDSInEE() &&
687  return;
688  }
689  } // end of if( fFedTcc >= 1 && fFedTcc <= MaxSMAndDS )
690  } // end of if( fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12"
691  // ...)
692 
693  //.................. Increment FedId counters
694  if (fFedId >= 0 && fFedId < fMaxFedIdCounter) {
696  }
697 
698  } // end of for(EcalRawDataCollection::const_iterator
699  // headerItr=myEventHeader->begin(); headerItr !=
700  // myEventHeader->end();++headerItr)
701 
702  if (fMemoCutOK == 0)
703  return; // return if no event passed the user's analysis cut
704 
705  //========================== SELECTED EVENTS ================================
707  if (fNbOfSelectedEvents == 1) {
708  Int_t n2 = 2;
709  CheckMsg(n2);
710  }
711 
712  //============================ Ecna init for the pointers array
713  //=================================
714  //.................................................................. EB (SM)
715  if (fMyCnaEBSM.empty() && fStexName == "SM") {
716  fMyCnaEBSM.resize(fMyEBEcal.MaxSMInEB());
717  }
718  //.................................................................. EE (Dee)
719  if (fMyCnaEEDee.empty() && fStexName == "Dee") {
720  fMyCnaEEDee.resize(fMyEEEcal.MaxDeeInEE());
721  }
722 
723  //============================ EVENT TREATMENT ==============================
724  Int_t MaxNbOfStex = 0;
725  if (fStexName == "SM") {
726  MaxNbOfStex = fMyEBEcal.MaxSMInEB();
727  }
728  if (fStexName == "Dee") {
729  MaxNbOfStex = fMyEEEcal.MaxDeeInEE();
730  }
731 
732  if ((fStexNumber > 0 && fNbOfTreatedStexs == 0) || (fStexNumber == 0 && fNbOfTreatedStexs < MaxNbOfStex)) {
733  //================================================================= Record
734  // type EB (SM)
735  if (fStexName == "SM" && fSMIndexBegin < fSMIndexStop) {
736  //......................................... Get digisEB
737  const edm::Handle<EBDigiCollection> &pdigisEB = iEvent.getHandle(EBdigiToken_);
738  const EBDigiCollection *digisEB = nullptr;
739  if (pdigisEB.isValid()) {
740  digisEB = pdigisEB.product();
741  } else {
742  edm::LogError("ecnaAnal") << "Error! can't get the product " << EBdigiCollection_.c_str();
743  }
744 
745  // Initialize vectors if not already done
746  if (int(digisEB->size()) > nChannels_) {
747  nChannels_ = digisEB->size();
748  }
749 
750  // Int_t print_count = 0;
751  if (Int_t(digisEB->end() - digisEB->begin()) >= 0 &&
752  Int_t(digisEB->end() - digisEB->begin()) <= Int_t(digisEB->size())) {
753  //..........................................EB
754  //===============================================================================
755  //
756  // Loop over Ecal barrel digisEB (Xtals)
757  //
758  //===============================================================================
759 
760  for (EBDigiCollection::const_iterator digiItr = digisEB->begin(); digiItr != digisEB->end(); ++digiItr) {
761  EBDetId id_crystal(digiItr->id());
762  // Int_t HashedIndex = id_crystal.hashedIndex();
763 
764  Int_t i0SM = id_crystal.ism() - 1; // <============== GET the SM number - 1 here
765 
766  if (i0SM >= 0 && i0SM < fMaxTreatedStexCounter) {
767  if (fMyCnaEBSM[i0SM].get() == nullptr && fStexStatus[i0SM] != 2) {
768  //=============================== Init Ecna EB
769  //===============================
770  fMyCnaEBSM[i0SM] = std::make_unique<TEcnaRun>(&fMyEcnaEBObjectManager, "EB", fNbOfSamples);
771  fMyCnaEBSM[i0SM]->GetReadyToReadData(
773 
774  edm::LogVerbatim("ecnaAnal")
775  << "*EcnaAnalyzer::analyze(...)> ********* INIT ECNA EB ********* "
776  << "\n fAnalysisName = " << fAnalysisName
777  << "\n fRunNumber = " << fRunNumber
778  << "\n fFirstReqEvent = " << fFirstReqEvent
779  << "\n fLastReqEvent = " << fLastReqEvent
780  << "\n fReqNbOfEvts = " << fReqNbOfEvts
781  << "\n SM = " << i0SM + 1
782  << "\n run type = " << runtype(fRunTypeNumber);
783  //============================================================================
784  }
785 
786  if (fStexStatus[i0SM] < 2) // nothing to do if status=2 reached
787  {
788  fStexDigiOK[i0SM]++;
789  if (fStexDigiOK[i0SM] == 1) {
790  fStexNbOfTreatedEvents[i0SM]++;
791  }
792 
793  if (fStexNbOfTreatedEvents[i0SM] >= 1 && fStexNbOfTreatedEvents[i0SM] <= fReqNbOfEvts) {
794  //......................................... date of first event
795  //(in real time)
796  edm::Timestamp Time = iEvent.time();
797  edm::TimeValue_t t_current_ev_time = (cond::Time_t)Time.value();
798  time_t i_current_ev_time = (time_t)(t_current_ev_time >> 32);
799  const time_t *p_current_ev_time = &i_current_ev_time;
800  char *astime = ctime(p_current_ev_time);
801 
802  if (fStexDigiOK[i0SM] == 1 && fStexNbOfTreatedEvents[i0SM] == 1 &&
803  (fStexNumber == 0 || i0SM + 1 == fStexNumber)) {
804  fTimeFirst[i0SM] = i_current_ev_time;
805  fDateFirst[i0SM] = astime;
806  fTimeLast[i0SM] = i_current_ev_time;
807  fDateLast[i0SM] = astime;
808  edm::LogVerbatim("ecnaAnal") << "*----> beginning of analysis for " << fStexName << i0SM + 1
809  << ". First analyzed event date : " << astime;
810  }
811 
812  if (i_current_ev_time < fTimeFirst[i0SM]) {
813  fTimeFirst[i0SM] = i_current_ev_time;
814  fDateFirst[i0SM] = astime;
815  }
816  if (i_current_ev_time > fTimeLast[i0SM]) {
817  fTimeLast[i0SM] = i_current_ev_time;
818  fDateLast[i0SM] = astime;
819  }
820 
821  //=============================================> CUT on i0SM
822  // value
823  if ((fStexNumber > 0 && i0SM == fStexNumber - 1) || (fStexNumber == 0)) {
824  Int_t iEta = id_crystal.ietaSM(); // ietaSM() : range = [1,85]
825  Int_t iPhi = id_crystal.iphiSM(); // iphiSM() : range = [1,20]
826 
827  Int_t n1SMCrys = (iEta - 1) * (fMyEBEcal.MaxTowPhiInSM() * fMyEBEcal.MaxCrysPhiInTow()) +
828  iPhi; // range = [1,1700]
829  Int_t n1SMTow = fMyEBNumbering.Get1SMTowFrom1SMCrys(n1SMCrys); // range = [1,68]
830  Int_t i0TowEcha = fMyEBNumbering.Get0TowEchaFrom1SMCrys(n1SMCrys); // range = [0,24]
831 
832  Int_t NbOfSamplesFromDigis = digiItr->size();
833 
834  EBDataFrame df(*digiItr);
835 
836  if (NbOfSamplesFromDigis > 0 && NbOfSamplesFromDigis <= fMyEBEcal.MaxSampADC()) {
837  Double_t adcDBLS = (Double_t)0;
838  // Three 1st samples mean value for Dynamic Base Line
839  // Substraction (DBLS)
840  if (fDynBaseLineSub == "yes") {
841  for (Int_t i0Sample = 0; i0Sample < 3; i0Sample++) {
842  adcDBLS += (Double_t)(df.sample(i0Sample).adc());
843  }
844  adcDBLS /= (Double_t)3;
845  }
846  // Loop over the samples
847  for (Int_t i0Sample = 0; i0Sample < fNbOfSamples; i0Sample++) {
848  Double_t adc = (Double_t)(df.sample(i0Sample).adc()) - adcDBLS;
849  //................................................. Calls
850  // to GetSampleAdcValues
851  if (fMyCnaEBSM[i0SM]->GetSampleAdcValues(
852  fStexNbOfTreatedEvents[i0SM], n1SMTow, i0TowEcha, i0Sample, adc) == kTRUE) {
853  fBuildEventDistribGood[i0SM]++;
854  } else {
855  fBuildEventDistribBad[i0SM]++;
856  }
857  }
858  } else {
859  edm::LogVerbatim("ecnaAnal")
860  << "EcnaAnalyzer::analyze(...)> NbOfSamplesFromDigis out of bounds = " << NbOfSamplesFromDigis;
861  }
862  } // end of if( (fStexNumber > 0 && i0SM == fStexNumber-1) ||
863  // (fStexNumber == 0) )
864  } // end of if( fStexNbOfTreatedEvents[i0SM] >= 1 &&
865  // fStexNbOfTreatedEvents[i0SM] <= fReqNbOfEvts )
866  } // end of if( fStexStatus[i0SM] < 2 )
867  } // end of if( i0SM >= 0 && i0SM<fMaxTreatedStexCounter )
868  } // end of for (EBDigiCollection::const_iterator digiItr =
869  // digisEB->begin();
870  // digiItr != digisEB->end(); ++digiItr)
871 
872  for (Int_t i0SM = 0; i0SM < fMaxTreatedStexCounter; i0SM++) {
873  fStexDigiOK[i0SM] = 0; // reset fStexDigiOK[i0SM] after loop on digis
874  }
875 
876  } // end of if( Int_t(digisEB->end()-digisEB->begin()) >= 0 &&
877  // Int_t(digisEB->end()-digisEB->begin()) <= Int_t(digisEB->size()) )
878  } // end of if( fStexName == "SM" && fSMIndexBegin < fSMIndexStop )
879 
880  //=============================================================== Record
881  // type EE (Dee)
882  if (fStexName == "Dee" && fDeeIndexBegin < fDeeIndexStop) {
883  //......................................... Get digisEE
884  const edm::Handle<EEDigiCollection> &pdigisEE = iEvent.getHandle(EEdigiToken_);
885  const EEDigiCollection *digisEE = nullptr;
886  if (pdigisEE.isValid()) {
887  digisEE = pdigisEE.product();
888  } else {
889  edm::LogError("ecnaAnal") << "Error! can't get the product " << EEdigiCollection_.c_str();
890  }
891 
892  // Initialize vectors if not already done
893  if (int(digisEE->size()) > nChannels_) {
894  nChannels_ = digisEE->size();
895  }
896 
897  // Int_t print_count = 0;
898  if (Int_t(digisEE->end() - digisEE->begin()) >= 0 &&
899  Int_t(digisEE->end() - digisEE->begin()) <= Int_t(digisEE->size())) {
900  //======================================================================================
901  //
902  // Loop over Ecal endcap digisEE (Xtals)
903  //
904  //======================================================================================
905 
906  for (EEDigiCollection::const_iterator digiItr = digisEE->begin(); digiItr != digisEE->end(); ++digiItr) {
907  EEDetId id_crystal(digiItr->id());
908 
909  Int_t iX_data = id_crystal.ix(); // iX_data : range = [1,100]
910  Int_t iY_data = id_crystal.iy(); // iY_data : range = [1,100]
911  Int_t i_quad = id_crystal.iquadrant(); // iquadrant() : range = [1,4]
912  Int_t i_sgnZ = id_crystal.zside(); // zside() : values = -1,+1
913 
914  Int_t iX = iX_data;
915  Int_t iY = iY_data; // iY : range = [1,100]
916 
917  //.......... See
918  // CMSSW/DataFormats/EcalDetId/src/EEDetId.cc::ixQuadrantOne() [ in
919  // which ix() = iX_data ]
920  if (i_quad == 1 || i_quad == 4) {
921  iX = iX_data - 50;
922  } // iX_data : range = [51,100], iX : range = [1,50]
923  if (i_quad == 3 || i_quad == 2) {
924  iX = 51 - iX_data;
925  } // iX_data : range = [50,1], iX : range = [1,50]
926 
927  Int_t n1DeeCrys =
928  (iX - 1) * (fMyEEEcal.MaxSCIYInDee() * fMyEEEcal.MaxCrysIYInSC()) + iY; // n1DeeCrys: range = [1,5000]
929 
930  Int_t n1DeeNumber = 0;
931  if (i_quad == 1 && i_sgnZ == 1) {
932  n1DeeNumber = 2;
933  }
934  if (i_quad == 1 && i_sgnZ == -1) {
935  n1DeeNumber = 3;
936  }
937  if (i_quad == 2 && i_sgnZ == 1) {
938  n1DeeNumber = 1;
939  }
940  if (i_quad == 2 && i_sgnZ == -1) {
941  n1DeeNumber = 4;
942  }
943  if (i_quad == 3 && i_sgnZ == 1) {
944  n1DeeNumber = 1;
945  }
946  if (i_quad == 3 && i_sgnZ == -1) {
947  n1DeeNumber = 4;
948  }
949  if (i_quad == 4 && i_sgnZ == 1) {
950  n1DeeNumber = 2;
951  }
952  if (i_quad == 4 && i_sgnZ == -1) {
953  n1DeeNumber = 3;
954  }
955 
956  Int_t i0Dee = n1DeeNumber - 1; // <============== GET the Dee number - 1 here
957 
958  if (i0Dee >= 0 && i0Dee < fMaxTreatedStexCounter) {
959  if (fMyCnaEEDee[i0Dee].get() == nullptr && fStexStatus[i0Dee] != 2) {
960  //=============================== Init Ecna EE
961  //===============================
962  fMyCnaEEDee[i0Dee] = std::make_unique<TEcnaRun>(&fMyEcnaEEObjectManager, "EE", fNbOfSamples);
963  fMyCnaEEDee[i0Dee]->GetReadyToReadData(
965 
966  edm::LogVerbatim("ecnaAnal")
967  << "*EcnaAnalyzer::analyze(...)> ********* INIT ECNA EE ********* "
968  << "\n fAnalysisName = " << fAnalysisName
969  << "\n fRunNumber = " << fRunNumber
970  << "\n fFirstReqEvent = " << fFirstReqEvent
971  << "\n fLastReqEvent = " << fLastReqEvent
972  << "\n fReqNbOfEvts = " << fReqNbOfEvts
973  << "\n Dee = " << i0Dee + 1
974  << "\n run type = " << runtype(fRunTypeNumber);
975  //============================================================================
976  }
977 
978  if (fStexStatus[i0Dee] < 2) // nothing to do if status=2 reached
979  {
980  Bool_t cOKForTreatment = kFALSE;
981 
982  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
983  fAnalysisName == "AdcAny") {
984  if (fFedTcc >= 1 && fFedTcc <= MaxSMAndDS) {
985  fFedDigiOK[fESFromFedTcc[fFedTcc - 1] - 1]++;
986 
987  if (!(fESFromFedTcc[fFedTcc - 1] == 5 || fESFromFedTcc[fFedTcc - 1] == 14)) {
988  if (fFedDigiOK[fESFromFedTcc[fFedTcc - 1] - 1] == 1) {
990  }
991  if (fFedNbOfTreatedEvents[fESFromFedTcc[fFedTcc - 1] - 1] >= 1 &&
994  cOKForTreatment = kTRUE;
995  }
996  }
997  if (fESFromFedTcc[fFedTcc - 1] == 5 || fESFromFedTcc[fFedTcc - 1] == 14) {
998  if (fFedDigiOK[fESFromFedTcc[fFedTcc - 1] - 1] == 1) {
1000  fDeeDS5Memo1 = n1DeeNumber;
1002  } else {
1003  if (fDeeDS5Memo2 == 0) {
1004  if (n1DeeNumber != fDeeDS5Memo1) {
1005  // change of Dee in Data sector 5
1006  fDeeDS5Memo2 = n1DeeNumber;
1008  }
1009  }
1010  }
1011  if (fFedNbOfTreatedEvents[fESFromFedTcc[fFedTcc - 1] - 1] >= 1 &&
1013  cOKForTreatment = kTRUE;
1014  }
1015  }
1016  } // end of if( fFedTcc >= 1 && fFedTcc <= MaxSMAndDS )
1017  } // end of if( fAnalysisName == "AdcPeg12" || fAnalysisName ==
1018  // "AdcSPeg12" .... )
1019  else {
1020  fStexDigiOK[i0Dee]++;
1021  if (fStexDigiOK[i0Dee] == 1) {
1022  fStexNbOfTreatedEvents[i0Dee]++;
1023  }
1024  if (fStexNbOfTreatedEvents[i0Dee] >= 1 && fStexNbOfTreatedEvents[i0Dee] <= fReqNbOfEvts) {
1025  cOKForTreatment = kTRUE;
1026  }
1027  }
1028 
1029  if (cOKForTreatment == kTRUE) {
1030  //......................................... date of first event
1031  //(in real time)
1032  edm::Timestamp Time = iEvent.time();
1033  edm::TimeValue_t t_current_ev_time = (cond::Time_t)Time.value();
1034  time_t i_current_ev_time = (time_t)(t_current_ev_time >> 32);
1035  const time_t *p_current_ev_time = &i_current_ev_time;
1036  char *astime = ctime(p_current_ev_time);
1037 
1038  if ((!(fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
1039  fAnalysisName == "AdcAny") &&
1040  fStexDigiOK[i0Dee] == 1 && fStexNbOfTreatedEvents[i0Dee] == 1) ||
1041  ((fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
1042  fAnalysisName == "AdcAny") &&
1043  fFedDigiOK[fESFromFedTcc[fFedTcc - 1] - 1] == 1 && fStexNbOfTreatedEvents[i0Dee] == 1 &&
1044  fMemoDateFirstEvent[i0Dee] == 0)) {
1045  fTimeFirst[i0Dee] = i_current_ev_time;
1046  fDateFirst[i0Dee] = astime;
1047  fTimeLast[i0Dee] = i_current_ev_time;
1048  fDateLast[i0Dee] = astime;
1049  edm::LogVerbatim("ecnaAnal")
1050  << "----- beginning of analysis for " << fStexName << i0Dee + 1 << "-------"
1051  << "\n First event date = " << astime << "\n Nb of selected evts = " << fNbOfSelectedEvents
1052  << "\n---------------------------------------------------------------";
1053  fMemoDateFirstEvent[i0Dee]++;
1054  }
1055 
1056  if (i_current_ev_time < fTimeFirst[i0Dee]) {
1057  fTimeFirst[i0Dee] = i_current_ev_time;
1058  fDateFirst[i0Dee] = astime;
1059  }
1060  if (i_current_ev_time > fTimeLast[i0Dee]) {
1061  fTimeLast[i0Dee] = i_current_ev_time;
1062  fDateLast[i0Dee] = astime;
1063  }
1064 
1065  //=============================================> cut on i0Dee
1066  // value
1067  if ((fStexNumber > 0 && i0Dee == fStexNumber - 1) || (fStexNumber == 0)) {
1068  TString sDir = fMyEENumbering.GetDeeDirViewedFromIP(n1DeeNumber);
1069  Int_t n1DeeSCEcna = fMyEENumbering.Get1DeeSCEcnaFrom1DeeCrys(n1DeeCrys, sDir);
1070  Int_t i0SCEcha = fMyEENumbering.Get1SCEchaFrom1DeeCrys(n1DeeCrys, sDir) - 1;
1071 
1072  Int_t NbOfSamplesFromDigis = digiItr->size();
1073 
1074  EEDataFrame df(*digiItr);
1075 
1076  if (NbOfSamplesFromDigis > 0 && NbOfSamplesFromDigis <= fMyEEEcal.MaxSampADC()) {
1077  Double_t adcDBLS = (Double_t)0;
1078  // Three 1st samples mean value for Dynamic Base Line
1079  // Substraction (DBLS)
1080  if (fDynBaseLineSub == "yes") {
1081  for (Int_t i0Sample = 0; i0Sample < 3; i0Sample++) {
1082  adcDBLS += (Double_t)(df.sample(i0Sample).adc());
1083  }
1084  adcDBLS /= (Double_t)3;
1085  }
1086  // Loop over the samples
1087  for (Int_t i0Sample = 0; i0Sample < fNbOfSamples; i0Sample++) {
1088  Double_t adc = (Double_t)(df.sample(i0Sample).adc()) - adcDBLS;
1089  //................................................. Calls
1090  // to GetSampleAdcValues
1091  if (fMyCnaEEDee[i0Dee]->GetSampleAdcValues(
1092  fStexNbOfTreatedEvents[i0Dee], n1DeeSCEcna, i0SCEcha, i0Sample, adc) == kTRUE) {
1093  fBuildEventDistribGood[i0Dee]++;
1094  } else {
1095  fBuildEventDistribBad[i0Dee]++;
1096  }
1097  }
1098  } else {
1099  edm::LogVerbatim("ecnaAnal")
1100  << "EcnaAnalyzer::analyze(...)> NbOfSamplesFromDigis out of bounds = " << NbOfSamplesFromDigis;
1101  }
1102  } // end of if( (fStexNumber > 0 && i0Dee == fStexNumber-1) ||
1103  // (fStexNumber == 0) )
1104  } // end of if( fFedNbOfTreatedEvents[fESFromFedTcc[fFedTcc-1]-1]
1105  // >= 1 &&
1106  // fFedNbOfTreatedEvents[fESFromFedTcc[fFedTcc-1]-1] <=
1107  // fReqNbOfEvts )
1108  } // end of if( fStexStatus[i0Dee] < 2 )
1109  } // end of if( i0Dee >= 0 && i0Dee<fMaxTreatedStexCounter )
1110  } // end of for (EBDigiCollection::const_iterator digiItr =
1111  // digisEB->begin();
1112  // digiItr != digisEB->end(); ++digiItr)
1113 
1114  // reset fStexDigiOK[i0Dee] or fFedDigiOK[i0Dee] to zero after loop on
1115  // digis
1116  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
1117  fAnalysisName == "AdcAny") {
1118  for (Int_t i0FedES = 0; i0FedES < fMaxFedUnitCounter; i0FedES++) {
1119  fFedDigiOK[i0FedES] = 0;
1120  }
1121 
1122  // reset fDeeDS5Memo1 and fDeeDS5Memo2 (for Data sector 5 versus Dee
1123  // number management)
1124  fDeeDS5Memo1 = 0;
1125  fDeeDS5Memo2 = 0;
1126  } else {
1127  for (Int_t i0Dee = 0; i0Dee < fMaxTreatedStexCounter; i0Dee++) {
1128  fStexDigiOK[i0Dee] = 0;
1129  }
1130  }
1131 
1132  } // end of if( Int_t(digisEB->end()-digisEB->begin()) >= 0 &&
1133  // Int_t(digisEB->end()-digisEB->begin()) <= Int_t(digisEB->size()) )
1134 
1135  } // end of if( fStexName == "Dee" && fDeeIndexBegin < fDeeIndexStop )
1136  } // end of if( (fStexNumber > 0 && fNbOfTreatedStexs == 0) || (fStexNumber ==
1137  // 0 && fNbOfTreatedStexs < MaxNbOfStex) )
1138 
1139  //=============================================================================================
1140  //
1141  // Number of treated events. Setting Stex and Fed status.
1142  //
1143  //=============================================================================================
1144 
1145  // (take into account the "Accelerating selection with FED number" section -
1146  // see above -)
1147  if (fStexName == "SM" || (fStexName == "Dee" &&
1148  !(fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" ||
1149  fAnalysisName == "AdcPhys" || fAnalysisName == "AdcAny"))) // one FED = one SM = one Stex
1150  {
1151  for (Int_t i0Stex = fStexIndexBegin; i0Stex < fStexIndexStop; i0Stex++) {
1152  if (fStexStatus[i0Stex] != 2) // do not change fStexStatus[i0Stex] if already set to 2
1153  // even if fStexNbOfTreatedEvents[i0Stex] == fReqNbOfEvts
1154  {
1155  if (fStexNbOfTreatedEvents[i0Stex] == fReqNbOfEvts) {
1156  fStexStatus[i0Stex] = 1;
1157  }
1158  if (fStexNbOfTreatedEvents[i0Stex] > fReqNbOfEvts) {
1159  fStexStatus[i0Stex] = 2;
1160  }
1161  }
1162  }
1163  }
1164 
1165  // one FED = one Data Sector (DS or ES)
1166  if (fStexName == "Dee" && (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" ||
1167  fAnalysisName == "AdcPhys" || fAnalysisName == "AdcAny")) {
1168  for (Int_t i0FedES = 0; i0FedES < fMaxFedUnitCounter; i0FedES++) {
1169  if (fFedStatus[i0FedES] != 2) // do not change fFedStatus[i0FedES] if already set to 2
1170  // even if fFedNbOfTreatedEvents[i0FedES] == fReqNbOfEvts
1171  {
1172  if (fFedNbOfTreatedEvents[i0FedES] == fReqNbOfEvts) {
1173  fFedStatus[i0FedES] = 1;
1174  fTreatedFedOrder++;
1175  fFedStatusOrder[i0FedES] = fTreatedFedOrder;
1176  }
1177  if (fFedNbOfTreatedEvents[i0FedES] > fReqNbOfEvts) {
1178  fFedStatus[i0FedES] = 2;
1179  }
1180  }
1181  }
1182 
1183  Int_t j0Fed = 4;
1184  //..................................................... Dee 4 (DS 1,2,3,4 ;
1185  // ES 1,2,3,4)
1186  for (Int_t i0FedES = 0; i0FedES <= 3; i0FedES++) {
1187  if (fFedStatus[i0FedES] == 1) {
1188  fNbOfTreatedFedsInDee[3]++;
1189  fFedStatus[i0FedES] = 2;
1190  }
1191  }
1192 
1193  //..................................................... Dee 3, Dee 4 (DS 5 ;
1194  // ES 5)
1195  j0Fed = 4;
1196  if (fFedStatus[j0Fed] == 1) {
1197  fNbOfTreatedFedsInDee[3]++;
1198  fNbOfTreatedFedsInDee[2]++;
1199  fFedStatus[j0Fed] = 2;
1200  }
1201 
1202  //.................................................... Dee 3 (DS 6,7,8,9 ;
1203  // ES 6,7,8,9)
1204  for (Int_t i0FedES = 5; i0FedES <= 8; i0FedES++) {
1205  if (fFedStatus[i0FedES] == 1) {
1206  fNbOfTreatedFedsInDee[2]++;
1207  fFedStatus[i0FedES] = 2;
1208  }
1209  }
1210 
1211  //..................................................... Dee 1 (DS 1,2,3,4 ;
1212  // ES 10,11,12,13)
1213  for (Int_t i0FedES = 9; i0FedES <= 12; i0FedES++) {
1214  if (fFedStatus[i0FedES] == 1) {
1215  fNbOfTreatedFedsInDee[0]++;
1216  fFedStatus[i0FedES] = 2;
1217  }
1218  }
1219 
1220  //..................................................... Dee 1, Dee 2 (DS 5 ;
1221  // ES 5)
1222  j0Fed = 13;
1223  if (fFedStatus[j0Fed] == 1) {
1224  fNbOfTreatedFedsInDee[0]++;
1225  fNbOfTreatedFedsInDee[1]++;
1226  fFedStatus[j0Fed] = 2;
1227  }
1228 
1229  //..................................................... Dee 2 (DS 6,7,8,9 ;
1230  // ES 15,16,17,18)
1231  for (Int_t i0FedES = 14; i0FedES <= 17; i0FedES++) {
1232  if (fFedStatus[i0FedES] == 1) {
1233  fNbOfTreatedFedsInDee[1]++;
1234  fFedStatus[i0FedES] = 2;
1235  }
1236  }
1237 
1238  //-----------------------------------------------------
1239  for (Int_t i0Dee = 0; i0Dee < 4; i0Dee++) {
1240  if (fNbOfTreatedFedsInStex[i0Dee] >= 0 && fNbOfTreatedFedsInStex[i0Dee] < 5) {
1242  }
1243  if (fNbOfTreatedFedsInDee[i0Dee] == 5) {
1244  fStexStatus[i0Dee] = 1;
1245  fNbOfTreatedFedsInDee[i0Dee] = 0;
1246  }
1247  }
1248 
1249  } // end of if( fStexName == "Dee" &&
1250  // ( fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" ... ) )
1251 
1252  //----------------------------------------------------------------------------------------------
1253  for (Int_t i0Stex = fStexIndexBegin; i0Stex < fStexIndexStop; i0Stex++) {
1254  if (fStexStatus[i0Stex] == 1) {
1255  fNbOfTreatedStexs++; // increase nb of treated Stex's only if
1256  // fStexStatus[i0Stex] == 1
1257  //....................................................... date of last
1258  // event edm::Timestamp Time = iEvent.time(); edm::TimeValue_t
1259  // t_current_ev_time = (cond::Time_t)Time.value(); time_t
1260  // i_current_ev_time = (time_t)(t_current_ev_time>>32); const time_t*
1261  // p_current_ev_time = &i_current_ev_time; char* astime =
1262  // ctime(p_current_ev_time); fTimeLast[i0Stex] = i_current_ev_time;
1263  // fDateLast[i0Stex] = astime;
1264 
1265  // if( i_current_ev_time > fTimeLast[i0Stex] )
1266  // {fTimeLast[i0Stex] = i_current_ev_time; fDateLast[i0Stex] = astime;}
1267 
1268  edm::LogVerbatim("ecnaAnal") << "---------- End of analysis for " << fStexName << i0Stex + 1 << " -----------";
1269  Int_t n3 = 3;
1270  CheckMsg(n3, i0Stex);
1271  edm::LogVerbatim("ecnaAnal") << " Number of selected events = " << fNbOfSelectedEvents;
1272  edm::LogVerbatim("ecnaAnal") << std::endl
1273  << fNbOfTreatedStexs << " " << fStexName << "'s with " << fReqNbOfEvts
1274  << " events analyzed."
1275  << "\n---------------------------------------------------------";
1276 
1277  //================================= WRITE RESULTS FILE
1278  if (fStexName == "SM") {
1279  if (fMyCnaEBSM[i0Stex].get() != nullptr) {
1280  //........................................ register dates 1 and 2
1281  fMyCnaEBSM[i0Stex]->StartStopDate(fDateFirst[i0Stex], fDateLast[i0Stex]);
1282  fMyCnaEBSM[i0Stex]->StartStopTime(fTimeFirst[i0Stex], fTimeLast[i0Stex]);
1283 
1284  //........................................ Init .root file
1285  fMyCnaEBSM[i0Stex]->GetReadyToCompute();
1286  fMyCnaEBSM[i0Stex]->SampleValues();
1287 
1288  //........................................ write the sample values in
1289  //.root file
1290  if (fMyCnaEBSM[i0Stex]->WriteRootFile() == kFALSE) {
1291  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer::analyze> PROBLEM with write ROOT file for SM" << i0Stex + 1
1292  << fTTBELL;
1293  }
1294  }
1295  // set pointer to zero in order to avoid recalculation and rewriting at
1296  // the destructor level
1297  fMyCnaEBSM[i0Stex].reset();
1298  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer::analyze> Set memory free: delete done for SM " << i0Stex + 1;
1299  }
1300 
1301  if (fStexName == "Dee") {
1302  if (fMyCnaEEDee[i0Stex].get() != nullptr) {
1303  //........................................ register dates 1 and 2
1304  fMyCnaEEDee[i0Stex]->StartStopDate(fDateFirst[i0Stex], fDateLast[i0Stex]);
1305  fMyCnaEEDee[i0Stex]->StartStopTime(fTimeFirst[i0Stex], fTimeLast[i0Stex]);
1306 
1307  //........................................ Init .root file
1308  fMyCnaEEDee[i0Stex]->GetReadyToCompute();
1309  fMyCnaEEDee[i0Stex]->SampleValues();
1310 
1311  //........................................ write the sample values in
1312  //.root file
1313  if (fMyCnaEEDee[i0Stex]->WriteRootFile() == kFALSE) {
1314  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer::analyze> PROBLEM with write ROOT file for Dee" << i0Stex + 1
1315  << " " << fTTBELL;
1316  }
1317  }
1318  // set pointer to zero in order to avoid recalculation and rewriting at
1319  // the destructor level
1320  fMyCnaEEDee[i0Stex].reset();
1321  edm::LogVerbatim("ecnaAnal") << "!EcnaAnalyzer::analyze> Set memory free: delete done for Dee " << i0Stex + 1;
1322  }
1323 
1324  fStexStatus[i0Stex] = 2; // set fStexStatus[i0Stex] to 2 definitively
1325  edm::LogVerbatim("ecnaAnal") << "*---------------------------------------------------------------------------- ";
1326 
1327  } // end of if( fStexStatus[i0Stex] == 1 )
1328  } // end of for(Int_t i0Stex=fStexIndexBegin; i0Stex<fStexIndexStop; i0Stex++)
1329 }
1330 // end of EcnaAnalyzer::analyse(...)
1331 
1332 Bool_t EcnaAnalyzer::AnalysisOutcome(const TString &s_opt) {
1333  //---- STOP if end of analysis
1334 
1335  Bool_t result = kFALSE;
1336 
1337  if (s_opt == "EVT") {
1338  Int_t MaxNbOfStex = 0;
1339  if (fStexName == "SM") {
1340  MaxNbOfStex = fMyEBEcal.MaxSMInEB();
1341  }
1342  if (fStexName == "Dee") {
1343  MaxNbOfStex = fMyEEEcal.MaxDeeInEE();
1344  }
1345 
1346  if (((fStexNumber > 0 && fNbOfTreatedStexs == 1) || (fStexNumber == 0 && fNbOfTreatedStexs == MaxNbOfStex)) &&
1349  edm::LogVerbatim("ecnaAnal")
1350  << "\n**************************** ANALYSIS REPORT > OK **************************************"
1351  << "\n*EcnaAnalyzer::AnalysisOutcome(...)> The maximum requested number of events and the maximum"
1352  << "\n number of treated " << fStexName << "'s have been reached."
1353  << "\n Analysis successfully ended from EcnaAnalyzer "
1354  << "\n Number of selected events = " << fNbOfSelectedEvents
1355  << "\n Last requested event number = " << fLastReqEvent
1356  << "\n Current event number = " << fCurrentEventNumber;
1357 
1358  Int_t n0 = 0;
1359  CheckMsg(n0);
1360 
1361  edm::LogVerbatim("ecnaAnal")
1362  << "****************************************************************************************\n";
1363 
1364  result = kTRUE;
1365  return result;
1366  }
1367 
1369  !((fStexNumber > 0 && fNbOfTreatedStexs == 1) || (fStexNumber == 0 && fNbOfTreatedStexs == MaxNbOfStex))) {
1370  edm::LogVerbatim("ecnaAnal") << "\n**************************** ANALYSIS REPORT >>> *** "
1371  "WARNING *** WARNING *** WARNING ***"
1372  << "\n*EcnaAnalyzer::AnalysisOutcome(...)> Last event reached "
1373  "before completion of analysis."
1374  << "\n Analysis ended from EcnaAnalyzer "
1375  << "\n Number of selected events = "
1377  << "\n Last requested event number = "
1378  << fLastReqEvent
1379  << "\n Current event number = "
1381 
1382  Int_t n0 = 0;
1383  CheckMsg(n0);
1384 
1385  edm::LogVerbatim("ecnaAnal")
1386  << "****************************************************************************************" << std::endl;
1387 
1388  result = kTRUE;
1389  return result;
1390  }
1391  } else {
1392  if (s_opt == "ERR_FNEG") {
1393  edm::LogVerbatim("ecnaAnal")
1394  << "\n**************************** ANALYSIS REPORT >>> **** ERROR **** ERROR **** ERROR ******"
1395  << "\n*EcnaAnalyzer::AnalysisOutcome(...)> First event number = " << fFirstReqEvent
1396  << ". Should be strictly potitive."
1397  << "\n Analysis ended from EcnaAnalyzer ";
1398 
1399  edm::LogVerbatim("ecnaAnal")
1400  << "****************************************************************************************" << std::endl;
1401 
1402  result = kTRUE;
1403  return result;
1404  }
1405  if (s_opt == "ERR_LREQ") {
1406  edm::LogVerbatim("ecnaAnal")
1407  << "\n**************************** ANALYSIS REPORT >>> **** ERROR **** ERROR **** ERROR ******"
1408  << "\n*EcnaAnalyzer::analyze(...)> Requested number of events = " << fReqNbOfEvts << "."
1409  << "\n Too large compared to the event range: " << fFirstReqEvent << " - "
1410  << fLastReqEvent << "\n Analysis ended from EcnaAnalyzer ";
1411 
1412  edm::LogVerbatim("ecnaAnal")
1413  << "****************************************************************************************" << std::endl;
1414 
1415  result = kTRUE;
1416  return result;
1417  }
1418  }
1419  return result;
1420 } // end of EcnaAnalyzer::AnalysisOutcome(const Int_t& n_option)
1421 
1422 void EcnaAnalyzer::CheckMsg(const Int_t &MsgNum) {
1423  Int_t nm1 = -1;
1424  CheckMsg(MsgNum, nm1);
1425 }
1426 
1427 void EcnaAnalyzer::CheckMsg(const Int_t &MsgNum, const Int_t &i0Stex) {
1428  //------ Cross-check messages
1429 
1430  if (MsgNum == 1) {
1431  edm::LogVerbatim("ecnaAnal") << "---------------- CROSS-CHECK A ------------------ "
1432  << "\n**************** CURRENT EVENT ****************** ";
1433  }
1434  if (MsgNum == 2) {
1435  edm::LogVerbatim("ecnaAnal") << "---------------- CROSS-CHECK B ------------------ "
1436  << "\n**** FIRST EVENT PASSING USER'S ANALYSIS CUT **** ";
1437  }
1438  if (MsgNum == 3) {
1439  edm::LogVerbatim("ecnaAnal") << "---------------- CROSS-CHECK C ------------------ "
1440  << "\n*** CURRENT VALUES BEFORE RESULT FILE WRITING *** ";
1441  }
1442  if (MsgNum == 3 || MsgNum == 4) {
1443  edm::LogVerbatim("ecnaAnal") << " fRecNumber = " << fRecNumber
1444  << "\n fEvtNumber = " << fEvtNumber;
1445  }
1446 
1447  edm::LogVerbatim("ecnaAnal") << " fCurrentEventNumber = " << fCurrentEventNumber
1448  << "\n fNbOfSelectedEvents = " << fNbOfSelectedEvents
1449  << "\n fRunNumber = " << fRunNumber
1450  << "\n Chozen run type = " << runtype(fChozenRunTypeNumber)
1451  << "\n Run type = " << runtype(fRunTypeNumber)
1452  << "\n fFedTcc = " << fFedTcc << "\n fFedId(+601) = " << fFedId + 601
1453  << "\n fStexName = " << fStexName
1454  << "\n Chozen gain = " << gainvalue(fChozenGainNumber)
1455  << "\n Mgpa Gain = " << gainvalue(fMgpaGainNumber) << std::endl;
1456 
1457  if (fAnalysisName == "AdcPeg12" || fAnalysisName == "AdcSPeg12" || fAnalysisName == "AdcPhys" ||
1458  fAnalysisName == "AdcAny") {
1459  if (fStexName == "SM") {
1460  for (Int_t j0Stex = fStexIndexBegin; j0Stex < fStexIndexStop; j0Stex++) {
1461  Int_t nStexNbOfTreatedEvents = fStexNbOfTreatedEvents[j0Stex];
1462  if (fStexStatus[j0Stex] == 1) {
1463  nStexNbOfTreatedEvents = fStexNbOfTreatedEvents[j0Stex];
1464  }
1465  if (fStexStatus[j0Stex] == 2) {
1466  nStexNbOfTreatedEvents = fStexNbOfTreatedEvents[j0Stex];
1467  }
1468 
1469  edm::LogVerbatim("ecnaAnal") << fStexName << std::setw(3) << j0Stex + 1 << ": " << std::setw(5)
1470  << nStexNbOfTreatedEvents << " events. " << fStexName
1471  << " status: " << fStexStatus[j0Stex];
1472  if (j0Stex == i0Stex) {
1473  edm::LogVerbatim("ecnaAnal") << " (going to write file for this " << fStexName << ").";
1474  }
1475  }
1476  }
1477 
1478  if (fStexName == "Dee") {
1479  for (Int_t i0FedES = 0; i0FedES < fMaxFedUnitCounter; i0FedES++) {
1480  Int_t nFedNbOfTreatedEvents = fFedNbOfTreatedEvents[i0FedES];
1481  if (fFedStatus[i0FedES] == 1) {
1482  nFedNbOfTreatedEvents = fFedNbOfTreatedEvents[i0FedES];
1483  }
1484  if (fFedStatus[i0FedES] == 2) {
1485  nFedNbOfTreatedEvents = fFedNbOfTreatedEvents[i0FedES];
1486  }
1487 
1488  edm::LogVerbatim("ecnaAnal") << "Fed (ES) " << std::setw(3) << i0FedES + 1 << ": " << std::setw(5)
1489  << nFedNbOfTreatedEvents << " events."
1490  << " Fed status: " << fFedStatus[i0FedES] << ", order: " << std::setw(3)
1491  << fFedStatusOrder[i0FedES] << " (" << fDeeNumberString[i0FedES] << ")";
1492  }
1493 
1494  for (Int_t j0Stex = fStexIndexBegin; j0Stex < fStexIndexStop; j0Stex++) {
1495  edm::LogVerbatim("ecnaAnal") << fStexName << std::setw(3) << j0Stex + 1 << ": " << std::setw(5)
1496  << fNbOfTreatedFedsInStex[j0Stex] << " analyzed Fed(s). " << fStexName
1497  << " status: " << fStexStatus[j0Stex];
1498  if (j0Stex == i0Stex) {
1499  edm::LogVerbatim("ecnaAnal") << " (going to write file for this " << fStexName << ").";
1500  }
1501  }
1502  }
1503 
1504  edm::LogVerbatim("ecnaAnal") << "Number of " << fStexName << "'s with " << fReqNbOfEvts
1505  << " events analyzed: " << fNbOfTreatedStexs;
1506  }
1507 
1508  if (MsgNum == 1 || MsgNum == 2) {
1509  edm::LogVerbatim("ecnaAnal") << "*---------------------------------------------------------------------------- ";
1510  }
1511  if (MsgNum == 3) {
1512  edm::LogVerbatim("ecnaAnal") << "*............................................................................ ";
1513  }
1514 
1515 } // end of EcnaAnalyzer::CheckMsg(const Int_t& MsgNum, const Int_t& i0Stex)
1516 
1517 TString EcnaAnalyzer::runtype(const Int_t &numtype) {
1518  TString cType = "?";
1519 
1520  if (numtype == 0) {
1521  cType = "COSMICS";
1522  }
1523  if (numtype == 1) {
1524  cType = "BEAMH4";
1525  }
1526  if (numtype == 2) {
1527  cType = "BEAMH2";
1528  }
1529  if (numtype == 3) {
1530  cType = "MTCC";
1531  }
1532  if (numtype == 4) {
1533  cType = "LASER_STD";
1534  }
1535  if (numtype == 5) {
1536  cType = "LASER_POWER_SCAN";
1537  }
1538  if (numtype == 6) {
1539  cType = "LASER_DELAY_SCAN";
1540  }
1541  if (numtype == 7) {
1542  cType = "TESTPULSE_SCAN_MEM";
1543  }
1544  if (numtype == 8) {
1545  cType = "TESTPULSE_MGPA";
1546  }
1547  if (numtype == 9) {
1548  cType = "PEDESTAL_STD";
1549  }
1550  if (numtype == 10) {
1551  cType = "PEDESTAL_OFFSET_SCAN";
1552  }
1553  if (numtype == 11) {
1554  cType = "PEDESTAL_25NS_SCAN";
1555  }
1556  if (numtype == 12) {
1557  cType = "LED_STD";
1558  }
1559 
1560  if (numtype == 13) {
1561  cType = "PHYSICS_GLOBAL";
1562  }
1563  if (numtype == 14) {
1564  cType = "COSMICS_GLOBAL";
1565  }
1566  if (numtype == 15) {
1567  cType = "HALO_GLOBAL";
1568  }
1569 
1570  if (numtype == 16) {
1571  cType = "LASER_GAP";
1572  }
1573  if (numtype == 17) {
1574  cType = "TESTPULSE_GAP";
1575  }
1576  if (numtype == 18) {
1577  cType = "PEDESTAL_GAP";
1578  }
1579  if (numtype == 19) {
1580  cType = "LED_GAP";
1581  }
1582 
1583  if (numtype == 20) {
1584  cType = "PHYSICS_LOCAL";
1585  }
1586  if (numtype == 21) {
1587  cType = "COSMICS_LOCAL";
1588  }
1589  if (numtype == 22) {
1590  cType = "HALO_LOCAL";
1591  }
1592  if (numtype == 23) {
1593  cType = "CALIB_LOCAL";
1594  }
1595 
1596  //.......................................... non-CMS types
1597  if (numtype == 24) {
1598  cType = "PEDSIM";
1599  } // SIMULATION
1600  if (numtype == 25) {
1601  cType = "ANY_RUN";
1602  } // ANY RUN (ALL TYPES ACCEPTED)
1603 
1604  return cType;
1605 }
1606 
1607 Int_t EcnaAnalyzer::gainvalue(const Int_t &numgain) {
1608  Int_t value = 0;
1609 
1610  if (numgain == 1) {
1611  value = 12;
1612  }
1613  if (numgain == 2) {
1614  value = 6;
1615  }
1616  if (numgain == 3) {
1617  value = 1;
1618  }
1619 
1620  return value;
1621 }
Int_t MaxCrysPhiInTow()
Log< level::Info, true > LogVerbatim
Int_t fFirstReqEvent
Definition: EcnaAnalyzer.h:196
edm::EDGetTokenT< EEDigiCollection > EEdigiToken_
Definition: EcnaAnalyzer.h:162
Int_t MaxSCIYInDee()
std::string digiProducer_
Definition: EcnaAnalyzer.h:156
Int_t fStexIndexBegin
Definition: EcnaAnalyzer.h:208
Int_t fDeeDS5Memo2
Definition: EcnaAnalyzer.h:221
TEcnaParEcal fMyEEEcal
Definition: EcnaAnalyzer.h:260
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< time_t > fTimeLast
Definition: EcnaAnalyzer.h:244
Int_t fRunTypeNumber
Definition: EcnaAnalyzer.h:195
TString runtype(const Int_t &)
Int_t fChozenRunTypeNumber
Definition: EcnaAnalyzer.h:190
EcnaAnalyzer(const edm::ParameterSet &)
Definition: EcnaAnalyzer.cc:45
~EcnaAnalyzer() override
TString GetDeeDirViewedFromIP(const Int_t &)
T const * product() const
Definition: Handle.h:70
TEcnaParEcal fMyEBEcal
Definition: EcnaAnalyzer.h:257
int ix() const
Definition: EEDetId.h:77
std::vector< T >::const_iterator const_iterator
TString sAnalysisName_
Definition: EcnaAnalyzer.h:164
Int_t fDeeIndexStop
Definition: EcnaAnalyzer.h:207
std::vector< Int_t > fNbOfTreatedFedsInStex
Definition: EcnaAnalyzer.h:234
Int_t fNbOfTreatedStexs
Definition: EcnaAnalyzer.h:232
Int_t MaxTowPhiInSM()
Int_t Get0TowEchaFrom1SMCrys(const Int_t &)
Int_t gainvalue(const Int_t &)
TString sNbOfSamples_
Definition: EcnaAnalyzer.h:165
Log< level::Error, false > LogError
Int_t Get1DeeSCEcnaFrom1DeeCrys(const Int_t &, const TString &)
Bool_t AnalysisOutcome(const TString &)
TString fAnalysisName
Definition: EcnaAnalyzer.h:188
void CheckMsg(const Int_t &, const Int_t &)
Int_t fCurrentEventNumber
Definition: EcnaAnalyzer.h:177
Int_t Get1SMTowFrom1SMCrys(const Int_t &)
std::vector< Int_t > fFedNbOfTreatedEvents
Definition: EcnaAnalyzer.h:229
Int_t fPEDESTAL_GAP
Definition: EcnaAnalyzer.h:238
Int_t fDeeDS5Memo1
Definition: EcnaAnalyzer.h:220
std::vector< Int_t > fBuildEventDistribBad
Definition: EcnaAnalyzer.h:180
TString sLastReqEvent_
Definition: EcnaAnalyzer.h:167
TString fStexName
Definition: EcnaAnalyzer.h:198
std::vector< TString > fDateLast
Definition: EcnaAnalyzer.h:246
std::array< Int_t, fMaxRunTypeCounter > fRunTypeCounter
Definition: EcnaAnalyzer.h:266
static constexpr Int_t fMaxFedIdCounter
Definition: EcnaAnalyzer.h:271
Int_t fMgpaGainNumber
Definition: EcnaAnalyzer.h:202
std::vector< Int_t > fStexDigiOK
Definition: EcnaAnalyzer.h:222
Int_t fStexNumber
Definition: EcnaAnalyzer.h:199
std::string EBdigiCollection_
Definition: EcnaAnalyzer.h:158
Bool_t fOutcomeError
Definition: EcnaAnalyzer.h:172
Int_t fMaxTreatedStexCounter
Definition: EcnaAnalyzer.h:219
int iEvent
Definition: GenABIO.cc:224
Int_t fEvtNumber
Definition: EcnaAnalyzer.h:174
TString fDynBaseLineSub
Definition: EcnaAnalyzer.h:191
edm::EDGetTokenT< EcalRawDataCollection > eventHeaderToken_
Definition: EcnaAnalyzer.h:160
unsigned long long Time_t
Definition: Time.h:14
std::vector< time_t > fTimeFirst
Definition: EcnaAnalyzer.h:243
int n0
Definition: AMPTWrapper.h:44
Int_t Get1SCEchaFrom1DeeCrys(const Int_t &, const TString &)
Int_t fNbOfSelectedEvents
Definition: EcnaAnalyzer.h:178
Int_t fMaxFedUnitCounter
Definition: EcnaAnalyzer.h:226
std::array< Int_t, fMaxFedIdCounter > fFedIdCounter
Definition: EcnaAnalyzer.h:272
Int_t fRecNumber
Definition: EcnaAnalyzer.h:176
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
Int_t fSMIndexBegin
Definition: EcnaAnalyzer.h:204
edm::EDGetTokenT< EBDigiCollection > EBdigiToken_
Definition: EcnaAnalyzer.h:161
std::vector< Int_t > fMemoDateFirstEvent
Definition: EcnaAnalyzer.h:248
Int_t fPEDESTAL_STD
Definition: EcnaAnalyzer.h:237
const_iterator begin() const
Definition: value.py:1
Int_t fTreatedFedOrder
Definition: EcnaAnalyzer.h:214
unsigned long long TimeValue_t
Definition: Timestamp.h:21
Int_t fPHYSICS_GLOBAL
Definition: EcnaAnalyzer.h:240
Int_t fSMIndexStop
Definition: EcnaAnalyzer.h:205
Int_t fRunNumber
Definition: EcnaAnalyzer.h:194
const_iterator end() const
const_iterator end() const
static constexpr Int_t fgMaxCar
Definition: EcnaAnalyzer.h:148
Int_t MaxDSInEE()
std::vector< std::unique_ptr< TEcnaRun > > fMyCnaEBSM
Definition: EcnaAnalyzer.h:253
std::array< Int_t, fMaxMgpaGainCounter > fMgpaGainCounter
Definition: EcnaAnalyzer.h:269
TEcnaObject fMyEcnaEBObjectManager
Definition: EcnaAnalyzer.h:250
std::vector< Int_t > fBuildEventDistribGood
Definition: EcnaAnalyzer.h:181
Int_t MaxCrysIYInSC()
std::vector< std::unique_ptr< TEcnaRun > > fMyCnaEEDee
Definition: EcnaAnalyzer.h:254
std::string eventHeaderProducer_
Definition: EcnaAnalyzer.h:155
std::vector< Int_t > fStexStatus
Definition: EcnaAnalyzer.h:224
TEcnaObject fMyEcnaEEObjectManager
Definition: EcnaAnalyzer.h:251
TString fTTBELL
Definition: EcnaAnalyzer.h:149
Int_t fLastReqEvent
Definition: EcnaAnalyzer.h:197
TEcnaNumbering fMyEENumbering
Definition: EcnaAnalyzer.h:259
const_iterator begin() const
The iterator returned can not safely be used across threads.
Int_t fMemoCutOK
Definition: EcnaAnalyzer.h:231
std::vector< Int_t > fFedStatusOrder
Definition: EcnaAnalyzer.h:215
Int_t nChannels_
Definition: EcnaAnalyzer.h:153
static constexpr Int_t fMaxRunTypeCounter
Definition: EcnaAnalyzer.h:265
Int_t fDeeIndexBegin
Definition: EcnaAnalyzer.h:206
Int_t fNbOfSamples
Definition: EcnaAnalyzer.h:193
std::vector< Int_t > fESFromFedTcc
Definition: EcnaAnalyzer.h:213
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool isValid() const
Definition: HandleBase.h:70
std::vector< Int_t > fSMFromFedTcc
Definition: EcnaAnalyzer.h:212
std::string eventHeaderCollection_
Definition: EcnaAnalyzer.h:157
Int_t MaxSampADC()
Int_t MaxDeeInEE()
Int_t MaxSMInEB()
void analyze(const edm::Event &, const edm::EventSetup &) override
Int_t fEvtNumberMemo
Definition: EcnaAnalyzer.h:175
TString sFirstReqEvent_
Definition: EcnaAnalyzer.h:166
Int_t fLASER_STD
Definition: EcnaAnalyzer.h:239
Int_t fStexIndexStop
Definition: EcnaAnalyzer.h:209
std::string EEdigiCollection_
Definition: EcnaAnalyzer.h:159
TString sStexNumber_
Definition: EcnaAnalyzer.h:170
std::vector< Int_t > fFedStatus
Definition: EcnaAnalyzer.h:227
static constexpr Int_t fMaxMgpaGainCounter
Definition: EcnaAnalyzer.h:268
std::vector< Int_t > fStexNbOfTreatedEvents
Definition: EcnaAnalyzer.h:223
std::vector< TString > fDateFirst
Definition: EcnaAnalyzer.h:245
Int_t fReqNbOfEvts
Definition: EcnaAnalyzer.h:201
std::vector< Int_t > fNbOfTreatedFedsInDee
Definition: EcnaAnalyzer.h:233
TString sReqNbOfEvts_
Definition: EcnaAnalyzer.h:168
TEcnaNumbering fMyEBNumbering
Definition: EcnaAnalyzer.h:256
Int_t fChozenGainNumber
Definition: EcnaAnalyzer.h:189
TString sStexName_
Definition: EcnaAnalyzer.h:169
std::vector< Int_t > fFedDigiOK
Definition: EcnaAnalyzer.h:228
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::vector< std::string > fDeeNumberString
Definition: EcnaAnalyzer.h:217