ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/CompoundParticle.h
Revision: 1.1
Committed: Thu Jun 11 12:21:26 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009a
Log Message:
Added CompoundParticle which is like a CompositeParticle except that it can own daughters. Clearly this class can only be used at analysis time since as implemented one can not store it in a tree.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2     // $Id: CompoundParticle.h,v 1.2 2009/06/10 06:27:50 loizides Exp $
3     //
4     // CompoundParticle
5     //
6     // A compound particle class that holds other (daughter) particles. The class provides
7     // the same features as the CompositeParticle but allows to transfer ownership of daughters.
8     // This class is cannot be stored in a tree.
9     //
10     // Authors: C.Loizides
11     //--------------------------------------------------------------------------------------------------
12    
13     #ifndef MITANA_DATATREE_COMPOUNDPARTICLE_H
14     #define MITANA_DATATREE_COMPOUNDPARTICLE_H
15    
16     #include "MitAna/DataTree/interface/Types.h"
17     #include "MitAna/DataTree/interface/Collections.h"
18    
19     namespace mithep
20     {
21     class CompoundParticle : public Particle
22     {
23     public:
24     CompoundParticle();
25     void AddDaughter(const Particle *p)
26     { fDaughters1.Add(p); ClearMom(); ClearCharge(); }
27     void AddDaughter(Particle *p, Bool_t owned);
28     void Clear(Option_t *opt="");
29     const Particle *Daughter(UInt_t i) const;
30     UInt_t NDaughters() const;
31     Bool_t HasDaughter(const Particle *p) const;
32     Bool_t HasCommonDaughter(const CompoundParticle *p) const;
33     Bool_t HasSameDaughters(const CompoundParticle *p) const;
34     EObjType ObjType() const { return kCompoundParticle; }
35    
36     protected:
37     Double_t GetCharge() const;
38     void GetMom() const;
39    
40     ParticleOArr fDaughters1; //daughter particles (not owned)
41     ParticleOArr fDaughters2; //daughter particles (owned)
42    
43     ClassDef(CompoundParticle, 1) // Compound particle class
44     };
45     }
46    
47     //--------------------------------------------------------------------------------------------------
48     inline void mithep::CompoundParticle::Clear(Option_t *opt)
49     {
50     // Clear object.
51    
52     fDaughters1.Clear(opt);
53     fDaughters2.Clear(opt);
54     ClearMom();
55     ClearCharge();
56     }
57    
58     //--------------------------------------------------------------------------------------------------
59     inline const mithep::Particle *mithep::CompoundParticle::Daughter(UInt_t i) const
60     {
61     // Return daughter at given index.
62    
63     if (i<fDaughters1.Entries())
64     return fDaughters1.At(i);
65    
66     return fDaughters2.At(i-fDaughters1.Entries());
67     }
68    
69     //--------------------------------------------------------------------------------------------------
70     inline Double_t mithep::CompoundParticle::GetCharge() const
71     {
72     // Return sum of charge of daughter particles.
73    
74     Double_t charge = 0;
75     for (UInt_t i=0; i<NDaughters(); ++i)
76     charge += Daughter(i)->Charge();
77    
78     return charge;
79     }
80    
81     //--------------------------------------------------------------------------------------------------
82     inline void mithep::CompoundParticle::GetMom() const
83     {
84     // Calculate the vector sum of the momenta of the daughters.
85    
86     FourVector mom;
87     for (UInt_t i=0; i<NDaughters(); ++i)
88     mom += (Daughter(i))->Mom();
89    
90     fCachedMom.SetCoordinates(mom.Pt(),mom.Eta(),mom.Phi(),mom.M());
91     }
92    
93     //--------------------------------------------------------------------------------------------------
94     inline UInt_t mithep::CompoundParticle::NDaughters() const
95     {
96     // Return number of daughters.
97    
98     return (fDaughters1.Entries()+fDaughters2.Entries());
99     }
100     #endif