ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/CompositeParticle.cc
Revision: 1.2
Committed: Tue Jul 1 08:56:50 2008 UTC (16 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.1: +60 -42 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.2 // $Id: CompositeParticle.cc,v 1.1 2008/06/30 16:49:50 loizides 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     Int_t CompositeParticle::Charge() const
11     {
12     // Return sum of charge of daughter particles.
13    
14     Int_t charge = 0;
15     for (UInt_t i=0; i<GetNDaughters(); ++i)
16     charge += GetDaughter(i)->Charge();
17    
18     return charge;
19     }
20    
21     //--------------------------------------------------------------------------------------------------
22     Bool_t CompositeParticle::HasCommonDaughter(const CompositeParticle *p) const
23     {
24     // Return true if a common daughter exists.
25    
26     if(!p) return kFALSE;
27    
28     for (UInt_t i=0; i<p->GetNDaughters(); ++i)
29     if (IsDaughter(p->GetDaughter(i)))
30     return kTRUE;
31 loizides 1.1
32 loizides 1.2 return kFALSE;
33 loizides 1.1 }
34    
35 loizides 1.2 //--------------------------------------------------------------------------------------------------
36     Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
37     {
38     // Return true if daughters are the same.
39 loizides 1.1
40 loizides 1.2 if(!p) return kFALSE;
41 loizides 1.1
42 loizides 1.2 if (GetNDaughters()!= p->GetNDaughters())
43     return kFALSE;
44 loizides 1.1
45 loizides 1.2 for (UInt_t i=0; i<p->GetNDaughters(); ++i)
46     if (!IsDaughter(p->GetDaughter(i)))
47     return kFALSE;
48 loizides 1.1
49 loizides 1.2 return kTRUE;
50 loizides 1.1 }
51    
52 loizides 1.2 //--------------------------------------------------------------------------------------------------
53     Bool_t CompositeParticle::IsDaughter(const Particle* p) const
54     {
55     // Return true if given particle is among daughters.
56    
57     if(!p) return kFALSE;
58    
59     if (!GetNDaughters())
60     return kFALSE;
61    
62     for (UInt_t i=0; i<GetNDaughters(); ++i)
63     if (GetDaughter(i)==p)
64     return kTRUE;
65    
66     return kFALSE;
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     for (UInt_t i=0; i<GetNDaughters(); ++i)
76     mom += (GetDaughter(i))->Mom();
77    
78     return mom;
79 loizides 1.1 }