1 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
loizides |
1.2 |
// $Id: CompoundParticle.h,v 1.1 2009/06/11 12:21:26 loizides Exp $
|
3 |
loizides |
1.1 |
//
|
4 |
|
|
// CompoundParticle
|
5 |
|
|
//
|
6 |
|
|
// A compound particle class that holds other (daughter) particles. The class provides
|
7 |
|
|
// the same features as the CompositeParticle but allows to transfer ownership of daughters.
|
8 |
loizides |
1.2 |
// This class is not supposed and can not be stored in a tree.
|
9 |
loizides |
1.1 |
//
|
10 |
|
|
// Authors: C.Loizides
|
11 |
|
|
//--------------------------------------------------------------------------------------------------
|
12 |
|
|
|
13 |
|
|
#ifndef MITANA_DATATREE_COMPOUNDPARTICLE_H
|
14 |
|
|
#define MITANA_DATATREE_COMPOUNDPARTICLE_H
|
15 |
|
|
|
16 |
|
|
#include "MitAna/DataTree/interface/Types.h"
|
17 |
loizides |
1.2 |
#include "MitAna/DataTree/interface/ParticleCol.h"
|
18 |
loizides |
1.1 |
|
19 |
|
|
namespace mithep
|
20 |
|
|
{
|
21 |
|
|
class CompoundParticle : public Particle
|
22 |
|
|
{
|
23 |
|
|
public:
|
24 |
|
|
CompoundParticle();
|
25 |
|
|
void AddDaughter(const Particle *p)
|
26 |
|
|
{ fDaughters1.Add(p); ClearMom(); ClearCharge(); }
|
27 |
|
|
void AddDaughter(Particle *p, Bool_t owned);
|
28 |
|
|
void Clear(Option_t *opt="");
|
29 |
|
|
const Particle *Daughter(UInt_t i) const;
|
30 |
|
|
UInt_t NDaughters() const;
|
31 |
|
|
Bool_t HasDaughter(const Particle *p) const;
|
32 |
|
|
Bool_t HasCommonDaughter(const CompoundParticle *p) const;
|
33 |
|
|
Bool_t HasSameDaughters(const CompoundParticle *p) const;
|
34 |
|
|
EObjType ObjType() const { return kCompoundParticle; }
|
35 |
|
|
|
36 |
|
|
protected:
|
37 |
|
|
Double_t GetCharge() const;
|
38 |
|
|
void GetMom() const;
|
39 |
|
|
|
40 |
|
|
ParticleOArr fDaughters1; //daughter particles (not owned)
|
41 |
|
|
ParticleOArr fDaughters2; //daughter particles (owned)
|
42 |
|
|
|
43 |
|
|
ClassDef(CompoundParticle, 1) // Compound particle class
|
44 |
|
|
};
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
//--------------------------------------------------------------------------------------------------
|
48 |
|
|
inline void mithep::CompoundParticle::Clear(Option_t *opt)
|
49 |
|
|
{
|
50 |
|
|
// Clear object.
|
51 |
|
|
|
52 |
|
|
fDaughters1.Clear(opt);
|
53 |
|
|
fDaughters2.Clear(opt);
|
54 |
|
|
ClearMom();
|
55 |
|
|
ClearCharge();
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
//--------------------------------------------------------------------------------------------------
|
59 |
|
|
inline const mithep::Particle *mithep::CompoundParticle::Daughter(UInt_t i) const
|
60 |
|
|
{
|
61 |
|
|
// Return daughter at given index.
|
62 |
|
|
|
63 |
|
|
if (i<fDaughters1.Entries())
|
64 |
|
|
return fDaughters1.At(i);
|
65 |
|
|
|
66 |
|
|
return fDaughters2.At(i-fDaughters1.Entries());
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
//--------------------------------------------------------------------------------------------------
|
70 |
|
|
inline Double_t mithep::CompoundParticle::GetCharge() const
|
71 |
|
|
{
|
72 |
|
|
// Return sum of charge of daughter particles.
|
73 |
|
|
|
74 |
|
|
Double_t charge = 0;
|
75 |
|
|
for (UInt_t i=0; i<NDaughters(); ++i)
|
76 |
|
|
charge += Daughter(i)->Charge();
|
77 |
|
|
|
78 |
|
|
return charge;
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
//--------------------------------------------------------------------------------------------------
|
82 |
|
|
inline void mithep::CompoundParticle::GetMom() const
|
83 |
|
|
{
|
84 |
|
|
// Calculate the vector sum of the momenta of the daughters.
|
85 |
|
|
|
86 |
|
|
FourVector mom;
|
87 |
|
|
for (UInt_t i=0; i<NDaughters(); ++i)
|
88 |
|
|
mom += (Daughter(i))->Mom();
|
89 |
|
|
|
90 |
|
|
fCachedMom.SetCoordinates(mom.Pt(),mom.Eta(),mom.Phi(),mom.M());
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
//--------------------------------------------------------------------------------------------------
|
94 |
|
|
inline UInt_t mithep::CompoundParticle::NDaughters() const
|
95 |
|
|
{
|
96 |
|
|
// Return number of daughters.
|
97 |
|
|
|
98 |
|
|
return (fDaughters1.Entries()+fDaughters2.Entries());
|
99 |
|
|
}
|
100 |
|
|
#endif
|