ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimSGToRawHitsTool Class Reference

Extract the raw hists from info in SG. More...

#include <FPGATrackSimSGToRawHitsTool.h>

Inheritance diagram for FPGATrackSimSGToRawHitsTool:

Public Member Functions

 FPGATrackSimSGToRawHitsTool (const std::string &, const std::string &, const IInterface *)
virtual ~FPGATrackSimSGToRawHitsTool ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode readData (FPGATrackSimEventInputHeader *header, const EventContext &eventContext) const override
 This function get from the SG the inner detector raw hits and prepares them for FPGATrackSim simulation.

Private Types

typedef std::map< Identifier, int > HitIndexMap

Private Member Functions

StatusCode readRawSilicon (FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, const EventContext &eventContext) const
StatusCode readTruthTracks (std::vector< FPGATrackSimTruthTrack > &truth, const EventContext &eventContext) const
StatusCode readOfflineTracks (std::vector< FPGATrackSimOfflineTrack > &Track, const EventContext &eventContext) const
StatusCode readOfflineClusters (std::vector< FPGATrackSimCluster > &Clusters, const EventContext &eventContext) const
StatusCode readPixelSimulation (FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext) const
StatusCode readStripSimulation (FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext) const
StatusCode dumpPixelClusters (HitIndexMap &pixelClusterIndexMap, const EventContext &eventContext) const
const HepMcParticleLinkgetTruthInformation (InDetSimDataCollection::const_iterator &iter, FPGATrackSimInputUtils::ParentBitmask &parentMask) const

Private Attributes

ToolHandle< Trk::ITruthToTrackm_truthToTrack {this, "TruthToTrackTool", "Trk::TruthToTrack/InDetTruthToTrack" }
 tool to create track parameters from a gen particle
ToolHandle< Trk::IExtrapolatorm_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
 ToolHandle for Extrapolator.
SG::ReadCondHandleKey< InDet::BeamSpotDatam_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey { this, "EventInfo", "EventInfo" }
SG::ReadHandleKey< InDet::SiClusterContainer > m_pixelClusterContainerKey { this, "pixelClustersName", "ITkPixelClusters" }
SG::ReadHandleKey< InDet::SiClusterContainer > m_sctClusterContainerKey { this, "SCT_ClustersName", "ITkStripClusters" }
SG::ReadHandleKey< xAOD::TrackParticleContainerm_offlineTracksKey { this, "OfflineTracks", "InDetTrackParticles"}
SG::ReadHandleKey< McEventCollectionm_mcCollectionKey { this, "McTruth", "TruthEvent" }
SG::ReadHandleKey< InDetSimDataCollectionm_pixelSDOKey { this, "PixelSDO", "ITkPixelSDO_Map" }
SG::ReadHandleKey< InDetSimDataCollectionm_stripSDOKey { this, "StripSDO", "ITkStripSDO_Map" }
SG::ReadHandleKey< PixelRDO_Containerm_pixelRDOKey { this, "PixelRDO", "ITkPixelRDOs" }
SG::ReadHandleKey< SCT_RDO_Containerm_stripRDOKey { this, "StripRDO", "ITkStripRDOs" }
Gaudi::Property< std::string > m_tracksTruthName { this, "OfflineName", "InDetTrackParticles", "name of offline tracks collection" }
Gaudi::Property< bool > m_dumpHitsOnTracks { this, "dumpHitsOnTracks", false }
Gaudi::Property< bool > m_dumpTruthIntersections { this, "dumpTruthIntersections", false }
Gaudi::Property< bool > m_readOfflineClusters { this, "ReadOfflineClusters", true, "flag to enable the offline cluster save" }
Gaudi::Property< bool > m_readTruthTracks { this, "ReadTruthTracks", true, "flag to enable the truth tracking save" }
Gaudi::Property< bool > m_readOfflineTracks { this, "ReadOfflineTracks", true, "flag to enable the offline tracking save" }
Gaudi::Property< bool > m_UseNominalOrigin { this, "UseNominalOrigin", false, "if true truth values are always with respect to (0,0,0)" }
Gaudi::Property< double > m_maxEta { this, "maxEta", 5.0 }
Gaudi::Property< double > m_minPt { this, "minPt", .8*CLHEP::GeV }
Gaudi::Property< bool > m_doMultiTruth { this, "doMultiTruth", true }
const PixelIDm_pixelId = nullptr
const SCT_IDm_sctId = nullptr
const InDetDD::SiDetectorManagerm_PIX_mgr = nullptr
const InDetDD::SiDetectorManagerm_SCT_mgr = nullptr

Detailed Description

Extract the raw hists from info in SG.

Definition at line 42 of file FPGATrackSimSGToRawHitsTool.h.

Member Typedef Documentation

◆ HitIndexMap

typedef std::map<Identifier, int> FPGATrackSimSGToRawHitsTool::HitIndexMap
private

Definition at line 91 of file FPGATrackSimSGToRawHitsTool.h.

Constructor & Destructor Documentation

◆ FPGATrackSimSGToRawHitsTool()

FPGATrackSimSGToRawHitsTool::FPGATrackSimSGToRawHitsTool ( const std::string & algname,
const std::string & name,
const IInterface * ifc )

Definition at line 46 of file FPGATrackSimSGToRawHitsTool.cxx.

46 :
47 base_class(algname, name, ifc)
48{}

◆ ~FPGATrackSimSGToRawHitsTool()

virtual FPGATrackSimSGToRawHitsTool::~FPGATrackSimSGToRawHitsTool ( )
inlinevirtual

Definition at line 46 of file FPGATrackSimSGToRawHitsTool.h.

46{ ; }

Member Function Documentation

◆ dumpPixelClusters()

StatusCode FPGATrackSimSGToRawHitsTool::dumpPixelClusters ( HitIndexMap & pixelClusterIndexMap,
const EventContext & eventContext ) const
private

Definition at line 511 of file FPGATrackSimSGToRawHitsTool.cxx.

511 {
512 unsigned int pixelClusterIndex = 0;
513 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
514 auto pixelClusterContainerHandle = SG::makeHandle(m_pixelClusterContainerKey, eventContext);
515 // Dump pixel clusters. They're in m_pixelContainer
516 for (const InDet::SiClusterCollection* pixelClusterCollection : *pixelClusterContainerHandle) {
517 if (pixelClusterCollection == nullptr) {
518 ATH_MSG_DEBUG("pixelClusterCollection not available!");
519 continue;
520 }
521
522 for (const InDet::SiCluster* cluster : *pixelClusterCollection) {
523 Identifier theId = cluster->identify();
524 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel cluster.
525 FPGATrackSimInputUtils::ParentBitmask parentMask; // FIXME set, but not used
526 if (!m_pixelSDOKey.empty()) {
527 for (const Identifier& rdoId : cluster->rdoList()) {
528 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId);
529 assert(sielement);
530 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
531
532 const int nCells = sielement->numberOfConnectedCells(cellID);
533 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
534 // this might be the ganged pixel copy.
535 if (nCells > 1 && iter == pixelSDOHandle->end()) {
536 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
537 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
538 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
539 }
540 } // end search for correct ganged pixel
541 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
542 if (iter != pixelSDOHandle->end()) { (void) getTruthInformation(iter, parentMask); } // FIXME not used??
543 } // if we have pixel sdo's available
544 }
545 pixelClusterIndexMap[theId] = pixelClusterIndex;
546 pixelClusterIndex++;
547 } // End loop over pixel clusters
548 } // End loop over pixel cluster collection
549
550 return StatusCode::SUCCESS;
551}
#define ATH_MSG_DEBUG(x)
SG::ReadHandleKey< InDet::SiClusterContainer > m_pixelClusterContainerKey
const HepMcParticleLink * getTruthInformation(InDetSimDataCollection::const_iterator &iter, FPGATrackSimInputUtils::ParentBitmask &parentMask) const
const InDetDD::SiDetectorManager * m_PIX_mgr
SG::ReadHandleKey< InDetSimDataCollection > m_pixelSDOKey
virtual SiCellId connectedCell(const SiReadoutCellId &readoutId, int number) const =0
readout id -> id of connected diodes.
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
virtual Identifier identifierFromCellId(const SiCellId &cellId) const override final
Identifier <-> SiCellId (ie strip number or pixel eta_index,phi_index) Identifier from SiCellId (ie s...
int numberOfConnectedCells(const SiCellId cellId) const
Test if readout cell has more than one diode associated with it.
std::bitset< NBITS > ParentBitmask
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
setRawEt setRawPhi nCells

◆ finalize()

StatusCode FPGATrackSimSGToRawHitsTool::finalize ( )
overridevirtual

Definition at line 80 of file FPGATrackSimSGToRawHitsTool.cxx.

80 {
81 return StatusCode::SUCCESS;
82}

◆ getTruthInformation()

const HepMcParticleLink * FPGATrackSimSGToRawHitsTool::getTruthInformation ( InDetSimDataCollection::const_iterator & iter,
FPGATrackSimInputUtils::ParentBitmask & parentMask ) const
private

Definition at line 838 of file FPGATrackSimSGToRawHitsTool.cxx.

839 {
840 const HepMcParticleLink* bestTruthLink{};
841 const InDetSimData& sdo(iter->second);
842 const std::vector<InDetSimData::Deposit>& deposits(sdo.getdeposits());
843 float bestPt{-999.f};
844 for (const InDetSimData::Deposit& dep : deposits) {
845
846 const HepMcParticleLink& particleLink = dep.first;
847 // RDO's without SDO's are delta rays or detector noise.
848 if (!particleLink.isValid()) { continue; }
849 const float genEta = particleLink->momentum().pseudoRapidity();
850 const float genPt = particleLink->momentum().perp(); // MeV
851 // reject unstable particles
852 if (!MC::isStable(particleLink.cptr())) { continue; }
853 // reject secondaries and low pT (<400 MeV) pileup
854 if (HepMC::is_simulation_particle(particleLink.cptr()) || particleLink.barcode() == 0 /*HepMC::no_truth_link(particleLink)*/) { continue; } // FIXME
855 // reject far forward particles
856 if (std::fabs(genEta) > m_maxEta) { continue; }
857 // "bestTruthLink" links to the highest pt particle
858 if (bestPt < genPt) {
859 bestPt = genPt;
860 bestTruthLink = &particleLink;
861 }
862 parentMask |= FPGATrackSimInputUtils::construct_truth_bitmap(std::shared_ptr<const HepMC3::GenParticle>(particleLink.cptr()));
863 // check SDO
864 } // end for each contributing particle
865 return bestTruthLink;
866}
std::pair< HepMcParticleLink, float > Deposit
const ParentBitmask construct_truth_bitmap(HepMC::ConstGenParticlePtr p)
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.

◆ initialize()

StatusCode FPGATrackSimSGToRawHitsTool::initialize ( )
overridevirtual

Definition at line 50 of file FPGATrackSimSGToRawHitsTool.cxx.

50 {
51
52 ATH_MSG_DEBUG("FPGATrackSimSGToRawHitsTool::initialize()");
53
54 if(!m_truthToTrack.empty() ) ATH_CHECK(m_truthToTrack.retrieve());
55 if(!m_extrapolator.empty()) ATH_CHECK(m_extrapolator.retrieve());
56 ATH_CHECK(m_beamSpotKey.initialize());
57
58 ATH_CHECK(detStore()->retrieve(m_PIX_mgr, "ITkPixel"));
59 ATH_CHECK(detStore()->retrieve(m_pixelId, "PixelID"));
60 ATH_CHECK(detStore()->retrieve(m_SCT_mgr, "ITkStrip"));
61 ATH_CHECK(detStore()->retrieve(m_sctId, "SCT_ID"));
62
63 ATH_CHECK(m_eventInfoKey.initialize());
66
68
72 ATH_CHECK(m_pixelRDOKey.initialize());
73 ATH_CHECK(m_stripRDOKey.initialize());
74
75 ATH_MSG_DEBUG("Initialization complete");
76 return StatusCode::SUCCESS;
77}
#define ATH_CHECK
Evaluate an expression and check for errors.
ToolHandle< Trk::ITruthToTrack > m_truthToTrack
tool to create track parameters from a gen particle
const InDetDD::SiDetectorManager * m_SCT_mgr
SG::ReadHandleKey< InDetSimDataCollection > m_stripSDOKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_offlineTracksKey
ToolHandle< Trk::IExtrapolator > m_extrapolator
ToolHandle for Extrapolator.
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
SG::ReadHandleKey< InDet::SiClusterContainer > m_sctClusterContainerKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
SG::ReadHandleKey< McEventCollection > m_mcCollectionKey

◆ readData()

StatusCode FPGATrackSimSGToRawHitsTool::readData ( FPGATrackSimEventInputHeader * header,
const EventContext & eventContext ) const
overridevirtual

This function get from the SG the inner detector raw hits and prepares them for FPGATrackSim simulation.

Definition at line 87 of file FPGATrackSimSGToRawHitsTool.cxx.

88{
89
90 auto eventInfo = SG::makeHandle(m_eventInfoKey, eventContext);
91 //Filled to variable / start event
92 FPGATrackSimEventInfo event_info;
93 event_info.setRunNumber(eventInfo->runNumber());
94 event_info.setEventNumber(eventInfo->eventNumber());
95 event_info.setLB(eventInfo->lumiBlock());
96 event_info.setBCID(eventInfo->bcid());
97 event_info.setaverageInteractionsPerCrossing(eventInfo->averageInteractionsPerCrossing());
98 event_info.setactualInteractionsPerCrossing(eventInfo->actualInteractionsPerCrossing());
99 event_info.setextendedLevel1ID(eventInfo->extendedLevel1ID());
100 event_info.setlevel1TriggerType(eventInfo->level1TriggerType());
101 eventHeader->newEvent(event_info);
102
103 HitIndexMap hitIndexMap; // keep running index event-unique to each hit
104 HitIndexMap pixelClusterIndexMap;
105 // get pixel and sct cluster containers
106 // dump raw silicon data
107 ATH_MSG_DEBUG("Dump raw silicon data");
108 ATH_CHECK(readRawSilicon(eventHeader, hitIndexMap, eventContext));
109 FPGATrackSimOptionalEventInfo optional;
111 std::vector <FPGATrackSimCluster> clusters;
112 ATH_CHECK(readOfflineClusters(clusters, eventContext));
113 for (const auto& cluster : clusters) optional.addOfflineCluster(cluster);
114 ATH_MSG_DEBUG("Saved " << optional.nOfflineClusters() << " offline clusters");
115 ATH_CHECK(dumpPixelClusters(pixelClusterIndexMap, eventContext));
116 }
117 if (m_readTruthTracks) {
118 std::vector <FPGATrackSimTruthTrack> truth;
119 ATH_CHECK(readTruthTracks(truth, eventContext));
120 for (const FPGATrackSimTruthTrack& trk : truth) optional.addTruthTrack(trk);
121 ATH_MSG_DEBUG("Saved " << optional.nTruthTracks() << " truth tracks");
122 }
123 std::vector <FPGATrackSimOfflineTrack> offline;
125 ATH_CHECK(readOfflineTracks(offline, eventContext));
126 for (const FPGATrackSimOfflineTrack& trk : offline) optional.addOfflineTrack(trk);
127 ATH_MSG_DEBUG("Saved " << optional.nOfflineTracks() << " offline tracks");
128 }
129 eventHeader->setOptional(optional);
130 ATH_MSG_DEBUG(*eventHeader);
131 ATH_MSG_DEBUG("End of execute()");
132 return StatusCode::SUCCESS;
133}
void setaverageInteractionsPerCrossing(const int &val)
void setBCID(const int &val)
void setLB(const int &val)
void setRunNumber(const unsigned long &val)
void setlevel1TriggerType(const unsigned int &val)
void setactualInteractionsPerCrossing(const int &val)
void setEventNumber(const unsigned long &val)
void setextendedLevel1ID(const unsigned int &val)
void addOfflineCluster(const FPGATrackSimCluster &c) const
void addOfflineTrack(const FPGATrackSimOfflineTrack &t) const
void addTruthTrack(const FPGATrackSimTruthTrack &t) const
Gaudi::Property< bool > m_readOfflineTracks
StatusCode readOfflineClusters(std::vector< FPGATrackSimCluster > &Clusters, const EventContext &eventContext) const
StatusCode readRawSilicon(FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, const EventContext &eventContext) const
StatusCode readOfflineTracks(std::vector< FPGATrackSimOfflineTrack > &Track, const EventContext &eventContext) const
Gaudi::Property< bool > m_readOfflineClusters
std::map< Identifier, int > HitIndexMap
Gaudi::Property< bool > m_readTruthTracks
StatusCode readTruthTracks(std::vector< FPGATrackSimTruthTrack > &truth, const EventContext &eventContext) const
StatusCode dumpPixelClusters(HitIndexMap &pixelClusterIndexMap, const EventContext &eventContext) const

◆ readOfflineClusters()

StatusCode FPGATrackSimSGToRawHitsTool::readOfflineClusters ( std::vector< FPGATrackSimCluster > & Clusters,
const EventContext & eventContext ) const
private

Definition at line 554 of file FPGATrackSimSGToRawHitsTool.cxx.

556{
557
558 //Lets do the Pixel clusters first
559 //Loopover the pixel clusters and convert them into a FPGATrackSimCluster for storage
560 // Dump pixel clusters. They're in m_pixelContainer
561 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
562 auto pixelClusterContainerHandler = SG::makeHandle(m_pixelClusterContainerKey, eventContext);
563 for (const InDet::SiClusterCollection* pixelClusterCollection : *pixelClusterContainerHandler) {
564 if (pixelClusterCollection == nullptr) {
565 ATH_MSG_DEBUG("pixelClusterCollection not available!");
566 continue;
567 }
568 const int size = pixelClusterCollection->size();
569 ATH_MSG_DEBUG("PixelClusterCollection found with " << size << " clusters");
570 for (const InDet::SiCluster* cluster : *pixelClusterCollection) {
571
572 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel cluster.
574 const HepMcParticleLink* bestTruthLink{};
575 if (!m_pixelSDOKey.empty()) {
576 for (const Identifier& rdoId : cluster->rdoList()) {
577 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId);
578 assert(sielement);
579 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
580 const int nCells = sielement->numberOfConnectedCells(cellID);
581 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
582 // this might be the ganged pixel copy.
583 if (nCells > 1 && iter == pixelSDOHandle->end()) {
584 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
585 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
586 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
587 }
588 } // end search for correct ganged pixel
589 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
590 if (iter != pixelSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
591 } // if we have pixel sdo's available
592 }
593 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
594
595 Identifier theID = cluster->identify();
596 //cluster object to be written out
597 FPGATrackSimCluster clusterOut;
598 //Rawhit object to represent the cluster
599 FPGATrackSimHit clusterEquiv;
600 //Lets get the information of this pixel cluster
601 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(theID);
602 assert(sielement);
603 const InDetDD::SiLocalPosition localPos = sielement->rawLocalPositionOfCell(theID);
604 const Amg::Vector3D globalPos(sielement->globalPosition(localPos));
605 clusterEquiv.setHitType(HitType::clustered);
606 clusterEquiv.setX(globalPos.x());
607 clusterEquiv.setY(globalPos.y());
608 clusterEquiv.setZ(globalPos.z());
609 clusterEquiv.setDetType(SiliconTech::pixel);
610 clusterEquiv.setIdentifierHash(sielement->identifyHash());
611 clusterEquiv.setIdentifier(sielement->identify().get_identifier32().get_compact());
612
613 int barrel_ec = m_pixelId->barrel_ec(theID);
614 if (barrel_ec == 0)
616 else if (barrel_ec == 2)
618 else if (barrel_ec == -2)
620
621 clusterEquiv.setLayerDisk(m_pixelId->layer_disk(theID));
622 clusterEquiv.setPhiModule(m_pixelId->phi_module(theID));
623 clusterEquiv.setEtaModule(m_pixelId->eta_module(theID));
624 clusterEquiv.setPhiIndex(m_pixelId->phi_index(theID));
625 clusterEquiv.setEtaIndex(m_pixelId->eta_index(theID));
626 clusterEquiv.setPhiCoord(localPos.xPhi());
627 clusterEquiv.setEtaCoord(localPos.xEta());
628
629 clusterEquiv.setPhiWidth(cluster->width().colRow()[1]);
630 clusterEquiv.setEtaWidth(cluster->width().colRow()[0]);
631 //Save the truth here as the MultiTruth object is only transient
632 if (bestParent) {
633 clusterEquiv.setEventIndex(bestTruthLink->eventIndex());
634 clusterEquiv.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
635 clusterEquiv.setUniqueID(bestTruthLink->id());
636 }
637 else {
638 clusterEquiv.setEventIndex(std::numeric_limits<long>::max());
639 clusterEquiv.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
640 clusterEquiv.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
641 }
642
643 clusterEquiv.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
644 clusterEquiv.setParentageMask(parentMask.to_ulong());
645 clusterOut.setClusterEquiv(clusterEquiv);
646 clusters.push_back(clusterOut);
647 }
648 }
649
650 //Now lets do the strip clusters
651 //Loopover the pixel clusters and convert them into a FPGATrackSimCluster for storage
652 // Dump pixel clusters. They're in m_pixelContainer
653 auto stripSDOHandle = SG::makeHandle(m_stripSDOKey, eventContext);
654 ATH_MSG_DEBUG("Found SCT SDO Map");
655 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, eventContext);
656
657 for (const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection : *stripRDOHandle) {
658 if (SCT_Collection == nullptr) { continue; }
659 for (const SCT_RDORawData* sctRawData : *SCT_Collection) {
660 const Identifier rdoId = sctRawData->identify();
661 // get the det element from the det element collection
662 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(rdoId);
663 const InDetDD::SiDetectorDesign& design = dynamic_cast<const InDetDD::SiDetectorDesign&>(sielement->design());
664 const InDetDD::SiLocalPosition localPos = design.localPositionOfCell(m_sctId->strip(rdoId));
665 const Amg::Vector3D gPos = sielement->globalPosition(localPos);
666 // if there is simulation truth available, try to retrieve the
667 // "most likely" barcode for this strip.
669 const HepMcParticleLink* bestTruthLink{};
670 if (!m_stripSDOKey.empty()) {
671 InDetSimDataCollection::const_iterator iter(stripSDOHandle->find(rdoId));
672 // if SDO found for this pixel, associate the particle
673 if (iter != stripSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
674 } // end if sct truth available
675 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
676
677 // push back the hit information to DataInput for HitList , copy from RawInput.cxx
678 FPGATrackSimCluster clusterOut;
679 FPGATrackSimHit clusterEquiv;
680 clusterEquiv.setHitType(HitType::clustered);
681 clusterEquiv.setX(gPos.x());
682 clusterEquiv.setY(gPos.y());
683 clusterEquiv.setZ(gPos.z());
684 clusterEquiv.setDetType(SiliconTech::strip);
685 clusterEquiv.setIdentifierHash(sielement->identifyHash());
686 clusterEquiv.setIdentifier(sielement->identify().get_identifier32().get_compact());
687
688 int barrel_ec = m_sctId->barrel_ec(rdoId);
689 if (barrel_ec == 0)
691 else if (barrel_ec == 2)
693 else if (barrel_ec == -2)
695
696 clusterEquiv.setLayerDisk(m_sctId->layer_disk(rdoId));
697 clusterEquiv.setPhiModule(m_sctId->phi_module(rdoId));
698 clusterEquiv.setEtaModule(m_sctId->eta_module(rdoId));
699 clusterEquiv.setPhiIndex(m_sctId->strip(rdoId));
700 clusterEquiv.setEtaIndex(m_sctId->row(rdoId));
701 clusterEquiv.setPhiCoord(localPos.xPhi());
702 clusterEquiv.setEtaCoord(localPos.xEta());
703 clusterEquiv.setSide(m_sctId->side(rdoId));
704 //I think this is the strip "cluster" width
705 clusterEquiv.setPhiWidth(sctRawData->getGroupSize());
706 //Save the truth here as the MultiTruth object is only transient
707 if (bestParent) {
708 clusterEquiv.setEventIndex(bestTruthLink->eventIndex());
709 clusterEquiv.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
710 clusterEquiv.setUniqueID(bestTruthLink->id());
711 }
712 else {
713 clusterEquiv.setEventIndex(std::numeric_limits<long>::max());
714 clusterEquiv.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
715 clusterEquiv.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
716 }
717
718 clusterEquiv.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
719 clusterEquiv.setParentageMask(parentMask.to_ulong());
720 clusterOut.setClusterEquiv(clusterEquiv);
721 clusters.push_back(clusterOut);
722 } // end for each RDO in the strip collection
723 } // end for each strip RDO collection
724 // dump all RDO's and SDO's for a given event, for debugging purposes
725
726 return StatusCode::SUCCESS;
727}
size_t size() const
Number of registered mappings.
void setClusterEquiv(const FPGATrackSimHit &input)
void setPhiModule(unsigned v)
void setIdentifierHash(unsigned v)
void setEtaIndex(unsigned v)
void setEventIndex(long v)
void setPhiIndex(unsigned v)
void setHitType(HitType type)
void setPhiCoord(float v)
void setIdentifier(unsigned int v)
void setZ(float v)
void setBarcode(const HepMcParticleLink::barcode_type &v)
void setX(float v)
void setParentageMask(unsigned long v)
void setBarcodePt(float v)
void setY(float v)
void setLayerDisk(unsigned v)
void setEtaModule(int v)
void setSide(unsigned v)
void setEtaCoord(float v)
void setEtaWidth(unsigned v)
void setPhiWidth(unsigned v)
void setUniqueID(const HepMcParticleLink::barcode_type &v)
void setDetectorZone(DetectorZone detZone)
void setDetType(SiliconTech detType)
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const =0
readout or diode id -> position.
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
virtual Identifier identify() const override final
identifier of this detector element (inline)
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
Eigen::Matrix< double, 3, 1 > Vector3D
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20

◆ readOfflineTracks()

StatusCode FPGATrackSimSGToRawHitsTool::readOfflineTracks ( std::vector< FPGATrackSimOfflineTrack > & Track,
const EventContext & eventContext ) const
private

Definition at line 136 of file FPGATrackSimSGToRawHitsTool.cxx.

137{
138 auto offlineTracksHandle = SG::makeHandle(m_offlineTracksKey, eventContext);
139 ATH_MSG_DEBUG("read Offline tracks, size= " << offlineTracksHandle->size());
140
141 int iTrk = -1;
142 for (const xAOD::TrackParticle* trackParticle : *offlineTracksHandle) {
143 iTrk++;
144 FPGATrackSimOfflineTrack tmpOfflineTrack;
145 tmpOfflineTrack.setQOverPt(trackParticle->pt() > 0 ? trackParticle->charge() / trackParticle->pt() : 0);
146 tmpOfflineTrack.setEta(trackParticle->eta());
147 tmpOfflineTrack.setPhi(trackParticle->phi());
148 tmpOfflineTrack.setD0(trackParticle->d0());
149 tmpOfflineTrack.setZ0(trackParticle->z0());
150
151 const Trk::TrackStates* trackStates = trackParticle->track()->trackStateOnSurfaces();
152 if (trackStates == nullptr) {
153 ATH_MSG_ERROR("missing trackStatesOnSurface");
154 return StatusCode::FAILURE;
155 }
156 for (const Trk::TrackStateOnSurface* tsos : *trackStates) {
157 if (tsos == nullptr) continue;
159 const Trk::MeasurementBase* measurement = tsos->measurementOnTrack();
160 if (tsos->trackParameters() != nullptr &&
161 tsos->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr &&
162 tsos->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0
163 ) {
164 const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>(measurement);
165 const Identifier& hitId = hit->identify();
166 FPGATrackSimOfflineHit tmpOfflineHit;
167 if (m_pixelId->is_pixel(hitId)) {
168 tmpOfflineHit.setIsPixel(true);
169 tmpOfflineHit.setIsBarrel(m_pixelId->is_barrel(hitId));
170
171 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(hitId);
172 tmpOfflineHit.setClusterID(sielement->identifyHash());
173 tmpOfflineHit.setTrackNumber(iTrk);
174 tmpOfflineHit.setLayer(m_pixelId->layer_disk(hitId));
175 tmpOfflineHit.setLocX((float)measurement->localParameters()[Trk::locX]);
176 tmpOfflineHit.setLocY((float)measurement->localParameters()[Trk::locY]);
177 }
178 else if (m_sctId->is_sct(hitId)) {
179 tmpOfflineHit.setIsPixel(false);
180 tmpOfflineHit.setIsBarrel(m_sctId->is_barrel(hitId));
181 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(hitId);
182 tmpOfflineHit.setClusterID(sielement->identifyHash());
183 tmpOfflineHit.setTrackNumber(iTrk);
184 tmpOfflineHit.setLayer(m_sctId->layer_disk(hitId));
185 tmpOfflineHit.setLocX(((float)measurement->localParameters()[Trk::locX]));
186 tmpOfflineHit.setLocY(-99999.9);
187 }
188 tmpOfflineTrack.addHit(tmpOfflineHit);
189 }
190 }
191 }
192 offline.push_back(tmpOfflineTrack);
193 }//end of loop over tracks
194
195
196 return StatusCode::SUCCESS;
197}
#define ATH_MSG_ERROR(x)
void addHit(const FPGATrackSimOfflineHit &s)
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Identifier identify() const
return the identifier -extends MeasurementBase
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ readPixelSimulation()

StatusCode FPGATrackSimSGToRawHitsTool::readPixelSimulation ( FPGATrackSimEventInputHeader * header,
HitIndexMap & hitIndexMap,
unsigned int & hitIndex,
const EventContext & eventContext ) const
private

Definition at line 219 of file FPGATrackSimSGToRawHitsTool.cxx.

223 {
224
225 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
226 auto pixelRDOHandle = SG::makeHandle(m_pixelRDOKey, eventContext);
227
228 ATH_MSG_DEBUG("Found Pixel SDO Map");
229
230 for (const InDetRawDataCollection<PixelRDORawData>* pixel_rdoCollection : *pixelRDOHandle) {
231 if (pixel_rdoCollection == nullptr) { continue; }
232 // loop on all RDOs
233 for (const PixelRDORawData* pixelRawData : *pixel_rdoCollection) {
234 Identifier rdoId = pixelRawData->identify();
235 // get the det element from the det element collection
236 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId); assert(sielement);
237
238 Amg::Vector2D localPos = sielement->rawLocalPositionOfCell(rdoId);
239 Amg::Vector3D globalPos = sielement->globalPosition(localPos);
240 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
241
242 // update map between pixel identifier and event-unique hit index.
243 // ganged pixels (nCells==2) get two entries.
244 hitIndexMap[rdoId] = hitIndex;
245 const int nCells = sielement->numberOfConnectedCells(cellID);
246 if (nCells == 2) {
247 const InDetDD::SiCellId tmpCell = sielement->connectedCell(cellID, 1);
248 const Identifier tmpId = sielement->identifierFromCellId(tmpCell);
249 hitIndexMap[tmpId] = hitIndex; // add second entry for ganged pixel ID
250 }
251 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel.
253 const HepMcParticleLink* bestTruthLink{};
254 if (!m_pixelSDOKey.empty()) {
255 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
256 if (nCells > 1 && iter == pixelSDOHandle->end()) {
257 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
258 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
259 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
260 }
261 } // end search for correct ganged pixel
262 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
263 if (iter != pixelSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
264 } // end if pixel truth available
265 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
266 ++hitIndex;
267
268 // push back the hit information to DataInput for HitList
269 FPGATrackSimHit tmpSGhit;
272 tmpSGhit.setIdentifierHash(sielement->identifyHash());
273 tmpSGhit.setIdentifier(sielement->identify().get_identifier32().get_compact());
274 tmpSGhit.setRdoIdentifier(rdoId.get_compact()); // full 64 bit hit identifier
275
276 int barrel_ec = m_pixelId->barrel_ec(rdoId);
277 if (barrel_ec == 0)
279 else if (barrel_ec == 2)
281 else if (barrel_ec == -2)
283
284 tmpSGhit.setLayerDisk(m_pixelId->layer_disk(rdoId));
285 tmpSGhit.setPhiModule(m_pixelId->phi_module(rdoId));
286 tmpSGhit.setEtaModule(m_pixelId->eta_module(rdoId));
287 tmpSGhit.setPhiIndex(m_pixelId->phi_index(rdoId));
288 tmpSGhit.setEtaIndex(m_pixelId->eta_index(rdoId));
289 tmpSGhit.setPhiCoord(localPos[0]);
290 tmpSGhit.setEtaCoord(localPos[1]);
291 tmpSGhit.setEtaWidth(0);
292 tmpSGhit.setPhiWidth(0);
293 tmpSGhit.setX(globalPos[Amg::x]);
294 tmpSGhit.setY(globalPos[Amg::y]);
295 tmpSGhit.setZ(globalPos[Amg::z]);
296 tmpSGhit.setToT(pixelRawData->getToT());
297 tmpSGhit.setisValidForITkHit(true); // Pixel clusters are close enough right now that they all can be considered valid for ITK
298 if (bestParent) {
299 tmpSGhit.setEventIndex(bestTruthLink->eventIndex());
300 tmpSGhit.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
301 tmpSGhit.setUniqueID(bestTruthLink->id()); // May need fixing when uid will be used.
302 }
303 else {
304 tmpSGhit.setEventIndex(std::numeric_limits<long>::max());
305 tmpSGhit.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
306 tmpSGhit.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
307 }
308
309 tmpSGhit.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
310 tmpSGhit.setParentageMask(parentMask.to_ulong());
311
312 if (m_doMultiTruth) {
313 // Add truth
314 FPGATrackSimMultiTruth mt;
315 FPGATrackSimMultiTruth::Barcode uniqueID(tmpSGhit.getEventIndex(), tmpSGhit.getBarcode()); // FIXME barcode-based
316 mt.maximize(uniqueID, tmpSGhit.getBarcodePt()); // FIXME barcode-based
317 tmpSGhit.setTruth(mt);
318 }
319
320 eventHeader->addHit(tmpSGhit);
321 } // end for each RDO in the collection
322 } // for each pixel RDO collection
323
324 return StatusCode::SUCCESS;
325}
long getEventIndex() const
float getBarcodePt() const
void setisValidForITkHit(bool v)
void setRdoIdentifier(Identifier::value_type v)
HepMcParticleLink::barcode_type getBarcode() const
void setToT(unsigned v)
void setTruth(const FPGATrackSimMultiTruth &v)
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
std::pair< unsigned long, unsigned long > Barcode
value_type get_compact() const
Get the compact id.
SiCellId connectedCell(const SiCellId cellId, int number) const
Get the cell ids sharing the readout for this cell.
Eigen::Matrix< double, 2, 1 > Vector2D
int uniqueID(const T &p)

◆ readRawSilicon()

StatusCode FPGATrackSimSGToRawHitsTool::readRawSilicon ( FPGATrackSimEventInputHeader * header,
HitIndexMap & hitIndexMap,
const EventContext & eventContext ) const
private

Definition at line 203 of file FPGATrackSimSGToRawHitsTool.cxx.

207{
208 ATH_MSG_DEBUG("read silicon hits");
209 unsigned int hitIndex = 0u;
210
211 ATH_CHECK(readPixelSimulation(eventHeader, hitIndexMap, hitIndex, eventContext));
212 ATH_CHECK(readStripSimulation(eventHeader, hitIndexMap, hitIndex, eventContext));
213
214 return StatusCode::SUCCESS;
215}
StatusCode readPixelSimulation(FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext) const
StatusCode readStripSimulation(FPGATrackSimEventInputHeader *header, HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext) const
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ readStripSimulation()

StatusCode FPGATrackSimSGToRawHitsTool::readStripSimulation ( FPGATrackSimEventInputHeader * header,
HitIndexMap & hitIndexMap,
unsigned int & hitIndex,
const EventContext & eventContext ) const
private

Definition at line 328 of file FPGATrackSimSGToRawHitsTool.cxx.

332 {
333
334 constexpr int MaxChannelinStripRow = 128;
335
336 auto stripSDOHandle = SG::makeHandle(m_stripSDOKey, eventContext);
337 ATH_MSG_DEBUG("Found SCT SDO Map");
338 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, eventContext);
339 for (const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection : *stripRDOHandle) {
340 if (SCT_Collection == nullptr) { continue; }
341
342 std::map<int, bool> firedStrips;
343 std::map<int, const SCT_RDORawData*> firedStripsToRDO;
344 // Preprocess the SCT collection hits to get information for encoding strip in ITK format
345 // All strips fired read into a map to an overview of full module that should be used to encode
346 // the data into the ITk formatl
347 for (const SCT_RDORawData* sctRawData : *SCT_Collection)
348 {
349 const Identifier rdoId = sctRawData->identify();
350 const int baseLineStrip{m_sctId->strip(rdoId)};
351 for(int i = 0; i < sctRawData->getGroupSize(); i++) {
352 firedStrips[baseLineStrip+ i] = true;
353 firedStripsToRDO[baseLineStrip + i] = sctRawData;
354 }
355 }
356
357 // Loop over the fired hits and encode them in the ITk strips hit map
358 // It find unique hits in the list that can be encoded and don't overlap
359 std::map<int, int> stripEncodingForITK;
360 std::map<int, const SCT_RDORawData* > stripEncodingForITKToRDO;
361 for(const auto& [stripID, fired]: firedStrips)
362 {
363 // Don't use the strip that has been set false.
364 // This will be the case where neighbouring strip will "used up in the cluster"
365 // And then we don't want to re use them
366 if(!fired) continue;
367
368 // Check the next 3 hits if they are there and have a hit in them
369 std::bitset<3> hitMap;
370
371
372 // Get the current chip id of the strip
373 int currChipID = stripID / MaxChannelinStripRow;
374 // Compute the maximum stripID this chip can have
375 int maxStripIDForCurrChip = (currChipID + 1) * MaxChannelinStripRow;
376
377 for(int i = 0; i < 3; i++)
378 {
379 // We don't want to "cluster" strips that are outside the range of this chip
380 if((stripID + 1 + i) >= maxStripIDForCurrChip) continue;
381
382 if(firedStrips.find(stripID + 1 + i) != firedStrips.end())
383 {
384 if(firedStrips.at(stripID + 1 + i))
385 {
386 hitMap[2 - i] = 1;
387 firedStrips[stripID + 1 + i] = false;
388 }
389 else
390 {
391 hitMap[2 - i] = 0;
392 }
393 }
394 }
395
396 // Encode the hit map into a int
397 stripEncodingForITK[stripID] = (int)(hitMap.to_ulong());
398 stripEncodingForITKToRDO[stripID] = firedStripsToRDO[stripID];
399 }
400
401 // Actual creation of the FPGAHit objects
402 for(const auto& [stripID, fired]: firedStrips)
403 {
404 const SCT_RDORawData* sctRawData = firedStripsToRDO[stripID];
405 const Identifier rdoId = sctRawData->identify();
406 // get the det element from the det element collection
407 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(rdoId);
408 const InDetDD::SiDetectorDesign& design = dynamic_cast<const InDetDD::SiDetectorDesign&>(sielement->design());
409
410 InDetDD::SiCellId frontId(stripID);
411 Amg::Vector2D localPos = design.localPositionOfCell(frontId);
412 std::pair<Amg::Vector3D, Amg::Vector3D> endsOfStrip = sielement->endsOfStrip(localPos);
413
414 hitIndexMap[rdoId] = hitIndex;
415 ++hitIndex;
416 // if there is simulation truth available, try to retrieve the
417 // "most likely" barcode for this strip.
419 const HepMcParticleLink* bestTruthLink{};
420 if (!m_stripSDOKey.empty()) {
421 InDetSimDataCollection::const_iterator iter(stripSDOHandle->find(rdoId));
422 // if SDO found for this strip, associate the particle
423 if (iter != stripSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
424 } // end if sct truth available
425 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
426 // push back the hit information to DataInput for HitList , copy from RawInput.cxx
427
428 FPGATrackSimHit tmpSGhit;
431 tmpSGhit.setIdentifierHash(sielement->identifyHash());
432 tmpSGhit.setIdentifier(sielement->identify().get_identifier32().get_compact());
433 tmpSGhit.setRdoIdentifier(rdoId.get_compact()); // full 64 bit hit identifier
434
435 int barrel_ec = m_sctId->barrel_ec(rdoId);
436 if (barrel_ec == 0)
438 else if (barrel_ec == 2)
440 else if (barrel_ec == -2)
442
443 tmpSGhit.setLayerDisk(m_sctId->layer_disk(rdoId));
444 tmpSGhit.setPhiModule(m_sctId->phi_module(rdoId));
445 tmpSGhit.setEtaModule(m_sctId->eta_module(rdoId));
446 tmpSGhit.setPhiIndex(stripID);
447 tmpSGhit.setEtaIndex(m_sctId->row(rdoId));
448 tmpSGhit.setPhiCoord(localPos[0]);
449 tmpSGhit.setEtaCoord(localPos[1]);
450 tmpSGhit.setSide(m_sctId->side(rdoId));
451 tmpSGhit.setEtaWidth(0);
452 tmpSGhit.setPhiWidth(1);
453 if (bestParent) {
454 tmpSGhit.setEventIndex(bestTruthLink->eventIndex());
455 tmpSGhit.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
456 tmpSGhit.setUniqueID(bestTruthLink->id());
457 }
458 else {
459 tmpSGhit.setEventIndex(std::numeric_limits<long>::max());
460 tmpSGhit.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
461 tmpSGhit.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
462 }
463
464 // If the strip has been identified by the previous for loop as a valid hit that can be encoded into ITk Strip format
465 if(stripEncodingForITK.find(stripID) != stripEncodingForITK.end())
466 {
467 // Each ITK ABC chip reads 128 channels in one row, so we just need to divide the current strip with 128 to get the chip index
468 // for the Strip ID, it is the remainder left after dividing by 128
469 int chipID = stripID / MaxChannelinStripRow;
470 int ITkStripID = stripID % MaxChannelinStripRow;
471
472 // for each ABC chip readout, each reads 256 channels actually. 0-127 corresponds to lower row and then 128-255 corresponds to the
473 // upper. This can be simulated in the code by using the eta module index. Even index are not offset, while odd index, the
474 // strip id is offset by 128
475 // One point to not is that for barrel, the eta module index start at 1, and not zero. Hence a shift of 1 is needed
476 int offset = m_sctId->eta_module(rdoId) % 2;
477 if(m_sctId->barrel_ec(rdoId) == 0) offset = (std::abs(m_sctId->eta_module(rdoId)) - 1) % 2;
478
479 ITkStripID += offset * MaxChannelinStripRow;
480
481 tmpSGhit.setisValidForITkHit(true);
482 tmpSGhit.setStripRowIDForITk(ITkStripID);
483 tmpSGhit.setStripChipIDForITk(chipID);
484 tmpSGhit.setStripHitMapForITk(stripEncodingForITK.at(stripID));
485 }
486
487 tmpSGhit.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
488 tmpSGhit.setParentageMask(parentMask.to_ulong());
489 tmpSGhit.setX(0.5 * (endsOfStrip.first.x() + endsOfStrip.second.x()));
490 tmpSGhit.setY(0.5 * (endsOfStrip.first.y() + endsOfStrip.second.y()));
491 tmpSGhit.setZ(0.5 * (endsOfStrip.first.z() + endsOfStrip.second.z()));
492
493 if (m_doMultiTruth) {
494 // Add truth
495 FPGATrackSimMultiTruth mt;
496 FPGATrackSimMultiTruth::Barcode uniqueID(tmpSGhit.getEventIndex(), tmpSGhit.getBarcode()); // FIXME barcode-based
497 mt.maximize(uniqueID, tmpSGhit.getBarcodePt()); // FIMXE barcode-based
498 tmpSGhit.setTruth(mt);
499 }
500
501 eventHeader->addHit(tmpSGhit);
502 } // end for each RDO in the strip collection
503 } // end for each strip RDO collection
504 // dump all RDO's and SDO's for a given event, for debugging purposes
505
506 return StatusCode::SUCCESS;
507}
void setStripChipIDForITk(int v)
void setStripHitMapForITk(int v)
void setStripRowIDForITk(int v)
std::pair< Amg::Vector3D, Amg::Vector3D > endsOfStrip(const Amg::Vector2D &position) const
Special method for SCT to retrieve the two ends of a "strip" Returned coordinates are in global frame...
virtual Identifier identify() const override final

◆ readTruthTracks()

StatusCode FPGATrackSimSGToRawHitsTool::readTruthTracks ( std::vector< FPGATrackSimTruthTrack > & truth,
const EventContext & eventContext ) const
private

Definition at line 730 of file FPGATrackSimSGToRawHitsTool.cxx.

731{
732 auto simTracksHandle = SG::makeHandle(m_mcCollectionKey, eventContext);
733 ATH_MSG_DEBUG("Dump truth tracks, size " << simTracksHandle->size());
734
735 // dump each truth track
736 for (unsigned int ievt = 0; ievt < simTracksHandle->size(); ++ievt) {
737 const HepMC::GenEvent* genEvent = simTracksHandle->at(ievt);
738 // retrieve the primary interaction vertex here. for now, use the dummy origin.
739 HepGeom::Point3D<double> primaryVtx(0., 0., 0.);
740 // the event should have signal process vertex unless it was generated as single particles.
741 // if it exists, use it for the primary vertex.
743 if (spv) {
744 primaryVtx.set(spv->position().x(),
745 spv->position().y(),
746 spv->position().z());
747 ATH_MSG_DEBUG("using signal process vertex for eventIndex " << ievt << ":"
748 << primaryVtx.x() << "\t" << primaryVtx.y() << "\t" << primaryVtx.z());
749 }
750 for (const auto& particle: *genEvent) {
751 const int pdgcode = particle->pdg_id();
752 // reject generated particles without a production vertex.
753 if (particle->production_vertex() == nullptr) {
754 continue;
755 }
756 float charge = MC::charge(pdgcode);
757 if (std::abs(charge) < 0.5) {
758 continue;
759 }
760 if (!MC::isStable(particle)) {
761 continue;
762 }
763 // truth-to-track tool
764 const Amg::Vector3D momentum(particle->momentum().px(), particle->momentum().py(), particle->momentum().pz());
765 const Amg::Vector3D position(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
766 const Trk::CurvilinearParameters cParameters(position, momentum, charge);
767 Trk::PerigeeSurface persf;
768 if (m_UseNominalOrigin) {
769 Amg::Vector3D origin(0, 0, 0);
770 persf = Trk::PerigeeSurface(origin);
771 }
772 else {
773 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle{ m_beamSpotKey, eventContext };
774 Trk::PerigeeSurface persf(beamSpotHandle->beamPos());
775 }
776 const std::unique_ptr<Trk::TrackParameters> tP = m_extrapolator->extrapolate(eventContext, cParameters, persf, Trk::anyDirection, false);
777 const double track_truth_d0 = tP ? tP->parameters()[Trk::d0] : 999.;
778 const double track_truth_phi = tP ? tP->parameters()[Trk::phi] : 999.;
779 const double track_truth_p = (tP && fabs(tP->parameters()[Trk::qOverP]) > 1.e-8) ?
780 tP->charge() / tP->parameters()[Trk::qOverP] : 10E7;
781 const double track_truth_x0 = tP ? tP->position().x() : 999.;
782 const double track_truth_y0 = tP ? tP->position().y() : 999.;
783 const double track_truth_z0 = tP ? tP->parameters()[Trk::z0] : 999.;
784 const double track_truth_q = tP ? tP->charge() : 0.;
785 const double track_truth_sinphi = tP ? std::sin(tP->parameters()[Trk::phi]) : -1.;
786 const double track_truth_cosphi = tP ? std::cos(tP->parameters()[Trk::phi]) : -1.;
787 const double track_truth_sintheta = tP ? std::sin(tP->parameters()[Trk::theta]) : -1.;
788 const double track_truth_costheta = tP ? std::cos(tP->parameters()[Trk::theta]) : -1.;
789 double truth_d0corr = track_truth_d0 - (primaryVtx.y() * cos(track_truth_phi) - primaryVtx.x() * sin(track_truth_phi));
790 double truth_zvertex = 0.;
791 const HepGeom::Point3D<double> startVertex(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
792 // categorize particle (prompt, secondary, etc.) based on InDetPerformanceRTT/detector paper criteria.
793 bool isPrimary = true;
794 if (std::abs(truth_d0corr) > 2.) { isPrimary = false; }
795 const int bc = HepMC::barcode(particle); // FIXME update barcode-based syntax
796 const int uid = HepMC::uniqueID(particle);
797 if (HepMC::is_simulation_particle(particle) || bc == 0) { isPrimary = false; } // FIXME update barcode-based syntax
798 if (isPrimary && particle->production_vertex()) {
799 const HepGeom::Point3D<double> startVertex(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
800 if (std::abs(startVertex.z() - truth_zvertex) > 100.) { isPrimary = false; }
801 if (particle->end_vertex()) {
802 HepGeom::Point3D<double> endVertex(particle->end_vertex()->position().x(), particle->end_vertex()->position().y(), particle->end_vertex()->position().z());
803 if (endVertex.perp() < FPGATrackSim_PT_TRUTHMIN && std::abs(endVertex.z()) < FPGATrackSim_Z_TRUTHMIN) { isPrimary = false; }
804 }
805 }
806 else {
807 isPrimary = false;
808 }
809
810 HepMcParticleLink truthLink2(uid, ievt, HepMcParticleLink::IS_POSITION, HepMcParticleLink::IS_ID);
811
812 FPGATrackSimTruthTrack tmpSGTrack;
813 tmpSGTrack.setVtxX(track_truth_x0);
814 tmpSGTrack.setVtxY(track_truth_y0);
815 tmpSGTrack.setVtxZ(track_truth_z0);
816 tmpSGTrack.setD0(track_truth_d0);
817 tmpSGTrack.setZ0(track_truth_z0);
818 tmpSGTrack.setQ(track_truth_q);
819 tmpSGTrack.setPX(track_truth_p * (track_truth_cosphi * track_truth_sintheta));
820 tmpSGTrack.setPY(track_truth_p * (track_truth_sinphi * track_truth_sintheta));
821 tmpSGTrack.setPZ(track_truth_p * track_truth_costheta);
822 tmpSGTrack.setPDGCode(pdgcode);
823 tmpSGTrack.setStatus(particle->status());
824 tmpSGTrack.setPrimary(!HepMC::is_simulation_particle(particle));
825 tmpSGTrack.setBarcode(truthLink2.barcode());
826 tmpSGTrack.setUniqueID(truthLink2.id());
827 tmpSGTrack.setEventIndex(truthLink2.eventIndex());
828
829 truth.push_back(tmpSGTrack);
830 } // end for each GenParticle in this GenEvent
831 } // end for each GenEvent
832
833
834 return StatusCode::SUCCESS;
835}
double charge(const T &p)
Definition AtlasPID.h:997
Gaudi::Property< bool > m_UseNominalOrigin
void setUniqueID(const HepMcParticleLink::barcode_type &v)
void setBarcode(const HepMcParticleLink::barcode_type &v)
int barcode(const T *p)
Definition Barcode.h:15
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:597
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
Definition GenVertex.h:24
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
double charge(const T &p)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
@ anyDirection
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
@ isPrimary
true if matched track has a hit in first or second pixel layer

Member Data Documentation

◆ m_beamSpotKey

SG::ReadCondHandleKey<InDet::BeamSpotData> FPGATrackSimSGToRawHitsTool::m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
private

Definition at line 57 of file FPGATrackSimSGToRawHitsTool.h.

57{ this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };

◆ m_doMultiTruth

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_doMultiTruth { this, "doMultiTruth", true }
private

Definition at line 82 of file FPGATrackSimSGToRawHitsTool.h.

82{ this, "doMultiTruth", true };

◆ m_dumpHitsOnTracks

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_dumpHitsOnTracks { this, "dumpHitsOnTracks", false }
private

Definition at line 74 of file FPGATrackSimSGToRawHitsTool.h.

74{ this, "dumpHitsOnTracks", false };

◆ m_dumpTruthIntersections

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_dumpTruthIntersections { this, "dumpTruthIntersections", false }
private

Definition at line 75 of file FPGATrackSimSGToRawHitsTool.h.

75{ this, "dumpTruthIntersections", false };

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> FPGATrackSimSGToRawHitsTool::m_eventInfoKey { this, "EventInfo", "EventInfo" }
private

Definition at line 58 of file FPGATrackSimSGToRawHitsTool.h.

58{ this, "EventInfo", "EventInfo" };

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> FPGATrackSimSGToRawHitsTool::m_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
private

ToolHandle for Extrapolator.

Definition at line 55 of file FPGATrackSimSGToRawHitsTool.h.

55{this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"};

◆ m_maxEta

Gaudi::Property<double> FPGATrackSimSGToRawHitsTool::m_maxEta { this, "maxEta", 5.0 }
private

Definition at line 80 of file FPGATrackSimSGToRawHitsTool.h.

80{ this, "maxEta", 5.0 };

◆ m_mcCollectionKey

SG::ReadHandleKey<McEventCollection> FPGATrackSimSGToRawHitsTool::m_mcCollectionKey { this, "McTruth", "TruthEvent" }
private

Definition at line 63 of file FPGATrackSimSGToRawHitsTool.h.

63{ this, "McTruth", "TruthEvent" };

◆ m_minPt

Gaudi::Property<double> FPGATrackSimSGToRawHitsTool::m_minPt { this, "minPt", .8*CLHEP::GeV }
private

Definition at line 81 of file FPGATrackSimSGToRawHitsTool.h.

81{ this, "minPt", .8*CLHEP::GeV };

◆ m_offlineTracksKey

SG::ReadHandleKey<xAOD::TrackParticleContainer> FPGATrackSimSGToRawHitsTool::m_offlineTracksKey { this, "OfflineTracks", "InDetTrackParticles"}
private

Definition at line 62 of file FPGATrackSimSGToRawHitsTool.h.

62{ this, "OfflineTracks", "InDetTrackParticles"};

◆ m_PIX_mgr

const InDetDD::SiDetectorManager* FPGATrackSimSGToRawHitsTool::m_PIX_mgr = nullptr
private

Definition at line 88 of file FPGATrackSimSGToRawHitsTool.h.

◆ m_pixelClusterContainerKey

SG::ReadHandleKey<InDet::SiClusterContainer> FPGATrackSimSGToRawHitsTool::m_pixelClusterContainerKey { this, "pixelClustersName", "ITkPixelClusters" }
private

Definition at line 59 of file FPGATrackSimSGToRawHitsTool.h.

59{ this, "pixelClustersName", "ITkPixelClusters" };

◆ m_pixelId

const PixelID* FPGATrackSimSGToRawHitsTool::m_pixelId = nullptr
private

Definition at line 85 of file FPGATrackSimSGToRawHitsTool.h.

◆ m_pixelRDOKey

SG::ReadHandleKey<PixelRDO_Container> FPGATrackSimSGToRawHitsTool::m_pixelRDOKey { this, "PixelRDO", "ITkPixelRDOs" }
private

Definition at line 66 of file FPGATrackSimSGToRawHitsTool.h.

66{ this, "PixelRDO", "ITkPixelRDOs" };

◆ m_pixelSDOKey

SG::ReadHandleKey<InDetSimDataCollection> FPGATrackSimSGToRawHitsTool::m_pixelSDOKey { this, "PixelSDO", "ITkPixelSDO_Map" }
private

Definition at line 64 of file FPGATrackSimSGToRawHitsTool.h.

64{ this, "PixelSDO", "ITkPixelSDO_Map" };

◆ m_readOfflineClusters

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_readOfflineClusters { this, "ReadOfflineClusters", true, "flag to enable the offline cluster save" }
private

Definition at line 76 of file FPGATrackSimSGToRawHitsTool.h.

76{ this, "ReadOfflineClusters", true, "flag to enable the offline cluster save" };

◆ m_readOfflineTracks

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_readOfflineTracks { this, "ReadOfflineTracks", true, "flag to enable the offline tracking save" }
private

Definition at line 78 of file FPGATrackSimSGToRawHitsTool.h.

78{ this, "ReadOfflineTracks", true, "flag to enable the offline tracking save" };

◆ m_readTruthTracks

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_readTruthTracks { this, "ReadTruthTracks", true, "flag to enable the truth tracking save" }
private

Definition at line 77 of file FPGATrackSimSGToRawHitsTool.h.

77{ this, "ReadTruthTracks", true, "flag to enable the truth tracking save" };

◆ m_SCT_mgr

const InDetDD::SiDetectorManager* FPGATrackSimSGToRawHitsTool::m_SCT_mgr = nullptr
private

Definition at line 89 of file FPGATrackSimSGToRawHitsTool.h.

◆ m_sctClusterContainerKey

SG::ReadHandleKey<InDet::SiClusterContainer> FPGATrackSimSGToRawHitsTool::m_sctClusterContainerKey { this, "SCT_ClustersName", "ITkStripClusters" }
private

Definition at line 60 of file FPGATrackSimSGToRawHitsTool.h.

60{ this, "SCT_ClustersName", "ITkStripClusters" };

◆ m_sctId

const SCT_ID* FPGATrackSimSGToRawHitsTool::m_sctId = nullptr
private

Definition at line 86 of file FPGATrackSimSGToRawHitsTool.h.

◆ m_stripRDOKey

SG::ReadHandleKey<SCT_RDO_Container> FPGATrackSimSGToRawHitsTool::m_stripRDOKey { this, "StripRDO", "ITkStripRDOs" }
private

Definition at line 67 of file FPGATrackSimSGToRawHitsTool.h.

67{ this, "StripRDO", "ITkStripRDOs" };

◆ m_stripSDOKey

SG::ReadHandleKey<InDetSimDataCollection> FPGATrackSimSGToRawHitsTool::m_stripSDOKey { this, "StripSDO", "ITkStripSDO_Map" }
private

Definition at line 65 of file FPGATrackSimSGToRawHitsTool.h.

65{ this, "StripSDO", "ITkStripSDO_Map" };

◆ m_tracksTruthName

Gaudi::Property<std::string> FPGATrackSimSGToRawHitsTool::m_tracksTruthName { this, "OfflineName", "InDetTrackParticles", "name of offline tracks collection" }
private

Definition at line 73 of file FPGATrackSimSGToRawHitsTool.h.

73{ this, "OfflineName", "InDetTrackParticles", "name of offline tracks collection" };

◆ m_truthToTrack

ToolHandle<Trk::ITruthToTrack> FPGATrackSimSGToRawHitsTool::m_truthToTrack {this, "TruthToTrackTool", "Trk::TruthToTrack/InDetTruthToTrack" }
private

tool to create track parameters from a gen particle

Definition at line 54 of file FPGATrackSimSGToRawHitsTool.h.

54{this, "TruthToTrackTool", "Trk::TruthToTrack/InDetTruthToTrack" };

◆ m_UseNominalOrigin

Gaudi::Property<bool> FPGATrackSimSGToRawHitsTool::m_UseNominalOrigin { this, "UseNominalOrigin", false, "if true truth values are always with respect to (0,0,0)" }
private

Definition at line 79 of file FPGATrackSimSGToRawHitsTool.h.

79{ this, "UseNominalOrigin", false, "if true truth values are always with respect to (0,0,0)" };

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