ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTrackParticleAuxContainerCnv_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// System include(s):
6#include <stdexcept>
7
8// Gaudi/Athena include(s):
9#include "GaudiKernel/MsgStream.h"
10
11// Core EDM include(s):
13
14// Local include(s):
18
19// Amg include
21
23#define MSGLVL MSG::DEBUG
24
26#define ATH_MSG( MSG ) \
27do { \
28 if( log.level() <= MSGLVL ) { \
29 log << MSGLVL << MSG << endmsg; \
30 } \
31} while( 0 )
32
36
40 MsgStream& log ) const {
41
42 // Greet the user:
43 ATH_MSG( "Converting xAOD::TrackParticleAuxContainer_v1 to current version..." );
44
45 // Clear the transient object:
46 newObj->resize( 0 );
47
48 // Copy the payload of the v1 object into the latest one by misusing
49 // the thinning code a bit...
50 SG::copyAuxStoreThinned( *oldObj, *newObj, nullptr );
51
52 // Set up interface containers on top of them:
53
54 //The old uses v_
56 for( size_t i = 0; i < oldObj->size(); ++i ) {
57 oldInt.push_back( new xAOD::TrackParticle_v1() );
58 }
59 oldInt.setStore( oldObj );
60
62 for( size_t i = 0; i < newObj->size(); ++i ) {
63 newInt.push_back( new xAOD::TrackParticle() );
64 }
65 newInt.setStore( newObj );
66
67 unsigned int index=0;
68 float x,y;
69 uint8_t numberOfBLayerHits=0,numberOfBLayerSharedHits=0,numberOfBLayerOutliers=0,numberOfBLayerSplitHits=0,expectBLayerHit=0;
70 std::vector<float> covMatrixVec;
71
72 for( size_t i = 0; i < oldInt.size(); ++i ) {
73 index=0;
74 if (oldInt[ i ]->indexOfParameterAtPosition (index, xAOD::FirstMeasurement)){
75 x = oldInt[ i ]->parameterX(index);
76 y = oldInt[ i ]->parameterY(index);
77 newInt[ i ]->setRadiusOfFirstHit(std::sqrt(x*x + y*y));
78 } else {
79 ATH_MSG( "Can't find first hit!" );
80 }
81
82
83 static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerHitsAcc( "numberOfBLayerHits" );
84 static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerSharedHitsAcc( "numberOfBLayerSharedHits" );
85 static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerOutliersAcc( "numberOfBLayerOutliers" );
86 static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerSplitHitsAcc( "numberOfBLayerSplitHits" );
87 static const SG::AuxElement::ConstAccessor< uint8_t > expectBLayerHitAcc( "expectBLayerHit" );
88
89 if( numberOfBLayerHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
90
91 numberOfBLayerHits = numberOfBLayerHitsAcc( *( oldInt[ i ] ) );
92 newInt[ i ]->setSummaryValue( numberOfBLayerHits ,xAOD::numberOfInnermostPixelLayerHits);
93
94 }
95
96 if( numberOfBLayerSharedHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
97
98 numberOfBLayerSharedHits = numberOfBLayerSharedHitsAcc( *( oldInt[ i ] ) );
99 newInt[ i ]->setSummaryValue( numberOfBLayerSharedHits ,xAOD::numberOfInnermostPixelLayerSharedHits);
100
101 }
102
103 if( numberOfBLayerOutliersAcc.isAvailable( *( oldInt[ i ] ) ) ) {
104
105 numberOfBLayerOutliers = numberOfBLayerOutliersAcc( *( oldInt[ i ] ) );
106 newInt[ i ]->setSummaryValue( numberOfBLayerOutliers ,xAOD::numberOfInnermostPixelLayerOutliers);
107
108 }
109
110 if( numberOfBLayerSplitHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
111
112 numberOfBLayerSplitHits = numberOfBLayerSplitHitsAcc( *( oldInt[ i ] ) );
113 newInt[ i ]->setSummaryValue( numberOfBLayerSplitHits ,xAOD::numberOfInnermostPixelLayerSplitHits);
114
115 }
116
117 if( expectBLayerHitAcc.isAvailable( *( oldInt[ i ] ) ) ) {
118 expectBLayerHit = expectBLayerHitAcc( *( oldInt[ i ] ) );
119 newInt[ i ]->setSummaryValue( expectBLayerHit ,xAOD::expectInnermostPixelLayerHit);
120
121 }
122
123
124 static const SG::AuxElement::ConstAccessor< std::vector<float> > definingParametersCovMatrixAcc( "definingParametersCovMatrix" );
125
126 if( definingParametersCovMatrixAcc.isAvailable( *( oldInt[ i ] ) ) ) {
127
128 covMatrixVec = definingParametersCovMatrixAcc( *( oldInt[ i ] ) );
129 if (!covMatrixVec.empty()) {
130 xAOD::ParametersCovMatrix_t cov;
131 Amg::expand( covMatrixVec.begin(), covMatrixVec.end(),cov );
132 newInt[ i ]->setDefiningParametersCovMatrix(cov);
133 }
134
135 }
136
137 }
138
139 // FIXME - what do we do about the identifier?
140
141 // Print what happened:
142 ATH_MSG( "Converting xAOD::TrackParticleAuxContainer_v1 to current version "
143 "[OK]" );
144
145 return;
146}
147
153 MsgStream& log ) const {
154
155 log << MSG::ERROR
156 << "Somebody called xAODTrackParticleAuxContainerCnv_v1::transToPers"
157 << endmsg;
158 throw std::runtime_error( "Somebody called xAODTrackParticleAuxContainerCnv_v1::"
159 "transToPers" );
160 return;
161}
#define endmsg
#define ATH_MSG(lvl)
#define y
#define x
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual void transToPers(const xAOD::TrackParticleAuxContainer *, xAOD::TrackParticleAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
virtual void persToTrans(const xAOD::TrackParticleAuxContainer_v1 *oldObj, xAOD::TrackParticleAuxContainer *newObj, MsgStream &log) const override
Function converting from the old type to the current one.
virtual bool resize(size_t size) override
Resize the arrays to a given size.
virtual size_t size() const override
Get the size of the container.
Temporary container used until we have I/O for AuxStoreInternal.
Class describing a TrackParticle.
Helper to copy an aux store while applying thinning.
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore &copy, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
Definition index.py:1
DataVector< xAOD::TrackParticle_v1 > TrackParticleContainer_v1
The container is a simple typedef for now.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
TrackParticleAuxContainer_v5 TrackParticleAuxContainer
Definition of the current TrackParticle auxiliary container.
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfInnermostPixelLayerSharedHits
number of Pixel 0th layer barrel hits shared by several tracks.
@ numberOfInnermostPixelLayerSplitHits
number of Pixel 0th layer barrel hits split by cluster splitting
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.