111 #include "StHbtMaker/Infrastructure/StHbtAnalysis.h"
112 #include "StHbtMaker/Base/StHbtTrackCut.h"
113 #include "StHbtMaker/Base/StHbtV0Cut.h"
114 #include "StHbtMaker/Base/StHbtKinkCut.h"
131 StHbtParticleCollection* partCollection)
133 switch (partCut->Type()) {
138 StHbtTrackIterator pIter;
139 StHbtTrackIterator startLoop = hbtEvent->TrackCollection()->begin();
140 StHbtTrackIterator endLoop = hbtEvent->TrackCollection()->end();
141 for (pIter=startLoop;pIter!=endLoop;pIter++){
143 bool tmpPassParticle = pCut->Pass(pParticle);
144 pCut->FillCutMonitor(pParticle, tmpPassParticle);
145 if (tmpPassParticle){
147 partCollection->push_back(particle);
156 StHbtV0Iterator pIter;
157 StHbtV0Iterator startLoop = hbtEvent->V0Collection()->begin();
158 StHbtV0Iterator endLoop = hbtEvent->V0Collection()->end();
160 for (pIter=startLoop;pIter!=endLoop;pIter++){
162 bool tmpPassV0 = pCut->Pass(pParticle);
163 pCut->FillCutMonitor(pParticle,tmpPassV0);
166 partCollection->push_back(particle);
169 pCut->FillCutMonitor(hbtEvent,partCollection);
176 StHbtKinkIterator pIter;
177 StHbtKinkIterator startLoop = hbtEvent->KinkCollection()->begin();
178 StHbtKinkIterator endLoop = hbtEvent->KinkCollection()->end();
180 for (pIter=startLoop;pIter!=endLoop;pIter++){
182 bool tmpPass = pCut->Pass(pParticle);
183 pCut->FillCutMonitor(pParticle,tmpPass);
186 partCollection->push_back(particle);
192 cout <<
"FillHbtParticleCollection function (in StHbtAnalysis.cxx) - undefined Particle Cut type!!! \n";
196 StHbtAnalysis::StHbtAnalysis(){
199 mFirstParticleCut = 0;
200 mSecondParticleCut = 0;
202 mCorrFctnCollection= 0;
203 mCorrFctnCollection =
new StHbtCorrFctnCollection;
204 mMixingBuffer =
new StHbtPicoEventCollection;
205 mNeventsProcessed = 0;
208 mPicoEventCollectionVectorHideAway = 0;
210 mMinSizePartCollection=0;
218 mFirstParticleCut = 0;
219 mSecondParticleCut = 0;
221 mCorrFctnCollection= 0;
222 mCorrFctnCollection =
new StHbtCorrFctnCollection;
223 mMixingBuffer =
new StHbtPicoEventCollection;
224 mNeventsProcessed = 0;
228 mEventCut = a.mEventCut->Clone();
230 mFirstParticleCut = a.mFirstParticleCut->Clone();
232 if (a.mFirstParticleCut==a.mSecondParticleCut)
233 SetSecondParticleCut(mFirstParticleCut);
235 mSecondParticleCut = a.mSecondParticleCut->Clone();
237 mPairCut = a.mPairCut->Clone();
240 SetEventCut(mEventCut);
241 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - event cut set " << endl;
243 if ( mFirstParticleCut ) {
244 SetFirstParticleCut(mFirstParticleCut);
245 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - first particle cut set " << endl;
247 if ( mSecondParticleCut ) {
248 SetSecondParticleCut(mSecondParticleCut);
249 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - second particle cut set " << endl;
251 SetPairCut(mPairCut);
252 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - pair cut set " << endl;
255 StHbtCorrFctnIterator iter;
256 for (iter=a.mCorrFctnCollection->begin(); iter!=a.mCorrFctnCollection->end();iter++){
257 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - looking for correlation functions " << endl;
259 if (fctn) AddCorrFctn(fctn);
260 else cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - correlation function not found " << endl;
263 mNumEventsToMix = a.mNumEventsToMix;
265 mMinSizePartCollection = a.mMinSizePartCollection;
267 cout <<
" StHbtAnalysis::StHbtAnalysis(const StHbtAnalysis& a) - analysis copied " << endl;
271 StHbtAnalysis::~StHbtAnalysis(){
272 cout <<
" StHbtAnalysis::~StHbtAnalysis()" << endl;
273 if (mEventCut)
delete mEventCut; mEventCut=0;
274 if (mFirstParticleCut == mSecondParticleCut) mSecondParticleCut=0;
275 if (mFirstParticleCut)
delete mFirstParticleCut; mFirstParticleCut=0;
276 if (mSecondParticleCut)
delete mSecondParticleCut; mSecondParticleCut=0;
277 if (mPairCut)
delete mPairCut; mPairCut=0;
279 StHbtCorrFctnIterator iter;
280 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
283 delete mCorrFctnCollection;
286 StHbtPicoEventIterator piter;
287 for (piter=mMixingBuffer->begin();piter!=mMixingBuffer->end();piter++){
290 delete mMixingBuffer;
295 if ( n<0 || n > (
int)mCorrFctnCollection->size() )
297 StHbtCorrFctnIterator iter=mCorrFctnCollection->begin();
298 for (
int i=0; i<n ;i++){
304 StHbtString StHbtAnalysis::Report()
306 cout <<
"StHbtAnalysis - constructing Report..."<<endl;
307 string temp =
"-----------\nHbt Analysis Report:\n";
308 temp +=
"\nEvent Cuts:\n";
309 temp += mEventCut->Report();
310 temp +=
"\nParticle Cuts - First Particle:\n";
311 temp += mFirstParticleCut->Report();
312 temp +=
"\nParticle Cuts - Second Particle:\n";
313 temp += mSecondParticleCut->Report();
314 temp +=
"\nPair Cuts:\n";
315 temp += mPairCut->Report();
316 temp +=
"\nCorrelation Functions:\n";
317 StHbtCorrFctnIterator iter;
318 if ( mCorrFctnCollection->size()==0 ) {
319 cout <<
"StHbtAnalysis-Warning : no correlations functions in this analysis " << endl;
321 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
322 temp += (*iter)->Report();
325 temp +=
"-------------\n";
326 StHbtString returnThis=temp;
335 EventBegin(hbtEvent);
337 bool tmpPassEvent = mEventCut->Pass(hbtEvent);
338 mEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
340 cout <<
"StHbtAnalysis::ProcessEvent() - Event has passed cut - build picoEvent from " <<
341 hbtEvent->TrackCollection()->size() <<
" tracks in TrackCollection" << endl;
345 FillHbtParticleCollection(mFirstParticleCut,(
StHbtEvent*)hbtEvent,mPicoEvent->FirstParticleCollection());
346 if ( !(AnalyzeIdenticalParticles()) )
347 FillHbtParticleCollection(mSecondParticleCut,(
StHbtEvent*)hbtEvent,mPicoEvent->SecondParticleCollection());
348 cout <<
"StHbtAnalysis::ProcessEvent - #particles in First, Second Collections: " <<
349 mPicoEvent->FirstParticleCollection()->size() <<
" " <<
350 mPicoEvent->SecondParticleCollection()->size() << endl;
354 if ((mPicoEvent->FirstParticleCollection()->size() >= mMinSizePartCollection )
355 && ( AnalyzeIdenticalParticles() || (mPicoEvent->SecondParticleCollection()->size() >= mMinSizePartCollection ))) {
368 if (AnalyzeIdenticalParticles()) {
369 MakePairs(
"real", mPicoEvent->FirstParticleCollection() );
372 MakePairs(
"real", mPicoEvent->FirstParticleCollection(),
373 mPicoEvent->SecondParticleCollection() );
375 cout <<
"StHbtAnalysis::ProcessEvent() - reals done ";
380 StHbtPicoEventIterator mPicoEventIter;
382 for (mPicoEventIter=MixingBuffer()->begin();mPicoEventIter!=MixingBuffer()->end();mPicoEventIter++){
383 storedEvent = *mPicoEventIter;
385 if (AnalyzeIdenticalParticles()) {
386 MakePairs(
"mixed",mPicoEvent->FirstParticleCollection(),
387 storedEvent->FirstParticleCollection() );
390 MakePairs(
"mixed",mPicoEvent->FirstParticleCollection(),
391 storedEvent->SecondParticleCollection() );
393 MakePairs(
"mixed",storedEvent->FirstParticleCollection(),
394 mPicoEvent->SecondParticleCollection() );
397 cout <<
" - mixed done " << endl;
401 if ( MixingBufferFull() ) {
402 delete MixingBuffer()->back();
403 MixingBuffer()->pop_back();
408 MixingBuffer()->push_front(mPicoEvent);
424 void StHbtAnalysis::MakePairs(
const char* typeIn, StHbtParticleCollection *partCollection1,
425 StHbtParticleCollection *partCollection2){
430 string type = typeIn;
434 StHbtCorrFctnIterator CorrFctnIter;
436 StHbtParticleIterator PartIter1, PartIter2;
438 StHbtParticleIterator StartOuterLoop = partCollection1->begin();
439 StHbtParticleIterator EndOuterLoop = partCollection1->end();
440 StHbtParticleIterator StartInnerLoop;
441 StHbtParticleIterator EndInnerLoop;
443 if (partCollection2) {
444 StartInnerLoop = partCollection2->begin();
445 EndInnerLoop = partCollection2->end();
449 EndInnerLoop = partCollection1->end() ;
452 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++) {
453 if (!partCollection2){
454 StartInnerLoop = PartIter1;
457 ThePair->SetTrack1(*PartIter1);
459 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++) {
461 ThePair->SetTrack2(*PartIter2);
471 if (mPairCut->Pass(ThePair)){
472 for (CorrFctnIter=mCorrFctnCollection->begin();
473 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
477 CorrFctn->AddRealPair(ThePair);
478 else if(type ==
"mixed")
479 CorrFctn->AddMixedPair(ThePair);
481 cout <<
"Problem with pair type, type = " << type.c_str() << endl;
493 void StHbtAnalysis::EventBegin(
const StHbtEvent* ev){
495 mFirstParticleCut->EventBegin(ev);
496 mSecondParticleCut->EventBegin(ev);
497 mPairCut->EventBegin(ev);
498 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
499 (*iter)->EventBegin(ev);
503 void StHbtAnalysis::EventEnd(
const StHbtEvent* ev){
504 mFirstParticleCut->EventEnd(ev);
505 mSecondParticleCut->EventEnd(ev);
506 mPairCut->EventEnd(ev);
507 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
508 (*iter)->EventEnd(ev);
512 void StHbtAnalysis::Finish(){
513 StHbtCorrFctnIterator iter;
514 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
519 void StHbtAnalysis::AddEventProcessed() {
virtual void ProcessEvent(const StHbtEvent *)
returns reports of all cuts applied and correlation functions being done