ATLAS Offline Software
Loading...
Searching...
No Matches
TrackCollHandle_TruthTracks::Imp Class Reference
Collaboration diagram for TrackCollHandle_TruthTracks::Imp:

Public Member Functions

bool loadHitLists (std::map< SimBarCode, SimHitList > &hitLists)
void loadGenParticles (std::map< SimBarCode, HepMC::ConstGenParticlePtr > &genParticles, const HepMC::ConstGenVertexPtr &vtx)
bool loadGenParticles (std::map< SimBarCode, HepMC::ConstGenParticlePtr > &genParticles, const QString &hepMcCollKey)
template<class collT>
void addHitCollections (std::map< SimBarCode, SimHitList > &hitLists)
void createSecondaryHitLists (const SimBarCode &origSimBarCode, const SimHitList &origHitList, std::map< SimBarCode, SimHitList > &outlists, int &newBarCode)
std::list< SimHitHandleBase * >::iterator closestCompatibleHandleItr (SimHitHandleBase *handle, const std::list< SimHitHandleBase * >::iterator &itFirst, std::list< SimHitHandleBase * > &handleList, const double &massSquared) const
void possiblyUpdateGUI ()
void updateVisibleAssociatedObjects () const
bool fixMomentumInfoInSimHits (HepMC::ConstGenParticlePtr p, SimHitList &hitlist) const

Static Public Member Functions

static double mag (const HepMC::FourVector &v)
static SimHitHandleBasecreateHitHandle (const TrackRecord &h)
static SimHitHandleBasecreateHitHandle (const TRTUncompressedHit &h)
static SimHitHandleBasecreateHitHandle (const SiHit &h)

Public Attributes

TrackCollHandle_TruthTrackstheclass = nullptr
std::map< SimBarCode::ExtBarCode, int > extBarCode2pdg
int updateGUICounter = 0
bool cut_fromIROnly = false
bool cut_excludeBarcodeZero = false
bool cut_excludeNeutrals = false
bool displayAscObjs = false

Static Public Attributes

static QString nameHepMCAugmentedEnd = " [augmented]"
static QString nameAugmentedOnly = "Sim hits/trk rec."
static const int maxPdgCode = 1000000000

Detailed Description

Definition at line 54 of file TrackCollHandle_TruthTracks.cxx.

Member Function Documentation

◆ addHitCollections()

template<class collT>
void TrackCollHandle_TruthTracks::Imp::addHitCollections ( std::map< SimBarCode, SimHitList > & hitLists)

Definition at line 206 of file TrackCollHandle_TruthTracks.cxx.

207{
208 std::map<SimBarCode,SimHitList>::iterator itHitList;
209
210 VP1SGAccessHelper sgaccess(theclass->systemBase());
211
212 for (const QString& key : VP1SGContentsHelper(theclass->systemBase()).getKeys<collT>()) {
213 const collT * hitColl;
214 if (!sgaccess.retrieve(hitColl, key)) {
215 theclass->message("Error: Could not retrieve "+QString(typeid(collT).name())+" collection with key = "+key);
216 continue;
217 }
218 theclass->messageVerbose("Retrieved hit collection of type "+QString(typeid(collT).name())+" with key = "+key);
219 typename collT::const_iterator it, itE(hitColl->end());
220 int itot(0), iadded(0);
221 for (it=hitColl->begin();it!=itE;++it) {
222 ++itot;
224 SimHitHandleBase * handle = createHitHandle(*it);
225 handle->cacheMomentum();
226 theclass->fixPDGCode(handle);
227 SimBarCode trackID = handle->simBarCode();
228 if (trackID.pdgCode()>maxPdgCode) {
229 continue;
230 }
231 if (trackID.isNonUniqueSecondary()) {
232 double absmom = handle->momentum();
233 if (absmom>=0&&absmom<1.0*CLHEP::MeV) {//Fixme: Useful? Put it higher??
234 // if (VP1Msg::verbose())
235 // theclass->messageVerbose("Ignoring low momentum sim hit for non. unique secondary particle");
236 delete handle;
237 continue;
238 }
239 }
240 itHitList = hitLists.find(trackID);
241 if ( itHitList == hitLists.end() ) {
243 l.push_back(std::pair<double,SimHitHandleBase*>(handle->hitTime(),handle));
244 hitLists[trackID] = l;
245 } else {
246 itHitList->second.emplace_back(handle->hitTime(),handle);
247 }
248 ++iadded;
249 }
250 theclass->messageVerbose(" => used "+str(iadded)+" of "+str(itot)+" hits");
251 }
252
253}
std::vector< std::pair< double, SimHitHandleBase * > > SimHitList
bool isNonUniqueSecondary() const
int pdgCode() const
const QString & name() const
static SimHitHandleBase * createHitHandle(const TrackRecord &h)
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
l
Printing final latex table to .tex output file.

◆ closestCompatibleHandleItr()

std::list< SimHitHandleBase * >::iterator TrackCollHandle_TruthTracks::Imp::closestCompatibleHandleItr ( SimHitHandleBase * handle,
const std::list< SimHitHandleBase * >::iterator & itFirst,
std::list< SimHitHandleBase * > & handleList,
const double & massSquared ) const

Definition at line 633 of file TrackCollHandle_TruthTracks.cxx.

636 {
637// if (itFirst==handleList.end())
638// return handleList.end();
639 const double mom = handle->momentum();
640 const double momSq = mom*mom;
641 const double betaSqMax = ( (mom < 0 || massSquared<=0 ? 1 : (momSq/(momSq+massSquared)) ));
642 const double speedSqMax = 4.0* CLHEP::c_squared * betaSqMax;//NB: The factor of 4 is a fudge factor, not really clear why needed!!! VP1 or GEANT4 bug!
643 // const double speedSqMax = 1.0001 * c_squared;/*fixme test*/
644// const double speedSqMax = 1.1*betaSqMax*300*300;/*fixme test*/
645// double testmsq=ParticleConstants::electronMassInMeV*MeV*ParticleConstants::electronMassInMeV;
646// const double speedSqMax = 1.0001 * c_squared * ( (mom < 0 || testmsq<=0 ? 1 : (momSq/(momSq+testmsq)) ));
647
648 unsigned ichecked(0);
649 unsigned maxchecked(50);
650
651 const double hitTime = handle->hitTime();
652 const Amg::Vector3D pos = handle->posStart();
653 double mom2, flightTime;
654 std::list<SimHitHandleBase*>::iterator it(itFirst), itE(handleList.end());
655 std::list<SimHitHandleBase*>::iterator itMinDist(itE);
656 double minDistSq(100*CLHEP::cm*100*CLHEP::cm);//Put to 1.0e99 for no hard limit.
657 if (mom>0)
658 if (mom<500*CLHEP::MeV) {
659 minDistSq = 20*CLHEP::cm*20*CLHEP::cm;
660 if (mom<100*CLHEP::MeV) {
661 minDistSq = 10*CLHEP::cm*10*CLHEP::cm;
662 if (mom<10*CLHEP::MeV)
663 minDistSq = 5*CLHEP::cm*5*CLHEP::cm;
664 }
665 }
666
667 for (;it!=itE;++it) {
668 ++ichecked;
669 mom2 = (*it)->momentum();
670 //Possible decreasing momentum requirement:
671 if (mom>=0&&mom2>=0) {
672 if (mom2>mom)
673 continue;
674 if (mom2<0.5*mom)//Guard against delta-rays-ish.
675 continue;
676 }
677
678 //Maximal separation requirement:
679 const double distSquared = ((*it)->posStart()-pos).mag2();
680
681 //Only investigate if it is the closest one:
682 if (distSquared>=minDistSq)
683 continue;
684
685 flightTime = (*it)->hitTime() - hitTime;
686 if (flightTime<=0||flightTime>100*CLHEP::ns) {
687 //Second hit comes before (shouldn't happen), or waaaay after the first hit.
688 if (flightTime<0)
689 theclass->message("closestCompatibleHandleItr WARNING: Should never happen. T1="+str(hitTime)+", T2="+str((*it)->hitTime()));
690 continue;
691 } else {
692 if (distSquared>flightTime*flightTime*speedSqMax)
693 continue;
694 }
695
696
697 //Check for coalignment of momenta:
698 double mindotproduct = -0.5;
699 if (mom>10.0*CLHEP::MeV) {
700 mindotproduct = -0.1;
701 if (mom>1000.0*CLHEP::MeV) {
702 mindotproduct = 0.5;
703 if (mom>10000.0*CLHEP::MeV) {
704 mindotproduct = 0.80;
705 }
706 }
707 }
708 if (mindotproduct>-1.0)
709 if (handle->momentumDirection().dot((*it)->momentumDirection())<mindotproduct)
710 continue;
711
712 // theclass->messageDebug("Test. Hit passed mom and causality.");
713
714 // //Possible minimal separation requirement: //FIXME: Turn this on if momentum is greater than...?
715 // if (mom2>=0&&massSquared>=0) {
716 // const double speedSqMin = 0.9999 * c_squared * momSq/(momSq+massSquared);
717 // const double minDistSquared = flightTimeSq*speedSqMin;
718 // if (distSquared<minDistSquared)
719 // continue;
720 // }
721 //Fixme: We might also make some requirement that distance should be less than e.g. 20cm??
722
723 //Hits are in principle compatible. Store it if it is also the closest:
724 // if (distSquared<minDistSq) {
725 minDistSq = distSquared;
726 itMinDist = it;
727
728 if (distSquared<15*15*CLHEP::cm*CLHEP::cm) {
729 //We already found a very good hit - should not look much further.
730 if (distSquared<5*5*CLHEP::cm*CLHEP::cm)
731 maxchecked = ichecked + 5;
732 else
733 maxchecked = ichecked + 15;
734 }
735
736 if (ichecked>maxchecked)//For performance reasons
737 break;
738 }
739 return itMinDist;
740}
float hitTime(const AFP_SIDSimHit &hit)
Eigen::Matrix< double, 3, 1 > Vector3D

◆ createHitHandle() [1/3]

SimHitHandleBase * TrackCollHandle_TruthTracks::Imp::createHitHandle ( const SiHit & h)
inlinestatic

Definition at line 73 of file TrackCollHandle_TruthTracks.cxx.

73{ return new SimHitHandle_SiHit(&h); }

◆ createHitHandle() [2/3]

SimHitHandleBase * TrackCollHandle_TruthTracks::Imp::createHitHandle ( const TrackRecord & h)
inlinestatic

Definition at line 71 of file TrackCollHandle_TruthTracks.cxx.

71{ return new SimHitHandle_TrackRecord(&h); }

◆ createHitHandle() [3/3]

SimHitHandleBase * TrackCollHandle_TruthTracks::Imp::createHitHandle ( const TRTUncompressedHit & h)
inlinestatic

Definition at line 72 of file TrackCollHandle_TruthTracks.cxx.

72{ return new SimHitHandle_TRTHit(&h); }

◆ createSecondaryHitLists()

void TrackCollHandle_TruthTracks::Imp::createSecondaryHitLists ( const SimBarCode & origSimBarCode,
const SimHitList & origHitList,
std::map< SimBarCode, SimHitList > & outlists,
int & newBarCode )

Definition at line 532 of file TrackCollHandle_TruthTracks.cxx.

536{
537 if (!origSimBarCode.isNonUniqueSecondary()||newBarCode>=0) {
538 theclass->message("createSecondaryHitLists"
539 " ERROR: Unexpected input");
540 return;
541 }
542
543 unsigned ntothitinput = origHitList.size();
544 HepMcParticleLink::index_type evtIndex = origSimBarCode.evtIndex();
545 int pdgCode = origSimBarCode.pdgCode();
546
548 // Temporarily put the (time,handle) pairs from the vector into a list. //
550
551 SimHitList::const_iterator itOrig(origHitList.begin()),itOrigE(origHitList.end());
552 std::list<SimHitHandleBase*> handleList;
553 for(;itOrig!=itOrigE;++itOrig)
554 handleList.push_back(itOrig->second);
555
557 // Produce handle lists based on requirements of proximity, //
558 // decreasing momenta and causality. //
560 std::set<std::list<SimHitHandleBase*> > outHandleLists;
561
562 bool ok;
563 double mass = VP1ParticleData::particleMass(pdgCode,ok);
564 double massSquared( (ok&&mass>=0) ? mass*mass : -1);
565 while (!handleList.empty()) {
566 std::list<SimHitHandleBase*> list;
567 std::list<SimHitHandleBase*>::iterator it(handleList.begin()), itNext, itTemp;
568 //Take this handle from the list, and increment to next one:
569 SimHitHandleBase * handle = *it;
570 list.push_back(handle);
571 itTemp = it++;
572 handleList.erase(itTemp);
573 while ( true ) {
574 if (it==handleList.end())
575 break;//TEST
576 itNext = closestCompatibleHandleItr(handle,it,handleList,massSquared);
578 if (itNext == handleList.end())//Fixme: cache handleList.end()? Check erase invalidation!
579 break;
580 handle = *itNext;
581 list.push_back(handle);
582 it = itNext; ++it;
583 handleList.erase(itNext);
584 if (it == handleList.end())//Fixme: cache handleList.end()? Check erase invalidation!
585 break;
586 }
587 if (list.size()==1) {//5 is ok for trt, but probably not for silicon!
588 //We need at least two sim hits//FIXME: 5?
589 //Fixme: Make minimum number of hits depend on energy?
590// theclass->messageVerbose("Ignoring secondary with barCode 0, since it seems to be the only sim. hit. by this track.");//Fixme: We could do something with posStart/posEnd?//fixme: update text to reflect 5
591 //FIXME: use this!: delete *(list.begin());
592 } else {
593 outHandleLists.insert(list);
594 }
595 }
596
598 // Put handle lists in output handle lists, and assign unique new fake barcodes //
600
601 //We assign fake negative barcodes to
602 //secondaries, since negative barcodes are
603 //by convention reserved for vertices in
604 //the HepMC collection.
605
606 std::set<std::list<SimHitHandleBase*> >::iterator itOutList(outHandleLists.begin()), itOutListE(outHandleLists.end());
607 unsigned totused(0);
608 for (;itOutList!=itOutListE;++itOutList) {
609 const SimBarCode fakeBarCode(newBarCode--,evtIndex,pdgCode);
610 //Fixme: Update barcodes contained in simhithandles!!
611 const unsigned n = itOutList->size();
612 totused += n;
613 outlists[fakeBarCode] = SimHitList();
614 std::map<SimBarCode,SimHitList>::iterator itActualOutList = outlists.find(fakeBarCode);
615 itActualOutList->second.reserve(n);
616
617 std::list<SimHitHandleBase*>::const_iterator itHandle(itOutList->begin()),itHandleE(itOutList->end());
618 for (;itHandle!=itHandleE;++itHandle)
619 itActualOutList->second.emplace_back((*itHandle)->hitTime(),*itHandle);
620
621 //Should be ok already, but just to be safe: (fixme: don't do this?)
622 sort(itActualOutList->second.begin(),itActualOutList->second.end());
623 }
624
625 if (VP1Msg::verbose())
626 theclass->messageVerbose("Grouped "+str(ntothitinput)+" secondaries with pdgCode = "
627 +str(pdgCode)+" into "+str(outHandleLists.size())
628 +" tracks ("+str(ntothitinput-totused)+" went unused).");
629}
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
HepMcParticleLink::index_type evtIndex() const
std::list< SimHitHandleBase * >::iterator closestCompatibleHandleItr(SimHitHandleBase *handle, const std::list< SimHitHandleBase * >::iterator &itFirst, std::list< SimHitHandleBase * > &handleList, const double &massSquared) const
static bool verbose()
Definition VP1Msg.h:31
static double particleMass(const int &pdgcode, bool &ok)
list(name, path='/')
Definition histSizes.py:38

◆ fixMomentumInfoInSimHits()

bool TrackCollHandle_TruthTracks::Imp::fixMomentumInfoInSimHits ( HepMC::ConstGenParticlePtr p,
SimHitList & hitlist ) const

Definition at line 744 of file TrackCollHandle_TruthTracks.cxx.

744 {
745 //Returns false only if we prune down to zero information!
746
747 if (hitlist.empty())
748 return true;
749
750
751 static double unknown = -1.0e99;
752 double mom(unknown), time(unknown);
753 if (p) {
754 HepMC::ConstGenVertexPtr v = p->production_vertex();
755 if (v) {
756 mom = mag(p->momentum());
757 time = v->position().t()/CLHEP::c_light;
758 // theclass->messageDebug("fixMomentumInfoInSimHits genparticle "+str(mom/GeV)+" GeV, time = "+str(time/ns)+" ns");
759 }
760 }
761
762 //First thing we do is to quickly determine if we are in the special
763 //situation of all hits+genparticle missing momentum information, or
764 //all hits already including momentum information.
765
766 bool sawhitwithoutmominfo(false);
767 bool sawhitwithmominfo(mom!=unknown);
768 SimHitList::iterator it(hitlist.begin()), itE(hitlist.end());
769 for (;it!=itE;++it) {
770 const bool hasinfo = it->second->momentum()>=0.0;
771 if (hasinfo)
772 sawhitwithmominfo = true;
773 else
774 sawhitwithoutmominfo = true;
775 if (sawhitwithoutmominfo&&sawhitwithmominfo)
776 break;
777 }
778
779 if (!sawhitwithoutmominfo) {
780 //Already perfectly fine
781 return true;
782 }
783 if (!sawhitwithmominfo) {
784 //Worst case scenario. Discard all for now.
785 theclass->messageDebug("Discarding hitlist." );
786 SimHitList::iterator it(hitlist.begin()), itE(hitlist.end());
787 for (;it!=itE;++it)
788 delete it->second;
789 hitlist.clear();
790 return false;
791 }
792
793// {
794// if (time!=unknown)
795// theclass->messageDebug("BEFORE STARTS WITH GP time = "+str(time/ns)+" ns, mom = "+str(mom/GeV)+" GeV" );
796// SimHitList::iterator it(hitlist.begin()), itE(hitlist.end());
797// for (;it!=itE;++it) {
798// theclass->messageDebug("BEFORE time = "+str(it->second->hitTime()/ns)+" ns, mom = "+str(it->second->momentum()/GeV)+" GeV" );
799// }
800// }
801
802 //OK, we have some mom info, but not in all hits. Time to do some dirty work!
803
804 //First (if no genparticle), we check if the hitlist begins with
805 //hits without momentum information. If it does, we simply supply
806 //the first hit with an *extrapolated* guess!
807 if (mom==unknown) {
808 if (hitlist.at(0).second->momentum()<0.0) {
809 SimHitList::iterator it(hitlist.begin()), itE(hitlist.end());
810 for (;it!=itE;++it) {
811 if (it->second->momentum()>=0.0) {
812 hitlist.at(0).second->setFakeMomentum(it->second->momentum()*1.00001);//We make it slightly bigger. Just because.
813 break;
814 }
815 }
816 if (hitlist.at(0).second->momentum()<0.0) {
817 theclass->messageDebug("fixMomentumInfoInSimHits ERROR: Should not happen! (1)" );
818 //Fixme: clear hitlist.
819 return false;
820 }
821 }
822 mom = hitlist.at(0).second->momentum();
823 time = hitlist.at(0).second->hitTime();
824 }
825
826 //Then we check if the hitlist ends with hits without momentum
827 //information. If it does we simply supply the very last of the hits
828 //with an *extrapolated* guess! (FIXME: ASSUME 0.01% loss every CLHEP::ns or
829 //something else that is simple? Or even use the extrapolator to the
830 //last of those hits?)
831 unsigned ilast = hitlist.size()-1;
832 if (hitlist.at(ilast).second->momentum()<0.0) {
833 for (int iLastWithMom = ilast-1;iLastWithMom>=0;--iLastWithMom) {
834 if (hitlist.at(iLastWithMom).second->momentum()>0.0) {
835 hitlist.at(ilast).second->setFakeMomentum(hitlist.at(iLastWithMom).second->momentum()*0.99999);//Slight smaller. Just because.
836 break;
837 }
838 }
839 if (hitlist.at(ilast).second->momentum()<0.0) {
840 //Get it from the genparticle:
841 if (mom==unknown) {
842 theclass->messageDebug("fixMomentumInfoInSimHits ERROR: Should not happen! (2)" );
843 //Fixme: clear hitlist.
844 return false;
845 }
846 hitlist.at(ilast).second->setFakeMomentum(mom*0.99999);
847 }
848 }
849
850 //Every unknown momentum is now surrounded in time with momentum information. Time to interpolate!!
851 if (mom==unknown||time==unknown) {
852 //No genparticle. Initialise from first hit.
853 mom = hitlist.at(0).second->momentum();
854 time = hitlist.at(0).second->hitTime();
855 }
856
857 unsigned iNextWithMom(0);
858 for (unsigned i = 0; i < hitlist.size(); ++i) {
859 if (hitlist.at(i).second->momentum()>=0.0) {
860 mom = hitlist.at(i).second->momentum();
861 time = hitlist.at(i).second->hitTime();
862 continue;
863 }
864 if (iNextWithMom<=i) {
865 for (unsigned j = i+1;j<hitlist.size();++j) {
866 if (hitlist.at(j).second->momentum()>=0.0) {
867 iNextWithMom = j;
868 break;
869 }
870 }
871 if (iNextWithMom<=i) {
872 theclass->messageDebug("fixMomentumInfoInSimHits ERROR: Should not happen! (3)" );
873 //Fixme: clear hitlist.
874 return false;
875 }
876 }
877 //
878 double time2 = hitlist.at(iNextWithMom).second->hitTime();
879 double mom2 = hitlist.at(iNextWithMom).second->momentum();
880 double t = hitlist.at(i).second->hitTime();
881// theclass->message("ABOUT TO INTERPOLATE time="+str(time/ns)+", t="+str(t/ns)+", time2="+str(time2/ns)+", mom="+str(mom/GeV)+", mom2="+str(mom2/GeV));//fixme
882
883 if (t<=time||t>=time2||time2<=time)
884 theclass->message("SUSPICIOUS TIME");//fixme
885 if (mom2>=mom)
886 theclass->message("SUSPICIOUS MOM mom="+str(mom)+", mom2="+str(mom2));//fixme
887 mom += (mom2-mom)*(t-time)/(time2-time);
888 time = t;
889 hitlist.at(i).second->setFakeMomentum(mom);
890 }
891
892
893
894
895// //Now we loop through the list and see what we need to fix, if anything:
896
897// unsigned iNextWithMom(0);
898// for (unsigned i = 1/*already dealt with first*/; i < hitlist.size(); ++i) {
899// if (hitlist.at(i).second->momentum()>=0.0) {
900// mom = hitlist.at(i).second->momentum();
901// time = hitlist.at(i).second->hitTime();
902// } else {
903// if (iNextWithMom<=i) {
904// for (unsigned j = i+1;j<hitlist.size();++j) {
905// if (hitlist.at(j).second->momentum()>=0.0) {
906// iNextWithMom = j;
907// break;
908// }
909// }
910// if (iNextWithMom<=i) {
911// //Discard end of list!!
912// unsigned j = i;
913// for (;j<hitlist.size();++j) {
914// //TESTdelete hitlist.at(j).second;
915// }
916// hitlist.resize(j);
917// theclass->messageDebug("Discarded "+str(hitlist.size()-i)+" simhits due to missing momentum information at the start of the list");
918// return !hitlist.empty() || !p;
919// }
920// //Interpolate mom(time) values:
921// double time2 = hitlist.at(iNextWithMom).second->hitTime();
922// double mom2 = hitlist.at(iNextWithMom).second->momentum();
923// double t = hitlist.at(i).second->hitTime();
924// if (t<=time||t>=time2||time2<=time)
925// theclass->message("SUSPICIOUS TIME");//fixme
926// if (mom2>=mom)
927// theclass->message("SUSPICIOUS MOM");//fixme
928// mom = (t-time)/(time2-time)*(mom2-mom);
929// time = t;
930// hitlist.at(i).second->setFakeMomentum(mom);
931// }
932// }
933// }
934
935
936// // typedef std::vector<std::pair<double,SimHitHandleBase*> > SimHitList;//hitTime() to SimHitHandle's
937
938
939// {
940// SimHitList::iterator it(hitlist.begin()), itE(hitlist.end());
941// for (;it!=itE;++it) {
942// theclass->messageDebug("AFTER time = "+str(it->second->hitTime()/ns)+" ns, mom = "+str(it->second->momentum()/GeV)+" GeV" );
943// }
944// }
945
946 return true;
947
948}
Scalar mag() const
mag method
time(flags, cells_name, *args, **kw)
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
Definition GenVertex.h:24
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ loadGenParticles() [1/2]

void TrackCollHandle_TruthTracks::Imp::loadGenParticles ( std::map< SimBarCode, HepMC::ConstGenParticlePtr > & genParticles,
const HepMC::ConstGenVertexPtr & vtx )

Definition at line 320 of file TrackCollHandle_TruthTracks.cxx.

322{
323 if (!vtx)
324 return;
325 for (const auto& p: *vtx){
326
327 if (!p)//fixme: message.
328 continue;
329 const HepMC::GenEvent* evt = p->parent_event();
330 if (!evt)
331 continue;//fixme: message.
332 //Fixme: If verbose: check barcode does not already exists!
333 SimBarCode simBarCode(HepMC::barcode(p),0/*evt->event_number()...fixme: correct??*/,p->pdg_id());
334 genParticles[simBarCode] = p;
335 if (!simBarCode.isNonUniqueSecondary())
336 extBarCode2pdg[simBarCode.extBarCode()] = p->pdg_id();
337
338 loadGenParticles(genParticles,p->end_vertex());
339 }
340}
std::map< SimBarCode::ExtBarCode, int > extBarCode2pdg
void loadGenParticles(std::map< SimBarCode, HepMC::ConstGenParticlePtr > &genParticles, const HepMC::ConstGenVertexPtr &vtx)
int barcode(const T *p)
Definition Barcode.h:15
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39

◆ loadGenParticles() [2/2]

bool TrackCollHandle_TruthTracks::Imp::loadGenParticles ( std::map< SimBarCode, HepMC::ConstGenParticlePtr > & genParticles,
const QString & hepMcCollKey )

Definition at line 343 of file TrackCollHandle_TruthTracks.cxx.

345{
347 const McEventCollection* mcColl;
348 if (!VP1SGAccessHelper(theclass->systemBase()).retrieve(mcColl,hepMcCollKey)) {
349 theclass->message("Error: Could not retrieve "+QString(typeid(McEventCollection).name())+" collection with key = "+hepMcCollKey);
350 return false;//fixme message
351 }
352
353 McEventCollection::const_iterator itEvt(mcColl->begin()), itEvtEnd(mcColl->end());
354 if (itEvt==itEvtEnd)
355 return false;//fixme message
356
357 for (;itEvt!=itEvtEnd;++itEvt) {
358 //NB: Signal is always the first event in collection!
359 const HepMC::GenEvent * evt = *itEvt;
360 if (!evt)
361 continue;
362 for(auto itVtx: evt->vertices()) loadGenParticles(genParticles,itVtx);
363 }
364
365 return true;
366}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.

◆ loadHitLists()

bool TrackCollHandle_TruthTracks::Imp::loadHitLists ( std::map< SimBarCode, SimHitList > & hitLists)

Definition at line 256 of file TrackCollHandle_TruthTracks.cxx.

257{
258 //Fixme: Return false if we do not find at least one collection
260
261 //Important that collections which inherently contains pdg codes (TRT) are loaded first!
264
267
268 if (VP1Msg::verbose())
269 theclass->messageVerbose( "Found " + str( hitLists.size() ) + " lists of sim. hits.");
270
271 //Time to assign all simhits with known pdg code a charge:
272 std::map<SimBarCode,SimHitList>::iterator it, itE(hitLists.end());
273 for (it = hitLists.begin(); it!=itE; ++it) {
274 if (it->first.unknownPdgCode())
275 continue;
276 bool ok;
277 double charge = VP1ParticleData::particleCharge(it->first.pdgCode(),ok);
278 if (!ok)
279 continue;
280 SimHitList::iterator itHit(it->second.begin()), itHitE(it->second.end());
281 for (;itHit!=itHitE;++itHit)
282 itHit->second->setCharge(charge);
284 }
285
286 //Fixme: Add hits from muon subsystems.
287
288 //Sort hitLists:
289 for (it = hitLists.begin(); it!=itE; ++it) {
290 sort(it->second.begin(),it->second.end());
292 }
293 return true;
294}
double charge(const T &p)
Definition AtlasPID.h:997
void addHitCollections(std::map< SimBarCode, SimHitList > &hitLists)
static bool hasTRTGeometry()
static bool hasPixelGeometry()
static bool hasSCTGeometry()
static double particleCharge(const int &pdgcode, bool &ok)

◆ mag()

double TrackCollHandle_TruthTracks::Imp::mag ( const HepMC::FourVector & v)
inlinestatic

Definition at line 56 of file TrackCollHandle_TruthTracks.cxx.

56 {
57 return std::sqrt( v.x()*v.x() + v.y()*v.y() + v.z()*v.z() );
58 }

◆ possiblyUpdateGUI()

void TrackCollHandle_TruthTracks::Imp::possiblyUpdateGUI ( )
inline

Definition at line 90 of file TrackCollHandle_TruthTracks.cxx.

90 {
91 if (!((updateGUICounter++)%750)) {
92 theclass->systemBase()->updateGUI();
93 }
94 }

◆ updateVisibleAssociatedObjects()

void TrackCollHandle_TruthTracks::Imp::updateVisibleAssociatedObjects ( ) const

Definition at line 955 of file TrackCollHandle_TruthTracks.cxx.

956{
957
958 theclass->message("updateVisibleAssociatedObjects");//fixme
959 theclass->largeChangesBegin();
960 theclass->trackHandleIterationBegin();
961 TrackHandle_TruthTrack* handle;
962 while ((handle=static_cast<TrackHandle_TruthTrack*>(theclass->getNextTrackHandle()))) {
963 handle->setAscObjsVisible(displayAscObjs);
964 }
965 theclass->largeChangesEnd();
966}

Member Data Documentation

◆ cut_excludeBarcodeZero

bool TrackCollHandle_TruthTracks::Imp::cut_excludeBarcodeZero = false

Definition at line 97 of file TrackCollHandle_TruthTracks.cxx.

◆ cut_excludeNeutrals

bool TrackCollHandle_TruthTracks::Imp::cut_excludeNeutrals = false

Definition at line 98 of file TrackCollHandle_TruthTracks.cxx.

◆ cut_fromIROnly

bool TrackCollHandle_TruthTracks::Imp::cut_fromIROnly = false

Definition at line 96 of file TrackCollHandle_TruthTracks.cxx.

◆ displayAscObjs

bool TrackCollHandle_TruthTracks::Imp::displayAscObjs = false

Definition at line 100 of file TrackCollHandle_TruthTracks.cxx.

◆ extBarCode2pdg

std::map<SimBarCode::ExtBarCode,int> TrackCollHandle_TruthTracks::Imp::extBarCode2pdg

Definition at line 87 of file TrackCollHandle_TruthTracks.cxx.

◆ maxPdgCode

const int TrackCollHandle_TruthTracks::Imp::maxPdgCode = 1000000000
static

Definition at line 105 of file TrackCollHandle_TruthTracks.cxx.

◆ nameAugmentedOnly

QString TrackCollHandle_TruthTracks::Imp::nameAugmentedOnly = "Sim hits/trk rec."
static

Definition at line 76 of file TrackCollHandle_TruthTracks.cxx.

◆ nameHepMCAugmentedEnd

QString TrackCollHandle_TruthTracks::Imp::nameHepMCAugmentedEnd = " [augmented]"
static

Definition at line 75 of file TrackCollHandle_TruthTracks.cxx.

◆ theclass

TrackCollHandle_TruthTracks* TrackCollHandle_TruthTracks::Imp::theclass = nullptr

Definition at line 60 of file TrackCollHandle_TruthTracks.cxx.

◆ updateGUICounter

int TrackCollHandle_TruthTracks::Imp::updateGUICounter = 0

Definition at line 89 of file TrackCollHandle_TruthTracks.cxx.


The documentation for this class was generated from the following file: