19 #include "TDatabasePDG.h"
20 #include "TParticlePDG.h"
31 const std::string&
name,
32 ISvcLocator* pSvcLocator) :
42 ATH_CHECK( m_beamSpotDecoKey.initialize() );
43 ATH_CHECK( m_truthPixelClusterName.initialize() );
44 ATH_CHECK( m_truthSCTClusterName.initialize() );
45 ATH_CHECK( m_truthParticleName.initialize() );
49 *
this, m_truthParticleName,
50 m_prefix.value(), m_decor_names, m_decor );
52 if( m_decor.size() != NDecorations ) {
53 ATH_MSG_ERROR(
"Incorrect booking of truth hits decorations" );
54 return StatusCode::FAILURE;
57 return StatusCode::SUCCESS;
65 const EventContext& ctx )
const {
70 ATH_MSG_ERROR(
"Failed to retrieve truth particle container" );
71 return StatusCode::FAILURE;
74 std::vector< IDTPM::OptionalDecoration< xAOD::TruthParticleContainer, float > >
80 std::unordered_map< int, float > barcodeSCTclustercount;
81 std::unordered_map< int, float > barcodePIXclustercount;
95 std::vector<int> truth_barcode;
97 truth_barcode = barcodeAcc( *sctCluster );
98 for(
const int&
barcode : truth_barcode ) {
99 auto result = barcodeSCTclustercount.emplace( std::pair<int, float>(
barcode, 0.0) );
107 std::vector<int> truth_barcode;
109 truth_barcode = barcodeAcc( *pixCluster );
110 for(
const int&
barcode : truth_barcode ) {
111 auto result = barcodePIXclustercount.emplace( std::pair<int, float>(
barcode, 0.0) );
118 if( float_decor.empty() ) {
119 ATH_MSG_ERROR(
"Failed to book Truth particles Hit decorations" );
120 return StatusCode::FAILURE;
127 if( (not beamPosX.isValid()) or (not beamPosY.isValid()) or (not beamPosZ.isValid()) ) {
129 return StatusCode::RECOVERABLE;
136 *truth_particle, float_decor, beamPos,
137 barcodePIXclustercount, barcodeSCTclustercount, ctx ) );
140 return StatusCode::SUCCESS;
151 std::unordered_map<int, float>& pixelMap,
152 std::unordered_map<int, float>& sctMap,
153 const EventContext& ctx )
const {
157 return StatusCode::SUCCESS;
164 if( std::isnan(
charge) ) {
166 return StatusCode::SUCCESS;
174 if(
it1 !=pixelMap.end() )
nSiHits += (*it1).second;
175 if( it2 !=sctMap.end() )
nSiHits += (*it2).second;
184 if ( not m_errorEmitted ) {
185 ATH_MSG_WARNING(
"A non existent production vertex was requested in calculating the track parameters d0 etc" );
187 m_errorEmitted =
true;
188 return StatusCode::RECOVERABLE;
191 if( not ptruthVertex ) {
192 ATH_MSG_DEBUG(
"A production vertex pointer was retrieved, but it is NULL" );
193 return StatusCode::SUCCESS;
196 const auto xPos = ptruthVertex->x();
197 const auto yPos = ptruthVertex->y();
198 const auto z_truth = ptruthVertex->z();
200 const float prodR_truth = std::sqrt( xPos * xPos + yPos * yPos );
205 std::unique_ptr< const Trk::TrackParameters > tP(
206 m_extrapolator->extrapolate( ctx, cParameters,
209 ATH_MSG_DEBUG(
"The TrackParameters pointer for this TruthParticle is NULL" );
210 return StatusCode::SUCCESS;
214 float d0_truth = tP->parameters()[
Trk::d0 ];
215 float theta_truth = tP->parameters()[
Trk::theta ];
216 float z0_truth = tP->parameters()[
Trk::z0 ];
217 float phi_truth = tP->parameters()[
Trk::phi ];
218 float qOverP_truth = tP->parameters()[
Trk::qOverP ];
219 float z0st_truth = z0_truth *
std::sin( theta_truth );
222 " has impact parameter (d0, z0) = (" << d0_truth <<
223 " ," << z0_truth <<
")" );
234 return StatusCode::SUCCESS;