31 #include "StMCTruth.h"
38 trackId = word&((1<<16)-1);
43 StMCTruth::operator int()
const
45 return trackId | (trackWt<<16);
48 StMCPivotTruth::StMCPivotTruth(
int normInput) :
49 fN(0), fNorm(normInput),
50 mTrackIds{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
51 mTrackWts{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
52 mTrackNum{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
60 void StMCPivotTruth::Add(
int trackId,
double wt)
66 for (
int i=0;i<fN;i++) {
67 if (mTrackIds[i]!=trackId)
continue;
72 if (fN>=HOWMANY)
return;
73 mTrackIds[fN] = trackId;
74 mTrackWts[fN] = (float)wt;
83 Add(truth.trackId,truth.trackWt);
86 void StMCPivotTruth::Add(
StMCTruth truth,
double wt)
89 Add(truth.trackId,truth.trackWt*wt);
92 StMCTruth StMCPivotTruth::Get(
int byCount)
const
94 int trackId=0,zeroId=byCount>>1;
95 double wt=0,sum=0,sun=0,sum0=0,sun0=0;
96 const float *wts = (byCount&1)? mTrackNum:mTrackWts;
97 for (
int i=0;i<fN;i++) {
98 if (mTrackIds[i]==0) { sun0=mTrackNum[i];sum0=wts[i];
continue;}
101 if (wts[i]<wt)
continue;
102 trackId = mTrackIds[i];
105 if (zeroId) { sum+=sum0; wt+=sum0; sun+=sun0;}
106 sum = ((byCount&1) || fNorm==0)? sum/100 : sun;
112 StMCPivotTruthMap::StMCPivotTruthMap(
int normInput)
119 StMCPivotTruthMap::~StMCPivotTruthMap()
125 delete fIter; fIter=0;
128 void StMCPivotTruthMap::Add(LongKey_t token,
int trackId,
double wt)
130 LongKey_t& word = (*fMap)(TMath::Hash(&token,
sizeof(token)),token);
133 pivo->Add(trackId,wt);
136 void StMCPivotTruthMap::Add(LongKey_t token,
StMCTruth truth)
138 Add(token,truth.trackId,truth.trackWt);
141 StMCTruth StMCPivotTruthMap::Get(LongKey_t token,
int byCount)
const
143 LongKey_t word = fMap->GetValue(TMath::Hash(&token,
sizeof(token)),token);
148 return pivo->Get(byCount);
152 StMCTruth StMCPivotTruthMap::Iter(LongKey_t &token)
const
156 if (!fIter) fIter =
new TExMapIter(fMap);
159 if (!fIter->Next(token,val)) {token = -1;
return 0;}