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