Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MbdEvent.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MbdEvent.h
1 #ifndef MBD_MBDEVENT_H
2 #define MBD_MBDEVENT_H
3 
4 #include "MbdDefs.h"
5 #include "MbdSig.h"
6 
7 #include <TFile.h>
8 #include <TTree.h>
9 #include <fun4all/Fun4AllBase.h>
10 #include <vector>
11 
12 class PHCompositeNode;
13 class Event;
14 class Packet;
15 class MbdPmtContainer;
16 class MbdOut;
17 class MbdCalib;
18 class MbdGeom;
19 class CDBUtils;
20 class TF1;
21 class TCanvas;
22 
23 class MbdEvent : public Fun4AllBase
24 {
25  public:
26  MbdEvent();
27  virtual ~MbdEvent();
28 
29  int SetRawData(Event *event, MbdPmtContainer *mbdpmts);
30  int Calculate(MbdPmtContainer *mbdpmts, MbdOut *mbdout);
31  int InitRun();
32  void Clear();
33 
34  void SetSim(const int s) { _simflag = s; }
35 
36  float get_bbcz() { return m_bbcz; }
37  float get_bbczerr() { return m_bbczerr; }
38  float get_bbct0() { return m_bbct0; }
39  float get_bbct0err() { return m_bbct0err; }
40 
41  int get_bbcn(const int iarm) { return m_bbcn[iarm]; }
42  float get_bbcq(const int iarm) { return m_bbcq[iarm]; }
43  float get_bbct(const int iarm) { return m_bbct[iarm]; }
44  float get_bbcte(const int iarm) { return m_bbcte[iarm]; }
45 
46  int get_pmtq(const int ipmt) { return m_pmtq[ipmt]; }
47  float get_pmttt(const int ipmt) { return m_pmttt[ipmt]; }
48  float get_pmttq(const int ipmt) { return m_pmttq[ipmt]; }
49 
50  int get_EventNumber(void) const { return m_evt; }
51 
52  void set_debugintt(const int d) { debugintt = d; }
53 
54  MbdSig *GetSig(const int ipmt) { return &_mbdsig[ipmt]; }
55 
56  private:
57  static const int NCHPERPKT = 128;
58 
59  MbdGeom *_mbdgeom{nullptr};
60  MbdCalib *_mbdcal{nullptr};
61 
62  int Read_Charge_Calib(const std::string &calfname);
63  int Read_TQ_T0_Offsets(const std::string &calfname);
64  int Read_TQ_CLK_Offsets(const std::string &calfname);
65  int Read_TT_CLK_Offsets(const std::string &calfname);
67 
68  int debugintt{0};
69  void ReadSyncFile(const char *fname = "SYNC_INTTMBD.root");
70 
71  float gaincorr[MbdDefs::MBD_N_PMT]{}; // gain corrections
72  float tq_t0_offsets[MbdDefs::MBD_N_PMT]{}; // t0 offsets in charge channels
75 
76  // float bz_offset{0.};
77 
78  int _verbose{0};
79  int _runnum{0};
80  int _simflag{0};
81  Packet *p[2]{nullptr, nullptr};
82 
83  // alignment data
84  Int_t m_evt{0};
85  Short_t m_clk{0};
86  Short_t m_femclk{0};
87 
88  // raw data
89  Float_t m_adc[MbdDefs::MBD_N_FEECH][MbdDefs::MAX_SAMPLES]{}; // raw waveform, adc values
90  Float_t m_samp[MbdDefs::MBD_N_FEECH][MbdDefs::MAX_SAMPLES]{}; // raw waveform, sample values
91  Float_t m_ampl[MbdDefs::MBD_N_FEECH]{}; // raw amplitude
92 
93  std::vector<MbdSig> _mbdsig;
94 
95  Float_t m_pmtq[MbdDefs::MBD_N_PMT]{}; // npe in each arm
96  Float_t m_pmttt[MbdDefs::MBD_N_PMT]{}; // time in each arm
97  Float_t m_pmttq[MbdDefs::MBD_N_PMT]{}; // time in each arm
98 
100 
101  // output data
102  Short_t m_bbcn[2]{}; // num hits for each arm (north and south)
103  Float_t m_bbcq[2]{}; // total charge (currently npe) in each arm
104  Float_t m_bbct[2]{}; // time in arm
105  Float_t m_bbcte[2]{}; // earliest hit time in arm
106  Float_t m_bbctl[2]{}; // latest hit time in arm
107  Float_t m_bbcz{std::numeric_limits<Float_t>::quiet_NaN()}; // z-vertex
108  Float_t m_bbczerr{std::numeric_limits<Float_t>::quiet_NaN()}; // z-vertex error
109  Float_t m_bbct0{std::numeric_limits<Float_t>::quiet_NaN()}; // start time
110  Float_t m_bbct0err{std::numeric_limits<Float_t>::quiet_NaN()}; // start time error
111  Float_t _tres = std::numeric_limits<Float_t>::quiet_NaN(); // time resolution of one channel
112 
113  TH1 *hevt_bbct[2]{}; // time in each bbc, per event
114  TF1 *gausfit[2]{nullptr, nullptr};
115 
116  TH2 *h2_tmax[2] = {}; // [0 == time ch, 1 == chg ch], max sample in evt vs ch
117 
118  float TRIG_SAMP[16]{}; // [board]
119 
120  TCanvas *ac{nullptr}; // for plots used during debugging
121 
122  // debug stuff
123  std::unique_ptr<TFile> _synctfile{nullptr};
124  TTree *_syncttree{nullptr};
125  int _syncevt{0};
126  std::vector<Int_t> bbevt;
127  std::vector<UShort_t> bbclk;
128  std::vector<Float_t> mybbz;
129  std::vector<Long64_t> bco;
130  std::vector<Double_t> intz;
131  std::vector<Double_t> bbz;
132 };
133 
134 #endif /* MBD_MBDEVENT_H */