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