Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:36

0001 #ifndef CL_TEcnaRun_H
0002 #define CL_TEcnaRun_H
0003 
0004 // system include files
0005 #include <memory>
0006 #include <iostream>
0007 #include <fstream>
0008 #include <iomanip>
0009 #include <string>
0010 #include <vector>
0011 #include <ctime>
0012 #include <cmath>
0013 #include <cstdio>
0014 #include "Riostream.h"
0015 
0016 // ROOT include files
0017 #include "TObject.h"
0018 #include "TSystem.h"
0019 #include "TString.h"
0020 #include "TVectorD.h"
0021 
0022 // user include files
0023 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaObject.h"
0024 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParEcal.h"
0025 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaHeader.h"
0026 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParCout.h"
0027 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParPaths.h"
0028 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h"
0029 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaWrite.h"
0030 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRootFile.h"
0031 
0032 ///-----------------------------------------------------------
0033 ///   TEcnaRun.h
0034 ///   Update: 05/10/2012
0035 ///   Authors:   B.Fabbro (bernard.fabbro@cea.fr), FX Gentit
0036 ///              DSM/IRFU/SPP CEA-Saclay
0037 ///   Copyright: Those valid for CEA sofware
0038 ///
0039 ///   ECNA web page:
0040 ///     http://cms-fabbro.web.cern.ch/cms-fabbro/
0041 ///     cna_new/Correlated_Noise_Analysis/ECNA_main_page.htm
0042 ///-----------------------------------------------------------
0043 ///
0044 /// TEcnaRun + ECNA (Ecal Correlated Noise Analysis) instructions for use
0045 ///            in the framework of CMSSW.
0046 ///
0047 ///==============> INTRODUCTION
0048 ///
0049 ///    The present documentation contains:
0050 ///
0051 ///    [1] a brief description of the ECNA package with instructions for use
0052 ///        in the framework of the CMS Software
0053 ///
0054 ///    [2] the documentation for the class TEcnaRun
0055 ///
0056 ///==[1]=====================================================================================
0057 ///
0058 ///         DOCUMENTATION FOR THE INTERFACE: ECNA package / CMSSW / SCRAM
0059 ///
0060 ///==========================================================================================
0061 ///
0062 ///  ECNA consists in 2 packages named: EcalCorrelatedNoiseAnalysisModules and
0063 ///  EcalCorrelatedNoiseAnalysisAlgos.
0064 ///
0065 ///  The directory tree is the following:
0066 ///
0067 ///      <local path>/CMSSW_a_b_c/src/----CalibCalorimetry/---EcalCorrelatedNoiseAnalysisModules/BuildFile
0068 ///                              |   |                    |                                     |---interface/
0069 ///                              |   |                    |                                     |---src/
0070 ///                                  |                    |                                     |---data/
0071 ///                                  |                    |
0072 ///                                  |                    |---EcalCorrelatedNoiseAnalysisAlgos/BuildFile
0073 ///                                  |                    |                                   |---interface/
0074 ///                                  |                    |                                   |---src/
0075 ///                                  |                    |                                   |---test/
0076 ///                                  |                    |
0077 ///                                  |                    |
0078 ///                                  |                    \--- <other packages of CalibCalorimetry>
0079 ///                                  |
0080 ///                                  \----<other subsystems...>
0081 ///
0082 ///
0083 ///    The package EcalCorrelatedNoiseAnalysisModules contains one standard analyzer
0084 ///    (EcnaAnalyzer). The user can edit its own analyzer.
0085 ///    A detailed description is given here after in the class TEcnaRun documentation.
0086 ///    The package EcalCorrelatedNoiseAnalysisAlgos contains the basic ECNA classes
0087 ///    (in src and interface) and standalone executables (in directory test).
0088 ///
0089 ///==[2]======================================================================================
0090 ///
0091 ///                         CLASS TEcnaRun DOCUMENTATION
0092 ///
0093 ///===========================================================================================
0094 ///TEcnaRun.
0095 ///
0096 ///
0097 /// Brief and general description
0098 /// -----------------------------
0099 ///
0100 ///   This class allows the user to calculate pedestals, noises,
0101 ///   correlations and other quantities of interest for correlated
0102 ///   noise studies on the CMS/ECAL (EB and EE).
0103 ///
0104 ///   Three main operations are performed by the class TEcnaRun. Each of them is
0105 ///   associated with a specific method of the analyzer EcnaAnalyzer:
0106 ///
0107 ///    (1) Initialization and calls to "preparation methods".
0108 ///        This task is done in the constructor of the analyzer:
0109 ///        EcnaAnalyzer::EcnaAnalyzer(const edm::ParameterSet& pSet)
0110 ///
0111 ///    (2) Building of the event distributions (distributions of the sample ADC
0112 ///        values for each sample, each channel, etc...)
0113 ///        This task is done in the method "analyze" of the analyzer:
0114 ///        EcnaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
0115 ///
0116 ///    (3) Calculation of the different quantities (correlations, pedestals, noises, etc...)
0117 ///        from the distributions obtained in (2) and writing of these quantities
0118 ///        in results ROOT files and also in ASCII files.
0119 ///        This task is done in the destructor of the analyzer:
0120 ///        EcnaAnalyzer::~EcnaAnalyzer()
0121 ///
0122 ///
0123 /// Use of the class TEcnaRun by the analyzer EcnaAnalyzer
0124 /// ------------------------------------------------------
0125 ///
0126 ///           see files EcnaAnalyzer.h and EcnaAnalyzer.cc
0127 ///           in package EcalCorrelatedNoiseAnalysisModules
0128 ///
0129 /// More detailled description of the class TEcnaRun
0130 /// -----------------------------------------------
0131 ///
0132 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0133 ///
0134 ///                     Declaration and Print Methods
0135 ///
0136 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0137 ///
0138 ///     Just after the declaration with the constructor,
0139 ///     you can set a "Print Flag" by means of the following "Print Methods":
0140 ///
0141 ///     TEcnaRun* MyCnaRun = new TEcnaRun(...); // declaration of the object MyCnaRun
0142 ///
0143 ///   // Print Methods:
0144 ///
0145 ///    MyCnaRun->PrintNoComment();  // Set flag to forbid printing of all the comments
0146 ///                                 // except ERRORS.
0147 ///
0148 ///    MyCnaRun->PrintWarnings();   // (DEFAULT)
0149 ///                                 // Set flag to authorize printing of some warnings.
0150 ///                                 // WARNING/INFO: information on something unusual
0151 ///                                 // in the data.
0152 ///                                 // WARNING/CORRECTION: something wrong (but not too serious)
0153 ///                                 // in the value of some argument.
0154 ///                                 // Automatically modified to a correct value.
0155 ///
0156 ///   MyCnaRun->PrintComments();    // Set flag to authorize printing of infos
0157 ///                                 // and some comments concerning initialisations
0158 ///
0159 ///   MyCnaRun->PrintAllComments(); // Set flag to authorize printing of all the comments
0160 ///
0161 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0162 ///
0163 ///           Method GetReadyToReadData(...) and associated methods
0164 ///
0165 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0166 ///
0167 ///      MyCnaRun->GetReadyToReadData(AnalysisName,      NbOfSamples,       RunNumber,
0168 ///                           FirstReqEvtNumber, LastReqEvtNumber,  ReqNbOfEvts,
0169 ///                                   StexNumber,        [RunType]);
0170 ///
0171 ///   Explanations for the arguments (all of them are input arguments):
0172 ///
0173 ///      TString  AnalysisName: code for the analysis. According to this code,
0174 ///                             the analyzer EcnaAnalyser selects the event type
0175 ///                             (PEDESTAL_STD, PEDESTAL_GAP, LASER_STD, etc...)
0176 ///                             and some other event characteristics
0177 ///                             (example: the gain in pedestal runs:
0178 ///                              AnalysisName = "Ped1" or "Ped6" or "Ped12")
0179 ///                             See EcnaAnalyser.h for a list of available codes.
0180 ///                             The string AnalysisName is automatically
0181 ///                             included in the name of the results files
0182 ///                             (see below: results files paragraph).
0183 ///
0184 ///      Int_t     NbOfSamples         number of samples (=10 maximum)
0185 ///      Int_t     RunNumber:          run number
0186 ///      Int_t     FirstReqEvtNumber:  first requested event number (numbering starting from 1)
0187 ///      Int_t     LastReqEvtNumber:   last  requested event number
0188 ///      Int_t     ReqNbOfEvts:        requested number of events
0189 ///      Int_t     StexNumber:         Stex number (Stex = SM if EB, Dee if EE)
0190 ///
0191 ///     The different quantities (correlations, etc...) will be calculated
0192 ///     for ReqNbOfEvts events between event# FirstReqEvtNumber and event# LastReqEvtNumber.
0193 ///     If LastReqEvtNumber = 0, the calculations will be performed from event# FirstReqEvtNumber
0194 ///     until EOF if necessary (i.e. if the number of treated events is < ReqNbOfEvts)
0195 ///
0196 ///      Int_t     RunType [optional]: run type
0197 ///
0198 ///                          PEDESTAL_STD =  9
0199 ///                          LASER_STD    =  4
0200 ///                          PEDESTAL_GAP = 18, etc...
0201 ///      (see CMSSSW/DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h)
0202 ///
0203 ///      if RunType is specified, the run type will be displayed on the plots
0204 ///
0205 ///==============> Method to set the start and stop times of the analysis (optional)
0206 ///
0207 ///  A method can be used to set the fStartDate and fStopDate attributes
0208 ///  of the class TEcnaHeader from start and stop time given by the user provided
0209 ///  these values have been recovered from the event reading:
0210 ///
0211 ///      void  MyCnaRun->StartStopDate(const TString& StartDate, const TString& StopDate);
0212 ///
0213 ///     // TString StartDate, StopDate:  start and stop time of the run
0214 ///     //                               in "date" format. Example:
0215 ///     //                               Wed Oct  8 04:14:23 2003
0216 ///
0217 ///     If the method is not called, the values of the attributes
0218 ///     fStartDate and fStopDate are set to: "!Start date> no info"
0219 ///     and "!Stop date> no info" at the level of Init() method of the class TEcnaHeader.
0220 ///     The values of StartDate and StopDate are written in the header of
0221 ///     the .root result file.
0222 ///
0223 ///  PS: another similar method exists, with time_t type arguments:
0224 ///
0225 ///     void  MyCnaRun->StartStopTime(time_t  StartTime, time_t  StopTime);
0226 ///
0227 ///
0228 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0229 ///
0230 ///                       Calculation methods
0231 ///
0232 ///&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0233 ///
0234 ///    The "calculation methods" are methods which compute the different
0235 ///    quantities of interest. They use the ADC sample values which can be
0236 ///    recovered by the method void SampleValues():
0237 ///
0238 ///  void SampleValues(); // 3D histo of the sample ADC value
0239 ///                       // for each triple (channel,sample,event)
0240 ///
0241 ///    List of the calculation methods with associated formulae:
0242 ///
0243 ///.......... Calculation methods ( need previous call to GetReadyToReadData(...) )
0244 ///
0245 ///   //   A(t,c,s,e) : ADC value for Stin t channel c, sample s, event e
0246 ///                                  (Stin = tower if EB, SC if EE)
0247 ///
0248 ///   //   E_e , Cov_e : average, covariance over the events
0249 ///   //   E_s , Cov_s : average, covariance over the samples
0250 ///   //   E_s,s'      : average  over couples of samples (half correlation matrix)
0251 ///
0252 ///   //   e* : random variable associated to events
0253 ///   //   s* : random variable associated to samples
0254 ///
0255 ///  void SampleMeans();  // Expectation values for each couple (channel,sample)
0256 ///  //    SMean(t,c,s)  = E_e[A(t,c,s,e*)]
0257 ///
0258 ///  void SampleSigmas(); // Sigmas for each couple (channel,sample)
0259 ///  //    SSigma(t,c,s) = sqrt{ Cov_e[A(t,c,s,e*),A(t,c,s,e*)] }
0260 ///
0261 ///  //...........................................
0262 ///  void CovariancesBetweenSamples();  // (s,s') covariances  for each channel
0263 ///  //    Cov(t,c;s,s') = Cov_e[ A(t,c,s,e*) , A(t,c,s',e*) ]
0264 ///  //                = E_e[ ( A(t,c,s,e*) - E_e[A(t,c,s,e*)] )*( A(t,c,s',e*) - E_e[A(t,c,s',e*)] ) ]
0265 ///
0266 ///  void CorrelationsBetweenSamples(); // (s,s') correlations for each channel
0267 ///  //    Cor(t,c;s,s') = Cov(t,c;s,s')/sqrt{ Cov(t,c;s,s)*Cov(t,c;s',s') }
0268 ///
0269 ///  //.............................................. *==> Stin = tower if EB, SuperCrystal if EE
0270 ///  void LowFrequencyCovariancesBetweenChannels();   // LF (t;c,c') covariances  for each Stin
0271 ///  void HighFrequencyCovariancesBetweenChannels();  // HF (t;c,c') covariances  for each Stin
0272 ///  void LowFrequencyCorrelationsBetweenChannels();  // LF (t;c,c') correlations for each Stin
0273 ///  void HighFrequencyCorrelationsBetweenChannels(); // HF (t;c,c') correlations for each Stin
0274 ///
0275 ///   //    LFCov(t;c,c') = Cov_e[ E_s[A(t,c,s*,e*)] , E_s[A(t,c',s*,e*) ]
0276 ///   //
0277 ///   //                = E_e[ ( E_s[A(t,c ,s*,e*)] - E_e[ E_s[A(t,c ,s*,e*)] ] )*
0278 ///   //                        ( E_s[A(t,c',s*,e*)] - E_e[ E_s[A(t,c',s*,e*)] ] ) ]
0279 ///   //
0280 ///   //    HFCov(t;c,c') = E_e[ Cov_s[ A(t,c,s*,e*) , A(t,c',s*,e*) ] ]
0281 ///   //
0282 ///   //                = E_e[ E_s[ ( A(t,c ,s*,e*) - E_s[A(t,c ,s*,e*)] )*
0283 ///   //                            ( A(t,c',s*,e*) - E_s[A(t,c',s*,e*)] ) ] ]
0284 ///   //
0285 ///   //    LFCor(t;c,c') = LFCov(t;c,c')/sqrt{ LFCov(t;c,c)*LFCov(t;c',c') }
0286 ///   //
0287 ///   //    HFCor(t;c,c') = HFCov(t;c,c')/sqrt{ HFCov(t;c,c)*HFCov(t;c',c') }
0288 ///
0289 ///  //.............................................. . *==> Stex = SM if EB, Dee if EE
0290 ///  void LowFrequencyMeanCorrelationsBetweenTowers();  // LF (tow,tow') correlations for each SM
0291 ///  void HighFrequencyMeanCorrelationsBetweenTowers(); // HF (tow,tow') correlations for each SM
0292 ///
0293 ///  void LowFrequencyMeanCorrelationsBetweenSCs();     // LF (sc,sc') correlations for each Dee
0294 ///  void HighFrequencyMeanCorrelationsBetweenSCs();    // HF (sc,sc') correlations for each Dee
0295 ///
0296 /// //.................................................... Quantities as a function of Xtal#
0297 ///  void Pedestals();
0298 ///  void TotalNoise();
0299 ///  void LowFrequencyNoise();
0300 ///  void HighFrequencyNoise();
0301 ///  void MeanCorrelationsBetweenSamples();
0302 ///  void SigmaOfCorrelationsBetweenSamples();
0303 ///
0304 ///  // Pedestal(t,c)    = E_e[ E_s[A(t,c,s*,e*)] ]
0305 ///  // TotalNoise(t,c)  = E_s[ sqrt{ E_e[ ( A(t,c,s*,e*) - E_e[A(t,c,s*,e*)] )^2 ] } ]
0306 ///  // LowFqNoise(t,c)  = sqrt{ E_e[ ( E_s[A(t,c,s*,e*)] - E_e[ E_s[A(t,c,s*,e*)] ] )^2 ] }
0307 ///  // HighFqNoise(t,c) = E_e[ sqrt{ E_s[ (A(t,c,s*,e*) - E_s[A(t,c,s*,e*)] )^2 ] } ]
0308 ///  // MeanCorss(t,c)   = E_s,s'[ Cor(t,c;s,s') ]
0309 ///  // SigmaCorss(t,c)  = E_s,s'[ Cor(t,c;s,s') - E_s,s'[ Cor(t,c;s,s') ] ]
0310 ///
0311 ///  //............ Quantities as a function of tower# (EB) or SC# (EE), average over the Xtals
0312 ///  void AveragePedestals();
0313 ///  void AverageTotalNoise();
0314 ///  void AverageLowFrequencyNoise();
0315 ///  void AverageHighFrequencyNoise();
0316 ///  void AverageMeanCorrelationsBetweenSamples();
0317 ///  void AverageSigmaOfCorrelationsBetweenSamples();
0318 ///
0319 ///  // t = tower if EB , SC if EE , c = channel (Xtal)
0320 ///  // AveragePedestal(t) = E_c[Pedestal(t,c*)]
0321 ///  // TotalNoise(t)      = E_c[TotalNoise(t,c*)]
0322 ///  // LowFqNoise(t)      = E_c[LowFqNoise(t,c*)]
0323 ///  // HighFqNoise(t)     = E_c[HighFqNoise(t,c*)]
0324 ///  // MeanCorss(t)       = E_c[MeanCorss(t,c*)]
0325 ///  // SigmaCorss(t)      = E_c[SigmaCorss(t,c*)]
0326 ///
0327 ///==============> RESULTS FILES
0328 ///
0329 ///  The calculation methods above provide results which can be used directly
0330 ///  in the user's code. However, these results can also be written in results
0331 ///  files by appropriate methods.
0332 ///  The names of the results files are automaticaly generated.
0333 ///
0334 ///  It is also possible to write results in ASCII files  => See TEcnaWrite and TEcnaGui
0335 ///  It is also possible to plot results in ROOT canvases => See TEcnaHistos and TEcnaGui
0336 ///
0337 /// *-----------> Codification for the name of the ROOT file:
0338 ///
0339 ///  The name of the ROOT file is the following:
0340 ///
0341 ///       aaa_S1_sss_Rrrr_fff_lll_SMnnn.root     for EB
0342 ///       aaa_S1_sss_Rrrr_fff_lll_Deennn.root    for EE
0343 ///
0344 ///  with:
0345 ///       aaa = Analysis name
0346 ///       sss = number of samples
0347 ///       rrr = Run number
0348 ///       fff = First requested event number
0349 ///       lll = Last  requested events
0350 ///       mmm = Requested number of events
0351 ///       nnn = SM number or Dee number
0352 ///
0353 ///  This name is automatically generated from the values of the arguments
0354 ///  of the method "GetReadyToReadData".
0355 ///
0356 /// *-----------> Method which writes the results in the ROOT file:
0357 ///
0358 ///       Bool_t  MyCnaRun->WriteRootFile();
0359 ///
0360 ///===================================================================================================
0361 ///
0362 
0363 class TEcnaRun : public TObject {
0364 private:
0365   //............ attributes
0366 
0367   Int_t fgMaxCar;  // Max nb of caracters for char*
0368 
0369   Int_t fCnaCommand, fCnaError;
0370 
0371   Int_t fCnew;  // flags for dynamical allocation
0372   Int_t fCdelete;
0373 
0374   TString fTTBELL;
0375 
0376   Int_t* fMiscDiag;  // Counters for miscellaneous diagnostics
0377   Int_t fNbOfMiscDiagCounters;
0378   Int_t fMaxMsgIndexForMiscDiag;
0379 
0380   TEcnaObject* fObjectManager;     // for ECNA object management
0381   TEcnaHeader* fFileHeader;        // header for result type file
0382   TEcnaParEcal* fEcal;             // for access to the Ecal current subdetector parameters
0383   TEcnaNumbering* fEcalNumbering;  // for access to the Ecal channel, Stin and Stex numbering
0384   TEcnaParCout* fCnaParCout;       // for comment/error messages
0385   TEcnaParPaths* fCnaParPaths;     // for file access
0386   TEcnaWrite* fCnaWrite;           // for access to the results files
0387 
0388   //  TEcnaRootFile *gCnaRootFile;
0389 
0390   TString fFlagSubDet;
0391   TString fStexName, fStinName;
0392 
0393   Bool_t fOpenRootFile;  // flag open ROOT file (open = kTRUE, close = kFALSE)
0394   Int_t fReadyToReadData;
0395 
0396   TString fRootFileName;
0397   TString fRootFileNameShort;
0398   TString fNewRootFileName;
0399   TString fNewRootFileNameShort;
0400 
0401   Int_t fSpecialStexStinNotIndexed;  // management of event distribution building
0402   Int_t fStinIndexBuilt;
0403   Int_t fBuildEvtNotSkipped;
0404 
0405   Int_t fNbSampForFic;
0406   Int_t fNbSampForCalc;
0407 
0408   Int_t fNumberOfEvents;
0409 
0410   Int_t fMemoReadNumberOfEventsforSamples;
0411 
0412   Double_t*** fT3d_AdcValues;  // 3D array[channel][sample][event] ADC values
0413   Double_t** fT3d2_AdcValues;
0414   Double_t* fT3d1_AdcValues;
0415   Int_t* fTagAdcEvt;
0416 
0417   Int_t** fT2d_NbOfEvts;  // 2D array[channel][sample] max nb of evts read for a given (channel,sample)
0418   Int_t* fT1d_NbOfEvts;
0419   Int_t* fTagNbOfEvts;
0420 
0421   Int_t* fT1d_StexStinFromIndex;  // 1D array[Stin] Stin Number as a function of the index Stin
0422   Int_t* fTagStinNumbers;
0423 
0424   Double_t** fT2d_ev;  // 2D array[channel][sample] for expectation values
0425   Double_t* fT1d_ev;
0426   Int_t* fTagMSp;
0427 
0428   Double_t** fT2d_sig;  // 2D array[channel][sample] for sigmass
0429   Double_t* fT1d_sig;
0430   Int_t* fTagSSp;
0431 
0432   Double_t*** fT3d_cov_ss;  // 3D array[channel][sample][sample] for (sample,sample) covariances
0433   Double_t** fT3d2_cov_ss;
0434   Double_t* fT3d1_cov_ss;
0435   Int_t* fTagCovCss;
0436 
0437   Double_t*** fT3d_cor_ss;  // 3D array[channel][sample][sample] for (sample,sample) correlations
0438   Double_t** fT3d2_cor_ss;
0439   Double_t* fT3d1_cor_ss;
0440   Int_t* fTagCorCss;
0441 
0442   //...........................................................................
0443   Double_t* fT1d_ev_ev;    // 1D array[channel] for expectation values of the expectation values of the samples
0444   Int_t* fTagPed;          // (PEDESTAL)
0445   Double_t* fT1d_av_mped;  // 1D array[Stin] for expectation values of the Pesdestals of the Stins
0446   Int_t* fTagAvPed;        // (AVERAGED PEDESTAL)
0447 
0448   Double_t* fT1d_evsamp_of_sigevt;  // 1D array[channel] for expectation values of the sigmas of the samples
0449   Int_t* fTagTno;                   // (TOTAL NOISE)
0450   Double_t* fT1d_av_totn;           // 1D array[Stin] for expectation values of the total noise
0451   Int_t* fTagAvTno;                 //(AVERAGED TOTAL NOISE)
0452 
0453   Double_t* fT1d_ev_cor_ss;    // 1D array[channel] for expectation values of the cor(s,s)
0454   Int_t* fTagMeanCorss;        // (MEAN COR(S,S))
0455   Double_t* fT1d_av_ev_corss;  // 1D array[Stin] for expectation values of the mean cor(s,s)
0456   Int_t* fTagAvMeanCorss;      // (AVERAGED MEAN COR(S,S))
0457 
0458   Double_t* fT1d_sigevt_of_evsamp;  // 1D array[channel] for sigmas of the expectation values of the samples
0459   Int_t* fTagLfn;                   // (LOW FREQUENCY NOISE)
0460   Double_t* fT1d_av_lofn;           // 1D array[Stin]  the expectation values of the low frequency noise
0461   Int_t* fTagAvLfn;                 // (AVERAGED LOW FREQUENCY NOISE)
0462 
0463   Double_t* fT1d_evevt_of_sigsamp;  // 1D array[channel] for sigmas of the sigmas of the samples
0464   Int_t* fTagHfn;                   // (HIGH FREQUENCY NOISE)
0465   Double_t* fT1d_av_hifn;           // 1D array[channel] for expectation values of the high frequency noise
0466   Int_t* fTagAvHfn;                 // (AVERAGED HIGH FREQUENCY NOISE)
0467 
0468   Double_t* fT1d_sig_cor_ss;    // 1D array[channel] for sigmas of the cor(s,s)
0469   Int_t* fTagSigCorss;          // (SIGMA OF COR(S,S))
0470   Double_t* fT1d_av_sig_corss;  // 1D array[channel] for expectation values of sigmas  the  of the cor(s,s)
0471   Int_t* fTagAvSigCorss;        // (AVERAGED SIGMA OF COR(S,S))
0472 
0473   //...........................................................................
0474   Double_t** fT2d_lf_cov;  // 2D array[channel][channel] for (channel,channel) low frequency covariances
0475   Double_t* fT2d1_lf_cov;
0476   Int_t* fTagLfCov;
0477 
0478   Double_t** fT2d_lf_cor;  // 2D array[channel][channel] for (channel,channel) low frequency correlations
0479   Double_t* fT2d1_lf_cor;
0480   Int_t* fTagLfCor;
0481 
0482   //...........................................................................
0483   Double_t** fT2d_hf_cov;  // 2D array[channel][channel] for (channel,channel) low frequency covariances
0484   Double_t* fT2d1_hf_cov;
0485   Int_t* fTagHfCov;
0486 
0487   Double_t** fT2d_hf_cor;  // 2D array[channel][channel] for (channel,channel) low frequency correlations
0488   Double_t* fT2d1_hf_cor;
0489   Int_t* fTagHfCor;
0490 
0491   //------------------------- 2 tableaux (ci,cj)
0492   Double_t** fT2d_lfcc_mostins;  // 2D array[Stin][Stin] for (Stin,Stin) mean cov(c,c)
0493   Double_t* fT2d1_lfcc_mostins;  // (relevant ones) averaged over samples
0494   Int_t* fTagLFccMoStins;
0495 
0496   Double_t** fT2d_hfcc_mostins;  // 2D array[Stin][Stin] for (Stin,Stin) mean cor(c,c)
0497   Double_t* fT2d1_hfcc_mostins;  // (relevant ones) averaged over samples
0498   Int_t* fTagHFccMoStins;
0499 
0500   //------------------------------------------------------------------------------------
0501 
0502   Int_t** fT2dCrysNumbersTable;
0503   Int_t* fT1dCrysNumbersTable;
0504 
0505   std::ofstream fFcout_f;
0506 
0507   Int_t fFlagPrint;
0508   Int_t fCodePrintComments, fCodePrintWarnings, fCodePrintAllComments, fCodePrintNoComment;
0509 
0510 public:
0511   //................. constructors
0512 
0513   TEcnaRun();                              //  constructor without argument
0514   TEcnaRun(TEcnaObject*, const TString&);  //  constructors with argument (FOR USER'S DECLARATION)
0515   TEcnaRun(TEcnaObject*, const TString&, const Int_t&);
0516 
0517   //TEcnaRun(const TString&, const Int_t&, const TEcnaParPaths*, const TEcnaParCout*);
0518   //TEcnaRun(const TString&);               //  constructors with argument (FOR USER'S DECLARATION)
0519   //TEcnaRun(const TString&, const Int_t&);
0520 
0521   TEcnaRun(const TEcnaRun&);  //  copy constructor
0522 
0523   //.................... C++ methods
0524 
0525   //TEcnaRun&  operator=(const TEcnaRun&);  //  overloading of the operator=
0526 
0527   //................. destructor
0528 
0529   ~TEcnaRun() override;
0530 
0531   //...................................................... methods that will (should) be private
0532 
0533   void Init(TEcnaObject*);
0534 
0535   void SetEcalSubDetector(const TString&);
0536 
0537   Bool_t GetPathForResults();
0538 
0539   Bool_t OpenRootFile(const Text_t*, const TString&);
0540   Bool_t CloseRootFile(const Text_t*);
0541 
0542   //======================================= methods for the user =========================================
0543   void GetReadyToReadData(const TString&, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&);
0544   void GetReadyToReadData(
0545       const TString&, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&);
0546 
0547   Bool_t GetSampleAdcValues(const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Double_t&);
0548   Bool_t ReadSampleAdcValues();
0549   Bool_t ReadSampleAdcValues(const Int_t&);
0550 
0551   void StartStopDate(const TString&, const TString&);
0552   void StartStopTime(time_t, time_t);
0553 
0554   //................... Calculation methods ( associated to GetReadyToReadData(...) )
0555   //-------------------- Standard Calculations
0556   void StandardCalculations();  // see list in the method itself (.cc file)
0557 
0558   void SampleMeans();   // Calculation of the expectation values over the events
0559                         // for each sample and for each channel
0560   void SampleSigmas();  // Calculation of the variances over the events
0561                         // for each sample and for each channel
0562   //...........................................
0563   void CovariancesBetweenSamples();   // Calculation of the (s,s) covariances over the events
0564                                       // for each channel
0565   void CorrelationsBetweenSamples();  // Calculation of the (s,s) correlations over the events
0566                                       // for each channel
0567   //..........................................................
0568   void Pedestals();
0569   void TotalNoise();
0570   void LowFrequencyNoise();
0571   void HighFrequencyNoise();
0572   void MeanCorrelationsBetweenSamples();
0573   void SigmaOfCorrelationsBetweenSamples();
0574 
0575   //..........................................................
0576   void AveragePedestals();
0577   void AverageTotalNoise();
0578   void AverageLowFrequencyNoise();
0579   void AverageHighFrequencyNoise();
0580   void AverageMeanCorrelationsBetweenSamples();
0581   void AverageSigmaOfCorrelationsBetweenSamples();
0582 
0583   //---------- Calculations involving cov and cor between channels
0584   //
0585   //   Recommended calling sequences: expert1, expert1 + expert2,  expert2
0586   //
0587   //   NOT recommended: expert2 + expert1  (lost of time and place)
0588   //
0589   //-------------------- Expert 1 Calculations
0590   void Expert1Calculations();  // see list in the method itself (.cc file)
0591 
0592   void LowFrequencyCovariancesBetweenChannels();
0593   void HighFrequencyCovariancesBetweenChannels();
0594 
0595   void LowFrequencyCorrelationsBetweenChannels();
0596   void HighFrequencyCorrelationsBetweenChannels();
0597 
0598   //-------------------- Expert 2 Calculations
0599   void Expert2Calculations();  // see list in the method itself (.cc file)
0600 
0601   void LowFrequencyMeanCorrelationsBetweenTowers();
0602   void HighFrequencyMeanCorrelationsBetweenTowers();
0603 
0604   void LowFrequencyMeanCorrelationsBetweenSCs();
0605   void HighFrequencyMeanCorrelationsBetweenSCs();
0606 
0607   //===================================== "technical" methods ==========================================
0608 
0609   void GetReadyToCompute();  // Make result root file name and check events
0610   void SampleValues();       // 3D histo of the sample ADC value for each triple (channel,sample,event)
0611 
0612   //.................................... Technical calculation methods (Stin = Tower or SC)
0613   void LowFrequencyMeanCorrelationsBetweenStins();
0614   void HighFrequencyMeanCorrelationsBetweenStins();
0615 
0616   //...................................... ROOT file methods
0617   const TString& GetRootFileName() const;
0618   const TString& GetRootFileNameShort() const;
0619   const TString& GetNewRootFileName() const;
0620   const TString& GetNewRootFileNameShort() const;
0621 
0622   Bool_t WriteRootFile();
0623   Bool_t WriteNewRootFile(const TString&);
0624   Bool_t WriteRootFile(const Text_t*, Int_t&);
0625 
0626   void TRootStinNumbers();
0627   void TRootNbOfEvts(const Int_t&);
0628 
0629   void TRootAdcEvt(const Int_t&, const Int_t&);
0630 
0631   void TRootMSp(const Int_t&);
0632   void TRootSSp(const Int_t&);
0633 
0634   void TRootCovCss(const Int_t&, const Int_t&);
0635   void TRootCorCss(const Int_t&, const Int_t&);
0636 
0637   void TRootLfCov();
0638   void TRootLfCor();
0639 
0640   void TRootHfCov();
0641   void TRootHfCor();
0642 
0643   void TRootLFccMoStins();
0644   void TRootHFccMoStins();
0645 
0646   void TRootPed();
0647   void TRootTno();
0648   void TRootMeanCorss();
0649 
0650   void TRootLfn();
0651   void TRootHfn();
0652   void TRootSigCorss();
0653 
0654   void TRootAvPed();
0655   void TRootAvEvCorss();
0656   void TRootAvSigCorss();
0657   void TRootAvTno();
0658   void TRootAvLfn();
0659   void TRootAvHfn();
0660 
0661   //................................ Flags Print Comments/Debug
0662   void PrintNoComment();    // (default) Set flags to forbid the printing of all the comments
0663                             // except ERRORS
0664   void PrintWarnings();     // Set flags to authorize printing of some warnings
0665   void PrintComments();     // Set flags to authorize printing of infos and some comments
0666                             // concerning initialisations
0667   void PrintAllComments();  // Set flags to authorize printing of all the comments
0668 
0669   ClassDefOverride(TEcnaRun, 1)  // Calculation of correlated noises from data
0670 };
0671 
0672 #endif  //  CL_TEcnaRun_H