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