StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StNuclei.cxx
1 #include "StNuclei.h"
2 #include "StRareTrack.h"
3 #include "StEventTypes.h"
4 #include <stdlib.h>
5 ClassImp(StNuclei)
6 
7 StNuclei::StNuclei(float plow,float phigh, int charge, int mass){
8  pcut[0] = plow;
9  pcut[1] = phigh;
10  chargeToAccept = charge;
11  minMass = mass;
12 }
13 
14 int StNuclei::Accept(StPrimaryTrack* trk){
15  int iret = 0;
16  int chargeOK = 0;
17  int dedxOK = 0;
18  int pOK=0;
19  StRareTrack track(trk);
20  if (chargeToAccept==0) {chargeOK = 1;}
21  else if (chargeToAccept<0 && track.chargesign()<0) {chargeOK=1;}
22  else if (chargeToAccept>0 && track.chargesign()>0) {chargeOK=1;}
23  float dedxmin;
24  int theCharge = 1;
25  if (abs(chargeToAccept)>1) theCharge=2;
26  float dedxExp =track.dedxExpected(minMass*0.939,theCharge);
27  dedxmin = 0.6*dedxExp; // within 40%
28  float dedx = track.dedx();
29  //now I want to elimate tracks that are too close to more common particles.
30  float dedxbad;
31  if (minMass>1) dedxbad = 1.1*track.dedxExpected((minMass-1)*0.939,theCharge);
32  if (minMass==1) dedxbad = 1.1*track.dedxExpected(0.494,1); //not kaon
33  if (dedx>dedxmin&&dedx>dedxbad) dedxOK=1;
34  float random_number = (float)rand()/(float)RAND_MAX;
35  // cout << "random number = " << random_number << endl;
36  if (random_number<0.005){dedxOK=1;} //randomly select particles
37  if (track.p()>pcut[0]&&track.p()<pcut[1]&&track.npntfit()>20&&track.iflag()>=0) pOK = 1;
38  // cout << "chargeOK = " << chargeOK << endl;
39  // cout << "dedxOK = " << dedxOK << endl;
40  // cout << "pOK = " << pOK << endl;
41  iret = chargeOK*dedxOK*pOK;
42  return iret;
43 }
44 void StNuclei::Report(){
45  cout << "StNuclei: charge = " << chargeToAccept << endl;
46  cout << "StNuclei: mass >= " << minMass << endl;
47  cout << "StNuclei: momentum > " << pcut << endl;
48 }