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