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