evansPairCut.cxx 5.2 KB

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