Subversion Repositories f9daq

Rev

Rev 329 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 329 Rev 332
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
        case PHI:      return 1.02;
36
        case LAMBDA0:  return 1.115683;
36
        case LAMBDA0:  return 1.115683;
-
 
37
        case ALL:      return -1;
37
        default: return 0;
38
        default: return 0;
38
}      
39
}      
39
 
40
 
40
}
41
}
41
 
42
 
42
 float BParticle::GetMass ()
43
 float BParticle::GetMass ()
43
 {
44
 {
44
   float m2 = m_e * m_e-m_px * m_px-m_py * m_py-m_pz * m_pz;
45
   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
   if (m2<0) m2=0;
46
   return sqrt(m2);
47
   return sqrt(m2);
47
 }  
48
 }  
48
 
49
 
49
 void BParticle::SetEnergyFromMass (float mass)
50
 void BParticle::SetEnergyFromMass (float mass)
50
 {
51
 {
-
 
52
   if (mass<0) return;
51
   m_e = sqrt( mass * mass + m_px * m_px +m_py * m_py +m_pz * m_pz );
53
   m_e = sqrt( mass * mass + m_px * m_px +m_py * m_py +m_pz * m_pz );
52
   
54
   
53
 }
55
 }
54
 
56
 
55
void BParticle::SetEnergyFromPid(){
57
void BParticle::SetEnergyFromPid(){
56
        SetEnergyFromMass(GetMass(m_pid));
58
        SetEnergyFromMass(GetMass(m_pid));
57
}
59
}
58
 
60
 
59
int SelectParticles(TClonesArray *pin , int charge, SIMPLEPID type, TClonesArray *pout){
61
int SelectParticles(TClonesArray *pin , int charge, SIMPLEPID type, TClonesArray *pout){
60
  pout->Clear();
62
  pout->Clear();
61
  int nprt=0;
63
  int nprt=0;
62
 
64
 
63
  for(TIter next(pin); BParticle * p =(BParticle *) next();) {
65
  for(TIter next(pin); BParticle * p =(BParticle *) next();) {
64
        if (p->charge()== charge && p->pid()== type ) {
66
        if (p->charge()== charge && p->pid()== type ) {
65
          TClonesArray& list = *pout;
67
          TClonesArray& list = *pout;
66
          new (list[nprt++]) BParticle ( *p );
68
          new (list[nprt++]) BParticle ( *p );
67
        }
69
        }
68
  }      
70
  }      
69
  return nprt;  
71
  return nprt;  
70
}
72
}
71
 
73
 
72
int CombineParticles(TClonesArray *plist1 ,TClonesArray *plist2 , int same, float masslow, float massup, SIMPLEPID pid, TClonesArray *pout){
74
int CombineParticles(TClonesArray *plist1 ,TClonesArray *plist2 , int same, float masslow, float massup, SIMPLEPID pid, TClonesArray *pout){
73
 // Loop over all the particles in both lists.
75
 // Loop over all the particles in both lists.
74
 pout->Clear();
76
 pout->Clear();
75
 int nprt=0;
77
 int nprt=0;
76
 
78
 
77
 for(TIter next1(plist1);BParticle * p1 =(BParticle *) next1();) {
79
 for(TIter next1(plist1);BParticle * p1 =(BParticle *) next1();) {
78
    // the second loop 
80
    // the second loop 
79
   for( TIter next2 = (plist1!=plist2 && same==0) ?  TIter(plist2): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) {  
81
   for( TIter next2 = (plist1!=plist2 && same==0) ?  TIter(plist2): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) {  
80
      BParticle  p = *p1 + *p2; // Combine two particles into a new particle   
82
      BParticle  p = *p1 + *p2; // Combine two particles into a new particle   
81
      if (p.InMassRange(masslow, massup)){
83
      if (p.InMassRange(masslow, massup)){
82
            p.SetPid(pid);
84
            p.SetPid(pid);
83
                TClonesArray& list = *pout;
85
                TClonesArray& list = *pout;
84
            new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles
86
            new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles
85
      }
87
      }
86
       
88
       
87
   }
89
   }
88
               
90
               
89
 }
91
 }
90
 return nprt;
92
 return nprt;
91
}
93
}
92
 
94
 
93
 
95
 
94
 
96
 
95
 
97