ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/CaloTower.h
Revision: 1.13
Committed: Mon May 18 06:44:56 2009 UTC (15 years, 11 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.12: +5 -3 lines
Log Message:
Added a comment about negative energy.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: CaloTower.h,v 1.12 2009/05/18 06:29:57 loizides Exp $
3 //
4 // CaloTower
5 //
6 // This class holds calo tower information. Note that the energy of the tower does not
7 // necessarily have to be greater 0, and as such E(), Et() (or Pt()) can return negative
8 // values.
9 //
10 // Authors: S.Xie
11 //--------------------------------------------------------------------------------------------------
12
13 #ifndef MITANA_DATATREE_CALOTOWER_H
14 #define MITANA_DATATREE_CALOTOWER_H
15
16 #include <TMath.h>
17 #include "MitCommon/DataFormats/interface/Vect3C.h"
18 #include "MitAna/DataCont/interface/CacheFlag.h"
19 #include "MitAna/DataTree/interface/DataObject.h"
20
21 namespace mithep
22 {
23 class CaloTower : public DataObject
24 {
25 public:
26 CaloTower() : fEmEnergy(0), fHadEnergy(0), fOuterEnergy(0) {}
27
28 Double_t E() const { return (fEmEnergy + fHadEnergy); }
29 Double_t EmEt() const { return fEmEnergy*TMath::Sin(Theta()); }
30 Double_t Eta() const { return fPosition.Eta(); }
31 Double_t Et() const { return E()*TMath::Sin(Theta()); }
32 Double_t EtWithHO() const { return EWithHO()*TMath::Sin(Theta()); }
33 Double_t EWithHO() const { return (fEmEnergy + fHadEnergy + fOuterEnergy); }
34 Double_t EmEnergy() const { return fEmEnergy; }
35 Double_t HadEnergy() const { return fHadEnergy; }
36 Double_t HadEt() const { return fHadEnergy*TMath::Sin(Theta()); }
37 const FourVectorM &Mom() const;
38 Double_t Phi() const { return fPosition.Phi(); }
39 Double_t Pt() const { return Et(); /*careful can become negative*/ }
40 EObjType ObjType() const { return kCaloTower; }
41 Double_t OuterEnergy() const { return fOuterEnergy; }
42 Double_t OuterEt() const { return fOuterEnergy*TMath::Sin(Theta()); }
43 const ThreeVectorC &Position() const;
44 Double_t Theta() const { return Position().Theta(); }
45 void SetEmEnergy(Double_t EmEnergy)
46 { fEmEnergy = EmEnergy; ClearMom(); }
47 void SetHadEnergy(Double_t HadEnergy)
48 { fHadEnergy = HadEnergy; ClearMom(); }
49 void SetOuterEnergy(Double_t OuterEnergy)
50 { fOuterEnergy = OuterEnergy; ClearMom(); }
51 void SetPosition(Double_t x, Double_t y, Double_t z)
52 { fPosition.SetXYZ(x,y,z); ClearMom(); ClearPos(); }
53
54 protected:
55 void ClearMom() const { fCacheMomFlag.ClearCache(); }
56 void ClearPos() const { fCachePosFlag.ClearCache(); }
57 void GetMom() const;
58 void GetPos() const;
59
60 Vect3C fPosition; //position of tower
61 Double32_t fEmEnergy; //[0,0,14]tower energy in Ecal
62 Double32_t fHadEnergy; //[0,0,14]tower energy in Hcal
63 Double32_t fOuterEnergy; //[0,0,14]tower energy in outer Hcal
64 mutable CacheFlag fCacheMomFlag; //||cache validity flag for momentum
65 mutable FourVectorM fCachedMom; //!cached momentum vector
66 mutable CacheFlag fCachePosFlag; //||cache validity flag for position
67 mutable ThreeVectorC fCachedPos; //!cached position vector
68
69 ClassDef(CaloTower, 1) // Calo tower class
70 };
71 }
72
73 //--------------------------------------------------------------------------------------------------
74 inline void mithep::CaloTower::GetMom() const
75 {
76 // Compute four momentum.
77
78 if (E() > 0)
79 fCachedMom.SetCoordinates(Et(),Eta(),Phi(),0.0);
80 else
81 fCachedMom = mithep::FourVectorM();
82 }
83
84 //--------------------------------------------------------------------------------------------------
85 inline void mithep::CaloTower::GetPos() const
86 {
87 // Compute position.
88
89 fCachedPos.SetCoordinates(fPosition.Rho(), fPosition.Eta(), fPosition.Phi());
90 }
91
92 //--------------------------------------------------------------------------------------------------
93 inline const mithep::FourVectorM &mithep::CaloTower::Mom() const
94 {
95 // Return cached momentum value.
96
97 if (!fCacheMomFlag.IsValid()) {
98 GetMom();
99 fCacheMomFlag.SetValid();
100 }
101 return fCachedMom;
102 }
103
104 //--------------------------------------------------------------------------------------------------
105 inline const mithep::ThreeVectorC &mithep::CaloTower::Position() const
106 {
107 // Return cached momentum value.
108
109 if (!fCachePosFlag.IsValid()) {
110 GetPos();
111 fCachePosFlag.SetValid();
112 }
113 return fCachedPos;
114 }
115 #endif