StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StuCutEvent.cxx
1 //
3 // $Id: StuCutEvent.cxx,v 1.3 2003/09/02 17:58:09 perev Exp $
4 //
5 // Author: Art Poskanzer, LBNL, Dec 1999
6 //
7 // Description: Class for applying event cuts
8 //
10 //
11 // $Log: StuCutEvent.cxx,v $
12 // Revision 1.3 2003/09/02 17:58:09 perev
13 // gcc 3.2 updates + WarnOff
14 //
15 // Revision 1.2 1999/12/21 16:12:24 posk
16 // Updates.
17 //
18 // Revision 1.1 1999/12/17 00:07:03 posk
19 // Classes for StEvent cuts.
20 //
21 // Revision 1.0 posk
22 // First version of StEvent cut classes.
23 //
25 
26 #include <Stiostream.h>
27 #include <stdlib.h>
28 #include "StuCutEvent.hh"
29 #include "StuCutTrack.hh"
30 #include "StEvent.h"
31 #include "StEventTypes.h"
32 #include "PhysicalConstants.h"
33 #include "SystemOfUnits.h"
34 #include "StThreeVectorF.hh"
35 #define PR(x) cout << "##### CutEvent: " << (#x) << " = " << (x) << endl;
36 
37 ClassImp(StuCutEvent)
38 
39 //-----------------------------------------------------------------------
40 
41 Int_t StuCutEvent::mMultCuts[2] = {10, 10000};
42 Float_t StuCutEvent::mVertexXCuts[2] = {-1., 1.};
43 Float_t StuCutEvent::mVertexYCuts[2] = {-1., 1.};
44 Float_t StuCutEvent::mVertexZCuts[2] = {-30., 30.};
45 UInt_t StuCutEvent::mEventN = 0;
46 UInt_t StuCutEvent::mGoodEventN = 0;
47 UInt_t StuCutEvent::mMultCut = 0;
48 UInt_t StuCutEvent::mVertexXCut = 0;
49 UInt_t StuCutEvent::mVertexYCut = 0;
50 UInt_t StuCutEvent::mVertexZCut = 0;
51 Float_t StuCutEvent::mEtaSymCuts[2] = {-0.1, 0.1};
52 UInt_t StuCutEvent::mEtaSymCutN = 0;
53 
54 //-----------------------------------------------------------------------
55 
56 StuCutEvent::StuCutEvent() {
57  // To apply event cuts
58 }
59 
60 //-----------------------------------------------------------------------
61 
62 StuCutEvent::~StuCutEvent() {
63 }
64 
65 //-----------------------------------------------------------------------
66 
67 Int_t StuCutEvent::CheckEvent(StEvent* pEvent) {
68  // Returns kTRUE if the event survives all the cuts
69 
70  mEventN++;
71 
72  // Number of primary vertices
73  Long_t nvtx = pEvent->numberOfPrimaryVertices();
74  if (nvtx == 0) return kFALSE;
75 
76  // have to add a mechanism to select the most relevant primary
77  // vertex and use only this one (for now only one vertex is assumed)
78 
79  StPrimaryVertex* pVertex = pEvent->primaryVertex(0);
80  if (!pVertex) return kFALSE;
81 
82  // Multiplicity
83  Long_t mult = pVertex->numberOfDaughters();
84  if (mMultCuts[1] > mMultCuts[0] &&
85  (mult < mMultCuts[0] || mult >= mMultCuts[1])) {
86  mMultCut++;
87  return kFALSE;
88  }
89 
90  const StThreeVectorF& vertex = pVertex->position();
91 
92  // Vertex x
93  Float_t vertexX = vertex.x();
94  if (mVertexXCuts[1] > mVertexXCuts[0] &&
95  (vertexX < mVertexXCuts[0] || vertexX >= mVertexXCuts[1])) {
96  mVertexXCut++;
97  return kFALSE;
98  }
99 
100  // Vertex y
101  Float_t vertexY = vertex.y();
102  if (mVertexYCuts[1] > mVertexYCuts[0] &&
103  (vertexY < mVertexYCuts[0] || vertexY >= mVertexYCuts[1])) {
104  mVertexYCut++;
105  return kFALSE;
106  }
107 
108  // Vertex z
109  Float_t vertexZ = vertex.z();
110  if (mVertexZCuts[1] > mVertexZCuts[0] &&
111  (vertexZ < mVertexZCuts[0] || vertexZ >= mVertexZCuts[1])) {
112  mVertexZCut++;
113  return kFALSE;
114  }
115 
116  mGoodEventN++;
117  return kTRUE;
118 }
119 
120 //-----------------------------------------------------------------------
121 
122 Int_t StuCutEvent::CheckEtaSymmetry() {
123  // Returns kTRUE if the event survives this Eta symmetry cut
124  // Call at the end of the event after doing CheckTrack for each track
125  // If kFALSE you should delete the last event
126 
127  Float_t mEtaSymPosN = (float)StuCutTrack::EtaSymPos();
128  Float_t mEtaSymNegN = (float)StuCutTrack::EtaSymNeg();
129  Float_t EtaSym = (mEtaSymPosN - mEtaSymNegN) /
130  (mEtaSymPosN + mEtaSymNegN);
131  StuCutTrack::EtaSymClear();
132  if (mEtaSymCuts[1] > mEtaSymCuts[0] &&
133  (EtaSym < mEtaSymCuts[0] || EtaSym >= mEtaSymCuts[1])) {
134  mEtaSymCutN++;
135  mGoodEventN--;
136  return kFALSE;
137  }
138 
139  return kTRUE;
140 }
141 
142 //-----------------------------------------------------------------------
143 
144 void StuCutEvent::PrintCutList() {
145  // Prints the list of cuts
146 
147  cout << "#######################################################" << endl;
148  cout << "# Total Events= " << mEventN << endl;
149  cout << "# Event Cut List:" << endl;
150  cout << "# Mult cuts= " << mMultCuts[0] << ", " << mMultCuts[1]
151  << " :\t Events Cut= " << mMultCut << endl;
152  cout << "# VertexX cuts= " << mVertexXCuts[0] << ", " << mVertexXCuts[1]
153  << " :\t Events Cut= " << mVertexXCut << endl;
154  cout << "# VertexY cuts= " << mVertexYCuts[0] << ", " << mVertexYCuts[1]
155  << " :\t Events Cut= " << mVertexYCut << endl;
156  cout << "# VertexZ cuts= " << mVertexZCuts[0] << ", " << mVertexZCuts[1]
157  << " :\t Events Cut= " << mVertexZCut << endl;
158  cout << "# Eta Symmetry cuts= " << mEtaSymCuts[0] << ", " << mEtaSymCuts[1]
159  << " :\t " << setprecision(4) << (float)mEtaSymCutN/(float)mEventN/perCent
160  << "% cut" << endl;
161  cout << "# Good Events = " << mGoodEventN << ", " << setprecision(4) <<
162  (float)mGoodEventN/(float)mEventN/perCent << "%" << endl;
163  cout << "#######################################################" << endl;
164 
165 }