Back to home page

sPhenix code displayed by LXR

 
 

    


Warning, file /coresoftware/offline/packages/mbd/MbdEvent.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef MBD_MBDEVENT_H
0002 #define MBD_MBDEVENT_H
0003 
0004 #include "MbdDefs.h"
0005 #include "MbdSig.h"
0006 
0007 #include <TFile.h>
0008 #include <TTree.h>
0009 
0010 #ifndef ONLINE
0011 #include <fun4all/Fun4AllBase.h>
0012 #endif
0013 
0014 #include <array>
0015 #include <limits>
0016 #include <vector>
0017 
0018 class PHCompositeNode;
0019 class Event;
0020 class MbdRawContainer;
0021 class MbdPmtContainer;
0022 class MbdOut;
0023 class MbdCalib;
0024 class MbdGeom;
0025 class CDBUtils;
0026 class TF1;
0027 class TCanvas;
0028 #ifndef ONLINE
0029 class CaloPacket;
0030 class CaloPacketContainer;
0031 class Gl1Packet;
0032 class PHG4TruthInfoContainer;
0033 class PHG4VtxPoint;
0034 #endif
0035 
0036 class MbdEvent
0037 {
0038  public:
0039   MbdEvent(const int cal_pass = 0, const bool proc_charge = false);
0040   virtual ~MbdEvent();
0041 
0042   int InitRun();
0043   int End();
0044   void Clear();
0045 
0046   int SetRawData(Event *event, MbdRawContainer *bbcraws, MbdPmtContainer *bbcpmts);
0047 #ifndef ONLINE
0048   int SetRawData(std::array< CaloPacket*,2> &dstp, MbdRawContainer *bbcraws, MbdPmtContainer *bbcpmts, Gl1Packet *gl1raw);
0049 #endif
0050   int ProcessPackets(MbdRawContainer *bbcraws);
0051   int ProcessRawContainer(MbdRawContainer *bbcraws, MbdPmtContainer *bbcpmts);
0052   void PostProcessChannels(MbdPmtContainer *bbcpmts);
0053   int Calculate(MbdPmtContainer *bbcpmts, MbdOut *bbcout, PHCompositeNode *topNode = nullptr);
0054 
0055   void SetSim(const int s) { _simflag = s; }
0056   void SetRawDstFlag(const int r) { _rawdstflag = r; }
0057   void SetFitsOnly(const int f) { _fitsonly = f; }
0058 
0059   float get_bbcz() { return m_bbcz; }
0060   float get_bbczerr() { return m_bbczerr; }
0061   float get_bbct0() { return m_bbct0; }
0062   float get_bbct0err() { return m_bbct0err; }
0063 
0064   int   get_bbcn(const int iarm) { return m_bbcn[iarm]; }
0065   float get_bbcq(const int iarm) { return m_bbcq[iarm]; }
0066   float get_bbct(const int iarm) { return m_bbct[iarm]; }
0067   float get_bbcte(const int iarm) { return m_bbcte[iarm]; }
0068 
0069   int   get_pmtq(const int ipmt) { return m_pmtq[ipmt]; }
0070   float get_pmttt(const int ipmt) { return m_pmttt[ipmt]; }
0071   float get_pmttq(const int ipmt) { return m_pmttq[ipmt]; }
0072 
0073   int   get_EventNumber(void) const { return m_evt; }
0074   void  set_EventNumber(int ievt) { m_evt = ievt; }
0075 
0076   void  set_debug(const int d) { _debug = d; }
0077 
0078   MbdSig *GetSig(const int ipmt) { return &_mbdsig[ipmt]; }
0079 
0080   MbdCalib *GetCalib() { return _mbdcal; }
0081 
0082   int FillSampMaxCalib();
0083 
0084   int  calib_is_done() { return _calib_done; }
0085 
0086   int  Verbosity() { return _verbose; }
0087   void Verbosity(const int v) { _verbose = v; }
0088 
0089  private:
0090   static const int NCHPERPKT = 128;
0091 
0092   MbdGeom *_mbdgeom{nullptr};
0093   MbdCalib *_mbdcal{nullptr};
0094 
0095   int Read_Charge_Calib(const std::string &gainfname);
0096   int Read_TQ_T0_Offsets(const std::string &t0cal_fname);
0097   int Read_TQ_CLK_Offsets(const std::string &t0cal_fname);
0098   int Read_TT_CLK_Offsets(const std::string &t0cal_fname);
0099   //int DoQuickClockOffsetCalib();
0100 
0101   bool isbadtch(const int ipmtch);
0102 
0103   // Debugging variables
0104   int _debug{0};
0105 #ifndef ONLINE
0106   PHG4TruthInfoContainer* _truth_container {nullptr};
0107   PHG4VtxPoint* _vtxp {nullptr};
0108   PHG4VtxPoint* GetPrimaryVtx(PHCompositeNode *topNode);
0109 #endif
0110   int epmt[2]{-1, -1};  // pmt of earliest time
0111   // int lpmt[2] {-1,-1};        // pmt of latest time
0112   double tepmt[2]{1e9, 1e9};    // earliest time
0113   double tlpmt[2]{-1e9, -1e9};  // latest time
0114   void ReadSyncFile(const char *fname = "SYNC_INTTMBD.root");
0115 
0116   float gaincorr[MbdDefs::MBD_N_PMT]{};       // gain corrections
0117   float tq_t0_offsets[MbdDefs::MBD_N_PMT]{};  // t0 offsets in charge channels
0118   float tq_clk_offsets[MbdDefs::MBD_N_PMT]{};
0119   float tt_clk_offsets[MbdDefs::MBD_N_PMT]{};
0120 
0121   // float bz_offset{0.};
0122 
0123   int _verbose{0};
0124   int _runnum{0};
0125   int _simflag{0};
0126   int _rawdstflag{0};  // dst with raw container
0127   int _fitsonly{0};    // stop reco after waveform fits (for DST_CALOFIT pass)
0128   int _nsamples{31};
0129   int _calib_done{0}; 
0130   unsigned int _no_sampmax{0};      //! sampmax calib doesn't exist
0131   int _is_online{0};                //! for OnlMon
0132 
0133   // alignment data
0134   Int_t   m_evt{0};
0135   Short_t m_clk{0};
0136   Short_t m_femclk{0};
0137   UInt_t  m_xmitclocks[2]{};     // [ipkt]
0138   UInt_t  m_femclocks[2][2]{};   // [ipkt][iadc]
0139 
0140   // raw data
0141   Float_t m_adc[MbdDefs::MBD_N_FEECH][MbdDefs::MAX_SAMPLES]{};   // raw waveform, adc values
0142   Float_t m_samp[MbdDefs::MBD_N_FEECH][MbdDefs::MAX_SAMPLES]{};  // raw waveform, sample values
0143 
0144   Float_t m_ampl[MbdDefs::MBD_N_FEECH]{};                        // raw amplitude (ADC)
0145   Float_t m_ttdc[MbdDefs::MBD_N_FEECH]{};                        // T-ch TDC
0146   Float_t m_qtdc[MbdDefs::MBD_N_FEECH]{};                        // Q-ch TDC
0147 
0148   std::vector<MbdSig> _mbdsig;
0149 
0150   Float_t m_pmtq[MbdDefs::MBD_N_PMT]{};   // npe in each arm
0151   Float_t m_pmttt[MbdDefs::MBD_N_PMT]{};  // time in each arm
0152   Float_t m_pmttq[MbdDefs::MBD_N_PMT]{};  // time in each arm
0153 
0154   int do_templatefit{1};
0155 
0156   // output data
0157   Short_t m_bbcn[2]{};                                            // num hits for each arm (north and south)
0158   Float_t m_bbcq[2]{};                                            // total charge (currently npe) in each arm
0159   Float_t m_bbct[2]{};                                            // time in arm
0160   Float_t m_bbcte[2]{};                                           // earliest hit time in arm
0161   Float_t m_bbctl[2]{};                                           // latest hit time in arm
0162   Float_t m_bbcz{std::numeric_limits<Float_t>::quiet_NaN()};      // z-vertex
0163   Float_t m_bbczerr{std::numeric_limits<Float_t>::quiet_NaN()};   // z-vertex error
0164   Float_t m_bbct0{std::numeric_limits<Float_t>::quiet_NaN()};     // start time
0165   Float_t m_bbct0err{std::numeric_limits<Float_t>::quiet_NaN()};  // start time error
0166   Float_t _tres{std::numeric_limits<Float_t>::quiet_NaN()};       // time resolution of one channel
0167 
0168   TH1 *hevt_bbct[2]{};  // time in each bbc, per event
0169   TF1 *gausfit[2]{nullptr, nullptr};
0170 
0171   float TRIG_SAMP[16]{};  // [board]
0172 
0173   // Calibration Data
0174   int  _calpass{0};
0175   bool _always_process_charge{false};
0176   TString _caldir;
0177   //std::string _caldir;
0178 
0179   // sampmax and other calib stuff
0180   int CalcSampMaxCalib();
0181   std::unique_ptr<TFile> _calpass1_tfile{nullptr};
0182   std::unique_ptr<TFile> _calpass2_tfile{nullptr};
0183   TH1 *h_smax[256]{};     // [feech], max sample in event
0184   TH2 *h2_smax[2]{};      // [0 == time ch, 1 == chg ch], max sample in evt vs ch
0185   TH2 *h2_wave[2]{};      // [0 == time ch, 1 == chg ch], all samples in evt vs ch
0186   TH2 *h2_trange_raw{};   // raw tdc at maxsamp vs ch
0187   TH2 *h2_trange{};       // subtracted tdc at maxsamp vs ch
0188   //TH1 *h_trange[2]{};     // subtracted tdc at maxsamp, [S/N]
0189 
0190   // pedestals (hists are in MbdSig)
0191   int CalcPedCalib();
0192 
0193   //
0194   void ClusterEarliest(std::vector<float> &times, double& mean, double& rms, double& rmin, double& rmax);
0195  
0196   // debug stuff
0197   TCanvas *ac{nullptr};  // for plots used during debugging
0198   void PlotDebug();
0199   std::unique_ptr<TFile> _synctfile{nullptr};
0200   TTree *_syncttree{nullptr};
0201   Double_t _refz{ std::numeric_limits<double>::quiet_NaN() };
0202   std::vector<Int_t> bbevt;
0203   std::vector<UShort_t> bbclk;
0204   std::vector<Float_t> mybbz;
0205   std::vector<Long64_t> bco;
0206   std::vector<Double_t> intz;
0207   std::vector<Double_t> bbz;
0208 };
0209 
0210 #endif /* MBD_MBDEVENT_H */