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.3 by loizides, Wed Sep 17 04:21:16 2008 UTC vs.
Revision 1.15 by bendavid, Thu Jun 18 22:56:30 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. Note that the energy of the tower does not
7 > // necessarily have to be greater 0. As such E() and  Et() can return negative
8 > // values. In those cases the FourVectorM will be 0, and also Pt() will return 0.
9   //
10 < // Authors: Si Xie
10 > // Authors: S.Xie
11   //--------------------------------------------------------------------------------------------------
12  
13 < #ifndef DATATREE_CALOTOWER_H
14 < #define DATATREE_CALOTOWER_H
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
# Line 19 | Line 23 | namespace mithep
23    class CaloTower : public DataObject
24    {
25      public:
26 <      CaloTower() {}
27 <      ~CaloTower() {}
28 <    
29 <      void                SetEmEnergy(Double_t EmEnergy)       { fEmEnergy    = EmEnergy;    }
30 <      void                SetEmPosition(Double_t x, Double_t y, Double_t z)
31 <                                                            { fEmPosition.SetXYZ(x,y,z);     }
32 <      void                SetHadEnergy(Double_t HadEnergy)     { fHadEnergy   = HadEnergy;   }
33 <      void                SetHadPosition(Double_t x, Double_t y, Double_t z)
34 <                                                            { fHadPosition.SetXYZ(x,y,z);    }
35 <      void                SetOuterEnergy(Double_t OuterEnergy) { fOuterEnergy = OuterEnergy; }  
36 <      void                SetEmLvl1(Int_t EmLvl1)              { fEmLvl1      = EmLvl1;      }
37 <      void                SetHadLvl1(Int_t HadLvl1)            { fHadLvl1     = HadLvl1;     }
38 <      void                SetMomentum(Double_t x, Double_t y, Double_t z, Double_t e)
39 <                                                            { fMomentum.SetPxPyPzE(x,y,z,e); }              
40 <
41 <      const FourVector   &Mom()         const { return fMomentum;                            }
42 <      Double_t            Eta()         const { return fMomentum.Eta();                      }
43 <      Double_t            Phi()         const { return fMomentum.Phi();                      }
44 <      Double_t            Theta()       const { return fMomentum.Theta();                    }
45 <      Double_t            E()           const { return fMomentum.E();                        }
46 <      Double_t            Et()          const { return E()*sin(Theta());                     }
47 <      Double_t            EmEnergy()    const { return fEmEnergy;                            }
48 <      const ThreeVector  &EmPosition()  const { return fEmPosition;                          }
49 <      Double_t            HadEnergy()   const { return fHadEnergy;                           }
50 <      const ThreeVector  &HadPosition() const { return fHadPosition;                         }
51 <      Double_t            OuterEnergy() const { return fOuterEnergy;                         }
52 <      Double_t            EmEt()        const { return fEmEnergy*sin(Theta());               }
53 <      Double_t            HadEt()       const { return fHadEnergy*sin(Theta());              }
54 <      Double_t            OuterEt()     const { return fOuterEnergy*sin(Theta());            }      
51 <      Double_t            EmLvl1()      const { return fEmLvl1;                              }
52 <      Double_t            HadLvl1()     const { return fHadLvl1;                             }      
26 >      CaloTower() : fEmEnergy(0), fHadEnergy(0), fOuterEnergy(0), fMass(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 >      Double_t             Mass()        const { return fMass;                                   }
38 >      const FourVectorM   &Mom()         const;
39 >      Double_t             Phi()         const { return fPosition.Phi();                         }
40 >      Double_t             Pt()          const { Double_t r=Et(); if(r<0) r=0; return r;         }
41 >      EObjType             ObjType()     const { return kCaloTower;                              }
42 >      Double_t             OuterEnergy() const { return fOuterEnergy;                            }
43 >      Double_t             OuterEt()     const { return fOuterEnergy*TMath::Sin(Theta());        }
44 >      const ThreeVectorC  &Position()    const;
45 >      Double_t             Theta()       const { return Position().Theta();                      }
46 >      void                 SetEmEnergy(Double_t EmEnergy)      
47 >                             { fEmEnergy    = EmEnergy;  ClearMom(); }
48 >      void                 SetHadEnergy(Double_t HadEnergy)    
49 >                             { fHadEnergy   = HadEnergy; ClearMom(); }
50 >      void                 SetOuterEnergy(Double_t OuterEnergy)
51 >                             { fOuterEnergy = OuterEnergy; ClearMom(); }
52 >      void                 SetMass(Double_t mass) { fMass = mass;      }
53 >      void                 SetPosition(Double_t x, Double_t y, Double_t z)
54 >                             { fPosition.SetXYZ(x,y,z); ClearMom(); ClearPos(); }
55  
56      protected:
57 <      FourVector          fMomentum;
58 <      ThreeVector         fEmPosition;   //Position of Ecal shower center
59 <      ThreeVector         fHadPosition;  //Position of Hcal shower center
60 <      Double_t            fEmEnergy;     //tower energy in Ecal
61 <      Double_t            fHadEnergy;    //tower energy in Hcal
62 <      Double_t            fOuterEnergy;
63 <      Int_t               fEmLvl1;
64 <      Int_t               fHadLvl1;
57 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
58 >      void                 ClearPos()    const { fCachePosFlag.ClearCache(); }
59 >      void                 GetMom()      const;
60 >      void                 GetPos()      const;
61 >    
62 >      Vect3C               fPosition;     //position of tower
63 >      Double32_t           fEmEnergy;     //[0,0,14]tower energy in Ecal
64 >      Double32_t           fHadEnergy;    //[0,0,14]tower energy in Hcal
65 >      Double32_t           fOuterEnergy;  //[0,0,14]tower energy in outer Hcal
66 >      Double32_t           fMass;         //[0,0,14]tower mass
67 >      mutable CacheFlag    fCacheMomFlag; //||cache validity flag for momentum
68 >      mutable FourVectorM  fCachedMom;    //!cached momentum vector
69 >      mutable CacheFlag    fCachePosFlag; //||cache validity flag for position
70 >      mutable ThreeVectorC fCachedPos;    //!cached position vector
71  
72 <    ClassDef(CaloTower, 1) // Generic particle class
72 >    ClassDef(CaloTower, 2) // Calo tower class
73    };
74   }
75 +
76 + //--------------------------------------------------------------------------------------------------
77 + inline void mithep::CaloTower::GetMom() const
78 + {
79 +  // Compute four momentum.
80 +  Double_t energy = E();
81 +  if (energy > 0) {
82 +    Double_t pt = TMath::Sin(Theta())*TMath::Sqrt(energy*energy + fMass*fMass);
83 +    fCachedMom.SetCoordinates(pt,Eta(),Phi(),Mass());
84 +  }
85 +  else
86 +    fCachedMom = mithep::FourVectorM();
87 + }
88 +
89 + //--------------------------------------------------------------------------------------------------
90 + inline void mithep::CaloTower::GetPos() const
91 + {
92 +  // Compute position.
93 +
94 +  fCachedPos.SetCoordinates(fPosition.Rho(), fPosition.Eta(), fPosition.Phi());
95 + }
96 +
97 + //--------------------------------------------------------------------------------------------------
98 + inline const mithep::FourVectorM &mithep::CaloTower::Mom() const
99 + {
100 +  // Return cached momentum value.
101 +
102 +  if (!fCacheMomFlag.IsValid()) {
103 +    GetMom();
104 +    fCacheMomFlag.SetValid();
105 +  }
106 +  return fCachedMom;
107 + }
108 +
109 + //--------------------------------------------------------------------------------------------------
110 + inline const mithep::ThreeVectorC &mithep::CaloTower::Position() const
111 + {
112 +  // Return cached momentum value.
113 +
114 +  if (!fCachePosFlag.IsValid()) {
115 +    GetPos();
116 +    fCachePosFlag.SetValid();
117 +  }
118 +  return fCachedPos;
119 + }
120   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines