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

Write Handler for ISF and ActsFatras. More...

#include <ActsFatrasWriteHandler.h>

Inheritance diagram for ActsFatrasWriteHandler:
Collaboration diagram for ActsFatrasWriteHandler:

Public Member Functions

 ActsFatrasWriteHandler (const std::string &, const std::string &, const IInterface *)
 Constructor.
 ~ActsFatrasWriteHandler ()
 Destructor.
virtual StatusCode initialize () override
virtual StatusCode finalize () override
StatusCode WriteHits (std::vector< SiHitCollection > &HitCollections, const EventContext &ctx) const
void createHits (const ISF::ISFParticle &isp, std::shared_ptr< const Acts::TrackingGeometry > trackingGeometry, const std::vector< ActsFatras::Hit > &hits, SiHitCollection &pixelSiHits, SiHitCollection &sctSiHits) const
 Loop over the hits and call the hit creator, provide the ActsFatras::Particle to create the hits.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

const PixelIDm_pixIdHelper {}
 the Pixel ID helper
const SCT_IDm_sctIdHelper {}
 the SCT ID helper
std::array< StringProperty, 2 > m_HitCollectionNames {{{this,"PixelCollectionName","PixelHits_ActsFatras"},{this,"SCTCollectionName","SCT_Hits_ActsFatras"}}}
SG::WriteHandleKeyArray< SiHitCollectionm_HitCollectionKeys

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Write Handler for ISF and ActsFatras.

Author
rui.w.nosp@m.ang@.nosp@m.cern..nosp@m.ch

Definition at line 45 of file ActsFatrasWriteHandler.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ActsFatrasWriteHandler()

ActsFatrasWriteHandler::ActsFatrasWriteHandler ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor.

Definition at line 20 of file ActsFatrasWriteHandler.cxx.

22 : AthAlgTool(type, name, parent){}
AthAlgTool()
Default constructor:

◆ ~ActsFatrasWriteHandler()

ActsFatrasWriteHandler::~ActsFatrasWriteHandler ( )

Destructor.

Definition at line 24 of file ActsFatrasWriteHandler.cxx.

24{}

Member Function Documentation

◆ createHits()

void ActsFatrasWriteHandler::createHits ( const ISF::ISFParticle & isp,
std::shared_ptr< const Acts::TrackingGeometry > trackingGeometry,
const std::vector< ActsFatras::Hit > & hits,
SiHitCollection & pixelSiHits,
SiHitCollection & sctSiHits ) const

Loop over the hits and call the hit creator, provide the ActsFatras::Particle to create the hits.

<

Todo
: fix edge effects

Definition at line 59 of file ActsFatrasWriteHandler.cxx.

63{
64 ATH_MSG_VERBOSE(name() << " particle " << isp << " with " << hits.size() << " hits");
65 for (auto& hit:hits){
66 double energyDeposit = hit.depositedEnergy() / Acts::UnitConstants::MeV;
67 double time = ActsTrk::timeToAthena(hit.time());
68
69 // get the ACTS geo identifier
70 auto hit_geoid = hit.geometryId();
71 // get the ACTS surface
72 try {
73 auto acts_surface = trackingGeometry->findSurface(hit_geoid);
74 const ActsDetectorElement* acts_de = dynamic_cast<const ActsDetectorElement*>(acts_surface->associatedDetectorElement());
75
76 const Trk::Surface& hitSurface = acts_de->atlasSurface();
77 ATH_MSG_VERBOSE(name() << " Surface position global atlas: " << hitSurface.center());
78 // get the ATLAS identifier and hash identifier
79 Identifier hitId = hitSurface.associatedDetectorElementIdentifier();
80 ATH_MSG_VERBOSE(name() << " hit Id Acts|atlas: "<< hit_geoid <<"|" << hitId);
81 const Trk::TrkDetElementBase* detElementBase = hitSurface.associatedDetectorElement();
82 const InDetDD::SiDetectorElement* hitSiDetElement = dynamic_cast<const InDetDD::SiDetectorElement*>((detElementBase));
83 ATH_MSG_VERBOSE(name() << " hit position global Acts|atlas: " << hit.position() <<"|" << detElementBase->center());
84
85 auto intersection = hitSurface.globalToLocal(hit.position());
86 ATH_MSG_VERBOSE(name() << " hit isOnSurface: "<<hitSurface.isOnSurface(hit.position()));
87 ATH_MSG_VERBOSE(name() << " intersection (atlas local) " << intersection.value().x() <<"," << intersection.value().y());
88 double interX = intersection.value().x();
89 double interY = intersection.value().y();
90
91 double thickness = hitSiDetElement->thickness();
92 ATH_MSG_VERBOSE(name() << " thickness (atlas)" << thickness);
93
94 const Amg::Transform3D &hitTransform = hitSiDetElement->transformHit().inverse();
95 // get the momentum direction into the local frame
96 Amg::Vector3D particleDir = hit.direction();
97 const Amg::Transform3D& sTransform = hitSurface.transform();
98 Amg::Vector3D localDirection = sTransform.inverse().linear() * particleDir;
99 localDirection *= thickness/cos(localDirection.theta());
100 // moving direction
101 int movingDirection = localDirection.z() > 0. ? 1 : -1;
102 // get he local distance of the intersection in x,y
103 double distX = localDirection.x();
104 double distY = localDirection.y();
105 // local entries in x,y
106 double localEntryX = interX-0.5*distX;
107 double localEntryY = interY-0.5*distY;
108 double localExitX = interX+0.5*distX;
109 double localExitY = interY+0.5*distY;
111 // transform into the hit frame
112 Amg::Vector3D localEntry(hitTransform * (sTransform * Amg::Vector3D(localEntryX,localEntryY,-0.5*movingDirection*thickness)));
113 Amg::Vector3D localExit(hitTransform * (sTransform * Amg::Vector3D(localExitX,localExitY,0.5*movingDirection*thickness)));
114 const HepGeom::Point3D<double> localEntryHep( localEntry.x(), localEntry.y(), localEntry.z() );
115 const HepGeom::Point3D<double> localExitHep( localExit.x(), localExit.y(), localExit.z() );
116
117 auto isPixel=hitSiDetElement->isPixel();
118 ATH_MSG_VERBOSE(name() << " localEntryHep|localExitHep (atlas)" << localEntryHep << "|" << localExitHep);
119 ATH_MSG_VERBOSE(name() << " isPixel " << isPixel);
120 ATH_MSG_VERBOSE(name() << " barrel_ec (atlas)" << (isPixel ? m_pixIdHelper->barrel_ec(hitId) : m_sctIdHelper->barrel_ec(hitId)));
121 ATH_MSG_VERBOSE(name() << " layer_disk (atlas)" << (isPixel ? m_pixIdHelper->layer_disk(hitId) : m_sctIdHelper->layer_disk(hitId)));
122 ATH_MSG_VERBOSE(name() << " eta_module (atlas)" << (isPixel ? m_pixIdHelper->eta_module(hitId) : m_sctIdHelper->eta_module(hitId)));
123 ATH_MSG_VERBOSE(name() << " phi_module (atlas)" << (isPixel ? m_pixIdHelper->phi_module(hitId) : m_sctIdHelper->phi_module(hitId)));
124
125 auto partLink = isp.getParticleLink();
126 auto siHit = SiHit(localEntryHep,
127 localExitHep,
128 energyDeposit,
129 time,
130 *partLink,
131 isPixel ? 0 : 1,
132 isPixel ? m_pixIdHelper->barrel_ec(hitId) : m_sctIdHelper->barrel_ec(hitId),
133 isPixel ? m_pixIdHelper->layer_disk(hitId) : m_sctIdHelper->layer_disk(hitId),
134 isPixel ? m_pixIdHelper->eta_module(hitId) : m_sctIdHelper->eta_module(hitId),
135 isPixel ? m_pixIdHelper->phi_module(hitId) : m_sctIdHelper->phi_module(hitId),
136 isPixel ? 0 : m_sctIdHelper->side(hitId));
137 if (isPixel)
138 pixelSiHits.push_back(siHit);
139 else
140 sctSiHits.push_back(siHit);
141 ATH_MSG_VERBOSE(name() << " convert and store 1 hit, total " << pixelSiHits.size() << " Pixel | "<<sctSiHits.size()<< " SCT hits stored for particle" << isp);
142 }
143 catch (const std::exception& e){
144 ATH_MSG_DEBUG(name() << "Can not find Acts Surface (" << e.what() << ")...Skip...");
145 }
146 }
147}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
const Trk::Surface & atlasSurface() const
Return a shared pointer on the ATLAS surface associated with this identifier,.
const PixelID * m_pixIdHelper
the Pixel ID helper
const SCT_ID * m_sctIdHelper
the SCT ID helper
void push_back(const T &t)
size_type size() const
const HepMcParticleLink * getParticleLink() const
HepMcParticleLink accessors.
const GeoTrf::Transform3D & transformHit() const
Local (simulation/hit frame) to global transform.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const
This method returns true if the GlobalPosition is on the Surface for both, within or without check of...
Definition Surface.cxx:123
const Amg::Vector3D & center() const
Returns the center position of the Surface.
virtual const Amg::Vector3D & center() const =0
Return the center of the element.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
constexpr double timeToAthena(const double actsT)
Converts a time unit from Acts to Athena units.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
time(flags, cells_name, *args, **kw)
@ energyDeposit

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode ActsFatrasWriteHandler::finalize ( )
overridevirtual

Definition at line 54 of file ActsFatrasWriteHandler.cxx.

55{
56 return StatusCode::SUCCESS;
57}

◆ initialize()

StatusCode ActsFatrasWriteHandler::initialize ( )
overridevirtual

Definition at line 26 of file ActsFatrasWriteHandler.cxx.

27{
28 ATH_MSG_INFO(name() << " initialize()" );
29 // Get the Pixel Identifier-helper
31 // Get the SCT Identifier-helper
33 // setup handle keys
34 for(auto const& HitCollectionName:m_HitCollectionNames){
35 m_HitCollectionKeys.push_back(static_cast<std::string>(HitCollectionName));
36 }
37 ATH_CHECK(m_HitCollectionKeys.initialize());
38
39 ATH_MSG_INFO(name() << " initialize() successful" );
40 return StatusCode::SUCCESS;
41}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
SG::WriteHandleKeyArray< SiHitCollection > m_HitCollectionKeys
std::array< StringProperty, 2 > m_HitCollectionNames
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ WriteHits()

StatusCode ActsFatrasWriteHandler::WriteHits ( std::vector< SiHitCollection > & HitCollections,
const EventContext & ctx ) const

Definition at line 43 of file ActsFatrasWriteHandler.cxx.

44{
45 auto HitsWriteHandles = m_HitCollectionKeys.makeHandles(ctx);
46 for(long unsigned int i=0;i<HitCollections.size();++i){
47 ATH_MSG_DEBUG(name() << " WriteHits: adding "<<m_HitCollectionNames[i]<< " "<<HitCollections[i].size()<<" hits");
48 ATH_CHECK(HitsWriteHandles[i].record(std::make_unique<SiHitCollection>(HitCollections[i])));
49 ATH_MSG_DEBUG(name() << " WriteHits: added "<<m_HitCollectionNames[i]<< " "<<HitCollections[i].size()<<" hits");
50 }
51 return StatusCode::SUCCESS;
52}

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_HitCollectionKeys

SG::WriteHandleKeyArray<SiHitCollection> ActsFatrasWriteHandler::m_HitCollectionKeys
protected

Definition at line 73 of file ActsFatrasWriteHandler.h.

◆ m_HitCollectionNames

std::array<StringProperty,2> ActsFatrasWriteHandler::m_HitCollectionNames {{{this,"PixelCollectionName","PixelHits_ActsFatras"},{this,"SCTCollectionName","SCT_Hits_ActsFatras"}}}
protected

Definition at line 72 of file ActsFatrasWriteHandler.h.

72{{{this,"PixelCollectionName","PixelHits_ActsFatras"},{this,"SCTCollectionName","SCT_Hits_ActsFatras"}}};

◆ m_pixIdHelper

const PixelID* ActsFatrasWriteHandler::m_pixIdHelper {}
protected

the Pixel ID helper

Definition at line 69 of file ActsFatrasWriteHandler.h.

69{};

◆ m_sctIdHelper

const SCT_ID* ActsFatrasWriteHandler::m_sctIdHelper {}
protected

the SCT ID helper

Definition at line 70 of file ActsFatrasWriteHandler.h.

70{};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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