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