53 #include "StStrangeEvMuDst.hh"
54 #include "StEventTypes.h"
55 #include "StMcEventTypes.hh"
56 #include "StuRefMult.hh"
57 #include "StMessMgr.h"
61 static TArrayF uncorBinMean, corBinMean, corError;
62 static TArrayF fracTracks, fracSigma, fracError;
69 void StStrangeEvMuDst::Fill(
StEvent& event) {
74 if (evSum) mMagneticField = evSum->magneticField();
75 else mMagneticField = 0.;
77 if (L0trig) mL0TriggerWord = L0trig->triggerWord();
78 else mL0TriggerWord = 0;
84 if ((L3summary) && !(L3summary->unbiasedTrigger()))
mEvent = -
mEvent;
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)
98 mPrimaryVertexX = primaryVertex->position().x();
99 mPrimaryVertexY = primaryVertex->position().y();
100 mPrimaryVertexZ = primaryVertex->position().z();
101 mPrimaryNegTracks = uncorrectedNumberOfNegativePrimaries(event);
102 mPrimaryTracks = uncorrectedNumberOfPositivePrimaries(event) +
105 mPrimaryVertexX = 0.;
106 mPrimaryVertexY = 0.;
107 mPrimaryVertexZ = 0.;
108 mPrimaryNegTracks = 0;
113 void StStrangeEvMuDst::Fill(
StMcEvent& event) {
115 mRun =
event.runNumber();
116 mEvent =
event.eventNumber();
120 mGlobalTracks =
event.tracks().size();
121 mPrimaryNegTracks = 0;
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++) {
134 if ((pdef) && (pdef->charge() < 0)) mPrimaryNegTracks++;
138 mPrimaryVertexX = 0.;
139 mPrimaryVertexY = 0.;
140 mPrimaryVertexZ = 0.;
145 StStrangeEvMuDst::~StStrangeEvMuDst() {
148 void StStrangeEvMuDst::Clear() {
151 mPrimaryVertexX = 0.;
152 mPrimaryVertexY = 0.;
153 mPrimaryVertexZ = 0.;
156 mPrimaryNegTracks = 0;
161 void StStrangeEvMuDst::SetCorrectionFile(
char* fname) {
162 FILE* fp = fopen(fname,
"r");
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);
174 uncorBinMean.AddAt(uBM,count);
175 corBinMean.AddAt(cBM,count);
176 corError.AddAt(cE,count);
179 uncorBinMean.Set(count);
180 corBinMean.Set(count);
184 gMessMgr->Warning() <<
"StStrangeEvMuDst: Failed to find correction file: "
185 << fname <<
"\n No corrections available!" << endm;
190 FILE* fp = fopen(fname,
"r");
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);
202 fracTracks.AddAt(fT,count);
203 fracSigma.AddAt(fS,count);
204 fracError.AddAt(fE,count);
207 fracTracks.Set(count);
208 fracSigma.Set(count);
209 fracError.Set(count);
212 gMessMgr->Warning() <<
"StStrangeEvMuDst: Failed to find fraction file: "
213 << fname <<
"\n No fractions available!" << endm;
217 Float_t StStrangeEvMuDst::primaryCorrectedTracks()
const {
218 int count = corBinMean.GetSize();
222 for (i=0; i<count; i++) {
223 if (uncorBinMean.At(i) > mPrimaryTracks)
break;
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);
232 return ((wt1*corBinMean.At(i) - wt2*corBinMean.At(j))/(wt1 - wt2));
234 gMessMgr->Warning() <<
"StStrangeEvMuDst: No corrections entered!\n" <<
235 " Use SetCorrectionFile(char*) to select a valid correction map file"
241 Float_t cTracks = primaryCorrectedTracks();
242 int count = fracTracks.GetSize();
246 for (i=0; i<count; i++) {
247 if (fracTracks.At(i) > cTracks)
break;
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);
256 return ((wt1*fracSigma.At(i) - wt2*fracSigma.At(j))/(wt1 - wt2));
258 gMessMgr->Warning() <<
"StStrangeEvMuDst: No fractions entered!\n" <<
259 " Use SetFractionFile(char*) to select a valid fraction map file"
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...
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...