ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimSGToRawHitsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
12
14
24
28
30
31#include "AtlasHepMC/GenEvent.h"
35
37
38#include "GaudiKernel/IPartPropSvc.h"
40
41#include <bitset>
42
43
44namespace {
45 // A few constants for truth cuts
46 const float FPGATrackSim_PT_TRUTHMIN = 400.;
47 const float FPGATrackSim_Z_TRUTHMIN = 2300.;
48}
49
50FPGATrackSimSGToRawHitsTool::FPGATrackSimSGToRawHitsTool(const std::string& algname, const std::string& name, const IInterface* ifc) :
51 base_class(algname, name, ifc)
52{}
53
55
56 ATH_MSG_DEBUG("FPGATrackSimSGToRawHitsTool::initialize()");
57
58 if(!m_truthToTrack.empty() ) ATH_CHECK(m_truthToTrack.retrieve());
59 if(!m_extrapolator.empty()) ATH_CHECK(m_extrapolator.retrieve());
60 ATH_CHECK(m_beamSpotKey.initialize());
61
62 SmartIF<IPartPropSvc> partPropSvc{service("PartPropSvc")};
63 ATH_CHECK(partPropSvc.isValid());
64 m_particleDataTable = partPropSvc->PDT();
65
66 ATH_CHECK(detStore()->retrieve(m_PIX_mgr, "ITkPixel"));
67 ATH_CHECK(detStore()->retrieve(m_pixelId, "PixelID"));
68 ATH_CHECK(detStore()->retrieve(m_SCT_mgr, "ITkStrip"));
69 ATH_CHECK(detStore()->retrieve(m_sctId, "SCT_ID"));
70
71 ATH_CHECK(m_eventInfoKey.initialize());
74
76
80 ATH_CHECK(m_pixelRDOKey.initialize());
81 ATH_CHECK(m_stripRDOKey.initialize());
82
83 ATH_MSG_DEBUG("Initialization complete");
84 return StatusCode::SUCCESS;
85}
86
87
89 return StatusCode::SUCCESS;
90}
91
92
96{
97 m_eventHeader = header; //take the external pointer
98 auto eventInfo = SG::makeHandle(m_eventInfoKey, eventContext);
99 //Filled to variable / start event
100 FPGATrackSimEventInfo event_info;
101 event_info.setRunNumber(eventInfo->runNumber());
102 event_info.setEventNumber(eventInfo->eventNumber());
103 event_info.setLB(eventInfo->lumiBlock());
104 event_info.setBCID(eventInfo->bcid());
105 event_info.setaverageInteractionsPerCrossing(eventInfo->averageInteractionsPerCrossing());
106 event_info.setactualInteractionsPerCrossing(eventInfo->actualInteractionsPerCrossing());
107 event_info.setextendedLevel1ID(eventInfo->extendedLevel1ID());
108 event_info.setlevel1TriggerType(eventInfo->level1TriggerType());
109 // event_info.setlevel1TriggerInfo(eventInfo->level1TriggerInfo ()); // unclear if needed, TODO come back to it
110 m_eventHeader->newEvent(event_info);//this also reset all variables
111 HitIndexMap hitIndexMap; // keep running index event-unique to each hit
112 HitIndexMap pixelClusterIndexMap;
113 // get pixel and sct cluster containers
114 // dump raw silicon data
115 ATH_MSG_DEBUG("Dump raw silicon data");
116 ATH_CHECK(readRawSilicon(hitIndexMap, eventContext));
119 std::vector <FPGATrackSimCluster> clusters;
120 ATH_CHECK(readOfflineClusters(clusters, eventContext));
121 for (const auto& cluster : clusters) optional.addOfflineCluster(cluster);
122 ATH_MSG_DEBUG("Saved " << optional.nOfflineClusters() << " offline clusters");
123 ATH_CHECK(dumpPixelClusters(pixelClusterIndexMap, eventContext));
124 }
125 if (m_readTruthTracks) {
126 std::vector <FPGATrackSimTruthTrack> truth;
127 ATH_CHECK(readTruthTracks(truth, eventContext));
128 for (const FPGATrackSimTruthTrack& trk : truth) optional.addTruthTrack(trk);
129 ATH_MSG_DEBUG("Saved " << optional.nTruthTracks() << " truth tracks");
130 }
131 std::vector <FPGATrackSimOfflineTrack> offline;
133 ATH_CHECK(readOfflineTracks(offline, eventContext));
134 for (const FPGATrackSimOfflineTrack& trk : offline) optional.addOfflineTrack(trk);
135 ATH_MSG_DEBUG("Saved " << optional.nOfflineTracks() << " offline tracks");
136 }
137 m_eventHeader->setOptional(optional);
139 ATH_MSG_DEBUG("End of execute()");
140 return StatusCode::SUCCESS;
141}
142
143
144StatusCode FPGATrackSimSGToRawHitsTool::readOfflineTracks(std::vector<FPGATrackSimOfflineTrack>& offline, const EventContext& eventContext)
145{
146 auto offlineTracksHandle = SG::makeHandle(m_offlineTracksKey, eventContext);
147 ATH_MSG_DEBUG("read Offline tracks, size= " << offlineTracksHandle->size());
148
149 int iTrk = -1;
150 for (const xAOD::TrackParticle* trackParticle : *offlineTracksHandle) {
151 iTrk++;
152 FPGATrackSimOfflineTrack tmpOfflineTrack;
153 tmpOfflineTrack.setQOverPt(trackParticle->pt() > 0 ? trackParticle->charge() / trackParticle->pt() : 0);
154 tmpOfflineTrack.setEta(trackParticle->eta());
155 tmpOfflineTrack.setPhi(trackParticle->phi());
156 tmpOfflineTrack.setD0(trackParticle->d0());
157 tmpOfflineTrack.setZ0(trackParticle->z0());
158
159 const Trk::TrackStates* trackStates = trackParticle->track()->trackStateOnSurfaces();
160 if (trackStates == nullptr) {
161 ATH_MSG_ERROR("missing trackStatesOnSurface");
162 return StatusCode::FAILURE;
163 }
164 for (const Trk::TrackStateOnSurface* tsos : *trackStates) {
165 if (tsos == nullptr) continue;
167 const Trk::MeasurementBase* measurement = tsos->measurementOnTrack();
168 if (tsos->trackParameters() != nullptr &&
169 tsos->trackParameters()->associatedSurface().associatedDetectorElement() != nullptr &&
170 tsos->trackParameters()->associatedSurface().associatedDetectorElement()->identify() != 0
171 ) {
172 const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>(measurement);
173 const Identifier& hitId = hit->identify();
174 FPGATrackSimOfflineHit tmpOfflineHit;
175 if (m_pixelId->is_pixel(hitId)) {
176 tmpOfflineHit.setIsPixel(true);
177 tmpOfflineHit.setIsBarrel(m_pixelId->is_barrel(hitId));
178
179 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(hitId);
180 tmpOfflineHit.setClusterID(sielement->identifyHash());
181 tmpOfflineHit.setTrackNumber(iTrk);
182 tmpOfflineHit.setLayer(m_pixelId->layer_disk(hitId));
183 tmpOfflineHit.setLocX((float)measurement->localParameters()[Trk::locX]);
184 tmpOfflineHit.setLocY((float)measurement->localParameters()[Trk::locY]);
185 }
186 else if (m_sctId->is_sct(hitId)) {
187 tmpOfflineHit.setIsPixel(false);
188 tmpOfflineHit.setIsBarrel(m_sctId->is_barrel(hitId));
189 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(hitId);
190 tmpOfflineHit.setClusterID(sielement->identifyHash());
191 tmpOfflineHit.setTrackNumber(iTrk);
192 tmpOfflineHit.setLayer(m_sctId->layer_disk(hitId));
193 tmpOfflineHit.setLocX(((float)measurement->localParameters()[Trk::locX]));
194 tmpOfflineHit.setLocY(-99999.9);
195 }
196 tmpOfflineTrack.addHit(tmpOfflineHit);
197 }
198 }
199 }
200 offline.push_back(tmpOfflineTrack);
201 }//end of loop over tracks
202
203
204 return StatusCode::SUCCESS;
205}
206
207
208
209// dump silicon channels with geant matching information.
210StatusCode
211FPGATrackSimSGToRawHitsTool::readRawSilicon(HitIndexMap& hitIndexMap, const EventContext& eventContext) // const cannot make variables push back to DataInput
212{
213 ATH_MSG_DEBUG("read silicon hits");
214 unsigned int hitIndex = 0u;
215
216 ATH_CHECK(readPixelSimulation(hitIndexMap, hitIndex, eventContext));
217 ATH_CHECK(readStripSimulation(hitIndexMap, hitIndex, eventContext));
218
219 return StatusCode::SUCCESS;
220}
221
222
223StatusCode
224FPGATrackSimSGToRawHitsTool::readPixelSimulation(HitIndexMap& hitIndexMap, unsigned int& hitIndex, const EventContext& eventContext) {
225
226 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
227 auto pixelRDOHandle = SG::makeHandle(m_pixelRDOKey, eventContext);
228
229 ATH_MSG_DEBUG("Found Pixel SDO Map");
230
231 for (const InDetRawDataCollection<PixelRDORawData>* pixel_rdoCollection : *pixelRDOHandle) {
232 if (pixel_rdoCollection == nullptr) { continue; }
233 // loop on all RDOs
234 for (const PixelRDORawData* pixelRawData : *pixel_rdoCollection) {
235 Identifier rdoId = pixelRawData->identify();
236 // get the det element from the det element collection
237 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId); assert(sielement);
238
239 Amg::Vector2D localPos = sielement->rawLocalPositionOfCell(rdoId);
240 Amg::Vector3D globalPos = sielement->globalPosition(localPos);
241 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
242
243 // update map between pixel identifier and event-unique hit index.
244 // ganged pixels (nCells==2) get two entries.
245 hitIndexMap[rdoId] = hitIndex;
246 const int nCells = sielement->numberOfConnectedCells(cellID);
247 if (nCells == 2) {
248 const InDetDD::SiCellId tmpCell = sielement->connectedCell(cellID, 1);
249 const Identifier tmpId = sielement->identifierFromCellId(tmpCell);
250 hitIndexMap[tmpId] = hitIndex; // add second entry for ganged pixel ID
251 }
252 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel.
254 const HepMcParticleLink* bestTruthLink{};
255 if (!m_pixelSDOKey.empty()) {
256 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
257 if (nCells > 1 && iter == pixelSDOHandle->end()) {
258 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
259 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
260 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
261 }
262 } // end search for correct ganged pixel
263 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
264 if (iter != pixelSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
265 } // end if pixel truth available
266 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
267 ++hitIndex;
268
269 // push back the hit information to DataInput for HitList
270 FPGATrackSimHit tmpSGhit;
273 tmpSGhit.setIdentifierHash(sielement->identifyHash());
274 tmpSGhit.setIdentifier(sielement->identify().get_identifier32().get_compact());
275 tmpSGhit.setRdoIdentifier(rdoId.get_compact()); // full 64 bit hit identifier
276
277 int barrel_ec = m_pixelId->barrel_ec(rdoId);
278 if (barrel_ec == 0)
280 else if (barrel_ec == 2)
282 else if (barrel_ec == -2)
284
285 tmpSGhit.setLayerDisk(m_pixelId->layer_disk(rdoId));
286 tmpSGhit.setPhiModule(m_pixelId->phi_module(rdoId));
287 tmpSGhit.setEtaModule(m_pixelId->eta_module(rdoId));
288 tmpSGhit.setPhiIndex(m_pixelId->phi_index(rdoId));
289 tmpSGhit.setEtaIndex(m_pixelId->eta_index(rdoId));
290 tmpSGhit.setPhiCoord(localPos[0]);
291 tmpSGhit.setEtaCoord(localPos[1]);
292 tmpSGhit.setEtaWidth(0);
293 tmpSGhit.setPhiWidth(0);
294 tmpSGhit.setX(globalPos[Amg::x]);
295 tmpSGhit.setY(globalPos[Amg::y]);
296 tmpSGhit.setZ(globalPos[Amg::z]);
297 tmpSGhit.setToT(pixelRawData->getToT());
298 tmpSGhit.setisValidForITkHit(true); // Pixel clusters are close enough right now that they all can be considered valid for ITK
299 if (bestParent) {
300 tmpSGhit.setEventIndex(bestTruthLink->eventIndex());
301 tmpSGhit.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
302 tmpSGhit.setUniqueID(bestTruthLink->id()); // May need fixing when uid will be used.
303 }
304 else {
305 tmpSGhit.setEventIndex(std::numeric_limits<long>::max());
306 tmpSGhit.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
307 tmpSGhit.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
308 }
309
310 tmpSGhit.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
311 tmpSGhit.setParentageMask(parentMask.to_ulong());
312
313 if (m_doMultiTruth) {
314 // Add truth
316 FPGATrackSimMultiTruth::Barcode uniqueID(tmpSGhit.getEventIndex(), tmpSGhit.getBarcode()); // FIXME barcode-based
317 mt.maximize(uniqueID, tmpSGhit.getBarcodePt()); // FIXME barcode-based
318 tmpSGhit.setTruth(mt);
319 }
320
321 m_eventHeader->addHit(tmpSGhit);
322 } // end for each RDO in the collection
323 } // for each pixel RDO collection
324
325 return StatusCode::SUCCESS;
326}
327
328StatusCode
329FPGATrackSimSGToRawHitsTool::readStripSimulation(HitIndexMap& hitIndexMap, unsigned int& hitIndex, const EventContext& eventContext) {
330
331 constexpr int MaxChannelinStripRow = 128;
332
333 auto stripSDOHandle = SG::makeHandle(m_stripSDOKey, eventContext);
334 ATH_MSG_DEBUG("Found SCT SDO Map");
335 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, eventContext);
336 for (const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection : *stripRDOHandle) {
337 if (SCT_Collection == nullptr) { continue; }
338
339 std::map<int, bool> firedStrips;
340 std::map<int, const SCT_RDORawData*> firedStripsToRDO;
341 // Preprocess the SCT collection hits to get information for encoding strip in ITK format
342 // All strips fired read into a map to an overview of full module that should be used to encode
343 // the data into the ITk formatl
344 for (const SCT_RDORawData* sctRawData : *SCT_Collection)
345 {
346 const Identifier rdoId = sctRawData->identify();
347 const int baseLineStrip{m_sctId->strip(rdoId)};
348 for(int i = 0; i < sctRawData->getGroupSize(); i++) {
349 firedStrips[baseLineStrip+ i] = true;
350 firedStripsToRDO[baseLineStrip + i] = sctRawData;
351 }
352 }
353
354 // Loop over the fired hits and encode them in the ITk strips hit map
355 // It find unique hits in the list that can be encoded and don't overlap
356 std::map<int, int> stripEncodingForITK;
357 std::map<int, const SCT_RDORawData* > stripEncodingForITKToRDO;
358 for(const auto& [stripID, fired]: firedStrips)
359 {
360 // Don't use the strip that has been set false.
361 // This will be the case where neighbouring strip will "used up in the cluster"
362 // And then we don't want to re use them
363 if(!fired) continue;
364
365 // Check the next 3 hits if they are there and have a hit in them
366 std::bitset<3> hitMap;
367
368
369 // Get the current chip id of the strip
370 int currChipID = stripID / MaxChannelinStripRow;
371 // Compute the maximum stripID this chip can have
372 int maxStripIDForCurrChip = (currChipID + 1) * MaxChannelinStripRow;
373
374 for(int i = 0; i < 3; i++)
375 {
376 // We don't want to "cluster" strips that are outside the range of this chip
377 if((stripID + 1 + i) >= maxStripIDForCurrChip) continue;
378
379 if(firedStrips.find(stripID + 1 + i) != firedStrips.end())
380 {
381 if(firedStrips.at(stripID + 1 + i))
382 {
383 hitMap[2 - i] = 1;
384 firedStrips[stripID + 1 + i] = false;
385 }
386 else
387 {
388 hitMap[2 - i] = 0;
389 }
390 }
391 }
392
393 // Encode the hit map into a int
394 stripEncodingForITK[stripID] = (int)(hitMap.to_ulong());
395 stripEncodingForITKToRDO[stripID] = firedStripsToRDO[stripID];
396 }
397
398 // Actual creation of the FPGAHit objects
399 for(const auto& [stripID, fired]: firedStrips)
400 {
401 const SCT_RDORawData* sctRawData = firedStripsToRDO[stripID];
402 const Identifier rdoId = sctRawData->identify();
403 // get the det element from the det element collection
404 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(rdoId);
405 const InDetDD::SiDetectorDesign& design = dynamic_cast<const InDetDD::SiDetectorDesign&>(sielement->design());
406
407 InDetDD::SiCellId frontId(stripID);
408 Amg::Vector2D localPos = design.localPositionOfCell(frontId);
409 std::pair<Amg::Vector3D, Amg::Vector3D> endsOfStrip = sielement->endsOfStrip(localPos);
410
411 hitIndexMap[rdoId] = hitIndex;
412 ++hitIndex;
413 // if there is simulation truth available, try to retrieve the
414 // "most likely" barcode for this strip.
416 const HepMcParticleLink* bestTruthLink{};
417 if (!m_stripSDOKey.empty()) {
418 InDetSimDataCollection::const_iterator iter(stripSDOHandle->find(rdoId));
419 // if SDO found for this strip, associate the particle
420 if (iter != stripSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
421 } // end if sct truth available
422 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
423 // push back the hit information to DataInput for HitList , copy from RawInput.cxx
424
425 FPGATrackSimHit tmpSGhit;
428 tmpSGhit.setIdentifierHash(sielement->identifyHash());
429 tmpSGhit.setIdentifier(sielement->identify().get_identifier32().get_compact());
430 tmpSGhit.setRdoIdentifier(rdoId.get_compact()); // full 64 bit hit identifier
431
432 int barrel_ec = m_sctId->barrel_ec(rdoId);
433 if (barrel_ec == 0)
435 else if (barrel_ec == 2)
437 else if (barrel_ec == -2)
439
440 tmpSGhit.setLayerDisk(m_sctId->layer_disk(rdoId));
441 tmpSGhit.setPhiModule(m_sctId->phi_module(rdoId));
442 tmpSGhit.setEtaModule(m_sctId->eta_module(rdoId));
443 tmpSGhit.setPhiIndex(stripID);
444 tmpSGhit.setEtaIndex(m_sctId->row(rdoId));
445 tmpSGhit.setPhiCoord(localPos[0]);
446 tmpSGhit.setEtaCoord(localPos[1]);
447 tmpSGhit.setSide(m_sctId->side(rdoId));
448 tmpSGhit.setEtaWidth(0);
449 tmpSGhit.setPhiWidth(1);
450 if (bestParent) {
451 tmpSGhit.setEventIndex(bestTruthLink->eventIndex());
452 tmpSGhit.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
453 tmpSGhit.setUniqueID(bestTruthLink->id());
454 }
455 else {
456 tmpSGhit.setEventIndex(std::numeric_limits<long>::max());
457 tmpSGhit.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
458 tmpSGhit.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
459 }
460
461 // If the strip has been identified by the previous for loop as a valid hit that can be encoded into ITk Strip format
462 if(stripEncodingForITK.find(stripID) != stripEncodingForITK.end())
463 {
464 // 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
465 // for the Strip ID, it is the remainder left after dividing by 128
466 int chipID = stripID / MaxChannelinStripRow;
467 int ITkStripID = stripID % MaxChannelinStripRow;
468
469 // for each ABC chip readout, each reads 256 channels actually. 0-127 corresponds to lower row and then 128-255 corresponds to the
470 // upper. This can be simulated in the code by using the eta module index. Even index are not offest, while odd index, the
471 // strip id is offest by 128
472 // 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
473 int offset = m_sctId->eta_module(rdoId) % 2;
474 if(m_sctId->barrel_ec(rdoId) == 0) offset = (std::abs(m_sctId->eta_module(rdoId)) - 1) % 2;
475
476 ITkStripID += offset * MaxChannelinStripRow;
477
478 tmpSGhit.setisValidForITkHit(true);
479 tmpSGhit.setStripRowIDForITk(ITkStripID);
480 tmpSGhit.setStripChipIDForITk(chipID);
481 tmpSGhit.setStripHitMapForITk(stripEncodingForITK.at(stripID));
482 }
483
484 tmpSGhit.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
485 tmpSGhit.setParentageMask(parentMask.to_ulong());
486 tmpSGhit.setX(0.5 * (endsOfStrip.first.x() + endsOfStrip.second.x()));
487 tmpSGhit.setY(0.5 * (endsOfStrip.first.y() + endsOfStrip.second.y()));
488 tmpSGhit.setZ(0.5 * (endsOfStrip.first.z() + endsOfStrip.second.z()));
489
490 if (m_doMultiTruth) {
491 // Add truth
493 FPGATrackSimMultiTruth::Barcode uniqueID(tmpSGhit.getEventIndex(), tmpSGhit.getBarcode()); // FIXME barcode-based
494 mt.maximize(uniqueID, tmpSGhit.getBarcodePt()); // FIMXE barcode-based
495 tmpSGhit.setTruth(mt);
496 }
497
498 m_eventHeader->addHit(tmpSGhit);
499 } // end for each RDO in the strip collection
500 } // end for each strip RDO collection
501 // dump all RDO's and SDO's for a given event, for debugging purposes
502
503 return StatusCode::SUCCESS;
504}
505
506
507StatusCode
508FPGATrackSimSGToRawHitsTool::dumpPixelClusters(HitIndexMap& pixelClusterIndexMap, const EventContext& eventContext) {
509 unsigned int pixelClusterIndex = 0;
510 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
511 auto pixelClusterContainerHandle = SG::makeHandle(m_pixelClusterContainerKey, eventContext);
512 // Dump pixel clusters. They're in m_pixelContainer
513 for (const InDet::SiClusterCollection* pixelClusterCollection : *pixelClusterContainerHandle) {
514 if (pixelClusterCollection == nullptr) {
515 ATH_MSG_DEBUG("pixelClusterCollection not available!");
516 continue;
517 }
518
519 for (const InDet::SiCluster* cluster : *pixelClusterCollection) {
520 Identifier theId = cluster->identify();
521 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel cluster.
522 FPGATrackSimInputUtils::ParentBitmask parentMask; // FIXME set, but not used
523 if (!m_pixelSDOKey.empty()) {
524 for (const Identifier& rdoId : cluster->rdoList()) {
525 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId);
526 assert(sielement);
527 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
528
529 const int nCells = sielement->numberOfConnectedCells(cellID);
530 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
531 // this might be the ganged pixel copy.
532 if (nCells > 1 && iter == pixelSDOHandle->end()) {
533 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
534 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
535 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
536 }
537 } // end search for correct ganged pixel
538 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
539 if (iter != pixelSDOHandle->end()) { (void) getTruthInformation(iter, parentMask); } // FIXME not used??
540 } // if we have pixel sdo's available
541 }
542 pixelClusterIndexMap[theId] = pixelClusterIndex;
543 pixelClusterIndex++;
544 } // End loop over pixel clusters
545 } // End loop over pixel cluster collection
546
547 return StatusCode::SUCCESS;
548}
549
550StatusCode
551FPGATrackSimSGToRawHitsTool::readOfflineClusters(std::vector <FPGATrackSimCluster>& clusters, const EventContext& eventContext)
552{
553
554 //Lets do the Pixel clusters first
555 //Loopover the pixel clusters and convert them into a FPGATrackSimCluster for storage
556 // Dump pixel clusters. They're in m_pixelContainer
557 auto pixelSDOHandle = SG::makeHandle(m_pixelSDOKey, eventContext);
558 auto pixelClusterContainerHandler = SG::makeHandle(m_pixelClusterContainerKey, eventContext);
559 for (const InDet::SiClusterCollection* pixelClusterCollection : *pixelClusterContainerHandler) {
560 if (pixelClusterCollection == nullptr) {
561 ATH_MSG_DEBUG("pixelClusterCollection not available!");
562 continue;
563 }
564 const int size = pixelClusterCollection->size();
565 ATH_MSG_DEBUG("PixelClusterCollection found with " << size << " clusters");
566 for (const InDet::SiCluster* cluster : *pixelClusterCollection) {
567
568 // if there is simulation truth available, try to retrieve the "most likely" barcode for this pixel cluster.
570 const HepMcParticleLink* bestTruthLink{};
571 if (!m_pixelSDOKey.empty()) {
572 for (const Identifier& rdoId : cluster->rdoList()) {
573 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(rdoId);
574 assert(sielement);
575 InDetDD::SiCellId cellID = sielement->cellIdFromIdentifier(rdoId);
576 const int nCells = sielement->numberOfConnectedCells(cellID);
577 InDetSimDataCollection::const_iterator iter(pixelSDOHandle->find(rdoId));
578 // this might be the ganged pixel copy.
579 if (nCells > 1 && iter == pixelSDOHandle->end()) {
580 InDetDD::SiReadoutCellId SiRC(m_pixelId->phi_index(rdoId), m_pixelId->eta_index(rdoId));
581 for (int ii = 0; ii < nCells && iter == pixelSDOHandle->end(); ++ii) {
582 iter = pixelSDOHandle->find(sielement->identifierFromCellId(sielement->design().connectedCell(SiRC, ii)));
583 }
584 } // end search for correct ganged pixel
585 // if SDO found for this pixel, associate the particle. otherwise leave unassociated.
586 if (iter != pixelSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
587 } // if we have pixel sdo's available
588 }
589 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
590
591 Identifier theID = cluster->identify();
592 //cluster object to be written out
593 FPGATrackSimCluster clusterOut;
594 //Rawhit object to represent the cluster
595 FPGATrackSimHit clusterEquiv;
596 //Lets get the information of this pixel cluster
597 const InDetDD::SiDetectorElement* sielement = m_PIX_mgr->getDetectorElement(theID);
598 assert(sielement);
599 const InDetDD::SiLocalPosition localPos = sielement->rawLocalPositionOfCell(theID);
600 const Amg::Vector3D globalPos(sielement->globalPosition(localPos));
601 clusterEquiv.setHitType(HitType::clustered);
602 clusterEquiv.setX(globalPos.x());
603 clusterEquiv.setY(globalPos.y());
604 clusterEquiv.setZ(globalPos.z());
605 clusterEquiv.setDetType(SiliconTech::pixel);
606 clusterEquiv.setIdentifierHash(sielement->identifyHash());
607 clusterEquiv.setIdentifier(sielement->identify().get_identifier32().get_compact());
608
609 int barrel_ec = m_pixelId->barrel_ec(theID);
610 if (barrel_ec == 0)
612 else if (barrel_ec == 2)
614 else if (barrel_ec == -2)
616
617 clusterEquiv.setLayerDisk(m_pixelId->layer_disk(theID));
618 clusterEquiv.setPhiModule(m_pixelId->phi_module(theID));
619 clusterEquiv.setEtaModule(m_pixelId->eta_module(theID));
620 clusterEquiv.setPhiIndex(m_pixelId->phi_index(theID));
621 clusterEquiv.setEtaIndex(m_pixelId->eta_index(theID));
622 clusterEquiv.setPhiCoord(localPos.xPhi());
623 clusterEquiv.setEtaCoord(localPos.xEta());
624
625 clusterEquiv.setPhiWidth(cluster->width().colRow()[1]);
626 clusterEquiv.setEtaWidth(cluster->width().colRow()[0]);
627 //Save the truth here as the MultiTruth object is only transient
628 if (bestParent) {
629 clusterEquiv.setEventIndex(bestTruthLink->eventIndex());
630 clusterEquiv.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
631 clusterEquiv.setUniqueID(bestTruthLink->id());
632 }
633 else {
634 clusterEquiv.setEventIndex(std::numeric_limits<long>::max());
635 clusterEquiv.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
636 clusterEquiv.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
637 }
638
639 clusterEquiv.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
640 clusterEquiv.setParentageMask(parentMask.to_ulong());
641 clusterOut.setClusterEquiv(clusterEquiv);
642 clusters.push_back(clusterOut);
643 }
644 }
645
646 //Now lets do the strip clusters
647 //Loopover the pixel clusters and convert them into a FPGATrackSimCluster for storage
648 // Dump pixel clusters. They're in m_pixelContainer
649 auto stripSDOHandle = SG::makeHandle(m_stripSDOKey, eventContext);
650 ATH_MSG_DEBUG("Found SCT SDO Map");
651 auto stripRDOHandle = SG::makeHandle(m_stripRDOKey, eventContext);
652
653 for (const InDetRawDataCollection<SCT_RDORawData>* SCT_Collection : *stripRDOHandle) {
654 if (SCT_Collection == nullptr) { continue; }
655 for (const SCT_RDORawData* sctRawData : *SCT_Collection) {
656 const Identifier rdoId = sctRawData->identify();
657 // get the det element from the det element collection
658 const InDetDD::SiDetectorElement* sielement = m_SCT_mgr->getDetectorElement(rdoId);
659 const InDetDD::SiDetectorDesign& design = dynamic_cast<const InDetDD::SiDetectorDesign&>(sielement->design());
660 const InDetDD::SiLocalPosition localPos = design.localPositionOfCell(m_sctId->strip(rdoId));
661 const Amg::Vector3D gPos = sielement->globalPosition(localPos);
662 // if there is simulation truth available, try to retrieve the
663 // "most likely" barcode for this strip.
665 const HepMcParticleLink* bestTruthLink{};
666 if (!m_stripSDOKey.empty()) {
667 InDetSimDataCollection::const_iterator iter(stripSDOHandle->find(rdoId));
668 // if SDO found for this pixel, associate the particle
669 if (iter != stripSDOHandle->end()) { bestTruthLink = getTruthInformation(iter, parentMask); }
670 } // end if sct truth available
671 HepMC::ConstGenParticlePtr bestParent = (bestTruthLink) ? bestTruthLink->cptr() : nullptr;
672
673 // push back the hit information to DataInput for HitList , copy from RawInput.cxx
674 FPGATrackSimCluster clusterOut;
675 FPGATrackSimHit clusterEquiv;
676 clusterEquiv.setHitType(HitType::clustered);
677 clusterEquiv.setX(gPos.x());
678 clusterEquiv.setY(gPos.y());
679 clusterEquiv.setZ(gPos.z());
680 clusterEquiv.setDetType(SiliconTech::strip);
681 clusterEquiv.setIdentifierHash(sielement->identifyHash());
682 clusterEquiv.setIdentifier(sielement->identify().get_identifier32().get_compact());
683
684 int barrel_ec = m_sctId->barrel_ec(rdoId);
685 if (barrel_ec == 0)
687 else if (barrel_ec == 2)
689 else if (barrel_ec == -2)
691
692 clusterEquiv.setLayerDisk(m_sctId->layer_disk(rdoId));
693 clusterEquiv.setPhiModule(m_sctId->phi_module(rdoId));
694 clusterEquiv.setEtaModule(m_sctId->eta_module(rdoId));
695 clusterEquiv.setPhiIndex(m_sctId->strip(rdoId));
696 clusterEquiv.setEtaIndex(m_sctId->row(rdoId));
697 clusterEquiv.setPhiCoord(localPos.xPhi());
698 clusterEquiv.setEtaCoord(localPos.xEta());
699 clusterEquiv.setSide(m_sctId->side(rdoId));
700 //I think this is the strip "cluster" width
701 clusterEquiv.setPhiWidth(sctRawData->getGroupSize());
702 //Save the truth here as the MultiTruth object is only transient
703 if (bestParent) {
704 clusterEquiv.setEventIndex(bestTruthLink->eventIndex());
705 clusterEquiv.setBarcode(bestTruthLink->barcode()); // FIXME barcode-based
706 clusterEquiv.setUniqueID(bestTruthLink->id());
707 }
708 else {
709 clusterEquiv.setEventIndex(std::numeric_limits<long>::max());
710 clusterEquiv.setBarcode(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
711 clusterEquiv.setUniqueID(std::numeric_limits<HepMcParticleLink::barcode_type>::max());
712 }
713
714 clusterEquiv.setBarcodePt(static_cast<unsigned long>(std::ceil(bestParent ? bestParent->momentum().perp() : 0.)));
715 clusterEquiv.setParentageMask(parentMask.to_ulong());
716 clusterOut.setClusterEquiv(clusterEquiv);
717 clusters.push_back(clusterOut);
718 } // end for each RDO in the strip collection
719 } // end for each strip RDO collection
720 // dump all RDO's and SDO's for a given event, for debugging purposes
721
722 return StatusCode::SUCCESS;
723}
724
725StatusCode
726FPGATrackSimSGToRawHitsTool::readTruthTracks(std::vector <FPGATrackSimTruthTrack>& truth, const EventContext& eventContext)
727{
728 auto simTracksHandle = SG::makeHandle(m_mcCollectionKey, eventContext);
729 ATH_MSG_DEBUG("Dump truth tracks, size " << simTracksHandle->size());
730
731 // dump each truth track
732 for (unsigned int ievt = 0; ievt < simTracksHandle->size(); ++ievt) {
733 const HepMC::GenEvent* genEvent = simTracksHandle->at(ievt);
734 // retrieve the primary interaction vertex here. for now, use the dummy origin.
735 HepGeom::Point3D<double> primaryVtx(0., 0., 0.);
736 // the event should have signal process vertex unless it was generated as single particles.
737 // if it exists, use it for the primary vertex.
739 if (spv) {
740 primaryVtx.set(spv->position().x(),
741 spv->position().y(),
742 spv->position().z());
743 ATH_MSG_DEBUG("using signal process vertex for eventIndex " << ievt << ":"
744 << primaryVtx.x() << "\t" << primaryVtx.y() << "\t" << primaryVtx.z());
745 }
746 for (const auto& particle: *genEvent) {
747 const int pdgcode = particle->pdg_id();
748 // reject generated particles without a production vertex.
749 if (particle->production_vertex() == nullptr) {
750 continue;
751 }
752 // reject neutral or unstable particles
753 const HepPDT::ParticleData* pd = m_particleDataTable->particle(abs(pdgcode));
754 if (pd == nullptr) {
755 continue;
756 }
757 float charge = pd->charge();
758 if (pdgcode < 0) charge *= -1.; // since we took absolute value above
759 if (std::abs(charge) < 0.5) {
760 continue;
761 }
762 if (!MC::isStable(particle)) {
763 continue;
764 }
765 // truth-to-track tool
766 const Amg::Vector3D momentum(particle->momentum().px(), particle->momentum().py(), particle->momentum().pz());
767 const Amg::Vector3D position(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
768 const Trk::CurvilinearParameters cParameters(position, momentum, charge);
770 if (m_UseNominalOrigin) {
771 Amg::Vector3D origin(0, 0, 0);
772 persf = Trk::PerigeeSurface(origin);
773 }
774 else {
775 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle{ m_beamSpotKey, eventContext };
776 Trk::PerigeeSurface persf(beamSpotHandle->beamPos());
777 }
778 const std::unique_ptr<Trk::TrackParameters> tP = m_extrapolator->extrapolate(eventContext, cParameters, persf, Trk::anyDirection, false);
779 const double track_truth_d0 = tP ? tP->parameters()[Trk::d0] : 999.;
780 const double track_truth_phi = tP ? tP->parameters()[Trk::phi] : 999.;
781 const double track_truth_p = (tP && fabs(tP->parameters()[Trk::qOverP]) > 1.e-8) ?
782 tP->charge() / tP->parameters()[Trk::qOverP] : 10E7;
783 const double track_truth_x0 = tP ? tP->position().x() : 999.;
784 const double track_truth_y0 = tP ? tP->position().y() : 999.;
785 const double track_truth_z0 = tP ? tP->parameters()[Trk::z0] : 999.;
786 const double track_truth_q = tP ? tP->charge() : 0.;
787 const double track_truth_sinphi = tP ? std::sin(tP->parameters()[Trk::phi]) : -1.;
788 const double track_truth_cosphi = tP ? std::cos(tP->parameters()[Trk::phi]) : -1.;
789 const double track_truth_sintheta = tP ? std::sin(tP->parameters()[Trk::theta]) : -1.;
790 const double track_truth_costheta = tP ? std::cos(tP->parameters()[Trk::theta]) : -1.;
791 double truth_d0corr = track_truth_d0 - (primaryVtx.y() * cos(track_truth_phi) - primaryVtx.x() * sin(track_truth_phi));
792 double truth_zvertex = 0.;
793 const HepGeom::Point3D<double> startVertex(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
794 // categorize particle (prompt, secondary, etc.) based on InDetPerformanceRTT/detector paper criteria.
795 bool isPrimary = true;
796 if (std::abs(truth_d0corr) > 2.) { isPrimary = false; }
797 const int bc = HepMC::barcode(particle); // FIXME update barcode-based syntax
798 const int uid = HepMC::uniqueID(particle);
799 if (HepMC::is_simulation_particle(particle) || bc == 0) { isPrimary = false; } // FIXME update barcode-based syntax
800 if (isPrimary && particle->production_vertex()) {
801 const HepGeom::Point3D<double> startVertex(particle->production_vertex()->position().x(), particle->production_vertex()->position().y(), particle->production_vertex()->position().z());
802 if (std::abs(startVertex.z() - truth_zvertex) > 100.) { isPrimary = false; }
803 if (particle->end_vertex()) {
804 HepGeom::Point3D<double> endVertex(particle->end_vertex()->position().x(), particle->end_vertex()->position().y(), particle->end_vertex()->position().z());
805 if (endVertex.perp() < FPGATrackSim_PT_TRUTHMIN && std::abs(endVertex.z()) < FPGATrackSim_Z_TRUTHMIN) { isPrimary = false; }
806 }
807 }
808 else {
809 isPrimary = false;
810 }
811
813
814 FPGATrackSimTruthTrack tmpSGTrack;
815 tmpSGTrack.setVtxX(track_truth_x0);
816 tmpSGTrack.setVtxY(track_truth_y0);
817 tmpSGTrack.setVtxZ(track_truth_z0);
818 tmpSGTrack.setD0(track_truth_d0);
819 tmpSGTrack.setZ0(track_truth_z0);
820 tmpSGTrack.setVtxZ(primaryVtx.z());
821 tmpSGTrack.setQ(track_truth_q);
822 tmpSGTrack.setPX(track_truth_p * (track_truth_cosphi * track_truth_sintheta));
823 tmpSGTrack.setPY(track_truth_p * (track_truth_sinphi * track_truth_sintheta));
824 tmpSGTrack.setPZ(track_truth_p * track_truth_costheta);
825 tmpSGTrack.setPDGCode(pdgcode);
826 tmpSGTrack.setStatus(particle->status());
827
828 tmpSGTrack.setBarcode(truthLink2.barcode());
829 tmpSGTrack.setUniqueID(truthLink2.id());
830 tmpSGTrack.setEventIndex(truthLink2.eventIndex());
831
832 truth.push_back(tmpSGTrack);
833 } // end for each GenParticle in this GenEvent
834 } // end for each GenEvent
835
836
837 return StatusCode::SUCCESS;
838}
839
840
841const HepMcParticleLink* FPGATrackSimSGToRawHitsTool::getTruthInformation(InDetSimDataCollection::const_iterator& iter,
843 const HepMcParticleLink* bestTruthLink{};
844 const InDetSimData& sdo(iter->second);
845 const std::vector<InDetSimData::Deposit>& deposits(sdo.getdeposits());
846 float bestPt{-999.f};
847 for (const InDetSimData::Deposit& dep : deposits) {
848
849 const HepMcParticleLink& particleLink = dep.first;
850 // RDO's without SDO's are delta rays or detector noise.
851 if (!particleLink.isValid()) { continue; }
852 const float genEta = particleLink->momentum().pseudoRapidity();
853 const float genPt = particleLink->momentum().perp(); // MeV
854 // reject unstable particles
855 if (!MC::isStable(particleLink.cptr())) { continue; }
856 // reject secondaries and low pT (<400 MeV) pileup
857 if (HepMC::is_simulation_particle(particleLink.cptr()) || particleLink.barcode() == 0 /*HepMC::no_truth_link(particleLink)*/) { continue; } // FIXME
858 // reject far forward particles
859 if (std::fabs(genEta) > m_maxEta) { continue; }
860 // "bestTruthLink" links to the highest pt particle
861 if (bestPt < genPt) {
862 bestPt = genPt;
863 bestTruthLink = &particleLink;
864 }
865 #ifdef HEPMC3
866 parentMask |= FPGATrackSimInputUtils::construct_truth_bitmap(std::shared_ptr<const HepMC3::GenParticle>(particleLink.cptr()));
867 #else
868 parentMask |= FPGATrackSimInputUtils::construct_truth_bitmap(particleLink.cptr());
869 #endif
870 // check SDO
871 } // end for each contributing particle
872 return bestTruthLink;
873}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
defines an "iterator" over instances of a given type in StoreGateSvc
: FPGATrackSim-specific class to represent an hit in the detector.
ATLAS-specific HepMC functions.
void setClusterEquiv(const FPGATrackSimHit &input)
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 setPhiModule(unsigned v)
void setIdentifierHash(unsigned v)
void setEtaIndex(unsigned v)
void setEventIndex(long v)
void setPhiIndex(unsigned v)
void setStripChipIDForITk(int v)
long getEventIndex() const
void setHitType(HitType type)
float getBarcodePt() const
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 setisValidForITkHit(bool v)
void setRdoIdentifier(Identifier::value_type v)
void setParentageMask(unsigned long v)
void setBarcodePt(float v)
HepMcParticleLink::barcode_type getBarcode() const
void setToT(unsigned v)
void setY(float v)
void setLayerDisk(unsigned v)
void setEtaModule(int v)
void setStripHitMapForITk(int v)
void setStripRowIDForITk(int v)
void setSide(unsigned v)
void setEtaCoord(float v)
void setTruth(const FPGATrackSimMultiTruth &v)
void setEtaWidth(unsigned v)
void setPhiWidth(unsigned v)
void setUniqueID(const HepMcParticleLink::barcode_type &v)
void setDetectorZone(DetectorZone detZone)
void setDetType(SiliconTech detType)
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
std::pair< unsigned long, unsigned long > Barcode
void addHit(const FPGATrackSimOfflineHit &s)
void addOfflineCluster(const FPGATrackSimCluster &c)
void addTruthTrack(const FPGATrackSimTruthTrack &t)
void addOfflineTrack(const FPGATrackSimOfflineTrack &t)
SG::ReadHandleKey< InDet::SiClusterContainer > m_pixelClusterContainerKey
Gaudi::Property< bool > m_readOfflineTracks
StatusCode readRawSilicon(HitIndexMap &hitIndexMap, const EventContext &eventContext)
ToolHandle< Trk::ITruthToTrack > m_truthToTrack
tool to create track parameters from a gen particle
StatusCode readPixelSimulation(HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext)
const InDetDD::SiDetectorManager * m_SCT_mgr
SG::ReadHandleKey< InDetSimDataCollection > m_stripSDOKey
const HepMcParticleLink * getTruthInformation(InDetSimDataCollection::const_iterator &iter, FPGATrackSimInputUtils::ParentBitmask &parentMask)
SG::ReadHandleKey< SCT_RDO_Container > m_stripRDOKey
StatusCode dumpPixelClusters(HitIndexMap &pixelClusterIndexMap, const EventContext &eventContext)
Gaudi::Property< bool > m_readOfflineClusters
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
StatusCode readOfflineClusters(std::vector< FPGATrackSimCluster > &Clusters, const EventContext &eventContext)
StatusCode readStripSimulation(HitIndexMap &hitIndexMap, unsigned int &hitIndex, const EventContext &eventContext)
const InDetDD::SiDetectorManager * m_PIX_mgr
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_offlineTracksKey
ToolHandle< Trk::IExtrapolator > m_extrapolator
ToolHandle for Extrapolator.
FPGATrackSimEventInputHeader * m_eventHeader
std::map< Identifier, int > HitIndexMap
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
SG::ReadHandleKey< InDet::SiClusterContainer > m_sctClusterContainerKey
Gaudi::Property< bool > m_readTruthTracks
virtual StatusCode finalize() override
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
FPGATrackSimSGToRawHitsTool(const std::string &, const std::string &, const IInterface *)
Gaudi::Property< bool > m_UseNominalOrigin
virtual StatusCode readData(FPGATrackSimEventInputHeader *header, const EventContext &eventContext) override
This function get from the SG the inner detector raw hits and prepares them for FPGATrackSim simulati...
StatusCode readOfflineTracks(std::vector< FPGATrackSimOfflineTrack > &Track, const EventContext &eventContext)
StatusCode readTruthTracks(std::vector< FPGATrackSimTruthTrack > &truth, const EventContext &eventContext)
SG::ReadHandleKey< McEventCollection > m_mcCollectionKey
const HepPDT::ParticleDataTable * m_particleDataTable
SG::ReadHandleKey< InDetSimDataCollection > m_pixelSDOKey
virtual StatusCode initialize() override
void setUniqueID(const HepMcParticleLink::barcode_type &v)
void setBarcode(const HepMcParticleLink::barcode_type &v)
value_type get_compact() const
Get the compact id.
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 SiCellId connectedCell(const SiReadoutCellId &readoutId, int number) const =0
readout id -> id of connected diodes.
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const =0
readout or diode id -> position.
Identifier for the strip or pixel cell.
Definition SiCellId.h:29
Base class for the detector design classes for Pixel and SCT.
Class to hold geometrical description of a silicon detector element.
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):
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 identifierFromCellId(const SiCellId &cellId) const override final
Identifier <-> SiCellId (ie strip number or pixel eta_index,phi_index) Identifier from SiCellId (ie s...
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
Identifier for the strip or pixel readout cell.
SiCellId connectedCell(const SiCellId cellId, int number) const
Get the cell ids sharing the readout for this cell.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
int numberOfConnectedCells(const SiCellId cellId) const
Test if readout cell has more than one diode associated with it.
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.
virtual Identifier identify() const override final
std::pair< HepMcParticleLink, float > Deposit
const std::vector< Deposit > & getdeposits() const
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Class describing the Line to which the Perigee refers to.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
const ParentBitmask construct_truth_bitmap(HepMC::ConstGenParticlePtr p)
std::bitset< NBITS > ParentBitmask
int barcode(const T *p)
Definition Barcode.h:16
int uniqueID(const T &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...
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
GenVertex * signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:627
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ anyDirection
DataVector< const Trk::TrackStateOnSurface > TrackStates
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ 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
TrackParticle_v1 TrackParticle
Reference the current persistent version: