ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
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 {
209 
211 
212  for (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() ) {
242  SimHitList l;
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 }

◆ 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 640 of file TrackCollHandle_TruthTracks.cxx.

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

◆ createHitHandle() [1/3]

static 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]

static 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]

static 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 539 of file TrackCollHandle_TruthTracks.cxx.

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

◆ fixMomentumInfoInSimHits()

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

Definition at line 751 of file TrackCollHandle_TruthTracks.cxx.

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

◆ 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 }

◆ 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 #ifdef HEPMC3
363  for(auto itVtx: evt->vertices()) loadGenParticles(genParticles,itVtx);
364 #else
365  HepMC::GenEvent::vertex_const_iterator itVtx(evt->vertices_begin()), itVtxEnd(evt->vertices_end());
366  for(;itVtx!=itVtxEnd;++itVtx) {
367  loadGenParticles(genParticles,*itVtx);
368  }
369 #endif
370  }
371 
372  return true;
373 }

◆ 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
259  addHitCollections<TrackRecordCollection>(hitLists);
260 
261  //Important that collections which inherently contains pdg codes (TRT) are loaded first!
263  addHitCollections<TRTUncompressedHitCollection>(hitLists);
264 
266  addHitCollections<SiHitCollection>(hitLists);
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:
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 }

◆ mag()

static 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)) {
93  }
94  }

◆ updateVisibleAssociatedObjects()

void TrackCollHandle_TruthTracks::Imp::updateVisibleAssociatedObjects ( ) const

Definition at line 962 of file TrackCollHandle_TruthTracks.cxx.

963 {
964 
965  theclass->message("updateVisibleAssociatedObjects");//fixme
968  TrackHandle_TruthTrack* handle;
969  while ((handle=static_cast<TrackHandle_TruthTrack*>(theclass->getNextTrackHandle()))) {
971  }
973 }

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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SimBarCode::isNonUniqueSecondary
bool isNonUniqueSecondary() const
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SimHitHandle_TRTHit
Definition: SimHitHandle_TRTHit.h:23
SimHitHandleBase::simBarCode
SimBarCode simBarCode() const
Definition: SimHitHandleBase.h:48
TrackCollHandle_TruthTracks::Imp::extBarCode2pdg
std::map< SimBarCode::ExtBarCode, int > extBarCode2pdg
Definition: TrackCollHandle_TruthTracks.cxx:87
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
TrackHandle_TruthTrack
Definition: TrackHandle_TruthTrack.h:28
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
skel.it
it
Definition: skel.GENtoEVGEN.py:396
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1StdCollection::largeChangesBegin
virtual void largeChangesBegin()
Definition: VP1StdCollection.cxx:228
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SimHitList
std::vector< std::pair< double, SimHitHandleBase * > > SimHitList
Definition: SimHitHandleBase.h:76
SimBarCode::pdgCode
int pdgCode() const
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
TruthTest.itE
itE
Definition: TruthTest.py:25
SimHitHandleBase::momentumDirection
virtual Amg::Vector3D momentumDirection() const =0
SimBarCode
Definition: SimBarCode.h:22
TrackCollHandle_TruthTracks::fixPDGCode
void fixPDGCode(SimHitHandleBase *) const
Definition: TrackCollHandle_TruthTracks.cxx:298
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
TrackCollHandle_TruthTracks::Imp::updateGUICounter
int updateGUICounter
Definition: TrackCollHandle_TruthTracks.cxx:89
SimHitHandleBase::posStart
virtual Amg::Vector3D posStart() const =0
TrackCollHandle_TruthTracks::Imp::createHitHandle
static SimHitHandleBase * createHitHandle(const TrackRecord &h)
Definition: TrackCollHandle_TruthTracks.cxx:71
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
TrackCollHandle_TruthTracks::Imp::maxPdgCode
static const int maxPdgCode
Definition: TrackCollHandle_TruthTracks.cxx:105
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
TrackCollHandle_TruthTracks::Imp::loadGenParticles
void loadGenParticles(std::map< SimBarCode, HepMC::ConstGenParticlePtr > &genParticles, const HepMC::ConstGenVertexPtr &vtx)
Definition: TrackCollHandle_TruthTracks.cxx:320
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrackCollHandle_TruthTracks::Imp::mag
static double mag(const HepMC::FourVector &v)
Definition: TrackCollHandle_TruthTracks.cxx:56
beamspotman.n
n
Definition: beamspotman.py:731
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TrackCollHandleBase::name
QString name() const
Definition: TrackCollHandleBase.cxx:310
VP1JobConfigInfo::hasSCTGeometry
static bool hasSCTGeometry()
Definition: VP1JobConfigInfo.cxx:128
VP1ParticleData::particleCharge
static double particleCharge(const int &pdgcode, bool &ok)
Definition: VP1ParticleData.cxx:103
SimHitHandleBase::cacheMomentum
void cacheMomentum()
Definition: SimHitHandleBase.h:58
SimHitHandle_TrackRecord
Definition: SimHitHandle_TrackRecord.h:28
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
SimHitHandleBase::hitTime
virtual double hitTime() const =0
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
TrackCollHandle_TruthTracks::Imp::theclass
TrackCollHandle_TruthTracks * theclass
Definition: TrackCollHandle_TruthTracks.cxx:60
VP1JobConfigInfo::hasTRTGeometry
static bool hasTRTGeometry()
Definition: VP1JobConfigInfo.cxx:129
SimHitHandleBase::momentum
double momentum() const
Definition: SimHitHandleBase.h:41
VP1SGAccessHelper::retrieve
bool retrieve(const T *&, const QString &key) const
TrackHandle_TruthTrack::setAscObjsVisible
void setAscObjsVisible(bool)
Definition: TrackHandle_TruthTrack.cxx:284
SimHitHandle_SiHit
Definition: SimHitHandle_SiHit.h:26
Muon::nsw::unknown
@ unknown
Definition: NSWTriggerElink.h:36
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
python.PhysicalConstants.c_squared
float c_squared
Definition: PhysicalConstants.py:64
charge
double charge(const T &p)
Definition: AtlasPID.h:538
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
TrackCollHandle_TruthTracks::Imp::closestCompatibleHandleItr
std::list< SimHitHandleBase * >::iterator closestCompatibleHandleItr(SimHitHandleBase *handle, const std::list< SimHitHandleBase * >::iterator &itFirst, std::list< SimHitHandleBase * > &handleList, const double &massSquared) const
Definition: TrackCollHandle_TruthTracks.cxx:640
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
TrackCollHandleBase::trackHandleIterationBegin
void trackHandleIterationBegin()
Definition: TrackCollHandleBase.cxx:717
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
VP1StdCollection::largeChangesEnd
virtual void largeChangesEnd()
Definition: VP1StdCollection.cxx:239
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
python.PyAthena.v
v
Definition: PyAthena.py:154
h
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
TrackCollHandle_TruthTracks::Imp::possiblyUpdateGUI
void possiblyUpdateGUI()
Definition: TrackCollHandle_TruthTracks.cxx:90
TrackCollHandle_TruthTracks::Imp::displayAscObjs
bool displayAscObjs
Definition: TrackCollHandle_TruthTracks.cxx:100
VP1ParticleData::particleMass
static double particleMass(const int &pdgcode, bool &ok)
Definition: VP1ParticleData.cxx:83
SimHitHandleBase
Definition: SimHitHandleBase.h:32
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
VP1JobConfigInfo::hasPixelGeometry
static bool hasPixelGeometry()
Definition: VP1JobConfigInfo.cxx:127
hitTime
float hitTime(const AFP_SIDSimHit &hit)
Definition: AFP_SIDSimHit.h:39
TrackCollHandleBase::getNextTrackHandle
TrackHandleBase * getNextTrackHandle()
Definition: TrackCollHandleBase.cxx:724
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:31
SimBarCode::evtIndex
HepMcParticleLink::index_type evtIndex() const
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37