ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/CompositeParticle.cc
Revision: 1.6
Committed: Wed Feb 18 08:18:36 2009 UTC (16 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.5: +2 -9 lines
Log Message:
Optimized HasDaughter function

File Contents

# User Rev Content
1 bendavid 1.6 // $Id: CompositeParticle.cc,v 1.5 2008/07/16 18:56:49 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 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 bendavid 1.6 return fDaughters.HasObject(p);
29 loizides 1.5 }
30    
31     //--------------------------------------------------------------------------------------------------
32 loizides 1.2 Bool_t CompositeParticle::HasCommonDaughter(const CompositeParticle *p) const
33     {
34     // Return true if a common daughter exists.
35    
36     if(!p) return kFALSE;
37    
38 loizides 1.3 for (UInt_t i=0; i<p->NDaughters(); ++i)
39 loizides 1.5 if (HasDaughter(p->Daughter(i)))
40 loizides 1.2 return kTRUE;
41 loizides 1.1
42 loizides 1.2 return kFALSE;
43 loizides 1.1 }
44    
45 loizides 1.2 //--------------------------------------------------------------------------------------------------
46     Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
47     {
48     // Return true if daughters are the same.
49 loizides 1.1
50 loizides 1.2 if(!p) return kFALSE;
51 loizides 1.1
52 loizides 1.3 if (NDaughters()!= p->NDaughters())
53 loizides 1.2 return kFALSE;
54 loizides 1.1
55 loizides 1.3 for (UInt_t i=0; i<p->NDaughters(); ++i)
56 loizides 1.5 if (!HasDaughter(p->Daughter(i)))
57 loizides 1.2 return kFALSE;
58 loizides 1.1
59 loizides 1.2 return kTRUE;
60 loizides 1.1 }
61    
62 loizides 1.2 //--------------------------------------------------------------------------------------------------
63     FourVector CompositeParticle::Mom() const
64     {
65     // Return the vector sum of the momenta of the daughters.
66    
67     FourVector mom;
68 loizides 1.3 for (UInt_t i=0; i<NDaughters(); ++i)
69     mom += (Daughter(i))->Mom();
70 loizides 1.2
71     return mom;
72 loizides 1.1 }