Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-02 08:25:30

0001 #ifndef DataAnalysis_H
0002 #define DataAnalysis_H
0003 
0004 #include <iostream>
0005 #include <fstream>
0006 #include "TString.h"
0007 #include "TFile.h"
0008 #include "TTree.h"
0009 #include "TObjString.h"
0010 
0011 #include "Setup.h"
0012 #include "RootSetupWrapper.h"
0013 #include "Calib.h"
0014 #include "Event.h"
0015 #include "Tile.h"
0016 #include "HGCROC.h"
0017 #include "Caen.h"
0018     
0019 class DataAnalysis{
0020 
0021  public:
0022   DataAnalysis(){
0023     eventptr=&event;
0024     rswptr=&rsw;
0025     calibptr=&calib;
0026   }
0027   ~DataAnalysis(){}
0028 
0029   //Getter methods
0030   inline TString GetRootInputName()         const {return RootInputName;};
0031   inline TString GetRootOutputName()        const {return RootOutputName;};
0032   inline TString GetPlotOutputDir()         const {return OutputNameDirPlots;};
0033   
0034   inline TFile* GetRootInput()         {return RootInput;}
0035   inline TFile* GetRootOutput()        {return RootOutput;}
0036 
0037   inline bool CanOverWrite(void)                const {return Overwrite;};
0038   inline bool IsCalibSaveToFile(void)           const {return SaveCalibToFile;};
0039   inline short GetExtPlotting(void)             const {return ExtPlot;};
0040   inline bool IsToRunQA(void)                   const {return RunQA;};
0041   inline bool GetDeltaTimePlotting(void)        const {return DeltaTimePlot;};
0042   inline double GetTimeMin(void)                const {return timemin;};
0043   inline double GetTimeMax(void)                const {return timemax;};
0044   inline double GetPercentMin(void)             const {return percentmin;};
0045   inline double GetPercentMax(void)             const {return percentmax;};
0046   inline int GetHGCROCNSampleInteg(void)        const {return nSampleHGCROCInt;};
0047   inline int GetHGCROCOptInteg(void)            const {return optHGCROCInt;};
0048   
0049   //setter methods
0050   //Overload method for boolean...or is it too dangerous?
0051   inline void CanOverWrite(bool b)               {Overwrite=b;};
0052   inline void IsCalibSaveToFile(bool b)          {SaveCalibToFile=b;};
0053   inline void SetExtPlotting(short b)            {ExtPlot = b;};
0054   inline void SetDeltaTimePlotting(bool b)      {DeltaTimePlot = b;};
0055   inline void SetTimeMin(double b)               {timemin = b;};
0056   inline void SetTimeMax(double b)               {timemax = b;};
0057   inline void SetPercentMin(double b)            {percentmin = b;};
0058   inline void SetPercentMax(double b)            {percentmax = b;};
0059   inline void EnableDebug(int i)                 {debug=i;};
0060   inline void IsToRunQA(bool b)                  {RunQA=b;};
0061   inline void IsToSimpleRunQA(bool b)            {RunSimpleQA=b;};
0062   
0063   inline void SetYear(int year)                  {yearData=year;};
0064   inline void SetRunListInput(TString name)      {RunListInputName=name;};
0065   inline void SetRootInput(TString name)         {RootInputName=name;};
0066   inline void SetRootOutput(TString name)        {RootOutputName =name;};
0067   inline void SetRootOutputHists(TString name)   {RootOutputNameHist =name;};
0068   inline void SetPlotOutputDir(TString name)     {OutputNameDirPlots =name;};
0069   inline void SetPlotExtension(TString name)     {plotSuffix = name;};
0070   inline void SetMaximumEvents(int numevents)    {eventNumber = numevents;};
0071   
0072   inline void SetHGCROCNSampleInteg(int n)       {optHGCROCInt      = 1; 
0073                                                   nSampleHGCROCInt  = n;
0074                                                   };
0075   inline void SetHGCROCNSampleIntegForced(int n) {optHGCROCInt      = 101; 
0076                                                   nSampleHGCROCInt  = n;
0077                                                   };
0078 
0079   
0080   //General methods
0081   bool CreateOutputRootFile(void);
0082   bool CreateOutputRootFileHist(void);
0083   bool CheckAndOpenIO(void);
0084   bool Process(void);
0085 
0086   //Variable members
0087   TString RootOutputName;                 // file name of root output with tree
0088   TString RootOutputNameHist;             // file name of root output with additional histograms & fits
0089   TString OutputNameDirPlots;             // directory name of output for plots
0090   TString RootInputName;                  // file name of input root file 
0091   TString RunListInputName;               // file name run list 
0092   TString plotSuffix          = "pdf";     // plot extension
0093   TFile* RootOutput           = nullptr;   // root file output tree
0094   TFile* RootOutputHist       = nullptr;   // root file output histos
0095   TFile* RootInput            = nullptr;   // root file input 
0096   bool RunQA                  = false;     // Flag to run QA routine
0097   bool RunSimpleQA            = false;     // Flag to run QA routine
0098   bool SaveCalibToFile        = false;     // Flag to save calib objects to text file
0099   short ExtPlot               = 0;         // Enable extended plotting
0100   bool DeltaTimePlot          = false;     // Enable deltatime plotting
0101   bool Overwrite              = false;     // Flag to overwrite outputs
0102   int debug                   = 0;         // debug level 
0103   int yearData                = -1;        // data taking year externally set
0104   int eventNumber             = -1;        // maximum events externally set
0105   double timemin              = 0;         // set min cut for deltatime
0106   double timemax              = 35000;     // set max cut for deltatime
0107   double percentmax           = 100;       // set min percent cut for deltatime
0108   double percentmin           = 0;         // set max percent cut for deltatime
0109   int optHGCROCInt            = 0;
0110   int nSampleHGCROCInt        = 1;
0111 
0112   RootSetupWrapper rsw;                   // Wrapper singleton class for setup
0113   RootSetupWrapper* rswptr;               // Pointer to wrapper for singleton class for setup
0114   Setup* setup;                           // geometry setup
0115   Calib calib;                            // calibration object
0116   Calib* calibptr;                        // pointer to calib object
0117   Event event;
0118   Event* eventptr;
0119   
0120   TTree* TsetupIn   = nullptr;
0121   TTree* TsetupOut  = nullptr;
0122   TTree* TdataIn    = nullptr;
0123   TTree* TdataOut   = nullptr;
0124   TTree* TcalibIn   = nullptr;
0125   TTree* TcalibOut  = nullptr;
0126 
0127  protected:
0128 
0129 
0130  private:
0131   bool QAData(void);
0132   bool SimpleQAData(void);
0133  };
0134 
0135 
0136 #endif