StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StStrangeEvMuDst.cc
1 /***********************************************************************
2  *
3  * $Id: StStrangeEvMuDst.cc,v 3.7 2003/02/10 16:00:29 genevb Exp $
4  *
5  * Authors: Gene Van Buren, UCLA, 24-Mar-2000
6  * Peter G. Jones, University of Birmingham, 19-Aug-1999
7  *
8  ***********************************************************************
9  *
10  * Description: Strangeness event micro dst class
11  *
12  ***********************************************************************
13  *
14  * $Log: StStrangeEvMuDst.cc,v $
15  * Revision 3.7 2003/02/10 16:00:29 genevb
16  * Implement cleared events
17  *
18  * Revision 3.6 2002/05/17 14:05:28 genevb
19  * Added L3 unbiased trigger info
20  *
21  * Revision 3.5 2002/04/30 16:02:47 genevb
22  * Common muDst, improved MC code, better kinks, StrangeCuts now a branch
23  *
24  * Revision 3.4 2001/11/05 23:41:06 genevb
25  * Add more dEdx, B field info, careful of changes to TTree unrolling
26  *
27  * Revision 3.3 2001/08/23 13:20:54 genevb
28  * Many bug workarounds...
29  *
30  * Revision 3.2 2001/05/04 20:15:14 genevb
31  * Common interfaces and reorganization of components, add MC event info
32  *
33  * Revision 3.1 2000/09/07 02:22:56 genevb
34  * Now using STAR standard uncorrected primary track multiplicity
35  *
36  * Revision 3.0 2000/07/14 12:56:49 genevb
37  * Revision 3 has event multiplicities and dedx information for vertex tracks
38  *
39  * Revision 2.0 2000/06/02 22:11:54 genevb
40  * New version of Strangeness micro DST package
41  *
42  * Revision 1.3 2000/03/31 03:20:24 jones
43  * Added topology map to V0/Xi; access funcs for each data member
44  *
45  * Revision 1.2 2000/03/29 20:52:13 genevb
46  * Added StKinkMuDst, replaced arrays
47  *
48  * Revision 1.1 2000/03/29 03:10:07 genevb
49  * Introduction of Strangeness Micro DST package
50  *
51  *
52  ***********************************************************************/
53 #include "StStrangeEvMuDst.hh"
54 #include "StEventTypes.h"
55 #include "StMcEventTypes.hh"
56 #include "StuRefMult.hh"
57 #include "StMessMgr.h"
58 #include "TArrayF.h"
59 
60 
61 static TArrayF uncorBinMean, corBinMean, corError;
62 static TArrayF fracTracks, fracSigma, fracError;
63 
64 ClassImp(StStrangeEvMuDst)
65 
67 }
68 
69 void StStrangeEvMuDst::Fill(StEvent& event) {
70 
71  mRun = event.runId();
72  mEvent = event.id();
73  StEventSummary* evSum = event.summary();
74  if (evSum) mMagneticField = evSum->magneticField();
75  else mMagneticField = 0.;
76  StTrigger* L0trig = event.l0Trigger();
77  if (L0trig) mL0TriggerWord = L0trig->triggerWord();
78  else mL0TriggerWord = 0;
79 
80  // Assign mEvent a negative vaule for L3-biased events
81  StL3Trigger* L3trig = event.l3Trigger();
82  if (L3trig) {
83  StL3EventSummary* L3summary = L3trig->l3EventSummary();
84  if ((L3summary) && !(L3summary->unbiasedTrigger())) mEvent = -mEvent;
85  }
86 
87  mGlobalTracks = 0;
88  StSPtrVecTrackNode& theNodes = event.trackNodes();
89  for (unsigned int i=0; i<theNodes.size(); i++) {
90  for (unsigned int j=0; j<theNodes[i]->entries(global); j++) {
91  if (theNodes[i]->track(global,j)->flag() > 0)
92  mGlobalTracks++;
93  }
94  }
95 
96  StPrimaryVertex* primaryVertex = event.primaryVertex();
97  if( primaryVertex ) {
98  mPrimaryVertexX = primaryVertex->position().x();
99  mPrimaryVertexY = primaryVertex->position().y();
100  mPrimaryVertexZ = primaryVertex->position().z();
101  mPrimaryNegTracks = uncorrectedNumberOfNegativePrimaries(event);
102  mPrimaryTracks = uncorrectedNumberOfPositivePrimaries(event) +
103  mPrimaryNegTracks;
104  } else {
105  mPrimaryVertexX = 0.;
106  mPrimaryVertexY = 0.;
107  mPrimaryVertexZ = 0.;
108  mPrimaryNegTracks = 0;
109  mPrimaryTracks = 0;
110  }
111 }
112 
113 void StStrangeEvMuDst::Fill(StMcEvent& event) {
114 
115  mRun = event.runNumber();
116  mEvent = event.eventNumber();
117  mL0TriggerWord = 0;
118  mMagneticField = 0.;
119 
120  mGlobalTracks = event.tracks().size();
121  mPrimaryNegTracks = 0;
122 
123  StMcVertex* primaryVertex = event.primaryVertex();
124  if( primaryVertex ) {
125  mPrimaryVertexX = primaryVertex->position().x();
126  mPrimaryVertexY = primaryVertex->position().y();
127  mPrimaryVertexZ = primaryVertex->position().z();
128  StPtrVecMcTrack& daughters = primaryVertex->daughters();
129  mPrimaryTracks = daughters.size();
130  for (int i=0; i<mPrimaryTracks; i++) {
131  StMcTrack* tri = daughters[i];
132  if (tri) {
133  StParticleDefinition* pdef = tri->particleDefinition();
134  if ((pdef) && (pdef->charge() < 0)) mPrimaryNegTracks++;
135  }
136  }
137  } else {
138  mPrimaryVertexX = 0.;
139  mPrimaryVertexY = 0.;
140  mPrimaryVertexZ = 0.;
141  mPrimaryTracks = 0;
142  }
143 }
144 
145 StStrangeEvMuDst::~StStrangeEvMuDst() {
146 }
147 
148 void StStrangeEvMuDst::Clear() {
149  mRun = -1;
150  mEvent = -1;
151  mPrimaryVertexX = 0.;
152  mPrimaryVertexY = 0.;
153  mPrimaryVertexZ = 0.;
154  mGlobalTracks = 0;
155  mPrimaryTracks = 0;
156  mPrimaryNegTracks = 0;
157  mMagneticField = 0.;
158  mL0TriggerWord = 0;
159 }
160 
161 void StStrangeEvMuDst::SetCorrectionFile(char* fname) {
162  FILE* fp = fopen(fname,"r");
163  if (fp) {
164  int asize=64;
165  int count=0;
166  float uBM,cBM,cE;
167  while (fscanf(fp,"%f %f +/- %f",&uBM,&cBM,&cE) != EOF) {
168  if ((count + 1) > corBinMean.GetSize()) {
169  uncorBinMean.Set(asize);
170  corBinMean.Set(asize);
171  corError.Set(asize);
172  asize *= 2;
173  }
174  uncorBinMean.AddAt(uBM,count);
175  corBinMean.AddAt(cBM,count);
176  corError.AddAt(cE,count);
177  count++;
178  }
179  uncorBinMean.Set(count);
180  corBinMean.Set(count);
181  corError.Set(count);
182  fclose(fp);
183  } else {
184  gMessMgr->Warning() << "StStrangeEvMuDst: Failed to find correction file: "
185  << fname << "\n No corrections available!" << endm;
186  }
187 }
188 
190  FILE* fp = fopen(fname,"r");
191  if (fp) {
192  int asize=64;
193  int count=0;
194  float fT,fS,fE;
195  while (fscanf(fp,"%f %f +/- %f",&fT,&fS,&fE) != EOF) {
196  if ((count + 1) > fracTracks.GetSize()) {
197  fracTracks.Set(asize);
198  fracSigma.Set(asize);
199  fracError.Set(asize);
200  asize *= 2;
201  }
202  fracTracks.AddAt(fT,count);
203  fracSigma.AddAt(fS,count);
204  fracError.AddAt(fE,count);
205  count++;
206  }
207  fracTracks.Set(count);
208  fracSigma.Set(count);
209  fracError.Set(count);
210  fclose(fp);
211  } else {
212  gMessMgr->Warning() << "StStrangeEvMuDst: Failed to find fraction file: "
213  << fname << "\n No fractions available!" << endm;
214  }
215 }
216 
217 Float_t StStrangeEvMuDst::primaryCorrectedTracks() const {
218  int count = corBinMean.GetSize();
219  if (count) {
220  count--;
221  int i,j=1;
222  for (i=0; i<count; i++) {
223  if (uncorBinMean.At(i) > mPrimaryTracks) break;
224  }
225  if (i != 0) j = i - 1;
226  Float_t wt1 = 1.0/(uncorBinMean.At(i) - mPrimaryTracks);
227  Float_t wt2 = 1.0/(uncorBinMean.At(j) - mPrimaryTracks);
228  if ((corError.At(i)) && (corError.At(j))) {
229  wt1 /= corError.At(i);
230  wt2 /= corError.At(j);
231  }
232  return ((wt1*corBinMean.At(i) - wt2*corBinMean.At(j))/(wt1 - wt2));
233  }
234  gMessMgr->Warning() << "StStrangeEvMuDst: No corrections entered!\n" <<
235  " Use SetCorrectionFile(char*) to select a valid correction map file"
236  << endm;
237  return -1.0;
238 }
239 
241  Float_t cTracks = primaryCorrectedTracks();
242  int count = fracTracks.GetSize();
243  if (count) {
244  count--;
245  int i,j=1;
246  for (i=0; i<count; i++) {
247  if (fracTracks.At(i) > cTracks) break;
248  }
249  if (i != 0) j = i - 1;
250  Float_t wt1 = 1.0/(fracTracks.At(i) - cTracks);
251  Float_t wt2 = 1.0/(fracTracks.At(j) - cTracks);
252  if ((fracError.At(i)) && (fracError.At(j))) {
253  wt1 /= fracError.At(i);
254  wt2 /= fracError.At(j);
255  }
256  return ((wt1*fracSigma.At(i) - wt2*fracSigma.At(j))/(wt1 - wt2));
257  }
258  gMessMgr->Warning() << "StStrangeEvMuDst: No fractions entered!\n" <<
259  " Use SetFractionFile(char*) to select a valid fraction map file"
260  << endm;
261  return -1.0;
262 }
263 
static void SetFractionFile(char *)
Set files to use.
Int_t mRun
Negative mRun value for bad FTPC run (set via tagRunNumber())
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
Int_t mEvent
Negative mEvent value for L3Bias (automatic during Fill())
Float_t fractionSigma() const
Cross section fraction.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
Definition: StMcEvent.hh:169