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.8 by loizides, Fri Mar 20 18:23:27 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();
14 <        
15 <        return charge;
16 < }
9 > //--------------------------------------------------------------------------------------------------
10 > Bool_t CompositeParticle::HasDaughter(const Particle *p) const
11 > {
12 >  // Return true if given particle is among daughters.
13  
14 < // Bool_t CompositeParticle::HasDaughter(const Particle* p) {
19 < //      if ( fDaughters.IndexOf(p) >= 0 )
20 < //              return true;
21 < //      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;
14 >  if(!p) return kFALSE;
15  
16 <        return false;
16 >  return fDaughters.HasObject(p);
17   }
18  
19 < Bool_t CompositeParticle::HasSameDaughters(CompositeParticle* p) const {
20 <        if ( fDaughters.GetEntries() != p->GetDaughters()->GetEntries())
21 <                return false;
22 <                
23 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
24 <                if (!HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
25 <                        return false;
19 > //--------------------------------------------------------------------------------------------------
20 > Bool_t CompositeParticle::HasCommonDaughter(const CompositeParticle *p) const
21 > {
22 >  // Return true if a common daughter exists.
23 >
24 >  if(!p) return kFALSE;
25 >
26 >  for (UInt_t i=0; i<p->NDaughters(); ++i)
27 >    if (HasDaughter(p->Daughter(i)))
28 >      return kTRUE;
29          
30 <        return true;
30 >  return kFALSE;
31   }
32  
33 < Bool_t CompositeParticle::HasCommonDaughter(CompositeParticle* p) const {
34 <        for (Int_t i=0; i<p->GetDaughters()->GetEntries();i++)
35 <                if (HasDaughter( (Particle*)p->GetDaughters()->At(i) ) )
36 <                        return true;
51 <        
52 <        return false;
53 < }
33 > //--------------------------------------------------------------------------------------------------
34 > Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle *p) const
35 > {
36 >  // Return true if daughters are the same.
37  
38 < FourVector CompositeParticle::Mom() const {
39 <        FourVector mom;
40 <        for (Int_t i=0; i<GetDaughters()->GetEntries(); i++)
41 <                mom += ((Particle*)GetDaughters()->At(i))->Mom();
38 >  if(!p) return kFALSE;
39 >
40 >  if (NDaughters()!= p->NDaughters())
41 >    return kFALSE;
42 >                
43 >  for (UInt_t i=0; i<p->NDaughters(); ++i)
44 >    if (!HasDaughter(p->Daughter(i)))
45 >        return kFALSE;
46          
47 <        return mom;
47 >  return kTRUE;
48   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines