randomRotateEventCut.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /***************************************************************************
  2. *
  3. * $Id: randomRotateEventCut.cxx,v 1.2 2001/04/02 16:16:34 jeromel Exp $
  4. *
  5. * Author: Mike Lisa, Ohio State, lisa@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: randomRotateEventCut.cxx,v $
  15. * Revision 1.2 2001/04/02 16:16:34 jeromel
  16. * Type cast in sprintf() statement for bool conversion (insure++ issue)
  17. *
  18. * Revision 1.1 2000/05/25 21:47:27 laue
  19. * new event cut which can be used to rotate an event around the z-axis
  20. *
  21. *
  22. **************************************************************************/
  23. #include "StHbtMaker/Cut/randomRotateEventCut.h"
  24. #include "Randomize.h"
  25. #include "PhysicalConstants.h"
  26. #include "SystemOfUnits.h"
  27. #include <cstdio>
  28. #ifdef __ROOT__
  29. ClassImp(randomRotateEventCut)
  30. #endif
  31. randomRotateEventCut::randomRotateEventCut() : mRotation(true) {
  32. mNEventsPassed = mNEventsFailed = 0;
  33. engine = new HepRandom();
  34. }
  35. //------------------------------
  36. //randomRotateEventCut::~randomRotateEventCut(){
  37. // /* noop */
  38. //}
  39. //------------------------------
  40. bool randomRotateEventCut::Pass(const StHbtEvent* event){
  41. int mult;
  42. double VertexZPos;
  43. double angle;
  44. bool goodEvent = true;
  45. if ( event->TrackCollection()->size() + event->V0Collection()->size() > 0 ) {
  46. mult = event->NumberOfTracks();
  47. VertexZPos = event->PrimVertPos().z();
  48. goodEvent =
  49. ((mult > mEventMult[0]) &&
  50. (mult < mEventMult[1]) &&
  51. (VertexZPos > mVertZPos[0]) &&
  52. (VertexZPos < mVertZPos[1]));
  53. if (goodEvent && mRotation ) {
  54. angle = engine->flat()*2.*pi;
  55. ((StHbtEvent*)event)->RotateZ(angle);
  56. }
  57. goodEvent ? mNEventsPassed++ : mNEventsFailed++ ;
  58. }
  59. return (goodEvent);
  60. }
  61. //------------------------------
  62. StHbtString randomRotateEventCut::Report(){
  63. string Stemp="";
  64. char Ctemp[100];
  65. sprintf(Ctemp,"\n randomRotateEventCut:");
  66. Stemp += Ctemp;
  67. sprintf(Ctemp,"\n Rotation :\t %d",(int) mRotation);
  68. Stemp += Ctemp;
  69. sprintf(Ctemp,"\n Multiplicity:\t %d-%d",mEventMult[0],mEventMult[1]);
  70. Stemp += Ctemp;
  71. sprintf(Ctemp,"\n Vertex Z-position:\t %E-%E",mVertZPos[0],mVertZPos[1]);
  72. Stemp += Ctemp;
  73. sprintf(Ctemp,"\n Number of events which passed:\t%ld Number which failed:\t%ld",mNEventsPassed,mNEventsFailed);
  74. Stemp += Ctemp;
  75. StHbtString returnThis = Stemp;
  76. return returnThis;
  77. }