ATLAS Offline Software
TrkMaterialProviderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <algorithm>
8 
9 // Interfaces
10 
16 #include "Identifier/Identifier.h"
18 
19 #include "muonEvent/CaloEnergy.h"
20 
21 // Amg::error
24 
25 // For measured energy loss
26 #include "CLHEP/Units/SystemOfUnits.h"
27 #include "MuidEvent/CaloMeas.h"
28 
29 // #define DEBUGON //To activate printout for TSOS lists at various stages
30 // for line-by-line debugging
31 #define MYDEBUG() std::cout<<__FILE__<<" "<<__func__<<" "<<__LINE__<<std::endl
32 
34 {
35  track.resetCaches();
36 }
37 
38 // constructor
39 Trk::TrkMaterialProviderTool::TrkMaterialProviderTool(const std::string& t, const std::string& n, const IInterface* p)
40  : AthAlgTool(t,n,p),
41  m_DetID(nullptr),
42  m_calorimeterVolume(nullptr),
43  m_indetVolume(nullptr),
44  m_maxNTracksIso(2),
45  m_paramPtCut(15.0*Gaudi::Units::GeV),
46  m_useCaloEnergyMeasurement(true),
47  m_useMuonCaloEnergyTool(true),
48  m_overwriteElossParam(false)
49 {
50  declareInterface<ITrkMaterialProviderTool>(this);
51 
52  declareProperty("ApplyTGScaling", m_applyTGScaling = true );
53  declareProperty("RpositionTSOS", m_repositionTSOS = true );
54  declareProperty("AggregateTSOS", m_aggregateTSOS = true );
55  declareProperty("UpdateTSOS", m_updateTSOS = true );
56  declareProperty("MaxNTracksIso", m_maxNTracksIso);
57  declareProperty("ParamPtCut", m_paramPtCut);
58  declareProperty("UseCaloEnergyMeasurement", m_useCaloEnergyMeasurement);
59  declareProperty("UseMuonCaloEnergyTool", m_useMuonCaloEnergyTool);
60 // this is a temporary solution to write Eloss information in the muon to validate the Eloss
61 // default value should be false
62  declareProperty("OverwriteElossParam", m_overwriteElossParam);
63 }
64 
65 // Athena standard methods
66 // initialize
69 {
70  ATH_CHECK(m_muonExtrapolator.retrieve());
71  ATH_CHECK(m_elossupdator.retrieve());
72  ATH_CHECK(m_scattool.retrieve());
73  if(m_useCaloEnergyMeasurement) {
74  ATH_CHECK(m_trackIsolationTool.retrieve());
75  if(m_useMuonCaloEnergyTool) {
76  ATH_CHECK(m_muonCaloEnergyTool.retrieve());
77  m_caloMeasTool.disable();
78  m_caloParamTool.disable();
79  }else{
80  ATH_CHECK(m_caloMeasTool.retrieve());
81  ATH_CHECK(m_caloParamTool.retrieve());
82  m_muonCaloEnergyTool.disable();
83  }
84  }
85  else{
86  m_caloMeasTool.disable();
87  m_caloParamTool.disable();
88  m_muonCaloEnergyTool.disable();
89  m_trackIsolationTool.disable();
90  }
91 
93  ATH_CHECK( m_fieldCacheCondObjInputKey.initialize() );
94 
95  // need an Atlas id-helper to identify sub-detectors, take the one from detStore
96  if (detStore()->retrieve(m_DetID, "AtlasID").isFailure()) {
97  ATH_MSG_ERROR ("Could not get AtlasDetectorID helper" );
98  return StatusCode::FAILURE;
99  }
100 
101  ATH_CHECK(m_trackingVolumesSvc.retrieve());
102 
103  m_calorimeterVolume = new Trk::Volume(m_trackingVolumesSvc->volume(Trk::ITrackingVolumesSvc::MuonSpectrometerEntryLayer));
104  if(!m_calorimeterVolume) {
105  ATH_MSG_ERROR("Unable to retrieve MuonSpectrometerEntryLayer volume");
106  return StatusCode::FAILURE;
107  }
108 
109  m_indetVolume = new Trk::Volume(m_trackingVolumesSvc->volume(Trk::ITrackingVolumesSvc::CalorimeterEntryLayer));
110  if(!m_indetVolume) {
111  ATH_MSG_ERROR("Unable to retrieve CalorimeterEntryLayer volume");
112  return StatusCode::FAILURE;
113  }
114 
115  if (m_trackingGeometryReadKey.key().empty()) {
116  ATH_CHECK(m_trackingGeometrySvc.retrieve());
117  } else
118  ATH_CHECK( m_trackingGeometryReadKey.initialize() );
119 
120  return StatusCode::SUCCESS;
121 }
122 
123 // finalize
126 {
127  ATH_MSG_DEBUG( name() << " finalize() successful" );
128  return StatusCode::SUCCESS;
129 }
130 
131 
132 // Update Calorimeter TSOS using TG
134 {
135  ATH_MSG_VERBOSE("updateCaloTSOS(Trk::Track& track, const Trk::TrackParameters* startParameters)");
136 
137  // back extrapolate to perigee, get pAtCaloEntry from list of TSOSs
138  // and update/add calo+ID material to mstrack to be refitted.
139  const Trk::TrackStates* inputTSOS_orig = track.trackStateOnSurfaces();
140 
141  auto inputTSOS = std::make_unique<Trk::TrackStates>();
142  for (const Trk::TrackStateOnSurface* tsos : *inputTSOS_orig) {
143  inputTSOS->push_back (tsos->clone());
144  }
145 
146  // Iterators
147  Trk::TrackStates::iterator lastIDwP = inputTSOS->end();
148  Trk::TrackStates::iterator firstCALO = inputTSOS->end();
149  Trk::TrackStates::iterator firstMS = inputTSOS->end();
150  Trk::TrackStates::iterator firstMSwP = inputTSOS->end();
151 
152  // find first MS TSOS (handling the case of TSOS w/o TP) and the last ID (or perigee)
153  Trk::TrackStates::iterator it = inputTSOS->begin();
154  Trk::TrackStates::iterator itEnd = inputTSOS->end();
155  for(; it!=itEnd; ++it) {
156 
157 #ifdef DEBUGON
158  printTSOS(*it, "TSOS ON TRACK");
159 #endif
160 
161  if(this->getVolumeByGeo(*it)==1 && (*it)->trackParameters())
162  lastIDwP = it;
163  if(firstCALO==inputTSOS->end() && this->getVolumeByGeo(*it)==2 && firstMS==itEnd)
164  firstCALO = it;
165  else if(this->getVolumeByGeo(*it)==3 && firstCALO!=inputTSOS->end()) {//&& !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
166  if(firstMS==itEnd)
167  firstMS = it;
168  if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
169  firstMSwP = it;
170  break;
171  }
172  }
173  }
174 
175  // if we have last ID TSOS from the list on track (i.e. combined muon) then use this as start parameters
176  if(lastIDwP != inputTSOS->end()) {
177 #ifdef DEBUGON
178  printTSOS(*lastIDwP, "LAST IDwP");
179 #endif
180  startParameters = (*lastIDwP)->trackParameters();
181  }
182 
183  if(lastIDwP == inputTSOS->end() && !startParameters) {
184  ATH_MSG_WARNING("Unable to find starting parameters for extrapolation");
185  ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
186  return;
187  }
188  if(firstCALO == inputTSOS->end()) {
189  ATH_MSG_DEBUG("Track without CALO TSOS!");
190  firstCALO = firstMS;
191  }
192  if(firstMS == inputTSOS->end()) {
193  ATH_MSG_WARNING("Unable to find first MS TSOS");
194  ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
195  return;
196  }
197 
198  // check that first MS TSOS is not a PerigeeSurface
199  //bool removeOoC = false;
200  Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
201  if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS->end()) {
202  firstMSnotPerigee=firstMS+1;
203  //removeOoC = true;
204  }
205 
206 #ifdef DEBUGON
207  printTSOS(*firstCALO, "FIRST CALO");
208  printTSOS(*firstMSnotPerigee, "FIRST MS");
209 #endif
210  double Eloss = 0.;
211  double X0ScaleMS = 0.;
212  double ElossScaleMS = 0.;
213  // get calorimeter TSOS from TG extrapolating from last ID to MS
214  Trk::TrackStates* caloTSOS = this->getCaloTSOS (*startParameters,
215  track,
216  (*firstMSnotPerigee)->surface(),
218  Trk::muon,
219  Eloss, X0ScaleMS, ElossScaleMS,
220  (firstMSwP == inputTSOS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
221  false,
222  true);
223 
224  if(!caloTSOS || caloTSOS->size()!=3) {
225  ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM (null or <3)");
226  if(caloTSOS) deleteTSOS(caloTSOS);
227  return;
228  }
229 
230 #ifdef DEBUGON
231  ATH_MSG_VERBOSE("OLD TSOS multiplicity : " << inputTSOS->size());
232  for(auto m : *inputTSOS) this->printTSOS(m, "OLD TSOS");
233 #endif
234 
235  // apply X0 and Eloss scale to MuonSpectrometer
236  this->updateVectorMS(inputTSOS.get(),firstMS,X0ScaleMS,ElossScaleMS);
237  // update the original vector
238  Trk::TrkMaterialProviderTool::updateVector(inputTSOS.get(), firstCALO, firstMS, caloTSOS);
239  track.setTrackStateOnSurfaces (std::move (inputTSOS));
241 }
242 
243 
244 // Update Calorimeter TSOS using TG for the combined fit
245 void Trk::TrkMaterialProviderTool::updateCaloTSOS(const Trk::Track& idTrack, Trk::Track& extrapolatedTrack) const
246 {
247  ATH_MSG_VERBOSE("updateCaloTSOS(Trk::Track& idTrack, Trk::Track& extrapolatedTrack)");
248 
249  const Trk::TrackStates* inputTSOS_ID = idTrack.trackStateOnSurfaces();
250  const Trk::TrackStates* inputTSOS_MS_orig = extrapolatedTrack.trackStateOnSurfaces();
251 
252  auto inputTSOS_MS = std::make_unique<Trk::TrackStates>();
253  for (const Trk::TrackStateOnSurface* tsos : *inputTSOS_MS_orig) {
254  inputTSOS_MS->push_back (tsos->clone());
255  }
256 
257 
258  // find last ID TSOS
259  Trk::TrackStates::const_iterator lastIDwP = inputTSOS_ID->end();
260  Trk::TrackStates::const_iterator itID = inputTSOS_ID->end()-1;
261  Trk::TrackStates::const_iterator itFront = inputTSOS_ID->begin();
262  while(*itID) {
263  if(this->getVolumeByGeo(*itID)==1 && (*itID)->trackParameters()) {
264  lastIDwP = itID;
265  break;
266  }
267  if(itID==itFront) break;
268  --itID;
269  }
270 
271  // find first MS TSOS
272  Trk::TrackStates::iterator firstCALO = inputTSOS_MS->end();
273  Trk::TrackStates::iterator firstMS = inputTSOS_MS->end();
274  Trk::TrackStates::iterator firstMSwP = inputTSOS_MS->end();
275  Trk::TrackStates::iterator itEnd = inputTSOS_MS->end();
276  Trk::TrackStates::iterator it = inputTSOS_MS->begin();
277  for(; it!=itEnd; ++it) {
278 
279 #ifdef DEBUGON
280  printTSOS(*it, "TSOS ON TRACK");
281 #endif
282 
283  if(firstCALO==inputTSOS_MS->end() && this->getVolumeByGeo(*it)==2)
284  firstCALO = it;
285  if(this->getVolumeByGeo(*it)==3) {// && !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
286  if(firstMS==itEnd)
287  firstMS = it;
288  if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
289  firstMSwP = it;
290  break;
291  }
292  }
293  }
294 
295  if(firstCALO == inputTSOS_MS->end()) {
296  ATH_MSG_DEBUG("Track without CALO TSOS!");
297  firstCALO = firstMS;
298  }
299  if(lastIDwP == inputTSOS_ID->end()) {
300  ATH_MSG_WARNING("Unable to find last ID TSOS with Track Parameters");
301  ATH_MSG_WARNING("Unable to update Calorimeter TSOS" );
302  return;
303  }
304  if(firstMS == inputTSOS_MS->end()) {
305  ATH_MSG_WARNING("Unable to find first MS TSOS!");
306  ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
307  return;
308  }
309 
310  // check that first MS TSOS is not a PerigeeSurface
311  //bool removeOoC = false;
312  Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
313  if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS_MS->end()) {
314  firstMSnotPerigee=firstMS+1;
315  //removeOoC = true;
316  }
317 
318 #ifdef DEBUGON
319  printTSOS(*lastIDwP, "LAST IDwP");
320  printTSOS(*firstCALO, "FIRST CALO");
321  printTSOS(*firstMSnotPerigee, "FIRST MS");
322  if(firstMSwP != inputTSOS_MS->end())
323  printTSOS(*firstMSwP, "FIRST MSwP");
324  else
325  ATH_MSG_WARNING("Unable to find first MS TSOS with Track Parameters");
326 #endif
327  double Eloss = 0.;
328  double X0ScaleMS = 0.;
329  double ElossScaleMS = 0.;
330  // get calorimeter TSOS from TG
331  Trk::TrackStates* caloTSOS = this->getCaloTSOS (*(*lastIDwP)->trackParameters(),
332  extrapolatedTrack,
333  (*firstMSnotPerigee)->surface(),
335  Trk::muon,
336  Eloss, X0ScaleMS, ElossScaleMS,
337  (firstMSwP == inputTSOS_MS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
338  false,
339  true);
340 
341 
342  if(!caloTSOS || caloTSOS->size()!=3) {
343  ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM (null or <3)");
344  if(caloTSOS) deleteTSOS(caloTSOS);
345  return;
346  }
347 
348 #ifdef DEBUGON
349  ATH_MSG_VERBOSE("ID TSOS multiplicity : " << inputTSOS_ID->size());
350  for(auto m : *inputTSOS_ID) printTSOS(m, "ID TSOS");
351  ATH_MSG_VERBOSE("OLD-MS TSOS multiplicity : " << inputTSOS_MS->size());
352  for(auto m : *inputTSOS_MS) printTSOS(m, "OLD-MS TSOS");
353 #endif
354 
355  // apply X0 and Eloss scale to MuonSpectrometer
356  this->updateVectorMS(inputTSOS_MS.get(),firstMS,X0ScaleMS,ElossScaleMS);
357  // update the original vector
358  Trk::TrkMaterialProviderTool::updateVector(inputTSOS_MS.get(), firstCALO, firstMS, caloTSOS);
359 
360  extrapolatedTrack.setTrackStateOnSurfaces (std::move (inputTSOS_MS));
361  myLocal_resetTrack(extrapolatedTrack);
362 }
363 
364 
365 
366 // Get Calorimeter MEOT using TG for the combined fit
368  std::vector<MaterialEffectsOnTrack>& calomeots) const
369 {
370  ATH_MSG_VERBOSE("getCaloMEOT(const Trk::Track& idTrack, const Trk::Track& msTrack, std::vector<MaterialEffectsOnTrack>& calomeots)");
371 
372  const Trk::TrackStates* inputTSOS_ID = idTrack.trackStateOnSurfaces();
373  const Trk::TrackStates* inputTSOS_MS = msTrack.trackStateOnSurfaces();
374 
375 #ifdef DEBUGON
376  for(auto m : *inputTSOS_ID) printTSOS(m, "TSOS ID TRACK");
377  for(auto m : *inputTSOS_MS) printTSOS(m, "TSOS MS TRACK");
378 #endif
379 
380  // find last ID TSOS
381  Trk::TrackStates::const_reverse_iterator lastIDwP = inputTSOS_ID->rbegin();
382  for (auto it = inputTSOS_ID->rbegin(); it != inputTSOS_ID->rend(); ++it) {
383  if(this->getVolumeByGeo(*it)==1 && (*it)->trackParameters()) {
384  lastIDwP = it;
385  break;
386  }
387  }
388 
389  if(lastIDwP == inputTSOS_ID->rend()) {
390  ATH_MSG_WARNING("Unable to find last ID TSOS with Track Parameters");
391  ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
392  return;
393  }
394 
395  // find first MS TSOS
396  Trk::TrackStates::const_iterator firstMS = inputTSOS_MS->end();
397  Trk::TrackStates::const_iterator firstMSwP = inputTSOS_MS->end();
398  Trk::TrackStates::const_iterator itEnd = inputTSOS_MS->end();
399  for(auto it = inputTSOS_MS->begin(); it!=itEnd ; ++it) {
400  if(this->getVolumeByGeo(*it)==3) {// && !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
401  if(firstMS==itEnd)
402  firstMS = it;
403  if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
404  firstMSwP = it;
405  break;
406  }
407  }
408  }
409 
410  if(firstMS == inputTSOS_MS->end()) {
411  ATH_MSG_WARNING("Unable to find first MS TSOS");
412  ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
413  return;
414  }
415 
416  // check that first MS TSOS is not a PerigeeSurface
417  Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
418  if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS_MS->end()) {
419  firstMSnotPerigee=firstMS+1;
420  }
421 
422 #ifdef DEBUGON
423  printTSOS(*lastIDwP, "LAST IDwP");
424  printTSOS(*firstMSnotPerigee, "FIRST MS");
425  if(firstMSwP != inputTSOS_MS->end())
426  printTSOS(*firstMSwP, "FIRST MSwP");
427  else
428  ATH_MSG_WARNING("Unable to find first MS TSOS with Track Parameters!");
429 #endif
430 
431  MagField::AtlasFieldCache fieldCache;
432  // Get field cache object
433  const EventContext& ctx = Gaudi::Hive::currentContext();
434  SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx};
435  const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
436 
437  if (fieldCondObj == nullptr) {
438  ATH_MSG_ERROR("Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key());
439  return;
440  }
441  fieldCondObj->getInitializedCache (fieldCache);
442 
443  double Eloss = 0.;
444  double X0ScaleMS = 0.;
445  double ElossScaleMS = 0.;
446  // get calorimeter TSOS from TG
447  Trk::TrackStates* caloTSOS = this->getCaloTSOS (*(*lastIDwP)->trackParameters(),
448  // idTrack,
449  fieldCache.toroidOn() ? msTrack : idTrack,
450  (*firstMSnotPerigee)->surface(),
452  Trk::muon,
453  Eloss, X0ScaleMS, ElossScaleMS,
454  (firstMSwP == inputTSOS_MS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
455  false,
456  true);
457 
458  if (!caloTSOS || caloTSOS->size() != 3)
459  {
460  double idqOverP = std::abs(idTrack.perigeeParameters()->parameters()[Trk::qOverP]);
461  double msqOverP = msTrack.perigeeParameters() ? msTrack.perigeeParameters()->parameters()[Trk::qOverP] : (*firstMS)->trackParameters()->parameters()[Trk::qOverP] ;
462 
463  if ((!fieldCache.toroidOn() && idqOverP * 4000. < 1) || (fieldCache.toroidOn() && msqOverP != 1 / 100000. && msqOverP != 0))
464  {
465  // Warnings only for high momentum ID tracks and MS tracks that have measured curvature (Straight track has pq= 100000)
466  if (!fieldCache.toroidOn())
467  ATH_MSG_WARNING(" Toroid off q*momentum of ID track " << 1. / idqOverP);
468  if (fieldCache.toroidOn())
469  ATH_MSG_WARNING(" Toroid on q*momentum of MS track " << 1. / msqOverP);
470  ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM+aggregation (null or !=3)");
471  if (!caloTSOS) {
472  ATH_MSG_WARNING(" Zero Calorimeter TSOS from extrapolateM+aggregation");
473  } else {
474  ATH_MSG_WARNING(" nr Calorimeter TSOS from extrapolateM+aggregation not equal to 3 " << caloTSOS->size());
475  }
476  }
477 
478  if (caloTSOS) deleteTSOS(caloTSOS);
479 
480  return;
481  }
482 
483  for (auto && i : *caloTSOS){
484  const Trk::MaterialEffectsOnTrack *meot=dynamic_cast<const Trk::MaterialEffectsOnTrack *>(i->materialEffectsOnTrack());
485  if (!meot) {
486  throw std::logic_error("TrackStateOnSurface without material effects on track." );
487  }
488  double sintheta=std::sin(i->trackParameters()->parameters()[Trk::theta]);
489  double qoverp=i->trackParameters()->parameters()[Trk::qOverP];
490  const CaloEnergy *eloss=nullptr;
491  if (meot) eloss=dynamic_cast<const CaloEnergy *>(meot->energyLoss());
492 
493  std::unique_ptr<Trk::EnergyLoss> neweloss=nullptr;
494  std::optional<Trk::ScatteringAngles> newsa= std::nullopt;
495  if (eloss) neweloss = std::make_unique<CaloEnergy>(*eloss);
496  else{
497  Trk::MaterialProperties matprop(meot->thicknessInX0(),1.,0.,0.,0.,0.);
498  double sigmascat = std::abs(qoverp)>0.0 ? std::sqrt(m_scattool->sigmaSquare(matprop,std::abs(1./qoverp),1.,Trk::muon)) : 0.0;
499  newsa=Trk::ScatteringAngles(0,0,sigmascat/sintheta,sigmascat);
500  }
502  meot->thicknessInX0(),
503  newsa,
504  std::move(neweloss),
505  i->trackParameters()->associatedSurface());
506  calomeots.push_back(newmeot);
507  delete i;
508  }
509  delete caloTSOS;
510 }
511 
512 
513 
514 // Get Calorimeter TSOS from TG (extrapolateM)
515 std::vector<const Trk::TrackStateOnSurface*>*
517  const Trk::TrackParameters* parms) const
518 {
519  std::vector<const Trk::TrackStateOnSurface*>* caloTSOS = new std::vector<const Trk::TrackStateOnSurface*>();
520  const Trk::TrackingVolume* targetVolume;
522  const EventContext& ctx = Gaudi::Hive::currentContext();
523 
524  const Trk::TrackingGeometry* trackingGeometry = retrieveTrackingGeometry( ctx );
525  if(!trackingGeometry) {
526  ATH_MSG_WARNING("Unable to retrieve tracking geometry");
527  return caloTSOS;
528  }
529 
530  // check if parm is expressed at ID or MS and set extrapolation direction and target volume
531  // ID
532  if( m_indetVolume->inside(parm.position()) ) {
534  targetVolume = trackingGeometry->trackingVolume("MuonSpectrometerEntrance");
535  if(!targetVolume) {
536  ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
537  return caloTSOS;
538  }
539  ATH_MSG_VERBOSE("TP inside ID -> extrapolating TP "<<parm<<" to MS entry volume "<<*targetVolume);
540  }
541  // MS
542  else if( !m_calorimeterVolume->inside(parm.position()) ) {
544  targetVolume = trackingGeometry->trackingVolume("InDet::Containers::InnerDetector");
545  if(!targetVolume) {
546  ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
547  return caloTSOS;
548  }
549  ATH_MSG_VERBOSE("TP inside MS -> extrapolating TP "<<parm<<" to ID exit volume "<<*targetVolume);
550  }
551  // CALO, it happens when called leadingTSOS from MS, backward extrapolation ok
552  else{
554  targetVolume = trackingGeometry->trackingVolume("InDet::Containers::InnerDetector");
555  if(!targetVolume) {
556  ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
557  return caloTSOS;
558  }
559  ATH_MSG_DEBUG("TP inside CALO or between CALO and MS -> assuming ID as target : "<<*targetVolume);
560  }
561 
562  // When doing backward extrapolation the starting TP are defined at MS entrance
563  // so we use them to get the MS momentum error needed later on when doing TSOS aggregation
564  if(!parms) {
565  if(dir == Trk::oppositeMomentum && parm.covariance())
566  parms = &parm;
567  else{
570  for(; it!=itEnd; ++it) {
571  if(this->getVolumeByGeo(*it)==3) //&& !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
572  if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
573  parms = (*it)->trackParameters();
574  break;
575  }
576  }
577  }
578  }
579 
580  if(dir == Trk::oppositeMomentum) {
581 //
582 // go to Beam line
583 //
584  Amg::Vector3D globPos(0.,0.,0.);
585  PerigeeSurface surface(globPos);
586  double Eloss = 0.;
587  double X0ScaleMS = 0.;
588  double ElossScaleMS = 0.;
589  // Collect calorimeter TSOS
590  Trk::TrackStates* caloTSOSdv = this->getCaloTSOS (parm,
591  muonTrack,
592  surface,
593  dir,
594  Trk::muon,
595  Eloss, X0ScaleMS, ElossScaleMS,
596  parms,
597  true,
598  false); // remove only MS TSOS and keep ID+CALO
599 
600  if(parms) ATH_MSG_DEBUG(" go to Beam Line parms position radius " << parms->position().perp() << " z " << parms->position().z());
601  ATH_MSG_DEBUG(" go to Beam Line destination surface position radius " << surface.center().perp() << " z " << surface.center().z());
602 
603  if(caloTSOSdv) {
604  for(unsigned int i=0; i<caloTSOSdv->size(); ++i)
605  caloTSOS->push_back(caloTSOSdv->get(i));
606  delete caloTSOSdv;
607  }
608  return caloTSOS;
609 
610  }
611 
612  // get boundary surfaces of the target volume
613  auto boundaryIntersections = targetVolume->boundarySurfacesOrdered<Trk::TrackParameters>(parm,dir,false);
614 
615  // loop over surfaces
616  double Eloss_previous = 0.;
617  for (auto& boundaryCandidate : boundaryIntersections){
618 
619  // get the surface object at the boundary
620  const Trk::BoundarySurface<Trk::TrackingVolume>* surfaceTV = boundaryCandidate.object;
621  if(!surfaceTV) continue;
622 
623  // get the Trk::Surface
624  const Trk::Surface& surface = surfaceTV->surfaceRepresentation();
625  double Eloss = 0.;
626  double X0ScaleMS = 0.;
627  double ElossScaleMS = 0.;
628  // Collect calorimeter TSOS
629  Trk::TrackStates* caloTSOSdv = this->getCaloTSOS (parm,
630  muonTrack,
631  surface,
632  dir,
633  Trk::muon,
634  Eloss, X0ScaleMS, ElossScaleMS,
635  parms,
636  true,
637  true);
638  // hack to convert DataVector to stl vector and delete the DataVector ...
639  if(caloTSOSdv&&Eloss>Eloss_previous) {
640 //
641 // keep the TSOS vector with the largest Eloss
642 // only one of the surfaces gives the rights intersection
643 // partial crossing with a plane or a cylinder give less Eloss
644 //
645  ATH_MSG_DEBUG(" getCaloTSOS: Previous solution had Eloss " << Eloss_previous << " latest " << Eloss);
646  if(parms) ATH_MSG_DEBUG(" parms position radius " << parms->position().perp() << " z " << parms->position().z());
647  ATH_MSG_DEBUG(" destination surface position radius " << surface.center().perp() << " z " << surface.center().z());
648 
649  for(unsigned int i=0; i<caloTSOSdv->size(); ++i)
650  caloTSOS->push_back(caloTSOSdv->get(i));
651  delete caloTSOSdv;
652  return caloTSOS;
653  }
654  }
655 
656 
657  return caloTSOS;
658 }
659 
660 
661 
662 // Get Calorimeter TSOS from TG (extrapolateM)
665  const Trk::Track& muonTrack,
666  const Trk::Surface& surf,
668  Trk::ParticleHypothesis mateffects,
669  double& Eloss,
670  double& X0ScaleMS,
671  double& ElossScaleMS,
672  const Trk::TrackParameters* parms,
673  bool boundaryCheck,
674  bool removeOoC) const
675 {
676  const EventContext& ctx = Gaudi::Hive::currentContext();
677  bool fremoveMS = false;
678  if(!removeOoC) fremoveMS = true;
679 
680  ATH_MSG_DEBUG("Retrieving Calorimeter TSOS from extrapolateM (dir=" << dir << ") with starting parameters : "
681  << parm << " to surface "<<surf);
682  if(parms) ATH_MSG_DEBUG("Parameters in MS provided : "<< *parms);
683 
684  double pOri = parm.momentum().mag();
685 
686  // Get TSOS from extrapolateM (from TG)
687  std::vector<const Trk::TrackStateOnSurface*>* caloTSOS = m_muonExtrapolator->extrapolateM(ctx,
688  parm,
689  surf, dir,
690  boundaryCheck,
691  mateffects);
692 
693  ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM, no-removal");
694 
695 #ifdef DEBUGON
696  ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM, no-removal");
697  for(auto m : *caloTSOS) this->printTSOS(m, "BEFORE-REMOVAL CALO TSOS");
698 #endif
699 
700 
701  Eloss = 0.;
702  double ElossID = 0.;
703  double ElossCalo = 0.;
704  double ElossMS = 0.;
705  for(const auto *m : *caloTSOS) {
706  if(m->materialEffectsOnTrack()) {
707  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
708  if(meot) {
709  const Trk::EnergyLoss* energyLoss = meot->energyLoss();
710  if (energyLoss) {
711  ATH_MSG_DEBUG(" volume " << this->getVolumeByGeo(m) << " Eloss from extrapolateM TG " << energyLoss->deltaE());
712 
713  Eloss += std::abs(energyLoss->deltaE());
714  if(this->getVolumeByGeo(m)==1) ElossID += std::abs(energyLoss->deltaE());
715  if(this->getVolumeByGeo(m)==2) ElossCalo += std::abs(energyLoss->deltaE());
716  if(this->getVolumeByGeo(m)==3) ElossMS += std::abs(energyLoss->deltaE());
717  }
718  }
719  }
720  }
721 
722  ATH_MSG_DEBUG("Total Eloss on TSOS from extrapolateM " << Eloss << " ElossID " << ElossID << " ElossMS " << ElossMS <<" Elosscalo " << ElossCalo);
723  if(fremoveMS) ATH_MSG_DEBUG(" ID Eloss will be added to Calo Eloss " << ElossID+ElossCalo);
724 
725  Eloss = ElossCalo;
726 
727 // remove ID and MS TSOSs
728  if(removeOoC && !caloTSOS->empty()) removeOutOfCalo(caloTSOS);
729  ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM");
730 // remove MS TSOSs
731  if(fremoveMS && !caloTSOS->empty()) removeMS(caloTSOS);
732  ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM");
733 
734 #ifdef DEBUGON
735  for(auto m : *caloTSOS) this->printTSOS(m, "ORIGINAL CALO TSOS");
736 #endif
737 
738 
739  Trk::TrackStates* finalCaloTSOS = nullptr;
740  if(caloTSOS->empty() || Eloss<=0) {
741  if(dir==Trk::alongMomentum&&pOri>4000.) {
742  ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM caloTSOS->size() "<< caloTSOS->size() << " Eloss " << Eloss );
743  ATH_MSG_WARNING(" momentum of track " << pOri);
744  ATH_MSG_WARNING(" momentum extrapolated of track " << parm.momentum().mag() << " radius " << parm.position().perp() << " z " << parm.position().z() );
745  ATH_MSG_WARNING(" surface radius " << surf.center().perp() << " z " << surf.center().z() );
746  if(parms) ATH_MSG_WARNING(" momentum of MS track " << parms->momentum().mag());
747  } // else track did not have enough momentum
748  deleteTSOS(caloTSOS);
749  return finalCaloTSOS;
750  }
751 
752  // Apply TG scaling to G4
753  double X0ScaleCALO=1.0;
754  double ElossScaleCALO=1.0;
755  X0ScaleMS=1.0;
756  ElossScaleMS=1.0;
757  const Trk::TrackStateOnSurface* tsosAtCaloExit = this->getCaloExitTSOS(caloTSOS, dir);
758  if(m_applyTGScaling) {
759  if(!tsosAtCaloExit) {
760  ATH_MSG_WARNING( name() << " Unable to find Calorimeter Exit TSOS with TrackParameters! No TG Scaling applied!" );
761  }else{
762  m_elossupdator->getX0ElossScales(1,
763  -log(tan(tsosAtCaloExit->trackParameters()->position().theta()/2)),
764  tsosAtCaloExit->trackParameters()->position().phi(),
765  X0ScaleCALO, ElossScaleCALO);
766  m_elossupdator->getX0ElossScales(0,
767  -log(tan(tsosAtCaloExit->trackParameters()->position().theta()/2)),
768  tsosAtCaloExit->trackParameters()->position().phi(),
769  X0ScaleMS, ElossScaleMS);
770  }
771  }
772  ATH_MSG_DEBUG("Eloss/X0 scaling corrections set to : " << ElossScaleCALO << " " << X0ScaleCALO);
773 
774  // Get momentum at calorimeter entrance
775  // Note that for SA fit i'm taking the pAtCaloEntry from the perigee parameters
776  double pAtCaloEntry = 0;
777  if(dir == Trk::alongMomentum) {
778  double OneOverP = std::abs(parm.parameters()[Trk::qOverP]);
779  if (OneOverP > 0.0)
780  pAtCaloEntry = 1./OneOverP;
781  else
782  pAtCaloEntry = parm.momentum().norm();
783  }else{
784  const Trk::TrackStateOnSurface* tsosAtCaloEntry = this->getCaloEntryTSOS(caloTSOS, dir);
785  if(!tsosAtCaloEntry) {
786  ATH_MSG_WARNING( name() << " Unable to find Calorimeter Entry TSOS with TrackParameters! Momentum at Calo Entry not available!" );
787  }else{
788  double OneOverP = std::abs(tsosAtCaloEntry->trackParameters()->parameters()[Trk::qOverP]);
789  if (OneOverP > 0.0)
790  pAtCaloEntry = 1./OneOverP;
791  else
792  pAtCaloEntry = tsosAtCaloEntry->trackParameters()->momentum().norm();
793  }
794  }
795 
796  ATH_MSG_DEBUG("Momentum at Calo Entry : " << pAtCaloEntry );
797 
798  // If parameters at MS are not provided then try to get them out of extrapolated Calo TSOSs (likely w/o covariance!)
799  if(!parms) {
800  if(!tsosAtCaloExit) {
801  ATH_MSG_DEBUG("Unable to find Calorimeter Exit TSOS with TrackParameters! Momentum at MS not available!" );
802  }else{
803  parms = tsosAtCaloExit->trackParameters();
804  ATH_MSG_DEBUG("MS track parameters taken from calorimeter TSOS");
805  }
806  }
807 
808  // Get momentum error in muon spectrometer
809  double pAtMuonEntryError = 0.0;
810  if(parms) {
811  if( std::abs(parms->parameters()[Trk::qOverP]) > 0.0 ) {
812  double pAtMuonEntry = std::abs(1./parms->parameters()[Trk::qOverP]);
813  if (!parms->covariance() ||
814  !Amg::hasPositiveDiagElems(*parms->covariance())) {
816  "MS track parameters without covariance, using 10% relative error!");
817  pAtMuonEntryError = pAtMuonEntry*0.1;
818  } else {
819  double qOverpAtMuonEntryError = Amg::error(*parms->covariance(),Trk::qOverP);
820  pAtMuonEntryError = pAtMuonEntry*pAtMuonEntry*qOverpAtMuonEntryError;
821  }
822  }
823  }
824 
825  ATH_MSG_DEBUG("Momentum Error at MS Entry : " << pAtMuonEntryError);
826 
827  // Get calorimeter measured energy for pT>m_paramPtCut (15 GeV)
828  double measCaloEnergy = 0.0;
829  double measCaloEnergyError = 0.0;
830  double fsrCaloEnergy = 0.0;
831  double eta = -log(tan(parm.parameters()[Trk::theta]/2));
832  double phi = parm.parameters()[Trk::phi0];
833  double totalEloss=0.0;
834  double meanElossIoni=0.0;
835  double sigmaElossIoni=0.0;
836  if(m_useCaloEnergyMeasurement) {
837 
838  // Get Mop and Mean (ionization) energy loss from TG after scaling
839  double e_exp=0.0;
840  this->getMopAndIoniEnergyLoss(caloTSOS,
841  pAtCaloEntry,
842  ElossScaleCALO,
843  totalEloss,
844  meanElossIoni,
845  sigmaElossIoni);
846 
847  double E_em_meas = 0.;
848  double E_em_exp = 0.;
849  double E_tile_meas = 0.;
850  double E_tile_exp = 0.;
851  double E_HEC_meas = 0.;
852  double E_HEC_exp = 0.;
853  double E_dead_exp = 0.;
854 
855  // Get measured energy in calorimeter (run2 tool)
856  if(m_useMuonCaloEnergyTool) {
857 //
858 // sigmaElossIoni should be scaled by 0.45 to go to Landau this is later done in updateEloss
859 //
860  if(muonTrack.trackParameters() && !muonTrack.trackParameters()->empty())
861  m_muonCaloEnergyTool->calculateMuonEnergies( &muonTrack,
862  totalEloss, meanElossIoni, 0.45*sigmaElossIoni,
863  measCaloEnergy, measCaloEnergyError, fsrCaloEnergy, e_exp,
864  E_em_meas,E_em_exp,E_tile_meas,E_tile_exp,E_HEC_meas,E_HEC_exp,E_dead_exp);
865 
866 
867  ATH_MSG_DEBUG(" eta " << eta << " Energy measurement from calorimeter: inputs totalEloss, meanElossIoni, sigmaElossIoni "
868  << totalEloss << " " << meanElossIoni << " " << sigmaElossIoni << " e_exp Ioni from TG " << e_exp << " e_exp original " << e_exp*totalEloss/(meanElossIoni+0.001));
869 
870  }
871  // (run1 tool) used for debugging purposes
872  else{
873  measCaloEnergy = this->getCaloMeasuredEnergy(eta,phi,
874  totalEloss,
875  meanElossIoni,
876  fsrCaloEnergy);
877  measCaloEnergyError = 0.50 * sqrt(measCaloEnergy/CLHEP::GeV) * CLHEP::GeV;
878  }
879 
880  ATH_MSG_DEBUG("Final measured energy in calorimeter : " << measCaloEnergy << " +- " << measCaloEnergyError << " MeV"
881  << " momentum fraction " << measCaloEnergy/pAtCaloEntry);
882  }
883 
884  // Check if we can use the measured eloss in the fit
885  bool useMeasuredEnergy = m_useCaloEnergyMeasurement;
886  if(pAtCaloEntry*sin(parm.parameters()[Trk::theta]) < m_paramPtCut) useMeasuredEnergy = false;
887  if(useMeasuredEnergy && !isIsolatedTrack(eta,phi)) useMeasuredEnergy = false;
888 
889  // Total eloss
890  double Eloss_tot=0.0;
891 
892  // Aggregate TSOS, applying scaling corrections (if available) and mean-to-mop correction (cloning!)
893  // This function checks if the measured energy loss has to be used assuming the track is isolated.
894  // Need to check for isolation before and pass 0 values for not-isolated tracks.
895  finalCaloTSOS = modifyTSOSvector(caloTSOS, X0ScaleCALO, ElossScaleCALO,
896  m_repositionTSOS, m_aggregateTSOS, m_updateTSOS,
897  measCaloEnergy, measCaloEnergyError, fsrCaloEnergy,
898  pAtCaloEntry, pAtMuonEntryError,
899  Eloss_tot, useMeasuredEnergy,
900  totalEloss, meanElossIoni, sigmaElossIoni);
901 
902  ATH_MSG_DEBUG( " after modifyTSOSvector X0ScaleCALO " << X0ScaleCALO << " ElossScaleCALO " << ElossScaleCALO <<
903  " pAtCaloEntry " << pAtCaloEntry << " pAtMuonEntryError " << pAtMuonEntryError << " total Eloss from TG through MuonEnergyTool " << Eloss_tot );
904  ATH_MSG_DEBUG("Aggregating and correcting TSOS down to : " << finalCaloTSOS->size() << " with total Eloss " << Eloss_tot);
905 
906 #ifdef DEBUGON
907  ATH_MSG_VERBOSE("FINAL CALO TSOS multiplicity : " << finalCaloTSOS->size());
908  for(auto m : *finalCaloTSOS) this->printTSOS(m, "FINAL CALO TSOS");
909 #endif
910 
911  // delete tsos from extrapolator
912  deleteTSOS(caloTSOS);
913 
914  return finalCaloTSOS;
915 }
916 
918 {
919  for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
920  if(tsos->materialEffectsOnTrack()) {
921  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(tsos->materialEffectsOnTrack());
922  if(meot) {
923  const Trk::EnergyLoss* energyLoss = meot->energyLoss();
924  if (energyLoss) {
925  const CaloEnergy* caloEnergy = dynamic_cast<const CaloEnergy*>(meot->energyLoss());
926  if(caloEnergy) {
927  if(caloEnergy->energyLossType()==CaloEnergy::Tail) {
928  CaloEnergy* paramCaloEnergy = new CaloEnergy(caloEnergy->deltaEParam(),
929  0.5*(caloEnergy->sigmaMinusDeltaEParam()+caloEnergy->sigmaPlusDeltaEParam()),
930  caloEnergy->sigmaMinusDeltaEParam(),
931  caloEnergy->sigmaPlusDeltaEParam(),
933  caloEnergy->caloLRLikelihood(),
934  caloEnergy->caloMuonIdTag());
935  paramCaloEnergy->set_measEnergyLoss(caloEnergy->deltaEMeas(), caloEnergy->sigmaDeltaEMeas());
936  paramCaloEnergy->set_paramEnergyLoss(caloEnergy->deltaEParam(), caloEnergy->sigmaMinusDeltaEParam(), caloEnergy->sigmaPlusDeltaEParam());
937  return paramCaloEnergy;
938  }
939  return caloEnergy->clone();
940  }
941  }
942  }
943  }
944  }
945  return (CaloEnergy*)nullptr;
946 }
947 
948 
950 
952 const Trk::TrackStateOnSurface* Trk::TrkMaterialProviderTool::getCaloExitTSOS(const std::vector<const Trk::TrackStateOnSurface*>* caloTSOS, Trk::PropDirection dir) const
953 {
954  const Trk::TrackStateOnSurface* tsosAtCaloExit = nullptr;
955  if(dir==Trk::alongMomentum) {
956  std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator it = caloTSOS->rbegin();
957  std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator itEnd = caloTSOS->rend();
958  for(; it!=itEnd; ++it) {
959  if((*it)->trackParameters()) {
960  ATH_MSG_DEBUG("Parameters at CALO exit found : "<< *((*it)->trackParameters()));
961  tsosAtCaloExit = *it;
962  return tsosAtCaloExit;
963  }
964  }
965  }else{
966  std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = caloTSOS->begin();
967  std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = caloTSOS->end();
968  for(; it!=itEnd; ++it) {
969  if((*it)->trackParameters()) {
970  ATH_MSG_DEBUG("Parameters at CALO exit found : "<< *((*it)->trackParameters()));
971  tsosAtCaloExit = *it;
972  return tsosAtCaloExit;
973  }
974  }
975  }
976  return tsosAtCaloExit;
977 }
978 
979 
981 const Trk::TrackStateOnSurface* Trk::TrkMaterialProviderTool::getCaloEntryTSOS(const std::vector<const Trk::TrackStateOnSurface*>* caloTSOS, Trk::PropDirection dir) const
982 {
983  const Trk::TrackStateOnSurface* tsosAtCaloEntry = nullptr;
984  if(dir==Trk::alongMomentum) {
985  std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = caloTSOS->begin();
986  std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = caloTSOS->end();
987  for(; it!=itEnd; ++it) {
988  if((*it)->trackParameters()) {
989  ATH_MSG_DEBUG("Parameters at CALO entry found : "<< *((*it)->trackParameters()));
990  tsosAtCaloEntry = *it;
991  return tsosAtCaloEntry;
992  }
993  }
994  }else{
995  std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator it = caloTSOS->rbegin();
996  std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator itEnd = caloTSOS->rend();
997  for(; it!=itEnd; ++it) {
998  if((*it)->trackParameters()) {
999  ATH_MSG_DEBUG("Parameters at CALO entry found : "<< *((*it)->trackParameters()));
1000  tsosAtCaloEntry = *it;
1001  return tsosAtCaloEntry;
1002  }
1003  }
1004  }
1005  return tsosAtCaloEntry;
1006 }
1007 
1008 
1010 void Trk::TrkMaterialProviderTool::removeOutOfCalo(std::vector<const Trk::TrackStateOnSurface*>* caloTSOS) const
1011 {
1012  // remove all track states on surface with getVolumeByGeo(state)!=2 ( ID = 1 Calo = 2 MS = 3)
1013  // and group all other track states at the beginning of the vector.
1014  // finally erase from the vector all track state pointer of the
1015  // deleted objects, which are after remove_if at the end of the vector.
1016  const TrkMaterialProviderTool *this_=this;
1017  caloTSOS->erase( std::remove_if(caloTSOS->begin(),
1018  caloTSOS->end(),
1019  [this_](const Trk::TrackStateOnSurface *&state) {
1020  if (state && this_->getVolumeByGeo(state)!=2) {
1021  delete state;
1022  state=nullptr;
1023  return true;
1024  }
1025 
1026  return false;
1027 
1028  } ),
1029  caloTSOS->end());
1030 
1031 }
1032 
1034 void Trk::TrkMaterialProviderTool::removeMS(std::vector<const Trk::TrackStateOnSurface*>* caloTSOS) const
1035 {
1036  // remove all track states on surface with getVolumeByGeo(state)==3 ( ID = 1 Calo = 2 MS = 3)
1037  // and group all other track states at the beginning of the vector.
1038  // finally erase from the vector all track state pointer of the
1039  // deleted objects, which are after remove_if at the end of the vector.
1040  const TrkMaterialProviderTool *this_=this;
1041  caloTSOS->erase( std::remove_if(caloTSOS->begin(),
1042  caloTSOS->end(),
1043  [this_](const Trk::TrackStateOnSurface *&state) {
1044  if (state && this_->getVolumeByGeo(state)==3) {
1045  delete state;
1046  state=nullptr;
1047  return true;
1048  }
1049 
1050  return false;
1051 
1052  } ),
1053  caloTSOS->end());
1054 
1055 }
1056 
1057 
1060  Trk::TrackStates::iterator firstCALO,
1062  Trk::TrackStates* caloTSOS)
1063 {
1064  //printTSOS(*firstCALO, "UPD->FIRST CALO");
1065  //printTSOS(*firstMS, "UPD->FIRST MS");
1066  unsigned int ntoupdate=0;
1067  Trk::TrackStates::iterator it = firstCALO;
1068  while(it!=firstMS) {
1069  ++it;
1070  ntoupdate++;
1071  }
1072 
1073  // replace calo TSOS elements in input vector
1074  if(ntoupdate==caloTSOS->size()) {
1075  std::copy(caloTSOS->begin(), caloTSOS->end(), firstCALO);
1076  }else{
1077  it = firstCALO;
1078  unsigned int i=0;
1079  while(i<ntoupdate) {
1080  it = inputTSOS->erase(it);
1081  ++i;
1082  --firstMS;
1083  }
1084  inputTSOS->insert(firstMS, caloTSOS->begin(), caloTSOS->end());
1085  }
1086  // delete the view container
1087  delete caloTSOS;
1088 }
1090  const Trk::TrackStates::iterator& firstMS,
1091  double X0ScaleMS, double ElossScaleMS) const
1092 {
1093 
1094  bool debug = false;
1095 
1096 // Scale the X0 and Energy loss in the Muon Spectrometer
1097 
1098  std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes> meotPattern(0);
1101  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1102  typePattern.set(Trk::TrackStateOnSurface::InertMaterial);
1103  typePattern.set(Trk::TrackStateOnSurface::Scatterer);
1104 
1105  if(X0ScaleMS<0.5||ElossScaleMS<0.5||X0ScaleMS>2.||ElossScaleMS>2.) {
1106  ATH_MSG_WARNING("Too large or too small X0ScaleMS " << X0ScaleMS << " ElossScaleMS " << ElossScaleMS);
1107  }
1108 
1109  Trk::TrackStates::iterator it = firstMS;
1110  int msStates = 0;
1111  int msMatStates = 0;
1112  int msMatParStates = 0;
1113 
1114 // In the MuonSpectrometer the TSOS for the MaterialEffectsOnTrack do NOT have trackParameters
1115 
1116  for(;it!= inputTSOS->end();++it) {
1117  msStates++;
1118  if((*it)->materialEffectsOnTrack()) {
1119  msMatStates++;
1120 // if((*it)->trackParameters()) {
1121 // ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1122 // continue;
1123 // }
1124  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>((*it)->materialEffectsOnTrack());
1125  if(meot) {
1126  msMatParStates++;
1127  const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1128  if(energyLoss) {
1129  const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1130  if(scatAngles) {
1131  auto scatNew = Trk::ScatteringAngles(
1132  0,
1133  0,
1134  std::sqrt(X0ScaleMS) * scatAngles->sigmaDeltaTheta(),
1135  std::sqrt(X0ScaleMS) * scatAngles->sigmaDeltaPhi());
1136  double deltaE = (ElossScaleMS * energyLoss->deltaE());
1137  double sigmaDeltaE = (ElossScaleMS * energyLoss->sigmaDeltaE());
1138  double sigmaPlusDeltaE =
1139  (ElossScaleMS * energyLoss->sigmaPlusDeltaE());
1140  double sigmaMinusDeltaE =
1141  (ElossScaleMS * energyLoss->sigmaMinusDeltaE());
1142  double deltaE_ioni = (ElossScaleMS * energyLoss->meanIoni());
1143  double sigmaDeltaE_ioni = (ElossScaleMS * energyLoss->sigmaIoni());
1144  double deltaE_rad = (ElossScaleMS * energyLoss->meanRad());
1145  double sigmaDeltaE_rad = (ElossScaleMS * energyLoss->sigmaRad());
1146  double depth = energyLoss->length();
1147 
1148  if (debug)
1149  std::cout << " updateVectorMS Old Eloss " << energyLoss->deltaE()
1150  << " new Eloss " << deltaE << std::endl;
1151 
1152  auto energyLossNew = std::make_unique<Trk::EnergyLoss>(deltaE,
1153  sigmaDeltaE,
1154  sigmaMinusDeltaE,
1155  sigmaPlusDeltaE,
1156  deltaE_ioni,
1157  sigmaDeltaE_ioni,
1158  deltaE_rad,
1159  sigmaDeltaE_rad,
1160  depth);
1161  const Trk::Surface& surf = meot->associatedSurface();
1162  auto newMeot =
1163  std::make_unique<Trk::MaterialEffectsOnTrack>(X0ScaleMS * meot->thicknessInX0(),
1164  scatNew,
1165  std::move(energyLossNew),
1166  surf,
1167  meotPattern);
1168  std::unique_ptr<Trk::TrackParameters> pars{};
1169  if ((*it)->trackParameters())
1170  pars = (*it)->trackParameters()->uniqueClone();
1171  // make new TSOS
1172  const Trk::TrackStateOnSurface* newTSOS =
1174  nullptr, std::move(pars), std::move(newMeot), typePattern);
1175  Trk::TrackStates* newTSOSvector =
1177  newTSOSvector->push_back(&(*newTSOS));
1178  // replace TSOS in MS with new one
1179  std::copy(newTSOSvector->begin(), newTSOSvector->end(), it);
1180  delete newTSOSvector;
1181  }
1182  }
1183  }
1184  }
1185  }
1186 
1187 
1188  if(debug) {
1189  std::cout << " msStates " << msStates << " msMatStates " << msMatStates << " msMatParStates " << msMatParStates << std::endl;
1190 
1191 // dump (new) energy loss
1192  for(it = firstMS;it!= inputTSOS->end();++it) {
1193  if((*it)->materialEffectsOnTrack()) {
1194  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>((*it)->materialEffectsOnTrack());
1195  if(meot) {
1196  const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1197  if(energyLoss) {
1198  const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1199  if(scatAngles) {
1200  std::cout << " updateVectorMS dump NEW Eloss " << energyLoss->deltaE() << std::endl;
1201  }
1202  }
1203  }
1204  }
1205  }
1206 
1207  } // end debug
1208 
1209 
1210 }
1211 
1212 //* Helper to indentify detector volume**/
1214 {
1215  unsigned int vol = 0;
1216  const Trk::MeasurementBase* mot = m->measurementOnTrack();
1217  if(mot) {
1219  if(id.is_valid()) {
1220  if(m_DetID->is_indet(id)) vol=1;
1221  else if(m_DetID->is_muon(id)) vol=3;
1222  else vol=2;
1223  }
1224  }
1225  if(!vol) {
1226  vol=3;
1227  if(m_indetVolume->inside(m->surface().globalReferencePoint())) vol=1;
1228  else if(m_calorimeterVolume->inside(m->surface().globalReferencePoint())) vol=2;
1229  }
1230  return vol;
1231 }
1232 
1233 
1234 //** Helper to delete TSOS vectors*/
1235 void Trk::TrkMaterialProviderTool::deleteTSOS(const std::vector<const Trk::TrackStateOnSurface*>* vecTSOS)
1236 {
1237  std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = vecTSOS->begin();
1238  std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = vecTSOS->end();
1239  for (; it != itEnd; ++it) delete *it;
1240  delete vecTSOS;
1241 }
1243 {
1244  if(vecTSOS->ownPolicy()==SG::VIEW_ELEMENTS) {
1246  Trk::TrackStates::const_iterator itEnd = vecTSOS->end();
1247  for (; it != itEnd; ++it) delete *it;
1248  }
1249  delete vecTSOS;
1250 }
1251 
1252 
1253 //** Helper to printout TSOS details*/
1255 {
1256  unsigned int ivolGeo = getVolumeByGeo(m);
1257  std::string volGeo="ID";
1258  if(ivolGeo==2) volGeo="CALO";
1259  else if(ivolGeo==3) volGeo="MS";
1260  ATH_MSG_VERBOSE(tag<<" Type "<<std::left<<std::setw(35)<<m->dumpType()
1261  <<" Volume "<<std::left<<std::setw(5)<<volGeo
1262  <<" r "<<std::left<<std::setw(10)<<m->surface().globalReferencePoint().perp()
1263  <<" z "<<std::left<<std::setw(10)<<m->surface().globalReferencePoint().z());
1264  if(m->materialEffectsOnTrack()) {
1265  ATH_MSG_VERBOSE(" -> Material: X0 "<<std::left<<std::setw(10)<<m->materialEffectsOnTrack()->thicknessInX0());
1266  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1267  if(meot) {
1268  const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1269  if (energyLoss) {
1270  ATH_MSG_DEBUG(" geo " << volGeo << " radius " << m->surface().globalReferencePoint().perp() << " z " << m->surface().globalReferencePoint().z() << " TSOS Eloss " <<energyLoss->deltaE());
1271  std::string type="P";
1272  const CaloEnergy* caloEnergy = dynamic_cast<const CaloEnergy*>(meot->energyLoss());
1273  if(caloEnergy && caloEnergy->energyLossType()==CaloEnergy::Tail) type="M";
1274  ATH_MSG_VERBOSE(" -> Eloss "<<type<<" "<<std::left<<std::setw(10)<<energyLoss->deltaE()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaDeltaE()
1275  <<" + "<<energyLoss->sigmaPlusDeltaE()<<" - "<<energyLoss->sigmaMinusDeltaE()
1276  <<" MopIoni "<<std::left<<std::setw(10)<<energyLoss->meanIoni()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaIoni()
1277  <<" MeanRad "<<std::left<<std::setw(10)<<energyLoss->meanRad()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaRad() );
1278  }
1279  const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1280  if(scatAngles) {
1281  ATH_MSG_VERBOSE(" -> Scattering: dPhi "<<std::left<<std::setw(10)<<scatAngles->deltaPhi()<<" +- "<<std::left<<std::setw(10)<<scatAngles->sigmaDeltaPhi()<<
1282  " dTheta "<<std::left<<std::setw(10)<<scatAngles->deltaTheta()<<" +- "<<std::left<<std::setw(10)<<scatAngles->sigmaDeltaTheta());
1283  }
1284  }
1285  }
1286  if(m->trackParameters()) {
1287  ATH_MSG_VERBOSE(" -> TP: r "<<std::left<<std::setw(10)<<m->trackParameters()->position().perp()
1288  <<" z "<<std::left<<std::setw(10)<<m->trackParameters()->position().z()
1289  <<" phi0 "<<std::left<<std::setw(10)<<m->trackParameters()->parameters()[Trk::phi0]
1290  <<" eta "<<std::left<<std::setw(10)<<-std::log(std::tan(m->trackParameters()->parameters()[Trk::theta]/2)));
1291  if(m->trackParameters()->covariance()) {
1292  ATH_MSG_VERBOSE(" -> Errors: qOverP "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::qOverP)
1293  <<" phi0 "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::phi0)
1294  <<" theta "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::theta));
1295  }
1296  }
1297 }
1298 
1301 Trk::TrkMaterialProviderTool::modifyTSOSvector(const std::vector<const Trk::TrackStateOnSurface*>* matvec,
1302  double scaleX0,
1303  double scaleEloss,
1304  bool reposition,
1305  bool aggregate,
1306  bool updateEloss,
1307  double caloEnergy,
1308  double caloEnergyError,
1309  double fsrCaloEnergy,
1310  double pCaloEntry,
1311  double momentumError,
1312  double& Eloss_tot,
1313  bool useMeasuredEnergy,
1314  double totalEloss, double meanElossIoni, double sigmaElossIoni) const
1315 {
1316  //
1317  // inputs: TSOSs for material (matvec) and scale factors for X0 (scaleX0) and Eloss (scaleEloss)
1318  //
1319  // returns: new vector of TSOSs including scaling of X0 and Eloss;
1320  //
1321  // options:
1322  // bool reposition correct repositioning of the scattering centers in space
1323  // bool aggregate put scattering centra together in two planes
1324  // bool update Eloss correct energy loss 1) including the measured calorimeter Eloss 2) include smearing of the muon momentum
1325  //
1326  // the routine should NOT be called for the ID
1327  // for best use in the Calorimeter: bool reposition = true, bool aggregate = true and updateEloss = true (measured caloEnergy and caloEnergyError should be passed)
1328  // note that the updateEloss is only active with aggregate = true
1329  // current version will NOT run correctly for MS (because the Eloss is made positive in the Calorimeter) needs fixing!
1330  // for best use in the Muon Specrometer: bool reposition = true, bool aggregate = true and updateEloss = false
1331  //
1332  // if one runs with reposition = false the scattering centra are kept at the END of the thick/dense material: that is not right for thick material for thin it is OK
1333  ATH_MSG_VERBOSE("Modifying TSOS vector size " << matvec->size()
1334  << " with X0, Eloss scales " << scaleX0 << " " << scaleEloss
1335  << " rep agg upd " << reposition << " " << aggregate << " " << updateEloss
1336  << " caloE " << caloEnergy << " +- " << caloEnergyError
1337  << " fsrCaloEnergy "<< fsrCaloEnergy
1338  << " p " << pCaloEntry << " dp " << momentumError);
1339 
1340  //
1341  Trk::TrackStates* newTSOSvector = new Trk::TrackStates(SG::VIEW_ELEMENTS);
1342 
1343  // initialize total sum variables
1344  //
1345  //
1346  Eloss_tot = 0.;
1347 
1348  double X0_tot = 0.;
1349 
1350  double sigmaDeltaPhi2_tot = 0.;
1351  double sigmaDeltaTheta2_tot = 0.;
1352  double deltaE_tot = 0.;
1353  double sigmaDeltaE_tot = 0.;
1354  double sigmaPlusDeltaE_tot = 0.;
1355  double sigmaMinusDeltaE_tot = 0.;
1356  double deltaE_ioni_tot = 0.;
1357  double sigmaDeltaE_ioni_tot=0.;
1358  double deltaE_rad_tot = 0.;
1359  double sigmaDeltaE_rad_tot =0.;
1360 
1361  const Trk::TrackStateOnSurface* mprevious = nullptr;
1362  const Trk::TrackStateOnSurface* mfirst = nullptr;
1363  const Trk::TrackStateOnSurface* mlast = nullptr;
1364  Amg::Vector3D posFirst(0.,0.,0.);
1365  double deltaEFirst = 0.;
1366 
1367  double deltaPhi = 0.;
1368  double deltaTheta = 0.;
1369 
1370  int n_tot = 0;
1371 
1372  double w_tot = 0.;
1373  double wdist2 = 0.;
1374  Amg::Vector3D wdir(0.,0.,0.);
1375  Amg::Vector3D wpos(0.,0.,0.);
1376 
1377  std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes> meotPattern(0);
1380 
1381  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1382  typePattern.set(Trk::TrackStateOnSurface::InertMaterial);
1383  typePattern.set(Trk::TrackStateOnSurface::Scatterer);
1384 
1385  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePatternScat(0);
1386  typePatternScat.set(Trk::TrackStateOnSurface::Scatterer);
1387 
1388  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePatternDeposit(0);
1389  typePatternDeposit.set(Trk::TrackStateOnSurface::CaloDeposit);
1390  const auto sqrt12=std::sqrt(12.);
1391  for(const auto *m : *matvec) {
1392 
1393  if(!m->trackParameters()) {
1394  ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1395  continue;
1396  }
1397  if(m->materialEffectsOnTrack()) {
1398  double X0 = m->materialEffectsOnTrack()->thicknessInX0();
1399  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1400  const Trk::EnergyLoss* energyLoss = nullptr;
1401  const Trk::ScatteringAngles* scat = nullptr;
1402  if(meot) {
1403  energyLoss = meot->energyLoss();
1404  if (!energyLoss) {
1405  ATH_MSG_WARNING("No energyLoss on TrackStateOnSurface ");
1406  continue;
1407  }
1408  scat = meot->scatteringAngles();
1409  if(!scat) {
1410  ATH_MSG_WARNING("No scatteringAngles on TrackStateOnSurface ");
1411  continue;
1412  }
1413  } else {
1414  ATH_MSG_WARNING("No materialEffectsOnTrack on TrackStateOnSurface ");
1415  continue;
1416  }
1417 
1418  double depth = energyLoss->length();
1419  X0_tot += std::abs(scaleX0 * X0);
1420 
1421  sigmaDeltaTheta2_tot += scaleX0*scat->sigmaDeltaTheta()*scat->sigmaDeltaTheta();
1422  sigmaDeltaPhi2_tot += scaleX0*scat->sigmaDeltaPhi()*scat->sigmaDeltaPhi();
1423 
1424  // Eloss sigma values add up linearly for Landau and exponential distributions
1425  deltaE_tot += std::abs(scaleEloss*energyLoss->deltaE());
1426  sigmaDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaDeltaE());
1427  sigmaPlusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaPlusDeltaE());
1428  sigmaMinusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaMinusDeltaE());
1429  deltaE_ioni_tot += std::abs(scaleEloss*energyLoss->meanIoni());
1430  sigmaDeltaE_ioni_tot += std::abs(scaleEloss*energyLoss->sigmaIoni());
1431  deltaE_rad_tot += std::abs(scaleEloss*energyLoss->meanRad());
1432  sigmaDeltaE_rad_tot += std::abs(scaleEloss*energyLoss->sigmaRad());
1433 
1434  n_tot++;
1435 
1436  Amg::Vector3D dir = m->trackParameters()->momentum().unit();
1437  Amg::Vector3D pos = m->trackParameters()->position();
1438  if(mprevious) {
1439  dir += mprevious->trackParameters()->momentum().unit();
1440  }
1441 
1442  dir = dir/dir.mag();
1443  Amg::Vector3D pos0 = pos - (depth/2.+depth/sqrt12)*dir;
1444  Amg::Vector3D posNew = pos - (depth/2.-depth/sqrt12)*dir;
1445  if(!mfirst) {
1446  mfirst = m;
1447  posFirst = pos0;
1448  deltaEFirst = energyLoss->deltaE();
1449  }
1450  mlast = m;
1451 
1452  double w = scat->sigmaDeltaTheta()*scat->sigmaDeltaTheta();
1453 
1454  w_tot += w;
1455  wpos += w*pos0/2.;
1456  wpos += w*posNew/2.;
1457  wdir += w*dir;
1458 
1459  wdist2 += w*(pos0-posFirst).mag2()/2.;
1460  wdist2 += w*(posNew-posFirst).mag2()/2.;
1461 
1462  if (!aggregate&&!reposition) {
1463 
1464  auto scatNew = ScatteringAngles(deltaPhi,
1465  deltaTheta,
1466  std::sqrt(sigmaDeltaPhi2_tot),
1467  std::sqrt(sigmaDeltaTheta2_tot));
1468  auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1469  sigmaDeltaE_tot,
1470  sigmaMinusDeltaE_tot,
1471  sigmaPlusDeltaE_tot,
1472  deltaE_ioni_tot,
1473  sigmaDeltaE_ioni_tot,
1474  deltaE_rad_tot,
1475  sigmaDeltaE_rad_tot,
1476  depth);
1477  auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1478  Eloss_tot += caloEnergyNew->deltaE();
1479  const Trk::Surface& surf = meot->associatedSurface();
1480  auto meotLast =
1481  std::make_unique<Trk::MaterialEffectsOnTrack>(
1482  X0_tot, scatNew, std::move(caloEnergyNew), surf, meotPattern);
1483  auto pars = m->trackParameters()->uniqueClone();
1484 
1485  // make new TSOS
1487  nullptr, std::move(pars), std::move(meotLast), typePattern);
1488 
1489  newTSOSvector->push_back(newTSOS);
1490 
1491  X0_tot = 0.;
1492  sigmaDeltaTheta2_tot = 0.;
1493  sigmaDeltaPhi2_tot = 0.;
1494  deltaE_tot = 0.;
1495  sigmaDeltaE_tot = 0;
1496  sigmaPlusDeltaE_tot = 0.;
1497  sigmaMinusDeltaE_tot = 0.;
1498  deltaE_ioni_tot = 0.;
1499  sigmaDeltaE_ioni_tot = 0.;
1500  deltaE_rad_tot = 0.;
1501  sigmaDeltaE_rad_tot = 0.;
1502 
1503 
1504  } else if(!aggregate&&reposition) {
1505 
1506  if(std::abs(depth)<10.) {
1507 
1508  // Thin scatterer: make only one TSOS
1509 
1510  auto scatNew =
1512  deltaTheta,
1513  sqrt(sigmaDeltaPhi2_tot),
1514  sqrt(sigmaDeltaTheta2_tot));
1515  auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1516  sigmaDeltaE_tot,
1517  sigmaMinusDeltaE_tot,
1518  sigmaPlusDeltaE_tot,
1519  deltaE_ioni_tot,
1520  sigmaDeltaE_ioni_tot,
1521  deltaE_rad_tot,
1522  sigmaDeltaE_rad_tot,
1523  depth);
1524  auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1525  Eloss_tot += caloEnergyNew->deltaE();
1526  const Trk::Surface& surf = meot->associatedSurface();
1527  auto meotLast =
1528  std::make_unique<Trk::MaterialEffectsOnTrack>(
1529  X0_tot, scatNew, std::move(caloEnergyNew), surf, meotPattern);
1530  auto pars = m->trackParameters()->uniqueClone();
1531  // make new TSOS
1532  const Trk::TrackStateOnSurface* newTSOS =
1534  nullptr, std::move(pars), std::move(meotLast), typePattern);
1535  newTSOSvector->push_back(newTSOS);
1536 
1537  X0_tot = 0.;
1538  sigmaDeltaTheta2_tot = 0.;
1539  sigmaDeltaPhi2_tot = 0.;
1540  deltaE_tot = 0.;
1541  sigmaDeltaE_tot = 0;
1542  sigmaPlusDeltaE_tot = 0.;
1543  sigmaMinusDeltaE_tot = 0.;
1544  deltaE_ioni_tot = 0.;
1545  sigmaDeltaE_ioni_tot = 0.;
1546  deltaE_rad_tot = 0.;
1547  sigmaDeltaE_rad_tot = 0.;
1548 
1549  } else {
1550  //
1551  // Thick scatterer: make two TSOSs
1552  //
1553  // prepare for first MaterialEffectsOnTrack with X0 = X0/2 Eloss = 0 and scattering2 = total2 / 2. depth = 0
1554  auto energyLoss0 = std::make_unique<Trk::EnergyLoss>(0.,0.,0.,0.);
1555  auto scatFirst = ScatteringAngles(deltaPhi,
1556  deltaTheta,
1557  std::sqrt(sigmaDeltaPhi2_tot / 2.),
1558  std::sqrt(sigmaDeltaTheta2_tot / 2.));
1559 
1560  // prepare for second MaterialEffectsOnTrack with X0 = X0/2 Eloss = Eloss total and scattering2 = total2 / 2. depth = 0
1561  auto scatNew =
1563  deltaTheta,
1564  std::sqrt(sigmaDeltaPhi2_tot / 2.),
1565  std::sqrt(sigmaDeltaTheta2_tot / 2.));
1566  auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1567  sigmaDeltaE_tot,
1568  sigmaMinusDeltaE_tot,
1569  sigmaPlusDeltaE_tot,
1570  deltaE_ioni_tot,
1571  sigmaDeltaE_ioni_tot,
1572  deltaE_rad_tot,
1573  sigmaDeltaE_rad_tot,
1574  0.);
1575  auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1576  Eloss_tot += caloEnergyNew->deltaE();
1577  double norm = dir.perp();
1578  // Rotation matrix representation
1579  Amg::Vector3D colx(-dir.y() / norm, dir.x() / norm, 0);
1580  Amg::Vector3D coly(
1581  -dir.x() * dir.z() / norm, -dir.y() * dir.z() / norm, norm);
1582  Amg::Vector3D colz(dir.x(), dir.y(), dir.z());
1583 
1584  Amg::Transform3D surfaceTransformFirst(colx, coly, colz, pos0);
1585  Amg::Transform3D surfaceTransformLast(colx, coly, colz, posNew);
1586  auto surfFirst =
1587  Trk::PlaneSurface(surfaceTransformFirst);
1588  auto surfLast =
1589  Trk::PlaneSurface(surfaceTransformLast);
1590  // make MaterialEffectsOnTracks
1591  auto meotFirst =
1592  std::make_unique<Trk::MaterialEffectsOnTrack>(
1593  X0_tot / 2., scatFirst, std::move(energyLoss0), surfFirst, meotPattern);
1594  auto meotLast =
1595  std::make_unique<Trk::MaterialEffectsOnTrack>(
1596  X0_tot / 2., scatNew, std::move(caloEnergyNew), surfLast, meotPattern);
1597 
1598 
1599  // calculate TrackParameters at first surface
1600  double qOverP0 = m->trackParameters()->charge()/ (m->trackParameters()->momentum().mag()-std::abs(energyLoss->deltaE()));
1601  if(mprevious) qOverP0 = mprevious->trackParameters()->charge()/mprevious->trackParameters()->momentum().mag();
1602 
1603  std::unique_ptr<Trk::TrackParameters> parsFirst =
1604  surfFirst.createUniqueParameters<5, Trk::Charged>(
1605  0., 0., dir.phi(), dir.theta(), qOverP0);
1606  // calculate TrackParameters at second surface
1607  double qOverPNew = m->trackParameters()->charge() /
1608  m->trackParameters()->momentum().mag();
1609  std::unique_ptr<Trk::TrackParameters> parsLast =
1610  surfLast.createUniqueParameters<5, Trk::Charged>(
1611  0., 0., dir.phi(), dir.theta(), qOverPNew);
1612  // make TSOS
1613  //
1614  const Trk::TrackStateOnSurface* newTSOSFirst =
1616  nullptr, std::move(parsFirst), std::move(meotFirst), typePattern);
1617  const Trk::TrackStateOnSurface* newTSOS =
1619  nullptr, std::move(parsLast), std::move(meotLast), typePattern);
1620 
1621 
1622  newTSOSvector->push_back(newTSOSFirst);
1623  newTSOSvector->push_back(newTSOS);
1624 
1625  X0_tot = 0.;
1626  sigmaDeltaTheta2_tot = 0.;
1627  sigmaDeltaPhi2_tot = 0.;
1628  deltaE_tot = 0.;
1629  sigmaDeltaE_tot = 0;
1630  sigmaPlusDeltaE_tot = 0.;
1631  sigmaMinusDeltaE_tot = 0.;
1632  deltaE_ioni_tot = 0.;
1633  sigmaDeltaE_ioni_tot = 0.;
1634  deltaE_rad_tot = 0.;
1635  sigmaDeltaE_rad_tot = 0.;
1636  }
1637  }
1638 
1639  mprevious = m;
1640 
1641 
1642  }
1643  }
1644  if (aggregate&&reposition) {
1645 
1646  if (n_tot>0) {
1647  //
1648  // Make three scattering planes in Calorimeter else make two
1649  //
1650  Amg::Vector3D pos = wpos/w_tot;
1651  bool threePlanes = false;
1652  if (std::abs(pos.z()) < 6700 && pos.perp() < 4200)
1653  threePlanes = true; // always 3 planes in calo
1654  //
1655  auto scatFirst =
1657  deltaTheta,
1658  std::sqrt(sigmaDeltaPhi2_tot / 2.),
1659  std::sqrt(sigmaDeltaTheta2_tot / 2.));
1660  auto scatNew =
1662  deltaTheta,
1663  std::sqrt(sigmaDeltaPhi2_tot / 2.),
1664  std::sqrt(sigmaDeltaTheta2_tot / 2.));
1665  Trk::EnergyLoss energyLoss2 = EnergyLoss(deltaE_tot,
1666  sigmaDeltaE_tot,
1667  sigmaMinusDeltaE_tot,
1668  sigmaPlusDeltaE_tot,
1669  deltaE_ioni_tot,
1670  sigmaDeltaE_ioni_tot,
1671  deltaE_rad_tot,
1672  sigmaDeltaE_rad_tot,
1673  0.);
1674  if (threePlanes)
1675  ATH_MSG_VERBOSE(" Calorimeter energyLoss2 delta E "
1676  << energyLoss2.deltaE() << " meanIoni "
1677  << energyLoss2.meanIoni() << " sigmaIoni "
1678  << energyLoss2.sigmaIoni() << " X0_tot " << X0_tot);
1679 
1680  int elossFlag =
1681  0; // return Flag for updateEnergyLoss Calorimeter energy (0 = not used)
1682 
1683  double calE = caloEnergy;
1684  double calEr = caloEnergyError;
1685 
1686  // if(!useMeasuredEnergy) calE = 0.;
1687  if (!useMeasuredEnergy)
1688  calEr = 0.;
1689 
1690  Trk::EnergyLoss energyLossNew =
1691  (updateEloss
1692  ? m_elossupdator->updateEnergyLoss(
1693  energyLoss2, calE, calEr, pCaloEntry, momentumError, elossFlag)
1694  : EnergyLoss(deltaE_tot,
1695  sigmaDeltaE_tot,
1696  sigmaMinusDeltaE_tot,
1697  sigmaPlusDeltaE_tot,
1698  deltaE_ioni_tot,
1699  sigmaDeltaE_ioni_tot,
1700  deltaE_rad_tot,
1701  sigmaDeltaE_rad_tot,
1702  0.));
1703  auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1704  if (threePlanes)
1705  ATH_MSG_VERBOSE(" After update Calorimeter energyLossNew "
1706  << energyLossNew.deltaE() << " meanIoni "
1707  << energyLossNew.meanIoni() << " sigmaIoni "
1708  << energyLossNew.sigmaIoni());
1709 
1710  caloEnergyNew->set_measEnergyLoss(caloEnergy, caloEnergyError);
1711  // Store FSR calo energy
1712  caloEnergyNew->set_fsrCandidateEnergy(fsrCaloEnergy);
1713  // Store both measured and parametrised eloss on CaloEnergy object
1714  if(elossFlag!=0) {
1715  caloEnergyNew->set_energyLossType(CaloEnergy::Tail);
1716  } else {
1717  if(!useMeasuredEnergy) caloEnergyNew->set_energyLossType(CaloEnergy::NotIsolated);
1718  }
1719 
1720  int eLossFlagTmp = 0;
1721  Trk::EnergyLoss energyLossParam = m_elossupdator->updateEnergyLoss(energyLoss2, 0.0, 0.0, pCaloEntry, 0., eLossFlagTmp);
1722 
1723  caloEnergyNew->set_paramEnergyLoss(energyLossParam.deltaE(), energyLossParam.sigmaMinusDeltaE(), energyLossParam.sigmaPlusDeltaE());
1724  if(m_overwriteElossParam&&m_useCaloEnergyMeasurement) caloEnergyNew->set_paramEnergyLoss(totalEloss,meanElossIoni,0.45*sigmaElossIoni);
1725  ATH_MSG_DEBUG( " modifyTSOSvector energyLossParam Eloss " << energyLossParam.deltaE() << " on TSOS " << energyLossNew.deltaE() << " calE " << calE);
1726  Eloss_tot += caloEnergyNew->deltaE();
1727 
1728  // direction of plane
1729  Amg::Vector3D dir = wdir/w_tot;
1730  dir = dir/dir.mag();
1731  double norm = dir.perp();
1732  // Rotation matrix representation
1733  Amg::Vector3D colx(-dir.y()/norm, dir.x()/norm, 0);
1734  Amg::Vector3D coly(-dir.x()*dir.z()/norm, -dir.y()*dir.z()/norm, norm);
1735  Amg::Vector3D colz( dir.x(), dir.y(), dir.z());
1736  // Centre position of the two planes
1737  double halflength2 = wdist2/w_tot - (pos-posFirst).mag()*(pos-posFirst).mag();
1738  double halflength = 0.;
1739  if(halflength2>0) halflength = sqrt(halflength2);
1740  Amg::Vector3D pos0 = pos - halflength*dir;
1741  Amg::Vector3D posNew = pos + halflength*dir;
1742 //
1743 // force the planes to be inside the Calorimeter
1744 //
1745  double scaleCalo = 1.;
1746  double scaleCaloNew = std::abs(pos0.z())/6700;
1747  if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1748  scaleCaloNew = std::abs(posNew.z())/6700;
1749  if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1750  scaleCaloNew = std::abs(pos0.perp())/4200;
1751  if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1752  scaleCaloNew = std::abs(posNew.perp())/4200;
1753  if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1754 
1755  if(scaleCalo>1.) {
1756  pos0 = pos0/scaleCalo;
1757  pos = pos/scaleCalo;
1758  posNew = posNew/scaleCalo;
1759  halflength = halflength/scaleCalo;
1760  ATH_MSG_VERBOSE(" position scattering planes inside calo scale factor " << scaleCalo);
1761  }
1762 
1763  if(updateEloss) ATH_MSG_VERBOSE("WITH updateEloss");
1764  Amg::Transform3D surfaceTransformFirst(colx,coly,colz,pos0);
1765  Amg::Transform3D surfaceTransformLast(colx,coly,colz,posNew);
1766  auto surfFirst = Trk::PlaneSurface( surfaceTransformFirst );
1767  auto surfLast= Trk::PlaneSurface( surfaceTransformLast );
1768  // calculate TrackParameters at first surface
1769  double qOverP0 = mfirst->trackParameters()->charge()/(mfirst->trackParameters()->momentum().mag()+std::abs(deltaEFirst));
1770  // calculate TrackParameters at last surface
1771  double qOverPNew = mlast->trackParameters()->charge()/mlast->trackParameters()->momentum().mag();
1772  std::unique_ptr<Trk::TrackParameters> parsFirst =
1773  surfFirst.createUniqueParameters<5, Trk::Charged>(
1774  0., 0., dir.phi(), dir.theta(), qOverP0);
1775  std::unique_ptr<Trk::TrackParameters> parsLast =
1776  surfLast.createUniqueParameters<5, Trk::Charged>(
1777  0., 0., dir.phi(), dir.theta(), qOverPNew);
1778 
1779  if(!threePlanes) {
1780  //
1781  // make two scattering planes and TSOS
1782  //
1783  // prepare for first MaterialEffectsOnTrack with X0 = X0/2
1784  // Eloss = 0 and scattering2 = total2 / 2. depth = 0
1785  auto meotFirst =
1786  std::make_unique<Trk::MaterialEffectsOnTrack>(X0_tot / 2.,
1787  scatFirst,
1788  nullptr,
1789  surfFirst,
1790  meotPattern);
1791  // prepare for second MaterialEffectsOnTrack with X0 = X0/2
1792  // Eloss = Eloss total and scattering2 = total2 / 2. depth = 0
1793  auto meotLast =
1794  std::make_unique<Trk::MaterialEffectsOnTrack>(X0_tot / 2.,
1795  scatNew,
1796  std::move(caloEnergyNew),
1797  surfLast,
1798  meotPattern);
1799  //
1800  //
1801  const Trk::TrackStateOnSurface* newTSOSFirst =
1803  nullptr, std::move(parsFirst), std::move(meotFirst), typePattern);
1804  auto whichPattern = (elossFlag != 0) ? typePatternDeposit : typePattern;
1805  const Trk::TrackStateOnSurface* newTSOS = new Trk::TrackStateOnSurface( nullptr,
1806  std::move(parsLast), std::move(meotLast), whichPattern);
1807  newTSOSvector->push_back(newTSOSFirst);
1808  newTSOSvector->push_back(newTSOS);
1809  } else {
1810  //
1811  // make three scattering planes and TSOS in Calorimeter
1812  //
1813  Amg::Transform3D surfaceTransform(colx, coly, colz, pos);
1814  auto surf = Trk::PlaneSurface(surfaceTransform);
1815  std::unique_ptr<Trk::TrackParameters> pars =
1816  surf.createUniqueParameters<5, Trk::Charged>(
1817  0., 0., dir.phi(), dir.theta(), qOverPNew);
1818 
1819  // prepare for first MaterialEffectsOnTrack with X0 = X0/2 Eloss
1820  // = 0 and scattering2 = total2 / 2. depth = 0
1821  auto meotFirst =
1822  std::make_unique<Trk::MaterialEffectsOnTrack>(
1823  X0_tot / 2., scatFirst, nullptr, surfFirst, meotPattern);
1824 
1825  // prepare for middle MaterialEffectsOnTrack with X0 = 0 Eloss =
1826  // ElossNew and scattering2 = 0. depth = 0
1827  auto meot =
1828  std::make_unique<Trk::MaterialEffectsOnTrack>(
1829  0.,std::nullopt, std::move(caloEnergyNew), surf, meotPattern);
1830 
1831  // prepare for last MaterialEffectsOnTrack with X0 = X0/2 Eloss
1832  // = 0 total and scattering2 = total2 / 2. depth = 0
1833  auto meotLast =
1834  std::make_unique<Trk::MaterialEffectsOnTrack>(
1835  X0_tot / 2., scatNew, nullptr, surfLast, meotPattern);
1836 
1837 
1838  const Trk::TrackStateOnSurface* newTSOSFirst =
1840  nullptr, std::move(parsFirst), std::move(meotFirst), typePatternScat);
1842  nullptr, std::move(pars), std::move(meot), typePatternDeposit);
1843  const Trk::TrackStateOnSurface* newTSOSLast =
1845  nullptr, std::move(parsLast), std::move(meotLast), typePatternScat);
1846 
1847  newTSOSvector->push_back(newTSOSFirst);
1848  newTSOSvector->push_back(newTSOS);
1849  newTSOSvector->push_back(newTSOSLast);
1850  }
1851 
1852 
1853  }
1854 
1855  }
1856 
1857  return newTSOSvector;
1858 }
1859 
1860 
1862 void Trk::TrkMaterialProviderTool::getMopAndIoniEnergyLoss(const std::vector<const Trk::TrackStateOnSurface*>* matvec,
1863  double pCaloEntry,
1864  double scaleEloss,
1865  double& totalEloss,
1866  double& meanElossIoni,
1867  double& sigmaElossIoni) const
1868 {
1869 // routine calculates the totalEloss = meanIoni + meanRad
1870 // meanElossIoni = meanIoni
1871 // sigmaElossIoni = sigmaIoni
1872 //
1873 
1874 // Be carefull with using deltaE() that number starts as totalEloss but is updated to values close to meanIoni depending on the fit
1875 
1876  double deltaE_tot = 0.;
1877  double sigmaDeltaE_tot = 0.;
1878  double sigmaPlusDeltaE_tot = 0.;
1879  double sigmaMinusDeltaE_tot = 0.;
1880  double deltaE_ioni_tot = 0.;
1881  double sigmaDeltaE_ioni_tot=0.;
1882  double deltaE_rad_tot = 0.;
1883  double sigmaDeltaE_rad_tot =0.;
1884 
1885  for(const auto *m : *matvec) {
1886  if(!m->trackParameters()) {
1887  ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1888  continue;
1889  }
1890  if(m->materialEffectsOnTrack()) {
1891  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1892  const Trk::EnergyLoss* energyLoss = nullptr;
1893  if(meot) {
1894  energyLoss = meot->energyLoss();
1895  if (!energyLoss) {
1896  ATH_MSG_WARNING("No energyLoss on TrackStateOnSurface ");
1897  continue;
1898  }
1899  } else {
1900  ATH_MSG_WARNING("No materialEffectsOnTrack on TrackStateOnSurface ");
1901  continue;
1902  }
1903  deltaE_tot += std::abs(scaleEloss*energyLoss->deltaE());
1904  sigmaDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaDeltaE());
1905  sigmaPlusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaPlusDeltaE());
1906  sigmaMinusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaMinusDeltaE());
1907  deltaE_ioni_tot += std::abs(scaleEloss*energyLoss->meanIoni());
1908  sigmaDeltaE_ioni_tot += std::abs(scaleEloss*energyLoss->sigmaIoni());
1909  deltaE_rad_tot += std::abs(scaleEloss*energyLoss->meanRad());
1910  sigmaDeltaE_rad_tot += std::abs(scaleEloss*energyLoss->sigmaRad());
1911 
1912  ATH_MSG_DEBUG(" position x " << m->trackParameters()->position().x() << " y " << m->trackParameters()->position().y() << " perp " << m->trackParameters()->position().perp() << " z " << m->trackParameters()->position().z() );
1913  ATH_MSG_DEBUG(" deltaE " << (scaleEloss*energyLoss->deltaE()) << " deltaE_ioni " << (scaleEloss*energyLoss->meanIoni()) << " sigmaDeltaE_ioni " << (scaleEloss*energyLoss->sigmaIoni()));
1914  ATH_MSG_DEBUG(" deltaE_tot " << deltaE_tot << " deltaE_ioni_tot " << deltaE_ioni_tot << " sigmaDeltaE_ioni_tot " << sigmaDeltaE_ioni_tot);
1915  if(energyLoss->sigmaIoni()<0) ATH_MSG_DEBUG(" ALARM sigmaIoni negative " << scaleEloss*energyLoss->sigmaIoni());
1916  if(energyLoss->sigmaRad()<0) ATH_MSG_DEBUG(" ALARM sigmaRad negative " << scaleEloss*energyLoss->sigmaRad());
1917 
1918  }
1919  }
1920 
1921  EnergyLoss eLoss = EnergyLoss(deltaE_tot, sigmaDeltaE_tot, sigmaMinusDeltaE_tot, sigmaPlusDeltaE_tot,
1922  deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1923  deltaE_rad_tot, sigmaDeltaE_rad_tot, 0.) ;
1924 
1925  int elossFlag=0;
1926 
1927  EnergyLoss eLoss2 ( m_elossupdator->updateEnergyLoss(eLoss, 0, 0, pCaloEntry, 0, elossFlag) );
1928 
1929  totalEloss = eLoss2.meanIoni() + eLoss2.meanRad();
1930  meanElossIoni = eLoss2.meanIoni();
1931  sigmaElossIoni = eLoss2.sigmaIoni();
1932 
1933  ATH_MSG_DEBUG("Mop Energy Loss " << totalEloss << " mean ionization energy loss " << meanElossIoni << " sigmaElossIoni " << sigmaElossIoni);
1934 }
1935 
1938 {
1939  int nTracks = 0;
1940  std::pair<int,double> inner = m_trackIsolationTool->trackIsolation(Gaudi::Hive::currentContext(),eta,phi);
1941  nTracks = inner.first;
1942 
1943  ATH_MSG_VERBOSE("Isolation : Number of tracks in cone " << nTracks << " cut < " << m_maxNTracksIso);
1944 
1945  return nTracks <= m_maxNTracksIso;
1946 }
1947 
1950  double totalEloss,
1951  double meanElossIoni,
1952  double& fsrCaloEnergy) const
1953 {
1954  // Retrieve the measured energy from calorimeter
1955  std::unique_ptr<Rec::CaloMeas> caloMeas = m_caloMeasTool->energyMeasurement(Gaudi::Hive::currentContext(),eta,phi,eta,phi);
1956 
1957 
1958  // Sum-up components
1959  double FinalMeasuredEnergy = getFinalMeasuredEnergy(caloMeas.get(), totalEloss, meanElossIoni, eta, fsrCaloEnergy);
1960 
1961  return FinalMeasuredEnergy;
1962 }
1963 
1966  double totalEloss,
1967  double meanElossIoni,
1968  double eta,
1969  double& fsrCaloEnergy) const
1970 {
1971  double MopLossCorrected = totalEloss;
1972  double MopLoss = totalEloss;
1973 
1974  // FSR candidate energy
1975  fsrCaloEnergy = MopLoss*m_caloParamTool->emMopFraction(eta);
1976 
1977  // percentage of inert material
1978  const double InertMaterial = m_caloParamTool->x0mapInertMaterial(eta);
1979  // percentage of em calorimeter material
1980  const double EmMaterial = m_caloParamTool->x0mapEmMaterial(eta);
1981  // percentage of hec calorimeter material
1982  const double HECMaterial = m_caloParamTool->x0mapHecMaterial(eta);
1983  // correction for the inert material
1984  double MaterialCorrection = InertMaterial * MopLossCorrected;
1985 
1986  // fraction of Tile used for the measurement
1987  const double TileMeasurementMaterial = caloMeas->Tile_SamplingFraction();
1988  // fraction of LArHEC used for the measurement
1989  const double LArHECMeasurementMaterial = caloMeas->LArHEC_SamplingFraction();
1990  // fraction of LArEM used for the measurement
1991  const double LArEmMeasurementMaterial = caloMeas->LArEM_SamplingFraction();
1992  // Measured energy deposition in Tile
1993  const double TileEnergy = caloMeas->Tile_EnergyMeasured();
1994  // Measured energy deposition in E/M
1995  const double EmEnergy = caloMeas->LArEM_EnergyMeasured();
1996 
1997  // Correction for forward calorimetry
1998  double ForwardHECCorrection = 0.;
1999  if (std::abs(eta)>2. && caloMeas->LArHEC_EnergyMeasured()>100.)
2000  ForwardHECCorrection = (1. - LArHECMeasurementMaterial) * HECMaterial * MopLossCorrected;
2001  const double LArHECEnergy = caloMeas->LArHEC_EnergyMeasured() + ForwardHECCorrection; // Measured energy deposition in LArHEC
2002 
2003  double TotalMeasuredEnergy = TileEnergy + EmEnergy + LArHECEnergy;
2004 
2005  ATH_MSG_VERBOSE( "Energy Deposition:Tile " << TileEnergy
2006  << " LArHEC " << LArHECEnergy
2007  << " EM " << EmEnergy);
2008  ATH_MSG_VERBOSE("ForwardHECCorrection " << ForwardHECCorrection
2009  << " HECMaterial " << HECMaterial
2010  << " MopLossCorrected " << MopLossCorrected );
2011 
2012  bool bHEC = false; // performed HEC measurement?
2013  bool bEM = false; // performed Em measurement?
2014 
2015  // If muon isolated, and no significant measurement is made then use the mop parameterization, else the mean
2016  if (std::abs(eta)<1.4) {
2017  if (LArHECEnergy + TileEnergy > 0.1 * MopLoss * HECMaterial) bHEC= true;
2018  }
2019  else if (std::abs(eta)>1.8) {
2020  if (LArHECEnergy + TileEnergy > 0.2 * MopLoss * HECMaterial) bHEC= true;
2021  }else{
2022  if (LArHECEnergy + TileEnergy > 0.25 * MopLoss * HECMaterial) bHEC= true;
2023  }
2024  if (EmEnergy > 0.5 * MopLoss * EmMaterial) bEM = true;
2025 
2026  double MeasCorrected = TotalMeasuredEnergy + MaterialCorrection;
2027  // Need to calculate the corresponding mip energy deposition
2028  // Muons of 10 GeV are already in the relativistic rise region
2029  // in order to obtain the mip deposition from the mean energy deposition of 10 GeV muons
2030  // should divide by approximately 1.4 (Review of Particle Physics Figure 27.3 p.243)
2031  const double IonizationLoss = (1./1.4) * meanElossIoni;
2032  double eOverMipCorrectionEm = 0.;
2033  double eOverMipCorrectionHEC = 0.;
2034  // Etrue = emip * Emeas
2035  // -DE = Emeas - Etrue = Etrue ( 1./emip -1.)
2036  if (bEM) {
2037  const double emipEM = 0.78;
2038  eOverMipCorrectionEm = - (1./emipEM-1.) * IonizationLoss * EmMaterial * LArEmMeasurementMaterial;
2039  if (EmEnergy + eOverMipCorrectionEm<0.)eOverMipCorrectionEm=0.;
2040  }
2041  if (bHEC) {
2042  const double emipTile = 0.86;
2043  const double emipLAr = 0.94;
2044  const double HECEnergy = TileEnergy + LArHECEnergy;
2045  const double eOverMipCorrectionTile = - (1./emipTile-1.) * TileEnergy / HECEnergy * IonizationLoss * HECMaterial * TileMeasurementMaterial;
2046  const double eOverMipCorrectionLAr = - (1./emipLAr-1.) * LArHECEnergy / HECEnergy * IonizationLoss * HECMaterial * LArHECMeasurementMaterial;
2047  eOverMipCorrectionHEC = eOverMipCorrectionTile + eOverMipCorrectionLAr;
2048  if (LArHECEnergy + TileEnergy + eOverMipCorrectionHEC < 0.0) eOverMipCorrectionHEC=0.;
2049  }
2050  const double eOverMipCorrection = eOverMipCorrectionEm + eOverMipCorrectionHEC;
2051 
2052  // // additional offset from high-statistics Z->mumu MC (measured by Peter K 30/11/2011)
2053  // double fix1FromPeter[26] = { 0.424104 , 0.479637 , 0.483419 , 0.490242 , 0.52806 ,
2054  // 0.573582 , 0.822098 , 0.767301 , 0.809919 , 0.658745 ,
2055  // 0.157187 , 0.413214 , 0.771074 , 0.61815 , 0.350113 ,
2056  // 0.322785 , 0.479294 , 0.806183 , 0.822161 , 0.757731 ,
2057  // -0.0857186, -0.0992693, -0.0492252, 0.0650174, 0.261538 ,
2058  // 0.360413 };
2059  // // (update from Peter K 09/12/2011)
2060  // double fix2FromPeter[26] = { -0.647703 , -0.303498 , -0.268645 , -0.261292 , -0.260152 ,
2061  // -0.269253 , -0.266212 , -0.240837 , -0.130172 , -0.111638 ,
2062  // -0.329423 , -0.321011 , -0.346050 , -0.305592 , -0.313293 ,
2063  // -0.317111 , -0.428393 , -0.524839 , -0.599547 , -0.464013 ,
2064  // -0.159663 , -0.140879 , -0.0975618, 0.0225352, 0.0701925,
2065  // -0.24778 };
2066  // int ieta = static_cast<int> (std::abs(eta)/0.10);
2067  // if (ieta > 25) ieta = 25;
2068 
2069  double FinalMeasuredEnergy = MeasCorrected + eOverMipCorrection;// + (fix1FromPeter[ieta] + fix2FromPeter[ieta])*CLHEP::GeV;
2070 
2071  return FinalMeasuredEnergy;
2072 }
2073 
2075  std::stringstream msg;
2076  msg << "Failed to get conditions data " << m_trackingGeometryReadKey.key() << ".";
2077  throw std::runtime_error(msg.str());
2078 }
2079 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloEnergy::Tail
@ Tail
Definition: CaloEnergy.h:43
Trk::ScatteringAngles::deltaPhi
double deltaPhi() const
returns the
Definition: ScatteringAngles.h:82
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
Trk::EnergyLoss::sigmaMinusDeltaE
double sigmaMinusDeltaE() const
returns the negative side
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
Trk::TrackStateOnSurface::CaloDeposit
@ CaloDeposit
This TSOS contains a CaloEnergy object.
Definition: TrackStateOnSurface.h:135
EnergyLoss.h
Trk::TrackStateOnSurface::Perigee
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
Definition: TrackStateOnSurface.h:117
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
ScatteringAngles.h
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
Trk::BoundarySurface
Definition: BoundarySurface.h:50
Trk::TrkMaterialProviderTool::m_paramPtCut
double m_paramPtCut
Definition: TrkMaterialProviderTool.h:227
Amg::hasPositiveDiagElems
bool hasPositiveDiagElems(const AmgSymMatrix(N) &mat)
Returns true if all diagonal elements of the covariance matrix are finite aka sane in the above defin...
Definition: EventPrimitivesCovarianceHelpers.h:96
Trk::TrkMaterialProviderTool::getMopAndIoniEnergyLoss
void getMopAndIoniEnergyLoss(const std::vector< const Trk::TrackStateOnSurface * > *matvec, double pCaloEntry, double scaleEloss, double &mopEloss, double &meanElossIoni, double &sigmaElossIoni) const
Function to get mop and mean (ionization) energy loss.
Definition: TrkMaterialProviderTool.cxx:1862
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CaloEnergy::clone
CaloEnergy * clone() const
Virtual constructor.
Definition: CaloEnergy.h:165
Trk::TrkMaterialProviderTool::m_aggregateTSOS
bool m_aggregateTSOS
Definition: TrkMaterialProviderTool.h:223
Trk::TrkMaterialProviderTool::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: TrkMaterialProviderTool.cxx:125
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CaloEnergy
class extending the basic Trk::EnergyLoss to describe the measured or parameterised muon energy loss ...
Definition: CaloEnergy.h:28
Trk::ParametersBase::charge
double charge() const
Returns the charge.
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
AtlasFieldCacheCondObj
Definition: AtlasFieldCacheCondObj.h:19
CaloEnergy::set_paramEnergyLoss
void set_paramEnergyLoss(const double deltaE, const double sigmaMinusDeltaE, const double sigmaPlusDeltaE)
set parametrised energy loss
Definition: CaloEnergy.h:133
Trk::TrkMaterialProviderTool::removeOutOfCalo
void removeOutOfCalo(std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
Helper to remove MS and ID TSOS.
Definition: TrkMaterialProviderTool.cxx:1010
OfflineHitType::InertMaterial
@ InertMaterial
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::Track::trackStateOnSurfaces
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
Rec::CaloMeas::LArEM_EnergyMeasured
double LArEM_EnergyMeasured(void) const
Definition: CaloMeas.h:84
EventPrimitivesHelpers.h
Trk::TrkMaterialProviderTool::updateVectorMS
void updateVectorMS(Trk::TrackStates *inputTSOS, const Trk::TrackStates::iterator &firstMS, double X0ScaleMS, double ElossScaleMS) const
update the TSOS vector for the Muon Spectrometer applying X0 and Eloss scaling
Definition: TrkMaterialProviderTool.cxx:1089
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CaloEnergy::deltaEMeas
double deltaEMeas() const
get measured energy loss
Definition: CaloEnergy.h:127
Trk::ITrackingVolumesSvc::MuonSpectrometerEntryLayer
@ MuonSpectrometerEntryLayer
Tracking Volume which defines the entrance surfaces of the MS.
Definition: ITrackingVolumesSvc.h:41
Trk::EnergyLoss::sigmaDeltaE
double sigmaDeltaE() const
returns the symmatric error
Trk::TrkMaterialProviderTool::getCaloExitTSOS
const Trk::TrackStateOnSurface * getCaloExitTSOS(const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
Helper to get last calo TSOS with TP.
Definition: TrkMaterialProviderTool.cxx:952
Trk::TrkMaterialProviderTool::m_repositionTSOS
bool m_repositionTSOS
Definition: TrkMaterialProviderTool.h:222
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
Trk::ScatteringAngles
represents a deflection of the track caused through multiple scattering in material.
Definition: ScatteringAngles.h:26
Trk::MaterialEffectsBase::thicknessInX0
double thicknessInX0() const
returns the actually traversed material .
CaloEnergy::deltaEParam
double deltaEParam() const
get parametrised energy loss
Definition: CaloEnergy.h:137
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::TrkMaterialProviderTool::updateVector
static void updateVector(Trk::TrackStates *inputTSOS, Trk::TrackStates::iterator lastID, Trk::TrackStates::iterator firstMS, Trk::TrackStates *caloTSOS)
Helper to update entries in the vector.
Definition: TrkMaterialProviderTool.cxx:1059
Trk::EnergyLoss::sigmaRad
double sigmaRad() const
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::EnergyLoss::meanIoni
double meanIoni() const
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
MagField::AtlasFieldCache::toroidOn
bool toroidOn() const
Trk::TrkMaterialProviderTool::m_useMuonCaloEnergyTool
bool m_useMuonCaloEnergyTool
Definition: TrkMaterialProviderTool.h:229
Rec::CaloMeas::LArHEC_EnergyMeasured
double LArHEC_EnergyMeasured(void) const
Definition: CaloMeas.h:72
CaloEnergy::set_measEnergyLoss
void set_measEnergyLoss(const double deltaE, const double sigmaDeltaE)
set measured energy loss
Definition: CaloEnergy.h:124
CaloEnergy::sigmaDeltaEMeas
double sigmaDeltaEMeas() const
get measured energy loss error
Definition: CaloEnergy.h:130
IdentifierExtractor.h
Trk::TrkMaterialProviderTool::m_overwriteElossParam
bool m_overwriteElossParam
Definition: TrkMaterialProviderTool.h:230
Trk::TrkMaterialProviderTool::getCaloTSOS
std::vector< const Trk::TrackStateOnSurface * > * getCaloTSOS(const Trk::TrackParameters &parm, const Trk::Track &muonTrack, const Trk::TrackParameters *parms=nullptr) const
Retrieve Calorimeter TSOS from TG and apply corrections.
Definition: TrkMaterialProviderTool.cxx:516
Trk::Charged
Definition: Charged.h:27
Trk::TrkMaterialProviderTool::deleteTSOS
static void deleteTSOS(const std::vector< const Trk::TrackStateOnSurface * > *vecTSOS)
Definition: TrkMaterialProviderTool.cxx:1235
Trk::TrkMaterialProviderTool::getCaloMEOT
void getCaloMEOT(const Trk::Track &idTrack, const Trk::Track &msTrack, std::vector< MaterialEffectsOnTrack > &calomeots) const
Get Calorimeter MEOT.
Definition: TrkMaterialProviderTool.cxx:367
pdg_comparison.X0
X0
Definition: pdg_comparison.py:314
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
Trk::EnergyLoss::length
double length() const
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
Trk::ScatteringAngles::sigmaDeltaTheta
double sigmaDeltaTheta() const
returns the
Definition: ScatteringAngles.h:100
Trk::TrkMaterialProviderTool::getParamCaloELoss
CaloEnergy * getParamCaloELoss(Trk::Track *track) const
Retrieve a clone of the parametrised energy loss.
Definition: TrkMaterialProviderTool.cxx:917
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CaloEnergy::energyLossType
CaloEnergy::EnergyLossType energyLossType(void) const
Accessor methods.
Definition: CaloEnergy.h:162
Trk::BoundarySurface::surfaceRepresentation
virtual const Surface & surfaceRepresentation() const =0
The Surface Representation of this.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::TrkMaterialProviderTool::throwFailedToGetTrackingGeomtry
void throwFailedToGetTrackingGeomtry() const
Definition: TrkMaterialProviderTool.cxx:2074
Trk::TrkMaterialProviderTool::getFinalMeasuredEnergy
double getFinalMeasuredEnergy(Rec::CaloMeas *caloMeas, double mopEloss, double meanElossIoni, double eta, double &fsrCaloEnergy) const
Function to get corrected (final) calorimeter measured energy loss.
Definition: TrkMaterialProviderTool.cxx:1965
updateDocumentation.wdir
wdir
Definition: updateDocumentation.py:8
Trk::TrkMaterialProviderTool::m_useCaloEnergyMeasurement
bool m_useCaloEnergyMeasurement
Definition: TrkMaterialProviderTool.h:228
Trk::TrackStates
DataVector< const Trk::TrackStateOnSurface > TrackStates
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:30
Trk::TrkMaterialProviderTool::isIsolatedTrack
bool isIsolatedTrack(double eta, double phi) const
Function to check isolation.
Definition: TrkMaterialProviderTool.cxx:1937
Rec::CaloMeas
Definition: CaloMeas.h:19
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:66
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
perfmonmt-refit.n_tot
n_tot
Definition: perfmonmt-refit.py:104
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
Trk::MaterialEffectsBase::ScatteringEffects
@ ScatteringEffects
contains material effects due to multiple scattering
Definition: MaterialEffectsBase.h:45
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
DataVector< const Trk::TrackStateOnSurface >
Trk::EnergyLoss::meanRad
double meanRad() const
Trk::TrkMaterialProviderTool::removeMS
void removeMS(std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
Helper to remove only MS TSOS.
Definition: TrkMaterialProviderTool.cxx:1034
Trk::TrkMaterialProviderTool::m_applyTGScaling
bool m_applyTGScaling
Definition: TrkMaterialProviderTool.h:221
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::ITrackingVolumesSvc::CalorimeterEntryLayer
@ CalorimeterEntryLayer
Tracking Volume which defines the entrance srufaces of the calorimeter.
Definition: ITrackingVolumesSvc.h:40
myLocal_resetTrack
void myLocal_resetTrack(Trk::Track &track)
Definition: TrkMaterialProviderTool.cxx:33
CaloMeas.h
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::Track::trackParameters
const DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:97
Trk::TrkMaterialProviderTool::m_maxNTracksIso
int m_maxNTracksIso
Definition: TrkMaterialProviderTool.h:226
Athena::Units
Definition: Units.h:45
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
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
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
DataVector< const Trk::TrackStateOnSurface >::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
Definition: DataVector.h:846
Amg::error
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Definition: EventPrimitivesHelpers.h:40
Trk::TrackStateOnSurface::InertMaterial
@ InertMaterial
This represents inert material, and so will contain MaterialEffectsBase.
Definition: TrackStateOnSurface.h:105
Rec::CaloMeas::Tile_EnergyMeasured
double Tile_EnergyMeasured(void) const
Definition: CaloMeas.h:60
Trk::Track::setTrackStateOnSurfaces
void setTrackStateOnSurfaces(std::unique_ptr< Trk::TrackStates > input)
Set the TrackStateOnSurfaces.
CaloEnergy::caloMuonIdTag
unsigned short caloMuonIdTag() const
the Calo Muon Identification tag
Definition: CaloEnergy.h:85
Trk::EnergyLoss
This class describes energy loss material effects in the ATLAS tracking EDM.
Definition: EnergyLoss.h:34
CaloEnergy::sigmaPlusDeltaEParam
double sigmaPlusDeltaEParam() const
get parametrised energy loss plus error
Definition: CaloEnergy.h:143
Trk::TrackingVolume::boundarySurfacesOrdered
std::vector< BoundaryIntersection< T > > boundarySurfacesOrdered(const T &parameters, PropDirection pDir=alongMomentum, bool startOffBoundary=false) const
Returns the boundary surfaces ordered in probability to hit them based on straight line intersection.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CaloEnergy::sigmaMinusDeltaEParam
double sigmaMinusDeltaEParam() const
get parametrised energy loss minus error
Definition: CaloEnergy.h:140
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Rec::CaloMeas::Tile_SamplingFraction
double Tile_SamplingFraction(void) const
Definition: CaloMeas.h:68
Trk::MaterialEffectsBase::EnergyLossEffects
@ EnergyLossEffects
contains energy loss corrections
Definition: MaterialEffectsBase.h:48
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::TrkMaterialProviderTool::printTSOS
void printTSOS(const Trk::TrackStateOnSurface *m, const std::string &tag) const
Definition: TrkMaterialProviderTool.cxx:1254
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trk::IdentifierExtractor::extract
static void extract(std::vector< Identifier > &ids, const std::vector< const MeasurementBase * > &measurements)
Definition: IdentifierExtractor.cxx:13
EventPrimitivesCovarianceHelpers.h
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
TrkMaterialProviderTool.h
Trk::MaterialProperties
Definition: MaterialProperties.h:40
TrackingVolume.h
Trk::MaterialEffectsOnTrack::energyLoss
const EnergyLoss * energyLoss() const
returns the energy loss object.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::TrkMaterialProviderTool::m_updateTSOS
bool m_updateTSOS
Definition: TrkMaterialProviderTool.h:224
CaloEnergy::NotIsolated
@ NotIsolated
Definition: CaloEnergy.h:43
Trk::MaterialEffectsOnTrack::scatteringAngles
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
MagField::AtlasFieldCache
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: AtlasFieldCache.h:43
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::TrackingGeometry::trackingVolume
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
Trk::ScatteringAngles::sigmaDeltaPhi
double sigmaDeltaPhi() const
returns the
Definition: ScatteringAngles.h:94
Trk::TrackStateOnSurface::Scatterer
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
Definition: TrackStateOnSurface.h:113
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
DataVector::ownPolicy
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
Trk::TrkMaterialProviderTool::initialize
StatusCode initialize()
AlgTool initailize method.
Definition: TrkMaterialProviderTool.cxx:68
TrackingGeometry.h
Trk::phi
@ phi
Definition: ParamDefs.h:75
Trk::TrkMaterialProviderTool::getCaloMeasuredEnergy
double getCaloMeasuredEnergy(double eta, double phi, double mopEloss, double meanElossIoni, double &fsrCaloEnergy) const
Function to get calorimeter measured energy loss.
Definition: TrkMaterialProviderTool.cxx:1949
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
calibdata.copy
bool copy
Definition: calibdata.py:27
Trk::TrkMaterialProviderTool::getVolumeByGeo
unsigned int getVolumeByGeo(const Trk::TrackStateOnSurface *m) const
Definition: TrkMaterialProviderTool.cxx:1213
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
Trk::ScatteringAngles::deltaTheta
double deltaTheta() const
returns the
Definition: ScatteringAngles.h:88
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
Trk::TrkMaterialProviderTool::modifyTSOSvector
Trk::TrackStates * modifyTSOSvector(const std::vector< const Trk::TrackStateOnSurface * > *matvec, double scaleX0, double scaleEloss, bool reposition, bool aggregate, bool updateEloss, double caloEnergy, double caloEnergyError, double fsrCaloEnergy, double pCaloEntry, double momentumError, double &Eloss_tot, bool useMeasuredEnergy=true, double mopEloss=0., double meanElossIoni=0., double sigmaElossIoni=0.) const
Function to modify TSOS doing repositioning, aggregation and corrections.
Definition: TrkMaterialProviderTool.cxx:1301
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
DataVector::erase
iterator erase(iterator position)
Remove element at a given position.
Trk::TrkMaterialProviderTool::TrkMaterialProviderTool
TrkMaterialProviderTool(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
Definition: TrkMaterialProviderTool.cxx:39
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:31
Trk::Volume
Definition: Volume.h:35
Trk::TrkMaterialProviderTool
Definition: TrkMaterialProviderTool.h:54
Rec::CaloMeas::LArEM_SamplingFraction
double LArEM_SamplingFraction(void) const
Definition: CaloMeas.h:96
Trk::TrackingVolume
Definition: TrackingVolume.h:121
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::MaterialEffectsBase::associatedSurface
const Surface & associatedSurface() const
returns the surface to which these m.eff. are associated.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Trk::EnergyLoss::sigmaPlusDeltaE
double sigmaPlusDeltaE() const
returns the positive side
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
Trk::TrkMaterialProviderTool::getCaloEntryTSOS
const Trk::TrackStateOnSurface * getCaloEntryTSOS(const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
Helper to get first calo TSOS with TP.
Definition: TrkMaterialProviderTool.cxx:981
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
CaloEnergy::caloLRLikelihood
double caloLRLikelihood() const
the calo Muon Identification likehood
Definition: CaloEnergy.h:88
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Trk::TrkMaterialProviderTool::updateCaloTSOS
void updateCaloTSOS(const Trk::Track &idTrack, Trk::Track &extrapolatedTrack) const
Update Calorimeter TSOS from input ID and MS tracks.
Definition: TrkMaterialProviderTool.cxx:245
Trk::EnergyLoss::sigmaIoni
double sigmaIoni() const
Rec::CaloMeas::LArHEC_SamplingFraction
double LArHEC_SamplingFraction(void) const
Definition: CaloMeas.h:80
CaloEnergy.h
Identifier
Definition: IdentifierFieldParser.cxx:14