ATLAS Offline Software
IDAlignMonResidualsAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ***************************************************************************************
6 // IDAlignMonResidualsAlg.cxx
7 // AUTHORS: Beate Heinemann, Tobias Golling, Ben Cooper, John Alison
8 // Adapted to AthenaMT 2021-2022 by Per Johansson
9 // ***************************************************************************************
10 
11 //main header
12 #include "IDAlignMonResidualsAlg.h"
13 
14 #include "TMath.h"
15 #include <cmath>
16 #include <sstream>
19 #include "InDetIdentifier/SCT_ID.h"
20 #include "InDetIdentifier/TRT_ID.h"
22 
28 
32 
35 #include "TrkGeometry/Layer.h"
36 #include "TrkSurfaces/Surface.h"
38 
41 
42 
43 // *********************************************************************
44 // Public Methods
45 // *********************************************************************
46 
47 IDAlignMonResidualsAlg::IDAlignMonResidualsAlg( const std::string & name, ISvcLocator* pSvcLocator ) :
48  AthMonitorAlgorithm(name, pSvcLocator),
49  m_trtcaldbTool("TRT_CalDbTool", this),
50  m_trackSelection( "InDet::InDetTrackSelectionTool/TrackSelectionTool", this),
51  m_extendedPlots(false)
52 {
53  m_iUpdator = ToolHandle<Trk::IUpdator>("Trk::KalmanUpdator");
54  m_propagator = ToolHandle<Trk::IPropagator>("Trk::RungeKuttaPropagator");
55  m_residualPullCalculator = ToolHandle<Trk::IResidualPullCalculator>(
56  "Trk::ResidualPullCalculator/ResidualPullCalculator");
57  m_hitQualityTool = ToolHandle<IInDetAlignHitQualSelTool>("");
58 
59  declareProperty("CheckRate" , m_checkrate=1000);
60  declareProperty("ITRT_CalDbTool" , m_trtcaldbTool);
61  declareProperty("iUpdator" , m_iUpdator);
62  declareProperty("propagator" , m_propagator);
63  declareProperty("TrackSelectionTool" , m_trackSelection);
64  declareProperty("ResidualPullCalculatorTool", m_residualPullCalculator);
65  declareProperty("HitQualityTool" , m_hitQualityTool);
66  declareProperty("Pixel_Manager" , m_Pixel_Manager);
67  declareProperty("SCT_Manager" , m_SCT_Manager);
68  declareProperty("ApplyTrackSelection" , m_applyTrkSel = true);
69 }
70 
71 //---------------------------------------------------------------------------------------
72 
74 
76 {
77  //initialize tools and services
78  ATH_MSG_DEBUG("Calling initialize() to setup tools/services");
80  if (sc.isFailure()) {
81  ATH_MSG_WARNING("Failed to initialize tools/services!");
82  return StatusCode::SUCCESS;
83  }
84  else
85  ATH_MSG_DEBUG("Successfully initialized tools/services");
86 
88  ATH_CHECK( m_trtcaldbTool.retrieve() );
89 
90  ATH_CHECK( m_tracksName.initialize() );
91  ATH_CHECK( m_tracksKey.initialize() );
92 
93  m_pixResidualX = Monitored::buildToolMap<int>(m_tools, "PixResidualX", m_nSiBlayers);
94  m_pixResidualX_3D = Monitored::buildToolMap<int>(m_tools, "PixResidualX_3D", m_nSiBlayers);
95  m_pixResidualY = Monitored::buildToolMap<int>(m_tools, "PixResidualY", m_nSiBlayers);
96  m_pixResidualY_3D = Monitored::buildToolMap<int>(m_tools, "PixResidualY_3D", m_nSiBlayers);
97  m_pixPullX = Monitored::buildToolMap<int>(m_tools, "PixPullX", m_nSiBlayers);
98  m_pixPullY = Monitored::buildToolMap<int>(m_tools, "PixPullY", m_nSiBlayers);
99  m_pixResidualXvsEta = Monitored::buildToolMap<int>(m_tools, "PixResidualXvsEta", m_nSiBlayers);
100  m_pixResidualYvsEta = Monitored::buildToolMap<int>(m_tools, "PixResidualYvsEta", m_nSiBlayers);
101  m_pixResidualXvsPhi = Monitored::buildToolMap<int>(m_tools, "PixResidualXvsPhi", m_nSiBlayers);
102  m_pixResidualYvsPhi = Monitored::buildToolMap<int>(m_tools, "PixResidualYvsPhi", m_nSiBlayers);
103  m_pixECAResidualX = Monitored::buildToolMap<int>(m_tools, "PixResidualXECA", m_nPixEClayers);
104  m_pixECAResidualY = Monitored::buildToolMap<int>(m_tools, "PixResidualYECA", m_nPixEClayers);
105  m_pixECResidualX_3D = Monitored::buildToolMap<int>(m_tools, "PixResidualXEC_3D", 2);
106  m_pixECResidualY_3D = Monitored::buildToolMap<int>(m_tools, "PixResidualYEC_3D", 2);
107  m_pixECCResidualX = Monitored::buildToolMap<int>(m_tools, "PixResidualXECC", m_nPixEClayers);
108  m_pixECCResidualY = Monitored::buildToolMap<int>(m_tools, "PixResidualYECC", m_nPixEClayers);
109  m_sctResidualX = Monitored::buildToolMap<int>(m_tools, "SCTResidualX", m_nSiBlayers);
110  m_sctResidualX_3D = Monitored::buildToolMap<int>(m_tools, "SCTResidualX_3D", m_nSiBlayers);
111  m_sctECAResidualX_3D = Monitored::buildToolMap<int>(m_tools, "SCTECAResidualX_3D", m_nSCTEClayers);
112  m_sctECCResidualX_3D = Monitored::buildToolMap<int>(m_tools, "SCTECCResidualX_3D", m_nSCTEClayers);
113  m_sctPullX = Monitored::buildToolMap<int>(m_tools, "SCTPullX", m_nSiBlayers);
114  m_sctResidualXvsEta = Monitored::buildToolMap<int>(m_tools, "SCTResidualXvsEta", m_nSiBlayers);
115  m_sctResidualXvsPhi = Monitored::buildToolMap<int>(m_tools, "SCTResidualXvsPhi", m_nSiBlayers);
116  m_trtBPredictedR = Monitored::buildToolMap<int>(m_tools, "TRTPredictedRB", m_nTRTBlayers);
117  m_trtBMeasuredR = Monitored::buildToolMap<int>(m_tools, "TRTMeasuredRB", m_nTRTBlayers);
118  m_trtBResidualR = Monitored::buildToolMap<int>(m_tools, "TRTResidualRB", m_nTRTBlayers);
119  m_trtBPullR = Monitored::buildToolMap<int>(m_tools, "TRTPullRB", m_nTRTBlayers);
120  m_trtBResidualRNoTube = Monitored::buildToolMap<int>(m_tools, "TRTResidualRNoTubeB", m_nTRTBlayers);
121  m_trtBPullRNoTube = Monitored::buildToolMap<int>(m_tools, "TRTPullRNoTubeB", m_nTRTBlayers);
122  m_trtBLR = Monitored::buildToolMap<int>(m_tools, "TRTLRB", m_nTRTBlayers);
123  m_trtBResVsEta= Monitored::buildToolMap<std::vector<int>>(m_tools, "TRTResVsEtaB", m_nTRTBlayers,m_nTRTBlayers);
124  m_trtBResVsPhiSec= Monitored::buildToolMap<std::vector<int>>(m_tools, "TRTResVsPhiSecB", m_nTRTBlayers,m_nTRTBlayers);
125  m_trtBLRVsPhiSec= Monitored::buildToolMap<std::vector<int>>(m_tools, "TRTLRVsPhiSecB", m_nTRTBlayers,m_nTRTBlayers);
126  m_trtECPredictedR = Monitored::buildToolMap<int>(m_tools, "TRTPredictedREC", m_nTRTEClayers);
127  m_trtECMeasuredR = Monitored::buildToolMap<int>(m_tools, "TRTMeasuredREC", m_nTRTEClayers);
128  m_trtECResidualR = Monitored::buildToolMap<int>(m_tools, "TRTResidualREC", m_nTRTEClayers);
129  m_trtECPullR = Monitored::buildToolMap<int>(m_tools, "TRTPullREC", m_nTRTEClayers);
130  m_trtECResidualRNoTube = Monitored::buildToolMap<int>(m_tools, "TRTResidualRNoTubeEC", m_nTRTEClayers);
131  m_trtECPullRNoTube = Monitored::buildToolMap<int>(m_tools, "TRTPullRNoTubeEC", m_nTRTEClayers);
132  m_trtECLR = Monitored::buildToolMap<int>(m_tools, "TRTLREC", m_nTRTEClayers);
133  m_trtECResVsEta= Monitored::buildToolMap<int>(m_tools, "TRTResVsEtaEC", m_nTRTEClayers);
134  m_trtECResVsPhiSec= Monitored::buildToolMap<int>(m_tools, "TRTResVsPhiEC", m_nTRTEClayers);
135  m_trtECLRVsPhiSec= Monitored::buildToolMap<int>(m_tools, "TRTLRVsPhiEC", m_nTRTEClayers);
136 
137  ATH_MSG_DEBUG("initialize() -- completed --");
139 }
140 
141 
142 //---------------------------------------------------------------------------------------
143 
144 StatusCode IDAlignMonResidualsAlg::fillHistograms( const EventContext& ctx ) const
145 {
146  using namespace Monitored;
147 
148  ATH_MSG_DEBUG("fillHistograms() -- dealing with track collection: " << m_tracksName.key());
149 
150  // For histogram naming
151  auto residualGroup = getGroup("Residuals");
152 
153  //counters
154  bool hasBeenCalledThisEvent=false;
155  float mu = 0.;
156  int nTracks = 0;
157 
159  auto mu_m = Monitored::Scalar<float>("mu_m", 0.0);
160  if (!hasBeenCalledThisEvent){
162  mu_m = mu;
163  hasBeenCalledThisEvent=true;
164  }
165  else
166  mu = -999;
167 
168  if (m_extendedPlots){
169  fill("residualGroup", mu_m);
170  }
171 
172  // Retrieving tracks
173  auto tracks = SG::makeHandle(m_tracksName, ctx);
174  if (not tracks.isValid()) {
175  ATH_MSG_ERROR(m_tracksName.key() << " could not be retrieved");
176  return StatusCode::RECOVERABLE;
177  }
178 
179  //looping over tracks
180  ATH_MSG_DEBUG ("IDAlignMonResidual: Start loop on tracks. Number of tracks " << tracks->size());
181  for (const Trk::Track* trksItr: *tracks) {
182 
183  // Found track?!
184  if ( !trksItr || trksItr->perigeeParameters() == nullptr ) {
185  ATH_MSG_DEBUG( "InDetAlignmentMonitoringRun3: NULL track pointer in collection" );
186  continue;
187  }
188 
189  // Select tracks
190  if ( m_applyTrkSel and !m_trackSelection->accept(*trksItr) )
191  continue;
192 
193  nTracks++;
194 
195  //check that all TSOS of track have track parameters defined (required to compute residuals/pulls)
196  if(trackRequiresRefit(trksItr)){
197  ATH_MSG_DEBUG("Not all TSOS contain track parameters - will be missing residuals/pulls");
198  }
199  else
200  ATH_MSG_DEBUG("All TSOS of track " << nTracks << "/" << tracks->size() << " contain track parameters - Good!");
201 
202  //trackStateOnSurfaces is a vector of Trk::TrackStateOnSurface objects which contain information
203  //on track at each (inner)detector surface it crosses eg hit used to fit track
204  ATH_MSG_DEBUG( "** IDAlignMonResiduals::fillHistograms() ** track: " << nTracks << " has " << trksItr->trackStateOnSurfaces()->size() << " TrkSurfaces");
205 
206  int nHits = 0; //counts number of tsos from which we can define residual/pull
207  int nTSOS = -1; //counts all TSOS on the track
208 
209  //looping over the hits of the track
210  for (const Trk::TrackStateOnSurface* tsos : *trksItr->trackStateOnSurfaces()) {
211 
212  ++nTSOS;
213 
214  if (tsos == nullptr) {
215  ATH_MSG_DEBUG(" TSOS (hit) = " << nTSOS << " is NULL ");
216  continue;
217  }
218 
219  //skipping outliers
220  ATH_MSG_DEBUG(" --> testing if hit " << nTSOS << "/" << trksItr->trackStateOnSurfaces()->size() << " is a track measurement");
221  if(!tsos->type(Trk::TrackStateOnSurface::Measurement)) {
222  ATH_MSG_DEBUG("Skipping TSOS " << nTSOS << " because it is an outlier (or the first TSOS on the track)");
223  continue;
224  }
225 
226  const Trk::MeasurementBase* mesh =tsos->measurementOnTrack();
227  ATH_MSG_DEBUG(" --> Defined hit measurementOnTrack() for hit: " << nTSOS << "/" << trksItr->trackStateOnSurfaces()->size() << " of track " << nTracks);
228 
229  //Trk::RIO_OnTrack object contains information on the hit used to fit the track at this surface
230  const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>(mesh);
231  ATH_MSG_DEBUG(" --> Going to retrive the Trk::RIO_OnTrack for hit " << nTSOS);
232  if (hit== nullptr) {
233  //for some reason the first tsos has no associated hit - maybe because this contains the defining parameters?
234  if (nHits >0) ATH_MSG_DEBUG("No hit associated with TSOS " << nTSOS);
235  continue;
236  }
237 
238  ATH_MSG_DEBUG(" --> Going to retrive the track parameters of this TSOS: " << nTSOS);
239  const Trk::TrackParameters* trackParameter = tsos->trackParameters();
240  if(trackParameter==nullptr) {
241  //if no TrackParameters for TSOS we cannot define residuals
242  ATH_MSG_DEBUG(" Skipping TSOS " << nTSOS << " because it does not have TrackParameters");
243  continue;
244  }
245 
246  const AmgSymMatrix(5)* TrackParCovariance = trackParameter ? trackParameter->covariance() : nullptr;
247 
248  if(TrackParCovariance==nullptr) {
249  //if no MeasuredTrackParameters the hit will not have associated convariance error matrix and will not
250  //be able to define a pull or unbiased residual (errors needed for propagation)
251  ATH_MSG_DEBUG("Skipping TSOS " << nTSOS << " because does not have MeasuredTrackParameters");
252  continue;
253  }
254 
256  " --> going to define residuals and everything of TSOS #" << nTSOS << "/" <<
257  trksItr->trackStateOnSurfaces()->size());
258 
259  float residualX = 9999.0;
260  float residualY = 9999.0;
261  float pullX = 9999.0;
262  float pullY = 9999.0;
263  float biasedResidualX = 9999.0;
264  float biasedResidualY = 9999.0;
265  int detType = 99;
266  int barrelEC = 99;
267  int layerDisk = 99;
268  int sctSide = 99;
269  int modEta = 9999;
270  int modPhi = 9999;
271 
272  const Identifier & hitId = hit->identify();
273  if (m_idHelper->is_trt(hitId)) detType = 2;
274  else if (m_idHelper->is_sct(hitId)) detType = 1;
275  else if (m_idHelper->is_pixel(hitId)) detType = 0;
276  else detType = 99;
277 
278  //hits with detType = 0 are no Inner Detector hits -> skip
279  if ( detType == 99) {
280  ATH_MSG_DEBUG(" --> Hit " << nTSOS << " with detector type " << detType << " is not an Inner Detector hit -> skip this hit");
281  continue;
282  }
283 
284  //TRT hits: detType = 2
285  if (detType == 2) {
286  ATH_MSG_DEBUG("** IDAlignMonResidualsAlg::fillHistograms() ** Hit is from the TRT, finding residuals... ");
287  bool isTubeHit = (mesh->localCovariance()(Trk::locX, Trk::locX) > 1.0);
288  const Trk::TrackParameters* trackParameter = tsos->trackParameters();
289  float hitR = hit->localParameters()[Trk::driftRadius];
290  float trketa = tsos->trackParameters()->eta();
291  float pullR = -9.9;
292 
293  const Identifier& id = m_trtID->layer_id(hitId);
294  int barrel_ec = m_trtID->barrel_ec(id);
295  int layer_or_wheel = m_trtID->layer_or_wheel(id);
296  int phi_module = m_trtID->phi_module(id);
297 
298  //finding residuals
299  if (!trackParameter) {
300  ATH_MSG_WARNING("No TrackParameters associated with TRT TrkSurface " << nTSOS);
301  continue;
302  }
303  ATH_MSG_DEBUG("Found Trk::TrackParameters for hit " << nTSOS << " --> TRT hit (detType= " << detType << ")" );
304 
305  //getting unbiased track parameters by removing the hit from the track and refitting
306  //std::unique_ptr <Trk::TrackParameters> trackParameterUnbiased;
307  auto trackParameterUnbiased = getUnbiasedTrackParameters(trksItr, tsos);
308 
309  if (!trackParameterUnbiased) {//updator can fail
310  ATH_MSG_WARNING("Cannot define unbiased parameters for hit, skipping it.");
311  continue;
312  }
313  ATH_MSG_DEBUG(" --> TRT UnBiased TrackParameters of hit " << nTSOS << " FOUND");
314 
315  float predictR = trackParameterUnbiased->parameters()[Trk::locR];
316 
317  const Trk::MeasurementBase* mesh = tsos->measurementOnTrack();
318  std::optional<Trk::ResidualPull> residualPull =
319  m_residualPullCalculator->residualPull(mesh,
320  trackParameterUnbiased.get(),
322 
323  if (residualPull) {
324  pullR = residualPull->pull()[Trk::locR];
325  }
326  else {
327  ATH_MSG_DEBUG(" no covariance of the track parameters given, can not calculate pull!");
328  }
329 
330  //delete trackParameterUnbiased;
331 
332  float residualR = hitR - predictR;
333 
334  const InDet::TRT_DriftCircleOnTrack* trtCircle =
335  dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(tsos->measurementOnTrack());
336 
337  if (trtCircle != nullptr) {
338  ATH_MSG_DEBUG(" fillHistograms() ** filling TRT histograms for hit/tsos #" << nTSOS
339  << " Barrel/EndCap: " << barrel_ec
340  << " layer/wheel: " << layer_or_wheel
341  << " phi: " << phi_module
342  << " Residual: " << residualR);
344  fillTRTHistograms(barrel_ec
345  , layer_or_wheel
346  , phi_module
347  , predictR
348  , hitR
349  , residualR
350  , pullR
351  , isTubeHit
352  , trketa);
353  }
354  }//end-TRT hit
355 
356  else { //have identified a PIXEL or SCT hit
357  if(m_doHitQuality) {
358  ATH_MSG_DEBUG("applying hit quality cuts to Silicon hit...");
359  hit = m_hitQualityTool->getGoodHit(tsos);
360  if(hit==nullptr) {
361  ATH_MSG_DEBUG("hit failed quality cuts and is rejected.");
362  continue;
363  }
364  ATH_MSG_DEBUG("hit passed quality cuts");
365  }
366  else ATH_MSG_DEBUG("hit quality cuts NOT APPLIED to Silicon hit.");
367 
368  //determining Si module physical position (can modify residual calculation eg. SCT endcaps)
369  if (detType==0){//pixel
370  const Identifier& id = m_pixelID->wafer_id(hitId);
371  barrelEC = m_pixelID -> barrel_ec(id);
372  layerDisk = m_pixelID -> layer_disk(id);
373  modEta = m_pixelID->eta_module(id); //For the endcaps these are the rings
374  modPhi = m_pixelID->phi_module(id);
375  }
376  else {//sct. Since detType == 0 or detType == 1 here
377  const Identifier& id = m_sctID->wafer_id(hitId);
378  barrelEC = m_sctID->barrel_ec(id);
379  layerDisk = m_sctID->layer_disk(id);
380  modEta = m_sctID->eta_module(id);
381  modPhi = m_sctID->phi_module(id);
382  sctSide = m_sctID->side(id);
383  }
384 
385  //finding residuals
386  if(trackParameter){//should always have TrackParameters since we now skip tracks with no MeasuredTrackParameters
387 
388  ATH_MSG_DEBUG("Found Trk::TrackParameters " << trackParameter);
389 
390  double unbiasedResXY[4] = {9999.0,9999.0,9999.0,9999.0};
391  double biasedResXY[4] = {9999.0,9999.0,9999.0,9999.0};
392 
393  //finding unbiased single residuals
394  StatusCode sc;
395  sc = getSiResiduals(trksItr,tsos,true,unbiasedResXY);
396  if (sc.isFailure()) {
397  ATH_MSG_DEBUG("Problem in determining unbiased residuals! Hit is skipped.");
398  auto detType_m = Monitored::Scalar<int>( "m_detType", detType);
399  fill(residualGroup, detType_m);
400  continue;
401  }
402  else
403  ATH_MSG_DEBUG("unbiased residuals found ok");
404 
405  residualX = (float)unbiasedResXY[0];
406  residualY = (float)unbiasedResXY[1];
407  pullX = (float)unbiasedResXY[2];
408  pullY = (float)unbiasedResXY[3];
409 
410  //finding biased single residuals (for interest)
411  sc = getSiResiduals(trksItr,tsos,false,biasedResXY);
412  if (sc.isFailure()) {
413  ATH_MSG_DEBUG("Problem in determining biased residuals! Hit is skipped.");
414  continue;
415  }
416  else
417  ATH_MSG_DEBUG("biased residuals found ok");
418 
419  biasedResidualX = (float)biasedResXY[0];
420  biasedResidualY = (float)biasedResXY[1];
421 
422  }
423  else {
424  ATH_MSG_DEBUG("No TrackParameters associated with Si TrkSurface "<< nTSOS << " - Hit is probably an outlier");
425  }
426  }//end-Pixel and SCT hits
427 
428  //--------------------------------------------
429  //
430  // Filling Residual Histograms for Pixel and SCT
431  //
432  //--------------------------------------------
433 
434  //Common for Pixel and SCT and other variables used
435  auto si_residualx_m = Monitored::Scalar<float>( "m_si_residualx", 0.0);
436  auto si_b_residualx_m = Monitored::Scalar<float>( "m_si_b_residualx", 0.0);
437  auto si_barrel_resX_m = Monitored::Scalar<float>( "m_si_barrel_resX", 0.0);
438  auto si_barrel_resY_m = Monitored::Scalar<float>( "m_si_barrel_resY", 0.0);
439  auto si_barrel_pullX_m = Monitored::Scalar<float>( "m_si_barrel_pullX", 0.0);
440  auto si_barrel_pullY_m = Monitored::Scalar<float>( "m_si_barrel_pullY", 0.0);
441  auto si_eca_resX_m = Monitored::Scalar<float>( "m_si_eca_resX", 0.0);
442  auto si_eca_resY_m = Monitored::Scalar<float>( "m_si_eca_resY", 0.0);
443  auto si_eca_pullX_m = Monitored::Scalar<float>( "m_si_eca_pullX", 0.0);
444  auto si_eca_pullY_m = Monitored::Scalar<float>( "m_si_eca_pullY", 0.0);
445  auto si_ecc_resX_m = Monitored::Scalar<float>( "m_si_ecc_resX", 0.0);
446  auto si_ecc_resY_m = Monitored::Scalar<float>( "m_si_ecc_resY", 0.0);
447  auto si_ecc_pullX_m = Monitored::Scalar<float>( "m_si_ecc_pullX", 0.0);
448  auto si_ecc_pullY_m = Monitored::Scalar<float>( "m_si_ecc_pullY", 0.0);
449  auto residualX_m = Monitored::Scalar<float>( "m_residualX", residualX);
450  auto residualY_m = Monitored::Scalar<float>( "m_residualY", residualY);
451  auto modEta_m = Monitored::Scalar<int>( "m_modEta", modEta );
452  auto modPhi_m = Monitored::Scalar<int>( "m_modPhi", modPhi );
453  int lb = GetEventInfo(ctx)->lumiBlock();
454  auto lb_m = Monitored::Scalar<int>( "m_lb", lb );
455  auto layerDisk_m = Monitored::Scalar<float>("m_layerDisk", layerDisk);
456  auto layerDisk_si_m = Monitored::Scalar<float>("m_layerDisk_si", 0);
457 
458  if (detType==0) {//filling pixel histograms
459  ATH_MSG_DEBUG(" This is a PIXEL hit " << hitId << " - filling histograms");
460 
461  si_residualx_m = residualX;
462  fill(residualGroup, si_residualx_m);
463 
464  if(barrelEC==0){//filling pixel barrel histograms
465  int ModEtaShift[4] = {0, 30, 53, 76};
466  int ModPhiShift[4] = {0, 24, 56, 104};
467 
468  //common Si plots
469  si_b_residualx_m = residualX;
470  fill(residualGroup, si_b_residualx_m);
471 
472  layerDisk_si_m = layerDisk;
473  si_barrel_resX_m = residualX;
474  fill(residualGroup, layerDisk_si_m, si_barrel_resX_m);
475  si_barrel_resY_m = residualY;
476  fill(residualGroup, layerDisk_si_m, si_barrel_resY_m);
477  si_barrel_pullX_m = pullX;
478  fill(residualGroup, layerDisk_si_m, si_barrel_pullX_m);
479  si_barrel_pullY_m = pullY;
480  fill(residualGroup, layerDisk_si_m, si_barrel_pullY_m);
481 
482  //Pixel Residual plots
483  auto pix_b_residualx_m = Monitored::Scalar<float>( "m_pix_b_residualx", residualX);
484  fill(residualGroup, pix_b_residualx_m);
485  auto pix_b_biased_residualx_m = Monitored::Scalar<float>( "m_pix_b_biased_residualx", biasedResidualX);
486  fill(residualGroup, pix_b_biased_residualx_m);
487  auto pix_b_residualy_m = Monitored::Scalar<float>( "m_pix_b_residualy", residualY);
488  fill(residualGroup, pix_b_residualy_m);
489  auto pix_b_biased_residualy_m = Monitored::Scalar<float>( "m_pix_b_biased_residualy", biasedResidualY);
490  fill(residualGroup, pix_b_biased_residualy_m);
491  auto pix_b_residualsx_m = Monitored::Scalar<float>("m_pix_residualsx", residualX);
492  fill(m_tools[m_pixResidualX[layerDisk]], pix_b_residualsx_m);
493  fill(m_tools[m_pixResidualX_3D[layerDisk]], modEta_m, modPhi_m, pix_b_residualsx_m);
494  auto pix_b_residualsy_m = Monitored::Scalar<float>("m_pix_residualsy", residualY);
495  fill(m_tools[m_pixResidualY[layerDisk]], pix_b_residualsy_m);
496  fill(m_tools[m_pixResidualY_3D[layerDisk]], modEta_m, modPhi_m, pix_b_residualsy_m);
497  auto pix_b_pullsx_m = Monitored::Scalar<float>("m_pix_pullsx", pullX);
498  fill(m_tools[m_pixPullX[layerDisk]], pix_b_pullsx_m);
499  auto pix_b_pullsy_m = Monitored::Scalar<float>("m_pix_pullsy", pullY);
500  fill(m_tools[m_pixPullY[layerDisk]], pix_b_pullsy_m);
501 
502  //Residuals vs Eta and Phi
503  fill(m_tools[m_pixResidualXvsEta[layerDisk]], modEta_m, residualX_m );
504  fill(m_tools[m_pixResidualYvsEta[layerDisk]], modEta_m, residualY_m );
505  fill(m_tools[m_pixResidualXvsPhi[layerDisk]], modPhi_m, residualX_m );
506  fill(m_tools[m_pixResidualYvsPhi[layerDisk]], modPhi_m, residualY_m );
507 
508  auto residualX_barrel_m = Monitored::Scalar<float>( "m_residualX_barrel", residualX);
509  auto residualY_barrel_m = Monitored::Scalar<float>( "m_residualY_barrel", residualY);
510  auto modPhiShift_barrel_m = Monitored::Scalar<int>( "m_modPhiShift_barrel", modPhi + ModPhiShift[layerDisk] );
511  auto modEtaShift_barrel_m = Monitored::Scalar<int>( "m_modEtaShift_barrel", modEta + ModEtaShift[layerDisk] );
512  fill(residualGroup, modPhiShift_barrel_m, residualX_barrel_m);
513  fill(residualGroup, modPhiShift_barrel_m, residualY_barrel_m);
514  fill(residualGroup, modEtaShift_barrel_m, residualX_barrel_m);
515  fill(residualGroup, modEtaShift_barrel_m, residualY_barrel_m);
516  }
517  else if(barrelEC==2){//three Pixel endcap disks from 0-2
518  int ModPhiShift[3] = {0, 55, 110};
519 
520  //Common Si plots
521  layerDisk_si_m = layerDisk;
522  si_eca_resX_m = residualX;
523  fill(residualGroup, layerDisk_si_m, si_eca_resX_m);
524  si_eca_resY_m = residualY;
525  fill(residualGroup, layerDisk_si_m, si_eca_resY_m);
526  si_eca_pullX_m = pullX;
527  fill(residualGroup, layerDisk_si_m, si_eca_pullX_m);
528  si_eca_pullY_m = pullY;
529  fill(residualGroup, layerDisk_si_m, si_eca_pullY_m);
530 
531  //Pixel Residual plots
532  auto pix_eca_residualx_m = Monitored::Scalar<float>( "m_pix_eca_residualx", residualX);
533  auto pix_ec_residualx_m = Monitored::Scalar<float>( "m_pix_ec_residualx", residualX);
534  fill(residualGroup, pix_eca_residualx_m);
535  fill(m_tools[m_pixECResidualX_3D[0]], layerDisk_m , modPhi_m, pix_ec_residualx_m);
536  auto pix_eca_residualy_m = Monitored::Scalar<float>( "m_pix_eca_residualy", residualY);
537  auto pix_ec_residualy_m = Monitored::Scalar<float>( "m_pix_ec_residualy", residualY);
538  fill(residualGroup, pix_eca_residualy_m);
539  fill(m_tools[m_pixECResidualY_3D[0]], layerDisk_m, modPhi_m, pix_ec_residualy_m);
540  auto pix_eca_pullx_m = Monitored::Scalar<float>( "m_pix_eca_pullx", pullX);
541  fill(residualGroup, pix_eca_pullx_m);
542  auto pix_eca_pully_m = Monitored::Scalar<float>( "m_pix_eca_pully", pullY);
543  fill(residualGroup, pix_eca_pully_m);
544 
545  //Residuals vs Eta and Phi
546  auto residualX_eca_m = Monitored::Scalar<float>( "m_residualX_eca", residualX );
547  auto residualY_eca_m = Monitored::Scalar<float>( "m_residualY_eca", residualY );
548  auto modPhiShift_eca_m = Monitored::Scalar<int>( "m_modPhiShift_eca", modPhi + ModPhiShift[layerDisk]);
549  fill(m_tools[m_pixECAResidualX[layerDisk]], modPhi_m, pix_eca_residualx_m);
550  fill(m_tools[m_pixECAResidualY[layerDisk]], modPhi_m, pix_eca_residualy_m);
551  fill(residualGroup, modPhiShift_eca_m, residualX_eca_m);
552  fill(residualGroup, modPhiShift_eca_m, residualY_eca_m);
553  }
554  else if(barrelEC==-2){
555  int ModPhiShift[3] = {0, 55, 110};
556 
557  //Common Si plots
558  layerDisk_si_m = layerDisk;
559  si_ecc_resX_m = residualX;
560  fill(residualGroup, layerDisk_si_m, si_ecc_resX_m);
561  si_ecc_resY_m = residualY;
562  fill(residualGroup, layerDisk_si_m, si_ecc_resY_m);
563  si_ecc_pullX_m = pullX;
564  fill(residualGroup, layerDisk_si_m, si_ecc_pullX_m);
565  si_ecc_pullY_m = pullY;
566  fill(residualGroup, layerDisk_si_m, si_ecc_pullY_m);
567 
568  //Pixel Residual plots
569  auto pix_ecc_residualx_m = Monitored::Scalar<float>( "m_pix_ecc_residualx", residualX);
570  auto pix_ec_residualx_m = Monitored::Scalar<float>( "m_pix_ec_residualx", residualX);
571  fill(residualGroup, pix_ecc_residualx_m);
572  fill(m_tools[m_pixECResidualX_3D[1]], layerDisk_m , modPhi_m, pix_ec_residualx_m);
573  auto pix_ecc_residualy_m = Monitored::Scalar<float>( "m_pix_ecc_residualy", residualY);
574  auto pix_ec_residualy_m = Monitored::Scalar<float>( "m_pix_ec_residualy", residualY);
575  fill(residualGroup, pix_ecc_residualy_m);
576  fill(m_tools[m_pixECResidualY_3D[1]], layerDisk_m, modPhi_m, pix_ec_residualy_m);
577  auto pix_ecc_pullx_m = Monitored::Scalar<float>( "m_pix_ecc_pullx", pullX);
578  fill(residualGroup, pix_ecc_pullx_m);
579  auto pix_ecc_pully_m = Monitored::Scalar<float>( "m_pix_ecc_pully", pullY);
580  fill(residualGroup, pix_ecc_pully_m);
581 
582  //Residuals vs Eta and Phi
583  auto residualX_ecc_m = Monitored::Scalar<float>( "m_residualX_ecc", residualX);
584  auto residualY_ecc_m = Monitored::Scalar<float>( "m_residualY_ecc", residualY);
585  auto modPhiShift_ecc_m = Monitored::Scalar<int>( "m_modPhiShift_ecc", modPhi + ModPhiShift[layerDisk] );
586  fill(m_tools[m_pixECCResidualX[layerDisk]], modPhi_m, pix_ecc_residualx_m);
587  fill(m_tools[m_pixECCResidualY[layerDisk]], modPhi_m, pix_ecc_residualy_m);
588  fill(residualGroup, modPhiShift_ecc_m, residualX_ecc_m);
589  fill(residualGroup, modPhiShift_ecc_m, residualY_ecc_m);
590  }
591  }
592  else if (detType==1) {//filling SCT histograms
593  si_residualx_m = residualX;
594  fill(residualGroup, si_residualx_m);
595 
596  ATH_MSG_DEBUG(" This is a SCT hit " << hitId << " - filling histograms");
597 
598  if(barrelEC==0){//filling SCT barrel histograms
599  int ModPhiShift[4] = {0, 42, 92, 150};
600  int ModEtaShift[4] = {0, 23, 46, 69};
601 
602  //common Si plots
603  si_b_residualx_m = residualX;
604  fill(residualGroup, si_b_residualx_m);
605 
606  layerDisk_si_m = 4 + 2 * layerDisk + sctSide;
607  si_barrel_resX_m = residualX;
608  fill(residualGroup, layerDisk_si_m, si_barrel_resX_m);
609  si_barrel_pullX_m = pullX;
610  fill(residualGroup, layerDisk_si_m, si_barrel_pullX_m);
611 
612  //SCT Residual plots
613  auto sct_b_residualx_m = Monitored::Scalar<float>( "m_sct_b_residualx", residualX);
614  fill(residualGroup, sct_b_residualx_m);
615  auto sct_b_biased_residualx_m = Monitored::Scalar<float>( "m_sct_b_biased_residualx", biasedResidualX);
616  auto sct_b_residualsx_m = Monitored::Scalar<float>("m_sct_residualsx", residualX);
617  fill(m_tools[m_sctResidualX[layerDisk]], sct_b_residualsx_m);
618  fill(m_tools[m_sctResidualX_3D[layerDisk]], modEta_m, modPhi_m, sct_b_residualsx_m);
619  auto sct_b_pullsx_m = Monitored::Scalar<float>("m_sct_pullsx", pullX);
620  fill(m_tools[m_sctPullX[layerDisk]], sct_b_pullsx_m);
621 
622  //Residuals vs Eta and Phi
623  fill(m_tools[m_sctResidualXvsEta[layerDisk]], modEta_m, residualX_m);
624  fill(m_tools[m_sctResidualXvsPhi[layerDisk]], modPhi_m, residualX_m);
625 
626  auto residualX_sct_barrel_m = Monitored::Scalar<float>( "m_residualX_sct_barrel", residualX);
627  auto modPhiShift_sct_barrel_m = Monitored::Scalar<int>( "m_modPhiShift_sct_barrel", modPhi + ModPhiShift[layerDisk] );
628  auto modEtaShift_sct_barrel_m = Monitored::Scalar<int>( "m_modEtaShift_sct_barrel", modEta + ModEtaShift[layerDisk] );
629  fill(residualGroup, modPhiShift_sct_barrel_m, residualX_sct_barrel_m);
630  fill(residualGroup, modEtaShift_sct_barrel_m, residualX_sct_barrel_m);
631  } // end SCT barrel
632 
633  else if(barrelEC==2){//nine SCT endcap disks from 0-8
634  int Nmods = 52;
635  int gap_sct = 10;
636 
637  //Common Si plots
638  layerDisk_si_m = 3 + 2 * layerDisk + sctSide;
639  si_eca_resX_m = residualX;
640  fill(residualGroup, layerDisk_si_m, si_eca_resX_m);
641  si_eca_pullX_m = pullX;
642  fill(residualGroup, layerDisk_si_m, si_eca_pullX_m);
643 
644  //SCT Residual plots
645  auto sct_eca_residualx_m = Monitored::Scalar<float>( "m_sct_eca_residualx", residualX);
646  fill(residualGroup, sct_eca_residualx_m);
647  fill(m_tools[m_sctECAResidualX_3D[layerDisk]], modEta_m, modPhi_m, sct_eca_residualx_m);
648  auto sct_eca_pullx_m = Monitored::Scalar<float>( "m_sct_eca_pullx", pullX);
649  fill(residualGroup, sct_eca_pullx_m);
650 
651  //Residuals vs Eta and Phi
652  auto residualX_sct_eca_m = Monitored::Scalar<float>( "m_residualX_sct_eca", residualX);
653  auto modPhiShift_sct_eca_m = Monitored::Scalar<int>( "m_modPhiShift_sct_eca", modPhi + layerDisk * (gap_sct + Nmods) );
654  fill(residualGroup, modPhiShift_sct_eca_m, residualX_sct_eca_m);
655  } // end SCT end-cap A
656 
657  else if(barrelEC==-2){//start SCT end-cap C
658  int Nmods = 52;
659  int gap_sct = 10;
660 
661  //Common Si plots
662  layerDisk_si_m = 3 + 2 * layerDisk + sctSide;
663  si_ecc_resX_m = residualX;
664  fill(residualGroup, layerDisk_si_m, si_ecc_resX_m);
665  si_ecc_pullX_m = pullX;
666  fill(residualGroup, layerDisk_si_m, si_ecc_pullX_m);
667 
668  //SCT Residual plots
669  auto sct_ecc_residualx_m = Monitored::Scalar<float>( "m_sct_ecc_residualx", residualX);
670  fill(residualGroup, sct_ecc_residualx_m);
671  fill(m_tools[m_sctECCResidualX_3D[layerDisk]], modEta_m, modPhi_m, sct_ecc_residualx_m);
672  auto sct_ecc_pullx_m = Monitored::Scalar<float>( "m_sct_ecc_pullx", pullX);
673  fill(residualGroup, sct_ecc_pullx_m);
674 
675  //Residuals vs Eta and Phi
676  auto residualX_sct_ecc_m = Monitored::Scalar<float>( "m_residualX_sct_ecc", residualX);
677  auto modPhiShift_sct_ecc_m = Monitored::Scalar<int>( "m_modPhiShift_sct_ecc", modPhi + layerDisk * (gap_sct + Nmods) );
678  fill(residualGroup, modPhiShift_sct_ecc_m, residualX_sct_ecc_m);
679  } // end SCT end-cap C
680  }// end of SCT
681  ++nHits;
682  //++nHitsEvent;
683  }//end of loop on track surfaces
684  } // end of loop on tracks
685 
686  ATH_MSG_DEBUG("Number of tracks : "<< nTracks);
687 
688  return StatusCode::SUCCESS;
689 }
690 
691 //__________________________________________________________________________
693 {
694  if (!m_doPulls) return StatusCode::FAILURE;
695 
696  StatusCode sc = StatusCode::SUCCESS;
697 
698  double residualX = -9999.0;
699  double residualY = -9999.0;
700  double pullX = -9999.0;
701  double pullY = -9999.0;
702 
703  //extract the hit object from the tsos
704  const Trk::MeasurementBase* mesh =tsos->measurementOnTrack();
705  const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>(mesh);
706 
707  //get the unbiased track parameters (can fail if no MeasuredTrackParameters exists)
708  std::unique_ptr <Trk::TrackParameters> trackParameterUnbiased{};
709  if(unBias) trackParameterUnbiased = getUnbiasedTrackParameters(track,tsos);
710 
711  //updator can fail in defining unbiased parameters, in which case we use biased
712  std::unique_ptr <Trk::TrackParameters> trackParameterForResiduals{};
713  if(trackParameterUnbiased){
714  trackParameterForResiduals = std:: move(trackParameterUnbiased);
715  }
716  else {
717  //use the original biased track parameters
718  std::unique_ptr <Trk::TrackParameters> uTrkPtr = tsos->trackParameters()->uniqueClone();
719  trackParameterForResiduals = std::move(uTrkPtr);
720  }
721 
722  if (!m_residualPullCalculator.empty()) {
723 
724  if (hit && trackParameterForResiduals) {
725 
726  ATH_MSG_DEBUG(" got hit and track parameters ");
727 
728  std::optional<Trk::ResidualPull> residualPull = std::nullopt;
729  if(unBias) residualPull = m_residualPullCalculator->residualPull(mesh, trackParameterForResiduals.get(), Trk::ResidualPull::Unbiased);
730  else residualPull = m_residualPullCalculator->residualPull(mesh, trackParameterForResiduals.get(), Trk::ResidualPull::Biased);
731 
732  ATH_MSG_DEBUG(" got hit and track parameters...done ");
733  if (residualPull) {
734 
735  ATH_MSG_DEBUG(" got residual pull object");
736  residualX = residualPull->residual()[Trk::loc1];
737  if(residualPull->isPullValid()) pullX = residualPull->pull()[Trk::loc1];
738  else {
739  ATH_MSG_DEBUG("ResidualPullCalculator finds invalid X Pull!!!");
740  sc = StatusCode::FAILURE;
741  }
742 
743  if (residualPull->dimension() >= 2){
744 
745  ATH_MSG_DEBUG(" residualPull dim >= 2");
746  residualY = residualPull->residual()[Trk::loc2];
747 
748  ATH_MSG_DEBUG(" residual Y = " << residualY);
749  if(residualPull->isPullValid()) pullY = residualPull->pull()[Trk::loc2];
750  else {
751  ATH_MSG_DEBUG("ResidualPullCalculator finds invalid Y Pull!!!");
752  sc = StatusCode::FAILURE;
753  }
754  }
755  }
756  else {
757  ATH_MSG_DEBUG("ResidualPullCalculator failed!");
758  sc = StatusCode::FAILURE;
759  }
760  }
761  }
762 
763  // for SCT modules the residual pull calculator only finds the (rotated) Rphi residual
764  // for each of the SCT sides; residualPull->dimension()==1 always.
765 
766  //std::pair <double, double> result(residualX, residualY);
767  results[0] = residualX;
768  results[1] = residualY;
769  results[2] = pullX;
770  results[3] = pullY;
771 
772  if(pullX!=pullX || pullY!=pullY){
773  ATH_MSG_DEBUG("ResidualPullCalculator finds Pull=NAN!!!");
774  sc = StatusCode::FAILURE;
775  }
776 
777  return sc;
778 
779 }
780 
781 
782 void IDAlignMonResidualsAlg::fillTRTHistograms(int barrel_ec, int layer_or_wheel, int phi_module, float predictR, float hitR, float residualR, float pullR, bool isTubeHit, float trketa) const {
783  bool LRcorrect = (predictR * hitR > 0);
784 
785  //Need to correct the TRT residual on the C-side.
786  if (barrel_ec == -1) {
787  residualR *= -1;
788  }
789 
790  if (barrel_ec == 1 || barrel_ec == -1)
791  fillTRTBarrelHistograms(barrel_ec
792  , layer_or_wheel
793  , phi_module
794  , predictR
795  , hitR
796  , residualR
797  , pullR
798  , LRcorrect
799  , isTubeHit
800  , trketa);
801 
803  if (barrel_ec == 2 || barrel_ec == -2)
804  fillTRTEndcapHistograms(barrel_ec
805  , phi_module
806  , predictR
807  , hitR
808  , residualR
809  , pullR
810  , LRcorrect
811  , isTubeHit
812  , trketa);
813 
814  return;
815 }
816 
817 //Filling barrel histograms
818 void IDAlignMonResidualsAlg::fillTRTBarrelHistograms(int barrel_ec, int layer_or_wheel, int phi_module, float predictR, float hitR, float residualR, float pullR, bool LRcorrect, bool isTubeHit, float trketa) const {
819 
820  //Loop over the barrel sides
821  for (unsigned int side = 0; side < 3; ++side) {
822  bool doFill = false;
823  if (!side) doFill = true;
824  else if (side == 1 && barrel_ec == 1) doFill = true;
825  else if (side == 2 && barrel_ec == -1) doFill = true;
826 
827  if (!doFill) continue;
828 
829  auto trt_b_PredictedR_m = Monitored::Scalar<float>( "m_trt_b_PredictedR", predictR);
830  fill(m_tools[m_trtBPredictedR[side]], trt_b_PredictedR_m);
831  auto trt_b_MeasuredR_m = Monitored::Scalar<float>( "m_trt_b_MeasuredR", hitR);
832  fill(m_tools[m_trtBMeasuredR[side]], trt_b_MeasuredR_m);
833  auto trt_b_residualR_m = Monitored::Scalar<float>( "m_trt_b_residualR", residualR);
834  fill(m_tools[m_trtBResidualR[side]], trt_b_residualR_m);
835  auto trt_b_pullR_m = Monitored::Scalar<float>( "m_trt_b_pullR", pullR);
836  fill(m_tools[m_trtBPullR[side]], trt_b_pullR_m);
837 
838  if (!isTubeHit) {
839  auto trt_b_residualR_notube_m = Monitored::Scalar<float>( "m_trt_b_residualR_notube", residualR);
840  fill(m_tools[m_trtBResidualRNoTube[side]], trt_b_residualR_notube_m);
841  auto trt_b_pullR_notube_m = Monitored::Scalar<float>( "m_trt_b_pullR_notube", pullR);
842  fill(m_tools[m_trtBPullRNoTube[side]], trt_b_pullR_notube_m);
843  }
844 
845  auto trt_b_lr_m = Monitored::Scalar<float>( "m_trt_b_lr", 0.0);
846  if (LRcorrect && !isTubeHit) trt_b_lr_m = 0.5;
847  if (LRcorrect && isTubeHit) trt_b_lr_m = 1.5;
848  if (!LRcorrect && !isTubeHit) trt_b_lr_m = 2.5;
849  if (!LRcorrect && isTubeHit) trt_b_lr_m = 3.5;
850  fill(m_tools[m_trtBLR[side]], trt_b_lr_m);
851 
852  auto trt_b_aveResVsTrackEta_m = Monitored::Scalar<float>( "m_trt_b_aveResVsTrackEta", trketa);
853  auto trt_b_PhiSec_m = Monitored::Scalar<float>( "m_trt_b_PhiSec", phi_module);
854  auto trt_b_lrVsPhiSec_m = Monitored::Scalar<float>( "m_trt_b_lrVsPhiSec", LRcorrect);
855  fill(m_tools[m_trtBResVsEta[side][layer_or_wheel]], trt_b_aveResVsTrackEta_m, trt_b_residualR_m);
856  fill(m_tools[m_trtBResVsPhiSec[side][layer_or_wheel]], trt_b_PhiSec_m, trt_b_residualR_m);
857  trt_b_lrVsPhiSec_m = LRcorrect;
858  fill(m_tools[m_trtBLRVsPhiSec[side][layer_or_wheel]], trt_b_PhiSec_m, trt_b_lrVsPhiSec_m);
859 
860  }//Over sides
861 
862  return;
863 }//fillTRTBarrelHistograms
864 
865 void IDAlignMonResidualsAlg::fillTRTEndcapHistograms(int barrel_ec, int phi_module, float predictR, float hitR, float residualR, float pullR, bool LRcorrect, bool isTubeHit, float trketa) const {
866  for (unsigned int endcap = 0; endcap < 2; ++endcap) {
867  bool doFill = false;
868  if (!endcap && barrel_ec == 2) doFill = true;
869  else if (endcap && barrel_ec == -2) doFill = true;
870 
871  if (!doFill) continue;
872 
873  auto trt_ec_PredictedR_m = Monitored::Scalar<float>( "m_trt_ec_PredictedR", predictR);
874  fill(m_tools[m_trtECPredictedR[endcap]], trt_ec_PredictedR_m);
875  auto trt_ec_MeasuredR_m = Monitored::Scalar<float>( "m_trt_ec_MeasuredR", hitR);
876  fill(m_tools[m_trtECMeasuredR[endcap]], trt_ec_MeasuredR_m);
877  auto trt_ec_residualR_m = Monitored::Scalar<float>( "m_trt_ec_residualR", residualR);
878  fill(m_tools[m_trtECResidualR[endcap]], trt_ec_residualR_m);
879  auto trt_ec_pullR_m = Monitored::Scalar<float>( "m_trt_ec_pullR", pullR);
880  fill(m_tools[m_trtECPullR[endcap]], trt_ec_pullR_m);
881 
882  if (!isTubeHit) {
883  auto trt_ec_pullR_notube_m = Monitored::Scalar<float>( "m_trt_ec_pullR_notube", pullR);
884  fill(m_tools[m_trtECPullRNoTube[endcap]], trt_ec_pullR_notube_m);
885  auto trt_ec_residualR_notube_m = Monitored::Scalar<float>( "m_trt_ec_residualR_notube", residualR);
886  fill(m_tools[m_trtECResidualRNoTube[endcap]], trt_ec_residualR_notube_m);
887  }
888 
889  auto trt_ec_lr_m = Monitored::Scalar<float>( "m_trt_ec_lr", 0.0);
890  if (LRcorrect && !isTubeHit) trt_ec_lr_m = 0.5;
891  else if (LRcorrect && isTubeHit) trt_ec_lr_m = 1.5;
892  else if (!LRcorrect && !isTubeHit) trt_ec_lr_m = 2.5;
893  else if (!LRcorrect && isTubeHit) trt_ec_lr_m = 3.5;
894  fill(m_tools[m_trtECLR[endcap]], trt_ec_lr_m);
895 
896  auto trt_ec_aveResVsTrackEta_m = Monitored::Scalar<float>( "m_trt_ec_aveResVsTrackEta", trketa);
897  fill(m_tools[m_trtECResVsEta[endcap]], trt_ec_aveResVsTrackEta_m, trt_ec_residualR_m);
898 
899  auto trt_ec_phi_m = Monitored::Scalar<float>( "m_trt_ec_phi", phi_module);
900  fill(m_tools[m_trtECResVsPhiSec[endcap]], trt_ec_phi_m, trt_ec_residualR_m);
901  auto trt_ec_lrVsPhiSec_m = Monitored::Scalar<float>( "m_trt_ec_lrVsPhiSec", LRcorrect);
902  fill(m_tools[m_trtECLRVsPhiSec[endcap]], trt_ec_phi_m, trt_ec_lrVsPhiSec_m);
903  }
904 
905  return;
906 }
907 
908 //---------------------------------------------------------------------------------------
909 std::unique_ptr <Trk::TrackParameters> IDAlignMonResidualsAlg::getUnbiasedTrackParameters(const Trk::Track* trkPnt, const Trk::TrackStateOnSurface* tsos) const
910 {
911 
912  std::unique_ptr <Trk::TrackParameters> TrackParams{};
913  std::unique_ptr <Trk::TrackParameters> UnbiasedTrackParams{};
914  std::unique_ptr <Trk::TrackParameters> PropagatedTrackParams{};
915  std::unique_ptr <Trk::TrackParameters> OtherSideUnbiasedTrackParams{};
916 
917  //controls if the SCT residuals will be 'truly' unbiased - removing also the opposite side hit.
918  bool trueUnbiased = true;
919 
920  Identifier surfaceID;
921 
922 
923  ATH_MSG_VERBOSE("original track parameters: " << *(tsos->trackParameters()) );
924  ATH_MSG_VERBOSE("Trying to unbias track parameters.");
925 
926  const Trk::RIO_OnTrack* hitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(tsos->measurementOnTrack());
927 
928  if (hitOnTrack != nullptr) surfaceID = hitOnTrack->identify();
929 
930 
931  // if SCT Hit and TrueUnbiased then remove other side hit first
932  if (surfaceID.is_valid() && trueUnbiased && m_idHelper->is_sct(surfaceID)) { //there's no TrueUnbiased for non-SCT (pixel) hits)
933  ATH_MSG_VERBOSE("Entering True Unbiased loop.");
934 
935  // check if other module side was also hit and try to remove other hit as well
936  const Trk::TrackStateOnSurface* OtherModuleSideHit(nullptr);
937  const Identifier waferID = m_sctID->wafer_id(surfaceID);
938  const IdentifierHash waferHash = m_sctID->wafer_hash(waferID);
939  IdentifierHash otherSideHash;
940  m_sctID->get_other_side(waferHash, otherSideHash);
941  const Identifier OtherModuleSideID = m_sctID->wafer_id(otherSideHash);
942 
943  for (const Trk::TrackStateOnSurface* TempTsos : *trkPnt->trackStateOnSurfaces()) {
944 
945  const Trk::RIO_OnTrack* TempHitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(TempTsos->measurementOnTrack());
946  if (TempHitOnTrack != nullptr) {
947  if (m_sctID->wafer_id(TempHitOnTrack->identify()) == OtherModuleSideID) {
948  ATH_MSG_VERBOSE("True unbiased residual. Removing OtherModuleSide Hit " << m_idHelper->show_to_string(OtherModuleSideID,nullptr,'/') );
949  OtherModuleSideHit = TempTsos;
950  }
951  }
952  }
953 
954  if (OtherModuleSideHit) {
955  const Trk::TrackParameters* OMSHmeasuredTrackParameter = OtherModuleSideHit->trackParameters();
956  const AmgSymMatrix(5)* OMSHmeasuredTrackParameterCov = OMSHmeasuredTrackParameter ? OMSHmeasuredTrackParameter->covariance() : nullptr;
957 
958  // check that the hit on the other module side has measuredtrackparameters, otherwise it cannot be removed from the track
959  if (OMSHmeasuredTrackParameterCov) {
960  ATH_MSG_VERBOSE("OtherSideTrackParameters: " << *(OtherModuleSideHit->trackParameters()) );
961  OtherSideUnbiasedTrackParams = m_iUpdator->removeFromState(*(OtherModuleSideHit->trackParameters()),
962  OtherModuleSideHit->measurementOnTrack()->localParameters(),
963  OtherModuleSideHit->measurementOnTrack()->localCovariance());
964 
965  if (OtherSideUnbiasedTrackParams) {
966  ATH_MSG_VERBOSE("Unbiased OtherSideTrackParameters: " << *OtherSideUnbiasedTrackParams);
967 
968 
969  const Trk::Surface* TempSurface = &(OtherModuleSideHit->measurementOnTrack()->associatedSurface());
970 
971  const Trk::MagneticFieldProperties* TempField = nullptr;
972  if (TempSurface)
973  {
974  ATH_MSG_VERBOSE("After OtherSide surface call. Surface exists");
975  if (TempSurface->associatedLayer())
976  {
977  ATH_MSG_VERBOSE("TempSurface->associatedLayer() exists");
978  if(TempSurface->associatedLayer()->enclosingTrackingVolume())
979  {
980  ATH_MSG_VERBOSE("TempSurface->associatedLayer()->enclosingTrackingVolume exists");
981 
982  TempField = dynamic_cast <const Trk::MagneticFieldProperties*>(TempSurface->associatedLayer()->enclosingTrackingVolume());
983  ATH_MSG_VERBOSE("After MagneticFieldProperties cast");
984  ATH_MSG_VERBOSE("Before other side unbiased propagation");
985 
986  if (TempSurface->associatedLayer() && TempField) PropagatedTrackParams = m_propagator->propagate(
987  Gaudi::Hive::currentContext(),
988  *OtherSideUnbiasedTrackParams,
990  Trk::anyDirection, false,
991  *TempField,
993 
994  } else {
995  ATH_MSG_VERBOSE("TempSurface->associatedLayer()->enclosingTrackingVolume does not exist");
996  }
997  } else {
998  ATH_MSG_VERBOSE("TempSurface->associatedLayer() does not exist");
999  }
1000  } else {
1001  ATH_MSG_VERBOSE("After OtherSide surface call. Surface does not exist");
1002  }
1003 
1004  ATH_MSG_VERBOSE("After other side unbiased propagation");
1005  if (PropagatedTrackParams) {
1006  ATH_MSG_VERBOSE("Propagated Track Parameters: " << *PropagatedTrackParams);
1007  } else {
1008  ATH_MSG_DEBUG("Propagation of unbiased OtherSideParameters failed");
1009  }
1010  } else {
1011  ATH_MSG_DEBUG("RemoveFromState did not work for OtherSideParameters");
1012  }
1013  } else {
1014  ATH_MSG_VERBOSE("No OtherModuleSideHit Measured Track Parameters found");
1015  }
1016  } else {
1017  ATH_MSG_VERBOSE("No OtherModuleSideHit found");
1018  }
1019  }
1020 
1021  // if propagation failed or no TrueUnbiased or no SCT then use original TrackParams
1022  if (!PropagatedTrackParams) {
1023  std::unique_ptr <Trk::TrackParameters> uTrkPtr = tsos->trackParameters()->uniqueClone();
1024  PropagatedTrackParams = std::move(uTrkPtr);
1025  }
1026 
1027  UnbiasedTrackParams =
1028  m_iUpdator
1029  ->removeFromState(*PropagatedTrackParams,
1031  tsos->measurementOnTrack()->localCovariance());
1032 
1033  if (UnbiasedTrackParams) {
1034  if(surfaceID.is_valid() ) ATH_MSG_VERBOSE("Unbiased residual. Removing original Hit " << m_idHelper->show_to_string(surfaceID,nullptr,'/') );
1035  ATH_MSG_VERBOSE("Unbiased Trackparameters: " << *UnbiasedTrackParams);
1036 
1037  TrackParams = std::move(UnbiasedTrackParams);
1038 
1039  } else { // Unbiasing went awry.
1040  ATH_MSG_WARNING("RemoveFromState did not work, using original TrackParameters");
1041 
1042  std::unique_ptr <Trk::TrackParameters> uTrkPtr = tsos->trackParameters()->uniqueClone();
1043  TrackParams = std::move(uTrkPtr);
1044  }
1045 
1046  return TrackParams;
1047 
1048 }
1049 
1050 //---------------------------------------------------------------------------------------
1052 {
1053  //initializing tools
1054 
1055  ATH_MSG_DEBUG("In setupTools()");
1056 
1057  StatusCode sc;
1058  //Get the PIX manager from the detector store
1060  ATH_MSG_DEBUG("Initialized PixelManager");
1061 
1062  //Get the SCT manager from the detector store
1064  ATH_MSG_DEBUG("Initialized SCTManager");
1065 
1066  ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
1067  ATH_MSG_DEBUG("Initialized PixelIDHelper");
1068 
1069  ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
1070  ATH_MSG_DEBUG("Initialized SCTIDHelper");
1071 
1072  ATH_CHECK(detStore()->retrieve(m_trtID, "TRT_ID"));
1073  ATH_MSG_DEBUG("Initialized TRTIDHelper");
1074 
1075  //ID Helper
1076  ATH_CHECK(detStore()->retrieve(m_idHelper, "AtlasID"));
1077 
1078  ATH_CHECK(m_iUpdator.retrieve());
1079  ATH_MSG_DEBUG("Retrieved iUpdator tool " << m_iUpdator);
1080 
1081  if (m_propagator.retrieve().isFailure()) {
1082  ATH_MSG_WARNING("Can not retrieve Propagator tool of type " << m_propagator.typeAndName());
1083  return StatusCode::FAILURE;
1084  } else ATH_MSG_INFO("Retrieved tool " << m_propagator.typeAndName());
1085 
1086  if (m_trackSelection.retrieve().isFailure()) {
1087  ATH_MSG_WARNING("Can not retrieve TrackSelection tool of type " << m_trackSelection.typeAndName());
1088  return StatusCode::FAILURE;
1089  } else ATH_MSG_INFO("Retrieved tool " << m_trackSelection.typeAndName());;
1090 
1091  if (m_residualPullCalculator.empty()) {
1092  ATH_MSG_DEBUG("No residual/pull calculator for general hit residuals configured.");
1093  ATH_MSG_DEBUG("It is recommended to give R/P calculators to the det-specific tool handle lists then.");
1094  m_doPulls = false;
1095  ATH_CHECK(m_residualPullCalculator.retrieve( DisableTool{!m_doPulls} ));
1096  } else if (m_residualPullCalculator.retrieve().isFailure()) {
1097  ATH_MSG_WARNING("Could not retrieve "<< m_residualPullCalculator << " (to calculate residuals and pulls) ");
1098  m_doPulls = false;
1099 
1100  } else {
1101  ATH_MSG_DEBUG("Generic hit residuals&pulls will be calculated in one or both available local coordinates");
1102  m_doPulls = true;
1103  }
1104 
1105  if (m_hitQualityTool.empty()) {
1106  ATH_MSG_DEBUG("No hit quality tool configured - not hit quality cuts will be imposed");
1107  m_doHitQuality = false;
1108  ATH_CHECK(m_hitQualityTool.retrieve( DisableTool{!m_doHitQuality} ));
1109  } else if (m_hitQualityTool.retrieve().isFailure()) {
1110  ATH_MSG_WARNING("Could not retrieve " << m_hitQualityTool << " to apply hit quality cuts to Si hits");
1111  m_doHitQuality = false;
1112  } else {
1113  ATH_MSG_DEBUG("Hit quality tool setup - hit quality cuts will be applied to Si hits");
1114  m_doHitQuality = true;
1115  }
1116 
1117 
1118  return StatusCode::SUCCESS;
1119 }
1120 
1121 //--------------------------------------------------------------------------------------------
1123 {
1124 
1125  // Checks to see if any of the measurements on track do not have track parameters associated
1126  // (as happens for certain track collections in e.g. ESD)
1127  // If this is the case we cannot define residuals and track needs to be refitted (return true)
1128 
1129  bool refitTrack = false;
1130 
1131  int nHits = 0;
1132  int nHitsNoParams = 0;
1133 
1134  ATH_MSG_DEBUG("Testing track to see if requires refit...");
1135 
1136  for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
1137 
1138  if(tsos == nullptr) continue;
1139 
1140  //skipping outliers
1141  if(!tsos->type(Trk::TrackStateOnSurface::Measurement)) continue;
1142 
1143  const Trk::MeasurementBase* mesh =tsos->measurementOnTrack();
1144  if (mesh==nullptr) continue;
1145  const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>(mesh);
1146  if (hit==nullptr) continue;
1147 
1148  ++nHits;
1149 
1150  const Trk::TrackParameters* trackParameter = tsos->trackParameters();
1151  if(trackParameter==nullptr) ++nHitsNoParams; //if no TrackParameters for TSOS we cannot define residuals
1152 
1153  }
1154 
1155  ATH_MSG_DEBUG("Total nhits on track (excluding outliers) = " << nHits << ", nhits without trackparameters = " << nHitsNoParams);
1156 
1157  if(nHitsNoParams>0) {
1158  refitTrack = true;
1159  ATH_MSG_DEBUG("Track Requires refit to get residuals!!!");
1160  }
1161 
1162  return refitTrack;
1163 }
1164 
1165 //--------------------------------------------------------------------------------------------
IDAlignMonResidualsAlg::m_trtECResVsEta
std::vector< int > m_trtECResVsEta
Definition: IDAlignMonResidualsAlg.h:138
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IDAlignMonResidualsAlg::m_Pixel_Manager
std::string m_Pixel_Manager
Definition: IDAlignMonResidualsAlg.h:85
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
IDAlignMonResidualsAlg::m_trtBPredictedR
std::vector< int > m_trtBPredictedR
Definition: IDAlignMonResidualsAlg.h:121
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
IDAlignMonResidualsAlg::m_pixPullY
std::vector< int > m_pixPullY
Definition: IDAlignMonResidualsAlg.h:103
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
IDAlignMonResidualsAlg::m_trtECLR
std::vector< int > m_trtECLR
Definition: IDAlignMonResidualsAlg.h:137
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
IDAlignMonResidualsAlg::m_tracksKey
SG::ReadHandleKey< TrackCollection > m_tracksKey
Definition: IDAlignMonResidualsAlg.h:75
IDAlignMonResidualsAlg::m_sctECAResidualX_3D
std::vector< int > m_sctECAResidualX_3D
Definition: IDAlignMonResidualsAlg.h:116
IDAlignMonResidualsAlg::m_hitQualityTool
ToolHandle< IInDetAlignHitQualSelTool > m_hitQualityTool
Definition: IDAlignMonResidualsAlg.h:83
IDAlignMonResidualsAlg::m_trtBLRVsPhiSec
std::vector< std::vector< int > > m_trtBLRVsPhiSec
Definition: IDAlignMonResidualsAlg.h:130
IDAlignMonResidualsAlg::m_pixECResidualX_3D
std::vector< int > m_pixECResidualX_3D
Definition: IDAlignMonResidualsAlg.h:110
IDAlignMonResidualsAlg::m_trtBResidualR
std::vector< int > m_trtBResidualR
Definition: IDAlignMonResidualsAlg.h:123
IDAlignMonResidualsAlg::m_pixECCResidualX
std::vector< int > m_pixECCResidualX
Definition: IDAlignMonResidualsAlg.h:112
Trk::MagneticFieldProperties
Definition: MagneticFieldProperties.h:31
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::locX
@ locX
Definition: ParamDefs.h:43
Surface.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
IDAlignMonResidualsAlg::m_pixPullX
std::vector< int > m_pixPullX
Definition: IDAlignMonResidualsAlg.h:102
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
PixelCluster.h
IDAlignMonResidualsAlg::m_nTRTEClayers
static const int m_nTRTEClayers
Definition: IDAlignMonResidualsAlg.h:97
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::ParametersBase::uniqueClone
std::unique_ptr< ParametersBase< DIM, T > > uniqueClone() const
clone method for polymorphic deep copy returning unique_ptr; it is not overriden, but uses the existi...
Definition: ParametersBase.h:97
Trk::Track::trackStateOnSurfaces
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
IDAlignMonResidualsAlg::m_tracksName
SG::ReadHandleKey< TrackCollection > m_tracksName
Definition: IDAlignMonResidualsAlg.h:76
IDAlignMonResidualsAlg::m_propagator
ToolHandle< Trk::IPropagator > m_propagator
Definition: IDAlignMonResidualsAlg.h:80
Trk::ResidualPull::Unbiased
@ Unbiased
RP with track state that has measurement not included.
Definition: ResidualPull.h:57
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
IDAlignMonResidualsAlg::m_trtECResidualRNoTube
std::vector< int > m_trtECResidualRNoTube
Definition: IDAlignMonResidualsAlg.h:135
IDAlignMonResidualsAlg::m_trtECResidualR
std::vector< int > m_trtECResidualR
Definition: IDAlignMonResidualsAlg.h:133
IDAlignMonResidualsAlg::~IDAlignMonResidualsAlg
virtual ~IDAlignMonResidualsAlg()
Definition: IDAlignMonResidualsAlg.cxx:73
IDAlignMonResidualsAlg::m_nPixEClayers
static const int m_nPixEClayers
Definition: IDAlignMonResidualsAlg.h:94
IDAlignMonResidualsAlg::m_pixECCResidualY
std::vector< int > m_pixECCResidualY
Definition: IDAlignMonResidualsAlg.h:113
IDAlignMonResidualsAlg::m_residualPullCalculator
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
The residual and pull calculator tool handle.
Definition: IDAlignMonResidualsAlg.h:81
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:41
IDAlignMonResidualsAlg::getSiResiduals
StatusCode getSiResiduals(const Trk::Track *, const Trk::TrackStateOnSurface *, bool, double *) const
Definition: IDAlignMonResidualsAlg.cxx:692
IDAlignMonResidualsAlg::m_sctResidualX
std::vector< int > m_sctResidualX
Definition: IDAlignMonResidualsAlg.h:114
IDAlignMonResidualsAlg::m_sctResidualXvsPhi
std::vector< int > m_sctResidualXvsPhi
Definition: IDAlignMonResidualsAlg.h:120
Layer.h
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
SiClusterOnTrack.h
IDAlignMonResidualsAlg::m_applyTrkSel
bool m_applyTrkSel
Definition: IDAlignMonResidualsAlg.h:91
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
Trk::locR
@ locR
Definition: ParamDefs.h:50
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
IDAlignMonResidualsAlg::m_trtBPullR
std::vector< int > m_trtBPullR
Definition: IDAlignMonResidualsAlg.h:124
IDAlignMonResidualsAlg::m_trtECPullRNoTube
std::vector< int > m_trtECPullRNoTube
Definition: IDAlignMonResidualsAlg.h:136
InDet::TRT_DriftCircleOnTrack
Definition: TRT_DriftCircleOnTrack.h:53
IDAlignMonResidualsAlg::fillTRTHistograms
void fillTRTHistograms(int barrel_ec, int layer_or_wheel, int phi_module, float predictR, float hitR, float residualR, float pullR, bool isTubeHit, float trketa) const
Definition: IDAlignMonResidualsAlg.cxx:782
SCT_Cluster.h
IDAlignMonResidualsAlg::m_trtECLRVsPhiSec
std::vector< int > m_trtECLRVsPhiSec
Definition: IDAlignMonResidualsAlg.h:140
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
IDAlignMonResidualsAlg::m_trtBResVsEta
std::vector< std::vector< int > > m_trtBResVsEta
Definition: IDAlignMonResidualsAlg.h:128
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
IDAlignMonResidualsAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: IDAlignMonResidualsAlg.cxx:144
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
IDAlignMonResidualsAlg::m_PIX_Mgr
const InDetDD::PixelDetectorManager * m_PIX_Mgr
Definition: IDAlignMonResidualsAlg.h:69
IDAlignMonResidualsAlg::m_SCT_Mgr
const InDetDD::SCT_DetectorManager * m_SCT_Mgr
Definition: IDAlignMonResidualsAlg.h:70
ITRT_ConditionsSvc.h
TRT::Hit::side
@ side
Definition: HitInfo.h:83
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
MagneticFieldProperties.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
IDAlignMonResidualsAlg::m_sctResidualXvsEta
std::vector< int > m_sctResidualXvsEta
Definition: IDAlignMonResidualsAlg.h:119
IDAlignMonResidualsAlg::m_pixResidualX_3D
std::vector< int > m_pixResidualX_3D
Definition: IDAlignMonResidualsAlg.h:99
IDAlignMonResidualsAlg::m_trtBPullRNoTube
std::vector< int > m_trtBPullRNoTube
Definition: IDAlignMonResidualsAlg.h:126
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IDAlignMonResidualsAlg::m_pixECAResidualX
std::vector< int > m_pixECAResidualX
Definition: IDAlignMonResidualsAlg.h:108
Monitored::detail::doFill
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.
Definition: HistogramFillerUtils.h:164
PixelDetectorManager.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
ResidualPull.h
IDAlignMonResidualsAlg::m_iUpdator
ToolHandle< Trk::IUpdator > m_iUpdator
Definition: IDAlignMonResidualsAlg.h:79
IDAlignMonResidualsAlg::m_pixResidualYvsEta
std::vector< int > m_pixResidualYvsEta
Definition: IDAlignMonResidualsAlg.h:105
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
IDAlignMonResidualsAlg::m_trtECPullR
std::vector< int > m_trtECPullR
Definition: IDAlignMonResidualsAlg.h:134
IDAlignMonResidualsAlg::m_trtBMeasuredR
std::vector< int > m_trtBMeasuredR
Definition: IDAlignMonResidualsAlg.h:122
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IDAlignMonResidualsAlg::fillTRTEndcapHistograms
void fillTRTEndcapHistograms(int barrel_ec, int phi_module, float predictR, float hitR, float residualR, float pullR, bool LRcorrect, bool isTubeHit, float trketa) const
Definition: IDAlignMonResidualsAlg.cxx:865
IDAlignMonResidualsAlg::m_checkrate
int m_checkrate
Definition: IDAlignMonResidualsAlg.h:89
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:59
IDAlignMonResidualsAlg::m_sctResidualX_3D
std::vector< int > m_sctResidualX_3D
Definition: IDAlignMonResidualsAlg.h:115
IDAlignMonResidualsAlg::m_trtECResVsPhiSec
std::vector< int > m_trtECResVsPhiSec
Definition: IDAlignMonResidualsAlg.h:139
TrackCollection.h
IDAlignMonResidualsAlg::m_pixECAResidualY
std::vector< int > m_pixECAResidualY
Definition: IDAlignMonResidualsAlg.h:109
IDAlignMonResidualsAlg::m_trtBLR
std::vector< int > m_trtBLR
Definition: IDAlignMonResidualsAlg.h:127
IDAlignMonResidualsAlg::m_trtECPredictedR
std::vector< int > m_trtECPredictedR
Definition: IDAlignMonResidualsAlg.h:131
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT_DriftCircleOnTrack.h
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
IDAlignMonResidualsAlg::m_SCT_Manager
std::string m_SCT_Manager
Definition: IDAlignMonResidualsAlg.h:86
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:866
SCT_ID::get_other_side
int get_other_side(const IdentifierHash &id, IdentifierHash &other) const
Wafer hash on other side.
Definition: SCT_ID.cxx:435
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:884
IDAlignMonResidualsAlg::m_sctECCResidualX_3D
std::vector< int > m_sctECCResidualX_3D
Definition: IDAlignMonResidualsAlg.h:117
Trk::MeasurementBase::localCovariance
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Definition: MeasurementBase.h:138
IDAlignMonResidualsAlg::setupTools
StatusCode setupTools()
Definition: IDAlignMonResidualsAlg.cxx:1051
Trk::MeasurementBase
Definition: MeasurementBase.h:58
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
IDAlignMonResidualsAlg::m_pixResidualX
std::vector< int > m_pixResidualX
Definition: IDAlignMonResidualsAlg.h:98
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
IDAlignMonResidualsAlg::m_trtECMeasuredR
std::vector< int > m_trtECMeasuredR
Definition: IDAlignMonResidualsAlg.h:132
IDAlignMonResidualsAlg::getUnbiasedTrackParameters
std::unique_ptr< Trk::TrackParameters > getUnbiasedTrackParameters(const Trk::Track *, const Trk::TrackStateOnSurface *) const
Definition: IDAlignMonResidualsAlg.cxx:909
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
IDAlignMonResidualsAlg::m_pixECResidualY_3D
std::vector< int > m_pixECResidualY_3D
Definition: IDAlignMonResidualsAlg.h:111
Trk::nonInteracting
@ nonInteracting
Definition: ParticleHypothesis.h:25
IDAlignMonResidualsAlg::m_trtcaldbTool
ToolHandle< ITRT_CalDbTool > m_trtcaldbTool
Definition: IDAlignMonResidualsAlg.h:78
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
SiCluster.h
python.ami.results
def results
Definition: ami.py:386
IDAlignMonResidualsAlg::m_nSiBlayers
static const int m_nSiBlayers
Definition: IDAlignMonResidualsAlg.h:93
TRT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: TRT_ID.h:875
LocalParameters.h
IDAlignMonResidualsAlg::m_nTRTBlayers
static const int m_nTRTBlayers
Definition: IDAlignMonResidualsAlg.h:96
AthMonitorAlgorithm::lbAverageInteractionsPerCrossing
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average mu, i.e.
Definition: AthMonitorAlgorithm.cxx:222
IDAlignMonResidualsAlg::m_extendedPlots
bool m_extendedPlots
Definition: IDAlignMonResidualsAlg.h:87
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
IDAlignMonResidualsAlg::fillTRTBarrelHistograms
void fillTRTBarrelHistograms(int barrel_ec, int layer_or_wheel, int phi_module, float predictR, float hitR, float residualR, float pullR, bool LRcorrect, bool isTubeHit, float trketa) const
Definition: IDAlignMonResidualsAlg.cxx:818
Trk::Surface::associatedLayer
const Trk::Layer * associatedLayer() const
return the associated Layer
IDAlignMonResidualsAlg::m_pixResidualYvsPhi
std::vector< int > m_pixResidualYvsPhi
Definition: IDAlignMonResidualsAlg.h:107
IDAlignMonResidualsAlg::m_sctPullX
std::vector< int > m_sctPullX
Definition: IDAlignMonResidualsAlg.h:118
IDAlignMonResidualsAlg::trackRequiresRefit
bool trackRequiresRefit(const Trk::Track *) const
Definition: IDAlignMonResidualsAlg.cxx:1122
IDAlignMonResidualsAlg::m_pixResidualXvsPhi
std::vector< int > m_pixResidualXvsPhi
Definition: IDAlignMonResidualsAlg.h:106
IDAlignMonResidualsAlg::m_trtBResVsPhiSec
std::vector< std::vector< int > > m_trtBResVsPhiSec
Definition: IDAlignMonResidualsAlg.h:129
TrackingVolume.h
Trk::ResidualPull::Biased
@ Biased
RP with track state including the hit.
Definition: ResidualPull.h:55
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IDAlignMonResidualsAlg::m_trtBResidualRNoTube
std::vector< int > m_trtBResidualRNoTube
Definition: IDAlignMonResidualsAlg.h:125
IDAlignMonResidualsAlg::m_trackSelection
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelection
Definition: IDAlignMonResidualsAlg.h:82
IDAlignMonResidualsAlg.h
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
Trk::Layer::enclosingTrackingVolume
const TrackingVolume * enclosingTrackingVolume() const
get the confining TrackingVolume
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
IDAlignMonResidualsAlg::m_pixelID
const PixelID * m_pixelID
Definition: IDAlignMonResidualsAlg.h:71
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
IDAlignMonResidualsAlg::IDAlignMonResidualsAlg
IDAlignMonResidualsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: IDAlignMonResidualsAlg.cxx:47
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
IDAlignMonResidualsAlg::m_trtID
const TRT_ID * m_trtID
Definition: IDAlignMonResidualsAlg.h:73
IDAlignMonResidualsAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: IDAlignMonResidualsAlg.cxx:75
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
SCT_DetectorManager.h
IDAlignMonResidualsAlg::m_doPulls
bool m_doPulls
Definition: IDAlignMonResidualsAlg.h:90
IDAlignMonResidualsAlg::m_pixResidualXvsEta
std::vector< int > m_pixResidualXvsEta
Definition: IDAlignMonResidualsAlg.h:104
FitQuality.h
IDAlignMonResidualsAlg::m_nSCTEClayers
static const int m_nSCTEClayers
Definition: IDAlignMonResidualsAlg.h:95
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
IDAlignMonResidualsAlg::m_sctID
const SCT_ID * m_sctID
Definition: IDAlignMonResidualsAlg.h:72
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
IDAlignMonResidualsAlg::m_pixResidualY
std::vector< int > m_pixResidualY
Definition: IDAlignMonResidualsAlg.h:100
IDAlignMonResidualsAlg::m_pixResidualY_3D
std::vector< int > m_pixResidualY_3D
Definition: IDAlignMonResidualsAlg.h:101
readCCLHist.float
float
Definition: readCCLHist.py:83
xAOD::refitTrack
@ refitTrack
Definition: TrackingPrimitives.h:463
IDAlignMonResidualsAlg::m_idHelper
const AtlasDetectorID * m_idHelper
Definition: IDAlignMonResidualsAlg.h:68
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
IDAlignMonResidualsAlg::m_doHitQuality
bool m_doHitQuality
Definition: IDAlignMonResidualsAlg.h:88