CMS 3D CMS Logo

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