CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h

Go to the documentation of this file.
00001 #ifndef   CL_TEcnaRead_H
00002 #define   CL_TEcnaRead_H
00003 
00004 #include <time.h>
00005 #include <math.h>
00006 
00007 #include "TSystem.h"
00008 #include "TObject.h"
00009 #include "TString.h"
00010 #include "Riostream.h"
00011 #include "TVectorD.h"
00012 #include "TMatrixD.h"
00013 
00014 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaObject.h"
00015 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParEcal.h"
00016 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaHeader.h"
00017 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParCout.h"
00018 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParPaths.h"
00019 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaNumbering.h"
00020 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParHistos.h"
00021 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaWrite.h"
00022 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaResultType.h"
00023 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRootFile.h"
00024 
00351 
00352 class TEcnaRead: public TObject {
00353   
00354  private:
00355 
00356   //............ attributes
00357 
00358   // static  const  Int_t        fgMaxCar    = 512;          <== DANGEROUS ! 
00359 
00360   Int_t fgMaxCar;   // Max nb of caracters for char*
00361 
00362   Int_t fCnew;      // flags for dynamical allocation
00363   Int_t fCdelete;       
00364 
00365   TString fTTBELL;
00366 
00367   TEcnaObject    *fObjectManager;  // pointer to TEcnaObject keeped in attribute
00368 
00369   TEcnaParCout   *fCnaParCout;  // for comments or error messages
00370   TEcnaParPaths  *fCnaParPaths; // for NbBinsADC 
00371 
00372   TEcnaHeader    *fFileHeader;    // header for result file
00373   TEcnaParEcal   *fEcal;          // for Ecal parameters
00374   TEcnaNumbering *fEcalNumbering; // for Ecal numbering
00375   TEcnaParHistos *fCnaParHistos;  // for Histo codes
00376   TEcnaWrite     *fCnaWrite;      // for writing in ascii files
00377 
00378   //  TEcnaRootFile *gCnaRootFile;
00379 
00380   TString fFlagSubDet;
00381   TString fStexName, fStinName;
00382 
00383   Bool_t  fOpenRootFile; // flag open ROOT file (open = kTRUE, close = kFALSE)
00384   TString fCurrentlyOpenFileName; // Name of the file currently open
00385   TString fFlagNoFileOpen; // Flag to indicate that no file is open
00386 
00387   Int_t fReadyToReadRootFile;
00388   Int_t fLookAtRootFile;
00389 
00390   Int_t* fT1d_StexStinFromIndex; // 1D array[Stin] Stin Number as a function of the index Stin
00391   Int_t* fTagStinNumbers;
00392   Int_t  fMemoStinNumbers;
00393 
00394   //  Int_t fMemoReadNumberOfEventsforSamples;
00395 
00396   TString fPathRoot;  // path for results .root files directory
00397 
00398   Int_t fNbChanByLine;  // Nb channels by line (for ASCII results file)
00399   Int_t fNbSampByLine;  // Nb samples by line  (for ASCII results file)
00400 
00401   Int_t fFlagPrint;
00402   Int_t fCodePrintComments, fCodePrintWarnings, fCodePrintAllComments, fCodePrintNoComment;
00403 
00404   //............... flag data exists
00405 
00406   Bool_t fDataExist;
00407 
00408   //................ 3d array for sample ADC value fast transfert
00409   Double_t*** fT3d_AdcValues;   // 3D array[channel][sample][event] ADC values distibutions
00410   Double_t**  fT3d2_AdcValues; 
00411   Double_t*   fT3d1_AdcValues;
00412 
00413   //==========================================================================================
00414   //
00415   //                                      M E T H O D S
00416   //
00417   //==========================================================================================
00418   //.......................................... private methods
00419 
00420   void        fCopy(const TEcnaRead&);
00421 
00422  public: 
00423 
00424   //................. constructors
00425   TEcnaRead();                  //  constructor without argument (FOR USER'S DECLARATION)
00426   //  constructor with argument (FOR USER'S DECLARATION):
00427   TEcnaRead(TEcnaObject*, const TString);
00428 
00429   TEcnaRead(const TEcnaRead&);   //  copy constructor
00430 
00431   //.................... C++ methods
00432   TEcnaRead&  operator=(const TEcnaRead&);  //  overloading of the operator=
00433 
00434   //................. destructor
00435   virtual ~TEcnaRead();
00436   
00437   //========================================================================
00438   //
00439   //                    METHODS FOR THE USER
00440   //
00441   //========================================================================
00442   void     FileParameters(TString,
00443                           const Int_t&, const Int_t&, const Int_t&,
00444                           const Int_t&, const Int_t&, const Int_t&, TString);
00445   
00446   Bool_t   LookAtRootFile();  // if file exists: kTRUE , if not: kFALSE
00447   Bool_t   DataExist();       // if data exist:  kTRUE , if not: kFALSE
00448 
00449   TVectorD Read1DHisto(const Int_t&, const TString, const Int_t&, const Int_t&, const Int_t&);
00450   TVectorD Read1DHisto(const Int_t&, const TString, const Int_t&);
00451   TVectorD Read1DHisto(const Int_t&, const TString, const TString);
00452 
00453   TMatrixD ReadMatrix(const Int_t&, const TString, const TString, const Int_t&, const Int_t&);
00454   TMatrixD ReadMatrix(const Int_t&, const TString, const TString);
00455 
00456   //========================================================================
00457   //
00458   //                       "TECHNICAL" METHODS
00459   //
00460   //========================================================================
00461   //...................................................... methods that will (should) be private
00462   void     Init();
00463   void     SetEcalSubDetector(const TString);
00464 
00465   void     Anew(const TString);
00466   void     Adelete(const TString);
00467 
00468   Bool_t   OpenRootFile(const Text_t *, TString);
00469   Bool_t   CloseRootFile(const Text_t *);
00470   void     TestArrayDimH1(const TString, const TString, const Int_t&, const Int_t&);
00471   void     TestArrayDimH2(const TString, const TString, const Int_t&, const Int_t&);
00472 
00473   Bool_t   ReadRootFileHeader(const Int_t&);
00474 
00475   TVectorD ReadSampleAdcValues(const Int_t&, const Int_t&, const Int_t&, const Int_t&);  //(nb evts in burst) of (StinEcha,samp)
00476   //------------------------------------------------------------------------------------------------
00477   TVectorD ReadSampleMeans(const Int_t&,  const Int_t&, const Int_t&);    // (sample) of (StexStin,Xtal)
00478   TVectorD ReadSampleMeans(const Int_t&,  const Int_t&);                  // (MaxCrysInStin*sample) of (StexStin)
00479 
00480   TVectorD ReadSampleSigmas(const Int_t&, const Int_t&, const Int_t&);    // (sample) of (StexStin,Xtal)
00481   TVectorD ReadSampleSigmas(const Int_t&, const Int_t&);                  // (MaxCrysInStin*sample) of (StexStin)
00482 
00483   //------------------------------------------------------------------------------------------------
00484   TVectorD ReadNumberOfEvents(const Int_t&);                    // EcnaStexCrys of (StexEcha)
00485   TVectorD ReadPedestals(const Int_t&);                         // EcnaStexCrys of (StexEcha)
00486   TVectorD ReadTotalNoise(const Int_t&);                        // EcnaStexCrys of (StexEcha)
00487   TVectorD ReadLowFrequencyNoise(const Int_t&);                 // EcnaStexCrys of (StexEcha)
00488   TVectorD ReadHighFrequencyNoise(const Int_t&);                // EcnaStexCrys of (StexEcha)
00489   TVectorD ReadMeanCorrelationsBetweenSamples(const Int_t&);    // EcnaStexCrys of (StexEcha)
00490   TVectorD ReadSigmaOfCorrelationsBetweenSamples(const Int_t&); // EcnaStexCrys of (StexEcha)
00491 
00492   //------------------------------------------------------------------------------------------------
00493   TVectorD ReadAverageNumberOfEvents(const Int_t&);                    // EcnaStexStin of (StexStin)
00494   TVectorD ReadAveragePedestals(const Int_t&);                         // EcnaStexStin of (StexStin)
00495   TVectorD ReadAverageTotalNoise(const Int_t&);                        // EcnaStexStin of (StexStin)
00496   TVectorD ReadAverageLowFrequencyNoise(const Int_t&);                 // EcnaStexStin of (StexStin)
00497   TVectorD ReadAverageHighFrequencyNoise(const Int_t&);                // EcnaStexStin of (StexStin)
00498   TVectorD ReadAverageMeanCorrelationsBetweenSamples(const Int_t&);    // EcnaStexStin of (StexStin)
00499   TVectorD ReadAverageSigmaOfCorrelationsBetweenSamples(const Int_t&); // EcnaStexStin of (StexStin)
00500 
00501   //------------------------------------------------------------------------------------------------
00502   TMatrixD ReadCovariancesBetweenSamples(const Int_t&, const Int_t&, const Int_t&);  // (samp,samp) of (StexStin,Xtal)
00503   TMatrixD ReadCorrelationsBetweenSamples(const Int_t&, const Int_t&, const Int_t&); // (samp,samp) of (StexStin,Xtal)
00504 
00505   //-----------------------------------------------------------------------------------------------
00506   TMatrixD ReadLowFrequencyCovariancesBetweenChannels(const Int_t&, const Int_t&, const Int_t&);
00507   TMatrixD ReadHighFrequencyCovariancesBetweenChannels(const Int_t&, const Int_t&, const Int_t&);
00508                                        // (Xtal in Stin X, Xtal in Stin Y) of (Stin_X, Stin_Y)
00509 
00510   TMatrixD ReadLowFrequencyCorrelationsBetweenChannels(const Int_t&, const Int_t&, const Int_t&);
00511   TMatrixD ReadHighFrequencyCorrelationsBetweenChannels(const Int_t&, const Int_t&, const Int_t&);
00512                                        // (Xtal in Stin X, Xtal in Stin Y) of (Stin_X, Stin_Y)
00513 
00514   //------------------- (BIG MATRIX 1700x1700 for barrel, 5000x5000? for endcap) ------------------
00515   TMatrixD ReadLowFrequencyCovariancesBetweenChannels(const Int_t&);  // (Xtal in Stin X, Xtal in Stin Y) for all Stins
00516   TMatrixD ReadHighFrequencyCovariancesBetweenChannels(const Int_t&);
00517   TMatrixD ReadLowFrequencyCorrelationsBetweenChannels(const Int_t&); // (Xtal in Stin X, Xtal in Stin Y) for all Stins
00518   TMatrixD ReadHighFrequencyCorrelationsBetweenChannels(const Int_t&);
00519 
00520   //-----------------------------------------------------------------------------------------------
00521   TMatrixD ReadLowFrequencyMeanCorrelationsBetweenStins(const Int_t&);  // 1 of (Stin,Stin) 
00522   TMatrixD ReadHighFrequencyMeanCorrelationsBetweenStins(const Int_t&); // 1 of (Stin,Stin) 
00523 
00524   //------------------------------------------------------------------------------------------------
00525   TString  GetAnalysisName();
00526   Int_t    GetNbOfSamples();
00527   Int_t    GetRunNumber();
00528   Int_t    GetFirstReqEvtNumber();
00529   Int_t    GetLastReqEvtNumber();
00530   Int_t    GetReqNbOfEvts();
00531   Int_t    GetStexNumber();
00532 
00533   time_t   GetStartTime();
00534   time_t   GetStopTime();
00535   TString  GetStartDate();
00536   TString  GetStopDate();
00537   TString  GetRootFileName();
00538   TString  GetRootFileNameShort();
00539 
00540   TString  GetRunType();
00541 
00542   //-------------------------------------------------------------------------------  "technical" methods
00543   TVectorD ReadRelevantCorrelationsBetweenSamples(const Int_t&, const Int_t&, const Int_t&);
00544   // N(N-1)/2 of (StexStin, Xtal)
00545 
00546   Int_t    GetStexStinFromIndex(const Int_t&);      // (no read in the ROOT file)
00547   Int_t    GetStinIndex(const Int_t&);              // Stin index from Stin number (StexStin)
00548 
00549   TVectorD ReadStinNumbers(const Int_t&);
00550   TMatrixD ReadNumberOfEventsForSamples(const Int_t&, const Int_t&, const Int_t&); // (Xtal,sample) of (StexStin)
00551 
00552   Double_t*** ReadSampleAdcValuesSameFile(const Int_t&, const Int_t&, const Int_t&); 
00553 
00554   Int_t   GetNumberOfEvents(const Int_t&, const Int_t&);
00555   Int_t   GetNumberOfBinsSampleAsFunctionOfTime();
00556 
00557   TString GetTypeOfQuantity(const CnaResultTyp);
00558 
00559   TString GetTechReadCode(const TString, const TString);
00560 
00561   //------------------------------------------------------------------------------------------------
00562   //............... Flags Print Comments/Debug
00563 
00564   void  PrintNoComment();   // (default) Set flags to forbid the printing of all the comments
00565                             // except ERRORS
00566   void  PrintWarnings();    // Set flags to authorize printing of some warnings
00567   void  PrintComments();    // Set flags to authorize printing of infos and some comments
00568                             // concerning initialisations
00569   void  PrintAllComments(); // Set flags to authorize printing of all the comments
00570 
00571 ClassDef(TEcnaRead,1) // Calculation of correlated noises from data
00572 };  
00573 
00574 #endif    //  CL_TEcnaRead_H
00575 
00576