CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/src/TEcnaRead.cc

Go to the documentation of this file.
00001 //----------Author's Name: B.Fabbro, FX Gentit DSM/IRFU/SPP CEA-Saclay
00002 //----------Copyright: Those valid for CEA sofware
00003 //----------Modified: 24/03/2011
00004 
00005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h"
00006 
00007 //--------------------------------------
00008 //  TEcnaRead.cc
00009 //  Class creation: 03 Dec 2002
00010 //  Documentation: see TEcnaRead.h
00011 //--------------------------------------
00012 
00013 R__EXTERN TEcnaRootFile *gCnaRootFile;
00014 
00015 ClassImp(TEcnaRead)
00016 //___________________________________________________________________________
00017 //
00018 
00019 TEcnaRead::TEcnaRead()
00020 {
00021   Init();
00022   // cout << "[Info Management] CLASS: TEcnaRead.          CREATE OBJECT: this = " << this << endl;
00023 }
00024 //Constructor without argument
00025 
00026 TEcnaRead::TEcnaRead(TEcnaObject* pObjectManager, const TString SubDet)
00027 {
00028   fObjectManager = (TEcnaObject*)pObjectManager;
00029   Long_t i_this = (Long_t)this;
00030   pObjectManager->RegisterPointer("TEcnaRead", i_this);
00031 
00032  //----------------------- Object management
00033   //............................ fCnaParCout
00034   fCnaParCout = 0;
00035   Int_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
00036   if( iCnaParCout == 0 )
00037     {fCnaParCout = new TEcnaParCout(pObjectManager); /*fCnew++*/}
00038   else
00039     {fCnaParCout = (TEcnaParCout*)iCnaParCout;}
00040 
00041   //............................ fCnaParPaths
00042   fCnaParPaths = 0;
00043   Int_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
00044   if( iCnaParPaths == 0 )
00045     {fCnaParPaths = new TEcnaParPaths(pObjectManager); /*fCnew++*/}
00046   else
00047     {fCnaParPaths = (TEcnaParPaths*)iCnaParPaths;}
00048 
00049   //............................ fEcalNumbering
00050   fEcalNumbering = 0;
00051   Int_t iEcalNumbering = pObjectManager->GetPointerValue("TEcnaNumbering");
00052   if( iEcalNumbering == 0 )
00053     {fEcalNumbering = new TEcnaNumbering(pObjectManager, SubDet.Data()); /*fCnew++*/}
00054   else
00055     {fEcalNumbering = (TEcnaNumbering*)iEcalNumbering;}
00056 
00057   //............................ fCnaParHistos
00058   fCnaParHistos = 0;
00059   Int_t iCnaParHistos = pObjectManager->GetPointerValue("TEcnaParHistos");
00060   if( iCnaParHistos == 0 )
00061     {fCnaParHistos = new TEcnaParHistos(pObjectManager, SubDet.Data()); /*fCnew++*/}
00062   else
00063     {fCnaParHistos = (TEcnaParHistos*)iCnaParHistos;}
00064 
00065   //............................ fCnaWrite
00066   fCnaWrite = 0;
00067   Int_t iCnaWrite = pObjectManager->GetPointerValue("TEcnaWrite");
00068   if( iCnaWrite == 0 )
00069     {fCnaWrite = new TEcnaWrite(pObjectManager, SubDet.Data()); /*fCnew++*/}
00070   else
00071     {fCnaWrite = (TEcnaWrite*)iCnaWrite;}
00072 
00073   // fEcal = 0; fEcal = new TEcnaParEcal(SubDet.Data());            // Anew("fEcal");
00074   //............................ fEcal  => to be changed in fParEcal
00075   fEcal = 0;
00076   Int_t iParEcal = pObjectManager->GetPointerValue("TEcnaParEcal");
00077   if( iParEcal == 0 )
00078     {fEcal = new TEcnaParEcal(pObjectManager, SubDet.Data()); /*fCnew++*/}
00079   else
00080     {fEcal = (TEcnaParEcal*)iParEcal;}
00081 
00082   //fFileHeader  = 0; 
00083   //const Text_t *h_name  = "CnaHeader";  //==> voir cette question avec FXG
00084   //const Text_t *h_title = "CnaHeader";  //==> voir cette question avec FXG
00085   //fFileHeader = new TEcnaHeader(h_name, h_title);  // Anew("fFileHeader");
00086 
00087   //............................ fFileHeader
00088   const Text_t *h_name  = "CnaHeader";  //==> voir cette question avec FXG
00089   const Text_t *h_title = "CnaHeader";  //==> voir cette question avec FXG
00090 
00091   // "CnaHeader" est le nom du fichier utilisé dans ReadRootFileHeader(...) sous la forme:
00092   //
00093   // TEcnaHeader *h;
00094   // h =(TEcnaHeader*)gCnaRootFile->fRootFile->Get("CnaHeader");
00095   //
00096 
00097   fFileHeader = 0;
00098   Int_t iFileHeader = pObjectManager->GetPointerValue("TEcnaHeader");
00099   if( iFileHeader == 0 )
00100     {fFileHeader = new TEcnaHeader(pObjectManager, h_name, h_title); /*fCnew++*/}
00101   else
00102     {fFileHeader = (TEcnaHeader*)iFileHeader;}
00103 
00104   Init();
00105   SetEcalSubDetector(SubDet.Data());
00106 
00107  // cout << "[Info Management] CLASS: TEcnaRead.          CREATE OBJECT: this = " << this << endl;
00108 }
00109 
00110 void TEcnaRead::Init()
00111 {
00112 //Initialisation concerning the ROOT file
00113 
00114   fCnew    = 0;
00115   fCdelete = 0;
00116 
00117   fTTBELL = '\007';
00118 
00119   fgMaxCar = (Int_t)512;
00120 
00121   fCodePrintNoComment   = fCnaParCout->GetCodePrint("NoComment");
00122   fCodePrintWarnings    = fCnaParCout->GetCodePrint("Warnings ");
00123   fCodePrintComments    = fCnaParCout->GetCodePrint("Comments");
00124   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
00125 
00126   //.................................. Set flag print to "Warnings"   (Init)
00127   fFlagPrint = fCodePrintWarnings;
00128 
00129   //................................ tags and array Stin numbers
00130   fTagStinNumbers  = 0;
00131   fMemoStinNumbers = 0;
00132   fT1d_StexStinFromIndex = 0;
00133 
00134   //................................ 
00135   //  fMemoReadNumberOfEventsforSamples = 0;
00136 
00137   //.......................... flag data exist (utile ici?)
00138   fDataExist = kFALSE;
00139 
00140   //......................... transfert Sample ADC Values 3D array   (Init)
00141   fT3d_AdcValues  = 0;
00142   fT3d2_AdcValues = 0;
00143   fT3d1_AdcValues = 0;
00144 
00145   //................................. path for .root files
00146   Int_t MaxCar = fgMaxCar;
00147   MaxCar = fgMaxCar;
00148   fPathRoot.Resize(MaxCar);
00149   fPathRoot  = "fPathRoot not defined";
00150 
00151   //.................................. Pointer and Flags for Root File   (Init)
00152   gCnaRootFile = 0;
00153 
00154   fOpenRootFile = kFALSE;
00155   fReadyToReadRootFile = 0;
00156   fLookAtRootFile      = 0;
00157 
00158   //................................. currently open file
00159   MaxCar = fgMaxCar;
00160   fFlagNoFileOpen.Resize(MaxCar);
00161   fFlagNoFileOpen = "No file is open";
00162 
00163   MaxCar = fgMaxCar;
00164   fCurrentlyOpenFileName.Resize(MaxCar);
00165   fCurrentlyOpenFileName = fFlagNoFileOpen;
00166 
00167 }// end of Init()
00168 
00169 //============================================================================================================
00170 
00171 void  TEcnaRead::SetEcalSubDetector(const TString SubDet)
00172 {
00173  // Set Subdetector (EB or EE)
00174 
00175   Int_t MaxCar = fgMaxCar;
00176   fFlagSubDet.Resize(MaxCar);
00177   fFlagSubDet = fEcal->GetEcalSubDetector();
00178 
00179   if( fFlagSubDet == "EB" ){fStexName = "SM";  fStinName = "tower";}
00180   if( fFlagSubDet == "EE" ){fStexName = "Dee"; fStinName = "SC";}
00181 }
00182 
00183 //============================================================================================================
00184 void TEcnaRead::Anew(const TString VarName)
00185 {
00186   // allocation survey for new
00187   
00188   fCnew++;
00189   // cout << "TEcnaRead::Anew---> new " << setw(4) << fCnew << " --------------> " << setw(25)
00190   //      << VarName.Data() << " / object(this): " << this << endl;
00191 }
00192 
00193 void TEcnaRead::Adelete(const TString VarName)
00194 {
00195   // allocation survey for delete
00196   
00197   fCdelete++;
00198   // cout << "TEcnaRead::Adelete> ========== delete" << setw(4) << fCdelete << " -> " << setw(25)
00199   //      << VarName.Data() << " / object(this): " << this << endl;
00200 }
00201 
00202 //=========================================== private copy ==========
00203 
00204 void  TEcnaRead::fCopy(const TEcnaRead& rund)
00205 {
00206 //Private copy
00207 
00208   fFileHeader   = rund.fFileHeader;
00209   fOpenRootFile = rund.fOpenRootFile;
00210 
00211   //........................................ Codes 
00212 
00213   fCodePrintComments    = rund.fCodePrintComments;
00214   fCodePrintWarnings    = rund.fCodePrintWarnings;
00215   fCodePrintAllComments = rund.fCodePrintAllComments;
00216   fCodePrintNoComment   = rund.fCodePrintNoComment;
00217 
00218   //.................................................. Tags
00219   fTagStinNumbers  = rund.fTagStinNumbers;
00220 
00221   fFlagPrint = rund.fFlagPrint;
00222   fPathRoot  = rund.fPathRoot;
00223 
00224   fCnew    = rund.fCnew;
00225   fCdelete = rund.fCdelete;
00226 }
00227 
00228 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00229 //
00230 //                    copy constructor
00231 //
00232 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00233 
00234 TEcnaRead::TEcnaRead(const TEcnaRead& dcop)
00235 {
00236   cout << "*TEcnaRead::TEcnaRead(const TEcnaRead& dcop)> "
00237        << " It is time to write a copy constructor"
00238        << endl;
00239   
00240   // { Int_t cintoto;  cin >> cintoto; }
00241   
00242 }
00243 
00244 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00245 //
00246 //                    overloading of the operator=
00247 //
00248 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00249 
00250 TEcnaRead& TEcnaRead::operator=(const TEcnaRead& dcop)
00251 {
00252 //Overloading of the operator=
00253 
00254   fCopy(dcop);
00255   return *this;
00256 }
00257 
00258 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00259 //
00260 //                            destructor
00261 //
00262 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00263 
00264 TEcnaRead::~TEcnaRead()
00265 {
00266 //Destructor
00267   
00268   // cout << "[Info Management] CLASS: TEcnaRead.          DESTROY OBJECT: this = " << this << endl;
00269 
00270   if(fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments){
00271     cout << "*TEcnaRead::~TEcnaRead()> Entering destructor" << endl;}
00272   
00273   //if (fFileHeader    != 0){delete fFileHeader;    Adelete("fFileHeader");}
00274   //if (fEcal          != 0){delete fEcal;          Adelete("fEcal");}
00275   //if (fCnaParCout    != 0){delete fCnaParCout;    Adelete("fCnaParCout");}
00276   //if (fCnaParPaths   != 0){delete fCnaParPaths;   Adelete("fCnaParPaths");}
00277   //if (fCnaWrite      != 0){delete fCnaWrite;      Adelete("fCnaWrite");}
00278   //if (fEcalNumbering != 0){delete fEcalNumbering; Adelete("fEcalNumbering");}
00279 
00280   if (fT1d_StexStinFromIndex != 0){delete [] fT1d_StexStinFromIndex; Adelete("fT1d_StexStinFromIndex");}
00281   if (fTagStinNumbers        != 0){delete [] fTagStinNumbers;        Adelete("fTagStinNumbers");}
00282 
00283   if (fT3d_AdcValues  != 0){delete [] fT3d_AdcValues;  Adelete("fT3d_AdcValues");}
00284   if (fT3d2_AdcValues != 0){delete [] fT3d2_AdcValues; Adelete("fT3d2_AdcValues");}
00285   if (fT3d1_AdcValues != 0){delete [] fT3d1_AdcValues; Adelete("fT3d1_AdcValues");}
00286 
00287   if ( fCnew != fCdelete )
00288     {
00289       cout << "!TEcnaRead/destructor> WRONG MANAGEMENT OF ALLOCATIONS: fCnew = "
00290            << fCnew << ", fCdelete = " << fCdelete << fTTBELL << endl;
00291     }
00292   else
00293     {
00294       // cout << "*TEcnaRead/destructor> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: fCnew = "
00295       //      << fCnew << ", fCdelete = " << fCdelete << endl;
00296     }
00297   
00298   if(fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments){
00299     cout << "*TEcnaRead::~TEcnaRead()> End of destructor " << endl;}
00300 }
00301 
00302 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00303 //
00304 //                             M  E  T  H  O  D  S
00305 //
00306 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00307 
00308 //============================================================================
00309 //
00310 //                       1 D   H I S T O S 
00311 //
00312 //============================================================================
00313 TVectorD TEcnaRead::Read1DHisto(const Int_t& VecDim,     const TString UserQuantity,
00314                                 const Int_t& n1StexStin, const Int_t& i0StinEcha, const Int_t& n1Sample)
00315 {
00316   Int_t VecDimTest = fFileHeader->fReqNbOfEvts;
00317 
00318   if( VecDim == VecDimTest )
00319     {
00320       TVectorD vec(VecDim);
00321 
00322       TString CallingMethod = "1D";
00323       TString StandardQuantity = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserQuantity);
00324 
00325       if( StandardQuantity == "Adc" )
00326         {
00327           Int_t i0Sample = n1Sample-1;
00328           vec = ReadSampleAdcValues(n1StexStin, i0StinEcha, i0Sample, VecDim);
00329         }
00330       else
00331         {
00332           for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00333           cout <<"!TEcnaRead::Read1DHisto(...)>  UserQuantity = " << UserQuantity
00334                << "(StandardQuantity = " << StandardQuantity
00335                << "). Wrong code, no file reading." << fTTBELL << endl;
00336         }
00337       return vec;
00338     }
00339   else
00340     {
00341       TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00342       cout <<"!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
00343            << ", VecDim = " << VecDim << "(VecDimTest = " << VecDimTest << ")"
00344            << ". Wrong code or array dimension. No file reading." << fTTBELL << endl;
00345       return vec;
00346     }
00347 }  // end of Read1DHisto / ReadSampleAdcValues
00348 
00349 TVectorD TEcnaRead::Read1DHisto(const Int_t& VecDim, const TString UserQuantity, const Int_t& n1StexStin)
00350 {
00351   Int_t  VecDimTest = fEcal->MaxCrysInStin()*fEcal->MaxSampADC();
00352   if( VecDim == VecDimTest )
00353     {
00354       TVectorD vec(VecDim);
00355       
00356       TString CallingMethod = "1D";
00357       TString StandardQuantity = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserQuantity);
00358       
00359       if( StandardQuantity == "MSp" || StandardQuantity == "SSp" )
00360         {
00361           if( StandardQuantity == "MSp" ){vec = ReadSampleMeans(n1StexStin, VecDim);}
00362           if( StandardQuantity == "SSp" ){vec = ReadSampleSigmas(n1StexStin, VecDim);}
00363         }
00364       else
00365         {
00366           for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00367           cout <<"!TEcnaRead::Read1DHisto(...)>  UserQuantity = " << UserQuantity
00368                << ", StandardQuantity = " << StandardQuantity
00369                << ". Wrong code, no file reading." << fTTBELL << endl;
00370         }
00371       return vec;
00372     }
00373   else
00374     {
00375       TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00376       cout <<"!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
00377            << ", VecDim = " << VecDim << "(VecDimTest = " << VecDimTest << ")"
00378            << ". Wrong code or array dimension. No file reading." << fTTBELL << endl; 
00379       return vec;
00380     }
00381 }  // end of Read1DHisto / ReadSampleMeans , ReadSampleSigmas
00382 
00383 TVectorD TEcnaRead::Read1DHisto(const Int_t& VecDim, const TString UserQuantity, const TString UserDetector)
00384 {
00385   // VecDim = fEcal->MaxCrysEcnaInStex if StandardDetector = "SM" or "Dee"
00386   // VecDim = fEcal->MaxStinEcnaInStas if StandardDetector = "EB" or "EE"
00387 
00388   Int_t VecDimTest = 1;
00389   TString StandardDetector = fCnaParHistos->BuildStandardDetectorCode(UserDetector);
00390   if( StandardDetector == "SM" || StandardDetector == "Dee"){VecDimTest = fEcal->MaxCrysEcnaInStex();}
00391   if( StandardDetector == "EB" || StandardDetector == "EE" ){VecDimTest = fEcal->MaxStinEcnaInStas();}
00392 
00393   if( VecDim == VecDimTest )
00394     {
00395       TVectorD vec(VecDim);
00396 
00397       TString CallingMethod = "1D";
00398       TString StandardQuantity = "?";
00399       StandardQuantity = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserQuantity);
00400       TString rTechReadCode = GetTechReadCode(StandardQuantity, StandardDetector);
00401 
00402       if( rTechReadCode != "?" )
00403         {
00404           if( StandardDetector == "SM" || StandardDetector == "Dee")
00405             {
00406               if( rTechReadCode == "NOEStex" ){vec = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());}
00407               if( rTechReadCode == "PedStex" ){vec = ReadPedestals(fEcal->MaxCrysEcnaInStex());}
00408               if( rTechReadCode == "TNoStex" ){vec = ReadTotalNoise(fEcal->MaxCrysEcnaInStex());}
00409               if( rTechReadCode == "LFNStex" ){vec = ReadLowFrequencyNoise(fEcal->MaxCrysEcnaInStex());}
00410               if( rTechReadCode == "HFNStex" ){vec = ReadHighFrequencyNoise(fEcal->MaxCrysEcnaInStex());}
00411               if( rTechReadCode == "MCsStex" ){vec = ReadMeanCorrelationsBetweenSamples(fEcal->MaxCrysEcnaInStex());}
00412               if( rTechReadCode == "SCsStex" ){vec = ReadSigmaOfCorrelationsBetweenSamples(fEcal->MaxCrysEcnaInStex());}
00413             }
00414 
00415           if( StandardDetector == "EB" || StandardDetector == "EE" )
00416             {
00417               TVectorD vecStex(fEcal->MaxStinEcnaInStex());
00418               for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vecStex(i)=(Double_t)0.;}
00419 
00420               time_t xStartTime = GetStartTime();
00421               time_t xStopTime =  GetStopTime();
00422               TString xStartDate = "sStartDate";
00423               TString xStopDate  = "sStopDate";
00424 
00425               for(Int_t i0Stex=0; i0Stex<fEcal->MaxStexInStas(); i0Stex++)
00426                 {
00427                   Int_t n1Stex = i0Stex+1;
00428                   FileParameters(fFileHeader->fTypAna,           fFileHeader->fNbOfSamples,
00429                                  fFileHeader->fRunNumber,        fFileHeader->fFirstReqEvtNumber,
00430                                  fFileHeader->fLastReqEvtNumber, fFileHeader->fReqNbOfEvts,
00431                                  n1Stex, fPathRoot);
00432 
00433                   if( LookAtRootFile() == kTRUE )
00434                     {
00435                       if( rTechReadCode == "NOEStas" ){vecStex = ReadAverageNumberOfEvents(fEcal->MaxStinEcnaInStex());}
00436                       if( rTechReadCode == "PedStas" ){vecStex = ReadAveragePedestals(fEcal->MaxStinEcnaInStex());}
00437                       if( rTechReadCode == "TNoStas" ){vecStex = ReadAverageTotalNoise(fEcal->MaxStinEcnaInStex());}
00438                       if( rTechReadCode == "LFNStas" ){vecStex = ReadAverageLowFrequencyNoise(fEcal->MaxStinEcnaInStex());}
00439                       if( rTechReadCode == "HFNStas" ){vecStex = ReadAverageHighFrequencyNoise(fEcal->MaxStinEcnaInStex());}
00440                       if( rTechReadCode == "MCsStas" )
00441                         {vecStex = ReadAverageMeanCorrelationsBetweenSamples(fEcal->MaxStinEcnaInStex());}
00442                       if( rTechReadCode == "SCsStas" )
00443                         {vecStex = ReadAverageSigmaOfCorrelationsBetweenSamples(fEcal->MaxStinEcnaInStex());}
00444                   
00445                       for(Int_t i0Stin=0; i0Stin<fEcal->MaxStinEcnaInStex(); i0Stin++)
00446                         {
00447                           vec(fEcal->MaxStinEcnaInStex()*i0Stex+i0Stin) = vecStex(i0Stin);
00448                         }
00449 
00450                       //............ Get start and stop date for the Stas (Stas = EB or EE)
00451                       if( i0Stex == 0 )
00452                         {
00453                           xStartTime = GetStartTime();
00454                           xStopTime =  GetStopTime();
00455                           xStartDate = GetStartDate();
00456                           xStopDate  = GetStopDate();
00457                         }
00458                       time_t  cStartTime = GetStartTime();
00459                       time_t  cStopTime  = GetStopTime();
00460                       TString cStartDate = GetStartDate();
00461                       TString cStopDate  = GetStopDate();
00462 
00463                       if( cStartTime < xStartTime ){xStartTime = cStartTime; xStartDate = cStartDate;}
00464                       if( cStopTime  > xStopTime  ){xStopTime  = cStopTime;  xStopDate  = cStopDate;}
00465 
00466                       fFileHeader->fStartDate = xStartDate;
00467                       fFileHeader->fStopDate  = xStopDate;
00468 
00469                       cout << "-------------------------------------------------------------" << endl;
00470                       cout << "*TEcnaRead::Read1DHisto(...)> CONTROLE 1a. i0Stex = " << i0Stex
00471                            << ", cStartDate = " << cStartDate
00472                            << ", xStartDate = " << xStartDate
00473                            << ", fFileHeader->fStartDate = " << fFileHeader->fStartDate << endl;
00474                       cout << "............................................................." << endl;
00475                       cout << "*TEcnaRead::Read1DHisto(...)> CONTROLE 1b. i0Stex = " << i0Stex
00476                            << ", cStopDate = "  << cStopDate 
00477                            << ", xStopDate  = " << xStopDate
00478                            << ", fFileHeader->fStopDate = " << fFileHeader->fStopDate << endl;
00479                       cout << "-------------------------------------------------------------" << endl;
00480                     }
00481                   else
00482                     {
00483                       cout  << "!TEcnaRead::Read1DHisto(const TString, const TString)> *ERROR* =====> "
00484                             << " ROOT file not found" << fTTBELL << endl;
00485                     }
00486                 }
00487             }
00488         }
00489       else
00490         {
00491           for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00492           cout <<"!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
00493                << ", UserDetector = " << UserDetector
00494                << ". Wrong code(s). No file reading." << fTTBELL << endl;
00495         }
00496       return vec;
00497     }
00498   else
00499     {
00500       TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i) = (double_t)0.;}
00501       cout <<"!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
00502            << ", UserDetector = " << UserDetector << ", VecDim = " << VecDim
00503            << ". Wrong code(s) or array dimension. No file reading." << fTTBELL << endl; 
00504       return vec;
00505     }
00506 }  // end of Read1DHisto / Stex and Stas histos
00507 
00508 //============================================================================
00509 //
00510 //                       2 D   H I S T O S 
00511 //
00512 //============================================================================
00513 TMatrixD TEcnaRead::ReadMatrix(const Int_t& MatDim,   const TString UserMatrixType, const TString UserBetweenWhat,
00514                                const Int_t& nb_arg_1, const Int_t&  nb_arg_2)
00515 {
00516   TMatrixD mat(MatDim, MatDim);
00517   TString CallingMethod = "2D";
00518   TString StandardMatrixType  = "?";
00519   TString StandardBetweenWhat = "?";
00520 
00521   StandardMatrixType  = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserMatrixType);
00522   StandardBetweenWhat = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserBetweenWhat);
00523 
00524   if( StandardMatrixType != "?" && StandardBetweenWhat != "?" )
00525     {
00526       if( StandardBetweenWhat == "Mss" )
00527         {
00528           Int_t n1StexStin = nb_arg_1; 
00529           Int_t i0StinEcha = nb_arg_2;
00530           
00531           if( StandardMatrixType == "Cov" )
00532             {mat = ReadCovariancesBetweenSamples(n1StexStin, i0StinEcha, MatDim);}
00533           
00534           if( StandardMatrixType == "Cor" )
00535             {mat = ReadCorrelationsBetweenSamples(n1StexStin, i0StinEcha, MatDim);}
00536         }
00537 
00538       if( StandardBetweenWhat != "Mss" )
00539         {
00540           Int_t n1StexStin_a = nb_arg_1; 
00541           Int_t n1StexStin_b = nb_arg_2;
00542 
00543           if( StandardMatrixType == "Cov" && StandardBetweenWhat == "MccLF" )
00544             {mat = ReadLowFrequencyCovariancesBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);}
00545 
00546           if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MccLF" )
00547             {mat = ReadLowFrequencyCorrelationsBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);}
00548 
00549           if( StandardMatrixType == "Cov" && StandardBetweenWhat == "MccHF" )
00550             {mat = ReadHighFrequencyCovariancesBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);}
00551 
00552           if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MccHF" )
00553             {mat = ReadHighFrequencyCorrelationsBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);}
00554         }
00555     }
00556   else
00557     {
00558       for(Int_t i=0; i<MatDim; i++)
00559         {for(Int_t j=0; j<MatDim; j++)
00560             {mat(i,j) = (double_t)0.;}}
00561       cout <<"!TEcnaRead::ReadMatrix(...)> UserMatrixType = " << UserMatrixType
00562            << ", UserBetweenWhat = " << UserBetweenWhat
00563            << ". Wrong code(s), no file reading." << fTTBELL << endl;
00564     }
00565   return mat;
00566 }
00567 
00568 TMatrixD TEcnaRead::ReadMatrix(const Int_t& MatDim, const TString UserMatrixType, const TString UserBetweenWhat)
00569 {
00570   //------------------- (BIG MATRIX 1700x1700 for barrel, 5000x5000 for endcap) ------------------
00571   TMatrixD mat(MatDim, MatDim);
00572   TString CallingMethod = "2D";
00573   TString StandardMatrixType  = "?";
00574   TString StandardBetweenWhat = "?";
00575 
00576   StandardMatrixType  = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserMatrixType);
00577   StandardBetweenWhat = fCnaParHistos->BuildStandardHistoCode(CallingMethod, UserBetweenWhat);
00578 
00579   if( StandardMatrixType != "?" && StandardBetweenWhat != "?" )
00580     {
00581       //......................... between channels (covariances, correlations)
00582       if( StandardMatrixType == "Cov" && StandardBetweenWhat == "MccLF" )
00583         {mat = ReadLowFrequencyCovariancesBetweenChannels(MatDim);}
00584 
00585       if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MccLF" )
00586         {mat = ReadLowFrequencyCorrelationsBetweenChannels(MatDim);}
00587 
00588       if( StandardMatrixType == "Cov" && StandardBetweenWhat == "MccHF" )
00589         {mat = ReadHighFrequencyCovariancesBetweenChannels(MatDim);}
00590 
00591       if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MccHF" )
00592         {mat = ReadHighFrequencyCorrelationsBetweenChannels(MatDim);}
00593 
00594       //......................... between Stins (mean correlations)
00595       if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MttLF" )
00596         {mat = ReadLowFrequencyMeanCorrelationsBetweenStins(MatDim);}
00597 
00598       if( StandardMatrixType == "Cor" && StandardBetweenWhat == "MttHF" )
00599         {mat = ReadHighFrequencyMeanCorrelationsBetweenStins(MatDim);}
00600   }
00601   else
00602     {
00603       for(Int_t i=0; i<MatDim; i++)
00604         {for(Int_t j=0; j<MatDim; j++)
00605             {mat(i,j) = (double_t)0.;}}
00606       cout <<"!TEcnaRead::ReadMatrix(...)> UserMatrixType = " << UserMatrixType
00607            << ", UserBetweenWhat = " << UserBetweenWhat
00608            << ". Wrong code(s), no file reading." << fTTBELL << endl;
00609     }
00610   return mat;
00611 }
00612 
00613 //============================================================================
00614 TString TEcnaRead::GetTechReadCode(const TString StandardQuantity, const TString StandardDetector)
00615 {
00616   TString rTechReadCode = "?";
00617   TString dTechDetector = "?";
00618 
00619   if( StandardDetector == "SM" || StandardDetector == "Dee"){dTechDetector = "Stex";}
00620   if( StandardDetector == "EB" || StandardDetector == "EE" ){dTechDetector = "Stas";}
00621 
00622   if( dTechDetector == "?")
00623     {
00624       cout << "!TEcnaRead::GetTechReadCode(...)> *** ERROR: wrong standard code *** dTechDetector = "
00625            << dTechDetector << ", StandardDetector = " << StandardDetector
00626            << fTTBELL << endl;
00627     }
00628   else
00629     {
00630       if( StandardQuantity == "NOE" && dTechDetector == "Stex" ){rTechReadCode = "NOEStex";}
00631       if( StandardQuantity == "NOE" && dTechDetector == "Stas" ){rTechReadCode = "NOEStas";}
00632       if( StandardQuantity == "Ped" && dTechDetector == "Stex" ){rTechReadCode = "PedStex";}
00633       if( StandardQuantity == "Ped" && dTechDetector == "Stas" ){rTechReadCode = "PedStas";}
00634       if( StandardQuantity == "TNo" && dTechDetector == "Stex" ){rTechReadCode = "TNoStex";}
00635       if( StandardQuantity == "TNo" && dTechDetector == "Stas" ){rTechReadCode = "TNoStas";}
00636       if( StandardQuantity == "LFN" && dTechDetector == "Stex" ){rTechReadCode = "LFNStex";}
00637       if( StandardQuantity == "LFN" && dTechDetector == "Stas" ){rTechReadCode = "LFNStas";}
00638       if( StandardQuantity == "HFN" && dTechDetector == "Stex" ){rTechReadCode = "HFNStex";}
00639       if( StandardQuantity == "HFN" && dTechDetector == "Stas" ){rTechReadCode = "HFNStas";}
00640       if( StandardQuantity == "MCs" && dTechDetector == "Stex" ){rTechReadCode = "MCsStex";}
00641       if( StandardQuantity == "MCs" && dTechDetector == "Stas" ){rTechReadCode = "MCsStas";}
00642       if( StandardQuantity == "SCs" && dTechDetector == "Stex" ){rTechReadCode = "SCsStex";}
00643       if( StandardQuantity == "SCs" && dTechDetector == "Stas" ){rTechReadCode = "SCsStas";}
00644     }
00645 
00646   if( rTechReadCode == "?")
00647     {
00648       cout << "!TEcnaRead::GetTechReadCode(...)> *** ERROR: wrong standard code *** rTechReadCode = " << rTechReadCode
00649            << ", StandardQuantity = " << StandardQuantity
00650            << fTTBELL << endl;
00651     }
00652 
00653   return rTechReadCode;
00654 }
00655 
00656 //==========================================================================================
00657 //
00658 //                             FileParameters(...)
00659 //                  
00660 //==========================================================================================
00661 void TEcnaRead::FileParameters(TString      typ_ana,    const Int_t& nb_of_samples,
00662                                const Int_t& run_number, const Int_t& nfirst,
00663                                const Int_t& nlast,      const Int_t& nreqevts,
00664                                const Int_t& Stex,       TString      path_root)
00665 {
00666   // Preparation for reading the ROOT file
00667   // Preliminary save of the arguments values because they can be of the form: fFileHeader->...
00668   // and because fFileHeader can be deleted and re-created in this method
00669 
00670   TString sTypAna      = typ_ana;
00671   Int_t   nNbOfSamples = nb_of_samples;
00672   Int_t   nRunNumber   = run_number;
00673   Int_t   nFirstEvt    = nfirst;
00674   Int_t   nLastEvt     = nlast;
00675   Int_t   nReqNbOfEvts = nreqevts;
00676   Int_t   nStexNumber  = Stex;
00677 
00678   //................................................................................................
00679   const Text_t *h_name  = "CnaHeader";   //==> voir cette question avec FXG
00680   const Text_t *h_title = "CnaHeader";   //==> voir cette question avec FXG
00681 
00682   // "CnaHeader" est le nom du fichier utilisé dans ReadRootFileHeader(...) sous la forme:
00683   //
00684   // TEcnaHeader *h;
00685   // h =(TEcnaHeader*)gCnaRootFile->fRootFile->Get("CnaHeader");
00686   //
00687 
00688   //----------- old version, with arguments h_name, h_title, (FXG) ----------
00689   //
00690   // fFileHeader->HeaderParameters(h_name,    h_title,
00691   //                               sTypAna,   nNbOfSamples, nRunNumber,
00692   //                               nFirstEvt, nLastEvt, nReqNbOfEvts, nStexNumber);
00693   //
00694   //-------------------------------------------------------------------------
00695 
00696   //---------- new version
00697   if( fFileHeader == 0 ){fFileHeader = new TEcnaHeader(fObjectManager, h_name, h_title);  /* Anew("fFileHeader") */ ;}
00698   fFileHeader->HeaderParameters(sTypAna,   nNbOfSamples, nRunNumber,
00699                                 nFirstEvt, nLastEvt,     nReqNbOfEvts, nStexNumber);
00700 
00701   // After this call to TEcnaHeader, we have:
00702   //     fFileHeader->fTypAna            = sTypAna
00703   //     fFileHeader->fNbOfSamples       = nNbOfSamples
00704   //     fFileHeader->fRunNumber         = nRunNumber
00705   //     fFileHeader->fFirstReqEvtNumber = nFirstEvt
00706   //     fFileHeader->fLastReqEvtNumber  = nLastEvt
00707   //     fFileHeader->fReqNbOfEvts       = nReqNbOfEvts
00708   //     fFileHeader->fStex              = nStexNumber                       ( FileParameters(...) )
00709   //.......................... path_root
00710   fPathRoot = path_root;
00711 
00712   //-------- gets the arguments for the file names (long and short) and makes these names
00713   fCnaWrite->RegisterFileParameters(typ_ana, nb_of_samples, run_number, nfirst, nlast, nreqevts, Stex);
00714   fCnaWrite->fMakeResultsFileName();
00715   //         names can be now recovered by call to TEcnaWrite methods: GetRootFileName() and GetRootFileNameShort()
00716 
00717   //------------------------- init Stin numbers memo flags
00718   fMemoStinNumbers = 0;
00719 
00720   if( fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments )
00721     {
00722       cout << endl;
00723       cout << "*TEcnaRead::FileParameters(...)>" << endl
00724            << "          The method has been called with the following argument values:" << endl
00725            << "          Analysis name                = "
00726            << fFileHeader->fTypAna << endl
00727            << "          Nb of required samples       = "
00728            << fFileHeader->fNbOfSamples << endl
00729            << "          Run number                   = "
00730            << fFileHeader->fRunNumber << endl
00731            << "          First requested event number = "
00732            << fFileHeader->fFirstReqEvtNumber << endl
00733            << "          Last requested event number  = "
00734            << fFileHeader->fLastReqEvtNumber << endl
00735            << "          Requested number of events   = "
00736            << fFileHeader->fReqNbOfEvts << endl
00737            << "          Stex number                  = "
00738            << fFileHeader->fStex << endl
00739            << "          Path for the ROOT file       = "
00740            << fPathRoot << endl
00741            << endl;
00742     }
00743   
00744   fReadyToReadRootFile = 1;           // set flag
00745 
00746 } //----------------- end of FileParameters(...)
00747 
00748 //=========================================================================
00749 //
00750 //   GetAnalysisName, GetNbOfSamples, GetRunNumber, GetFirstReqEvtNumber
00751 //   GetLastReqEvtNumber, GetReqNbOfEvts, GetStexNumber
00752 //
00753 //=========================================================================
00754 TString TEcnaRead::GetAnalysisName()     {return fFileHeader->fTypAna;}
00755 Int_t   TEcnaRead::GetNbOfSamples()      {return fFileHeader->fNbOfSamples;}
00756 Int_t   TEcnaRead::GetRunNumber()        {return fFileHeader->fRunNumber;}
00757 Int_t   TEcnaRead::GetFirstReqEvtNumber(){return fFileHeader->fFirstReqEvtNumber;}
00758 Int_t   TEcnaRead::GetLastReqEvtNumber() {return fFileHeader->fLastReqEvtNumber;}
00759 Int_t   TEcnaRead::GetReqNbOfEvts()      {return fFileHeader->fReqNbOfEvts;}
00760 Int_t   TEcnaRead::GetStexNumber()       {return fFileHeader->fStex;}
00761 //=========================================================================
00762 //
00763 //     GetStartDate, GetStopDate, GetRunType
00764 //
00765 //=========================================================================
00766 time_t  TEcnaRead::GetStartTime(){return fFileHeader->fStartTime;}
00767 time_t  TEcnaRead::GetStopTime() {return fFileHeader->fStopTime;}
00768 TString TEcnaRead::GetStartDate(){return fFileHeader->fStartDate;}
00769 TString TEcnaRead::GetStopDate() {return fFileHeader->fStopDate;}
00770 TString TEcnaRead::GetRunType()
00771 {
00772   TString cType = "run type not defined";
00773   Int_t numtype = fFileHeader->fRunType;
00774   //----------------------------------------- run types
00775 
00776   if( numtype ==  0 ){cType = "COSMICS";}
00777   if( numtype ==  1 ){cType = "BEAMH4";}
00778   if( numtype ==  2 ){cType = "BEAMH2";}
00779   if( numtype ==  3 ){cType = "MTCC";}
00780   if( numtype ==  4 ){cType = "LASER_STD";}
00781   if( numtype ==  5 ){cType = "LASER_POWER_SCAN";}
00782   if( numtype ==  6 ){cType = "LASER_DELAY_SCAN";}
00783   if( numtype ==  7 ){cType = "TESTPULSE_SCAN_MEM";}
00784   if( numtype ==  8 ){cType = "TESTPULSE_MGPA";}
00785   if( numtype ==  9 ){cType = "PEDESTAL_STD";}
00786   if( numtype == 10 ){cType = "PEDESTAL_OFFSET_SCAN";}
00787   if( numtype == 11 ){cType = "PEDESTAL_25NS_SCAN";}
00788   if( numtype == 12 ){cType = "LED_STD";}
00789 
00790   if( numtype == 13 ){cType = "PHYSICS_GLOBAL";}
00791   if( numtype == 14 ){cType = "COSMICS_GLOBAL";}
00792   if( numtype == 15 ){cType = "HALO_GLOBAL";}
00793 
00794   if( numtype == 16 ){cType = "LASER_GAP";}
00795   if( numtype == 17 ){cType = "TESTPULSE_GAP";}
00796   if( numtype == 18 ){cType = "PEDESTAL_GAP";}
00797   if( numtype == 19 ){cType = "LED_GAP";}
00798 
00799   if( numtype == 20 ){cType = "PHYSICS_LOCAL";}
00800   if( numtype == 21 ){cType = "COSMICS_LOCAL";}
00801   if( numtype == 22 ){cType = "HALO_LOCAL";}
00802   if( numtype == 23 ){cType = "CALIB_LOCAL";}
00803 
00804   if( numtype == 24 ){cType = "PEDSIM";}
00805 
00806   return cType;
00807 }
00808 //==========================================================================
00809 //
00810 //                       R E A D    M E T H O D S  
00811 //                      (   R O O T    F I L E  )
00812 //
00813 //==========================================================================
00814 //-------------------------------------------------------------
00815 //
00816 //                      OpenRootFile
00817 //
00818 //-------------------------------------------------------------
00819 Bool_t TEcnaRead::OpenRootFile(const Text_t *name, TString status) {
00820 //Open the Root file
00821 
00822   Bool_t ok_open = kFALSE;
00823 
00824   TString s_name;
00825   s_name = fPathRoot;
00826   s_name.Append('/');
00827   s_name.Append(name);
00828 
00829   // if( gCnaRootFile != 0 )
00830   //  {
00831   //    Int_t iPointer = (Int_t)gCnaRootFile;
00832   //   cout << "*TEcnaRead::OpenRootFile(...)> RootFile pointer not (re)initialized to 0. gCnaRootFile = "
00833   //       << gCnaRootFile << ", pointer =  " << iPointer << fTTBELL << endl;
00834   //
00835   //   delete gCnaRootFile; gCnaRootFile = 0;  Adelete("gCnaRootFile");
00836   //  }
00837 
00838   //if( gCnaRootFile != 0 ){gCnaRootFile->ReStart(s_name.Data(), status);}
00839   //if( gCnaRootFile == 0 )
00840   //  {
00841       // gCnaRootFile = new TEcnaRootFile(fObjectManager, s_name.Data(), status);  Anew("gCnaRootFile");
00842 
00843       Int_t iCnaRootFile = fObjectManager->GetPointerValue("TEcnaRootFile");
00844       if( iCnaRootFile == 0 )
00845         {
00846           gCnaRootFile = new TEcnaRootFile(fObjectManager, s_name.Data(), status); /* Anew("gCnaRootFile");*/
00847         }
00848       else
00849         { 
00850           gCnaRootFile = (TEcnaRootFile*)iCnaRootFile;
00851           gCnaRootFile->ReStart(s_name.Data(), status);
00852         }
00853   //  }
00854   
00855   if ( gCnaRootFile->fRootFileStatus == "RECREATE" ){ok_open = gCnaRootFile->OpenW();}
00856   if ( gCnaRootFile->fRootFileStatus == "READ"     ){ok_open = gCnaRootFile->OpenR();}
00857 
00858   if ( ok_open == kFALSE )
00859     {
00860       cout << "!TEcnaRead::OpenRootFile> " << s_name.Data() << ": file not found." << endl;
00861       //if( gCnaRootFile != 0 )
00862       //  {delete gCnaRootFile; gCnaRootFile = 0;  Adelete("gCnaRootFile");}
00863     }
00864   else
00865     {
00866       if(fFlagPrint == fCodePrintAllComments)
00867         {
00868           cout << "*TEcnaRead::OpenRootFile> Open ROOT file " << s_name.Data() << " OK "
00869                << ", gCnaRootFile = " << gCnaRootFile << endl;
00870         }      
00871       fOpenRootFile = kTRUE;
00872       fCurrentlyOpenFileName = s_name;
00873       if(fFlagPrint == fCodePrintAllComments)
00874         {
00875           cout << "*TEcnaRead::OpenRootFile> Open ROOT file: " << fCurrentlyOpenFileName.Data() << " => OK "
00876                << ", gCnaRootFile = " << gCnaRootFile << endl << endl;
00877         }
00878     }
00879   return ok_open;
00880 }                     // end of OpenRootFile()
00881 
00882 //-------------------------------------------------------------
00883 //
00884 //                      CloseRootFile
00885 //
00886 //-------------------------------------------------------------
00887 Bool_t TEcnaRead::CloseRootFile(const Text_t *name) {
00888 //Close the Root file
00889  
00890   Bool_t ok_close = kFALSE;
00891 
00892   if (fOpenRootFile == kTRUE ) 
00893     {
00894       if( gCnaRootFile != 0 )
00895         {
00896           gCnaRootFile->CloseFile();
00897           
00898           if(fFlagPrint == fCodePrintAllComments){
00899             TString e_path;  e_path.Append(name);
00900             cout << "*TEcnaRead::CloseRootFile> Close ROOT file " << e_path.Data() << " OK " << endl;}
00901           if(fFlagPrint == fCodePrintAllComments){
00902             Long_t pointer_value = (Long_t)gCnaRootFile;
00903             cout << "*TEcnaRead::CloseRootFile(...)> going to delete gCnaRootFile, gCnaRootFile = " << gCnaRootFile
00904                  << ", pointer = " << pointer_value << endl;}
00905 
00906           //delete gCnaRootFile;   gCnaRootFile = 0;  Adelete("gCnaRootFile");
00907           
00908           ok_close      = kTRUE;
00909           fOpenRootFile = kFALSE;
00910           fCurrentlyOpenFileName = fFlagNoFileOpen;
00911           fReadyToReadRootFile = 0;
00912         }
00913       else
00914         {
00915           cout << "*TEcnaRead::CloseRootFile(...)> RootFile pointer equal to zero. Close not possible. gCnaRootFile = "
00916                << gCnaRootFile
00917                << fTTBELL << endl;
00918         }
00919     }
00920   else
00921     {
00922       cout << "*TEcnaRead::CloseRootFile(...)> no close since no file is open. fOpenRootFile = " << fOpenRootFile
00923            << endl;
00924     }
00925   return ok_close;
00926 }
00927 
00928 //============================================================================
00929 //
00930 //                      LookAtRootFile()
00931 //                   Called by TEcnaHistos
00932 //                  
00933 //============================================================================
00934 Bool_t TEcnaRead::LookAtRootFile()
00935 {
00936 //---------- Reads the ROOT file header and makes allocations and some other things
00937 
00938   fLookAtRootFile = 0;          // set flag to zero before looking for the file
00939 
00940   Bool_t ok_read = kFALSE;
00941 
00942   if(fReadyToReadRootFile == 1)
00943     {
00944       //------------ Call to ReadRootFileHeader
00945       Int_t iprint = 0;
00946       if( ReadRootFileHeader(iprint) == kTRUE )   //    (1) = print, (0) = no print
00947         {
00948           //........................................ allocation tags      
00949           if( fTagStinNumbers == 0 ){fTagStinNumbers = new Int_t[1]; Anew("fTagStinNumbers");}
00950 
00951           //...................... allocation for fT1d_StexStinFromIndex[]
00952           if(fT1d_StexStinFromIndex == 0)
00953             {fT1d_StexStinFromIndex = new Int_t[fEcal->MaxStinEcnaInStex()]; Anew("fT1d_StexStinFromIndex");}
00954           
00955           //.. recover of the Stin numbers from the ROOT file (= init fT1d_StexStinFromIndex+init TagStin)
00956           TVectorD vec(fEcal->MaxStinEcnaInStex());
00957           for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
00958           vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
00959           
00960           for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++ ){
00961             fT1d_StexStinFromIndex[i] = (Int_t)vec(i);}
00962 
00963           fTagStinNumbers[0] = 1;                fFileHeader->fStinNumbersCalc++;
00964           ok_read = kTRUE;
00965           
00966           fLookAtRootFile = 1;           // set flag
00967         }
00968       else
00969         {
00970           cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
00971                << " ROOT file not found " << fTTBELL << endl;
00972           ok_read = kFALSE; 
00973         }
00974     }
00975   else
00976     {
00977       cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
00978            << " FileParameters not called " << fTTBELL << endl;
00979       ok_read = kFALSE;      
00980     }
00981   return ok_read;
00982 } //----------------- end of LookAtRootFile()
00983 //-------------------------------------------------------------------------
00984 //
00985 //                     DataExist()
00986 //
00987 //     DON'T SUPPRESS: CALLED BY ANOTHER CLASSES
00988 //
00989 //-------------------------------------------------------------------------
00990 Bool_t TEcnaRead::DataExist()
00991 {
00992   // return kTRUE if the data are present in the ROOT file, kFALSE if not.
00993   // fDataExist is set in the read methods
00994 
00995   return fDataExist;
00996 }
00997 //-------------------------------------------------------------------------
00998 //
00999 //                     ReadRootFileHeader
01000 //
01001 //-------------------------------------------------------------------------
01002 Bool_t TEcnaRead::ReadRootFileHeader(const Int_t& i_print)
01003 {
01004 //Read the header of the Root file => test the file existence
01005 
01006   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01007   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01008 
01009   if( i_print == 1 ){cout << "*TEcnaRead::ReadRootFileHeader> file_name = "
01010                          << fCnaWrite->fRootFileNameShort.Data() << endl;}
01011 
01012   Bool_t ok_open = kFALSE;
01013   Bool_t ok_read = kFALSE;
01014  
01015   TString FileNameLong = fCnaWrite->GetRootFileName(); 
01016   Bool_t allowed_to_read = kFALSE;
01017 
01018   //  if( fOpenRootFile )
01019   //    {
01020   //      cout << "!TEcnaRead::ReadRootFileHeader(...)*** ERROR ***> "
01021   //       << "Reading header on file already open." << endl;
01022   //    }
01023 
01024   if( FileNameLong == fCurrentlyOpenFileName )
01025     {
01026       allowed_to_read = kTRUE;
01027     }
01028   else
01029     {
01030       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01031       ok_open = OpenRootFile(file_name, "READ");
01032       if(ok_open)
01033         {
01034           allowed_to_read = kTRUE;
01035         }
01036       else
01037         {
01038           cout << "!TEcnaRead::ReadRootFileHeader(...) *** ERROR ***> Open .root file failed for file: "
01039                << file_name << fTTBELL << endl;
01040           allowed_to_read = kFALSE;
01041         }
01042     }
01043 
01044   if( allowed_to_read == kTRUE )
01045     {
01046       TEcnaHeader *headerFile;
01047       headerFile =(TEcnaHeader*)gCnaRootFile->fRootFile->Get("CnaHeader");
01048 
01049       //..... get the attributes which are not already set by the call to TEcnaHeader
01050       //      in FileParameters(...) and are only available in the ROOT file
01051 
01052       fFileHeader->fStartTime = headerFile->fStartTime;
01053       fFileHeader->fStopTime  = headerFile->fStopTime;
01054       fFileHeader->fStartDate = headerFile->fStartDate;
01055       fFileHeader->fStopDate  = headerFile->fStopDate;
01056 
01057       fFileHeader->fRunType   = headerFile->fRunType;
01058 
01059       //....... Les f..Calc dans le header: pour acces direct a la taille des differentes data du fichier
01060       fFileHeader->fStinNumbersCalc = headerFile->fStinNumbersCalc;
01061       fFileHeader->fAdcEvtCalc      = headerFile->fAdcEvtCalc;
01062       fFileHeader->fMSpCalc         = headerFile->fMSpCalc;
01063       fFileHeader->fSSpCalc         = headerFile->fSSpCalc;
01064       fFileHeader->fAvTnoCalc       = headerFile->fAvTnoCalc;
01065       fFileHeader->fAvLfnCalc       = headerFile->fAvLfnCalc;
01066       fFileHeader->fAvHfnCalc       = headerFile->fAvHfnCalc;
01067 
01068       fFileHeader->fCovCssCalc      = headerFile->fCovCssCalc;
01069       fFileHeader->fCorCssCalc      = headerFile->fCorCssCalc;
01070       fFileHeader->fHfCovCalc       = headerFile->fHfCovCalc;
01071       fFileHeader->fHfCorCalc       = headerFile->fHfCorCalc;
01072       fFileHeader->fLfCovCalc       = headerFile->fLfCovCalc;
01073       fFileHeader->fLfCorCalc       = headerFile->fLfCorCalc;
01074       fFileHeader->fLFccMoStinsCalc = headerFile->fLFccMoStinsCalc;
01075       fFileHeader->fHFccMoStinsCalc = headerFile->fHFccMoStinsCalc;
01076       fFileHeader->fMeanCorssCalc   = headerFile->fMeanCorssCalc;
01077       fFileHeader->fSigCorssCalc    = headerFile->fSigCorssCalc;
01078 
01079       fFileHeader->fAvPedCalc       = headerFile->fAvPedCalc;
01080       fFileHeader->fAvMeanCorssCalc = headerFile->fAvMeanCorssCalc;
01081       fFileHeader->fAvSigCorssCalc  = headerFile->fAvSigCorssCalc;
01082           
01083       if(i_print == 1){fFileHeader->Print();}
01084       ok_read = kTRUE;
01085 
01086       CloseRootFile(file_name);
01087     }
01088   return ok_read;
01089 }
01090 //-------------------------------------------------------------------------
01091 void  TEcnaRead::TestArrayDimH1(const TString CallingMethod, const TString MaxName,
01092                                 const Int_t& MaxValue, const Int_t& VecDim)
01093 {
01094 // array dim test
01095 
01096   if( MaxValue != VecDim)
01097     {
01098       cout << "!TEcnaRead::TestArrayDimH1(...)> No matching for array dimension: CallingMethod: " << CallingMethod.Data()
01099            << ", MaxName: " << MaxName.Data()
01100            << ", Maxvalue = " << MaxValue
01101            << ", VecDim = " << VecDim << fTTBELL << endl;
01102     }
01103 #define NOPM
01104 #ifndef NOPM
01105   else
01106     {
01107       cout << "!TEcnaRead::TestArrayDimH1(...)> matching array dimension: OK. CallingMethod: " << CallingMethod.Data()
01108            << ", MaxName: " << MaxName.Data()
01109            << ", Maxvalue = " << MaxValue
01110            << ", VecDim = " << VecDim << endl;
01111     }
01112 #endif // NOPM
01113 }
01114 //-------------------------------------------------------------------------
01115 void  TEcnaRead::TestArrayDimH2(const TString CallingMethod, const TString MaxName,
01116                                 const Int_t& MaxValue, const Int_t& MatDim)
01117 {
01118 // array dim test
01119 
01120   if( MaxValue != MatDim)
01121     {
01122       cout << "!TEcnaRead::TestArrayDimH2(...)> No matching for array dimension: CallingMethod: " << CallingMethod.Data()
01123            << ", MaxName: " << MaxName.Data()
01124            << ", Maxvalue = " << MaxValue
01125            << ", MatDim = " << MatDim << fTTBELL << endl;
01126     }
01127 #define NOPN
01128 #ifndef NOPN
01129   else
01130     {
01131       cout << "!TEcnaRead::TestArrayDimH2(...)> matching array dimension: OK. CallingMethod: " << CallingMethod.Data()
01132            << ", MaxName: " << MaxName.Data()
01133            << ", Maxvalue = " << MaxValue
01134            << ", MatDim = " << MatDim << endl;
01135     }
01136 #endif // NOPN
01137 }
01138 
01139 //-------------------------------------------------------------------------
01140 //
01141 //                     ReadStinNumbers(...)
01142 //
01143 //-------------------------------------------------------------------------
01144 TVectorD TEcnaRead::ReadStinNumbers(const Int_t& VecDim)
01145 {
01146 //Get the Stin numbers and put them in a TVectorD
01147 //Read the ROOT file at first call and load in a TVectorD attribute
01148 //Get directly the TVectorD attribute at other times
01149 //
01150 // Possible values for VecDim:
01151 //          (1) VecDim = fEcal->MaxStinEcnaInStex()
01152 
01153   TVectorD vec(VecDim);
01154 
01155   TestArrayDimH1("ReadStinNumbers", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
01156 
01157   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01158 
01159   if (fMemoStinNumbers == 0)
01160     {
01161       CnaResultTyp typ = cTypNumbers;
01162       const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01163       const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01164 
01165       //.............. reading of the ROOT file data type TResultTyp = cTypStinsNumbers
01166       //               to get the conversion: Stin index -> Stin number (n1StexStin)
01167 
01168       Bool_t ok_open = kFALSE;
01169       Bool_t ok_read = kFALSE;
01170 
01171       TString FileNameLong = fCnaWrite->GetRootFileName();
01172       Bool_t allowed_to_read = kFALSE;
01173 
01174 //      if ( fOpenRootFile )
01175 //      {
01176 //        cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> Reading on file already open."
01177 //             << fTTBELL << endl;
01178 //      }
01179 
01180       if( FileNameLong == fCurrentlyOpenFileName )
01181         {
01182           allowed_to_read = kTRUE;
01183         }
01184       else
01185         {
01186           if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01187           ok_open = OpenRootFile(file_name, "READ");
01188           
01189           if(ok_open)
01190             {
01191               allowed_to_read = kTRUE;
01192             }
01193           else
01194             {
01195               cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> Open .root file failed for file: "
01196                    << file_name << fTTBELL << endl;
01197               allowed_to_read = kFALSE;
01198               ok_read = kFALSE;
01199             }
01200         }
01201 
01202       if( allowed_to_read == kTRUE )
01203         {
01204           Int_t i_zero = 0;
01205           ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01206           
01207           if( ok_read == kTRUE )
01208             {
01209               fDataExist = kTRUE;
01210               //......... Get the Stin numbers and put them in TVectorD vec()
01211               for ( Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++)
01212                 {
01213                   vec(i_Stin) = gCnaRootFile->fCnaIndivResult->fMatHis(0,i_Stin);
01214                   fT1d_StexStinFromIndex[i_Stin] = (Int_t)vec(i_Stin);
01215                 }
01216               fMemoStinNumbers++;
01217             }
01218           else
01219             {
01220               fDataExist = kFALSE;
01221               cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> "
01222                    << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01223                    << "                                                -> quantity: <"
01224                    << GetTypeOfQuantity(typ) << "> not available in file."
01225                    << fTTBELL << endl;
01226             }
01227           CloseRootFile(file_name);
01228         }
01229       
01230       if( ok_read == kTRUE )
01231         {
01232           //........................... Print the Stin numbers 
01233           if(fFlagPrint == fCodePrintAllComments)
01234             {
01235               for(Int_t i=0; i < VecDim; i++)
01236                 {
01237                   cout << "*TEcnaRead::ReadStinNumbers(...)> StinNumber[" << i << "] = "
01238                        << vec[i] << endl;
01239                 }
01240             }
01241         }
01242     }
01243   else
01244     {
01245       fDataExist = kTRUE;
01246       for ( Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++)
01247         {vec(i_Stin) = fT1d_StexStinFromIndex[i_Stin];}
01248     }
01249   return vec;
01250 } // ----------------- ( end of ReadStinNumbers(...) ) -----------------
01251 
01252 //============================================================================
01253 //
01254 //                       1 D   H I S T O S   (TECHNICAL METHODS)
01255 //
01256 //============================================================================
01257 
01258 //--------------------------------------------------------------------------------------
01259 //
01260 //                 ReadSampleAdcValues(i0StexEcha,sample,fFileHeader->fReqNbOfEvts)  
01261 //
01262 //--------------------------------------------------------------------------------------
01263 TVectorD TEcnaRead::ReadSampleAdcValues(const Int_t& n1StexStin, const Int_t& i0StinEcha,
01264                                         const Int_t& sample,     const Int_t& VecDim)
01265 {
01266 //Read the sample ADC values for each event for a given i0StexEcha and a given sample
01267 //in the results ROOT file and return it in a TVectorD(requested nb of events)
01268 //
01269 //Possible values for VecDim: (1) VecDim = fFileHeader->fReqNbOfEvts
01270 
01271   TestArrayDimH1("ReadSampleAdcValues", "fFileHeader->fReqNbOfEvts", fFileHeader->fReqNbOfEvts, VecDim);
01272 
01273   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01274 
01275   TVectorD vec(VecDim);
01276   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01277 
01278   CnaResultTyp typ = cTypAdcEvt;   //  sample as a function of time type
01279 
01280   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01281   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01282 
01283   Bool_t ok_open = kFALSE;
01284   Bool_t ok_read = kFALSE;
01285 
01286   TString FileNameLong = fCnaWrite->GetRootFileName();
01287   Bool_t allowed_to_read = kFALSE;
01288   
01289   //  if ( fOpenRootFile )
01290   //   {
01291   //     cout << "!TEcnaRead::ReadSampleAdcValues(...) *** ERROR ***> "
01292   //       << "Reading on file already open." << fTTBELL << endl;
01293   //   }
01294   
01295   if( FileNameLong == fCurrentlyOpenFileName )
01296     {
01297       allowed_to_read = kTRUE;
01298     }
01299   else
01300     {
01301       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01302       ok_open = OpenRootFile(file_name, "READ");
01303 
01304       if(ok_open)
01305         {
01306           allowed_to_read = kTRUE;
01307         }
01308       else
01309         {
01310           cout << "!TEcnaRead::ReadSampleAdcValues(...) *** ERROR ***> Open .root file failed for file: "
01311                << file_name << fTTBELL << endl;
01312           allowed_to_read = kFALSE;
01313           ok_read = kFALSE;
01314         }
01315     }
01316   
01317   if( allowed_to_read == kTRUE )
01318     {
01319       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
01320       
01321       if ( ok_read == kTRUE )
01322         {
01323           fDataExist = kTRUE;
01324           for ( Int_t i_bin=0; i_bin<VecDim; i_bin++)
01325             {
01326               vec(i_bin) = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
01327             }   
01328         }
01329       else
01330         {
01331           fDataExist = kFALSE;
01332           cout << "!TEcnaRead::ReadSampleAdcValues(...) *** ERROR ***> "
01333                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01334                << "                                                 -> quantity: <"
01335                << GetTypeOfQuantity(typ) << "> not available in file."
01336                << fTTBELL << endl;
01337         }
01338       CloseRootFile(file_name);
01339     }
01340   return vec;
01341 }
01342 //--- (end of ReadSampleAdcValues) ----------
01343 
01344 
01345 //-------------------------------------------------------------------------
01346 //
01347 //                  ReadSampleMeans  
01348 //
01349 //-------------------------------------------------------------------------
01350 TVectorD TEcnaRead::ReadSampleMeans(const Int_t & n1StexStin, const Int_t & i0StinEcha,
01351                                     const Int_t & VecDim)
01352 {
01353 //Read the expectation values of the samples
01354 //for a given Stin and a given channel
01355 //in the ROOT file and return them in a TVectorD
01356 //
01357 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples
01358 
01359   TestArrayDimH1("ReadSampleMeans", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, VecDim);
01360 
01361   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01362   
01363   TVectorD vec(VecDim);
01364   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01365 
01366   CnaResultTyp typ = cTypMSp;
01367 
01368   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01369   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01370 
01371   Bool_t ok_open = kFALSE;
01372   Bool_t ok_read = kFALSE;
01373 
01374   TString FileNameLong = fCnaWrite->GetRootFileName();
01375   Bool_t allowed_to_read = kFALSE;
01376     
01377   // if ( fOpenRootFile )
01378   //  {
01379   //    cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01380   //       << " Reading on file already open." << fTTBELL << endl;
01381   //  }
01382 
01383   if( FileNameLong == fCurrentlyOpenFileName )
01384     {
01385       allowed_to_read = kTRUE;
01386     }
01387   else
01388     {
01389       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01390       ok_open = OpenRootFile(file_name, "READ");
01391       if(ok_open)
01392         {
01393           allowed_to_read = kTRUE;
01394         }
01395       else
01396         {
01397           cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> Open .root file failed for file: "
01398                << file_name << fTTBELL << endl;
01399           allowed_to_read = kFALSE;
01400           ok_read = kFALSE;
01401         }
01402     }
01403   
01404   if( allowed_to_read == kTRUE )
01405     {
01406       Int_t i_zero = 0;
01407       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01408       
01409       if ( ok_read == kTRUE )
01410         {
01411           fDataExist = kTRUE;
01412           for ( Int_t i_samp = 0; i_samp < VecDim; i_samp++)
01413             {
01414               vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
01415             }   
01416         }
01417       else
01418         {
01419           fDataExist = kFALSE;
01420           cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01421                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01422                << "                                                quantity: <"
01423                << GetTypeOfQuantity(typ) << "> not available in file."
01424                << fTTBELL << endl;
01425         }
01426       CloseRootFile(file_name);
01427     }
01428   return vec;
01429 }
01430 //------------------------------------------------------------------------------------------------
01431 TVectorD TEcnaRead::ReadSampleMeans(const Int_t & n1StexStin, const Int_t & VecDim)
01432 {
01433 //Read the expectation values of the samples
01434 //for all the channel of a given Stin 
01435 //in the ROOT file and return them in a TVectorD
01436 //
01437 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()
01438 
01439   TestArrayDimH1("ReadSampleMeans", "fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()",
01440                  fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin() , VecDim);
01441   
01442   TVectorD vec(VecDim);
01443   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01444 
01445   CnaResultTyp typ = cTypMSp;
01446 
01447   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01448   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01449 
01450   Bool_t ok_open = kFALSE;
01451   Bool_t ok_read = kFALSE;
01452 
01453   TString FileNameLong = fCnaWrite->GetRootFileName();
01454   Bool_t allowed_to_read = kFALSE;
01455       
01456   //if ( fOpenRootFile )
01457   //  {
01458   //    cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01459   //       << " Reading on file already open." << fTTBELL << endl;
01460   //  }
01461 
01462   if( FileNameLong == fCurrentlyOpenFileName )
01463     {
01464       allowed_to_read = kTRUE;
01465     } 
01466   else
01467     {
01468       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01469       ok_open = OpenRootFile(file_name, "READ");
01470 
01471       if(ok_open)
01472         {
01473           allowed_to_read = kTRUE;
01474         }
01475       else
01476         {
01477           cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> Open .root file failed for file: "
01478                << file_name << fTTBELL << endl;
01479           allowed_to_read = kFALSE;
01480           ok_read = kFALSE;
01481         }
01482     }
01483   
01484   if( allowed_to_read == kTRUE )
01485     {
01486       Int_t i_zero = 0;
01487       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01488       
01489       if ( ok_read == kTRUE )
01490         {
01491           fDataExist = kTRUE;
01492 
01493           for( Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++ )
01494             {
01495               Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01496               for ( Int_t i_samp=0; i_samp<fFileHeader->fNbOfSamples; i_samp++ )
01497                 {
01498                   vec(i0StinEcha*fFileHeader->fNbOfSamples+i_samp) =
01499                     gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
01500                 }
01501             }   
01502         }
01503       else
01504         {
01505           fDataExist = kFALSE;
01506           cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01507                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01508                << "                                                -> quantity: <"
01509                << GetTypeOfQuantity(typ) << "> not available in file."
01510                << fTTBELL << endl;
01511         }
01512       CloseRootFile(file_name);
01513     }
01514   return vec;
01515 }
01516 
01517 //-------------------------------------------------------------------------
01518 //
01519 //                  ReadSampleSigmas  
01520 //                   
01521 //-------------------------------------------------------------------------
01522 TVectorD TEcnaRead::ReadSampleSigmas(const Int_t & n1StexStin, const Int_t & i0StinEcha,
01523                                      const Int_t & VecDim)
01524 {
01525 //Read the expectation values of the samples
01526 //for a given Stin and a given channel
01527 //in the ROOT file and return them in a TVectorD
01528 //
01529 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples
01530 
01531   TestArrayDimH1("ReadSampleSigmas", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, VecDim);
01532 
01533   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01534   
01535   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01536 
01537   CnaResultTyp typ = cTypSSp;
01538 
01539   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01540   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01541 
01542   Bool_t ok_open = kFALSE;
01543   Bool_t ok_read = kFALSE;
01544 
01545   TString FileNameLong = fCnaWrite->GetRootFileName();
01546   Bool_t allowed_to_read = kFALSE;
01547      
01548   //if ( fOpenRootFile )
01549   //  {
01550   //    cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01551   //       << "Reading on file already open." << fTTBELL << endl;
01552   //  }
01553 
01554   if( FileNameLong == fCurrentlyOpenFileName )
01555     {
01556       allowed_to_read = kTRUE;
01557     }
01558   else
01559     {
01560       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01561       ok_open = OpenRootFile(file_name, "READ");
01562 
01563       if(ok_open)
01564         {
01565           allowed_to_read = kTRUE;
01566         }
01567       else
01568         {
01569           cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> Open .root file failed for file: "
01570                << file_name << fTTBELL << endl;
01571           allowed_to_read = kFALSE;
01572           ok_read = kFALSE;
01573         }
01574     }
01575   
01576   if( allowed_to_read == kTRUE )
01577     {
01578       Int_t i_zero = 0;
01579       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01580       
01581       if ( ok_read == kTRUE )
01582         {
01583           fDataExist = kTRUE;
01584           for ( Int_t i_samp = 0; i_samp < VecDim; i_samp++)
01585             {
01586               vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha,i_samp);
01587             }   
01588         }
01589       else
01590         {
01591           fDataExist = kFALSE;
01592           cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01593                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01594                << "                                                 -> quantity: <"
01595                << GetTypeOfQuantity(typ) << "> not available in file."
01596                << fTTBELL << endl;
01597         }
01598       CloseRootFile(file_name);
01599     }
01600   return vec;
01601 }
01602 //------------------------------------------------------------------------------------------------
01603 TVectorD TEcnaRead::ReadSampleSigmas(const Int_t & n1StexStin, const Int_t & VecDim)
01604 {
01605 //Read the expectation values of the samples
01606 //for all the channel of a given Stin
01607 //in the ROOT file and return them in a TVectorD
01608 //
01609 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()
01610 
01611   TestArrayDimH1("ReadSampleSigmas", "fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()", 
01612                  fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin(), VecDim);
01613   
01614   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01615 
01616   CnaResultTyp typ = cTypSSp;
01617 
01618   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01619   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01620 
01621   Bool_t ok_open = kFALSE;
01622   Bool_t ok_read = kFALSE;
01623 
01624   TString FileNameLong = fCnaWrite->GetRootFileName();
01625   Bool_t allowed_to_read = kFALSE;
01626        
01627   //if ( fOpenRootFile )
01628   //  {
01629   //    cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01630   //       << "Reading on file already open." << fTTBELL << endl;
01631   // }
01632 
01633   if( FileNameLong == fCurrentlyOpenFileName )
01634     {
01635       allowed_to_read = kTRUE;
01636     }
01637   else
01638     {
01639       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01640       ok_open = OpenRootFile(file_name, "READ");
01641 
01642       if(ok_open)
01643         {
01644           allowed_to_read = kTRUE;
01645         }
01646       else
01647         {
01648           cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> Open .root file failed for file: "
01649                << file_name << fTTBELL << endl;
01650           allowed_to_read = kFALSE;
01651           ok_read = kFALSE;
01652         }
01653     }
01654   
01655   if( allowed_to_read == kTRUE )
01656     {
01657       Int_t i_zero = 0;
01658       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01659       
01660       if ( ok_read == kTRUE )
01661         {
01662           fDataExist = kTRUE;
01663 
01664           for( Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++ )
01665             {
01666               Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01667               for ( Int_t i_samp = 0; i_samp < fFileHeader->fNbOfSamples; i_samp++)
01668                 {
01669                   vec(i0StinEcha*fFileHeader->fNbOfSamples+i_samp) =
01670                     gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha,i_samp);
01671                 }
01672             }   
01673         }
01674       else
01675         {
01676           fDataExist = kFALSE;
01677           cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01678                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01679                << "                                                 -> quantity: <"
01680                << GetTypeOfQuantity(typ) << "> not available in file."
01681                << fTTBELL << endl;
01682         }
01683       CloseRootFile(file_name);
01684     }
01685   return vec;
01686 }
01687 
01688 //-----------------------------------------------------------------------------
01689 //
01690 //                  ReadNumberOfEvents(...)
01691 //
01692 //-----------------------------------------------------------------------------
01693 TVectorD TEcnaRead::ReadNumberOfEvents(const Int_t& VecDim)
01694 {
01695 //Read the numbers of found events in the data
01696 //for the crystals and for the samples for all the Stin's in the Stex
01697 //in the ROOT file, compute the average on the samples
01698 //and return them in a TVectorD(MaxCrysEcnaInStex)
01699 //
01700 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
01701 
01702   TestArrayDimH1("ReadNumberOfEvents", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
01703 
01704   TVectorD vec(VecDim);
01705   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01706 
01707   TMatrixD mat(fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
01708 
01709   for(Int_t iStexStin=0; iStexStin<fEcal->MaxStinEcnaInStex(); iStexStin++)
01710     {
01711       //............. set mat(,) to zero before reading it
01712       for(Int_t i=0; i<fEcal->MaxCrysInStin(); i++)
01713         {for(Int_t j=0; j<fFileHeader->fNbOfSamples; j++){mat(i,j)=(Double_t)0.;}}
01714       //............. read mat(,)
01715       Int_t n1StexStin = iStexStin+1;
01716       mat = ReadNumberOfEventsForSamples(n1StexStin, fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
01717 
01718       for(Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++)
01719         {
01720           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01721           vec(i0StexEcha) = 0; 
01722           //.... average value over the samples
01723           for(Int_t i_samp=0; i_samp<fFileHeader->fNbOfSamples; i_samp++)
01724             {vec(i0StexEcha) += mat(i0StinEcha, i_samp);}
01725           vec(i0StexEcha) = vec(i0StexEcha)/fFileHeader->fNbOfSamples;
01726         } 
01727     }
01728   return vec;
01729 }
01730 
01731 //-----------------------------------------------------------------------------
01732 //
01733 //                  ReadNumberOfEventsForSamples 
01734 //
01735 //-----------------------------------------------------------------------------
01736 TMatrixD TEcnaRead::ReadNumberOfEventsForSamples(const Int_t& n1StexStin,
01737                                                  const Int_t& MatDimX, const Int_t& MatDimY)
01738 {
01739 //Read the numbers of found events in the data
01740 //for the crystals and for the samples, for a given Stin in the Stex
01741 //in the ROOT file and return them in a TMatrixD(MaxCrysInStin,NbOfSamples)
01742 //
01743 //Possible values for MatDimX and MatDimY:
01744 //  (1) MatDimX = fEcal->MaxCrysInStin(), MatDimY = fFileHeader->fNbOfSamples
01745 
01746 
01747 
01748   TMatrixD mat(MatDimX, MatDimY);
01749   for(Int_t i=0; i<MatDimX; i++)
01750     {for(Int_t j=0; j<MatDimY; j++){mat(i,j)=(Double_t)0.;}}
01751 
01752   Int_t Stin_index = GetStinIndex(n1StexStin);
01753   if( Stin_index >= 0 )
01754     {
01755       if(fLookAtRootFile == 1)
01756         {
01757           CnaResultTyp typ = cTypNbOfEvts;
01758           const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01759           const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01760           
01761           Bool_t ok_open = kFALSE;
01762           Bool_t ok_read = kFALSE;
01763           
01764           TString FileNameLong = fCnaWrite->GetRootFileName();
01765           Bool_t allowed_to_read = kFALSE;
01766           
01767           //      if ( fOpenRootFile )
01768           //        {
01769           //          cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01770           //               << " Reading on file already open." << fTTBELL << endl;
01771           //        }
01772 
01773           if( FileNameLong == fCurrentlyOpenFileName  )
01774             {
01775               allowed_to_read = kTRUE;
01776             }
01777           else
01778             {
01779               if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01780               ok_open = OpenRootFile(file_name, "READ");  // set fOpenRootFile to kTRUE
01781               if(ok_open)
01782                 {
01783                   allowed_to_read = kTRUE;
01784                 }
01785               else
01786                 {
01787                   cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> Open .root file failed for file: "
01788                        << file_name << fTTBELL << endl;
01789                   allowed_to_read = kFALSE;
01790                   ok_read = kFALSE;
01791                 }
01792             }
01793           
01794           if( allowed_to_read == kTRUE )
01795             {
01796               Int_t i_zero = 0;
01797               ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01798               
01799               if ( ok_read == kTRUE )
01800                 {
01801                   fDataExist = kTRUE;
01802                   for (Int_t i_crys=0; i_crys<MatDimX; i_crys++)
01803                     {                 
01804                       Int_t j_cna_chan = Stin_index*MatDimX + i_crys;
01805                       for ( Int_t i_samp=0; i_samp<MatDimY; i_samp++)
01806                         {
01807                           mat(i_crys, i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(j_cna_chan, i_samp);
01808                         }
01809                     }
01810                 }
01811               else
01812                 {
01813                   fDataExist = kFALSE;
01814                   cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01815                        << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01816                        << "                                                                 -> quantity: <"
01817                        << GetTypeOfQuantity(typ) << "> not available in file."
01818                        << fTTBELL << endl;
01819                 }
01820             }
01821           CloseRootFile(file_name);
01822         }  // end of if (fLookAtRootFile == 1)
01823       else
01824         {
01825           cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01826                << "It is not possible to access the number of found events: the ROOT file has not been read."
01827                << fTTBELL << endl;
01828         }
01829     }  // end of if (Stin_index >= 0)
01830   return mat;
01831 }// ----------------- end of ReadNumberOfEventsForSamples(...)
01832 
01833 //-------------------------------------------------------------------------
01834 //
01835 //        ReadPedestals(...)      
01836 //
01837 //-------------------------------------------------------------------------
01838 TVectorD TEcnaRead::ReadPedestals(const Int_t& VecDim)
01839 {
01840 //Read the expectation values of the expectation values of the samples
01841 //for all the channels of a given Stin
01842 //in the ROOT file and return them in a TVectorD
01843 //
01844 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
01845 
01846   TestArrayDimH1("ReadPedestals", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
01847 
01848   TVectorD vec(VecDim);
01849   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01850 
01851   CnaResultTyp typ = cTypPed;    // pedestals type
01852   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01853   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01854 
01855   Bool_t ok_open = kFALSE;
01856   Bool_t ok_read = kFALSE;
01857   
01858   TString FileNameLong = fCnaWrite->GetRootFileName();
01859   Bool_t allowed_to_read = kFALSE;
01860   
01861 //    if ( fOpenRootFile )
01862 //    {
01863 //      cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> "
01864 //         << "Reading on file already open." << fTTBELL << endl;
01865 //    }
01866 
01867   if( FileNameLong == fCurrentlyOpenFileName )
01868     {
01869       allowed_to_read = kTRUE;
01870     }
01871   else
01872     {
01873       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01874       ok_open = OpenRootFile(file_name, "READ");
01875       if(ok_open)
01876         {
01877           allowed_to_read = kTRUE;
01878         }
01879       else
01880         {
01881           cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> Open .root file failed for file: "
01882                << file_name << fTTBELL << endl;
01883           allowed_to_read = kFALSE;
01884           ok_read = kFALSE;
01885         }
01886     }
01887 
01888   if( allowed_to_read == kTRUE )
01889     {
01890       Int_t i_zero = 0;
01891       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01892       
01893       if ( ok_read == kTRUE )
01894         {
01895           fDataExist = kTRUE;
01896           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
01897             {
01898               vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
01899             }   
01900         }
01901       else
01902         {
01903           fDataExist = kFALSE;
01904           cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> "
01905                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01906                << "                                              -> quantity: <"
01907                << GetTypeOfQuantity(typ) << "> not available in file."
01908                << fTTBELL << endl;
01909         }
01910       CloseRootFile(file_name);
01911     }
01912   return vec;
01913 }
01914 
01915 //-------------------------------------------------------------------------
01916 //
01917 //              ReadTotalNoise(...)      
01918 //
01919 //-------------------------------------------------------------------------
01920 TVectorD TEcnaRead::ReadTotalNoise(const Int_t& VecDim)
01921 {
01922 //Read the expectation values of the sigmas of the samples
01923 //for all the channels of a given Stin
01924 //in the ROOT file and return them in a TVectorD
01925 //
01926 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
01927 
01928   TestArrayDimH1("ReadTotalNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
01929 
01930   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01931   CnaResultTyp typ = cTypTno;   // Total noise type
01932   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01933   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
01934 
01935   Bool_t ok_open = kFALSE;
01936   Bool_t ok_read = kFALSE;
01937 
01938   TString FileNameLong = fCnaWrite->GetRootFileName();
01939   Bool_t allowed_to_read = kFALSE;
01940   
01941   //  if ( fOpenRootFile )
01942   //  {
01943   //    cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> "
01944   //       << "Reading on file already open." << fTTBELL << endl;
01945   //  }
01946 
01947   if( FileNameLong == fCurrentlyOpenFileName )
01948     {
01949       allowed_to_read = kTRUE;
01950     }
01951   else
01952     {
01953       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
01954       ok_open = OpenRootFile(file_name, "READ");
01955       if(ok_open)
01956         {
01957           allowed_to_read = kTRUE;
01958         }
01959       else
01960         {
01961           cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> Open .root file failed for file: "
01962                << file_name << fTTBELL << endl;
01963           allowed_to_read = kFALSE;
01964           ok_read = kFALSE;
01965         }
01966     }
01967 
01968   if( allowed_to_read == kTRUE )
01969     {
01970       Int_t i_zero = 0;
01971       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01972       
01973       if ( ok_read == kTRUE )
01974         {
01975           fDataExist = kTRUE;
01976           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
01977             {
01978               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
01979             }   
01980         }
01981       else
01982         {
01983           fDataExist = kFALSE;
01984           cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> "
01985                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
01986                << "                                               -> quantity: <"
01987                << GetTypeOfQuantity(typ) << "> not available in file."
01988                << fTTBELL << endl;
01989         }
01990       CloseRootFile(file_name);
01991     }
01992   return vec;
01993 }
01994 //-------------------------------------------------------------------------
01995 //
01996 //          ReadMeanCorrelationsBetweenSamples(...)      
01997 //
01998 //-------------------------------------------------------------------------
01999 TVectorD TEcnaRead::ReadMeanCorrelationsBetweenSamples(const Int_t& VecDim)
02000 {
02001 //Read the Expectation values of the (sample,sample) correlations
02002 //for all the channels of a given Stin
02003 //in the ROOT file and return them in a TVectorD
02004 //
02005 //Possible values for VecDim: (1) VecDim = fEcal->MaxCrysEcnaInStex()
02006 
02007   TestArrayDimH1("ReadMeanCorrelationsBetweenSamples", "fEcal->MaxCrysEcnaInStex()",
02008                  fEcal->MaxCrysEcnaInStex(), VecDim);
02009 
02010   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02011   CnaResultTyp typ = cTypMeanCorss;     // mean corss type
02012   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02013   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02014 
02015   Bool_t ok_open = kFALSE;
02016   Bool_t ok_read = kFALSE;
02017 
02018   TString FileNameLong = fCnaWrite->GetRootFileName();
02019   Bool_t allowed_to_read = kFALSE;
02020    
02021   //if ( fOpenRootFile )
02022   //  {
02023   //    cout << "!TEcnaRead::ReadMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
02024   //       << "Reading on file already open." << fTTBELL << endl;
02025   //  }
02026 
02027   if( FileNameLong == fCurrentlyOpenFileName )
02028     {
02029       allowed_to_read = kTRUE;
02030     }
02031   else
02032     {
02033       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02034       ok_open = OpenRootFile(file_name, "READ");
02035       if(ok_open)
02036         {
02037           allowed_to_read = kTRUE;
02038         }
02039       else
02040         {
02041           cout << "!TEcnaRead::ReadMeanCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
02042                << file_name << fTTBELL << endl;
02043           allowed_to_read = kFALSE;
02044           ok_read = kFALSE;
02045         }
02046     }
02047 
02048   if( allowed_to_read == kTRUE )
02049     {
02050       Int_t i_zero = 0;
02051       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02052       
02053       if ( ok_read == kTRUE )
02054         {
02055           fDataExist = kTRUE;
02056           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02057             {
02058               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02059             }   
02060         }
02061       else
02062         {
02063           fDataExist = kFALSE;
02064           cout << "!TEcnaRead::ReadMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
02065                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02066                << "                                                                   ->  quantity: <"
02067                << GetTypeOfQuantity(typ) << "> not available in file."
02068                << fTTBELL << endl;
02069         }
02070       CloseRootFile(file_name);
02071     }
02072   return vec;
02073 }
02074 
02075 //-------------------------------------------------------------------------
02076 //
02077 //              ReadLowFrequencyNoise(...)      
02078 //
02079 //-------------------------------------------------------------------------
02080 TVectorD TEcnaRead::ReadLowFrequencyNoise(const Int_t& VecDim)
02081 {
02082 //Read the sigmas of the expectation values of the samples
02083 //for all the channels of a given Stin
02084 //in the ROOT file and return them in a TVectorD
02085 //
02086 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02087 
02088   TestArrayDimH1("ReadLowFrequencyNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
02089 
02090   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02091   CnaResultTyp typ = cTypLfn;        // low frequency noise type
02092   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02093   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02094 
02095   Bool_t ok_open = kFALSE;
02096   Bool_t ok_read = kFALSE;
02097 
02098   TString FileNameLong = fCnaWrite->GetRootFileName();
02099   Bool_t allowed_to_read = kFALSE;
02100     
02101 //  if ( fOpenRootFile )
02102 //    {
02103 //      cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> "
02104 //         << "Reading on file already open." << fTTBELL << endl;
02105 //    }
02106 
02107   if( FileNameLong == fCurrentlyOpenFileName )
02108     {
02109       allowed_to_read = kTRUE;
02110     }
02111   else
02112     {
02113       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02114       ok_open = OpenRootFile(file_name, "READ");
02115 
02116       if(ok_open)
02117         {
02118           allowed_to_read = kTRUE;
02119         }
02120       else
02121         {
02122           cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
02123                << file_name << fTTBELL << endl;
02124           allowed_to_read = kFALSE;
02125           ok_read = kFALSE;
02126         }
02127     }
02128 
02129   if( allowed_to_read == kTRUE )
02130     {
02131       Int_t i_zero = 0;
02132       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02133       
02134       if ( ok_read == kTRUE )
02135         {
02136           fDataExist = kTRUE;
02137           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02138             {
02139               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02140             }   
02141         }
02142       else
02143         {
02144           fDataExist = kFALSE;
02145           cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> "
02146                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02147                << "                                                      -> quantity: <"
02148                << GetTypeOfQuantity(typ) << "> not available in file."
02149                << fTTBELL << endl;
02150         }
02151       CloseRootFile(file_name);
02152     }
02153   return vec;
02154 }
02155 
02156 //-------------------------------------------------------------------------
02157 //
02158 //              ReadHighFrequencyNoise(...)      
02159 //
02160 //-------------------------------------------------------------------------
02161 TVectorD TEcnaRead::ReadHighFrequencyNoise(const Int_t& VecDim)
02162 {
02163 //Read the sigmas of the sigmas of the samples
02164 //for all the channels of a given Stin
02165 //in the ROOT file and return them in a TVectorD
02166 //
02167 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02168 
02169   TestArrayDimH1("ReadHighFrequencyNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
02170   
02171   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02172   CnaResultTyp typ = cTypHfn;        // high frequency noise type
02173   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02174   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02175 
02176   Bool_t ok_open = kFALSE;
02177   Bool_t ok_read = kFALSE;
02178   
02179   TString FileNameLong = fCnaWrite->GetRootFileName();
02180   Bool_t allowed_to_read = kFALSE;
02181 
02182 //  if ( fOpenRootFile )
02183 //    {
02184 //      cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> "
02185 //         << "Reading on file already open." << fTTBELL << endl;
02186 //    }
02187 
02188   if( FileNameLong == fCurrentlyOpenFileName )
02189     {
02190       allowed_to_read = kTRUE;
02191     }
02192   else
02193     {
02194       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02195       ok_open = OpenRootFile(file_name, "READ");
02196 
02197       if(ok_open)
02198         {
02199           allowed_to_read = kTRUE;
02200         }
02201       else
02202         {
02203           cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
02204                << file_name << fTTBELL << endl;
02205           allowed_to_read = kFALSE;
02206           ok_read = kFALSE;
02207         }
02208     }
02209 
02210   if( allowed_to_read == kTRUE )
02211     {
02212       Int_t i_zero = 0;
02213       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02214       
02215       if ( ok_read == kTRUE )
02216         {
02217           fDataExist = kTRUE;
02218           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02219             {
02220               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02221             }   
02222         }
02223       else
02224         {
02225           fDataExist = kFALSE;
02226           cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> "
02227                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02228                << "                                                       -> quantity: <"
02229                << GetTypeOfQuantity(typ) << "> not available in file."
02230                << fTTBELL << endl;
02231         }
02232       CloseRootFile(file_name);
02233     }
02234   return vec;
02235 }
02236 
02237 //-------------------------------------------------------------------------
02238 //
02239 //              ReadSigmaOfCorrelationsBetweenSamples(...)       
02240 //
02241 //-------------------------------------------------------------------------
02242 TVectorD TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(const Int_t& VecDim)
02243 {
02244 //Read the Expectation values of the (sample,sample) correlations
02245 //for all the channels of a given Stin
02246 //in the ROOT file and return them in a TVectorD
02247 //
02248 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02249 
02250   TestArrayDimH1("ReadSigmaOfCorrelationsBetweenSamples", "fEcal->MaxCrysEcnaInStex()",
02251                  fEcal->MaxCrysEcnaInStex(), VecDim);
02252 
02253   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02254   CnaResultTyp typ = cTypSigCorss;  // sigma of corss type
02255   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02256   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02257 
02258   Bool_t ok_open = kFALSE;
02259   Bool_t ok_read = kFALSE;
02260   
02261   TString FileNameLong = fCnaWrite->GetRootFileName();
02262   Bool_t allowed_to_read = kFALSE;
02263   
02264 //  if ( fOpenRootFile )
02265 //    {
02266 //      cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02267 //         << "Reading on file already open." << fTTBELL << endl;
02268 //    }
02269 
02270   if( FileNameLong == fCurrentlyOpenFileName )
02271     {
02272       allowed_to_read = kTRUE;
02273     }
02274   else
02275     {
02276       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02277       ok_open = OpenRootFile(file_name, "READ");
02278 
02279       if(ok_open)
02280         {
02281           allowed_to_read = kTRUE;
02282         }
02283       else
02284         {
02285           cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
02286                << file_name << fTTBELL << endl;
02287           allowed_to_read = kFALSE;
02288           ok_read = kFALSE;
02289         }
02290     }
02291 
02292   if( allowed_to_read == kTRUE )
02293     {
02294       Int_t i_zero = 0;
02295       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02296       
02297       if ( ok_read == kTRUE )
02298         {
02299           fDataExist = kTRUE;
02300           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02301             {
02302               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02303             }   
02304         }
02305       else
02306         {
02307           fDataExist = kFALSE;
02308           cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02309                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02310                << "                                                                      -> quantity: <"
02311                << GetTypeOfQuantity(typ) << "> not available in file."
02312                << fTTBELL << endl;
02313         }
02314       CloseRootFile(file_name);
02315     }
02316   return vec;
02317 }
02318 //==================================================================================================
02319 //-----------------------------------------------------------------------------
02320 //
02321 //                  ReadAverageNumberOfEvents(...)
02322 //
02323 //       NB: read "direct" numbers of evts and compute the average HERE
02324 //           (different from ReadAveragePedestals, Noises, etc...)
02325 //
02326 //-----------------------------------------------------------------------------
02327 TVectorD TEcnaRead::ReadAverageNumberOfEvents(const Int_t& VecDim)
02328 {
02329 //Read the numbers of found events in the data
02330 //for the crystals and for the samples for all the Stin's in the Stex
02331 //in the ROOT file, compute the average on the samples and on the crystals
02332 //and return them in a TVectorD(MaxStinEcnaInStex)
02333 //
02334 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02335 
02336   TestArrayDimH1("ReadAverageNumberOfEvents", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
02337 
02338   TVectorD vecAverage(VecDim);
02339   for(Int_t i=0; i<VecDim; i++){vecAverage(i)=(Double_t)0.;}
02340 
02341   TVectorD vecMean(fEcal->MaxCrysEcnaInStex());
02342   for(Int_t i=0; i<fEcal->MaxCrysEcnaInStex(); i++){vecMean(i)=(Double_t)0.;}
02343 
02344   vecMean = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
02345 
02346   for(Int_t i0StexStin=0; i0StexStin<VecDim; i0StexStin++)
02347     {
02348       vecAverage(i0StexStin) = 0;
02349       //.... average value over the crystals
02350       for(Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++)
02351         {
02352           Int_t n1StexStin = i0StexStin+1;
02353           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
02354           
02355           if( fStexName == "SM" )
02356             {vecAverage(i0StexStin) += vecMean(i0StexEcha);}
02357 
02358           if( fStexName == "Dee" )
02359             {
02360               //--------- EE --> Special translation for mixed SCEcna (29 and 32)
02361               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02362               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02363               Int_t n1StinEcha = i0StinEcha+1;
02364               if( n1StexStin == 10 && n1StinEcha == 11 )
02365                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02366               if( n1StexStin == 11 && n1StinEcha == 11 )
02367                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02368               if( !( (n1StexStin == 29 || n1StexStin == 32) && n1StinEcha == 11 )  )
02369                 {vecAverage(i0StexStin) += vecMean(i0StexEcha);}
02370             }
02371         }
02372 
02373       Double_t xdivis = (Double_t)0.;
02374       if( fStexName == "SM"  )
02375         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02376       if( fStexName == "Dee" )
02377         {
02378           Int_t n1StexStin = i0StexStin+1;
02379           xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStin, "TEcnaRead");
02380         }
02381 
02382       vecAverage(i0StexStin) = vecAverage(i0StexStin)/xdivis;   
02383     }
02384   return vecAverage;
02385 }
02386 
02387 //-------------------------------------------------------------------------
02388 //
02389 //        ReadAveragePedestals(...)      
02390 //
02391 //-------------------------------------------------------------------------
02392 TVectorD TEcnaRead::ReadAveragePedestals(const Int_t& VecDim)
02393 {
02394 //Read the expectation values of the Pedestals
02395 //for all the Stins of a given Stex
02396 //in the ROOT file and return them in a TVectorD
02397 //
02398 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02399 
02400   TestArrayDimH1("ReadAveragePedestals", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
02401 
02402   TVectorD vec(VecDim);
02403   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02404 
02405   CnaResultTyp typ = cTypAvPed;    // averaged pedestals type
02406   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02407   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02408 
02409   Bool_t ok_open = kFALSE;
02410   Bool_t ok_read = kFALSE;
02411 
02412   TString FileNameLong = fCnaWrite->GetRootFileName();
02413   Bool_t allowed_to_read = kFALSE;
02414   
02415 //  if ( fOpenRootFile )
02416 //    {
02417 //      cout << "!TEcnaRead::ReadAveragePedestals(...) *** ERROR ***> "
02418 //         << "Reading on file already open." << fTTBELL << endl;
02419 //    }
02420 
02421   if( FileNameLong == fCurrentlyOpenFileName )
02422     {
02423       allowed_to_read = kTRUE;
02424     }
02425   else
02426     {
02427       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02428       ok_open = OpenRootFile(file_name, "READ");
02429 
02430       if(ok_open)
02431         {
02432           allowed_to_read = kTRUE;
02433         }
02434       else
02435         {
02436           cout << "!TEcnaRead::ReadAveragePedestals(...) *** ERROR ***> Open .root file failed for file: "
02437                << file_name << fTTBELL << endl;
02438           allowed_to_read = kFALSE;
02439           ok_read = kFALSE;
02440         }
02441     }
02442 
02443   if( allowed_to_read == kTRUE )
02444     {
02445       Int_t i_zero = 0;
02446       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02447       
02448       if ( ok_read == kTRUE )
02449         {
02450           fDataExist = kTRUE;
02451           for(Int_t i0StexStin=0; i0StexStin<VecDim; i0StexStin++)
02452             {
02453               vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02454             }   
02455         }
02456       else
02457         {
02458           fDataExist = kFALSE;
02459           cout << "!TEcnaRead::ReadAveragePedestals(...) *** ERROR ***> "
02460                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02461                << "                                                     -> quantity: <"
02462                << GetTypeOfQuantity(typ) << "> not available in file."
02463                << fTTBELL << endl;
02464         }
02465       CloseRootFile(file_name);
02466     }
02467   return vec;
02468 } // end of ReadAveragePedestals
02469 
02470 //-------------------------------------------------------------------------
02471 //
02472 //        ReadAverageTotalNoise(...)      
02473 //
02474 //-------------------------------------------------------------------------
02475 TVectorD TEcnaRead::ReadAverageTotalNoise(const Int_t& VecDim)
02476 {
02477 //Read the expectation values of the Total Noise
02478 //for all the Stins of a given Stex
02479 //in the ROOT file and return them in a TVectorD
02480 //
02481 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02482 
02483   TestArrayDimH1("ReadAverageTotalNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
02484 
02485   TVectorD vec(VecDim);
02486   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02487 
02488   CnaResultTyp typ = cTypAvTno;    // averaged Total Noise type
02489   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02490   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02491 
02492   Bool_t ok_open = kFALSE;
02493   Bool_t ok_read = kFALSE;
02494   
02495   TString FileNameLong = fCnaWrite->GetRootFileName();
02496   Bool_t allowed_to_read = kFALSE;
02497   
02498 //  if ( fOpenRootFile )
02499 //    {
02500 //      cout << "!TEcnaRead::ReadAverageTotalNoise(...) *** ERROR ***> "
02501 //         << "Reading on file already open." << fTTBELL << endl;
02502 //    }
02503 
02504   if( FileNameLong == fCurrentlyOpenFileName )
02505     {
02506       allowed_to_read = kTRUE;
02507     }
02508   else
02509     {
02510       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02511       ok_open = OpenRootFile(file_name, "READ");
02512 
02513       if(ok_open)
02514         {
02515           allowed_to_read = kTRUE;
02516         }
02517       else
02518         {
02519           cout << "!TEcnaRead::ReadAverageTotalNoise(...) *** ERROR ***> Open .root file failed for file: "
02520                << file_name << fTTBELL << endl;
02521           allowed_to_read = kFALSE;
02522           ok_read = kFALSE;
02523         }
02524     }
02525 
02526   if( allowed_to_read == kTRUE )
02527     {
02528       Int_t i_zero = 0;
02529       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02530       
02531       if ( ok_read == kTRUE )
02532         {
02533           fDataExist = kTRUE;
02534           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02535             {
02536               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02537             }   
02538         }
02539       else
02540         {
02541           fDataExist = kFALSE;
02542           cout << "!TEcnaRead::ReadAverageTotalNoise(...) *** ERROR ***> "
02543                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02544                << "                                                      -> quantity: <"
02545                << GetTypeOfQuantity(typ) << "> not available in file."
02546                << fTTBELL << endl;
02547         }
02548       CloseRootFile(file_name);
02549     }
02550   return vec;
02551 }
02552 
02553 //-------------------------------------------------------------------------
02554 //
02555 //        ReadAverageLowFrequencyNoise(...)      
02556 //
02557 //-------------------------------------------------------------------------
02558 TVectorD TEcnaRead::ReadAverageLowFrequencyNoise(const Int_t& VecDim)
02559 {
02560 //Read the expectation values of the Pedestals
02561 //for all the Stins of a given Stex
02562 //in the ROOT file and return them in a TVectorD
02563 //
02564 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02565 
02566   TestArrayDimH1("ReadAverageLowFrequencyNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
02567 
02568   TVectorD vec(VecDim);
02569   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02570 
02571   CnaResultTyp typ = cTypAvLfn;    // averaged Low FrequencyNoise type
02572   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02573   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02574 
02575   Bool_t ok_open = kFALSE;
02576   Bool_t ok_read = kFALSE;
02577   
02578   TString FileNameLong = fCnaWrite->GetRootFileName();
02579   Bool_t allowed_to_read = kFALSE;
02580 
02581 //  if ( fOpenRootFile )
02582 //    {
02583 //      cout << "!TEcnaRead::ReadAverageLowFrequencyNoise(...) *** ERROR ***> "
02584 //         << "Reading on file already open." << fTTBELL << endl;
02585 //    }
02586 
02587   if( FileNameLong == fCurrentlyOpenFileName )
02588     {
02589       allowed_to_read = kTRUE;
02590     }
02591   else
02592     {
02593       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02594       ok_open = OpenRootFile(file_name, "READ");
02595 
02596       if(ok_open)
02597         {
02598           allowed_to_read = kTRUE;
02599         }
02600       else
02601         {
02602           cout << "!TEcnaRead::ReadAverageLowFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
02603                << file_name << fTTBELL << endl;
02604           allowed_to_read = kFALSE;
02605           ok_read = kFALSE;
02606         }
02607     }
02608 
02609   if( allowed_to_read == kTRUE )
02610     {
02611       Int_t i_zero = 0;
02612       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02613       
02614       if ( ok_read == kTRUE )
02615         {
02616           fDataExist = kTRUE;
02617           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02618             {
02619               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02620             }   
02621         }
02622       else
02623         {
02624           fDataExist = kFALSE;
02625           cout << "!TEcnaRead::ReadAverageLowFrequencyNoise(...) *** ERROR ***> "
02626                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02627                << "                                                             -> quantity: <"
02628                << GetTypeOfQuantity(typ) << "> not available in file."
02629                << fTTBELL << endl;
02630         }
02631       CloseRootFile(file_name);
02632     }
02633   return vec;
02634 } // end of ReadAverageLowFrequencyNoise
02635 
02636 //-------------------------------------------------------------------------
02637 //
02638 //        ReadAverageHighFrequencyNoise(...)      
02639 //
02640 //-------------------------------------------------------------------------
02641 TVectorD TEcnaRead::ReadAverageHighFrequencyNoise(const Int_t& VecDim)
02642 {
02643 //Read the expectation values of the Pedestals
02644 //for all the Stins of a given Stex
02645 //in the ROOT file and return them in a TVectorD
02646 //
02647 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02648 
02649   TestArrayDimH1("ReadAverageHighFrequencyNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
02650 
02651   TVectorD vec(VecDim);
02652  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02653 
02654   CnaResultTyp typ = cTypAvHfn;    // averaged High FrequencyNoise type
02655   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02656   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02657 
02658   Bool_t ok_open = kFALSE;
02659   Bool_t ok_read = kFALSE;
02660   
02661   TString FileNameLong = fCnaWrite->GetRootFileName();
02662   Bool_t allowed_to_read = kFALSE;
02663   
02664 //  if ( fOpenRootFile )
02665 //    {
02666 //      cout << "!TEcnaRead::ReadAverageHighFrequencyNoise(...) *** ERROR ***> "
02667 //         << "Reading on file already open." << fTTBELL << endl;
02668 //    }
02669 
02670   if( FileNameLong == fCurrentlyOpenFileName )
02671     {
02672       allowed_to_read = kTRUE;
02673     }
02674   else
02675     {
02676       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02677       ok_open = OpenRootFile(file_name, "READ");
02678 
02679       if(ok_open)
02680         {
02681           allowed_to_read = kTRUE;
02682         }
02683       else
02684         {
02685           cout << "!TEcnaRead::ReadAverageHighFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
02686                << file_name << fTTBELL << endl;
02687           allowed_to_read = kFALSE;
02688           ok_read = kFALSE;
02689         }
02690     }
02691 
02692   if( allowed_to_read == kTRUE )
02693     {
02694       Int_t i_zero = 0;
02695       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02696       
02697       if ( ok_read == kTRUE )
02698         {
02699           fDataExist = kTRUE;
02700           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02701             {
02702               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02703             }   
02704         }
02705       else
02706         {
02707           fDataExist = kFALSE;
02708           cout << "!TEcnaRead::ReadAverageHighFrequencyNoise(...) *** ERROR ***> "
02709                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02710                << "                                                              -> quantity: <"
02711                << GetTypeOfQuantity(typ) << "> not available in file."
02712                << fTTBELL << endl;
02713         }
02714       CloseRootFile(file_name);
02715     }
02716   return vec;
02717 } // end of ReadAverageHighFrequencyNoise
02718 
02719 //-------------------------------------------------------------------------
02720 //
02721 //        ReadAverageMeanCorrelationsBetweenSamples(...)      
02722 //
02723 //-------------------------------------------------------------------------
02724 TVectorD TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(const Int_t& VecDim)
02725 {
02726 //Read the expectation values of the Pedestals
02727 //for all the Stins of a given Stex
02728 //in the ROOT file and return them in a TVectorD
02729 //
02730 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02731 
02732   TestArrayDimH1("ReadAverageMeanCorrelationsBetweenSamples", "fEcal->MaxStinEcnaInStex()",
02733                  fEcal->MaxStinEcnaInStex(), VecDim);
02734 
02735   TVectorD vec(VecDim);
02736  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02737 
02738   CnaResultTyp typ = cTypAvMeanCorss;    // averaged MeanCorrelationsBetweenSamples type
02739   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02740   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02741 
02742   Bool_t ok_open = kFALSE;
02743   Bool_t ok_read = kFALSE;
02744 
02745   TString FileNameLong = fCnaWrite->GetRootFileName();
02746   Bool_t allowed_to_read = kFALSE;
02747     
02748 //  if ( fOpenRootFile )
02749 //    {
02750 //      cout << "!TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
02751 //         << "Reading on file already open." << fTTBELL << endl;
02752 //    }
02753 
02754   if( FileNameLong == fCurrentlyOpenFileName )
02755     {
02756       allowed_to_read = kTRUE;
02757     }
02758   else
02759     {
02760       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02761       ok_open = OpenRootFile(file_name, "READ");
02762 
02763       if(ok_open)
02764         {
02765           allowed_to_read = kTRUE;
02766         }
02767       else
02768         {
02769           cout << "!TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
02770                << file_name << fTTBELL << endl;
02771           allowed_to_read = kFALSE;
02772           ok_read = kFALSE;
02773         }
02774     }
02775 
02776   if( allowed_to_read == kTRUE )
02777     {
02778       Int_t i_zero = 0;
02779       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02780       
02781       if ( ok_read == kTRUE )
02782         {
02783           fDataExist = kTRUE;
02784           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02785             {
02786               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02787             }   
02788         }
02789       else
02790         {
02791           fDataExist = kFALSE;
02792           cout << "!TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
02793                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02794                << "                                                                          -> quantity: <"
02795                << GetTypeOfQuantity(typ) << "> not available in file."
02796                << fTTBELL << endl;
02797         }
02798       CloseRootFile(file_name);
02799     }
02800   return vec;
02801 } // end of ReadAverageMeanCorrelationsBetweenSamples
02802 
02803 //-------------------------------------------------------------------------
02804 //
02805 //        ReadAverageSigmaOfCorrelationsBetweenSamples(...)      
02806 //
02807 //-------------------------------------------------------------------------
02808 TVectorD TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(const Int_t& VecDim)
02809 {
02810 //Read the expectation values of the Pedestals
02811 //for all the Stins of a given Stex
02812 //in the ROOT file and return them in a TVectorD
02813 //
02814 //Possible values for VecDim: (1) VecDim = fEcal->MaxStinEcnaInStex()
02815 
02816   TestArrayDimH1("ReadAverageSigmaOfCorrelationsBetweenSamples", "fEcal->MaxStinEcnaInStex()",
02817                  fEcal->MaxStinEcnaInStex(), VecDim);
02818 
02819   TVectorD vec(VecDim);
02820  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02821 
02822   CnaResultTyp typ = cTypAvSigCorss;    // averaged SigmaOfCorrelationsBetweenSamples type
02823   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02824   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02825 
02826   Bool_t ok_open = kFALSE;
02827   Bool_t ok_read = kFALSE;
02828 
02829   TString FileNameLong = fCnaWrite->GetRootFileName();
02830   Bool_t allowed_to_read = kFALSE;
02831       
02832 //  if ( fOpenRootFile )
02833 //    {
02834 //      cout << "!TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02835 //         << "Reading on file already open." << fTTBELL << endl;
02836 //    }
02837 
02838   if( FileNameLong == fCurrentlyOpenFileName )
02839     {
02840       allowed_to_read = kTRUE;
02841     }
02842   else
02843     {
02844       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02845       ok_open = OpenRootFile(file_name, "READ");
02846 
02847       if(ok_open)
02848         {
02849           allowed_to_read = kTRUE;
02850         }
02851       else
02852         {
02853           cout << "!TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
02854                << file_name << fTTBELL << endl;
02855           allowed_to_read = kFALSE;
02856           ok_read = kFALSE;
02857         }
02858     }
02859 
02860   if( allowed_to_read == kTRUE )
02861     {
02862       Int_t i_zero = 0;
02863       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02864       
02865       if ( ok_read == kTRUE )
02866         {
02867           fDataExist = kTRUE;
02868           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02869             {
02870               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02871             }   
02872         }
02873       else
02874         {
02875           fDataExist = kFALSE;
02876           cout << "!TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02877                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02878                << "                                                                             -> quantity: <"
02879                << GetTypeOfQuantity(typ) << "> not available in file."
02880                << fTTBELL << endl;
02881         }
02882       CloseRootFile(file_name);
02883     }
02884   return vec;
02885 } // end of ReadAverageSigmaOfCorrelationsBetweenSamples
02886 
02887 
02888 //============================================================================
02889 //
02890 //                       2 D   H I S T O S   (TECHNICAL METHODS)
02891 //
02892 //============================================================================
02893 //-------------------------------------------------------------------------
02894 //
02895 //  ReadCovariancesBetweenSamples(n1StexStin,StinEcha,fFileHeader->fNbOfSamples)
02896 //
02897 //-------------------------------------------------------------------------
02898 TMatrixD TEcnaRead::ReadCovariancesBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
02899                                                   const Int_t& MatDim)
02900 {
02901 //Read the (sample,sample) covariances for a given channel
02902 //in ROOT file and return them in a TMatrixD
02903 //
02904 //Possible values for MatDim: (1) MatDim = fFileHeader->fNbOfSamples
02905 
02906   TestArrayDimH2("ReadCovariancesBetweenSamples", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, MatDim);
02907 
02908   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
02909 
02910   TMatrixD mat(MatDim, MatDim);
02911   for(Int_t i=0; i<MatDim; i++)
02912     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
02913   
02914   CnaResultTyp typ = cTypCovCss;
02915 
02916   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02917   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
02918 
02919   Bool_t ok_open = kFALSE;
02920   Bool_t ok_read = kFALSE;
02921   
02922   TString FileNameLong = fCnaWrite->GetRootFileName();
02923   Bool_t allowed_to_read = kFALSE;
02924       
02925 //  if ( fOpenRootFile )
02926 //    {
02927 //      cout << "!TEcnaRead::ReadCovariancesBetweenSamples(...) *** ERROR ***> "
02928 //         << "Reading on file already open." << fTTBELL << endl;
02929 //    }
02930 
02931   if( FileNameLong == fCurrentlyOpenFileName )
02932     {
02933       allowed_to_read = kTRUE;
02934     }
02935   else
02936     {
02937       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
02938       ok_open = OpenRootFile(file_name, "READ");
02939 
02940       if(ok_open)
02941         {
02942           allowed_to_read = kTRUE;
02943         }
02944       else
02945         {
02946           cout << "!TEcnaRead::ReadCovariancesBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
02947                << file_name << fTTBELL << endl;
02948           allowed_to_read = kFALSE;
02949           ok_read = kFALSE;
02950         }
02951     }
02952 
02953   if( allowed_to_read == kTRUE )
02954     {
02955       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
02956       
02957       if ( ok_read == kTRUE )
02958         {
02959           fDataExist = kTRUE;
02960           for( Int_t i_samp = 0; i_samp < MatDim; i_samp++ )
02961             {
02962               for ( Int_t j_samp = 0; j_samp < MatDim; j_samp++)
02963                 {
02964                  mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);
02965                 }
02966             }
02967         }
02968       else
02969         {
02970           fDataExist = kFALSE;
02971           cout << "!TEcnaRead::ReadCovariancesBetweenSamples() *** ERROR ***> "
02972                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
02973                << "                                                           -> quantity: <"
02974                << GetTypeOfQuantity(typ) << "> not available in file."
02975                << fTTBELL << endl;
02976         }
02977       CloseRootFile(file_name);
02978     }
02979   return mat;
02980 }
02981 
02982 //-------------------------------------------------------------------------
02983 //
02984 //  ReadCorrelationsBetweenSamples(n1StexStin,StinEcha,fFileHeader->fNbOfSamples)
02985 //
02986 //-------------------------------------------------------------------------
02987 TMatrixD TEcnaRead::ReadCorrelationsBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
02988                                                    const Int_t& MatDim)
02989 {
02990 //Read the (sample,sample) correlations for a given channel
02991 //in ROOT file and return them in a TMatrixD
02992 //
02993 //Possible values for MatDim: (1) MatDim = fFileHeader->fNbOfSamples
02994 
02995   TestArrayDimH2("ReadCorrelationsBetweenSamples", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, MatDim);
02996 
02997   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
02998   TMatrixD mat(MatDim, MatDim);
02999   for(Int_t i=0; i<MatDim; i++)
03000     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03001 
03002   CnaResultTyp typ = cTypCorCss;
03003   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03004   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03005 
03006   Bool_t ok_open = kFALSE;
03007   Bool_t ok_read = kFALSE;
03008     
03009   TString FileNameLong = fCnaWrite->GetRootFileName();
03010   Bool_t allowed_to_read = kFALSE;
03011       
03012 //  if ( fOpenRootFile )
03013 //    {
03014 //      cout << "!TEcnaRead::ReadCorrelationsBetweenSamples(...) *** ERROR ***> "
03015 //         << "Reading on file already open." << fTTBELL << endl;
03016 //    }
03017 
03018   if( FileNameLong == fCurrentlyOpenFileName )
03019     {
03020       allowed_to_read = kTRUE;
03021     }
03022   else
03023     {
03024       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03025       ok_open = OpenRootFile(file_name, "READ");
03026 
03027       if(ok_open)
03028         {
03029           allowed_to_read = kTRUE;
03030         }
03031       else
03032         {
03033           cout << "!TEcnaRead::ReadCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
03034                << file_name << fTTBELL << endl;
03035           allowed_to_read = kFALSE;
03036           ok_read = kFALSE;
03037         }
03038     }
03039 
03040   if( allowed_to_read == kTRUE )
03041     {
03042       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
03043       
03044       if ( ok_read == kTRUE )
03045         {
03046           fDataExist = kTRUE;
03047           for ( Int_t i_samp = 0; i_samp < MatDim; i_samp++){
03048             for ( Int_t j_samp = 0; j_samp < MatDim; j_samp++){
03049               mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);}}
03050         }
03051       else
03052         {
03053           fDataExist = kFALSE;
03054           cout << "!TEcnaRead::ReadCorrelationsBetweenSamples() *** ERROR ***> "
03055                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03056                << "                                                            -> quantity: <"
03057                << GetTypeOfQuantity(typ) << "> not available in file."
03058                << fTTBELL << endl;
03059         }
03060       CloseRootFile(file_name);
03061     }
03062   return mat;
03063 }
03064 //-------------------------------------------------------------------------
03065 //
03066 //  ReadRelevantCorrelationsBetweenSamples(n1StexStin,i0StinEcha)
03067 //                 (NOT USED)
03068 //-------------------------------------------------------------------------
03069 TVectorD TEcnaRead::ReadRelevantCorrelationsBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
03070                                                            const Int_t & InPutMatDim )
03071 {
03072 //Read the (sample,sample) correlations for a given channel
03073 //in ROOT file and return the relevant correlations in a TVectorD
03074 //
03075 //Possible values for InPutMatDim: (1) InPutMatDim = fFileHeader->fNbOfSamples
03076 //
03077 //  *===>  OutPut TVectorD dimension value = InPutMatDim*(InPutMatDim-1)/2
03078 
03079   TestArrayDimH2("ReadRelevantCorrelationsBetweenSamples", "fFileHeader->fNbOfSamples",
03080                  fFileHeader->fNbOfSamples, InPutMatDim);
03081 
03082   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
03083   Int_t nb_of_relevant = InPutMatDim*(InPutMatDim-1)/2;
03084   TVectorD vec_rel(nb_of_relevant); for(Int_t i=0; i<nb_of_relevant; i++){vec_rel(i)=(Double_t)0.;}
03085   CnaResultTyp typ = cTypCorCss;
03086   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03087   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03088 
03089   Bool_t ok_open = kFALSE;
03090   Bool_t ok_read = kFALSE;
03091     
03092   TString FileNameLong = fCnaWrite->GetRootFileName();
03093   Bool_t allowed_to_read = kFALSE;
03094 
03095 //  if ( fOpenRootFile )
03096 //    {
03097 //      cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples(...) *** ERROR ***> "
03098 //         << "Reading on file already open." << fTTBELL << endl;
03099 //    }
03100 
03101   if( FileNameLong == fCurrentlyOpenFileName )
03102     {
03103       allowed_to_read = kTRUE;
03104     }
03105   else
03106     {
03107       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03108       ok_open = OpenRootFile(file_name, "READ");
03109 
03110       if(ok_open)
03111         {
03112           allowed_to_read = kTRUE;
03113         }
03114       else
03115         {
03116           cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
03117                << file_name << fTTBELL << endl;
03118           allowed_to_read = kFALSE;
03119           ok_read = kFALSE;
03120         }
03121     }
03122 
03123   if( allowed_to_read == kTRUE )
03124     {
03125       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
03126       
03127       if ( ok_read == kTRUE )
03128         {
03129           fDataExist = kTRUE;
03130           Int_t k_cor = 0;
03131           for ( Int_t i_samp = 0; i_samp < InPutMatDim; i_samp++){
03132             for ( Int_t j_samp = 0; j_samp < i_samp; j_samp++){
03133               vec_rel(k_cor) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);
03134               k_cor++;}}
03135         }
03136       else
03137         {
03138           fDataExist = kFALSE;
03139           cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples() *** ERROR ***> "
03140                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03141                << "                                                                    -> quantity: <"
03142                << GetTypeOfQuantity(typ) << "> not available in file."
03143                << fTTBELL << endl;
03144         }
03145       CloseRootFile(file_name);
03146     }
03147   return vec_rel;
03148 }
03149 //----- end of (ReadRelevantCorrelationsBetweenSamples ) -------
03150 
03151 //-----------------------------------------------------------------------------------------
03152 //
03153 //        ReadLowFrequencyCovariancesBetweenChannels(Stin_a, Stin_b)
03154 //
03155 //-----------------------------------------------------------------------------------------
03156 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t& n1StexStin_a,
03157                                                                const Int_t& n1StexStin_b,
03158                                                                const Int_t& MatDim)
03159 {
03160 //Read the Low Frequency cov(i0StinEcha of Stin_a, i0StinEcha of Stin b)
03161 //in ROOT file and return them in a TMatrixD
03162 //
03163 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
03164 
03165   TestArrayDimH2("ReadLowFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysInStin()",
03166                  fEcal->MaxCrysInStin(), MatDim);
03167 
03168   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
03169   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
03170 
03171   TMatrixD mat(MatDim, MatDim);
03172   for(Int_t i=0; i<MatDim; i++)
03173     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03174   
03175   CnaResultTyp typ = cTypLfCov;
03176 
03177   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03178   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03179 
03180   Bool_t ok_open = kFALSE;
03181   Bool_t ok_read = kFALSE;
03182     
03183   TString FileNameLong = fCnaWrite->GetRootFileName();
03184   Bool_t allowed_to_read = kFALSE;
03185   
03186 //  if ( fOpenRootFile )
03187 //    {
03188 //      cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***>"
03189 //         << " Reading on file already open." << fTTBELL << endl;
03190 //    }
03191 
03192   if( FileNameLong == fCurrentlyOpenFileName )
03193     {
03194       allowed_to_read = kTRUE;
03195     }
03196   else
03197     {
03198       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03199       ok_open = OpenRootFile(file_name, "READ");
03200 
03201       if(ok_open)
03202         {
03203           allowed_to_read = kTRUE;
03204         }
03205       else
03206         {
03207           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03208                << file_name << fTTBELL << endl;
03209           allowed_to_read = kFALSE;
03210           ok_read = kFALSE;
03211         }
03212     }
03213 
03214   if( allowed_to_read == kTRUE )
03215     {
03216       Int_t i_zero = 0;
03217       ok_read = gCnaRootFile->ReadElement(typ,i_zero);
03218       
03219       if ( ok_read == kTRUE )
03220         {
03221           fDataExist = kTRUE;
03222           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
03223             {
03224               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
03225               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
03226                 {
03227                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
03228                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03229                 }
03230             }
03231         }
03232       else
03233         {
03234           fDataExist = kFALSE;
03235           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
03236                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03237                << "                                                                           -> quantity: <"
03238                << GetTypeOfQuantity(typ) << "> not available in file."
03239                << fTTBELL << endl;
03240         }
03241       CloseRootFile(file_name);
03242     }
03243   return mat;
03244 }
03245 //----- end of ( ReadLowFrequencyCovariancesBetweenChannels(...) ) -------
03246 
03247 //-------------------------------------------------------------------------------------------
03248 //
03249 //         ReadLowFrequencyCorrelationsBetweenChannels(Stin_a, Stin_b)
03250 //
03251 //-------------------------------------------------------------------------------------------
03252 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t & n1StexStin_a,
03253                                                                 const Int_t & n1StexStin_b,
03254                                                                 const Int_t& MatDim)
03255 {
03256 //Read the Low Frequency cor(i0StinEcha of Stin_a, i0StinEcha of Stin b)
03257 //in ROOT file and return them in a TMatrixD
03258 //
03259 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
03260 
03261   TestArrayDimH2("ReadLowFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysInStin()", fEcal->MaxCrysInStin(), MatDim);
03262 
03263   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
03264   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
03265 
03266   TMatrixD mat(MatDim, MatDim);
03267   for(Int_t i=0; i<MatDim; i++)
03268     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03269   
03270   CnaResultTyp typ = cTypLfCor;
03271 
03272   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03273   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03274 
03275   Bool_t ok_open = kFALSE;
03276   Bool_t ok_read = kFALSE;
03277     
03278   TString FileNameLong = fCnaWrite->GetRootFileName();
03279   Bool_t allowed_to_read = kFALSE;
03280   
03281 //  if ( fOpenRootFile )
03282 //    {
03283 //      cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***>"
03284 //         << " Reading on file already open." << fTTBELL << endl;
03285 //    }
03286 
03287   if( FileNameLong == fCurrentlyOpenFileName )
03288     {
03289       allowed_to_read = kTRUE;
03290     }
03291   else
03292     {
03293       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03294       ok_open = OpenRootFile(file_name, "READ");
03295 
03296       if(ok_open)
03297         {
03298           allowed_to_read = kTRUE;
03299         }
03300       else
03301         {
03302           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03303                << file_name << fTTBELL << endl;
03304           allowed_to_read = kFALSE;
03305           ok_read = kFALSE;
03306         }
03307     }
03308 
03309   if( allowed_to_read == kTRUE )
03310     {
03311       Int_t i_zero = 0;
03312 
03313       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03314       
03315       if ( ok_read == kTRUE )
03316         {
03317           fDataExist = kTRUE;
03318           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
03319             {
03320               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
03321               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
03322                 {
03323                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
03324                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03325                 }
03326             }
03327         }
03328       else
03329         {
03330           fDataExist = kFALSE;
03331           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
03332                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03333                << "                                                                            -> quantity: <"
03334                << GetTypeOfQuantity(typ) << "> not available in file."
03335                << fTTBELL << endl;
03336         }
03337       CloseRootFile(file_name);
03338     }
03339   return mat;
03340 }
03341 //----- end of ( ReadLowFrequencyCorrelationsBetweenChannels(...) ) -------
03342 
03343 //-----------------------------------------------------------------------------------------
03344 //
03345 //        ReadHighFrequencyCovariancesBetweenChannels(Stin_a, Stin_b)
03346 //
03347 //-----------------------------------------------------------------------------------------
03348 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t & n1StexStin_a,
03349                                                                 const Int_t & n1StexStin_b,
03350                                                                 const Int_t& MatDim)
03351 {
03352 //Read the High Frequency cov(i0StinEcha of Stin_a, i0StinEcha of Stin b)
03353 //in ROOT file and return them in a TMatrixD
03354 //
03355 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
03356 
03357   TestArrayDimH2("ReadHighFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysInStin()",
03358                  fEcal->MaxCrysInStin(), MatDim);
03359 
03360   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
03361   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
03362 
03363   TMatrixD mat(MatDim, MatDim);
03364   for(Int_t i=0; i<MatDim; i++)
03365     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03366   
03367   CnaResultTyp typ = cTypHfCov;
03368 
03369   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03370   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03371 
03372   Bool_t ok_open = kFALSE;
03373   Bool_t ok_read = kFALSE;
03374     
03375   TString FileNameLong = fCnaWrite->GetRootFileName();
03376   Bool_t allowed_to_read = kFALSE;
03377   
03378 //  if ( fOpenRootFile )
03379 //    {
03380 //      cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***>"
03381 //         << " Reading on file already open." << fTTBELL << endl;
03382 //    }
03383 
03384   if( FileNameLong == fCurrentlyOpenFileName )
03385     {
03386       allowed_to_read = kTRUE;
03387     }
03388   else
03389     {
03390       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03391       ok_open = OpenRootFile(file_name, "READ");
03392 
03393       if(ok_open)
03394         {
03395           allowed_to_read = kTRUE;
03396         }
03397       else
03398         {
03399           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03400                << file_name << fTTBELL << endl;
03401           allowed_to_read = kFALSE;
03402           ok_read = kFALSE;
03403         }
03404     }
03405 
03406   if( allowed_to_read == kTRUE )
03407     {
03408       Int_t i_zero = 0;
03409       ok_read = gCnaRootFile->ReadElement(typ,i_zero);
03410       
03411       if ( ok_read == kTRUE )
03412         {
03413           fDataExist = kTRUE;
03414           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
03415             {
03416               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
03417               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
03418                 {
03419                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
03420                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03421                 }
03422             }
03423         }
03424       else
03425         {
03426           fDataExist = kFALSE;
03427           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
03428                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03429                << "                                                                            -> quantity: <"
03430                << GetTypeOfQuantity(typ) << "> not available in file."
03431                << fTTBELL << endl;
03432         }
03433       CloseRootFile(file_name);
03434     }
03435   return mat;
03436 }
03437 //----- end of ( ReadHighFrequencyCovariancesBetweenChannels(...) ) -------
03438 
03439 //-------------------------------------------------------------------------------------------
03440 //
03441 //         ReadHighFrequencyCorrelationsBetweenChannels(Stin_a, Stin_b)
03442 //
03443 //-------------------------------------------------------------------------------------------
03444 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t & n1StexStin_a,
03445                                                                  const Int_t & n1StexStin_b,
03446                                                                  const Int_t& MatDim)
03447 {
03448 //Read the High Frequency Cor(i0StinEcha of Stin_a, i0StinEcha of Stin b)
03449 //in ROOT file and return them in a TMatrixD
03450 //
03451 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
03452 
03453   TestArrayDimH2("ReadHighFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysInStin()",
03454                  fEcal->MaxCrysInStin(), MatDim);
03455 
03456   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
03457   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
03458 
03459   TMatrixD mat(MatDim, MatDim);
03460   for(Int_t i=0; i<MatDim; i++)
03461     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03462   
03463   CnaResultTyp typ = cTypHfCor;
03464 
03465   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03466   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03467 
03468   Bool_t ok_open = kFALSE;
03469   Bool_t ok_read = kFALSE;
03470     
03471   TString FileNameLong = fCnaWrite->GetRootFileName();
03472   Bool_t allowed_to_read = kFALSE;
03473     
03474 //  if ( fOpenRootFile )
03475 //    {
03476 //      cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***>"
03477 //         << " Reading on file already open." << fTTBELL << endl;
03478 //    }
03479 
03480   if( FileNameLong == fCurrentlyOpenFileName )
03481     {
03482       allowed_to_read = kTRUE;
03483     }
03484   else
03485     {
03486       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03487       ok_open = OpenRootFile(file_name, "READ");
03488 
03489       if(ok_open)
03490         {
03491           allowed_to_read = kTRUE;
03492         }
03493       else
03494         {
03495           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03496                << file_name << fTTBELL << endl;
03497           allowed_to_read = kFALSE;
03498           ok_read = kFALSE;
03499         }
03500     }
03501 
03502   if( allowed_to_read == kTRUE )
03503     {
03504       Int_t i_zero = 0;
03505 
03506       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03507       
03508       if ( ok_read == kTRUE )
03509         {
03510           fDataExist = kTRUE;
03511           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
03512             {
03513               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
03514               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
03515                 {
03516                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
03517                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03518                 }
03519             }
03520         }
03521       else
03522         {
03523           fDataExist = kFALSE;
03524           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
03525                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03526                << "                                                                             -> quantity: <"
03527                << GetTypeOfQuantity(typ) << "> not available in file."
03528                << fTTBELL << endl;
03529         }
03530       CloseRootFile(file_name);
03531     }
03532   return mat;
03533 }
03534 //----- end of ( ReadHighFrequencyCorrelationsBetweenChannels(...) ) -------
03535 
03536 //-------------------------------------------------------------------------
03537 //
03538 //         ReadLowFrequencyCovariancesBetweenChannels(...)
03539 //                  (NOT USED)
03540 //-------------------------------------------------------------------------
03541 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t& MatDim)
03542 {
03543 //Read all the Low Frequency covariances
03544 //in ROOT file and return them in a TMatrixD
03545 //
03546 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
03547 
03548   TestArrayDimH2("ReadLowFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysEcnaInStex()",
03549                  fEcal->MaxCrysEcnaInStex(), MatDim);
03550 
03551   //=====> WARNING: BIG MATRIX (1700x1700)
03552   TMatrixD mat(MatDim, MatDim);
03553   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03554 
03555   TVectorD vec(fEcal->MaxStinEcnaInStex());
03556   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03557   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03558   
03559   CnaResultTyp typ = cTypLfCov;
03560 
03561   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03562   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03563 
03564   Bool_t ok_open = kFALSE;
03565   Bool_t ok_read = kFALSE;
03566     
03567   TString FileNameLong = fCnaWrite->GetRootFileName();
03568   Bool_t allowed_to_read = kFALSE;
03569   
03570 //  if ( fOpenRootFile )
03571 //    {
03572 //      cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels() *** ERROR ***>"
03573 //         << " Reading on file already open." << fTTBELL << endl;
03574 //    }
03575 
03576   if( FileNameLong == fCurrentlyOpenFileName )
03577     {
03578       allowed_to_read = kTRUE;
03579     }
03580   else
03581     {
03582       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03583       ok_open = OpenRootFile(file_name, "READ");
03584 
03585       if(ok_open)
03586         {
03587           allowed_to_read = kTRUE;
03588         }
03589       else
03590         {
03591           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03592                << file_name << fTTBELL << endl;
03593           allowed_to_read = kFALSE;
03594           ok_read = kFALSE;
03595         }
03596     }
03597 
03598   if( allowed_to_read == kTRUE )
03599     {
03600       Int_t i_zero = 0;
03601       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03602       
03603       if ( ok_read == kTRUE )
03604         {
03605           fDataExist = kTRUE;
03606           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
03607             {
03608               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
03609                 {
03610                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
03611                     {
03612                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
03613                         {
03614                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
03615                             {
03616                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
03617                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() +i_crys;
03618                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
03619                                 {
03620                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
03621                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() +j_crys;
03622                                   mat(i_chan_sm, j_chan_sm) =
03623                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03624                                 }
03625                             }
03626                         }
03627                     }
03628                 }
03629             }
03630         }
03631       else
03632         {
03633           fDataExist = kFALSE;
03634           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels() *** ERROR ***> "
03635                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03636                << "                                                                        -> quantity: <"
03637                << GetTypeOfQuantity(typ) << "> not available in file."
03638                << fTTBELL << endl;
03639         }
03640       CloseRootFile(file_name);
03641     }
03642   return mat;
03643 }
03644 //----- end of ( ReadLowFrequencyCovariancesBetweenChannels(...) ) -------
03645 
03646 //-------------------------------------------------------------------------
03647 //
03648 //         ReadLowFrequencyCorrelationsBetweenChannels(...)
03649 //
03650 //-------------------------------------------------------------------------
03651 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t& MatDim)
03652 {
03653 //Read all the Low Frequency correlations
03654 //in ROOT file and return them in a TMatrixD
03655 //
03656 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
03657 
03658   TestArrayDimH2("ReadLowFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysEcnaInStex()",
03659                  fEcal->MaxCrysEcnaInStex(), MatDim);
03660 
03661   //=====> WARNING: BIG MATRIX (1700x1700)
03662   TMatrixD mat(MatDim, MatDim);
03663   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03664 
03665   TVectorD vec(fEcal->MaxStinEcnaInStex());
03666   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03667   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03668   
03669   CnaResultTyp typ = cTypLfCor;
03670 
03671   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03672   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03673 
03674   Bool_t ok_open = kFALSE;
03675   Bool_t ok_read = kFALSE;
03676     
03677   TString FileNameLong = fCnaWrite->GetRootFileName();
03678   Bool_t allowed_to_read = kFALSE;
03679     
03680 //  if ( fOpenRootFile )
03681 //    {
03682 //      cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels() *** ERROR ***>"
03683 //         << " Reading on file already open." << fTTBELL << endl;
03684 //    }
03685 
03686   if( FileNameLong == fCurrentlyOpenFileName )
03687     {
03688       allowed_to_read = kTRUE;
03689     }
03690   else
03691     {
03692       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03693       ok_open = OpenRootFile(file_name, "READ");
03694 
03695       if(ok_open)
03696         {
03697           allowed_to_read = kTRUE;
03698         }
03699       else
03700         {
03701           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03702                << file_name << fTTBELL << endl;
03703           allowed_to_read = kFALSE;
03704           ok_read = kFALSE;
03705         }
03706     }
03707 
03708   if( allowed_to_read == kTRUE )
03709     {
03710       Int_t i_zero = 0;
03711       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03712       
03713       if ( ok_read == kTRUE )
03714         {
03715           fDataExist = kTRUE;
03716           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
03717             {
03718               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
03719                 {
03720                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
03721                     {
03722                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
03723                         {
03724                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
03725                             {
03726                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
03727                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() + i_crys;
03728                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
03729                                 {
03730                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
03731                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() + j_crys;
03732                                   mat(i_chan_sm, j_chan_sm) =
03733                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03734                                 }
03735                             }
03736                         }
03737                     }
03738                 }
03739             }
03740         }
03741       else
03742         {
03743           fDataExist = kFALSE;
03744           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
03745                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03746                << "                                                                         ->  quantity: <"
03747                << GetTypeOfQuantity(typ) << "> not available in file."
03748                << fTTBELL << endl;
03749         }
03750       CloseRootFile(file_name);
03751     }
03752   return mat;
03753 }
03754 //----- end of (ReadLowFrequencyCorrelationsBetweenChannels(...) ) -------
03755 
03756 //-------------------------------------------------------------------------
03757 //
03758 //         ReadHighFrequencyCovariancesBetweenChannels(...)
03759 //                  (NOT USED)
03760 //-------------------------------------------------------------------------
03761 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t& MatDim)
03762 {
03763 //Read all the High Frequency covariances
03764 //in ROOT file and return them in a TMatrixD
03765 //
03766 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
03767 
03768   TestArrayDimH2("ReadHighFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysEcnaInStex()",
03769                  fEcal->MaxCrysEcnaInStex(), MatDim);
03770 
03771   //=====> WARNING: BIG MATRIX (1700x1700)
03772   TMatrixD mat(MatDim, MatDim);
03773   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03774 
03775   TVectorD vec(fEcal->MaxStinEcnaInStex());
03776   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03777   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03778   
03779   CnaResultTyp typ = cTypHfCov;
03780 
03781   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03782   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03783 
03784   Bool_t ok_open = kFALSE;
03785   Bool_t ok_read = kFALSE;
03786     
03787   TString FileNameLong = fCnaWrite->GetRootFileName();
03788   Bool_t allowed_to_read = kFALSE;
03789 
03790 //  if ( fOpenRootFile )
03791 //    {
03792 //      cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels() *** ERROR ***>"
03793 //         << " Reading on file already open." << fTTBELL << endl;
03794 //    }
03795 
03796   if( FileNameLong == fCurrentlyOpenFileName )
03797     {
03798       allowed_to_read = kTRUE;
03799     }
03800   else
03801     {
03802       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03803       ok_open = OpenRootFile(file_name, "READ");
03804 
03805       if(ok_open)
03806         {
03807           allowed_to_read = kTRUE;
03808         }
03809       else
03810         {
03811           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03812                << file_name << fTTBELL << endl;
03813           allowed_to_read = kFALSE;
03814           ok_read = kFALSE;
03815         }
03816     }
03817 
03818   if( allowed_to_read == kTRUE )
03819     {
03820       Int_t i_zero = 0;
03821       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03822       
03823       if ( ok_read == kTRUE )
03824         {
03825           fDataExist = kTRUE;
03826           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
03827             {
03828               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
03829                 {
03830                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
03831                     {
03832                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
03833                         {
03834                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
03835                             {
03836                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
03837                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() +i_crys;
03838                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
03839                                 {
03840                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
03841                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() +j_crys;
03842                                   mat(i_chan_sm, j_chan_sm) =
03843                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03844                                 }
03845                             }
03846                         }
03847                     }
03848                 }
03849             }
03850         }
03851       else
03852         {
03853           fDataExist = kFALSE;
03854           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels() *** ERROR ***> "
03855                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03856                << "                                                                         -> quantity: <"
03857                << GetTypeOfQuantity(typ) << "> not available in file."
03858                << fTTBELL << endl;
03859         }
03860       CloseRootFile(file_name);
03861     }
03862   return mat;
03863 }
03864 //----- end of ( ReadHighFrequencyCovariancesBetweenChannels(...) ) -------
03865 
03866 //-------------------------------------------------------------------------
03867 //
03868 //         ReadHighFrequencyCorrelationsBetweenChannels(...)
03869 //
03870 //-------------------------------------------------------------------------
03871 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t& MatDim)
03872 {
03873 //Read all the High Frequency correlations
03874 //in ROOT file and return them in a TMatrixD
03875 //
03876 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
03877 
03878   TestArrayDimH2("ReadHighFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysEcnaInStex()",
03879                  fEcal->MaxCrysEcnaInStex(), MatDim);
03880 
03881   //=====> WARNING: BIG MATRIX (1700x1700)
03882   TMatrixD mat(MatDim, MatDim);
03883   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03884 
03885   TVectorD vec(fEcal->MaxStinEcnaInStex());
03886   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03887   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03888   
03889   CnaResultTyp typ = cTypHfCor;
03890 
03891   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03892   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
03893 
03894   Bool_t ok_open = kFALSE;
03895   Bool_t ok_read = kFALSE;
03896     
03897   TString FileNameLong = fCnaWrite->GetRootFileName();
03898   Bool_t allowed_to_read = kFALSE;
03899   
03900 //  if ( fOpenRootFile )
03901 //    {
03902 //      cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels() *** ERROR ***>"
03903 //         << " Reading on file already open." << fTTBELL << endl;
03904 //    }
03905 
03906   if( FileNameLong == fCurrentlyOpenFileName )
03907     {
03908       allowed_to_read = kTRUE;
03909     }
03910   else
03911     {
03912       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
03913       ok_open = OpenRootFile(file_name, "READ");
03914 
03915       if(ok_open)
03916         {
03917           allowed_to_read = kTRUE;
03918         }
03919       else
03920         {
03921           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed for file: "
03922                << file_name << fTTBELL << endl;
03923           allowed_to_read = kFALSE;
03924           ok_read = kFALSE;
03925         }
03926     }
03927 
03928   if( allowed_to_read == kTRUE )
03929     {
03930       Int_t i_zero = 0;
03931       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03932       
03933       if ( ok_read == kTRUE )
03934         {
03935           fDataExist = kTRUE;
03936           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
03937             {
03938               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
03939                 {
03940                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
03941                     {
03942                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
03943                         {
03944                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
03945                             {
03946                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
03947                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() + i_crys;
03948                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
03949                                 {
03950                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
03951                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() + j_crys;
03952                                   mat(i_chan_sm, j_chan_sm) =
03953                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
03954                                 }
03955                             }
03956                         }
03957                     }
03958                 }
03959             }
03960         }
03961       else
03962         {
03963           fDataExist = kFALSE;
03964           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
03965                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
03966                << "                                                                          -> quantity: <"
03967                << GetTypeOfQuantity(typ) << "> not available in file."
03968                << fTTBELL << endl;
03969         }
03970       CloseRootFile(file_name);
03971     }
03972   return mat;
03973 }
03974 //-------------- ( end of ReadHighFrequencyCorrelationsBetweenChannels(...) ) ---------
03975 
03976 
03977 //-------------------------------------------------------------------------
03978 //
03979 //         ReadLowFrequencyMeanCorrelationsBetweenStins(...)
03980 //
03981 //-------------------------------------------------------------------------
03982 TMatrixD TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins(const Int_t& MatDim)
03983 {
03984 //Read all the Low Frequency Mean Correlations Between Stins the for all (Stin_X, Stin_Y)
03985 //in ROOT file and return them in a TMatrixD
03986 //
03987 //Possible values for MatDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
03988 
03989   TestArrayDimH2("ReadLowFrequencyMeanCorrelationsBetweenStins", "fEcal->MaxStinEcnaInStex()",
03990                  fEcal->MaxStinEcnaInStex(), MatDim);
03991 
03992   TMatrixD mat(MatDim, MatDim);
03993   for(Int_t i=0; i<MatDim; i++)
03994     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
03995 
03996   TVectorD vec(fEcal->MaxStinEcnaInStex());
03997   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03998   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03999 
04000   CnaResultTyp typ = cTypLFccMoStins;
04001 
04002   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
04003   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
04004 
04005   Bool_t ok_open = kFALSE;
04006   Bool_t ok_read = kFALSE;
04007     
04008   TString FileNameLong = fCnaWrite->GetRootFileName();
04009   Bool_t allowed_to_read = kFALSE;
04010     
04011 //  if ( fOpenRootFile )
04012 //    {
04013 //      cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins() *** ERROR ***>"
04014 //         << " Reading on file already open." << fTTBELL << endl;
04015 //    }
04016 
04017   if( FileNameLong == fCurrentlyOpenFileName )
04018     {
04019       allowed_to_read = kTRUE;
04020     }
04021   else
04022     {
04023       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
04024       ok_open = OpenRootFile(file_name, "READ");
04025 
04026       if(ok_open)
04027         {
04028           allowed_to_read = kTRUE;
04029         }
04030       else
04031         {
04032           cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins(...) *** ERROR ***> Open .root file failed for file: "
04033                << file_name << fTTBELL << endl;
04034           allowed_to_read = kFALSE;
04035           ok_read = kFALSE;
04036         }
04037     }
04038 
04039   if( allowed_to_read == kTRUE )
04040     {
04041       Int_t i_zero = 0;
04042       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
04043       
04044       if( ok_read == kTRUE )
04045         {
04046           fDataExist = kTRUE;
04047           for(Int_t index_Stin_a = 0; index_Stin_a < MatDim; index_Stin_a++)
04048             {
04049               for(Int_t index_Stin_b = 0; index_Stin_b < MatDim; index_Stin_b++)   
04050                 {
04051                   if( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim)
04052                     {
04053                       if( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim)
04054                         {
04055                           Int_t vec_ia_m = (Int_t)vec(index_Stin_a)-1;
04056                           Int_t vec_ib_m = (Int_t)vec(index_Stin_b)-1;
04057                           mat((Int_t)vec_ia_m, vec_ib_m) =
04058                             gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a,index_Stin_b);
04059                         }
04060                     }
04061                 }
04062             }
04063         } 
04064       else
04065         {
04066           fDataExist = kFALSE;
04067           cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
04068                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
04069                << "                                                                          -> quantity: <"
04070                << GetTypeOfQuantity(typ) << "> not available in file."
04071                << fTTBELL << endl;
04072         }
04073       CloseRootFile(file_name);
04074     }
04075   return mat;
04076 }
04077 //-------- ( end of ReadLowFrequencyMeanCorrelationsBetweenStins) --------
04078 
04079 //-------------------------------------------------------------------------
04080 //
04081 //         ReadHighFrequencyMeanCorrelationsBetweenStins(...)
04082 //
04083 //-------------------------------------------------------------------------
04084 TMatrixD TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins(const Int_t& MatDim)
04085 {
04086 //Read all the High Frequency Mean Correlations Between Stins the for all (Stin_X, Stin_Y)
04087 //in ROOT file and return them in a TMatrixD
04088 //
04089 //Possible values for MatDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
04090 
04091   TestArrayDimH2("ReadHighFrequencyMeanCorrelationsBetweenStins", "fEcal->MaxStinEcnaInStex()",
04092                  fEcal->MaxStinEcnaInStex(), MatDim);
04093 
04094   TMatrixD mat(MatDim, MatDim);
04095   for(Int_t i=0; i<MatDim; i++)
04096     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
04097 
04098   TVectorD vec(fEcal->MaxStinEcnaInStex());
04099   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
04100   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
04101 
04102   CnaResultTyp typ = cTypHFccMoStins;
04103 
04104   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
04105   const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
04106 
04107   Bool_t ok_open = kFALSE;
04108   Bool_t ok_read = kFALSE;
04109     
04110   TString FileNameLong = fCnaWrite->GetRootFileName();
04111   Bool_t allowed_to_read = kFALSE;
04112   
04113 //  if ( fOpenRootFile )
04114 //    {
04115 //      cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins() *** ERROR ***>"
04116 //         << " Reading on file already open." << fTTBELL << endl;
04117 //    }
04118 
04119   if( FileNameLong == fCurrentlyOpenFileName )
04120     {
04121       allowed_to_read = kTRUE;
04122     }
04123   else
04124     {
04125       if( fCurrentlyOpenFileName != fFlagNoFileOpen ){CloseRootFile(current_file_name);}
04126       ok_open = OpenRootFile(file_name, "READ");
04127 
04128       if(ok_open)
04129         {
04130           allowed_to_read = kTRUE;
04131         }
04132       else
04133         {
04134           cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins(...) *** ERROR ***> Open .root file failed for file: "
04135                << file_name << fTTBELL << endl;
04136           allowed_to_read = kFALSE;
04137           ok_read = kFALSE;
04138         }
04139     }
04140 
04141   if( allowed_to_read == kTRUE )
04142     {
04143       Int_t i_zero = 0;
04144       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
04145       
04146       if( ok_read == kTRUE )
04147         {
04148           fDataExist = kTRUE;
04149           for(Int_t index_Stin_a = 0; index_Stin_a < MatDim; index_Stin_a++)
04150             {
04151               for(Int_t index_Stin_b = 0; index_Stin_b < MatDim; index_Stin_b++)   
04152                 {
04153                   if( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim)
04154                     {
04155                       if( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim)
04156                         {
04157                           Int_t vec_ia_m = (Int_t)vec(index_Stin_a)-1;
04158                           Int_t vec_ib_m = (Int_t)vec(index_Stin_b)-1;
04159                           mat((Int_t)vec_ia_m, (Int_t)vec_ib_m) =
04160                             gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a,index_Stin_b);
04161                         }
04162                     }
04163                 }
04164             }
04165         } 
04166       else
04167         {
04168           fDataExist = kFALSE;
04169           cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
04170                << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
04171                << "                                                                           -> quantity: <"
04172                << GetTypeOfQuantity(typ) << "> not available in file."
04173                << fTTBELL << endl;
04174         }
04175       CloseRootFile(file_name);
04176     }
04177   return mat;
04178 }
04179 //-------- ( end of ReadHighFrequencyMeanCorrelationsBetweenStins) --------
04180 
04181 //=============================================================================
04182 //
04183 //             M I S C E L L A N E O U S     R E A D      M E T H O D S
04184 //
04185 //=============================================================================
04186 
04187 //--------------------------------------------------------------------------------------
04188 //
04189 //       ReadSampleAdcValuesSameFile(fEcal->MaxCrysEcnaInStex(),
04190 //                                   fFileHeader->fNbOfSamples, fFileHeader->fReqNbOfEvts)  
04191 //
04192 //--------------------------------------------------------------------------------------
04193 Double_t*** TEcnaRead::ReadSampleAdcValuesSameFile(const Int_t& DimX, const Int_t& DimY, const Int_t& DimZ)
04194 {
04195 
04196 //Possible values for DimX, DimY, DimZ : (1) DimX = fEcal->MaxCrysEcnaInStex()
04197 //                                           DimY = fFileHeader->fNbOfSamples
04198 //                                           DimZ = fFileHeader->fReqNbOfEvts
04199 
04200   if(fT3d_AdcValues == 0)
04201     {
04202       //............ Allocation for the 3d array 
04203       fT3d_AdcValues   = new Double_t**[DimX];                         fCnew++;  
04204       fT3d2_AdcValues  = new  Double_t*[DimX*DimY];                    fCnew++;  
04205       fT3d1_AdcValues  = new   Double_t[DimX*DimY*DimZ];               fCnew++;
04206       
04207       for(Int_t i0StexEcha = 0 ; i0StexEcha < DimX ; i0StexEcha++){
04208         fT3d_AdcValues[i0StexEcha] = &fT3d2_AdcValues[0] + i0StexEcha*DimY;
04209         for(Int_t j_samp = 0 ; j_samp < DimY ; j_samp++){
04210           fT3d2_AdcValues[DimY*i0StexEcha + j_samp] = &fT3d1_AdcValues[0]+
04211             DimZ*(DimY*i0StexEcha+j_samp);}}
04212     }
04213   
04214   //................................. Init to zero                 (ReadSampleAdcValuesSameFile)
04215   for (Int_t iza=0; iza<DimX; iza++)
04216     {
04217       for (Int_t izb=0; izb<DimY; izb++)
04218         {
04219           for (Int_t izc=0; izc<DimZ; izc++)
04220             {
04221               if( fT3d_AdcValues[iza][izb][izc] != (Double_t)0 )
04222                 {
04223                   fT3d_AdcValues[iza][izb][izc] = (Double_t)0;
04224                 }
04225             }
04226         }
04227     }     
04228   
04229   //-------------------------------------------------------------------------- (ReadSampleAdcValuesSameFile)
04230   CnaResultTyp typ = cTypAdcEvt;   //  sample as a function of time type
04231 
04232   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
04233 
04234   Bool_t ok_open = kFALSE;
04235   Bool_t ok_read = kFALSE;
04236 
04237   Int_t  i_entry      = 0;  
04238   Int_t  i_entry_fail = 0;  
04239 
04240   ok_open = OpenRootFile(file_name, "READ");
04241   
04242   if( ok_open == kTRUE )
04243     {
04244       for(Int_t i0StexEcha=0; i0StexEcha<DimX; i0StexEcha++)
04245         {
04246           if( i0StexEcha == 0 )
04247             {
04248               i_entry = gCnaRootFile->ReadElementNextEntryNumber(typ, i0StexEcha);
04249               if( i_entry >= 0 ){ok_read = kTRUE;}
04250             }
04251           if( i_entry >= 0 )                                                //  (ReadSampleAdcValuesSameFile)
04252             {
04253               if( i0StexEcha > 0 ){ok_read = gCnaRootFile->ReadElement(i_entry); i_entry++;}
04254               
04255               if ( ok_read == kTRUE )
04256                 {
04257                   fDataExist = kTRUE;     
04258                   for(Int_t sample=0; sample<DimY; sample++)
04259                     {
04260                       for ( Int_t i_bin=0; i_bin<DimZ; i_bin++)
04261                         {
04262                           fT3d_AdcValues[i0StexEcha][sample][i_bin]
04263                             = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
04264                         }  
04265                     }
04266                 } 
04267               else                                                        //  (ReadSampleAdcValuesSameFile)
04268                 {
04269                   fDataExist = kFALSE;
04270                   cout << "!TEcnaRead::ReadSampleAdcValuesSameFile(...) *** ERROR ***> "
04271                        << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << endl
04272                        << "                                                         -> quantity: <"
04273                        << GetTypeOfQuantity(typ) << "> not available in file."
04274                        << fTTBELL << endl;
04275                 }
04276             }
04277           else
04278             {
04279               i_entry_fail++;
04280             }
04281         }
04282       CloseRootFile(file_name);
04283     }
04284   else
04285     {
04286       cout  << "*TEcnaRead::ReadSampleAdcValuesSameFile(...)> *ERROR* =====> "
04287             << " ROOT file not found" << fTTBELL << endl;
04288     }
04289 
04290   if(i_entry_fail > 0 )
04291     {
04292       cout  << "*TEcnaRead::ReadSampleAdcValuesSameFile(...)> *ERROR* =====> "
04293             << " Entry reading failure(s). i_entry_fail = "
04294             << i_entry_fail << fTTBELL << endl;
04295     }
04296   return fT3d_AdcValues;
04297 }
04298 //--- (end of ReadSampleAdcValuesSameFile) ----------
04299 
04300 
04301 //=========================================================================
04302 //
04303 //          M I S C E L L A N E O U S    G E T    M E T H O D S   
04304 //
04305 //=========================================================================
04306 Int_t TEcnaRead::GetNumberOfEvents(const Int_t& xFapNbOfReqEvts)
04307 {
04308   //...... Calculate the number of found events  (file existence already tested in calling method)
04309   Int_t xFapNbOfEvts = 0; 
04310 
04311   TVectorD NOFE_histp(fEcal->MaxCrysEcnaInStex());
04312   for(Int_t i=0; i<fEcal->MaxCrysEcnaInStex(); i++){NOFE_histp(i)=(Double_t)0.;}
04313   NOFE_histp = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
04314 
04315   //... Call to fCnaWrite->NumberOfEventsAnalysis(...) 1rst argument must be Int_t, not TVectorD,
04316   //    duplicate NOFE_histp to NOFE_int to obtain fFapNbOfEvts from fCnaWrite->NumberOfEventsAnalysis(...)
04317   Int_t* NOFE_int = new Int_t[fEcal->MaxCrysEcnaInStex()];   fCnew++;
04318   for(Int_t i=0; i<fEcal->MaxCrysEcnaInStex(); i++){NOFE_int[i]=(Int_t)NOFE_histp(i);}
04319 
04320   xFapNbOfEvts = fCnaWrite->NumberOfEventsAnalysis(NOFE_int, fEcal->MaxCrysEcnaInStex(), xFapNbOfReqEvts);
04321 
04322   delete [] NOFE_int; NOFE_int = 0;                          fCdelete++;
04323 
04324   return xFapNbOfEvts;
04325 }
04326 
04327 //-------------------------------------------------------------------------
04328 //
04329 //    Get the name of the quantity from its "CnaResultTyp" type
04330 //
04331 //-------------------------------------------------------------------------
04332 TString TEcnaRead::GetTypeOfQuantity(const CnaResultTyp arg_typ)
04333 {
04334   TString quantity_name = "?";
04335 
04336   if( arg_typ == cTypNumbers)
04337     {
04338       if( fFlagSubDet == "EB" ){quantity_name = "SM numbers";}
04339       if( fFlagSubDet == "EE" ){quantity_name = "Dee numbers";}
04340     }
04341   if( arg_typ == cTypMSp    ){quantity_name = "Mean samples";}
04342   if( arg_typ == cTypSSp    ){quantity_name = "Sigma of samples";}
04343 
04344   if( arg_typ == cTypNbOfEvts ){quantity_name = "Number of events";}
04345   if( arg_typ == cTypPed      ){quantity_name = "Pedestals";}
04346   if( arg_typ == cTypTno      ){quantity_name = "Total noise";}
04347   if( arg_typ == cTypLfn      ){quantity_name = "LF noise";}
04348   if( arg_typ == cTypHfn      ){quantity_name = "HF noise";}
04349   if( arg_typ == cTypMeanCorss){quantity_name = "Mean cor(s,s')";}
04350   if( arg_typ == cTypSigCorss ){quantity_name = "Sigma of cor(s,s')";}
04351 
04352   if( arg_typ == cTypAvPed      ){quantity_name = "Average pedestals";}
04353   if( arg_typ == cTypAvTno      ){quantity_name = "Average total noise";}
04354   if( arg_typ == cTypAvLfn      ){quantity_name = "Average LF noise";}
04355   if( arg_typ == cTypAvHfn      ){quantity_name = "Average HF noise";}
04356   if( arg_typ == cTypAvMeanCorss){quantity_name = "Average mean cor(s,s')";}
04357   if( arg_typ == cTypAvSigCorss ){quantity_name = "Average sigma of cor(s,s')";}
04358 
04359   if( arg_typ == cTypAdcEvt ){quantity_name = "Sample ADC a.f.o event number";}
04360 
04361   if( arg_typ == cTypCovCss ){quantity_name = "Cov(s,s')";}
04362   if( arg_typ == cTypCorCss ){quantity_name = "Cor(s,s')";}
04363   if( arg_typ == cTypLfCov  ){quantity_name = "LF Cov(c,c')";}
04364   if( arg_typ == cTypLfCor  ){quantity_name = "LF Cor(c,c')";}
04365   if( arg_typ == cTypHfCov  ){quantity_name = "HF Cov(c,c')";}
04366   if( arg_typ == cTypHfCor  ){quantity_name = "HF Cor(c,c')";}
04367 
04368   if( fFlagSubDet == "EB" )
04369     {
04370       if( arg_typ == cTypLFccMoStins){quantity_name = "Mean LF |Cor(c,c')| in (tow,tow')";}
04371       if( arg_typ == cTypHFccMoStins){quantity_name = "Mean HF |Cor(c,c')| in (tow,tow')";}
04372     }
04373   if( fFlagSubDet == "EE" )
04374     {
04375       if( arg_typ == cTypLFccMoStins){quantity_name = "Mean LF |Cor(c,c')| in (SC,SC')";}
04376       if( arg_typ == cTypHFccMoStins){quantity_name = "Mean HF |Cor(c,c')| in (SC,SC')";}
04377     }
04378   return quantity_name;
04379 }
04380 
04381 //-------------------------------------------------------------------------
04382 //
04383 //    Get the ROOT file name (long and short)
04384 //
04385 //-------------------------------------------------------------------------
04386 TString TEcnaRead::GetRootFileName(){return fCnaWrite->GetRootFileName();}
04387 TString TEcnaRead::GetRootFileNameShort(){return fCnaWrite->GetRootFileNameShort();}
04388 //-------------------------------------------------------------------------
04389 //
04390 //                     GetStexStinFromIndex
04391 //
04392 //  *==> DON'T SUPPRESS: this method is called by TEcnaRun and TEcnaHistos
04393 //
04394 //-------------------------------------------------------------------------
04395 Int_t TEcnaRead::GetStexStinFromIndex(const Int_t& i0StexStinEcna)
04396 {
04397 // Get the Stin number in Stex from the Stin index
04398 
04399   Int_t number = -1;
04400   TVectorD vec(fEcal->MaxStinEcnaInStex());
04401   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
04402   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
04403   number = (Int_t)vec(i0StexStinEcna);
04404   return number;
04405 }
04406 
04407 //------------------------------------------------------------------------
04408 
04409 Int_t  TEcnaRead::GetNumberOfBinsSampleAsFunctionOfTime(){return GetReqNbOfEvts();}
04410 //-------------------------------------------------------------------------
04411 //
04412 //                     GetStinIndex(n1StexStin)
04413 //
04414 //-------------------------------------------------------------------------
04415 Int_t  TEcnaRead::GetStinIndex(const Int_t & n1StexStin)
04416 {
04417 //Get the index of the Stin from its number in Stex
04418 
04419   if(fFlagPrint == fCodePrintAllComments){
04420     cout << "*TEcnaRead::GetStinIndex(...)> fEcal->MaxStinEcnaInStex() = "
04421          << fEcal->MaxStinEcnaInStex() << endl
04422          << "                              n1StexStin = " << n1StexStin
04423          << endl << endl;}
04424 
04425   Int_t Stin_index = n1StexStin-1;    // suppose les 68 tours 
04426 
04427 #define NOGT
04428 #ifndef NOGT
04429   Int_t Stin_index = -1;
04430   TVectorD vec(fEcal->MaxStinEcnaInStex());
04431   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
04432   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
04433 
04434   //........................... Get the Stin index
04435 
04436   for(Int_t i=0; i < fEcal->MaxStinEcnaInStex(); i++)
04437     {
04438       if(fFlagPrint == fCodePrintAllComments){
04439         cout << "*TEcnaRead::GetStinIndex(...)> StinNumber[" << i << "] = "
04440              << vec[i] << endl;}
04441       if ( vec[i] == n1StexStin ){Stin_index = i;}
04442     }
04443 
04444   if(fFlagPrint == fCodePrintAllComments){
04445     cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << endl;
04446     cout << "*TEcnaRead::GetStinIndex> Stin number: " << n1StexStin  << endl
04447          << "                          Stin index : " << Stin_index << endl;
04448     cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << endl;}
04449 
04450   if ( Stin_index < 0 )
04451     {
04452       if(fFlagPrint == fCodePrintAllComments){
04453         cout << "!TEcnaRead::GetStinIndex *** WARNING ***> n1StexStin" << n1StexStin << " : "
04454              << "index Stin not found"
04455              << fTTBELL << endl;}
04456     }
04457 #endif // NOGT
04458 
04459   return Stin_index;
04460 }
04461 
04462 //=========================================================================
04463 //
04464 //         METHODS TO SET FLAGS TO PRINT (OR NOT) COMMENTS (DEBUG)
04465 //
04466 //=========================================================================
04467 
04468 void  TEcnaRead::PrintComments()
04469 {
04470 // Set flags to authorize printing of some comments concerning initialisations (default)
04471 
04472   fFlagPrint = fCodePrintComments;
04473   cout << "*TEcnaRead::PrintComments()> Warnings and some comments on init will be printed" << endl;
04474 }
04475 
04476 void  TEcnaRead::PrintWarnings()
04477 {
04478 // Set flags to authorize printing of warnings
04479 
04480   fFlagPrint = fCodePrintWarnings;
04481   cout << "*TEcnaRead::PrintWarnings()> Warnings will be printed" << endl;
04482 }
04483 
04484 void  TEcnaRead::PrintAllComments()
04485 {
04486 // Set flags to authorize printing of the comments of all the methods
04487 
04488   fFlagPrint = fCodePrintAllComments;
04489   cout << "*TEcnaRead::PrintAllComments()> All the comments will be printed" << endl;
04490 }
04491 
04492 void  TEcnaRead::PrintNoComment()
04493 {
04494 // Set flags to forbid the printing of all the comments
04495 
04496   fFlagPrint = fCodePrintNoComment;
04497 }