ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/CompositeParticle.cc
Revision: 1.5
Committed: Wed Jul 16 18:56:49 2008 UTC (16 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006b, Mit_006a, Mit_006, Mit_005, Mit_004, MITHEP_2_0_x
Changes since 1.4: +20 -20 lines
Log Message:
Revert to HasDaughter.

File Contents

# User Rev Content
1 loizides 1.5 // $Id: CompositeParticle.cc,v 1.4 2008/07/16 09:32:05 bendavid Exp $
2 loizides 1.1
3     #include "MitAna/DataTree/interface/CompositeParticle.h"
4    
5     ClassImp(mithep::CompositeParticle)
6    
7     using namespace mithep;
8    
9 loizides 1.2 //--------------------------------------------------------------------------------------------------
10 bendavid 1.4 Double_t CompositeParticle::Charge() const
11 loizides 1.2 {
12     // Return sum of charge of daughter particles.
13    
14 bendavid 1.4 Double_t charge = 0;
15 loizides 1.3 for (UInt_t i=0; i<NDaughters(); ++i)
16     charge += Daughter(i)->Charge();
17 loizides 1.2
18     return charge;
19     }
20    
21     //--------------------------------------------------------------------------------------------------
22 loizides 1.5 Bool_t CompositeParticle::HasDaughter(const Particle* p) const
23     {
24     // Return true if given particle is among daughters.
25    
26     if(!p) return kFALSE;
27    
28     if (!NDaughters())
29     return kFALSE;
30    
31     for (UInt_t i=0; i<NDaughters(); ++i)
32     if (Daughter(i)==p)
33     return kTRUE;
34    
35     return kFALSE;
36     }
37    
38     //--------------------------------------------------------------------------------------------------
39 loizides 1.2 Bool_t CompositeParticle::HasCommonDaughter(const CompositeParticle *p) const
40     {
41     // Return true if a common daughter exists.
42    
43     if(!p) return kFALSE;
44    
45 loizides 1.3 for (UInt_t i=0; i<p->NDaughters(); ++i)
46 loizides 1.5 if (HasDaughter(p->Daughter(i)))
47 loizides 1.2 return kTRUE;
48 loizides 1.1
49 loizides 1.2 return kFALSE;
50 loizides 1.1 }
51    
52 loizides 1.2 //--------------------------------------------------------------------------------------------------
53     Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
54     {
55     // Return true if daughters are the same.
56 loizides 1.1
57 loizides 1.2 if(!p) return kFALSE;
58 loizides 1.1
59 loizides 1.3 if (NDaughters()!= p->NDaughters())
60 loizides 1.2 return kFALSE;
61 loizides 1.1
62 loizides 1.3 for (UInt_t i=0; i<p->NDaughters(); ++i)
63 loizides 1.5 if (!HasDaughter(p->Daughter(i)))
64 loizides 1.2 return kFALSE;
65 loizides 1.1
66 loizides 1.2 return kTRUE;
67 loizides 1.1 }
68    
69 loizides 1.2 //--------------------------------------------------------------------------------------------------
70     FourVector CompositeParticle::Mom() const
71     {
72     // Return the vector sum of the momenta of the daughters.
73    
74     FourVector mom;
75 loizides 1.3 for (UInt_t i=0; i<NDaughters(); ++i)
76     mom += (Daughter(i))->Mom();
77 loizides 1.2
78     return mom;
79 loizides 1.1 }