ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/CompositeParticle.cc
(Generate patch)

Comparing UserCode/MitAna/DataTree/src/CompositeParticle.cc (file contents):
Revision 1.1 by loizides, Mon Jun 30 16:49:50 2008 UTC vs.
Revision 1.2 by loizides, Tue Jul 1 08:56:50 2008 UTC

# Line 2 | Line 2
2  
3   #include "MitAna/DataTree/interface/CompositeParticle.h"
4  
5
5   ClassImp(mithep::CompositeParticle)
6  
7   using namespace mithep;
8  
9 < Int_t CompositeParticle::Charge() const {
10 <        Int_t charge = 0;
11 <        for (Int_t i=0; i<GetDaughters()->GetEntries(); i++)
12 <                charge += ((Particle*)GetDaughters()->At(i))->Charge();
9 > //--------------------------------------------------------------------------------------------------
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          
32 <        return charge;
32 >  return kFALSE;
33   }
34  
35 < // Bool_t CompositeParticle::HasDaughter(const Particle* p) {
36 < //      if ( fDaughters.IndexOf(p) >= 0 )
37 < //              return true;
38 < //      else
22 < //              return false;
23 < // }
24 <
25 < Bool_t CompositeParticle::HasDaughter(const Particle* p) const {
26 <        if ( fDaughters.GetEntries() == 0 )
27 <                return false;
28 <
29 <        for (UInt_t i=0; i<fDaughters.GetEntries(); i++)
30 <                if (fDaughters.At(i)==p)
31 <                        return true;
35 > //--------------------------------------------------------------------------------------------------
36 > Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
37 > {
38 >  // Return true if daughters are the same.
39  
40 <        return false;
34 < }
40 >  if(!p) return kFALSE;
41  
42 < Bool_t CompositeParticle::HasSameDaughters(CompositeParticle* p) const {
43 <        if ( fDaughters.GetEntries() != p->GetDaughters()->GetEntries())
38 <                return false;
42 >  if (GetNDaughters()!= p->GetNDaughters())
43 >    return kFALSE;
44                  
45 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
46 <                if (!HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
47 <                        return false;
45 >  for (UInt_t i=0; i<p->GetNDaughters(); ++i)
46 >    if (!IsDaughter(p->GetDaughter(i)))
47 >        return kFALSE;
48          
49 <        return true;
49 >  return kTRUE;
50   }
51  
52 < Bool_t CompositeParticle::HasCommonDaughter(CompositeParticle* p) const {
53 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
54 <                if (HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
55 <                        return true;
56 <        
57 <        return false;
52 > //--------------------------------------------------------------------------------------------------
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   }
68  
69 < FourVector CompositeParticle::Mom() const {
70 <        FourVector mom;
71 <        for (Int_t i=0; i<GetDaughters()->GetEntries(); i++)
72 <                mom += ((Particle*)GetDaughters()->At(i))->Mom();
73 <        
74 <        return mom;
69 > //--------------------------------------------------------------------------------------------------
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines