ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/CaloTower.h
(Generate patch)

Comparing UserCode/MitAna/DataTree/interface/CaloTower.h (file contents):
Revision 1.8 by loizides, Wed Feb 18 15:38:54 2009 UTC vs.
Revision 1.11 by loizides, Sun Mar 8 12:09:58 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines