rotationEventCut.cxx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /***************************************************************************
  2. *
  3. * $Id: rotationEventCut.cxx,v 1.4 2001/12/05 15:13:22 laue Exp $
  4. *
  5. * Author: Frank Laue, Ohio State, laue@mps.ohio-state.edu
  6. ***************************************************************************
  7. *
  8. * Description: part of STAR HBT Framework: StHbtMaker package
  9. * A simple event-wise cut that selects on multiplicity and z-position
  10. * of primary vertex and rotates the event around the z-axis
  11. *
  12. ***************************************************************************
  13. *
  14. * $Log: rotationEventCut.cxx,v $
  15. * Revision 1.4 2001/12/05 15:13:22 laue
  16. * rotationEventCut.h: cut on l3 trigger algorithm
  17. * franksXiCut.cxx: updates
  18. *
  19. * Revision 1.3 2001/06/21 19:09:44 laue
  20. * updated to match changed base classes
  21. *
  22. * Revision 1.1 2000/06/14 18:22:33 laue
  23. * New event cut
  24. *
  25. * Revision 1.1 2000/05/25 21:47:28 laue
  26. * new event cut which can be used to rotate an event around the z-axis
  27. *
  28. **************************************************************************/
  29. #include "StHbtMaker/Cut/rotationEventCut.h"
  30. #include "Randomize.h"
  31. #include "PhysicalConstants.h"
  32. #include "SystemOfUnits.h"
  33. #include "StHbtParticle.hh"
  34. #include "StHbtPair.hh"
  35. #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
  36. #include <cstdio>
  37. #ifdef __ROOT__
  38. ClassImp(rotationEventCut)
  39. #endif
  40. rotationEventCut::rotationEventCut() : mRotation(false), mRandom(false), mSmear(0), mL3TriggerAlgorithm(0) {
  41. mNEventsPassed = mNEventsFailed = 0;
  42. mEventRefMult[0] = 0; mEventRefMult[1] = 100000;
  43. mEventMult[0] = 0; mEventMult[1] = 100000;
  44. mEventMultGood[0] = 0; mEventMultGood[1] = 100000;
  45. mNumberOfTracks[0] = 0; mNumberOfTracks[1] = 100000;
  46. mNumberOfV0s[0] = 0; mNumberOfV0s[1] = 100000;
  47. mReactionPlaneError[0]=-10.; mReactionPlaneError[1]=+10.;
  48. engine = new HepJamesRandom();
  49. gauss = new RandGauss(engine);
  50. }
  51. //------------------------------
  52. //rotationEventCut::~rotationEventCut(){
  53. // /* noop */
  54. //}
  55. //------------------------------
  56. bool rotationEventCut::Pass(const StHbtEvent* event){
  57. int refMult,mult,multGood;
  58. double VertexZPos;
  59. double angle;
  60. double smear;
  61. bool goodEvent = true;
  62. refMult = event->UncorrectedNumberOfNegativePrimaries();
  63. mult = event->NumberOfTracks();
  64. multGood = event->NumberOfGoodTracks();
  65. // cout << " rotationEventCut::Pass(...) refMult=" << refMult << " mult=" << mult << " multGood=" << multGood << endl;
  66. // cout << " rotationEventCut::Pass(...) mNumberOfV0s[0] event->V0Collection()->size() mNumberOfV0s[0] ";
  67. // cout << mNumberOfV0s[0] << " " << event->V0Collection()->size() << " " << mNumberOfV0s[1] << endl;
  68. VertexZPos = event->PrimVertPos().z();
  69. goodEvent =
  70. (
  71. (refMult >= mEventRefMult[0]) &&
  72. (refMult <= mEventRefMult[1]) &&
  73. (mult >= mEventMult[0]) &&
  74. (mult <= mEventMult[1]) &&
  75. (multGood >= mEventMultGood[0]) &&
  76. (multGood <= mEventMultGood[1]) &&
  77. (event->ReactionPlaneError() >= mReactionPlaneError[0]) &&
  78. (event->ReactionPlaneError() <= mReactionPlaneError[1]) &&
  79. ((int)event->TrackCollection()->size() >= mNumberOfTracks[0]) &&
  80. ((int)event->TrackCollection()->size() <= mNumberOfTracks[1]) &&
  81. ((int)event->V0Collection()->size() >= mNumberOfV0s[0]) &&
  82. ((int)event->V0Collection()->size() <= mNumberOfV0s[1])
  83. );
  84. if (mL3TriggerAlgorithm) goodEvent = goodEvent && (mL3TriggerAlgorithm & event->L3TriggerAlgorithm(0));
  85. if ( mVertZPos[0] < mVertZPos[1])
  86. goodEvent = goodEvent && ( (VertexZPos >= mVertZPos[0]) && (VertexZPos <= mVertZPos[1]) );
  87. else {
  88. goodEvent = goodEvent && !( (VertexZPos >= mVertZPos[0]) && (VertexZPos <= mVertZPos[1]) );
  89. cout << " rotationEventCut::Pass(const StHbtEvent* event) : upper limit < lower limit - inverting the cut" << endl;
  90. }
  91. if (goodEvent && mRotation ) {
  92. angle = gauss->shoot()*2.*pi; // gaussian
  93. ((StHbtEvent*)event)->RotateZ(-1.* event->ReactionPlane() + angle);
  94. }
  95. if (goodEvent && mRandom ) {
  96. angle = engine->flat()*2.*pi;
  97. ((StHbtEvent*)event)->RotateZ(angle);
  98. }
  99. if (goodEvent && mSmear!=0 ) {
  100. smear = gauss->shoot()*mSmear/360.*2*pi; // gaussian
  101. ((StHbtEvent*)event)->RotateZ(smear);
  102. }
  103. if (event->PrimVertPos().x() == event->PrimVertPos().y() == event->PrimVertPos().z() ) {
  104. for ( int i=0; i<50; i++) cout << " rotationEventCut::Pass(...) - flagged bad from embedding " << endl;
  105. goodEvent = false;
  106. }
  107. // if ( event->TrackCollection()->size() + event->V0Collection()->size() > 0 ) goodEvent=false;
  108. goodEvent ? mNEventsPassed++ : mNEventsFailed++ ;
  109. return (goodEvent);
  110. }
  111. //------------------------------
  112. StHbtString rotationEventCut::Report(){
  113. string Stemp="";
  114. char Ctemp[100];
  115. sprintf(Ctemp,"rotationEventCut: ");
  116. Stemp += Ctemp;
  117. sprintf(Ctemp,"\n Rotation :\t %d",mRotation);
  118. Stemp += Ctemp;
  119. sprintf(Ctemp,"\n Random :\t %d",mRandom);
  120. Stemp += Ctemp;
  121. sprintf(Ctemp,"\n Smear :\t %E",mSmear);
  122. Stemp += Ctemp;
  123. sprintf(Ctemp,"\n Reference Multiplicity:\t %d-%d",mEventRefMult[0],mEventRefMult[1]);
  124. Stemp += Ctemp;
  125. sprintf(Ctemp,"\n Multiplicity:\t %d-%d",mEventMult[0],mEventMult[1]);
  126. Stemp += Ctemp;
  127. sprintf(Ctemp,"\n Multiplicity good tracks:\t %d-%d",mEventMultGood[0],mEventMultGood[1]);
  128. Stemp += Ctemp;
  129. sprintf(Ctemp,"\n NumberOfTracks:\t %d-%d",mNumberOfTracks[0],mNumberOfTracks[1]);
  130. Stemp += Ctemp;
  131. sprintf(Ctemp,"\n NumberOfV0s:\t %d-%d",mNumberOfV0s[0],mNumberOfV0s[1]);
  132. Stemp += Ctemp;
  133. sprintf(Ctemp,"\n Vertex Z-position:\t %E-%E",mVertZPos[0],mVertZPos[1]);
  134. Stemp += Ctemp;
  135. sprintf(Ctemp,"\n Number of events which passed:\t%ld Number which failed:\t%ld",mNEventsPassed,mNEventsFailed);
  136. Stemp += Ctemp;
  137. StHbtString returnThis = Stemp;
  138. return returnThis;
  139. }