84{
85
86
88 if (not h_trtPrds.isValid()) {
90 return StatusCode::FAILURE;
91 }
92
93
94
95
96 const PRD_MultiTruthCollection* prdmtColl = nullptr;
98 SG::ReadHandle<PRD_MultiTruthCollection> h_prdmtColl(
m_multiTruth);
99 if (not h_prdmtColl.isValid()){
101 ATH_MSG_WARNING(
"PRD MultiTruth collection not available (" <<
m_multiTruth.key() <<
"). Skipping this info although requested.");}
102 } else {
103 prdmtColl = h_prdmtColl.cptr();
104 }
105 }
106
107
108
109
110 const InDetSimDataCollection* sdoCollection = nullptr;
112 SG::ReadHandle<InDetSimDataCollection> h_sdoCollection(
m_SDOcontainer);
113 if (not h_sdoCollection.isValid()) {
116 } else{
117 sdoCollection = h_sdoCollection.cptr();
118 }
119 }
120
121
122
123 SG::WriteHandle<xAOD::TrackMeasurementValidationContainer> xaod(
m_xAodContainer);
124 ATH_CHECK(xaod.record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>() ) );
125
126 SG::WriteHandle<std::vector<unsigned int>> offsets(
m_xAodOffset);
127 ATH_CHECK(offsets.record(std::make_unique<std::vector<unsigned int>>(
m_TRTHelper->straw_layer_hash_max() , 0) ));
128
129 InDet::TRT_DriftCircleContainer::const_iterator
it = h_trtPrds->begin();
130 InDet::TRT_DriftCircleContainer::const_iterator it_end = h_trtPrds->end();
132 for( ;
it!=it_end; ++
it ) {
133
134
135 if(
m_TRTHelper->straw_layer_hash_max() <= (*it)->identifyHash() )
136 ATH_MSG_ERROR(
"My assumption about the maximum size of the hash was wrong");
137 (*offsets)[ (*it)->identifyHash() ] =
counter;
138
139
140 if( (*it)->empty() ) continue;
141
142
143 for( const auto prd : **it ){
144
146
147
149 xaod->push_back(xprd);
150
151 Identifier surfaceID = prd->identify();
152
154
155
156
162 const InDetDD::TRT_BaseElement* element =
m_trtman->getElement(surfaceID);
163 AUXDATA(xprd,
float, strawphi) = element->
center(surfaceID).phi();
164
165 int chip=0;
166 int board=-1;
170 else if (chip<12)
171 board=0;
172 else {
173 chip=chip-20;
174 board=1;
175 }
176 AUXDATA(xprd,
int, TRTboard) = board ;
177 AUXDATA(xprd,
int, TRTchip) = chip ;
178
179
180
183 float locX = locpos.x();
184 if ( !(std::isinf(locpos.y()) || std::isnan(locpos.y())) ){
185 if (locpos.y()>=1e-07)
187 } else {
189 }
190
191
193
195 if(localCov.size() == 1){
197 } else if(localCov.size() == 2){
199 } else {
201 }
202
203
204
205 const Amg::Vector3D gpos = prd->detectorElement()->surface(surfaceID).localToGlobal(prd->localPosition());
207
208
209
210 unsigned int word = prd->getWord();
211
212
213 double tot = prd->timeOverThreshold();
214 bool isvalid=false;
215 AUXDATA(xprd,
float, drifttime) = prd->driftTime(isvalid) ;
216 AUXDATA(xprd,
int, status) = isvalid;
218 AUXDATA(xprd,
char, isHT) = prd->highLevel() ;
220
221
222
223 AUXDATA(xprd,
float, leadingEdge) = prd->rawDriftTime();
224
225
227 if(prd->highLevel()) {
229 }
230 else {
231 AUXDATA(xprd,
float, driftTimeHTCorrection) = 0;
232 }
233
234
235
236 unsigned int theWord = word & 0x04020100;
237 char highThreshold = 0;
238
239 if (theWord == 0x04000000)
240 highThreshold = 1;
241 else if (theWord == 0x00020000)
242 highThreshold = 2;
243 else if (theWord == 0x00000100)
244 highThreshold = 3;
245 else if (theWord == 0x04020000)
246 highThreshold = 4;
247 else if (theWord == 0x00020100)
248 highThreshold = 5;
249 else if (theWord == 0x04000100)
250 highThreshold = 6;
251 else if (theWord == 0x04020100)
252 highThreshold = 7;
253
254 AUXDATA(xprd,
char, highThreshold) = highThreshold;
255
256
257 AUXDATA(xprd,
unsigned int, bitPattern) = word;
258
262
263 if ( stat==1 || stat==4 ) { gas_type =
kArgon; }
264 else if ( stat==5 ) { gas_type =
kKrypton; }
265 else if ( stat==2 || stat==3 ) { gas_type =
kXenon; }
266 else if ( stat==6 ) gas_type =
kEmAr;
267 else if ( stat==7 ) gas_type =
kEmKr;
268 }
269 AUXDATA(xprd,
char, gasType) = gas_type;
270
271
273 if(prdmtColl){
274 std::vector<int> uniqueIDs;
275 auto range = prdmtColl->equal_range(surfaceID);
276 for (
auto i =
range.first; i !=
range.second; ++i) {
278 }
279 AUXDATA(xprd, std::vector<int> , truth_barcode) = uniqueIDs;
280 }
281 }
283 if(sdoCollection){
284
285 auto pos = sdoCollection->find(surfaceID);
286 int sdo_word = -1000000;
287 if( pos != sdoCollection->end() ) {
288 sdo_word =
pos->second.word();
289 }
290 AUXDATA(xprd,
int, sdo_word) = sdo_word;
291 }
292 }
293
294 }
295 }
296 ATH_MSG_DEBUG(
" recorded TRT_PrepData obejcts: size " << xaod->size() );
297
298
299
300
302
303
305
307}
#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: