Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:43

0001 #ifndef ANALYSES_H
0002 #define ANALYSES_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 Analyses{
0020 
0021  public:
0022   Analyses(){
0023     eventptr=&event;
0024     rswptr=&rsw;
0025     calibptr=&calib;
0026   }
0027   ~Analyses(){}
0028 
0029   //Getter methods
0030   inline TString GetASCIIinputName()        const {return ASCIIinputName;};
0031   inline TString GetMapInputName()          const {return MapInputName;};
0032   inline TString GetRootCalibInputName()    const {return RootCalibInputName;};
0033   inline TString GetRootInputName()         const {return RootInputName;};
0034   inline TString GetRootPedestalInputName() const {return RootPedestalInputName;};
0035   inline TString GetRootOutputName()        const {return RootOutputName;};
0036   inline TString GetPlotOutputDir()         const {return OutputNameDirPlots;};
0037   inline TString GetExternalBadChannelMap() const {return ExternalBadChannelMap;};
0038   
0039   inline std::fstream* GetASCIIinput() {return &ASCIIinput;};
0040   inline std::fstream* GetMapInput()   {return &MapInput;};
0041 
0042   inline TFile* GetRootCalibInput()    {return RootCalibInput;}
0043   inline TFile* GetRootInput()         {return RootInput;}
0044   inline TFile* GetRootPedestalInput() {return RootPedestalInput;}
0045   inline TFile* GetRootOutput()        {return RootOutput;}
0046 
0047   inline bool CanOverWrite(void)                const {return Overwrite;};
0048   inline bool IsToApplyPedestalCorrection(void) const {return ApplyPedestalCorrection;};
0049   inline bool IsToApplyCalibration(void)        const {return ApplyCalibration;};
0050   inline bool IsToConvert(void)                 const {return Convert;};
0051   inline bool IsToExtractPedestal(void)         const {return ExtractPedestal;};
0052   inline bool IsToExtractScaling(void)          const {return ExtractScaling;};
0053   inline bool IsToExtractScalingImproved(void)  const {return ExtractScalingImproved;};
0054   inline bool IsToReextractNoise(void)          const {return ReextractNoise;};
0055   inline bool IsToSaveNoiseOnly(void)           const {return SaveNoiseOnly;};
0056   inline bool IsToSaveMipsOnly(void)            const {return SaveMipsOnly;};
0057   inline bool IsCalibSaveToFile(void)           const {return SaveCalibToFile;};
0058   inline short GetCalcBadChannel(void)          const {return CalcBadChannel;};
0059   inline short GetExtPlotting(void)             const {return ExtPlot;};
0060 
0061   //setter methods
0062   //Overload method for boolean...or is it too dangerous?
0063   inline void CanOverWrite(bool b)               {Overwrite=b;};
0064   inline void IsCalibSaveToFile(bool b)          {SaveCalibToFile=b;};
0065   inline void IsToApplyPedestalCorrection(bool b){ApplyPedestalCorrection=b;};
0066   inline void IsToApplyCalibration(bool b)       {ApplyCalibration=b;};
0067   inline void IsToConvert(bool b)                {Convert=b;};
0068   inline void IsToExtractPedestal(bool b)        {ExtractPedestal=b;};
0069   inline void IsToExtractScaling(bool b)         {ExtractScaling=b;};
0070   inline void IsToExtractScalingImproved(bool b) {ExtractScalingImproved=b;};
0071   inline void IsToReextractNoise(bool b)         {ReextractNoise=b;};
0072   inline void IsToSaveNoiseOnly(bool b)          {SaveNoiseOnly = b;};
0073   inline void IsToSaveMipsOnly(bool b)           {SaveMipsOnly = b;};
0074   inline void SetCalcBadChannel(short b)         {CalcBadChannel = b;};
0075   inline void SetExtPlotting(short b)            {ExtPlot = b;};
0076   inline void EnableDebug(int i)                 {debug=i;};
0077   
0078   
0079   inline void SetYear(int year)                  {yearData=year;};
0080   inline void SetASCIIinput(TString name)        {ASCIIinputName=name;};
0081   inline void SetMapInput(TString name)          {MapInputName=name;};
0082   inline void SetRunListInput(TString name)      {RunListInputName=name;};
0083   inline void SetRootCalibInput(TString name)    {RootCalibInputName=name;};
0084   inline void SetRootInput(TString name)         {RootInputName=name;};
0085   inline void SetRootPedestalInput(TString name) {RootPedestalInputName=name;};
0086   inline void SetRootOutput(TString name)        {RootOutputName =name;};
0087   inline void SetRootOutputHists(TString name)   {RootOutputNameHist =name;};
0088   inline void SetPlotOutputDir(TString name)     {OutputNameDirPlots =name;};
0089   inline void SetExternalBadChannelMap(TString name)     {ExternalBadChannelMap =name;};
0090   
0091   
0092   //General methods
0093   bool CreateOutputRootFile(void);
0094   bool CheckAndOpenIO(void);
0095   bool Process(void);
0096 
0097   //Variable members
0098   TString ASCIIinputName;                 // CAEN ASCII file input name (only needed for converting data)
0099   TString RootOutputName;                 // file name of root output with tree
0100   TString RootOutputNameHist;             // file name of root output with additional histograms & fits
0101   TString OutputNameDirPlots;             // directory name of output for plots
0102   TString RootInputName;                  // file name of input root file 
0103   TString RootCalibInputName;             // file name of calibration root file (mip calib)
0104   TString RootPedestalInputName;          // file name of pedestal root file (pedestal values)
0105   TString MapInputName;                   // file name geometry mapping
0106   TString RunListInputName;               // file name run list 
0107   TString ExternalBadChannelMap;          // file name external bad channel map
0108   TFile* RootOutput         =nullptr;     // root file output tree
0109   TFile* RootOutputHist     =nullptr;     // root file output histos
0110   TFile* RootInput          =nullptr;     // root file input 
0111   TFile* RootPedestalInput  =nullptr;     // root file pedestal values
0112   TFile* RootCalibInput     =nullptr;     // root file calib values (mip)
0113   std::fstream ASCIIinput;                // ASCII file streamer for CAEN data
0114   std::fstream MapInput;                  // file streamer for geometry mapping
0115   bool Convert                =false;     // Flag for data conversion 
0116   bool ExtractPedestal        =false;     // Flag for pedestal extraction
0117   bool ExtractScaling         =false;     // Flag for mip scaling extraction
0118   bool ExtractScalingImproved =false;     // Flag for mip scaling extraction 2nd pass
0119   bool ReextractNoise         =false;     // Flag to enable noise trigger extraction and alternative pass for pedestals
0120   bool ApplyPedestalCorrection=false;     // Flag for application of pedestals
0121   bool ApplyCalibration       =false;     // Flag for aplication of calibration
0122   bool SaveNoiseOnly          =false;     // Flag to reduce file to noise/pedestal only
0123   bool SaveMipsOnly           =false;     // Flag to reduce file to mips only
0124   bool SaveCalibToFile        =false;     // Flag to save calib objects to text file
0125   short CalcBadChannel        =0;         // Flag to create bad channel map
0126   short ExtPlot               =0;         // Enable extended plotting
0127   bool Overwrite              =false;     // Flag to overwrite outputs
0128   int debug                   =0;         // debug level 
0129   int yearData                =-1;        // data taking year externally set
0130   RootSetupWrapper rsw;                   // Wrapper singleton class for setup
0131   RootSetupWrapper* rswptr;               // Pointer to wrapper for singleton class for setup
0132   Setup* setup;                           // geometry setup
0133   Calib calib;                            // calibration object
0134   Calib* calibptr;                        // pointer to calib object
0135   Event event;
0136   Event* eventptr;
0137   
0138   TTree* TsetupIn=nullptr;
0139   TTree* TsetupOut=nullptr;
0140   TTree* TdataIn=nullptr;
0141   TTree* TdataOut=nullptr;
0142   TTree* TcalibIn=nullptr;
0143   TTree* TcalibOut=nullptr;
0144 
0145  protected:
0146 
0147 
0148  private:
0149   bool ConvertASCII2Root(void);
0150   bool ConvertOldRootFile2Root(void);
0151   bool GetPedestal(void);
0152   bool CorrectPedestal(void);
0153   bool GetScaling(void);
0154   bool GetImprovedScaling(void);
0155   bool GetNoiseSampleAndRefitPedestal(void);
0156   bool Calibrate(void);
0157   bool SaveNoiseTriggersOnly(void);
0158   bool SaveMuonTriggersOnly(void);
0159   std::map<int,short> ReadExternalBadChannelMap(void);
0160  };
0161 
0162 
0163 #endif