StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rotationEventCut.cxx
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 
30 #include "StHbtMaker/Cut/rotationEventCut.h"
31 #include "Randomize.h"
32 #include "PhysicalConstants.h"
33 #include "SystemOfUnits.h"
34 #include "StHbtParticle.hh"
35 #include "StHbtPair.hh"
36 #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
37 
38 #include <cstdio>
39 
40 #ifdef __ROOT__
41 ClassImp(rotationEventCut)
42 #endif
43 
44 rotationEventCut::rotationEventCut() : mRotation(false), mRandom(false), mSmear(0), mL3TriggerAlgorithm(0) {
45  mNEventsPassed = mNEventsFailed = 0;
46  mEventRefMult[0] = 0; mEventRefMult[1] = 100000;
47  mEventMult[0] = 0; mEventMult[1] = 100000;
48  mEventMultGood[0] = 0; mEventMultGood[1] = 100000;
49  mNumberOfTracks[0] = 0; mNumberOfTracks[1] = 100000;
50  mNumberOfV0s[0] = 0; mNumberOfV0s[1] = 100000;
51  mReactionPlaneError[0]=-10.; mReactionPlaneError[1]=+10.;
52 
53  engine = new HepJamesRandom();
54  gauss = new RandGauss(engine);
55 }
56 //------------------------------
57 //rotationEventCut::~rotationEventCut(){
58 // /* noop */
59 //}
60 //------------------------------
61 bool rotationEventCut::Pass(const StHbtEvent* event){
62  int refMult,mult,multGood;
63  double VertexZPos;
64  double angle;
65  double smear;
66  bool goodEvent = true;
67 
68  refMult = event->UncorrectedNumberOfNegativePrimaries();
69  mult = event->NumberOfTracks();
70  multGood = event->NumberOfGoodTracks();
71 // cout << " rotationEventCut::Pass(...) refMult=" << refMult << " mult=" << mult << " multGood=" << multGood << endl;
72 // cout << " rotationEventCut::Pass(...) mNumberOfV0s[0] event->V0Collection()->size() mNumberOfV0s[0] ";
73 // cout << mNumberOfV0s[0] << " " << event->V0Collection()->size() << " " << mNumberOfV0s[1] << endl;
74 
75  VertexZPos = event->PrimVertPos().z();
76  goodEvent =
77  (
78  (refMult >= mEventRefMult[0]) &&
79  (refMult <= mEventRefMult[1]) &&
80  (mult >= mEventMult[0]) &&
81  (mult <= mEventMult[1]) &&
82  (multGood >= mEventMultGood[0]) &&
83  (multGood <= mEventMultGood[1]) &&
84  (event->ReactionPlaneError() >= mReactionPlaneError[0]) &&
85  (event->ReactionPlaneError() <= mReactionPlaneError[1]) &&
86  ((int)event->TrackCollection()->size() >= mNumberOfTracks[0]) &&
87  ((int)event->TrackCollection()->size() <= mNumberOfTracks[1]) &&
88  ((int)event->V0Collection()->size() >= mNumberOfV0s[0]) &&
89  ((int)event->V0Collection()->size() <= mNumberOfV0s[1])
90  );
91 
92  if (mL3TriggerAlgorithm) goodEvent = goodEvent && (mL3TriggerAlgorithm & event->L3TriggerAlgorithm(0));
93 
94  if ( mVertZPos[0] < mVertZPos[1])
95  goodEvent = goodEvent && ( (VertexZPos >= mVertZPos[0]) && (VertexZPos <= mVertZPos[1]) );
96  else {
97  goodEvent = goodEvent && !( (VertexZPos >= mVertZPos[0]) && (VertexZPos <= mVertZPos[1]) );
98  cout << " rotationEventCut::Pass(const StHbtEvent* event) : upper limit < lower limit - inverting the cut" << endl;
99  }
100 
101  if (goodEvent && mRotation ) {
102  angle = gauss->shoot()*2.*pi; // gaussian
103  ((StHbtEvent*)event)->RotateZ(-1.* event->ReactionPlane() + angle);
104  }
105 
106  if (goodEvent && mRandom ) {
107  angle = engine->flat()*2.*pi;
108  ((StHbtEvent*)event)->RotateZ(angle);
109  }
110 
111  if (goodEvent && mSmear!=0 ) {
112  smear = gauss->shoot()*mSmear/360.*2*pi; // gaussian
113  ((StHbtEvent*)event)->RotateZ(smear);
114  }
115 
116 
117  if (event->PrimVertPos().x() == event->PrimVertPos().y() == event->PrimVertPos().z() ) {
118  for ( int i=0; i<50; i++) cout << " rotationEventCut::Pass(...) - flagged bad from embedding " << endl;
119  goodEvent = false;
120  }
121 
122  // if ( event->TrackCollection()->size() + event->V0Collection()->size() > 0 ) goodEvent=false;
123 
124 
125  goodEvent ? mNEventsPassed++ : mNEventsFailed++ ;
126 
127 
128  return (goodEvent);
129 }
130 
131 //------------------------------
132 StHbtString rotationEventCut::Report(){
133  string Stemp="";
134  char Ctemp[100];
135  sprintf(Ctemp,"rotationEventCut: ");
136  Stemp += Ctemp;
137  sprintf(Ctemp,"\n Rotation :\t %d",mRotation);
138  Stemp += Ctemp;
139  sprintf(Ctemp,"\n Random :\t %d",mRandom);
140  Stemp += Ctemp;
141  sprintf(Ctemp,"\n Smear :\t %E",mSmear);
142  Stemp += Ctemp;
143  sprintf(Ctemp,"\n Reference Multiplicity:\t %d-%d",mEventRefMult[0],mEventRefMult[1]);
144  Stemp += Ctemp;
145  sprintf(Ctemp,"\n Multiplicity:\t %d-%d",mEventMult[0],mEventMult[1]);
146  Stemp += Ctemp;
147  sprintf(Ctemp,"\n Multiplicity good tracks:\t %d-%d",mEventMultGood[0],mEventMultGood[1]);
148  Stemp += Ctemp;
149  sprintf(Ctemp,"\n NumberOfTracks:\t %d-%d",mNumberOfTracks[0],mNumberOfTracks[1]);
150  Stemp += Ctemp;
151  sprintf(Ctemp,"\n NumberOfV0s:\t %d-%d",mNumberOfV0s[0],mNumberOfV0s[1]);
152  Stemp += Ctemp;
153  sprintf(Ctemp,"\n Vertex Z-position:\t %E-%E",mVertZPos[0],mVertZPos[1]);
154  Stemp += Ctemp;
155  sprintf(Ctemp,"\n Number of events which passed:\t%ld Number which failed:\t%ld",mNEventsPassed,mNEventsFailed);
156  Stemp += Ctemp;
157  StHbtString returnThis = Stemp;
158  return returnThis;
159 }