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.9 by bendavid, Thu Feb 26 17:06:24 2009 UTC

# Line 12 | Line 12
12   #define MITANA_DATATREE_CALOTOWER_H
13  
14   #include "MitAna/DataTree/interface/DataObject.h"
15 + #include "MitAna/DataTree/interface/CacheFlag.h"
16   #include <TMath.h>
17  
18   namespace mithep
# Line 30 | Line 31 | namespace mithep
31        Double_t            EmEnergy()    const { return fEmEnergy;                               }
32        Double_t            HadEnergy()   const { return fHadEnergy;                              }
33        Double_t            HadEt()       const { return fHadEnergy*TMath::Sin(Theta());          }
34 <      const FourVectorM   Mom()         const;
34 >      const FourVectorM  &Mom()         const;
35        Double_t            Phi()         const { return fPosition.Phi();                         }
36        EObjType            ObjType()     const { return kCaloTower;                              }
37        Double_t            OuterEnergy() const { return fOuterEnergy;                            }
38        Double_t            OuterEt()     const { return fOuterEnergy*TMath::Sin(Theta());        }
39 <      const ThreeVectorC  Position()    const { return fPosition;                               }
39 >      const ThreeVectorC &Position()    const { return fPosition;                               }
40        Double_t            Theta()       const { return fPosition.Theta();                       }
41 <      void                SetEmEnergy(Double_t EmEnergy)       { fEmEnergy    = EmEnergy;       }
42 <      void                SetHadEnergy(Double_t HadEnergy)     { fHadEnergy   = HadEnergy;      }
43 <      void                SetOuterEnergy(Double_t OuterEnergy) { fOuterEnergy = OuterEnergy;    }
41 >      void                SetEmEnergy(Double_t EmEnergy)       { fEmEnergy    = EmEnergy; ClearMom(); }
42 >      void                SetHadEnergy(Double_t HadEnergy)     { fHadEnergy   = HadEnergy; ClearMom(); }
43 >      void                SetOuterEnergy(Double_t OuterEnergy) { fOuterEnergy = OuterEnergy; ClearMom(); }
44        void                SetPosition(Double_t x, Double_t y, Double_t z)
45 <                                                               { fPosition.SetXYZ(x,y,z);       }
45 >                                                               { fPosition.SetXYZ(x,y,z); ClearMom(); }
46  
47      protected:
48 +      void                ClearMom()     const { fCacheMomFlag.ClearCache(); }
49 +      void                GetMom()       const;
50 +    
51        ThreeVectorC32      fPosition;     //position of tower
52        Double32_t          fEmEnergy;     //tower energy in Ecal
53        Double32_t          fHadEnergy;    //tower energy in Hcal
54        Double32_t          fOuterEnergy;  //tower energy in outer Hcal
55 +      
56 +      mutable CacheFlag   fCacheMomFlag; //||cache validity flag for momentum
57 +      mutable FourVectorM fCachedMom;    //!cached momentum vector (filled by derived classes)
58  
59      ClassDef(CaloTower, 1) // Calo tower class
60    };
61   }
62  
63   //--------------------------------------------------------------------------------------------------
64 < inline const mithep::FourVectorM mithep::CaloTower::Mom() const
64 > inline void mithep::CaloTower::GetMom() const
65   {
66    // Compute and return four momentum.
67  
68    if (E() > 0)
69 <    return mithep::FourVectorM(Et(),Eta(),Phi(),0.0);
69 >    fCachedMom.SetCoordinates(Et(),Eta(),Phi(),0.0);
70    else
71 <    return mithep::FourVectorM();
71 >    fCachedMom = mithep::FourVectorM();
72 > }
73 >
74 > //--------------------------------------------------------------------------------------------------
75 > inline const mithep::FourVectorM &mithep::CaloTower::Mom() const
76 > {
77 >  // Return cached momentum value.
78 >
79 >  if (!fCacheMomFlag.IsValid()) {
80 >    GetMom();
81 >    fCacheMomFlag.SetValid();
82 >  }
83 >
84 >  return fCachedMom;
85   }
86   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines