ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/CompositeParticle.h
Revision: 1.19
Committed: Thu Feb 26 17:06:24 2009 UTC (16 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.18: +4 -4 lines
Log Message:
Incorporate updated RefArray (no size template argument anymore) and add necessary caches and cache clear calls

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.19 // $Id: CompositeParticle.h,v 1.18 2009/02/18 15:38:54 loizides Exp $
3 loizides 1.1 //
4     // Composite Particle
5     //
6 loizides 1.4 // A composite particle class that holds other (daughter) particles.
7 loizides 1.1 //
8 loizides 1.2 // Authors: J.Bendavid, C.Loizides
9 loizides 1.1 //--------------------------------------------------------------------------------------------------
10    
11 loizides 1.12 #ifndef MITANA_DATATREE_COMPOSITEPARTICLE_H
12     #define MITANA_DATATREE_COMPOSITEPARTICLE_H
13 loizides 1.1
14 loizides 1.2 #include "MitAna/DataTree/interface/Types.h"
15 loizides 1.1 #include "MitAna/DataTree/interface/Particle.h"
16 loizides 1.11 #include "MitAna/DataCont/interface/RefArray.h"
17 loizides 1.1
18     namespace mithep
19     {
20     class CompositeParticle : public Particle
21     {
22     public:
23 loizides 1.10 CompositeParticle() {}
24 loizides 1.1
25 bendavid 1.19 void AddDaughter(const Particle *p) { fDaughters.Add(p); ClearMom(); ClearCharge(); }
26     void Clear(Option_t *opt="") { fDaughters.Clear(opt); ClearMom(); ClearCharge(); }
27 loizides 1.17 const Particle *Daughter(UInt_t i) const { return fDaughters.At(i); }
28     UInt_t NDaughters() const { return fDaughters.Entries(); }
29 loizides 1.9 Bool_t HasDaughter(const Particle *p) const;
30 loizides 1.2 Bool_t HasCommonDaughter(const CompositeParticle *p) const;
31     Bool_t HasSameDaughters(const CompositeParticle *p) const;
32 loizides 1.17 EObjType ObjType() const { return kCompositeParticle; }
33 loizides 1.5
34 loizides 1.1 protected:
35 loizides 1.18 Double_t GetCharge() const;
36     void GetMom() const;
37    
38 bendavid 1.19 RefArray<Particle> fDaughters; //references to daughter particles
39 loizides 1.1
40 loizides 1.2 ClassDef(CompositeParticle, 1) // Composite particle class
41 loizides 1.1 };
42     }
43 loizides 1.18
44     //--------------------------------------------------------------------------------------------------
45     inline Double_t mithep::CompositeParticle::GetCharge() const
46     {
47     // Return sum of charge of daughter particles.
48    
49     Double_t charge = 0;
50     for (UInt_t i=0; i<NDaughters(); ++i)
51     charge += Daughter(i)->Charge();
52    
53     return charge;
54     }
55    
56     //--------------------------------------------------------------------------------------------------
57     inline void mithep::CompositeParticle::GetMom() const
58     {
59     // Calculate the vector sum of the momenta of the daughters.
60    
61     FourVector mom;
62     for (UInt_t i=0; i<NDaughters(); ++i)
63     mom += (Daughter(i))->Mom();
64    
65     fCachedMom.SetCoordinates(mom.Pt(),mom.Eta(),mom.Phi(),mom.M());
66     }
67 loizides 1.1 #endif