CMS 3D CMS Logo

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