Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:37

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 GetRootCalibOutputName()   const {return RootCalibOutputName;};
0034   inline TString GetRootInputName()         const {return RootInputName;};
0035   inline TString GetRootPedestalInputName() const {return RootPedestalInputName;};
0036   inline TString GetRootOutputName()        const {return RootOutputName;};
0037   inline TString GetPlotOutputDir()         const {return OutputNameDirPlots;};
0038   inline TString GetExternalBadChannelMap() const {return ExternalBadChannelMap;};
0039   inline TString GetExternalCalibFile()     const {return ExternalCalibFile;};
0040   
0041   inline std::fstream* GetASCIIinput() {return &ASCIIinput;};
0042   inline std::fstream* GetMapInput()   {return &MapInput;};
0043 
0044   inline TFile* GetRootCalibInput()    {return RootCalibInput;}
0045   inline TFile* GetRootInput()         {return RootInput;}
0046   inline TFile* GetRootPedestalInput() {return RootPedestalInput;}
0047   inline TFile* GetRootOutput()        {return RootOutput;}
0048 
0049   inline bool CanOverWrite(void)                const {return Overwrite;};
0050   inline bool IsToTransferCalib(void)           const {return ApplyTransferCalib;};
0051   inline bool IsToApplyCalibration(void)        const {return ApplyCalibration;};
0052   inline bool IsToConvert(void)                 const {return Convert;};
0053   inline bool IsToExtractPedestal(void)         const {return ExtractPedestal;};
0054   inline bool IsToExtractScaling(void)          const {return ExtractScaling;};
0055   inline bool IsToExtractScalingImproved(void)  const {return ExtractScalingImproved;};
0056   inline bool IsHGCROC(void)                    const {return HGCROC;};
0057   
0058   inline bool IsToReextractNoise(void)          const {return ReextractNoise;};
0059   inline bool IsToSaveNoiseOnly(void)           const {return SaveNoiseOnly;};
0060   inline bool IsToSaveMipsOnly(void)            const {return SaveMipsOnly;};
0061   inline bool IsToEvalLocalTrigg(void)          const {return EvalLocalTriggers;};
0062   inline bool UseLocTriggFromFile(void)         const {return LocTriggFile;};
0063   inline bool IsToSaveCalibOnly(void)           const {return SaveCalibOnly;};
0064   inline bool IsCalibSaveToFile(void)           const {return SaveCalibToFile;};
0065   inline bool IsToSkimHGCROC(void)              const {return SkimHGCROC;};
0066   inline short GetCalcBadChannel(void)          const {return CalcBadChannel;};
0067   inline short GetExtPlotting(void)             const {return ExtPlot;};
0068   inline bool GetOverWriteCalib(void)           const {return OverWriteCalib;};
0069   inline int GetMaxEvents(void)                 const {return maxEvents;};
0070 
0071   //setter methods
0072   //Overload method for boolean...or is it too dangerous?
0073   inline void CanOverWrite(bool b)               {Overwrite=b;};
0074   inline void IsCalibSaveToFile(bool b)          {SaveCalibToFile=b;};
0075   inline void IsToTransferCalib(bool b)          {ApplyTransferCalib=b;};
0076   inline void IsToApplyCalibration(bool b)       {ApplyCalibration=b;};
0077   inline void IsToConvert(bool b)                {Convert=b;};
0078   inline void IsToExtractPedestal(bool b)        {ExtractPedestal=b;};
0079   inline void IsToExtractScaling(bool b)         {ExtractScaling=b;};
0080   inline void IsToExtractScalingImproved(bool b) {ExtractScalingImproved=b;};
0081   inline void IsHGCROC(bool b)                   {HGCROC=b;};
0082   inline void IsToReextractNoise(bool b)         {ReextractNoise=b;};
0083   inline void IsToSaveNoiseOnly(bool b)          {SaveNoiseOnly = b;};
0084   inline void IsToSaveMipsOnly(bool b)           {SaveMipsOnly = b;};
0085   inline void IsToEvalLocalTrigg(bool b)         {EvalLocalTriggers = b;};
0086   inline void IsToSaveCalibOnly(bool b)          {SaveCalibOnly = b;};
0087   inline void IsToSkimHGCROC(bool b)             {SkimHGCROC = b;};
0088   inline void UseLocTriggFromFile(bool b)        {LocTriggFile = b;};
0089   inline void SetCalcBadChannel(short b)         {CalcBadChannel = b;};
0090   inline void SetOverWriteCalib(bool b)          {OverWriteCalib = b;};
0091   inline void SetExtPlotting(short b)            {ExtPlot = b;};
0092   inline void EnableDebug(int i)                 {debug=i;};
0093   
0094   inline void SetYear(int year)                  {yearData=year;};
0095   inline void SetASCIIinput(TString name)        {ASCIIinputName=name;};
0096   inline void SetMapInput(TString name)          {MapInputName=name;};
0097   inline void SetRunListInput(TString name)      {RunListInputName=name;};
0098   inline void SetRootCalibInput(TString name)    {RootCalibInputName=name;};
0099   inline void SetRootCalibOutput(TString name)   {RootCalibOutputName=name;};
0100   inline void SetRootInput(TString name)         {RootInputName=name;};
0101   inline void SetRootPedestalInput(TString name) {RootPedestalInputName=name;};
0102   inline void SetRootOutput(TString name)        {RootOutputName =name;};
0103   inline void SetRootOutputHists(TString name)   {RootOutputNameHist =name;};
0104   inline void SetPlotOutputDir(TString name)     {OutputNameDirPlots =name;};
0105   inline void SetPlotExtension(TString name)     {plotSuffix = name;};
0106   inline void SetExternalBadChannelMap(TString name)     {ExternalBadChannelMap =name;};
0107   inline void SetExternalCalibFile(TString name)     {ExternalCalibFile =name;};
0108   inline void SetMaxEvents(int n)                 {maxEvents = n;};
0109   
0110   //General methods
0111   bool CreateOutputRootFile(void);
0112   bool CheckAndOpenIO(void);
0113   bool Process(void);
0114 
0115   //Variable members
0116   TString ASCIIinputName;                 // CAEN ASCII file input name (only needed for converting data)
0117   TString RootOutputName;                 // file name of root output with tree
0118   TString RootOutputNameHist;             // file name of root output with additional histograms & fits
0119   TString OutputNameDirPlots;             // directory name of output for plots
0120   TString RootInputName;                  // file name of input root file 
0121   TString RootCalibInputName;             // file name of calibration root file (mip calib)
0122   TString RootCalibOutputName;            // file name of calibration root file (mip calib) output
0123   TString RootPedestalInputName;          // file name of pedestal root file (pedestal values)
0124   TString MapInputName;                   // file name geometry mapping
0125   TString RunListInputName;               // file name run list 
0126   TString ExternalBadChannelMap;          // file name external bad channel map
0127   TString ExternalCalibFile;              // file name external calib file
0128   TString plotSuffix        = "pdf";      // plot extension
0129   TFile* RootOutput         =nullptr;     // root file output tree
0130   TFile* RootOutputHist     =nullptr;     // root file output histos
0131   TFile* RootInput          =nullptr;     // root file input 
0132   TFile* RootPedestalInput  =nullptr;     // root file pedestal values
0133   TFile* RootCalibInput     =nullptr;     // root file calib values (mip)
0134   TFile* RootCalibOutput    =nullptr;     // root file calib values (mip) output
0135   std::fstream ASCIIinput;                // ASCII file streamer for CAEN data
0136   std::fstream MapInput;                  // file streamer for geometry mapping
0137   bool Convert                =false;     // Flag for data conversion 
0138   bool HGCROC                 =false;     // Flag for HGCROC data conversion
0139   bool ExtractPedestal        =false;     // Flag for pedestal extraction
0140   bool ExtractScaling         =false;     // Flag for mip scaling extraction
0141   bool ExtractScalingImproved =false;     // Flag for mip scaling extraction 2nd pass
0142   bool ReextractNoise         =false;     // Flag to enable noise trigger extraction and alternative pass for pedestals
0143   bool ApplyTransferCalib     =false;     // Flag for application of pedestals
0144   bool ApplyCalibration       =false;     // Flag for aplication of calibration
0145   bool SaveNoiseOnly          =false;     // Flag to reduce file to noise/pedestal only
0146   bool SaveMipsOnly           =false;     // Flag to reduce file to mips only
0147   bool SaveCalibOnly          =false;     // Flag to reduce file to mips only
0148   bool SaveCalibToFile        =false;     // Flag to save calib objects to text file
0149   bool SkimHGCROC             =false;     // Flag to skim HGCROC data from pure noise events
0150   bool EvalLocalTriggers      =false;     // Flag to run local trigger eval
0151   bool LocTriggFile           =false;     // Flag to use already evaluated triggeres
0152   short CalcBadChannel        =0;         // Flag to create bad channel map
0153   bool OverWriteCalib         =false;     // Flag to overwrite calib from text file
0154   short ExtPlot               =0;         // Enable extended plotting
0155   bool Overwrite              =false;     // Flag to overwrite outputs
0156   int debug                   =0;         // debug level 
0157   int yearData                =-1;        // data taking year externally set
0158   RootSetupWrapper rsw;                   // Wrapper singleton class for setup
0159   RootSetupWrapper* rswptr;               // Pointer to wrapper for singleton class for setup
0160   Setup* setup;                           // geometry setup
0161   Calib calib;                            // calibration object
0162   Calib* calibptr;                        // pointer to calib object
0163   Event event;
0164   Event* eventptr;
0165   int maxEvents               = -1;
0166   
0167   TTree* TsetupIn=nullptr;
0168   TTree* TsetupOut=nullptr;
0169   TTree* TdataIn=nullptr;
0170   TTree* TdataOut=nullptr;
0171   TTree* TcalibIn=nullptr;
0172   TTree* TcalibOut=nullptr;
0173 
0174  protected:
0175 
0176 
0177  private:
0178   bool ConvertASCII2Root(void);
0179   bool ConvertOldRootFile2Root(void);
0180   bool GetPedestal(void);
0181   bool TransferCalib(void);
0182   bool GetScaling(void);
0183   bool GetImprovedScaling(void);
0184   bool GetNoiseSampleAndRefitPedestal(void);
0185   bool RunEvalLocalTriggers(void);
0186   bool Calibrate(void);
0187   bool SaveNoiseTriggersOnly(void);
0188   bool SaveMuonTriggersOnly(void);
0189   bool SaveCalibToOutputOnly(void);
0190   bool SkimHGCROCData(void);
0191   std::map<int,short> ReadExternalBadChannelMap(void);
0192  };
0193 
0194 
0195 #endif