1 |
// $Id: CompositeParticle.cc,v 1.4 2008/07/16 09:32:05 bendavid Exp $
|
2 |
|
3 |
#include "MitAna/DataTree/interface/CompositeParticle.h"
|
4 |
|
5 |
ClassImp(mithep::CompositeParticle)
|
6 |
|
7 |
using namespace mithep;
|
8 |
|
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 |
//--------------------------------------------------------------------------------------------------
|
22 |
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 |
if (!NDaughters())
|
29 |
return kFALSE;
|
30 |
|
31 |
for (UInt_t i=0; i<NDaughters(); ++i)
|
32 |
if (Daughter(i)==p)
|
33 |
return kTRUE;
|
34 |
|
35 |
return kFALSE;
|
36 |
}
|
37 |
|
38 |
//--------------------------------------------------------------------------------------------------
|
39 |
Bool_t CompositeParticle::HasCommonDaughter(const CompositeParticle *p) const
|
40 |
{
|
41 |
// Return true if a common daughter exists.
|
42 |
|
43 |
if(!p) return kFALSE;
|
44 |
|
45 |
for (UInt_t i=0; i<p->NDaughters(); ++i)
|
46 |
if (HasDaughter(p->Daughter(i)))
|
47 |
return kTRUE;
|
48 |
|
49 |
return kFALSE;
|
50 |
}
|
51 |
|
52 |
//--------------------------------------------------------------------------------------------------
|
53 |
Bool_t CompositeParticle::HasSameDaughters(const CompositeParticle* p) const
|
54 |
{
|
55 |
// Return true if daughters are the same.
|
56 |
|
57 |
if(!p) return kFALSE;
|
58 |
|
59 |
if (NDaughters()!= p->NDaughters())
|
60 |
return kFALSE;
|
61 |
|
62 |
for (UInt_t i=0; i<p->NDaughters(); ++i)
|
63 |
if (!HasDaughter(p->Daughter(i)))
|
64 |
return kFALSE;
|
65 |
|
66 |
return kTRUE;
|
67 |
}
|
68 |
|
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<NDaughters(); ++i)
|
76 |
mom += (Daughter(i))->Mom();
|
77 |
|
78 |
return mom;
|
79 |
}
|