179 #include "StMcAnalysisMaker.h"
180 #include "PhysicalConstants.h"
181 #include "SystemOfUnits.h"
183 #include "StMessMgr.h"
185 #include "StAssociationMaker/StAssociationMaker.h"
186 #include "StAssociationMaker/StTrackPairInfo.hh"
188 #include "StThreeVectorF.hh"
190 #include "StEventTypes.h"
192 #include "StMcEventTypes.hh"
194 #include "StMcEvent.hh"
197 const Int_t StMcAnalysisMaker::mNumDeltaX = 50;
198 const Int_t StMcAnalysisMaker::mNumDeltaZ = 50;
199 const Float_t StMcAnalysisMaker::mMinDeltaX = -0.52;
200 const Float_t StMcAnalysisMaker::mMaxDeltaX = 0.52;
201 const Float_t StMcAnalysisMaker::mMinDeltaZ = -0.52;
202 const Float_t StMcAnalysisMaker::mMaxDeltaZ = 0.52;
204 Float_t sector, row, isDet,
205 xM, yM, zM, pxM, pyM, pzM, dEM, dSM, nM,
206 xR, yR, zR, dER, IdM, IdR, qR, nR;
208 static const Char_t *vTpcHitMRPair =
"sector:row:isDet:xM:yM:zM:pxM:pyM:pzM:dEM:dSM:nM:xR:yR:zR:dER:IdM:IdR:qR:nR";
211 Float_t barrel, layer, ladder, wafer, hybrid, index,
212 xM, yM, zM, pxM, pyM, pzM, dEM, dSM, nM,
213 xR, yR, zR, dER, IdM, IdR, qR, nR;
215 static const Char_t *vSvtHitMRPair =
"barrel:layer:ladder:wafer:hybrid:index:xM:yM:zM:pxM:pyM:pzM:dEM:dSM:nM:xR:yR:zR:dER:IdM:IdR:qR:nR";
218 Float_t ladder, wafer,
219 xM, yM, zM, pxM, pyM, pzM, dEM, dSM, nM,
220 xR, yR, zR, dER, IdM, IdR, qR, nR;
222 static const Char_t *vSsdHitMRPair =
"ladder:wafer:xM:yM:zM:pxM:pyM:pzM:dEM:dSM:nM:xR:yR:zR:dER:IdM:IdR:qR:nR";
232 mSvtHitResolution(0),
233 mSsdHitResolution(0),
241 mAssociationCanvas(0),
248 mAssociationCanvas = 0;
251 mSvtHitResolution = 0;
252 mSsdHitResolution = 0;
262 StMcAnalysisMaker::~StMcAnalysisMaker()
266 cout <<
"Inside StMcAnalysisMaker Destructor" << endl;
277 void StMcAnalysisMaker::Clear(
const char*)
297 Int_t StMcAnalysisMaker::Init()
304 else {
mNtupleFile =
new TFile(
"TrackMapNtuple.root",
"RECREATE",
"Track Ntuple");}
307 mNumDeltaX,mMinDeltaX,mMaxDeltaX,mNumDeltaZ,mMinDeltaZ,mMaxDeltaZ);
311 mNumDeltaX,mMinDeltaX,mMaxDeltaX,mNumDeltaZ,mMinDeltaZ,mMaxDeltaZ);
316 mNumDeltaX,mMinDeltaX,mMaxDeltaX,mNumDeltaZ,mMinDeltaZ,mMaxDeltaZ);
320 mMomResolution =
new TH1F(
"momRes",
"(|p| - |pmc|)/|pmc|",100,-1.,1.);
321 mMomResolution->SetXTitle(
"Resolution (%)");
323 coordRec =
new TH2F(
"coordRc",
"X vs Y pos. of Hits", 100, -200, 200, 100, -200, 200);
327 coordMcPartner =
new TH2F(
"coordMc",
"X vs Y pos. of Hits", 100, -200, 200, 100, -200, 200);
335 mNtupleFile =
new TFile(
"TrackMapNtuple.root",
"RECREATE",
"Track Ntuple");
337 const char* vars =
"px:py:pz:p:pxrec:pyrec:pzrec:prec:commTpcHits:hitDiffX:hitDiffY:hitDiffZ:mcTrkId:mostCommIdTruth:nHitsIdTruth:nMcHits:nFitPts:nDetPts:quality";
338 mTrackNtuple =
new TNtuple(
"TrackNtuple",
"Track Pair Info",vars);
341 mTpcHitNtuple =
new TNtuple(
"TpcHitNtuple",
"the TPC hit pairs Info",vTpcHitMRPair);
345 mSvtHitNtuple =
new TNtuple(
"SvtHitNtuple",
"the SVT hit pairs Info",vSvtHitMRPair);
349 mSsdHitNtuple =
new TNtuple(
"SsdHitNtuple",
"the SSD hit pairs Info",vSsdHitMRPair);
352 return StMaker::Init();
373 mcTpcHitMapType* theMcHitMap = assoc->mcTpcHitMap();
374 rcSvtHitMapType* svtHitMap = assoc->rcSvtHitMap();
375 mcSvtHitMapType* svtMcHitMap = assoc->mcSvtHitMap();
376 rcSsdHitMapType* ssdHitMap = assoc->rcSsdHitMap();
377 mcSsdHitMapType* ssdMcHitMap = assoc->mcSsdHitMap();
378 rcTrackMapType* theTrackMap = assoc->rcTrackMap();
379 mcV0MapType* theMcV0Map = assoc->mcV0Map();
382 gMessMgr->Warning() <<
"----------WARNING----------\n"
383 <<
"No Hit Map found for this event!" << endm;
392 if (rEvent->primaryVertex()) {
393 VertexPos = rEvent->primaryVertex()->position();
394 cout <<
"Position of Primary Vertex from StEvent:" << endl;
395 cout << VertexPos << endl;
398 cout <<
"----------- WARNING ------------" << endl;
399 cout <<
"No primary vertex from StEvent!!" << endl;
400 cout <<
"Assume it is at (0,0,0) " << endl;
403 cout <<
"Position of Primary Vertex from StMcEvent:" << endl;
404 cout << mEvent->primaryVertex()->position() << endl;
411 unsigned int j,k, nhits;
412 nhits = tpcColl->numberOfHits();
413 if (tpcColl && nhits) {
416 for (k=0; !gotOneHit && k<tpcColl->numberOfSectors(); k++)
417 for (j=0; !gotOneHit && j<tpcColl->sector(k)->numberOfPadrows(); j++)
418 if (tpcColl->sector(k)->padrow(j)->hits().size()) {
420 firstHit = tpcColl->sector(k)->padrow(j)->hits()[0];
421 cout <<
"First Hit Found in Sector "
422 << firstHit->sector() <<
" Padrow "
423 << firstHit->padrow() << endl;
426 cout <<
"This hit has " << theHitMap->count(firstHit) <<
" MC Hits associated with it."<< endl;
430 cout <<
"Position of First Rec. Hit and Associated (if any) MC Hit:" << endl;
431 pair<rcTpcHitMapIter,rcTpcHitMapIter> hitBounds = theHitMap->equal_range(firstHit);
432 for (rcTpcHitMapIter it=hitBounds.first; it!=hitBounds.second; ++it)
433 cout <<
"[" << (*it).first->position() <<
", " << (*it).second->position() <<
"]" << endl;
436 cout <<
"There are no reconstructed TPC Hits in this event" << endl;
446 assert (recHits || mcHits);
447 cout <<
"Making Hit Resolution Histogram..." << endl;
450 for (
unsigned int iSector=0; iSector< recHits->numberOfSectors(); iSector++) {
451 for (
unsigned int iPadrow=0; iPadrow<recHits->sector(iSector)->numberOfPadrows();
453 for (StTpcHitIterator iter = recHits->sector(iSector)->padrow(iPadrow)->hits().begin();
454 iter != recHits->sector(iSector)->padrow(iPadrow)->hits().end();
458 if (rhit->TestBit(StMcHit::kMatched))
460 pair<rcTpcHitMapIter,rcTpcHitMapIter>
461 recBounds = theHitMap->equal_range(rhit);
463 for (rcTpcHitMapIter it2=recBounds.first; it2!=recBounds.second; ++it2){
467 DeltaX = rhit->position().x() - mhit->position().x();
468 DeltaZ = rhit->position().z() - mhit->position().z();
472 memset (&TpcHitMRPair, 0,
sizeof(TpcHitMRPair));
473 TpcHitMRPair.sector = rhit->sector();
474 TpcHitMRPair.row = rhit->padrow();
475 TpcHitMRPair.xR = rhit->position().x();
476 TpcHitMRPair.yR = rhit->position().y();
477 TpcHitMRPair.zR = rhit->position().z();
478 TpcHitMRPair.dER = rhit->charge();
479 TpcHitMRPair.IdR = rhit->idTruth();
480 TpcHitMRPair.qR = rhit->qaTruth();
481 TpcHitMRPair.nR = theHitMap->count(rhit);
482 TpcHitMRPair.isDet = mhit->isDet();
483 TpcHitMRPair.xM = mhit->position().x();
484 TpcHitMRPair.yM = mhit->position().y();
485 TpcHitMRPair.zM = mhit->position().z();
486 TpcHitMRPair.pxM = mhit->localMomentum().x();
487 TpcHitMRPair.pyM = mhit->localMomentum().y();
488 TpcHitMRPair.pzM = mhit->localMomentum().z();
489 TpcHitMRPair.dEM = mhit->dE();
490 TpcHitMRPair.dSM = mhit->dS();
491 mTrack = mhit->parentTrack();
492 if (mTrack) TpcHitMRPair.IdM = mTrack->key();
493 else TpcHitMRPair.IdM = 0;
494 TpcHitMRPair.nM = theMcHitMap->count(mhit);
499 memset (&TpcHitMRPair, 0,
sizeof(TpcHitMRPair));
500 TpcHitMRPair.sector = rhit->sector();
501 TpcHitMRPair.row = rhit->padrow();
502 TpcHitMRPair.xR = rhit->position().x();
503 TpcHitMRPair.yR = rhit->position().y();
504 TpcHitMRPair.zR = rhit->position().z();
505 TpcHitMRPair.dER = rhit->charge();
506 TpcHitMRPair.IdR = rhit->idTruth();
507 TpcHitMRPair.qR = rhit->qaTruth();
508 TpcHitMRPair.nR = theHitMap->count(rhit);
514 for (
unsigned int iSector=0;
515 iSector<mcHits->numberOfSectors(); iSector++) {
517 if (Debug()) {cout << iSector + 1 <<
" "; flush(cout);}
519 for (
unsigned int iPadrow=0;
520 iPadrow<tpcSectHitColl->numberOfPadrows();
523 for (
unsigned int iHit=0;
524 iHit<tpcPadRowHitColl->hits().size();
528 if (mhit->TestBit(StMcHit::kMatched))
continue;
529 memset (&TpcHitMRPair, 0,
sizeof(TpcHitMRPair));
530 TpcHitMRPair.sector = mhit->sector();
531 TpcHitMRPair.row = mhit->padrow();
532 TpcHitMRPair.isDet = mhit->isDet();
533 TpcHitMRPair.xM = mhit->position().x();
534 TpcHitMRPair.yM = mhit->position().y();
535 TpcHitMRPair.zM = mhit->position().z();
536 TpcHitMRPair.pxM = mhit->localMomentum().x();
537 TpcHitMRPair.pyM = mhit->localMomentum().y();
538 TpcHitMRPair.pzM = mhit->localMomentum().z();
539 TpcHitMRPair.dEM = mhit->dE();
540 TpcHitMRPair.dSM = mhit->dS();
541 mTrack = mhit->parentTrack();
542 if (mTrack) TpcHitMRPair.IdM = mTrack->key();
543 else TpcHitMRPair.IdM = 0;
552 if (recHits && mcHits) {
553 for (
unsigned int iBarrel=0; iBarrel< recHits->numberOfBarrels(); iBarrel++) {
554 for (
unsigned int iLadder=0; iLadder<recHits->barrel(iBarrel)->numberOfLadders(); iLadder++) {
555 for (
unsigned int iWafer = 0; iWafer < recHits->barrel(iBarrel)->ladder(iLadder)->numberOfWafers(); iWafer++) {
556 for (StSvtHitIterator iter = recHits->barrel(iBarrel)->ladder(iLadder)->wafer(iWafer)->hits().begin();
557 iter != recHits->barrel(iBarrel)->ladder(iLadder)->wafer(iWafer)->hits().end();
561 if (rhit->TestBit(StMcHit::kMatched))
563 pair<rcSvtHitMapIter,rcSvtHitMapIter> recBounds = svtHitMap->equal_range(rhit);
564 for (rcSvtHitMapIter it2=recBounds.first; it2!=recBounds.second; ++it2){
567 DeltaX = rhit->position().x() - mhit->position().x();
568 DeltaZ = rhit->position().z() - mhit->position().z();
570 memset (&SvtHitMRPair, 0,
sizeof(SvtHitMRPair));
571 SvtHitMRPair.barrel = rhit->barrel();
572 SvtHitMRPair.ladder = rhit->ladder();
573 SvtHitMRPair.layer = rhit->layer();
574 SvtHitMRPair.wafer = rhit->wafer();
575 SvtHitMRPair.hybrid = rhit->hybrid();
576 SvtHitMRPair.index = rhit->index();
577 SvtHitMRPair.xR = rhit->position().x();
578 SvtHitMRPair.yR = rhit->position().y();
579 SvtHitMRPair.zR = rhit->position().z();
580 SvtHitMRPair.dER = rhit->charge();
581 SvtHitMRPair.IdR = rhit->idTruth();
582 SvtHitMRPair.qR = rhit->qaTruth();
583 SvtHitMRPair.nR = svtHitMap->count(rhit);
584 SvtHitMRPair.xM = mhit->position().x();
585 SvtHitMRPair.yM = mhit->position().y();
586 SvtHitMRPair.zM = mhit->position().z();
587 SvtHitMRPair.pxM = mhit->localMomentum().x();
588 SvtHitMRPair.pyM = mhit->localMomentum().y();
589 SvtHitMRPair.pzM = mhit->localMomentum().z();
590 SvtHitMRPair.dEM = mhit->dE();
591 SvtHitMRPair.dSM = mhit->dS();
592 mTrack = mhit->parentTrack();
593 if (mTrack) SvtHitMRPair.IdM = mTrack->key();
594 else SvtHitMRPair.IdM = 0;
595 SvtHitMRPair.nM = svtMcHitMap->count(mhit);
600 memset (&SvtHitMRPair, 0,
sizeof(SvtHitMRPair));
601 SvtHitMRPair.barrel = rhit->barrel();
602 SvtHitMRPair.ladder = rhit->ladder();
603 SvtHitMRPair.layer = rhit->layer();
604 SvtHitMRPair.wafer = rhit->wafer();
605 SvtHitMRPair.hybrid = rhit->hybrid();
606 SvtHitMRPair.index = rhit->index();
607 SvtHitMRPair.xR = rhit->position().x();
608 SvtHitMRPair.yR = rhit->position().y();
609 SvtHitMRPair.zR = rhit->position().z();
610 SvtHitMRPair.dER = rhit->charge();
611 SvtHitMRPair.IdR = rhit->idTruth();
612 SvtHitMRPair.qR = rhit->qaTruth();
613 SvtHitMRPair.nR = svtHitMap->count(rhit);
620 for (
unsigned int iBarrel=0; iBarrel< mcHits->numberOfBarrels(); iBarrel++) {
621 for (
unsigned int iLadder=0; iLadder<mcHits->barrel(iBarrel)->numberOfLadders(); iLadder++) {
622 for (
unsigned int iWafer = 0; iWafer < mcHits->barrel(iBarrel)->ladder(iLadder)->numberOfWafers(); iWafer++) {
623 for (StMcSvtHitIterator iter = mcHits->barrel(iBarrel)->ladder(iLadder)->wafer(iWafer)->hits().begin();
624 iter != mcHits->barrel(iBarrel)->ladder(iLadder)->wafer(iWafer)->hits().end();
628 if (mhit->TestBit(StMcHit::kMatched))
continue;
629 memset (&SvtHitMRPair, 0,
sizeof(SvtHitMRPair));
630 SvtHitMRPair.barrel = mhit->barrel();
631 SvtHitMRPair.ladder = mhit->ladder();
632 SvtHitMRPair.layer = mhit->layer();
633 SvtHitMRPair.wafer = mhit->wafer();
634 SvtHitMRPair.hybrid = mhit->hybrid();
635 SvtHitMRPair.index = -1;
636 SvtHitMRPair.barrel = mhit->barrel();
637 SvtHitMRPair.ladder = mhit->ladder();
638 SvtHitMRPair.xM = mhit->position().x();
639 SvtHitMRPair.yM = mhit->position().y();
640 SvtHitMRPair.zM = mhit->position().z();
641 SvtHitMRPair.pxM = mhit->localMomentum().x();
642 SvtHitMRPair.pyM = mhit->localMomentum().y();
643 SvtHitMRPair.pzM = mhit->localMomentum().z();
644 SvtHitMRPair.dEM = mhit->dE();
645 SvtHitMRPair.dSM = mhit->dS();
646 mTrack = mhit->parentTrack();
647 if (mTrack) SvtHitMRPair.IdM = mTrack->key();
648 else SvtHitMRPair.IdM = 0;
659 if (recHits && mcHits) {
660 for (
unsigned int iLadder=0; iLadder<recHits->numberOfLadders(); iLadder++) {
661 for (
unsigned int iWafer = 0; iWafer < recHits->ladder(iLadder)->numberOfWafers(); iWafer++) {
662 for (StSsdHitIterator iter = recHits->ladder(iLadder)->wafer(iWafer)->hits().begin();
663 iter != recHits->ladder(iLadder)->wafer(iWafer)->hits().end();
667 if (rhit->TestBit(StMcHit::kMatched))
669 pair<rcSsdHitMapIter,rcSsdHitMapIter> recBounds = ssdHitMap->equal_range(rhit);
670 for (rcSsdHitMapIter it2=recBounds.first; it2!=recBounds.second; ++it2){
673 DeltaX = rhit->position().x() - mhit->position().x();
674 DeltaZ = rhit->position().z() - mhit->position().z();
676 memset (&SsdHitMRPair, 0,
sizeof(SsdHitMRPair));
677 SsdHitMRPair.ladder = rhit->ladder();
678 SsdHitMRPair.wafer = rhit->wafer();
679 SsdHitMRPair.xR = rhit->position().x();
680 SsdHitMRPair.yR = rhit->position().y();
681 SsdHitMRPair.zR = rhit->position().z();
682 SsdHitMRPair.dER = rhit->charge();
683 SsdHitMRPair.IdR = rhit->idTruth();
684 SsdHitMRPair.qR = rhit->qaTruth();
685 SsdHitMRPair.nR = ssdHitMap->count(rhit);
686 SsdHitMRPair.xM = mhit->position().x();
687 SsdHitMRPair.yM = mhit->position().y();
688 SsdHitMRPair.zM = mhit->position().z();
689 SsdHitMRPair.pxM = mhit->localMomentum().x();
690 SsdHitMRPair.pyM = mhit->localMomentum().y();
691 SsdHitMRPair.pzM = mhit->localMomentum().z();
692 SsdHitMRPair.dEM = mhit->dE();
693 SsdHitMRPair.dSM = mhit->dS();
694 mTrack = mhit->parentTrack();
695 if (mTrack) SsdHitMRPair.IdM = mTrack->key();
696 else SsdHitMRPair.IdM = 0;
697 SsdHitMRPair.nM = ssdMcHitMap->count(mhit);
702 memset (&SsdHitMRPair, 0,
sizeof(SsdHitMRPair));
703 SsdHitMRPair.ladder = rhit->ladder();
704 SsdHitMRPair.wafer = rhit->wafer();
705 SsdHitMRPair.xR = rhit->position().x();
706 SsdHitMRPair.yR = rhit->position().y();
707 SsdHitMRPair.zR = rhit->position().z();
708 SsdHitMRPair.dER = rhit->charge();
709 SsdHitMRPair.IdR = rhit->idTruth();
710 SsdHitMRPair.qR = rhit->qaTruth();
711 SsdHitMRPair.nR = ssdHitMap->count(rhit);
717 for (
unsigned int iLadder=0; iLadder<mcHits->numberOfLadders(); iLadder++) {
718 for (
unsigned int iWafer = 0; iWafer < mcHits->ladder(iLadder)->numberOfWafers(); iWafer++) {
719 for (StMcSsdHitIterator iter = mcHits->ladder(iLadder)->wafer(iWafer)->hits().begin();
720 iter != mcHits->ladder(iLadder)->wafer(iWafer)->hits().end();
724 if (mhit->TestBit(StMcHit::kMatched))
continue;
725 memset (&SsdHitMRPair, 0,
sizeof(SsdHitMRPair));
726 SsdHitMRPair.ladder = mhit->ladder();
727 SsdHitMRPair.wafer = mhit->wafer();
728 SsdHitMRPair.ladder = mhit->ladder();
729 SsdHitMRPair.xM = mhit->position().x();
730 SsdHitMRPair.yM = mhit->position().y();
731 SsdHitMRPair.zM = mhit->position().z();
732 SsdHitMRPair.pxM = mhit->localMomentum().x();
733 SsdHitMRPair.pyM = mhit->localMomentum().y();
734 SsdHitMRPair.pzM = mhit->localMomentum().z();
735 SsdHitMRPair.dEM = mhit->dE();
736 SsdHitMRPair.dSM = mhit->dS();
737 mTrack = mhit->parentTrack();
738 if (mTrack) SsdHitMRPair.IdM = mTrack->key();
739 else SsdHitMRPair.IdM = 0;
746 cout <<
"Finished Making Histogram." << endl;
749 gMessMgr->Warning() <<
"----------WARNING----------\n"
750 <<
"No Track Map found for this event!" << endm;
756 StSPtrVecTrackNode& rcTrackNodes = rEvent->trackNodes();
759 if (! rcTrackNodes.size()) {
760 cout <<
"Track Nodes List is empty!" << endl;
763 firstTrackNode = *(rcTrackNodes.begin());
764 if (! firstTrackNode) {
765 cout <<
"No tracks in Track Nodes List!" << endl;
768 firstTrack =
dynamic_cast<const StGlobalTrack*
>(firstTrackNode->track(global));
770 cout <<
"GlobalTrack for first Track Nodehas not been found!" << endl;
773 cout <<
"MC Tracks associated with first Track in collection: " << theTrackMap->count(firstTrack) << endl;
774 if (!theTrackMap->count(firstTrack) && theTrackMap->size()) {
775 cout <<
"First track in track node container was not associated. Pick first track in map." << endl;
776 firstTrack = theTrackMap->begin()->first;
778 pair<rcTrackMapIter,rcTrackMapIter> trackBounds = theTrackMap->equal_range(firstTrack);
779 cout <<
"Momentum of First Track and of Associated Tracks (if there are any):" << endl;
785 recMom = pTrk->geometry()->momentum();
787 recMom = firstTrack->geometry()->momentum();
788 for (rcTrackMapIter trkIt=trackBounds.first; trkIt!=trackBounds.second; ++trkIt) {
789 const StMcTrack* origTrk = (*trkIt).second->partnerMcTrack();
790 cout <<
"[" << abs(recMom) <<
", ";
791 cout << abs((*trkIt).second->partnerMcTrack()->momentum()) <<
"]" << endl;
792 cout <<
"These tracks have : \n";
793 cout << (*trkIt).second->commonTpcHits() <<
" TPC hits in common, out of " << origTrk->tpcHits().size() << endl;
794 cout << (*trkIt).second->commonSvtHits() <<
" SVT hits in common, out of " << origTrk->svtHits().size() << endl;
795 cout << (*trkIt).second->commonFtpcHits() <<
" FTPC hits in common, out of " << origTrk->ftpcHits().size() << endl;
806 float* values =
new float[19];
808 for (rcTrackMapIter tIter=theTrackMap->begin();
809 tIter!=theTrackMap->end(); ++tIter){
811 recTrack = (*tIter).first;
813 mcTrack = (*tIter).second->partnerMcTrack();
814 pmc = mcTrack->momentum();
815 for (
int k=0; k<3; k++) values[k] = pmc[k];
818 primTrk =
dynamic_cast<const StPrimaryTrack*
>(recTrack->node()->track(primary));
820 p = primTrk->geometry()->momentum();
822 p = recTrack->geometry()->momentum();
824 for (
int j=0; j<3; j++) values[j+4] = p[j];
826 values[8]=(*tIter).second->commonTpcHits();
829 diff = (p.mag() - pmc.mag())/pmc.mag();
830 mMomResolution->Fill(diff,1.);
835 StPtrVecHit recTpcHits = recTrack->detectorInfo()->hits(kTpcId);
836 multimap<int,float> idTruths;
837 set<int> uniqueIdTruths;
838 for (StHitIterator hi=recTpcHits.begin();
839 hi!=recTpcHits.end(); hi++) {
842 if (!rHit) { cout <<
"This Hit is not a TPC Hit"<< endl;
continue;}
843 idTruths.insert( multimap<int,float>::value_type(rHit->idTruth(),rHit->qaTruth()));
844 uniqueIdTruths.insert(static_cast<int>(rHit->idTruth()));
845 pair<rcTpcHitMapIter,rcTpcHitMapIter> rBounds = theHitMap->equal_range(rHit);
846 for (rcTpcHitMapIter hIter=rBounds.first; hIter!=rBounds.second; hIter++) {
848 if (mHit->parentTrack() != mcTrack)
continue;
849 rHitPos += rHit->position();
850 mHitPos += mHit->position();
855 rHitPos /=(float) (*tIter).second->commonTpcHits();
856 mHitPos /=(float) (*tIter).second->commonTpcHits();
857 for (
int jj=0; jj<3; jj++) values[9+jj] = rHitPos[jj] - mHitPos[jj];
858 values[12] = mcTrack->key();
860 int mostCommonIdTruth = -9;
861 int cachedNHitsIdTruth = 0;
862 for (set<int>::iterator si=uniqueIdTruths.begin(); si!=uniqueIdTruths.end(); ++si) {
863 int currentNHitsIdTruth = idTruths.count(static_cast<int>(*si));
864 if (currentNHitsIdTruth>cachedNHitsIdTruth) {
865 mostCommonIdTruth = *si;
866 cachedNHitsIdTruth = currentNHitsIdTruth;
874 pair<multimap<int,float>::iterator,multimap<int,float>::iterator> mostCommRange = idTruths.equal_range(mostCommonIdTruth);
875 for (multimap<int,float>::iterator mi=mostCommRange.first; mi!=mostCommRange.second; ++mi) {
876 idQuality+=mi->second;
878 if (cachedNHitsIdTruth) { idQuality/=cachedNHitsIdTruth; }
880 values[13] = mostCommonIdTruth;
881 values[14] = cachedNHitsIdTruth;
882 values[15] = mcTrack->tpcHits().size();
883 values[16] = recTrack->fitTraits().numberOfFitPoints(kTpcId);
884 values[17] = recTpcHits.size();
885 values[18] = idQuality;
888 cout <<
"Finished Track Loop, Made Ntuple" << endl;
897 unsigned int maxCommonTpcHits = 0;
899 trackBounds = theTrackMap->equal_range(firstTrack);
900 for (rcTrackMapIter rcIt = trackBounds.first;
901 rcIt != trackBounds.second;
903 if ((*rcIt).second->commonTpcHits() > maxCommonTpcHits) {
904 partner = (*rcIt).second->partnerMcTrack();
905 maxCommonTpcHits = (*rcIt).second->commonTpcHits();
908 StHitIterator rcHitIt;
909 StMcTpcHitIterator mcHitIt;
910 StMcSvtHitIterator mcSitIt;
911 StPtrVecHit theHits = firstTrack->detectorInfo()->hits();
912 for (rcHitIt = theHits.begin();
913 rcHitIt != theHits.end();
914 rcHitIt++)
coordRec->Fill((*rcHitIt)->position().x(),(*rcHitIt)->position().y());
916 for (mcHitIt = ((std::vector<StMcTpcHit*> *)&partner->tpcHits() )->begin();
917 mcHitIt != partner->tpcHits().end();
918 mcHitIt++)
coordMcPartner->Fill((*mcHitIt)->position().x(),(*mcHitIt)->position().y());
919 for (mcSitIt = ((std::vector<StMcSvtHit*> *)&partner->svtHits())->begin();
920 mcSitIt != partner->svtHits().end();
921 mcSitIt++)
coordMcPartner->Fill((*mcSitIt)->position().x(),(*mcSitIt)->position().y());
925 gMessMgr->Warning() <<
"----------WARNING----------\n"
926 <<
"No V0 Map found for this event!" << endm;
931 StSPtrVecMcVertex& mcVertices = mEvent->vertices();
933 StMcVertexIterator mcVertexIt;
936 bool foundV0Pair =
false;
937 for (mcVertexIt = mcVertices.begin(); mcVertexIt != mcVertices.end();
940 pair<mcV0MapIter,mcV0MapIter> mcV0Bounds = theMcV0Map->equal_range(*mcVertexIt);
944 if (mcV0Bounds.first != mcV0Bounds.second) {
945 cout <<
"Printing Position of a V0 pair:\n";
946 cout <<
"Position of MC V0 vertex: " << (*mcVertexIt)->position() << endl;
950 for(mcV0MapIter mcV0MapIt = mcV0Bounds.first;
951 mcV0MapIt != mcV0Bounds.second; ++mcV0MapIt){
952 rcV0Partner = (*mcV0MapIt).second;
953 cout <<
"Position of rc V0 vertex: " << rcV0Partner->position() << endl;
956 if (foundV0Pair)
break;
TH2F * coordRec
Diff. between x and z coordinates of the hits.
TNtuple * mTpcHitNtuple
Miscellaneous info of the track pairs.
virtual void Clear(Option_t *option="")
User defined functions.
TCanvas * mAssociationCanvas
Miscellaneous info of the TPC hit pairs.
TNtuple * mTrackNtuple
File to contain the mTrackNtuple, otherwise it is deleted!
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
TH2F * mSvtHitResolution
Diff. between x and z coordinates of the hits.
TFile * mNtupleFile
X and Y coord of MC Track.
TNtuple * mSsdHitNtuple
Miscellaneous info of the TPC hit pairs.
TH2F * coordMcPartner
X and Y coord of rec. Track.
TH2F * mHitResolution
Diff. between p of rec. & Monte Carlo, in %.
rcTpcHitMapType * rcTpcHitMap()
Diff btw global r and phi coords of FTPC hits.
TH2F * mSsdHitResolution
Diff. between x and z coordinates of the hits.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
TNtuple * mSvtHitNtuple
Miscellaneous info of the TPC hit pairs.