Rev 267 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 267 | Rev 271 | ||
---|---|---|---|
1 | //+ |
1 | //+ |
2 | // File : BParticle.cc |
2 | // File : BParticle.cc |
3 | // Description : Implementation of BTrack class // |
3 | // Description : Implementation of BTrack class // |
4 | //- |
4 | //- |
5 | 5 | ||
6 | #include "BParticle.h" |
6 | #include "BParticle.h" |
7 | 7 | ||
8 | ClassImp (BParticle) |
8 | ClassImp (BParticle) |
9 | 9 | ||
10 | 10 | ||
11 | BParticle::BParticle ( float px, float py, float pz, float e, |
11 | BParticle::BParticle ( float px, float py, float pz, float e, |
12 | float charge, SIMPLEPID pid ) { |
12 | float charge, SIMPLEPID pid ) { |
13 | m_px = px; |
13 | m_px = px; |
14 | m_py = py; |
14 | m_py = py; |
15 | m_pz = pz; |
15 | m_pz = pz; |
16 | m_e = e; |
16 | m_e = e; |
17 | m_charge = charge; |
17 | m_charge = charge; |
18 | m_pid = pid; |
18 | m_pid = pid; |
19 | } |
19 | } |
20 | 20 | ||
21 | 21 | ||
22 | float BParticle::GetMass(SIMPLEPID pid){ |
22 | float BParticle::GetMass(SIMPLEPID pid){ |
23 | 23 | ||
24 | switch (pid){ |
24 | switch (pid){ |
25 | case PHOTON: return 0; |
25 | case PHOTON: return 0; |
26 | case ELECTRON: return 0.51; |
26 | case ELECTRON: return 0.51; |
27 | case PION: return 0.139; |
27 | case PION: return 0.139; |
28 | case MUON: return 0.105; |
28 | case MUON: return 0.105; |
29 | case KAON: return 0.497; |
29 | case KAON: return 0.497; |
30 | case PROTON: return 0.938; |
30 | case PROTON: return 0.938; |
31 | case JPSI: return 3.1; |
31 | case JPSI: return 3.1; |
32 | case D: return 1.86; |
32 | case D: return 1.86; |
33 | case DSTAR: return 2.01; |
33 | case DSTAR: return 2.01; |
34 | case B: return 5.27; |
34 | case B: return 5.27; |
- | 35 | case PHI: return 1.02; |
|
35 | default: return 0; |
36 | default: return 0; |
36 | } |
37 | } |
37 | 38 | ||
38 | } |
39 | } |
39 | 40 | ||
40 | float BParticle::GetMass () |
41 | float BParticle::GetMass () |
41 | { |
42 | { |
42 | float m2 = m_e * m_e-m_px * m_px-m_py * m_py-m_pz * m_pz; |
43 | float m2 = m_e * m_e-m_px * m_px-m_py * m_py-m_pz * m_pz; |
43 | if (m2<0) m2=0; |
44 | if (m2<0) m2=0; |
44 | return sqrt(m2); |
45 | return sqrt(m2); |
45 | } |
46 | } |
46 | 47 | ||
47 | void BParticle::SetEnergyFromMass (float mass) |
48 | void BParticle::SetEnergyFromMass (float mass) |
48 | { |
49 | { |
49 | m_e = sqrt( mass * mass + m_px * m_px +m_py * m_py +m_pz * m_pz ); |
50 | m_e = sqrt( mass * mass + m_px * m_px +m_py * m_py +m_pz * m_pz ); |
50 | 51 | ||
51 | } |
52 | } |
52 | 53 | ||
53 | void BParticle::SetEnergyFromPid(){ |
54 | void BParticle::SetEnergyFromPid(){ |
54 | SetEnergyFromMass(GetMass(m_pid)); |
55 | SetEnergyFromMass(GetMass(m_pid)); |
55 | } |
56 | } |
56 | 57 | ||
57 | int SelectParticles(TClonesArray *pin , int charge, SIMPLEPID type, TClonesArray *pout){ |
58 | int SelectParticles(TClonesArray *pin , int charge, SIMPLEPID type, TClonesArray *pout){ |
58 | pout->Clear(); |
59 | pout->Clear(); |
59 | int nprt=0; |
60 | int nprt=0; |
60 | 61 | ||
61 | for(TIter next(pin); BParticle * p =(BParticle *) next();) { |
62 | for(TIter next(pin); BParticle * p =(BParticle *) next();) { |
62 | if (p->charge()== charge && p->pid()== type ) { |
63 | if (p->charge()== charge && p->pid()== type ) { |
63 | TClonesArray& list = *pout; |
64 | TClonesArray& list = *pout; |
64 | new (list[nprt++]) BParticle ( *p ); |
65 | new (list[nprt++]) BParticle ( *p ); |
65 | } |
66 | } |
66 | } |
67 | } |
67 | return nprt; |
68 | return nprt; |
68 | } |
69 | } |
69 | 70 | ||
70 | int CombineParticles(TClonesArray *plist1 ,TClonesArray *plist2 , int same, float masslow, float massup, SIMPLEPID pid, TClonesArray *pout){ |
71 | int CombineParticles(TClonesArray *plist1 ,TClonesArray *plist2 , int same, float masslow, float massup, SIMPLEPID pid, TClonesArray *pout){ |
71 | // Loop over all the particles in both lists. |
72 | // Loop over all the particles in both lists. |
72 | pout->Clear(); |
73 | pout->Clear(); |
73 | int nprt=0; |
74 | int nprt=0; |
74 | 75 | ||
75 | for(TIter next1(plist1);BParticle * p1 =(BParticle *) next1();) { |
76 | for(TIter next1(plist1);BParticle * p1 =(BParticle *) next1();) { |
76 | // the second loop |
77 | // the second loop |
77 | for( TIter next2 = (plist1!=plist2 && same==0) ? TIter(plist2): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) { |
78 | for( TIter next2 = (plist1!=plist2 && same==0) ? TIter(plist2): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) { |
78 | BParticle p = *p1 + *p2; // Combine two particles into a new particle |
79 | BParticle p = *p1 + *p2; // Combine two particles into a new particle |
79 | if (p.InMassRange(masslow, massup)){ |
80 | if (p.InMassRange(masslow, massup)){ |
80 | p.SetPid(pid); |
81 | p.SetPid(pid); |
81 | TClonesArray& list = *pout; |
82 | TClonesArray& list = *pout; |
82 | new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles |
83 | new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles |
83 | } |
84 | } |
84 | 85 | ||
85 | } |
86 | } |
86 | 87 | ||
87 | } |
88 | } |
88 | return nprt; |
89 | return nprt; |
89 | } |
90 | } |
90 | 91 | ||
91 | 92 | ||
92 | 93 | ||
93 | 94 |