CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TEcnaRun.cc
Go to the documentation of this file.
1 //----------Author's Names: B.Fabbro, FX Gentit DSM/IRFU/SPP CEA-Saclay
2 //----------Copyright: Those valid for CEA sofware
3 //----------Modified: 24/03/2011
4 
6 
7 //--------------------------------------
8 // TEcnaRun.cc
9 // Class creation: 03 Dec 2002
10 // Documentation: see TEcnaRun.h
11 //--------------------------------------
12 
14 
15 ClassImp(TEcnaRun)
16 //___________________________________________________________________________
17 //
18 
20 {
21 //Constructor without argument: nothing special done
22 
23  // cout << "[Info Management] CLASS: TEcnaRun. CREATE OBJECT: this = " << this << endl;
24 }
25 
26 TEcnaRun::TEcnaRun(TEcnaObject* pObjectManager, const TString SubDet)
27 {
28 //Constructor with argument: call to Init() and declare fEcal according to SubDet value ("EB" or "EE")
29 
30  // cout << "[Info Management] CLASS: TEcnaRun. CREATE OBJECT: this = " << this << endl;
31 
32  Init();
33  fObjectManager = (TEcnaObject*)pObjectManager;
34  Long_t i_this = (Long_t)this;
35  pObjectManager->RegisterPointer("TEcnaRun", i_this);
36 
37  //............................ fCnaParCout
38  fCnaParCout = 0;
39  Long_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
40  if( iCnaParCout == 0 )
41  {fCnaParCout = new TEcnaParCout(pObjectManager); /*fCnew++*/}
42  else
43  {fCnaParCout = (TEcnaParCout*)iCnaParCout;}
44 
45  //............................ fCnaParPaths
46  fCnaParPaths = 0;
47  Long_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
48  if( iCnaParPaths == 0 )
49  {fCnaParPaths = new TEcnaParPaths(pObjectManager); /*fCnew++*/}
50  else
51  {fCnaParPaths = (TEcnaParPaths*)iCnaParPaths;}
52 
53  //fCfgResultsRootFilePath = fCnaParPaths->ResultsRootFilePath();
54  //fCfgHistoryRunListFilePath = fCnaParPaths->HistoryRunListFilePath();
55 
56  //ffFileHeader = 0;
57  //fconst Text_t *h_name = "CnaHeader"; //==> voir cette question avec FXG
58  //fconst Text_t *h_title = "CnaHeader"; //==> voir cette question avec FXG
59  //ffFileHeader = new TEcnaHeader(h_name, h_title); //fCnew++;
60 
61  //............................ fFileHeader
62  const Text_t *h_name = "CnaHeader"; //==> voir cette question avec FXG
63  const Text_t *h_title = "CnaHeader"; //==> voir cette question avec FXG
64 
65  fFileHeader = 0;
66  //Int_t iFileHeader = pObjectManager->GetPointerValue("TEcnaHeader");
67  Long_t iFileHeader = 0; // one TEcnaHeader object for each file since they can be open simultaneously
68  if( iFileHeader == 0 )
69  {fFileHeader = new TEcnaHeader(pObjectManager, h_name, h_title); /*fCnew++*/}
70  else
71  {fFileHeader = (TEcnaHeader*)iFileHeader;}
72 
73  SetEcalSubDetector(SubDet.Data());
74  fNbSampForFic = fEcal->MaxSampADC(); // DEFAULT Number of samples for ROOT file
75 }
76 
77 TEcnaRun::TEcnaRun(TEcnaObject* pObjectManager, const TString SubDet, const Int_t& NbOfSamples)
78 {
79  //fCnaParPaths = 0; fCnaParPaths = new TEcnaParPaths(); //fCnew++;
80  //fCnaParCout = 0; fCnaParCout = new TEcnaParCout(); //fCnew++;
81 
82  Init();
83  fObjectManager = (TEcnaObject*)pObjectManager;
84  Long_t i_this = (Long_t)this;
85  pObjectManager->RegisterPointer("TEcnaRun", i_this);
86 
87  //............................ fCnaParCout
88  fCnaParCout = 0;
89  Long_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
90  if( iCnaParCout == 0 )
91  {fCnaParCout = new TEcnaParCout(pObjectManager); /*fCnew++*/}
92  else
93  {fCnaParCout = (TEcnaParCout*)iCnaParCout;}
94 
95  //............................ fCnaParPaths
96  fCnaParPaths = 0;
97  Long_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
98  if( iCnaParPaths == 0 )
99  {fCnaParPaths = new TEcnaParPaths(pObjectManager); /*fCnew++*/}
100  else
101  {fCnaParPaths = (TEcnaParPaths*)iCnaParPaths;}
102 
103  //fCfgResultsRootFilePath = fCnaParPaths->ResultsRootFilePath();
104  //fCfgHistoryRunListFilePath = fCnaParPaths->HistoryRunListFilePath();
105 
106  //............................ fFileHeader
107  const Text_t *h_name = "CnaHeader"; //==> voir cette question avec FXG
108  const Text_t *h_title = "CnaHeader"; //==> voir cette question avec FXG
109 
110  fFileHeader = 0;
111  //Long_t iFileHeader = pObjectManager->GetPointerValue("TEcnaHeader");
112  Long_t iFileHeader = 0; // one TEcnaHeader object for each file since they can be open simultaneously
113  if( iFileHeader == 0 )
114  {fFileHeader = new TEcnaHeader(pObjectManager, h_name, h_title); /*fCnew++*/}
115  else
116  {fFileHeader = (TEcnaHeader*)iFileHeader;}
117 
118  SetEcalSubDetector(SubDet.Data());
119  if( NbOfSamples>0 && NbOfSamples<=fEcal->MaxSampADC() )
120  {
121  fNbSampForFic = NbOfSamples;
122  }
123  else
124  {
125  cout << "TEcnaRun/CONSTRUCTOR> Number of required samples = " << NbOfSamples
126  << ": OUT OF RANGE. Set to the default value (= " << fEcal->MaxSampADC() << ")."
127  << fTTBELL << endl;
128  fNbSampForFic = fEcal->MaxSampADC(); // DEFAULT Number of samples for file reading
129  }
130 }
131 
132 //.... return true or false according to the existence of the path. The path itself is in an attribute of fCnaParPaths.
134 
136 {
137 //Initialisation
138 
139  fCnew = 0;
140  fCdelete = 0;
141  fCnaCommand = 0;
142  fCnaError = 0;
143 
144  fTTBELL = '\007';
145 
146  //........................... TString file names init
147  fgMaxCar = (Int_t)512;
148 
149  //................ MiscDiag counters .................
150  fMaxMsgIndexForMiscDiag = (Int_t)10;
151  fNbOfMiscDiagCounters = (Int_t)50;
152  fMiscDiag = 0;
153 
154  fNumberOfEvents = 0;
155  //............................. init pointers ( Init() )
156  fT3d_AdcValues = 0;
157  fT3d2_AdcValues = 0;
158  fT3d1_AdcValues = 0;
159 
161 
162  fT2d_NbOfEvts = 0;
163  fT1d_NbOfEvts = 0;
164 
165  fT2d_ev = 0;
166  fT1d_ev = 0;
167  fT2d_sig = 0;
168  fT1d_sig = 0;
169 
170  fT3d_cov_ss = 0;
171  fT3d2_cov_ss = 0;
172  fT3d1_cov_ss = 0;
173 
174  fT3d_cor_ss = 0;
175  fT3d2_cor_ss = 0;
176  fT3d1_cor_ss = 0;
177 
178  fT2d_lf_cov = 0;
179  fT2d1_lf_cov = 0;
180 
181  fT2d_lf_cor = 0;
182  fT2d1_lf_cor = 0;
183 
184  fT2d_hf_cov = 0;
185  fT2d1_hf_cov = 0;
186 
187  fT2d_hf_cor = 0;
188  fT2d1_hf_cor = 0;
189 
190  fT2d_lfcc_mostins = 0;
191  fT2d1_lfcc_mostins = 0;
192 
193  fT2d_hfcc_mostins = 0;
194  fT2d1_hfcc_mostins = 0;
195 
196  fT1d_ev_ev = 0;
198  fT1d_ev_cor_ss = 0;
199  fT1d_av_mped = 0;
200  fT1d_av_totn = 0;
201  fT1d_av_lofn = 0;
202  fT1d_av_hifn = 0;
203  fT1d_av_ev_corss = 0;
204  fT1d_av_sig_corss = 0;
205 
208  fT1d_sig_cor_ss = 0;
209 
212 
213  //................................ tags ( Init() )
214  fTagStinNumbers = 0;
215 
216  fTagNbOfEvts = 0;
217 
218  fTagAdcEvt = 0;
219 
220  fTagMSp = 0;
221  fTagSSp = 0;
222 
223  fTagCovCss = 0;
224  fTagCorCss = 0;
225 
226  fTagHfCov = 0;
227  fTagHfCor = 0;
228  fTagLfCov = 0;
229  fTagLfCor = 0;
230 
231  fTagLFccMoStins = 0;
232  fTagHFccMoStins = 0;
233 
234  fTagPed = 0;
235  fTagTno = 0;
236  fTagMeanCorss = 0;
237 
238  fTagLfn = 0;
239  fTagHfn = 0;
240  fTagSigCorss = 0;
241 
242  fTagAvPed = 0;
243  fTagAvTno = 0;
244  fTagAvLfn = 0;
245  fTagAvHfn = 0;
246 
247  fTagAvMeanCorss = 0;
248  fTagAvSigCorss = 0;
249 
250  //................................................... Code Print ( Init() )
252  fCodePrintWarnings = fCnaParCout->GetCodePrint("Warnings "); // => default value
255 
257 
258  //...................................................
259  gCnaRootFile = 0;
260  fOpenRootFile = kFALSE;
261  fReadyToReadData = 0;
262 
263  //.............................................. Miscellaneous
265 
266  fStinIndexBuilt = 0;
268 
270 
271 }// end of Init()
272 
273 //========================================================================
274 void TEcnaRun::SetEcalSubDetector(const TString SubDet)
275 {
276  // Set Subdetector (EB or EE)
277 
278  Int_t MaxCar = fgMaxCar;
279  fFlagSubDet.Resize(MaxCar);
280  fFlagSubDet = SubDet.Data();
281 
282  fEcal = 0; fEcal = new TEcnaParEcal(fFlagSubDet.Data()); //fCnew++;
283  fEcalNumbering = 0; fEcalNumbering = new TEcnaNumbering(fFlagSubDet.Data(), fEcal); //fCnew++;
284  fCnaWrite = 0;
285  fCnaWrite =
287 
288  if( fFlagSubDet == "EB" ){fStexName = "SM "; fStinName = "tower";}
289  if( fFlagSubDet == "EE" ){fStexName = "Dee"; fStinName = " SC ";}
290 }
291 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
292 //
293 // copy constructor
294 //
295 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
296 
298 {
299  cout << "*TEcnaRun::TEcnaRun(const TEcnaRun& dcop)> "
300  << " Now is the time to write a copy constructor"
301  << endl;
302 
303  //{ Int_t cintoto; cin >> cintoto; }
304 
305 }
306 
307 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
308 //
309 // overloading of the operator=
310 //
311 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
312 
313 //TEcnaRun& TEcnaRun::operator=(const TEcnaRun& dcop)
314 //{
315 //Overloading of the operator=
316 //
317 // fCopy(dcop);
318 // return *this;
319 //}
320 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
321 //
322 // destructor
323 //
324 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
325 
327 {
328  //Destructor
329 
331  {
332  cout << "*TEcnaRun::~TEcnaRun()> Entering destructor." << endl;
333  }
334 
336  {
337  if( fBuildEvtNotSkipped > 0 )
338  {
339  cout << "************************************************************************************* "
340  << endl;
341  cout << "*TEcnaRun::~TEcnaRun()> Nb of calls to GetSampleAdcValues by cmsRun: "
342  << fBuildEvtNotSkipped << endl;
343  cout << "************************************************************************************* "
344  << endl;
345  }
346  }
347 
349  {
350  Int_t misc_czero = 0;
351  for(Int_t i = 0; i < fNbOfMiscDiagCounters; i++)
352  {
353  if( fMiscDiag[i] != 0 )
354  {
355  cout << " fMiscDiag Counter "
356  << setw(3) << i << " = " << setw(9) << fMiscDiag[i]
357  << " (INFO: alloc on non zero freed zone) " << endl;
358  }
359  else
360  {
361  misc_czero++;
362  }
363  }
364  cout << " Nb of fMiscDiag counters at zero: "
365  << misc_czero << " (total nb of counters: "
366  << fNbOfMiscDiagCounters << ")" << endl;
367  }
368 
369  if (fMiscDiag != 0){delete [] fMiscDiag; fCdelete++;}
370 
371  //if (fFileHeader != 0){delete fFileHeader; fCdelete++;}
372  //if (fEcal != 0){delete fEcal; fCdelete++;}
373  //if (fEcalNumbering != 0){delete fEcalNumbering; fCdelete++;}
374  //if (fCnaParCout != 0){delete fCnaParCout; fCdelete++;}
375  //if (fCnaParPaths != 0){delete fCnaParPaths; fCdelete++;}
376  //if (fCnaWrite != 0){delete fCnaWrite; fCdelete++;}
377 
379 
380  if (fT2d_NbOfEvts != 0){delete [] fT2d_NbOfEvts; fCdelete++;}
381  if (fT1d_NbOfEvts != 0){delete [] fT1d_NbOfEvts; fCdelete++;}
382 
383  if (fT3d_AdcValues != 0){delete [] fT3d_AdcValues; fCdelete++;}
384  if (fT3d2_AdcValues != 0){delete [] fT3d2_AdcValues; fCdelete++;}
385  if (fT3d1_AdcValues != 0){delete [] fT3d1_AdcValues; fCdelete++;}
386 
387  if (fT2d_ev != 0){delete [] fT2d_ev; fCdelete++;}
388  if (fT1d_ev != 0){delete [] fT1d_ev; fCdelete++;}
389 
390  if (fT2d_sig != 0){delete [] fT2d_sig; fCdelete++;}
391  if (fT1d_sig != 0){delete [] fT1d_sig; fCdelete++;}
392 
393  if (fT3d_cov_ss != 0){delete [] fT3d_cov_ss; fCdelete++;}
394  if (fT3d2_cov_ss != 0){delete [] fT3d2_cov_ss; fCdelete++;}
395  if (fT3d1_cov_ss != 0){delete [] fT3d1_cov_ss; fCdelete++;}
396 
397  if (fT3d_cor_ss != 0){delete [] fT3d_cor_ss; fCdelete++;}
398  if (fT3d2_cor_ss != 0){delete [] fT3d2_cor_ss; fCdelete++;}
399  if (fT3d1_cor_ss != 0){delete [] fT3d1_cor_ss; fCdelete++;}
400 
401  if (fT2d_lf_cov != 0){delete [] fT2d_lf_cov; fCdelete++;}
402  if (fT2d1_lf_cov != 0){delete [] fT2d1_lf_cov; fCdelete++;}
403 
404  if (fT2d_lf_cor != 0){delete [] fT2d_lf_cor; fCdelete++;}
405  if (fT2d1_lf_cor != 0){delete [] fT2d1_lf_cor; fCdelete++;}
406 
407  if (fT2d_hf_cov != 0){delete [] fT2d_hf_cov; fCdelete++;}
408  if (fT2d1_hf_cov != 0){delete [] fT2d1_hf_cov; fCdelete++;}
409 
410  if (fT2d_hf_cor != 0){delete [] fT2d_hf_cor; fCdelete++;}
411  if (fT2d1_hf_cor != 0){delete [] fT2d1_hf_cor; fCdelete++;}
412 
413  if (fT2d_lfcc_mostins != 0){delete [] fT2d_lfcc_mostins; fCdelete++;}
414  if (fT2d1_lfcc_mostins != 0){delete [] fT2d1_lfcc_mostins ; fCdelete++;}
415 
416  if (fT2d_hfcc_mostins != 0){delete [] fT2d_hfcc_mostins ; fCdelete++;}
417  if (fT2d1_hfcc_mostins != 0){delete [] fT2d1_hfcc_mostins; fCdelete++;}
418 
419  if (fT1d_ev_ev != 0){delete [] fT1d_ev_ev; fCdelete++;}
420  if (fT1d_evsamp_of_sigevt != 0){delete [] fT1d_evsamp_of_sigevt; fCdelete++;}
421  if (fT1d_ev_cor_ss != 0){delete [] fT1d_ev_cor_ss; fCdelete++;}
422  if (fT1d_av_mped != 0){delete [] fT1d_av_mped; fCdelete++;}
423  if (fT1d_av_totn != 0){delete [] fT1d_av_totn; fCdelete++;}
424  if (fT1d_av_lofn != 0){delete [] fT1d_av_lofn; fCdelete++;}
425  if (fT1d_av_hifn != 0){delete [] fT1d_av_hifn; fCdelete++;}
426  if (fT1d_av_ev_corss != 0){delete [] fT1d_av_ev_corss; fCdelete++;}
427  if (fT1d_av_sig_corss != 0){delete [] fT1d_av_sig_corss; fCdelete++;}
428 
429  if (fT1d_sigevt_of_evsamp != 0){delete [] fT1d_sigevt_of_evsamp; fCdelete++;}
430  if (fT1d_evevt_of_sigsamp != 0){delete [] fT1d_evevt_of_sigsamp; fCdelete++;}
431  if (fT1d_sig_cor_ss != 0){delete [] fT1d_sig_cor_ss; fCdelete++;}
432 
433  if (fT2dCrysNumbersTable != 0){delete [] fT2dCrysNumbersTable; fCdelete++;}
434  if (fT1dCrysNumbersTable != 0){delete [] fT1dCrysNumbersTable; fCdelete++;}
435 
436  if (fTagStinNumbers != 0){delete [] fTagStinNumbers; fCdelete++;}
437  if (fTagNbOfEvts != 0){delete [] fTagNbOfEvts; fCdelete++;}
438  if (fTagAdcEvt != 0){delete [] fTagAdcEvt; fCdelete++;}
439  if (fTagMSp != 0){delete [] fTagMSp; fCdelete++;}
440  if (fTagSSp != 0){delete [] fTagSSp; fCdelete++;}
441 
442  if (fTagCovCss != 0){delete [] fTagCovCss; fCdelete++;}
443  if (fTagCorCss != 0){delete [] fTagCorCss; fCdelete++;}
444 
445  if (fTagHfCov != 0){delete [] fTagHfCov; fCdelete++;}
446  if (fTagHfCor != 0){delete [] fTagHfCor; fCdelete++;}
447  if (fTagLfCov != 0){delete [] fTagLfCov; fCdelete++;}
448  if (fTagLfCor != 0){delete [] fTagLfCor; fCdelete++;}
449 
450  if (fTagLFccMoStins != 0){delete [] fTagLFccMoStins; fCdelete++;}
451  if (fTagHFccMoStins != 0){delete [] fTagHFccMoStins; fCdelete++;}
452 
453  if (fTagPed != 0){delete [] fTagPed; fCdelete++;}
454  if (fTagTno != 0){delete [] fTagTno; fCdelete++;}
455  if (fTagMeanCorss != 0){delete [] fTagMeanCorss; fCdelete++;}
456 
457  if (fTagLfn != 0){delete [] fTagLfn; fCdelete++;}
458  if (fTagHfn != 0){delete [] fTagHfn; fCdelete++;}
459  if (fTagSigCorss != 0){delete [] fTagSigCorss; fCdelete++;}
460 
461  if (fTagAvPed != 0){delete [] fTagAvPed; fCdelete++;}
462  if (fTagAvTno != 0){delete [] fTagAvTno; fCdelete++;}
463  if (fTagAvLfn != 0){delete [] fTagAvLfn; fCdelete++;}
464  if (fTagAvHfn != 0){delete [] fTagAvHfn; fCdelete++;}
465  if (fTagAvMeanCorss != 0){delete [] fTagAvMeanCorss; fCdelete++;}
466  if (fTagAvSigCorss != 0){delete [] fTagAvSigCorss; fCdelete++;}
467 
468  if ( fCnew != fCdelete )
469  {
470  cout << "!TEcnaRun::~TEcnaRun()> WRONG MANAGEMENT OF MEMORY ALLOCATIONS: fCnew = "
471  << fCnew << ", fCdelete = " << fCdelete << fTTBELL << endl;
472  }
473  else
474  {
475  // cout << "*TEcnaRun::~TEcnaRun()> Management of memory allocations: OK. fCnew = "
476  // << fCnew << ", fCdelete = " << fCdelete << endl;
477  }
478 
480  {
481  cout << "*TEcnaRun::~TEcnaRun()> Exiting destructor (this = " << this << ")." << endl
482  << "~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#"
483  << endl;
484  }
485 
486  // cout << "[Info Management] CLASS: TEcnaRun. DESTROY OBJECT: this = " << this << endl;
487 }
488 
489 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
490 //
491 // M E T H O D S
492 //
493 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
494 
495 //============================================================================
496 //
497 // GetReadyToReadData(...)
498 //
499 // Preparation of the result file name + tags allocations
500 // + ADC event distribution array allocation + nb of events array allocation
501 //
502 //============================================================================
503 
504 void TEcnaRun::GetReadyToReadData(TString typ_ana, const Int_t& run_number,
505  const Int_t& nfirst, const Int_t& nlast, const Int_t& nbevts,
506  const Int_t& Stex)
507 {
508 //Preparation of the data reading. Set part of the header. No RunType as argument.
509 //Use default value = 99999999 and call method with all the arguments (see below)
510 
511  Int_t RunType = 99999999;
512  GetReadyToReadData(typ_ana, run_number, nfirst, nlast, nbevts, Stex, RunType);
513 }
514 //--------------------------------------------------------------------------------
515 void TEcnaRun::GetReadyToReadData( TString typ_ana, const Int_t& run_number,
516  const Int_t& nfirst, const Int_t& nlast, const Int_t& nbevts,
517  const Int_t& Stex, const Int_t& run_type)
518 {
519 //Preparation of the data reading. Set part of the header
520 //
521 // [nfirst, nlast] = [1,50] (50 events) or [151,300] (150 events) or etc...
522 
523  Int_t nrangeevts = nlast - nfirst + 1; // number of events in range
524 
525  if( nrangeevts < nbevts )
526  {
527  if( nlast >= nfirst )
528  {
529  cout << "*TEcnaRun::GetReadyToReadData(...)> --- WARNING ---> number of events = " << nbevts
530  << ", out of range (range = " << nfirst << "," << nlast << ")" << endl
531  << " The number of found events will be less " << endl
532  << " than the number of requested events." << endl;
533  }
534  if( nlast < nfirst )
535  {
536  cout << "*TEcnaRun::GetReadyToReadData(...)> --- INFO ---> last requested event number = " << nlast
537  << ", less than first requested event number (= " << nfirst << ")" << endl
538  << " File will be read until EOF if the number of found events" << endl
539  << " remains less than the number of requested events." << endl;
540  }
541 
542  }
543 
544  //............. allocation for counters
545  fMiscDiag = new Int_t[fNbOfMiscDiagCounters]; fCnew++;
546  for (Int_t iz=0; iz<fNbOfMiscDiagCounters; iz++){fMiscDiag[iz] = (Int_t)0;}
547 
548  //************** CHECK OF ARGUMENTS: nfirst_arg and nbevts_arg
549  Int_t nentries = 99999999; // => to be reintroduced as argument (like run_type) (?)
550  if ( nfirst <= nentries )
551  {
552  //--------------------- test positivity of nfirst_arg (GetReadyToReadData)
553  if ( nfirst > 0 )
554  {
555  //-------- test compatibility between the last requested event number
556  // and the number of entries
557  if( nlast <= nentries )
558  {
559  const Text_t *h_name = "CnaHeader"; //==> voir cette question avec FXG
560  const Text_t *h_title = "CnaHeader"; //==> voir cette question avec FXG
561  //fFileHeader->HeaderParameters(h_name, h_title ,
562  // typ_ana, fNbSampForFic,
563  // run_number, nfirst, nlast, nbevts,
564  // Stex, nentries); fCnew++;
565 
566  if ( fEcal->MaxStinEcnaInStex() > 0 && fEcal->MaxCrysInStin() > 0 && fNbSampForFic > 0 )
567  {
568  if( fFileHeader == 0 ){fFileHeader = new TEcnaHeader(fObjectManager, h_name, h_title);} // fCnew++;
569 
571  run_number, nfirst, nlast, nbevts,
572  Stex, run_type);
573 
574  // After this call to TEcnaHeader, we have: (GetReadyToReadData)
575  // fFileHeader->fTypAna = typ_ana
576  // fFileHeader->fNbOfSamples = fNbSampForFic
577  // fFileHeader->fRunNumber = run_number
578  // fFileHeader->fFirstReqEvtNumber = nfirst
579  // fFileHeader->fLastReqEvtNumber = nlast
580  // fFileHeader->fReqNbOfEvts = nbevts
581  // fFileHeader->fStex = Stex number
582  // fFileHeader->fRunType = run_type
583 
584  // fFileHeader->Print();
585 
586  // {Int_t cintoto; cout << "taper 0 pour continuer" << endl; cin >> cintoto;}
587 
588  // fFileHeader->SetName("CnaHeader"); *======> voir FXG
589  // fFileHeader->SetTitle("CnaHeader");
590 
591  //......................................... allocation tags + init of them (GetReadyToReadData)
592 
593  fTagStinNumbers = new Int_t[1]; fCnew++; fTagStinNumbers[0] = (Int_t)0;
594  fTagNbOfEvts = new Int_t[1]; fCnew++; fTagNbOfEvts[0] = (Int_t)0;
595 
596  fTagAdcEvt = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
597  for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagAdcEvt[iz] = (Int_t)0;}
598 
599  fTagMSp = new Int_t[1]; fCnew++; fTagMSp[0] = (Int_t)0;
600  fTagSSp = new Int_t[1]; fCnew++; fTagSSp[0] = (Int_t)0;
601 
602  fTagCovCss = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
603  for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagCovCss[iz] = (Int_t)0;}
604 
605  fTagCorCss = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
606  for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagCorCss[iz] = (Int_t)0;}
607 
608  fTagLfCov = new Int_t[1]; fCnew++; fTagLfCov[0] = (Int_t)0;
609  fTagLfCor = new Int_t[1]; fCnew++; fTagLfCor[0] = (Int_t)0;
610 
611  fTagHfCov = new Int_t[1]; fCnew++; fTagHfCov[0] = (Int_t)0;
612  fTagHfCor = new Int_t[1]; fCnew++; fTagHfCor[0] = (Int_t)0;
613 
614  fTagLFccMoStins = new Int_t[1]; fCnew++; fTagLFccMoStins[0] = (Int_t)0;
615  fTagHFccMoStins = new Int_t[1]; fCnew++; fTagHFccMoStins[0] = (Int_t)0;
616 
617  fTagPed = new Int_t[1]; fCnew++; fTagPed[0] = (Int_t)0;
618  fTagTno = new Int_t[1]; fCnew++; fTagTno[0] = (Int_t)0;
619  fTagMeanCorss = new Int_t[1]; fCnew++; fTagMeanCorss[0] = (Int_t)0;
620 
621  fTagLfn = new Int_t[1]; fCnew++; fTagLfn[0] = (Int_t)0;
622  fTagHfn = new Int_t[1]; fCnew++; fTagHfn[0] = (Int_t)0;
623  fTagSigCorss = new Int_t[1]; fCnew++; fTagSigCorss[0] = (Int_t)0;
624 
625  fTagAvPed = new Int_t[1]; fCnew++; fTagAvPed[0] = (Int_t)0;
626  fTagAvTno = new Int_t[1]; fCnew++; fTagAvTno[0] = (Int_t)0;
627  fTagAvLfn = new Int_t[1]; fCnew++; fTagAvLfn[0] = (Int_t)0;
628  fTagAvHfn = new Int_t[1]; fCnew++; fTagAvHfn[0] = (Int_t)0;
629  fTagAvMeanCorss = new Int_t[1]; fCnew++; fTagAvMeanCorss[0] = (Int_t)0;
630  fTagAvSigCorss = new Int_t[1]; fCnew++; fTagAvSigCorss[0] = (Int_t)0;
631 
632  //====================================================================================
633  //
634  // allocation for fT1d_StexStinFromIndex[] and init to fSpecialStexStinNotIndexed
635  //
636  //====================================================================================
637 
638  if(fT1d_StexStinFromIndex == 0)
639  {
641  }
642  for ( Int_t i0_Stin = 0; i0_Stin < fEcal->MaxStinEcnaInStex(); i0_Stin++ )
643  {
645  }
646 
647  //------------------------------------------------------------- (GetReadyToReadData)
648 
649  //====================================================================================
650  //
651  // allocation of the 3D array fT3d_AdcValues[channel][sample][events] (ADC values)
652  //
653  // This array is filled in the GetSampleAdcValues(...) method
654  //
655  //====================================================================================
656 
657  if(fT3d_AdcValues == 0)
658  {
659  //............ Allocation for the 3d array
660  cout << "*TEcnaRun::GetReadyToReadData(...)> Allocation of 3D array for ADC distributions."
661  << " Nb of requested evts = " << fFileHeader->fReqNbOfEvts << endl
662  << " This number must not be too large"
663  << " (no failure after this message means alloc OK)." << endl;
664 
665  fT3d_AdcValues = new Double_t**[fEcal->MaxCrysEcnaInStex()]; fCnew++;
666 
668  new Double_t*[fEcal->MaxCrysEcnaInStex()*
669  fNbSampForFic]; fCnew++;
670 
672  new Double_t[fEcal->MaxCrysEcnaInStex()*
675 
676  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++){
677  fT3d_AdcValues[i0StexEcha] = &fT3d2_AdcValues[0] + i0StexEcha*fNbSampForFic;
678  for(Int_t j0Sample=0; j0Sample<fNbSampForFic; j0Sample++){
679  fT3d2_AdcValues[fNbSampForFic*i0StexEcha + j0Sample] = &fT3d1_AdcValues[0]+
680  fFileHeader->fReqNbOfEvts*(fNbSampForFic*i0StexEcha+j0Sample);}}
681  }
682  //................................. Init to zero
683  for (Int_t iza=0; iza<fEcal->MaxCrysEcnaInStex(); iza++)
684  {
685  for (Int_t izb=0; izb<fNbSampForFic; izb++)
686  {
687  for (Int_t izc=0; izc<fFileHeader->fReqNbOfEvts; izc++)
688  {
689  if( fT3d_AdcValues[iza][izb][izc] != (Double_t)0 )
690  {
691  fMiscDiag[0]++;
692  fT3d_AdcValues[iza][izb][izc] = (Double_t)0;
693  }
694  }
695  }
696  }
697 
698  //--------------------------------------------------------- (GetReadyToReadData)
699  //====================================================================================
700  //
701  // allocation of the 2D array fT2d_NbOfEvts[channel][sample] (Max nb of evts)
702  //
703  //====================================================================================
704 
705  if (fT2d_NbOfEvts == 0)
706  {
707  fT2d_NbOfEvts = new Int_t*[fEcal->MaxCrysEcnaInStex()]; fCnew++;
708  fT1d_NbOfEvts = new Int_t[fEcal->MaxCrysEcnaInStex()*
709  fNbSampForFic]; fCnew++;
710 
711  for(Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
712  {
713  fT2d_NbOfEvts[i0StexEcha] =
714  &fT1d_NbOfEvts[0] + i0StexEcha*fNbSampForFic;
715  }
716 
717  //................ Init the array to 0
718  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
719  {
720  for(Int_t i0Sample=0; i0Sample<fNbSampForFic; i0Sample++)
721  {
722  fT2d_NbOfEvts[i0StexEcha][i0Sample] = 0;
723  }
724  }
725  }
726  else
727  {
728  cerr << "!TEcnaRun::GetReadyToReadData(...)> *** ERROR *** No allocation for fT2d_NbOfEvts!"
729  << " Pointer already not NULL " << fTTBELL << endl;
730  // {Int_t cintoto; cout << "Enter: 0 and RETURN to continue or: CTRL C to exit"
731  // << endl; cin >> cintoto;}
732  }
733  }
734  else
735  {
736  cerr << endl
737  << "!TEcnaRun::GetReadyToReadData(...)> "
738  << " *** ERROR *** " << endl
739  << " --------------------------------------------------"
740  << endl
741  << " NULL or NEGATIVE values for arguments" << endl
742  << " with expected positive values:" << endl
743  << " Number of Stins in Stex = " << fEcal->MaxStinEcnaInStex() << endl
744  << " Number of crystals in Stin = " << fEcal->MaxCrysInStin() << endl
745  << " Number of samples by channel = " << fNbSampForFic << endl
746  << endl
747  << endl
748  << " hence, no memory allocation for array member has been performed." << endl;
749 
750  cout << "Enter: 0 and RETURN to continue or: CTRL C to exit";
751  Int_t toto;
752  cin >> toto;
753  }
754  //----------------------------------------------------------- (GetReadyToReadData)
756  cout << endl;
757  cout << "*TEcnaRun::GetReadyToReadData(...)>" << endl
758  << " The method has been called with the following argument values:" << endl
759  << " Analysis name = "
760  << fFileHeader->fTypAna << endl
761  << " Run number = "
762  << fFileHeader->fRunNumber << endl
763  << " Run type = "
764  << fFileHeader->fRunType << endl
765  << " First requested event number = "
766  << fFileHeader->fFirstReqEvtNumber << endl
767  << " Last requested event number = "
768  << fFileHeader->fLastReqEvtNumber << endl
769  << " " << fStexName.Data() << " number = "
770  << fFileHeader->fStex << endl
771  << " Number of " << fStinName.Data()
772  << " in " << fStexName.Data() << " = "
773  << fEcal->MaxStinEcnaInStex() << endl
774  << " Number of crystals in " << fStinName.Data() << " = "
775  << fEcal->MaxCrysInStin() << endl
776  << " Number of samples by channel = "
777  << fNbSampForFic << endl
778  << endl;}
779 
780  fReadyToReadData = 1; // set flag
781  }
782  else
783  {
785  cout << "!TEcnaRun::GetReadyToReadData(...) > WARNING/CORRECTION:" << endl
786  << "! The fisrt requested event number is not positive (nfirst = " << nfirst << ") "
787  << fTTBELL << endl;}
788  }
789  }
790  else
791  {
793  cout << endl << "!TEcnaRun::GetReadyToReadData(...)> WARNING/CORRECTION:" << endl
794  << "! The number of requested events (nbevts = " << nbevts << ") is too large." << endl
795  << "! Last event number = " << nlast << " > number of entries = " << nentries << ". "
796  << fTTBELL << endl << endl;}
797  }
798  }
799  else
800  {
801  cout << "!TEcnaRun::GetReadyToReadData(...) *** ERROR ***> "
802  << " The first requested event number is greater than the number of entries."
803  << fTTBELL << endl;
804  }
806  cout << "*TEcnaRun::GetReadyToReadData(...)> Leaving the method. fReadyToReadData = "
807  << fReadyToReadData << endl; }
808 
809 } // end of GetReadyToReadData
810 
811 //====================================================================================================
812 //
813 // GetSampleAdcValues: method called by the CMSSW analyzer (cmsRun)
814 //
815 // At each event, put the Sample ADC value in the 3D array: fT3d_AdcValues[i0StexEcha][i0Sample][i0EventIndex]
816 //
817 // |============================================================|
818 // | |
819 // | (Stex,Stin) means: (SM,tower) for EB and: (Dee,SC) for EE |
820 // | |
821 // |============================================================|
822 //
823 // (Stin number <-> Stin index correspondance, ADC sample values)
824 //
825 // THIS METHOD IS CALLED INSIDE THE LOOPS OVER:
826 // ( EVENTS (tower or SC (CRYSTAL in tower or SC (SAMPLES))))
827 //
828 // Arguments: Event = event number. Range = [ 1, fFileHeader->fReqNbOfEvts ]
829 // n1StexStin = Stin number in Stex. Range = [ 1, fEcal->MaxStinEcnaInStex() ]
830 // i0StinEcha = channel number in Stin. Range = [ 0, fEcal->MaxCrysInStin() - 1 ]
831 // sample = ADC sample number. Range = [ 0, fNbSampForFic - 1 ]
832 // adcvalue = ADC sample value.
833 //
834 //====================================================================================================
835 Bool_t TEcnaRun::GetSampleAdcValues(const Int_t& n1EventNumber, const Int_t& n1StexStin,
836  const Int_t& i0StinEcha, const Int_t& i0Sample,
837  const Double_t& adcvalue)
838 {
839  //Building of the arrays fT1d_StexStinFromIndex[] and fT3d_AdcValues[][][]
840 
841  fBuildEvtNotSkipped++; // event not skipped by cmsRun
842 
843  Bool_t ret_code = kFALSE;
844 
845  Int_t i0EventIndex = n1EventNumber - 1; // INDEX FOR Event number
846  Int_t i0StexStinEcna = n1StexStin - 1; // INDEX FOR StexStin = Number_of_the_Stin_in_Stex - 1
847 
848  Int_t i_trouve = 0;
849  //.................................................................. (GetSampleAdcValues)
850  if(fReadyToReadData == 1)
851  {
852  if( n1StexStin>= 1 && n1StexStin <= fEcal->MaxStinEcnaInStex() )
853  {
854  if( i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin() )
855  {
856  if( i0Sample >= 0 && i0Sample < fEcal->MaxSampADC() )
857  {
858  //..... Put the StexStin number in 1D array fT1d_StexStinFromIndex[] = Stin index + 1
859  if( fT1d_StexStinFromIndex != 0 ) // table fT1d_StexStinFromIndex[index] already allocated
860  {
861  ret_code = kTRUE;
862 
863  // StexStin already indexed
864  if( n1StexStin == fT1d_StexStinFromIndex[i0StexStinEcna] ){i_trouve = 1;}
865 
866  // StexStin index not found: set index for new StexStin
867  if (i_trouve != 1 )
868  {
869  if( fT1d_StexStinFromIndex[i0StexStinEcna] == fSpecialStexStinNotIndexed )
870  {
871  fT1d_StexStinFromIndex[i0StexStinEcna] = n1StexStin;
873  fTagStinNumbers[0] = 1;
874  fStinIndexBuilt++; // number of found Stins
875 
877  {
878  if( fStinIndexBuilt == 1 )
879  {
880  cout << endl << "*TEcnaRun::GetSampleAdcValues(...)> event " << n1EventNumber
881  << " : first event for " << fStexName.Data() << " " << fFileHeader->fStex
882  << "; " << fStinName.Data() << "s : ";
883  }
884  if( fFlagSubDet == "EB" )
885  {cout << fT1d_StexStinFromIndex[i0StexStinEcna] << ", ";}
886  if( fFlagSubDet == "EE" )
887  {cout << fEcalNumbering->
888  GetDeeSCConsFrom1DeeSCEcna(fFileHeader->fStex, fT1d_StexStinFromIndex[i0StexStinEcna])
889  << ", ";}
890  }
891  //.................................................... (GetSampleAdcValues)
893  {
894  cout << " (" << fStinIndexBuilt << " " << fStinName.Data()
895  << " found), channel " << i0StinEcha << ", i0Sample " << i0Sample << endl;
896  }
897  ret_code = kTRUE;
898  } // if ( fT1d_StexStinFromIndex[i0StexStinEcna] == fSpecialStexStinNotIndexed )
899  else
900  {
901  cout << "!TEcnaRun::GetSampleAdcValues(...)> *** ERROR ***> NOT ALLOWED if RESULT. "
902  << " n1StexStin = " << n1StexStin << ", fT1d_StexStinFromIndex["
903  << i0StexStinEcna << "] = "
904  << fT1d_StexStinFromIndex[i0StexStinEcna]
905  << ", fStinIndexBuilt = " << fStinIndexBuilt
906  << fTTBELL << endl;
907  ret_code = kFALSE;
908  }
909  } // if (i_trouve != 1 )
910 
911  } // if( fT1d_StexStinFromIndex != 0 )
912  else
913  {
914  cout << "!TEcnaRun, GetSampleAdcValues *** ERROR ***> "
915  << " fT1d_StexStinFromIndex = " << fT1d_StexStinFromIndex
916  << " fT1d_StexStinFromIndex[] ALLOCATION NOT DONE" << fTTBELL << endl;
917  ret_code = kFALSE;
918  } //.................................................................. (GetSampleAdcValues)
919  } // end of if( i0Sample >= 0 && i0Sample < fNbSampForFic )
920  else
921  {
922  //.......Reading data => Message and error only if sample >= fEcal->MaxSampADC()
923  // (not fNbSampForFic, the later is used only for calculations)
924  if( i0Sample >= fEcal->MaxSampADC() )
925  {
926  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
927  << " sample number = " << i0Sample << ". OUT OF BOUNDS"
928  << " (max = " << fNbSampForFic << ")"
929  << fTTBELL << endl;
930  ret_code = kFALSE;
931  }
932  else
933  {
934  ret_code = kTRUE;
935  }
936  }// else of if( i0Sample >= 0 && i0Sample < fNbSampForFic )
937  } // end of if( i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin() )
938  else
939  {
940  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
941  << " channel number in " << fStinName.Data() << " = " << i0StinEcha << ". OUT OF BOUNDS"
942  << " (max = " << fEcal->MaxCrysInStin() << ")"
943  << fTTBELL << endl;
944  ret_code = kFALSE;
945  } // else of if( i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin() )
946  }
947  else
948  {
949  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
950  << fStinName.Data() << " number in " << fStexName.Data() << " = " << n1StexStin << ". OUT OF BOUNDS"
951  << " (max = " << fEcal->MaxStinEcnaInStex() << ")"
952  << fTTBELL << endl;
953  ret_code = kFALSE;
954  }
955 
956  //.................................................................. (GetSampleAdcValues)
957  //........ Filling of the 2D array of the event numbers in the data reading loop and
958  // filling of the 3D array of the ADC sample values
959  //
960  // ONLY if ret_code == kTRUE
961 
962  if( ret_code == kTRUE )
963  {
964  //............ 1) Conversion (Stin,i0StinEcha) -> i0StexEcha (same numbering for EB and EE)
965  //==========================================================================================
966  // n1StexStin (Tower or SC): 1 2 3
967  // iStexStin 0 1 2
968  //
969  // i0StinEcha: 0......24 0......24 0......24
970  //
971  // i0StexEcha : 0......24 25......49 50......74 grouped by StexStin's
972  // i0StexEcha+1 (Xtal): 1......25 26......50 51......75
973  //
974  //==========================================================================================
975 
976  Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinEcha;
977 
978  //--------------------------------------------------------- (GetSampleAdcValues)
979  if( i0StexEcha >= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex() )
980  {
981  //............ 2) Increase of the nb of evts for (StexEcha,sample) (events found in the data)
982  (fT2d_NbOfEvts[i0StexEcha][i0Sample])++; // value after first incrementation = 1
983  fTagNbOfEvts[0] = 1;
985 
986  //............ 3) Filling of the 3D array of the ADC values
987  if ( i0EventIndex >= 0 && i0EventIndex < fFileHeader->fReqNbOfEvts )
988  {
989  if( i0Sample >= 0 && i0Sample < fNbSampForFic )
990  {
991  fT3d_AdcValues[i0StexEcha][i0Sample][i0EventIndex] = adcvalue;
992  }
993  else
994  {
995  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
996  << " sample index = " << i0Sample << ". OUT OF BOUNDS"
997  << " (max = " << fNbSampForFic << ")"
998  << fTTBELL << endl;
999  }
1000  }
1001  else
1002  {
1003  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
1004  << " event number = " << n1EventNumber << ". OUT OF BOUNDS"
1005  << " (max = " << fFileHeader->fReqNbOfEvts << ")"
1006  << fTTBELL << endl;
1007  ret_code = kFALSE;
1008  }
1009  }
1010  else
1011  {
1012  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> "
1013  << " CHANNEL NUMBER OUT OF BOUNDS" << endl
1014  << " i0StexEcha number = " << i0StexEcha
1015  << " , n1StexStin = " << n1StexStin
1016  << " , i0StinEcha = " << i0StinEcha
1017  << " , fEcal->MaxCrysEcnaInStex() = " << fEcal->MaxCrysEcnaInStex()
1018  << fTTBELL << endl;
1019  ret_code = kFALSE;
1020  // {Int_t cintoto; cout << "TAPER 0 POUR CONTINUER" << endl; cin >> cintoto;}
1021  }
1022  } // end of if( ret_code == kTRUE )
1023  else
1024  {
1025  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> ret_code = kFALSE "
1026  << fTTBELL << endl;
1027  }
1028  } // end of if(fReadyToReadData == 1)
1029  else
1030  {
1031  cout << "!TEcnaRun::GetSampleAdcValues(...) *** ERROR ***> GetReadyToReadData(...) not called."
1032  << fTTBELL << endl;
1033  ret_code = kFALSE;
1034  }
1035  //.................................................................. (GetSampleAdcValues)
1036  if (ret_code == kFALSE)
1037  {
1038  cout << "!TEcnaRun::GetSampleAdcValues(...)> *** ERROR ***> ret_code = " << ret_code
1039  << " (FALSE). Event: " << n1EventNumber
1040  << ", " << fStexName.Data() << ": " << fFileHeader->fStex
1041  << ", " << fStinName.Data() << ": " << n1StexStin
1042  << ", channel: " << i0StinEcha
1043  << ", Sample: " << i0Sample
1044  << ", ADC value: " << adcvalue << endl;
1045  }
1046  return ret_code;
1047 }
1048 //------------- ( end of GetSampleAdcValues ) -----------------------
1049 //====================================================================================================
1050 //
1051 // ReadSampleAdcValues: Get the Sample ADC values from file by using TEcnaRead.
1052 //
1053 //====================================================================================================
1055 
1056 Bool_t TEcnaRun::ReadSampleAdcValues(const Int_t& nb_samp_for_calc)
1057 {
1058  // read the Sample ADC values from "ADC" result root files (ReadSampleAdcValues)
1059 
1060  // put the number of sample for calculations in attribute fNbSampForCalc
1061  // and call the method without arguments
1062  // We must have: nb_samp_for_calc <= fFileHeader->fNbOfSamples (= nb of samples in ROOT file)
1063 
1064  fNbSampForCalc = nb_samp_for_calc;
1065 
1066 // TEcnaRead* MyRootFile = new TEcnaRead(fFlagSubDet.Data(), fCnaParPaths, fCnaParCout,
1067 // fFileHeader, fEcalNumbering, fCnaWrite); // fCnew++;
1068 
1069  TEcnaRead* MyRootFile = new TEcnaRead(fObjectManager, fFlagSubDet.Data()); // fCnew++;
1070 
1071  MyRootFile->PrintNoComment();
1072 
1076  fCnaParPaths->ResultsRootFilePath().Data());
1077 
1078  Bool_t ok_read = MyRootFile->LookAtRootFile();
1079 
1080  fFileHeader->fStartTime = MyRootFile->GetStartTime();
1081  fFileHeader->fStopTime = MyRootFile->GetStopTime();
1082  fFileHeader->fStartDate = MyRootFile->GetStartDate();
1083  fFileHeader->fStopDate = MyRootFile->GetStopDate();
1084 
1085  if ( ok_read == kTRUE )
1086  {
1087  fRootFileName = MyRootFile->GetRootFileName();
1088  fRootFileNameShort = MyRootFile->GetRootFileNameShort();
1089  cout << "*TEcnaRun::ReadSampleAdcValues> Reading sample ADC values from file: " << endl
1090  << " " << fRootFileName << endl;
1091 
1092  size_t i_no_data = 0;
1093 
1094  //.......... Read the StinNumbers in the old file (ReadSampleAdcValues)
1095  TVectorD vec(fEcal->MaxStinEcnaInStex());
1096  for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
1097  vec = MyRootFile->ReadStinNumbers(fEcal->MaxStinEcnaInStex());
1098  if( MyRootFile->DataExist() == kTRUE )
1099  {
1100  fTagStinNumbers[0] = 1;
1102  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
1103  {fT1d_StexStinFromIndex[i0StexStinEcna] = (Int_t)vec(i0StexStinEcna);}
1104  }
1105  else
1106  {
1107  i_no_data++;
1108  }
1109  //.......... Read the Numbers of Events in the old file (ReadSampleAdcValues)
1110  TMatrixD partial_matrix(fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
1111  for(Int_t i=0; i<fEcal->MaxCrysInStin(); i++)
1112  {for(Int_t j=0; j<fFileHeader->fNbOfSamples; j++){partial_matrix(i,j)=(Double_t)0.;}}
1113 
1114  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
1115  {
1116  Int_t n1StexStin = MyRootFile->GetStexStinFromIndex(i0StexStinEcna);
1117  if(n1StexStin != -1)
1118  {
1119  partial_matrix =
1120  MyRootFile->ReadNumberOfEventsForSamples
1121  (n1StexStin, fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
1122 
1123  if( MyRootFile->DataExist() == kTRUE )
1124  {
1125  fTagNbOfEvts[0] = 1;
1127  for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
1128  {
1129  Int_t i0StexEcha = (n1StexStin-1)*fEcal->MaxCrysInStin() + i0StinCrys;
1130  for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples; i0Sample++)
1131  {fT2d_NbOfEvts[i0StexEcha][i0Sample] = (Int_t)partial_matrix(i0StinCrys,i0Sample);}
1132  }
1133  }
1134  else
1135  {
1136  i_no_data++;
1137  }
1138  }
1139  }
1140 
1141  //.......... Read the Sample ADC values in the old file (ReadSampleAdcValues)
1142  Double_t*** fT3d_read_AdcValues =
1143  MyRootFile->ReadSampleAdcValuesSameFile
1145 
1146  if( MyRootFile->DataExist() == kTRUE )
1147  {
1148  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1149  {
1150  for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples;i0Sample++)
1151  {
1152  for(Int_t i_event=0; i_event<fFileHeader->fReqNbOfEvts; i_event++)
1153  {fT3d_AdcValues[i0StexEcha][i0Sample][i_event] =
1154  fT3d_read_AdcValues[i0StexEcha][i0Sample][i_event];}
1155  }
1156  }
1157  }
1158  else
1159  {
1160  i_no_data++;
1161  }
1162  if(i_no_data)
1163  {
1164  cout << "!TEcnaRun::ReadSampleAdcValues(...)> *ERROR* =====> "
1165  << " Read failure. i_no_data = " << i_no_data << fTTBELL << endl;
1166  }
1167  }
1168  else
1169  {
1170  cout << "!TEcnaRun::ReadSampleAdcValues(...)> *ERROR* =====> "
1171  << " ROOT file not found" << fTTBELL << endl;
1172  }
1173  delete MyRootFile; // fCdelete++;
1174  return ok_read;
1175 }
1176 //------------- ( end of ReadSampleAdcValues ) -----------------------
1177 //-------------------------------------------------------------------------
1178 //
1179 // Get the ROOT file name (long and short)
1180 //
1181 //-------------------------------------------------------------------------
1184 
1185 //###################################################################################################
1186 //
1187 // THE FOLLOWING METHODS ARE CALLED AFTER THE LOOPS OVER EVENTS, STINS, CRYSTALS AND SAMPLES
1188 //
1189 //###################################################################################################
1190 //=========================================================================
1191 //
1192 // Set start time, stop time, StartDate, StopDate
1193 //
1194 //=========================================================================
1195 void TEcnaRun::StartStopTime(time_t t_startime, time_t t_stoptime)
1196 {
1197 // Put the start an stop time (if they exist) in fFileHeader class attributes.
1198 
1199  fFileHeader->fStartTime = t_startime;
1200  fFileHeader->fStopTime = t_stoptime;
1201 }
1202 
1203 void TEcnaRun::StartStopDate(TString c_startdate, TString c_stopdate)
1204 {
1205 // Put the start an stop date (if they exist) in fFileHeader class attributes.
1206 
1207  fFileHeader->fStartDate = c_startdate;
1208  fFileHeader->fStopDate = c_stopdate;
1209 }
1210 
1211 //=========================================================================
1212 //
1213 // GetReadyToCompute() (technical)
1214 //
1215 //=========================================================================
1217 {
1218 //
1219  // MAKE THE RESULTS FILE NAME and
1220  // CHECK OF THE NUMBER OF FOUND EVENTS AND init fNumberOfEvents
1221  // (number used to compute the average values over the events)
1222  // The number of events fNumberOfEvents is extracted from the array fT2d_NbOfEvts[]
1223  // which has been filled by the GetSampleAdcValues(...) method
1224 
1225  //..................... Making of the Root File name that will be written
1230 
1231  fCnaWrite->fMakeResultsFileName(); // set fRootFileName, fRootFileNameShort
1232 
1233  //..................... Checking numbers of found events channel by channel
1234  if( fT2d_NbOfEvts != 0 )
1235  {
1238  }
1239  else
1240  {
1241  cout << "*TEcnaRun::GetReadyToCompute()> no data? fT2d_NbOfEvts = " << fT2d_NbOfEvts << endl;
1242  }
1243 }
1244 // end of GetReadyToCompute()
1245 
1246 //-------------------------------------------------------------------
1247 //
1248 // SampleValues() (technical)
1249 //
1250 // Written in .root file corresponding to analysis name
1251 // beginning with: "Adc" (see EcnaAnalyzer.cc in package "Modules")
1252 //
1253 //-------------------------------------------------------------------
1255 {
1256 //3D histo of the sample ADC values for all the triples (StexEcha, sample, event)
1257 
1258  // The histo is already in fT3d_AdcValues[][][]
1259  // this method sets the "Tag", increment the "f...Calc" (and must be kept for that)
1260  // f...Calc > 0 => allow writing on file.
1261 
1263  for( Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1264  {fTagAdcEvt[i0StexEcha] = 1; fFileHeader->fAdcEvtCalc++;}
1265 }
1266 
1267 //=========================================================================
1268 //
1269 // C A L C U L A T I O N M E T H O D S
1270 //
1271 // fTag... = 1 => Calculation done. OK for writing on result file
1272 // ...Calc++ => Incrementation for result file size.
1273 //
1274 //=========================================================================
1276 {
1277  SampleMeans();
1278  SampleSigmas();
1280 
1281  Pedestals(); // => mean over Xtal's
1282  TotalNoise();
1287 
1288  AveragePedestals(); // Average => mean over Stin's (Tower if EB, SC if EE)
1294 }
1295 
1297 {
1298  // long time, big file
1299 
1302 }
1303 
1305 {
1306  // long time, no big file
1307  // expert 1 is called (if not called before) without writing in file.
1308  // Results are used only in memory to compute expert2 calculations
1309 
1312 }
1313 //====================================================================
1314 //
1315 // E X P E C T A T I O N V A L U E S , V A R I A N C E S
1316 //
1317 //====================================================================
1318 //----------------------------------------------------------------
1319 // Calculation of the expectation values of the samples
1320 // for all the StexEchas
1321 //
1322 // SMean(c,s) = E_e[A(c,s,e*)]
1323 // A(c,s,e) : ADC value for channel c, sample s, event e
1324 // E_e : average over the events
1325 //----------------------------------------------------------------
1327 {
1328 // Calculation of the expectation values over events
1329 // for the samples 0 to fNbSampForCalc and for all the StexEchas
1330 
1331  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SampleMeans() " << endl;}
1333  cout << " Calculation: sample expectation values over the events"
1334  << " for each channel." << endl;}
1335 
1336  //................... Allocation fT2d_ev
1337  if ( fT2d_ev == 0 ){
1338  Int_t n_samp = fNbSampForCalc;
1339  Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1340  fT2d_ev = new Double_t*[n_StexEcha]; fCnew++;
1341  fT1d_ev = new Double_t[n_StexEcha*n_samp]; fCnew++;
1342  for(Int_t i = 0 ; i < n_StexEcha ; i++){
1343  fT2d_ev[i] = &fT1d_ev[0] + i*n_samp;}
1344  }
1345  //................... init fT2d_ev to zero
1346  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1347  {
1348  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
1349  {
1350  if( fT2d_ev[i0StexEcha][i0Sample] != (Double_t)0 )
1351  {fMiscDiag[1]++; fT2d_ev[i0StexEcha][i0Sample] = (Double_t)0;}
1352  }
1353  }
1354 
1355  //................... Calculation
1356  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
1357  {
1358  for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
1359  {
1360  for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
1361  {
1362  fT2d_ev[i0StexEcha][i0Sample] += fT3d_AdcValues[i0StexEcha][i0Sample][i_event];
1363  }
1364  fT2d_ev[i0StexEcha][i0Sample] /= fNumberOfEvents;
1365  }
1366  }
1367  fTagMSp[0] = 1; fFileHeader->fMSpCalc++;
1368 }
1369 
1370 //--------------------------------------------------------
1371 // Calculation of the sigmas of the samples
1372 // for all the StexEchas
1373 //
1374 // SSigma(c,s) = sqrt{ Cov_e[A(c,s,e*),A(c,s,e*)] }
1375 // A(c,s,e) : ADC value for channel c, sample s, event e
1376 // Cov_e : covariance over the events
1377 //--------------------------------------------------------
1379 {
1380 //Calculation of the sigmas of the samples for all the StexEchas
1381 
1382  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SampleSigmas()" << endl;}
1384  cout << " Calculation: sample ADC sigmas over the events "
1385  << " for each channel." << endl;}
1386 
1387  //... preliminary calculation of the expectation values if not done yet.
1388  // The tag is set to 1 after call to the method. It is reset to 0
1389  // because the expectation values must not be written in the result ROOT file
1390  // (since the tag was equal to 0)
1391  if(fTagMSp[0] != 1){SampleMeans(); fTagMSp[0] = 0;}
1392 
1393  //................... Allocation fT2d_sig
1394  if( fT2d_sig == 0){
1395  Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1396  Int_t n_samp = fNbSampForCalc;
1397  fT2d_sig = new Double_t*[n_StexEcha]; fCnew++;
1398  fT1d_sig = new Double_t[n_StexEcha*n_samp]; fCnew++;
1399  for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
1400  fT2d_sig[i0StexEcha] = &fT1d_sig[0] + i0StexEcha*n_samp;}
1401  }
1402  // ................... init fT2d_sig to zero
1403  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1404  {
1405  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
1406  {
1407  if( fT2d_sig[i0StexEcha][i0Sample] != (Double_t)0 )
1408  {fMiscDiag[2]++; fT2d_sig[i0StexEcha][i0Sample] = (Double_t)0;}
1409  }
1410  }
1411 
1412  //................... Calculation
1413  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
1414  {
1415  for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
1416  {
1417  Double_t variance = (Double_t)0.;
1418  for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
1419  {
1420  Double_t ecart = fT3d_AdcValues[i0StexEcha][i0Sample][i_event] - fT2d_ev[i0StexEcha][i0Sample];
1421  variance += ecart*ecart;
1422  }
1423  variance /= fNumberOfEvents;
1424  fT2d_sig[i0StexEcha][i0Sample] = sqrt(variance);
1425  }
1426  }
1427  fTagSSp[0] = 1; fFileHeader->fSSpCalc++;
1428 }
1429 
1430 //====================================================================
1431 //
1432 // C O V A R I A N C E S & C O R R E L A T I O N S
1433 //
1434 // B E T W E E N S A M P L E S
1435 //
1436 //====================================================================
1437 //-----------------------------------------------------------
1438 // Calculation of the covariances between samples
1439 // for all the StexEchas
1440 // Cov(c;s,s') = Cov_e[ A(c,s,e*) , A(c,s',e*) ]
1441 // = E_e[ ( A(c,s,e*) - E_e[A(c,s,e*)] )*
1442 // ( A(c,s',e*) - E_e[A(c,s',e*)] ) ]
1443 // A(c,s,e) : ADC value for channel c, sample s, event e
1444 // E_e , Cov_e : average, covariance over the events
1445 //-----------------------------------------------------------
1447 {
1448  //Calculation of the covariances between samples for all the StexEchas
1449 
1450  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::CovariancesBetweenSamples()" << endl;}
1452  cout << " Calculation: covariances between samples"
1453  << " for each channel." << endl;}
1454 
1455  //................... Allocations cov_ss
1456  if( fT3d_cov_ss == 0 ){
1457  const Int_t n_samp = fNbSampForCalc;
1458  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1459  fT3d_cov_ss = new Double_t**[n_StexEcha]; fCnew++;
1460  fT3d2_cov_ss = new Double_t*[n_StexEcha*n_samp]; fCnew++;
1461  fT3d1_cov_ss = new Double_t[n_StexEcha*n_samp*n_samp]; fCnew++;
1462  for(Int_t i = 0 ; i < n_StexEcha ; i++){
1463  fT3d_cov_ss[i] = &fT3d2_cov_ss[0] + i*n_samp;
1464  for(Int_t j = 0 ; j < n_samp ; j++){
1465  fT3d2_cov_ss[n_samp*i+j] = &fT3d1_cov_ss[0]+n_samp*(n_samp*i+j);}}
1466  }
1467 
1468  //.................. Calculation (= init)
1469  //.................. computation of half of the matrix, diagonal included)
1470 
1471  //... preliminary calculation of the expectation values if not done yet.
1472  // The tag is set to 1 after call to the method. It is reset to 0
1473  // because the expectation values must not be written in the result ROOT file
1474  // (since the tag was equal to 0)
1475  // Results in array fT2d_ev[j0StexEcha][i0Sample]
1476  if(fTagMSp[0] != 1){SampleMeans(); fTagMSp[0] = 0;}
1477 
1478 
1479  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
1480  {
1481  for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
1482  {
1483  for (Int_t j0Sample = 0 ; j0Sample <= i0Sample; j0Sample++)
1484  {
1485  fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] = (Double_t)0;
1486  for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
1487  {
1488  fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] +=
1489  (fT3d_AdcValues[j0StexEcha][i0Sample][i_event] - fT2d_ev[j0StexEcha][i0Sample])
1490  *(fT3d_AdcValues[j0StexEcha][j0Sample][i_event] - fT2d_ev[j0StexEcha][j0Sample]);
1491  }
1492  fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] /= (Double_t)fNumberOfEvents;
1493  fT3d_cov_ss[j0StexEcha][j0Sample][i0Sample] = fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample];
1494  }
1495  }
1496  fTagCovCss[j0StexEcha] = 1; fFileHeader->fCovCssCalc++;
1497  }
1498 }
1499 
1500 //-----------------------------------------------------------
1501 //
1502 // Calculation of the correlations between samples
1503 // for all the StexEchas
1504 // Cor(c;s,s') = Cov(c;s,s')/sqrt{ Cov(c;s,s)*Cov(c;s',s') }
1505 //-----------------------------------------------------------
1507 {
1508 //Calculation of the correlations between samples for all the StexEchas
1509 
1510  //... preliminary calculation of the covariances if not done yet.
1511  // Test only the first tag since the cov are computed globaly
1512  // but set all the tags to 0 because we don't want to write
1513  // the covariances in the result ROOT file
1514  if ( fTagCovCss[0] != 1 ){CovariancesBetweenSamples();
1515  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
1516  {fTagCovCss[j0StexEcha] = 0;}}
1517 
1518  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::CorrelationsBetweenSamples()" << endl;}
1520  cout << " Calculation: correlations between samples"
1521  << " for each channel." << endl;}
1522 
1523  //................... Allocations cor_ss
1524  if( fT3d_cor_ss == 0){
1525  const Int_t n_samp = fNbSampForCalc;
1526  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1527  fT3d_cor_ss = new Double_t**[n_StexEcha]; fCnew++;
1528  fT3d2_cor_ss = new Double_t*[n_StexEcha*n_samp]; fCnew++;
1529  fT3d1_cor_ss = new Double_t[n_StexEcha*n_samp*n_samp]; fCnew++;
1530  for(Int_t i = 0 ; i < n_StexEcha ; i++){
1531  fT3d_cor_ss[i] = &fT3d2_cor_ss[0] + i*n_samp;
1532  for(Int_t j = 0 ; j < n_samp ; j++){
1533  fT3d2_cor_ss[n_samp*i+j] = &fT3d1_cor_ss[0]+n_samp*(n_samp*i+j);}}
1534  }
1535 
1536  //..................... calculation of the correlations (=init)
1537  //......................computation of half of the matrix, diagonal included (verif = 1)
1538 
1539  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
1540  {
1541  for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
1542  {
1543  for (Int_t j0Sample = 0 ; j0Sample <= i0Sample ; j0Sample++)
1544  {
1545  if( (fT3d_cov_ss[j0StexEcha][i0Sample][i0Sample] > 0) &&
1546  (fT3d_cov_ss[j0StexEcha][j0Sample][j0Sample] > 0) )
1547  {
1548  fT3d_cor_ss[j0StexEcha][i0Sample][j0Sample] = fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample]/
1549  ( sqrt(fT3d_cov_ss[j0StexEcha][i0Sample][i0Sample])*sqrt(fT3d_cov_ss[j0StexEcha][j0Sample][j0Sample]) );
1550  }
1551  else
1552  {
1553  (fT3d_cor_ss)[j0StexEcha][i0Sample][j0Sample] = (Double_t)0; // prevoir compteur + fTTBELL
1554  }
1555  fT3d_cor_ss[j0StexEcha][j0Sample][i0Sample] = fT3d_cor_ss[j0StexEcha][i0Sample][j0Sample];
1556  }
1557  }
1558  fTagCorCss[j0StexEcha] = 1; fFileHeader->fCorCssCalc++;
1559  }
1560 }
1561 
1562 //===========================================================================
1563 //
1564 // M E A N P E D E S T A L S , T O T A L N O I S E ,
1565 // L O W F R E Q U E N C Y N O I S E ,
1566 // H I G H F R E Q U E N C Y N O I S E
1567 // M E A N O F C O R ( S , S ), S I G M A O F C O R ( S , S )
1568 //
1569 //===========================================================================
1570 //-------------------------------------------------------------------------
1571 //
1572 // Calculation of the Pedestals for each channel in Stex
1573 // tag: Ped
1574 // Pedestal(c ) = E_e[ E_s[A(c ,s*,e*)] ]
1575 // A(c,s,e) : ADC value for channel c, sample s, event e
1576 // E_e : average over the events
1577 // E_s : average over the samples
1578 //
1579 //-------------------------------------------------------------------------
1581 {
1582 // Calculation, for each channel, of the expectation values
1583 // (over the samples 0 to fNbSampForCalc-1) of the ADC expectation values
1584 // (over the events)
1585 
1586  //... preliminary calculation of the expectation values if not done yet
1587  if ( fTagMSp[0] != 1 ){SampleMeans(); fTagMSp[0]=0;}
1588 
1589  //................... Allocation ev_ev + init to zero (mandatory)
1590  if( fT1d_ev_ev == 0 ){fT1d_ev_ev = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;}
1591  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1592  {if( fT1d_ev_ev[i0StexEcha] != (Double_t)0 )
1593  {fMiscDiag[11]++; fT1d_ev_ev[i0StexEcha] = (Double_t)0;}}
1594 
1595  //..................... Calculation
1596  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::Pedestals()" << endl;}
1598  cout << " Calculation, for all the channels, of the expectation values (over the samples 1 to "
1599  << fNbSampForCalc << ")" << endl
1600  << " of the ADC expectation values (over the events)." << endl;}
1601 
1602  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1603  {
1604  for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
1605  {
1606  fT1d_ev_ev[i0StexEcha] += fT2d_ev[i0StexEcha][i0Sample];
1607  }
1608  fT1d_ev_ev[i0StexEcha] /= fNbSampForCalc;
1609  }
1610  fTagPed[0] = 1; fFileHeader->fPedCalc++;
1611 }
1612 //------------------------ (end of Pedestals) ----------------------------
1613 
1614 //------------------------------------------------------------------------------
1615 //
1616 // Calculation of the TN (Total Noise)
1617 // tag: Tno
1618 //
1619 // TotalNoise(c) = E_s[ sqrt{ E_e[ ( A(c ,s*,e*) - E_e[A(c ,s*,e*)] )^2 ] } ]
1620 // A(c,s,e) : ADC value for channel c, sample s, event e
1621 // E_e : average over the events
1622 // E_s : average over the samples
1623 //
1624 //------------------------------------------------------------------------------
1626 {
1627 // Calculation, for each channel, of the expectation values
1628 // (over the samples 0 to fNbSampForCalc-1) of the sigmas
1629 // (over the events)
1630 
1631  //... preliminary calculation of the sigmas if not done yet
1632  if ( fTagSSp[0] != 1 ){SampleSigmas(); fTagSSp[0]=0;}
1633 
1634  //................... Allocation ev_ev + init to zero (mandatory)
1635  if( fT1d_evsamp_of_sigevt == 0 ){fT1d_evsamp_of_sigevt = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;}
1636  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1637  {if( fT1d_evsamp_of_sigevt[i0StexEcha] != (Double_t)0 )
1638  {fMiscDiag[12]++; fT1d_evsamp_of_sigevt[i0StexEcha] = (Double_t)0;}}
1639 
1640  //..................... Calculation
1641  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::TotalNoise()" << endl;}
1643  cout << " Calculation, for all the channels, of the expectation values (over the samples 1 to "
1644  << fNbSampForCalc << ")" << endl
1645  << " of the ADC expectation values (over the events)." << endl;}
1646 
1647  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1648  {
1649  for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
1650  {
1651  if( fT2d_sig[i0StexEcha][i0Sample] < 0)
1652  {
1653  cout << "!TEcnaRun::TotalNoise() *** ERROR ***> Negative sigma!"
1654  << fTTBELL << endl;
1655  }
1656  else
1657  {
1658  fT1d_evsamp_of_sigevt[i0StexEcha] += fT2d_sig[i0StexEcha][i0Sample];
1659  }
1660  }
1661  fT1d_evsamp_of_sigevt[i0StexEcha] /= fNbSampForCalc;
1662  }
1663  fTagTno[0] = 1; fFileHeader->fTnoCalc++;
1664 }
1665 //------------------------ (end of TotalNoise) ----------------------------
1666 
1667 //---------------------------------------------------------------------------------
1668 //
1669 // Calculation of the LFN (Low Frequency Noise)
1670 // tag: Lfn
1671 //
1672 // LowFqNoise(c) = sqrt{ E_e[ ( E_s[A(c ,s*,e*)] - E_e[ E_s[A(c ,s*,e*)] ] )^2 ] }
1673 // A(c,s,e) : ADC value for channel c, sample s, event e
1674 // E_e : average over the events
1675 // E_s : average over the samples
1676 //
1677 //---------------------------------------------------------------------------------
1679 {
1680 // Calculation, for each channel, of the sigma (over the events)
1681 // of the ADC expectation values (over the samples 0 to fNbSampForCalc-1)
1682 
1683  //................... Allocation fT1d_sigevt_of_evsamp + init to zero (mandatory)
1684  if( fT1d_sigevt_of_evsamp == 0 ){
1685  fT1d_sigevt_of_evsamp = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
1686  }
1687  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1688  {
1689  if( fT1d_sigevt_of_evsamp[i0StexEcha] != (Double_t)0 )
1690  {fMiscDiag[13]++; fT1d_sigevt_of_evsamp[i0StexEcha] = (Double_t)0;}
1691  }
1692 
1693  //................... Allocation mean_over_samples
1694  TVectorD mean_over_samples(fNumberOfEvents);
1695  for(Int_t i=0; i<fNumberOfEvents; i++){mean_over_samples(i)=(Double_t)0.;}
1696 
1697  //..................... Calculation
1698  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyNoise()" << endl;}
1700  cout << " Calculation, for each channel, of the sigma (over the events)" << endl
1701  << " of the ADC expectation values (over the samples 1 to "
1702  << fNbSampForCalc << ")." << endl;}
1703 
1704  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1705  {
1706  // Calculation of the mean over the events of the mean over the samples
1707  Double_t mean_over_events = (Double_t)0;
1708  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
1709  {
1710  // Calculation, for each event, of the mean over the samples
1711  mean_over_samples(n_event) = (Double_t)0.;
1712  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
1713  {
1714  mean_over_samples(n_event) += fT3d_AdcValues[i0StexEcha][i0Sample][n_event];
1715  }
1716  mean_over_samples(n_event) /= (Double_t)fNbSampForCalc;
1717 
1718  mean_over_events += mean_over_samples(n_event);
1719  }
1720  mean_over_events /= (Double_t)fNumberOfEvents;
1721 
1722  // Calculation of the sigma over the events of the mean over the samples
1723  Double_t var = (Double_t)0;
1724  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
1725  {
1726  Double_t ecart = mean_over_samples(n_event) - mean_over_events;
1727  var += ecart*ecart;
1728  }
1729  var /= (Double_t)fNumberOfEvents;
1730 
1731  fT1d_sigevt_of_evsamp[i0StexEcha] = sqrt(var);
1732  }
1733  fTagLfn[0] = 1; fFileHeader->fLfnCalc++;
1734 }
1735 //------------------------ (end of LowFrequencyNoise) ----------------------------
1736 
1737 //---------------------------------------------------------------------------------
1738 //
1739 // Calculation of the HFN (High Frequency Noise)
1740 // tag: Hfn
1741 //
1742 // HighFqNoise(c) = E_e[ sqrt{ E_s[ (A(c ,s*,e*) - E_s[A(c ,s*,e*)] )^2 ] } ]
1743 // A(c,s,e) : ADC value for channel c, sample s, event e
1744 // E_e : average over the events
1745 // E_s : average over the samples
1746 //
1747 //---------------------------------------------------------------------------------
1749 {
1750 // Calculation, for each channel, of the mean (over the events)
1751 // of the ADC sigmas (over the samples 0 to fNbSampForCalc-1)
1752 
1753  //................... Allocation fT1d_evevt_of_sigsamp + init to zero (mandatory)
1754  if( fT1d_evevt_of_sigsamp == 0 ){
1755  fT1d_evevt_of_sigsamp = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
1756  }
1757  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1758  {
1759  if( fT1d_evevt_of_sigsamp[i0StexEcha] != (Double_t)0 )
1760  {fMiscDiag[14]++; fT1d_evevt_of_sigsamp[i0StexEcha] = (Double_t)0;}
1761  }
1762 
1763  //................... Allocations mean_over_samples, sigma_over_sample
1764  TVectorD mean_over_samples(fNumberOfEvents);
1765  for(Int_t i=0; i<fNumberOfEvents; i++){mean_over_samples(i)=(Double_t)0.;}
1766  TVectorD sigma_over_samples(fNumberOfEvents);
1767  for(Int_t i=0; i<fNumberOfEvents; i++){sigma_over_samples(i)=(Double_t)0.;}
1768 
1769  //..................... Calculation
1770  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyNoise()" << endl;}
1772  cout << " Calculation, for each channel, of the sigma (over the events)" << endl
1773  << " of the ADC expectation values (over the samples 1 to "
1774  << fNbSampForCalc << ")." << endl;}
1775 
1776  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1777  {
1778  //..................... Calculation of the sigma over samples
1779  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
1780  {
1781  // Calculation, for each event, of the mean over the samples
1782  mean_over_samples(n_event) = (Double_t)0.;
1783  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
1784  {mean_over_samples(n_event) += fT3d_AdcValues[i0StexEcha][i0Sample][n_event];}
1785  mean_over_samples(n_event) /= (Double_t)fNbSampForCalc;
1786 
1787  // Calculation, for each event, of the sigma over the samples
1788  Double_t var_over_samples = (Double_t)0;
1789  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
1790  {Double_t deviation = fT3d_AdcValues[i0StexEcha][i0Sample][n_event] - mean_over_samples(n_event);
1791  var_over_samples += deviation*deviation;}
1792  var_over_samples /= (Double_t)fNbSampForCalc;
1793 
1794  if( var_over_samples < 0)
1795  {cout << "!TEcnaRun::HighFrequencyNoise() *** ERROR ***> Negative variance! " << fTTBELL << endl;}
1796  else
1797  {sigma_over_samples(n_event) = sqrt(var_over_samples);}
1798  }
1799 
1800  //....... Calculation of the mean over the events of the sigma over samples
1801  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
1802  {fT1d_evevt_of_sigsamp[i0StexEcha] += sigma_over_samples(n_event);}
1803 
1804  fT1d_evevt_of_sigsamp[i0StexEcha] /= (Double_t)fNumberOfEvents;
1805  }
1806  fTagHfn[0] = 1; fFileHeader->fHfnCalc++;
1807 }
1808 //------------------------ (end of HighFrequencyNoise) ----------------------------
1809 
1810 //-------------------------------------------------------------------------
1811 //
1812 // Calculation of the expectation values of (sample,sample)
1813 // correlations for all the channels (mean cor(s,s))
1814 // tag: MeanCorss
1815 //
1816 // MeanCorss(c) = E_s,s'[ Cor(c;s,s') ]
1817 // E_s,s': average over couples of samples (half correlation matrix)
1818 //
1819 //-------------------------------------------------------------------------
1821 {
1822  // Calculation, for all the channels, of the expectation values
1823  // of the correlations between the first fNbSampForCalc samples
1824 
1825  //... preliminary calculation of the correlations if not done yet
1826  // (test only the first element since the cor are computed globaly)
1827  if ( fTagCorCss[0] != 1 ){CorrelationsBetweenSamples(); fTagCorCss[0]=0;}
1828 
1829  //................... Allocations ev_cor_ss + init to zero (mandatory)
1830  if( fT1d_ev_cor_ss == 0 ){
1831  Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1832  fT1d_ev_cor_ss = new Double_t[n_StexEcha]; fCnew++;
1833  }
1834  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1835  {
1836  if( fT1d_ev_cor_ss[i0StexEcha] != (Double_t)0 )
1837  {fMiscDiag[15]++; fT1d_ev_cor_ss[i0StexEcha] = (Double_t)0;}
1838  }
1839 
1840  //.......... 1D array half_cor_ss[N(N-1)/2] to put the N (sample,sample) correlations
1841  // ( half of (them minus the diagonal) )
1842  Int_t ndim = (Int_t)(fNbSampForCalc*(fNbSampForCalc - 1)/2);
1843 
1844  TVectorD half_cor_ss(ndim); for(Int_t i=0; i<ndim; i++){half_cor_ss(i)=(Double_t)0.;}
1845 
1846  //..................... Calculation
1847  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::MeanCorrelationsBetweenSamples()" << endl;}
1849  cout << " Calculation, for all the channels, of the expectation values of the" << endl
1850  << " correlations between the first " << fNbSampForCalc << " samples." << endl;}
1851 
1852  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1853  {
1854  //..................... half_cor_ss() array filling
1855  Int_t i_count = 0;
1856  for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
1857  {
1858  for (Int_t j0Sample = 0; j0Sample < i0Sample; j0Sample++)
1859  {
1860  half_cor_ss(i_count) = fT3d_cor_ss[i0StexEcha][i0Sample][j0Sample];
1861  i_count++;
1862  }
1863  }
1864  //...................... mean cor(s,s') calculation
1865  fT1d_ev_cor_ss[i0StexEcha] = (Double_t)0;
1866  for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
1867  {
1868  fT1d_ev_cor_ss[i0StexEcha] += half_cor_ss(i_rcor);
1869  }
1870  fT1d_ev_cor_ss[i0StexEcha] /= (Double_t)ndim;
1871  }
1873 }
1874 //--------------- (end of MeanCorrelationsBetweenSamples) -----------
1875 
1876 //-------------------------------------------------------------------------
1877 //
1878 // Calculation of the sigmas of the (sample,sample) correlations
1879 // for all the channels (sigma of cor(s,s))
1880 // tag: SigCorss
1881 //
1882 // SigmaCorss(c) = E_s,s'[ Cor(c;s,s') - E_s,s'[ Cor(c;s,s') ] ]
1883 // E_s,s': average over couples of samples (half correlation matrix)
1884 //
1885 //--------------------------------------------------------------------------
1887 {
1888  //Calculation of the sigmas of the (sample,sample) correlations for all the StexEchas
1889 
1890  //... preliminary calculation of the mean cor(s,s') if not done yet
1891  // (test only the first element since the cor are computed globaly)
1892  // Results available in array fT1d_ev_cor_ss[i0StexEcha]
1894 
1895  //................... Allocations sig_cor_ss + init to zero
1896  if( fT1d_sig_cor_ss == 0 ){
1897  Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
1898  fT1d_sig_cor_ss = new Double_t[n_StexEcha]; fCnew++;
1899  }
1900  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1901  {
1902  if( fT1d_sig_cor_ss[i0StexEcha] != (Double_t)0 )
1903  {fMiscDiag[16]++; fT1d_sig_cor_ss[i0StexEcha] = (Double_t)0;}
1904  }
1905 
1906  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SigmasOfCorrelationsBetweenSamples()" << endl;}
1908  cout << " Calculation of the sigmas of the (sample,sample)" << endl
1909  << " correlations for all the channels." << endl;}
1910 
1911  //.......... 1D array half_cor_ss[N(N-1)/2] to put the N (sample,sample) correlations
1912  // (half of them minus the diagonal)
1913  Int_t ndim = (Int_t)(fNbSampForCalc*(fNbSampForCalc - 1)/2);
1914 
1915  TVectorD half_cor_ss(ndim); for(Int_t i=0; i<ndim; i++){half_cor_ss(i)=(Double_t)0.;}
1916 
1917  //.................. Calculation
1918  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
1919  {
1920  //..................... half_cor_ss() array filling
1921  Int_t i_count = 0;
1922  for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
1923  {
1924  for (Int_t j0Sample = 0; j0Sample < i0Sample; j0Sample++)
1925  {
1926  half_cor_ss(i_count) = fT3d_cor_ss[i0StexEcha][i0Sample][j0Sample];
1927  i_count++;
1928  }
1929  }
1930 
1931  //...................... sigma of cor(s,s') calculation
1932  Double_t var = (Double_t)0;
1933  for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
1934  {
1935  Double_t ecart = half_cor_ss(i_rcor) - fT1d_ev_cor_ss[i0StexEcha];
1936  var += ecart*ecart;
1937  }
1938  var /= (Double_t)ndim;
1939  fT1d_sig_cor_ss[i0StexEcha] = sqrt(var);
1940  }
1942 }
1943 //--------------- (end of SigmaOfCorrelationsBetweenSamples) -----------
1944 
1945 //-----------------------------------------------------------------------------
1946 //
1947 // Calculation of the average Pedestals for each Stin in Stex
1948 // tag: AvPed
1949 //
1950 //-----------------------------------------------------------------------------
1952 {
1953 // Calculation of the average
1954 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Pedestals
1955 
1956  //... preliminary calculation of the Pedestals if not done yet
1957  if ( fTagPed[0] != 1 ){Pedestals(); fTagPed[0]=0;}
1958  //................... Allocation av_mped + init to zero (mandatory)
1959  if( fT1d_av_mped == 0 ){fT1d_av_mped = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
1960  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
1961  {if( fT1d_av_mped[i0StexStinEcna] != (Double_t)0 )
1962  {fMiscDiag[41]++; fT1d_av_mped[i0StexStinEcna] = (Double_t)0;}}
1963 
1964  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragePedestals()" << endl;}
1966  cout << " Calculation, for all the "
1967  << fStinName.Data() << "s, of the average Pedestals" << endl;}
1968 
1969  //................... Calculation
1970  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
1971  {
1972  Int_t n1StexStinEcna = i0StexStinEcna+1;
1973  fT1d_av_mped[i0StexStinEcna] = (Double_t)0;
1974  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
1975  {
1976  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
1977 
1978  if( fStexName == "SM " )
1979  {fT1d_av_mped[i0StexStinEcna] += fT1d_ev_ev[i0StexEcha];}
1980 
1981  if( fStexName == "Dee" )
1982  {
1983  //---------------- Special translation for mixed SCEcna (29 and 32)
1984  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
1985  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
1986  Int_t n1StinEcha = i0StinEcha+1;
1987  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
1988  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
1989  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
1990  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
1991  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
1992  {fT1d_av_mped[i0StexStinEcna] += fT1d_ev_ev[i0StexEcha];}
1993  }
1994  }
1995  Double_t xdivis = (Double_t)0.;
1996  if( fStexName == "SM " )
1997  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
1998  if( fStexName == "Dee" )
1999  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2000 
2001  fT1d_av_mped[i0StexStinEcna] = fT1d_av_mped[i0StexStinEcna]/xdivis;
2002  }
2003 
2004  fTagAvPed[0] = 1; fFileHeader->fAvPedCalc++;
2005 }
2006 //-----------------------------------------------------------------------------
2007 //
2008 // Calculation of the average total noise for each Stin in Stex
2009 // tag: AvTno
2010 //
2011 //-----------------------------------------------------------------------------
2013 {
2014 // Calculation of the average
2015 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Total Noise
2016 
2017  //... preliminary calculation of the averaged Total Noise if not done yet
2018  if ( fTagTno[0] != 1 ){TotalNoise(); fTagTno[0]=0;}
2019  //................... Allocation av_totn + init to zero (mandatory)
2020  if( fT1d_av_totn == 0 ){fT1d_av_totn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
2021  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2022  {if( fT1d_av_totn[i0StexStinEcna] != (Double_t)0 )
2023  {fMiscDiag[42]++; fT1d_av_totn[i0StexStinEcna] = (Double_t)0;}}
2024 
2025  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AverageTotalNoise()" << endl;}
2027  cout << " Calculation, for all the "
2028  << fStinName.Data() << "s, of the average total Noise" << endl;}
2029 
2030  //................... Calculation
2031  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2032  {
2033  Int_t n1StexStinEcna = i0StexStinEcna+1;
2034  fT1d_av_totn[i0StexStinEcna] = (Double_t)0;
2035  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
2036  {
2037  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
2038 
2039  if( fStexName == "SM " )
2040  {fT1d_av_totn[i0StexStinEcna] += fT1d_evsamp_of_sigevt[i0StexEcha];}
2041 
2042  if( fStexName == "Dee" )
2043  {
2044  //---------------- Special translation for mixed SCEcna (29 and 32)
2045  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
2046  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
2047  Int_t n1StinEcha = i0StinEcha+1;
2048  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
2049  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
2050  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
2051  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
2052  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
2053  {fT1d_av_totn[i0StexStinEcna] += fT1d_evsamp_of_sigevt[i0StexEcha];}
2054  }
2055  }
2056  Double_t xdivis = (Double_t)0.;
2057  if( fStexName == "SM " )
2058  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
2059  if( fStexName == "Dee" )
2060  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2061 
2062  fT1d_av_totn[i0StexStinEcna] = fT1d_av_totn[i0StexStinEcna]/xdivis;
2063  }
2064  fTagAvTno[0] = 1; fFileHeader->fAvTnoCalc++;
2065 }
2066 //-----------------------------------------------------------------------------
2067 //
2068 // Calculation of the average Low Frequency noise for each Stin in Stex
2069 // tag: AvLfn
2070 //
2071 //-----------------------------------------------------------------------------
2073 {
2074 // Calculation of the average
2075 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Low Frequency Noise
2076 
2077  //... preliminary calculation of the Low Frequency Noise if not done yet
2078  if ( fTagLfn[0] != 1 ){LowFrequencyNoise(); fTagLfn[0]=0;}
2079  //................... Allocation av_lofn + init to zero (mandatory)
2080  if( fT1d_av_lofn == 0 ){fT1d_av_lofn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
2081  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2082  {if( fT1d_av_lofn[i0StexStinEcna] != (Double_t)0 )
2083  {fMiscDiag[43]++; fT1d_av_lofn[i0StexStinEcna] = (Double_t)0;}}
2084 
2085  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AverageLowFrequencyNoise()" << endl;}
2087  cout << " Calculation, for all the "
2088  << fStinName.Data() << "s, of the average Low Frequency Noise" << endl;}
2089 
2090  //................... Calculation
2091  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2092  {
2093  Int_t n1StexStinEcna = i0StexStinEcna+1;
2094  fT1d_av_lofn[i0StexStinEcna] = (Double_t)0;
2095  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
2096  {
2097  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
2098 
2099  if( fStexName == "SM " )
2100  {fT1d_av_lofn[i0StexStinEcna] += fT1d_sigevt_of_evsamp[i0StexEcha];}
2101 
2102  if( fStexName == "Dee" )
2103  {
2104  //---------------- Special translation for mixed SCEcna (29 and 32)
2105  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
2106  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
2107  Int_t n1StinEcha = i0StinEcha+1;
2108  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
2109  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
2110  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
2111  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
2112  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
2113  {fT1d_av_lofn[i0StexStinEcna] += fT1d_sigevt_of_evsamp[i0StexEcha];}
2114  }
2115  }
2116  Double_t xdivis = (Double_t)0.;
2117  if( fStexName == "SM " )
2118  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
2119  if( fStexName == "Dee" )
2120  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2121 
2122  fT1d_av_lofn[i0StexStinEcna] = fT1d_av_lofn[i0StexStinEcna]/xdivis;
2123  }
2124  fTagAvLfn[0] = 1; fFileHeader->fAvLfnCalc++;
2125 }
2126 //-----------------------------------------------------------------------------
2127 //
2128 // Calculation of the average high frequency noise for each Stin in Stex
2129 // tag: AvHfn
2130 //
2131 //-----------------------------------------------------------------------------
2133 {
2134 // Calculation of the average
2135 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the High Frequency Noise
2136 
2137  //... preliminary calculation of the High Frequency Noise if not done yet
2138  if ( fTagHfn[0] != 1 ){HighFrequencyNoise(); fTagHfn[0]=0;}
2139  //................... Allocation av_hifn + init to zero (mandatory)
2140  if( fT1d_av_hifn == 0 ){fT1d_av_hifn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
2141  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2142  {if( fT1d_av_hifn[i0StexStinEcna] != (Double_t)0 )
2143  {fMiscDiag[44]++; fT1d_av_hifn[i0StexStinEcna] = (Double_t)0;}}
2144 
2145  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AverageHighFrequencyNoise()" << endl;}
2147  cout << " Calculation, for all the "
2148  << fStinName.Data() << "s, of the average High Frequency Noise" << endl;}
2149 
2150  //................... Calculation
2151  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2152  {
2153  Int_t n1StexStinEcna = i0StexStinEcna+1;
2154  fT1d_av_hifn[i0StexStinEcna] = (Double_t)0;
2155  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
2156  {
2157  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
2158 
2159  if( fStexName == "SM " )
2160  {fT1d_av_hifn[i0StexStinEcna] += fT1d_evevt_of_sigsamp[i0StexEcha];}
2161 
2162  if( fStexName == "Dee" )
2163  {
2164  //---------------- Special translation for mixed SCEcna (29 and 32)
2165  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
2166  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
2167  Int_t n1StinEcha = i0StinEcha+1;
2168  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
2169  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
2170  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
2171  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
2172  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
2173  {fT1d_av_hifn[i0StexStinEcna] += fT1d_evevt_of_sigsamp[i0StexEcha];}
2174  }
2175  }
2176  Double_t xdivis = (Double_t)0.;
2177  if( fStexName == "SM " )
2178  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
2179  if( fStexName == "Dee" )
2180  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2181 
2182  fT1d_av_hifn[i0StexStinEcna] = fT1d_av_hifn[i0StexStinEcna]/xdivis;
2183  }
2184  fTagAvHfn[0] = 1; fFileHeader->fAvHfnCalc++;
2185 }
2186 //-----------------------------------------------------------------------------
2187 //
2188 // Calculation of the average mean cor(s,s) for each Stin in Stex
2189 // tag: AvMeanCorss
2190 //
2191 //-----------------------------------------------------------------------------
2193 {
2194 // Calculation of the average
2195 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the mean cor(s,s)
2196 
2197  //... preliminary calculation of the mean cor(s,s) if not done yet
2199  //................... Allocation av_ev_corss + init to zero (mandatory)
2200  if( fT1d_av_ev_corss == 0 ){fT1d_av_ev_corss = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
2201  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2202  {if( fT1d_av_ev_corss[i0StexStinEcna] != (Double_t)0 )
2203  {fMiscDiag[45]++; fT1d_av_ev_corss[i0StexStinEcna] = (Double_t)0;}}
2204 
2205  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AverageMeanCorrelationsBetweenSamples()" << endl;}
2207  cout << " Calculation, for all the "
2208  << fStinName.Data() << "s, of the average mean cor(s,s)" << endl;}
2209 
2210  //................... Calculation
2211  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2212  {
2213  Int_t n1StexStinEcna = i0StexStinEcna+1;
2214  fT1d_av_ev_corss[i0StexStinEcna] = (Double_t)0;
2215  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
2216  {
2217  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
2218 
2219  if( fStexName == "SM " )
2220  {fT1d_av_ev_corss[i0StexStinEcna] += fT1d_ev_cor_ss[i0StexEcha];}
2221 
2222  if( fStexName == "Dee" )
2223  {
2224  //---------------- Special translation for mixed SCEcna (29 and 32)
2225  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
2226  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
2227  Int_t n1StinEcha = i0StinEcha+1;
2228  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
2229  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
2230  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
2231  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
2232  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
2233  {fT1d_av_ev_corss[i0StexStinEcna] += fT1d_ev_cor_ss[i0StexEcha];}
2234  }
2235  }
2236  Double_t xdivis = (Double_t)0.;
2237  if( fStexName == "SM " )
2238  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
2239  if( fStexName == "Dee" )
2240  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2241 
2242  fT1d_av_ev_corss[i0StexStinEcna] = fT1d_av_ev_corss[i0StexStinEcna]/xdivis;
2243  }
2245 }
2246 //-----------------------------------------------------------------------------
2247 //
2248 // Calculation of the average sigma of cor(s,s) for each Stin in Stex
2249 // tag: AvSigCorss
2250 //
2251 //-----------------------------------------------------------------------------
2253 {
2254 // Calculation of the average
2255 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the sigma of cor(s,s)
2256 
2257  //... preliminary calculation of the sigma of cor(s,s) if not done yet
2259  //................... Allocation av_sig_corss + init to zero (mandatory)
2260  if( fT1d_av_sig_corss == 0 ){fT1d_av_sig_corss = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
2261  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2262  {if( fT1d_av_sig_corss[i0StexStinEcna] != (Double_t)0 )
2263  {fMiscDiag[46]++; fT1d_av_sig_corss[i0StexStinEcna] = (Double_t)0;}}
2264 
2265  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AverageSigmaOfCorrelationsBetweenSamples()" << endl;}
2267  cout << " Calculation, for all the "
2268  << fStinName.Data() << "s, of the average sigma of cor(s,s)" << endl;}
2269 
2270  //................... Calculation
2271  for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2272  {
2273  Int_t n1StexStinEcna = i0StexStinEcna+1;
2274  fT1d_av_sig_corss[i0StexStinEcna] = (Double_t)0;
2275  for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
2276  {
2277  Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
2278 
2279  if( fStexName == "SM " )
2280  {fT1d_av_sig_corss[i0StexStinEcna] += fT1d_sig_cor_ss[i0StexEcha];}
2281 
2282  if( fStexName == "Dee" )
2283  {
2284  //---------------- Special translation for mixed SCEcna (29 and 32)
2285  // Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
2286  // Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
2287  Int_t n1StinEcha = i0StinEcha+1;
2288  if( n1StexStinEcna == 10 && n1StinEcha == 11 )
2289  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
2290  if( n1StexStinEcna == 11 && n1StinEcha == 11 )
2291  {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
2292  if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 ) )
2293  {fT1d_av_sig_corss[i0StexStinEcna] += fT1d_sig_cor_ss[i0StexEcha];}
2294  }
2295  }
2296  Double_t xdivis = (Double_t)0.;
2297  if( fStexName == "SM " )
2298  {xdivis = (Double_t)fEcal->MaxCrysInStin();}
2299  if( fStexName == "Dee" )
2300  {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
2301 
2302  fT1d_av_sig_corss[i0StexStinEcna] = fT1d_av_sig_corss[i0StexStinEcna]/xdivis;
2303  }
2305 }
2306 
2307 //======================================================================
2308 //
2309 // C O V A R I A N C E S & C O R R E L A T I O N S
2310 //
2311 // B E T W E E N C H A N N E L S
2312 //
2313 //======================================================================
2314 //----------------------------------------------------------------------
2315 //
2316 // Calculation of the Low Frequency Covariances between channels
2317 //
2318 // LFCov(Ci,Cj) = Cov_e[ E_s[A(Ci,s*,e*)] , E_s[A(Cj,s*,e*) ]
2319 //
2320 // = E_e[ ( E_s[A(Ci,s*,e*)] - E_e[ E_s[A(Ci,s*,e*)] ] )*
2321 // ( E_s[A(Cj,s*,e*)] - E_e[ E_s[A(Cj,s*,e*)] ] ) ]
2322 //
2323 // A(Ci,s,e) : ADC value for channel Ci, sample s, event e
2324 //
2325 // E_e , Cov_e : average, covariance over the events
2326 // E_s : average over the samples
2327 //
2328 // e* : random variable associated to events
2329 // s* : random variable associated to samples
2330 //
2331 //----------------------------------------------------------------------
2333 {
2334 //Calculation of the Low Frequency Covariances between channels
2335 
2336  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyCovariancesBetweenChannels()" << endl;}
2338  cout << " Calculation of the Low Frequency Covariances between channels" << endl;}
2339 
2340  //................. allocation fT2d_lf_cov + init to zero (mandatory)
2341  if( fT2d_lf_cov == 0 ){
2342  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
2343  fT2d_lf_cov = new Double_t*[n_StexEcha]; fCnew++;
2344  fT2d1_lf_cov = new Double_t[n_StexEcha*n_StexEcha]; fCnew++;
2345  for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
2346  fT2d_lf_cov[i0StexEcha] = &fT2d1_lf_cov[0] + i0StexEcha*n_StexEcha;}}
2347 
2348  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2349  {
2350  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
2351  {
2352  if( fT2d_lf_cov[i0StexEcha][j0StexEcha] != (Double_t)0 )
2353  {fMiscDiag[21]++; fT2d_lf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;}
2354  }
2355  }
2356  //........................................... Calculation (LowFrequencyCovariancesBetweenChannels)
2357  //................... Allocation mean_over_samples(i0StexEcha, n_event)
2358  TMatrixD mean_over_samples(fEcal->MaxCrysEcnaInStex(), fNumberOfEvents);
2359  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2360  {for(Int_t n_event=0; n_event<fNumberOfEvents; n_event++)
2361  {mean_over_samples(i0StexEcha, n_event)=(Double_t)0.;}}
2362  //................... Allocation MoeOfMos(i0StexEcha)
2363  TVectorD MoeOfMos(fEcal->MaxCrysEcnaInStex());
2364  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2365  { MoeOfMos(i0StexEcha)=(Double_t)0.;}
2366 
2367  //................... Calculation
2369  cout << " Calculation, for each pair of channels, of the covariance (over the events)" << endl
2370  << " between the ADC expectation values (over the samples 1 to "
2371  << fNbSampForCalc << ")." << endl;}
2372 
2373  cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
2374 
2375  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2376  {
2377  MoeOfMos(i0StexEcha) = (Double_t)0;
2378 
2379  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2380  || ( fFlagSubDet == "EB") )
2381  {
2382  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2383  {
2384  // Calculation, for each event, of the mean over the samples ( = E_s[A(c_i,s*,e_n] )
2385  mean_over_samples(i0StexEcha, n_event) = (Double_t)0.;
2386  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
2387  {
2388  mean_over_samples(i0StexEcha, n_event) += fT3d_AdcValues[i0StexEcha][i0Sample][n_event];
2389  }
2390  mean_over_samples(i0StexEcha, n_event) /= (Double_t)fNbSampForCalc;
2391  }
2392  //Calculation of the mean over the events of E_s[A(c_i,s*,e_n] ( = E_e[E_s[A(c_i,s*,e*]] )
2393  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2394  {MoeOfMos(i0StexEcha) += mean_over_samples(i0StexEcha, n_event);}
2395  MoeOfMos(i0StexEcha) /= (Double_t)fNumberOfEvents;
2396  }
2397  }
2398 
2399  //... Calculation of half of the matrix, diagonal included (LowFrequencyCovariancesBetweenChannels)
2400  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2401  {
2402  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2403  || ( fFlagSubDet == "EB") )
2404  {
2405  for(Int_t j0StexEcha = 0; j0StexEcha <= i0StexEcha; j0StexEcha++)
2406  {
2407  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
2408  || ( fFlagSubDet == "EB") )
2409  {
2410  fT2d_lf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;
2411  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2412  {
2413  fT2d_lf_cov[i0StexEcha][j0StexEcha] +=
2414  ( mean_over_samples(i0StexEcha, n_event) - MoeOfMos(i0StexEcha) )
2415  *( mean_over_samples(j0StexEcha, n_event) - MoeOfMos(j0StexEcha) );
2416  }
2417  fT2d_lf_cov[i0StexEcha][j0StexEcha] /= (Double_t)fNumberOfEvents;
2418 
2419  fT2d_lf_cov[j0StexEcha][i0StexEcha] = fT2d_lf_cov[i0StexEcha][j0StexEcha];
2420  }
2421  }
2422  if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[LFN Cov], ";}
2423  }
2424  }
2425  cout << endl;
2426  fTagLfCov[0] = 1; fFileHeader->fLfCovCalc++;
2427 }
2428 //---------- (end of LowFrequencyCovariancesBetweenChannels ) --------------------
2429 
2430 //------------------------------------------------------------------
2431 //
2432 // Calculation of the Low Frequency Correlations between channels
2433 //
2434 // LFCor(Ci,Cj) = LFCov(Ci,Cj)/sqrt(LFCov(Ci,Ci)*LFCov(Cj,Cj))
2435 //
2436 //------------------------------------------------------------------
2438 {
2439 //Calculation of the Low Frequency Correlations between channels
2440 
2441  //... preliminary calculation of the covariances if not done yet.
2442  if ( fTagLfCov[0] != 1 )
2444 
2445  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyCorrelationsBetweenChannels()" << endl;}
2447  cout << " Calculation of the Low Frequency Correlations between channels" << endl
2448  << " Starting allocation. "
2449  << endl;}
2450 
2451  //................. allocation fT2d_lf_cor + init to zero (mandatory)
2452  if( fT2d_lf_cor == 0 ){
2453  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
2454  fT2d_lf_cor = new Double_t*[n_StexEcha]; fCnew++;
2455  fT2d1_lf_cor = new Double_t[n_StexEcha*n_StexEcha]; fCnew++;
2456  for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
2457  fT2d_lf_cor[i0StexEcha] = &fT2d1_lf_cor[0] + i0StexEcha*n_StexEcha;}
2458  }
2459 
2460  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2461  {
2462  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
2463  {
2464  if( fT2d_lf_cor[i0StexEcha][j0StexEcha] != (Double_t)0 )
2465  {fMiscDiag[22]++; fT2d_lf_cor[i0StexEcha][j0StexEcha] = (Double_t)0;}
2466  }
2467  }
2468 
2469  //................. calculation
2470  //........................... computation of half of the matrix, diagonal included
2471  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2472  {
2473  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2474  || ( fFlagSubDet == "EB") )
2475  {
2476  for (Int_t j0StexEcha = 0 ; j0StexEcha <= i0StexEcha ; j0StexEcha++)
2477  {
2478  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
2479  || ( fFlagSubDet == "EB") )
2480  {
2481  if( fT2d_lf_cov[i0StexEcha][i0StexEcha] > 0
2482  && fT2d_lf_cov[j0StexEcha][j0StexEcha] > 0 )
2483  {
2484  fT2d_lf_cor[i0StexEcha][j0StexEcha] =
2485  fT2d_lf_cov[i0StexEcha][j0StexEcha]/
2486  ( (Double_t)sqrt( fT2d_lf_cov[i0StexEcha][i0StexEcha]*
2487  fT2d_lf_cov[j0StexEcha][j0StexEcha] ) );
2488  }
2489  else
2490  {
2491  fT2d_lf_cor[i0StexEcha][j0StexEcha] = (Double_t)0.;
2492  }
2493  fT2d_lf_cor[j0StexEcha][i0StexEcha] = fT2d_lf_cor[i0StexEcha][j0StexEcha];
2494  }
2495  }
2496  }
2497  if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[LFN Cor], ";}
2498  }
2499  cout << endl;
2500 
2501  fTagLfCor[0] = 1; fFileHeader->fLfCorCalc++;
2502 }
2503 //--------------- (end of LowFrequencyCorrelationsBetweenChannels) --------------------
2504 
2505 //------------------------------------------------------------------
2506 //
2507 // Calculation of the High Frequency Covariances between channels
2508 //
2509 // HFCov(Ci,Cj) = E_e[ Cov_s[ A(Ci,s*,e*) , A(Cj,s*,e*) ] ]
2510 //
2511 // = E_e[ E_s[ ( A(Ci,s*,e*) - E_s[A(Ci,s*,e*)] )*
2512 // ( A(Cj,s*,e*) - E_s[A(Cj,s*,e*)] ) ] ]
2513 //
2514 // A(Ci,s,e) : ADC value for channel Ci, sample s, event e
2515 //
2516 // E_e : average over the events
2517 // E_s , Cov_s : average, covariance over the samples
2518 //
2519 //------------------------------------------------------------------
2521 {
2522 //Calculation of the High Frequency Covariances between channels
2523 
2524  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyCovariancesBetweenChannels()" << endl;}
2526  cout << " Calculation of the High Frequency Covariances between channels" << endl;}
2527 
2528  //................. allocation fT2d_hf_cov + init to zero (mandatory)
2529  if( fT2d_hf_cov == 0 ){
2530  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
2531  fT2d_hf_cov = new Double_t*[n_StexEcha]; fCnew++;
2532  fT2d1_hf_cov = new Double_t[n_StexEcha*n_StexEcha]; fCnew++;
2533  for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
2534  fT2d_hf_cov[i0StexEcha] = &fT2d1_hf_cov[0] + i0StexEcha*n_StexEcha;}
2535  }
2536 
2537  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2538  {
2539  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
2540  {
2541  if( fT2d_hf_cov[i0StexEcha][j0StexEcha] != (Double_t)0 )
2542  {fMiscDiag[23]++; fT2d_hf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;}
2543  }
2544  }
2545 
2546  //................... Allocation mean_over_samples(i0StexEcha, n_event)
2547  TMatrixD mean_over_samples(fEcal->MaxCrysEcnaInStex(), fNumberOfEvents);
2548  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2549  {for(Int_t n_event=0; n_event<fNumberOfEvents; n_event++)
2550  {mean_over_samples(i0StexEcha, n_event)=(Double_t)0.;}}
2551  //................... Allocation cov_over_samp(i0StexEcha,j0StexEcha)
2552  TMatrixD cov_over_samp(fEcal->MaxCrysEcnaInStex(), fEcal->MaxCrysEcnaInStex());
2553  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2554  {for(Int_t j0StexEcha=0; j0StexEcha<fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
2555  {cov_over_samp(i0StexEcha, j0StexEcha)=(Double_t)0.;}}
2556 
2557  //........................................... Calculation (HighFrequencyCovariancesBetweenChannels)
2559  cout << " Calculation of the mean (over the events)" << endl
2560  << " of the covariances between the channels (over the samples 1 to "
2561  << fNbSampForCalc << ")." << endl;}
2562 
2563  cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
2564 
2565  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2566  {
2567  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2568  || ( fFlagSubDet == "EB") )
2569  {
2570  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2571  {
2572  // Calculation, for each event, of the mean over the samples ( = E_s[A(c_i,s*,e_n] )
2573  mean_over_samples(i0StexEcha, n_event) = (Double_t)0.;
2574  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
2575  {mean_over_samples(i0StexEcha, n_event) += fT3d_AdcValues[i0StexEcha][i0Sample][n_event];}
2576  mean_over_samples(i0StexEcha, n_event) /= (Double_t)fNbSampForCalc;
2577  }
2578  }
2579  if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFNa Cov], ";}
2580  }
2581  cout << endl;
2582 
2583  cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
2584 
2585  //... Calculation of half of the matrix, diagonal included (HighFrequencyCovariancesBetweenChannels)
2586  for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
2587  {
2588  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2589  || ( fFlagSubDet == "EB") )
2590  {
2591  for(Int_t j0StexEcha = 0; j0StexEcha <= i0StexEcha; j0StexEcha++)
2592  {
2593  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
2594  || ( fFlagSubDet == "EB") )
2595  {
2596  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2597  {
2598  // Calculation, for each event, of the covariance over the samples
2599  cov_over_samp(i0StexEcha,j0StexEcha) = (Double_t)0;
2600  for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
2601  {
2602  cov_over_samp(i0StexEcha,j0StexEcha) +=
2603  ( fT3d_AdcValues[i0StexEcha][i0Sample][n_event] - mean_over_samples(i0StexEcha, n_event) )*
2604  ( fT3d_AdcValues[j0StexEcha][i0Sample][n_event] - mean_over_samples(j0StexEcha, n_event) );
2605  }
2606  cov_over_samp(i0StexEcha,j0StexEcha) /= (Double_t)fNbSampForCalc;
2607 
2608  }
2609  //....... Calculation of the mean over the events of Cov_s[A(c_i,s*,e*),A(c_j,s*,e*)]
2610  //......... Calculation of half of the matrix, diagonal included
2611  fT2d_hf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;
2612  for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
2613  {
2614  fT2d_hf_cov[i0StexEcha][j0StexEcha] += cov_over_samp(i0StexEcha,j0StexEcha);
2615  }
2616  fT2d_hf_cov[i0StexEcha][j0StexEcha] /= (Double_t)fNumberOfEvents;
2617 
2618  fT2d_hf_cov[j0StexEcha][i0StexEcha] = fT2d_hf_cov[i0StexEcha][j0StexEcha];
2619  }
2620  }
2621  }
2622  if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFNb Cov], ";}
2623  }
2624  cout << endl;
2625 
2626  fTagHfCov[0] = 1; fFileHeader->fHfCovCalc++;
2627 }
2628 //---------- (end of HighFrequencyCovariancesBetweenChannels ) --------------------
2629 
2630 //------------------------------------------------------------------
2631 //
2632 // Calculation of the High Frequency Correlations between channels
2633 //
2634 // HFCor(Ci,Cj) = HFCov(Ci,Cj)/sqrt(HFCov(Ci,Ci)*HFCov(Cj,Cj))
2635 //
2636 //------------------------------------------------------------------
2638 {
2639 //Calculation of the High Frequency Correlations between channels
2640 
2641  //... preliminary calculation of the covariances if not done yet.
2642  if ( fTagHfCov[0] != 1 )
2644 
2645  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyCorrelationsBetweenChannels()" << endl;}
2647  cout << " Calculation of the High Frequency Correlations between channels" << endl
2648  << " Starting allocation. "
2649  << endl;}
2650 
2651  //................. allocation fT2d_hf_cor + init to zero (mandatory)
2652  if( fT2d_hf_cor == 0 ){
2653  const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
2654  fT2d_hf_cor = new Double_t*[n_StexEcha]; fCnew++;
2655  fT2d1_hf_cor = new Double_t[n_StexEcha*n_StexEcha]; fCnew++;
2656  for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
2657  fT2d_hf_cor[i0StexEcha] = &fT2d1_hf_cor[0] + i0StexEcha*n_StexEcha;}
2658  }
2659 
2660  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2661  {
2662  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
2663  {
2664  if( fT2d_hf_cor[i0StexEcha][j0StexEcha] != (Double_t)0 )
2665  {fMiscDiag[24]++; fT2d_hf_cor[i0StexEcha][j0StexEcha] = (Double_t)0;}
2666  }
2667  }
2668 
2669  //................. calculation
2670  //........................... computation of half of the matrix, diagonal included
2671 
2672  for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
2673  {
2674  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
2675  || ( fFlagSubDet == "EB") )
2676  {
2677  for (Int_t j0StexEcha = 0 ; j0StexEcha <= i0StexEcha ; j0StexEcha++)
2678  {
2679  if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
2680  || ( fFlagSubDet == "EB") )
2681  {
2682  if( fT2d_hf_cov[i0StexEcha][i0StexEcha] > 0
2683  && fT2d_hf_cov[j0StexEcha][j0StexEcha] > 0 )
2684  {
2685  fT2d_hf_cor[i0StexEcha][j0StexEcha] =
2686  fT2d_hf_cov[i0StexEcha][j0StexEcha]/
2687  ( (Double_t)sqrt(fT2d_hf_cov[i0StexEcha][i0StexEcha]) *
2688  (Double_t)sqrt(fT2d_hf_cov[j0StexEcha][j0StexEcha]) );
2689  }
2690  else
2691  {
2692  fT2d_hf_cor[i0StexEcha][j0StexEcha] = (Double_t)0.;
2693  }
2694 
2695  fT2d_hf_cor[j0StexEcha][i0StexEcha] = fT2d_hf_cor[i0StexEcha][j0StexEcha];
2696  }
2697  }
2698  }
2699  if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFN Cor], ";}
2700  }
2701  cout << endl;
2702 
2703  fTagHfCor[0] = 1; fFileHeader->fHfCorCalc++;
2704 }
2705 //------- (end of HighFrequencyCorrelationsBetweenChannels) ----------
2706 
2707 //=================================================================================
2708 //
2709 // L O W & H I G H F R E Q U E N C Y C O R R E L A T I O N S
2710 //
2711 // B E T W E E N T O W E R S ( E B ) O R S C s ( E E )
2712 //
2713 //=================================================================================
2714 //-----------------------------------------------------------------------------
2715 // Calculation of the mean Low Frequency Correlations
2716 // between channels for each Stin
2717 //-----------------------------------------------------------------------------
2722 
2724 {
2725 //Calculation of the mean Low Frequency Correlations
2726 //between channels for each Stin
2727 
2728  //... preliminary calculation of the Low Frequency Cor(c,c) if not done yet
2729  // Only one tag (dim=1) to set to 0 (no write in the result ROOT file)
2731 
2732  //..... mean fT2d_lfcc_mostins for each pair (Stin_X,Stin_Y)
2733  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()" << endl;}
2735  cout << " Calculation of the mean, for each "
2736  << fStinName.Data() << ", of the" << endl
2737  << " Low Frequency Correlations between channels." << endl;}
2738 
2739  //................. allocation fT2d_lfcc_mostins + init to zero (mandatory)
2740  if( fT2d_lfcc_mostins == 0 ){
2741  const Int_t n_Stin = fEcal->MaxStinEcnaInStex();
2742  fT2d_lfcc_mostins = new Double_t*[n_Stin]; fCnew++;
2743  fT2d1_lfcc_mostins = new Double_t[n_Stin*n_Stin]; fCnew++;
2744  for(Int_t i0StexStinEcna = 0 ; i0StexStinEcna < n_Stin ; i0StexStinEcna++){
2745  fT2d_lfcc_mostins[i0StexStinEcna] = &fT2d1_lfcc_mostins[0] + i0StexStinEcna*n_Stin;}
2746  }
2747 
2748  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2749  {
2750  for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
2751  {
2752  if( fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] != (Double_t)0 )
2753  {fMiscDiag[31]++; fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;}
2754  }
2755  }
2756 
2757  //..... Calculation of the mean LF Cor(c,c) for each pair (Stin_X,Stin_Y)
2758  //
2759  // ! => Warning: this matrix is NOT symmetric => take N*N elements
2760  // Only (Stin,Stin) matrix is symmetric.
2761  // (StinEcha,StinEcha) matrix inside a (Stin,Stin) element is NOT symmetric
2762  // (except for the (Stin,Stin) DIAGONAL elements)
2763  // Then:
2764  // 1D array half_LFccMos[N*N] to put the (channel,channel) correlations
2765 
2766  Int_t ndim = (Int_t)(fEcal->MaxCrysInStin()*fEcal->MaxCrysInStin());
2767 
2768  TVectorD half_LFccMos(ndim); for(Int_t i=0; i<ndim; i++){half_LFccMos(i)=(Double_t)0.;}
2769 
2770  //..................... Calculation
2771  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()" << endl;}
2773  cout << " Calculation, for each "
2774  << fStinName.Data() << ", of the mean " << endl
2775  << " Low Frequency cor(c,c)." << endl;}
2776 
2777  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2778  {
2779  for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
2780  {
2781  //................... .Copy the Mean Correlations(c,c') in 1D vector half_LFccMos()
2782  Int_t i_count = 0;
2783  for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
2784  {
2785  Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinCrys;
2786  for(Int_t j0StinCrys=0; j0StinCrys<fEcal->MaxCrysInStin(); j0StinCrys++)
2787  {
2788  Int_t j0StexEcha = j0StexStinEcna*fEcal->MaxCrysInStin() + j0StinCrys;
2789  if( (i0StexEcha>= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex()) &&
2790  (j0StexEcha>= 0 && j0StexEcha < fEcal->MaxCrysEcnaInStex()) )
2791  {half_LFccMos(i_count) = fT2d_lf_cor[i0StexEcha][j0StexEcha]; i_count++;}
2792  else
2793  {cout << "!TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()> Channel number out of range."
2794  << "i0StexEcha = " << i0StexEcha <<", j0StexEcha = " << j0StexEcha << fTTBELL << endl; }
2795  }
2796  }
2797  //...... Calculation of the mean absolute values of the LF mean Correlations(c,c')
2798  fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;
2799  for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
2800  {
2801  fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] += fabs(half_LFccMos(i_rcor));
2802  }
2803  fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] /= (Double_t)ndim;
2804  }
2805  if( i0StexStinEcna%10 == 0 ){cout << i0StexStinEcna << "[LFN MCtt], ";}
2806  }
2807  cout << endl;
2808 
2810 } // ------- end of LowFrequencyMeanCorrelationsBetweenStins() -------
2811 
2812 //-----------------------------------------------------------------------------
2813 // Calculation of the mean High Frequency Correlations
2814 // between channels for each Stin
2815 //-----------------------------------------------------------------------------
2820 
2822 {
2823 //Calculation of the mean High Frequency Correlations
2824 //between channels for each Stin
2825 
2826  //... preliminary calculation of the High Frequency Cor(c,c) if not done yet
2827  // Only one tag (dim=1) to set to 0 (no write in the result ROOT file)
2829 
2830  //..... mean fT2d_hfcc_mostins for each pair (Stin_X,Stin_Y)
2831  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()" << endl;}
2833  cout << " Calculation of the mean, for each "
2834  << fFlagSubDet.Data() << ", of the" << endl
2835  << " High Frequency Correlations between channels." << endl;}
2836 
2837  //................. allocation fT2d_hfcc_mostins + init to zero (mandatory)
2838  if( fT2d_hfcc_mostins == 0 ){
2839  const Int_t n_Stin = fEcal->MaxStinEcnaInStex();
2840  fT2d_hfcc_mostins = new Double_t*[n_Stin]; fCnew++;
2841  fT2d1_hfcc_mostins = new Double_t[n_Stin*n_Stin]; fCnew++;
2842  for(Int_t i0StexStinEcna = 0 ; i0StexStinEcna < n_Stin ; i0StexStinEcna++){
2843  fT2d_hfcc_mostins[i0StexStinEcna] = &fT2d1_hfcc_mostins[0] + i0StexStinEcna*n_Stin;}
2844  }
2845 
2846  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2847  {
2848  for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
2849  {
2850  if( fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] != (Double_t)0 )
2851  {fMiscDiag[32]++; fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;}
2852  }
2853  }
2854 
2855  //..... Calculation of the mean HF Cor(c,c) for each pair (Stin_X,Stin_Y)
2856  //
2857  // ! => Warning: this matrix is NOT symmetric => take N*N elements
2858  // Only (Stin,Stin) matrix is symmetric.
2859  // (StinEcha,StinEcha) matrix inside a (Stin,Stin) element is NOT symmetric
2860  // (except for the (Stin,Stin) DIAGONAL elements)
2861  // Then:
2862  // 1D array half_LFccMos[N*N] to put the (channel,channel) correlations
2863 
2864  Int_t ndim = (Int_t)(fEcal->MaxCrysInStin()*fEcal->MaxCrysInStin());
2865 
2866  TVectorD half_HFccMos(ndim); for(Int_t i=0; i<ndim; i++){half_HFccMos(i)=(Double_t)0.;}
2867 
2868  if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()" << endl;}
2870  cout << " Calculation, for each "
2871  << fFlagSubDet.Data() << ", of the mean " << endl
2872  << " High Frequency cor(c,c)." << endl;}
2873 
2874  //..................... Calculation
2875  for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
2876  {
2877  for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
2878  {
2879  //.................... Copy the relevant Mean Correlations(c,c') in 1D vector half_HFccMos()
2880  Int_t i_count = 0;
2881  for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
2882  {
2883  Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinCrys;
2884  for(Int_t j0StinCrys=0; j0StinCrys<fEcal->MaxCrysInStin(); j0StinCrys++)
2885  {
2886  Int_t j0StexEcha = j0StexStinEcna*fEcal->MaxCrysInStin() + j0StinCrys;
2887  if( (i0StexEcha>= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex()) &&
2888  (j0StexEcha>= 0 && j0StexEcha < fEcal->MaxCrysEcnaInStex()) )
2889  {half_HFccMos(i_count) = fT2d_hf_cor[i0StexEcha][j0StexEcha]; i_count++;}
2890  else
2891  {cout << "!TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()> Channel number out of range."
2892  << "i0StexEcha = " << i0StexEcha <<", j0StexEcha = " << j0StexEcha << fTTBELL << endl; }
2893  }
2894  }
2895  //..... Calculation of the mean absolute values of the HF mean Correlations(c,c')
2896  fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;
2897  for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
2898  {
2899  fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] += fabs(half_HFccMos(i_rcor));
2900  }
2901  fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] /= (Double_t)ndim;
2902  }
2903  if( i0StexStinEcna%10 == 0 ){cout << i0StexStinEcna << "[HFN MCtt], ";}
2904  }
2905  cout << endl;
2906 
2908 } // ------- end of HighFrequencyMeanCorrelationsBetweenStins() -------
2909 
2910 //=========================================================================
2911 //
2912 // W R I T I N G M E T H O D S
2913 //
2914 //=========================================================================
2915 
2916 //=========================================================================
2917 //
2918 // W R I T I N G M E T H O D S : R O O T F I L E S
2919 //
2920 //=========================================================================
2921 //-------------------------------------------------------------
2922 //
2923 // OpenRootFile
2924 //
2925 //-------------------------------------------------------------
2926 Bool_t TEcnaRun::OpenRootFile(const Text_t *name, TString status) {
2927 //Open the Root file
2928 
2929  Bool_t ok_open = kFALSE;
2930 
2931  TString s_name;
2932  s_name = fCnaParPaths->ResultsRootFilePath();
2933  s_name.Append('/');
2934  s_name.Append(name);
2935 
2936  //gCnaRootFile = new TEcnaRootFile(fObjectManager, s_name.Data(), status); fCnew++;
2937 
2938  Long_t iCnaRootFile = fObjectManager->GetPointerValue("TEcnaRootFile");
2939  if( iCnaRootFile == 0 )
2940  {
2941  gCnaRootFile = new TEcnaRootFile(fObjectManager, s_name.Data(), status); /* Anew("gCnaRootFile");*/
2942  }
2943  else
2944  {
2945  gCnaRootFile = (TEcnaRootFile*)iCnaRootFile;
2946  gCnaRootFile->ReStart(s_name.Data(), status);
2947  }
2948 
2949  if ( gCnaRootFile->fRootFileStatus == "RECREATE" ){ok_open = gCnaRootFile->OpenW();}
2950  if ( gCnaRootFile->fRootFileStatus == "READ" ){ok_open = gCnaRootFile->OpenR();}
2951 
2952  if (!ok_open) // unable to open file
2953  {
2954  cout << "TEcnaRun::OpenRootFile> Cannot open file " << s_name.Data() << endl;
2955  }
2956  else
2957  {
2959  {cout << "*TEcnaRun::OpenRootFile> Open ROOT file OK for file " << s_name.Data() << endl;}
2960  fOpenRootFile = kTRUE;
2961  }
2962  return ok_open;
2963 }
2964 //-------------------------------------------------------------
2965 //
2966 // CloseRootFile
2967 //
2968 //-------------------------------------------------------------
2969 Bool_t TEcnaRun::CloseRootFile(const Text_t *name) {
2970 //Close the Root file
2971 
2972  TString s_name;
2973  s_name = fCnaParPaths->ResultsRootFilePath();
2974  s_name.Append('/');
2975  s_name.Append(name);
2976 
2977  Bool_t ok_close = kFALSE;
2978 
2979  if (fOpenRootFile == kTRUE )
2980  {
2982 
2984  cout << "*TEcnaRun::CloseRootFile> ROOT file " << s_name.Data() << " closed." << endl;}
2985 
2986  // delete gCnaRootFile; gCnaRootFile = 0; fCdelete++;
2987 
2988  fOpenRootFile = kFALSE;
2989  ok_close = kTRUE;
2990  }
2991  else
2992  {
2993  cout << "*TEcnaRun::CloseRootFile(...)> No close since no file is open."
2994  << fTTBELL << endl;
2995  }
2996  return ok_close;
2997 }
2998 //-------------------------------------------------------------
2999 //
3000 // WriteRootFile without arguments.
3001 // Call WriteRootFile WITH argument (file name)
3002 // after an automatic generation of the file name.
3003 //
3004 // Codification for the file name:
3005 // see comment at the beginning of this file
3006 //
3007 //-------------------------------------------------------------
3008 
3009 //=================================================================================
3010 //
3011 // WriteRootFile() ====> D O N ' T S U P P R E S S ! ! !
3012 // Called by the analyzer in package: "Modules"
3013 //
3014 //=================================================================================
3016 //Write the Root file.
3017 //File name automatically generated by fCnaWrite->fMakeResultsFileName()
3018 //previously called in GetReadyToCompute().
3019 
3020  Bool_t ok_write = kFALSE;
3021 
3022  //============================= check number of found events
3023  Int_t nCountEvts = 0;
3024 
3025  for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
3026  {for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples; i0Sample++)
3027  {nCountEvts += fT2d_NbOfEvts[i0StexEcha][i0Sample];}}
3028 
3029  if ( nCountEvts <= 0 )
3030  {
3031  //============== no write if no event found
3032  cout << "!TEcnaRun::WriteRootFile()> No event found for file " << fCnaWrite->GetRootFileNameShort().Data()
3033  << ". File will not be written." << endl;
3034  ok_write = kTRUE;
3035  }
3036  else
3037  {
3039  cout << "*TEcnaRun::WriteRootFile()> Results are going to be written in the ROOT file: " << endl
3040  << " " << fCnaWrite->GetRootFileName().Data() << endl;}
3041 
3042  const Text_t *FileShortName = (const Text_t *)fCnaWrite->GetRootFileNameShort().Data();
3043  ok_write = WriteRootFile(FileShortName, fFileHeader->fNbOfSamples);
3044 
3045  if( ok_write == kTRUE )
3046  {
3048  {cout << "*TEcnaRun::WriteRootFile()> Writing OK for file " << fCnaWrite->GetRootFileName().Data()
3049  << endl;}
3050  }
3051  else
3052  {
3053  cout << "!TEcnaRun::WriteRootFile()> Writing FAILLED for file " << fCnaWrite->GetRootFileName().Data()
3054  << fTTBELL << endl;
3055  }
3056  }
3057  return ok_write;
3058 } // end of WriteRootFile()
3059 
3060 //--------------------------------------------------------------------
3061 //
3062 // WriteNewRootFile with argument
3063 // Called by TEcnaGui for results file of the Calculations method
3064 // analysis type and nb of samples changed, other arguments kept
3065 //
3066 //--------------------------------------------------------------------
3067 Bool_t TEcnaRun::WriteNewRootFile(const TString TypAna){
3068 //Write a new Root file. File name automatically generated by fCnaWrite->fMakeResultsFileName()
3069 //called here.
3070 
3071  Bool_t ok_write = kFALSE;
3072 
3078 
3079  fCnaWrite->fMakeResultsFileName(); // set fRootFileName, fRootFileNameShort
3082 
3083  const Text_t *FileShortName = (const Text_t *)fNewRootFileNameShort.Data();
3084 
3086  cout << "*TEcnaRun::WriteNewRootFile()> Results are going to be written in the ROOT file: " << endl
3087  << " " << fNewRootFileNameShort.Data() << endl;}
3088 
3089  ok_write = WriteRootFile(FileShortName, fNbSampForCalc);
3090 
3091  return ok_write;
3092 }
3093 
3094 //-------------------------------------------------------------------------
3095 //
3096 // Get the new ROOT file name (long and short)
3097 // (called by TEcnaGui in Calculations method)
3098 //
3099 //-------------------------------------------------------------------------
3102 
3103 //--------------------------------------------------------------------
3104 //
3105 // WriteRootFile with argument
3106 //
3107 //--------------------------------------------------------------------
3108 Bool_t TEcnaRun::WriteRootFile(const Text_t* name, Int_t& argNbSampWrite)
3109 {
3110 //Write the Root file
3111 
3112  const Text_t* file_name = name;
3113 
3114  Bool_t ok_write = kFALSE;
3115 
3116  if ( fOpenRootFile )
3117  {
3118  cout << "!TEcnaRun::WriteRootFile(...) *** ERROR ***> Writing on file already open."
3119  << fTTBELL << endl;
3120  }
3121  else
3122  {
3123  // List of the different element types and associated parameters as ordered in the ROOT file (smaller -> larger)
3124  // ==========
3125  //
3126  // WARNING *** HERE SIZES ARE THESE FOR THE BARREL (1700 Xtals) and for 10 samples ***
3127  //
3128  // Nb of Type of element Type Type Size Comment
3129  // elements Number Name
3130  //
3131  // 1 fMatHis(1,StexStin) ( 0) cTypNumbers 1*( 1, 68) = 68
3132 
3133  // 1 fMatHis(1,StexStin) (12) cTypAvPed 1*( 1, 68) = 68
3134  // 1 fMatHis(1,StexStin) ( 3) cTypAvTno 1*( 1, 68) = 68
3135  // 1 fMatHis(1,StexStin) ( 4) cTypAvLfn 1*( 1, 68) = 68
3136  // 1 fMatHis(1,StexStin) ( 5) cTypAvHfn 1*( 1, 68) = 68
3137  // 1 fMatHis(1,StexStin) (13) cTypAvMeanCorss 1*( 1, 68) = 68
3138  // 1 fMatHis(1,StexStin) (14) cTypAvSigCorss 1*( 1, 68) = 68
3139 
3140  // 1 fMatHis(1,StexEcha) (16) cTypPed 1*( 1,1700) = 1 700
3141  // 1 fMatHis(1,StexEcha) (17) cTypTno 1*( 1,1700) = 1 700
3142  // 1 fMatHis(1,StexEcha) (10) cTypMeanCorss 1*( 1,1700) = 1 700
3143  // 1 fMatHis(1,StexEcha) (18) cTypLfn 1*( 1,1700) = 1 700
3144  // 1 fMatHis(1,StexEcha) (19) cTypHfn 1*( 1,1700) = 1 700
3145  // 1 fMatHis(1,StexEcha) (11) cTypSigCorss 1*( 1,1700) = 1 700
3146 
3147  // 1 fMatMat(Stin,Stin) (23) cTypLFccMoStins 1*( 68, 68) = 4 624
3148  // 1 fMatMat(Stin,Stin) (24) cTypHFccMoStins 1*( 68, 68) = 4 624
3149 
3150  // 1 fMatHis(StexEcha, sample) (15) cTypNbOfEvts 1*(1700, 10) = 17 000
3151  // 1 fMatHis(StexEcha, sample) ( 1) cTypMSp 1*(1700, 10) = 17 000
3152  // 1 fMatHis(StexEcha, sample) ( 2) cTypSSp 1*(1700, 10) = 17 000
3153 
3154  // StexEcha fMatMat(sample, sample) ( 8) cTypCovCss 1700*( 10, 10) = 170 000
3155  // StexEcha fMatMat(sample, sample ( 9) cTypCorCss 1700*( 10, 10) = 170 000
3156 
3157  // StexEcha fMatHis(sample, bin_evt) (20) cTypAdcEvt, 1700*( 10, 150) = 2 550 000
3158 
3159  // 1 fMatMat(StexEcha, StexEcha) (21) cTypLfCov 1*(1700,1700) = 2 890 000
3160  // 1 fMatMat(StexEcha, StexEcha) (22) cTypLfCor 1*(1700,1700) = 2 890 000
3161 
3162  // 1 fMatMat(StexEcha, StexEcha) ( 6) cTypHfCov 1*(1700,1700) = 2 890 000 // (06/05/08)
3163  // 1 fMatMat(StexEcha, StexEcha) ( 7) cTypHfCor 1*(1700,1700) = 2 890 000 // (06/05/08)
3164 
3165 
3166  //......................................................................................................
3167 
3168  OpenRootFile(file_name, "RECREATE");
3169 
3170  TString typ_name = "?";
3171  Int_t v_nb_times = 0;
3172  Int_t v_dim_one = 0;
3173  Int_t v_dim_two = 0;
3174  Int_t v_size = 0;
3175  Int_t v_tot = 0;
3176  Int_t v_tot_writ = 0;
3177 
3178  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3179  //
3180  // ===> no general method and no translation to TEcnaWrite
3181  // because the fT1d.. and fT2d... arrays
3182  // are attributes of TEcnaRun (calls to the "TRootXXXX" methods)
3183  //
3184  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3185 
3186  //-------------------------- Stin numbers
3187  // 1 fMatHis(1,Stin) ( 0) cTypNumbers 1*( 1, 68) = 68
3188 
3189  Int_t MaxCar = fgMaxCar;
3190  typ_name.Resize(MaxCar);
3191  typ_name = "StinNumbers";
3192  v_nb_times = fFileHeader->fStinNumbersCalc;
3193  v_dim_one = 1;
3194  v_dim_two = fEcal->MaxStinEcnaInStex();
3195  v_size = v_nb_times*v_dim_one*v_dim_two;
3196  v_tot += v_size;
3197 
3199  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3200  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3201  << setw(9) << v_size;}
3202 
3203  for (Int_t i = 0; i < v_nb_times; i++)
3204  {
3205  if ( fTagStinNumbers[0] == 1 )
3206  {
3209  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3211  TRootStinNumbers();
3212  gCnaRootFile->fCnaResultsTree->Fill();
3213  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3214  }
3215  }
3216  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3217 
3218  //-------------------------- Average Pedestals (1 value per Stin)
3219  // 1 fMatHis(1, StexStin) (12) cTypAvPed 1*(1, 68) = 68
3220 
3221  MaxCar = fgMaxCar;
3222  typ_name.Resize(MaxCar);
3223  typ_name = "AvPed";
3224  v_nb_times = fFileHeader->fAvPedCalc;
3225  v_dim_one = 1;
3226  v_dim_two = fEcal->MaxStinEcnaInStex();
3227  v_size = v_nb_times*v_dim_one*v_dim_two;
3228  v_tot += v_size;
3229 
3231  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3232  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3233  << setw(9) << v_size;}
3234 
3235  for (Int_t i = 0; i < v_nb_times; i++)
3236  {
3237  if ( fTagAvPed[0] == 1 )
3238  {
3241  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3243  TRootAvPed();
3244  gCnaRootFile->fCnaResultsTree->Fill();
3245  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3246  }
3247  }
3248  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3249 
3250  //-------------------------- Average Total noise
3251  // StexEcha fMatHis(1, StexStin) ( 3) cTypAvTno 1*(1, 68) = 68
3252 
3253  MaxCar = fgMaxCar;
3254  typ_name.Resize(MaxCar);
3255  typ_name = "AvTno";
3256  v_nb_times = fFileHeader->fAvTnoCalc;
3257  v_dim_one = 1;
3258  v_dim_two = fEcal->MaxStinEcnaInStex();
3259  v_size = v_nb_times*v_dim_one*v_dim_two;
3260  v_tot += v_size;
3261 
3263  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3264  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3265  << setw(9) << v_size;}
3266 
3267  for (Int_t i = 0; i < v_nb_times; i++)
3268  {
3269  if ( fTagAvTno[0] == 1 )
3270  {
3273  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3275  TRootAvTno();
3276  gCnaRootFile->fCnaResultsTree->Fill();
3277  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3278  }
3279  }
3280  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3281 
3282  //-------------------------- Average Low frequency noise
3283  // 1 fMatHis(1, StexStin) ( 4) cTypAvLfn 1*(1, 68) = 68
3284 
3285  MaxCar = fgMaxCar;
3286  typ_name.Resize(MaxCar);
3287  typ_name = "AvLfn";
3288  v_nb_times = fFileHeader->fAvLfnCalc;
3289  v_dim_one = 1;
3290  v_dim_two = fEcal->MaxStinEcnaInStex();
3291  v_size = v_nb_times*v_dim_one*v_dim_two;
3292  v_tot += v_size;
3293 
3295  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3296  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3297  << setw(9) << v_size;}
3298 
3299  for (Int_t i = 0; i < v_nb_times; i++)
3300  {
3301  if ( fTagAvLfn[0] == 1 )
3302  {
3305  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3307  TRootAvLfn();
3308  gCnaRootFile->fCnaResultsTree->Fill();
3309  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3310  }
3311  }
3312  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3313 
3314  //-------------------------- Average High frequency noise
3315  // 1 fMatHis(1, StexStin) ( 5) cTypAvHfn 1*(1, 68) = 68
3316 
3317  MaxCar = fgMaxCar;
3318  typ_name.Resize(MaxCar);
3319  typ_name = "AvHfn";
3320  v_nb_times = fFileHeader->fAvHfnCalc;
3321  v_dim_one = 1;
3322  v_dim_two = fEcal->MaxStinEcnaInStex();
3323  v_size = v_nb_times*v_dim_one*v_dim_two;
3324  v_tot += v_size;
3325 
3327  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3328  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3329  << setw(9) << v_size;}
3330 
3331  for (Int_t i = 0; i < v_nb_times; i++)
3332  {
3333  if ( fTagAvHfn[0] == 1 )
3334  {
3337  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3339  TRootAvHfn();
3340  gCnaRootFile->fCnaResultsTree->Fill();
3341  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3342  }
3343  }
3344  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3345 
3346  //-------------------------- Average mean cor(s,s)
3347  // 1 fMatHis(1, StexStin) (13) cTypAvMeanCorss 1*(1, 68) = 68
3348 
3349  MaxCar = fgMaxCar;
3350  typ_name.Resize(MaxCar);
3351  typ_name = "AvMeanCorss";
3352  v_nb_times = fFileHeader->fAvMeanCorssCalc;
3353  v_dim_one = 1;
3354  v_dim_two = fEcal->MaxStinEcnaInStex();
3355  v_size = v_nb_times*v_dim_one*v_dim_two;
3356  v_tot += v_size;
3357 
3359  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3360  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3361  << setw(9) << v_size;}
3362 
3363  for (Int_t i = 0; i < v_nb_times; i++)
3364  {
3365  if ( fTagAvMeanCorss[0] == 1 )
3366  {
3369  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3371  TRootAvEvCorss();
3372  gCnaRootFile->fCnaResultsTree->Fill();
3373  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3374  }
3375  }
3376  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3377 
3378  //-------------------------- Average sigma of cor(s,s)
3379  // 1 fMatHis(1, StexStin) (14) cTypAvSigCorss 1*(1, 68) = 68
3380 
3381  MaxCar = fgMaxCar;
3382  typ_name.Resize(MaxCar);
3383  typ_name = "AvSigCorss";
3384  v_nb_times = fFileHeader->fAvSigCorssCalc;
3385  v_dim_one = 1;
3386  v_dim_two = fEcal->MaxStinEcnaInStex();
3387  v_size = v_nb_times*v_dim_one*v_dim_two;
3388  v_tot += v_size;
3389 
3391  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3392  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3393  << setw(9) << v_size;}
3394 
3395  for (Int_t i = 0; i < v_nb_times; i++)
3396  {
3397  if ( fTagAvSigCorss[0] == 1 )
3398  {
3401  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3403  TRootAvSigCorss();
3404  gCnaRootFile->fCnaResultsTree->Fill();
3405  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3406  }
3407  }
3408  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3409 
3410  //-------------------------- Expectation values of the expectation values of the samples (pedestals)
3411  // 1 fMatHis(1,StexEcha) (16) cTypPed 1*( 1,1700) = 1 700
3412 
3413  MaxCar = fgMaxCar;
3414  typ_name.Resize(MaxCar);
3415  typ_name = "Ped";
3416  v_nb_times = fFileHeader->fPedCalc;
3417  v_dim_one = 1;
3418  v_dim_two = fEcal->MaxCrysEcnaInStex();
3419  v_size = v_nb_times*v_dim_one*v_dim_two;
3420  v_tot += v_size;
3421 
3423  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3424  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3425  << setw(9) << v_size;}
3426 
3427  for (Int_t i = 0; i < v_nb_times; i++)
3428  {
3429  if ( fTagPed[0] == 1 )
3430  {
3433  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3435  TRootPed();
3436  gCnaRootFile->fCnaResultsTree->Fill();
3437  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3438  }
3439  }
3440  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3441 
3442  //-------------------------- Expectation values of the sigmas the samples
3443  // 1 fMatHis(1,StexEcha) (17) cTypTno 1*( 1,1700) = 1 700
3444 
3445  MaxCar = fgMaxCar;
3446  typ_name.Resize(MaxCar);
3447  typ_name = "Tno";
3448  v_nb_times = fFileHeader->fTnoCalc;
3449  v_dim_one = 1;
3450  v_dim_two = fEcal->MaxCrysEcnaInStex();
3451  v_size = v_nb_times*v_dim_one*v_dim_two;
3452  v_tot += v_size;
3453 
3455  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3456  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3457  << setw(9) << v_size;}
3458 
3459  for (Int_t i = 0; i < v_nb_times; i++)
3460  {
3461  if ( fTagTno[0] == 1 )
3462  {
3465  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3467  TRootTno();
3468  gCnaRootFile->fCnaResultsTree->Fill();
3469  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3470  }
3471  }
3472  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3473 
3474  //-------------------------- Expectation values of the correlations between the samples
3475  // 1 fMatHis(1,StexEcha) (10) cTypMeanCorss 1*( 1,1700) = 1 700
3476 
3477  MaxCar = fgMaxCar;
3478  typ_name.Resize(MaxCar);
3479  typ_name = "MeanCorss";
3480  v_nb_times = fFileHeader->fMeanCorssCalc;
3481  v_dim_one = 1;
3482  v_dim_two = fEcal->MaxCrysEcnaInStex();
3483  v_size = v_nb_times*v_dim_one*v_dim_two;
3484  v_tot += v_size;
3485 
3487  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3488  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3489  << setw(9) << v_size;}
3490 
3491  for (Int_t i = 0; i < v_nb_times; i++)
3492  {
3493  if ( fTagMeanCorss[0] == 1 )
3494  {
3497  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3499  TRootMeanCorss();
3500  gCnaRootFile->fCnaResultsTree->Fill();
3501  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3502  }
3503  }
3504  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3505 
3506  //-------------------------- Sigmas of the expectation values of the samples
3507  // 1 fMatHis(1,StexEcha) (18) cTypLfn 1*( 1,1700) = 1 700
3508 
3509  MaxCar = fgMaxCar;
3510  typ_name.Resize(MaxCar);
3511  typ_name = "Lfn";
3512  v_nb_times = fFileHeader->fLfnCalc;
3513  v_dim_one = 1;
3514  v_dim_two = fEcal->MaxCrysEcnaInStex();
3515  v_size = v_nb_times*v_dim_one*v_dim_two;
3516  v_tot += v_size;
3517 
3519  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3520  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3521  << setw(9) << v_size;}
3522 
3523  for (Int_t i = 0; i < v_nb_times; i++)
3524  {
3525  if ( fTagLfn[0] == 1 )
3526  {
3529  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3531  TRootLfn();
3532  gCnaRootFile->fCnaResultsTree->Fill();
3533  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3534  }
3535  }
3536  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3537 
3538  //-------------------------- Sigmas of the sigmas of the samples
3539  // 1 fMatHis(1,StexEcha) (19) cTypHfn 1*( 1,1700) = 1 700
3540 
3541  MaxCar = fgMaxCar;
3542  typ_name.Resize(MaxCar);
3543  typ_name = "Hfn";
3544  v_nb_times = fFileHeader->fHfnCalc;
3545  v_dim_one = 1;
3546  v_dim_two = fEcal->MaxCrysEcnaInStex();
3547  v_size = v_nb_times*v_dim_one*v_dim_two;
3548  v_tot += v_size;
3549 
3551  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3552  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3553  << setw(9) << v_size;}
3554 
3555  for (Int_t i = 0; i < v_nb_times; i++)
3556  {
3557  if ( fTagHfn[0] == 1 )
3558  {
3561  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3563  TRootHfn();
3564  gCnaRootFile->fCnaResultsTree->Fill();
3565  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3566  }
3567  }
3568  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3569 
3570  //-------------------------- Sigmas of the correlations between the samples
3571  // 1 fMatHis(1,StexEcha) (11) cTypSigCorss 1*( 1,1700) = 1 700
3572 
3573  MaxCar = fgMaxCar;
3574  typ_name.Resize(MaxCar);
3575  typ_name = "SigCorss";
3576  v_nb_times = fFileHeader->fSigCorssCalc;
3577  v_dim_one = 1;
3578  v_dim_two = fEcal->MaxCrysEcnaInStex();
3579  v_size = v_nb_times*v_dim_one*v_dim_two;
3580  v_tot += v_size;
3581 
3583  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3584  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3585  << setw(9) << v_size;}
3586 
3587  for (Int_t i = 0; i < v_nb_times; i++)
3588  {
3589  if ( fTagSigCorss[0] == 1 )
3590  {
3593  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3595  TRootSigCorss();
3596  gCnaRootFile->fCnaResultsTree->Fill();
3597  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3598  }
3599  }
3600  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3601 
3602  //----- Mean Covariances between StexEchas (averaged over samples) for all (Stin_X,Stin_Y)
3603  // 1 fMatMat(Stin,Stin) (23) cTypLFccMoStins 1*( 68, 68) = 4 624
3604 
3605  MaxCar = fgMaxCar;
3606  typ_name.Resize(MaxCar);
3607  typ_name = "LFccMoStins";
3608  v_nb_times = fFileHeader->fLFccMoStinsCalc;
3609  v_dim_one = fEcal->MaxStinEcnaInStex();
3610  v_dim_two = fEcal->MaxStinEcnaInStex();
3611  v_size = v_nb_times*v_dim_one*v_dim_two;
3612  v_tot += v_size;
3613 
3615  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3616  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3617  << setw(9) << v_size;}
3618 
3619  for (Int_t i = 0; i < v_nb_times; i++)
3620  {
3621  if ( fTagLFccMoStins[0] == 1 )
3622  {
3625  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3627  TRootLFccMoStins();
3628  gCnaRootFile->fCnaResultsTree->Fill();
3629  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3630  }
3631  }
3632  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3633 
3634  //----- Mean Correlations between StexEchas (averaged over samples) for all (Stin_X,Stin_Y)
3635  // 1 fMatMat(Stin,Stin) (24) cTypHFccMoStins 1*( 68, 68) = 4 624
3636 
3637  MaxCar = fgMaxCar;
3638  typ_name.Resize(MaxCar);
3639  typ_name = "HFccMoStins";
3640  v_nb_times = fFileHeader->fHFccMoStinsCalc;
3641  v_dim_one = fEcal->MaxStinEcnaInStex();
3642  v_dim_two = fEcal->MaxStinEcnaInStex();
3643  v_size = v_nb_times*v_dim_one*v_dim_two;
3644  v_tot += v_size;
3645 
3647  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3648  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3649  << setw(9) << v_size;}
3650 
3651  for (Int_t i = 0; i < v_nb_times; i++)
3652  {
3653  if ( fTagHFccMoStins[0] == 1 )
3654  {
3657  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3659  TRootHFccMoStins();
3660  gCnaRootFile->fCnaResultsTree->Fill();
3661  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3662  }
3663  }
3664  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3665 
3666  //-------------------------- Numbers of found events (NbOfEvts)
3667  // 1 fMatHis(StexEcha, sample) (15) cTypNbOfEvts 1*(1700, 10) = 17 000
3668 
3669  MaxCar = fgMaxCar;
3670  typ_name.Resize(MaxCar);
3671  typ_name = "NbOfEvts";
3672  v_nb_times = fFileHeader->fNbOfEvtsCalc;
3673  v_dim_one = fEcal->MaxCrysEcnaInStex();
3674  v_dim_two = argNbSampWrite;
3675  v_size = v_nb_times*v_dim_one*v_dim_two;
3676  v_tot += v_size;
3677 
3679  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3680  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3681  << setw(9) << v_size;}
3682 
3683  for (Int_t i = 0; i < v_nb_times; i++)
3684  {
3685  if ( fTagNbOfEvts[0] == 1 )
3686  {
3689  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3691  TRootNbOfEvts(argNbSampWrite);
3692  gCnaRootFile->fCnaResultsTree->Fill();
3693  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3694  }
3695  }
3696  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3697 
3698  //-------------------------- Expectation values of the samples
3699  // 1 fMatHis(StexEcha, sample) ( 1) cTypMSp 1*(1700, 10) = 17 000
3700 
3701  MaxCar = fgMaxCar;
3702  typ_name.Resize(MaxCar);
3703  typ_name = "MSp";
3704  v_nb_times = fFileHeader->fMSpCalc;
3705  v_dim_one = fEcal->MaxCrysEcnaInStex();
3706  v_dim_two = argNbSampWrite;
3707  v_size = v_nb_times*v_dim_one*v_dim_two;
3708  v_tot += v_size;
3709 
3711  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3712  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3713  << setw(9) << v_size;}
3714 
3715  for (Int_t i = 0; i < v_nb_times; i++)
3716  {
3717  if ( fTagMSp[0] == 1 )
3718  {
3721  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3723  TRootMSp(argNbSampWrite);
3724  gCnaRootFile->fCnaResultsTree->Fill();
3725  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3726  }
3727  }
3728  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3729 
3730  //-------------------------- Sigmas of the samples
3731  // 1 fMatHis(StexEcha, sample) ( 2) cTypSSp 1*(1700, 10) = 17 000
3732 
3733  MaxCar = fgMaxCar;
3734  typ_name.Resize(MaxCar);
3735  typ_name = "SSp";
3736  v_nb_times = fFileHeader->fSSpCalc;
3737  v_dim_one = fEcal->MaxCrysEcnaInStex();
3738  v_dim_two = argNbSampWrite;
3739  v_size = v_nb_times*v_dim_one*v_dim_two;
3740  v_tot += v_size;
3741 
3743  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3744  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3745  << setw(9) << v_size;}
3746 
3747  for (Int_t i = 0; i < v_nb_times; i++)
3748  {
3749  if ( fTagSSp[0] == 1 )
3750  {
3753  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3755  TRootSSp(argNbSampWrite);
3756  gCnaRootFile->fCnaResultsTree->Fill();
3757  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3758  }
3759  }
3760  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3761 
3762  //-------------------------- Covariances between samples
3763 
3764  // StexEcha fMatMat(sample, sample) ( 8) cTypCovCss 1700*( 10, 10) = 170 000
3765 
3766  MaxCar = fgMaxCar;
3767  typ_name.Resize(MaxCar);
3768  typ_name = "CovCss";
3769  v_nb_times = fFileHeader->fCovCssCalc;
3770  v_dim_one = argNbSampWrite;
3771  v_dim_two = argNbSampWrite;
3772  v_size = v_nb_times*v_dim_one*v_dim_two;
3773  v_tot += v_size;
3774 
3776  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3777  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3778  << setw(9) << v_size;}
3779 
3780  for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
3781  {
3782  if ( fTagCovCss[i0StexEcha] == 1 )
3783  {
3785  gCnaRootFile->fCnaIndivResult->fIthElement = i0StexEcha;
3786  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3788  TRootCovCss(i0StexEcha, argNbSampWrite);
3789  gCnaRootFile->fCnaResultsTree->Fill();
3790  if( i0StexEcha == 0 && fFlagPrint == fCodePrintAllComments)
3791  {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3792  }
3793  }
3794  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3795 
3796  //-------------------------- Correlations between samples
3797  // StexEcha fMatMat(sample, sample) ( 9) cTypCorCss 1700*( 10, 10) = 170 000
3798 
3799  MaxCar = fgMaxCar;
3800  typ_name.Resize(MaxCar);
3801  typ_name = "CorCss";
3802  v_nb_times = fFileHeader->fCorCssCalc;
3803  v_dim_one = argNbSampWrite;
3804  v_dim_two = argNbSampWrite;
3805  v_size = v_nb_times*v_dim_one*v_dim_two;
3806  v_tot += v_size;
3807 
3809  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3810  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3811  << setw(9) << v_size;}
3812 
3813  for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
3814  {
3815  if ( fTagCorCss[i0StexEcha] == 1 )
3816  {
3818  gCnaRootFile->fCnaIndivResult->fIthElement = i0StexEcha;
3819  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3821  TRootCorCss(i0StexEcha, argNbSampWrite);
3822  gCnaRootFile->fCnaResultsTree->Fill();
3823  if( i0StexEcha == 0 && fFlagPrint == fCodePrintAllComments)
3824  {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3825  }
3826  }
3827  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3828 
3829  //-------------------------- Samples as a function of event = events distributions
3830  // StexEcha fMatHis(sample, bins) (20) cTypAdcEvt, 1700*( 10, 150) = 2 550 000
3831 
3832  MaxCar = fgMaxCar;
3833  typ_name.Resize(MaxCar);
3834  typ_name = "AdcEvt";
3835  v_nb_times = fFileHeader->fAdcEvtCalc;
3836  v_dim_one = argNbSampWrite;
3837  v_dim_two = fFileHeader->fReqNbOfEvts;
3838  v_size = v_nb_times*v_dim_one*v_dim_two;
3839  v_tot += v_size;
3840 
3842  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3843  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3844  << setw(9) << v_size;}
3845 
3846  for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
3847  {
3848  if ( fTagAdcEvt[i0StexEcha] == 1 )
3849  {
3851  gCnaRootFile->fCnaIndivResult->fIthElement = i0StexEcha;
3852  gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
3854  TRootAdcEvt(i0StexEcha, argNbSampWrite);
3855  gCnaRootFile->fCnaResultsTree->Fill();
3856  if( i0StexEcha == 0 && fFlagPrint == fCodePrintAllComments )
3857  {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3858  }
3859  }
3860  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3861 
3862  //-------------------------- Low Frequency Covariances between StexEchas
3863  // sample fMatMat(StexEcha, StexEcha) (21) cTypLfCov 1*(1700,1700) = 2 890 000
3864 
3865  MaxCar = fgMaxCar;
3866  typ_name.Resize(MaxCar);
3867  typ_name = "LfCov";
3868  v_nb_times = fFileHeader->fLfCovCalc;
3869  v_dim_one = fEcal->MaxCrysEcnaInStex();
3870  v_dim_two = fEcal->MaxCrysEcnaInStex();
3871  v_size = v_nb_times*v_dim_one*v_dim_two;
3872  v_tot += v_size;
3873 
3875  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3876  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3877  << setw(9) << v_size;}
3878 
3879  for (Int_t i = 0; i < v_nb_times; i++)
3880  { //=================================== Record type EB
3881  if ( fTagLfCov[0] == 1 )
3882  {
3885  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3887  TRootLfCov();
3888  gCnaRootFile->fCnaResultsTree->Fill();
3889  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3890  }
3891  }
3892  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3893 
3894  //-------------------------- Low Frequency Correlations between StexEchas
3895  // sample fMatMat(StexEcha, StexEcha) (22) cTypLfCor 1*(1700,1700) = 2 890 000
3896 
3897  MaxCar = fgMaxCar;
3898  typ_name.Resize(MaxCar);
3899  typ_name = "LfCor";
3900  v_nb_times = fFileHeader->fLfCorCalc;
3901  v_dim_one = fEcal->MaxCrysEcnaInStex();
3902  v_dim_two = fEcal->MaxCrysEcnaInStex();
3903  v_size = v_nb_times*v_dim_one*v_dim_two;
3904  v_tot += v_size;
3905 
3907  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3908  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3909  << setw(9) << v_size;}
3910 
3911  for (Int_t i = 0; i < v_nb_times; i++)
3912  {
3913  if ( fTagLfCor[0] == 1 )
3914  {
3917  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3919  TRootLfCor();
3920  gCnaRootFile->fCnaResultsTree->Fill();
3921  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3922  }
3923  }
3924  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3925 
3926  //-------------------------- High Frequency Covariances between StexEchas
3927  // sample fMatMat(StexEcha, StexEcha) (6) cTypHfCov 1*(1700,1700) = 2 890 000
3928 
3929  MaxCar = fgMaxCar;
3930  typ_name.Resize(MaxCar);
3931  typ_name = "HfCov";
3932  v_nb_times = fFileHeader->fHfCovCalc;
3933  v_dim_one = fEcal->MaxCrysEcnaInStex();
3934  v_dim_two = fEcal->MaxCrysEcnaInStex();
3935  v_size = v_nb_times*v_dim_one*v_dim_two;
3936  v_tot += v_size;
3937 
3939  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3940  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3941  << setw(9) << v_size;}
3942 
3943  for (Int_t i = 0; i < v_nb_times; i++)
3944  {
3945  if ( fTagHfCov[0] == 1 )
3946  {
3949  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3951  TRootHfCov();
3952  gCnaRootFile->fCnaResultsTree->Fill();
3953  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3954  }
3955  }
3956  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3957 
3958  //-------------------------- High Frequency Correlations between StexEchas
3959  // sample fMatMat(StexEcha, StexEcha) (7) cTypHfCor 1*(1700,1700) = 2 890 000
3960 
3961  MaxCar = fgMaxCar;
3962  typ_name.Resize(MaxCar);
3963  typ_name = "HfCor";
3964  v_nb_times = fFileHeader->fHfCorCalc;
3965  v_dim_one = fEcal->MaxCrysEcnaInStex();
3966  v_dim_two = fEcal->MaxCrysEcnaInStex();
3967  v_size = v_nb_times*v_dim_one*v_dim_two;
3968  v_tot += v_size;
3969 
3971  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
3972  << " * (" << setw(4) << v_dim_one << "," << setw(4) << v_dim_two << ") = "
3973  << setw(9) << v_size;}
3974 
3975  for (Int_t i = 0; i < v_nb_times; i++)
3976  {
3977  if ( fTagHfCor[0] == 1 )
3978  {
3981  gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
3983  TRootHfCor();
3984  gCnaRootFile->fCnaResultsTree->Fill();
3985  if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
3986  }
3987  }
3988  if(fFlagPrint == fCodePrintAllComments){cout << endl;}
3989 
3990  //---------------------------------------------- WRITING
3991  //...................................... file
3992  gCnaRootFile->fRootFile->Write();
3993  //...................................... header
3994  fFileHeader->Write();
3995 
3996  //...................................... status message
3998  cout << "*TEcnaRun::WriteRootFile(...)> " << setw(20) << "TOTAL: "
3999  << setw(21) << "CALCULATED = " << setw(9) << v_tot
4000  << " => WRITTEN ON FILE = " << setw(9) << v_tot_writ << endl;}
4001 
4003  cout << "*TEcnaRun::WriteRootFile(...)> Write OK in file " << file_name << " in directory:" << endl
4004  << " " << fCnaParPaths->ResultsRootFilePath().Data()
4005  << endl;}
4006 
4007  ok_write = kTRUE;
4008 
4009  //...................................... close
4010  CloseRootFile(file_name);
4011  }
4012  return ok_write;
4013 } //-------------- End of WriteRootFile(...) -----------------------
4014 
4015 //======================== "PREPA FILL" METHODS ===========================
4016 
4017 //-------------------------------------------------------------------------
4018 //
4019 // Prepa Fill Stin numbers as a function of the Stin index
4020 // (for writing in the ROOT file)
4021 //
4022 //-------------------------------------------------------------------------
4024 {
4025  if (fTagStinNumbers[0] == 1 )
4026  {
4027  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4028  {
4029  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4030  fT1d_StexStinFromIndex[j0StexStinEcna];
4031  }
4032  }
4033 }
4034 
4035 //-------------------------------------------------------------------------
4036 //
4037 // Prepa Fill last evt numbers for all the (StexEcha,sample)
4038 // (for writing in the ROOT file)
4039 //
4040 //-------------------------------------------------------------------------
4041 void TEcnaRun::TRootNbOfEvts(const Int_t& argNbSampWrite)
4042 {
4043  if (fTagNbOfEvts[0] == 1 )
4044  {
4045  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4046  {
4047  for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
4048  {
4049  gCnaRootFile->fCnaIndivResult->fMatHis(j0StexEcha, i0Sample) =
4050  fT2d_NbOfEvts[j0StexEcha][i0Sample];
4051  }
4052  }
4053  }
4054 }
4055 
4056 //-------------------------------------------------------------------------
4057 //
4058 // Prepa Fill histogram of samples as a function of event
4059 // (for writing in the ROOT file)
4060 //
4061 //-------------------------------------------------------------------------
4062 void TEcnaRun::TRootAdcEvt(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
4063 {
4064  if (fTagAdcEvt[user_StexEcha] == 1 )
4065  {
4066  for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
4067  {
4068  //...................... all the bins set to zero
4069  for (Int_t j_bin = 0; j_bin < fFileHeader->fReqNbOfEvts; j_bin++)
4070  {
4071  gCnaRootFile->fCnaIndivResult->fMatHis(i0Sample, j_bin) = (Double_t)0.;
4072  }
4073  //...................... fill the non-zero bins
4074  for (Int_t j_bin = 0; j_bin < fFileHeader->fReqNbOfEvts; j_bin++)
4075  {
4076  gCnaRootFile->fCnaIndivResult->fMatHis(i0Sample, j_bin) =
4077  fT3d_AdcValues[user_StexEcha][i0Sample][j_bin];
4078  }
4079  }
4080  }
4081 }
4082 
4083 //-------------------------------------------------------------------------
4084 //
4085 // Prepa Fill expectation values of the samples for all the StexEchas
4086 // (for writing in the ROOT file)
4087 //
4088 //-------------------------------------------------------------------------
4089 void TEcnaRun::TRootMSp(const Int_t& argNbSampWrite)
4090 {
4091  if (fTagMSp[0] == 1 )
4092  {
4093  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4094  {
4095  for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
4096  {
4097  gCnaRootFile->fCnaIndivResult->fMatHis( j0StexEcha, i0Sample) =
4098  fT2d_ev[j0StexEcha][i0Sample];
4099  }
4100  }
4101  }
4102 }
4103 
4104 //-------------------------------------------------------------------------
4105 //
4106 // Prepa Fill sigmas of the samples for all the StexEchas
4107 // (for writing in the ROOT file)
4108 //
4109 //-------------------------------------------------------------------------
4110 void TEcnaRun::TRootSSp(const Int_t& argNbSampWrite)
4111 {
4112  if (fTagSSp[0] == 1 )
4113  {
4114  for (Int_t j0StexEcha=0; j0StexEcha<fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4115  {
4116  for (Int_t i0Sample=0; i0Sample<argNbSampWrite; i0Sample++)
4117  {
4118  gCnaRootFile->fCnaIndivResult->fMatHis(j0StexEcha, i0Sample) =
4119  fT2d_sig[j0StexEcha][i0Sample];
4120  }
4121  }
4122  }
4123 }
4124 
4125 //-------------------------------------------------------------------------
4126 //
4127 // Prepa Fill mean covariances between StexEchas, mean over samples
4128 // for all (Stin_X, Stin_Y)
4129 // (for writing in ROOT file)
4130 //
4131 //-------------------------------------------------------------------------
4133 {
4134  if (fTagLFccMoStins[0] == 1 )
4135  {
4136  for (Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
4137  {
4138  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4139  {
4140  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexStinEcna, j0StexStinEcna) =
4141  fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna];
4142  }
4143  }
4144  }
4145 }
4146 
4147 //-------------------------------------------------------------------------
4148 //
4149 // Prepa Fill mean correlations between StexEchas, mean over samples
4150 // for all (Stin_X, Stin_Y)
4151 // (for writing in ROOT file)
4152 //
4153 //-------------------------------------------------------------------------
4155 {
4156  if (fTagHFccMoStins[0] == 1 )
4157  {
4158  for (Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
4159  {
4160  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4161  {
4162  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexStinEcna, j0StexStinEcna) =
4163  fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna];
4164  }
4165  }
4166  }
4167 }
4168 
4169 //-------------------------------------------------------------------------
4170 //
4171 // Prepa Fill ADC distributions of the samples for all the StexEchas
4172 // (for writing in the ROOT file)
4173 //
4174 //-------------------------------------------------------------------------
4176 {
4177  if (fTagAvTno[0] == 1 )
4178  {
4179  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4180  {
4181  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4182  fT1d_av_totn[j0StexStinEcna];
4183  }
4184  }
4185 }
4186 //-------------------------------------------------------------------------
4187 //
4188 // Prepa Fill ADC distributions xmin of the samples for all the StexEchas
4189 // (for writing in the ROOT file)
4190 //
4191 //-------------------------------------------------------------------------
4193 {
4194  if (fTagAvLfn[0] == 1 )
4195  {
4196  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4197  {
4198  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4199  fT1d_av_lofn[j0StexStinEcna];
4200  }
4201  }
4202 }
4203 
4204 //-------------------------------------------------------------------------
4205 //
4206 // Prepa Fill ADC distributions xmax of the samples for all the StexEchas
4207 // (for writing in the ROOT file)
4208 //
4209 //-------------------------------------------------------------------------
4211 {
4212  if (fTagAvHfn[0] == 1 )
4213  {
4214  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4215  {
4216  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4217  fT1d_av_hifn[j0StexStinEcna];
4218  }
4219  }
4220 }
4221 
4222 //-------------------------------------------------------------------------
4223 //
4224 // Prepa Fill Low Frequency covariances between StexEchas
4225 // (for writing in ROOT file)
4226 //
4227 //-------------------------------------------------------------------------
4229 {
4230  if (fTagLfCov[0] == 1 )
4231  {
4232  for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
4233  {
4234  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4235  {
4236  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
4237  fT2d_lf_cov[i0StexEcha][j0StexEcha];
4238  }
4239  }
4240  }
4241 }
4242 
4243 //-------------------------------------------------------------------------
4244 //
4245 // Prepa Fill Low Frequency correlations between StexEchas
4246 // (for writing in ROOT file)
4247 //
4248 //-------------------------------------------------------------------------
4250 {
4251  if (fTagLfCor[0] == 1 )
4252  {
4253  for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
4254  {
4255  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4256  {
4257  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
4258  fT2d_lf_cor[i0StexEcha][j0StexEcha];
4259  }
4260  }
4261  }
4262 }
4263 
4264 //-------------------------------------------------------------------------
4265 //
4266 // Prepa Fill High Frequency covariances between StexEchas
4267 // (for writing in ROOT file)
4268 //
4269 //-------------------------------------------------------------------------
4271 {
4272  if (fTagHfCov[0] == 1 )
4273  {
4274  for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
4275  {
4276  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4277  {
4278  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
4279  fT2d_hf_cov[i0StexEcha][j0StexEcha];
4280  }
4281  }
4282  }
4283 }
4284 
4285 //-------------------------------------------------------------------------
4286 //
4287 // Prepa Fill High Frequency correlations between StexEchas
4288 // (for writing in ROOT file)
4289 //
4290 //-------------------------------------------------------------------------
4292 {
4293  if (fTagHfCor[0] == 1 )
4294  {
4295  for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
4296  {
4297  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4298  {
4299  gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
4300  fT2d_hf_cor[i0StexEcha][j0StexEcha];
4301  }
4302  }
4303  }
4304 }
4305 
4306 
4307 //-------------------------------------------------------------------------
4308 //
4309 // Prepa Fill covariances between samples for a given StexEcha
4310 // (for writing in ROOT file)
4311 //
4312 //-------------------------------------------------------------------------
4313 void TEcnaRun::TRootCovCss(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
4314 {
4315  if (fTagCovCss[user_StexEcha] == 1 )
4316  {
4317  for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
4318  {
4319  for (Int_t j0Sample = 0; j0Sample < argNbSampWrite; j0Sample++)
4320  {
4321  gCnaRootFile->fCnaIndivResult->fMatMat(i0Sample, j0Sample) =
4322  fT3d_cov_ss[user_StexEcha][i0Sample][j0Sample];
4323  }
4324  }
4325  }
4326 }
4327 
4328 //-------------------------------------------------------------------------
4329 //
4330 // Prepa Fill correlations between samples for a given StexEcha
4331 // (for writing in ROOT file)
4332 //
4333 //-------------------------------------------------------------------------
4334 void TEcnaRun::TRootCorCss(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
4335 {
4336  if (fTagCorCss[user_StexEcha] == 1 )
4337  {
4338  for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
4339  {
4340  for (Int_t j0Sample = 0; j0Sample < argNbSampWrite; j0Sample++)
4341  {
4342  gCnaRootFile->fCnaIndivResult->fMatMat(i0Sample, j0Sample) =
4343  fT3d_cor_ss[user_StexEcha][i0Sample][j0Sample];
4344  }
4345  }
4346  }
4347 }
4348 
4349 //-------------------------------------------------------------------------
4350 //
4351 // Prepa Fill expectation values of the expectation values of the samples
4352 // for all the StexEchas
4353 // (for writing in ROOT file)
4354 //
4355 //-------------------------------------------------------------------------
4357 {
4358  if (fTagPed[0] == 1 )
4359  {
4360  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4361  {
4362  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4363  fT1d_ev_ev[j0StexEcha];
4364  }
4365  }
4366 }
4367 //-------------------------------------------------------------------------
4368 //
4369 // Prepa Fill expectation values of the sigmas of the samples
4370 // for all the StexEchas
4371 // (for writing in ROOT file)
4372 //
4373 //-------------------------------------------------------------------------
4375 {
4376  if (fTagTno[0] == 1 )
4377  {
4378  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4379  {
4380  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4381  fT1d_evsamp_of_sigevt[j0StexEcha];
4382  }
4383  }
4384 }
4385 
4386 //-------------------------------------------------------------------------
4387 //
4388 // Prepa Fill expectation values of the (sample,sample) correlations
4389 // for all the StexEchas
4390 // (for writing in ROOT file)
4391 //
4392 //-------------------------------------------------------------------------
4394 {
4395  if (fTagMeanCorss[0] == 1 )
4396  {
4397  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4398  {
4399  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4400  fT1d_ev_cor_ss[j0StexEcha];
4401  }
4402  }
4403 }
4404 
4405 //-------------------------------------------------------------------------
4406 //
4407 // Prepa Fill sigmas of the expectation values of the samples
4408 // for all the StexEchas
4409 // (for writing in ROOT file)
4410 //
4411 //-------------------------------------------------------------------------
4413 {
4414  if (fTagLfn[0] == 1 )
4415  {
4416  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4417  {
4418  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4419  fT1d_sigevt_of_evsamp[j0StexEcha];
4420  }
4421  }
4422 }
4423 
4424 //-------------------------------------------------------------------------
4425 //
4426 // Prepa Fill sigmas of the expectation values of the sigmas
4427 // for all the StexEchas
4428 // (for writing in ROOT file)
4429 //
4430 //-------------------------------------------------------------------------
4432 {
4433  if (fTagHfn[0] == 1 )
4434  {
4435  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4436  {
4437  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4438  fT1d_evevt_of_sigsamp[j0StexEcha];
4439  }
4440  }
4441 }
4442 
4443 //-------------------------------------------------------------------------
4444 //
4445 // Prepa Fill sigmas of the (sample,sample) correlations
4446 // for all the StexEchas
4447 // (for writing in ROOT file)
4448 //
4449 //-------------------------------------------------------------------------
4451 {
4452  if (fTagSigCorss[0] == 1 )
4453  {
4454  for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
4455  {
4456  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
4457  fT1d_sig_cor_ss[j0StexEcha];
4458  }
4459  }
4460 }
4461 
4462 //-------------------------------------------------------------------------
4463 //
4464 // Prepa Fill Average Pedestals
4465 // for all the StexStins
4466 // (for writing in ROOT file)
4467 //
4468 //-------------------------------------------------------------------------
4470 {
4471  if (fTagAvPed[0] == 1 )
4472  {
4473  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4474  {
4475  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4476  fT1d_av_mped[j0StexStinEcna];
4477  }
4478  }
4479 }
4480 
4481 //-------------------------------------------------------------------------
4482 //
4483 // Prepa Fill
4484 //
4485 // (for writing in ROOT file)
4486 //
4487 //-------------------------------------------------------------------------
4489 {
4490  if (fTagAvMeanCorss[0] == 1 ) // test 1st elt only since global calc
4491  {
4492  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4493  {
4494  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4495  fT1d_av_ev_corss[j0StexStinEcna];
4496  }
4497  }
4498 }
4499 
4500 //-------------------------------------------------------------------------
4501 //
4502 // Prepa Fill
4503 //
4504 // (for writing in ROOT file)
4505 //
4506 //-------------------------------------------------------------------------
4508 {
4509  if (fTagAvSigCorss[0] == 1 ) // test 1st elt only since global calc
4510  {
4511  for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
4512  {
4513  gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
4514  fT1d_av_sig_corss[j0StexStinEcna];
4515  }
4516  }
4517 }
4518 
4519 //=========================================================================
4520 //
4521 // METHODS TO SET FLAGS TO PRINT (OR NOT) COMMENTS (DEBUG)
4522 //
4523 //=========================================================================
4524 
4526 {
4527 // Set flags to authorize printing of some comments concerning initialisations (default)
4528 
4530  cout << "*TEcnaRun::PrintComments()> Warnings and some comments on init will be printed" << endl;
4531 }
4532 
4534 {
4535 // Set flags to authorize printing of warnings
4536 
4538  cout << "*TEcnaRun::PrintWarnings()> Warnings will be printed" << endl;
4539 }
4540 
4542 {
4543 // Set flags to authorize printing of the comments of all the methods
4544 
4546  cout << "*TEcnaRun::PrintAllComments()> All the comments will be printed" << endl;
4547 }
4548 
4550 {
4551 // Set flags to forbid the printing of all the comments
4552 
4554 }
4555 //=========================== E N D ======================================
TEcnaResultType * fCnaIndivResult
Definition: TEcnaRootFile.h:45
TEcnaNArrayD fMatMat
void TRootAdcEvt(const Int_t &, const Int_t &)
Definition: TEcnaRun.cc:4062
Bool_t OpenR(const Text_t *="")
Double_t * fT1d_av_sig_corss
Definition: TEcnaRun.h:472
void AverageTotalNoise()
Definition: TEcnaRun.cc:2012
int i
Definition: DBlmapReader.cc:9
Int_t NumberOfEventsAnalysis(Int_t **, const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaWrite.cc:519
Double_t * fT1d_av_mped
Definition: TEcnaRun.h:447
Double_t * fT3d1_cor_ss
Definition: TEcnaRun.h:441
Int_t * fTagCorCss
Definition: TEcnaRun.h:442
void LowFrequencyMeanCorrelationsBetweenSCs()
Definition: TEcnaRun.cc:2720
Int_t fCodePrintNoComment
Definition: TEcnaRun.h:510
void HighFrequencyMeanCorrelationsBetweenStins()
Definition: TEcnaRun.cc:2821
void Expert1Calculations()
Definition: TEcnaRun.cc:1296
Int_t fStex
Definition: TEcnaHeader.h:56
Int_t fHFccMoStinsCalc
Definition: TEcnaHeader.h:83
void TRootHfn()
Definition: TEcnaRun.cc:4431
Int_t * fTagLFccMoStins
Definition: TEcnaRun.h:496
Int_t fAvLfnCalc
Definition: TEcnaHeader.h:73
Double_t * fT1d_sigevt_of_evsamp
Definition: TEcnaRun.h:460
Int_t fSSpCalc
Definition: TEcnaHeader.h:71
void HighFrequencyMeanCorrelationsBetweenTowers()
Definition: TEcnaRun.cc:2816
Int_t * fMiscDiag
Definition: TEcnaRun.h:378
Int_t fBuildEvtNotSkipped
Definition: TEcnaRun.h:405
Bool_t fOpenRootFile
Definition: TEcnaRun.h:395
void CovariancesBetweenSamples()
Definition: TEcnaRun.cc:1446
Int_t * fTagStinNumbers
Definition: TEcnaRun.h:424
Int_t fCdelete
Definition: TEcnaRun.h:374
Int_t * fTagLfCor
Definition: TEcnaRun.h:482
Bool_t OpenRootFile(const Text_t *, TString)
Definition: TEcnaRun.cc:2926
TEcnaObject * fObjectManager
Definition: TEcnaRun.h:382
Int_t fReadyToReadData
Definition: TEcnaRun.h:396
TEcnaParCout * fCnaParCout
Definition: TEcnaRun.h:386
void TRootSigCorss()
Definition: TEcnaRun.cc:4450
Int_t fRunType
Definition: TEcnaHeader.h:63
void FileParameters(TString, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, TString)
Definition: TEcnaRead.cc:649
Int_t fCodePrintAllComments
Definition: TEcnaRun.h:510
void TRootSSp(const Int_t &)
Definition: TEcnaRun.cc:4110
Double_t * fT1d_sig_cor_ss
Definition: TEcnaRun.h:470
Int_t fHfnCalc
Definition: TEcnaHeader.h:88
void TRootLfCor()
Definition: TEcnaRun.cc:4249
void SetEcalSubDetector(const TString)
Definition: TEcnaRun.cc:274
void TRootLFccMoStins()
Definition: TEcnaRun.cc:4132
TEcnaHeader * fFileHeader
Definition: TEcnaRun.h:383
TEcnaRun()
Definition: TEcnaRun.cc:19
void PrintComments()
Definition: TEcnaRun.cc:4525
TString fStexName
Definition: TEcnaRun.h:393
TString GetStartDate()
Definition: TEcnaRead.cc:756
void LowFrequencyMeanCorrelationsBetweenTowers()
Definition: TEcnaRun.cc:2718
Int_t * fTagCovCss
Definition: TEcnaRun.h:437
Int_t fAvMeanCorssCalc
Definition: TEcnaHeader.h:92
Double_t * fT2d1_lf_cov
Definition: TEcnaRun.h:477
void TRootCovCss(const Int_t &, const Int_t &)
Definition: TEcnaRun.cc:4313
Int_t * fTagPed
Definition: TEcnaRun.h:446
void TRootAvTno()
Definition: TEcnaRun.cc:4175
Int_t fHfCorCalc
Definition: TEcnaHeader.h:79
TString GetRootFileNameShort()
Definition: TEcnaRead.cc:4376
Int_t * fT1dCrysNumbersTable
Definition: TEcnaRun.h:505
time_t GetStopTime()
Definition: TEcnaRead.cc:755
void Expert2Calculations()
Definition: TEcnaRun.cc:1304
Double_t * fT1d_av_ev_corss
Definition: TEcnaRun.h:457
void SetSizeHis(Int_t, Int_t)
Double_t ** fT2d_hfcc_mostins
Definition: TEcnaRun.h:498
void TRootAvLfn()
Definition: TEcnaRun.cc:4192
Int_t fReqNbOfEvts
Definition: TEcnaHeader.h:55
Int_t * fTagAvTno
Definition: TEcnaRun.h:453
void TotalNoise()
Definition: TEcnaRun.cc:1625
Double_t * fT3d1_AdcValues
Definition: TEcnaRun.h:416
Int_t * fTagHfn
Definition: TEcnaRun.h:466
void TRootHfCor()
Definition: TEcnaRun.cc:4291
Double_t *** fT3d_cor_ss
Definition: TEcnaRun.h:439
Double_t * fT1d_av_totn
Definition: TEcnaRun.h:452
Double_t * fT2d1_lf_cor
Definition: TEcnaRun.h:481
void PrintWarnings()
Definition: TEcnaRun.cc:4533
Double_t ** fT2d_sig
Definition: TEcnaRun.h:430
Int_t fMSpCalc
Definition: TEcnaHeader.h:70
void TRootAvEvCorss()
Definition: TEcnaRun.cc:4488
Int_t fNbOfEvtsCalc
Definition: TEcnaHeader.h:67
void PrintNoComment()
Definition: TEcnaRun.cc:4549
void SigmaOfCorrelationsBetweenSamples()
Definition: TEcnaRun.cc:1886
Int_t fNbOfSamples
Definition: TEcnaHeader.h:51
Int_t * fTagSSp
Definition: TEcnaRun.h:432
R__EXTERN TEcnaRootFile * gCnaRootFile
Definition: TEcnaRootFile.h:68
void GetReadyToCompute()
Definition: TEcnaRun.cc:1216
TString fStopDate
Definition: TEcnaHeader.h:61
Int_t fNbSampForFic
Definition: TEcnaRun.h:407
Double_t ** fT2d_ev
Definition: TEcnaRun.h:426
Int_t fMeanCorssCalc
Definition: TEcnaHeader.h:86
Double_t ** fT2d_hf_cor
Definition: TEcnaRun.h:489
Double_t * fT1d_ev_ev
Definition: TEcnaRun.h:445
void RegisterFileParameters(const TString, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const TString, const TString, const time_t, const time_t)
Definition: TEcnaWrite.cc:609
Bool_t CloseRootFile(const Text_t *)
Definition: TEcnaRun.cc:2969
TString GetRootFileNameShort()
Definition: TEcnaRun.cc:1183
void TRootStinNumbers()
Definition: TEcnaRun.cc:4023
Double_t ** fT3d2_cov_ss
Definition: TEcnaRun.h:435
Int_t fCnaError
Definition: TEcnaRun.h:371
Long_t GetPointerValue(const TString)
Definition: TEcnaObject.cc:229
void TRootHFccMoStins()
Definition: TEcnaRun.cc:4154
void TRootMSp(const Int_t &)
Definition: TEcnaRun.cc:4089
Int_t fHfCovCalc
Definition: TEcnaHeader.h:78
Int_t * fTagTno
Definition: TEcnaRun.h:451
Double_t ** fT3d2_cor_ss
Definition: TEcnaRun.h:440
Double_t * fT1d_av_hifn
Definition: TEcnaRun.h:467
Int_t GetCodePrint(const TString)
Definition: TEcnaParCout.cc:70
TString fFlagSubDet
Definition: TEcnaRun.h:392
Double_t ** fT2d_hf_cov
Definition: TEcnaRun.h:485
Double_t * fT3d1_cov_ss
Definition: TEcnaRun.h:436
Int_t * fTagAvLfn
Definition: TEcnaRun.h:463
Int_t * fT1d_NbOfEvts
Definition: TEcnaRun.h:420
TEcnaNArrayD fMatHis
Int_t fStinIndexBuilt
Definition: TEcnaRun.h:404
CnaResultTyp fTypOfCnaResult
Int_t * fTagLfn
Definition: TEcnaRun.h:461
void TRootAvHfn()
Definition: TEcnaRun.cc:4210
Int_t fCorCssCalc
Definition: TEcnaHeader.h:77
TVectorD ReadStinNumbers(const Int_t &)
Definition: TEcnaRead.cc:1132
void TRootPed()
Definition: TEcnaRun.cc:4356
Double_t * fT2d1_hf_cov
Definition: TEcnaRun.h:486
void AverageMeanCorrelationsBetweenSamples()
Definition: TEcnaRun.cc:2192
Double_t *** fT3d_AdcValues
Definition: TEcnaRun.h:414
void TRootTno()
Definition: TEcnaRun.cc:4374
T sqrt(T t)
Definition: SSEVec.h:46
void SampleValues()
Definition: TEcnaRun.cc:1254
void GetReadyToReadData(TString, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaRun.cc:504
Bool_t GetPathForResults()
Definition: TEcnaRun.cc:133
void TRootCorCss(const Int_t &, const Int_t &)
Definition: TEcnaRun.cc:4334
Int_t fCodePrintComments
Definition: TEcnaRun.h:510
Double_t *** fT3d_cov_ss
Definition: TEcnaRun.h:434
Int_t GetStexStinFromIndex(const Int_t &)
Definition: TEcnaRead.cc:4384
void AverageLowFrequencyNoise()
Definition: TEcnaRun.cc:2072
Int_t fAvTnoCalc
Definition: TEcnaHeader.h:72
TEcnaParPaths * fCnaParPaths
Definition: TEcnaRun.h:387
Int_t * fTagAvSigCorss
Definition: TEcnaRun.h:473
Bool_t ReadSampleAdcValues()
Definition: TEcnaRun.cc:1054
Int_t fPedCalc
Definition: TEcnaHeader.h:84
int j
Definition: DBlmapReader.cc:9
Int_t * fTagHfCor
Definition: TEcnaRun.h:491
Int_t * fTagNbOfEvts
Definition: TEcnaRun.h:421
Int_t * fTagAvPed
Definition: TEcnaRun.h:448
Bool_t WriteRootFile()
Definition: TEcnaRun.cc:3015
Int_t fMemoReadNumberOfEventsforSamples
Definition: TEcnaRun.h:412
TString GetStopDate()
Definition: TEcnaRead.cc:757
Int_t fNbSampForCalc
Definition: TEcnaRun.h:408
void TRootLfn()
Definition: TEcnaRun.cc:4412
void TRootLfCov()
Definition: TEcnaRun.cc:4228
Int_t fFlagPrint
Definition: TEcnaRun.h:509
Int_t fMaxMsgIndexForMiscDiag
Definition: TEcnaRun.h:380
Int_t fAvHfnCalc
Definition: TEcnaHeader.h:74
Int_t * fTagHFccMoStins
Definition: TEcnaRun.h:500
Int_t fNumberOfEvents
Definition: TEcnaRun.h:410
Double_t * fT2d1_hfcc_mostins
Definition: TEcnaRun.h:499
Int_t fSpecialStexStinNotIndexed
Definition: TEcnaRun.h:403
Int_t * fTagAvMeanCorss
Definition: TEcnaRun.h:458
void HighFrequencyCorrelationsBetweenChannels()
Definition: TEcnaRun.cc:2637
void PrintNoComment()
Definition: TEcnaRead.cc:4481
void SampleMeans()
Definition: TEcnaRun.cc:1326
Bool_t WriteNewRootFile(const TString)
Definition: TEcnaRun.cc:3067
void LowFrequencyNoise()
Definition: TEcnaRun.cc:1678
Int_t MaxCrysInStin()
TString GetRootFileName()
Definition: TEcnaRead.cc:4375
Int_t StexEchaForCons(const Int_t &, const Int_t &)
TString fStartDate
Definition: TEcnaHeader.h:60
TString fRootFileStatus
Definition: TEcnaRootFile.h:34
void StandardCalculations()
Definition: TEcnaRun.cc:1275
void Init()
Definition: TEcnaRun.cc:135
Bool_t GetPathForResultsRootFiles()
TString GetRootFileName()
Definition: TEcnaRun.cc:1182
Bool_t DataExist()
Definition: TEcnaRead.cc:978
void AverageSigmaOfCorrelationsBetweenSamples()
Definition: TEcnaRun.cc:2252
Bool_t RegisterPointer(const TString, const Long_t &)
Definition: TEcnaObject.cc:102
Double_t ** fT2d_lf_cor
Definition: TEcnaRun.h:480
void LowFrequencyMeanCorrelationsBetweenStins()
Definition: TEcnaRun.cc:2723
Int_t * fTagLfCov
Definition: TEcnaRun.h:478
Int_t fCnew
Definition: TEcnaRun.h:373
Int_t fCodePrintWarnings
Definition: TEcnaRun.h:510
Int_t MaxCrysInStinEcna(const Int_t &, const Int_t &, const TString)
Double_t * fT2d1_hf_cor
Definition: TEcnaRun.h:490
Double_t * fT1d_evsamp_of_sigevt
Definition: TEcnaRun.h:450
TString GetNewRootFileNameShort()
Definition: TEcnaRun.cc:3101
Bool_t GetSampleAdcValues(const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Double_t &)
Definition: TEcnaRun.cc:835
TString fTypAna
Definition: TEcnaHeader.h:50
void SetSizeMat(Int_t, Int_t)
void ReSet(Int_t)
TMatrixD ReadNumberOfEventsForSamples(const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaRead.cc:1724
Int_t fAvPedCalc
Definition: TEcnaHeader.h:91
Double_t *** ReadSampleAdcValuesSameFile(const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaRead.cc:4181
Int_t fFirstReqEvtNumber
Definition: TEcnaHeader.h:53
void HighFrequencyMeanCorrelationsBetweenSCs()
Definition: TEcnaRun.cc:2818
void TRootAvSigCorss()
Definition: TEcnaRun.cc:4507
Int_t * fTagHfCov
Definition: TEcnaRun.h:487
Int_t * fTagAvHfn
Definition: TEcnaRun.h:468
void HighFrequencyCovariancesBetweenChannels()
Definition: TEcnaRun.cc:2520
Int_t * fTagSigCorss
Definition: TEcnaRun.h:471
void MeanCorrelationsBetweenSamples()
Definition: TEcnaRun.cc:1820
Double_t * fT2d1_lfcc_mostins
Definition: TEcnaRun.h:495
void PrintAllComments()
Definition: TEcnaRun.cc:4541
void SampleSigmas()
Definition: TEcnaRun.cc:1378
TString GetNewRootFileName()
Definition: TEcnaRun.cc:3100
TString fNewRootFileNameShort
Definition: TEcnaRun.h:401
TString ResultsRootFilePath()
Int_t fLfCorCalc
Definition: TEcnaHeader.h:81
Int_t * fTagMSp
Definition: TEcnaRun.h:428
Int_t fAdcEvtCalc
Definition: TEcnaHeader.h:69
Int_t fTnoCalc
Definition: TEcnaHeader.h:85
Int_t MaxCrysEcnaInStex()
time_t fStartTime
Definition: TEcnaHeader.h:58
time_t fStopTime
Definition: TEcnaHeader.h:59
void TRootNbOfEvts(const Int_t &)
Definition: TEcnaRun.cc:4041
Int_t fLfCovCalc
Definition: TEcnaHeader.h:80
Double_t * fT1d_ev
Definition: TEcnaRun.h:427
Int_t fLFccMoStinsCalc
Definition: TEcnaHeader.h:82
Int_t fLastReqEvtNumber
Definition: TEcnaHeader.h:54
int nlast
Definition: AMPTWrapper.h:47
void AveragePedestals()
Definition: TEcnaRun.cc:1951
void HighFrequencyNoise()
Definition: TEcnaRun.cc:1748
Int_t * fTagAdcEvt
Definition: TEcnaRun.h:417
void TRootMeanCorss()
Definition: TEcnaRun.cc:4393
Int_t MaxSampADC()
void AverageHighFrequencyNoise()
Definition: TEcnaRun.cc:2132
Int_t fgMaxCar
Definition: TEcnaRun.h:369
virtual ~TEcnaRun()
Definition: TEcnaRun.cc:326
void Pedestals()
Definition: TEcnaRun.cc:1580
void HeaderParameters(TString, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaHeader.cc:126
Int_t Get0StexEchaFrom1StexStinAnd0StinEcha(const Int_t &, const Int_t &)
void LowFrequencyCovariancesBetweenChannels()
Definition: TEcnaRun.cc:2332
Double_t ** fT3d2_AdcValues
Definition: TEcnaRun.h:415
Bool_t LookAtRootFile()
Definition: TEcnaRead.cc:922
void ReStart(const Text_t *)
void LowFrequencyCorrelationsBetweenChannels()
Definition: TEcnaRun.cc:2437
tuple cout
Definition: gather_cfg.py:121
Int_t MaxStinEcnaInStex()
Int_t fRunNumber
Definition: TEcnaHeader.h:52
TString GetRootFileNameShort()
Definition: TEcnaWrite.cc:385
Int_t fSigCorssCalc
Definition: TEcnaHeader.h:89
TString fRootFileName
Definition: TEcnaRun.h:398
void CorrelationsBetweenSamples()
Definition: TEcnaRun.cc:1506
TString fNewRootFileName
Definition: TEcnaRun.h:400
Int_t fLfnCalc
Definition: TEcnaHeader.h:87
void StartStopDate(TString, TString)
Definition: TEcnaRun.cc:1203
Double_t ** fT2d_lf_cov
Definition: TEcnaRun.h:476
Bool_t OpenW(const Text_t *="")
void fMakeResultsFileName()
Definition: TEcnaWrite.cc:639
Int_t ** fT2d_NbOfEvts
Definition: TEcnaRun.h:419
Double_t * fT1d_av_lofn
Definition: TEcnaRun.h:462
Int_t fCnaCommand
Definition: TEcnaRun.h:371
Int_t ** fT2dCrysNumbersTable
Definition: TEcnaRun.h:504
void TRootHfCov()
Definition: TEcnaRun.cc:4270
tuple status
Definition: ntuplemaker.py:245
Int_t fStinNumbersCalc
Definition: TEcnaHeader.h:66
TString fStinName
Definition: TEcnaRun.h:393
TString GetRootFileName()
Definition: TEcnaWrite.cc:384
Int_t fNbOfMiscDiagCounters
Definition: TEcnaRun.h:379
TEcnaWrite * fCnaWrite
Definition: TEcnaRun.h:388
Int_t * fT1d_StexStinFromIndex
Definition: TEcnaRun.h:423
TString fTTBELL
Definition: TEcnaRun.h:376
void StartStopTime(time_t, time_t)
Definition: TEcnaRun.cc:1195
TTree * fCnaResultsTree
Definition: TEcnaRootFile.h:40
Double_t * fT1d_evevt_of_sigsamp
Definition: TEcnaRun.h:465
Int_t * fTagMeanCorss
Definition: TEcnaRun.h:456
Double_t * fT1d_sig
Definition: TEcnaRun.h:431
Int_t fAvSigCorssCalc
Definition: TEcnaHeader.h:93
TEcnaNumbering * fEcalNumbering
Definition: TEcnaRun.h:385
Int_t fCovCssCalc
Definition: TEcnaHeader.h:76
Double_t * fT1d_ev_cor_ss
Definition: TEcnaRun.h:455
TFile * fRootFile
Definition: TEcnaRootFile.h:36
time_t GetStartTime()
Definition: TEcnaRead.cc:754
TString fRootFileNameShort
Definition: TEcnaRun.h:399
TEcnaParEcal * fEcal
Definition: TEcnaRun.h:384
void TRootAvPed()
Definition: TEcnaRun.cc:4469
Double_t ** fT2d_lfcc_mostins
Definition: TEcnaRun.h:494