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.6 by bendavid, Wed Feb 18 08:18:36 2009 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();
13 <        
14 <        return charge;
9 > //--------------------------------------------------------------------------------------------------
10 > Double_t CompositeParticle::Charge() const
11 > {
12 >  // Return sum of charge of daughter particles.
13 >
14 >  Double_t charge = 0;
15 >  for (UInt_t i=0; i<NDaughters(); ++i)
16 >    charge += Daughter(i)->Charge();
17 >  
18 >  return charge;
19   }
20  
21 < // Bool_t CompositeParticle::HasDaughter(const Particle* p) {
22 < //      if ( fDaughters.IndexOf(p) >= 0 )
23 < //              return true;
24 < //      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;
21 > //--------------------------------------------------------------------------------------------------
22 > Bool_t CompositeParticle::HasDaughter(const Particle* p) const
23 > {
24 >  // Return true if given particle is among daughters.
25  
26 <        return false;
26 >  if(!p) return kFALSE;
27 >
28 >  return fDaughters.HasObject(p);
29   }
30  
31 < Bool_t CompositeParticle::HasSameDaughters(CompositeParticle* p) const {
32 <        if ( fDaughters.GetEntries() != p->GetDaughters()->GetEntries())
33 <                return false;
34 <                
35 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
36 <                if (!HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
37 <                        return false;
31 > //--------------------------------------------------------------------------------------------------
32 > 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 >  for (UInt_t i=0; i<p->NDaughters(); ++i)
39 >    if (HasDaughter(p->Daughter(i)))
40 >      return kTRUE;
41          
42 <        return true;
42 >  return kFALSE;
43   }
44  
45 < Bool_t CompositeParticle::HasCommonDaughter(CompositeParticle* p) const {
46 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
47 <                if (HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
48 <                        return true;
45 > //--------------------------------------------------------------------------------------------------
46 > Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
47 > {
48 >  // Return true if daughters are the same.
49 >
50 >  if(!p) return kFALSE;
51 >
52 >  if (NDaughters()!= p->NDaughters())
53 >    return kFALSE;
54 >                
55 >  for (UInt_t i=0; i<p->NDaughters(); ++i)
56 >    if (!HasDaughter(p->Daughter(i)))
57 >        return kFALSE;
58          
59 <        return false;
59 >  return kTRUE;
60   }
61  
62 < FourVector CompositeParticle::Mom() const {
63 <        FourVector mom;
64 <        for (Int_t i=0; i<GetDaughters()->GetEntries(); i++)
65 <                mom += ((Particle*)GetDaughters()->At(i))->Mom();
66 <        
67 <        return mom;
62 > //--------------------------------------------------------------------------------------------------
63 > FourVector CompositeParticle::Mom() const
64 > {
65 >  // Return the vector sum of the momenta of the daughters.
66 >
67 >  FourVector mom;
68 >  for (UInt_t i=0; i<NDaughters(); ++i)
69 >    mom += (Daughter(i))->Mom();
70 >  
71 >  return mom;
72   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines