Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:20:03

0001 #ifndef TIMINGCUT_H
0002 #define TIMINGCUT_H
0003 
0004 #include <jetbase/Jet.h>
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <phparameter/PHParameters.h>
0009 
0010 #include <cmath>
0011 #include <string>
0012 
0013 class PHCompositeNode;
0014 
0015 class TimingCut : public SubsysReco
0016 {
0017  public:
0018   explicit TimingCut(const std::string &jetNodeName, const std::string &name = "TimingCutModule", bool doAbort = false);
0019 
0020   ~TimingCut() override = default;
0021 
0022   float calc_dphi(float maxJetPhi, float subJetPhi)
0023   {
0024     float dPhi = std::abs(maxJetPhi - subJetPhi);
0025     if(dPhi>M_PI) dPhi -= M_PI;
0026     return dPhi;
0027   }
0028 
0029   bool Pass_Delta_t(float lead_time, float sub_time, float maxJetPhi, float subJetPhi)
0030   {
0031     float dPhi = calc_dphi(maxJetPhi, subJetPhi);
0032     return (std::abs(lead_time - sub_time) < _dt_width && dPhi > _min_dphi);
0033   }
0034 
0035   bool Pass_Lead_t(float lead_time)
0036   {
0037     return std::abs(lead_time + _t_shift) < _t_width;
0038   }
0039 
0040   bool Pass_Mbd_dt(float lead_time, float mbd_time)
0041   {
0042     return std::abs(lead_time - mbd_time) < _mbd_dt_width;
0043   }
0044 
0045   void set_t_shift(float new_shift) { _t_shift = new_shift; }
0046   float get_t_shift() { return _t_shift; }
0047 
0048   void set_t_width(float new_t_width) { _t_width = new_t_width; }
0049   float get_t_width() { return _t_width; }
0050   
0051   void set_dt_width(float new_dt_width) { _dt_width = new_dt_width; }
0052   float get_dt_width() { return _dt_width; }
0053 
0054   void set_mbd_dt_width(float new_mbd_dt_width) { _mbd_dt_width = new_mbd_dt_width; }
0055   float get_mbd_dt_width() { return _mbd_dt_width; }
0056 
0057   void set_min_dphi(float new_min_dphi) { _min_dphi = new_min_dphi; }
0058   float get_min_dphi() { return _min_dphi; }
0059 
0060   int Init(PHCompositeNode *topNode) override;
0061 
0062   int process_event(PHCompositeNode *topNode) override;
0063 
0064   int ResetEvent(PHCompositeNode *topNode) override;
0065 
0066   int End(PHCompositeNode *topNode) override;
0067 
0068   int Reset(PHCompositeNode * /*topNode*/) override;
0069 
0070   void Print(const std::string &what = "ALL") const override;
0071 
0072   int CreateNodeTree(PHCompositeNode *topNode);
0073 
0074   void SetDefaultParams()
0075   {
0076     _cutParams.set_int_param("passLeadtCut", 0);
0077     _cutParams.set_int_param("passDeltatCut", 0);
0078     _cutParams.set_int_param("passMbdDtCut", 0);
0079     _cutParams.set_int_param("failAnyTimeCut",0);
0080     _cutParams.set_double_param("maxJett",9999);
0081     _cutParams.set_double_param("subJett",9999);
0082     _cutParams.set_double_param("mbd_time",9999);
0083     _cutParams.set_double_param("dPhi",9999);
0084   }
0085 
0086 private:
0087   bool _doAbort;
0088   bool _missingInfoWarningPrinted = false;
0089   std::string _jetNodeName;
0090   PHParameters _cutParams;
0091   float _t_width{6.0};
0092   float _dt_width{3.0};
0093   float _t_shift{2.0};
0094   float _mbd_dt_width{3.0};
0095   float _min_dphi{3*M_PI/4};
0096 };
0097 
0098 #endif