Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:28:15

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