35 #include "StHbtMaker/Infrastructure/StHbtSectoredAnalysis.h"
36 #include "StHbtMaker/Infrastructure/StHbtParticleCollection.hh"
37 #include "StHbtMaker/Base/StHbtTrackCut.h"
38 #include "StHbtMaker/Base/StHbtV0Cut.h"
47 int StHbtSectoredAnalysis::Index(
int binx,
int biny,
int binz)
49 return binx + biny*mNumBinsX + binz*mNumBinsX*mNumBinsY;
57 void StHbtSectoredAnalysis::SortHbtParticleCollection(
StHbtParticleCut* partCut,
59 StHbtParticleCollection** SectoredPicoEvent)
62 switch (partCut->Type()) {
67 StHbtTrackIterator pIter;
68 StHbtTrackIterator startLoop = hbtEvent->TrackCollection()->begin();
69 StHbtTrackIterator endLoop = hbtEvent->TrackCollection()->end();
71 for (pIter=startLoop;pIter!=endLoop;pIter++){
73 bool tmpPassParticle = pCut->Pass(pParticle);
74 pCut->FillCutMonitor(pParticle, tmpPassParticle);
77 if (particle->FourMomentum().px()<mPXmin || particle->FourMomentum().px()>mPXmax ||
78 particle->FourMomentum().py()<mPYmin || particle->FourMomentum().py()>mPYmax ||
79 particle->FourMomentum().pz()<mPZmin || particle->FourMomentum().pz()>mPZmax)
80 SectoredPicoEvent[mNumBinsX*mNumBinsY*mNumBinsZ]->push_back(particle);
82 i = (int) floor((particle->FourMomentum().px()-mPXmin)/mDeltaP);
83 j = (int) floor((particle->FourMomentum().py()-mPYmin)/mDeltaP);
84 k = (int) floor((particle->FourMomentum().pz()-mPZmin)/mDeltaP);
85 SectoredPicoEvent[Index(i,j,k)]->push_back(particle);
96 StHbtV0Iterator pIter;
97 StHbtV0Iterator startLoop = hbtEvent->V0Collection()->begin();
98 StHbtV0Iterator endLoop = hbtEvent->V0Collection()->end();
101 for (pIter=startLoop;pIter!=endLoop;pIter++){
103 bool tmpPassV0 = pCut->Pass(pParticle);
104 pCut->FillCutMonitor(pParticle, tmpPassV0);
107 if (particle->FourMomentum().px()<mPXmin || particle->FourMomentum().px()>mPXmax ||
108 particle->FourMomentum().py()<mPYmin || particle->FourMomentum().py()>mPYmax ||
109 particle->FourMomentum().pz()<mPZmin || particle->FourMomentum().pz()>mPZmax)
110 SectoredPicoEvent[mNumBinsX*mNumBinsY*mNumBinsZ]->push_back(particle);
112 i = (int) floor((particle->FourMomentum().px()-mPXmin)/mDeltaP);
113 j = (int) floor((particle->FourMomentum().py()-mPYmin)/mDeltaP);
114 k = (int) floor((particle->FourMomentum().pz()-mPZmin)/mDeltaP);
115 SectoredPicoEvent[Index(i,j,k)]->push_back(particle);
122 cout <<
"FillHbtParticleCollection function (in StHbtSectoredAnalysis.cxx) - undefined Particle Cut type!!! \n";
128 StHbtSectoredAnalysis::StHbtSectoredAnalysis(){
131 mFirstParticleCut = 0;
132 mSecondParticleCut = 0;
134 mCorrFctnCollection= 0;
135 mNeventsProcessed = 0;
147 mCorrFctnCollection =
new StHbtCorrFctnCollection;
148 mSectoredMixingBuffer =
new StHbtSectoredPicoEventCollection;
155 mFirstParticleCut = 0;
156 mSecondParticleCut = 0;
158 mCorrFctnCollection= 0;
159 mNeventsProcessed = 0;
170 mCorrFctnCollection =
new StHbtCorrFctnCollection;
171 mSectoredMixingBuffer =
new StHbtSectoredPicoEventCollection;
174 mEventCut = a.mEventCut->Clone();
176 mFirstParticleCut = a.mFirstParticleCut->Clone();
178 if (a.mFirstParticleCut==a.mSecondParticleCut)
179 SetSecondParticleCut(mFirstParticleCut);
181 mSecondParticleCut = a.mSecondParticleCut->Clone();
183 mPairCut = a.mPairCut->Clone();
186 SetEventCut(mEventCut);
187 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - event cut set " << endl;
189 if ( mFirstParticleCut ) {
190 SetFirstParticleCut(mFirstParticleCut);
191 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - first particle cut set " << endl;
193 if ( mSecondParticleCut ) {
194 SetSecondParticleCut(mSecondParticleCut);
195 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - second particle cut set " << endl;
197 SetPairCut(mPairCut);
198 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - pair cut set " << endl;
201 StHbtCorrFctnIterator iter;
202 for (iter=a.mCorrFctnCollection->begin(); iter!=a.mCorrFctnCollection->end();iter++){
203 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - looking for correlation functions " << endl;
205 if (fctn) AddCorrFctn(fctn);
206 else cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - correlation function not found " << endl;
209 mNumEventsToMix = a.mNumEventsToMix;
211 cout <<
" StHbtSectoredAnalysis::StHbtSectoredAnalysis(const StHbtSectoredAnalysis& a) - analysis copied " << endl;
216 StHbtSectoredAnalysis::~StHbtSectoredAnalysis(){
218 delete mFirstParticleCut ;
219 delete mSecondParticleCut ;
222 StHbtCorrFctnIterator iter;
223 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
226 delete mCorrFctnCollection;
228 StHbtSectoredPicoEventIterator piter;
229 for (piter=mSectoredMixingBuffer->begin();piter!=mSectoredMixingBuffer->end();piter++){
232 delete mSectoredMixingBuffer;
237 if ( n<0 || n > (
int)mCorrFctnCollection->size() )
239 StHbtCorrFctnIterator iter=mCorrFctnCollection->begin();
240 for (
int i=0; i<n ;i++){
246 StHbtString StHbtSectoredAnalysis::Report()
249 sprintf(Sect,
"Sector bounds: %4.2f<px<%4.2f %4.2f<py<%4.2f %4.2f<pz<%4.2f, DeltaP=%4.2f", mPXmin, mPXmax, mPYmin, mPYmax, mPZmin, mPZmax, mDeltaP);
250 cout <<
"StHbtSectoredAnalysis - constructing Report..."<<endl;
251 string temp =
"-----------\nHbt Analysis Report:\n";
252 temp +=
"\nEvent Cuts:\n";
253 temp += mEventCut->Report();
254 temp +=
"\nParticle Cuts - First Particle:\n";
255 temp += mFirstParticleCut->Report();
256 temp +=
"\nParticle Cuts - Second Particle:\n";
257 temp += mSecondParticleCut->Report();
258 temp +=
"\nPair Cuts:\n";
259 temp += mPairCut->Report();
260 temp +=
"\nCorrelation Functions:\n";
261 StHbtCorrFctnIterator iter;
262 if ( mCorrFctnCollection->size()==0 ) {
263 cout <<
"StHbtSectoredAnalysis-Warning : no correlations functions in this analysis " << endl;
265 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
266 temp += (*iter)->Report();
269 temp +=
"\nSectoring Information:\n";
271 temp +=
"\n-------------\n";
272 StHbtString returnThis=temp;
281 int i, j, k, i2, j2, k2;
282 int size1=0, size2=0;
286 EventBegin(hbtEvent);
288 bool tmpPassEvent = mEventCut->Pass(hbtEvent);
289 mEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
291 cout <<
"StHbtSectoredAnalysis::ProcessEvent() - Event has passed cut - build sectoredpicoEvent from " <<
292 hbtEvent->TrackCollection()->size() <<
" tracks in TrackCollection" << endl;
298 SortHbtParticleCollection(mFirstParticleCut,(
StHbtEvent*)hbtEvent,picoEvent->FirstSectoredCollection());
299 if ( !(AnalyzeIdenticalParticles()) )
300 SortHbtParticleCollection(mSecondParticleCut,(
StHbtEvent*)hbtEvent,picoEvent->SecondSectoredCollection());
304 for (i=0; i<mNumBinsX; i++)
305 for (j=0; j<mNumBinsY; j++)
306 for (k=0; k<mNumBinsZ; k++) {
307 size1 += picoEvent->FirstSectoredCollection()[Index(i,j,k)]->size();
308 if ( !(AnalyzeIdenticalParticles()) )
309 size2 += picoEvent->SecondSectoredCollection()[Index(i,j,k)]->size();
312 cout <<
"StHbtSectoredAnalysis::ProcessEvent - #particles in First, Second Collections: " <<
313 size1 <<
" " << size2 << endl;
315 if (AnalyzeIdenticalParticles()) {
317 for (i=0; i<mNumBinsX; i++)
318 for (j=0; j<mNumBinsY; j++)
319 for (k=0; k<mNumBinsZ; k++) {
326 for (j2=j-1; j2<=j+1; j2++)
327 for (k2=k-1; k2<=k+1; k2++) {
328 if (j2<mNumBinsY && k2<mNumBinsZ && j2!=-1 && k2!=-1 && i+1<mNumBinsX) {
329 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[Index(i+1,j2,k2)]);
333 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
339 for (k2=k-1; k2<=k+1; k2++) {
340 if (k2<mNumBinsZ && k2!=-1 && j+1<mNumBinsY) {
341 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[Index(i,j+1,k2)]);
345 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
352 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[Index(i,j,k+1)]);
356 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
361 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)]);
364 CreateRealPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
370 for (i=0; i<mNumBinsX; i++)
371 for (j=0; j<mNumBinsY; j++)
372 for (k=0; k<mNumBinsZ; k++) {
374 for (i2=i-1; i2<=i+1; i2++)
375 for (j2=j-1; j2<=j+1; j2++)
376 for (k2=k-1; k2<=k+1; k2++)
377 if (i2<mNumBinsX && j2<mNumBinsY && k2<mNumBinsZ && i2!=-1 && j2!=-1 && k2!=-1)
378 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->SecondSectoredCollection()[Index(i2,j2,k2)]);
381 CreateRealPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], picoEvent->SecondSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
387 for (i=0; i<mNumBinsX; i++)
388 for (j=0; j<mNumBinsY; j++)
389 for (k=0; k<mNumBinsZ; k++)
390 if (i==0 || j==0 || k==0 || i==mNumBinsX-1 || j==mNumBinsY-1 || k==mNumBinsZ-1)
391 CreateRealPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], picoEvent->SecondSectoredCollection()[Index(i,j,k)]);
394 CreateRealPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], picoEvent->SecondSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
397 cout <<
"StHbtSectoredAnalysis::ProcessEvent() - reals done, " << endl;
401 if (SectoredMixingBufferFull()){
402 cout <<
"Mixing Buffer is full - lets rock and roll" << endl;
405 cout <<
"Mixing Buffer not full -gotta wait " << SectoredMixingBuffer()->size() << endl;
407 if (SectoredMixingBufferFull()){
409 StHbtSectoredPicoEventIterator picoEventIter;
410 for (picoEventIter=SectoredMixingBuffer()->begin();picoEventIter!=SectoredMixingBuffer()->end();picoEventIter++){
411 storedEvent = *picoEventIter;
412 if (AnalyzeIdenticalParticles()){
414 for (i=0; i<mNumBinsX; i++)
415 for (j=0; j<mNumBinsY; j++)
416 for (k=0; k<mNumBinsZ; k++) {
418 for (i2=i-1; i2<=i+1; i2++)
419 for (j2=j-1; j2<=j+1; j2++)
420 for (k2=k-1; k2<=k+1; k2++)
421 if (i2<mNumBinsX && j2<mNumBinsY && k2<mNumBinsZ && i2!=-1 && j2!=-1 && k2!=-1) {
422 CreateMixedPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], storedEvent->FirstSectoredCollection()[Index(i2,j2,k2)]);
426 CreateMixedPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], storedEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
432 for (i=0; i<mNumBinsX; i++)
433 for (j=0; j<mNumBinsY; j++)
434 for (k=0; k<mNumBinsZ; k++)
435 if (i==0 || j==0 || k==0 || i==mNumBinsX-1 || j==mNumBinsY-1 || k==mNumBinsZ-1){
436 CreateMixedPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], storedEvent->FirstSectoredCollection()[Index(i,j,k)]);
440 CreateMixedPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], storedEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
446 for (i=0; i<mNumBinsX; i++)
447 for (j=0; j<mNumBinsY; j++)
448 for (k=0; k<mNumBinsZ; k++) {
450 for (i2=i-1; i2<=i+1; i2++)
451 for (j2=j-1; j2<=j+1; j2++)
452 for (k2=k-1; k2<=k+1; k2++)
453 if (i2<mNumBinsX && j2<mNumBinsY && k2<mNumBinsZ && i2!=-1 && j2!=-1 && k2!=-1)
454 CreateMixedPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], storedEvent->SecondSectoredCollection()[Index(i2,j2,k2)]);
457 CreateMixedPairs(picoEvent->FirstSectoredCollection()[Index(i,j,k)], storedEvent->SecondSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
462 for (i=0; i<mNumBinsX; i++)
463 for (j=0; j<mNumBinsY; j++)
464 for (k=0; k<mNumBinsZ; k++)
465 if (i==0 || j==0 || k==0 || i==mNumBinsX-1 || j==mNumBinsY-1 || k==mNumBinsZ-1)
466 CreateMixedPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], storedEvent->SecondSectoredCollection()[Index(i,j,k)]);
469 CreateMixedPairs(picoEvent->FirstSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ], storedEvent->SecondSectoredCollection()[mNumBinsX*mNumBinsY*mNumBinsZ]);
476 picoEventIter = SectoredMixingBuffer()->end();
478 delete *picoEventIter;
480 SectoredMixingBuffer()->pop_back();
482 SectoredMixingBuffer()->push_front(picoEvent);
485 cout <<
"StHbtSectoredAnalysis::ProcessEvent() - return to caller ... " << endl;
491 void StHbtSectoredAnalysis::CreateRealPairs(StHbtParticleCollection *partColl1) {
493 if (partColl1->size()<2)
return;
497 StHbtParticleIterator PartIter1;
498 StHbtParticleIterator PartIter2;
499 StHbtCorrFctnIterator CorrFctnIter;
500 StHbtParticleIterator StartOuterLoop = partColl1->begin();
501 StHbtParticleIterator EndOuterLoop = partColl1->end();
502 StHbtParticleIterator StartInnerLoop;
503 StHbtParticleIterator EndInnerLoop;
506 EndInnerLoop = partColl1->end() ;
508 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
509 StartInnerLoop = PartIter1;
511 ThePair->SetTrack1(*PartIter1);
512 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++){
513 ThePair->SetTrack2(*PartIter2);
519 if (mPairCut->Pass(ThePair)){
520 for (CorrFctnIter=mCorrFctnCollection->begin();
521 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
523 CorrFctn->AddRealPair(ThePair);
534 void StHbtSectoredAnalysis::CreateRealPairs(StHbtParticleCollection *partColl1, StHbtParticleCollection *partColl2) {
536 if (partColl1->size()<1 || partColl2->size()<1)
return;
542 StHbtParticleIterator PartIter1;
543 StHbtParticleIterator PartIter2;
544 StHbtCorrFctnIterator CorrFctnIter;
545 StHbtParticleIterator StartOuterLoop = partColl1->begin();
546 StHbtParticleIterator EndOuterLoop = partColl1->end();
547 StHbtParticleIterator StartInnerLoop = partColl2->begin();
548 StHbtParticleIterator EndInnerLoop = partColl2->end();
550 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
551 ThePair->SetTrack1(*PartIter1);
552 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++){
553 ThePair->SetTrack2(*PartIter2);
559 if (mPairCut->Pass(ThePair)){
560 for (CorrFctnIter=mCorrFctnCollection->begin();
561 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
563 CorrFctn->AddRealPair(ThePair);
574 void StHbtSectoredAnalysis::CreateMixedPairs(StHbtParticleCollection *partColl1, StHbtParticleCollection *partColl2) {
576 if (partColl1->size()<1 || partColl2->size()<1)
return;
582 StHbtParticleIterator PartIter1;
583 StHbtParticleIterator PartIter2;
584 StHbtCorrFctnIterator CorrFctnIter;
585 StHbtParticleIterator StartOuterLoop = partColl1->begin();
586 StHbtParticleIterator EndOuterLoop = partColl1->end();
587 StHbtParticleIterator StartInnerLoop = partColl2->begin();
588 StHbtParticleIterator EndInnerLoop = partColl2->end();
590 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
591 ThePair->SetTrack1(*PartIter1);
592 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++){
593 ThePair->SetTrack2(*PartIter2);
599 if (mPairCut->Pass(ThePair)){
600 for (CorrFctnIter=mCorrFctnCollection->begin();
601 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
603 CorrFctn->AddMixedPair(ThePair);
614 void StHbtSectoredAnalysis::EventBegin(
const StHbtEvent* ev){
615 mFirstParticleCut->EventBegin(ev);
616 mSecondParticleCut->EventBegin(ev);
617 mPairCut->EventBegin(ev);
618 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
619 (*iter)->EventBegin(ev);
623 void StHbtSectoredAnalysis::EventEnd(
const StHbtEvent* ev){
624 mFirstParticleCut->EventBegin(ev);
625 mSecondParticleCut->EventBegin(ev);
626 mPairCut->EventEnd(ev);
627 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
628 (*iter)->EventEnd(ev);
632 void StHbtSectoredAnalysis::Finish(){
633 StHbtCorrFctnIterator iter;
634 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
639 void StHbtSectoredAnalysis::AddEventProcessed() {
virtual void ProcessEvent(const StHbtEvent *)
returns reports of all cuts applied and correlation functions being done