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.4 by bendavid, Thu Nov 13 14:08:06 2008 UTC vs.
Revision 1.12 by loizides, Mon May 18 06:29:57 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines