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