PandaTree
PFCandBase.h
1 #ifndef PandaTree_Objects_PFCandBase_h
2 #define PandaTree_Objects_PFCandBase_h
3 #include "Constants.h"
4 #include "Particle.h"
5 #include "../../Framework/interface/Array.h"
6 #include "../../Framework/interface/Collection.h"
7 #include "../../Framework/interface/Ref.h"
8 #include "../../Framework/interface/RefVector.h"
9 #include "RecoVertex.h"
10 #include "PackedTrack.h"
11 
12 namespace panda {
13 
14  class PFCandBase : public Particle {
15  public:
16  enum PType {
17  hp,
18  hm,
19  ep,
20  em,
21  mup,
22  mum,
23  gamma,
24  h0,
25  h_HF,
26  egamma_HF,
27  Xp,
28  Xm,
29  X,
30  nPTypes
31  };
32 
33  static TString PTypeName[nPTypes];
34 
35  static int const q_[nPTypes];
36  static int const pdgId_[nPTypes];
37 
38  struct datastore : public Particle::datastore {
40  ~datastore() { deallocate(); }
41 
42  UChar_t* ptype{0};
43  ContainerBase const* vertexContainer_{0};
44  Short_t* vertex_{0};
45  ContainerBase const* trackContainer_{0};
46  Short_t* track_{0};
47  Float_t* hCalFrac{0};
48 
49  void allocate(UInt_t n) override;
50  void deallocate() override;
51  void setStatus(TTree&, TString const&, utils::BranchList const&) override;
52  utils::BranchList getStatus(TTree&, TString const&) const override;
53  utils::BranchList getBranchNames(TString const& = "") const override;
54  void setAddress(TTree&, TString const&, utils::BranchList const& = {"*"}, Bool_t setStatus = kTRUE) override;
55  void book(TTree&, TString const&, utils::BranchList const& = {"*"}, Bool_t dynamic = kTRUE) override;
56  void releaseTree(TTree&, TString const&) override;
57  void resizeVectors_(UInt_t) override;
58  };
59 
62 
63  typedef Particle base_type;
64 
65  PFCandBase(datastore&, UInt_t idx);
66  ~PFCandBase();
67  PFCandBase& operator=(PFCandBase const&);
68 
69  static char const* typeName() { return "PFCandBase"; }
70 
71  void print(std::ostream& = std::cout, UInt_t level = 1) const override;
72  void dump(std::ostream& = std::cout) const override;
73 
74  virtual double puppiW() const = 0;
75  virtual double puppiWNoLep() const = 0;
76  virtual void setPuppiW(double w, double wnl) = 0;
77  TLorentzVector puppiP4() const { TLorentzVector p4; p4.SetPtEtaPhiM(pt() * puppiW(), eta(), phi(), m() * puppiW()); return p4; }
78  TLorentzVector puppiNoLepP4() const { TLorentzVector p4; p4.SetPtEtaPhiM(pt() * puppiWNoLep(), eta(), phi(), m() * puppiWNoLep()); return p4; }
79  int q() const { return q_[ptype]; }
80  int pdgId() const { return pdgId_[ptype]; }
81  TVector3 pca() const;
82  double dxy(TVector3 const&) const;
83  double dz(TVector3 const&) const;
84 
85  UChar_t& ptype;
86  Ref<RecoVertex> vertex;
87  Ref<PackedTrack> track;
88  Float_t& hCalFrac;
89 
90  /* BEGIN CUSTOM PFCandBase.h.classdef */
91  /* END CUSTOM */
92 
93  static utils::BranchList getListOfBranches();
94 
95  void destructor(Bool_t recursive = kFALSE);
96 
97  protected:
99 
100  void doBook_(TTree&, TString const&, utils::BranchList const& = {"*"}) override;
101  void doInit_() override;
102  };
103 
108 
109  /* BEGIN CUSTOM PFCandBase.h.global */
110  /* END CUSTOM */
111 
112 }
113 
114 #endif
Base class for fixed-size containers.
Definition: ArrayBase.h:13
A reference to an element in a container.
Definition: Ref.h:20
Definition: Particle.h:12
Base class for dynamic-size containers.
Definition: CollectionBase.h:16
Short_t * vertex_
transient
Definition: PFCandBase.h:44
Template class for fixed-size container implementations. Inherits from base_type::array_type of the e...
Definition: Array.h:20
Short_t * track_
transient
Definition: PFCandBase.h:46
List of branch names.
Definition: IOUtils.h:64
void resizeVectors_(UInt_t) override
Override when there are vector members.
Definition: PFCandBase.cc:110
Definition: Particle.h:14
Base class for all containers.
Definition: ContainerBase.h:18
Template class for dynamic-size container implementations. Inherits from base_type::collection_type o...
Definition: Collection.h:19
Definition: PFCandBase.h:38
void dump(std::ostream &=std::cout) const override
Dump the object content.
Definition: PFCandBase.cc:204
void print(std::ostream &=std::cout, UInt_t level=1) const override
Print the object content.
Definition: PFCandBase.cc:196
Base class for elements of containers.
Definition: Element.h:32
Definition: Array.h:11
A vector of references to elements in a container.
Definition: RefVector.h:18
Definition: PFCandBase.h:14