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