Execute method.
75{
76
77
79 if (not h_trtPrds.isValid()) {
81 return StatusCode::FAILURE;
82 }
83
84
85
86
87 const PRD_MultiTruthCollection* prdmtColl = nullptr;
89 SG::ReadHandle<PRD_MultiTruthCollection> h_prdmtColl(
m_multiTruth, ctx);
90 if (not h_prdmtColl.isValid()){
93 } else {
94 prdmtColl = h_prdmtColl.cptr();
95 }
96 }
97
98
99
100
101 const InDetSimDataCollection* sdoCollection = nullptr;
103 SG::ReadHandle<InDetSimDataCollection> h_sdoCollection(
m_SDOcontainer, ctx);
104 if (not h_sdoCollection.isValid()) {
107 } else{
108 sdoCollection = h_sdoCollection.cptr();
109 }
110 }
111
112
113
114 SG::WriteHandle<xAOD::TrackMeasurementValidationContainer> xaod(
m_xAodContainer, ctx);
115 ATH_CHECK(xaod.record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>() ) );
116
117 SG::WriteHandle<std::vector<unsigned int>> offsets(
m_xAodOffset, ctx);
118 ATH_CHECK(offsets.record(std::make_unique<std::vector<unsigned int>>(
m_TRTHelper->straw_layer_hash_max() , 0) ));
119
120 InDet::TRT_DriftCircleContainer::const_iterator
it = h_trtPrds->begin();
121 InDet::TRT_DriftCircleContainer::const_iterator it_end = h_trtPrds->end();
123 for( ;
it!=it_end; ++
it ) {
124
125
126 if(
m_TRTHelper->straw_layer_hash_max() <= (*it)->identifyHash() )
127 ATH_MSG_ERROR(
"My assumption about the maximum size of the hash was wrong");
128 (*offsets)[ (*it)->identifyHash() ] =
counter;
129
130
131 if( (*it)->empty() ) continue;
132
133
134 for( const auto prd : **it ){
135
137
138
140 xaod->push_back(xprd);
141
142 Identifier surfaceID = prd->identify();
143
145
146
147
153 const InDetDD::TRT_BaseElement* element =
m_trtman->getElement(surfaceID);
154 AUXDATA(xprd,
float, strawphi) = element->
center(surfaceID).phi();
155
156 int chip=0;
157 int board=-1;
161 else if (chip<12)
162 board=0;
163 else {
164 chip=chip-20;
165 board=1;
166 }
167 AUXDATA(xprd,
int, TRTboard) = board ;
168 AUXDATA(xprd,
int, TRTchip) = chip ;
169
170
171
174 float locX = locpos.x();
175 if ( !(std::isinf(locpos.y()) || std::isnan(locpos.y())) ){
176 if (locpos.y()>=1e-07)
178 } else {
180 }
181
182
184
186 if(localCov.size() == 1){
188 } else if(localCov.size() == 2){
190 } else {
192 }
193
194
195
196 const Amg::Vector3D gpos = prd->detectorElement()->surface(surfaceID).localToGlobal(prd->localPosition());
198
199
200
201 unsigned int word = prd->getWord();
202
203
204 double tot = prd->timeOverThreshold();
205 bool isvalid=false;
206 AUXDATA(xprd,
float, drifttime) = prd->driftTime(isvalid) ;
207 AUXDATA(xprd,
int, status) = isvalid;
209 AUXDATA(xprd,
char, isHT) = prd->highLevel() ;
211
212
213
214 AUXDATA(xprd,
float, leadingEdge) = prd->rawDriftTime();
215
216
218 if(prd->highLevel()) {
220 }
221 else {
222 AUXDATA(xprd,
float, driftTimeHTCorrection) = 0;
223 }
224
225
226
227 unsigned int theWord = word & 0x04020100;
228 char highThreshold = 0;
229
230 if (theWord == 0x04000000)
231 highThreshold = 1;
232 else if (theWord == 0x00020000)
233 highThreshold = 2;
234 else if (theWord == 0x00000100)
235 highThreshold = 3;
236 else if (theWord == 0x04020000)
237 highThreshold = 4;
238 else if (theWord == 0x00020100)
239 highThreshold = 5;
240 else if (theWord == 0x04000100)
241 highThreshold = 6;
242 else if (theWord == 0x04020100)
243 highThreshold = 7;
244
245 AUXDATA(xprd,
char, highThreshold) = highThreshold;
246
247
248 AUXDATA(xprd,
unsigned int, bitPattern) = word;
249
253
254 if ( stat==1 || stat==4 ) { gas_type =
kArgon; }
255 else if ( stat==5 ) { gas_type =
kKrypton; }
256 else if ( stat==2 || stat==3 ) { gas_type =
kXenon; }
257 else if ( stat==6 ) gas_type =
kEmAr;
258 else if ( stat==7 ) gas_type =
kEmKr;
259 }
260 AUXDATA(xprd,
char, gasType) = gas_type;
261
262
264 if(prdmtColl){
265 std::vector<int> uniqueIDs;
266 auto range = prdmtColl->equal_range(surfaceID);
267 for (
auto i =
range.first; i !=
range.second; ++i) {
269 }
270 AUXDATA(xprd, std::vector<int> , truth_barcode) = std::move(uniqueIDs);
271 }
272 }
274 if(sdoCollection){
275
276 auto pos = sdoCollection->find(surfaceID);
277 int sdo_word = -1000000;
278 if( pos != sdoCollection->end() ) {
279 sdo_word =
pos->second.word();
280 }
281 AUXDATA(xprd,
int, sdo_word) = sdo_word;
282 }
283 }
284
285 }
286 }
287 ATH_MSG_DEBUG(
" recorded TRT_PrepData obejcts: size " << xaod->size() );
288
289
290
291
293
294
296
298}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define AUXDATA(OBJ, TYP, NAME)
value_type get_compact() const
Get the compact id.
virtual const Amg::Vector3D & center() const override final
Element Surface: center of a straw layer.
ServiceHandle< ITRT_StrawNeighbourSvc > m_neighbourSvc
SG::ReadHandleKey< InDet::TRT_DriftCircleContainer > m_driftcirclecontainer
ToolHandle< ITRT_StrawStatusSummaryTool > m_TRTStrawSummaryTool
const TRT_ID * m_TRTHelper
const InDetDD::TRT_DetectorManager * m_trtman
Gaudi::Property< bool > m_writeSDOs
ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool
Gaudi::Property< bool > m_useTruthInfo
bool m_firstEventWarnings
SG::WriteHandleKey< xAOD::TrackMeasurementValidationContainer > m_xAodContainer
SG::ReadHandleKey< InDetSimDataCollection > m_SDOcontainer
ToolHandle< ITRT_CalDbTool > m_trtcaldbTool
SG::WriteHandleKey< std::vector< unsigned int > > m_xAodOffset
SG::ReadHandleKey< PRD_MultiTruthCollection > m_multiTruth
void setLocalPositionError(float localXError, float localYError, float localXYCorrelation)
Sets the local position error.
void setLocalPosition(float localX, float localY)
Sets the local position.
void setIdentifier(uint64_t identifier)
Sets the identifier.
void setGlobalPosition(float globalX, float globalY, float globalZ)
Sets the global position.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
::StatusCode StatusCode
StatusCode definition for legacy code.
TrackMeasurementValidation_v1 TrackMeasurementValidation
Reference the current persistent version: