CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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: 08/04/2010
00004 
00005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h"
00006 
00007 R__EXTERN TEcnaRootFile *gCnaRootFile;
00008 
00009 ClassImp(TEcnaRead)
00010 //___________________________________________________________________________
00011 //
00012 // TEcnaRead.
00013 //==============> INTRODUCTION
00014 //
00015 //    This class allows the user to read the .root results files (containing
00016 //   expectation values, variances, covariances, correlations and other
00017 //   quantities of interest) previously computed by the class TEcnaRun.
00018 //   (see documentation of this class)
00019 //
00020 //==============> PRELIMINARY REMARK
00021 //
00022 //    The user is not obliged to use directly this class. Another class
00023 //   named TEcnaHistos can be used to make plots of the results computed
00024 //   previously by means of the class TEcnaRun. The class TEcnaHistos
00025 //   calls TEcnaRead and manage the reading of the .root result files.
00026 //   (see the documentation of the class TEcnaHistos)
00027 //
00028 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00029 //
00030 //      Class TEcnaRead      ***   I N S T R U C T I O N S   F O R   U S E   ***
00031 //
00032 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00033 //
00034 //   //==============> TEcnaRead DECLARATION
00035 //
00036 //   // The declaration is done by calling the constructor without argument:
00037 //
00038 //       TEcnaRead* MyCnaRead = new TEcnaRead();
00039 //   
00040 //   //==============> PREPARATION METHOD GetReadyToReadRootFile(...)
00041 //
00042 //   // There is a preparation method named: GetReadyToReadRootFile(...);
00043 //
00044 //   //    GetReadyToReadRootFile(...) is used to read the quantities written
00045 //   //    in the ROOT files in order to use these quantities for analysis.
00046 //
00047 //   //.......  Example of program using GetReadyToReadRootFile(...)
00048 //
00049 //   //  This example describes the reading of one result file. This file is in a
00050 //   //  directory which name is given by the contents of a TString named PathForRootFile
00051 //
00052 //   //................ Set values for the arguments and call to the method
00053 //
00054 //      TString AnalysisName      = "AdcPed12"
00055 //      Int_t   RunNumber         = 22770;
00056 //      Int_t   FirstReqEvtNumber = 0;    
00057 //      Int_t   LastReqEvtNumber  = 150; 
00058 //      Int_t   NbOfEvts          = 150;
00059 //      TString PathForRootFile   = "/afs/cern.ch/etc..." // .root result files directory
00060 //
00061 //      TEcnaRead*  MyCnaRead = new TEcnaRead();
00062 //      MyCnaRead->GetReadyToReadRootFile(AnalysisName,      RunNumber,
00063 //                                        FirstReqEvtNumber, LastReqEvtNumber, ReqNbOfEvts, Stex,
00064 //                                        PathForRootFile);
00065 //
00066 //   //==============>  CALL TO THE METHOD: Bool_t LookAtRootFile() (MANDATORY)
00067 //    
00068 //    // This methods returns a boolean. It tests the existence
00069 //    // of the ROOT file corresponding to the argument values given
00070 //    // in the call to the method GetReadyToReadRootFile(...).
00071 //    // It is recommended to test the return value of the method.
00072 //
00073 //    //....... Example of use:
00074 //
00075 //     if( MyCnaRead->LookAtRootFile() == kFALSE )
00076 //        {
00077 //          cout << "*** ERROR: ROOT file not found" << endl;
00078 //        }
00079 //      else
00080 //        {
00081 //         //........... The ROOT file exists and has been found
00082 //         //
00083 //         //---> CALLS TO THE METHODS WHICH RECOVER THE QUANTITIES. EXAMPLE:
00084 //         //     (see the complete list of the methods hereafter)
00085 //
00086 //           Int_t   MaxSamples  = 10;
00087 //           TMatrixD CorMat(MaxSamples,MaxSamples);
00088 //           Int_t smStin = 59;
00089 //           Int_t i0StinEcha =  4;
00090 //           CorMat = MyCnaRead->ReadCorrelationsBetweenSamples(smStin,i0StinEcha);
00091 //                        :
00092 //            (Analysis of the correlations, etc...)
00093 //                        :
00094 //        }
00095 //
00096 //******************************************************************************
00097 //
00098 //                      *=======================*
00099 //                      | DETAILLED DESCRIPTION |
00100 //                      *=======================*
00101 //
00102 
00103 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00104 //
00105 //       Method GetReadyToReadRootFile(...) and associated methods
00106 //
00107 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00108 //
00109 //   TEcnaRead* MyCnaRead = new TEcnaRead();  // declaration of the object MyCnaRead
00110 //
00111 //   MyCnaRead->GetReadyToReadRootFile(AnalysisName, RunNumber,    NbOfSamples
00112 //                                     FirstReqEvtNumber, LastReqEvtNumber,  ReqEvtNumber, Stexumber,
00113 //                                     PathForRootFile);           
00114 //      
00115 //   Arguments:
00116 //
00117 //      TString  AnalysisName: code for the analysis. This code is
00118 //                             necessary to distinguish between different
00119 //                             analyses on the same events of a same run
00120 //                             (example: pedestal run for the 3 gains:
00121 //                                       AnalysisName = "Ped1" or "Ped6" or "Ped12")
00122 //                             The string AnalysisName is automatically
00123 //                             included in the name of the results files
00124 //                             (see below: results files paragraph)
00125 //
00126 //      Int_t    NbOfSamples         number of samples (=10 maximum) 
00127 //      Int_t    RunNumber:          run number
00128 //      Int_t    FirstReqEvtNumber:  first requested event number (numbering starting from 1)
00129 //      Int_t    LastReqEvtNumber:   last  requested event number
00130 //      Int_t    StexNumber:         SM or Dee number (Stex = SM if EB, Dee if EE)
00131 //      
00132 //     
00133 //      TString  PathForRootFile: Path of the directory containing the ROOT file.
00134 //               The path must be complete: /afs/cern.ch/user/... etc...
00135 //
00136 //==============> METHODS TO RECOVER THE QUANTITIES FROM THE ROOT FILE
00137 //
00138 //                SM = SuperModule  (EB) equivalent to a Dee   (EE)
00139 //                SC = SuperCrystal (EE) equivalent to a Tower (EB)
00140 //
00141 //                Stex = SM    in case of EB  ,  Dee in case of EE
00142 //                Stin = Tower in case of EB  ,  SC  in case of EE
00143 //
00144 //  n1StexStin = Stin#    in Stex = Tower number in SM (RANGE = [1,68]) .OR.  SC number in Dee (RANGE = [1,149])
00145 //  i0StexEcha = Channel# in Stex = Electronic channel number in SM    (RANGE = [0,1699]) .OR. in Dee (RANGE = [0,3724])
00146 //  i0StinEcha = Channel# in Stin = Electronic channel number in tower (RANGE = [0,24])   .OR. in SC  (RANGE = [0,24])
00147 //
00148 //  MaxCrysInStin     = Maximum number of Xtals in a tower or a SC (25)
00149 //  MaxCrysEcnaInStex = Maximum number of Xtals in SM (1700) or in the matrix including Dee (5000)
00150 //  MaxStinEcnaInStex = Maximum number of towers in SM (68)  or in the matrix including Dee (200)
00151 //  MaxSampADC        = Maximum number of samples (10)
00152 //  NbOfSample        = Number of samples used to perform the calculations
00153 //                      (example: for the 3 first samples, NbOfSample = 3)
00154 //
00155 //
00156 //  TVectorD and TMatrixD sizes are indicated after the argument lists or at the beginning of method sub-lists
00157 //
00158 //
00159 //  TMatrixD ReadNumberOfEventsForSamples
00160 //  (const Int_t& n1StexStin, const Int_t& MaxCrysInStin, const Int_t& NbOfSamples); // TMatrixD(MaxCrysInStin,NbOfSamples)
00161 //
00162 //  TVectorD ReadSampleValues
00163 //  (const Int_t& i0StexEcha, const Int_t& sample, const Int_t& NbOfReqEvts)         // TVectorD(Nb of requested evts)
00164 // 
00165 //  TVectorD ReadSampleMeans
00166 //           (const Int_t& n1StexStin,  const Int_t& i0StinEcha, const Int_t& NbOfSamples); // TVectorD(NbOfSamples)
00167 //  TVectorD ReadSampleSigmas
00168 //           (const Int_t& n1StexStin, const Int_t& i0StinEcha, const Int_t& NbOfSamples);  // TVectorD(NbOfSamples)
00169 //  TVectorD ReadSigmasOfSamples
00170 //           (const Int_t& n1StexStin, const Int_t& i0StinEcha, const Int_t& NbOfSamples);  // TVectorD(NbOfSamples)
00171 //
00172 //  TMatrixD ReadCovariancesBetweenSamples
00173 //               (const Int_t& n1StexStin, const Int_t& i0StinEcha); // TMatrixD(NbOfSamples,NbOfSamples)
00174 //  TMatrixD ReadCorrelationsBetweenSamples
00175 //               (const Int_t& n1StexStin, const Int_t& i0StinEcha); // TMatrixD(NbOfSamples,NbOfSamples)
00176 //
00177 // -----------------------------------------------------------  TMatrixD(MaxCrysInStin, MaxCrysInStin)
00178 //  TMatrixD ReadLowFrequencyCovariancesBetweenChannels
00179 //              (const Int_t& n1StexStin_X, const Int_t& n1StexStin_Y, const Int_t& MaxCrysInStin); 
00180 // 
00181 //  TMatrixD ReadLowFrequencyCorrelationsBetweenChannels
00182 //              (const Int_t& n1StexStin_X, const Int_t& n1StexStin_Y, const Int_t& MaxCrysInStin);
00183 //
00184 //  TMatrixD ReadHighFrequencyCovariancesBetweenChannels
00185 //              (const Int_t& n1StexStin_X, const Int_t& n1StexStin_Y, const Int_t& MaxCrysInStin);
00186 //  TMatrixD ReadHighFrequencyCorrelationsBetweenChannels
00187 //              (const Int_t& n1StexStin_X, const Int_t& n1StexStin_Y, const Int_t& MaxCrysInStin);
00188 //
00189 // ----------------- TMatrixD(MaxCrysEcnaInStex, MaxCrysEcnaInStex) (BIG!: 1700x1700 for EB and 5000x5000 for EE) 
00190 //  TMatrixD ReadLowFrequencyCovariancesBetweenChannels(const Int_t& MaxCrysEcnaInStex);
00191 //  TMatrixD ReadLowFrequencyCorrelationsBetweenChannels(const Int_t& MaxCrysEcnaInStex);
00192 //
00193 //  TMatrixD ReadHighFrequencyCovariancesBetweenChannels(const Int_t& MaxCrysEcnaInStex);
00194 //  TMatrixD ReadHighFrequencyCorrelationsBetweenChannels(const Int_t& MaxCrysEcnaInStex);
00195 //
00196 // ---------------------------------------------------- TMatrixD(MaxStinEcnaInStex, MaxStinEcnaInStex)
00197 //  TMatrixD ReadLowFrequencyMeanCorrelationsBetweenStins(const Int_t& MaxStinEcnaInStex);
00198 //  TMatrixD ReadHighFrequencyMeanCorrelationsBetweenStins(const Int_t& MaxStinEcnaInStex);
00199 //
00200 // ---------------------------------------------------------------------------------------------------------------
00201 //  TVectorD ReadPedestals(const Int_t& MaxCrysEcnaInStex);                         // TVectorD(MaxCrysEcnaInStex)
00202 //  TVectorD ReadTotalNoise(const Int_t& MaxCrysEcnaInStex);                        // TVectorD(MaxCrysEcnaInStex)
00203 //  TVectorD ReadMeanOfCorrelationsBetweenSamples(const Int_t& MaxCrysEcnaInStex);  // TVectorD(MaxCrysEcnaInStex)
00204 //
00205 //  TVectorD ReadLowFrequencyNoise(const Int_t& MaxCrysEcnaInStex);                 // TVectorD(MaxCrysEcnaInStex)
00206 //  TVectorD ReadHighFrequencyNoise(const Int_t& MaxCrysEcnaInStex);                // TVectorD(MaxCrysEcnaInStex)
00207 //  TVectorD ReadSigmaOfCorrelationsBetweenSamples(const Int_t& MaxCrysEcnaInStex); // TVectorD(MaxCrysEcnaInStex)
00208 //
00209 //----------------------------------------------------------------------------------------------------------------
00210 //  TString GetStartDate()
00211 //  TString GetStopDate()
00212 //  TString GetRunType()
00213 //  Int_t   GetFirstReqEvtNumber();
00214 //  Int_t   GetReqNbOfEvts();
00215 //
00216 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00217 //
00218 //                         Print Methods
00219 //
00220 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00221 //
00222 //     Just after the declaration with the constructor without arguments,
00223 //     you can set a "Print Flag" by means of the following "Print Methods":
00224 //
00225 //     TEcnaRead* MyCnaRead = new TEcnaRead(); // declaration of the object MyCnaRead
00226 //
00227 //    // Print Methods: 
00228 //
00229 //    MyCnaRead->PrintNoComment();  // Set flag to forbid printing of all the comments
00230 //                                  // except ERRORS.
00231 //
00232 //    MyCnaRead->PrintWarnings();   // (DEFAULT)
00233 //                                  // Set flag to authorize printing of some warnings.
00234 //                                  // WARNING/INFO: information on something unusual
00235 //                                  // in the data.
00236 //                                  // WARNING/CORRECTION: something wrong (but not too serious)
00237 //                                  // in the value of some argument.
00238 //                                  // Automatically modified to a correct value.
00239 //
00240 //    MyCnaRead->PrintComments();    // Set flag to authorize printing of infos
00241 //                                   //  and some comments concerning initialisations
00242 //
00243 //    MyCnaRead->PrintAllComments(); // Set flag to authorize printing of all the comments
00244 //
00245 //-------------------------------------------------------------------------
00246 //
00247 //        For more details on other classes of the CNA package:
00248 //
00249 //                 https://www.cern.ch/cms-fabbro/cna
00250 //
00251 //-------------------------------------------------------------------------
00252 //
00253 //------------------------------ TEcnaRead.cxx -----------------------------
00254 //  
00255 //   Creation (first version): 03 Dec 2002
00256 //
00257 //   For questions or comments, please send e-mail to Bernard Fabbro:
00258 //             
00259 //   fabbro@hep.saclay.cea.fr 
00260 //
00261 //------------------------------------------------------------------------
00262 
00263 TEcnaRead::TEcnaRead()
00264 {
00265 //Constructor without argument
00266   
00267  // cout << "[Info Management] CLASS: TEcnaRead.          CREATE OBJECT: this = " << this << endl;
00268 
00269   Init();
00270 }
00271 
00272 TEcnaRead::TEcnaRead(const TString SubDet,
00273                      const TEcnaParPaths*  pCnaParPaths,
00274                      const TEcnaParCout*   pCnaParCout,
00275                      const TEcnaHeader*    pFileHeader,
00276                      const TEcnaNumbering* pEcalNumbering,
00277                      const TEcnaWrite*     pCnaWrite)
00278 {
00279 //Constructor with argument
00280 
00281  // cout << "[Info Management] CLASS: TEcnaRead.          CREATE OBJECT: this = " << this << endl;
00282 
00283   fCnaParPaths = 0;
00284   if( pCnaParPaths == 0 )
00285     {fCnaParPaths = new TEcnaParPaths(); /* Anew("fCnaParPaths");*/ }
00286   else
00287     {fCnaParPaths = (TEcnaParPaths*)pCnaParPaths;}
00288 
00289   fCnaParCout  = 0;
00290   if( pCnaParCout == 0 )
00291     {fCnaParCout = new TEcnaParCout();   /*Anew("fCnaParCout");*/ }
00292   else
00293     {fCnaParCout = (TEcnaParCout*)pCnaParCout;}
00294 
00295   fFileHeader  = 0; 
00296   if( pFileHeader == 0 )
00297     {
00298       const Text_t *h_name  = "CnaHeader";  //==> voir cette question avec FXG
00299       const Text_t *h_title = "CnaHeader";  //==> voir cette question avec FXG
00300       fFileHeader = new TEcnaHeader(h_name, h_title);  // Anew("fFileHeader");
00301     }
00302   else
00303     {fFileHeader = (TEcnaHeader*)pFileHeader;}
00304 
00305   Init();
00306   SetEcalSubDetector(SubDet.Data(), pEcalNumbering, pCnaWrite);
00307 }
00308 
00309 void TEcnaRead::Init()
00310 {
00311 //Initialisation concerning the ROOT file
00312 
00313   fCnew    = 0;
00314   fCdelete = 0;
00315 
00316   fTTBELL = '\007';
00317 
00318   fgMaxCar = (Int_t)512;
00319 
00320   fCodePrintNoComment   = fCnaParCout->GetCodePrint("NoComment");
00321   fCodePrintWarnings    = fCnaParCout->GetCodePrint("Warnings ");
00322   fCodePrintComments    = fCnaParCout->GetCodePrint("Comments");
00323   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
00324 
00325   //.................................. Set flag print to "Warnings"   (Init)
00326   fFlagPrint = fCodePrintWarnings;
00327 
00328   fUserSamp      = -1;
00329   fUserChan      = -1;
00330  
00331   fSectChanSizeX = 0;
00332   fSectChanSizeY = 0;
00333   fSectSampSizeX = 0;
00334   fSectSampSizeY = 0;
00335 
00336   //.................................. Flags for Root File   (Init)
00337   fOpenRootFile = kFALSE;
00338 
00339   fReadyToReadRootFile = 0;
00340   fLookAtRootFile      = 0;
00341 
00342   fT1d_StexStinFromIndex = 0;
00343 
00344   //................................ tags Stin numbers
00345   fTagStinNumbers  = 0;
00346   fMemoStinNumbers = 0;
00347 
00348   //.......................... flag data exist
00349   fDataExist = kFALSE;
00350 
00351   //......................... transfert Sample ADC Values 3D array   (Init)
00352   fT3d_distribs  = 0;
00353   fT3d2_distribs = 0;
00354   fT3d1_distribs = 0;
00355 
00356   //................................. others
00357   Int_t MaxCar = fgMaxCar;
00358 
00359   MaxCar = fgMaxCar;
00360   fPathRoot.Resize(MaxCar);
00361   fPathRoot  = "fPathRoot> not defined";
00362 
00363 }// end of Init()
00364 
00365 //============================================================================================================
00366 void  TEcnaRead::SetEcalSubDetector(const TString SubDet,
00367                                     const TEcnaNumbering* pEcalNumbering,
00368                                     const TEcnaWrite* pCnaWrite)
00369 {
00370  // Set Subdetector (EB or EE)
00371 
00372   fEcal = 0; fEcal = new TEcnaParEcal(SubDet.Data());            // Anew("fEcal");
00373   Int_t MaxCar = fgMaxCar;
00374   fFlagSubDet.Resize(MaxCar);
00375   fFlagSubDet = fEcal->GetEcalSubDetector();
00376 
00377   if( fFlagSubDet == "EB" ){fStexName = "SM";  fStinName = "tower";}
00378   if( fFlagSubDet == "EE" ){fStexName = "Dee"; fStinName = "SC";}
00379 
00380   fEcalNumbering = 0;
00381   if( pEcalNumbering == 0 )
00382     {fEcalNumbering = new TEcnaNumbering(fFlagSubDet.Data(), fEcal);   /*Anew("fEcalNumbering")*/ ;}
00383   else
00384     {fEcalNumbering = (TEcnaNumbering*)pEcalNumbering;}
00385 
00386   fCnaWrite = 0;
00387   if( pCnaWrite == 0 )
00388     {fCnaWrite =
00389        new TEcnaWrite(fFlagSubDet.Data(), fCnaParPaths, fCnaParCout, fEcal, fEcalNumbering); /*Anew("fCnaWrite")*/ ;}
00390   else
00391     {fCnaWrite = (TEcnaWrite*)pCnaWrite;}
00392 }
00393 //============================================================================================================
00394 void TEcnaRead::Anew(const TString VarName)
00395 {
00396   // allocation survey for new
00397   
00398   fCnew++;
00399   // cout << "TEcnaRead::Anew---> new " << setw(4) << fCnew << " --------------> " << setw(25)
00400   //      << VarName.Data() << " / object(this): " << this << endl;
00401 }
00402 
00403 void TEcnaRead::Adelete(const TString VarName)
00404 {
00405   // allocation survey for delete
00406   
00407   fCdelete++;
00408   // cout << "TEcnaRead::Adelete> ========== delete" << setw(4) << fCdelete << " -> " << setw(25)
00409   //      << VarName.Data() << " / object(this): " << this << endl;
00410 }
00411 
00412 //=========================================== private copy ==========
00413 
00414 void  TEcnaRead::fCopy(const TEcnaRead& rund)
00415 {
00416 //Private copy
00417 
00418   fFileHeader   = rund.fFileHeader;
00419   fOpenRootFile = rund.fOpenRootFile;
00420 
00421   fUserSamp     = rund.fUserSamp;
00422   fUserChan     = rund.fUserChan;
00423 
00424   fSectChanSizeX = rund.fSectChanSizeX;
00425   fSectChanSizeY = rund.fSectChanSizeY;
00426   fSectSampSizeX = rund.fSectSampSizeX;
00427   fSectSampSizeY = rund.fSectSampSizeY;
00428 
00429   //........................................ Codes 
00430 
00431   fCodePrintComments    = rund.fCodePrintComments;
00432   fCodePrintWarnings    = rund.fCodePrintWarnings;
00433   fCodePrintAllComments = rund.fCodePrintAllComments;
00434   fCodePrintNoComment   = rund.fCodePrintNoComment;
00435 
00436   //.................................................. Tags
00437   fTagStinNumbers  = rund.fTagStinNumbers;
00438 
00439   fFlagPrint = rund.fFlagPrint;
00440   fPathRoot  = rund.fPathRoot;
00441 
00442   fCnew    = rund.fCnew;
00443   fCdelete = rund.fCdelete;
00444 }
00445 
00446 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00447 //
00448 //                    copy constructor
00449 //
00450 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00451 
00452 TEcnaRead::TEcnaRead(const TEcnaRead& dcop)
00453 {
00454   cout << "*TEcnaRead::TEcnaRead(const TEcnaRead& dcop)> "
00455        << " It is time to write a copy constructor" << endl
00456     // << " type an integer value and then RETURN to continue"
00457        << endl;
00458   
00459   // { Int_t cintoto;  cin >> cintoto; }
00460   
00461 }
00462 
00463 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00464 //
00465 //                    overloading of the operator=
00466 //
00467 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00468 
00469 TEcnaRead& TEcnaRead::operator=(const TEcnaRead& dcop)
00470 {
00471 //Overloading of the operator=
00472 
00473   fCopy(dcop);
00474   return *this;
00475 }
00476 
00477 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00478 //
00479 //                            destructor
00480 //
00481 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00482 
00483 TEcnaRead::~TEcnaRead()
00484 {
00485 //Destructor
00486   
00487   // cout << "[Info Management] CLASS: TEcnaRead.          DESTROY OBJECT: this = " << this << endl;
00488 
00489   if(fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments){
00490     cout << "*TEcnaRead::~TEcnaRead()> Entering destructor" << endl;}
00491   
00492   //if (fFileHeader    != 0){delete fFileHeader;    Adelete("fFileHeader");}
00493   //if (fEcal          != 0){delete fEcal;          Adelete("fEcal");}
00494   //if (fCnaParCout    != 0){delete fCnaParCout;    Adelete("fCnaParCout");}
00495   //if (fCnaParPaths   != 0){delete fCnaParPaths;   Adelete("fCnaParPaths");}
00496   //if (fCnaWrite      != 0){delete fCnaWrite;      Adelete("fCnaWrite");}
00497   //if (fEcalNumbering != 0){delete fEcalNumbering; Adelete("fEcalNumbering");}
00498 
00499   if (fT1d_StexStinFromIndex != 0){delete [] fT1d_StexStinFromIndex; Adelete("fT1d_StexStinFromIndex");}
00500   if (fTagStinNumbers        != 0){delete [] fTagStinNumbers;        Adelete("fTagStinNumbers");}
00501 
00502   if (fT3d_distribs  != 0){delete [] fT3d_distribs;  Adelete("fT3d_distribs");}
00503   if (fT3d2_distribs != 0){delete [] fT3d2_distribs; Adelete("fT3d2_distribs");}
00504   if (fT3d1_distribs != 0){delete [] fT3d1_distribs; Adelete("fT3d1_distribs");}
00505 
00506   if ( fCnew != fCdelete )
00507     {
00508       cout << "!TEcnaRead/destructor> WRONG MANAGEMENT OF ALLOCATIONS: fCnew = "
00509            << fCnew << ", fCdelete = " << fCdelete << fTTBELL << endl;
00510     }
00511   else
00512     {
00513       // cout << "*TEcnaRead/destructor> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: fCnew = "
00514       //      << fCnew << ", fCdelete = " << fCdelete << endl;
00515     }
00516   
00517   if(fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments){
00518     cout << "*TEcnaRead::~TEcnaRead()> End of destructor " << endl;}
00519 }
00520 
00521 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00522 //
00523 //                             M  E  T  H  O  D  S
00524 //
00525 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00526 
00527 //============================================================================
00528 //
00529 //                  GetReadyToReadRootFile(...)
00530 //                  
00531 //============================================================================
00532 void TEcnaRead::GetReadyToReadRootFile(TString      typ_ana,    const Int_t& nb_of_samples,
00533                                       const Int_t& run_number, const Int_t& nfirst,
00534                                       const Int_t& nlast,      const Int_t& nreqevts,  const Int_t& Stex,
00535                                       TString      path_root)
00536 {
00537   //Preparation for reading the ROOT file
00538 
00539   // Preliminary save of the arguments values because it can be of the form: fFileHeader->...
00540   // and because fFileHeader can be deleted and re-created in this method
00541 
00542   TString sTypAna      = typ_ana;
00543   Int_t   nNbOfSamples = nb_of_samples;
00544   Int_t   nRunNumber   = run_number;
00545   Int_t   nFirstEvt    = nfirst;
00546   Int_t   nLastEvt     = nlast;
00547   Int_t   nReqNbOfEvts = nreqevts;
00548   Int_t   nStexNumber  = Stex;
00549 
00550   //................................................................................................
00551   const Text_t *h_name  = "CnaHeader";   //==> voir cette question avec FXG
00552   const Text_t *h_title = "CnaHeader";   //==> voir cette question avec FXG
00553 
00554   //----------- old version, with arguments h_name, h_title, (FXG) -----(----
00555   //
00556   // fFileHeader->HeaderParameters(h_name,    h_title,
00557   //                               sTypAna,   nNbOfSamples, nRunNumber,
00558   //                               nFirstEvt, nLastEvt, nReqNbOfEvts, nStexNumber);
00559   //
00560   //-------------------------------------------------------------------------
00561 
00562   //---------- new version
00563   if( fFileHeader == 0 ){fFileHeader = new TEcnaHeader(h_name, h_title);  /* Anew("fFileHeader") */ ;}
00564   fFileHeader->HeaderParameters(sTypAna,   nNbOfSamples, nRunNumber,
00565                                 nFirstEvt, nLastEvt,     nReqNbOfEvts, nStexNumber);
00566 
00567   // After this call to TEcnaHeader, we have:
00568   //     fFileHeader->fTypAna            = sTypAna
00569   //     fFileHeader->fNbOfSamples       = nNbOfSamples
00570   //     fFileHeader->fRunNumber         = nRunNumber
00571   //     fFileHeader->fFirstReqEvtNumber = nFirstEvt
00572   //     fFileHeader->fLastReqEvtNumber  = nLastEvt
00573   //     fFileHeader->fReqNbOfEvts       = nReqNbOfEvts
00574   //     fFileHeader->fStex              = nStexNumber                       ( GetReadyToReadRootFile(...) )
00575   //.......................... path_root
00576   fPathRoot = path_root;
00577 
00578   //-------- gets the arguments for the file names (long and short) and makes these names
00579   fCnaWrite->RegisterFileParameters(typ_ana, nb_of_samples, run_number, nfirst, nlast, nreqevts, Stex);
00580   fCnaWrite->fMakeResultsFileName();
00581 
00582   //------------------------- init Stin numbers memo flags
00583   fMemoStinNumbers = 0;
00584 
00585   if( fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments )
00586     {
00587       cout << endl;
00588       cout << "*TEcnaRead::GetReadyToReadRootFile(...)>" << endl
00589            << "          The method has been called with the following argument values:" << endl
00590            << "          Analysis name                = "
00591            << fFileHeader->fTypAna << endl
00592            << "          Nb of required samples       = "
00593            << fFileHeader->fNbOfSamples << endl
00594            << "          Run number                   = "
00595            << fFileHeader->fRunNumber << endl
00596            << "          First requested event number = "
00597            << fFileHeader->fFirstReqEvtNumber << endl
00598            << "          Last requested event number  = "
00599            << fFileHeader->fLastReqEvtNumber << endl
00600            << "          Requested number of events   = "
00601            << fFileHeader->fReqNbOfEvts << endl
00602            << "          Stex number                  = "
00603            << fFileHeader->fStex << endl
00604            << "          Path for the ROOT file       = "
00605            << fPathRoot << endl
00606            << endl;
00607     }
00608   
00609   fReadyToReadRootFile = 1;           // set flag
00610   
00611   if(fFlagPrint == fCodePrintAllComments){
00612     cout << "*TEcnaRead::GetReadyToReadRootFile(...)> Leaving the method."
00613          << endl;}
00614 } //----------------- end of GetReadyToReadRootFile(...)
00615 
00616 //=========================================================================
00617 //
00618 //     Set start time and stop time, GetStartDate, GetStopDate
00619 //
00620 //=========================================================================
00621 time_t  TEcnaRead::GetStartTime(){return fFileHeader->fStartTime;}
00622 time_t  TEcnaRead::GetStopTime() {return fFileHeader->fStopTime;}
00623 TString TEcnaRead::GetStartDate(){return fFileHeader->fStartDate;}
00624 TString TEcnaRead::GetStopDate() {return fFileHeader->fStopDate;}
00625 TString TEcnaRead::GetRunType()
00626 {
00627   TString cType = "run type not defined";
00628   Int_t numtype = fFileHeader->fRunType;
00629   //----------------------------------------- run types
00630 
00631   if( numtype ==  0 ){cType = "COSMICS";}
00632   if( numtype ==  1 ){cType = "BEAMH4";}
00633   if( numtype ==  2 ){cType = "BEAMH2";}
00634   if( numtype ==  3 ){cType = "MTCC";}
00635   if( numtype ==  4 ){cType = "LASER_STD";}
00636   if( numtype ==  5 ){cType = "LASER_POWER_SCAN";}
00637   if( numtype ==  6 ){cType = "LASER_DELAY_SCAN";}
00638   if( numtype ==  7 ){cType = "TESTPULSE_SCAN_MEM";}
00639   if( numtype ==  8 ){cType = "TESTPULSE_MGPA";}
00640   if( numtype ==  9 ){cType = "PEDESTAL_STD";}
00641   if( numtype == 10 ){cType = "PEDESTAL_OFFSET_SCAN";}
00642   if( numtype == 11 ){cType = "PEDESTAL_25NS_SCAN";}
00643   if( numtype == 12 ){cType = "LED_STD";}
00644 
00645   if( numtype == 13 ){cType = "PHYSICS_GLOBAL";}
00646   if( numtype == 14 ){cType = "COSMICS_GLOBAL";}
00647   if( numtype == 15 ){cType = "HALO_GLOBAL";}
00648 
00649   if( numtype == 16 ){cType = "LASER_GAP";}
00650   if( numtype == 17 ){cType = "TESTPULSE_GAP";}
00651   if( numtype == 18 ){cType = "PEDESTAL_GAP";}
00652   if( numtype == 19 ){cType = "LED_GAP";}
00653 
00654   if( numtype == 20 ){cType = "PHYSICS_LOCAL";}
00655   if( numtype == 21 ){cType = "COSMICS_LOCAL";}
00656   if( numtype == 22 ){cType = "HALO_LOCAL";}
00657   if( numtype == 23 ){cType = "CALIB_LOCAL";}
00658 
00659   if( numtype == 24 ){cType = "PEDSIM";}
00660 
00661   return cType;
00662 }
00663 //==========================================================================
00664 //
00665 //                       R E A D    M E T H O D S  
00666 //                      (   R O O T    F I L E  )
00667 //
00668 //==========================================================================
00669 
00670 //============================================================================
00671 //
00672 //                      LookAtRootFile()
00673 //                  
00674 //============================================================================
00675 Bool_t TEcnaRead::LookAtRootFile()
00676 {
00677 //---------- Reads the ROOT file header and makes allocations and some other things
00678 
00679   fLookAtRootFile = 0;          // set flag to zero before looking for the file
00680 
00681   Bool_t ok_read = kFALSE;
00682 
00683   if(fReadyToReadRootFile == 1)
00684     {
00685       //------------ Call to ReadRootFileHeader
00686       if( ReadRootFileHeader(0) == kTRUE )   //    (1) = print, (0) = no print
00687         {
00688           //........................................ allocation tags      
00689           if( fTagStinNumbers == 0 ){fTagStinNumbers = new Int_t[1]; Anew("fTagStinNumbers");}
00690 
00691           //...................... allocation for fT1d_StexStinFromIndex[]
00692           if(fT1d_StexStinFromIndex == 0)
00693             {fT1d_StexStinFromIndex = new Int_t[fEcal->MaxStinEcnaInStex()]; Anew("fT1d_StexStinFromIndex");}
00694           
00695           //.. recover of the Stin numbers from the ROOT file (= init fT1d_StexStinFromIndex+init TagStin)
00696           TVectorD vec(fEcal->MaxStinEcnaInStex());
00697           for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
00698           vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
00699           
00700           for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++ ){
00701             fT1d_StexStinFromIndex[i] = (Int_t)vec(i);}
00702 
00703           fTagStinNumbers[0] = 1;                fFileHeader->fStinNumbersCalc++;
00704           ok_read = kTRUE;
00705           
00706           fLookAtRootFile = 1;           // set flag
00707         }
00708       else
00709         {
00710           cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
00711                << " ROOT file not found " << fTTBELL << endl;
00712           ok_read = kFALSE; 
00713         }
00714     }
00715   else
00716     {
00717       cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
00718            << " GetReadyToReadRootFile not called " << fTTBELL << endl;
00719       ok_read = kFALSE;      
00720     }
00721   return ok_read;
00722 } //----------------- end of LookAtRootFile()
00723 
00724 //-------------------------------------------------------------------------
00725 //
00726 //                     ReadRootFileHeader
00727 //
00728 //-------------------------------------------------------------------------
00729 Bool_t TEcnaRead::ReadRootFileHeader(const Int_t& i_print)
00730 {
00731 //Read the header of the Root file
00732 
00733   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
00734 
00735   if( i_print == 1 ){cout << "*TEcnaRead::ReadRootFileHeader> file_name = "
00736                          << fCnaWrite->fRootFileNameShort.Data() << endl;}
00737 
00738   Bool_t ok_open = kFALSE;
00739   Bool_t ok_read = kFALSE;
00740   
00741   if ( fOpenRootFile )
00742     {
00743       cout << "!TEcnaRead::ReadRootFileHeader(...)*** ERROR ***> "
00744            << "Reading header on file already open." << endl;
00745     } 
00746   else
00747     {
00748       ok_open = OpenRootFile(file_name, "READ");
00749 
00750       if(ok_open)
00751         {
00752           TEcnaHeader *h;
00753           h =(TEcnaHeader*)gCnaRootFile->fRootFile->Get("CnaHeader");
00754 
00755           //..... get the attributes which are not already set by the call to TEcnaHeader
00756           //      in GetReadyToReadRootFile(...) and are only available in the ROOT file
00757 
00758           fFileHeader->fStartTime = h->fStartTime;
00759           fFileHeader->fStopTime  = h->fStopTime;
00760           fFileHeader->fStartDate = h->fStartDate;
00761           fFileHeader->fStopDate  = h->fStopDate;
00762 
00763           fFileHeader->fRunType   = h->fRunType;
00764 
00765           //........................................................................
00766           fFileHeader->fStinNumbersCalc = h->fStinNumbersCalc;
00767           fFileHeader->fAdcEvtCalc      = h->fAdcEvtCalc;
00768           fFileHeader->fMSpCalc         = h->fMSpCalc;
00769           fFileHeader->fSSpCalc         = h->fSSpCalc;
00770           fFileHeader->fAvTnoCalc       = h->fAvTnoCalc;
00771           fFileHeader->fAvLfnCalc       = h->fAvLfnCalc;
00772           fFileHeader->fAvHfnCalc       = h->fAvHfnCalc;
00773 
00774           fFileHeader->fCovCssCalc      = h->fCovCssCalc;
00775           fFileHeader->fCorCssCalc      = h->fCorCssCalc;
00776           fFileHeader->fHfCovCalc       = h->fHfCovCalc;
00777           fFileHeader->fHfCorCalc       = h->fHfCorCalc;
00778           fFileHeader->fLfCovCalc       = h->fLfCovCalc;
00779           fFileHeader->fLfCorCalc       = h->fLfCorCalc;
00780           fFileHeader->fLFccMoStinsCalc = h->fLFccMoStinsCalc;
00781           fFileHeader->fHFccMoStinsCalc = h->fHFccMoStinsCalc;
00782           fFileHeader->fMeanCorssCalc   = h->fMeanCorssCalc;
00783           fFileHeader->fSigCorssCalc    = h->fSigCorssCalc;
00784 
00785           fFileHeader->fAvPedCalc       = h->fAvPedCalc;
00786           fFileHeader->fAvMeanCorssCalc = h->fAvMeanCorssCalc;
00787           fFileHeader->fAvSigCorssCalc  = h->fAvSigCorssCalc;
00788           
00789           if(i_print == 1){fFileHeader->Print();}
00790           CloseRootFile(file_name);
00791           ok_read = kTRUE;
00792         }
00793       else
00794         {
00795           cout << "!TEcnaRead::ReadRootFileHeader(...) *** ERROR ***> Open ROOT file failed for file: "
00796                << file_name << fTTBELL << endl;
00797           ok_read = kFALSE;
00798         }
00799     }
00800   return ok_read;
00801 }
00802 
00803 //-------------------------------------------------------------
00804 //
00805 //                      OpenRootFile
00806 //
00807 //-------------------------------------------------------------
00808 Bool_t TEcnaRead::OpenRootFile(const Text_t *name, TString status) {
00809 //Open the Root file
00810 
00811   TString s_path;
00812   s_path = fPathRoot;
00813   s_path.Append('/');
00814   s_path.Append(name);
00815 
00816   gCnaRootFile = 0; gCnaRootFile = new TEcnaRootFile(s_path.Data(), status);     Anew("gCnaRootFile");
00817 
00818   Bool_t ok_open = kFALSE;
00819 
00820   if ( gCnaRootFile->fRootFileStatus == "RECREATE" ){ok_open = gCnaRootFile->OpenW();}
00821   if ( gCnaRootFile->fRootFileStatus == "READ"     ){ok_open = gCnaRootFile->OpenR();}
00822 
00823   if (!ok_open)
00824     {
00825       cout << "!TEcnaRead::OpenRootFile> " << s_path.Data() << ": file not found." << endl;
00826       if( gCnaRootFile != 0 ){delete gCnaRootFile; gCnaRootFile = 0;  Adelete("gCnaRootFile");}
00827     }
00828   else
00829     {
00830       if(fFlagPrint == fCodePrintAllComments){
00831         TString e_path;  e_path.Append(name);
00832         cout << "*TEcnaRead::OpenRootFile>  Open  ROOT file " << e_path.Data() << " OK " << endl;}      
00833       fOpenRootFile  = kTRUE;
00834     }
00835 
00836   return ok_open;
00837 }                     // end of OpenRootFile()
00838 
00839 //-------------------------------------------------------------
00840 //
00841 //                      CloseRootFile
00842 //
00843 //-------------------------------------------------------------
00844 Bool_t TEcnaRead::CloseRootFile(const Text_t *name) {
00845 //Close the Root file
00846  
00847   Bool_t ok_close = kFALSE;
00848 
00849   if (fOpenRootFile == kTRUE ) 
00850     {
00851       gCnaRootFile->CloseFile();
00852       
00853       if(fFlagPrint == fCodePrintAllComments){
00854         TString e_path;  e_path.Append(name);
00855         cout << "*TEcnaRead::CloseRootFile> Close ROOT file " << e_path.Data() << " OK " << endl;}
00856       
00857       if( gCnaRootFile != 0 ){delete gCnaRootFile;   gCnaRootFile = 0;  Adelete("gCnaRootFile");}
00858       fOpenRootFile = kFALSE;
00859       ok_close      = kTRUE;
00860     }
00861   else
00862     {
00863       cout << "*TEcnaRead::CloseRootFile(...)> no close since no file is open"
00864            << fTTBELL << endl;
00865     }
00866 
00867   return ok_close;
00868 }
00869 //-------------------------------------------------------------------------
00870 //
00871 //                     DataExist()
00872 //
00873 //     DON'T SUPPRESS: CALLED BY ANOTHER CLASSES
00874 //
00875 //-------------------------------------------------------------------------
00876 Bool_t TEcnaRead::DataExist()
00877 {
00878   // return kTRUE if the data are present in the ROOT file, kFALSE if not.
00879   // fDataExist is set in the read methods
00880 
00881   return fDataExist;
00882 }
00883 //-------------------------------------------------------------------------
00884 //
00885 //                     ReadStinNumbers(...)
00886 //
00887 //-------------------------------------------------------------------------
00888 TVectorD TEcnaRead::ReadStinNumbers(const Int_t& VecDim)
00889 {
00890 //Get the Stin numbers and put them in a TVectorD
00891 //Read the ROOT file at first call and load in a TVectorD attribute
00892 //Get directly the TVectorD attribute at other times
00893 //
00894 // Possible values for VecDim:
00895 //          (1) VecDim = fEcal->MaxCrysEcnaInStex()
00896 
00897   TVectorD vec(VecDim); 
00898   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
00899 
00900   if (fMemoStinNumbers == 0)
00901     {
00902       CnaResultTyp typ = cTypNumbers;
00903       const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
00904 
00905       //.............. reading of the ROOT file data type TResultTyp = cTypStinsNumbers
00906       //               to get the conversion: Stin index -> Stin number (n1StexStin)
00907 
00908       Bool_t ok_open = kFALSE;
00909       Bool_t ok_read = kFALSE;
00910 
00911       if ( fOpenRootFile )
00912         {
00913           cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> Reading on file already open."
00914                << fTTBELL << endl;
00915         } 
00916       else
00917         {
00918           ok_open = OpenRootFile(file_name, "READ");
00919           
00920           Int_t i_zero = 0;
00921           ok_read = gCnaRootFile->ReadElement(typ, i_zero);
00922           
00923           if ( ok_read == kTRUE )
00924             {
00925               fDataExist = kTRUE;
00926               //......... Get the Stin numbers and put them in TVectorD vec()
00927               for ( Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++)
00928                 {
00929                   vec(i_Stin) = gCnaRootFile->fCnaIndivResult->fMatHis(0,i_Stin);
00930                   fT1d_StexStinFromIndex[i_Stin] = (Int_t)vec(i_Stin);
00931                 }
00932               fMemoStinNumbers++;
00933             }
00934           else
00935             {
00936               fDataExist = kFALSE;
00937               cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> "
00938                    << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
00939                    <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
00940                    << fTTBELL << endl;
00941             }
00942         }
00943       CloseRootFile(file_name);
00944       
00945       if( ok_read == kTRUE )
00946         {
00947           //........................... Print the Stin numbers 
00948           if(fFlagPrint == fCodePrintAllComments)
00949             {
00950               for(Int_t i=0; i < VecDim; i++)
00951                 {
00952                   cout << "*TEcnaRead::ReadStinNumbers(...)> StinNumber[" << i << "] = "
00953                        << vec[i] << endl;
00954                 }
00955             }
00956         }
00957     }
00958   else
00959     {
00960       fDataExist = kTRUE;
00961       for ( Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++)
00962         {vec(i_Stin) = fT1d_StexStinFromIndex[i_Stin];}
00963     }
00964 
00965   return vec;
00966 } // ----------------- ( end of ReadStinNumbers(...) ) -----------------
00967 
00968 //-----------------------------------------------------------------------------
00969 //
00970 //                  ReadNumberOfEventsForSamples 
00971 //
00972 //-----------------------------------------------------------------------------
00973 TMatrixD TEcnaRead::ReadNumberOfEventsForSamples(const Int_t& n1StexStin,
00974                                                  const Int_t& MatDimX, const Int_t& MatDimY)
00975 {
00976 //Read the numbers of found events in the data
00977 //for the crystals and for the samples, for a given Stin in the Stex
00978 //in the ROOT file and return them in a TMatrixD(MaxCrysInStin,NbOfSamples)
00979 //
00980 //Possible values for MatDimX and MatDimY:
00981 //  (1) MatDimX = fEcal->MaxCrysInStin(), MatDimY = fFileHeader->fNbOfSamples
00982 
00983   TMatrixD mat(MatDimX, MatDimY);
00984   for(Int_t i=0; i<MatDimX; i++)
00985     {for(Int_t j=0; j<MatDimY; j++){mat(i,j)=(Double_t)0.;}}
00986 
00987   Int_t Stin_index = GetStinIndex(n1StexStin);
00988   if( Stin_index >= 0 )
00989     {
00990       if(fLookAtRootFile == 1)
00991         {
00992           CnaResultTyp typ = cTypNbOfEvts;
00993           const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
00994           
00995           Bool_t ok_open = kFALSE;
00996           Bool_t ok_read = kFALSE;
00997           
00998           if ( fOpenRootFile )
00999             {
01000               cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01001                    << " Reading on file already open." << fTTBELL << endl;
01002             } 
01003           else
01004             {
01005               ok_open = OpenRootFile(file_name, "READ");
01006               
01007               Int_t i_zero = 0;
01008               ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01009               
01010               if ( ok_read == kTRUE )
01011                 {
01012                   fDataExist = kTRUE;
01013                   for (Int_t i_crys=0; i_crys<MatDimX; i_crys++)
01014                     {                 
01015                       Int_t j_cna_chan = Stin_index*MatDimX + i_crys;
01016                       for ( Int_t i_samp=0; i_samp<MatDimY; i_samp++)
01017                         {
01018                           mat(i_crys, i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(j_cna_chan, i_samp);
01019                         }
01020                     }
01021                 }
01022               else
01023                 {
01024                   fDataExist = kFALSE;
01025                   cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01026                    << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01027                    <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01028                    << fTTBELL << endl;
01029                 }
01030             }
01031           CloseRootFile(file_name);
01032         }
01033       else
01034         {
01035           cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
01036                << "It is not possible to access the number of found events: the ROOT file has not been read."
01037                << fTTBELL << endl;
01038         }
01039     }  // end of if (Stin_index >= 0)
01040   return mat;
01041 }
01042 
01043 //--------------------------------------------------------------------------------------
01044 //
01045 //                 ReadSampleValues(i0StexEcha,sample,fFileHeader->fReqNbOfEvts)  
01046 //
01047 //--------------------------------------------------------------------------------------
01048 TVectorD TEcnaRead::ReadSampleValues(const Int_t& i0StexEcha, const Int_t& sample, const Int_t& VecDim)
01049 {
01050 //Read the event distribution for a given i0StexEcha and a given sample
01051 //in the results ROOT file and return it in a TVectorD(nb of evts in burst)
01052 //
01053 //Possible values for VecDim: (1) VecDim = fFileHeader->fReqNbOfEvts
01054 
01055   TVectorD vec(VecDim);
01056   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01057 
01058   CnaResultTyp typ = cTypAdcEvt;   //  sample as a function of time type
01059 
01060   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01061 
01062   Bool_t ok_open = kFALSE;
01063   Bool_t ok_read = kFALSE;
01064   
01065   if ( fOpenRootFile )
01066     {
01067       cout << "!TEcnaRead::ReadSampleValues(...) *** ERROR ***> "
01068            << "Reading on file already open." << fTTBELL << endl;
01069     } 
01070   else
01071     {
01072       ok_open = OpenRootFile(file_name, "READ");
01073       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
01074       
01075       if ( ok_read == kTRUE )
01076         {
01077           fDataExist = kTRUE;
01078           for ( Int_t i_bin=0; i_bin<VecDim; i_bin++)
01079             {
01080               vec(i_bin) = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
01081             }   
01082         }
01083       else
01084         {
01085           fDataExist = kFALSE;
01086           cout << "!TEcnaRead::ReadSampleValues(...) *** ERROR ***> "
01087                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01088                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01089                << fTTBELL << endl;
01090         }
01091     }
01092   CloseRootFile(file_name);
01093 
01094   return vec;
01095 }
01096 //--- (end of ReadSampleValues) ----------
01097 
01098 //--------------------------------------------------------------------------------------
01099 //
01100 //       ReadSampleValuesSameFile(fEcal->MaxCrysEcnaInStex(),
01101 //                                fFileHeader->fNbOfSamples, fFileHeader->fReqNbOfEvts)  
01102 //
01103 //--------------------------------------------------------------------------------------
01104 Double_t*** TEcnaRead::ReadSampleValuesSameFile(const Int_t& DimX, const Int_t& DimY, const Int_t& DimZ)
01105 {
01106 
01107 //Possible values for DimX, DimY, DimZ : (1) DimX = fEcal->MaxCrysEcnaInStex()
01108 //                                           DimY = fFileHeader->fNbOfSamples
01109 //                                           DimZ = fFileHeader->fReqNbOfEvts
01110 
01111   if(fT3d_distribs == 0)
01112     {
01113       //............ Allocation for the 3d array 
01114       fT3d_distribs   = new Double_t**[DimX];                         fCnew++;  
01115       fT3d2_distribs  = new  Double_t*[DimX*DimY];                    fCnew++;  
01116       fT3d1_distribs  = new   Double_t[DimX*DimY*DimZ];               fCnew++;
01117       
01118       for(Int_t i0StexEcha = 0 ; i0StexEcha < DimX ; i0StexEcha++){
01119         fT3d_distribs[i0StexEcha] = &fT3d2_distribs[0] + i0StexEcha*DimY;
01120         for(Int_t j_samp = 0 ; j_samp < DimY ; j_samp++){
01121           fT3d2_distribs[DimY*i0StexEcha + j_samp] = &fT3d1_distribs[0]+
01122             DimZ*(DimY*i0StexEcha+j_samp);}}
01123     }
01124   
01125   //................................. Init to zero                 (ReadSampleValuesSameFile)
01126   for (Int_t iza=0; iza<DimX; iza++)
01127     {
01128       for (Int_t izb=0; izb<DimY; izb++)
01129         {
01130           for (Int_t izc=0; izc<DimZ; izc++)
01131             {
01132               if( fT3d_distribs[iza][izb][izc] != (Double_t)0 )
01133                 {
01134                   fT3d_distribs[iza][izb][izc] = (Double_t)0;
01135                 }
01136             }
01137         }
01138     }     
01139   
01140   //-------------------------------------------------------------------------- (ReadSampleValuesSameFile)
01141   CnaResultTyp typ = cTypAdcEvt;   //  sample as a function of time type
01142 
01143   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01144 
01145   Bool_t ok_open = kFALSE;
01146   Bool_t ok_read = kFALSE;
01147 
01148   Int_t  i_entry      = 0;  
01149   Int_t  i_entry_fail = 0;  
01150 
01151   ok_open = OpenRootFile(file_name, "READ");
01152   
01153   if( ok_open == kTRUE )
01154     {
01155       for(Int_t i0StexEcha=0; i0StexEcha<DimX; i0StexEcha++)
01156         {
01157           if( i0StexEcha == 0 )
01158             {
01159               i_entry = gCnaRootFile->ReadElementNextEntryNumber(typ, i0StexEcha);
01160               if( i_entry >= 0 ){ok_read = kTRUE;}
01161             }
01162           if( i_entry >= 0 )                                                //  (ReadSampleValuesSameFile)
01163             {
01164               if( i0StexEcha > 0 ){ok_read = gCnaRootFile->ReadElement(i_entry); i_entry++;}
01165               
01166               if ( ok_read == kTRUE )
01167                 {
01168                   fDataExist = kTRUE;     
01169                   for(Int_t sample=0; sample<DimY; sample++)
01170                     {
01171                       for ( Int_t i_bin=0; i_bin<DimZ; i_bin++)
01172                         {
01173                           fT3d_distribs[i0StexEcha][sample][i_bin]
01174                             = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
01175                         }  
01176                     }
01177                 } 
01178               else                                                        //  (ReadSampleValuesSameFile)
01179                 {
01180                   fDataExist = kFALSE;
01181                   cout << "!TEcnaRead::ReadSampleValuesSameFile(...) *** ERROR ***> "
01182                        << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01183                        <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01184                        << fTTBELL << endl;
01185                 }
01186             }
01187           else
01188             {
01189               i_entry_fail++;
01190             }
01191         }
01192       CloseRootFile(file_name);
01193     }
01194   else
01195     {
01196       cout  << "*TEcnaRead::ReadSampleValuesSameFile(...)> *ERROR* =====> "
01197             << " ROOT file not found" << fTTBELL << endl;
01198     }
01199 
01200   if(i_entry_fail > 0 )
01201     {
01202       cout  << "*TEcnaRead::ReadSampleValuesSameFile(...)> *ERROR* =====> "
01203             << " Entry reading failure(s). i_entry_fail = "
01204             << i_entry_fail << fTTBELL << endl;
01205     }
01206   return fT3d_distribs;
01207 }
01208 //--- (end of ReadSampleValuesSameFile) ----------
01209 
01210 //-------------------------------------------------------------------------
01211 //
01212 //                  ReadSampleMeans  
01213 //
01214 //-------------------------------------------------------------------------
01215 TVectorD TEcnaRead::ReadSampleMeans(const Int_t & n1StexStin,
01216                                                   const Int_t & i0StinEcha, const Int_t & VecDim)
01217 {
01218 //Read the expectation values of the samples
01219 //for a given Stin and a given channel
01220 //in the ROOT file and return them in a TVectorD
01221 //
01222 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples
01223 
01224   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01225   
01226   TVectorD vec(VecDim);
01227   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01228 
01229   CnaResultTyp typ = cTypMSp;
01230 
01231   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01232 
01233   Bool_t ok_open = kFALSE;
01234   Bool_t ok_read = kFALSE;
01235   
01236   if ( fOpenRootFile )
01237     {
01238       cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01239            << " Reading on file already open." << fTTBELL << endl;
01240     } 
01241   else
01242     {
01243       ok_open = OpenRootFile(file_name, "READ");
01244 
01245       Int_t i_zero = 0;
01246       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01247       
01248       if ( ok_read == kTRUE )
01249         {
01250           fDataExist = kTRUE;
01251           for ( Int_t i_samp = 0; i_samp < VecDim; i_samp++)
01252             {
01253               vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
01254             }   
01255         }
01256       else
01257         {
01258           fDataExist = kFALSE;
01259           cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> "
01260                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01261                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01262                << fTTBELL << endl;
01263         }
01264     }
01265   CloseRootFile(file_name);
01266   return vec;
01267 }
01268 
01269 //-------------------------------------------------------------------------
01270 //
01271 //                  ReadSampleSigmas  
01272 //                   
01273 //-------------------------------------------------------------------------
01274 TVectorD TEcnaRead::ReadSampleSigmas(const Int_t & n1StexStin,
01275                                           const Int_t & i0StinEcha, const Int_t & VecDim)
01276 {
01277 //Read the expectation values of the samples
01278 //for a given Stin and a given channel
01279 //in the ROOT file and return them in a TVectorD
01280 //
01281 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples
01282 
01283   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01284   
01285   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01286 
01287   CnaResultTyp typ = cTypSSp;
01288 
01289   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01290 
01291   Bool_t ok_open = kFALSE;
01292   Bool_t ok_read = kFALSE;
01293   
01294   if ( fOpenRootFile )
01295     {
01296       cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01297            << "Reading on file already open." << fTTBELL << endl;
01298     } 
01299   else
01300     {
01301       ok_open = OpenRootFile(file_name, "READ");
01302 
01303       Int_t i_zero = 0;
01304       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01305       
01306       if ( ok_read == kTRUE )
01307         {
01308           fDataExist = kTRUE;
01309           for ( Int_t i_samp = 0; i_samp < VecDim; i_samp++)
01310             {
01311               vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha,i_samp);
01312             }   
01313         }
01314       else
01315         {
01316           fDataExist = kFALSE;
01317           cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> "
01318                    << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01319                    <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01320                    << fTTBELL << endl;
01321         }
01322     }
01323   CloseRootFile(file_name);
01324   return vec;
01325 }
01326 
01327 #define RSOS
01328 #ifndef RSOS
01329 //-------------------------------------------------------------------------
01330 //
01331 //                  ReadSigmasOfSamples(...)
01332 //
01333 //-------------------------------------------------------------------------
01334 TVectorD TEcnaRead::ReadSigmasOfSamples(const Int_t & n1StexStin,
01335                                        const Int_t & i0StinEcha, const Int_t & VecDim)
01336 {
01337 //Read the expectation values of the samples
01338 //for a given Stin and a given channel
01339 //in the ROOT file and return them in a TVectorD
01340 //
01341 //Possible values for VecDim : (1) VecDim = fFileHeader->fNbOfSamples
01342 
01343   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01344   
01345   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
01346 
01347   CnaResultTyp typ = cTypSSp;
01348 
01349   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01350 
01351   Bool_t ok_open = kFALSE;
01352   Bool_t ok_read = kFALSE;
01353   
01354   if ( fOpenRootFile )
01355     {
01356       cout << "!TEcnaRead::ReadSigmasOfSamples(...) *** ERROR ***> "
01357            << "Reading on file already open." << fTTBELL << endl;
01358     } 
01359   else
01360     {
01361       ok_open = OpenRootFile(file_name, "READ");
01362 
01363       Int_t i_zero = 0;
01364       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01365       
01366       if ( ok_read == kTRUE )
01367         {
01368           fDataExist = kTRUE;
01369           for ( Int_t i_samp = 0; i_samp < VecDim; i_samp++)
01370             {
01371               vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha,i_samp);
01372               if( vec(i_samp) >= (Double_t)0. )
01373                 {
01374                   vec(i_samp) = (Double_t)sqrt((Double_t)vec(i_samp));
01375                 }
01376               else
01377                 {
01378                   vec(i_samp) = (Double_t)(-1.);
01379                   cout << cout << "!TEcnaRead::ReadSigmasOfSamples(...) *** ERROR ***> "
01380                        << "Negative variance! Sigma forced to -1" << fTTBELL << endl;
01381                 }
01382             }   
01383         }
01384       else
01385         {
01386           fDataExist = kFALSE;
01387           cout << "!TEcnaRead::ReadSigmasOfSamples(...) *** ERROR ***> "
01388                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01389                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01390                << fTTBELL << endl;
01391         }
01392     }
01393   CloseRootFile(file_name);
01394   return vec;
01395 }
01396 #endif // RSOS
01397 
01398 //-------------------------------------------------------------------------
01399 //
01400 //  ReadCovariancesBetweenSamples(n1StexStin,StinEcha,fFileHeader->fNbOfSamples)
01401 //
01402 //-------------------------------------------------------------------------
01403 TMatrixD TEcnaRead::ReadCovariancesBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
01404                                                  const Int_t& MatDim)
01405 {
01406 //Read the (sample,sample) covariances for a given channel
01407 //in ROOT file and return them in a TMatrixD
01408 //
01409 //Possible values for MatDim: (1) MatDim = fFileHeader->fNbOfSamples
01410 
01411   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01412 
01413   TMatrixD mat(MatDim, MatDim);
01414   for(Int_t i=0; i<MatDim; i++)
01415     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01416   
01417   CnaResultTyp typ = cTypCovCss;
01418 
01419   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01420 
01421   Bool_t ok_open = kFALSE;
01422   Bool_t ok_read = kFALSE;
01423   
01424   if ( fOpenRootFile )
01425     {
01426       cout << "!TEcnaRead::ReadCovariancesBetweenSamples(...) *** ERROR ***> "
01427            << "Reading on file already open." << fTTBELL << endl;
01428     } 
01429   else
01430     {
01431       ok_open = OpenRootFile(file_name, "READ");
01432 
01433       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
01434       
01435       if ( ok_read == kTRUE )
01436         {
01437           fDataExist = kTRUE;
01438           for( Int_t i_samp = 0; i_samp < MatDim; i_samp++ )
01439             {
01440               for ( Int_t j_samp = 0; j_samp < MatDim; j_samp++)
01441                 {
01442                  mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);
01443                 }
01444             }
01445         }
01446       else
01447         {
01448           fDataExist = kFALSE;
01449           cout << "!TEcnaRead::ReadCovariancesBetweenSamples() *** ERROR ***> "
01450                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01451                << " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01452                << fTTBELL << endl;
01453         }
01454     }
01455 
01456   CloseRootFile(file_name);
01457 
01458   return mat;
01459 }
01460 
01461 //-------------------------------------------------------------------------
01462 //
01463 //  ReadCorrelationsBetweenSamples(n1StexStin,StinEcha,fFileHeader->fNbOfSamples)
01464 //
01465 //-------------------------------------------------------------------------
01466 TMatrixD TEcnaRead::ReadCorrelationsBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
01467                                                   const Int_t& MatDim)
01468 {
01469 //Read the (sample,sample) correlations for a given channel
01470 //in ROOT file and return them in a TMatrixD
01471 //
01472 //Possible values for MatDim: (1) MatDim = fFileHeader->fNbOfSamples
01473 
01474   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01475   TMatrixD mat(MatDim, MatDim);
01476   for(Int_t i=0; i<MatDim; i++)
01477     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01478  
01479   CnaResultTyp typ = cTypCorCss;
01480   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01481 
01482   Bool_t ok_open = kFALSE;
01483   Bool_t ok_read = kFALSE;
01484   
01485   if ( fOpenRootFile )
01486     {
01487       cout << "!TEcnaRead::ReadCorrelationsBetweenSamples(...) *** ERROR ***> "
01488            << "Reading on file already open." << fTTBELL << endl;
01489     } 
01490   else
01491     {
01492       ok_open = OpenRootFile(file_name, "READ");
01493       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
01494       
01495       if ( ok_read == kTRUE )
01496         {
01497           fDataExist = kTRUE;
01498           for ( Int_t i_samp = 0; i_samp < MatDim; i_samp++){
01499             for ( Int_t j_samp = 0; j_samp < MatDim; j_samp++){
01500               mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);}}
01501         }
01502       else
01503         {
01504           fDataExist = kFALSE;
01505           cout << "!TEcnaRead::ReadCorrelationsBetweenSamples() *** ERROR ***> "
01506                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01507                << " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01508                << fTTBELL << endl;
01509         }
01510     }
01511   CloseRootFile(file_name);
01512   return mat;
01513 }
01514 //-------------------------------------------------------------------------
01515 //
01516 //  ReadRelevantCorrelationsBetweenSamples(n1StexStin,i0StinEcha)
01517 //                 (NOT USED)
01518 //-------------------------------------------------------------------------
01519 TVectorD TEcnaRead::ReadRelevantCorrelationsBetweenSamples(const Int_t & n1StexStin, const Int_t & i0StinEcha,
01520                                                           const Int_t & InPutMatDim )
01521 {
01522 //Read the (sample,sample) correlations for a given channel
01523 //in ROOT file and return the relevant correlations in a TVectorD
01524 //
01525 //Possible values for InPutMatDim: (1) InPutMatDim = fFileHeader->fNbOfSamples
01526 //
01527 //  *===>  OutPut TVectorD dimension value = InPutMatDim*(InPutMatDim-1)/2
01528 
01529   Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
01530   Int_t nb_of_relevant = InPutMatDim*(InPutMatDim-1)/2;
01531   TVectorD vec_rel(nb_of_relevant); for(Int_t i=0; i<nb_of_relevant; i++){vec_rel(i)=(Double_t)0.;}
01532   CnaResultTyp typ = cTypCorCss;
01533   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01534 
01535   Bool_t ok_open = kFALSE;
01536   Bool_t ok_read = kFALSE;
01537   
01538   if ( fOpenRootFile )
01539     {
01540       cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples(...) *** ERROR ***> "
01541            << "Reading on file already open." << fTTBELL << endl;
01542     } 
01543   else
01544     {
01545       ok_open = OpenRootFile(file_name, "READ");
01546       ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
01547       
01548       if ( ok_read == kTRUE )
01549         {
01550           fDataExist = kTRUE;
01551           Int_t k_cor = 0;
01552           for ( Int_t i_samp = 0; i_samp < InPutMatDim; i_samp++){
01553             for ( Int_t j_samp = 0; j_samp < i_samp; j_samp++){
01554               vec_rel(k_cor) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp,j_samp);
01555               k_cor++;}}
01556         }
01557       else
01558         {
01559           fDataExist = kFALSE;
01560           cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples() *** ERROR ***> "
01561                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01562                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01563                << fTTBELL << endl;
01564         }
01565     }
01566   CloseRootFile(file_name);
01567   return vec_rel;
01568 }
01569 //----- end of (ReadRelevantCorrelationsBetweenSamples ) -------
01570 
01571 //-----------------------------------------------------------------------------------------
01572 //
01573 //        ReadLowFrequencyCovariancesBetweenChannels(Stin_a, Stin_b)
01574 //
01575 //-----------------------------------------------------------------------------------------
01576 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t& n1StexStin_a,
01577                                                               const Int_t& n1StexStin_b,
01578                                                               const Int_t& MatDim)
01579 {
01580 //Read the Low Frequency cov(i0StinEcha of Stin_a, i0StinEcha of Stin b)
01581 //in ROOT file and return them in a TMatrixD
01582 //
01583 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
01584 
01585   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
01586   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
01587 
01588   TMatrixD mat(MatDim, MatDim);
01589   for(Int_t i=0; i<MatDim; i++)
01590     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01591   
01592   CnaResultTyp typ = cTypLfCov;
01593 
01594   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01595 
01596   Bool_t ok_open = kFALSE;
01597   Bool_t ok_read = kFALSE;
01598   
01599   if ( fOpenRootFile )
01600     {
01601       cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***>"
01602            << " Reading on file already open." << fTTBELL << endl;
01603     } 
01604   else
01605     {
01606       ok_open = OpenRootFile(file_name, "READ");
01607 
01608       Int_t i_zero = 0;
01609       ok_read = gCnaRootFile->ReadElement(typ,i_zero);
01610       
01611       if ( ok_read == kTRUE )
01612         {
01613           fDataExist = kTRUE;
01614           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
01615             {
01616               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
01617               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
01618                 {
01619                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
01620                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01621                 }
01622             }
01623         }
01624       else
01625         {
01626           fDataExist = kFALSE;
01627           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
01628                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01629                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01630                << fTTBELL << endl;
01631         }
01632     }
01633 
01634   CloseRootFile(file_name);
01635 
01636   return mat;
01637 }
01638 //----- end of ( ReadLowFrequencyCovariancesBetweenChannels(...) ) -------
01639 
01640 //-------------------------------------------------------------------------------------------
01641 //
01642 //         ReadLowFrequencyCorrelationsBetweenChannels(Stin_a, Stin_b)
01643 //
01644 //-------------------------------------------------------------------------------------------
01645 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t & n1StexStin_a,
01646                                                                const Int_t & n1StexStin_b,
01647                                                                const Int_t& MatDim)
01648 {
01649 //Read the Low Frequency cor(i0StinEcha of Stin_a, i0StinEcha of Stin b)
01650 //in ROOT file and return them in a TMatrixD
01651 //
01652 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
01653 
01654   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
01655   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
01656 
01657   TMatrixD mat(MatDim, MatDim);
01658   for(Int_t i=0; i<MatDim; i++)
01659     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01660   
01661   CnaResultTyp typ = cTypLfCor;
01662 
01663   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01664 
01665   Bool_t ok_open = kFALSE;
01666   Bool_t ok_read = kFALSE;
01667   
01668   if ( fOpenRootFile )
01669     {
01670       cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***>"
01671            << " Reading on file already open." << fTTBELL << endl;
01672     } 
01673   else
01674     {
01675       ok_open = OpenRootFile(file_name, "READ");
01676 
01677       Int_t i_zero = 0;
01678 
01679       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01680       
01681       if ( ok_read == kTRUE )
01682         {
01683           fDataExist = kTRUE;
01684           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
01685             {
01686               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
01687               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
01688                 {
01689                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
01690                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01691                 }
01692             }
01693         }
01694       else
01695         {
01696           fDataExist = kFALSE;
01697           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
01698                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01699                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01700                << fTTBELL << endl;
01701         }
01702     }
01703 
01704   CloseRootFile(file_name);
01705 
01706   return mat;
01707 }
01708 //----- end of ( ReadLowFrequencyCorrelationsBetweenChannels(...) ) -------
01709 
01710 //-----------------------------------------------------------------------------------------
01711 //
01712 //        ReadHighFrequencyCovariancesBetweenChannels(Stin_a, Stin_b)
01713 //
01714 //-----------------------------------------------------------------------------------------
01715 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t & n1StexStin_a,
01716                                                                const Int_t & n1StexStin_b,
01717                                                                const Int_t& MatDim)
01718 {
01719 //Read the High Frequency cov(i0StinEcha of Stin_a, i0StinEcha of Stin b)
01720 //in ROOT file and return them in a TMatrixD
01721 //
01722 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
01723 
01724   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
01725   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
01726 
01727   TMatrixD mat(MatDim, MatDim);
01728   for(Int_t i=0; i<MatDim; i++)
01729     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01730   
01731   CnaResultTyp typ = cTypHfCov;
01732 
01733   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01734 
01735   Bool_t ok_open = kFALSE;
01736   Bool_t ok_read = kFALSE;
01737   
01738   if ( fOpenRootFile )
01739     {
01740       cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***>"
01741            << " Reading on file already open." << fTTBELL << endl;
01742     } 
01743   else
01744     {
01745       ok_open = OpenRootFile(file_name, "READ");
01746 
01747       Int_t i_zero = 0;
01748       ok_read = gCnaRootFile->ReadElement(typ,i_zero);
01749       
01750       if ( ok_read == kTRUE )
01751         {
01752           fDataExist = kTRUE;
01753           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
01754             {
01755               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
01756               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
01757                 {
01758                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
01759                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01760                 }
01761             }
01762         }
01763       else
01764         {
01765           fDataExist = kFALSE;
01766           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
01767                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01768                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01769                << fTTBELL << endl;
01770         }
01771     }
01772 
01773   CloseRootFile(file_name);
01774 
01775   return mat;
01776 }
01777 //----- end of ( ReadHighFrequencyCovariancesBetweenChannels(...) ) -------
01778 
01779 //-------------------------------------------------------------------------------------------
01780 //
01781 //         ReadHighFrequencyCorrelationsBetweenChannels(Stin_a, Stin_b)
01782 //
01783 //-------------------------------------------------------------------------------------------
01784 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t & n1StexStin_a,
01785                                                                 const Int_t & n1StexStin_b,
01786                                                                 const Int_t& MatDim)
01787 {
01788 //Read the High Frequency Cor(i0StinEcha of Stin_a, i0StinEcha of Stin b)
01789 //in ROOT file and return them in a TMatrixD
01790 //
01791 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysInStin()
01792 
01793   Int_t   index_Stin_a = GetStinIndex(n1StexStin_a);
01794   Int_t   index_Stin_b = GetStinIndex(n1StexStin_b);
01795 
01796   TMatrixD mat(MatDim, MatDim);
01797   for(Int_t i=0; i<MatDim; i++)
01798     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01799   
01800   CnaResultTyp typ = cTypHfCor;
01801 
01802   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01803 
01804   Bool_t ok_open = kFALSE;
01805   Bool_t ok_read = kFALSE;
01806   
01807   if ( fOpenRootFile )
01808     {
01809       cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***>"
01810            << " Reading on file already open." << fTTBELL << endl;
01811     } 
01812   else
01813     {
01814       ok_open = OpenRootFile(file_name, "READ");
01815 
01816       Int_t i_zero = 0;
01817 
01818       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01819       
01820       if ( ok_read == kTRUE )
01821         {
01822           fDataExist = kTRUE;
01823           for ( Int_t i_crys = 0; i_crys < MatDim; i_crys++)
01824             {
01825               Int_t i_cna_chan = index_Stin_a*MatDim + i_crys;
01826               for ( Int_t j_crys = 0; j_crys < MatDim; j_crys++)
01827                 {
01828                   Int_t j_cna_chan = index_Stin_b*MatDim + j_crys;
01829                   mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01830                 }
01831             }
01832         }
01833       else
01834         {
01835           fDataExist = kFALSE;
01836           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
01837                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01838                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01839                << fTTBELL << endl;
01840         }
01841     }
01842 
01843   CloseRootFile(file_name);
01844 
01845   return mat;
01846 }
01847 //----- end of ( ReadHighFrequencyCorrelationsBetweenChannels(...) ) -------
01848 
01849 //-------------------------------------------------------------------------
01850 //
01851 //         ReadLowFrequencyCovariancesBetweenChannels(...)
01852 //                  (NOT USED)
01853 //-------------------------------------------------------------------------
01854 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t& MatDim)
01855 {
01856 //Read all the Low Frequency covariances
01857 //in ROOT file and return them in a TMatrixD
01858 //
01859 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
01860 
01861   //=====> WARNING: BIG MATRIX (1700x1700)
01862   TMatrixD mat(MatDim, MatDim);
01863   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01864 
01865   TVectorD vec(fEcal->MaxStinEcnaInStex());
01866   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
01867   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
01868   
01869   CnaResultTyp typ = cTypLfCov;
01870 
01871   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01872 
01873   Bool_t ok_open = kFALSE;
01874   Bool_t ok_read = kFALSE;
01875   
01876   if ( fOpenRootFile )
01877     {
01878       cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels() *** ERROR ***>"
01879            << " Reading on file already open." << fTTBELL << endl;
01880     } 
01881   else
01882     {
01883       ok_open = OpenRootFile(file_name, "READ");
01884 
01885       Int_t i_zero = 0;
01886       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01887       
01888       if ( ok_read == kTRUE )
01889         {
01890           fDataExist = kTRUE;
01891           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
01892             {
01893               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
01894                 {
01895                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
01896                     {
01897                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
01898                         {
01899                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
01900                             {
01901                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
01902                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() +i_crys;
01903                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
01904                                 {
01905                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
01906                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() +j_crys;
01907                                   mat(i_chan_sm, j_chan_sm) =
01908                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01909                                 }
01910                             }
01911                         }
01912                     }
01913                 }
01914             }
01915         }
01916       else
01917         {
01918           fDataExist = kFALSE;
01919           cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels() *** ERROR ***> "
01920                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
01921                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
01922                << fTTBELL << endl;
01923         }
01924     }
01925 
01926   CloseRootFile(file_name);
01927 
01928   return mat;
01929 }
01930 //----- end of ( ReadLowFrequencyCovariancesBetweenChannels(...) ) -------
01931 
01932 //-------------------------------------------------------------------------
01933 //
01934 //         ReadLowFrequencyCorrelationsBetweenChannels(...)
01935 //
01936 //-------------------------------------------------------------------------
01937 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t& MatDim)
01938 {
01939 //Read all the Low Frequency correlations
01940 //in ROOT file and return them in a TMatrixD
01941 //
01942 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
01943 
01944   //=====> WARNING: BIG MATRIX (1700x1700)
01945   TMatrixD mat(MatDim, MatDim);
01946   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
01947 
01948   TVectorD vec(fEcal->MaxStinEcnaInStex());
01949   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
01950   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
01951   
01952   CnaResultTyp typ = cTypLfCor;
01953 
01954   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
01955 
01956   Bool_t ok_open = kFALSE;
01957   Bool_t ok_read = kFALSE;
01958   
01959   if ( fOpenRootFile )
01960     {
01961       cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels() *** ERROR ***>"
01962            << " Reading on file already open." << fTTBELL << endl;
01963     } 
01964   else
01965     {
01966       ok_open = OpenRootFile(file_name, "READ");
01967 
01968       Int_t i_zero = 0;
01969       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
01970       
01971       if ( ok_read == kTRUE )
01972         {
01973           fDataExist = kTRUE;
01974           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
01975             {
01976               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
01977                 {
01978                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
01979                     {
01980                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
01981                         {
01982                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
01983                             {
01984                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
01985                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() + i_crys;
01986                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
01987                                 {
01988                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
01989                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() + j_crys;
01990                                   mat(i_chan_sm, j_chan_sm) =
01991                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
01992                                 }
01993                             }
01994                         }
01995                     }
01996                 }
01997             }
01998         }
01999       else
02000         {
02001           fDataExist = kFALSE;
02002           cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
02003                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02004                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02005                << fTTBELL << endl;
02006         }
02007     }
02008 
02009   CloseRootFile(file_name);
02010 
02011   return mat;
02012 }
02013 //----- end of (ReadLowFrequencyCorrelationsBetweenChannels(...) ) -------
02014 
02015 //-------------------------------------------------------------------------
02016 //
02017 //         ReadHighFrequencyCovariancesBetweenChannels(...)
02018 //                  (NOT USED)
02019 //-------------------------------------------------------------------------
02020 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t& MatDim)
02021 {
02022 //Read all the High Frequency covariances
02023 //in ROOT file and return them in a TMatrixD
02024 //
02025 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02026 
02027   //=====> WARNING: BIG MATRIX (1700x1700)
02028   TMatrixD mat(MatDim, MatDim);
02029   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
02030 
02031   TVectorD vec(fEcal->MaxStinEcnaInStex());
02032   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
02033   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
02034   
02035   CnaResultTyp typ = cTypHfCov;
02036 
02037   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02038 
02039   Bool_t ok_open = kFALSE;
02040   Bool_t ok_read = kFALSE;
02041   
02042   if ( fOpenRootFile )
02043     {
02044       cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels() *** ERROR ***>"
02045            << " Reading on file already open." << fTTBELL << endl;
02046     } 
02047   else
02048     {
02049       ok_open = OpenRootFile(file_name, "READ");
02050 
02051       Int_t i_zero = 0;
02052       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02053       
02054       if ( ok_read == kTRUE )
02055         {
02056           fDataExist = kTRUE;
02057           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
02058             {
02059               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
02060                 {
02061                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
02062                     {
02063                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
02064                         {
02065                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
02066                             {
02067                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
02068                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() +i_crys;
02069                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
02070                                 {
02071                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
02072                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() +j_crys;
02073                                   mat(i_chan_sm, j_chan_sm) =
02074                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
02075                                 }
02076                             }
02077                         }
02078                     }
02079                 }
02080             }
02081         }
02082       else
02083         {
02084           fDataExist = kFALSE;
02085           cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels() *** ERROR ***> "
02086                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02087                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02088                << fTTBELL << endl;
02089         }
02090     }
02091 
02092   CloseRootFile(file_name);
02093 
02094   return mat;
02095 }
02096 //----- end of ( ReadHighFrequencyCovariancesBetweenChannels(...) ) -------
02097 
02098 //-------------------------------------------------------------------------
02099 //
02100 //         ReadHighFrequencyCorrelationsBetweenChannels(...)
02101 //
02102 //-------------------------------------------------------------------------
02103 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t& MatDim)
02104 {
02105 //Read all the High Frequency correlations
02106 //in ROOT file and return them in a TMatrixD
02107 //
02108 //Possible values for MatDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02109 
02110   //=====> WARNING: BIG MATRIX (1700x1700)
02111   TMatrixD mat(MatDim, MatDim);
02112   for(Int_t i=0; i<MatDim; i++){for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
02113 
02114   TVectorD vec(fEcal->MaxStinEcnaInStex());
02115   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
02116   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
02117   
02118   CnaResultTyp typ = cTypHfCor;
02119 
02120   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02121 
02122   Bool_t ok_open = kFALSE;
02123   Bool_t ok_read = kFALSE;
02124   
02125   if ( fOpenRootFile )
02126     {
02127       cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels() *** ERROR ***>"
02128            << " Reading on file already open." << fTTBELL << endl;
02129     } 
02130   else
02131     {
02132       ok_open = OpenRootFile(file_name, "READ");
02133 
02134       Int_t i_zero = 0;
02135       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02136       
02137       if ( ok_read == kTRUE )
02138         {
02139           fDataExist = kTRUE;
02140           for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++)
02141             {
02142               if ( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex())
02143                 {
02144                   for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++)
02145                     {
02146                       if ( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex())
02147                         {
02148                           for ( Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++)
02149                             {
02150                               Int_t i_cna_chan = index_Stin_a*fEcal->MaxCrysInStin() + i_crys;
02151                               Int_t i_chan_sm = (Int_t)(vec(index_Stin_a)-1)*fEcal->MaxCrysInStin() + i_crys;
02152                               for ( Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++)
02153                                 {
02154                                   Int_t j_cna_chan = index_Stin_b*fEcal->MaxCrysInStin() + j_crys;
02155                                   Int_t j_chan_sm = (Int_t)(vec(index_Stin_b)-1)*fEcal->MaxCrysInStin() + j_crys;
02156                                   mat(i_chan_sm, j_chan_sm) =
02157                                     gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan,j_cna_chan);
02158                                 }
02159                             }
02160                         }
02161                     }
02162                 }
02163             }
02164         }
02165       else
02166         {
02167           fDataExist = kFALSE;
02168           cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
02169                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02170                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02171                << fTTBELL << endl;
02172         }
02173     }
02174 
02175   CloseRootFile(file_name);
02176 
02177   return mat;
02178 }
02179 //-------------- ( end of ReadHighFrequencyCorrelationsBetweenChannels(...) ) ---------
02180 
02181 
02182 //-------------------------------------------------------------------------
02183 //
02184 //         ReadLowFrequencyMeanCorrelationsBetweenStins(...)
02185 //
02186 //-------------------------------------------------------------------------
02187 TMatrixD TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins(const Int_t& MatDim)
02188 {
02189 //Read all the Low Frequency Mean Correlations Between Towers the for all (Stin_X, Stin_Y)
02190 //in ROOT file and return them in a TMatrixD
02191 //
02192 //Possible values for MatDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02193 
02194   TMatrixD mat(MatDim, MatDim);
02195   for(Int_t i=0; i<MatDim; i++)
02196     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
02197 
02198   TVectorD vec(fEcal->MaxStinEcnaInStex());
02199   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
02200   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
02201 
02202   CnaResultTyp typ = cTypLFccMoStins;
02203 
02204   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02205 
02206   Bool_t ok_open = kFALSE;
02207   Bool_t ok_read = kFALSE;
02208   
02209   if ( fOpenRootFile )
02210     {
02211       cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins() *** ERROR ***>"
02212            << " Reading on file already open." << fTTBELL << endl;
02213     } 
02214   else
02215     {
02216       ok_open = OpenRootFile(file_name, "READ");
02217 
02218       Int_t i_zero = 0;
02219       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02220       
02221       if( ok_read == kTRUE )
02222         {
02223           fDataExist = kTRUE;
02224           for(Int_t index_Stin_a = 0; index_Stin_a < MatDim; index_Stin_a++)
02225             {
02226               for(Int_t index_Stin_b = 0; index_Stin_b < MatDim; index_Stin_b++)   
02227                 {
02228                   if( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim)
02229                     {
02230                       if( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim)
02231                         {
02232                           mat((Int_t)vec(index_Stin_a)-1, (Int_t)vec(index_Stin_b)-1) =
02233                             gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a,index_Stin_b);
02234                         }
02235                     }
02236                 }
02237             }
02238         } 
02239       else
02240         {
02241           fDataExist = kFALSE;
02242           cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
02243                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02244                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02245                << fTTBELL << endl;
02246         }
02247 
02248       CloseRootFile(file_name);
02249     }
02250 
02251   return mat;
02252 }
02253 //-------- ( end of ReadLowFrequencyMeanCorrelationsBetweenStins) --------
02254 
02255 //-------------------------------------------------------------------------
02256 //
02257 //         ReadHighFrequencyMeanCorrelationsBetweenStins(...)
02258 //
02259 //-------------------------------------------------------------------------
02260 TMatrixD TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins(const Int_t& MatDim)
02261 {
02262 //Read all the High Frequency Mean Correlations Between Towers the for all (Stin_X, Stin_Y)
02263 //in ROOT file and return them in a TMatrixD
02264 //
02265 //Possible values for MatDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02266 
02267   TMatrixD mat(MatDim, MatDim);
02268   for(Int_t i=0; i<MatDim; i++)
02269     {for(Int_t j=0; j<MatDim; j++){mat(i,j)=(Double_t)0.;}}
02270 
02271   TVectorD vec(fEcal->MaxStinEcnaInStex());
02272   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
02273   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
02274 
02275   CnaResultTyp typ = cTypHFccMoStins;
02276 
02277   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02278 
02279   Bool_t ok_open = kFALSE;
02280   Bool_t ok_read = kFALSE;
02281   
02282   if ( fOpenRootFile )
02283     {
02284       cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins() *** ERROR ***>"
02285            << " Reading on file already open." << fTTBELL << endl;
02286     } 
02287   else
02288     {
02289       ok_open = OpenRootFile(file_name, "READ");
02290 
02291       Int_t i_zero = 0;
02292       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02293       
02294       if( ok_read == kTRUE )
02295         {
02296           fDataExist = kTRUE;
02297           for(Int_t index_Stin_a = 0; index_Stin_a < MatDim; index_Stin_a++)
02298             {
02299               for(Int_t index_Stin_b = 0; index_Stin_b < MatDim; index_Stin_b++)   
02300                 {
02301                   if( vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim)
02302                     {
02303                       if( vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim)
02304                         {
02305                           mat((Int_t)vec(index_Stin_a)-1, (Int_t)vec(index_Stin_b)-1) =
02306                             gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a,index_Stin_b);
02307                         }
02308                     }
02309                 }
02310             }
02311         } 
02312       else
02313         {
02314           fDataExist = kFALSE;
02315           cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
02316                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02317                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02318                << fTTBELL << endl;
02319         }
02320 
02321       CloseRootFile(file_name);
02322     }
02323 
02324   return mat;
02325 }
02326 //-------- ( end of ReadHighFrequencyMeanCorrelationsBetweenStins) --------
02327 
02328 //============================================================================
02329 //
02330 //                       1 D   H I S T O S :  M E A N
02331 //
02332 //============================================================================
02333 //-----------------------------------------------------------------------------
02334 //
02335 //                  ReadNumberOfEvents(...)
02336 //
02337 //-----------------------------------------------------------------------------
02338 TVectorD TEcnaRead::ReadNumberOfEvents(const Int_t& VecDim)
02339 {
02340 //Read the numbers of found events in the data
02341 //for the crystals and for the samples for all the Stin's in the Stex
02342 //in the ROOT file, compute the average on the samples
02343 //and return them in a TVectorD(MaxCrysEcnaInStex)
02344 //
02345 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02346 
02347   TVectorD vec(VecDim);
02348   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02349 
02350   TMatrixD mat(fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
02351 
02352   for(Int_t iStexStin=0; iStexStin<fEcal->MaxStinEcnaInStex(); iStexStin++)
02353     {
02354       //............. set mat(,) to zero before reading it
02355       for(Int_t i=0; i<fEcal->MaxCrysInStin(); i++)
02356         {for(Int_t j=0; j<fFileHeader->fNbOfSamples; j++){mat(i,j)=(Double_t)0.;}}
02357       //............. read mat(,)
02358       mat = ReadNumberOfEventsForSamples(iStexStin+1, fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
02359 
02360       for(Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++)
02361         {
02362           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(iStexStin+1, i0StinEcha);
02363           vec(i0StexEcha) = 0; 
02364           //.... average value over the samples
02365           for(Int_t i_samp=0; i_samp<fFileHeader->fNbOfSamples; i_samp++)
02366             {vec(i0StexEcha) += mat(i0StinEcha, i_samp);}
02367           vec(i0StexEcha) = vec(i0StexEcha)/fFileHeader->fNbOfSamples;
02368         } 
02369     }
02370   return vec;
02371 }
02372 
02373 //-------------------------------------------------------------------------
02374 //
02375 //        ReadPedestals(...)      
02376 //
02377 //-------------------------------------------------------------------------
02378 TVectorD TEcnaRead::ReadPedestals(const Int_t& VecDim)
02379 {
02380 //Read the expectation values of the expectation values of the samples
02381 //for all the channels of a given Stin
02382 //in the ROOT file and return them in a TVectorD
02383 //
02384 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02385 
02386   TVectorD vec(VecDim);
02387   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02388 
02389   CnaResultTyp typ = cTypPed;    // pedestals type
02390   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02391 
02392   Bool_t ok_open = kFALSE;
02393   Bool_t ok_read = kFALSE;
02394   
02395   if ( fOpenRootFile )
02396     {
02397       cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> "
02398            << "Reading on file already open." << fTTBELL << endl;
02399     } 
02400   else
02401     {
02402       ok_open = OpenRootFile(file_name, "READ");
02403 
02404       Int_t i_zero = 0;
02405       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02406       
02407       if ( ok_read == kTRUE )
02408         {
02409           fDataExist = kTRUE;
02410           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02411             {
02412               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
02413             }   
02414         }
02415       else
02416         {
02417           fDataExist = kFALSE;
02418           cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> "
02419                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02420                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02421                << fTTBELL << endl;
02422         }
02423     }
02424   CloseRootFile(file_name);
02425   return vec;
02426 }
02427 
02428 //-------------------------------------------------------------------------
02429 //
02430 //              ReadTotalNoise(...)      
02431 //
02432 //-------------------------------------------------------------------------
02433 TVectorD TEcnaRead::ReadTotalNoise(const Int_t& VecDim)
02434 {
02435 //Read the expectation values of the sigmas of the samples
02436 //for all the channels of a given Stin
02437 //in the ROOT file and return them in a TVectorD
02438 //
02439 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02440 
02441   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02442   CnaResultTyp typ = cTypTno;   // Total noise type
02443   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02444 
02445   Bool_t ok_open = kFALSE;
02446   Bool_t ok_read = kFALSE;
02447   
02448   if ( fOpenRootFile )
02449     {
02450       cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> "
02451            << "Reading on file already open." << fTTBELL << endl;
02452     } 
02453   else
02454     {
02455       ok_open = OpenRootFile(file_name, "READ");
02456 
02457       Int_t i_zero = 0;
02458       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02459       
02460       if ( ok_read == kTRUE )
02461         {
02462           fDataExist = kTRUE;
02463           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02464             {
02465               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02466             }   
02467         }
02468       else
02469         {
02470           fDataExist = kFALSE;
02471           cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> "
02472                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02473                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02474                << fTTBELL << endl;
02475         }
02476     }
02477   CloseRootFile(file_name);
02478   return vec;
02479 }
02480 //-------------------------------------------------------------------------
02481 //
02482 //          ReadMeanOfCorrelationsBetweenSamples(...)      
02483 //
02484 //-------------------------------------------------------------------------
02485 TVectorD TEcnaRead::ReadMeanOfCorrelationsBetweenSamples(const Int_t& VecDim)
02486 {
02487 //Read the Expectation values of the (sample,sample) correlations
02488 //for all the channels of a given Stin
02489 //in the ROOT file and return them in a TVectorD
02490 //
02491 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02492 
02493   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02494   CnaResultTyp typ = cTypMeanCorss;     // mean of corss type
02495   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02496 
02497   Bool_t ok_open = kFALSE;
02498   Bool_t ok_read = kFALSE;
02499   
02500   if ( fOpenRootFile )
02501     {
02502       cout << "!TEcnaRead::ReadMeanOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02503            << "Reading on file already open." << fTTBELL << endl;
02504     } 
02505   else
02506     {
02507       ok_open = OpenRootFile(file_name, "READ");
02508 
02509       Int_t i_zero = 0;
02510       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02511       
02512       if ( ok_read == kTRUE )
02513         {
02514           fDataExist = kTRUE;
02515           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02516             {
02517               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02518             }   
02519         }
02520       else
02521         {
02522           fDataExist = kFALSE;
02523           cout << "!TEcnaRead::ReadMeanOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02524                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02525                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02526                << fTTBELL << endl;
02527         }
02528     }
02529 
02530   CloseRootFile(file_name);
02531   return vec;
02532 }
02533 
02534 //-------------------------------------------------------------------------
02535 //
02536 //              ReadLowFrequencyNoise(...)      
02537 //
02538 //-------------------------------------------------------------------------
02539 TVectorD TEcnaRead::ReadLowFrequencyNoise(const Int_t& VecDim)
02540 {
02541 //Read the sigmas of the expectation values of the samples
02542 //for all the channels of a given Stin
02543 //in the ROOT file and return them in a TVectorD
02544 //
02545 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02546 
02547   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02548   CnaResultTyp typ = cTypLfn;        // low frequency noise type
02549   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02550 
02551   Bool_t ok_open = kFALSE;
02552   Bool_t ok_read = kFALSE;
02553   
02554   if ( fOpenRootFile )
02555     {
02556       cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> "
02557            << "Reading on file already open." << fTTBELL << endl;
02558     } 
02559   else
02560     {
02561       ok_open = OpenRootFile(file_name, "READ");
02562 
02563       Int_t i_zero = 0;
02564       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02565       
02566       if ( ok_read == kTRUE )
02567         {
02568           fDataExist = kTRUE;
02569           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02570             {
02571               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02572             }   
02573         }
02574       else
02575         {
02576           fDataExist = kFALSE;
02577           cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> "
02578                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02579                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02580                << fTTBELL << endl;
02581         }
02582     }
02583 
02584   CloseRootFile(file_name);
02585   return vec;
02586 }
02587 
02588 //-------------------------------------------------------------------------
02589 //
02590 //              ReadHighFrequencyNoise(...)      
02591 //
02592 //-------------------------------------------------------------------------
02593 TVectorD TEcnaRead::ReadHighFrequencyNoise(const Int_t& VecDim)
02594 {
02595 //Read the sigmas of the sigmas of the samples
02596 //for all the channels of a given Stin
02597 //in the ROOT file and return them in a TVectorD
02598 //
02599 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02600   
02601   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02602   CnaResultTyp typ = cTypHfn;        // high frequency noise type
02603   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02604 
02605   Bool_t ok_open = kFALSE;
02606   Bool_t ok_read = kFALSE;
02607   
02608   if ( fOpenRootFile )
02609     {
02610       cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> "
02611            << "Reading on file already open." << fTTBELL << endl;
02612     } 
02613   else
02614     {
02615       ok_open = OpenRootFile(file_name, "READ");
02616 
02617       Int_t i_zero = 0;
02618       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02619       
02620       if ( ok_read == kTRUE )
02621         {
02622           fDataExist = kTRUE;
02623           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02624             {
02625               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02626             }   
02627         }
02628       else
02629         {
02630           fDataExist = kFALSE;
02631           cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> "
02632                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02633                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02634                << fTTBELL << endl;
02635         }
02636     }
02637 
02638   CloseRootFile(file_name);
02639   return vec;
02640 }
02641 
02642 //-------------------------------------------------------------------------
02643 //
02644 //              ReadSigmaOfCorrelationsBetweenSamples(...)       
02645 //
02646 //-------------------------------------------------------------------------
02647 TVectorD TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(const Int_t& VecDim)
02648 {
02649 //Read the Expectation values of the (sample,sample) correlations
02650 //for all the channels of a given Stin
02651 //in the ROOT file and return them in a TVectorD
02652 //
02653 //Possible values for VecDim: (1) MatDim = fEcal->MaxCrysEcnaInStex()
02654 
02655   TVectorD vec(VecDim); for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02656   CnaResultTyp typ = cTypSigCorss;  // sigma of corss type
02657   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02658 
02659   Bool_t ok_open = kFALSE;
02660   Bool_t ok_read = kFALSE;
02661   
02662   if ( fOpenRootFile )
02663     {
02664       cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02665            << "Reading on file already open." << fTTBELL << endl;
02666     } 
02667   else
02668     {
02669       ok_open = OpenRootFile(file_name, "READ");
02670 
02671       Int_t i_zero = 0;
02672       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02673       
02674       if ( ok_read == kTRUE )
02675         {
02676           fDataExist = kTRUE;
02677           for ( Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++)
02678             {
02679               vec(i_StexCrys)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero,i_StexCrys);
02680             }   
02681         }
02682       else
02683         {
02684           fDataExist = kFALSE;
02685           cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
02686                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02687                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02688                << fTTBELL << endl;
02689         }
02690     }
02691 
02692   CloseRootFile(file_name);
02693   return vec;
02694 }
02695 //============================================================================
02696 //
02697 //                  1 D   H I S T O S :  A V E R A G E D   M E A N
02698 //
02699 //============================================================================
02700 //-----------------------------------------------------------------------------
02701 //
02702 //                  ReadAveragedNumberOfEvents(...)
02703 //
02704 //       NB: read "direct" numbers of evts and compute the average HERE
02705 //           (different from ReadAveragedPedestals, Noises, etc...)
02706 //
02707 //-----------------------------------------------------------------------------
02708 TVectorD TEcnaRead::ReadAveragedNumberOfEvents(const Int_t& VecDim)
02709 {
02710 //Read the numbers of found events in the data
02711 //for the crystals and for the samples for all the Stin's in the Stex
02712 //in the ROOT file, compute the average on the samples and on the crystals
02713 //and return them in a TVectorD(MaxStinEcnaInStex)
02714 //
02715 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02716 
02717   TVectorD vecAveraged(VecDim);
02718   for(Int_t i=0; i<VecDim; i++){vecAveraged(i)=(Double_t)0.;}
02719 
02720   TVectorD vecMean(fEcal->MaxCrysEcnaInStex());
02721   for(Int_t i=0; i<fEcal->MaxCrysEcnaInStex(); i++){vecMean(i)=(Double_t)0.;}
02722 
02723   vecMean = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
02724 
02725   for(Int_t i0StexStin=0; i0StexStin<VecDim; i0StexStin++)
02726     {
02727       Int_t n1StexStin = i0StexStin+1;
02728       vecAveraged(i0StexStin) = 0;
02729       //.... average value over the crystals
02730       for(Int_t i0StinEcha=0; i0StinEcha<fEcal->MaxCrysInStin(); i0StinEcha++)
02731         {
02732           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(i0StexStin+1, i0StinEcha);
02733           
02734           if( fStexName == "SM" )
02735             {vecAveraged(i0StexStin) += vecMean(i0StexEcha);}
02736 
02737           if( fStexName == "Dee" )
02738             {
02739               //--------- EE --> Special translation for mixed SCEcna (29 and 32)
02740               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02741               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02742               Int_t n1StinEcha = i0StinEcha+1;
02743               if( n1StexStin == 10 && n1StinEcha == 11 )
02744                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02745               if( n1StexStin == 11 && n1StinEcha == 11 )
02746                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02747               if( !( (n1StexStin == 29 || n1StexStin == 32) && n1StinEcha == 11 )  )
02748                 {vecAveraged(i0StexStin) += vecMean(i0StexEcha);}
02749             }
02750         }
02751 
02752       Double_t xdivis = (Double_t)0.;
02753       if( fStexName == "SM"  )
02754         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02755       if( fStexName == "Dee" )
02756         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, i0StexStin+1, "TEcnaRead");}
02757 
02758       vecAveraged(i0StexStin) = vecAveraged(i0StexStin)/xdivis;   
02759     }
02760   return vecAveraged;
02761 }
02762 
02763 //-------------------------------------------------------------------------
02764 //
02765 //        ReadAveragedPedestals(...)      
02766 //
02767 //-------------------------------------------------------------------------
02768 TVectorD TEcnaRead::ReadAveragedPedestals(const Int_t& VecDim)
02769 {
02770 //Read the expectation values of the Pedestals
02771 //for all the Stins of a given Stex
02772 //in the ROOT file and return them in a TVectorD
02773 //
02774 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02775 
02776   TVectorD vec(VecDim);
02777   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02778 
02779   CnaResultTyp typ = cTypAvPed;    // averaged pedestals type
02780   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02781 
02782   Bool_t ok_open = kFALSE;
02783   Bool_t ok_read = kFALSE;
02784   
02785   if ( fOpenRootFile )
02786     {
02787       cout << "!TEcnaRead::ReadAveragedPedestals(...) *** ERROR ***> "
02788            << "Reading on file already open." << fTTBELL << endl;
02789     } 
02790   else
02791     {
02792       ok_open = OpenRootFile(file_name, "READ");
02793 
02794       Int_t i_zero = 0;
02795       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02796       
02797       if ( ok_read == kTRUE )
02798         {
02799           fDataExist = kTRUE;
02800           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02801             {
02802               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02803             }   
02804         }
02805       else
02806         {
02807           fDataExist = kFALSE;
02808           cout << "!TEcnaRead::ReadAveragedPedestals(...) *** ERROR ***> "
02809                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02810                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02811                << fTTBELL << endl;
02812         }
02813     }
02814   CloseRootFile(file_name);
02815   return vec;
02816 } // end of ReadAveragedPedestals
02817 
02818 //-------------------------------------------------------------------------
02819 //
02820 //        ReadAveragedTotalNoise(...)      
02821 //
02822 //-------------------------------------------------------------------------
02823 TVectorD TEcnaRead::ReadAveragedTotalNoise(const Int_t& VecDim)
02824 {
02825 //Read the expectation values of the Total Noise
02826 //for all the Stins of a given Stex
02827 //in the ROOT file and return them in a TVectorD
02828 //
02829 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02830 
02831   TVectorD vec(VecDim);
02832   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02833 
02834   CnaResultTyp typ = cTypAvTno;    // averaged Total Noise type
02835   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02836 
02837   Bool_t ok_open = kFALSE;
02838   Bool_t ok_read = kFALSE;
02839   
02840   if ( fOpenRootFile )
02841     {
02842       cout << "!TEcnaRead::ReadAveragedTotalNoise(...) *** ERROR ***> "
02843            << "Reading on file already open." << fTTBELL << endl;
02844     } 
02845   else
02846     {
02847       ok_open = OpenRootFile(file_name, "READ");
02848 
02849       Int_t i_zero = 0;
02850       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02851       
02852       if ( ok_read == kTRUE )
02853         {
02854           fDataExist = kTRUE;
02855           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02856             {
02857               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02858             }   
02859         }
02860       else
02861         {
02862           fDataExist = kFALSE;
02863           cout << "!TEcnaRead::ReadAveragedTotalNoise(...) *** ERROR ***> "
02864                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02865                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02866                << fTTBELL << endl;
02867         }
02868     }
02869   CloseRootFile(file_name);
02870   return vec;
02871 }
02872 
02873 //-------------------------------------------------------------------------
02874 //
02875 //        ReadAveragedLowFrequencyNoise(...)      
02876 //
02877 //-------------------------------------------------------------------------
02878 TVectorD TEcnaRead::ReadAveragedLowFrequencyNoise(const Int_t& VecDim)
02879 {
02880 //Read the expectation values of the Pedestals
02881 //for all the Stins of a given Stex
02882 //in the ROOT file and return them in a TVectorD
02883 //
02884 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02885 
02886   TVectorD vec(VecDim);
02887   for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02888 
02889   CnaResultTyp typ = cTypAvLfn;    // averaged Low FrequencyNoise type
02890   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02891 
02892   Bool_t ok_open = kFALSE;
02893   Bool_t ok_read = kFALSE;
02894   
02895   if ( fOpenRootFile )
02896     {
02897       cout << "!TEcnaRead::ReadAveragedLowFrequencyNoise(...) *** ERROR ***> "
02898            << "Reading on file already open." << fTTBELL << endl;
02899     } 
02900   else
02901     {
02902       ok_open = OpenRootFile(file_name, "READ");
02903 
02904       Int_t i_zero = 0;
02905       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02906       
02907       if ( ok_read == kTRUE )
02908         {
02909           fDataExist = kTRUE;
02910           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02911             {
02912               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02913             }   
02914         }
02915       else
02916         {
02917           fDataExist = kFALSE;
02918           cout << "!TEcnaRead::ReadAveragedLowFrequencyNoise(...) *** ERROR ***> "
02919                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02920                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02921                << fTTBELL << endl;
02922         }
02923     }
02924   CloseRootFile(file_name);
02925   return vec;
02926 } // end of ReadAveragedLowFrequencyNoise
02927 
02928 //-------------------------------------------------------------------------
02929 //
02930 //        ReadAveragedHighFrequencyNoise(...)      
02931 //
02932 //-------------------------------------------------------------------------
02933 TVectorD TEcnaRead::ReadAveragedHighFrequencyNoise(const Int_t& VecDim)
02934 {
02935 //Read the expectation values of the Pedestals
02936 //for all the Stins of a given Stex
02937 //in the ROOT file and return them in a TVectorD
02938 //
02939 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02940 
02941   TVectorD vec(VecDim);
02942  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02943 
02944   CnaResultTyp typ = cTypAvHfn;    // averaged High FrequencyNoise type
02945   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
02946 
02947   Bool_t ok_open = kFALSE;
02948   Bool_t ok_read = kFALSE;
02949   
02950   if ( fOpenRootFile )
02951     {
02952       cout << "!TEcnaRead::ReadAveragedHighFrequencyNoise(...) *** ERROR ***> "
02953            << "Reading on file already open." << fTTBELL << endl;
02954     } 
02955   else
02956     {
02957       ok_open = OpenRootFile(file_name, "READ");
02958 
02959       Int_t i_zero = 0;
02960       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
02961       
02962       if ( ok_read == kTRUE )
02963         {
02964           fDataExist = kTRUE;
02965           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
02966             {
02967               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
02968             }   
02969         }
02970       else
02971         {
02972           fDataExist = kFALSE;
02973           cout << "!TEcnaRead::ReadAveragedHighFrequencyNoise(...) *** ERROR ***> "
02974                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
02975                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
02976                << fTTBELL << endl;
02977         }
02978     }
02979   CloseRootFile(file_name);
02980   return vec;
02981 } // end of ReadAveragedHighFrequencyNoise
02982 
02983 //-------------------------------------------------------------------------
02984 //
02985 //        ReadAveragedMeanOfCorrelationsBetweenSamples(...)      
02986 //
02987 //-------------------------------------------------------------------------
02988 TVectorD TEcnaRead::ReadAveragedMeanOfCorrelationsBetweenSamples(const Int_t& VecDim)
02989 {
02990 //Read the expectation values of the Pedestals
02991 //for all the Stins of a given Stex
02992 //in the ROOT file and return them in a TVectorD
02993 //
02994 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
02995 
02996   TVectorD vec(VecDim);
02997  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
02998 
02999   CnaResultTyp typ = cTypAvMeanCorss;    // averaged MeanOfCorrelationsBetweenSamples type
03000   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03001 
03002   Bool_t ok_open = kFALSE;
03003   Bool_t ok_read = kFALSE;
03004   
03005   if ( fOpenRootFile )
03006     {
03007       cout << "!TEcnaRead::ReadAveragedMeanOfCorrelationsBetweenSamples(...) *** ERROR ***> "
03008            << "Reading on file already open." << fTTBELL << endl;
03009     } 
03010   else
03011     {
03012       ok_open = OpenRootFile(file_name, "READ");
03013 
03014       Int_t i_zero = 0;
03015       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03016       
03017       if ( ok_read == kTRUE )
03018         {
03019           fDataExist = kTRUE;
03020           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
03021             {
03022               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
03023             }   
03024         }
03025       else
03026         {
03027           fDataExist = kFALSE;
03028           cout << "!TEcnaRead::ReadAveragedMeanOfCorrelationsBetweenSamples(...) *** ERROR ***> "
03029                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
03030                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
03031                << fTTBELL << endl;
03032         }
03033     }
03034   CloseRootFile(file_name);
03035   return vec;
03036 } // end of ReadAveragedMeanOfCorrelationsBetweenSamples
03037 
03038 //-------------------------------------------------------------------------
03039 //
03040 //        ReadAveragedSigmaOfCorrelationsBetweenSamples(...)      
03041 //
03042 //-------------------------------------------------------------------------
03043 TVectorD TEcnaRead::ReadAveragedSigmaOfCorrelationsBetweenSamples(const Int_t& VecDim)
03044 {
03045 //Read the expectation values of the Pedestals
03046 //for all the Stins of a given Stex
03047 //in the ROOT file and return them in a TVectorD
03048 //
03049 //Possible values for VecDim: (1) MatDim = fEcal->MaxStinEcnaInStex()
03050 
03051   TVectorD vec(VecDim);
03052  for(Int_t i=0; i<VecDim; i++){vec(i)=(Double_t)0.;}
03053 
03054   CnaResultTyp typ = cTypAvSigCorss;    // averaged SigmaOfCorrelationsBetweenSamples type
03055   const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03056 
03057   Bool_t ok_open = kFALSE;
03058   Bool_t ok_read = kFALSE;
03059   
03060   if ( fOpenRootFile )
03061     {
03062       cout << "!TEcnaRead::ReadAveragedSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
03063            << "Reading on file already open." << fTTBELL << endl;
03064     } 
03065   else
03066     {
03067       ok_open = OpenRootFile(file_name, "READ");
03068 
03069       Int_t i_zero = 0;
03070       ok_read = gCnaRootFile->ReadElement(typ, i_zero);
03071       
03072       if ( ok_read == kTRUE )
03073         {
03074           fDataExist = kTRUE;
03075           for ( Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++)
03076             {
03077               vec(i0StexStin)  = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
03078             }   
03079         }
03080       else
03081         {
03082           fDataExist = kFALSE;
03083           cout << "!TEcnaRead::ReadAveragedSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
03084                << fCnaWrite->fRootFileNameShort.Data() << ": ROOT file failed ->"
03085                <<  " quantity: <" << GetTypeOfQuantity(typ) << "> not available in file."
03086                << fTTBELL << endl;
03087         }
03088     }
03089   CloseRootFile(file_name);
03090   return vec;
03091 } // end of ReadAveragedSigmaOfCorrelationsBetweenSamples
03092 
03093 //=========================================================================
03094 //
03095 //          M I S C E L L A N E O U S    G E T    M E T H O D S   
03096 //
03097 //=========================================================================
03098 //-------------------------------------------------------------------------
03099 //
03100 //    Get the name of the quantity from its "CnaResultTyp" type
03101 //
03102 
03103 //=========================================================================
03104 //
03105 //          M I S C E L L A N E O U S    G E T    M E T H O D S   
03106 //
03107 //=========================================================================
03108 //-------------------------------------------------------------------------
03109 //
03110 //    Get the name of the quantity from its "CnaResultTyp" type
03111 //
03112 //-------------------------------------------------------------------------
03113 TString TEcnaRead::GetTypeOfQuantity(const CnaResultTyp arg_typ)
03114 {
03115   TString quantity_name = "?";
03116 
03117   if( arg_typ == cTypNumbers)
03118     {
03119       if( fFlagSubDet == "EB" ){quantity_name = "SM numbers";}
03120       if( fFlagSubDet == "EE" ){quantity_name = "Dee numbers";}
03121     }
03122   if( arg_typ == cTypMSp    ){quantity_name = "Mean of samples";}
03123   if( arg_typ == cTypSSp    ){quantity_name = "Sigma of samples";}
03124 
03125   if( arg_typ == cTypNbOfEvts ){quantity_name = "Number of events";}
03126   if( arg_typ == cTypPed      ){quantity_name = "Pedestals";}
03127   if( arg_typ == cTypTno      ){quantity_name = "Total noise";}
03128   if( arg_typ == cTypLfn      ){quantity_name = "LF noise";}
03129   if( arg_typ == cTypHfn      ){quantity_name = "HF noise";}
03130   if( arg_typ == cTypMeanCorss){quantity_name = "Mean of cor(s,s')";}
03131   if( arg_typ == cTypSigCorss ){quantity_name = "Sigma of cor(s,s')";}
03132 
03133   if( arg_typ == cTypAvPed      ){quantity_name = "Averaged pedestals";}
03134   if( arg_typ == cTypAvTno      ){quantity_name = "Averaged total noise";}
03135   if( arg_typ == cTypAvLfn      ){quantity_name = "Averaged LF noise";}
03136   if( arg_typ == cTypAvHfn      ){quantity_name = "Averaged HF noise";}
03137   if( arg_typ == cTypAvMeanCorss){quantity_name = "Averaged mean of cor(s,s')";}
03138   if( arg_typ == cTypAvSigCorss ){quantity_name = "Averaged sigma of cor(s,s')";}
03139 
03140   if( arg_typ == cTypAdcEvt ){quantity_name = "Sample ADC a.f.o event number";}
03141 
03142   if( arg_typ == cTypCovCss ){quantity_name = "Cov(s,s')";}
03143   if( arg_typ == cTypCorCss ){quantity_name = "Cor(s,s')";}
03144   if( arg_typ == cTypLfCov  ){quantity_name = "LF Cov(c,c')";}
03145   if( arg_typ == cTypLfCor  ){quantity_name = "LF Cor(c,c')";}
03146   if( arg_typ == cTypHfCov  ){quantity_name = "HF Cov(c,c')";}
03147   if( arg_typ == cTypHfCor  ){quantity_name = "HF Cor(c,c')";}
03148 
03149   if( fFlagSubDet == "EB" )
03150     {
03151       if( arg_typ == cTypLFccMoStins){quantity_name = "Mean LF |Cor(c,c')| in (tow,tow')";}
03152       if( arg_typ == cTypHFccMoStins){quantity_name = "Mean HF |Cor(c,c')| in (tow,tow')";}
03153     }
03154   if( fFlagSubDet == "EE" )
03155     {
03156       if( arg_typ == cTypLFccMoStins){quantity_name = "Mean LF |Cor(c,c')| in (SC,SC')";}
03157       if( arg_typ == cTypHFccMoStins){quantity_name = "Mean HF |Cor(c,c')| in (SC,SC')";}
03158     }
03159   return quantity_name;
03160 }
03161 
03162 //-------------------------------------------------------------------------
03163 //
03164 //    Get the ROOT file name (long and short)
03165 //
03166 //-------------------------------------------------------------------------
03167 TString TEcnaRead::GetRootFileName(){return fCnaWrite->GetRootFileName();}
03168 TString TEcnaRead::GetRootFileNameShort(){return fCnaWrite->GetRootFileNameShort();}
03169 //-------------------------------------------------------------------------
03170 //
03171 //                     GetStexStinFromIndex
03172 //
03173 //  *====> DON'T SUPPRESS: this method is called by TEcnaRun and TEcnaHistos
03174 //
03175 //-------------------------------------------------------------------------
03176 Int_t TEcnaRead::GetStexStinFromIndex(const Int_t& i0StexStinEcna)
03177 {
03178 // Get the Stin number in Stex from the Stin index
03179 
03180   Int_t number = -1;
03181   TVectorD vec(fEcal->MaxStinEcnaInStex());
03182   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03183   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03184   number = (Int_t)vec(i0StexStinEcna);
03185   return number;
03186 }
03187 
03188 TString  TEcnaRead::GetAnalysisName()
03189 {
03190   TString astring = "?";
03191   if (fFileHeader != 0){astring = fFileHeader->fTypAna;}
03192   else {cout << "!TEcnaRead::GetAnalysisName()> fFileHeader pointer = "
03193              << fFileHeader << endl;}
03194   return astring;
03195 }
03196 //------------------------------------------------------------------------
03197 Int_t  TEcnaRead::GetFirstReqEvtNumber()
03198 {
03199   Int_t number = -1;
03200   if (fFileHeader != 0){number = fFileHeader->fFirstReqEvtNumber;}
03201   else {cout << "!TEcnaRead::GetFirstReqEvtNumber()> fFileHeader pointer = "
03202              << fFileHeader << endl;}
03203   return number;
03204 }
03205 //------------------------------------------------------------------------
03206 Int_t  TEcnaRead::GetReqNbOfEvts()
03207 {
03208   Int_t number = -1;
03209   if (fFileHeader != 0){number = fFileHeader->fReqNbOfEvts;}
03210   else {cout << "!TEcnaRead::GetReqNbOfEvts()> fFileHeader pointer = "
03211              << fFileHeader << endl;}
03212   return number;
03213 }
03214 //------------------------------------------------------------------------
03215 
03216 Int_t  TEcnaRead::GetNumberOfBinsSampleAsFunctionOfTime(){return GetReqNbOfEvts();}
03217 //-------------------------------------------------------------------------
03218 //
03219 //                     GetStinIndex(n1StexStin)
03220 //
03221 //-------------------------------------------------------------------------
03222 Int_t  TEcnaRead::GetStinIndex(const Int_t & n1StexStin)
03223 {
03224 //Get the index of the Stin from its number in Stex
03225 
03226   if(fFlagPrint == fCodePrintAllComments){
03227     cout << "*TEcnaRead::GetStinIndex(...)> fEcal->MaxStinEcnaInStex() = "
03228          << fEcal->MaxStinEcnaInStex() << endl
03229          << "                              n1StexStin = " << n1StexStin
03230          << endl << endl;}
03231 
03232   Int_t Stin_index = n1StexStin-1;    // suppose les 68 tours 
03233 
03234 #define NOGT
03235 #ifndef NOGT
03236   Int_t Stin_index = -1;
03237   TVectorD vec(fEcal->MaxStinEcnaInStex());
03238   for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
03239   vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
03240 
03241   //........................... Get the Stin index
03242 
03243   for(Int_t i=0; i < fEcal->MaxStinEcnaInStex(); i++)
03244     {
03245       if(fFlagPrint == fCodePrintAllComments){
03246         cout << "*TEcnaRead::GetStinIndex(...)> StinNumber[" << i << "] = "
03247              << vec[i] << endl;}
03248       if ( vec[i] == n1StexStin ){Stin_index = i;}
03249     }
03250 
03251   if(fFlagPrint == fCodePrintAllComments){
03252     cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << endl;
03253     cout << "*TEcnaRead::GetStinIndex> Stin number: " << n1StexStin  << endl
03254          << "                          Stin index : " << Stin_index << endl;
03255     cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << endl;}
03256 
03257   if ( Stin_index < 0 )
03258     {
03259       if(fFlagPrint == fCodePrintAllComments){
03260         cout << "!TEcnaRead::GetStinIndex *** WARNING ***> n1StexStin" << n1StexStin << " : "
03261              << "index Stin not found"
03262              << fTTBELL << endl;}
03263     }
03264 #endif // NOGT
03265 
03266   return Stin_index;
03267 }
03268 
03269 //=========================================================================
03270 //
03271 //         METHODS TO SET FLAGS TO PRINT (OR NOT) COMMENTS (DEBUG)
03272 //
03273 //=========================================================================
03274 
03275 void  TEcnaRead::PrintComments()
03276 {
03277 // Set flags to authorize printing of some comments concerning initialisations (default)
03278 
03279   fFlagPrint = fCodePrintComments;
03280   cout << "*TEcnaRead::PrintComments()> Warnings and some comments on init will be printed" << endl;
03281 }
03282 
03283 void  TEcnaRead::PrintWarnings()
03284 {
03285 // Set flags to authorize printing of warnings
03286 
03287   fFlagPrint = fCodePrintWarnings;
03288   cout << "*TEcnaRead::PrintWarnings()> Warnings will be printed" << endl;
03289 }
03290 
03291 void  TEcnaRead::PrintAllComments()
03292 {
03293 // Set flags to authorize printing of the comments of all the methods
03294 
03295   fFlagPrint = fCodePrintAllComments;
03296   cout << "*TEcnaRead::PrintAllComments()> All the comments will be printed" << endl;
03297 }
03298 
03299 void  TEcnaRead::PrintNoComment()
03300 {
03301 // Set flags to forbid the printing of all the comments
03302 
03303   fFlagPrint = fCodePrintNoComment;
03304 }