Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-07 09:25:15

0001 #ifndef CalibSampleParser_H
0002 #define CalibSampleParser_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 CalibSampleParser{
0020     public:
0021         CalibSampleParser(){
0022             rswptr=&rsw;
0023             calibptr=&calib;
0024         }
0025         ~CalibSampleParser(){}
0026 
0027         // getter methods
0028 
0029 
0030         // setter methods
0031         inline void EnableDebug(int i)                  {debug=i;};
0032         inline void SetInputFile(TString name)          {inputFilePath=name;};
0033         inline void SetMappingFile(TString name)        {MapInputName=name;};
0034         inline void SetOutputFilename(TString name)     {OutputFilename=name;};
0035         inline void SetPlotDirectory(TString name)      {outputDirPlots=name;};
0036         inline void SetRunListInput(TString name)       {RunListInputName=name;};
0037         inline void SetRunNumber(int i)                 {RunNr=i;};
0038         inline void EnablePlotting()                    {doPlotting=true;};
0039         inline void SwitchPedestalCalib()               {optParse=1;};
0040         inline void SetInputCalibFile(TString name)     {calibInputFile=name;};
0041 
0042 
0043         // general methods
0044         bool CheckAndOpenIO(void);
0045         bool Process(void);
0046 
0047         // variable members 
0048         TString         inputFilePath;                  // path to the input file
0049         TString         MapInputName;                   // input mapping file name
0050         TString         calibInputFile;                 // input .root file with calib object to 'hack' with pedestal values - to use with SwitchPedestalCalib on
0051         TString         RunListInputName;               // file name run list 
0052         int             RunNr           = -1;           // run number to analyze
0053         std::fstream    MapInput;                       // file streamer for geometry mapping
0054         TString         OutputFilename;                 // output root file name, by default the same name as .csv file
0055         TString         OutputHistFilename;             // output root file name with histograms / plots / spectra
0056         TString         outputDirPlots;                 // directory for plots
0057         TFile*          RootCalibInput  = nullptr;      // root file input with calib object
0058         TFile*          RootOutput      = nullptr;      // root file output 
0059         TFile*          RootOutputHist  = nullptr;      // root file output for histos
0060         int             debug           = 0;            // debug level
0061         int             optParse        = 0;            // 0 - default .csv file from H2GCalib, 1 - pedestal extracted with .py script
0062 
0063         Event       event;                          // basically the tree branch
0064         RootSetupWrapper rsw;                       // Wrapper singleton class for setup
0065         RootSetupWrapper* rswptr;                   // Pointer to wrapper for singleton class for setup
0066         Setup*      setup;                          // geometry setup - read from the mapping file
0067         Calib       calib;                          // calibration object
0068         Calib*      calibptr;                       // pointer to calib object
0069 
0070         TTree*      tOutTree        = nullptr;      // output tree
0071         TTree*      TsetupOut       = nullptr;      // output geometry tree
0072         TTree*      TcalibIn        = nullptr;      
0073         TTree*      TcalibOut       = nullptr;
0074 
0075         bool        doPlotting      = false;
0076 
0077         std::vector<int>  calibChannelsSet; // #of channels, channels listed
0078         int         kcu             = 0;
0079 
0080     protected:
0081 
0082     private:
0083         bool Parse();
0084         bool ProcessAndPlotWaveforms();
0085         bool ParsePedestalCalib();
0086 
0087         bool IsCalibChannel(int channel){
0088             for(int i=0; i < calibChannelsSet.size(); i++){
0089                 if( calibChannelsSet.at(i) == channel ) return true;
0090             }
0091             return false;
0092         }
0093 
0094 };
0095 
0096 #endif