13 #include "GaudiKernel/ITHistSvc.h"
17 m_extrapolationEngine(
""),
24 m_particleHypothesis(2),
25 m_smearProductionVertex(false),
26 m_smearFlatOriginT(false),
27 m_smearFlatOriginZ(false),
41 m_collectSensitive(false),
42 m_collectPassive(false),
43 m_collectBoundary(false),
44 m_collectMaterial(false),
45 m_backExtrapolation(false),
46 m_stepwiseExtrapolation(false),
53 m_treeName(
"ExtrapolationEngineTest"),
54 m_treeFolder(
"/val/"),
55 m_treeDescription(
"ExtrapolationEngine test setup"),
62 m_sensitiveLayerIndex(nullptr),
63 m_sensitiveLocalPosX(nullptr),
64 m_sensitiveLocalPosY(nullptr),
65 m_sensitiveCenterPosX(nullptr),
66 m_sensitiveCenterPosY(nullptr),
67 m_sensitiveCenterPosZ(nullptr),
68 m_sensitiveCenterPosR(nullptr),
69 m_sensitiveCenterPosPhi(nullptr),
70 m_materialThicknessInX0(0.),
71 m_materialThicknessInL0(0.),
72 m_materialThicknessZARho(0.),
73 m_materialEmulatedIonizationLoss(0.),
74 m_materialThicknessInX0Bwd(0.),
75 m_materialThicknessInL0Bwd(0.),
76 m_materialThicknessInX0Sensitive(0.),
77 m_materialThicknessInX0Passive(0.),
78 m_materialThicknessInX0Boundary(0.),
79 m_materialThicknessInX0Cylinder(0.),
80 m_materialThicknessInX0Disc(0.),
81 m_materialThicknessInX0Plane(0.),
82 m_materialThicknessInX0Accumulated(nullptr),
83 m_materialThicknessInX0Steps(nullptr),
84 m_materialThicknessInL0Steps(nullptr),
85 m_materialPositionX(nullptr),
86 m_materialPositionY(nullptr),
87 m_materialPositionZ(nullptr),
88 m_materialPositionR(nullptr),
89 m_materialPositionP(nullptr),
90 m_materialPositionPt(nullptr),
91 m_materialScaling(nullptr),
92 m_stepDirection(nullptr),
93 m_endStepSuccessful(0),
94 m_endStepPositionX(0.),
95 m_endStepPositionY(0.),
96 m_endStepPositionZ(0.),
97 m_endStepPositionR(0.),
103 m_endStepPathLength(0.),
104 m_endStepThicknessInX0(0.) {
159 for (
size_t ip = 0;
ip < m_parameterNames.size(); ++
ip) {
161 delete m_pPositionX[
ip];
162 delete m_pPositionY[
ip];
163 delete m_pPositionZ[
ip];
164 delete m_pPositionR[
ip];
171 delete m_sensitiveLayerIndex;
172 delete m_sensitiveSurfaceType;
173 delete m_sensitiveCenterPosX;
174 delete m_sensitiveCenterPosY;
175 delete m_sensitiveCenterPosZ;
176 delete m_sensitiveCenterPosR;
177 delete m_sensitiveCenterPosPhi;
178 delete m_sensitiveLocalPosX;
179 delete m_sensitiveLocalPosY;
180 delete m_sensitiveLocalPosR;
181 delete m_sensitiveLocalPosPhi;
182 delete m_sensitiveDetector;
183 delete m_sensitiveIsInnermost;
184 delete m_sensitiveIsNextToInnermost;
185 delete m_sensitiveBarrelEndcap;
186 delete m_sensitiveLayerDisc;
187 delete m_sensitiveEtaModule;
188 delete m_sensitivePhiModule;
189 delete m_sensitiveSide;
190 delete m_sensitiveNearBondGap;
191 delete m_sensitiveisInside;
192 delete m_sensitiveisInsideBound;
193 delete m_materialtInX0AccumulatedUpTo;
194 delete m_materialThicknessInX0Accumulated;
195 delete m_materialThicknessInX0Steps;
196 delete m_materialThicknessInL0Steps;
197 delete m_materialPositionX;
198 delete m_materialPositionY;
199 delete m_materialPositionZ;
200 delete m_materialPositionR;
201 delete m_materialPositionP;
202 delete m_materialPositionPt;
203 delete m_materialScaling;
204 delete m_stepDirection;
206 return StatusCode::SUCCESS;
210 if (m_extrapolationEngine.retrieve().isFailure()) {
212 return StatusCode::FAILURE;
213 }
else ATH_MSG_INFO(
"Successfully retrieved ExtrapolationEngine.");
215 if (!m_posmomWriter.empty() && m_posmomWriter.retrieve().isFailure()) {
216 ATH_MSG_FATAL(
"Could not retrieve position/momentum writer.");
217 return StatusCode::FAILURE;
218 }
else ATH_MSG_INFO(
"Successfully retrieved ExtrapolationEngine.");
223 return StatusCode::FAILURE;
225 ATH_MSG_INFO(
"Successfully retrieved ATLAS ID Helper.");
229 return StatusCode::FAILURE;
231 ATH_MSG_INFO(
"Successfully retrieved Pixel ID Helper.");
235 return StatusCode::FAILURE;
242 return StatusCode::FAILURE;
247 return StatusCode::SUCCESS;
254 m_tree =
new TTree(m_treeName.c_str(), m_treeDescription.c_str());
256 m_tree->Branch(
"StartPosX", &m_startPositionX);
257 m_tree->Branch(
"StartPosY", &m_startPositionY);
258 m_tree->Branch(
"StartPosZ", &m_startPositionZ);
259 m_tree->Branch(
"StartPosR", &m_startPositionR);
260 m_tree->Branch(
"StartPhi", &m_startPhi);
261 m_tree->Branch(
"StartEta", &m_startEta);
262 m_tree->Branch(
"StartTheta", &m_startTheta);
263 m_tree->Branch(
"StartP", &m_startP);
264 m_tree->Branch(
"StartPt", &m_startPt);
265 if (m_parametersMode) m_tree->Branch(
"StartCharge", &m_charge);
267 m_tree->Branch(
"EndSuccessful", &m_endSuccessful);
268 m_tree->Branch(
"EndPosX", &m_endPositionX);
269 m_tree->Branch(
"EndPosY", &m_endPositionY);
270 m_tree->Branch(
"EndPosZ", &m_endPositionZ);
271 m_tree->Branch(
"EndPosR", &m_endPositionR);
272 m_tree->Branch(
"EndPhi", &m_endPhi);
273 m_tree->Branch(
"EndEta", &m_endEta);
274 m_tree->Branch(
"EndTheta", &m_endTheta);
275 m_tree->Branch(
"EndP", &m_endP);
276 m_tree->Branch(
"EndPt", &m_endPt);
278 m_tree->Branch(
"EndPathLength", &m_endPathLength);
280 if (m_backExtrapolation) {
281 m_tree->Branch(
"BackSuccessful", &m_backSuccessful);
282 m_tree->Branch(
"BackPosX", &m_backPositionX);
283 m_tree->Branch(
"BackPosY", &m_backPositionY);
284 m_tree->Branch(
"BackPosZ", &m_backPositionZ);
285 m_tree->Branch(
"BackPosR", &m_backPositionR);
286 m_tree->Branch(
"BackPhi", &m_backPhi);
287 m_tree->Branch(
"BackEta", &m_backEta);
288 m_tree->Branch(
"BackTheta", &m_backTheta);
289 m_tree->Branch(
"BackP", &m_backP);
290 m_tree->Branch(
"BackPt", &m_backPt);
294 m_parameterNames.emplace_back(
"Sensitive");
295 m_parameterNames.emplace_back(
"Passive");
296 m_parameterNames.emplace_back(
"Boundary");
297 for (
size_t ip = 0;
ip < m_parameterNames.size(); ++
ip) {
299 m_pPositionX.push_back(
new std::vector<float> );
300 m_pPositionY.push_back(
new std::vector<float> );
301 m_pPositionZ.push_back(
new std::vector<float> );
302 m_pPositionR.push_back(
new std::vector<float> );
303 m_pPhi.push_back(
new std::vector<float> );
304 m_pTheta.push_back(
new std::vector<float> );
305 m_pEta.push_back(
new std::vector<float> );
306 m_pP.push_back(
new std::vector<float> );
307 m_pPt.push_back(
new std::vector<float> );
310 m_tree->Branch(m_parameterNames[
ip] +
"PosX", m_pPositionX[
ip]);
311 m_tree->Branch(m_parameterNames[
ip] +
"PosY", m_pPositionY[
ip]);
312 m_tree->Branch(m_parameterNames[
ip] +
"PosZ", m_pPositionZ[
ip]);
313 m_tree->Branch(m_parameterNames[
ip] +
"PosR", m_pPositionR[
ip]);
314 m_tree->Branch(m_parameterNames[
ip] +
"Phi", m_pPhi[
ip]);
315 m_tree->Branch(m_parameterNames[
ip] +
"Eta", m_pTheta[
ip]);
316 m_tree->Branch(m_parameterNames[
ip] +
"Theta", m_pEta[
ip]);
317 m_tree->Branch(m_parameterNames[
ip] +
"P", m_pP[
ip]);
318 m_tree->Branch(m_parameterNames[
ip] +
"Pt", m_pPt[
ip]);
321 if (m_collectSensitive) {
322 m_sensitiveLayerIndex =
new std::vector< int >;
323 m_sensitiveSurfaceType =
new std::vector< int >;
324 m_sensitiveCenterPosX =
new std::vector< float >;
325 m_sensitiveCenterPosY =
new std::vector< float >;
326 m_sensitiveCenterPosZ =
new std::vector< float >;
327 m_sensitiveCenterPosR =
new std::vector< float >;
328 m_sensitiveCenterPosPhi =
new std::vector< float >;
329 m_sensitiveLocalPosX =
new std::vector< float >;
330 m_sensitiveLocalPosY =
new std::vector< float >;
331 m_sensitiveLocalPosR =
new std::vector< float >;
332 m_sensitiveLocalPosPhi =
new std::vector< float >;
333 m_sensitiveDetector =
new std::vector< int >;
334 m_sensitiveIsInnermost =
new std::vector< int >;
335 m_sensitiveIsNextToInnermost =
new std::vector< int >;
336 m_sensitiveBarrelEndcap =
new std::vector< int >;
337 m_sensitiveLayerDisc =
new std::vector< int >;
338 m_sensitiveEtaModule =
new std::vector< int >;
339 m_sensitivePhiModule =
new std::vector< int >;
340 m_sensitiveSide =
new std::vector< int >;
341 m_sensitiveNearBondGap =
new std::vector< int >;
342 m_sensitiveisInside =
new std::vector< int >;
343 m_sensitiveisInsideBound =
new std::vector< int >;
344 m_materialtInX0AccumulatedUpTo =
new std::vector< float >;
346 m_tree->Branch(
"SensitiveLayerIndex" , m_sensitiveLayerIndex);
347 m_tree->Branch(
"SensitiveSurfaceType" , m_sensitiveSurfaceType);
348 m_tree->Branch(
"SensitiveCenterPosX" , m_sensitiveCenterPosX);
349 m_tree->Branch(
"SensitiveCenterPosY" , m_sensitiveCenterPosY);
350 m_tree->Branch(
"SensitiveCenterPosZ" , m_sensitiveCenterPosZ);
351 m_tree->Branch(
"SensitiveCenterPosR" , m_sensitiveCenterPosR);
352 m_tree->Branch(
"SensitiveCenterPosPhi", m_sensitiveCenterPosPhi);
353 m_tree->Branch(
"SensitiveLocalPosX" , m_sensitiveLocalPosX);
354 m_tree->Branch(
"SensitiveLocalPosY" , m_sensitiveLocalPosY);
355 m_tree->Branch(
"SensitiveLocalPosR" , m_sensitiveLocalPosR);
356 m_tree->Branch(
"SensitiveLocalPosPhi" , m_sensitiveLocalPosPhi);
357 m_tree->Branch(
"SensitiveDetector" , m_sensitiveDetector);
358 m_tree->Branch(
"SensitiveIsInnermost" , m_sensitiveIsInnermost);
359 m_tree->Branch(
"SensitiveIsNextToInnermost" , m_sensitiveIsNextToInnermost);
360 m_tree->Branch(
"SensitiveBarrelEndcap", m_sensitiveBarrelEndcap);
361 m_tree->Branch(
"SensitiveLayerDisc" , m_sensitiveLayerDisc);
362 m_tree->Branch(
"SensitiveEtaModule" , m_sensitiveEtaModule);
363 m_tree->Branch(
"SensitivePhiModule" , m_sensitivePhiModule);
364 m_tree->Branch(
"SensitiveSide" , m_sensitiveSide);
365 m_tree->Branch(
"SensitiveNearBondGap" , m_sensitiveNearBondGap);
366 m_tree->Branch(
"SensitiveisInside" , m_sensitiveisInside);
367 m_tree->Branch(
"SensitiveisInsideBound", m_sensitiveisInsideBound);
368 m_tree->Branch(
"MaterialtInX0AccumulatedUpTo" , m_materialtInX0AccumulatedUpTo);
373 if (m_collectMaterial) {
374 m_materialThicknessInX0Accumulated =
new std::vector<float>;
375 m_materialThicknessInX0Steps =
new std::vector<float>;
376 m_materialThicknessInL0Steps =
new std::vector<float>;
377 m_materialPositionX =
new std::vector<float>;
378 m_materialPositionY =
new std::vector<float>;
379 m_materialPositionZ =
new std::vector<float>;
380 m_materialPositionR =
new std::vector<float>;
381 m_materialPositionP =
new std::vector<float>;
382 m_materialPositionPt =
new std::vector<float>;
383 m_materialScaling =
new std::vector<float>;
384 m_stepDirection =
new std::vector<int>;
385 m_tree->Branch(
"MaterialThicknessInX0", &m_materialThicknessInX0);
386 m_tree->Branch(
"MaterialThicknessInL0", &m_materialThicknessInL0);
387 m_tree->Branch(
"MaterialThicknessZARho", &m_materialThicknessZARho);
388 m_tree->Branch(
"MaterialEmulatedEloss", &m_materialEmulatedIonizationLoss);
389 m_tree->Branch(
"MaterialThicknessSensitiveInX0", &m_materialThicknessInX0Sensitive);
390 m_tree->Branch(
"MaterialThicknessPassiveInX0", &m_materialThicknessInX0Passive);
391 m_tree->Branch(
"MaterialThicknessBoundaryInX0", &m_materialThicknessInX0Boundary);
392 m_tree->Branch(
"MaterialThicknessCylinderInX0", &m_materialThicknessInX0Cylinder);
393 m_tree->Branch(
"MaterialThicknessDiscInX0", &m_materialThicknessInX0Disc);
394 m_tree->Branch(
"MaterialThicknessPlaneInX0", &m_materialThicknessInX0Plane);
395 m_tree->Branch(
"MaterialThicknessAccumulatedX0", m_materialThicknessInX0Accumulated);
396 m_tree->Branch(
"MaterialThicknessStepsInX0", m_materialThicknessInX0Steps);
397 m_tree->Branch(
"MaterialThicknessStepsInL0", m_materialThicknessInL0Steps);
398 m_tree->Branch(
"MaterialPosX", m_materialPositionX);
399 m_tree->Branch(
"MaterialPosY", m_materialPositionY);
400 m_tree->Branch(
"MaterialPosZ", m_materialPositionZ);
401 m_tree->Branch(
"MaterialPosR", m_materialPositionR);
402 m_tree->Branch(
"MaterialPosP", m_materialPositionP);
403 m_tree->Branch(
"MaterialPosPt", m_materialPositionPt);
404 m_tree->Branch(
"MaterialScaling", m_materialScaling);
405 m_tree->Branch(
"StepDirection", m_stepDirection);
408 if (m_stepwiseExtrapolation) {
409 m_tree->Branch(
"EndStepSuccessful", &m_endStepSuccessful);
410 m_tree->Branch(
"EndStepPosX", &m_endStepPositionX);
411 m_tree->Branch(
"EndStepPosY", &m_endStepPositionY);
412 m_tree->Branch(
"EndStepPosZ", &m_endStepPositionZ);
413 m_tree->Branch(
"EndStepPosR", &m_endStepPositionR);
414 m_tree->Branch(
"EndStepPhi", &m_endStepPhi);
415 m_tree->Branch(
"EndStepEta", &m_endStepEta);
416 m_tree->Branch(
"EndStepTheta", &m_endStepTheta);
417 m_tree->Branch(
"EndStepP", &m_endStepP);
418 m_tree->Branch(
"EndStepPt", &m_endStepPt);
419 m_tree->Branch(
"EndStepPathLength", &m_endStepPathLength);
420 m_tree->Branch(
"EndStepMaterialThicknessInX0", &m_endStepThicknessInX0);
424 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
426 ATH_MSG_ERROR(
"initialize() Could not find Hist Service -> Switching Tree output off !");
430 if (tHistSvc && ((tHistSvc->regTree(m_treeFolder + m_treeName, m_tree)).isFailure())) {
431 ATH_MSG_ERROR(
"initialize() Could not register the validation Tree -> Switching Tree output off !");
435 return StatusCode::SUCCESS;
439 ATH_MSG_VERBOSE(
"Running the ExtrapolationEngineTest Test in parameters mode : " << m_parametersMode);
440 if (m_parametersMode == 0) {
441 return runTestT<Trk::NeutralParameters, Trk::NeutralPerigee>();
443 return runTestT<Trk::TrackParameters, Trk::Perigee>();
447 ATH_MSG_VERBOSE(
"Running the ExtrapolationEngineTest Test in scanning mode");
449 if (m_phiScans.empty()) {
450 ATH_MSG_VERBOSE(
"Running in scan mode: Phi scans not given. Automatically calculated.");
451 m_currentPhi = m_phiMin +
double(m_currentPhiStep + 1) * (m_phiMax - m_phiMin) /
double(m_stepsPhi);
454 if (m_currentPhiStep >=
int(m_phiScans.size())) m_currentPhiStep = 0;
455 m_currentPhi = m_phiScans.at(m_currentPhiStep);
459 if (m_etaScans.empty()) {
460 ATH_MSG_ERROR(
"Running in scan mode without specified eta values");
461 return StatusCode::FAILURE;
464 for (
auto etaValue : m_etaScans) {
465 m_currentEta = etaValue;
466 ATH_MSG_VERBOSE(
"Running the ExtrapolationEngineTest Test in parameters mode : " << m_parametersMode);
467 if (m_parametersMode == 0) {
468 if (runTestT<Trk::NeutralParameters, Trk::NeutralPerigee>().isFailure())
return StatusCode::FAILURE;
470 if (runTestT<Trk::TrackParameters, Trk::Perigee>().isFailure())
return StatusCode::FAILURE;
473 return StatusCode::SUCCESS;