CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRun.h

Go to the documentation of this file.
00001 #ifndef   CL_TEcnaRun_H
00002 #define   CL_TEcnaRun_H
00003 
00004 // system include files
00005 #include <memory>
00006 #include <iostream>
00007 #include <fstream>
00008 #include <iomanip>
00009 #include <string>
00010 #include <vector>
00011 #include <time.h>
00012 #include <math.h>
00013 #include <stdio.h>
00014 #include "Riostream.h"
00015 
00016 // ROOT include files
00017 #include "TObject.h"
00018 #include "TSystem.h"
00019 #include "TString.h"
00020 #include "TVectorD.h"
00021 
00022 // user include files
00023 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaObject.h"
00024 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParEcal.h"
00025 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaHeader.h"
00026 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParCout.h"
00027 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParPaths.h"
00028 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h"
00029 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaWrite.h"
00030 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRootFile.h"
00031 
00362 
00363 class TEcnaRun: public TObject {
00364   
00365  private:
00366 
00367   //............ attributes
00368 
00369   Int_t fgMaxCar;      // Max nb of caracters for char* 
00370 
00371   Int_t fCnaCommand,  fCnaError;
00372 
00373   Int_t fCnew;          // flags for dynamical allocation
00374   Int_t fCdelete;       
00375 
00376   TString fTTBELL;
00377 
00378   Int_t* fMiscDiag;                          // Counters for miscellaneous diagnostics
00379   Int_t  fNbOfMiscDiagCounters;
00380   Int_t  fMaxMsgIndexForMiscDiag;
00381 
00382   TEcnaObject    *fObjectManager; // for ECNA object management
00383   TEcnaHeader    *fFileHeader;    // header for result type file
00384   TEcnaParEcal   *fEcal;          // for access to the Ecal current subdetector parameters
00385   TEcnaNumbering *fEcalNumbering; // for access to the Ecal channel, Stin and Stex numbering
00386   TEcnaParCout   *fCnaParCout;    // for comment/error messages
00387   TEcnaParPaths  *fCnaParPaths;   // for file access
00388   TEcnaWrite     *fCnaWrite;      // for access to the results files
00389 
00390   //  TEcnaRootFile *gCnaRootFile;
00391 
00392   TString fFlagSubDet;
00393   TString fStexName, fStinName;
00394 
00395   Bool_t  fOpenRootFile;   // flag open ROOT file (open = kTRUE, close = kFALSE)
00396   Int_t   fReadyToReadData;
00397 
00398   TString  fRootFileName;
00399   TString  fRootFileNameShort;
00400   TString  fNewRootFileName;
00401   TString  fNewRootFileNameShort;
00402 
00403   Int_t   fSpecialStexStinNotIndexed;  // management of event distribution building
00404   Int_t   fStinIndexBuilt;
00405   Int_t   fBuildEvtNotSkipped;
00406 
00407   Int_t   fNbSampForFic;
00408   Int_t   fNbSampForCalc;
00409 
00410   Int_t   fNumberOfEvents;
00411 
00412   Int_t   fMemoReadNumberOfEventsforSamples;
00413 
00414   Double_t*** fT3d_AdcValues;   // 3D array[channel][sample][event] ADC values
00415   Double_t**  fT3d2_AdcValues; 
00416   Double_t*   fT3d1_AdcValues;
00417   Int_t*      fTagAdcEvt;
00418 
00419   Int_t**     fT2d_NbOfEvts; // 2D array[channel][sample] max nb of evts read for a given (channel,sample) 
00420   Int_t*      fT1d_NbOfEvts;
00421   Int_t*      fTagNbOfEvts;
00422 
00423   Int_t*      fT1d_StexStinFromIndex; // 1D array[Stin] Stin Number as a function of the index Stin
00424   Int_t*      fTagStinNumbers;
00425 
00426   Double_t**  fT2d_ev;        // 2D array[channel][sample] for expectation values
00427   Double_t*   fT1d_ev;
00428   Int_t*      fTagMSp;
00429 
00430   Double_t**  fT2d_sig;       // 2D array[channel][sample] for sigmass
00431   Double_t*   fT1d_sig;
00432   Int_t*      fTagSSp;
00433  
00434   Double_t*** fT3d_cov_ss;    // 3D array[channel][sample][sample] for (sample,sample) covariances
00435   Double_t**  fT3d2_cov_ss;
00436   Double_t*   fT3d1_cov_ss;
00437   Int_t*      fTagCovCss;
00438 
00439   Double_t*** fT3d_cor_ss;    // 3D array[channel][sample][sample] for (sample,sample) correlations
00440   Double_t**  fT3d2_cor_ss;
00441   Double_t*   fT3d1_cor_ss;
00442   Int_t*      fTagCorCss;
00443 
00444 //...........................................................................
00445   Double_t*   fT1d_ev_ev;     // 1D array[channel] for expectation values of the expectation values of the samples
00446   Int_t*      fTagPed;        // (PEDESTAL)
00447   Double_t*   fT1d_av_mped;   // 1D array[Stin] for expectation values of the Pesdestals of the Stins
00448   Int_t*      fTagAvPed;      // (AVERAGED PEDESTAL)
00449 
00450   Double_t*   fT1d_evsamp_of_sigevt; // 1D array[channel] for expectation values of the sigmas of the samples
00451   Int_t*      fTagTno;               // (TOTAL NOISE)
00452   Double_t*   fT1d_av_totn;          // 1D array[Stin] for expectation values of the total noise
00453   Int_t*      fTagAvTno;             //(AVERAGED TOTAL NOISE)
00454 
00455   Double_t*   fT1d_ev_cor_ss;   // 1D array[channel] for expectation values of the cor(s,s)
00456   Int_t*      fTagMeanCorss;    // (MEAN COR(S,S))
00457   Double_t*   fT1d_av_ev_corss; // 1D array[Stin] for expectation values of the mean cor(s,s)
00458   Int_t*      fTagAvMeanCorss;  // (AVERAGED MEAN COR(S,S))
00459 
00460   Double_t*   fT1d_sigevt_of_evsamp;  // 1D array[channel] for sigmas of the expectation values of the samples
00461   Int_t*      fTagLfn;                // (LOW FREQUENCY NOISE)
00462   Double_t*   fT1d_av_lofn;           // 1D array[Stin]  the expectation values of the low frequency noise
00463   Int_t*      fTagAvLfn;              // (AVERAGED LOW FREQUENCY NOISE)
00464 
00465   Double_t*   fT1d_evevt_of_sigsamp; // 1D array[channel] for sigmas of the sigmas of the samples
00466   Int_t*      fTagHfn;               // (HIGH FREQUENCY NOISE)
00467   Double_t*   fT1d_av_hifn;          // 1D array[channel] for expectation values of the high frequency noise
00468   Int_t*      fTagAvHfn;             // (AVERAGED HIGH FREQUENCY NOISE)
00469 
00470   Double_t*   fT1d_sig_cor_ss;   // 1D array[channel] for sigmas of the cor(s,s)
00471   Int_t*      fTagSigCorss;      // (SIGMA OF COR(S,S))
00472   Double_t*   fT1d_av_sig_corss; // 1D array[channel] for expectation values of sigmas  the  of the cor(s,s)
00473   Int_t*      fTagAvSigCorss;    // (AVERAGED SIGMA OF COR(S,S))
00474 
00475   //...........................................................................
00476   Double_t**  fT2d_lf_cov; // 2D array[channel][channel] for (channel,channel) low frequency covariances
00477   Double_t*   fT2d1_lf_cov;
00478   Int_t*      fTagLfCov;
00479 
00480   Double_t**  fT2d_lf_cor; // 2D array[channel][channel] for (channel,channel) low frequency correlations
00481   Double_t*   fT2d1_lf_cor;
00482   Int_t*      fTagLfCor;
00483 
00484   //...........................................................................
00485   Double_t**  fT2d_hf_cov; // 2D array[channel][channel] for (channel,channel) low frequency covariances
00486   Double_t*   fT2d1_hf_cov;
00487   Int_t*      fTagHfCov;
00488 
00489   Double_t**  fT2d_hf_cor; // 2D array[channel][channel] for (channel,channel) low frequency correlations
00490   Double_t*   fT2d1_hf_cor;
00491   Int_t*      fTagHfCor;
00492 
00493   //------------------------- 2 tableaux (ci,cj)
00494   Double_t**  fT2d_lfcc_mostins;  // 2D array[Stin][Stin] for (Stin,Stin) mean cov(c,c)
00495   Double_t*   fT2d1_lfcc_mostins; // (relevant ones) averaged over samples
00496   Int_t*      fTagLFccMoStins;
00497 
00498   Double_t**  fT2d_hfcc_mostins;  // 2D array[Stin][Stin] for (Stin,Stin) mean cor(c,c)
00499   Double_t*   fT2d1_hfcc_mostins; // (relevant ones) averaged over samples
00500   Int_t*      fTagHFccMoStins;
00501 
00502   //------------------------------------------------------------------------------------
00503 
00504   Int_t**     fT2dCrysNumbersTable;
00505   Int_t*      fT1dCrysNumbersTable;
00506 
00507   ofstream    fFcout_f;
00508 
00509   Int_t       fFlagPrint;
00510   Int_t       fCodePrintComments, fCodePrintWarnings, fCodePrintAllComments, fCodePrintNoComment;
00511 
00512 
00513  public: 
00514 
00515   //................. constructors
00516   
00517   TEcnaRun();                            //  constructor without argument
00518   TEcnaRun(TEcnaObject*, const TString);               //  constructors with argument (FOR USER'S DECLARATION)
00519   TEcnaRun(TEcnaObject*, const TString, const Int_t&);
00520 
00521   //TEcnaRun(const TString, const Int_t&, const TEcnaParPaths*, const TEcnaParCout*);
00522   //TEcnaRun(const TString);               //  constructors with argument (FOR USER'S DECLARATION)
00523   //TEcnaRun(const TString, const Int_t&);
00524 
00525   TEcnaRun(const TEcnaRun&);   //  copy constructor
00526 
00527   //.................... C++ methods
00528 
00529   //TEcnaRun&  operator=(const TEcnaRun&);  //  overloading of the operator=
00530 
00531   //................. destructor
00532   
00533   virtual ~TEcnaRun();
00534   
00535   //...................................................... methods that will (should) be private
00536 
00537   void Init();
00538 
00539   void SetEcalSubDetector(const TString);
00540 
00541   Bool_t GetPathForResults();
00542 
00543   Bool_t OpenRootFile(const Text_t *, TString);
00544   Bool_t CloseRootFile(const Text_t *);
00545 
00546   //======================================= methods for the user =========================================
00547   void GetReadyToReadData(TString, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&);
00548   void GetReadyToReadData(TString, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Int_t&);
00549   
00550   Bool_t GetSampleAdcValues(const Int_t&, const Int_t&, const Int_t&, const Int_t&, const Double_t&);
00551   Bool_t ReadSampleAdcValues();
00552   Bool_t ReadSampleAdcValues(const Int_t&);
00553 
00554   void StartStopDate(TString, TString);
00555   void StartStopTime(time_t, time_t);
00556 
00557   //................... Calculation methods ( associated to GetReadyToReadData(...) )
00558   //-------------------- Standard Calculations
00559   void StandardCalculations();       // see list in the method itself (.cc file)
00560 
00561   void SampleMeans();                // Calculation of the expectation values over the events
00562                                      // for each sample and for each channel
00563   void SampleSigmas();               // Calculation of the variances over the events
00564                                      // for each sample and for each channel
00565   //...........................................
00566   void CovariancesBetweenSamples();  // Calculation of the (s,s) covariances over the events
00567                                      // for each channel
00568   void CorrelationsBetweenSamples(); // Calculation of the (s,s) correlations over the events
00569                                      // for each channel
00570   //..........................................................
00571   void Pedestals();                        
00572   void TotalNoise();
00573   void LowFrequencyNoise();
00574   void HighFrequencyNoise();
00575   void MeanCorrelationsBetweenSamples();
00576   void SigmaOfCorrelationsBetweenSamples();
00577 
00578   //..........................................................
00579   void AveragePedestals();
00580   void AverageTotalNoise();
00581   void AverageLowFrequencyNoise();
00582   void AverageHighFrequencyNoise();
00583   void AverageMeanCorrelationsBetweenSamples();
00584   void AverageSigmaOfCorrelationsBetweenSamples();
00585 
00586   //---------- Calculations involving cov and cor between channels
00587   //
00588   //   Recommended calling sequences: expert1, expert1 + expert2,  expert2
00589   //
00590   //   NOT recommended: expert2 + expert1  (lost of time and place)
00591   //
00592   //-------------------- Expert 1 Calculations
00593   void Expert1Calculations();       // see list in the method itself (.cc file)
00594 
00595   void LowFrequencyCovariancesBetweenChannels();
00596   void HighFrequencyCovariancesBetweenChannels();
00597 
00598   void LowFrequencyCorrelationsBetweenChannels();
00599   void HighFrequencyCorrelationsBetweenChannels();
00600 
00601   //-------------------- Expert 2 Calculations
00602   void Expert2Calculations();       // see list in the method itself (.cc file)
00603 
00604   void LowFrequencyMeanCorrelationsBetweenTowers();
00605   void HighFrequencyMeanCorrelationsBetweenTowers();
00606 
00607   void LowFrequencyMeanCorrelationsBetweenSCs();
00608   void HighFrequencyMeanCorrelationsBetweenSCs();
00609 
00610   //===================================== "technical" methods ==========================================
00611 
00612   void GetReadyToCompute(); // Make result root file name and check events
00613   void SampleValues();      // 3D histo of the sample ADC value for each triple (channel,sample,event)
00614 
00615   //.................................... Technical calculation methods (Stin = Tower or SC)
00616   void LowFrequencyMeanCorrelationsBetweenStins();
00617   void HighFrequencyMeanCorrelationsBetweenStins();
00618 
00619   //...................................... ROOT file methods
00620   TString GetRootFileName();
00621   TString GetRootFileNameShort();
00622   TString GetNewRootFileName();
00623   TString GetNewRootFileNameShort();
00624 
00625   Bool_t WriteRootFile();
00626   Bool_t WriteNewRootFile(const TString);
00627   Bool_t WriteRootFile(const Text_t *, Int_t&);
00628 
00629   void TRootStinNumbers();
00630   void TRootNbOfEvts(const Int_t&);
00631 
00632   void TRootAdcEvt(const Int_t&, const Int_t&);
00633 
00634   void TRootMSp(const Int_t&);
00635   void TRootSSp(const Int_t&);
00636 
00637   void TRootCovCss(const Int_t&, const Int_t&);
00638   void TRootCorCss(const Int_t&, const Int_t&);
00639 
00640   void TRootLfCov();
00641   void TRootLfCor();
00642 
00643   void TRootHfCov();
00644   void TRootHfCor();
00645 
00646   void TRootLFccMoStins();
00647   void TRootHFccMoStins();
00648 
00649   void TRootPed();
00650   void TRootTno();
00651   void TRootMeanCorss();
00652 
00653   void TRootLfn();
00654   void TRootHfn();
00655   void TRootSigCorss();
00656 
00657   void TRootAvPed();
00658   void TRootAvEvCorss();
00659   void TRootAvSigCorss();
00660   void TRootAvTno();
00661   void TRootAvLfn();
00662   void TRootAvHfn();
00663 
00664   //................................ Flags Print Comments/Debug
00665   void PrintNoComment();   // (default) Set flags to forbid the printing of all the comments
00666                            // except ERRORS
00667   void PrintWarnings();    // Set flags to authorize printing of some warnings
00668   void PrintComments();    // Set flags to authorize printing of infos and some comments
00669                            // concerning initialisations
00670   void PrintAllComments(); // Set flags to authorize printing of all the comments
00671 
00672 ClassDef(TEcnaRun,1) // Calculation of correlated noises from data
00673 };  
00674 
00675 #endif    //  CL_TEcnaRun_H
00676 
00677 
00678 
00679 
00680 
00681 
00682 
00683 
00684 
00685 
00686