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