ATLAS Offline Software
xAODTrackParticleAuxContainerCnv_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
6 
7 // System include(s):
8 #include <stdexcept>
9 
10 // Gaudi/Athena include(s):
11 #include "GaudiKernel/MsgStream.h"
12 
13 // Core EDM include(s):
15 
16 // Local include(s):
20 
21 // Amg include
23 
25 #define MSGLVL MSG::DEBUG
26 
28 #define ATH_MSG( MSG ) \
29 do { \
30  if( log.level() <= MSGLVL ) { \
31  log << MSGLVL << MSG << endmsg; \
32  } \
33 } while( 0 )
34 
36 {
37 }
38 
42  MsgStream& log ) const {
43 
44  // Greet the user:
45  ATH_MSG( "Converting xAOD::TrackParticleAuxContainer_v1 to current version..." );
46 
47  // Clear the transient object:
48  newObj->resize( 0 );
49 
50  // Copy the payload of the v1 object into the latest one by misusing
51  // the thinning code a bit...
52  SG::copyAuxStoreThinned( *oldObj, *newObj, nullptr );
53 
54  // Set up interface containers on top of them:
55 
56  //The old uses v_
58  for( size_t i = 0; i < oldObj->size(); ++i ) {
59  oldInt.push_back( new xAOD::TrackParticle_v1() );
60  }
61  oldInt.setStore( oldObj );
62 
64  for( size_t i = 0; i < newObj->size(); ++i ) {
65  newInt.push_back( new xAOD::TrackParticle() );
66  }
67  newInt.setStore( newObj );
68 
69  unsigned int index=0;
70  float x,y;
72  std::vector<float> covMatrixVec;
73 
74  for( size_t i = 0; i < oldInt.size(); ++i ) {
75  index=0;
76  if (oldInt[ i ]->indexOfParameterAtPosition (index, xAOD::FirstMeasurement)){
77  x = oldInt[ i ]->parameterX(index);
78  y = oldInt[ i ]->parameterY(index);
79  newInt[ i ]->setRadiusOfFirstHit(std::sqrt(x*x + y*y));
80  } else {
81  ATH_MSG( "Can't find first hit!" );
82  }
83 
84 
85  static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerHitsAcc( "numberOfBLayerHits" );
86  static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerSharedHitsAcc( "numberOfBLayerSharedHits" );
87  static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerOutliersAcc( "numberOfBLayerOutliers" );
88  static const SG::AuxElement::ConstAccessor< uint8_t > numberOfBLayerSplitHitsAcc( "numberOfBLayerSplitHits" );
89  static const SG::AuxElement::ConstAccessor< uint8_t > expectBLayerHitAcc( "expectBLayerHit" );
90 
91  if( numberOfBLayerHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
92 
93  numberOfBLayerHits = numberOfBLayerHitsAcc( *( oldInt[ i ] ) );
94  newInt[ i ]->setSummaryValue( numberOfBLayerHits ,xAOD::numberOfInnermostPixelLayerHits);
95 
96  }
97 
98  if( numberOfBLayerSharedHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
99 
100  numberOfBLayerSharedHits = numberOfBLayerSharedHitsAcc( *( oldInt[ i ] ) );
102 
103  }
104 
105  if( numberOfBLayerOutliersAcc.isAvailable( *( oldInt[ i ] ) ) ) {
106 
107  numberOfBLayerOutliers = numberOfBLayerOutliersAcc( *( oldInt[ i ] ) );
109 
110  }
111 
112  if( numberOfBLayerSplitHitsAcc.isAvailable( *( oldInt[ i ] ) ) ) {
113 
114  numberOfBLayerSplitHits = numberOfBLayerSplitHitsAcc( *( oldInt[ i ] ) );
116 
117  }
118 
119  if( expectBLayerHitAcc.isAvailable( *( oldInt[ i ] ) ) ) {
120  expectBLayerHit = expectBLayerHitAcc( *( oldInt[ i ] ) );
121  newInt[ i ]->setSummaryValue( expectBLayerHit ,xAOD::expectInnermostPixelLayerHit);
122 
123  }
124 
125 
126  static const SG::AuxElement::ConstAccessor< std::vector<float> > definingParametersCovMatrixAcc( "definingParametersCovMatrix" );
127 
128  if( definingParametersCovMatrixAcc.isAvailable( *( oldInt[ i ] ) ) ) {
129 
130  covMatrixVec = definingParametersCovMatrixAcc( *( oldInt[ i ] ) );
131  xAOD::ParametersCovMatrix_t cov;
132  Amg::expand( covMatrixVec.begin(), covMatrixVec.end(),cov );
133  newInt[ i ]->setDefiningParametersCovMatrix(cov);
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 }
SG::copyAuxStoreThinned
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore &copy, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
xAOD::numberOfInnermostPixelLayerSplitHits
@ numberOfInnermostPixelLayerSplitHits
number of Pixel 0th layer barrel hits split by cluster splitting
Definition: TrackingPrimitives.h:240
xAOD::TrackParticleAuxContainer_v5
Temporary container used until we have I/O for AuxStoreInternal.
Definition: TrackParticleAuxContainer_v5.h:35
xAODTrackParticleAuxContainerCnv_v1::persToTrans
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.
Definition: xAODTrackParticleAuxContainerCnv_v1.cxx:40
xAODTrackParticleAuxContainerCnv_v1.h
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
xAOD::expectBLayerHit
@ expectBLayerHit
Do we expect a b-layer hit for this track? [unit8_t] (should be [bool])
Definition: TrackingPrimitives.h:235
index
Definition: index.py:1
EventPrimitivesHelpers.h
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
x
#define x
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: AuxContainerBase.cxx:485
xAOD::numberOfBLayerHits
@ numberOfBLayerHits
these are the hits in the first pixel layer, i.e.
Definition: TrackingPrimitives.h:231
xAOD::numberOfBLayerSplitHits
@ numberOfBLayerSplitHits
number of Pixel b-layer hits split by cluster splitting [unit8_t].
Definition: TrackingPrimitives.h:234
Amg::expand
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
Definition: EventPrimitivesHelpers.h:75
xAOD::AuxContainerBase::size
virtual size_t size() const override
Get the size of the container.
Definition: AuxContainerBase.cxx:410
xAOD::numberOfInnermostPixelLayerOutliers
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
Definition: TrackingPrimitives.h:238
copyAuxStoreThinned.h
Helper to copy an aux store while applying thinning.
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::FirstMeasurement
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.
Definition: TrackingPrimitives.h:213
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
DataVector< xAOD::TrackParticle_v1 >
xAOD::TrackParticleAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: TrackParticleAuxContainer_v1.h:37
xAOD::numberOfBLayerSharedHits
@ numberOfBLayerSharedHits
number of Pixel b-layer hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:233
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
y
#define y
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::numberOfInnermostPixelLayerSharedHits
@ numberOfInnermostPixelLayerSharedHits
number of Pixel 0th layer barrel hits shared by several tracks.
Definition: TrackingPrimitives.h:239
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
TrackParticleContainer_v1.h
xAODTrackParticleAuxContainerCnv_v1::transToPers
virtual void transToPers(const xAOD::TrackParticleAuxContainer *, xAOD::TrackParticleAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
Definition: xAODTrackParticleAuxContainerCnv_v1.cxx:151
xAODTrackParticleAuxContainerCnv_v1::xAODTrackParticleAuxContainerCnv_v1
xAODTrackParticleAuxContainerCnv_v1()
Default constructor.
Definition: xAODTrackParticleAuxContainerCnv_v1.cxx:35
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ATH_MSG
#define ATH_MSG(MSG)
Another convenience macro for printing messages in the converter.
Definition: xAODTrackParticleAuxContainerCnv_v1.cxx:28
TrackParticleContainer.h
xAOD::numberOfBLayerOutliers
@ numberOfBLayerOutliers
number of blayer outliers [unit8_t].
Definition: TrackingPrimitives.h:232
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237