1 int sortCompare (
const void * elem1,
const void * elem2 ) {
2 int *e1 = (
int *) elem1;
3 int *e2 = (
int *) elem2;
4 return (e1[1] - e2[1]);
6 int rSortCompare (
const void * elem1,
const void * elem2 ) {
7 double *e1 = (
double *) elem1;
8 double *e2 = (
double *) elem2;
9 return (e1[2] - e2[2]);
25 #include "StEStructHijing.h"
27 #include "StEStructPool/AnalysisMaker/StEStructEventCuts.h"
28 #include "StEStructPool/AnalysisMaker/StEStructTrackCuts.h"
29 #include "StEStructPool/EventMaker/StEStructEvent.h"
30 #include "StEStructPool/EventMaker/StEStructTrack.h"
31 #include "StEStructPool/EventMaker/StEStructCentrality.h"
33 StEStructHijing::StEStructHijing() {
37 museImpactParameter =
true;
44 StEStructHijing::StEStructHijing(
THijing* hijing,
47 bool useImpactParameter,
51 mEventsToDo = eventsToDo;
52 museImpactParameter = useImpactParameter;
59 bool StEStructHijing::hasGenerator() {
return (mHijing) ?
true :
false; }
63 if(!mHijing || mEventCount== mEventsToDo) {
70 mHijing->GenerateEvent();
81 retVal->SetBField(0.5);
83 int nTracks = countGoodTracks();
85 mImpact = mHijing->GetImpactParameter();
86 if (museImpactParameter) {
87 centMeasure = mImpact;
89 centMeasure = nTracks;
91 retVal->SetCentrality(centMeasure);
92 if (!mECuts->goodCentrality(centMeasure)) {
95 mECuts->fillHistogram(mECuts->centralityName(),centMeasure,
false);
98 retVal->FillChargeCollections();
99 mECuts->fillHistogram(mECuts->centralityName(),centMeasure,
true);
106 int numParticles=mHijing->GetNParticles();
109 for (
int i=0;i<numParticles;i++) {
110 if (!isTrackGood(i)) {
111 mTCuts->fillHistograms(
false);
114 mTCuts->fillHistograms(
true);
115 eTrack->SetInComplete();
117 int pid = mHijing->GetPdg(i);
120 for(
int k=0;k<3;k++){
121 p[0] = mHijing->GetPx(i);
122 p[1] = mHijing->GetPy(i);
123 p[2] = mHijing->GetPz(i);
124 v[0] = mHijing->GetVx(i);
125 v[1] = mHijing->GetVy(i);
126 v[2] = mHijing->GetVz(i);
129 float pt = sqrt(p[0]*p[0] + p[1]*p[1]);
130 float theta = acos(p[2]/ TMath::Sqrt(pt*pt + p[2]*p[2]) );
131 float eta = -1.0*log(tan(theta/2.0));
132 float *gdca = globalDCA(p,v);
133 float phi=atan2((
double)p[1], (
double)p[0]);
135 eTrack->SetBx(gdca[0]);
136 eTrack->SetBy(gdca[1]);
137 eTrack->SetBz(gdca[2]);
138 eTrack->SetBxPrimary(gdca[0]);
139 eTrack->SetByPrimary(gdca[1]);
140 eTrack->SetBzPrimary(gdca[2]);
141 eTrack->SetBxGlobal(gdca[0]);
142 eTrack->SetByGlobal(gdca[1]);
143 eTrack->SetBzGlobal(gdca[2]);
146 eTrack->SetPIDe_dEdx(10);
147 eTrack->SetPIDpi_dEdx(10);
148 eTrack->SetPIDk_dEdx(10);
149 eTrack->SetPIDp_dEdx(10);
150 eTrack->SetPIDd_dEdx(10);
151 eTrack->SetPIDe_ToF(10);
152 eTrack->SetPIDpi_ToF(10);
153 eTrack->SetPIDk_ToF(10);
154 eTrack->SetPIDp_ToF(10);
155 eTrack->SetPIDd_ToF(10);
156 if ((pid == 7) || (pid == 8)) {
157 eTrack->SetPIDe_dEdx(0);
158 eTrack->SetPIDe_ToF(0);
159 }
else if ((pid == -211) || (pid == 211)) {
160 eTrack->SetPIDpi_dEdx(0);
161 eTrack->SetPIDpi_ToF(0);
162 }
else if ((pid == -321) || (pid == 321)) {
163 eTrack->SetPIDk_dEdx(0);
164 eTrack->SetPIDk_ToF(0);
165 }
else if ((pid == -2212) || (pid == 2212)) {
166 eTrack->SetPIDp_dEdx(0);
167 eTrack->SetPIDp_ToF(0);
168 }
else if ((pid == -2213) || (pid == 2213)) {
170 eTrack->SetPIDd_dEdx(0);
171 eTrack->SetPIDd_ToF(0);
182 eTrack->SetTopologyMapData(0, 0xffffff80);
183 eTrack->SetTopologyMapData(1, 0x3fff);
184 eTrack->SetTopologyMapTPCNHits(45);
185 eTrack->SetNMaxPoints(45);
186 eTrack->SetNFoundPoints(45);
187 eTrack->SetNFitPoints(45);
190 eTrack->SetCharge(-1);
192 eTrack->SetCharge(1);
195 estructEvent->AddTrack(eTrack);
204 bool StEStructHijing::isTrackGood(
int it) {
206 bool useTrack =
true;
208 i = mTrackList[2*it];
209 if (mTrackList[2*it+1] < 0) {
214 i = (int) rTrackList[4*it];
215 if (rTrackList[4*it+3] < 0) {
219 int pid = mHijing->GetPdg(i);
220 if (!measureable(pid)) {
225 p[0] = mHijing->GetPx(i);
226 p[1] = mHijing->GetPy(i);
227 p[2] = mHijing->GetPz(i);
228 v[0] = mHijing->GetVx(i);
229 v[1] = mHijing->GetVy(i);
230 v[2] = mHijing->GetVz(i);
233 pid < 0 ? q=-1 : q=+1;
234 float pt = sqrt(p[0]*p[0]+p[1]*p[1]);
235 float theta = acos(p[2]/ TMath::Sqrt(pt * pt + p[2] * p[2]) );
236 float eta = -1.0*log(tan(theta/2.0));
237 float phi = atan2((
double)p[1], (
double)p[0]);
238 float* gdca = globalDCA(p,v);
240 float yt = log(sqrt(1+_r*_r)+_r);
241 int iFrag = mHijing->GetOrigin(i);
243 useTrack = (mTCuts->goodGlobalDCA(gdca[3]) && useTrack);
244 useTrack = (mTCuts->goodCharge(q) && useTrack);
245 useTrack = (mTCuts->goodPt(pt) && useTrack);
246 useTrack = (mTCuts->goodEta(eta) && useTrack);
247 useTrack = (mTCuts->goodPhi(phi) && useTrack);
248 useTrack = (mTCuts->goodYt(yt) && useTrack);
250 useTrack = mTCuts->goodFragment(iFrag);
261 int StEStructHijing::filterTracks() {
266 delete [] mTrackList;
268 double pi = acos(-1);
269 int numParticles = mHijing->GetNParticles();
272 mTrackList =
new int[2*numParticles];
273 for (
int i=0;i<numParticles;i++) {
274 double px = mHijing->GetPx(i);
275 double py = mHijing->GetPy(i);
276 double pz = mHijing->GetPz(i);
277 double phi = atan2(py,px);
281 int iphi = 150 * phi / (2*pi);
282 double theta = acos(pz/ TMath::Sqrt(px*px + py*py + pz*pz) );
283 double eta = -1.0*log(tan(theta/2.0));
284 int ieta = 75 * (1 + eta) / 2;
286 if (0 <= ieta && ieta < 75) {
288 ibin = 150 * ieta + iphi;
291 mTrackList[2*i+1] = ibin;
295 qsort(mTrackList, numParticles, 2*
sizeof(
int), sortCompare);
299 for (
int i=0;i<numParticles-1;i++) {
300 if (mTrackList[2*i+1] < 0) {
301 mTrackList[2*i] = -1;
303 }
else if (mTrackList[2*i+1] == mTrackList[2*i+3]) {
304 if (ran.Rndm() > 1.0) {
305 mTrackList[2*i+1] *= -1;
308 }
else if (mTrackList[2*i+1] == mTrackList[2*i-1]) {
309 if (ran.Rndm() > 1.0) {
310 mTrackList[2*i+1] *= -1;
315 return nRejNext + nRejLast;
324 int StEStructHijing::filterTrackArea() {
328 delete [] rTrackList;
330 double pi = acos(-1);
331 int numParticles = mHijing->GetNParticles();
334 rTrackList =
new double[4*numParticles];
335 for (
int i=0;i<numParticles;i++) {
336 double px = mHijing->GetPx(i);
337 double py = mHijing->GetPy(i);
338 double pz = mHijing->GetPz(i);
339 double phi = atan2(py,px);
340 double theta = acos(pz/ TMath::Sqrt(px*px + py*py + pz*pz) );
341 double eta = -1.0*log(tan(theta/2.0));
343 rTrackList[4*i+1] = phi;
344 rTrackList[4*i+2] = eta;
345 rTrackList[4*i+3] = 1;
349 qsort(rTrackList, numParticles, 4*
sizeof(
double), rSortCompare);
353 double DeltaEta = 2.0/15;
354 double DeltaPhi = 2.0*pi/15;
357 for (
int i=0;i<numParticles;i++) {
359 double eta = rTrackList[4*i+2];
360 if (fabs(eta)-1 > DeltaEta) {
364 double phi = rTrackList[4*i+1];
367 while ((j < numParticles) && (rTrackList[4*j+2]-eta < DeltaEta)) {
369 dPhi = fmod(fabs(phi-rTrackList[4*j+1])+pi,2*pi) - pi;;
370 if (fabs(dPhi) < DeltaPhi) {
376 while ((j >= 0) && (rTrackList[4*j+2]-eta < DeltaEta)) {
377 dPhi = fmod(fabs(phi-rTrackList[4*j+1])+pi,2*pi) - pi;;
378 if (fabs(dPhi) < DeltaPhi) {
384 double eff = 0.9 - 0.0025*iDense/(DeltaEta*DeltaPhi);
386 if (ran.Rndm() > eff) {
387 rTrackList[4*i+3] = -1;
398 int StEStructHijing::countGoodTracks() {
400 int numParticles = mHijing->GetNParticles();
401 for (
int i=0;i<numParticles;i++) {
402 if (isTrackGood(i)) {
408 void StEStructHijing::setHijingReader(
THijing* hijing){
409 if (mHijing)
delete mHijing;