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