155 #include "StHbtMaker/Reader/StStandardHbtEventReader.h"
160 #include "StEventTypes.h"
161 #include "StEventUtilities/StuRefMult.hh"
162 #include "StEventSummary.h"
163 #include "StGlobalTrack.h"
164 #include "StTrackNode.h"
165 #include "StContainers.h"
166 #include "StPrimaryVertex.h"
167 #include "StVertex.h"
168 #include "StMeasuredPoint.h"
169 #include "StDedxPidTraits.h"
170 #include "StTrackPidTraits.h"
171 #include "StTrackGeometry.h"
172 #include "StTrackDetectorInfo.h"
173 #include "StParticleTypes.hh"
174 #include "StTpcDedxPidAlgorithm.h"
176 #include "StEventInfo.h"
181 #include "SystemOfUnits.h"
182 #include "StHbtMaker/Infrastructure/StHbtTrackCollection.hh"
183 #include "StHbtMaker/Infrastructure/StHbtV0Collection.hh"
184 #include "StHbtMaker/Infrastructure/StHbtXiCollection.hh"
185 #include "StHbtMaker/Infrastructure/StHbtKinkCollection.hh"
186 #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
187 #include "StHbtMaker/Base/StHbtEventCut.h"
188 #include "StHbtMaker/Base/StHbtTrackCut.h"
189 #include "StHbtMaker/Base/StHbtV0Cut.h"
190 #include "StHbtMaker/Base/StHbtXiCut.h"
191 #include "StHbtMaker/Base/StHbtKinkCut.h"
193 #include "StStrangeMuDstMaker/StV0MuDst.hh"
194 #include "StStrangeMuDstMaker/StXiMuDst.hh"
195 #include "StStrangeMuDstMaker/StKinkMuDst.hh"
197 #include "StEventMaker/StEventMaker.h"
199 #include "StFlowMaker/StFlowMaker.h"
200 #include "StFlowMaker/StFlowEvent.h"
201 #include "StFlowAnalysisMaker/StFlowAnalysisMaker.h"
202 #include "StFlowMaker/StFlowSelection.h"
210 #if !(ST_NO_NAMESPACES)
211 using namespace units;
216 StStandardHbtEventReader::StStandardHbtEventReader() : mTrackType(primary), mReadTracks(1), mReadV0s(1), mReadXis(1), mReadKinks(1) {
222 mFlowAnalysisMaker = 0;
225 StStandardHbtEventReader::~StStandardHbtEventReader(){
226 if (mEventCut)
delete mEventCut;
227 if (mTrackCut)
delete mTrackCut;
228 if (mV0Cut)
delete mV0Cut;
229 if (mXiCut)
delete mXiCut;
230 if (mKinkCut)
delete mKinkCut;
233 StHbtString StStandardHbtEventReader::Report(){
234 StHbtString temp =
"\n This is the StStandardHbtEventReader\n";
236 sprintf(ccc,
" Track type is %d\n",mTrackType);
238 sprintf(ccc,
" mReadTracks is %d\n",mReadTracks);
240 sprintf(ccc,
" mReadV0s is %d\n",mReadV0s);
242 sprintf(ccc,
" mReadXis is %d\n",mReadXis);
244 temp +=
"---> EventCuts in Reader: ";
246 temp += mEventCut->Report();
251 temp +=
"\n---> TrackCuts in Reader: ";
253 temp += mTrackCut->Report();
258 temp +=
"\n---> V0Cuts in Reader: ";
260 temp += mV0Cut->Report();
265 temp +=
"\n---> XiCuts in Reader: ";
267 temp += mXiCut->Report();
272 temp +=
"\n---> KinkCuts in Reader: ";
274 temp += mKinkCut->Report();
283 StHbtEvent* StStandardHbtEventReader::ReturnHbtEvent(){
284 cout <<
" StStandardHbtEventReader::ReturnHbtEvent()" << endl;
291 if (mTheEventMaker) {
293 rEvent = tempMaker->event();
296 cout <<
" read from event.root file " << endl;
297 rEvent = (
StEvent *) GetInputDS(
"StEvent");
298 cout <<
" read from event.root file " << endl;
301 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - No StEvent!!! " << endl;
315 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - no tag reader " << endl;
318 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - tag reader is switched on " << endl;
319 if (!mTheTagReader->EventMatch(rEvent->info()->runId() , rEvent->info()->id()) ) {
320 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - no tags for this event" << endl;
327 unsigned int mult = rEvent->trackNodes().size();
329 if ( rEvent->numberOfPrimaryVertices() != 1) {
330 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - rEvent->numberOfPrimaryVertices()=" <<
331 rEvent->numberOfPrimaryVertices() << endl;
336 hbtEvent->SetPrimVertPos(vp);
337 cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - primary vertex : " << vp << endl;
340 hbtEvent->SetRunNumber( rEvent->runId() );
342 if ( rEvent->summary() ) {
343 hbtEvent->SetMagneticField(rEvent->summary()->magneticField());
344 cout <<
" StStandardHbtEventReader - magnetic field " << hbtEvent->MagneticField() << endl;
348 cout <<
"StStandardHbtEventReader - no StEvent summary -> no magnetic field written to HbtEvent" << endl;
351 if ( rEvent->l0Trigger() ) {
352 hbtEvent->SetTriggerWord(rEvent->l0Trigger()->triggerWord());
353 hbtEvent->SetTriggerActionWord(rEvent->l0Trigger()->triggerActionWord());
356 cout <<
"StStandardHbtEventReader - no StEvent l0Trigger" << endl;
359 int nL3Processed,nL3Accept,nL3Build;
360 unsigned int firedL3TriggerAlgorithm=0;
361 if ( rEvent->l3Trigger() && rEvent->l3Trigger()->l3EventSummary()) {
362 const StL3EventSummary* mL3EventSummary = rEvent->l3Trigger()->l3EventSummary();
363 unsigned int nAlgorithms = mL3EventSummary->numberOfAlgorithms();
364 cout <<
"Number of L3 algorithms for this run: " << nAlgorithms << endl;
365 const StSPtrVecL3AlgorithmInfo& mL3AlgInfo = mL3EventSummary->algorithms();
366 for (
unsigned int i=0; i<nAlgorithms; i++) {
367 int algId = mL3AlgInfo[i]->id();
368 nL3Processed = mL3AlgInfo[i]->numberOfProcessedEvents();
369 nL3Accept = mL3AlgInfo[i]->numberOfAcceptedEvents();
370 nL3Build = mL3AlgInfo[i]->numberOfBuildEvents();
371 if (mL3AlgInfo[i]->build()) cout <<
"**";
372 cout <<
" alg id " << algId <<
":\t #proc " << nL3Processed <<
"\t #accept " << nL3Accept <<
"\t #build " << nL3Build << endl;
376 const StPtrVecL3AlgorithmInfo& mL3TriggerAlgInfo = mL3EventSummary->algorithmsAcceptingEvent();
377 cout <<
"Number of L3 algorithms which triggered this event: " << mL3TriggerAlgInfo.size() << endl;
378 cout <<
"triggered algorithms: ";
379 for (
unsigned int i=0; i<mL3TriggerAlgInfo.size(); i++) cout << mL3TriggerAlgInfo[i]->
id() <<
" ";
382 firedL3TriggerAlgorithm=0;
383 for (StPtrVecL3AlgorithmInfoConstIterator theIter = mL3TriggerAlgInfo.begin(); theIter != mL3TriggerAlgInfo.end(); ++theIter) {
384 firedL3TriggerAlgorithm |= ( 1<<((*theIter)->id()) );
385 cout << ((*theIter)->id()) <<
" " << firedL3TriggerAlgorithm << endl;
387 hbtEvent->SetL3TriggerAlgorithm(0,firedL3TriggerAlgorithm);
390 cout <<
"StStandardHbtEventReader - no StEvent l3Trigger" << endl;
392 cout <<
"StStandardHbtEventReader - done" << endl;
398 if (!(mEventCut->Pass(hbtEvent))){
408 cout <<
"StStandardHbtReader::ReturnHbtEvent() - We have " << mult <<
" tracks to store - we skip tracks with nhits==0" << endl;
412 if (!PidAlgorithm) cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - Whoa!! No PidAlgorithm!! " << endl;
421 int iNoPidTraits = 0;
427 int iWrongTrackType =0;
430 for (
unsigned int icount=0; icount<(
unsigned int)mult; icount++){
431 cTrack = rEvent->trackNodes()[icount]->track(mTrackType);
434 if (cTrack->flag()>=0) iGoodTracks++;
436 cout << iTracks <<
" " << iGoodTracks <<
" : ";
437 cout << cTrack->type() <<
" ";
438 cout << cTrack->flag() <<
" ";
439 cout << cTrack->key() <<
" ";
440 cout << cTrack->impactParameter() <<
" ";
441 cout << cTrack->numberOfPossiblePoints() <<
" ";
447 hbtEvent->SetNumberOfTracks(iTracks);
448 hbtEvent->SetNumberOfGoodTracks(iGoodTracks);
450 hbtEvent->SetUncorrectedNumberOfPositivePrimaries(uncorrectedNumberOfPositivePrimaries(*rEvent));
451 hbtEvent->SetUncorrectedNumberOfNegativePrimaries(uncorrectedNumberOfNegativePrimaries(*rEvent));
452 hbtEvent->SetEventNumber(rEvent->info()->id());
454 if (rEvent->triggerDetectorCollection()) {
456 hbtEvent->SetZdcAdcWest((
int)zdc.adc(10));
457 hbtEvent->SetZdcAdcEast((
int)zdc.adc(13));
460 cout <<
"StStandardHbtEventReader::Return(...) - no triggerDetectorCollection " << endl;
484 for (
unsigned int icount=0; icount<(
unsigned int)mult; icount++){
486 cout <<
" track# " << icount;
489 gTrack = rEvent->trackNodes()[icount]->track(global);
490 pTrack = rEvent->trackNodes()[icount]->track(primary);
491 cTrack = rEvent->trackNodes()[icount]->track(mTrackType);
494 if (!cTrack) { iWrongTrackType++;
continue; }
495 if (cTrack->flag() < 0) { iBadFlag++;
continue; }
498 cout <<
"StStandardHbtEventReader::Return(...) - no global track pointer !?! " << endl;
503 if (!cTrack->detectorInfo()) {
504 cout <<
"StStandardHbtEventReader::Return(...) - no detector info " << endl;
508 int nhits = cTrack->detectorInfo()->numberOfPoints(kTpcId);
512 cout <<
"No hits -- skipping track (because it crashes otherwise)" << endl;
530 cout <<
"Getting readty to instantiate new StHbtTrack " << endl;
541 if (!(mTrackCut->Pass(hbtTrack))){
552 hbtEvent->TrackCollection()->push_back(hbtTrack);
555 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i tracks of type %i \n",iTracks,mTrackType);
556 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i good tracks of type %i \n",iGoodTracks,mTrackType);
557 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i wrong type tracks \n",iWrongTrackType);
558 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i no hits, tracks skipped \n",iNoHits);
559 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i no tpcPidTraits, tracks skipped \n",iNoPidTraits);
560 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i failed tracks cuts, track skipped \n",iFailedCut);
561 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i bad flag, track skipped \n",iBadFlag);
562 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) tracks pushed into collection \n",hbtEvent->TrackCollection()->size(), mult);
574 if( muDstMaker && mReadV0s ) {
575 for(
int i= 0; i < muDstMaker->GetNV0(); i++){
576 StV0MuDst* v0FromMuDst = muDstMaker->GetV0(i);
582 if (!(mV0Cut->Pass(hbtV0))){
587 hbtEvent->V0Collection()->push_back(hbtV0);
589 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) V0s pushed into collection \n",
590 hbtEvent->V0Collection()->size(),
591 muDstMaker->GetNV0());
597 if( muDstMaker && mReadXis ) {
598 for(
int i= 0; i < muDstMaker->GetNXi(); i++){
599 StXiMuDst* xiFromMuDst = muDstMaker->GetXi(i);
605 if (!(mXiCut->Pass(hbtXi))){
610 hbtEvent->XiCollection()->push_back(hbtXi);
612 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) Xis pushed into collection \n",
613 hbtEvent->XiCollection()->size(),
614 muDstMaker->GetNXi());
625 for (
unsigned int icount=0; icount<(
unsigned int)rEvent->kinkVertices().size(); icount++)
627 StKinkVertex* starKink = rEvent->kinkVertices()[icount];
631 if (!(mKinkCut->Pass(hbtKink))){
636 hbtEvent->KinkCollection()->push_back(hbtKink);
638 printf(
" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) Kinks pushed into collection \n",
639 hbtEvent->KinkCollection()->size(),
640 rEvent->kinkVertices().size());
644 if ( mFlowMaker && hbtEvent ) {
666 if (!(mEventCut->Pass(hbtEvent))){