StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventSummary.cxx
1 /***************************************************************************
2  *
3  * $Id: StEventSummary.cxx,v 2.11 2009/11/23 16:34:06 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, July 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEventSummary.cxx,v $
13  * Revision 2.11 2009/11/23 16:34:06 fisyak
14  * Cleanup, remove dependence on dst tables, clean up software monitors
15  *
16  * Revision 2.10 2001/05/30 17:45:54 perev
17  * StEvent branching
18  *
19  * Revision 2.9 2001/05/17 22:56:33 ullrich
20  * Removed all usage of dst_summary_param.
21  *
22  * Revision 2.8 2001/04/05 04:00:49 ullrich
23  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
24  *
25  * Revision 2.7 2000/01/31 12:01:00 ullrich
26  * Unique const_cast syntax for all platforms.
27  *
28  * Revision 2.6 2000/01/25 15:31:47 fisyak
29  * Add namespace for CC5
30  *
31  * Revision 2.5 2000/01/14 19:06:47 ullrich
32  * Made code more robust if read-in table is not well defined.
33  *
34  * Revision 2.4 2000/01/11 16:11:40 ullrich
35  * Magnetic field in kGauss.
36  *
37  * Revision 2.3 1999/12/21 15:08:50 ullrich
38  * Modified to cope with new compiler version on Sun (CC5.0).
39  *
40  * Revision 2.2 1999/10/28 22:25:13 ullrich
41  * Adapted new StArray version. First version to compile on Linux and Sun.
42  *
43  * Revision 2.1 1999/10/13 19:44:35 ullrich
44  * Initial Revision
45  *
46  **************************************************************************/
47 #include <algorithm>
48 #include <float.h>
49 #include "StEventSummary.h"
50 #include "SystemOfUnits.h"
51 #ifndef ST_NO_NAMESPACES
52 using units::tesla;
53 using units::degree;
54 #endif
55 
56 static const char rcsid[] = "$Id: StEventSummary.cxx,v 2.11 2009/11/23 16:34:06 fisyak Exp $";
57 
58 ClassImp(StEventSummary)
59 
61 {
62  initBinRanges();
63 
64  mNumberOfTracks = 0;
65  mNumberOfGoodTracks = 0;
66  mNumberOfGoodPrimaryTracks = 0;
67  mNumberOfPositiveTracks = 0;
68  mNumberOfNegativeTracks = 0;
69  mNumberOfExoticTracks = 0;
70  mNumberOfVertices = 0;
71  mNumberOfVertexTypes.Set(mVertexTypeArraySize);
72  mNumberOfPileupVertices = 0;
73  mMeanPt = 0;
74  mMeanPt2 = 0;
75  mMeanEta = 0;
76  mRmsEta = 0;
77 
78  mEtaBins.Set(mPtAndEtaBinsSize);
79  mPtBins.Set(mPtAndEtaBinsSize);
80  mPhiBins.Set(mPhiBinsSize);
81 
82  mEtaOfTracksHisto.Set(mHistogramSize);
83  mPtOfTracksHisto.Set(mHistogramSize);
84  mPhiOfTracksHisto.Set(mHistogramSize);
85  mEneryVsEtaHisto.Set(mHistogramSize);
86  mEnergyVsPhiHisto.Set(mHistogramSize);
87  mMagneticFieldZ = 0;
88 }
89 
90 
91 StEventSummary::~StEventSummary() { /* noop */ }
92 
93 void StEventSummary::Clear( Option_t * opt ){
94  mNumberOfVertexTypes.Set(0);
95  mEtaBins.Set(0);
96  mPtBins.Set(0);
97  mPhiBins.Set(0);
98  mEtaOfTracksHisto.Set(0);
99  mPtOfTracksHisto.Set(0);
100  mPhiOfTracksHisto.Set(0);
101  mEneryVsEtaHisto.Set(0);
102  mEnergyVsPhiHisto.Set(0);
103 }
104 
105 void
106 StEventSummary::initBinRanges()
107 {
108  mVertexTypeArraySize = 5;
109  mPhiBinsSize = 10;
110  mPtAndEtaBinsSize = 9;
111  mHistogramSize = 10;
112 
113  mEtaBins.Set(mPtAndEtaBinsSize);
114  mPtBins.Set(mPtAndEtaBinsSize);
115  mPhiBins.Set(mPhiBinsSize);
116 
117  mEtaBins[0] = -2.;
118  mEtaBins[1] = -1.;
119  mEtaBins[2] = -0.5;
120  mEtaBins[3] = .5;
121  mEtaBins[4] = 1.;
122  mEtaBins[5] = 2.;
123  mEtaBins[6] = 2.;
124  mEtaBins[7] = 2.;
125  mEtaBins[8] = 2.;
126 
127  mPtBins[0] = 0.1;
128  mPtBins[1] = 0.15;
129  mPtBins[2] = 0.2;
130  mPtBins[3] = 0.3;
131  mPtBins[4] = 0.5;
132  mPtBins[5] = 1.;
133  mPtBins[6] = 1.;
134  mPtBins[7] = 1.;
135  mPtBins[8] = 1.;
136 
137  mPhiBins[0] = 0*degree;
138  mPhiBins[1] = 36*degree;
139  mPhiBins[2] = 72*degree;
140  mPhiBins[3] = 108*degree;
141  mPhiBins[4] = 144*degree;
142  mPhiBins[5] = 180*degree;
143  mPhiBins[6] = 216*degree;
144  mPhiBins[7] = 252*degree;
145  mPhiBins[8] = 288*degree;
146  mPhiBins[9] = 324*degree;
147 }
148 
149 int StEventSummary::numberOfTracks() const { return mNumberOfTracks; }
150 
151 int StEventSummary::numberOfGoodTracks() const { return mNumberOfGoodTracks; }
152 
153 int StEventSummary::numberOfGoodTracks(StChargeSign s) const
154 {
155  return s == negative ? mNumberOfNegativeTracks : mNumberOfPositiveTracks;
156 }
157 
158 int
159 StEventSummary::numberOfGoodPrimaryTracks() const { return mNumberOfGoodPrimaryTracks; }
160 
161 int
162 StEventSummary::numberOfExoticTracks() const { return mNumberOfExoticTracks; }
163 
164 int
165 StEventSummary::numberOfVertices() const { return mNumberOfVertices; }
166 
167 int
168 StEventSummary::numberOfVerticesOfType(StVertexId id) const
169 {
170  unsigned int i = id-1; // vector numbering scheme starts at 1
171  if (i < mVertexTypeArraySize)
172  return const_cast<TArrayL&>(mNumberOfVertexTypes)[i];
173  else
174  return 0;
175 }
176 
177 int
178 StEventSummary::numberOfPileupVertices() const { return mNumberOfPileupVertices; }
179 
180 float
181 StEventSummary::meanPt() const { return mMeanPt; }
182 
183 float
184 StEventSummary::meanPt2() const { return mMeanPt2; }
185 
186 float
187 StEventSummary::meanEta() const { return mMeanEta; }
188 
189 float
190 StEventSummary::rmsEta() const { return mRmsEta; }
191 
192 const StThreeVectorF&
193 StEventSummary::primaryVertexPosition() const { return mPrimaryVertexPos; }
194 
195 unsigned int
196 StEventSummary::numberOfBins() const { return mHistogramSize; }
197 
198 int
199 StEventSummary::tracksInEtaBin(unsigned int i) const
200 {
201  return i < mHistogramSize ? const_cast<TArrayL&>(mEtaOfTracksHisto)[i] : 0;
202 }
203 
204 int
205 StEventSummary::tracksInPhiBin(unsigned int i) const
206 {
207  return i < mHistogramSize ? const_cast<TArrayL&>(mPhiOfTracksHisto)[i] : 0;
208 }
209 
210 int
211 StEventSummary::tracksInPtBin(unsigned int i) const
212 {
213  return i < mHistogramSize ? const_cast<TArrayL&>(mPtOfTracksHisto)[i] : 0;
214 }
215 
216 float
217 StEventSummary::energyInEtaBin(unsigned int i) const
218 {
219  return i < mHistogramSize ? const_cast<TArrayF&>(mEneryVsEtaHisto)[i] : 0;
220 }
221 
222 float
223 StEventSummary::energyInPhiBin(unsigned int i) const
224 {
225  return i < mHistogramSize ? const_cast<TArrayF&>(mEnergyVsPhiHisto)[i] : 0;
226 }
227 
228 float
229 StEventSummary::lowerEdgeEtaBin(unsigned int i) const
230 {
231  if (i <= mPtAndEtaBinsSize) {
232  if (i == 0)
233  return -FLT_MAX; // no lower limit
234  else
235  return const_cast<TArrayF&>(mEtaBins)[i-1];
236  }
237  else
238  return 0;
239 }
240 
241 float
242 StEventSummary::upperEdgeEtaBin(unsigned int i) const
243 {
244  if (i <= mPtAndEtaBinsSize) {
245  if (i == mPtAndEtaBinsSize)
246  return FLT_MAX;
247  else
248  return const_cast<TArrayF&>(mEtaBins)[i];
249  }
250  else
251  return 0;
252 }
253 
254 float
255 StEventSummary::lowerEdgePtBin(unsigned int i) const
256 {
257  if (i <= mPtAndEtaBinsSize) {
258  if (i == 0)
259  return 0;
260  else
261  return const_cast<TArrayF&>(mPtBins)[i-1];
262  }
263  else
264  return 0;
265 }
266 
267 float
268 StEventSummary::upperEdgePtBin(unsigned int i) const
269 {
270  if (i <= mPtAndEtaBinsSize) {
271  if (i == mPtAndEtaBinsSize)
272  return FLT_MAX;
273  else
274  return const_cast<TArrayF&>(mPtBins)[i];
275  }
276  else
277  return 0;
278 }
279 
280 float
281 StEventSummary::lowerEdgePhiBin(unsigned int i) const
282 {
283  if (i < mPhiBinsSize)
284  return const_cast<TArrayF&>(mPhiBins)[i];
285  else
286  return 0;
287 }
288 
289 float
290 StEventSummary::upperEdgePhiBin(unsigned int i) const
291 {
292  if (i < mPhiBinsSize) {
293  if ((int)i == mPhiBinsSize-1)
294  return const_cast<TArrayF&>(mPhiBins)[0];
295  else
296  return const_cast<TArrayF&>(mPhiBins)[i+1];
297  }
298  else
299  return 0;
300 }
301 
302 void
303 StEventSummary::setNumberOfTracks(int val) { mNumberOfTracks = val; }
304 
305 void
306 StEventSummary::setNumberOfGoodTracks(int val) { mNumberOfGoodTracks = val; }
307 
308 void
309 StEventSummary::setNumberOfGoodTracks(StChargeSign s, int val)
310 {
311  if (s == negative)
312  mNumberOfNegativeTracks = val;
313  else
314  mNumberOfPositiveTracks = val;
315 }
316 
317 void
318 StEventSummary::setNumberOfGoodPrimaryTracks(int val) { mNumberOfGoodPrimaryTracks = val; }
319 
320 void
321 StEventSummary::setNumberOfExoticTracks( int val) { mNumberOfExoticTracks = val; }
322 
323 void
324 StEventSummary::setNumberOfVertices(int val) { mNumberOfVertices = val; }
325 
326 void
327 StEventSummary::setNumberOfVerticesForType(StVertexId id, int val)
328 {
329  int i = id-1;
330  if (i < mVertexTypeArraySize)
331  mNumberOfVertexTypes[i] = val;
332 }
333 
334 void
335 StEventSummary::setNumberOfPileupVertices(int val) { mNumberOfPileupVertices = val; }
336 
337 void
338 StEventSummary::setMeanPt(float val) { mMeanPt = val; }
339 
340 void
341 StEventSummary::setMeanPt2(float val) { mMeanPt2 = val; }
342 
343 void
344 StEventSummary::setMeanEta(float val) { mMeanEta = val; }
345 
346 void
347 StEventSummary::setRmsEta(float val) { mRmsEta = val; }
348 
349 void
350 StEventSummary::setPrimaryVertexPosition(const StThreeVectorF& val) { mPrimaryVertexPos = val; }
351 
352 double
353 StEventSummary::magneticField() const { return mMagneticFieldZ; }
354 
355 void
356 StEventSummary::setMagneticField(double val) { mMagneticFieldZ = val; }