StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJetElement.h
1 // -*- mode: c++ -*-
2 
3 //
4 // Pibero Djawotho <pibero@tamu.edu>
5 // Texas A&M University
6 // 2 September 2009
7 //
8 
9 #ifndef ST_JET_ELEMENT_H
10 #define ST_JET_ELEMENT_H
11 
12 #include "TVector3.h"
13 #include "TRef.h"
14 
15 #include "StJetCandidate.h"
16 
17 class StJetElement : public TObject {
18 public:
19  StJetElement(short id = -1, short detId = -1)
20  : mId(id)
21  , mDetectorId(detId)
22  , mPt(0)
23  , mEta(0)
24  , mPhi(0)
25  , mJet(0)
26  {
27  }
28 
29  short id () const { return mId; }
30  short detectorId () const { return mDetectorId; }
31  float pt () const { return mPt; }
32  float eta () const { return mEta; }
33  float phi () const { return mPhi; }
34  TVector3 momentum () const;
35  TVector3 localMomentum() const;
36  float jt () const { return localMomentum().Perp(); }
37  float ps () const { return localMomentum().Px(); }
38  float pn () const { return localMomentum().Py(); }
39  float pl () const { return localMomentum().Pz(); }
40  float frag () const { return momentum().Mag() / jet()->momentum().Mag(); }
41  StJetCandidate* jet () const { return (StJetCandidate*)mJet.GetObject(); }
42 
43  void setJet(const StJetCandidate* jet) { mJet = (TObject*)jet; }
44 
45 protected:
46  short mId;
47  short mDetectorId;
48  float mPt;
49  float mEta;
50  float mPhi;
51  TRef mJet;
52 
53  ClassDef(StJetElement, 1);
54 };
55 
56 inline TVector3 StJetElement::momentum() const
57 {
58  TVector3 mom;
59  mom.SetPtEtaPhi(mPt,mEta,mPhi);
60  return mom;
61 }
62 
63 inline TVector3 StJetElement::localMomentum() const
64 {
65  TVector3 longUnit = jet()->momentum().Unit();
66  TVector3 normUnit = TVector3(0,0,1).Cross(longUnit).Unit();
67  TVector3 sideUnit = longUnit.Cross(normUnit);
68  TVector3 mom = momentum();
69  return TVector3(mom.Dot(sideUnit),mom.Dot(normUnit),mom.Dot(longUnit));
70 }
71 
72 #endif // ST_JET_ELEMENT_H