StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
evansPairCut.cxx
1 #include "StHbtMaker/Cut/evansPairCut.h"
2 #include <string>
3 #include <cstdio>
4 
5 #ifdef __ROOT__
6 ClassImp(evansPairCut)
7 #endif
8 
9 //__________________
10 evansPairCut::evansPairCut(){
11  mNPairsPassed = mNPairsFailed = 0;
12  AngleCut = 0.020;
13  pCutDistance = 0.010;
14  Bfield = 0.5; // B-field in Tesla
15 }
16 //__________________
17 //evansPairCut::~evansPairCut(){
18 // /* no-op */
19 //}
20 //__________________
21 bool evansPairCut::Pass(const StHbtPair* pair){
22 
23  return true;
24 }
25 void evansPairCut::ParityPairCuts(ParityBuff *Plus, ParityBuff *Minus){
26  // _________________________________________________________________________
27  // here we compare three quantities for each pair-
28  // The first is do the pair have the same sign
29  // for p(z)-if not we don't make the other comparisons (this is to save time as the other cuts are
30  // more time consuming.
31  // The second is a comparison of the two tracks momentum. Two tracks with identical production angle
32  //but different transverse momentum (p1 and p2 in GeV/c) will by traversing a magnetic field of B Tesla
33  //be seperated at a radius of .5 meters by (to first order) DIST = ([(.5)**][.3*B]/2)(1/p1-1/p2). The effective
34  // DIST is the parameter which is set (assuming the B-field is know) as pCutDistance
35  // If the tracks are close enough in momentum, we go on to the third (and slowest) cut. If the opening angle
36  //between the tracks is less than the adjustable parameter 'AngleCut' the tracks are rejected.
37  // Any two tracks that fail all three cuts are removed from the sample entirely.
38  // ______________________________________________________________________
39 
40  StHbtThreeVector FirstTrack;
41  StHbtThreeVector SecondTrack;
42  vector <int> PlusIsGood;
43  vector <int> MinusIsGood;
44 
45  double cosSqAngleCut = cos(AngleCut)*cos(AngleCut);
46 
47  int newPlusSize = Plus->size();
48  int newMinusSize = Minus->size();
49 
50  double pCut = (pCutDistance*2.0)/( (0.5)*(0.5)*(0.3)*Bfield);
51 
52  cout <<"begin evans Pair Cut "<< newPlusSize<< " plus and "<< newMinusSize<<" minus tracks"<< endl;
53 
54  {for (int jjj = 0; jjj < newPlusSize; jjj++){
55  PlusIsGood.push_back(1);
56  }}
57  {for (int jjj = 0; jjj < newMinusSize; jjj++){
58  MinusIsGood.push_back(1);
59  }}
60 
61  // loop over all combinations of plus and minus tracks, flagging any pairs that are too close
62  double FdotS;
63  {for (int bbb = 0; bbb < newPlusSize; bbb++){
64  FirstTrack = ((*Plus)[bbb]).vect();
65  {for (int hhh = 0; hhh < newMinusSize; hhh++){
66  SecondTrack = ((*Minus)[hhh]).vect();
67  if (FirstTrack.z()*SecondTrack.z() > 0. ){
68  FdotS = FirstTrack.dot(SecondTrack);
69  if ( ( (FdotS*FdotS) / (FirstTrack.mag2()* SecondTrack.mag2()) > cosSqAngleCut ) && (FdotS > 0 ) ){
70  if (fabs(1.0/FirstTrack.mag()-1.0/SecondTrack.mag()) < pCut){
71  PlusIsGood[bbb] = 0;
72  MinusIsGood[hhh] = 0;
73  }
74  }
75  }
76  }}
77  }}
78 
79  // now check plus vectors with other plus vectors
80 
81  {for (int bbb = 0; bbb < newPlusSize; bbb++){
82  FirstTrack = ((*Plus)[bbb]).vect();
83  {for (int hhh = (bbb+1); hhh < newPlusSize; hhh++){
84  SecondTrack = ((*Plus)[hhh]).vect();
85  if (FirstTrack.z()*SecondTrack.z() > 0. ){
86  FdotS = FirstTrack.dot(SecondTrack);
87  if ( ( (FdotS*FdotS) / (FirstTrack.mag2()* SecondTrack.mag2()) > cosSqAngleCut ) && (FdotS > 0 ) ){
88  if (fabs(1.0/FirstTrack.mag()-1.0/SecondTrack.mag()) < pCut){
89  PlusIsGood[bbb] = 0;
90  PlusIsGood[hhh] = 0;
91  }
92  }
93  }
94  }}
95  }}
96 
97  // now check minus vectors with other minus vectors
98 
99  {for (int bbb = 0; bbb < newMinusSize; bbb++){
100  FirstTrack = ((*Minus)[bbb]).vect();
101  {for (int hhh = (bbb+1); hhh < newMinusSize; hhh++){
102  SecondTrack = ((*Minus)[hhh]).vect();
103  if (FirstTrack.z()*SecondTrack.z() > 0. ){
104  FdotS = FirstTrack.dot(SecondTrack);
105  if ( ( (FdotS*FdotS) / (FirstTrack.mag2()* SecondTrack.mag2()) > cosSqAngleCut ) && (FdotS > 0 ) ){
106  if (fabs(1.0/FirstTrack.mag()-1.0/SecondTrack.mag()) < pCut){
107  MinusIsGood[bbb] = 0;
108  MinusIsGood[hhh] = 0;
109  }
110  }
111  }
112  }}
113  }}
114 
115  // now remove the 'bad' tracks from the 'plus' and 'minus' vectors
116 
117  unsigned int jjj = 0;
118  while (jjj < (*Plus).size()){
119  if (PlusIsGood[jjj]==0){
120  (*Plus).erase((*Plus).begin()+jjj);
121  PlusIsGood.erase(PlusIsGood.begin()+jjj);
122  }
123  else{
124  jjj++;
125  }
126  }
127  jjj = 0;
128  while (jjj < (*Minus).size()){
129  if (MinusIsGood[jjj]==0){
130  (*Minus).erase((*Minus).begin()+jjj);
131  MinusIsGood.erase(MinusIsGood.begin()+jjj);
132  }
133  else{
134  jjj++;
135  }
136  }
137 
138  // clean up
139 
140  PlusIsGood.clear();
141  MinusIsGood.clear();
142 
143  cout << "end evans Pair Cut with "<< (*Plus).size()<< " plus and "<< (*Minus).size() <<" minus tracks"<< endl;
144 
145 }
146 //__________________
147 StHbtString evansPairCut::Report(){
148  string Stemp = "evans Pair Cut Report\n";
149  // char Ctemp[100];
150  // sprintf(Ctemp,"Open angle Cut of \t%f radians and distance cut o:\t%f (assuming B field of \t%f Tesla \n",AngleCut,pCutDistance,Bfield);
151  // Stemp += Ctemp;
152  StHbtString returnThis = Stemp;
153  return returnThis;
154 }
155 //__________________