21 #include "GaudiKernel/ITHistSvc.h"
27 m_trackingGeometrySvc(
"TrackingGeometrySvc",
"AtlasTrackingGeometrySvc"),
28 m_trackingGeometry(nullptr),
29 m_trackingGeometryName(
"AtlasTrackingGeometry"),
31 m_mappingVolumeName(
"InDet::Detectors::Pixel::Barrel"),
32 m_mappingTreeName(
"LayerMappingTest"),
33 m_mappingTreeDescription(
"Test Algorithm for Layer - 3D point association"),
34 m_mappingTree(nullptr),
35 m_mappingPositionX(0.),
36 m_mappingPositionY(0.),
37 m_mappingPositionZ(0.),
38 m_mappingPositionR(0.),
39 m_assignedPositionX(0.),
40 m_assignedPositionY(0.),
41 m_assignedPositionZ(0.),
42 m_assignedPositionR(0.),
43 m_assignedCorrection(0.),
44 m_assignedLayerIndex(0),
45 m_assignmentDistance(0.),
46 m_unmappedTree(nullptr),
47 m_unmappedPositionX(0.),
48 m_unmappedPositionY(0.),
49 m_unmappedPositionZ(0.),
50 m_unmappedPositionR(0.)
67 if (m_trackingGeometrySvc.retrieve().isFailure()) {
68 ATH_MSG_FATAL(
"Cannot retrieve TrackingGeometrySvc. Abort job. " );
69 return StatusCode::FAILURE;
71 m_trackingGeometryName = m_trackingGeometrySvc->trackingGeometryName();
73 return StatusCode::SUCCESS;
82 m_mappingTree =
new TTree(m_mappingTreeName.c_str(), m_mappingTreeDescription.c_str());
84 m_mappingTree->Branch(
"ValPosX", &m_mappingPositionX,
"valpx/F");
85 m_mappingTree->Branch(
"ValPosY", &m_mappingPositionY,
"valpy/F");
86 m_mappingTree->Branch(
"ValPosZ", &m_mappingPositionZ,
"valpz/F");
87 m_mappingTree->Branch(
"ValPosR", &m_mappingPositionR,
"valpr/F");
90 m_mappingTree->Branch(
"AssocPosX", &m_assignedPositionX,
"asspx/F");
91 m_mappingTree->Branch(
"AssocPosY", &m_assignedPositionY,
"asspy/F");
92 m_mappingTree->Branch(
"AssocPosZ", &m_assignedPositionZ,
"asspz/F");
93 m_mappingTree->Branch(
"AssocPosR", &m_assignedPositionR,
"asspr/F");
94 m_mappingTree->Branch(
"AssocCorr", &m_assignedCorrection,
"asscor/F");
95 m_mappingTree->Branch(
"AssocLayer", &m_assignedLayerIndex,
"assidx/I");
96 m_mappingTree->Branch(
"AssocDistance", &m_assignmentDistance,
"asignd/F");
99 m_unmappedTree =
new TTree(
"UnmappedHits",
"Unmapped Hits of the MappingTest Algorithm");
101 m_unmappedTree->Branch(
"UnmappedHitX", &m_unmappedPositionX,
"unmappedx/F");
102 m_unmappedTree->Branch(
"UnmappedHitY", &m_unmappedPositionY,
"unmappedy/F");
103 m_unmappedTree->Branch(
"UnmappedHitZ", &m_unmappedPositionZ,
"unmappedz/F");
104 m_unmappedTree->Branch(
"UnmappedHitR", &m_unmappedPositionR,
"unmappedr/F");
107 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
109 ATH_MSG_ERROR(
"initialize() Could not find Hist Service -> Switching Tree output off !" );
110 delete m_unmappedTree; m_unmappedTree =
nullptr;
111 delete m_mappingTree; m_mappingTree =
nullptr;
113 if (tHistSvc && ((tHistSvc->regTree(
"/val/UnmappedAssociations", m_unmappedTree)).isFailure()
114 || (tHistSvc->regTree(
"/val/MappingTest", m_mappingTree)).isFailure()) ) {
115 ATH_MSG_ERROR(
"initialize() Could not register the validation Tree -> Switching Tree output off !" );
116 delete m_unmappedTree; m_unmappedTree =
nullptr;
117 delete m_mappingTree; m_mappingTree =
nullptr;
120 return StatusCode::SUCCESS;
129 if (!m_trackingGeometry) {
130 if ((
detStore()->
retrieve(m_trackingGeometry, m_trackingGeometryName)).isFailure())
131 ATH_MSG_FATAL(
"Could not retrieve TrackingGeometry '" << m_trackingGeometryName <<
"' from DetectorStore." );
133 ATH_MSG_INFO(
"TrackingGeometry '" << m_trackingGeometryName <<
"' successfully retrieved from DetectorStore." );
136 if (!m_executed && m_trackingGeometry){
138 const TrackingVolume* tVolume = m_trackingGeometry->trackingVolume(m_mappingVolumeName);
140 ATH_MSG_INFO(
"Retrieved TrackingVolume '" << tVolume->
volumeName() <<
"'. Start the mapping validation.");
152 double mapX = mapRad*
cos(mapPhi);
153 double mapY = mapRad*
sin(mapPhi);
164 m_mappingPositionX = mapX;
165 m_mappingPositionY = mapY;
166 m_mappingPositionZ = mapZ;
167 m_mappingPositionR = mapRad;
173 m_assignedCorrection = 0.;
174 m_assignedLayerIndex = lIntersect.
object->layerIndex().value();
177 m_mappingTree->Fill();
181 m_unmappedPositionX = mapY;
182 m_unmappedPositionY = mapY;
183 m_unmappedPositionZ = mapZ;
184 m_unmappedPositionR = mapRad;
186 m_unmappedTree->Fill();
191 ATH_MSG_INFO(
"Could not retrieve the TrackingVolume '" << m_mappingVolumeName <<
"'." );
195 return StatusCode::SUCCESS;