CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/src/TEcnaRun.cc

Go to the documentation of this file.
00001 //----------Author's Names: B.Fabbro, FX Gentit DSM/IRFU/SPP CEA-Saclay
00002 //----------Copyright: Those valid for CEA sofware
00003 //----------Modified: 01/04/2010
00004 // ROOT include files
00005 
00006 // user's include files
00007 
00008 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRun.h"
00009 
00010 R__EXTERN TEcnaRootFile *gCnaRootFile;
00011 
00012 ClassImp(TEcnaRun)
00013 //___________________________________________________________________________
00014 //
00015 // TEcnaRun + ECNA (Ecal Correlated Noise Analysis) instructions for use 
00016 //           in the framework of CMSSW.
00017 //
00018 //==============> INTRODUCTION
00019 //
00020 //    The present documentation contains:
00021 //
00022 //    [1] a brief description of the ECNA package with instructions for use
00023 //        in the framework of the CMS Software
00024 //
00025 //    [2] the documentation for the class TEcnaRun
00026 //
00027 //
00028 //==[1]=====================================================================================
00029 //
00030 //
00031 //         DOCUMENTATION FOR THE INTERFACE: ECNA package / CMSSW / SCRAM
00032 //
00033 //
00034 //==========================================================================================
00035 //
00036 //  ECNA consists in 2 packages named: EcalCorrelatedNoiseAnalysisModules and
00037 //  EcalCorrelatedNoiseAnalysisAlgos.
00038 //
00039 //  The directory tree is the following:
00040 //
00041 //      <local path>/CMSSW_a_b_c/src/----CalibCalorimetry/---EcalCorrelatedNoiseAnalysisModules/BuildFile
00042 //                              |   |                    |                                     |---interface/
00043 //                              |   |                    |                                     |---src/
00044 //                                  |                    |                                     |---data/
00045 //                                  |                    |
00046 //                                  |                    |---EcalCorrelatedNoiseAnalysisAlgos/BuildFile
00047 //                                  |                    |                                   |---interface/
00048 //                                  |                    |                                   |---src/
00049 //                                  |                    |                                   |---test/
00050 //                                  |                    |
00051 //                                  |                    |
00052 //                                  |                    \--- <other packages of CalibCalorimetry> 
00053 //                                  |
00054 //                                  \----<other subsystems...>
00055 //
00056 //
00057 //    The package EcalCorrelatedNoiseAnalysisModules contains one standard analyzer
00058 //    (EcnaAnalyzer). The user can edit its own analyzer.
00059 //    A detailed description is given here after in the class TEcnaRun documentation.
00060 //    An analyzer skeleton can be obtained by means of the
00061 //    SkeletonCodeGenerator "mkedanlzr" (see the CMSSW Framework/Edm web page).
00062 //
00063 //    The package EcalCorrelatedNoiseAnalysisAlgos contains the basic classes of ECNA 
00064 //    (in src and interface) and standalone executables (in directory test).
00065 //
00066 // 
00067 //==[2]======================================================================================
00068 //
00069 //
00070 //                         CLASS TEcnaRun DOCUMENTATION
00071 //
00072 //
00073 //===========================================================================================
00074 //TEcnaRun.
00075 //
00076 //
00077 //
00078 // Brief and general description
00079 // -----------------------------
00080 //
00081 //   This class allows the user to calculate pedestals, noises,
00082 //   correlations and other quantities of interest for correlated
00083 //   noise studies on the CMS/ECAL (EB and EE).
00084 //
00085 //   Three main operations are performed by the class TEcnaRun. Each of them is
00086 //   associated with a specific method of the analyzer EcnaAnalyzer:
00087 //
00088 //    (1) Initialization and calls to "preparation methods" of the CNA.
00089 //        This task is done in the constructor of the analyzer:
00090 //        EcnaAnalyzer::EcnaAnalyzer(const edm::ParameterSet& pSet)
00091 //
00092 //    (2) Building of the event distributions (distributions of the sample ADC
00093 //        values for each sample, each channel, etc...)
00094 //        This task is done in the method "analyze" of the analyzer:
00095 //        EcnaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00096 //
00097 //    (3) Calculation of the different quantities (correlations, pedestals, noises, etc...)
00098 //        from the distributions obtained in (2) and writing of these quantities
00099 //        in results ROOT files and also in ASCII files.
00100 //        This task is done in the destructor of the analyzer:
00101 //        EcnaAnalyzer::~EcnaAnalyzer()
00102 //   
00103 //
00104 // Use of the class TEcnaRun by the analyzer EcnaAnalyzer
00105 // ------------------------------------------------------
00106 //
00107 //           see files EcnaAnalyzer.h and EcnaAnalyzer.cc
00108 //           in package EcalCorrelatedNoiseAnalysisModules
00109 //
00110 //
00111 // More detailled description of the class TEcnaRun
00112 // -----------------------------------------------
00113 //
00114 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00115 //
00116 //                     Declaration and Print Methods
00117 //
00118 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00119 //
00120 //     Just after the declaration with the constructor without arguments,
00121 //     you can set a "Print Flag" by means of the following "Print Methods":
00122 //
00123 //     TEcnaRun* MyCnaRun = new TEcnaRun(); // declaration of the object MyCnaRun
00124 //
00125 //   // Print Methods: 
00126 //
00127 //    MyCnaRun->PrintNoComment();  // Set flag to forbid printing of all the comments
00128 //                                 // except ERRORS.
00129 //
00130 //    MyCnaRun->PrintWarnings();   // (DEFAULT)
00131 //                                 // Set flag to authorize printing of some warnings.
00132 //                                 // WARNING/INFO: information on something unusual
00133 //                                 // in the data.
00134 //                                 // WARNING/CORRECTION: something wrong (but not too serious)
00135 //                                 // in the value of some argument.
00136 //                                 // Automatically modified to a correct value.
00137 //
00138 //   MyCnaRun->PrintComments();    // Set flag to authorize printing of infos
00139 //                                 // and some comments concerning initialisations
00140 //
00141 //   MyCnaRun->PrintAllComments(); // Set flag to authorize printing of all the comments
00142 //
00143 //
00144 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00145 //
00146 //           Method GetReadyToReadData(...) and associated methods
00147 //
00148 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00149 //
00150 //      MyCnaRun->GetReadyToReadData(AnalysisName,      NbOfSamples, RunNumber,
00151 //                                   FirstReqEvtNumber, LastReqEvtNumber,  ReqNbOfEvts,
00152 //                                   StexNumber,        [RunType]);
00153 //
00154 //
00155 //   Explanations for the arguments (all of them are input arguments):
00156 //
00157 //      TString  AnalysisName: code for the analysis. This code is
00158 //                             necessary to distinguish between different
00159 //                             analyses on the same events of a same run
00160 //                             (example: pedestal run for the 3 gains:
00161 //                                       AnalysisName = "Ped1" or "Ped6" or "Ped12")
00162 //                             The string AnalysisName is automatically
00163 //                             included in the name of the results files
00164 //                             (see below: results files paragraph)
00165 //
00166 //      Int_t     NbOfSamples         number of samples (=10 maximum) 
00167 //      Int_t     RunNumber:          run number
00168 //      Int_t     FirstReqEvtNumber:  first requested event number (numbering starting from 1)
00169 //      Int_t     LastReqEvtNumber:   last  requested event number
00170 //      Int_t     StexNumber:         SM or Dee number (Stex = SM if EB, Dee if EE)
00171 //      
00172 //        The different quantities (correlations, etc...) will be calculated
00173 //        from the event numbered: FirstReqEvtNumber
00174 //        to the event numbered:   LastReqEvtNumber.
00175 //
00176 //      Int_t     RunType [optional]: run type
00177 //
00178 //                          PEDESTAL_STD = 9
00179 //                          LASER_STD    = 4
00180 //                          PEDESTAL_GAP = 18, etc...
00181 //      (see CMSSSW/DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h)
00182 //
00183 //      if RunType is specified, the run type will be displayed on the plots
00184 //
00185 //==============> Method to set the start and stop times of the analysis (optional)
00186 //
00187 //  A method can be used to set the fStartDate and fStopDate attributes
00188 //  of the class TEcnaHeader from start and stop time given by the user provided
00189 //  these values have been recovered from the event reading:
00190 //
00191 //      void  MyCnaRun->StartStopDate(TString StartDate, TString StopDate);
00192 // 
00193 //     // TString StartDate, StopDate:  start and stop time of the run
00194 //     //                               in "date" format. Example: 
00195 //     //                               Wed Oct  8 04:14:23 2003
00196 //
00197 //     If the method is not called, the values of the attributes
00198 //     fStartDate and fStopDate are set to: "!Start date> no info"
00199 //     and "!Stop date> no info" at the level of Init() method of the class TEcnaHeader.
00200 //     The values of StartDate and StopDate are written in the header of
00201 //     the .root result file.
00202 //
00203 //
00204 //  Another similar method exists, with time_t type arguments:
00205 //
00206 //     void  MyCnaRun->StartStopTime(time_t  StartTime, time_t  StopTime);
00207 //
00208 //
00209 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00210 //
00211 //                       Calculation methods
00212 //
00213 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
00214 //
00215 //    The "calculation methods" are methods which compute the different
00216 //    quantities of interest. 
00217 //
00218 //    List of the calculation methods:
00219 //
00220 
00221 //  //................... Calculation methods ( associated to GetReadyToReadData(...) )
00222 //  void SampleValues(); // 3D histo of the sample ADC value 
00223 //                       // for each triple (channel,sample,event)
00224 //  void SampleMeans();  // Calculation of the expectation values over the events
00225 //                       // for each sample and for each channel
00226 //  void SampleSigmas(); // Calculation of the sigmas over the events
00227 //                       // for each sample and for each channel
00228 //  //...........................................
00229 //  void CovariancesBetweenSamples();  // Calculation of the (s,s) covariances over the events
00230 //                                     // for each channel
00231 //  void CorrelationsBetweenSamples(); // Calculation of the (s,s) correlations over the events
00232 //                                     // for each channel
00233 //  //..........................................................
00234 //  void LowFrequencyCovariancesBetweenChannels();
00235 //  void HighFrequencyCovariancesBetweenChannels();
00236 //  void LowFrequencyCorrelationsBetweenChannels();
00237 //  void HighFrequencyCorrelationsBetweenChannels();
00238 //  //..........................................................
00239 //  void LowFrequencyMeanCorrelationsBetweenTowers();
00240 //  void HighFrequencyMeanCorrelationsBetweenTowers();
00241 //
00242 //  void LowFrequencyMeanCorrelationsBetweenSCs();
00243 //  void HighFrequencyMeanCorrelationsBetweenSCs();
00244 //
00245 // //.................................................... Quantities as a function of Xtals
00246 //  void Pedestals();
00247 //  void TotalNoise();
00248 //  void LowFrequencyNoise();
00249 //  void HighFrequencyNoise();
00250 //  void MeanOfCorrelationsBetweenSamples();
00251 //  void SigmaOfCorrelationsBetweenSamples();
00252 //
00253 //  //......................... Quantities as a function of tower (EB) or SC (EE), average over the Xtals
00254 //  void AveragedPedestals();
00255 //  void AveragedTotalNoise();
00256 //  void AveragedLowFrequencyNoise();
00257 //  void AveragedHighFrequencyNoise();
00258 //  void AveragedMeanOfCorrelationsBetweenSamples();
00259 //  void AveragedSigmaOfCorrelationsBetweenSamples();
00260 //
00261 //
00262 //==============> RESULTS FILES
00263 //
00264 //  The calculation methods above provide results which can be used directly
00265 //  in the user's code. However, these results can also be written in results
00266 //  files by appropriate methods.
00267 //  The names of the results files are automaticaly generated.
00268 //
00269 //  It is also possible to write results in ASCII files  => See TEcnaWrite and TEcnaGui
00270 //  It is also possible to plot results in ROOT canvases => See TEcnaHistos and TEcnaGui
00271 //                              
00272 //
00273 // *-----------> Codification for the name of the ROOT file:
00274 //
00275 //  The name of the ROOT file is the following:
00276 //
00277 //       aaa_S1_sss_Rrrr_fff_lll_SMnnn.root     for EB
00278 //       aaa_S1_sss_Rrrr_fff_lll_Deennn.root    for EE
00279 //
00280 //  with:
00281 //       aaa = Analysis name
00282 //       sss = number of samples
00283 //       rrr = Run number
00284 //       fff = First requested event number
00285 //       lll = Last  requested events
00286 //       mmm = Requested number of events
00287 //       nnn = SM number or Dee number
00288 //
00289 //  This name is automatically generated from the values of the arguments
00290 //  of the method "GetReadyToReadData".
00291 //
00292 // *-----------> Method which writes the result in the ROOT file:
00293 //
00294 //       Bool_t  MyCnaRun->WriteRootFile();
00295 //
00296 //===================================================================================================
00297 //
00298 //-------------------------------------------------------------------------
00299 //
00300 //        For more details on other classes of the CNA package:
00301 //
00302 //                 http://www.cern.ch/cms-fabbro/cna
00303 //
00304 //-------------------------------------------------------------------------
00305 
00306 //------------------------------ TEcnaRun.cc ------------------------------
00307 //  
00308 //   Creation (first version): 03 Dec 2002
00309 //
00310 //   For questions or comments, please send e-mail to Bernard Fabbro:
00311 //             
00312 //   fabbro@hep.saclay.cea.fr 
00313 //
00314 //------------------------------------------------------------------------
00315 
00316 TEcnaRun::TEcnaRun()
00317 {
00318 //Constructor without argument: nothing special done
00319 
00320  // cout << "[Info Management] CLASS: TEcnaRun.           CREATE OBJECT: this = " << this << endl;
00321 }
00322 
00323 TEcnaRun::TEcnaRun(const TString SubDet)
00324 {
00325 //Constructor with argument: call to Init() and declare fEcal according to SubDet value ("EB" or "EE")
00326 
00327  // cout << "[Info Management] CLASS: TEcnaRun.           CREATE OBJECT: this = " << this << endl;
00328 
00329   Init();
00330   SetEcalSubDetector(SubDet.Data());
00331   fNbSampForFic = fEcal->MaxSampADC(); // DEFAULT Number of samples for ROOT file
00332 }
00333 
00334 TEcnaRun::TEcnaRun(const TString SubDet, const Int_t& NbOfSamples)
00335 {
00336 //Constructor with arguments: call to Init(), declare fEcal according to SubDet value ("EB" or "EE")
00337 // and set NbOfSamples according to the user's willing
00338 
00339  // cout << "[Info Management] CLASS: TEcnaRun.           CREATE OBJECT: this = " << this << endl;
00340 
00341   Init();
00342   SetEcalSubDetector(SubDet.Data());
00343   if( NbOfSamples>0 && NbOfSamples<=fEcal->MaxSampADC() )
00344     {
00345       fNbSampForFic = NbOfSamples;
00346     }
00347   else
00348     {
00349       cout << "TEcnaRun/CONSTRUCTOR> Number of required samples = " << NbOfSamples
00350            << ": OUT OF RANGE. Set to the default value (= " << fEcal->MaxSampADC() << ")."
00351            << fTTBELL << endl;
00352       fNbSampForFic = fEcal->MaxSampADC(); // DEFAULT Number of samples for file reading
00353     }
00354 }
00355 
00356 void TEcnaRun::Init()
00357 {
00358 //Initialisation
00359 
00360   fCnew       = 0;
00361   fCdelete    = 0;
00362   fCnaCommand = 0;
00363   fCnaError   = 0;
00364 
00365   fTTBELL = '\007';
00366 
00367   //........................... TString file names init
00368   fgMaxCar  = (Int_t)512;
00369 
00370   //................ MiscDiag counters .................
00371   fMaxMsgIndexForMiscDiag = (Int_t)10;
00372   fNbOfMiscDiagCounters   = (Int_t)50;
00373   fMiscDiag = 0;
00374 
00375   fNumberOfEvents = 0;
00376   //............................. init pointers  ( Init() )
00377   fT3d_distribs  = 0;
00378   fT3d2_distribs = 0;
00379   fT3d1_distribs = 0;
00380 
00381   fT1d_StexStinFromIndex = 0;
00382 
00383   fT2d_NbOfEvts = 0;
00384   fT1d_NbOfEvts = 0; 
00385 
00386   fT2d_ev        = 0;
00387   fT1d_ev        = 0;
00388   fT2d_sig       = 0;
00389   fT1d_sig       = 0;
00390 
00391   fT3d_cov_ss    = 0;
00392   fT3d2_cov_ss   = 0;
00393   fT3d1_cov_ss   = 0;
00394 
00395   fT3d_cor_ss    = 0;
00396   fT3d2_cor_ss   = 0;
00397   fT3d1_cor_ss   = 0;
00398 
00399   fT2d_lf_cov  = 0;
00400   fT2d1_lf_cov = 0;
00401 
00402   fT2d_lf_cor  = 0;
00403   fT2d1_lf_cor = 0;
00404 
00405   fT2d_hf_cov  = 0;
00406   fT2d1_hf_cov = 0;
00407 
00408   fT2d_hf_cor  = 0;
00409   fT2d1_hf_cor = 0;
00410 
00411   fT2d_lfcc_mostins  = 0;
00412   fT2d1_lfcc_mostins = 0;
00413 
00414   fT2d_hfcc_mostins  = 0;
00415   fT2d1_hfcc_mostins = 0;
00416 
00417   fT1d_ev_ev            = 0;
00418   fT1d_evsamp_of_sigevt = 0;
00419   fT1d_ev_cor_ss        = 0;
00420   fT1d_av_mped          = 0;
00421   fT1d_av_totn          = 0;
00422   fT1d_av_lofn          = 0;
00423   fT1d_av_hifn          = 0;
00424   fT1d_av_ev_corss      = 0;
00425   fT1d_av_sig_corss     = 0;
00426 
00427   fT1d_sigevt_of_evsamp = 0;
00428   fT1d_evevt_of_sigsamp = 0;
00429   fT1d_sig_cor_ss       = 0;
00430 
00431   fT2dCrysNumbersTable = 0;
00432   fT1dCrysNumbersTable = 0;
00433 
00434   //................................ tags   ( Init() )
00435   fTagStinNumbers = 0;
00436 
00437   fTagNbOfEvts = 0;
00438 
00439   fTagAdcEvt = 0;
00440 
00441   fTagMSp       = 0;
00442   fTagSSp      = 0;
00443 
00444   fTagCovCss   = 0;
00445   fTagCorCss   = 0;
00446 
00447   fTagHfCov    = 0;
00448   fTagHfCor    = 0;
00449   fTagLfCov    = 0;
00450   fTagLfCor    = 0;
00451 
00452   fTagLFccMoStins = 0;
00453   fTagHFccMoStins = 0;
00454 
00455   fTagPed     = 0;
00456   fTagTno    = 0;
00457   fTagMeanCorss  = 0;
00458 
00459   fTagLfn    = 0;
00460   fTagHfn   = 0;
00461   fTagSigCorss = 0;
00462 
00463   fTagAvPed = 0;
00464   fTagAvTno = 0;
00465   fTagAvLfn = 0;
00466   fTagAvHfn = 0;
00467 
00468   fTagAvMeanCorss  = 0;
00469   fTagAvSigCorss = 0;
00470 
00471   //................................................... Code Print  ( Init() )
00472   fFlagPrint = fCodePrintWarnings;
00473   fCnaParCout = 0; fCnaParCout = new TEcnaParCout();    //fCnew++;
00474   fCodePrintNoComment   = fCnaParCout->GetCodePrint("NoComment");
00475   fCodePrintWarnings    = fCnaParCout->GetCodePrint("Warnings ");      // => default value
00476   fCodePrintComments    = fCnaParCout->GetCodePrint("Comments");
00477   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
00478 
00479   //................................................... Paths
00480   fCnaParPaths = 0; fCnaParPaths = new TEcnaParPaths();  //fCnew++;
00481   fOpenRootFile = kFALSE;
00482   
00483   fReadyToReadData = 0;
00484 
00485   //.............................................. Miscellaneous
00486   fFileHeader = 0;
00487   const Text_t *h_name  = "CnaHeader";   //==> voir cette question avec FXG
00488   const Text_t *h_title = "CnaHeader";   //==> voir cette question avec FXG
00489   fFileHeader = new TEcnaHeader(h_name, h_title);     //fCnew++;
00490 
00491   fSpecialStexStinNotIndexed = -1;
00492 
00493   fStinIndexBuilt     = 0;
00494   fBuildEvtNotSkipped = 0;
00495 }// end of Init()
00496 
00497 //========================================================================
00498 void  TEcnaRun::SetEcalSubDetector(const TString SubDet)
00499 {
00500  // Set Subdetector (EB or EE)
00501 
00502   Int_t MaxCar = fgMaxCar;
00503   fFlagSubDet.Resize(MaxCar);
00504   fFlagSubDet = SubDet.Data();
00505 
00506   fEcal          = 0; fEcal          = new TEcnaParEcal(fFlagSubDet.Data());           //fCnew++;
00507   fEcalNumbering = 0; fEcalNumbering = new TEcnaNumbering(fFlagSubDet.Data(), fEcal);  //fCnew++;
00508   fCnaWrite      = 0;
00509   fCnaWrite =
00510     new TEcnaWrite(fFlagSubDet.Data(), fCnaParPaths, fCnaParCout, fEcal, fEcalNumbering); //fCnew++;
00511 
00512   if( fFlagSubDet == "EB" ){fStexName = "SM "; fStinName = "tower";}
00513   if( fFlagSubDet == "EE" ){fStexName = "Dee"; fStinName = " SC  ";}
00514 }
00515 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00516 //
00517 //                    copy constructor
00518 //
00519 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00520 
00521 TEcnaRun::TEcnaRun(const TEcnaRun& dcop)
00522 {
00523   cout << "*TEcnaRun::TEcnaRun(const TEcnaRun& dcop)> "
00524        << " Now is the time to write a copy constructor" 
00525        << endl;
00526   
00527   //{ Int_t cintoto;  cin >> cintoto; }
00528   
00529 }
00530 
00531 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00532 //
00533 //                    overloading of the operator=
00534 //
00535 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00536 
00537 //TEcnaRun& TEcnaRun::operator=(const TEcnaRun& dcop)
00538 //{
00539 //Overloading of the operator=
00540 //
00541 //  fCopy(dcop);
00542 //  return *this;
00543 //}
00544 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00545 //
00546 //                            destructor
00547 //
00548 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00549 
00550 TEcnaRun::~TEcnaRun()
00551 {
00552   //Destructor
00553   
00554   if(fFlagPrint == fCodePrintAllComments)
00555     {
00556       cout << "*TEcnaRun::~TEcnaRun()> Entering destructor." << endl;
00557     }
00558 
00559   if(fFlagPrint != fCodePrintNoComment || fFlagPrint == fCodePrintWarnings )
00560     {
00561       if( fBuildEvtNotSkipped > 0 )
00562         {
00563           cout << "************************************************************************************* "
00564                << endl;
00565           cout << "*TEcnaRun::~TEcnaRun()> Nb of calls to BuildEventsDistributions by cmsRun: "
00566                << fBuildEvtNotSkipped << endl;
00567           cout << "************************************************************************************* "
00568                << endl;
00569         }
00570     }
00571 
00572   if(fFlagPrint == fCodePrintAllComments)
00573     {
00574       Int_t misc_czero = 0;
00575       for(Int_t i = 0; i < fNbOfMiscDiagCounters; i++)
00576         {
00577           if( fMiscDiag[i] != 0 )
00578             {
00579               cout << "                          fMiscDiag Counter "
00580                    << setw(3) << i << " = " << setw(9) << fMiscDiag[i]
00581                    << " (INFO: alloc on non zero freed zone) " << endl;
00582             }
00583           else
00584             {
00585               misc_czero++;
00586             }
00587         }
00588       cout << "                          Nb of fMiscDiag counters at zero: "
00589            << misc_czero << " (total nb of counters: "
00590            << fNbOfMiscDiagCounters << ")" << endl;
00591     }
00592   
00593   if (fMiscDiag                != 0){delete [] fMiscDiag;                 fCdelete++;}
00594   
00595   //if (fFileHeader              != 0){delete fFileHeader;                  fCdelete++;}
00596   //if (fEcal                    != 0){delete fEcal;                        fCdelete++;}
00597   //if (fEcalNumbering           != 0){delete fEcalNumbering;               fCdelete++;}
00598   //if (fCnaParCout              != 0){delete fCnaParCout;                  fCdelete++;}
00599   //if (fCnaParPaths             != 0){delete fCnaParPaths;                 fCdelete++;}
00600   //if (fCnaWrite                != 0){delete fCnaWrite;                    fCdelete++;}
00601   
00602   if (fT1d_StexStinFromIndex   != 0){delete [] fT1d_StexStinFromIndex;    fCdelete++;}
00603 
00604   if (fT2d_NbOfEvts        != 0){delete [] fT2d_NbOfEvts;         fCdelete++;}
00605   if (fT1d_NbOfEvts        != 0){delete [] fT1d_NbOfEvts;         fCdelete++;}
00606 
00607   if (fT3d_distribs        != 0){delete [] fT3d_distribs;         fCdelete++;}
00608   if (fT3d2_distribs       != 0){delete [] fT3d2_distribs;        fCdelete++;}
00609   if (fT3d1_distribs       != 0){delete [] fT3d1_distribs;        fCdelete++;}
00610 
00611   if (fT2d_ev              != 0){delete [] fT2d_ev;               fCdelete++;}
00612   if (fT1d_ev              != 0){delete [] fT1d_ev;               fCdelete++;}
00613 
00614   if (fT2d_sig             != 0){delete [] fT2d_sig;              fCdelete++;}
00615   if (fT1d_sig             != 0){delete [] fT1d_sig;              fCdelete++;}
00616 
00617   if (fT3d_cov_ss          != 0){delete [] fT3d_cov_ss;           fCdelete++;}
00618   if (fT3d2_cov_ss         != 0){delete [] fT3d2_cov_ss;          fCdelete++;}
00619   if (fT3d1_cov_ss         != 0){delete [] fT3d1_cov_ss;          fCdelete++;}
00620 
00621   if (fT3d_cor_ss          != 0){delete [] fT3d_cor_ss;           fCdelete++;}
00622   if (fT3d2_cor_ss         != 0){delete [] fT3d2_cor_ss;          fCdelete++;}
00623   if (fT3d1_cor_ss         != 0){delete [] fT3d1_cor_ss;          fCdelete++;}
00624 
00625   if (fT2d_lf_cov          != 0){delete [] fT2d_lf_cov;           fCdelete++;}
00626   if (fT2d1_lf_cov         != 0){delete [] fT2d1_lf_cov;          fCdelete++;}
00627 
00628   if (fT2d_lf_cor          != 0){delete [] fT2d_lf_cor;           fCdelete++;}
00629   if (fT2d1_lf_cor         != 0){delete [] fT2d1_lf_cor;          fCdelete++;}
00630 
00631   if (fT2d_hf_cov          != 0){delete [] fT2d_hf_cov;           fCdelete++;}
00632   if (fT2d1_hf_cov         != 0){delete [] fT2d1_hf_cov;          fCdelete++;}
00633 
00634   if (fT2d_hf_cor          != 0){delete [] fT2d_hf_cor;           fCdelete++;}
00635   if (fT2d1_hf_cor         != 0){delete [] fT2d1_hf_cor;          fCdelete++;}
00636 
00637   if (fT2d_lfcc_mostins    != 0){delete [] fT2d_lfcc_mostins;     fCdelete++;}
00638   if (fT2d1_lfcc_mostins   != 0){delete [] fT2d1_lfcc_mostins ;   fCdelete++;}
00639 
00640   if (fT2d_hfcc_mostins    != 0){delete [] fT2d_hfcc_mostins ;    fCdelete++;}
00641   if (fT2d1_hfcc_mostins   != 0){delete [] fT2d1_hfcc_mostins;    fCdelete++;}
00642 
00643   if (fT1d_ev_ev             != 0){delete [] fT1d_ev_ev;              fCdelete++;}
00644   if (fT1d_evsamp_of_sigevt  != 0){delete [] fT1d_evsamp_of_sigevt;   fCdelete++;}
00645   if (fT1d_ev_cor_ss         != 0){delete [] fT1d_ev_cor_ss;          fCdelete++;}
00646   if (fT1d_av_mped           != 0){delete [] fT1d_av_mped;            fCdelete++;}
00647   if (fT1d_av_totn           != 0){delete [] fT1d_av_totn;            fCdelete++;}
00648   if (fT1d_av_lofn           != 0){delete [] fT1d_av_lofn;            fCdelete++;}
00649   if (fT1d_av_hifn           != 0){delete [] fT1d_av_hifn;            fCdelete++;}
00650   if (fT1d_av_ev_corss       != 0){delete [] fT1d_av_ev_corss;        fCdelete++;}
00651   if (fT1d_av_sig_corss      != 0){delete [] fT1d_av_sig_corss;       fCdelete++;}
00652 
00653   if (fT1d_sigevt_of_evsamp    != 0){delete [] fT1d_sigevt_of_evsamp;     fCdelete++;}
00654   if (fT1d_evevt_of_sigsamp    != 0){delete [] fT1d_evevt_of_sigsamp;     fCdelete++;}
00655   if (fT1d_sig_cor_ss          != 0){delete [] fT1d_sig_cor_ss;           fCdelete++;}
00656 
00657   if (fT2dCrysNumbersTable     != 0){delete [] fT2dCrysNumbersTable;      fCdelete++;}
00658   if (fT1dCrysNumbersTable     != 0){delete [] fT1dCrysNumbersTable;      fCdelete++;}
00659 
00660   if (fTagStinNumbers          != 0){delete [] fTagStinNumbers;           fCdelete++;}
00661   if (fTagNbOfEvts             != 0){delete [] fTagNbOfEvts;              fCdelete++;}
00662   if (fTagAdcEvt               != 0){delete [] fTagAdcEvt;                fCdelete++;}
00663   if (fTagMSp                  != 0){delete [] fTagMSp;                   fCdelete++;}
00664   if (fTagSSp                  != 0){delete [] fTagSSp;                   fCdelete++;}
00665 
00666   if (fTagCovCss               != 0){delete [] fTagCovCss;                fCdelete++;}
00667   if (fTagCorCss               != 0){delete [] fTagCorCss;                fCdelete++;}
00668 
00669   if (fTagHfCov                != 0){delete [] fTagHfCov;                 fCdelete++;}
00670   if (fTagHfCor                != 0){delete [] fTagHfCor;                 fCdelete++;}
00671   if (fTagLfCov                != 0){delete [] fTagLfCov;                 fCdelete++;}
00672   if (fTagLfCor                != 0){delete [] fTagLfCor;                 fCdelete++;}
00673 
00674   if (fTagLFccMoStins          != 0){delete [] fTagLFccMoStins;           fCdelete++;}
00675   if (fTagHFccMoStins          != 0){delete [] fTagHFccMoStins;           fCdelete++;}
00676 
00677   if (fTagPed                 != 0){delete [] fTagPed;                  fCdelete++;}
00678   if (fTagTno                 != 0){delete [] fTagTno;                  fCdelete++;}
00679   if (fTagMeanCorss           != 0){delete [] fTagMeanCorss;            fCdelete++;}
00680 
00681   if (fTagLfn                != 0){delete [] fTagLfn;                 fCdelete++;}
00682   if (fTagHfn                != 0){delete [] fTagHfn;                 fCdelete++;}
00683   if (fTagSigCorss           != 0){delete [] fTagSigCorss;            fCdelete++;}
00684 
00685   if (fTagAvPed          != 0){delete [] fTagAvPed;           fCdelete++;}
00686   if (fTagAvTno          != 0){delete [] fTagAvTno;           fCdelete++;}
00687   if (fTagAvLfn          != 0){delete [] fTagAvLfn;           fCdelete++;}
00688   if (fTagAvHfn          != 0){delete [] fTagAvHfn;           fCdelete++;}
00689   if (fTagAvMeanCorss    != 0){delete [] fTagAvMeanCorss;     fCdelete++;}
00690   if (fTagAvSigCorss     != 0){delete [] fTagAvSigCorss;      fCdelete++;}
00691 
00692   if ( fCnew != fCdelete )
00693     {
00694       cout << "!TEcnaRun::~TEcnaRun()> WRONG MANAGEMENT OF MEMORY ALLOCATIONS: fCnew = "
00695            << fCnew << ", fCdelete = " << fCdelete << fTTBELL << endl;
00696     }
00697   else
00698     {
00699       // cout << "*TEcnaRun::~TEcnaRun()> Management of memory allocations: OK. fCnew = "
00700       //   << fCnew << ", fCdelete = " << fCdelete << endl;
00701     }
00702 
00703   if(fFlagPrint == fCodePrintAllComments)
00704     {
00705       cout << "*TEcnaRun::~TEcnaRun()> Exiting destructor (this = " << this << ")." << endl
00706            << "~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#"
00707            << endl;
00708     }
00709 
00710  // cout << "[Info Management] CLASS: TEcnaRun.           DESTROY OBJECT: this = " << this << endl;
00711 }
00712 
00713 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00714 //
00715 //                             M  E  T  H  O  D  S
00716 //
00717 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00718 
00719 //============================================================================
00720 //
00721 //                           GetReadyToReadData(...)
00722 //                  
00723 //  Preparation of the result file name + tags allocations
00724 //  + ADC event distribution array allocation + nb of events array allocation
00725 //
00726 //============================================================================
00727 
00728 void TEcnaRun::GetReadyToReadData(TString      typ_ana, const Int_t& run_number,
00729                                  const Int_t& nfirst,  const Int_t& nlast, const Int_t& nbevts,
00730                                  const Int_t& Stex)
00731 {
00732 //Preparation of the data reading. Set part of the header. No RunType as argument.
00733 //Use default value = 99999999 and call method with all the arguments (see below)
00734 
00735   Int_t RunType = 99999999;
00736   GetReadyToReadData(typ_ana, run_number, nfirst, nlast, nbevts, Stex, RunType);
00737 }
00738 //--------------------------------------------------------------------------------
00739 void TEcnaRun::GetReadyToReadData( TString       typ_ana, const Int_t& run_number,
00740                                    const Int_t&  nfirst,  const Int_t& nlast, const Int_t& nbevts,
00741                                    const Int_t&  Stex,    const Int_t& run_type)
00742 {
00743 //Preparation of the data reading. Set part of the header
00744 //
00745 //   [nfirst, nlast] = [1,50] (50 events) or [151,300] (150 events) or etc...
00746 
00747   Int_t nrangeevts = nlast - nfirst + 1;  // number of events in range
00748 
00749   if( nrangeevts < nbevts )
00750     {
00751       if( nlast >= nfirst )
00752         {
00753           cout << "*TEcnaRun::GetReadyToReadData(...)> --- WARNING ---> number of events = " << nbevts
00754                << ", out of range (range = " << nfirst << "," << nlast << ")" << endl
00755                << "                                    The number of found events will be less " << endl
00756                << "                                    than the number of requested events." << endl;
00757         }
00758       if( nlast < nfirst )
00759         {
00760           cout << "*TEcnaRun::GetReadyToReadData(...)> --- INFO ---> last requested event number = " << nlast
00761                << ", less than first requested event number (= " << nfirst << ")" << endl
00762                << "                                    File will be read until EOF if the number of found events" << endl
00763                << "                                    remains less than the number of requested events." << endl;
00764         }
00765 
00766     }
00767   
00768   Int_t ifirst  = nfirst - 1;
00769 
00770   //............. allocation for counters
00771   fMiscDiag = new Int_t[fNbOfMiscDiagCounters];       fCnew++;
00772   for (Int_t iz=0; iz<fNbOfMiscDiagCounters; iz++){fMiscDiag[iz] = (Int_t)0;}
00773 
00774   //************** CHECK OF ARGUMENTS: nfirst_arg and nbevts_arg
00775   Int_t nentries = 99999999;   // => to be reintroduced as argument (like run_type) (?)
00776   if ( nfirst <= nentries )
00777     {
00778       //--------------------- test positivity of nfirst_arg        (GetReadyToReadData)
00779       if ( nfirst > 0 )
00780         {
00781           //-------- test compatibility between the last requested event number
00782           //         and the number of entries
00783           if( nlast <= nentries )
00784             { 
00785               const Text_t *h_name  = "CnaHeader";   //==> voir cette question avec FXG
00786               const Text_t *h_title = "CnaHeader";   //==> voir cette question avec FXG
00787               //fFileHeader->HeaderParameters(h_name,     h_title ,
00788               //                              typ_ana,    fNbSampForFic,
00789               //                              run_number, nfirst,  nlast,  nbevts,
00790               //                              Stex,       nentries);                 fCnew++;
00791 
00792               if ( fEcal->MaxStinEcnaInStex() > 0  &&  fEcal->MaxCrysInStin() > 0  &&  fNbSampForFic > 0 ) 
00793                 {
00794                   if( fFileHeader == 0 ){fFileHeader = new TEcnaHeader(h_name, h_title);}     // fCnew++;
00795                   
00796                   fFileHeader->HeaderParameters(typ_ana,    fNbSampForFic,
00797                                                 run_number, nfirst, nlast, nbevts,
00798                                                 Stex,       run_type);
00799 
00800                   // After this call to TEcnaHeader, we have:               (GetReadyToReadData)
00801                   //     fFileHeader->fTypAna            = typ_ana
00802                   //     fFileHeader->fNbOfSamples       = fNbSampForFic
00803                   //     fFileHeader->fRunNumber         = run_number
00804                   //     fFileHeader->fFirstReqEvtNumber = nfirst
00805                   //     fFileHeader->fLastReqEvtNumber  = nlast
00806                   //     fFileHeader->fReqNbOfEvts       = nbevts
00807                   //     fFileHeader->fStex              = Stex number
00808                   //     fFileHeader->fRunType           = run_type
00809                   
00810                   // fFileHeader->Print();
00811                   
00812                   // {Int_t cintoto; cout << "taper 0 pour continuer" << endl; cin >> cintoto;}
00813                   
00814                   //  fFileHeader->SetName("CnaHeader");              *======> voir FXG
00815                   //  fFileHeader->SetTitle("CnaHeader");
00816                   
00817                   //......................................... allocation tags + init of them (GetReadyToReadData)
00818                   
00819                   fTagStinNumbers = new Int_t[1]; fCnew++; fTagStinNumbers[0] = (Int_t)0;
00820                   fTagNbOfEvts    = new Int_t[1]; fCnew++; fTagNbOfEvts[0]    = (Int_t)0;
00821                   
00822                   fTagAdcEvt      = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
00823                   for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagAdcEvt[iz] = (Int_t)0;}
00824                   
00825                   fTagMSp         = new Int_t[1]; fCnew++; fTagMSp[0] = (Int_t)0;
00826                   fTagSSp         = new Int_t[1]; fCnew++; fTagSSp[0] = (Int_t)0;
00827                   
00828                   fTagCovCss      = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
00829                   for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagCovCss[iz] = (Int_t)0;}
00830                   
00831                   fTagCorCss      = new Int_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;
00832                   for (Int_t iz=0; iz<fEcal->MaxCrysEcnaInStex(); iz++){fTagCorCss[iz] = (Int_t)0;}
00833                   
00834                   fTagLfCov       = new Int_t[1]; fCnew++; fTagLfCov[0] = (Int_t)0;
00835                   fTagLfCor       = new Int_t[1]; fCnew++; fTagLfCor[0] = (Int_t)0;
00836                   
00837                   fTagHfCov       = new Int_t[1]; fCnew++; fTagHfCov[0] = (Int_t)0;
00838                   fTagHfCor       = new Int_t[1]; fCnew++; fTagHfCor[0] = (Int_t)0;
00839                   
00840                   fTagLFccMoStins = new Int_t[1]; fCnew++; fTagLFccMoStins[0] = (Int_t)0;
00841                   fTagHFccMoStins = new Int_t[1]; fCnew++; fTagHFccMoStins[0] = (Int_t)0;
00842                   
00843                   fTagPed         = new Int_t[1]; fCnew++; fTagPed[0]         = (Int_t)0;
00844                   fTagTno         = new Int_t[1]; fCnew++; fTagTno[0]         = (Int_t)0;
00845                   fTagMeanCorss   = new Int_t[1]; fCnew++; fTagMeanCorss[0]   = (Int_t)0; 
00846                   
00847                   fTagLfn         = new Int_t[1]; fCnew++; fTagLfn[0]         = (Int_t)0; 
00848                   fTagHfn         = new Int_t[1]; fCnew++; fTagHfn[0]         = (Int_t)0; 
00849                   fTagSigCorss    = new Int_t[1]; fCnew++; fTagSigCorss[0]    = (Int_t)0; 
00850                   
00851                   fTagAvPed       = new Int_t[1]; fCnew++; fTagAvPed[0]       = (Int_t)0; 
00852                   fTagAvTno       = new Int_t[1]; fCnew++; fTagAvTno[0]       = (Int_t)0; 
00853                   fTagAvLfn       = new Int_t[1]; fCnew++; fTagAvLfn[0]       = (Int_t)0; 
00854                   fTagAvHfn       = new Int_t[1]; fCnew++; fTagAvHfn[0]       = (Int_t)0; 
00855                   fTagAvMeanCorss = new Int_t[1]; fCnew++; fTagAvMeanCorss[0] = (Int_t)0; 
00856                   fTagAvSigCorss  = new Int_t[1]; fCnew++; fTagAvSigCorss[0]  = (Int_t)0; 
00857                   
00858                   //====================================================================================
00859                   //
00860                   //   allocation for fT1d_StexStinFromIndex[] and init to fSpecialStexStinNotIndexed
00861                   //
00862                   //====================================================================================
00863                   
00864                   if(fT1d_StexStinFromIndex == 0)
00865                     {
00866                       fT1d_StexStinFromIndex = new Int_t[fEcal->MaxStinEcnaInStex()];          fCnew++;
00867                     }
00868                   for ( Int_t i0_Stin = 0; i0_Stin < fEcal->MaxStinEcnaInStex(); i0_Stin++ )
00869                     {
00870                       fT1d_StexStinFromIndex[i0_Stin] = fSpecialStexStinNotIndexed;
00871                     }
00872                   
00873                   //-------------------------------------------------------------  (GetReadyToReadData)
00874           
00875                   //====================================================================================
00876                   //
00877                   //   allocation of the 3D array fT3d_distribs[channel][sample][events] (ADC values)
00878                   //
00879                   //   This array is filled in the BuildEventDistributions(...) method
00880                   //
00881                   //====================================================================================
00882                   
00883                   if(fT3d_distribs == 0)
00884                     {
00885                       //............ Allocation for the 3d array 
00886                       cout << "*TEcnaRun::GetReadyToReadData(...)> Allocation of 3D array for ADC distributions."
00887                            << " Nb of requested evts = " << fFileHeader->fReqNbOfEvts << endl
00888                            << "                                    This number must not be too large"
00889                            << " (no failure after this message means alloc OK)." << endl;
00890 
00891                       fT3d_distribs = new Double_t**[fEcal->MaxCrysEcnaInStex()];        fCnew++;  
00892 
00893                       fT3d2_distribs  =
00894                         new  Double_t*[fEcal->MaxCrysEcnaInStex()*
00895                                        fNbSampForFic];                          fCnew++;  
00896 
00897                       fT3d1_distribs  =
00898                         new   Double_t[fEcal->MaxCrysEcnaInStex()*
00899                                        fNbSampForFic*
00900                                        fFileHeader->fReqNbOfEvts];                       fCnew++;
00901 
00902                       for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++){
00903                         fT3d_distribs[i0StexEcha] = &fT3d2_distribs[0] + i0StexEcha*fNbSampForFic;
00904                         for(Int_t j0Sample=0; j0Sample<fNbSampForFic; j0Sample++){
00905                           fT3d2_distribs[fNbSampForFic*i0StexEcha + j0Sample] = &fT3d1_distribs[0]+
00906                             fFileHeader->fReqNbOfEvts*(fNbSampForFic*i0StexEcha+j0Sample);}}
00907                     }
00908 
00909                   //................................. Init to zero
00910                   for (Int_t iza=0; iza<fEcal->MaxCrysEcnaInStex(); iza++)
00911                     {
00912                       for (Int_t izb=0; izb<fNbSampForFic; izb++)
00913                         {
00914                           for (Int_t izc=0; izc<fFileHeader->fReqNbOfEvts; izc++)
00915                             {
00916                               if( fT3d_distribs[iza][izb][izc] != (Double_t)0 )
00917                                 {
00918                                   fMiscDiag[0]++;
00919                                   fT3d_distribs[iza][izb][izc] = (Double_t)0;
00920                                 }
00921                             }
00922                         }
00923                     }
00924 
00925                   //--------------------------------------------------------- (GetReadyToReadData)        
00926                   //====================================================================================
00927                   //
00928                   //   allocation of the 2D array fT2d_NbOfEvts[channel][sample] (Max nb of evts)
00929                   //
00930                   //====================================================================================
00931                   
00932                   if (fT2d_NbOfEvts == 0)
00933                     {
00934                       fT2d_NbOfEvts  = new Int_t*[fEcal->MaxCrysEcnaInStex()];           fCnew++;
00935                       fT1d_NbOfEvts  = new  Int_t[fEcal->MaxCrysEcnaInStex()*
00936                                                       fNbSampForFic];            fCnew++;
00937                       
00938                       for(Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
00939                         {
00940                           fT2d_NbOfEvts[i0StexEcha] =
00941                             &fT1d_NbOfEvts[0] + i0StexEcha*fNbSampForFic;
00942                         }
00943                       
00944                       //................ Init the array to 0
00945                       for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
00946                         {
00947                           for(Int_t i0Sample=0; i0Sample<fNbSampForFic; i0Sample++)
00948                             {
00949                               fT2d_NbOfEvts[i0StexEcha][i0Sample] = 0;
00950                             }
00951                         }
00952                     }
00953                   else
00954                     {
00955                       cerr << "!TEcnaRun::GetReadyToReadData(...)> *** ERROR *** No allocation for fT2d_NbOfEvts!"
00956                            << " Pointer already not NULL " << fTTBELL << endl;
00957                       // {Int_t cintoto; cout << "Enter: 0 and RETURN to continue or: CTRL C to exit"
00958                       //                   << endl; cin >> cintoto;}
00959                     }
00960                 }
00961               else
00962                 {
00963                   cerr << endl
00964                        << "!TEcnaRun::GetReadyToReadData(...)> "
00965                        << " *** ERROR *** " << endl
00966                        << " --------------------------------------------------"
00967                        << endl
00968                        << " NULL or NEGATIVE values for arguments" << endl
00969                        << " with expected positive values:"        << endl
00970                        << " Number of Stins in Stex = " << fEcal->MaxStinEcnaInStex()  << endl
00971                        << " Number of crystals in Stin     = " << fEcal->MaxCrysInStin() << endl
00972                        << " Number of samples by channel    = " << fNbSampForFic << endl
00973                        << endl
00974                        << endl
00975                        << " hence, no memory allocation for array member has been performed." << endl;
00976                   
00977                   cout << "Enter: 0 and RETURN to continue or: CTRL C to exit";
00978                   Int_t toto;
00979                   cin >> toto;
00980                 }
00981               //----------------------------------------------------------- (GetReadyToReadData)
00982               if(fFlagPrint == fCodePrintAllComments ){
00983                 cout << endl;
00984                 cout << "*TEcnaRun::GetReadyToReadData(...)>" << endl
00985                      << "          The method has been called with the following argument values:"  << endl
00986                      << "          Analysis name                = "
00987                      << fFileHeader->fTypAna << endl
00988                      << "          Run number                   = "
00989                      << fFileHeader->fRunNumber << endl
00990                      << "          Run type                     = "
00991                      << fFileHeader->fRunType << endl
00992                      << "          First requested event number = "
00993                      << fFileHeader->fFirstReqEvtNumber << endl
00994                      << "          Last requested event number  = "
00995                      << fFileHeader->fLastReqEvtNumber << endl
00996                      << "          " << fStexName.Data() << " number             = "
00997                      << fFileHeader->fStex << endl
00998                      << "          Number of " << fStinName.Data()
00999                      << " in " << fStexName.Data() << "       = "
01000                      << fEcal->MaxStinEcnaInStex()  << endl
01001                      << "          Number of crystals in " << fStinName.Data() << "  = "
01002                      << fEcal->MaxCrysInStin()  << endl
01003                      << "          Number of samples by channel = "
01004                      << fNbSampForFic  << endl
01005                      << endl;}
01006               
01007               fReadyToReadData = 1;                        // set flag
01008             }
01009           else
01010             {
01011               if (fFlagPrint != fCodePrintNoComment){
01012                 cout << "!TEcnaRun::GetReadyToReadData(...) > WARNING/CORRECTION:" << endl
01013                      << "! The fisrt requested event number is not positive (nfirst = " << nfirst << ") "
01014                      << fTTBELL << endl;}
01015               ifirst = 0;
01016             }
01017         }
01018       else
01019         {
01020           if (fFlagPrint != fCodePrintNoComment){
01021             cout << endl << "!TEcnaRun::GetReadyToReadData(...)> WARNING/CORRECTION:" << endl
01022                  << "! The number of requested events (nbevts = " << nbevts << ") is too large." << endl
01023                  << "! Last event number = " << nlast << " > number of entries = " << nentries << ". "
01024                  << fTTBELL << endl << endl;}
01025         }
01026     }
01027   else
01028     {
01029       cout << "!TEcnaRun::GetReadyToReadData(...) *** ERROR ***> "
01030            << " The first requested event number is greater than the number of entries."
01031            << fTTBELL << endl;
01032     }
01033   if(fFlagPrint == fCodePrintAllComments){
01034     cout << "*TEcnaRun::GetReadyToReadData(...)> Leaving the method. fReadyToReadData = "
01035          << fReadyToReadData << endl; }
01036 
01037 } // end of GetReadyToReadData
01038 
01039 //====================================================================================================
01040 //
01041 //     BuildEventDistributions: method called by the CMSSW analyzer (cmsRun)
01042 //
01043 //     At each event, put the Sample ADC value in the 3D array: fT3d_distribs[i0StexEcha][i0Sample][i0EventIndex]
01044 //
01045 //         |============================================================|
01046 //         |                                                            |
01047 //         | (Stex,Stin) means: (SM,tower) for EB and: (Dee,SC) for EE  |
01048 //         |                                                            |
01049 //         |============================================================|
01050 //
01051 //    (Stin number <-> Stin index correspondance, ADC sample values)
01052 //
01053 //        THIS METHOD IS CALLED INSIDE THE LOOPS OVER:
01054 //          ( EVENTS (tower or SC (CRYSTAL in tower or SC (SAMPLES)))) 
01055 //
01056 //  Arguments: Event    = event number.              Range = [ 1, fFileHeader->fReqNbOfEvts ]
01057 //             n1StexStin = Stin number in Stex.     Range = [ 1, fEcal->MaxStinEcnaInStex() ]
01058 //             i0StinEcha = channel number in Stin.  Range = [ 0, fEcal->MaxCrysInStin() - 1 ]     
01059 //             sample   = ADC sample number.         Range = [ 0, fNbSampForFic - 1 ]
01060 //             adcvalue = ADC sample value.
01061 //
01062 //====================================================================================================
01063 Bool_t TEcnaRun::BuildEventDistributions(const Int_t&    n1EventNumber, const Int_t& n1StexStin,
01064                                         const Int_t&    i0StinEcha,    const Int_t& i0Sample,
01065                                         const Double_t& adcvalue)
01066 {
01067   //Building of the arrays fT1d_StexStinFromIndex[] and fT3d_distribs[][][]
01068   
01069   fBuildEvtNotSkipped++;      // event not skipped by cmsRun
01070 
01071   Bool_t ret_code = kFALSE;
01072 
01073   Int_t i0EventIndex   = n1EventNumber - 1;  // INDEX FOR Event number  
01074   Int_t i0StexStinEcna = n1StexStin - 1;     // INDEX FOR StexStin = Number_of_the_Stin_in_Stex - 1
01075 
01076   Int_t i_trouve = 0;
01077   //.................................................................. (BuildEventDistributions)
01078   if(fReadyToReadData == 1)  
01079     {
01080       if( n1StexStin>= 1 && n1StexStin <= fEcal->MaxStinEcnaInStex() )
01081         {      
01082           if( i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin() )
01083             {
01084               if( i0Sample >= 0 && i0Sample < fNbSampForFic )
01085                 {
01086                   //..... Put the StexStin number in 1D array fT1d_StexStinFromIndex[] = Stin index + 1
01087                   if( fT1d_StexStinFromIndex != 0 )  // table fT1d_StexStinFromIndex[index] already allocated
01088                     {
01089                       ret_code = kTRUE;
01090 
01091                       // StexStin already indexed
01092                       if( n1StexStin == fT1d_StexStinFromIndex[i0StexStinEcna] ){i_trouve = 1;}
01093                   
01094                       // StexStin index not found: new StexStin
01095                       if (i_trouve != 1 )
01096                         {
01097                           if( fT1d_StexStinFromIndex[i0StexStinEcna] == fSpecialStexStinNotIndexed )
01098                             {
01099                               fT1d_StexStinFromIndex[i0StexStinEcna] = n1StexStin;
01100                               fFileHeader->fStinNumbersCalc = 1;
01101                               fTagStinNumbers[0] = 1;
01102                               fStinIndexBuilt++;                      //  number of found Stins
01103                               
01104                               if(fFlagPrint == fCodePrintAllComments)
01105                                 {
01106                                   if( fStinIndexBuilt == 1 )
01107                                     {
01108                                       cout << endl << "*TEcnaRun::BuildEventDistributions(...)> event " << n1EventNumber
01109                                            << " : first event for " << fStexName.Data() << " " << fFileHeader->fStex
01110                                            << "; " << fStinName.Data() << "s : ";
01111                                     }
01112                                   if( fFlagSubDet == "EB" )
01113                                     {cout << fT1d_StexStinFromIndex[i0StexStinEcna] << ", ";}
01114                                   if( fFlagSubDet == "EE" )
01115                                     {cout << fEcalNumbering->
01116                                        GetDeeSCConsFrom1DeeSCEcna(fFileHeader->fStex, fT1d_StexStinFromIndex[i0StexStinEcna])
01117                                           << ", ";}
01118                                 }
01119                               //.................................................... (BuildEventDistributions)
01120                               if(fFlagPrint == fCodePrintAllComments)
01121                                 {
01122                                   cout << " (" << fStinIndexBuilt << " " << fStinName.Data()
01123                                        << " found), channel " << i0StinEcha << ", i0Sample " << i0Sample << endl;
01124                                 }
01125                               ret_code = kTRUE;
01126                             } // if ( fT1d_StexStinFromIndex[i0StexStinEcna] == fSpecialStexStinNotIndexed )
01127                           else
01128                             {
01129                               cout << "!TEcnaRun::BuildEventDistributions(...)> *** ERROR ***> NOT ALLOWED if RESULT. " 
01130                                    << " n1StexStin = " << n1StexStin << ", fT1d_StexStinFromIndex["
01131                                    << i0StexStinEcna << "] = "
01132                                    << fT1d_StexStinFromIndex[i0StexStinEcna]
01133                                    << ", fStinIndexBuilt = " << fStinIndexBuilt
01134                                    << fTTBELL << endl;
01135                               ret_code = kFALSE;
01136                             }
01137                         }  //  if (i_trouve != 1 )
01138                     } //  if( fT1d_StexStinFromIndex != 0 ) 
01139                   else
01140                     {
01141                       cout << "!TEcnaRun, BuildEventDistributions *** ERROR ***> "
01142                            << " fT1d_StexStinFromIndex = " << fT1d_StexStinFromIndex
01143                            << " fT1d_StexStinFromIndex[] ALLOCATION NOT DONE" << fTTBELL << endl;
01144                       ret_code = kFALSE;
01145                     } //.................................................................. (BuildEventDistributions)
01146                 } // if( i0Sample >= 0 && i0Sample < fNbSampForFic )
01147               else
01148                 {
01149                   //.......Reading data => Message and error only if sample >= fEcal->MaxSampADC()
01150                   //       (not fNbSampForFic, the later is used only for calculations)
01151                   if( i0Sample >= fEcal->MaxSampADC() )
01152                     {
01153                       cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> "
01154                            << " sample number = " << i0Sample << ". OUT OF BOUNDS"
01155                            << " (max = " << fEcal->MaxSampADC() << ")"
01156                            << fTTBELL << endl;
01157                       ret_code = kFALSE;
01158                     }
01159                   else
01160                     {
01161                       ret_code = kTRUE;
01162                     }
01163                 }
01164             }
01165           else
01166             {
01167               cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> "
01168                    << " channel number in " << fStinName.Data() << " = " << i0StinEcha << ". OUT OF BOUNDS"
01169                    << " (max = " << fEcal->MaxCrysInStin() << ")" 
01170                    << fTTBELL << endl;
01171               ret_code = kFALSE;
01172             }
01173         }
01174       else
01175         {
01176           cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> "
01177                << fStinName.Data() << " number in " << fStexName.Data() << " = " << n1StexStin << ". OUT OF BOUNDS"
01178                << " (max = " << fEcal->MaxStinEcnaInStex() << ")"
01179                << fTTBELL << endl;
01180           ret_code = kFALSE;
01181         }
01182       //.................................................................. (BuildEventDistributions)
01183       //........ Filling of the 2D array of the event numbers in the data reading loop and 
01184       //         filling of the 3D array of the ADC sample values
01185 
01186       if( ret_code == kTRUE )
01187         {
01188           if( i0Sample < fNbSampForFic )
01189             {
01190               //............ 1) Conversion (Stin,i0StinEcha) -> i0StexEcha  (same numbering for EB and EE)
01191               //=========================================================================================
01192               //   n1StexStin (Tower or SC):     1            2            3
01193               //   iStexStin                     0            1            2 
01194               //
01195               //   i0StinEcha:                 0......24    0......24    0......24
01196               //
01197               //   i0StexEcha         :        0......24   25......49   50......74   grouped by StexStin's
01198               //   i0StexEcha+1 (Xtal):        1......25   26......50   51......75       
01199               //
01200               //=========================================================================================
01201 
01202               Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinEcha;
01203               
01204               //--------------------------------------------------------- (BuildEventDistributions)
01205               if( i0StexEcha >= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex() )
01206                 {
01207                   //............ 2) Increase of the nb of evts for (StexEcha,sample) (events found in the data)
01208                   (fT2d_NbOfEvts[i0StexEcha][i0Sample])++;     // value after first incrementation = 1
01209                   fTagNbOfEvts[0] = 1;
01210                   fFileHeader->fNbOfEvtsCalc = 1;
01211                   
01212                   //............ 3) Filling of the 3D array of the ADC values
01213                   if ( i0EventIndex >= 0 && i0EventIndex < fFileHeader->fReqNbOfEvts )
01214                     {  
01215                       fT3d_distribs[i0StexEcha][i0Sample][i0EventIndex] = adcvalue;
01216                     }
01217                   else
01218                     {
01219                       cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> "
01220                            << " event number = " << n1EventNumber << ". OUT OF BOUNDS"
01221                            << " (max = " << fFileHeader->fReqNbOfEvts << ")"
01222                            << fTTBELL << endl;
01223                       ret_code = kFALSE;
01224                     }
01225                 }
01226               else
01227                 {
01228                   cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> "
01229                        << " CHANNEL NUMBER OUT OF BOUNDS" << endl
01230                        << " i0StexEcha number = " << i0StexEcha
01231                        << " , n1StexStin = " << n1StexStin
01232                        << " , i0StinEcha = " << i0StinEcha
01233                        << " , fEcal->MaxCrysEcnaInStex() = " << fEcal->MaxCrysEcnaInStex() 
01234                        << fTTBELL << endl; 
01235                   ret_code = kFALSE;
01236                   // {Int_t cintoto; cout << "TAPER 0 POUR CONTINUER" << endl; cin >> cintoto;}
01237                 }
01238             }
01239           else
01240             {
01241               cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> Nb of required samples = "
01242                    << i0Sample << " (Max = " << fNbSampForFic << ")" << fTTBELL << endl; 
01243             }
01244         }
01245       else
01246         {
01247           cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> ret_code = kFALSE "
01248                << fTTBELL << endl;
01249         }
01250     }
01251   else
01252     {
01253       cout << "!TEcnaRun::BuildEventDistributions(...) *** ERROR ***> GetReadyToReadData(...) not called."
01254            << fTTBELL << endl;
01255       ret_code = kFALSE;
01256     }
01257   //.................................................................. (BuildEventDistributions)
01258   if (ret_code == kFALSE)
01259     {
01260       cout << "!TEcnaRun::BuildEventDistributions(...) > ret_code = " << ret_code << ". event: " << n1EventNumber
01261            << ", n1StexStin: " << n1StexStin
01262            << ", i0StinEcha: " << i0StinEcha
01263            << ", i0Sample: "   << i0Sample
01264            << ", adcvalue: " << adcvalue << endl;
01265     } 
01266   return ret_code;
01267 }
01268 //------------- ( end of BuildEventDistributions ) -----------------------
01269 //====================================================================================================
01270 //
01271 //  ReadEventDistributions: called by external program. Get the distributions of the Sample ADC values
01272 //                          from file by using TEcnaRead.
01273 //
01274 //====================================================================================================
01275 Bool_t TEcnaRun::ReadEventDistributions()
01276 {
01277   return ReadEventDistributions(fEcal->MaxSampADC());
01278 }
01279 
01280 Bool_t TEcnaRun::ReadEventDistributions(const Int_t& nb_samp_for_calc)
01281 {
01282   // read the Sample ADC values from "ADC" result root files                     (ReadEventDistributions)
01283 
01284   // put the number of sample for calculations in attribute fNbSampForCalc
01285   // and call the method without arguments
01286   // We must have: nb_samp_for_calc <= fFileHeader->fNbOfSamples (= nb of samples in ROOT file)
01287 
01288   fNbSampForCalc = nb_samp_for_calc;
01289 
01290   TEcnaRead* MyRootFile = new TEcnaRead(fFlagSubDet.Data(), fCnaParPaths, fCnaParCout,
01291                                       fFileHeader, fEcalNumbering, fCnaWrite);          //  fCnew++;
01292   
01293   MyRootFile->PrintNoComment();
01294   
01295   MyRootFile->GetReadyToReadRootFile(fFileHeader->fTypAna, fFileHeader->fNbOfSamples, fFileHeader->fRunNumber,
01296                                      fFileHeader->fFirstReqEvtNumber, fFileHeader->fLastReqEvtNumber,
01297                                      fFileHeader->fReqNbOfEvts,       fFileHeader->fStex,
01298                                      fCnaParPaths->ResultsRootFilePath().Data());
01299   
01300   Bool_t ok_read = MyRootFile->LookAtRootFile();
01301   
01302   fFileHeader->fStartTime = MyRootFile->GetStartTime();
01303   fFileHeader->fStopTime  = MyRootFile->GetStopTime();
01304   fFileHeader->fStartDate = MyRootFile->GetStartDate();
01305   fFileHeader->fStopDate  = MyRootFile->GetStopDate();
01306   
01307   if ( ok_read == kTRUE )
01308     {
01309       fRootFileName      = MyRootFile->GetRootFileName();
01310       fRootFileNameShort = MyRootFile->GetRootFileNameShort();
01311       cout << "*TEcnaRun::ReadEventDistributions> Reading sample ADC values from file: " << endl
01312            << "           " << fRootFileName << endl;
01313       
01314       Int_t i_no_data = 0;
01315 
01316       //.......... Read the StinNumbers in the old file                     (ReadEventDistributions)
01317       TVectorD vec(fEcal->MaxStinEcnaInStex());
01318       for(Int_t i=0; i<fEcal->MaxStinEcnaInStex(); i++){vec(i)=(Double_t)0.;}
01319       vec = MyRootFile->ReadStinNumbers(fEcal->MaxStinEcnaInStex());
01320       if( MyRootFile->DataExist() == kTRUE )
01321         {
01322           fTagStinNumbers[0] = 1;
01323           fFileHeader->fStinNumbersCalc = 1;
01324           for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
01325             {fT1d_StexStinFromIndex[i0StexStinEcna] = (Int_t)vec(i0StexStinEcna);}
01326         }
01327       else
01328         {
01329           i_no_data++;
01330         }
01331       //.......... Read the Numbers of Events in the old file                      (ReadEventDistributions)
01332       TMatrixD partial_matrix(fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
01333       for(Int_t i=0; i<fEcal->MaxCrysInStin(); i++)
01334         {for(Int_t j=0; j<fFileHeader->fNbOfSamples; j++){partial_matrix(i,j)=(Double_t)0.;}}
01335       
01336       for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
01337         {
01338           Int_t n1StexStin = MyRootFile->GetStexStinFromIndex(i0StexStinEcna);
01339           if(n1StexStin != -1)
01340             {
01341               partial_matrix =
01342                 MyRootFile->ReadNumberOfEventsForSamples
01343                 (n1StexStin, fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
01344 
01345               if( MyRootFile->DataExist() == kTRUE )
01346                 {
01347                   fTagNbOfEvts[0] = 1;
01348                   fFileHeader->fNbOfEvtsCalc = 1;
01349                   for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
01350                     {
01351                       Int_t i0StexEcha = (n1StexStin-1)*fEcal->MaxCrysInStin() + i0StinCrys;
01352                       for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples; i0Sample++)
01353                         {fT2d_NbOfEvts[i0StexEcha][i0Sample] = (Int_t)partial_matrix(i0StinCrys,i0Sample);}
01354                     }
01355                 }
01356               else
01357                 {
01358                   i_no_data++;
01359                 }
01360             }
01361         }
01362 
01363       //.......... Read the Sample ADC values in the old file                     (ReadEventDistributions)
01364       Double_t*** fT3d_read_distribs =
01365         MyRootFile->ReadSampleValuesSameFile
01366         (fEcal->MaxCrysEcnaInStex(), fFileHeader->fNbOfSamples, fFileHeader->fReqNbOfEvts);
01367       
01368       if( MyRootFile->DataExist() == kTRUE )
01369         {             
01370           for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01371             {
01372               for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples;i0Sample++)
01373                 {      
01374                   for(Int_t i_event=0; i_event<fFileHeader->fReqNbOfEvts; i_event++)
01375                     {fT3d_distribs[i0StexEcha][i0Sample][i_event] = 
01376                        fT3d_read_distribs[i0StexEcha][i0Sample][i_event];}
01377                 }
01378             }
01379         }
01380       else
01381         {
01382           i_no_data++;
01383         }
01384       if( i_no_data != 0 )
01385         {
01386           cout << "!TEcnaRun::ReadEventDistributions(...)> *ERROR* =====> "
01387                << " Read failure. i_no_data = " << i_no_data << fTTBELL << endl;  
01388         }
01389     }
01390   else
01391     {
01392       cout << "!TEcnaRun::ReadEventDistributions(...)> *ERROR* =====> "
01393            << " ROOT file not found" << fTTBELL << endl;     
01394     }
01395   delete MyRootFile;        //  fCdelete++;
01396   return ok_read;
01397 }
01398 //------------- ( end of ReadEventDistributions ) -----------------------
01399 //-------------------------------------------------------------------------
01400 //
01401 //    Get the ROOT file name (long and short)
01402 //
01403 //-------------------------------------------------------------------------
01404 TString TEcnaRun::GetRootFileName(){return fRootFileName;}
01405 TString TEcnaRun::GetRootFileNameShort(){return fRootFileNameShort;}
01406 
01407 //###################################################################################################
01408 //
01409 // THE FOLLOWING METHODS ARE CALLED AFTER THE LOOPS OVER EVENTS, STINS, CRYSTALS AND SAMPLES
01410 //
01411 //###################################################################################################
01412 
01413 
01414 //=========================================================================
01415 //
01416 //     Set start time, stop time, StartDate, StopDate
01417 //
01418 //=========================================================================
01419 void TEcnaRun::StartStopTime(time_t t_startime, time_t t_stoptime)
01420 {
01421 // Put the start an stop time (if they exist) in fFileHeader class attributes.
01422   
01423   fFileHeader->fStartTime = t_startime;
01424   fFileHeader->fStopTime  = t_stoptime;
01425 }
01426 
01427 void TEcnaRun::StartStopDate(TString c_startdate, TString c_stopdate)
01428 {
01429 // Put the start an stop date (if they exist) in fFileHeader class attributes.
01430 
01431   fFileHeader->fStartDate = c_startdate;
01432   fFileHeader->fStopDate  = c_stopdate;
01433 }
01434 //=========================================================================
01435 //      
01436 //       S A M P L E S    A D C   V A L U E S 
01437 //
01438 //       Written in .root file corresponding to analysis name
01439 //       beginning with: "Adc" (see EcanAnalyzer.cc in package "Modules")
01440 //
01441 //=========================================================================
01442 
01443 //-------------------------------------------------------------------
01444 //
01445 //                      SampleValues
01446 //
01447 //-------------------------------------------------------------------
01448 void TEcnaRun::SampleValues()
01449 {
01450 //3D histo of the sample ADC values for all the triples (StexEcha, sample, event)
01451 
01452   if(fFlagPrint == fCodePrintAllComments){
01453     cout << "*TEcnaRun::SampleValues()>"
01454          << " Sample ADC values 3D histo"
01455          << " (channel, sample, event number):" << endl
01456          << "                          registration for writing in results .root file."
01457          << endl;}
01458 
01459   // The histo is already in fT3d_distribs[][][]
01460   // this method sets the "Tag", increment the "Calc" (and must be kept for that)
01461   
01462   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
01463     {fTagAdcEvt[i0StexEcha] = 1;        fFileHeader->fAdcEvtCalc++;}
01464 }
01465 
01466 //=========================================================================
01467 //
01468 //                         GetReadyToCompute()
01469 //
01470 //=========================================================================
01471 void TEcnaRun::GetReadyToCompute()
01472 {
01473 //
01474   //  CHECK OF THE NUMBER OF FOUND EVENTS AND init of fNumberOfEvents
01475   //       (number used to compute the average values over the events)
01476   // The number of events fNumberOfEvents is extracted from the array fT2d_NbOfEvts[] 
01477   // which has been built by the BuildEventDistribution(...) method
01478 
01479   if( fT2d_NbOfEvts != 0 )
01480     {
01481       fNumberOfEvents = fCnaWrite->NumberOfEvents(fT2d_NbOfEvts, fEcal->MaxCrysEcnaInStex(),
01482                                                   fNbSampForFic, fFileHeader->fReqNbOfEvts);
01483     }
01484   else
01485     {
01486       cout << "*TEcnaRun::GetReadyToCompute()> no data? fT2d_NbOfEvts = " << fT2d_NbOfEvts << endl;
01487     }
01488 
01489 }  
01490 //  end of GetReadyToCompute()
01491 
01492 //=========================================================================
01493 //
01494 //               C A L C U L A T I O N    M E T H O D S
01495 //
01496 //     fTag... => Calculation done. OK for writing on result file
01497 //     ...Calc => Incrementation for result file size. 
01498 //
01499 //=========================================================================
01500 
01501 //====================================================================
01502 //
01503 //       E X P E C T A T I O N   V A L U E S  ,  V A R I A N C E S
01504 // 
01505 //====================================================================
01506 
01507 //----------------------------------------------------------------
01508 //
01509 //     Calculation of the expectation values of the samples
01510 //                 for all the StexEchas
01511 //
01512 //----------------------------------------------------------------
01513 void TEcnaRun::SampleMeans()
01514 {
01515 // Calculation of the expectation values over events
01516 // for the samples 0 to fNbSampForCalc and for all the StexEchas
01517 
01518   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SampleMeans() " << endl;}
01519   if(fFlagPrint == fCodePrintAllComments){
01520     cout  << "           Calculation: sample expectation values over the events"
01521           << " for each channel." << endl;}
01522   
01523   //................... Allocation fT2d_ev
01524   if ( fT2d_ev == 0 ){
01525     Int_t n_samp = fNbSampForCalc;
01526     Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
01527     fT2d_ev = new Double_t*[n_StexEcha];             fCnew++;  
01528     fT1d_ev = new  Double_t[n_StexEcha*n_samp];      fCnew++;   
01529     for(Int_t i = 0 ; i < n_StexEcha ; i++){
01530       fT2d_ev[i] = &fT1d_ev[0] + i*n_samp;}
01531   }
01532   //................... init fT2d_ev to zero
01533   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01534     {
01535       for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
01536         {
01537           if( fT2d_ev[i0StexEcha][i0Sample] != (Double_t)0 )
01538             {fMiscDiag[1]++; fT2d_ev[i0StexEcha][i0Sample] = (Double_t)0;}
01539         } 
01540     }
01541   
01542   //................... Calculation
01543   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
01544     {
01545       for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
01546         {
01547           for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
01548             {
01549               fT2d_ev[i0StexEcha][i0Sample] += fT3d_distribs[i0StexEcha][i0Sample][i_event];
01550             }
01551           fT2d_ev[i0StexEcha][i0Sample] /= fNumberOfEvents;
01552         }
01553     }
01554   fTagMSp[0] = 1;        fFileHeader->fMSpCalc++;
01555 }
01556 
01557 //--------------------------------------------------------
01558 //
01559 //      Calculation of the sigmas of the samples
01560 //                 for all the StexEchas
01561 //
01562 //--------------------------------------------------------
01563 void TEcnaRun::SampleSigmas() 
01564 {
01565 //Calculation of the sigmas of the samples for all the StexEchas
01566   
01567   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SampleSigmas()" << endl;}
01568   if(fFlagPrint == fCodePrintAllComments){
01569     cout << "           Calculation: sample ADC sigmas over the events "
01570          << " for each channel." << endl;}
01571   
01572   //... preliminary calculation of the expectation values if not done yet.
01573   //    The tag is set to 1 after call to the method. It is reset to 0
01574   //    because the expectation values must not be written in the result ROOT file
01575   //    (since the tag was equal to 0)
01576   if(fTagMSp[0] != 1){SampleMeans(); fTagMSp[0] = 0;}
01577 
01578   //................... Allocation fT2d_sig
01579   if( fT2d_sig == 0){
01580     Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
01581     Int_t n_samp = fNbSampForCalc;
01582     fT2d_sig = new Double_t*[n_StexEcha];                fCnew++;        
01583     fT1d_sig = new  Double_t[n_StexEcha*n_samp];         fCnew++;  
01584     for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
01585       fT2d_sig[i0StexEcha] = &fT1d_sig[0] + i0StexEcha*n_samp;}
01586   }
01587   // ................... init fT2d_sig to zero
01588   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01589     {
01590       for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
01591         {
01592           if( fT2d_sig[i0StexEcha][i0Sample] != (Double_t)0 )
01593             {fMiscDiag[2]++; fT2d_sig[i0StexEcha][i0Sample] = (Double_t)0;}
01594         } 
01595     }
01596   
01597   //................... Calculation
01598   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
01599     {
01600       for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
01601         {
01602           Double_t variance = (Double_t)0.;
01603           for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
01604             {
01605               Double_t ecart = fT3d_distribs[i0StexEcha][i0Sample][i_event] - fT2d_ev[i0StexEcha][i0Sample];
01606               variance += ecart*ecart;
01607             }
01608           variance /= fNumberOfEvents;
01609           fT2d_sig[i0StexEcha][i0Sample] = sqrt(variance);
01610         }
01611     }
01612   fTagSSp[0] = 1;        fFileHeader->fSSpCalc++;
01613 }
01614 
01615 //====================================================================
01616 //
01617 //       C O V A R I A N C E S   &   C O R R E L A T I O N S
01618 //
01619 //                 B E T W E E N   S A M P L E S
01620 //
01621 //====================================================================
01622 //-----------------------------------------------------------
01623 //
01624 //      Calculation of the covariances between samples
01625 //      for all the StexEchas
01626 //
01627 //-----------------------------------------------------------
01628 void TEcnaRun::CovariancesBetweenSamples()
01629 {
01630   //Calculation of the covariances between samples for all the StexEchas
01631   
01632   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::CovariancesBetweenSamples()" << endl;}
01633   if(fFlagPrint == fCodePrintAllComments){
01634     cout << "           Calculation: covariances between samples"
01635          << " for each channel." << endl;}
01636   
01637   //................... Allocations cov_ss
01638   if( fT3d_cov_ss == 0 ){
01639     const Int_t n_samp = fNbSampForCalc;
01640     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
01641     fT3d_cov_ss  = new Double_t**[n_StexEcha];                fCnew++;  
01642     fT3d2_cov_ss = new  Double_t*[n_StexEcha*n_samp];         fCnew++;  
01643     fT3d1_cov_ss = new   Double_t[n_StexEcha*n_samp*n_samp];  fCnew++;  
01644     for(Int_t i = 0 ; i < n_StexEcha ; i++){
01645       fT3d_cov_ss[i] = &fT3d2_cov_ss[0] + i*n_samp;
01646       for(Int_t j = 0 ; j < n_samp ; j++){
01647         fT3d2_cov_ss[n_samp*i+j] = &fT3d1_cov_ss[0]+n_samp*(n_samp*i+j);}}
01648   }
01649   
01650   //.................. Calculation (= init)
01651   //.................. computation of half of the matrix, diagonal included)
01652 
01653   //... preliminary calculation of the expectation values if not done yet.
01654   //    The tag is set to 1 after call to the method. It is reset to 0
01655   //    because the expectation values must not be written in the result ROOT file
01656   //    (since the tag was equal to 0)
01657   //    Results in array  fT2d_ev[j0StexEcha][i0Sample]
01658   if(fTagMSp[0] != 1){SampleMeans(); fTagMSp[0] = 0;}
01659 
01660 
01661   for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
01662     {
01663       for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
01664         {
01665           for (Int_t j0Sample = 0 ; j0Sample <= i0Sample; j0Sample++)
01666             {
01667               fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] = (Double_t)0;
01668               for( Int_t i_event = 0; i_event < fNumberOfEvents; i_event++ )
01669                 {
01670                   fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] +=
01671                     (fT3d_distribs[j0StexEcha][i0Sample][i_event] - fT2d_ev[j0StexEcha][i0Sample])
01672                     *(fT3d_distribs[j0StexEcha][j0Sample][i_event] - fT2d_ev[j0StexEcha][j0Sample]);
01673                 }
01674               fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample] /= (Double_t)fNumberOfEvents;
01675               fT3d_cov_ss[j0StexEcha][j0Sample][i0Sample] = fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample];
01676             }
01677         }
01678       fTagCovCss[j0StexEcha] = 1;     fFileHeader->fCovCssCalc++;
01679     }
01680 }
01681 
01682 //-----------------------------------------------------------
01683 //
01684 //      Calculation of the correlations between samples
01685 //      for all the StexEchas
01686 //
01687 //-----------------------------------------------------------
01688 void TEcnaRun::CorrelationsBetweenSamples()
01689 {
01690 //Calculation of the correlations between samples for all the StexEchas
01691 
01692   //... preliminary calculation of the covariances if not done yet.
01693   //    Test only the first tag since the cov are computed globaly
01694   //    but set all the tags to 0 because we don't want to write
01695   //    the covariances in the result ROOT file    
01696   if ( fTagCovCss[0] != 1 ){CovariancesBetweenSamples();
01697   for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
01698     {fTagCovCss[j0StexEcha] = 0;}}
01699   
01700   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::CorrelationsBetweenSamples()" << endl;}
01701   if(fFlagPrint == fCodePrintAllComments){
01702     cout << "           Calculation: correlations between samples"
01703          << " for each channel." << endl;}
01704 
01705   //................... Allocations cor_ss
01706   if( fT3d_cor_ss == 0){
01707     const Int_t n_samp = fNbSampForCalc;
01708     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
01709     fT3d_cor_ss  = new Double_t**[n_StexEcha];                fCnew++;  
01710     fT3d2_cor_ss = new  Double_t*[n_StexEcha*n_samp];         fCnew++;  
01711     fT3d1_cor_ss = new   Double_t[n_StexEcha*n_samp*n_samp];  fCnew++;  
01712     for(Int_t i = 0 ; i < n_StexEcha ; i++){
01713       fT3d_cor_ss[i] = &fT3d2_cor_ss[0] + i*n_samp;
01714       for(Int_t j = 0 ; j < n_samp ; j++){
01715         fT3d2_cor_ss[n_samp*i+j] = &fT3d1_cor_ss[0]+n_samp*(n_samp*i+j);}}
01716   }
01717   
01718   //..................... calculation of the correlations (=init)
01719   //......................computation of half of the matrix, diagonal included (verif = 1)
01720     
01721  for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
01722    {
01723      for (Int_t i0Sample = 0 ; i0Sample < fNbSampForCalc ; i0Sample++)
01724        {
01725          for (Int_t j0Sample = 0 ; j0Sample <= i0Sample ; j0Sample++)
01726            {
01727              if( (fT3d_cov_ss[j0StexEcha][i0Sample][i0Sample] > 0) &&
01728                  (fT3d_cov_ss[j0StexEcha][j0Sample][j0Sample] > 0) )
01729                {
01730                  fT3d_cor_ss[j0StexEcha][i0Sample][j0Sample] = fT3d_cov_ss[j0StexEcha][i0Sample][j0Sample]/
01731                    ( sqrt(fT3d_cov_ss[j0StexEcha][i0Sample][i0Sample])*sqrt(fT3d_cov_ss[j0StexEcha][j0Sample][j0Sample]) );
01732                }
01733              else
01734                {
01735                  (fT3d_cor_ss)[j0StexEcha][i0Sample][j0Sample] = (Double_t)0; // prevoir compteur + fTTBELL
01736                }
01737              fT3d_cor_ss[j0StexEcha][j0Sample][i0Sample] = fT3d_cor_ss[j0StexEcha][i0Sample][j0Sample];
01738            }
01739        }
01740      fTagCorCss[j0StexEcha] = 1;          fFileHeader->fCorCssCalc++;
01741    }
01742 }
01743 
01744 //===========================================================================
01745 //
01746 //     M E A N   P E D E S T A L S ,   T O T A L    N O I S E ,
01747 //     L O W     F R E Q U E N C Y    N O I S E , 
01748 //     H I G H   F R E Q U E N C Y    N O I S E 
01749 //     M E A N   O F  C O R ( S , S ),  S I G M A   O F  C O R ( S , S )
01750 //
01751 //===========================================================================
01752 //-------------------------------------------------------------------------
01753 //
01754 //         Calculation of the Pedestals for each channel in Stex
01755 //         tag: Ped
01756 //      
01757 //-------------------------------------------------------------------------
01758 void TEcnaRun::Pedestals()
01759 {
01760 // Calculation, for each channel, of the expectation values
01761 // (over the samples 0 to fNbSampForCalc-1) of the ADC expectation values 
01762 // (over the events)
01763 
01764   //... preliminary calculation of the expectation values if not done yet
01765   if ( fTagMSp[0] != 1 ){SampleMeans(); fTagMSp[0]=0;}
01766 
01767   //................... Allocation ev_ev + init to zero (mandatory)
01768   if( fT1d_ev_ev == 0 ){fT1d_ev_ev = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;}
01769   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01770     {if( fT1d_ev_ev[i0StexEcha] != (Double_t)0 )
01771       {fMiscDiag[11]++; fT1d_ev_ev[i0StexEcha] = (Double_t)0;}}
01772   
01773   //..................... Calculation
01774   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::Pedestals()" << endl;}
01775   if(fFlagPrint == fCodePrintAllComments){
01776     cout << "           Calculation, for all the channels, of the expectation values (over the samples 1 to "
01777          << fNbSampForCalc << ")" << endl
01778          << "          of the ADC expectation values (over the events)." << endl;}
01779   
01780   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01781     {     
01782       for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
01783         {
01784           fT1d_ev_ev[i0StexEcha] += fT2d_ev[i0StexEcha][i0Sample];
01785         }
01786       fT1d_ev_ev[i0StexEcha] /= fNbSampForCalc;
01787     }
01788   fTagPed[0] = 1;                      fFileHeader->fPedCalc++;
01789 }
01790 //------------------------ (end of Pedestals) ----------------------------
01791 
01792 //-------------------------------------------------------------------------
01793 //
01794 //         Calculation of the TN (Total Noise)
01795 //         tag: Tno
01796 //      
01797 //-------------------------------------------------------------------------
01798 void TEcnaRun::TotalNoise()
01799 {
01800 // Calculation, for each channel, of the expectation values
01801 // (over the samples 0 to fNbSampForCalc-1) of the sigmas 
01802 // (over the events)
01803 
01804   //... preliminary calculation of the sigmas if not done yet
01805   if ( fTagSSp[0] != 1 ){SampleSigmas(); fTagSSp[0]=0;}
01806 
01807   //................... Allocation ev_ev + init to zero (mandatory)
01808   if( fT1d_evsamp_of_sigevt == 0 ){fT1d_evsamp_of_sigevt = new Double_t[fEcal->MaxCrysEcnaInStex()]; fCnew++;}
01809   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01810     {if( fT1d_evsamp_of_sigevt[i0StexEcha] != (Double_t)0 )
01811       {fMiscDiag[12]++; fT1d_evsamp_of_sigevt[i0StexEcha] = (Double_t)0;}}
01812   
01813   //..................... Calculation
01814   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::TotalNoise()" << endl;}
01815   if(fFlagPrint == fCodePrintAllComments){
01816     cout << "           Calculation, for all the channels, of the expectation values (over the samples 1 to "
01817          << fNbSampForCalc << ")" << endl
01818          << "          of the ADC expectation values (over the events)." << endl;}
01819 
01820   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01821     {     
01822       for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
01823         {
01824           if( fT2d_sig[i0StexEcha][i0Sample] < 0)
01825             {
01826               cout << "!TEcnaRun::TotalNoise() *** ERROR ***> Negative sigma!"
01827                    << fTTBELL << endl;
01828             }
01829           else
01830             {
01831               fT1d_evsamp_of_sigevt[i0StexEcha] += fT2d_sig[i0StexEcha][i0Sample];
01832             }
01833         }
01834       fT1d_evsamp_of_sigevt[i0StexEcha] /= fNbSampForCalc;
01835     }
01836   fTagTno[0] = 1;                     fFileHeader->fTnoCalc++;
01837 }
01838 //------------------------ (end of TotalNoise) ----------------------------
01839 
01840 //-------------------------------------------------------------------------
01841 //
01842 //      Calculation of the LFN  (Low Frequency Noise)
01843 //      tag: Lfn
01844 //
01845 //-------------------------------------------------------------------------
01846 void TEcnaRun::LowFrequencyNoise()
01847 {
01848 // Calculation, for each channel, of the sigma (over the events)
01849 // of the ADC expectation values (over the samples 0 to fNbSampForCalc-1)
01850 
01851   //................... Allocation fT1d_sigevt_of_evsamp + init to zero (mandatory)
01852   if( fT1d_sigevt_of_evsamp == 0 ){
01853     fT1d_sigevt_of_evsamp = new Double_t[fEcal->MaxCrysEcnaInStex()];              fCnew++;  
01854   }
01855   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01856     {
01857       if( fT1d_sigevt_of_evsamp[i0StexEcha] != (Double_t)0 )
01858         {fMiscDiag[13]++; fT1d_sigevt_of_evsamp[i0StexEcha] = (Double_t)0;}
01859     }
01860 
01861   //................... Allocation mean_over_samples
01862   TVectorD  mean_over_samples(fNumberOfEvents);
01863   for(Int_t i=0; i<fNumberOfEvents; i++){mean_over_samples(i)=(Double_t)0.;}
01864 
01865   //..................... Calculation
01866   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyNoise()" << endl;}
01867   if(fFlagPrint == fCodePrintAllComments){
01868     cout << "           Calculation, for each channel, of the sigma (over the events)" << endl
01869          << "           of the ADC expectation values (over the samples 1 to "
01870          <<  fNbSampForCalc << ")." << endl;}
01871 
01872   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01873     {
01874       // Calculation of the mean over the events of the mean over the samples
01875       Double_t mean_over_events = (Double_t)0;
01876       for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
01877         {
01878           // Calculation, for each event, of the mean over the samples  
01879           mean_over_samples(n_event) = (Double_t)0.;
01880           for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
01881             {
01882               mean_over_samples(n_event) += fT3d_distribs[i0StexEcha][i0Sample][n_event];
01883             }
01884           mean_over_samples(n_event) /= (Double_t)fNbSampForCalc;
01885 
01886           mean_over_events += mean_over_samples(n_event);
01887         }
01888        mean_over_events /= (Double_t)fNumberOfEvents;
01889        
01890        // Calculation of the sigma over the events of the mean over the samples
01891        Double_t var = (Double_t)0;
01892        for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
01893          {
01894           Double_t ecart =  mean_over_samples(n_event) - mean_over_events;
01895           var += ecart*ecart;
01896          }
01897        var /= (Double_t)fNumberOfEvents;
01898        
01899        fT1d_sigevt_of_evsamp[i0StexEcha] = sqrt(var);
01900     }
01901   fTagLfn[0] = 1;                      fFileHeader->fLfnCalc++;
01902 }
01903 //------------------------ (end of LowFrequencyNoise) ----------------------------
01904 
01905 //-------------------------------------------------------------------------
01906 //
01907 //      Calculation of the HFN  (High Frequency Noise)
01908 //      tag: Hfn
01909 //
01910 //-------------------------------------------------------------------------
01911 void TEcnaRun::HighFrequencyNoise()
01912 {
01913 // Calculation, for each channel, of the mean (over the events)
01914 // of the ADC sigmas (over the samples 0 to fNbSampForCalc-1)
01915 
01916   //................... Allocation fT1d_evevt_of_sigsamp + init to zero (mandatory)
01917   if( fT1d_evevt_of_sigsamp == 0 ){
01918     fT1d_evevt_of_sigsamp = new Double_t[fEcal->MaxCrysEcnaInStex()];              fCnew++;  
01919   }
01920   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01921     {
01922       if( fT1d_evevt_of_sigsamp[i0StexEcha] != (Double_t)0 )
01923         {fMiscDiag[14]++; fT1d_evevt_of_sigsamp[i0StexEcha] = (Double_t)0;}
01924     }
01925 
01926   //................... Allocations mean_over_samples, sigma_over_sample
01927   TVectorD  mean_over_samples(fNumberOfEvents);
01928   for(Int_t i=0; i<fNumberOfEvents; i++){mean_over_samples(i)=(Double_t)0.;} 
01929   TVectorD  sigma_over_samples(fNumberOfEvents);
01930   for(Int_t i=0; i<fNumberOfEvents; i++){sigma_over_samples(i)=(Double_t)0.;}
01931 
01932   //..................... Calculation
01933   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyNoise()" << endl;}
01934   if(fFlagPrint == fCodePrintAllComments){
01935     cout << "           Calculation, for each channel, of the sigma (over the events)" << endl
01936          << "           of the ADC expectation values (over the samples 1 to "
01937          <<  fNbSampForCalc << ")." << endl;}
01938 
01939   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01940     {
01941       //..................... Calculation of the sigma over samples
01942       for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
01943         {
01944           // Calculation, for each event, of the mean over the samples  
01945           mean_over_samples(n_event) = (Double_t)0.;
01946           for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
01947             {mean_over_samples(n_event) += fT3d_distribs[i0StexEcha][i0Sample][n_event];}
01948           mean_over_samples(n_event) /= (Double_t)fNbSampForCalc;
01949           
01950           // Calculation, for each event, of the sigma over the samples
01951           Double_t var_over_samples =  (Double_t)0;
01952           for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
01953             {Double_t deviation = fT3d_distribs[i0StexEcha][i0Sample][n_event] - mean_over_samples(n_event);
01954             var_over_samples += deviation*deviation;}
01955           var_over_samples /= (Double_t)fNbSampForCalc;
01956           
01957           if( var_over_samples < 0)
01958             {cout << "!TEcnaRun::HighFrequencyNoise() *** ERROR ***> Negative variance! " << fTTBELL << endl;}
01959           else
01960             {sigma_over_samples(n_event) = sqrt(var_over_samples);}
01961         }
01962 
01963       //....... Calculation of the mean over the events of the sigma over samples
01964       for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
01965         {fT1d_evevt_of_sigsamp[i0StexEcha] += sigma_over_samples(n_event);}
01966 
01967       fT1d_evevt_of_sigsamp[i0StexEcha] /= (Double_t)fNumberOfEvents;
01968     }
01969   fTagHfn[0] = 1;                      fFileHeader->fHfnCalc++;
01970 }
01971 //------------------------ (end of HighFrequencyNoise) ----------------------------
01972 
01973 //-------------------------------------------------------------------------
01974 //
01975 //      Calculation of the expectation values of (sample,sample)
01976 //      correlations for all the channels (mean of cor(s,s))
01977 //      tag: MeanCorss
01978 //
01979 //-------------------------------------------------------------------------
01980 void TEcnaRun::MeanOfCorrelationsBetweenSamples()
01981 {
01982   // Calculation, for all the channels, of the expectation values
01983   // of the correlations between the first fNbSampForCalc samples
01984   
01985   //... preliminary calculation of the correlations if not done yet
01986   //    (test only the first element since the cor are computed globaly)
01987   if ( fTagCorCss[0] != 1 ){CorrelationsBetweenSamples(); fTagCorCss[0]=0;}
01988 
01989   //................... Allocations ev_cor_ss + init to zero (mandatory)
01990   if( fT1d_ev_cor_ss == 0 ){
01991     Int_t n_StexEcha =  fEcal->MaxCrysEcnaInStex();
01992     fT1d_ev_cor_ss = new Double_t[n_StexEcha];               fCnew++;  
01993   }
01994   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
01995     {
01996       if( fT1d_ev_cor_ss[i0StexEcha] != (Double_t)0 )
01997         {fMiscDiag[15]++; fT1d_ev_cor_ss[i0StexEcha] = (Double_t)0;}
01998     }
01999   
02000   //.......... 1D array half_cor_ss[N(N-1)/2] to put the N (sample,sample) correlations
02001   //           ( half of (them minus the diagonal) ) 
02002   Int_t ndim = (Int_t)(fNbSampForCalc*(fNbSampForCalc - 1)/2);
02003 
02004   TVectorD  half_cor_ss(ndim); for(Int_t i=0; i<ndim; i++){half_cor_ss(i)=(Double_t)0.;}
02005 
02006   //..................... Calculation
02007   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::MeanOfCorrelationsBetweenSamples()" << endl;}
02008   if(fFlagPrint == fCodePrintAllComments){
02009     cout << "           Calculation, for all the channels, of the expectation values of the" << endl
02010          << "           correlations between the first " << fNbSampForCalc << " samples." << endl;}
02011 
02012   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02013     {
02014       //..................... half_cor_ss() array filling
02015       Int_t i_count = 0;
02016       for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
02017         {
02018           for (Int_t j0Sample = 0; j0Sample < i0Sample; j0Sample++)
02019             {
02020               half_cor_ss(i_count) = fT3d_cor_ss[i0StexEcha][i0Sample][j0Sample];
02021               i_count++;
02022             }
02023         }
02024       //...................... mean of cor(s,s') calculation
02025       fT1d_ev_cor_ss[i0StexEcha] = (Double_t)0;
02026       for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
02027         {
02028           fT1d_ev_cor_ss[i0StexEcha] += half_cor_ss(i_rcor);
02029         }
02030       fT1d_ev_cor_ss[i0StexEcha] /= (Double_t)ndim;
02031     }
02032   fTagMeanCorss[0] = 1;               fFileHeader->fMeanCorssCalc++;
02033 }
02034 //--------------- (end of MeanOfCorrelationsBetweenSamples) -----------
02035 
02036 //-------------------------------------------------------------------------
02037 //
02038 //      Calculation of the sigmas of the (sample,sample) correlations
02039 //      for all the channels (sigma of cor(s,s))
02040 //      tag: SigCorss
02041 //
02042 //--------------------------------------------------------------------------
02043 void  TEcnaRun::SigmaOfCorrelationsBetweenSamples()
02044 {
02045   //Calculation of the sigmas of the (sample,sample) correlations for all the StexEchas
02046  
02047   //... preliminary calculation of the mean of cor(s,s') if not done yet
02048   //    (test only the first element since the cor are computed globaly)
02049   //    Results available in array fT1d_ev_cor_ss[i0StexEcha]
02050   if ( fTagMeanCorss[0] != 1 ){MeanOfCorrelationsBetweenSamples(); fTagMeanCorss[0]=0;}
02051 
02052   //................... Allocations sig_cor_ss + init to zero
02053   if( fT1d_sig_cor_ss == 0 ){
02054     Int_t n_StexEcha =  fEcal->MaxCrysEcnaInStex();
02055     fT1d_sig_cor_ss = new Double_t[n_StexEcha];                fCnew++;  
02056   }
02057   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02058     {
02059       if( fT1d_sig_cor_ss[i0StexEcha] != (Double_t)0 )
02060         {fMiscDiag[16]++; fT1d_sig_cor_ss[i0StexEcha] = (Double_t)0;}
02061     }
02062 
02063   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::SigmasOfCorrelationsBetweenSamples()" << endl;}
02064   if(fFlagPrint == fCodePrintAllComments){
02065     cout << "           Calculation of the sigmas of the (sample,sample)" << endl
02066          << "           correlations for all the channels." << endl;}
02067 
02068   //.......... 1D array half_cor_ss[N(N-1)/2] to put the N (sample,sample) correlations
02069   //           (half of them minus the diagonal)
02070   Int_t ndim = (Int_t)(fNbSampForCalc*(fNbSampForCalc - 1)/2);
02071 
02072   TVectorD  half_cor_ss(ndim); for(Int_t i=0; i<ndim; i++){half_cor_ss(i)=(Double_t)0.;}
02073 
02074   //.................. Calculation
02075   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02076     {
02077       //..................... half_cor_ss() array filling
02078       Int_t i_count = 0;
02079       for (Int_t i0Sample = 0; i0Sample < fNbSampForCalc; i0Sample++)
02080         {
02081           for (Int_t j0Sample = 0; j0Sample < i0Sample; j0Sample++)
02082             {
02083               half_cor_ss(i_count) = fT3d_cor_ss[i0StexEcha][i0Sample][j0Sample];
02084               i_count++;
02085             }
02086         }
02087 
02088       //...................... sigma of cor(s,s') calculation
02089       Double_t var = (Double_t)0;
02090       for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
02091         {
02092           Double_t ecart = half_cor_ss(i_rcor) - fT1d_ev_cor_ss[i0StexEcha];
02093           var += ecart*ecart;
02094         }
02095       var /= (Double_t)ndim;
02096       fT1d_sig_cor_ss[i0StexEcha] = sqrt(var);
02097     }
02098   fTagSigCorss[0] = 1;              fFileHeader->fSigCorssCalc++;
02099 }
02100 //--------------- (end of SigmaOfCorrelationsBetweenSamples) -----------
02101 
02102 //-----------------------------------------------------------------------------
02103 //
02104 //  Calculation of the average of the Pedestals for each Stin in Stex
02105 //  tag: AvPed
02106 //      
02107 //-----------------------------------------------------------------------------
02108 void TEcnaRun::AveragedPedestals()
02109 {
02110 // Calculation of the average 
02111 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Pedestals
02112 
02113   //... preliminary calculation of the Pedestals if not done yet
02114   if ( fTagPed[0] != 1 ){Pedestals(); fTagPed[0]=0;}
02115   //................... Allocation av_mped + init to zero (mandatory)
02116   if( fT1d_av_mped == 0 ){fT1d_av_mped = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02117   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02118     {if( fT1d_av_mped[i0StexStinEcna] != (Double_t)0 )
02119       {fMiscDiag[41]++; fT1d_av_mped[i0StexStinEcna] = (Double_t)0;}}
02120  
02121   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedPedestals()" << endl;}
02122   if(fFlagPrint == fCodePrintAllComments){
02123     cout << "           Calculation, for all the "
02124          << fStinName.Data() << "s, of the average of the Pedestals" << endl;}
02125 
02126   //................... Calculation
02127   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02128     {
02129       Int_t n1StexStinEcna = i0StexStinEcna+1;
02130       fT1d_av_mped[i0StexStinEcna] = (Double_t)0;
02131       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02132         {
02133           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02134 
02135           if( fStexName == "SM " )
02136             {fT1d_av_mped[i0StexStinEcna] += fT1d_ev_ev[i0StexEcha];}
02137 
02138           if( fStexName == "Dee" )
02139             {
02140               //---------------- Special translation for mixed SCEcna (29 and 32)
02141               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02142               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02143               Int_t n1StinEcha = i0StinEcha+1;
02144               if( n1StexStinEcna == 10 && n1StinEcha == 11 )
02145                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02146               if( n1StexStinEcna == 11 && n1StinEcha == 11 )
02147                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02148               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02149                 {fT1d_av_mped[i0StexStinEcna] += fT1d_ev_ev[i0StexEcha];}
02150             }
02151         }
02152       Double_t xdivis = (Double_t)0.;
02153       if( fStexName == "SM "  )
02154         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02155       if( fStexName == "Dee" )
02156         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02157       
02158       fT1d_av_mped[i0StexStinEcna] = fT1d_av_mped[i0StexStinEcna]/xdivis;
02159     }
02160   
02161   fTagAvPed[0] = 1;                      fFileHeader->fAvPedCalc++;
02162 }
02163 //-----------------------------------------------------------------------------
02164 //
02165 // Calculation of the average of the Total noise for each Stin in Stex
02166 // tag: AvTno
02167 //      
02168 //-----------------------------------------------------------------------------
02169 void TEcnaRun::AveragedTotalNoise()
02170 {
02171 // Calculation of the average 
02172 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Total Noise
02173   
02174   //... preliminary calculation of the averaged Total Noise if not done yet
02175   if ( fTagTno[0] != 1 ){TotalNoise(); fTagTno[0]=0;}
02176   //................... Allocation av_totn + init to zero (mandatory)
02177   if( fT1d_av_totn == 0 ){fT1d_av_totn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02178   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02179     {if( fT1d_av_totn[i0StexStinEcna] != (Double_t)0 )
02180       {fMiscDiag[42]++; fT1d_av_totn[i0StexStinEcna] = (Double_t)0;}}
02181 
02182   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedTotalNoise()" << endl;}
02183   if(fFlagPrint == fCodePrintAllComments){
02184     cout << "           Calculation, for all the "
02185          << fStinName.Data() << "s, of the average of the Total Noise" << endl;}
02186 
02187   //................... Calculation
02188   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02189     {
02190       Int_t n1StexStinEcna = i0StexStinEcna+1;
02191       fT1d_av_totn[i0StexStinEcna] = (Double_t)0;
02192       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02193         {
02194           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02195           
02196           if( fStexName == "SM " )
02197             {fT1d_av_totn[i0StexStinEcna] += fT1d_evsamp_of_sigevt[i0StexEcha];}
02198           
02199           if( fStexName == "Dee" )
02200             {
02201               //---------------- Special translation for mixed SCEcna (29 and 32)
02202               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02203               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02204               Int_t n1StinEcha = i0StinEcha+1;
02205               if( n1StexStinEcna == 10 && n1StinEcha == 11 )
02206                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02207               if( n1StexStinEcna == 11 && n1StinEcha == 11 )
02208                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02209               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02210                 {fT1d_av_totn[i0StexStinEcna] += fT1d_evsamp_of_sigevt[i0StexEcha];}
02211             }
02212         }
02213       Double_t xdivis = (Double_t)0.;
02214       if( fStexName == "SM "  )
02215         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02216       if( fStexName == "Dee" )
02217         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02218       
02219       fT1d_av_totn[i0StexStinEcna] = fT1d_av_totn[i0StexStinEcna]/xdivis;
02220     }
02221   fTagAvTno[0] = 1;                      fFileHeader->fAvTnoCalc++;
02222 }
02223 //-----------------------------------------------------------------------------
02224 //
02225 // Calculation of the average of the Low Frequency noise for each Stin in Stex
02226 // tag: AvLfn
02227 //      
02228 //-----------------------------------------------------------------------------
02229 void TEcnaRun::AveragedLowFrequencyNoise()
02230 {
02231 // Calculation of the average 
02232 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the Low Frequency Noise
02233   
02234   //... preliminary calculation of the Low Frequency Noise if not done yet
02235   if ( fTagLfn[0] != 1 ){LowFrequencyNoise(); fTagLfn[0]=0;}
02236   //................... Allocation av_lofn + init to zero (mandatory)
02237   if( fT1d_av_lofn == 0 ){fT1d_av_lofn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02238   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02239     {if( fT1d_av_lofn[i0StexStinEcna] != (Double_t)0 )
02240       {fMiscDiag[43]++; fT1d_av_lofn[i0StexStinEcna] = (Double_t)0;}}
02241 
02242   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedLowFrequencyNoise()" << endl;}
02243   if(fFlagPrint == fCodePrintAllComments){
02244     cout << "           Calculation, for all the "
02245          << fStinName.Data() << "s, of the average of the Low Frequency Noise" << endl;}
02246 
02247   //................... Calculation
02248   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02249     {
02250       Int_t n1StexStinEcna = i0StexStinEcna+1;
02251       fT1d_av_lofn[i0StexStinEcna] = (Double_t)0;
02252       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02253         {
02254           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02255 
02256           if( fStexName == "SM " )
02257             {fT1d_av_lofn[i0StexStinEcna] += fT1d_sigevt_of_evsamp[i0StexEcha];}
02258           
02259           if( fStexName == "Dee" )
02260             {
02261               //---------------- Special translation for mixed SCEcna (29 and 32)
02262               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02263               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02264               Int_t n1StinEcha = i0StinEcha+1;
02265               if( n1StexStinEcna == 10 &&  n1StinEcha == 11 )
02266                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02267               if( n1StexStinEcna == 11 &&  n1StinEcha == 11 )
02268                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02269               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02270                 {fT1d_av_lofn[i0StexStinEcna] += fT1d_sigevt_of_evsamp[i0StexEcha];}
02271             }
02272         }
02273       Double_t xdivis = (Double_t)0.;
02274       if( fStexName == "SM "  )
02275         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02276       if( fStexName == "Dee" )
02277         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02278       
02279       fT1d_av_lofn[i0StexStinEcna] = fT1d_av_lofn[i0StexStinEcna]/xdivis;
02280     }
02281   fTagAvLfn[0] = 1;                      fFileHeader->fAvLfnCalc++; 
02282 }
02283 //-----------------------------------------------------------------------------
02284 //
02285 // Calculation of the average of the high frequency noise for each Stin in Stex
02286 // tag: AvHfn
02287 //      
02288 //-----------------------------------------------------------------------------
02289 void TEcnaRun::AveragedHighFrequencyNoise()
02290 {
02291 // Calculation of the average 
02292 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the High Frequency Noise
02293   
02294   //... preliminary calculation of the High Frequency Noise if not done yet
02295   if ( fTagHfn[0] != 1 ){HighFrequencyNoise(); fTagHfn[0]=0;}
02296   //................... Allocation av_hifn + init to zero (mandatory)
02297   if( fT1d_av_hifn == 0 ){fT1d_av_hifn = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02298   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02299     {if( fT1d_av_hifn[i0StexStinEcna] != (Double_t)0 )
02300       {fMiscDiag[44]++; fT1d_av_hifn[i0StexStinEcna] = (Double_t)0;}}
02301 
02302   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedHighFrequencyNoise()" << endl;}
02303   if(fFlagPrint == fCodePrintAllComments){
02304     cout << "           Calculation, for all the "
02305          << fStinName.Data() << "s, of the average of the High Frequency Noise" << endl;}
02306 
02307   //................... Calculation
02308   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02309     {   
02310       Int_t n1StexStinEcna = i0StexStinEcna+1;
02311       fT1d_av_hifn[i0StexStinEcna] = (Double_t)0;
02312       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02313         {
02314           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02315 
02316           if( fStexName == "SM " )
02317             {fT1d_av_hifn[i0StexStinEcna] += fT1d_evevt_of_sigsamp[i0StexEcha];}
02318           
02319           if( fStexName == "Dee" )
02320             {
02321               //---------------- Special translation for mixed SCEcna (29 and 32)
02322               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02323               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02324               Int_t n1StinEcha = i0StinEcha+1;
02325               if( n1StexStinEcna == 10 &&  n1StinEcha == 11 )
02326                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02327               if( n1StexStinEcna == 11 &&  n1StinEcha == 11 )
02328                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02329               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02330                 {fT1d_av_hifn[i0StexStinEcna] += fT1d_evevt_of_sigsamp[i0StexEcha];}
02331             }
02332         }
02333       Double_t xdivis = (Double_t)0.;
02334       if( fStexName == "SM "  )
02335         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02336       if( fStexName == "Dee" )
02337         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02338 
02339       fT1d_av_hifn[i0StexStinEcna] = fT1d_av_hifn[i0StexStinEcna]/xdivis;
02340     }
02341   fTagAvHfn[0] = 1;                      fFileHeader->fAvHfnCalc++;  
02342 }
02343 //-----------------------------------------------------------------------------
02344 //
02345 // Calculation of the average of the mean of cor(s,s) for each Stin in Stex
02346 // tag: AvMeanCorss
02347 //      
02348 //-----------------------------------------------------------------------------
02349 void TEcnaRun::AveragedMeanOfCorrelationsBetweenSamples()
02350 {
02351 // Calculation of the average 
02352 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the mean of cor(s,s)
02353   
02354   //... preliminary calculation of the mean of cor(s,s) if not done yet
02355   if ( fTagMeanCorss[0] != 1 ){MeanOfCorrelationsBetweenSamples(); fTagMeanCorss[0]=0;}
02356   //................... Allocation av_ev_corss + init to zero (mandatory)
02357   if( fT1d_av_ev_corss == 0 ){fT1d_av_ev_corss = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02358   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02359     {if( fT1d_av_ev_corss[i0StexStinEcna] != (Double_t)0 )
02360       {fMiscDiag[45]++; fT1d_av_ev_corss[i0StexStinEcna] = (Double_t)0;}}
02361 
02362   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedMeanOfCorrelationsBetweenSamples()" << endl;}
02363   if(fFlagPrint == fCodePrintAllComments){
02364     cout << "           Calculation, for all the "
02365          << fStinName.Data() << "s, of the average of the mean of cor(s,s)" << endl;}
02366 
02367   //................... Calculation
02368   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02369     {
02370       Int_t n1StexStinEcna = i0StexStinEcna+1;
02371       fT1d_av_ev_corss[i0StexStinEcna] = (Double_t)0;
02372       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02373         {
02374           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02375 
02376           if( fStexName == "SM " )
02377             {fT1d_av_ev_corss[i0StexStinEcna] += fT1d_ev_cor_ss[i0StexEcha];}
02378           
02379           if( fStexName == "Dee" )
02380             {
02381               //---------------- Special translation for mixed SCEcna (29 and 32)
02382               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02383               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02384               Int_t n1StinEcha = i0StinEcha+1;
02385               if( n1StexStinEcna == 10 &&  n1StinEcha == 11 )
02386                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02387               if( n1StexStinEcna == 11 &&  n1StinEcha == 11 )
02388                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02389               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02390                 {fT1d_av_ev_corss[i0StexStinEcna] += fT1d_ev_cor_ss[i0StexEcha];}
02391             }
02392         }
02393       Double_t xdivis = (Double_t)0.;
02394       if( fStexName == "SM "  )
02395         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02396       if( fStexName == "Dee" )
02397         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02398 
02399       fT1d_av_ev_corss[i0StexStinEcna] = fT1d_av_ev_corss[i0StexStinEcna]/xdivis;
02400     }
02401   fTagAvMeanCorss[0] = 1;                      fFileHeader->fAvMeanCorssCalc++;    
02402 }
02403 //-----------------------------------------------------------------------------
02404 //
02405 // Calculation of the average of the sigma of cor(s,s) for each Stin in Stex
02406 // tag: AvSigCorss
02407 //      
02408 //-----------------------------------------------------------------------------
02409 void TEcnaRun::AveragedSigmaOfCorrelationsBetweenSamples()
02410 {
02411 // Calculation of the average 
02412 // (over the Stin's 0 to fEcal->MaxStinInStex()) of the sigma of cor(s,s)
02413   
02414   //... preliminary calculation of the sigma of cor(s,s) if not done yet
02415   if ( fTagSigCorss[0] != 1 ){SigmaOfCorrelationsBetweenSamples(); fTagSigCorss[0]=0;}
02416   //................... Allocation av_sig_corss + init to zero (mandatory)
02417   if( fT1d_av_sig_corss == 0 ){fT1d_av_sig_corss = new Double_t[fEcal->MaxStinEcnaInStex()]; fCnew++;}
02418   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02419     {if( fT1d_av_sig_corss[i0StexStinEcna] != (Double_t)0 )
02420       {fMiscDiag[46]++; fT1d_av_sig_corss[i0StexStinEcna] = (Double_t)0;}}
02421 
02422   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::AveragedSigmaOfCorrelationsBetweenSamples()" << endl;}
02423   if(fFlagPrint == fCodePrintAllComments){
02424     cout << "           Calculation, for all the "
02425          << fStinName.Data() << "s, of the average of the sigma of cor(s,s)" << endl;}
02426 
02427   //................... Calculation
02428   for(Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02429     {
02430       Int_t n1StexStinEcna = i0StexStinEcna+1;
02431       fT1d_av_sig_corss[i0StexStinEcna] = (Double_t)0;
02432       for(Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++)
02433         {
02434           Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStinEcna, i0StinEcha);
02435 
02436           if( fStexName == "SM " )
02437             {fT1d_av_sig_corss[i0StexStinEcna] += fT1d_sig_cor_ss[i0StexEcha];}
02438           
02439           if( fStexName == "Dee" )
02440             {
02441               //---------------- Special translation for mixed SCEcna (29 and 32)
02442               //                 Xtal 11 of SCEcna 29 -> Xtal 11 of SCEcna 10
02443               //                 Xtal 11 of SCEcna 32 -> Xtal 11 of SCEcna 11
02444               Int_t n1StinEcha = i0StinEcha+1;
02445               if( n1StexStinEcna == 10 &&  n1StinEcha == 11 )
02446                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);}
02447               if( n1StexStinEcna == 11 &&  n1StinEcha == 11 )
02448                 {i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);}
02449               if( !( (n1StexStinEcna == 29 || n1StexStinEcna == 32) && n1StinEcha == 11 )  )
02450                 {fT1d_av_sig_corss[i0StexStinEcna] += fT1d_sig_cor_ss[i0StexEcha];}
02451             }
02452         }
02453       Double_t xdivis = (Double_t)0.;
02454       if( fStexName == "SM "  )
02455         {xdivis = (Double_t)fEcal->MaxCrysInStin();}
02456       if( fStexName == "Dee" )
02457         {xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStinEcna, "TEcnaRun");}
02458 
02459       fT1d_av_sig_corss[i0StexStinEcna] = fT1d_av_sig_corss[i0StexStinEcna]/xdivis;
02460     }
02461   fTagAvSigCorss[0] = 1;                      fFileHeader->fAvSigCorssCalc++;       
02462 }
02463 
02464 //====================================================================
02465 //
02466 //       C O V A R I A N C E S   &   C O R R E L A T I O N S
02467 //
02468 //                 B E T W E E N   C H A N N E L S
02469 //
02470 //====================================================================
02471 //------------------------------------------------------------------
02472 //
02473 //  Calculation of the Low Frequency Covariances between channels
02474 //
02475 //------------------------------------------------------------------
02476 void TEcnaRun::LowFrequencyCovariancesBetweenChannels()
02477 {
02478 //Calculation of the Low Frequency Covariances between channels
02479   
02480   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyCovariancesBetweenChannels()" << endl;}
02481   if(fFlagPrint == fCodePrintAllComments){
02482     cout << "           Calculation of the Low Frequency Covariances between channels" << endl;}
02483 
02484   //................. allocation fT2d_lf_cov + init to zero (mandatory)
02485   if( fT2d_lf_cov == 0 ){
02486     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
02487     fT2d_lf_cov  = new Double_t*[n_StexEcha];                   fCnew++;
02488     fT2d1_lf_cov = new  Double_t[n_StexEcha*n_StexEcha];          fCnew++;
02489     for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
02490         fT2d_lf_cov[i0StexEcha] = &fT2d1_lf_cov[0] + i0StexEcha*n_StexEcha;}}
02491 
02492   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02493     {
02494       for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
02495         {
02496           if( fT2d_lf_cov[i0StexEcha][j0StexEcha] != (Double_t)0 )
02497             {fMiscDiag[21]++; fT2d_lf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;}
02498         }
02499     }
02500   //........................................... Calculation  (LowFrequencyCovariancesBetweenChannels)
02501   //................... Allocation mean_over_samples(i0StexEcha, n_event)
02502   TMatrixD mean_over_samples(fEcal->MaxCrysEcnaInStex(), fNumberOfEvents);
02503   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02504     {for(Int_t n_event=0; n_event<fNumberOfEvents; n_event++)
02505         {mean_over_samples(i0StexEcha, n_event)=(Double_t)0.;}}
02506   //................... Allocation MoeOfMos(i0StexEcha)
02507   TVectorD MoeOfMos(fEcal->MaxCrysEcnaInStex());
02508   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02509     { MoeOfMos(i0StexEcha)=(Double_t)0.;}
02510 
02511   //................... Calculation  
02512   if(fFlagPrint != fCodePrintNoComment){
02513     cout << "          Calculation, for each pair of channels, of the covariance (over the events)" << endl
02514          << "          between the ADC expectation values (over the samples 1 to "
02515          <<  fNbSampForCalc << ")." << endl;}
02516 
02517   cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
02518 
02519   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02520     {
02521       MoeOfMos(i0StexEcha) = (Double_t)0;
02522 
02523       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02524           || ( fFlagSubDet == "EB") )
02525         {
02526           for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02527             {
02528               // Calculation, for each event, of the mean over the samples  ( = E_s[A(c_i,s*,e_n] )
02529               mean_over_samples(i0StexEcha, n_event) = (Double_t)0.;
02530               for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
02531                 {
02532                   mean_over_samples(i0StexEcha, n_event) += fT3d_distribs[i0StexEcha][i0Sample][n_event];
02533                 }
02534               mean_over_samples(i0StexEcha, n_event) /= (Double_t)fNbSampForCalc;
02535             }
02536           //Calculation of the mean over the events of E_s[A(c_i,s*,e_n] ( = E_e[E_s[A(c_i,s*,e*]] )
02537           for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02538             {MoeOfMos(i0StexEcha) += mean_over_samples(i0StexEcha, n_event);}
02539           MoeOfMos(i0StexEcha) /= (Double_t)fNumberOfEvents;
02540         }
02541     }
02542 
02543   //... Calculation of half of the matrix, diagonal included        (LowFrequencyCovariancesBetweenChannels)
02544   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02545     {
02546       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02547           || ( fFlagSubDet == "EB") )
02548         {
02549           for(Int_t j0StexEcha = 0; j0StexEcha <= i0StexEcha; j0StexEcha++)
02550             {
02551               if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
02552                   || ( fFlagSubDet == "EB") )
02553                 {
02554                   fT2d_lf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;
02555                   for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02556                     {
02557                       fT2d_lf_cov[i0StexEcha][j0StexEcha] +=
02558                         ( mean_over_samples(i0StexEcha, n_event) - MoeOfMos(i0StexEcha) )
02559                         *( mean_over_samples(j0StexEcha, n_event) - MoeOfMos(j0StexEcha) );    
02560                     }
02561                   fT2d_lf_cov[i0StexEcha][j0StexEcha] /= (Double_t)fNumberOfEvents;
02562                   
02563                   fT2d_lf_cov[j0StexEcha][i0StexEcha] = fT2d_lf_cov[i0StexEcha][j0StexEcha];
02564                 }
02565             }
02566           if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[LFN Cov], ";}
02567         }
02568     }
02569   cout << endl;
02570   fTagLfCov[0] = 1;    fFileHeader->fLfCovCalc++;
02571 }
02572 //---------- (end of LowFrequencyCovariancesBetweenChannels ) --------------------
02573 
02574 //------------------------------------------------------------------
02575 //
02576 //  Calculation of the Low Frequency Correlations between channels
02577 //
02578 //------------------------------------------------------------------
02579 void TEcnaRun::LowFrequencyCorrelationsBetweenChannels()
02580 {
02581 //Calculation of the Low Frequency Correlations between channels
02582 
02583   //... preliminary calculation of the covariances if not done yet.
02584   if ( fTagLfCov[0] != 1 )
02585     {LowFrequencyCovariancesBetweenChannels(); fTagLfCov[0] = 0;}
02586   
02587   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyCorrelationsBetweenChannels()" << endl;}
02588   if(fFlagPrint == fCodePrintAllComments){
02589     cout << "          Calculation of the Low Frequency Correlations between channels" << endl
02590          << "          Starting allocation. "
02591          << endl;}
02592 
02593   //................. allocation fT2d_lf_cor + init to zero (mandatory)
02594   if( fT2d_lf_cor == 0 ){
02595     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
02596     fT2d_lf_cor  = new Double_t*[n_StexEcha];                   fCnew++;
02597     fT2d1_lf_cor = new  Double_t[n_StexEcha*n_StexEcha];        fCnew++;
02598     for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
02599         fT2d_lf_cor[i0StexEcha] = &fT2d1_lf_cor[0] + i0StexEcha*n_StexEcha;} 
02600   }
02601   
02602   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02603     {
02604       for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
02605         {
02606           if( fT2d_lf_cor[i0StexEcha][j0StexEcha] != (Double_t)0 )
02607             {fMiscDiag[22]++; fT2d_lf_cor[i0StexEcha][j0StexEcha] = (Double_t)0;}
02608         }
02609     }
02610   
02611   //................. calculation  
02612   //........................... computation of half of the matrix, diagonal included
02613   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02614     {
02615       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02616           || ( fFlagSubDet == "EB") )
02617         {
02618           for (Int_t j0StexEcha = 0 ; j0StexEcha <= i0StexEcha ; j0StexEcha++)
02619             {
02620               if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
02621                   || ( fFlagSubDet == "EB") )
02622                 {
02623                   if(  fT2d_lf_cov[i0StexEcha][i0StexEcha] > 0
02624                        && fT2d_lf_cov[j0StexEcha][j0StexEcha] > 0 )
02625                     {
02626                       fT2d_lf_cor[i0StexEcha][j0StexEcha] =
02627                         fT2d_lf_cov[i0StexEcha][j0StexEcha]/
02628                         ( (Double_t)sqrt( fT2d_lf_cov[i0StexEcha][i0StexEcha]*
02629                                           fT2d_lf_cov[j0StexEcha][j0StexEcha] ) );
02630                     }
02631                   else
02632                     {
02633                       fT2d_lf_cor[i0StexEcha][j0StexEcha] = (Double_t)0.;
02634                     }
02635                   fT2d_lf_cor[j0StexEcha][i0StexEcha] = fT2d_lf_cor[i0StexEcha][j0StexEcha];
02636                 }
02637             }
02638         }
02639       if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[LFN Cor], ";}
02640     }
02641   cout << endl;
02642   
02643   fTagLfCor[0] = 1;    fFileHeader->fLfCorCalc++;
02644 }
02645 //--------------- (end of LowFrequencyCorrelationsBetweenChannels) --------------------
02646 
02647 //------------------------------------------------------------------
02648 //
02649 //  Calculation of the High Frequency Covariances between channels
02650 //
02651 //------------------------------------------------------------------
02652 void TEcnaRun::HighFrequencyCovariancesBetweenChannels()
02653 {
02654 //Calculation of the High Frequency Covariances between channels
02655   
02656   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyCovariancesBetweenChannels()" << endl;}
02657   if(fFlagPrint == fCodePrintAllComments){
02658     cout << "           Calculation of the High Frequency Covariances between channels" << endl;}
02659 
02660   //................. allocation fT2d_hf_cov + init to zero (mandatory)
02661   if( fT2d_hf_cov == 0 ){
02662     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
02663     fT2d_hf_cov   = new Double_t*[n_StexEcha];                   fCnew++;
02664     fT2d1_hf_cov  = new  Double_t[n_StexEcha*n_StexEcha];        fCnew++;
02665     for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
02666         fT2d_hf_cov[i0StexEcha] = &fT2d1_hf_cov[0] + i0StexEcha*n_StexEcha;} 
02667   }
02668 
02669   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02670     {
02671       for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
02672         {
02673           if( fT2d_hf_cov[i0StexEcha][j0StexEcha] != (Double_t)0 )
02674             {fMiscDiag[23]++; fT2d_hf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;}
02675         }
02676     }
02677 
02678   //................... Allocation mean_over_samples(i0StexEcha, n_event) 
02679   TMatrixD mean_over_samples(fEcal->MaxCrysEcnaInStex(), fNumberOfEvents);
02680   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02681     {for(Int_t n_event=0; n_event<fNumberOfEvents; n_event++)
02682         {mean_over_samples(i0StexEcha, n_event)=(Double_t)0.;}}
02683   //................... Allocation cov_over_samp(i0StexEcha,j0StexEcha)
02684   TMatrixD cov_over_samp(fEcal->MaxCrysEcnaInStex(), fEcal->MaxCrysEcnaInStex());
02685   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02686     {for(Int_t j0StexEcha=0; j0StexEcha<fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
02687         {cov_over_samp(i0StexEcha, j0StexEcha)=(Double_t)0.;}}
02688 
02689   //........................................... Calculation    (HighFrequencyCovariancesBetweenChannels)
02690   if(fFlagPrint != fCodePrintNoComment){
02691     cout << "          Calculation of the mean (over the events)" << endl
02692          << "          of the covariances between the channels (over the samples 1 to "
02693          <<  fNbSampForCalc << ")." << endl;}
02694 
02695   cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
02696 
02697   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02698     {
02699       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02700           || ( fFlagSubDet == "EB") )
02701         {
02702           for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02703             {
02704               // Calculation, for each event, of the mean over the samples  ( = E_s[A(c_i,s*,e_n] )
02705               mean_over_samples(i0StexEcha, n_event) = (Double_t)0.;
02706               for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
02707                 {mean_over_samples(i0StexEcha, n_event) += fT3d_distribs[i0StexEcha][i0Sample][n_event];}
02708               mean_over_samples(i0StexEcha, n_event) /= (Double_t)fNbSampForCalc;
02709             }
02710         }
02711       if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFNa Cov], ";}
02712     }
02713   cout << endl;
02714 
02715   cout << " Please, wait (end at i= " << fEcal->MaxCrysEcnaInStex() << "): " << endl;
02716 
02717   //... Calculation of half of the matrix, diagonal included    (HighFrequencyCovariancesBetweenChannels)
02718   for(Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
02719     {
02720       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02721           || ( fFlagSubDet == "EB") )
02722         {
02723           for(Int_t j0StexEcha = 0; j0StexEcha <= i0StexEcha; j0StexEcha++)
02724             {
02725               if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
02726                   || ( fFlagSubDet == "EB") )
02727                 {
02728                   for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02729                     {
02730                       // Calculation, for each event, of the covariance over the samples
02731                       cov_over_samp(i0StexEcha,j0StexEcha) = (Double_t)0;
02732                       for(Int_t i0Sample=0; i0Sample<fNbSampForCalc; i0Sample++)
02733                         {
02734                           cov_over_samp(i0StexEcha,j0StexEcha) +=
02735                             ( fT3d_distribs[i0StexEcha][i0Sample][n_event] - mean_over_samples(i0StexEcha, n_event) )*
02736                             ( fT3d_distribs[j0StexEcha][i0Sample][n_event] - mean_over_samples(j0StexEcha, n_event) );
02737                         }
02738                       cov_over_samp(i0StexEcha,j0StexEcha) /= (Double_t)fNbSampForCalc;
02739 
02740                     }
02741                   //....... Calculation of the mean over the events of Cov_s[A(c_i,s*,e*),A(c_j,s*,e*)]
02742                   //......... Calculation of half of the matrix, diagonal included
02743                   fT2d_hf_cov[i0StexEcha][j0StexEcha] = (Double_t)0;
02744                   for (Int_t n_event = 0; n_event < fNumberOfEvents; n_event++)
02745                     {
02746                       fT2d_hf_cov[i0StexEcha][j0StexEcha] += cov_over_samp(i0StexEcha,j0StexEcha);
02747                     }
02748                     fT2d_hf_cov[i0StexEcha][j0StexEcha] /= (Double_t)fNumberOfEvents;
02749                   
02750                   fT2d_hf_cov[j0StexEcha][i0StexEcha] = fT2d_hf_cov[i0StexEcha][j0StexEcha];
02751                 }
02752             }
02753         }
02754       if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFNb Cov], ";}
02755     }
02756   cout << endl;
02757 
02758   fTagHfCov[0] = 1;    fFileHeader->fHfCovCalc++;
02759 }
02760 //---------- (end of HighFrequencyCovariancesBetweenChannels ) --------------------
02761 
02762 //------------------------------------------------------------------
02763 //
02764 //  Calculation of the High Frequency Correlations between channels
02765 //
02766 //------------------------------------------------------------------
02767 void TEcnaRun::HighFrequencyCorrelationsBetweenChannels()
02768 {
02769 //Calculation of the High Frequency Correlations between channels
02770 
02771   //... preliminary calculation of the covariances if not done yet.
02772   if ( fTagHfCov[0] != 1 )
02773     {HighFrequencyCovariancesBetweenChannels(); fTagHfCov[0] = 0;}
02774   
02775   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyCorrelationsBetweenChannels()" << endl;}
02776   if(fFlagPrint == fCodePrintAllComments){
02777     cout << "           Calculation of the High Frequency Correlations between channels" << endl
02778          << "          Starting allocation. "
02779          << endl;}
02780 
02781   //................. allocation fT2d_hf_cor + init to zero (mandatory)
02782   if( fT2d_hf_cor == 0 ){
02783     const Int_t n_StexEcha = fEcal->MaxCrysEcnaInStex();
02784     fT2d_hf_cor  = new Double_t*[n_StexEcha];                   fCnew++;
02785     fT2d1_hf_cor = new  Double_t[n_StexEcha*n_StexEcha];        fCnew++;
02786     for(Int_t i0StexEcha = 0 ; i0StexEcha < n_StexEcha ; i0StexEcha++){
02787         fT2d_hf_cor[i0StexEcha] = &fT2d1_hf_cor[0] + i0StexEcha*n_StexEcha;} 
02788   }
02789 
02790   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02791     {
02792       for (Int_t j0StexEcha = 0 ; j0StexEcha < fEcal->MaxCrysEcnaInStex() ; j0StexEcha++)
02793         {
02794           if( fT2d_hf_cor[i0StexEcha][j0StexEcha] != (Double_t)0 )
02795             {fMiscDiag[24]++; fT2d_hf_cor[i0StexEcha][j0StexEcha] = (Double_t)0;}
02796         }
02797     }
02798   
02799   //................. calculation  
02800   //........................... computation of half of the matrix, diagonal included
02801   
02802   for (Int_t i0StexEcha = 0 ; i0StexEcha < fEcal->MaxCrysEcnaInStex() ; i0StexEcha++)
02803     {
02804       if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, i0StexEcha) > 0)
02805           || ( fFlagSubDet == "EB") )
02806         {
02807           for (Int_t j0StexEcha = 0 ; j0StexEcha <= i0StexEcha ; j0StexEcha++)
02808             {
02809               if( (fFlagSubDet == "EE" && fEcalNumbering->StexEchaForCons(fFileHeader->fStex, j0StexEcha) > 0)
02810                   || ( fFlagSubDet == "EB") )
02811                 {
02812                   if(  fT2d_hf_cov[i0StexEcha][i0StexEcha] > 0
02813                        && fT2d_hf_cov[j0StexEcha][j0StexEcha] > 0 )
02814                     {
02815                       fT2d_hf_cor[i0StexEcha][j0StexEcha] =
02816                         fT2d_hf_cov[i0StexEcha][j0StexEcha]/
02817                         (  (Double_t)sqrt(fT2d_hf_cov[i0StexEcha][i0StexEcha]) *
02818                            (Double_t)sqrt(fT2d_hf_cov[j0StexEcha][j0StexEcha])  );
02819                     }
02820                   else
02821                     {
02822                       fT2d_hf_cor[i0StexEcha][j0StexEcha] = (Double_t)0.;
02823                     }
02824                   
02825                   fT2d_hf_cor[j0StexEcha][i0StexEcha] = fT2d_hf_cor[i0StexEcha][j0StexEcha];
02826                 }
02827             }
02828         }
02829       if( i0StexEcha%100 == 0 ){cout << i0StexEcha << "[HFN Cor], ";}
02830     }
02831   cout << endl;  
02832   
02833   fTagHfCor[0] = 1;    fFileHeader->fHfCorCalc++;
02834 }
02835 //------- (end of HighFrequencyCorrelationsBetweenChannels) ----------
02836 
02837 //=================================================================================
02838 //
02839 //          L O W  &  H I G H    F R E Q U E N C Y    C O R R E L A T I O N S
02840 //
02841 //       B E T W E E N   T O W E R S  ( E B )  O R   S C s   ( E E )
02842 //
02843 //=================================================================================
02844 //-----------------------------------------------------------------------------
02845 //      Calculation of the mean of the Low Frequency Correlations
02846 //      between channels for each Stin
02847 //-----------------------------------------------------------------------------
02848 void TEcnaRun::LowFrequencyMeanCorrelationsBetweenTowers()
02849 {LowFrequencyMeanCorrelationsBetweenStins();}
02850 void TEcnaRun::LowFrequencyMeanCorrelationsBetweenSCs()
02851 {LowFrequencyMeanCorrelationsBetweenStins();}
02852 
02853 void TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()
02854 {
02855 //Calculation of the mean of the Low Frequency Correlations
02856 //between channels for each Stin
02857 
02858   //... preliminary calculation of the Low Frequency Cor(c,c) if not done yet
02859   //    Only one tag (dim=1) to set to 0 (no write in the result ROOT file)
02860   if(fTagLfCor[0] != 1){LowFrequencyCorrelationsBetweenChannels(); fTagLfCor[0]=0;}
02861 
02862   //..... mean of the fT2d_lfcc_mostins for each pair (Stin_X,Stin_Y)
02863   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()" << endl;}
02864   if(fFlagPrint == fCodePrintAllComments){
02865     cout << "           Calculation of the mean, for each "
02866          << fStinName.Data() << ", of the" << endl
02867          << "           Low Frequency Correlations between channels." << endl;}
02868   
02869   //................. allocation fT2d_lfcc_mostins + init to zero (mandatory)
02870   if( fT2d_lfcc_mostins == 0 ){
02871     const Int_t n_Stin = fEcal->MaxStinEcnaInStex();
02872     fT2d_lfcc_mostins  = new Double_t*[n_Stin];                 fCnew++;
02873     fT2d1_lfcc_mostins = new  Double_t[n_Stin*n_Stin];          fCnew++;  
02874     for(Int_t i0StexStinEcna = 0 ; i0StexStinEcna < n_Stin ; i0StexStinEcna++){
02875         fT2d_lfcc_mostins[i0StexStinEcna] = &fT2d1_lfcc_mostins[0] + i0StexStinEcna*n_Stin;} 
02876   }
02877   
02878   for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02879     {
02880       for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
02881         {
02882           if( fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] != (Double_t)0 )
02883             {fMiscDiag[31]++; fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;}
02884         }
02885     }
02886 
02887   //..... Calculation of the mean of the LF Cor(c,c) for each pair (Stin_X,Stin_Y)
02888   //
02889   //           ! => Warning: this matrix is NOT symmetric => take N*N elements
02890   //                Only (Stin,Stin) matrix is symmetric.
02891   //                (StinEcha,StinEcha) matrix inside a (Stin,Stin) element is NOT symmetric
02892   //                (except for the (Stin,Stin) DIAGONAL elements)
02893   //      Then:
02894   //            1D array half_LFccMos[N*N] to put the (channel,channel) correlations
02895 
02896   Int_t ndim = (Int_t)(fEcal->MaxCrysInStin()*fEcal->MaxCrysInStin());
02897 
02898   TVectorD  half_LFccMos(ndim); for(Int_t i=0; i<ndim; i++){half_LFccMos(i)=(Double_t)0.;}
02899 
02900   //..................... Calculation
02901   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()" << endl;}
02902   if(fFlagPrint == fCodePrintAllComments){
02903     cout << "           Calculation, for each "
02904          << fStinName.Data() << ", of the mean of the" << endl
02905          << "           Low Frequency cor(c,c)." << endl;}
02906 
02907   for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02908     {
02909       for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
02910         {
02911           //................... .Copy the Mean Correlations(c,c') in 1D vector half_LFccMos() 
02912           Int_t i_count = 0;
02913           for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
02914             {
02915               Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinCrys;
02916               for(Int_t j0StinCrys=0; j0StinCrys<fEcal->MaxCrysInStin(); j0StinCrys++)
02917                 {
02918                   Int_t j0StexEcha = j0StexStinEcna*fEcal->MaxCrysInStin() + j0StinCrys;
02919                   if(  (i0StexEcha>= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex()) &&
02920                        (j0StexEcha>= 0 && j0StexEcha < fEcal->MaxCrysEcnaInStex())  )
02921                   {half_LFccMos(i_count) = fT2d_lf_cor[i0StexEcha][j0StexEcha]; i_count++;}
02922                   else
02923                     {cout << "!TEcnaRun::LowFrequencyMeanCorrelationsBetweenStins()> Channel number out of range."
02924                           << "i0StexEcha = " << i0StexEcha <<", j0StexEcha = " << j0StexEcha << fTTBELL << endl; }
02925                 }
02926             }
02927           //...... Calculation of the mean of the absolute values of the LF mean Correlations(c,c')
02928           fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;
02929           for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
02930             {
02931               fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] += fabs(half_LFccMos(i_rcor));
02932             }
02933           fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna] /= (Double_t)ndim;
02934         }
02935       if( i0StexStinEcna%10 == 0 ){cout << i0StexStinEcna << "[LFN MCtt], ";}
02936     }
02937   cout << endl;
02938 
02939   fTagLFccMoStins[0] = 1;           fFileHeader->fLFccMoStinsCalc++;
02940 } // ------- end of LowFrequencyMeanCorrelationsBetweenStins() -------
02941 
02942 //-----------------------------------------------------------------------------
02943 //      Calculation of the mean of the High Frequency Correlations
02944 //      between channels for each Stin
02945 //-----------------------------------------------------------------------------
02946 void TEcnaRun::HighFrequencyMeanCorrelationsBetweenTowers()
02947 {HighFrequencyMeanCorrelationsBetweenStins();}
02948 void TEcnaRun::HighFrequencyMeanCorrelationsBetweenSCs()
02949 {HighFrequencyMeanCorrelationsBetweenStins();}
02950 
02951 void TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()
02952 {
02953 //Calculation of the mean of the High Frequency Correlations
02954 //between channels for each Stin
02955 
02956   //... preliminary calculation of the High Frequency Cor(c,c) if not done yet
02957   //    Only one tag (dim=1) to set to 0 (no write in the result ROOT file)
02958   if(fTagHfCor[0] != 1){HighFrequencyCorrelationsBetweenChannels();fTagHfCor[0]=0;}
02959 
02960   //..... mean of the fT2d_hfcc_mostins for each pair (Stin_X,Stin_Y)
02961   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()" << endl;}
02962   if(fFlagPrint == fCodePrintAllComments){
02963     cout << "           Calculation of the mean, for each "
02964          << fFlagSubDet.Data() << ", of the" << endl
02965          << "           High Frequency Correlations between channels." << endl;}
02966 
02967   //................. allocation fT2d_hfcc_mostins + init to zero (mandatory)
02968   if( fT2d_hfcc_mostins == 0 ){
02969     const Int_t n_Stin = fEcal->MaxStinEcnaInStex();
02970     fT2d_hfcc_mostins  = new Double_t*[n_Stin];                 fCnew++;
02971     fT2d1_hfcc_mostins = new  Double_t[n_Stin*n_Stin];           fCnew++;  
02972     for(Int_t i0StexStinEcna = 0 ; i0StexStinEcna < n_Stin ; i0StexStinEcna++){
02973         fT2d_hfcc_mostins[i0StexStinEcna] = &fT2d1_hfcc_mostins[0] + i0StexStinEcna*n_Stin;} 
02974   }
02975   
02976   for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
02977     {
02978       for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
02979         {
02980           if( fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] != (Double_t)0 )
02981             {fMiscDiag[32]++; fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;}
02982         }
02983     }
02984 
02985   //..... Calculation of the mean of the HF Cor(c,c) for each pair (Stin_X,Stin_Y)
02986   //
02987   //           ! => Warning: this matrix is NOT symmetric => take N*N elements
02988   //                Only (Stin,Stin) matrix is symmetric.
02989   //                (StinEcha,StinEcha) matrix inside a (Stin,Stin) element is NOT symmetric
02990   //                (except for the (Stin,Stin) DIAGONAL elements)
02991   //      Then:
02992   //            1D array half_LFccMos[N*N] to put the (channel,channel) correlations
02993 
02994   Int_t ndim = (Int_t)(fEcal->MaxCrysInStin()*fEcal->MaxCrysInStin());
02995 
02996   TVectorD half_HFccMos(ndim); for(Int_t i=0; i<ndim; i++){half_HFccMos(i)=(Double_t)0.;}
02997 
02998   if(fFlagPrint != fCodePrintNoComment){cout << "*TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()" << endl;}
02999   if(fFlagPrint == fCodePrintAllComments){
03000     cout << "           Calculation, for each "
03001          << fFlagSubDet.Data()  << ", of the mean of the" << endl
03002          << "           High Frequency cor(c,c)." << endl;}
03003 
03004   //..................... Calculation
03005   for(Int_t i0StexStinEcna=0; i0StexStinEcna<fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
03006     {
03007       for(Int_t j0StexStinEcna=0; j0StexStinEcna<fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
03008         {
03009           //.................... Copy the relevant Mean Correlations(c,c') in 1D vector half_HFccMos()
03010           Int_t i_count = 0;
03011           for(Int_t i0StinCrys=0; i0StinCrys<fEcal->MaxCrysInStin(); i0StinCrys++)
03012             {
03013               Int_t i0StexEcha = i0StexStinEcna*fEcal->MaxCrysInStin() + i0StinCrys;
03014               for(Int_t j0StinCrys=0; j0StinCrys<fEcal->MaxCrysInStin(); j0StinCrys++)
03015                 {
03016                   Int_t j0StexEcha = j0StexStinEcna*fEcal->MaxCrysInStin() + j0StinCrys;
03017                   if(  (i0StexEcha>= 0 && i0StexEcha < fEcal->MaxCrysEcnaInStex()) &&
03018                        (j0StexEcha>= 0 && j0StexEcha < fEcal->MaxCrysEcnaInStex())  )
03019                     {half_HFccMos(i_count) = fT2d_hf_cor[i0StexEcha][j0StexEcha]; i_count++;}
03020                   else
03021                     {cout << "!TEcnaRun::HighFrequencyMeanCorrelationsBetweenStins()> Channel number out of range."
03022                           << "i0StexEcha = " << i0StexEcha <<", j0StexEcha = " << j0StexEcha << fTTBELL << endl; }
03023                 }
03024             }
03025           //..... Calculation of the mean of the absolute values of the HF mean Correlations(c,c')
03026           fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] = (Double_t)0;
03027           for(Int_t i_rcor = 0; i_rcor < ndim; i_rcor++)
03028             {
03029               fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] += fabs(half_HFccMos(i_rcor));
03030             }
03031           fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna] /= (Double_t)ndim;
03032         }
03033       if( i0StexStinEcna%10 == 0 ){cout << i0StexStinEcna << "[HFN MCtt], ";}
03034     }
03035   cout << endl;
03036 
03037   fTagHFccMoStins[0] = 1;                   fFileHeader->fHFccMoStinsCalc++;
03038 } // ------- end of HighFrequencyMeanCorrelationsBetweenStins() -------
03039 
03040 //=========================================================================
03041 //
03042 //                  W R I T I N G     M E T H O D S
03043 //
03044 //=========================================================================
03045 
03046 //=========================================================================
03047 //
03048 //         W R I T I N G   M E T H O D S :    R O O T    F I L E S
03049 //
03050 //=========================================================================
03051 //-------------------------------------------------------------
03052 //
03053 //                      OpenRootFile
03054 //
03055 //-------------------------------------------------------------
03056 Bool_t TEcnaRun::OpenRootFile(const Text_t *name, TString status) {
03057 //Open the Root file
03058 
03059   TString s_path;
03060   s_path = fCnaParPaths->ResultsRootFilePath();
03061   s_path.Append('/');
03062   s_path.Append(name);
03063   
03064   gCnaRootFile   = new TEcnaRootFile(s_path.Data(), status);     fCnew++;
03065   Bool_t ok_open = kFALSE;
03066 
03067   if ( gCnaRootFile->fRootFileStatus == "RECREATE" ){ok_open = gCnaRootFile->OpenW();}
03068   if ( gCnaRootFile->fRootFileStatus == "READ"     ){ok_open = gCnaRootFile->OpenR();}
03069 
03070   if (!ok_open) // unable to open file
03071     {
03072       cout << "TEcnaRun::OpenRootFile> Cannot open file " << s_path.Data() << endl;
03073     }
03074   else
03075     {
03076       if(fFlagPrint == fCodePrintAllComments)
03077         {cout << "*TEcnaRun::OpenRootFile> Open ROOT file OK for file " << s_path.Data() << endl;}  
03078       fOpenRootFile  = kTRUE;
03079     }
03080   return ok_open;
03081 }
03082 //-------------------------------------------------------------
03083 //
03084 //                      CloseRootFile
03085 //
03086 //-------------------------------------------------------------
03087 Bool_t TEcnaRun::CloseRootFile(const Text_t *name) {
03088 //Close the Root file
03089  
03090   Bool_t ok_close = kFALSE;
03091 
03092   if (fOpenRootFile == kTRUE ) 
03093     {
03094       gCnaRootFile->CloseFile();
03095 
03096       if(fFlagPrint == fCodePrintAllComments){
03097         cout << "*TEcnaRun::CloseRootFile> Close ROOT file." << endl;}
03098 
03099       delete gCnaRootFile;                                     fCdelete++;
03100       fOpenRootFile = kFALSE;
03101       ok_close      = kTRUE;
03102     }
03103   else
03104     {
03105       cout << "*TEcnaRun::CloseRootFile(...)> No close since no file is open."
03106            << fTTBELL << endl;
03107     }
03108   return ok_close;
03109 }
03110 //-------------------------------------------------------------
03111 //
03112 //   WriteRootFile without arguments.
03113 //   Call WriteRootFile WITH argument (file name)
03114 //   after an automatic generation of the file name.
03115 //
03116 //   Codification for the file name:
03117 //            see comment at the beginning of this file
03118 //
03119 //-------------------------------------------------------------
03120 
03121 //=================================================================================
03122 //
03123 //         WriteRootFile()   ====>  D O N ' T    S U P P R E S S  ! ! !
03124 //                                  Called by the analyzer in package: "Modules"
03125 //
03126 //=================================================================================
03127 Bool_t TEcnaRun::WriteRootFile(){
03128 //Write the Root file. File name automatically generated in fMakeResultsFileName.
03129   Bool_t ok_write = kFALSE;
03130 
03131   fCnaWrite->RegisterFileParameters(fFileHeader->fTypAna.Data(), fFileHeader->fNbOfSamples,
03132                                     fFileHeader->fRunNumber,
03133                                     fFileHeader->fFirstReqEvtNumber, fFileHeader->fLastReqEvtNumber,
03134                                     fFileHeader->fReqNbOfEvts,       fFileHeader->fStex);
03135   
03136   fCnaWrite->fMakeResultsFileName();  // set fRootFileName, fRootFileNameShort
03137   
03138   const Text_t *FileShortName = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03139 
03140   //============================= check number of found events
03141   Int_t nCountEvts = 0;
03142   
03143   for(Int_t i0StexEcha=0; i0StexEcha<fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
03144     {for(Int_t i0Sample=0; i0Sample<fFileHeader->fNbOfSamples; i0Sample++)
03145       {nCountEvts += fT2d_NbOfEvts[i0StexEcha][i0Sample];}}
03146   
03147   if ( nCountEvts <= 0 )
03148     {
03149       //============== no write if no event found
03150       cout << "!TEcnaRun::WriteRootFile()> No event found for file " << fCnaWrite->fRootFileNameShort.Data()
03151            << ". File will not be written." << endl;
03152       ok_write = kTRUE;
03153     }
03154   else
03155     {    
03156       if(fFlagPrint == fCodePrintAllComments){
03157         cout << "*TEcnaRun::WriteRootFile()> Results are going to be written in the ROOT file: " << endl
03158              << "                           " << fCnaWrite->fRootFileName.Data() << endl;}
03159       
03160       ok_write = WriteRootFile(FileShortName, fFileHeader->fNbOfSamples);
03161 
03162       if( ok_write == kTRUE )
03163         {
03164           if(fFlagPrint != fCodePrintNoComment)
03165             {cout << "*TEcnaRun::WriteRootFile()> Writing OK for file " << fCnaWrite->fRootFileNameShort.Data()
03166                   << endl;}
03167         }
03168       else
03169         {
03170           cout << "!TEcnaRun::WriteRootFile()> Writing FAILLED for file " << fCnaWrite->fRootFileNameShort.Data()
03171                << fTTBELL << endl;
03172         }
03173     }
03174   return ok_write;
03175 } // end of WriteRootFile()
03176 
03177 //--------------------------------------------------------------------
03178 //
03179 //               WriteNewRootFile with argument
03180 //    Called by TEcnaGui for results file of the Calculations method
03181 //    analysis type and nb of samples changed, other arguments kept
03182 //
03183 //--------------------------------------------------------------------
03184 Bool_t TEcnaRun::WriteNewRootFile(const TString TypAna){
03185 //Write a new Root file. File name automatically generated in fMakeResultsFileName.
03186   Bool_t ok_write = kFALSE;
03187 
03188   fCnaWrite->RegisterFileParameters(TypAna.Data(),   fNbSampForCalc, fFileHeader->fRunNumber,
03189                                     fFileHeader->fFirstReqEvtNumber, fFileHeader->fLastReqEvtNumber,
03190                                     fFileHeader->fReqNbOfEvts,       fFileHeader->fStex,
03191                                     fFileHeader->fStartDate, fFileHeader->fStopDate,
03192                                     fFileHeader->fStartTime, fFileHeader->fStopTime);
03193 
03194   fCnaWrite->fMakeResultsFileName();  // set fRootFileName, fRootFileNameShort
03195   fNewRootFileName      = fCnaWrite->GetRootFileName();
03196   fNewRootFileNameShort = fCnaWrite->GetRootFileNameShort();
03197 
03198   //  const Text_t *FileShortName = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
03199   const Text_t *FileShortName = (const Text_t *)fNewRootFileNameShort.Data();
03200 
03201   if(fFlagPrint == fCodePrintAllComments){
03202     cout << "*TEcnaRun::WriteNewRootFile()> Results are going to be written in the ROOT file: " << endl
03203          << "                              " << fNewRootFileNameShort.Data() << endl;}
03204 
03205   ok_write = WriteRootFile(FileShortName, fNbSampForCalc);
03206   
03207   return ok_write;
03208 }
03209 
03210 //-------------------------------------------------------------------------
03211 //
03212 //    Get the new ROOT file name (long and short)
03213 //   (called by TEcnaGui in Calculations method)
03214 //
03215 //-------------------------------------------------------------------------
03216 TString TEcnaRun::GetNewRootFileName(){return fNewRootFileName;}
03217 TString TEcnaRun::GetNewRootFileNameShort(){return fNewRootFileNameShort;}
03218 
03219 //--------------------------------------------------------------------
03220 //
03221 //               WriteRootFile with argument
03222 //
03223 //--------------------------------------------------------------------
03224 Bool_t TEcnaRun::WriteRootFile(const Text_t* name, Int_t& argNbSampWrite) 
03225 {
03226 //Write the Root file
03227 
03228   const Text_t* file_name = name;
03229 
03230   Bool_t ok_open  = kFALSE;
03231   Bool_t ok_write = kFALSE;
03232 
03233   if ( fOpenRootFile )
03234     {
03235       cout << "!TEcnaRun::WriteRootFile(...) *** ERROR ***> Writing on file already open."
03236            << fTTBELL << endl;
03237     }
03238   else
03239     {
03240       //..... List of the different element types and associated parameters as ordered in the ROOT file
03241       //                                                                    ==========
03242       //
03243       //              WARNING  *** SIZES ARE THESE FOR THE BARREL (1700 Xtals) and for 10 samples ***
03244       //
03245       //   Nb of   Type of element            Type      Type                                    Size    Comment
03246       // elements                             Number    Name
03247       //
03248       //        1  fMatHis(1,StexStin)         ( 0)  cTypNumbers             1*(   1,  68) =         68
03249 
03250       //        1  fMatHis(1,StexStin)         (12)  cTypAvPed               1*(   1,  68) =         68
03251       //        1  fMatHis(1, StexStin)        ( 3)  cTypAvTno               1*(   1,  68) =         68
03252       //        1  fMatHis(1, StexStin)        ( 4)  cTypAvLfn               1*(   1,  68) =         68
03253       //        1  fMatHis(1, StexStin)        ( 5)  cTypAvHfn               1*(   1,  68) =         68
03254       //        1  fMatHis(1,StexStin)         (13)  cTypAvMeanCorss         1*(   1,  68) =         68
03255       //        1  fMatHis(1,StexStin)         (14)  cTypAvSigCorss          1*(   1,  68) =         68
03256 
03257       //        1  fMatHis(1,StexEcha)         (16)  cTypPed                 1*(   1,1700) =      1 700
03258       //        1  fMatHis(1,StexEcha)         (17)  cTypTno                 1*(   1,1700) =      1 700
03259       //        1  fMatHis(1,StexEcha)         (10)  cTypMeanCorss           1*(   1,1700) =      1 700
03260       //        1  fMatHis(1,StexEcha)         (18)  cTypLfn                 1*(   1,1700) =      1 700
03261       //        1  fMatHis(1,StexEcha)         (19)  cTypHfn                 1*(   1,1700) =      1 700
03262       //        1  fMatHis(1,StexEcha)         (11)  cTypSigCorss            1*(   1,1700) =      1 700
03263 
03264       //        1  fMatMat(Stin,Stin)          (23)  cTypLFccMoStins         1*(  68,  68) =      4 624
03265       //        1  fMatMat(Stin,Stin)          (24)  cTypHFccMoStins         1*(  68,  68) =      4 624
03266 
03267       //        1  fMatHis(StexEcha, sample)   (15)  cTypNbOfEvts            1*(1700,  10) =     17 000
03268       //        1  fMatHis(StexEcha, sample)   ( 1)  cTypMSp                 1*(1700,  10) =     17 000
03269       //        1  fMatHis(StexEcha, sample)   ( 2)  cTypSSp                 1*(1700,  10) =     17 000
03270  
03271       //   StexEcha  fMatMat(sample, sample)   ( 8)  cTypCovCss           1700*(  10,  10) =    170 000
03272       //   StexEcha  fMatMat(sample, sample    ( 9)  cTypCorCss           1700*(  10,  10) =    170 000
03273 
03274       //   StexEcha  fMatHis(sample, bin_evt)  (20)  cTypAdcEvt,          1700*(  10, 150) =  2 550 000
03275 
03276       //        1  fMatMat(StexEcha, StexEcha) (21)  cTypLfCov               1*(1700,1700) =  2 890 000
03277       //        1  fMatMat(StexEcha, StexEcha) (22)  cTypLfCor               1*(1700,1700) =  2 890 000
03278 
03279       //        1  fMatMat(StexEcha, StexEcha) ( 6)  cTypHfCov               1*(1700,1700) =  2 890 000 // (06/05/08)
03280       //        1  fMatMat(StexEcha, StexEcha) ( 7)  cTypHfCor               1*(1700,1700) =  2 890 000 // (06/05/08)
03281 
03282 
03283       //......................................................................................................
03284 
03285       ok_open = OpenRootFile(file_name, "RECREATE");
03286 
03287       TString typ_name = "?";
03288       Int_t v_nb_times = 0;
03289       Int_t v_dim_one  = 0;
03290       Int_t v_dim_two  = 0;
03291       Int_t v_size     = 0;
03292       Int_t v_tot      = 0;
03293       Int_t v_tot_writ = 0;
03294 
03295       //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03296       //       
03297       //  ===> no general method and no translation to TEcnaWrite
03298       //       because the fT1d.. and fT2d... arrays
03299       //       are attributes of TEcnaRun (calls to the "TRootXXXX" methods)
03300       //
03301       //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03302 
03303       //-------------------------- Stin numbers 
03304       //       1   fMatHis(1,Stin)           ( 0)  cTypNumbers        1*(   1,  68) =         68
03305 
03306       Int_t MaxCar = fgMaxCar;
03307       typ_name.Resize(MaxCar);
03308       typ_name   = "StinNumbers";
03309       v_nb_times = fFileHeader->fStinNumbersCalc;
03310       v_dim_one  = 1;
03311       v_dim_two  = fEcal->MaxStinEcnaInStex();
03312       v_size     = v_nb_times*v_dim_one*v_dim_two;
03313       v_tot     += v_size;
03314 
03315       if(fFlagPrint == fCodePrintAllComments){
03316       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03317            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03318            << setw(9) << v_size;}
03319 
03320       for (Int_t i = 0; i < v_nb_times; i++)
03321         {
03322           if ( fTagStinNumbers[0] == 1 )
03323             {
03324               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypNumbers;
03325               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03326               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03327               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03328               TRootStinNumbers();
03329               gCnaRootFile->fCnaResultsTree->Fill();
03330               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03331             }
03332         }
03333       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03334 
03335       //-------------------------- Averaged Pedestals (1 value per Stin)
03336       //       1   fMatHis(1, StexStin)   (12)  cTypAvPed      1*(1,  68) =     68
03337 
03338       MaxCar = fgMaxCar;
03339       typ_name.Resize(MaxCar);
03340       typ_name   = "AvPed";
03341       v_nb_times = fFileHeader->fAvPedCalc;
03342       v_dim_one  = 1;
03343       v_dim_two  = fEcal->MaxStinEcnaInStex();
03344       v_size     = v_nb_times*v_dim_one*v_dim_two;
03345       v_tot     += v_size;
03346  
03347       if(fFlagPrint == fCodePrintAllComments){
03348       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03349            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03350            << setw(9) << v_size;}
03351 
03352       for (Int_t i = 0; i < v_nb_times; i++)
03353         {
03354           if ( fTagAvPed[0] == 1 )
03355             {
03356               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvPed;
03357               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03358               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03359               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03360               TRootAvPed();
03361               gCnaRootFile->fCnaResultsTree->Fill();
03362               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03363             }
03364         }
03365       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03366 
03367       //-------------------------- Averaged Total noise
03368       // StexEcha   fMatHis(1, StexStin)     ( 3)  cTypAvTno      1*(1,  68) =     68
03369 
03370       MaxCar = fgMaxCar;
03371       typ_name.Resize(MaxCar);
03372       typ_name   = "AvTno";
03373       v_nb_times = fFileHeader->fAvTnoCalc;
03374       v_dim_one  = 1;
03375       v_dim_two  = fEcal->MaxStinEcnaInStex();
03376       v_size     = v_nb_times*v_dim_one*v_dim_two;
03377       v_tot     += v_size;
03378 
03379       if(fFlagPrint == fCodePrintAllComments){
03380       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03381            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03382            << setw(9) << v_size;}
03383 
03384       for (Int_t i = 0; i < v_nb_times; i++)
03385         {
03386           if ( fTagAvTno[0] == 1 )
03387             {
03388               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvTno;
03389               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03390               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03391               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03392               TRootAvTno();
03393               gCnaRootFile->fCnaResultsTree->Fill(); 
03394               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03395             }
03396         }
03397       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03398 
03399       //-------------------------- Averaged Low frequency noise
03400       //       1   fMatHis(1, StexStin)   ( 4)  cTypAvLfn      1*(1,  68) =     68
03401 
03402       MaxCar = fgMaxCar;
03403       typ_name.Resize(MaxCar);
03404       typ_name   = "AvLfn";
03405       v_nb_times = fFileHeader->fAvLfnCalc;
03406       v_dim_one  = 1;
03407       v_dim_two  = fEcal->MaxStinEcnaInStex();
03408       v_size     = v_nb_times*v_dim_one*v_dim_two;
03409       v_tot     += v_size;
03410  
03411       if(fFlagPrint == fCodePrintAllComments){
03412       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03413            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03414            << setw(9) << v_size;}
03415       
03416       for (Int_t i = 0; i < v_nb_times; i++)
03417         {
03418           if ( fTagAvLfn[0] == 1 )
03419             {
03420               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvLfn;
03421               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03422               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03423               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03424               TRootAvLfn();
03425               gCnaRootFile->fCnaResultsTree->Fill();
03426               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03427             }
03428         }
03429       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03430       
03431       //-------------------------- Averaged High frequency noise
03432       //       1   fMatHis(1, StexStin)   ( 5)  cTypAvHfn      1*(1,  68) =     68
03433 
03434       MaxCar = fgMaxCar;      
03435       typ_name.Resize(MaxCar);
03436       typ_name   = "AvHfn";
03437       v_nb_times = fFileHeader->fAvHfnCalc;
03438       v_dim_one  = 1;
03439       v_dim_two  = fEcal->MaxStinEcnaInStex();
03440       v_size     = v_nb_times*v_dim_one*v_dim_two;
03441       v_tot     += v_size;
03442  
03443       if(fFlagPrint == fCodePrintAllComments){
03444       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03445            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03446            << setw(9) << v_size;}
03447       
03448       for (Int_t i = 0; i < v_nb_times; i++)
03449         {
03450           if ( fTagAvHfn[0] == 1 )
03451             {
03452               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvHfn;
03453               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03454               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03455               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03456               TRootAvHfn();
03457               gCnaRootFile->fCnaResultsTree->Fill();
03458               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03459             }
03460         }
03461       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03462 
03463       //-------------------------- Averaged mean of cor(s,s)
03464       //       1   fMatHis(1, StexStin)   (13)  cTypAvMeanCorss      1*(1,  68) =     68
03465 
03466       MaxCar = fgMaxCar;
03467       typ_name.Resize(MaxCar);
03468       typ_name   = "AvMeanCorss";
03469       v_nb_times = fFileHeader->fAvMeanCorssCalc;
03470       v_dim_one  = 1;
03471       v_dim_two  = fEcal->MaxStinEcnaInStex();
03472       v_size     = v_nb_times*v_dim_one*v_dim_two;
03473       v_tot     += v_size;
03474  
03475       if(fFlagPrint == fCodePrintAllComments){
03476       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03477            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03478            << setw(9) << v_size;}
03479 
03480       for (Int_t i = 0; i < v_nb_times; i++)
03481         {
03482           if ( fTagAvMeanCorss[0] == 1 )
03483             {
03484               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvMeanCorss;
03485               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03486               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03487               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03488               TRootAvEvCorss();
03489               gCnaRootFile->fCnaResultsTree->Fill();
03490               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03491             }
03492         }
03493       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03494       
03495       //--------------------------  Averaged sigma of cor(s,s)
03496       //       1   fMatHis(1, StexStin)    (14)  cTypAvSigCorss      1*(1,  68) =     68
03497 
03498       MaxCar = fgMaxCar;
03499       typ_name.Resize(MaxCar);
03500       typ_name   = "AvSigCorss";
03501       v_nb_times = fFileHeader->fAvSigCorssCalc;
03502       v_dim_one  = 1;
03503       v_dim_two  = fEcal->MaxStinEcnaInStex();
03504       v_size     = v_nb_times*v_dim_one*v_dim_two;
03505       v_tot     += v_size;
03506  
03507       if(fFlagPrint == fCodePrintAllComments){
03508       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03509            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03510            << setw(9) << v_size;}
03511 
03512       for (Int_t i = 0; i < v_nb_times; i++)
03513         {
03514           if ( fTagAvSigCorss[0] == 1 )
03515             {
03516               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAvSigCorss;
03517               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03518               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03519               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03520               TRootAvSigCorss();
03521               gCnaRootFile->fCnaResultsTree->Fill();
03522               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03523             }
03524         }
03525       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03526 
03527       //-------------------------- Expectation values of the expectation values of the samples (pedestals)
03528       //       1   fMatHis(1,StexEcha)         (16)  cTypPed                1*(   1,1700) =      1 700
03529 
03530       MaxCar = fgMaxCar;
03531       typ_name.Resize(MaxCar);
03532       typ_name   = "Ped";
03533       v_nb_times = fFileHeader->fPedCalc;
03534       v_dim_one  = 1;
03535       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03536       v_size     = v_nb_times*v_dim_one*v_dim_two;
03537       v_tot     += v_size;
03538 
03539       if(fFlagPrint == fCodePrintAllComments){
03540       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03541            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03542            << setw(9) << v_size;}
03543 
03544       for (Int_t i = 0; i < v_nb_times; i++)
03545         {
03546           if ( fTagPed[0] == 1 )
03547             {
03548               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypPed;
03549               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03550               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03551               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03552               TRootPed();
03553               gCnaRootFile->fCnaResultsTree->Fill();
03554               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03555             }
03556         }
03557       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03558                   
03559       //-------------------------- Expectation values of the sigmas the samples
03560       //       1   fMatHis(1,StexEcha)         (17)  cTypTno               1*(   1,1700) =      1 700
03561 
03562       MaxCar = fgMaxCar;
03563       typ_name.Resize(MaxCar);
03564       typ_name   = "Tno";
03565       v_nb_times = fFileHeader->fTnoCalc;
03566       v_dim_one  = 1;
03567       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03568       v_size     = v_nb_times*v_dim_one*v_dim_two;
03569       v_tot     += v_size;
03570 
03571       if(fFlagPrint == fCodePrintAllComments){
03572       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03573            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03574            << setw(9) << v_size;}
03575 
03576       for (Int_t i = 0; i < v_nb_times; i++)
03577         {
03578           if ( fTagTno[0] == 1 )
03579             {
03580               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypTno;
03581               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03582               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03583               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03584               TRootTno();
03585               gCnaRootFile->fCnaResultsTree->Fill();
03586               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03587             }
03588         }
03589       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03590                                      
03591       //-------------------------- Expectation values of the correlations between the samples
03592       //       1   fMatHis(1,StexEcha)         (10)  cTypMeanCorss            1*(   1,1700) =      1 700
03593 
03594       MaxCar = fgMaxCar;
03595       typ_name.Resize(MaxCar);
03596       typ_name   = "MeanCorss";
03597       v_nb_times = fFileHeader->fMeanCorssCalc;
03598       v_dim_one  = 1;
03599       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03600       v_size     = v_nb_times*v_dim_one*v_dim_two;
03601       v_tot     += v_size;
03602 
03603       if(fFlagPrint == fCodePrintAllComments){
03604       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03605            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03606            << setw(9) << v_size;}
03607 
03608       for (Int_t i = 0; i < v_nb_times; i++)
03609         {
03610           if ( fTagMeanCorss[0] == 1 )
03611             {
03612               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypMeanCorss;
03613               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03614               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03615               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03616               TRootMeanCorss();
03617               gCnaRootFile->fCnaResultsTree->Fill();
03618               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03619             }
03620         } 
03621       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03622       
03623       //-------------------------- Sigmas of the expectation values of the samples  
03624       //       1   fMatHis(1,StexEcha)         (18)  cTypLfn               1*(   1,1700) =      1 700
03625 
03626       MaxCar = fgMaxCar;
03627       typ_name.Resize(MaxCar);
03628       typ_name   = "Lfn";
03629       v_nb_times = fFileHeader->fLfnCalc;
03630       v_dim_one  = 1;
03631       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03632       v_size     = v_nb_times*v_dim_one*v_dim_two;
03633       v_tot     += v_size;
03634 
03635       if(fFlagPrint == fCodePrintAllComments){
03636       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03637            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03638            << setw(9) << v_size;}
03639 
03640       for (Int_t i = 0; i < v_nb_times; i++)
03641         {
03642           if ( fTagLfn[0] == 1 )
03643             {
03644               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypLfn;
03645               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03646               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03647               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03648               TRootLfn();
03649               gCnaRootFile->fCnaResultsTree->Fill();
03650               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03651             }
03652         } 
03653       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03654       
03655       //-------------------------- Sigmas of the sigmas of the samples  
03656       //       1   fMatHis(1,StexEcha)         (19)  cTypHfn              1*(   1,1700) =      1 700
03657 
03658       MaxCar = fgMaxCar;
03659       typ_name.Resize(MaxCar);
03660       typ_name   = "Hfn";
03661       v_nb_times = fFileHeader->fHfnCalc;
03662       v_dim_one  = 1;
03663       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03664       v_size     = v_nb_times*v_dim_one*v_dim_two;
03665       v_tot     += v_size;
03666 
03667       if(fFlagPrint == fCodePrintAllComments){
03668       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03669            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03670            << setw(9) << v_size;}
03671  
03672       for (Int_t i = 0; i < v_nb_times; i++)
03673         {
03674           if ( fTagHfn[0] == 1 )
03675             {
03676               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypHfn;
03677               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03678               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03679               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03680               TRootHfn();
03681               gCnaRootFile->fCnaResultsTree->Fill();
03682               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03683             }
03684         }
03685       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03686                     
03687       //-------------------------- Sigmas of the correlations between the samples  
03688       //       1   fMatHis(1,StexEcha)         (11)  cTypSigCorss           1*(   1,1700) =      1 700
03689 
03690       MaxCar = fgMaxCar;
03691       typ_name.Resize(MaxCar);
03692       typ_name   = "SigCorss";
03693       v_nb_times = fFileHeader->fSigCorssCalc;
03694       v_dim_one  = 1;
03695       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03696       v_size     = v_nb_times*v_dim_one*v_dim_two;
03697       v_tot     += v_size;
03698 
03699       if(fFlagPrint == fCodePrintAllComments){
03700       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03701            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03702            << setw(9) << v_size;}
03703    
03704       for (Int_t i = 0; i < v_nb_times; i++)
03705         {
03706           if ( fTagSigCorss[0] == 1 )
03707             {
03708               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypSigCorss;
03709               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03710               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03711               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03712               TRootSigCorss();
03713               gCnaRootFile->fCnaResultsTree->Fill();
03714               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03715             }
03716         }
03717       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03718 
03719       //----- Mean Covariances between StexEchas (averaged over samples) for all (Stin_X,Stin_Y)
03720       //       1   fMatMat(Stin,Stin)       (23)  cTypLFccMoStins         1*(  68,  68) =      4 624
03721 
03722       MaxCar = fgMaxCar;
03723       typ_name.Resize(MaxCar);
03724       typ_name   = "LFccMoStins";
03725       v_nb_times = fFileHeader->fLFccMoStinsCalc;
03726       v_dim_one  = fEcal->MaxStinEcnaInStex();
03727       v_dim_two  = fEcal->MaxStinEcnaInStex();
03728       v_size     = v_nb_times*v_dim_one*v_dim_two;
03729       v_tot     += v_size;
03730  
03731       if(fFlagPrint == fCodePrintAllComments){
03732       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03733            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03734            << setw(9) << v_size;}
03735 
03736       for (Int_t i = 0; i < v_nb_times; i++)
03737         {
03738           if ( fTagLFccMoStins[0] == 1 )
03739             {
03740               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypLFccMoStins;
03741               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03742               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
03743               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
03744               TRootLFccMoStins();
03745               gCnaRootFile->fCnaResultsTree->Fill();
03746               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03747             }
03748         } 
03749       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03750             
03751       //----- Mean Correlations between StexEchas (averaged over samples) for all (Stin_X,Stin_Y)
03752       //       1   fMatMat(Stin,Stin)       (24)  cTypHFccMoStins         1*(  68,  68) =      4 624
03753 
03754       MaxCar = fgMaxCar;
03755       typ_name.Resize(MaxCar);
03756       typ_name   = "HFccMoStins";
03757       v_nb_times = fFileHeader->fHFccMoStinsCalc;
03758       v_dim_one  = fEcal->MaxStinEcnaInStex();
03759       v_dim_two  = fEcal->MaxStinEcnaInStex();
03760       v_size     = v_nb_times*v_dim_one*v_dim_two;
03761       v_tot     += v_size;
03762  
03763       if(fFlagPrint == fCodePrintAllComments){
03764       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03765            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03766            << setw(9) << v_size;}
03767 
03768       for (Int_t i = 0; i < v_nb_times; i++)
03769         {
03770           if ( fTagHFccMoStins[0] == 1 )
03771             {
03772               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypHFccMoStins;
03773               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03774               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
03775               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
03776               TRootHFccMoStins();
03777               gCnaRootFile->fCnaResultsTree->Fill();
03778               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03779             }
03780         }
03781       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03782       
03783       //-------------------------- Numbers of found events (NbOfEvts)
03784       //       1   fMatHis(StexEcha, sample)   (15)  cTypNbOfEvts       1*(1700,  10) =     17 000
03785 
03786       MaxCar = fgMaxCar;
03787       typ_name.Resize(MaxCar);
03788       typ_name   = "NbOfEvts";
03789       v_nb_times = fFileHeader->fNbOfEvtsCalc;
03790       v_dim_one  = fEcal->MaxCrysEcnaInStex();
03791       v_dim_two  = argNbSampWrite;
03792       v_size     = v_nb_times*v_dim_one*v_dim_two;
03793       v_tot     += v_size;
03794  
03795       if(fFlagPrint == fCodePrintAllComments){
03796       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03797            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03798            << setw(9) << v_size;}
03799 
03800       for (Int_t i = 0; i < v_nb_times; i++)
03801         {
03802           if ( fTagNbOfEvts[0] == 1 )
03803             {
03804               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypNbOfEvts;
03805               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03806               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03807               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03808               TRootNbOfEvts(argNbSampWrite);
03809               gCnaRootFile->fCnaResultsTree->Fill();
03810               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03811             }
03812         }
03813       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03814                   
03815       //-------------------------- Expectation values of the samples
03816       //       1   fMatHis(StexEcha, sample)   ( 1)  cTypMSp                  1*(1700,  10) =     17 000
03817 
03818       MaxCar = fgMaxCar;
03819       typ_name.Resize(MaxCar);
03820       typ_name   = "MSp";
03821       v_nb_times = fFileHeader->fMSpCalc;
03822       v_dim_one  = fEcal->MaxCrysEcnaInStex();
03823       v_dim_two  = argNbSampWrite;
03824       v_size     = v_nb_times*v_dim_one*v_dim_two;
03825       v_tot     += v_size;
03826  
03827       if(fFlagPrint == fCodePrintAllComments){
03828       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03829            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03830            << setw(9) << v_size;}
03831 
03832       for (Int_t i = 0; i < v_nb_times; i++)
03833         {
03834           if ( fTagMSp[0] == 1 )
03835             {
03836               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypMSp;
03837               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03838               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03839               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03840               TRootMSp(argNbSampWrite);
03841               gCnaRootFile->fCnaResultsTree->Fill();
03842               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03843             }
03844         }
03845       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03846       
03847       //-------------------------- Sigmas of the samples     
03848       //       1   fMatHis(StexEcha, sample)   ( 2)  cTypSSp                 1*(1700,  10) =     17 000
03849 
03850       MaxCar = fgMaxCar;
03851       typ_name.Resize(MaxCar);
03852       typ_name   = "SSp";
03853       v_nb_times = fFileHeader->fSSpCalc;
03854       v_dim_one  = fEcal->MaxCrysEcnaInStex();
03855       v_dim_two  = argNbSampWrite;
03856       v_size     = v_nb_times*v_dim_one*v_dim_two;
03857       v_tot     += v_size;
03858  
03859       if(fFlagPrint == fCodePrintAllComments){
03860       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03861            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03862            << setw(9) << v_size;}
03863 
03864       for (Int_t i = 0; i < v_nb_times; i++)
03865         {
03866           if ( fTagSSp[0] == 1 )
03867             {
03868               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypSSp;
03869               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
03870               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03871               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03872               TRootSSp(argNbSampWrite);
03873               gCnaRootFile->fCnaResultsTree->Fill();
03874               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03875             }
03876         }
03877       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03878 
03879       //-------------------------- Covariances between samples
03880 
03881       // StexEcha   fMatMat(sample,  sample)   ( 8)  cTypCovCss           1700*(  10,  10) =    170 000
03882 
03883       MaxCar = fgMaxCar;
03884       typ_name.Resize(MaxCar);
03885       typ_name   = "CovCss";
03886       v_nb_times = fFileHeader->fCovCssCalc;
03887       v_dim_one  = argNbSampWrite;
03888       v_dim_two  = argNbSampWrite;
03889       v_size     = v_nb_times*v_dim_one*v_dim_two;
03890       v_tot     += v_size;
03891  
03892       if(fFlagPrint == fCodePrintAllComments){
03893       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03894            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03895            << setw(9) << v_size;}
03896 
03897       for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
03898         {
03899           if ( fTagCovCss[i0StexEcha] == 1 )
03900             {
03901               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypCovCss;
03902               gCnaRootFile->fCnaIndivResult->fIthElement     = i0StexEcha;
03903               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
03904               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
03905               TRootCovCss(i0StexEcha, argNbSampWrite);
03906               gCnaRootFile->fCnaResultsTree->Fill();
03907               if( i0StexEcha == 0  && fFlagPrint == fCodePrintAllComments)
03908                 {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03909             }
03910         }
03911       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03912       
03913       //-------------------------- Correlations between samples   
03914       // StexEcha   fMatMat(sample,  sample)   ( 9)  cTypCorCss           1700*(  10,  10) =    170 000
03915 
03916       MaxCar = fgMaxCar;
03917       typ_name.Resize(MaxCar);
03918       typ_name   = "CorCss";
03919       v_nb_times = fFileHeader->fCorCssCalc;
03920       v_dim_one  = argNbSampWrite;
03921       v_dim_two  = argNbSampWrite;
03922       v_size     = v_nb_times*v_dim_one*v_dim_two;
03923       v_tot     += v_size;
03924 
03925       if(fFlagPrint == fCodePrintAllComments){
03926       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03927            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03928            << setw(9) << v_size;}
03929  
03930       for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
03931         {
03932           if ( fTagCorCss[i0StexEcha] == 1 )
03933             {
03934               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypCorCss;
03935               gCnaRootFile->fCnaIndivResult->fIthElement     = i0StexEcha;
03936               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
03937               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
03938               TRootCorCss(i0StexEcha, argNbSampWrite);
03939               gCnaRootFile->fCnaResultsTree->Fill();
03940               if( i0StexEcha == 0  && fFlagPrint == fCodePrintAllComments)
03941                 {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03942             }     
03943         }
03944       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03945 
03946       //-------------------------- Samples as a function of event = events distributions
03947       // StexEcha   fMatHis(sample,  bins)     (20)  cTypAdcEvt,        1700*(  10, 150) =  2 550 000
03948 
03949       MaxCar = fgMaxCar;
03950       typ_name.Resize(MaxCar);
03951       typ_name   = "AdcEvt";
03952       v_nb_times = fFileHeader->fAdcEvtCalc;
03953       v_dim_one  = argNbSampWrite;
03954       v_dim_two  = fFileHeader->fReqNbOfEvts;
03955       v_size     = v_nb_times*v_dim_one*v_dim_two;
03956       v_tot     += v_size;
03957  
03958       if(fFlagPrint == fCodePrintAllComments){
03959       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03960            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03961            << setw(9) << v_size;}
03962 
03963       for (Int_t i0StexEcha = 0; i0StexEcha < v_nb_times; i0StexEcha++)
03964         {
03965           if ( fTagAdcEvt[i0StexEcha] == 1 )
03966             {
03967               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypAdcEvt;
03968               gCnaRootFile->fCnaIndivResult->fIthElement     = i0StexEcha;
03969               gCnaRootFile->fCnaIndivResult->SetSizeHis(v_dim_one,v_dim_two);
03970               gCnaRootFile->fCnaIndivResult->fMatMat.ReSet(1,1);
03971               TRootAdcEvt(i0StexEcha, argNbSampWrite);
03972               gCnaRootFile->fCnaResultsTree->Fill();
03973               if( i0StexEcha == 0  && fFlagPrint == fCodePrintAllComments)
03974                 {cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
03975             }
03976         }
03977       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
03978 
03979       //-------------------------- Low Frequency Covariances between StexEchas
03980       //  sample   fMatMat(StexEcha, StexEcha)  (21)  cTypLfCov           1*(1700,1700) =  2 890 000
03981 
03982       MaxCar = fgMaxCar;
03983       typ_name.Resize(MaxCar);
03984       typ_name   = "LfCov";
03985       v_nb_times = fFileHeader->fLfCovCalc;
03986       v_dim_one  = fEcal->MaxCrysEcnaInStex();
03987       v_dim_two  = fEcal->MaxCrysEcnaInStex();
03988       v_size     = v_nb_times*v_dim_one*v_dim_two;
03989       v_tot     += v_size;
03990  
03991       if(fFlagPrint == fCodePrintAllComments){
03992       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
03993            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
03994            << setw(9) << v_size;}
03995 
03996       for (Int_t i = 0; i < v_nb_times; i++)
03997         {      //=================================== Record type EB
03998           if ( fTagLfCov[0] == 1 )
03999             {
04000               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypLfCov;
04001               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
04002               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
04003               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
04004               TRootLfCov();
04005               gCnaRootFile->fCnaResultsTree->Fill();
04006               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
04007             }
04008         }
04009       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
04010       
04011       //-------------------------- Low Frequency Correlations between StexEchas
04012       //  sample   fMatMat(StexEcha, StexEcha)  (22)  cTypLfCor           1*(1700,1700) =  2 890 000
04013 
04014       MaxCar = fgMaxCar;
04015       typ_name.Resize(MaxCar);
04016       typ_name   = "LfCor";
04017       v_nb_times = fFileHeader->fLfCorCalc;
04018       v_dim_one  = fEcal->MaxCrysEcnaInStex();
04019       v_dim_two  = fEcal->MaxCrysEcnaInStex();
04020       v_size     = v_nb_times*v_dim_one*v_dim_two;
04021       v_tot     += v_size;
04022 
04023       if(fFlagPrint == fCodePrintAllComments){
04024       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
04025            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
04026            << setw(9) << v_size;}
04027 
04028       for (Int_t i = 0; i < v_nb_times; i++)
04029         {
04030           if ( fTagLfCor[0] == 1 )
04031             {
04032               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypLfCor;
04033               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
04034               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
04035               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
04036               TRootLfCor();
04037               gCnaRootFile->fCnaResultsTree->Fill();
04038               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
04039             }
04040         }
04041       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
04042 
04043       //-------------------------- High Frequency Covariances between StexEchas
04044       //  sample   fMatMat(StexEcha, StexEcha)  (6)  cTypHfCov           1*(1700,1700) =  2 890 000
04045 
04046       MaxCar = fgMaxCar;
04047       typ_name.Resize(MaxCar);
04048       typ_name   = "HfCov";
04049       v_nb_times = fFileHeader->fHfCovCalc;
04050       v_dim_one  = fEcal->MaxCrysEcnaInStex();
04051       v_dim_two  = fEcal->MaxCrysEcnaInStex();
04052       v_size     = v_nb_times*v_dim_one*v_dim_two;
04053       v_tot     += v_size;
04054  
04055       if(fFlagPrint == fCodePrintAllComments){
04056       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
04057            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
04058            << setw(9) << v_size;}
04059 
04060       for (Int_t i = 0; i < v_nb_times; i++)
04061         {
04062           if ( fTagHfCov[0] == 1 )
04063             {
04064               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypHfCov;
04065               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
04066               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
04067               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
04068               TRootHfCov();
04069               gCnaRootFile->fCnaResultsTree->Fill();
04070               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
04071             }
04072         }
04073       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
04074       
04075       //-------------------------- High Frequency Correlations between StexEchas
04076       //  sample   fMatMat(StexEcha, StexEcha)  (7)  cTypHfCor           1*(1700,1700) =  2 890 000
04077 
04078       MaxCar = fgMaxCar;
04079       typ_name.Resize(MaxCar);
04080       typ_name   = "HfCor";
04081       v_nb_times = fFileHeader->fHfCorCalc;
04082       v_dim_one  = fEcal->MaxCrysEcnaInStex();
04083       v_dim_two  = fEcal->MaxCrysEcnaInStex();
04084       v_size     = v_nb_times*v_dim_one*v_dim_two;
04085       v_tot     += v_size;
04086 
04087       if(fFlagPrint == fCodePrintAllComments){
04088       cout << "*TEcnaRun::WriteRootFile(...)> " << setw(18) << typ_name << ": " << setw(4) << v_nb_times
04089            << " * ("  << setw(4) << v_dim_one << ","  << setw(4) << v_dim_two  << ") = "
04090            << setw(9) << v_size;}
04091 
04092       for (Int_t i = 0; i < v_nb_times; i++)
04093         {
04094           if ( fTagHfCor[0] == 1 )
04095             {
04096               gCnaRootFile->fCnaIndivResult->fTypOfCnaResult = cTypHfCor;
04097               gCnaRootFile->fCnaIndivResult->fIthElement     = i;
04098               gCnaRootFile->fCnaIndivResult->SetSizeMat(v_dim_one,v_dim_two);
04099               gCnaRootFile->fCnaIndivResult->fMatHis.ReSet(1,1);
04100               TRootHfCor();
04101               gCnaRootFile->fCnaResultsTree->Fill();
04102               if( i == 0 && fFlagPrint == fCodePrintAllComments ){cout << " => WRITTEN ON FILE "; v_tot_writ += v_size;}
04103             }
04104         }
04105       if(fFlagPrint == fCodePrintAllComments){cout << endl;}
04106 
04107       //---------------------------------------------- WRITING 
04108       //...................................... file 
04109       gCnaRootFile->fRootFile->Write();
04110       //...................................... header
04111       fFileHeader->Write();
04112 
04113       //...................................... status message
04114       if(fFlagPrint == fCodePrintAllComments){
04115         cout << "*TEcnaRun::WriteRootFile(...)> " << setw(20) << "TOTAL: "
04116              << setw(21) << "CALCULATED = " << setw(9) <<  v_tot
04117              << " => WRITTEN ON FILE = "    << setw(9) << v_tot_writ << endl;}
04118 
04119       if(fFlagPrint == fCodePrintAllComments){
04120         cout << "*TEcnaRun::WriteRootFile(...)> Write OK in file " << file_name << " in directory:" << endl
04121              << "                           " << fCnaParPaths->ResultsRootFilePath().Data()
04122              << endl;}
04123 
04124       ok_write = kTRUE;
04125 
04126       //...................................... close
04127       CloseRootFile(file_name);
04128     }
04129   return ok_write;
04130 }  //-------------- End of WriteRootFile(...) -----------------------
04131 
04132 //======================== "PREPA FILL" METHODS ===========================
04133 
04134 //-------------------------------------------------------------------------
04135 //
04136 //  Prepa Fill Stin numbers as a function of the Stin index 
04137 //                       (for writing in the ROOT file)
04138 //
04139 //-------------------------------------------------------------------------
04140 void TEcnaRun::TRootStinNumbers()
04141 {
04142   if (fTagStinNumbers[0] == 1 )
04143     {
04144       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04145         {
04146           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04147             fT1d_StexStinFromIndex[j0StexStinEcna];
04148         }
04149     }
04150 }
04151 
04152 //-------------------------------------------------------------------------
04153 //
04154 //  Prepa Fill last evt numbers for all the (StexEcha,sample)
04155 //                       (for writing in the ROOT file)
04156 //
04157 //-------------------------------------------------------------------------
04158 void TEcnaRun::TRootNbOfEvts(const Int_t& argNbSampWrite)
04159 {
04160   if (fTagNbOfEvts[0] == 1 )
04161     {
04162       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04163         {
04164           for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
04165             {
04166               gCnaRootFile->fCnaIndivResult->fMatHis(j0StexEcha, i0Sample) =
04167                 fT2d_NbOfEvts[j0StexEcha][i0Sample];
04168             }
04169         }
04170     }
04171 }
04172 
04173 //-------------------------------------------------------------------------
04174 //
04175 //  Prepa Fill histogram of samples as a function of event
04176 //                       (for writing in the ROOT file)
04177 //
04178 //-------------------------------------------------------------------------
04179 void TEcnaRun::TRootAdcEvt(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
04180 {
04181   if (fTagAdcEvt[user_StexEcha] == 1 )
04182     {
04183       for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
04184         {
04185           //...................... all the bins set to zero
04186           for (Int_t j_bin = 0; j_bin < fFileHeader->fReqNbOfEvts; j_bin++)
04187             {
04188               gCnaRootFile->fCnaIndivResult->fMatHis(i0Sample, j_bin) = (Double_t)0.;
04189             }
04190           //...................... fill the non-zero bins 
04191           for (Int_t j_bin = 0; j_bin < fFileHeader->fReqNbOfEvts; j_bin++)
04192             {
04193               gCnaRootFile->fCnaIndivResult->fMatHis(i0Sample, j_bin) =
04194                 fT3d_distribs[user_StexEcha][i0Sample][j_bin]; 
04195             }
04196         }
04197     }
04198 }
04199 
04200 //-------------------------------------------------------------------------
04201 //
04202 //  Prepa Fill expectation values of the samples for all the StexEchas
04203 //                       (for writing in the ROOT file)
04204 //
04205 //-------------------------------------------------------------------------
04206 void TEcnaRun::TRootMSp(const Int_t& argNbSampWrite)
04207 {
04208   if (fTagMSp[0] == 1 )
04209     {
04210       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04211         {
04212           for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
04213             {
04214               gCnaRootFile->fCnaIndivResult->fMatHis( j0StexEcha, i0Sample) =
04215                 fT2d_ev[j0StexEcha][i0Sample];
04216             }
04217         }
04218     }
04219 }
04220 
04221 //-------------------------------------------------------------------------
04222 //
04223 //  Prepa Fill sigmas of the samples for all the StexEchas
04224 //                       (for writing in the ROOT file)
04225 //
04226 //-------------------------------------------------------------------------
04227 void TEcnaRun::TRootSSp(const Int_t& argNbSampWrite)
04228 {
04229   if (fTagSSp[0] == 1 )
04230     {
04231       for (Int_t j0StexEcha=0; j0StexEcha<fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04232         {
04233           for (Int_t i0Sample=0; i0Sample<argNbSampWrite; i0Sample++)
04234             {
04235               gCnaRootFile->fCnaIndivResult->fMatHis(j0StexEcha, i0Sample) =
04236                 fT2d_sig[j0StexEcha][i0Sample];
04237             }
04238         }
04239     }
04240 }
04241 
04242 //-------------------------------------------------------------------------
04243 //
04244 //  Prepa Fill mean covariances between StexEchas, mean over samples
04245 //  for all (Stin_X, Stin_Y)
04246 //                           (for writing in ROOT file)
04247 //
04248 //-------------------------------------------------------------------------
04249 void TEcnaRun::TRootLFccMoStins()
04250 {
04251   if (fTagLFccMoStins[0] == 1 )
04252     {
04253       for (Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
04254         {
04255           for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04256             {
04257               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexStinEcna, j0StexStinEcna) =
04258                 fT2d_lfcc_mostins[i0StexStinEcna][j0StexStinEcna];
04259             }
04260         }
04261     }
04262 }
04263 
04264 //-------------------------------------------------------------------------
04265 //
04266 //  Prepa Fill mean correlations between StexEchas, mean over samples
04267 //  for all (Stin_X, Stin_Y)
04268 //                           (for writing in ROOT file)
04269 //
04270 //-------------------------------------------------------------------------
04271 void TEcnaRun::TRootHFccMoStins()
04272 {
04273   if (fTagHFccMoStins[0] == 1 )
04274     {
04275       for (Int_t i0StexStinEcna = 0; i0StexStinEcna < fEcal->MaxStinEcnaInStex(); i0StexStinEcna++)
04276         {
04277           for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04278             {
04279               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexStinEcna, j0StexStinEcna) =
04280                 fT2d_hfcc_mostins[i0StexStinEcna][j0StexStinEcna];
04281             }
04282         }
04283     }
04284 }
04285 
04286 //-------------------------------------------------------------------------
04287 //
04288 //  Prepa Fill ADC distributions of the samples for all the StexEchas
04289 //                       (for writing in the ROOT file)
04290 //
04291 //-------------------------------------------------------------------------
04292 void TEcnaRun::TRootAvTno()
04293 {
04294   if (fTagAvTno[0] == 1 )
04295     {
04296       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04297         {
04298           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04299             fT1d_av_totn[j0StexStinEcna];
04300         }
04301     }
04302 }
04303 //-------------------------------------------------------------------------
04304 //
04305 //  Prepa Fill ADC distributions xmin of the samples for all the StexEchas
04306 //                       (for writing in the ROOT file)
04307 //
04308 //-------------------------------------------------------------------------
04309 void TEcnaRun::TRootAvLfn()
04310 {
04311   if (fTagAvLfn[0] == 1 )
04312     {
04313       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04314         {
04315           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04316             fT1d_av_lofn[j0StexStinEcna];  
04317         }
04318     }
04319 }
04320 
04321 //-------------------------------------------------------------------------
04322 //
04323 //  Prepa Fill ADC distributions xmax of the samples for all the StexEchas
04324 //                       (for writing in the ROOT file)
04325 //
04326 //-------------------------------------------------------------------------
04327 void TEcnaRun::TRootAvHfn()
04328 {
04329   if (fTagAvHfn[0] == 1 )
04330     {
04331       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04332         {
04333           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04334             fT1d_av_hifn[j0StexStinEcna];  
04335         }
04336     }
04337 }
04338 
04339 //-------------------------------------------------------------------------
04340 //
04341 //  Prepa Fill Low Frequency covariances between StexEchas
04342 //                           (for writing in ROOT file)
04343 //
04344 //-------------------------------------------------------------------------
04345 void TEcnaRun::TRootLfCov()
04346 {
04347   if (fTagLfCov[0] == 1 )
04348     {
04349       for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
04350         {
04351           for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04352             {
04353               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
04354                 fT2d_lf_cov[i0StexEcha][j0StexEcha];
04355             }
04356         }
04357     }
04358 }
04359 
04360 //-------------------------------------------------------------------------
04361 //
04362 //  Prepa Fill Low Frequency correlations between StexEchas
04363 //                         (for writing in ROOT file)
04364 //
04365 //-------------------------------------------------------------------------
04366 void TEcnaRun::TRootLfCor()
04367 {
04368   if (fTagLfCor[0] == 1 )
04369     {
04370       for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
04371         {
04372           for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04373             {
04374               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
04375                 fT2d_lf_cor[i0StexEcha][j0StexEcha];
04376             }
04377         }
04378     }
04379 }
04380 
04381 //-------------------------------------------------------------------------
04382 //
04383 //  Prepa Fill High Frequency covariances between StexEchas
04384 //                           (for writing in ROOT file)
04385 //
04386 //-------------------------------------------------------------------------
04387 void TEcnaRun::TRootHfCov()
04388 {
04389   if (fTagHfCov[0] == 1 )
04390     {
04391       for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
04392         {
04393           for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04394             {
04395               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
04396                 fT2d_hf_cov[i0StexEcha][j0StexEcha];
04397             }
04398         }
04399     }
04400 }
04401 
04402 //-------------------------------------------------------------------------
04403 //
04404 //  Prepa Fill High Frequency correlations between StexEchas
04405 //                         (for writing in ROOT file)
04406 //
04407 //-------------------------------------------------------------------------
04408 void TEcnaRun::TRootHfCor()
04409 {
04410   if (fTagHfCor[0] == 1 )
04411     {
04412       for (Int_t i0StexEcha = 0; i0StexEcha < fEcal->MaxCrysEcnaInStex(); i0StexEcha++)
04413         {
04414           for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04415             {
04416               gCnaRootFile->fCnaIndivResult->fMatMat(i0StexEcha, j0StexEcha) =
04417                 fT2d_hf_cor[i0StexEcha][j0StexEcha];
04418             }
04419         }
04420     }
04421 }
04422 
04423 
04424 //-------------------------------------------------------------------------
04425 //
04426 //  Prepa Fill covariances between samples for a given StexEcha
04427 //                      (for writing in ROOT file)
04428 //
04429 //-------------------------------------------------------------------------
04430 void TEcnaRun::TRootCovCss(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
04431 {
04432    if (fTagCovCss[user_StexEcha] == 1 )
04433      {
04434        for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
04435          {
04436            for (Int_t j0Sample = 0; j0Sample < argNbSampWrite; j0Sample++)
04437              {
04438                gCnaRootFile->fCnaIndivResult->fMatMat(i0Sample, j0Sample) =
04439                  fT3d_cov_ss[user_StexEcha][i0Sample][j0Sample];
04440              }
04441          }
04442      }
04443 }
04444 
04445 //-------------------------------------------------------------------------
04446 //
04447 //  Prepa Fill correlations between samples for a given StexEcha
04448 //                        (for writing in ROOT file)
04449 //
04450 //-------------------------------------------------------------------------
04451 void TEcnaRun::TRootCorCss(const Int_t& user_StexEcha, const Int_t& argNbSampWrite)
04452 {
04453    if (fTagCorCss[user_StexEcha] == 1 )
04454      {
04455        for (Int_t i0Sample = 0; i0Sample < argNbSampWrite; i0Sample++)
04456          {
04457            for (Int_t j0Sample = 0; j0Sample < argNbSampWrite; j0Sample++)
04458              {
04459                gCnaRootFile->fCnaIndivResult->fMatMat(i0Sample, j0Sample) =
04460                  fT3d_cor_ss[user_StexEcha][i0Sample][j0Sample];
04461              }
04462          }
04463      }
04464 }
04465 
04466 //-------------------------------------------------------------------------
04467 //
04468 //  Prepa Fill expectation values of the expectation values of the samples
04469 //  for all the StexEchas
04470 //                        (for writing in ROOT file)
04471 //
04472 //-------------------------------------------------------------------------
04473 void TEcnaRun::TRootPed()
04474 {
04475   if (fTagPed[0] == 1 )
04476     {
04477       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04478         {
04479           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04480             fT1d_ev_ev[j0StexEcha];
04481         }      
04482     }
04483 }
04484 //-------------------------------------------------------------------------
04485 //
04486 //  Prepa Fill expectation values of the sigmas of the samples
04487 //  for all the StexEchas
04488 //                        (for writing in ROOT file)
04489 //
04490 //-------------------------------------------------------------------------
04491 void TEcnaRun::TRootTno()
04492 {
04493   if (fTagTno[0] == 1 )
04494     {
04495       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04496         {
04497           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04498             fT1d_evsamp_of_sigevt[j0StexEcha];
04499         }      
04500     }
04501 }
04502 
04503 //-------------------------------------------------------------------------
04504 //
04505 //  Prepa Fill expectation values of the (sample,sample) correlations
04506 //  for all the StexEchas
04507 //                        (for writing in ROOT file)
04508 //
04509 //-------------------------------------------------------------------------
04510 void TEcnaRun::TRootMeanCorss()
04511 {
04512   if (fTagMeanCorss[0] == 1 )
04513     {
04514       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04515         {
04516           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04517             fT1d_ev_cor_ss[j0StexEcha];
04518         }      
04519     }
04520 }
04521 
04522 //-------------------------------------------------------------------------
04523 //
04524 //  Prepa Fill sigmas of the expectation values of the samples
04525 //  for all the StexEchas
04526 //                        (for writing in ROOT file)
04527 //
04528 //-------------------------------------------------------------------------
04529 void TEcnaRun::TRootLfn()
04530 {
04531   if (fTagLfn[0] == 1 )
04532     {
04533       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04534         {
04535           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04536             fT1d_sigevt_of_evsamp[j0StexEcha];
04537         }      
04538     }
04539 }
04540 
04541 //-------------------------------------------------------------------------
04542 //
04543 //  Prepa Fill sigmas of the expectation values of the sigmas
04544 //  for all the StexEchas
04545 //                        (for writing in ROOT file)
04546 //
04547 //-------------------------------------------------------------------------
04548 void TEcnaRun::TRootHfn()
04549 {
04550   if (fTagHfn[0] == 1 )
04551     {
04552       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04553         {
04554           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04555             fT1d_evevt_of_sigsamp[j0StexEcha];
04556         }      
04557     }
04558 }
04559 
04560 //-------------------------------------------------------------------------
04561 //
04562 //  Prepa Fill sigmas of the (sample,sample) correlations
04563 //  for all the StexEchas
04564 //                        (for writing in ROOT file)
04565 //
04566 //-------------------------------------------------------------------------
04567 void TEcnaRun::TRootSigCorss()
04568 {
04569   if (fTagSigCorss[0] == 1 )
04570     {
04571       for (Int_t j0StexEcha = 0; j0StexEcha < fEcal->MaxCrysEcnaInStex(); j0StexEcha++)
04572         {
04573           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexEcha) =
04574             fT1d_sig_cor_ss[j0StexEcha];
04575         }      
04576     }
04577 }
04578 
04579 //-------------------------------------------------------------------------
04580 //
04581 //  Prepa Fill Averaged Pedestals
04582 //  for all the StexStins
04583 //                        (for writing in ROOT file)
04584 //
04585 //-------------------------------------------------------------------------
04586 void TEcnaRun::TRootAvPed()
04587 {
04588   if (fTagAvPed[0] == 1 )
04589     {
04590       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04591         {
04592           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04593             fT1d_av_mped[j0StexStinEcna];
04594         }
04595     }
04596 }
04597 
04598 //-------------------------------------------------------------------------
04599 //
04600 //  Prepa Fill 
04601 //  
04602 //                        (for writing in ROOT file)
04603 //
04604 //-------------------------------------------------------------------------
04605 void TEcnaRun::TRootAvEvCorss()
04606 {
04607   if (fTagAvMeanCorss[0] == 1 )   // test 1st elt only since global calc
04608     {
04609       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04610         {
04611           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04612             fT1d_av_ev_corss[j0StexStinEcna];
04613         }
04614     }
04615 }
04616 
04617 //-------------------------------------------------------------------------
04618 //
04619 //  Prepa Fill 
04620 //  
04621 //                        (for writing in ROOT file)
04622 //
04623 //-------------------------------------------------------------------------
04624 void TEcnaRun::TRootAvSigCorss()
04625 {
04626   if (fTagAvSigCorss[0] == 1 )   // test 1st elt only since global calc
04627     {
04628       for (Int_t j0StexStinEcna = 0; j0StexStinEcna < fEcal->MaxStinEcnaInStex(); j0StexStinEcna++)
04629         {
04630           gCnaRootFile->fCnaIndivResult->fMatHis(0, j0StexStinEcna) =
04631             fT1d_av_sig_corss[j0StexStinEcna];
04632         } 
04633     }
04634 }
04635 
04636 //=========================================================================
04637 //
04638 //         METHODS TO SET FLAGS TO PRINT (OR NOT) COMMENTS (DEBUG)
04639 //
04640 //=========================================================================
04641 
04642 void TEcnaRun::PrintComments()
04643 {
04644 // Set flags to authorize printing of some comments concerning initialisations (default)
04645 
04646   fFlagPrint = fCodePrintComments;
04647   cout << "*TEcnaRun::PrintComments()> Warnings and some comments on init will be printed" << endl;
04648 }
04649 
04650 void TEcnaRun::PrintWarnings()
04651 {
04652 // Set flags to authorize printing of warnings
04653 
04654   fFlagPrint = fCodePrintWarnings;
04655   cout << "*TEcnaRun::PrintWarnings()> Warnings will be printed" << endl;
04656 }
04657 
04658 void TEcnaRun::PrintAllComments()
04659 {
04660 // Set flags to authorize printing of the comments of all the methods
04661 
04662   fFlagPrint = fCodePrintAllComments;
04663   cout << "*TEcnaRun::PrintAllComments()> All the comments will be printed" << endl;
04664 }
04665 
04666 void  TEcnaRun::PrintNoComment()
04667 {
04668 // Set flags to forbid the printing of all the comments
04669 
04670   fFlagPrint = fCodePrintNoComment;
04671 }
04672 //=========================== E N D ======================================