CMS 3D CMS Logo

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