Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:37

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef READDIGITALCURRENTS_READDIGITALCURRENTS_H
0004 #define READDIGITALCURRENTS_READDIGITALCURRENTS_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <fstream>
0009 #include <map>
0010 #include <string>
0011 #include <vector>
0012 
0013 class Fun4AllHistoManager;
0014 class PHCompositeNode;
0015 
0016 // class PHG4CylinderCellGeom;
0017 
0018 // class TFile;
0019 class TH1;
0020 class TH2;
0021 class TH3;
0022 
0023 class readDigitalCurrents : public SubsysReco
0024 {
0025  public:
0026   readDigitalCurrents(const std::string &name = "readDigitalCurrents", const std::string &filename = "DC_Hist_OnPlane_WIBF.root");
0027 
0028   virtual ~readDigitalCurrents();
0029 
0030   /** Called during initialization.
0031       Typically this is where you can book histograms, and e.g.
0032       register them to Fun4AllServer (so they can be output to file
0033       using Fun4AllServer::dumpHistos() method).
0034    */
0035   int Init(PHCompositeNode *topNode) override;
0036 
0037   /** Called for first event when run number is known.
0038       Typically this is where you may want to fetch data from
0039       database, because you know the run number. A place
0040       to book histograms which have to know the run number.
0041    */
0042   int InitRun(PHCompositeNode *topNode) override;
0043 
0044   /** Called for each event.
0045       This is where you do the real work.
0046    */
0047   int process_event(PHCompositeNode *topNode) override;
0048 
0049   /// Clean up internals after each event.
0050   int ResetEvent(PHCompositeNode *topNode) override;
0051 
0052   /// Called at the end of each run.
0053   int EndRun(const int runnumber) override;
0054 
0055   /// Called at the end of all processing.
0056   int End(PHCompositeNode *topNode) override;
0057 
0058   /// Reset
0059   int Reset(PHCompositeNode * /*topNode*/) override;
0060 
0061   void Print(const std::string &what = "ALL") const override;
0062 
0063   void SetBeamXing(const std::vector<int> &beamXs);
0064   void SetEvtStart(int newEvtStart);
0065   void FillCSV(int fillCSVFile);
0066   void SetCollSyst(int coll_syst = 0);
0067   void SetIBF(double ampIBFfrac = 0.004);
0068   void SetCCGC(double f_ccgc = 0);
0069 
0070   // double pi = 3.14159265358979323846;//2 * acos(0.0);
0071 
0072  protected:
0073   Fun4AllHistoManager *hm{nullptr};
0074   std::string _filename;
0075   // TFile *outfile {nullptr};
0076   std::map<int, int> _timestamps;
0077   std::vector<int> _keys;
0078   double _ampIBFfrac{0.02};
0079   int _collSyst{0};
0080   std::ofstream myCSVFile;
0081 
0082  private:
0083   std::vector<int> _beamxing;
0084   int _evtstart{0};
0085 
0086   int _fillCSVFile{0};
0087 
0088   int _f_ccgc{0};
0089 
0090   TH2 *_h_modules_measuredibf{nullptr};
0091 
0092   TH1 *_h_R{nullptr};
0093   TH1 *_h_hits{nullptr};
0094   TH3 *_h_DC_SC{nullptr};
0095   TH2 *_h_DC_SC_XY{nullptr};
0096   TH2 *_h_hit_XY{nullptr};
0097   TH2 *_h_DC_E{nullptr};
0098   // TH3*   _h_SC_ibf {nullptr};
0099   static const int nFrames{30};
0100   TH3 *_h_SC_ibf[nFrames]{};
0101 
0102   float _event_timestamp{0};
0103   float _event_bunchXing{0};
0104 
0105   // double pi = 2 * acos(0.0);
0106   double adc_pedestal{0.};  // 74.4;
0107   double cm{1e1};
0108   double m{1e3};
0109   double mm{1};  // changed to make 'm' 1.0, for convenience.
0110   //    float ns=1e-9,us=1e-6,ms=1e-3,s=1;
0111   double ns{1e-9};
0112   double s{1};
0113   double V{1};
0114   // double ionMobility=3.37*cm*cm/V/s;
0115   double ionMobility{1.65 * cm * cm / V / s};
0116   double vIon{ionMobility * 400 * V / cm};
0117 
0118   //    float f=0.5;//for now, just pick the middle of the hit.  Do better later.
0119 };
0120 
0121 #endif  // READDIGITALCURRENTS_H