ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::TrkMaterialProviderTool Class Referencefinal

#include <TrkMaterialProviderTool.h>

Inheritance diagram for Trk::TrkMaterialProviderTool:
Collaboration diagram for Trk::TrkMaterialProviderTool:

Public Member Functions

 TrkMaterialProviderTool (const std::string &, const std::string &, const IInterface *)
 AlgTool like constructor.
virtual ~TrkMaterialProviderTool ()=default
 Virtual destructor.
StatusCode initialize ()
 AlgTool initailize method.
StatusCode finalize ()
 AlgTool finalize method.
void updateCaloTSOS (const Trk::Track &idTrack, Trk::Track &extrapolatedTrack) const
 Update Calorimeter TSOS from input ID and MS tracks.
void updateCaloTSOS (Trk::Track &track, const Trk::TrackParameters *startParamaters=nullptr) const
 Update Calorimeter TSOS from input MS/CB track.
void getCaloMEOT (const Trk::Track &idTrack, const Trk::Track &msTrack, std::vector< MaterialEffectsOnTrack > &calomeots) const
 Get Calorimeter MEOT.
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.
CaloEnergygetParamCaloELoss (Trk::Track *track) const
 Retrieve a clone of the parametrised energy loss.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Trk::TrackStatesgetCaloTSOS (const Trk::TrackParameters &parm, const Trk::Track &muonTrack, const Trk::Surface &surf, Trk::PropDirection dir, Trk::ParticleHypothesis mateffects, double &Eloss, double &X0ScaleMS, double &ElossScaleMS, const Trk::TrackParameters *parms=nullptr, bool boundaryCheck=false, bool removeOoC=false) const
 Internal method to retrieve Calorimeter TSOS from TG and apply corrections.
const Trk::TrackStateOnSurfacegetCaloExitTSOS (const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
 Helper to get last calo TSOS with TP.
const Trk::TrackStateOnSurfacegetCaloEntryTSOS (const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
 Helper to get first calo TSOS with TP.
void removeOutOfCalo (std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
 Helper to remove MS and ID TSOS.
void removeMS (std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
 Helper to remove only MS TSOS.
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
unsigned int getVolumeByGeo (const Trk::TrackStateOnSurface *m) const
void printTSOS (const Trk::TrackStateOnSurface *m, const std::string &tag) const
Trk::TrackStatesmodifyTSOSvector (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.
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.
bool isIsolatedTrack (double eta, double phi) const
 Function to check isolation.
double getCaloMeasuredEnergy (double eta, double phi, double mopEloss, double meanElossIoni, double &fsrCaloEnergy) const
 Function to get calorimeter measured energy loss.
double getFinalMeasuredEnergy (Rec::CaloMeas *caloMeas, double mopEloss, double meanElossIoni, double eta, double &fsrCaloEnergy) const
 Function to get corrected (final) calorimeter measured energy loss.
void throwFailedToGetTrackingGeomtry () const
const TrackingGeometryretrieveTrackingGeometry (const EventContext &ctx) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static void updateVector (Trk::TrackStates *inputTSOS, Trk::TrackStates::iterator lastID, Trk::TrackStates::iterator firstMS, Trk::TrackStates *caloTSOS)
 Helper to update entries in the vector.
static void deleteTSOS (const std::vector< const Trk::TrackStateOnSurface * > *vecTSOS)
static void deleteTSOS (Trk::TrackStates *vecTSOS)

Private Attributes

PublicToolHandle< Trk::IExtrapolatorm_muonExtrapolator {this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator",""}
PublicToolHandle< Trk::IEnergyLossUpdatorm_elossupdator {this,"EnergyLossUpdator","Trk::EnergyLossUpdator/AtlasEnergyLossUpdator",""}
ServiceHandle< Trk::ITrackingVolumesSvcm_trackingVolumesSvc {this, "TrackingVolumeSvc", "Trk::TrackingVolumesSvc/TrackingVolumesSvc"}
ServiceHandle< ITrackingGeometrySvcm_trackingGeometrySvc {this, "TrackingGeometrySvc", "", ""}
SG::ReadCondHandleKey< TrackingGeometrym_trackingGeometryReadKey {this, "TrackingGeometryReadKey", "", "Key of the TrackingGeometry conditions data."}
ToolHandle< Trk::IMultipleScatteringUpdatorm_scattool
ToolHandle< Rec::IMuidCaloEnergyMeasm_caloMeasTool {this, "CaloMeasTool", "Rec::MuidCaloEnergyMeas/MuidCaloEnergyMeas"}
ToolHandle< Rec::IMuidCaloEnergyParamm_caloParamTool {this, "CaloParamTool", "Rec::MuidCaloEnergyParam/MuidCaloEnergyParam"}
ToolHandle< Rec::IMuidTrackIsolationm_trackIsolationTool {this, "TrackIsolationTool", "Rec::MuidTrackIsolation/MuidTrackIsolation"}
ToolHandle< Rec::IMuonCaloEnergyToolm_muonCaloEnergyTool
const AtlasDetectorIDm_DetID
std::unique_ptr< Trk::Volumem_calorimeterVolume
std::unique_ptr< Trk::Volumem_indetVolume
SG::ReadCondHandleKey< AtlasFieldCacheCondObjm_fieldCacheCondObjInputKey
bool m_applyTGScaling
bool m_repositionTSOS
bool m_aggregateTSOS
bool m_updateTSOS
int m_maxNTracksIso
double m_paramPtCut
bool m_useCaloEnergyMeasurement
bool m_useMuonCaloEnergyTool
bool m_overwriteElossParam
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 55 of file TrkMaterialProviderTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrkMaterialProviderTool()

TrkMaterialProviderTool::TrkMaterialProviderTool ( const std::string & t,
const std::string & n,
const IInterface * p )

AlgTool like constructor.

Definition at line 39 of file TrkMaterialProviderTool.cxx.

40 : AthAlgTool(t,n,p),
41 m_DetID(nullptr),
43 m_paramPtCut(15.0*Gaudi::Units::GeV),
47{
48 declareInterface<ITrkMaterialProviderTool>(this);
49
50 declareProperty("ApplyTGScaling", m_applyTGScaling = true );
51 declareProperty("RpositionTSOS", m_repositionTSOS = true );
52 declareProperty("AggregateTSOS", m_aggregateTSOS = true );
53 declareProperty("UpdateTSOS", m_updateTSOS = true );
54 declareProperty("MaxNTracksIso", m_maxNTracksIso);
55 declareProperty("ParamPtCut", m_paramPtCut);
56 declareProperty("UseCaloEnergyMeasurement", m_useCaloEnergyMeasurement);
57 declareProperty("UseMuonCaloEnergyTool", m_useMuonCaloEnergyTool);
58// this is a temporary solution to write Eloss information in the muon to validate the Eloss
59// default value should be false
60 declareProperty("OverwriteElossParam", m_overwriteElossParam);
61}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~TrkMaterialProviderTool()

virtual Trk::TrkMaterialProviderTool::~TrkMaterialProviderTool ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ deleteTSOS() [1/2]

void TrkMaterialProviderTool::deleteTSOS ( const std::vector< const Trk::TrackStateOnSurface * > * vecTSOS)
staticprivate

Definition at line 1233 of file TrkMaterialProviderTool.cxx.

1234{
1235 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = vecTSOS->begin();
1236 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = vecTSOS->end();
1237 for (; it != itEnd; ++it) delete *it;
1238 delete vecTSOS;
1239}

◆ deleteTSOS() [2/2]

void TrkMaterialProviderTool::deleteTSOS ( Trk::TrackStates * vecTSOS)
staticprivate

Definition at line 1240 of file TrkMaterialProviderTool.cxx.

1241{
1242 if(vecTSOS->ownPolicy()==SG::VIEW_ELEMENTS) {
1244 Trk::TrackStates::const_iterator itEnd = vecTSOS->end();
1245 for (; it != itEnd; ++it) delete *it;
1246 }
1247 delete vecTSOS;
1248}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode TrkMaterialProviderTool::finalize ( )

AlgTool finalize method.

Definition at line 123 of file TrkMaterialProviderTool.cxx.

124{
125 ATH_MSG_DEBUG( name() << " finalize() successful" );
126 return StatusCode::SUCCESS;
127}
#define ATH_MSG_DEBUG(x)

◆ getCaloEntryTSOS()

const Trk::TrackStateOnSurface * TrkMaterialProviderTool::getCaloEntryTSOS ( const std::vector< const Trk::TrackStateOnSurface * > * caloTSOS,
Trk::PropDirection dir ) const
private

Helper to get first calo TSOS with TP.

Definition at line 979 of file TrkMaterialProviderTool.cxx.

980{
981 const Trk::TrackStateOnSurface* tsosAtCaloEntry = nullptr;
982 if(dir==Trk::alongMomentum) {
983 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = caloTSOS->begin();
984 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = caloTSOS->end();
985 for(; it!=itEnd; ++it) {
986 if((*it)->trackParameters()) {
987 ATH_MSG_DEBUG("Parameters at CALO entry found : "<< *((*it)->trackParameters()));
988 tsosAtCaloEntry = *it;
989 return tsosAtCaloEntry;
990 }
991 }
992 }else{
993 std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator it = caloTSOS->rbegin();
994 std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator itEnd = caloTSOS->rend();
995 for(; it!=itEnd; ++it) {
996 if((*it)->trackParameters()) {
997 ATH_MSG_DEBUG("Parameters at CALO entry found : "<< *((*it)->trackParameters()));
998 tsosAtCaloEntry = *it;
999 return tsosAtCaloEntry;
1000 }
1001 }
1002 }
1003 return tsosAtCaloEntry;
1004}
@ alongMomentum

◆ getCaloExitTSOS()

const Trk::TrackStateOnSurface * TrkMaterialProviderTool::getCaloExitTSOS ( const std::vector< const Trk::TrackStateOnSurface * > * caloTSOS,
Trk::PropDirection dir ) const
private

Helper to get last calo TSOS with TP.

Definition at line 950 of file TrkMaterialProviderTool.cxx.

951{
952 const Trk::TrackStateOnSurface* tsosAtCaloExit = nullptr;
953 if(dir==Trk::alongMomentum) {
954 std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator it = caloTSOS->rbegin();
955 std::vector<const Trk::TrackStateOnSurface*>::const_reverse_iterator itEnd = caloTSOS->rend();
956 for(; it!=itEnd; ++it) {
957 if((*it)->trackParameters()) {
958 ATH_MSG_DEBUG("Parameters at CALO exit found : "<< *((*it)->trackParameters()));
959 tsosAtCaloExit = *it;
960 return tsosAtCaloExit;
961 }
962 }
963 }else{
964 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it = caloTSOS->begin();
965 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd = caloTSOS->end();
966 for(; it!=itEnd; ++it) {
967 if((*it)->trackParameters()) {
968 ATH_MSG_DEBUG("Parameters at CALO exit found : "<< *((*it)->trackParameters()));
969 tsosAtCaloExit = *it;
970 return tsosAtCaloExit;
971 }
972 }
973 }
974 return tsosAtCaloExit;
975}

◆ getCaloMeasuredEnergy()

double TrkMaterialProviderTool::getCaloMeasuredEnergy ( double eta,
double phi,
double mopEloss,
double meanElossIoni,
double & fsrCaloEnergy ) const
private

Function to get calorimeter measured energy loss.

Definition at line 1947 of file TrkMaterialProviderTool.cxx.

1951{
1952 // Retrieve the measured energy from calorimeter
1953 std::unique_ptr<Rec::CaloMeas> caloMeas = m_caloMeasTool->energyMeasurement(Gaudi::Hive::currentContext(),eta,phi,eta,phi);
1954
1955
1956 // Sum-up components
1957 double FinalMeasuredEnergy = getFinalMeasuredEnergy(caloMeas.get(), totalEloss, meanElossIoni, eta, fsrCaloEnergy);
1958
1959 return FinalMeasuredEnergy;
1960}
Scalar eta() const
pseudorapidity method
double getFinalMeasuredEnergy(Rec::CaloMeas *caloMeas, double mopEloss, double meanElossIoni, double eta, double &fsrCaloEnergy) const
Function to get corrected (final) calorimeter measured energy loss.
ToolHandle< Rec::IMuidCaloEnergyMeas > m_caloMeasTool
@ phi
Definition ParamDefs.h:75

◆ getCaloMEOT()

void TrkMaterialProviderTool::getCaloMEOT ( const Trk::Track & idTrack,
const Trk::Track & msTrack,
std::vector< MaterialEffectsOnTrack > & calomeots ) const
virtual

Get Calorimeter MEOT.

Implements Trk::ITrkMaterialProviderTool.

Definition at line 365 of file TrkMaterialProviderTool.cxx.

367{
368 ATH_MSG_VERBOSE("getCaloMEOT(const Trk::Track& idTrack, const Trk::Track& msTrack, std::vector<MaterialEffectsOnTrack>& calomeots)");
369
370 const Trk::TrackStates* inputTSOS_ID = idTrack.trackStateOnSurfaces();
371 const Trk::TrackStates* inputTSOS_MS = msTrack.trackStateOnSurfaces();
372
373#ifdef DEBUGON
374 for(auto m : *inputTSOS_ID) printTSOS(m, "TSOS ID TRACK");
375 for(auto m : *inputTSOS_MS) printTSOS(m, "TSOS MS TRACK");
376#endif
377
378 // find last ID TSOS
379 Trk::TrackStates::const_reverse_iterator lastIDwP = inputTSOS_ID->rbegin();
380 for (auto it = inputTSOS_ID->rbegin(); it != inputTSOS_ID->rend(); ++it) {
381 if(this->getVolumeByGeo(*it)==1 && (*it)->trackParameters()) {
382 lastIDwP = it;
383 break;
384 }
385 }
386
387 if(lastIDwP == inputTSOS_ID->rend()) {
388 ATH_MSG_WARNING("Unable to find last ID TSOS with Track Parameters");
389 ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
390 return;
391 }
392
393 // find first MS TSOS
394 Trk::TrackStates::const_iterator firstMS = inputTSOS_MS->end();
395 Trk::TrackStates::const_iterator firstMSwP = inputTSOS_MS->end();
396 Trk::TrackStates::const_iterator itEnd = inputTSOS_MS->end();
397 for(auto it = inputTSOS_MS->begin(); it!=itEnd ; ++it) {
398 if(this->getVolumeByGeo(*it)==3) {// && !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
399 if(firstMS==itEnd)
400 firstMS = it;
401 if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
402 firstMSwP = it;
403 break;
404 }
405 }
406 }
407
408 if(firstMS == inputTSOS_MS->end()) {
409 ATH_MSG_WARNING("Unable to find first MS TSOS");
410 ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
411 return;
412 }
413
414 // check that first MS TSOS is not a PerigeeSurface
415 Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
416 if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS_MS->end()) {
417 firstMSnotPerigee=firstMS+1;
418 }
419
420#ifdef DEBUGON
421 printTSOS(*lastIDwP, "LAST IDwP");
422 printTSOS(*firstMSnotPerigee, "FIRST MS");
423 if(firstMSwP != inputTSOS_MS->end())
424 printTSOS(*firstMSwP, "FIRST MSwP");
425 else
426 ATH_MSG_WARNING("Unable to find first MS TSOS with Track Parameters!");
427#endif
428
429 MagField::AtlasFieldCache fieldCache;
430 // Get field cache object
431 const EventContext& ctx = Gaudi::Hive::currentContext();
432 SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx};
433 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
434
435 if (fieldCondObj == nullptr) {
436 ATH_MSG_ERROR("Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key());
437 return;
438 }
439 fieldCondObj->getInitializedCache (fieldCache);
440
441 double Eloss = 0.;
442 double X0ScaleMS = 0.;
443 double ElossScaleMS = 0.;
444 // get calorimeter TSOS from TG
445 Trk::TrackStates* caloTSOS = this->getCaloTSOS (*(*lastIDwP)->trackParameters(),
446 // idTrack,
447 fieldCache.toroidOn() ? msTrack : idTrack,
448 (*firstMSnotPerigee)->surface(),
450 Trk::muon,
451 Eloss, X0ScaleMS, ElossScaleMS,
452 (firstMSwP == inputTSOS_MS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
453 false,
454 true);
455
456 if (!caloTSOS || caloTSOS->size() != 3)
457 {
458 double idqOverP = std::abs(idTrack.perigeeParameters()->parameters()[Trk::qOverP]);
459 double msqOverP = msTrack.perigeeParameters() ? msTrack.perigeeParameters()->parameters()[Trk::qOverP] : (*firstMS)->trackParameters()->parameters()[Trk::qOverP] ;
460
461 if ((!fieldCache.toroidOn() && idqOverP * 4000. < 1) || (fieldCache.toroidOn() && msqOverP != 1 / 100000. && msqOverP != 0))
462 {
463 // Warnings only for high momentum ID tracks and MS tracks that have measured curvature (Straight track has pq= 100000)
464 if (!fieldCache.toroidOn())
465 ATH_MSG_WARNING(" Toroid off q*momentum of ID track " << 1. / idqOverP);
466 if (fieldCache.toroidOn())
467 ATH_MSG_WARNING(" Toroid on q*momentum of MS track " << 1. / msqOverP);
468 ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM+aggregation (null or !=3)");
469 if (!caloTSOS) {
470 ATH_MSG_WARNING(" Zero Calorimeter TSOS from extrapolateM+aggregation");
471 } else {
472 ATH_MSG_WARNING(" nr Calorimeter TSOS from extrapolateM+aggregation not equal to 3 " << caloTSOS->size());
473 }
474 }
475
476 if (caloTSOS) deleteTSOS(caloTSOS);
477
478 return;
479 }
480
481 for (auto && i : *caloTSOS){
482 const Trk::MaterialEffectsOnTrack *meot=dynamic_cast<const Trk::MaterialEffectsOnTrack *>(i->materialEffectsOnTrack());
483 if (!meot) {
484 throw std::logic_error("TrackStateOnSurface without material effects on track." );
485 }
486 double sintheta=std::sin(i->trackParameters()->parameters()[Trk::theta]);
487 double qoverp=i->trackParameters()->parameters()[Trk::qOverP];
488 const CaloEnergy *eloss=nullptr;
489 if (meot) eloss=dynamic_cast<const CaloEnergy *>(meot->energyLoss());
490
491 std::unique_ptr<Trk::EnergyLoss> neweloss=nullptr;
492 std::optional<Trk::ScatteringAngles> newsa= std::nullopt;
493 if (eloss) neweloss = std::make_unique<CaloEnergy>(*eloss);
494 else{
495 Trk::MaterialProperties matprop(meot->thicknessInX0(),1.,0.,0.,0.,0.);
496 double sigmascat = std::abs(qoverp)>0.0 ? std::sqrt(m_scattool->sigmaSquare(matprop,std::abs(1./qoverp),1.,Trk::muon)) : 0.0;
497 newsa=Trk::ScatteringAngles(0,0,sigmascat/sintheta,sigmascat);
498 }
499 Trk::MaterialEffectsOnTrack newmeot(
500 meot->thicknessInX0(),
501 newsa,
502 std::move(neweloss),
503 i->trackParameters()->associatedSurface());
504 calomeots.push_back(newmeot);
505 delete i;
506 }
507 delete caloTSOS;
508}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataVector.h:847
size_type size() const noexcept
Returns the number of elements in the collection.
double thicknessInX0() const
returns the actually traversed material .
const EnergyLoss * energyLoss() const
returns the energy loss object.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
const Perigee * perigeeParameters() const
return Perigee.
static void deleteTSOS(const std::vector< const Trk::TrackStateOnSurface * > *vecTSOS)
void printTSOS(const Trk::TrackStateOnSurface *m, const std::string &tag) const
ToolHandle< Trk::IMultipleScatteringUpdator > m_scattool
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.
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
unsigned int getVolumeByGeo(const Trk::TrackStateOnSurface *m) const
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67

◆ getCaloTSOS() [1/2]

Trk::TrackStates * TrkMaterialProviderTool::getCaloTSOS ( const Trk::TrackParameters & parm,
const Trk::Track & muonTrack,
const Trk::Surface & surf,
Trk::PropDirection dir,
Trk::ParticleHypothesis mateffects,
double & Eloss,
double & X0ScaleMS,
double & ElossScaleMS,
const Trk::TrackParameters * parms = nullptr,
bool boundaryCheck = false,
bool removeOoC = false ) const
private

Internal method to retrieve Calorimeter TSOS from TG and apply corrections.

Definition at line 662 of file TrkMaterialProviderTool.cxx.

673{
674 const EventContext& ctx = Gaudi::Hive::currentContext();
675 bool fremoveMS = false;
676 if(!removeOoC) fremoveMS = true;
677
678 ATH_MSG_DEBUG("Retrieving Calorimeter TSOS from extrapolateM (dir=" << dir << ") with starting parameters : "
679 << parm << " to surface "<<surf);
680 if(parms) ATH_MSG_DEBUG("Parameters in MS provided : "<< *parms);
681
682 double pOri = parm.momentum().mag();
683
684 // Get TSOS from extrapolateM (from TG)
685 std::vector<const Trk::TrackStateOnSurface*>* caloTSOS = m_muonExtrapolator->extrapolateM(ctx,
686 parm,
687 surf, dir,
688 boundaryCheck,
689 mateffects);
690
691 ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM, no-removal");
692
693#ifdef DEBUGON
694 ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM, no-removal");
695 for(auto m : *caloTSOS) this->printTSOS(m, "BEFORE-REMOVAL CALO TSOS");
696#endif
697
698
699 Eloss = 0.;
700 double ElossID = 0.;
701 double ElossCalo = 0.;
702 double ElossMS = 0.;
703 for(const auto *m : *caloTSOS) {
704 if(m->materialEffectsOnTrack()) {
705 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
706 if(meot) {
707 const Trk::EnergyLoss* energyLoss = meot->energyLoss();
708 if (energyLoss) {
709 ATH_MSG_DEBUG(" volume " << this->getVolumeByGeo(m) << " Eloss from extrapolateM TG " << energyLoss->deltaE());
710
711 Eloss += std::abs(energyLoss->deltaE());
712 if(this->getVolumeByGeo(m)==1) ElossID += std::abs(energyLoss->deltaE());
713 if(this->getVolumeByGeo(m)==2) ElossCalo += std::abs(energyLoss->deltaE());
714 if(this->getVolumeByGeo(m)==3) ElossMS += std::abs(energyLoss->deltaE());
715 }
716 }
717 }
718 }
719
720 ATH_MSG_DEBUG("Total Eloss on TSOS from extrapolateM " << Eloss << " ElossID " << ElossID << " ElossMS " << ElossMS <<" Elosscalo " << ElossCalo);
721 if(fremoveMS) ATH_MSG_DEBUG(" ID Eloss will be added to Calo Eloss " << ElossID+ElossCalo);
722
723 Eloss = ElossCalo;
724
725// remove ID and MS TSOSs
726 if(removeOoC && !caloTSOS->empty()) removeOutOfCalo(caloTSOS);
727 ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM");
728// remove MS TSOSs
729 if(fremoveMS && !caloTSOS->empty()) removeMS(caloTSOS);
730 ATH_MSG_DEBUG("Retrieved " << caloTSOS->size() << " Calorimeter TSOS from extrapolateM");
731
732#ifdef DEBUGON
733 for(auto m : *caloTSOS) this->printTSOS(m, "ORIGINAL CALO TSOS");
734#endif
735
736
737 Trk::TrackStates* finalCaloTSOS = nullptr;
738 if(caloTSOS->empty() || Eloss<=0) {
739 if(dir==Trk::alongMomentum&&pOri>4000.) {
740 ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM caloTSOS->size() "<< caloTSOS->size() << " Eloss " << Eloss );
741 ATH_MSG_WARNING(" momentum of track " << pOri);
742 ATH_MSG_WARNING(" momentum extrapolated of track " << parm.momentum().mag() << " radius " << parm.position().perp() << " z " << parm.position().z() );
743 ATH_MSG_WARNING(" surface radius " << surf.center().perp() << " z " << surf.center().z() );
744 if(parms) ATH_MSG_WARNING(" momentum of MS track " << parms->momentum().mag());
745 } // else track did not have enough momentum
746 deleteTSOS(caloTSOS);
747 return finalCaloTSOS;
748 }
749
750 // Apply TG scaling to G4
751 double X0ScaleCALO=1.0;
752 double ElossScaleCALO=1.0;
753 X0ScaleMS=1.0;
754 ElossScaleMS=1.0;
755 const Trk::TrackStateOnSurface* tsosAtCaloExit = this->getCaloExitTSOS(caloTSOS, dir);
756 if(m_applyTGScaling) {
757 if(!tsosAtCaloExit) {
758 ATH_MSG_WARNING( name() << " Unable to find Calorimeter Exit TSOS with TrackParameters! No TG Scaling applied!" );
759 }else{
760 m_elossupdator->getX0ElossScales(1,
761 -log(tan(tsosAtCaloExit->trackParameters()->position().theta()/2)),
762 tsosAtCaloExit->trackParameters()->position().phi(),
763 X0ScaleCALO, ElossScaleCALO);
764 m_elossupdator->getX0ElossScales(0,
765 -log(tan(tsosAtCaloExit->trackParameters()->position().theta()/2)),
766 tsosAtCaloExit->trackParameters()->position().phi(),
767 X0ScaleMS, ElossScaleMS);
768 }
769 }
770 ATH_MSG_DEBUG("Eloss/X0 scaling corrections set to : " << ElossScaleCALO << " " << X0ScaleCALO);
771
772 // Get momentum at calorimeter entrance
773 // Note that for SA fit i'm taking the pAtCaloEntry from the perigee parameters
774 double pAtCaloEntry = 0;
775 if(dir == Trk::alongMomentum) {
776 double OneOverP = std::abs(parm.parameters()[Trk::qOverP]);
777 if (OneOverP > 0.0)
778 pAtCaloEntry = 1./OneOverP;
779 else
780 pAtCaloEntry = parm.momentum().norm();
781 }else{
782 const Trk::TrackStateOnSurface* tsosAtCaloEntry = this->getCaloEntryTSOS(caloTSOS, dir);
783 if(!tsosAtCaloEntry) {
784 ATH_MSG_WARNING( name() << " Unable to find Calorimeter Entry TSOS with TrackParameters! Momentum at Calo Entry not available!" );
785 }else{
786 double OneOverP = std::abs(tsosAtCaloEntry->trackParameters()->parameters()[Trk::qOverP]);
787 if (OneOverP > 0.0)
788 pAtCaloEntry = 1./OneOverP;
789 else
790 pAtCaloEntry = tsosAtCaloEntry->trackParameters()->momentum().norm();
791 }
792 }
793
794 ATH_MSG_DEBUG("Momentum at Calo Entry : " << pAtCaloEntry );
795
796 // If parameters at MS are not provided then try to get them out of extrapolated Calo TSOSs (likely w/o covariance!)
797 if(!parms) {
798 if(!tsosAtCaloExit) {
799 ATH_MSG_DEBUG("Unable to find Calorimeter Exit TSOS with TrackParameters! Momentum at MS not available!" );
800 }else{
801 parms = tsosAtCaloExit->trackParameters();
802 ATH_MSG_DEBUG("MS track parameters taken from calorimeter TSOS");
803 }
804 }
805
806 // Get momentum error in muon spectrometer
807 double pAtMuonEntryError = 0.0;
808 if(parms) {
809 if( std::abs(parms->parameters()[Trk::qOverP]) > 0.0 ) {
810 double pAtMuonEntry = std::abs(1./parms->parameters()[Trk::qOverP]);
811 if (!parms->covariance() ||
812 !Amg::hasPositiveDiagElems(*parms->covariance())) {
814 "MS track parameters without covariance, using 10% relative error!");
815 pAtMuonEntryError = pAtMuonEntry*0.1;
816 } else {
817 double qOverpAtMuonEntryError = Amg::error(*parms->covariance(),Trk::qOverP);
818 pAtMuonEntryError = pAtMuonEntry*pAtMuonEntry*qOverpAtMuonEntryError;
819 }
820 }
821 }
822
823 ATH_MSG_DEBUG("Momentum Error at MS Entry : " << pAtMuonEntryError);
824
825 // Get calorimeter measured energy for pT>m_paramPtCut (15 GeV)
826 double measCaloEnergy = 0.0;
827 double measCaloEnergyError = 0.0;
828 double fsrCaloEnergy = 0.0;
829 double eta = -log(tan(parm.parameters()[Trk::theta]/2));
830 double phi = parm.parameters()[Trk::phi0];
831 double totalEloss=0.0;
832 double meanElossIoni=0.0;
833 double sigmaElossIoni=0.0;
835
836 // Get Mop and Mean (ionization) energy loss from TG after scaling
837 double e_exp=0.0;
838 this->getMopAndIoniEnergyLoss(caloTSOS,
839 pAtCaloEntry,
840 ElossScaleCALO,
841 totalEloss,
842 meanElossIoni,
843 sigmaElossIoni);
844
845 double E_em_meas = 0.;
846 double E_em_exp = 0.;
847 double E_tile_meas = 0.;
848 double E_tile_exp = 0.;
849 double E_HEC_meas = 0.;
850 double E_HEC_exp = 0.;
851 double E_dead_exp = 0.;
852
853 // Get measured energy in calorimeter (run2 tool)
855//
856// sigmaElossIoni should be scaled by 0.45 to go to Landau this is later done in updateEloss
857//
858 if(muonTrack.trackParameters() && !muonTrack.trackParameters()->empty())
859 m_muonCaloEnergyTool->calculateMuonEnergies( &muonTrack,
860 totalEloss, meanElossIoni, 0.45*sigmaElossIoni,
861 measCaloEnergy, measCaloEnergyError, fsrCaloEnergy, e_exp,
862 E_em_meas,E_em_exp,E_tile_meas,E_tile_exp,E_HEC_meas,E_HEC_exp,E_dead_exp);
863
864
865 ATH_MSG_DEBUG(" eta " << eta << " Energy measurement from calorimeter: inputs totalEloss, meanElossIoni, sigmaElossIoni "
866 << totalEloss << " " << meanElossIoni << " " << sigmaElossIoni << " e_exp Ioni from TG " << e_exp << " e_exp original " << e_exp*totalEloss/(meanElossIoni+0.001));
867
868 }
869 // (run1 tool) used for debugging purposes
870 else{
871 measCaloEnergy = this->getCaloMeasuredEnergy(eta,phi,
872 totalEloss,
873 meanElossIoni,
874 fsrCaloEnergy);
875 measCaloEnergyError = 0.50 * sqrt(measCaloEnergy/CLHEP::GeV) * CLHEP::GeV;
876 }
877
878 ATH_MSG_DEBUG("Final measured energy in calorimeter : " << measCaloEnergy << " +- " << measCaloEnergyError << " MeV"
879 << " momentum fraction " << measCaloEnergy/pAtCaloEntry);
880 }
881
882 // Check if we can use the measured eloss in the fit
883 bool useMeasuredEnergy = m_useCaloEnergyMeasurement;
884 if(pAtCaloEntry*sin(parm.parameters()[Trk::theta]) < m_paramPtCut) useMeasuredEnergy = false;
885 if(useMeasuredEnergy && !isIsolatedTrack(eta,phi)) useMeasuredEnergy = false;
886
887 // Total eloss
888 double Eloss_tot=0.0;
889
890 // Aggregate TSOS, applying scaling corrections (if available) and mean-to-mop correction (cloning!)
891 // This function checks if the measured energy loss has to be used assuming the track is isolated.
892 // Need to check for isolation before and pass 0 values for not-isolated tracks.
893 finalCaloTSOS = modifyTSOSvector(caloTSOS, X0ScaleCALO, ElossScaleCALO,
895 measCaloEnergy, measCaloEnergyError, fsrCaloEnergy,
896 pAtCaloEntry, pAtMuonEntryError,
897 Eloss_tot, useMeasuredEnergy,
898 totalEloss, meanElossIoni, sigmaElossIoni);
899
900 ATH_MSG_DEBUG( " after modifyTSOSvector X0ScaleCALO " << X0ScaleCALO << " ElossScaleCALO " << ElossScaleCALO <<
901 " pAtCaloEntry " << pAtCaloEntry << " pAtMuonEntryError " << pAtMuonEntryError << " total Eloss from TG through MuonEnergyTool " << Eloss_tot );
902 ATH_MSG_DEBUG("Aggregating and correcting TSOS down to : " << finalCaloTSOS->size() << " with total Eloss " << Eloss_tot);
903
904#ifdef DEBUGON
905 ATH_MSG_VERBOSE("FINAL CALO TSOS multiplicity : " << finalCaloTSOS->size());
906 for(auto m : *finalCaloTSOS) this->printTSOS(m, "FINAL CALO TSOS");
907#endif
908
909 // delete tsos from extrapolator
910 deleteTSOS(caloTSOS);
911
912 return finalCaloTSOS;
913}
double deltaE() const
returns the
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
const DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
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.
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.
double getCaloMeasuredEnergy(double eta, double phi, double mopEloss, double meanElossIoni, double &fsrCaloEnergy) const
Function to get calorimeter measured energy loss.
PublicToolHandle< Trk::IEnergyLossUpdator > m_elossupdator
const Trk::TrackStateOnSurface * getCaloEntryTSOS(const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
Helper to get first calo TSOS with TP.
void removeMS(std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
Helper to remove only MS TSOS.
const Trk::TrackStateOnSurface * getCaloExitTSOS(const std::vector< const Trk::TrackStateOnSurface * > *caloTSOS, Trk::PropDirection dir) const
Helper to get last calo TSOS with TP.
bool isIsolatedTrack(double eta, double phi) const
Function to check isolation.
ToolHandle< Rec::IMuonCaloEnergyTool > m_muonCaloEnergyTool
PublicToolHandle< Trk::IExtrapolator > m_muonExtrapolator
void removeOutOfCalo(std::vector< const Trk::TrackStateOnSurface * > *caloTSOS) const
Helper to remove MS and ID TSOS.
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 ...
bool hasPositiveDiagElems(const AmgSymMatrix(N) &mat)
Returns true if all diagonal elements of the covariance matrix are finite aka sane in the above defin...
@ phi0
Definition ParamDefs.h:65

◆ getCaloTSOS() [2/2]

std::vector< const Trk::TrackStateOnSurface * > * TrkMaterialProviderTool::getCaloTSOS ( const Trk::TrackParameters & parm,
const Trk::Track & muonTrack,
const Trk::TrackParameters * parms = nullptr ) const
virtual

Retrieve Calorimeter TSOS from TG and apply corrections.

Implements Trk::ITrkMaterialProviderTool.

Definition at line 514 of file TrkMaterialProviderTool.cxx.

516{
517 std::vector<const Trk::TrackStateOnSurface*>* caloTSOS = new std::vector<const Trk::TrackStateOnSurface*>();
518 const Trk::TrackingVolume* targetVolume;
520 const EventContext& ctx = Gaudi::Hive::currentContext();
521
522 const Trk::TrackingGeometry* trackingGeometry = retrieveTrackingGeometry( ctx );
523 if(!trackingGeometry) {
524 ATH_MSG_WARNING("Unable to retrieve tracking geometry");
525 return caloTSOS;
526 }
527
528 // check if parm is expressed at ID or MS and set extrapolation direction and target volume
529 // ID
530 if( m_indetVolume->inside(parm.position()) ) {
532 targetVolume = trackingGeometry->trackingVolume("MuonSpectrometerEntrance");
533 if(!targetVolume) {
534 ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
535 return caloTSOS;
536 }
537 ATH_MSG_VERBOSE("TP inside ID -> extrapolating TP "<<parm<<" to MS entry volume "<<*targetVolume);
538 }
539 // MS
540 else if( !m_calorimeterVolume->inside(parm.position()) ) {
542 targetVolume = trackingGeometry->trackingVolume("InDet::Containers::InnerDetector");
543 if(!targetVolume) {
544 ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
545 return caloTSOS;
546 }
547 ATH_MSG_VERBOSE("TP inside MS -> extrapolating TP "<<parm<<" to ID exit volume "<<*targetVolume);
548 }
549 // CALO, it happens when called leadingTSOS from MS, backward extrapolation ok
550 else{
552 targetVolume = trackingGeometry->trackingVolume("InDet::Containers::InnerDetector");
553 if(!targetVolume) {
554 ATH_MSG_WARNING("Unable to get target volume for calo material collection!");
555 return caloTSOS;
556 }
557 ATH_MSG_DEBUG("TP inside CALO or between CALO and MS -> assuming ID as target : "<<*targetVolume);
558 }
559
560 // When doing backward extrapolation the starting TP are defined at MS entrance
561 // so we use them to get the MS momentum error needed later on when doing TSOS aggregation
562 if(!parms) {
563 if(dir == Trk::oppositeMomentum && parm.covariance())
564 parms = &parm;
565 else{
568 for(; it!=itEnd; ++it) {
569 if(this->getVolumeByGeo(*it)==3) //&& !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
570 if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
571 parms = (*it)->trackParameters();
572 break;
573 }
574 }
575 }
576 }
577
578 if(dir == Trk::oppositeMomentum) {
579//
580// go to Beam line
581//
582 Amg::Vector3D globPos(0.,0.,0.);
583 PerigeeSurface surface(globPos);
584 double Eloss = 0.;
585 double X0ScaleMS = 0.;
586 double ElossScaleMS = 0.;
587 // Collect calorimeter TSOS
588 Trk::TrackStates* caloTSOSdv = this->getCaloTSOS (parm,
589 muonTrack,
590 surface,
591 dir,
592 Trk::muon,
593 Eloss, X0ScaleMS, ElossScaleMS,
594 parms,
595 true,
596 false); // remove only MS TSOS and keep ID+CALO
597
598 if(parms) ATH_MSG_DEBUG(" go to Beam Line parms position radius " << parms->position().perp() << " z " << parms->position().z());
599 ATH_MSG_DEBUG(" go to Beam Line destination surface position radius " << surface.center().perp() << " z " << surface.center().z());
600
601 if(caloTSOSdv) {
602 for(unsigned int i=0; i<caloTSOSdv->size(); ++i)
603 caloTSOS->push_back(caloTSOSdv->get(i));
604 delete caloTSOSdv;
605 }
606 return caloTSOS;
607
608 }
609
610 // get boundary surfaces of the target volume
611 auto boundaryIntersections = targetVolume->boundarySurfacesOrdered<Trk::TrackParameters>(parm,dir,false);
612
613 // loop over surfaces
614 double Eloss_previous = 0.;
615 for (auto& boundaryCandidate : boundaryIntersections){
616
617 // get the surface object at the boundary
618 const Trk::BoundarySurface<Trk::TrackingVolume>* surfaceTV = boundaryCandidate.object;
619 if(!surfaceTV) continue;
620
621 // get the Trk::Surface
622 const Trk::Surface& surface = surfaceTV->surfaceRepresentation();
623 double Eloss = 0.;
624 double X0ScaleMS = 0.;
625 double ElossScaleMS = 0.;
626 // Collect calorimeter TSOS
627 Trk::TrackStates* caloTSOSdv = this->getCaloTSOS (parm,
628 muonTrack,
629 surface,
630 dir,
631 Trk::muon,
632 Eloss, X0ScaleMS, ElossScaleMS,
633 parms,
634 true,
635 true);
636 // hack to convert DataVector to stl vector and delete the DataVector ...
637 if(caloTSOSdv&&Eloss>Eloss_previous) {
638//
639// keep the TSOS vector with the largest Eloss
640// only one of the surfaces gives the rights intersection
641// partial crossing with a plane or a cylinder give less Eloss
642//
643 ATH_MSG_DEBUG(" getCaloTSOS: Previous solution had Eloss " << Eloss_previous << " latest " << Eloss);
644 if(parms) ATH_MSG_DEBUG(" parms position radius " << parms->position().perp() << " z " << parms->position().z());
645 ATH_MSG_DEBUG(" destination surface position radius " << surface.center().perp() << " z " << surface.center().z());
646
647 for(unsigned int i=0; i<caloTSOSdv->size(); ++i)
648 caloTSOS->push_back(caloTSOSdv->get(i));
649 delete caloTSOSdv;
650 return caloTSOS;
651 }
652 }
653
654
655 return caloTSOS;
656}
const T * get(size_type n) const
Access an element, as an rvalue.
virtual const Surface & surfaceRepresentation() const =0
The Surface Representation of this.
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
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.
const TrackingGeometry * retrieveTrackingGeometry(const EventContext &ctx) const
std::unique_ptr< Trk::Volume > m_calorimeterVolume
std::unique_ptr< Trk::Volume > m_indetVolume
Eigen::Matrix< double, 3, 1 > Vector3D
PropDirection
PropDirection, enum for direction of the propagation.
@ oppositeMomentum
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ getFinalMeasuredEnergy()

double TrkMaterialProviderTool::getFinalMeasuredEnergy ( Rec::CaloMeas * caloMeas,
double mopEloss,
double meanElossIoni,
double eta,
double & fsrCaloEnergy ) const
private

Function to get corrected (final) calorimeter measured energy loss.

Function to get corrected calorimeter measured energy loss.

Definition at line 1963 of file TrkMaterialProviderTool.cxx.

1968{
1969 double MopLossCorrected = totalEloss;
1970 double MopLoss = totalEloss;
1971
1972 // FSR candidate energy
1973 fsrCaloEnergy = MopLoss*m_caloParamTool->emMopFraction(eta);
1974
1975 // percentage of inert material
1976 const double InertMaterial = m_caloParamTool->x0mapInertMaterial(eta);
1977 // percentage of em calorimeter material
1978 const double EmMaterial = m_caloParamTool->x0mapEmMaterial(eta);
1979 // percentage of hec calorimeter material
1980 const double HECMaterial = m_caloParamTool->x0mapHecMaterial(eta);
1981 // correction for the inert material
1982 double MaterialCorrection = InertMaterial * MopLossCorrected;
1983
1984 // fraction of Tile used for the measurement
1985 const double TileMeasurementMaterial = caloMeas->Tile_SamplingFraction();
1986 // fraction of LArHEC used for the measurement
1987 const double LArHECMeasurementMaterial = caloMeas->LArHEC_SamplingFraction();
1988 // fraction of LArEM used for the measurement
1989 const double LArEmMeasurementMaterial = caloMeas->LArEM_SamplingFraction();
1990 // Measured energy deposition in Tile
1991 const double TileEnergy = caloMeas->Tile_EnergyMeasured();
1992 // Measured energy deposition in E/M
1993 const double EmEnergy = caloMeas->LArEM_EnergyMeasured();
1994
1995 // Correction for forward calorimetry
1996 double ForwardHECCorrection = 0.;
1997 if (std::abs(eta)>2. && caloMeas->LArHEC_EnergyMeasured()>100.)
1998 ForwardHECCorrection = (1. - LArHECMeasurementMaterial) * HECMaterial * MopLossCorrected;
1999 const double LArHECEnergy = caloMeas->LArHEC_EnergyMeasured() + ForwardHECCorrection; // Measured energy deposition in LArHEC
2000
2001 double TotalMeasuredEnergy = TileEnergy + EmEnergy + LArHECEnergy;
2002
2003 ATH_MSG_VERBOSE( "Energy Deposition:Tile " << TileEnergy
2004 << " LArHEC " << LArHECEnergy
2005 << " EM " << EmEnergy);
2006 ATH_MSG_VERBOSE("ForwardHECCorrection " << ForwardHECCorrection
2007 << " HECMaterial " << HECMaterial
2008 << " MopLossCorrected " << MopLossCorrected );
2009
2010 bool bHEC = false; // performed HEC measurement?
2011 bool bEM = false; // performed Em measurement?
2012
2013 // If muon isolated, and no significant measurement is made then use the mop parameterization, else the mean
2014 if (std::abs(eta)<1.4) {
2015 if (LArHECEnergy + TileEnergy > 0.1 * MopLoss * HECMaterial) bHEC= true;
2016 }
2017 else if (std::abs(eta)>1.8) {
2018 if (LArHECEnergy + TileEnergy > 0.2 * MopLoss * HECMaterial) bHEC= true;
2019 }else{
2020 if (LArHECEnergy + TileEnergy > 0.25 * MopLoss * HECMaterial) bHEC= true;
2021 }
2022 if (EmEnergy > 0.5 * MopLoss * EmMaterial) bEM = true;
2023
2024 double MeasCorrected = TotalMeasuredEnergy + MaterialCorrection;
2025 // Need to calculate the corresponding mip energy deposition
2026 // Muons of 10 GeV are already in the relativistic rise region
2027 // in order to obtain the mip deposition from the mean energy deposition of 10 GeV muons
2028 // should divide by approximately 1.4 (Review of Particle Physics Figure 27.3 p.243)
2029 const double IonizationLoss = (1./1.4) * meanElossIoni;
2030 double eOverMipCorrectionEm = 0.;
2031 double eOverMipCorrectionHEC = 0.;
2032 // Etrue = emip * Emeas
2033 // -DE = Emeas - Etrue = Etrue ( 1./emip -1.)
2034 if (bEM) {
2035 const double emipEM = 0.78;
2036 eOverMipCorrectionEm = - (1./emipEM-1.) * IonizationLoss * EmMaterial * LArEmMeasurementMaterial;
2037 if (EmEnergy + eOverMipCorrectionEm<0.)eOverMipCorrectionEm=0.;
2038 }
2039 if (bHEC) {
2040 const double emipTile = 0.86;
2041 const double emipLAr = 0.94;
2042 const double HECEnergy = TileEnergy + LArHECEnergy;
2043 const double eOverMipCorrectionTile = - (1./emipTile-1.) * TileEnergy / HECEnergy * IonizationLoss * HECMaterial * TileMeasurementMaterial;
2044 const double eOverMipCorrectionLAr = - (1./emipLAr-1.) * LArHECEnergy / HECEnergy * IonizationLoss * HECMaterial * LArHECMeasurementMaterial;
2045 eOverMipCorrectionHEC = eOverMipCorrectionTile + eOverMipCorrectionLAr;
2046 if (LArHECEnergy + TileEnergy + eOverMipCorrectionHEC < 0.0) eOverMipCorrectionHEC=0.;
2047 }
2048 const double eOverMipCorrection = eOverMipCorrectionEm + eOverMipCorrectionHEC;
2049
2050 // // additional offset from high-statistics Z->mumu MC (measured by Peter K 30/11/2011)
2051 // double fix1FromPeter[26] = { 0.424104 , 0.479637 , 0.483419 , 0.490242 , 0.52806 ,
2052 // 0.573582 , 0.822098 , 0.767301 , 0.809919 , 0.658745 ,
2053 // 0.157187 , 0.413214 , 0.771074 , 0.61815 , 0.350113 ,
2054 // 0.322785 , 0.479294 , 0.806183 , 0.822161 , 0.757731 ,
2055 // -0.0857186, -0.0992693, -0.0492252, 0.0650174, 0.261538 ,
2056 // 0.360413 };
2057 // // (update from Peter K 09/12/2011)
2058 // double fix2FromPeter[26] = { -0.647703 , -0.303498 , -0.268645 , -0.261292 , -0.260152 ,
2059 // -0.269253 , -0.266212 , -0.240837 , -0.130172 , -0.111638 ,
2060 // -0.329423 , -0.321011 , -0.346050 , -0.305592 , -0.313293 ,
2061 // -0.317111 , -0.428393 , -0.524839 , -0.599547 , -0.464013 ,
2062 // -0.159663 , -0.140879 , -0.0975618, 0.0225352, 0.0701925,
2063 // -0.24778 };
2064 // int ieta = static_cast<int> (std::abs(eta)/0.10);
2065 // if (ieta > 25) ieta = 25;
2066
2067 double FinalMeasuredEnergy = MeasCorrected + eOverMipCorrection;// + (fix1FromPeter[ieta] + fix2FromPeter[ieta])*CLHEP::GeV;
2068
2069 return FinalMeasuredEnergy;
2070}
double LArEM_SamplingFraction(void) const
Definition CaloMeas.h:93
double LArEM_EnergyMeasured(void) const
Definition CaloMeas.h:81
double Tile_SamplingFraction(void) const
Definition CaloMeas.h:65
double LArHEC_SamplingFraction(void) const
Definition CaloMeas.h:77
double Tile_EnergyMeasured(void) const
Definition CaloMeas.h:57
double LArHEC_EnergyMeasured(void) const
Definition CaloMeas.h:69
ToolHandle< Rec::IMuidCaloEnergyParam > m_caloParamTool

◆ getMopAndIoniEnergyLoss()

void TrkMaterialProviderTool::getMopAndIoniEnergyLoss ( const std::vector< const Trk::TrackStateOnSurface * > * matvec,
double pCaloEntry,
double scaleEloss,
double & mopEloss,
double & meanElossIoni,
double & sigmaElossIoni ) const
private

Function to get mop and mean (ionization) energy loss.

Definition at line 1860 of file TrkMaterialProviderTool.cxx.

1866{
1867// routine calculates the totalEloss = meanIoni + meanRad
1868// meanElossIoni = meanIoni
1869// sigmaElossIoni = sigmaIoni
1870//
1871
1872// Be carefull with using deltaE() that number starts as totalEloss but is updated to values close to meanIoni depending on the fit
1873
1874 double deltaE_tot = 0.;
1875 double sigmaDeltaE_tot = 0.;
1876 double sigmaPlusDeltaE_tot = 0.;
1877 double sigmaMinusDeltaE_tot = 0.;
1878 double deltaE_ioni_tot = 0.;
1879 double sigmaDeltaE_ioni_tot=0.;
1880 double deltaE_rad_tot = 0.;
1881 double sigmaDeltaE_rad_tot =0.;
1882
1883 for(const auto *m : *matvec) {
1884 if(!m->trackParameters()) {
1885 ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1886 continue;
1887 }
1888 if(m->materialEffectsOnTrack()) {
1889 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1890 const Trk::EnergyLoss* energyLoss = nullptr;
1891 if(meot) {
1892 energyLoss = meot->energyLoss();
1893 if (!energyLoss) {
1894 ATH_MSG_WARNING("No energyLoss on TrackStateOnSurface ");
1895 continue;
1896 }
1897 } else {
1898 ATH_MSG_WARNING("No materialEffectsOnTrack on TrackStateOnSurface ");
1899 continue;
1900 }
1901 deltaE_tot += std::abs(scaleEloss*energyLoss->deltaE());
1902 sigmaDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaDeltaE());
1903 sigmaPlusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaPlusDeltaE());
1904 sigmaMinusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaMinusDeltaE());
1905 deltaE_ioni_tot += std::abs(scaleEloss*energyLoss->meanIoni());
1906 sigmaDeltaE_ioni_tot += std::abs(scaleEloss*energyLoss->sigmaIoni());
1907 deltaE_rad_tot += std::abs(scaleEloss*energyLoss->meanRad());
1908 sigmaDeltaE_rad_tot += std::abs(scaleEloss*energyLoss->sigmaRad());
1909
1910 ATH_MSG_DEBUG(" position x " << m->trackParameters()->position().x() << " y " << m->trackParameters()->position().y() << " perp " << m->trackParameters()->position().perp() << " z " << m->trackParameters()->position().z() );
1911 ATH_MSG_DEBUG(" deltaE " << (scaleEloss*energyLoss->deltaE()) << " deltaE_ioni " << (scaleEloss*energyLoss->meanIoni()) << " sigmaDeltaE_ioni " << (scaleEloss*energyLoss->sigmaIoni()));
1912 ATH_MSG_DEBUG(" deltaE_tot " << deltaE_tot << " deltaE_ioni_tot " << deltaE_ioni_tot << " sigmaDeltaE_ioni_tot " << sigmaDeltaE_ioni_tot);
1913 if(energyLoss->sigmaIoni()<0) ATH_MSG_DEBUG(" ALARM sigmaIoni negative " << scaleEloss*energyLoss->sigmaIoni());
1914 if(energyLoss->sigmaRad()<0) ATH_MSG_DEBUG(" ALARM sigmaRad negative " << scaleEloss*energyLoss->sigmaRad());
1915
1916 }
1917 }
1918
1919 EnergyLoss eLoss = EnergyLoss(deltaE_tot, sigmaDeltaE_tot, sigmaMinusDeltaE_tot, sigmaPlusDeltaE_tot,
1920 deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1921 deltaE_rad_tot, sigmaDeltaE_rad_tot, 0.) ;
1922
1923 int elossFlag=0;
1924
1925 EnergyLoss eLoss2 ( m_elossupdator->updateEnergyLoss(eLoss, 0, 0, pCaloEntry, 0, elossFlag) );
1926
1927 totalEloss = eLoss2.meanIoni() + eLoss2.meanRad();
1928 meanElossIoni = eLoss2.meanIoni();
1929 sigmaElossIoni = eLoss2.sigmaIoni();
1930
1931 ATH_MSG_DEBUG("Mop Energy Loss " << totalEloss << " mean ionization energy loss " << meanElossIoni << " sigmaElossIoni " << sigmaElossIoni);
1932}
double meanRad() const
double sigmaPlusDeltaE() const
returns the positive side
double sigmaMinusDeltaE() const
returns the negative side
double sigmaIoni() const
double meanIoni() const
double sigmaDeltaE() const
returns the symmatric error
double sigmaRad() const

◆ getParamCaloELoss()

CaloEnergy * TrkMaterialProviderTool::getParamCaloELoss ( Trk::Track * track) const
virtual

Retrieve a clone of the parametrised energy loss.

Implements Trk::ITrkMaterialProviderTool.

Definition at line 915 of file TrkMaterialProviderTool.cxx.

916{
917 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
918 if(tsos->materialEffectsOnTrack()) {
919 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(tsos->materialEffectsOnTrack());
920 if(meot) {
921 const Trk::EnergyLoss* energyLoss = meot->energyLoss();
922 if (energyLoss) {
923 const CaloEnergy* caloEnergy = dynamic_cast<const CaloEnergy*>(meot->energyLoss());
924 if(caloEnergy) {
925 if(caloEnergy->energyLossType()==CaloEnergy::Tail) {
926 CaloEnergy* paramCaloEnergy = new CaloEnergy(caloEnergy->deltaEParam(),
927 0.5*(caloEnergy->sigmaMinusDeltaEParam()+caloEnergy->sigmaPlusDeltaEParam()),
928 caloEnergy->sigmaMinusDeltaEParam(),
929 caloEnergy->sigmaPlusDeltaEParam(),
931 caloEnergy->caloLRLikelihood(),
932 caloEnergy->caloMuonIdTag());
933 paramCaloEnergy->set_measEnergyLoss(caloEnergy->deltaEMeas(), caloEnergy->sigmaDeltaEMeas());
934 paramCaloEnergy->set_paramEnergyLoss(caloEnergy->deltaEParam(), caloEnergy->sigmaMinusDeltaEParam(), caloEnergy->sigmaPlusDeltaEParam());
935 return paramCaloEnergy;
936 }
937 return caloEnergy->clone();
938 }
939 }
940 }
941 }
942 }
943 return (CaloEnergy*)nullptr;
944}
CaloEnergy::EnergyLossType energyLossType(void) const
Accessor methods.
Definition CaloEnergy.h:162
double caloLRLikelihood() const
the calo Muon Identification likehood
Definition CaloEnergy.h:88
double sigmaMinusDeltaEParam() const
get parametrised energy loss minus error
Definition CaloEnergy.h:140
void set_measEnergyLoss(const double deltaE, const double sigmaDeltaE)
set measured energy loss
Definition CaloEnergy.h:124
CaloEnergy * clone() const
Virtual constructor.
Definition CaloEnergy.h:165
double deltaEMeas() const
get measured energy loss
Definition CaloEnergy.h:127
void set_paramEnergyLoss(const double deltaE, const double sigmaMinusDeltaE, const double sigmaPlusDeltaE)
set parametrised energy loss
Definition CaloEnergy.h:133
double sigmaDeltaEMeas() const
get measured energy loss error
Definition CaloEnergy.h:130
unsigned short caloMuonIdTag() const
the Calo Muon Identification tag
Definition CaloEnergy.h:85
double deltaEParam() const
get parametrised energy loss
Definition CaloEnergy.h:137
double sigmaPlusDeltaEParam() const
get parametrised energy loss plus error
Definition CaloEnergy.h:143

◆ getVolumeByGeo()

unsigned int TrkMaterialProviderTool::getVolumeByGeo ( const Trk::TrackStateOnSurface * m) const
private

Definition at line 1211 of file TrkMaterialProviderTool.cxx.

1212{
1213 unsigned int vol = 0;
1214 const Trk::MeasurementBase* mot = m->measurementOnTrack();
1215 if(mot) {
1216 Identifier id = Trk::IdentifierExtractor::extract(mot);
1217 if(id.is_valid()) {
1218 if(m_DetID->is_indet(id)) vol=1;
1219 else if(m_DetID->is_muon(id)) vol=3;
1220 else vol=2;
1221 }
1222 }
1223 if(!vol) {
1224 vol=3;
1225 if(m_indetVolume->inside(m->surface().globalReferencePoint())) vol=1;
1226 else if(m_calorimeterVolume->inside(m->surface().globalReferencePoint())) vol=2;
1227 }
1228 return vol;
1229}
static void extract(std::vector< Identifier > &ids, const std::vector< const MeasurementBase * > &measurements)

◆ initialize()

StatusCode TrkMaterialProviderTool::initialize ( )

AlgTool initailize method.

handle to the magnetic field cache

Definition at line 66 of file TrkMaterialProviderTool.cxx.

67{
68 ATH_CHECK(m_muonExtrapolator.retrieve());
69 ATH_CHECK(m_elossupdator.retrieve());
70 ATH_CHECK(m_scattool.retrieve());
75 m_caloMeasTool.disable();
76 m_caloParamTool.disable();
77 }else{
78 ATH_CHECK(m_caloMeasTool.retrieve());
79 ATH_CHECK(m_caloParamTool.retrieve());
80 m_muonCaloEnergyTool.disable();
81 }
82 }
83 else{
84 m_caloMeasTool.disable();
85 m_caloParamTool.disable();
86 m_muonCaloEnergyTool.disable();
87 m_trackIsolationTool.disable();
88 }
89
92
93 // need an Atlas id-helper to identify sub-detectors, take the one from detStore
94 if (detStore()->retrieve(m_DetID, "AtlasID").isFailure()) {
95 ATH_MSG_ERROR ("Could not get AtlasDetectorID helper" );
96 return StatusCode::FAILURE;
97 }
98
100
103 ATH_MSG_ERROR("Unable to retrieve MuonSpectrometerEntryLayer volume");
104 return StatusCode::FAILURE;
105 }
106
108 if(!m_indetVolume) {
109 ATH_MSG_ERROR("Unable to retrieve CalorimeterEntryLayer volume");
110 return StatusCode::FAILURE;
111 }
112
113 if (m_trackingGeometryReadKey.key().empty()) {
115 } else
116 ATH_CHECK( m_trackingGeometryReadKey.initialize() );
117
118 return StatusCode::SUCCESS;
119}
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
@ CalorimeterEntryLayer
Tracking Volume which defines the entrance srufaces of the calorimeter.
@ MuonSpectrometerEntryLayer
Tracking Volume which defines the entrance surfaces of the MS.
ServiceHandle< Trk::ITrackingVolumesSvc > m_trackingVolumesSvc
ServiceHandle< ITrackingGeometrySvc > m_trackingGeometrySvc
ToolHandle< Rec::IMuidTrackIsolation > m_trackIsolationTool
SG::ReadCondHandleKey< TrackingGeometry > m_trackingGeometryReadKey
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::ITrkMaterialProviderTool::interfaceID ( )
inlinestaticinherited

Definition at line 54 of file ITrkMaterialProviderTool.h.

55{
57}
static const InterfaceID IID_ITrkMaterialProviderTool("Trk::ITrkMaterialProviderTool", 1, 0)

◆ isIsolatedTrack()

bool TrkMaterialProviderTool::isIsolatedTrack ( double eta,
double phi ) const
private

Function to check isolation.

Definition at line 1935 of file TrkMaterialProviderTool.cxx.

1936{
1937 int nTracks = 0;
1938 std::pair<int,double> inner = m_trackIsolationTool->trackIsolation(Gaudi::Hive::currentContext(),eta,phi);
1939 nTracks = inner.first;
1940
1941 ATH_MSG_VERBOSE("Isolation : Number of tracks in cone " << nTracks << " cut < " << m_maxNTracksIso);
1942
1943 return nTracks <= m_maxNTracksIso;
1944}

◆ modifyTSOSvector()

Trk::TrackStates * TrkMaterialProviderTool::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
private

Function to modify TSOS doing repositioning, aggregation and corrections.

Definition at line 1299 of file TrkMaterialProviderTool.cxx.

1313{
1314 //
1315 // inputs: TSOSs for material (matvec) and scale factors for X0 (scaleX0) and Eloss (scaleEloss)
1316 //
1317 // returns: new vector of TSOSs including scaling of X0 and Eloss;
1318 //
1319 // options:
1320 // bool reposition correct repositioning of the scattering centers in space
1321 // bool aggregate put scattering centra together in two planes
1322 // bool update Eloss correct energy loss 1) including the measured calorimeter Eloss 2) include smearing of the muon momentum
1323 //
1324 // the routine should NOT be called for the ID
1325 // for best use in the Calorimeter: bool reposition = true, bool aggregate = true and updateEloss = true (measured caloEnergy and caloEnergyError should be passed)
1326 // note that the updateEloss is only active with aggregate = true
1327 // current version will NOT run correctly for MS (because the Eloss is made positive in the Calorimeter) needs fixing!
1328 // for best use in the Muon Specrometer: bool reposition = true, bool aggregate = true and updateEloss = false
1329 //
1330 // 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
1331 ATH_MSG_VERBOSE("Modifying TSOS vector size " << matvec->size()
1332 << " with X0, Eloss scales " << scaleX0 << " " << scaleEloss
1333 << " rep agg upd " << reposition << " " << aggregate << " " << updateEloss
1334 << " caloE " << caloEnergy << " +- " << caloEnergyError
1335 << " fsrCaloEnergy "<< fsrCaloEnergy
1336 << " p " << pCaloEntry << " dp " << momentumError);
1337
1338 //
1340
1341 // initialize total sum variables
1342 //
1343 //
1344 Eloss_tot = 0.;
1345
1346 double X0_tot = 0.;
1347
1348 double sigmaDeltaPhi2_tot = 0.;
1349 double sigmaDeltaTheta2_tot = 0.;
1350 double deltaE_tot = 0.;
1351 double sigmaDeltaE_tot = 0.;
1352 double sigmaPlusDeltaE_tot = 0.;
1353 double sigmaMinusDeltaE_tot = 0.;
1354 double deltaE_ioni_tot = 0.;
1355 double sigmaDeltaE_ioni_tot=0.;
1356 double deltaE_rad_tot = 0.;
1357 double sigmaDeltaE_rad_tot =0.;
1358
1359 const Trk::TrackStateOnSurface* mprevious = nullptr;
1360 const Trk::TrackStateOnSurface* mfirst = nullptr;
1361 const Trk::TrackStateOnSurface* mlast = nullptr;
1362 Amg::Vector3D posFirst(0.,0.,0.);
1363 double deltaEFirst = 0.;
1364
1365 double deltaPhi = 0.;
1366 double deltaTheta = 0.;
1367
1368 int n_tot = 0;
1369
1370 double w_tot = 0.;
1371 double wdist2 = 0.;
1372 Amg::Vector3D wdir(0.,0.,0.);
1373 Amg::Vector3D wpos(0.,0.,0.);
1374
1375 std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes> meotPattern(0);
1378
1379 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1381 typePattern.set(Trk::TrackStateOnSurface::Scatterer);
1382
1383 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePatternScat(0);
1384 typePatternScat.set(Trk::TrackStateOnSurface::Scatterer);
1385
1386 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePatternDeposit(0);
1387 typePatternDeposit.set(Trk::TrackStateOnSurface::CaloDeposit);
1388 const auto sqrt12=std::sqrt(12.);
1389 for(const auto *m : *matvec) {
1390
1391 if(!m->trackParameters()) {
1392 ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1393 continue;
1394 }
1395 if(m->materialEffectsOnTrack()) {
1396 double X0 = m->materialEffectsOnTrack()->thicknessInX0();
1397 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1398 const Trk::EnergyLoss* energyLoss = nullptr;
1399 const Trk::ScatteringAngles* scat = nullptr;
1400 if(meot) {
1401 energyLoss = meot->energyLoss();
1402 if (!energyLoss) {
1403 ATH_MSG_WARNING("No energyLoss on TrackStateOnSurface ");
1404 continue;
1405 }
1406 scat = meot->scatteringAngles();
1407 if(!scat) {
1408 ATH_MSG_WARNING("No scatteringAngles on TrackStateOnSurface ");
1409 continue;
1410 }
1411 } else {
1412 ATH_MSG_WARNING("No materialEffectsOnTrack on TrackStateOnSurface ");
1413 continue;
1414 }
1415
1416 double depth = energyLoss->length();
1417 X0_tot += std::abs(scaleX0 * X0);
1418
1419 sigmaDeltaTheta2_tot += scaleX0*scat->sigmaDeltaTheta()*scat->sigmaDeltaTheta();
1420 sigmaDeltaPhi2_tot += scaleX0*scat->sigmaDeltaPhi()*scat->sigmaDeltaPhi();
1421
1422 // Eloss sigma values add up linearly for Landau and exponential distributions
1423 deltaE_tot += std::abs(scaleEloss*energyLoss->deltaE());
1424 sigmaDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaDeltaE());
1425 sigmaPlusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaPlusDeltaE());
1426 sigmaMinusDeltaE_tot += std::abs(scaleEloss*energyLoss->sigmaMinusDeltaE());
1427 deltaE_ioni_tot += std::abs(scaleEloss*energyLoss->meanIoni());
1428 sigmaDeltaE_ioni_tot += std::abs(scaleEloss*energyLoss->sigmaIoni());
1429 deltaE_rad_tot += std::abs(scaleEloss*energyLoss->meanRad());
1430 sigmaDeltaE_rad_tot += std::abs(scaleEloss*energyLoss->sigmaRad());
1431
1432 n_tot++;
1433
1434 Amg::Vector3D dir = m->trackParameters()->momentum().unit();
1435 Amg::Vector3D pos = m->trackParameters()->position();
1436 if(mprevious) {
1437 dir += mprevious->trackParameters()->momentum().unit();
1438 }
1439
1440 dir = dir/dir.mag();
1441 Amg::Vector3D pos0 = pos - (depth/2.+depth/sqrt12)*dir;
1442 Amg::Vector3D posNew = pos - (depth/2.-depth/sqrt12)*dir;
1443 if(!mfirst) {
1444 mfirst = m;
1445 posFirst = pos0;
1446 deltaEFirst = energyLoss->deltaE();
1447 }
1448 mlast = m;
1449
1450 double w = scat->sigmaDeltaTheta()*scat->sigmaDeltaTheta();
1451
1452 w_tot += w;
1453 wpos += w*pos0/2.;
1454 wpos += w*posNew/2.;
1455 wdir += w*dir;
1456
1457 wdist2 += w*(pos0-posFirst).mag2()/2.;
1458 wdist2 += w*(posNew-posFirst).mag2()/2.;
1459
1460 if (!aggregate&&!reposition) {
1461
1462 auto scatNew = ScatteringAngles(deltaPhi,
1463 deltaTheta,
1464 std::sqrt(sigmaDeltaPhi2_tot),
1465 std::sqrt(sigmaDeltaTheta2_tot));
1466 auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1467 sigmaDeltaE_tot,
1468 sigmaMinusDeltaE_tot,
1469 sigmaPlusDeltaE_tot,
1470 deltaE_ioni_tot,
1471 sigmaDeltaE_ioni_tot,
1472 deltaE_rad_tot,
1473 sigmaDeltaE_rad_tot,
1474 depth);
1475 auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1476 Eloss_tot += caloEnergyNew->deltaE();
1477 const Trk::Surface& surf = meot->associatedSurface();
1478 auto meotLast =
1479 std::make_unique<Trk::MaterialEffectsOnTrack>(
1480 X0_tot, scatNew, std::move(caloEnergyNew), surf, meotPattern);
1481 auto pars = m->trackParameters()->uniqueClone();
1482
1483 // make new TSOS
1484 const Trk::TrackStateOnSurface* newTSOS = new Trk::TrackStateOnSurface(
1485 nullptr, std::move(pars), std::move(meotLast), typePattern);
1486
1487 newTSOSvector->push_back(newTSOS);
1488
1489 X0_tot = 0.;
1490 sigmaDeltaTheta2_tot = 0.;
1491 sigmaDeltaPhi2_tot = 0.;
1492 deltaE_tot = 0.;
1493 sigmaDeltaE_tot = 0;
1494 sigmaPlusDeltaE_tot = 0.;
1495 sigmaMinusDeltaE_tot = 0.;
1496 deltaE_ioni_tot = 0.;
1497 sigmaDeltaE_ioni_tot = 0.;
1498 deltaE_rad_tot = 0.;
1499 sigmaDeltaE_rad_tot = 0.;
1500
1501
1502 } else if(!aggregate&&reposition) {
1503
1504 if(std::abs(depth)<10.) {
1505
1506 // Thin scatterer: make only one TSOS
1507
1508 auto scatNew =
1509 ScatteringAngles(deltaPhi,
1510 deltaTheta,
1511 sqrt(sigmaDeltaPhi2_tot),
1512 sqrt(sigmaDeltaTheta2_tot));
1513 auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1514 sigmaDeltaE_tot,
1515 sigmaMinusDeltaE_tot,
1516 sigmaPlusDeltaE_tot,
1517 deltaE_ioni_tot,
1518 sigmaDeltaE_ioni_tot,
1519 deltaE_rad_tot,
1520 sigmaDeltaE_rad_tot,
1521 depth);
1522 auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1523 Eloss_tot += caloEnergyNew->deltaE();
1524 const Trk::Surface& surf = meot->associatedSurface();
1525 auto meotLast =
1526 std::make_unique<Trk::MaterialEffectsOnTrack>(
1527 X0_tot, scatNew, std::move(caloEnergyNew), surf, meotPattern);
1528 auto pars = m->trackParameters()->uniqueClone();
1529 // make new TSOS
1530 const Trk::TrackStateOnSurface* newTSOS =
1531 new Trk::TrackStateOnSurface(
1532 nullptr, std::move(pars), std::move(meotLast), typePattern);
1533 newTSOSvector->push_back(newTSOS);
1534
1535 X0_tot = 0.;
1536 sigmaDeltaTheta2_tot = 0.;
1537 sigmaDeltaPhi2_tot = 0.;
1538 deltaE_tot = 0.;
1539 sigmaDeltaE_tot = 0;
1540 sigmaPlusDeltaE_tot = 0.;
1541 sigmaMinusDeltaE_tot = 0.;
1542 deltaE_ioni_tot = 0.;
1543 sigmaDeltaE_ioni_tot = 0.;
1544 deltaE_rad_tot = 0.;
1545 sigmaDeltaE_rad_tot = 0.;
1546
1547 } else {
1548 //
1549 // Thick scatterer: make two TSOSs
1550 //
1551 // prepare for first MaterialEffectsOnTrack with X0 = X0/2 Eloss = 0 and scattering2 = total2 / 2. depth = 0
1552 auto energyLoss0 = std::make_unique<Trk::EnergyLoss>(0.,0.,0.,0.);
1553 auto scatFirst = ScatteringAngles(deltaPhi,
1554 deltaTheta,
1555 std::sqrt(sigmaDeltaPhi2_tot / 2.),
1556 std::sqrt(sigmaDeltaTheta2_tot / 2.));
1557
1558 // prepare for second MaterialEffectsOnTrack with X0 = X0/2 Eloss = Eloss total and scattering2 = total2 / 2. depth = 0
1559 auto scatNew =
1560 ScatteringAngles(deltaPhi,
1561 deltaTheta,
1562 std::sqrt(sigmaDeltaPhi2_tot / 2.),
1563 std::sqrt(sigmaDeltaTheta2_tot / 2.));
1564 auto energyLossNew = Trk::EnergyLoss(deltaE_tot,
1565 sigmaDeltaE_tot,
1566 sigmaMinusDeltaE_tot,
1567 sigmaPlusDeltaE_tot,
1568 deltaE_ioni_tot,
1569 sigmaDeltaE_ioni_tot,
1570 deltaE_rad_tot,
1571 sigmaDeltaE_rad_tot,
1572 0.);
1573 auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1574 Eloss_tot += caloEnergyNew->deltaE();
1575 double norm = dir.perp();
1576 // Rotation matrix representation
1577 Amg::Vector3D colx(-dir.y() / norm, dir.x() / norm, 0);
1578 Amg::Vector3D coly(
1579 -dir.x() * dir.z() / norm, -dir.y() * dir.z() / norm, norm);
1580 Amg::Vector3D colz(dir.x(), dir.y(), dir.z());
1581
1582 Amg::Transform3D surfaceTransformFirst(colx, coly, colz, pos0);
1583 Amg::Transform3D surfaceTransformLast(colx, coly, colz, posNew);
1584 auto surfFirst =
1585 Trk::PlaneSurface(surfaceTransformFirst);
1586 auto surfLast =
1587 Trk::PlaneSurface(surfaceTransformLast);
1588 // make MaterialEffectsOnTracks
1589 auto meotFirst =
1590 std::make_unique<Trk::MaterialEffectsOnTrack>(
1591 X0_tot / 2., scatFirst, std::move(energyLoss0), surfFirst, meotPattern);
1592 auto meotLast =
1593 std::make_unique<Trk::MaterialEffectsOnTrack>(
1594 X0_tot / 2., scatNew, std::move(caloEnergyNew), surfLast, meotPattern);
1595
1596
1597 // calculate TrackParameters at first surface
1598 double qOverP0 = m->trackParameters()->charge()/ (m->trackParameters()->momentum().mag()-std::abs(energyLoss->deltaE()));
1599 if(mprevious) qOverP0 = mprevious->trackParameters()->charge()/mprevious->trackParameters()->momentum().mag();
1600
1601 std::unique_ptr<Trk::TrackParameters> parsFirst =
1602 surfFirst.createUniqueParameters<5, Trk::Charged>(
1603 0., 0., dir.phi(), dir.theta(), qOverP0);
1604 // calculate TrackParameters at second surface
1605 double qOverPNew = m->trackParameters()->charge() /
1606 m->trackParameters()->momentum().mag();
1607 std::unique_ptr<Trk::TrackParameters> parsLast =
1608 surfLast.createUniqueParameters<5, Trk::Charged>(
1609 0., 0., dir.phi(), dir.theta(), qOverPNew);
1610 // make TSOS
1611 //
1612 const Trk::TrackStateOnSurface* newTSOSFirst =
1613 new Trk::TrackStateOnSurface(
1614 nullptr, std::move(parsFirst), std::move(meotFirst), typePattern);
1615 const Trk::TrackStateOnSurface* newTSOS =
1616 new Trk::TrackStateOnSurface(
1617 nullptr, std::move(parsLast), std::move(meotLast), typePattern);
1618
1619
1620 newTSOSvector->push_back(newTSOSFirst);
1621 newTSOSvector->push_back(newTSOS);
1622
1623 X0_tot = 0.;
1624 sigmaDeltaTheta2_tot = 0.;
1625 sigmaDeltaPhi2_tot = 0.;
1626 deltaE_tot = 0.;
1627 sigmaDeltaE_tot = 0;
1628 sigmaPlusDeltaE_tot = 0.;
1629 sigmaMinusDeltaE_tot = 0.;
1630 deltaE_ioni_tot = 0.;
1631 sigmaDeltaE_ioni_tot = 0.;
1632 deltaE_rad_tot = 0.;
1633 sigmaDeltaE_rad_tot = 0.;
1634 }
1635 }
1636
1637 mprevious = m;
1638
1639
1640 }
1641 }
1642 if (aggregate&&reposition) {
1643
1644 if (n_tot>0) {
1645 //
1646 // Make three scattering planes in Calorimeter else make two
1647 //
1648 Amg::Vector3D pos = wpos/w_tot;
1649 bool threePlanes = false;
1650 if (std::abs(pos.z()) < 6700 && pos.perp() < 4200)
1651 threePlanes = true; // always 3 planes in calo
1652 //
1653 auto scatFirst =
1654 ScatteringAngles(deltaPhi,
1655 deltaTheta,
1656 std::sqrt(sigmaDeltaPhi2_tot / 2.),
1657 std::sqrt(sigmaDeltaTheta2_tot / 2.));
1658 auto scatNew =
1659 ScatteringAngles(deltaPhi,
1660 deltaTheta,
1661 std::sqrt(sigmaDeltaPhi2_tot / 2.),
1662 std::sqrt(sigmaDeltaTheta2_tot / 2.));
1663 Trk::EnergyLoss energyLoss2 = EnergyLoss(deltaE_tot,
1664 sigmaDeltaE_tot,
1665 sigmaMinusDeltaE_tot,
1666 sigmaPlusDeltaE_tot,
1667 deltaE_ioni_tot,
1668 sigmaDeltaE_ioni_tot,
1669 deltaE_rad_tot,
1670 sigmaDeltaE_rad_tot,
1671 0.);
1672 if (threePlanes)
1673 ATH_MSG_VERBOSE(" Calorimeter energyLoss2 delta E "
1674 << energyLoss2.deltaE() << " meanIoni "
1675 << energyLoss2.meanIoni() << " sigmaIoni "
1676 << energyLoss2.sigmaIoni() << " X0_tot " << X0_tot);
1677
1678 int elossFlag =
1679 0; // return Flag for updateEnergyLoss Calorimeter energy (0 = not used)
1680
1681 double calE = caloEnergy;
1682 double calEr = caloEnergyError;
1683
1684 // if(!useMeasuredEnergy) calE = 0.;
1685 if (!useMeasuredEnergy)
1686 calEr = 0.;
1687
1688 Trk::EnergyLoss energyLossNew =
1689 (updateEloss
1690 ? m_elossupdator->updateEnergyLoss(
1691 energyLoss2, calE, calEr, pCaloEntry, momentumError, elossFlag)
1692 : EnergyLoss(deltaE_tot,
1693 sigmaDeltaE_tot,
1694 sigmaMinusDeltaE_tot,
1695 sigmaPlusDeltaE_tot,
1696 deltaE_ioni_tot,
1697 sigmaDeltaE_ioni_tot,
1698 deltaE_rad_tot,
1699 sigmaDeltaE_rad_tot,
1700 0.));
1701 auto caloEnergyNew = std::make_unique<CaloEnergy>(energyLossNew);
1702 if (threePlanes)
1703 ATH_MSG_VERBOSE(" After update Calorimeter energyLossNew "
1704 << energyLossNew.deltaE() << " meanIoni "
1705 << energyLossNew.meanIoni() << " sigmaIoni "
1706 << energyLossNew.sigmaIoni());
1707
1708 caloEnergyNew->set_measEnergyLoss(caloEnergy, caloEnergyError);
1709 // Store FSR calo energy
1710 caloEnergyNew->set_fsrCandidateEnergy(fsrCaloEnergy);
1711 // Store both measured and parametrised eloss on CaloEnergy object
1712 if(elossFlag!=0) {
1713 caloEnergyNew->set_energyLossType(CaloEnergy::Tail);
1714 } else {
1715 if(!useMeasuredEnergy) caloEnergyNew->set_energyLossType(CaloEnergy::NotIsolated);
1716 }
1717
1718 int eLossFlagTmp = 0;
1719 Trk::EnergyLoss energyLossParam = m_elossupdator->updateEnergyLoss(energyLoss2, 0.0, 0.0, pCaloEntry, 0., eLossFlagTmp);
1720
1721 caloEnergyNew->set_paramEnergyLoss(energyLossParam.deltaE(), energyLossParam.sigmaMinusDeltaE(), energyLossParam.sigmaPlusDeltaE());
1722 if(m_overwriteElossParam&&m_useCaloEnergyMeasurement) caloEnergyNew->set_paramEnergyLoss(totalEloss,meanElossIoni,0.45*sigmaElossIoni);
1723 ATH_MSG_DEBUG( " modifyTSOSvector energyLossParam Eloss " << energyLossParam.deltaE() << " on TSOS " << energyLossNew.deltaE() << " calE " << calE);
1724 Eloss_tot += caloEnergyNew->deltaE();
1725
1726 // direction of plane
1727 Amg::Vector3D dir = wdir/w_tot;
1728 dir = dir/dir.mag();
1729 double norm = dir.perp();
1730 // Rotation matrix representation
1731 Amg::Vector3D colx(-dir.y()/norm, dir.x()/norm, 0);
1732 Amg::Vector3D coly(-dir.x()*dir.z()/norm, -dir.y()*dir.z()/norm, norm);
1733 Amg::Vector3D colz( dir.x(), dir.y(), dir.z());
1734 // Centre position of the two planes
1735 double halflength2 = wdist2/w_tot - (pos-posFirst).mag()*(pos-posFirst).mag();
1736 double halflength = 0.;
1737 if(halflength2>0) halflength = sqrt(halflength2);
1738 Amg::Vector3D pos0 = pos - halflength*dir;
1739 Amg::Vector3D posNew = pos + halflength*dir;
1740//
1741// force the planes to be inside the Calorimeter
1742//
1743 double scaleCalo = 1.;
1744 double scaleCaloNew = std::abs(pos0.z())/6700;
1745 if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1746 scaleCaloNew = std::abs(posNew.z())/6700;
1747 if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1748 scaleCaloNew = std::abs(pos0.perp())/4200;
1749 if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1750 scaleCaloNew = std::abs(posNew.perp())/4200;
1751 if(scaleCaloNew>scaleCalo) scaleCalo = scaleCaloNew;
1752
1753 if(scaleCalo>1.) {
1754 pos0 = pos0/scaleCalo;
1755 pos = pos/scaleCalo;
1756 posNew = posNew/scaleCalo;
1757 halflength = halflength/scaleCalo;
1758 ATH_MSG_VERBOSE(" position scattering planes inside calo scale factor " << scaleCalo);
1759 }
1760
1761 if(updateEloss) ATH_MSG_VERBOSE("WITH updateEloss");
1762 Amg::Transform3D surfaceTransformFirst(colx,coly,colz,pos0);
1763 Amg::Transform3D surfaceTransformLast(colx,coly,colz,posNew);
1764 auto surfFirst = Trk::PlaneSurface( surfaceTransformFirst );
1765 auto surfLast= Trk::PlaneSurface( surfaceTransformLast );
1766 // calculate TrackParameters at first surface
1767 double qOverP0 = mfirst->trackParameters()->charge()/(mfirst->trackParameters()->momentum().mag()+std::abs(deltaEFirst));
1768 // calculate TrackParameters at last surface
1769 double qOverPNew = mlast->trackParameters()->charge()/mlast->trackParameters()->momentum().mag();
1770 std::unique_ptr<Trk::TrackParameters> parsFirst =
1771 surfFirst.createUniqueParameters<5, Trk::Charged>(
1772 0., 0., dir.phi(), dir.theta(), qOverP0);
1773 std::unique_ptr<Trk::TrackParameters> parsLast =
1774 surfLast.createUniqueParameters<5, Trk::Charged>(
1775 0., 0., dir.phi(), dir.theta(), qOverPNew);
1776
1777 if(!threePlanes) {
1778 //
1779 // make two scattering planes and TSOS
1780 //
1781 // prepare for first MaterialEffectsOnTrack with X0 = X0/2
1782 // Eloss = 0 and scattering2 = total2 / 2. depth = 0
1783 auto meotFirst =
1784 std::make_unique<Trk::MaterialEffectsOnTrack>(X0_tot / 2.,
1785 scatFirst,
1786 nullptr,
1787 surfFirst,
1788 meotPattern);
1789 // prepare for second MaterialEffectsOnTrack with X0 = X0/2
1790 // Eloss = Eloss total and scattering2 = total2 / 2. depth = 0
1791 auto meotLast =
1792 std::make_unique<Trk::MaterialEffectsOnTrack>(X0_tot / 2.,
1793 scatNew,
1794 std::move(caloEnergyNew),
1795 surfLast,
1796 meotPattern);
1797 //
1798 //
1799 const Trk::TrackStateOnSurface* newTSOSFirst =
1800 new Trk::TrackStateOnSurface(
1801 nullptr, std::move(parsFirst), std::move(meotFirst), typePattern);
1802 auto whichPattern = (elossFlag != 0) ? typePatternDeposit : typePattern;
1803 const Trk::TrackStateOnSurface* newTSOS = new Trk::TrackStateOnSurface( nullptr,
1804 std::move(parsLast), std::move(meotLast), whichPattern);
1805 newTSOSvector->push_back(newTSOSFirst);
1806 newTSOSvector->push_back(newTSOS);
1807 } else {
1808 //
1809 // make three scattering planes and TSOS in Calorimeter
1810 //
1811 Amg::Transform3D surfaceTransform(colx, coly, colz, pos);
1812 auto surf = Trk::PlaneSurface(surfaceTransform);
1813 std::unique_ptr<Trk::TrackParameters> pars =
1814 surf.createUniqueParameters<5, Trk::Charged>(
1815 0., 0., dir.phi(), dir.theta(), qOverPNew);
1816
1817 // prepare for first MaterialEffectsOnTrack with X0 = X0/2 Eloss
1818 // = 0 and scattering2 = total2 / 2. depth = 0
1819 auto meotFirst =
1820 std::make_unique<Trk::MaterialEffectsOnTrack>(
1821 X0_tot / 2., scatFirst, nullptr, surfFirst, meotPattern);
1822
1823 // prepare for middle MaterialEffectsOnTrack with X0 = 0 Eloss =
1824 // ElossNew and scattering2 = 0. depth = 0
1825 auto meot =
1826 std::make_unique<Trk::MaterialEffectsOnTrack>(
1827 0.,std::nullopt, std::move(caloEnergyNew), surf, meotPattern);
1828
1829 // prepare for last MaterialEffectsOnTrack with X0 = X0/2 Eloss
1830 // = 0 total and scattering2 = total2 / 2. depth = 0
1831 auto meotLast =
1832 std::make_unique<Trk::MaterialEffectsOnTrack>(
1833 X0_tot / 2., scatNew, nullptr, surfLast, meotPattern);
1834
1835
1836 const Trk::TrackStateOnSurface* newTSOSFirst =
1837 new Trk::TrackStateOnSurface(
1838 nullptr, std::move(parsFirst), std::move(meotFirst), typePatternScat);
1839 const Trk::TrackStateOnSurface* newTSOS = new Trk::TrackStateOnSurface(
1840 nullptr, std::move(pars), std::move(meot), typePatternDeposit);
1841 const Trk::TrackStateOnSurface* newTSOSLast =
1842 new Trk::TrackStateOnSurface(
1843 nullptr, std::move(parsLast), std::move(meotLast), typePatternScat);
1844
1845 newTSOSvector->push_back(newTSOSFirst);
1846 newTSOSvector->push_back(newTSOS);
1847 newTSOSvector->push_back(newTSOSLast);
1848 }
1849
1850
1851 }
1852
1853 }
1854
1855 return newTSOSvector;
1856}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar mag() const
mag method
Scalar mag2() const
mag2 method - forward to squaredNorm()
value_type push_back(value_type pElem)
Add an element to the end of the collection.
double length() const
@ ScatteringEffects
contains material effects due to multiple scattering
@ EnergyLossEffects
contains energy loss corrections
const Surface & associatedSurface() const
returns the surface to which these m.eff. are associated.
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
double charge() const
Returns the charge.
double sigmaDeltaPhi() const
returns the
double sigmaDeltaTheta() const
returns the
@ InertMaterial
This represents inert material, and so will contain MaterialEffectsBase.
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
@ CaloDeposit
This TSOS contains a CaloEnergy object.
std::string depth
tag string for intendation
Definition fastadd.cxx:46
Eigen::Affine3d Transform3D

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ printTSOS()

void TrkMaterialProviderTool::printTSOS ( const Trk::TrackStateOnSurface * m,
const std::string & tag ) const
private

Definition at line 1252 of file TrkMaterialProviderTool.cxx.

1253{
1254 unsigned int ivolGeo = getVolumeByGeo(m);
1255 std::string volGeo="ID";
1256 if(ivolGeo==2) volGeo="CALO";
1257 else if(ivolGeo==3) volGeo="MS";
1258 ATH_MSG_VERBOSE(tag<<" Type "<<std::left<<std::setw(35)<<m->dumpType()
1259 <<" Volume "<<std::left<<std::setw(5)<<volGeo
1260 <<" r "<<std::left<<std::setw(10)<<m->surface().globalReferencePoint().perp()
1261 <<" z "<<std::left<<std::setw(10)<<m->surface().globalReferencePoint().z());
1262 if(m->materialEffectsOnTrack()) {
1263 ATH_MSG_VERBOSE(" -> Material: X0 "<<std::left<<std::setw(10)<<m->materialEffectsOnTrack()->thicknessInX0());
1264 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(m->materialEffectsOnTrack());
1265 if(meot) {
1266 const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1267 if (energyLoss) {
1268 ATH_MSG_DEBUG(" geo " << volGeo << " radius " << m->surface().globalReferencePoint().perp() << " z " << m->surface().globalReferencePoint().z() << " TSOS Eloss " <<energyLoss->deltaE());
1269 std::string type="P";
1270 const CaloEnergy* caloEnergy = dynamic_cast<const CaloEnergy*>(meot->energyLoss());
1271 if(caloEnergy && caloEnergy->energyLossType()==CaloEnergy::Tail) type="M";
1272 ATH_MSG_VERBOSE(" -> Eloss "<<type<<" "<<std::left<<std::setw(10)<<energyLoss->deltaE()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaDeltaE()
1273 <<" + "<<energyLoss->sigmaPlusDeltaE()<<" - "<<energyLoss->sigmaMinusDeltaE()
1274 <<" MopIoni "<<std::left<<std::setw(10)<<energyLoss->meanIoni()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaIoni()
1275 <<" MeanRad "<<std::left<<std::setw(10)<<energyLoss->meanRad()<<" +- "<<std::left<<std::setw(10)<<energyLoss->sigmaRad() );
1276 }
1277 const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1278 if(scatAngles) {
1279 ATH_MSG_VERBOSE(" -> Scattering: dPhi "<<std::left<<std::setw(10)<<scatAngles->deltaPhi()<<" +- "<<std::left<<std::setw(10)<<scatAngles->sigmaDeltaPhi()<<
1280 " dTheta "<<std::left<<std::setw(10)<<scatAngles->deltaTheta()<<" +- "<<std::left<<std::setw(10)<<scatAngles->sigmaDeltaTheta());
1281 }
1282 }
1283 }
1284 if(m->trackParameters()) {
1285 ATH_MSG_VERBOSE(" -> TP: r "<<std::left<<std::setw(10)<<m->trackParameters()->position().perp()
1286 <<" z "<<std::left<<std::setw(10)<<m->trackParameters()->position().z()
1287 <<" phi0 "<<std::left<<std::setw(10)<<m->trackParameters()->parameters()[Trk::phi0]
1288 <<" eta "<<std::left<<std::setw(10)<<-std::log(std::tan(m->trackParameters()->parameters()[Trk::theta]/2)));
1289 if(m->trackParameters()->covariance()) {
1290 ATH_MSG_VERBOSE(" -> Errors: qOverP "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::qOverP)
1291 <<" phi0 "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::phi0)
1292 <<" theta "<<std::left<<std::setw(10)<<Amg::error(*m->trackParameters()->covariance(),Trk::theta));
1293 }
1294 }
1295}
double deltaPhi() const
returns the
double deltaTheta() const
returns the

◆ removeMS()

void TrkMaterialProviderTool::removeMS ( std::vector< const Trk::TrackStateOnSurface * > * caloTSOS) const
private

Helper to remove only MS TSOS.

Helper to remove MS TSOS.

Definition at line 1032 of file TrkMaterialProviderTool.cxx.

1033{
1034 // remove all track states on surface with getVolumeByGeo(state)==3 ( ID = 1 Calo = 2 MS = 3)
1035 // and group all other track states at the beginning of the vector.
1036 // finally erase from the vector all track state pointer of the
1037 // deleted objects, which are after remove_if at the end of the vector.
1038 const TrkMaterialProviderTool *this_=this;
1039 caloTSOS->erase( std::remove_if(caloTSOS->begin(),
1040 caloTSOS->end(),
1041 [this_](const Trk::TrackStateOnSurface *&state) {
1042 if (state && this_->getVolumeByGeo(state)==3) {
1043 delete state;
1044 state=nullptr;
1045 return true;
1046 }
1047
1048 return false;
1049
1050 } ),
1051 caloTSOS->end());
1052
1053}
TrkMaterialProviderTool(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.

◆ removeOutOfCalo()

void TrkMaterialProviderTool::removeOutOfCalo ( std::vector< const Trk::TrackStateOnSurface * > * caloTSOS) const
private

Helper to remove MS and ID TSOS.

Definition at line 1008 of file TrkMaterialProviderTool.cxx.

1009{
1010 // remove all track states on surface with getVolumeByGeo(state)!=2 ( ID = 1 Calo = 2 MS = 3)
1011 // and group all other track states at the beginning of the vector.
1012 // finally erase from the vector all track state pointer of the
1013 // deleted objects, which are after remove_if at the end of the vector.
1014 const TrkMaterialProviderTool *this_=this;
1015 caloTSOS->erase( std::remove_if(caloTSOS->begin(),
1016 caloTSOS->end(),
1017 [this_](const Trk::TrackStateOnSurface *&state) {
1018 if (state && this_->getVolumeByGeo(state)!=2) {
1019 delete state;
1020 state=nullptr;
1021 return true;
1022 }
1023
1024 return false;
1025
1026 } ),
1027 caloTSOS->end());
1028
1029}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ retrieveTrackingGeometry()

const TrackingGeometry * Trk::TrkMaterialProviderTool::retrieveTrackingGeometry ( const EventContext & ctx) const
inlineprivate

Definition at line 178 of file TrkMaterialProviderTool.h.

178 {
179
180 if (m_trackingGeometryReadKey.key().empty()) {
181 return m_trackingGeometrySvc->trackingGeometry();
182 }
183 SG::ReadCondHandle<TrackingGeometry> handle(m_trackingGeometryReadKey,
184 ctx);
185 if (!handle.isValid()) {
187 }
188 return handle.cptr();
189 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ throwFailedToGetTrackingGeomtry()

void TrkMaterialProviderTool::throwFailedToGetTrackingGeomtry ( ) const
private

Definition at line 2072 of file TrkMaterialProviderTool.cxx.

2072 {
2073 std::stringstream msg;
2074 msg << "Failed to get conditions data " << m_trackingGeometryReadKey.key() << ".";
2075 throw std::runtime_error(msg.str());
2076}
MsgStream & msg() const

◆ updateCaloTSOS() [1/2]

void TrkMaterialProviderTool::updateCaloTSOS ( const Trk::Track & idTrack,
Trk::Track & extrapolatedTrack ) const
virtual

Update Calorimeter TSOS from input ID and MS tracks.

Implements Trk::ITrkMaterialProviderTool.

Definition at line 243 of file TrkMaterialProviderTool.cxx.

244{
245 ATH_MSG_VERBOSE("updateCaloTSOS(Trk::Track& idTrack, Trk::Track& extrapolatedTrack)");
246
247 const Trk::TrackStates* inputTSOS_ID = idTrack.trackStateOnSurfaces();
248 const Trk::TrackStates* inputTSOS_MS_orig = extrapolatedTrack.trackStateOnSurfaces();
249
250 auto inputTSOS_MS = std::make_unique<Trk::TrackStates>();
251 for (const Trk::TrackStateOnSurface* tsos : *inputTSOS_MS_orig) {
252 inputTSOS_MS->push_back (tsos->clone());
253 }
254
255
256 // find last ID TSOS
257 Trk::TrackStates::const_iterator lastIDwP = inputTSOS_ID->end();
258 Trk::TrackStates::const_iterator itID = inputTSOS_ID->end()-1;
259 Trk::TrackStates::const_iterator itFront = inputTSOS_ID->begin();
260 while(*itID) {
261 if(this->getVolumeByGeo(*itID)==1 && (*itID)->trackParameters()) {
262 lastIDwP = itID;
263 break;
264 }
265 if(itID==itFront) break;
266 --itID;
267 }
268
269 // find first MS TSOS
270 Trk::TrackStates::iterator firstCALO = inputTSOS_MS->end();
271 Trk::TrackStates::iterator firstMS = inputTSOS_MS->end();
272 Trk::TrackStates::iterator firstMSwP = inputTSOS_MS->end();
273 Trk::TrackStates::iterator itEnd = inputTSOS_MS->end();
274 Trk::TrackStates::iterator it = inputTSOS_MS->begin();
275 for(; it!=itEnd; ++it) {
276
277#ifdef DEBUGON
278 printTSOS(*it, "TSOS ON TRACK");
279#endif
280
281 if(firstCALO==inputTSOS_MS->end() && this->getVolumeByGeo(*it)==2)
282 firstCALO = it;
283 if(this->getVolumeByGeo(*it)==3) {// && !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
284 if(firstMS==itEnd)
285 firstMS = it;
286 if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
287 firstMSwP = it;
288 break;
289 }
290 }
291 }
292
293 if(firstCALO == inputTSOS_MS->end()) {
294 ATH_MSG_DEBUG("Track without CALO TSOS!");
295 firstCALO = firstMS;
296 }
297 if(lastIDwP == inputTSOS_ID->end()) {
298 ATH_MSG_WARNING("Unable to find last ID TSOS with Track Parameters");
299 ATH_MSG_WARNING("Unable to update Calorimeter TSOS" );
300 return;
301 }
302 if(firstMS == inputTSOS_MS->end()) {
303 ATH_MSG_WARNING("Unable to find first MS TSOS!");
304 ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
305 return;
306 }
307
308 // check that first MS TSOS is not a PerigeeSurface
309 //bool removeOoC = false;
310 Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
311 if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS_MS->end()) {
312 firstMSnotPerigee=firstMS+1;
313 //removeOoC = true;
314 }
315
316#ifdef DEBUGON
317 printTSOS(*lastIDwP, "LAST IDwP");
318 printTSOS(*firstCALO, "FIRST CALO");
319 printTSOS(*firstMSnotPerigee, "FIRST MS");
320 if(firstMSwP != inputTSOS_MS->end())
321 printTSOS(*firstMSwP, "FIRST MSwP");
322 else
323 ATH_MSG_WARNING("Unable to find first MS TSOS with Track Parameters");
324#endif
325 double Eloss = 0.;
326 double X0ScaleMS = 0.;
327 double ElossScaleMS = 0.;
328 // get calorimeter TSOS from TG
329 Trk::TrackStates* caloTSOS = this->getCaloTSOS (*(*lastIDwP)->trackParameters(),
330 extrapolatedTrack,
331 (*firstMSnotPerigee)->surface(),
333 Trk::muon,
334 Eloss, X0ScaleMS, ElossScaleMS,
335 (firstMSwP == inputTSOS_MS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
336 false,
337 true);
338
339
340 if(!caloTSOS || caloTSOS->size()!=3) {
341 ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM (null or <3)");
342 if(caloTSOS) deleteTSOS(caloTSOS);
343 return;
344 }
345
346#ifdef DEBUGON
347 ATH_MSG_VERBOSE("ID TSOS multiplicity : " << inputTSOS_ID->size());
348 for(auto m : *inputTSOS_ID) printTSOS(m, "ID TSOS");
349 ATH_MSG_VERBOSE("OLD-MS TSOS multiplicity : " << inputTSOS_MS->size());
350 for(auto m : *inputTSOS_MS) printTSOS(m, "OLD-MS TSOS");
351#endif
352
353 // apply X0 and Eloss scale to MuonSpectrometer
354 this->updateVectorMS(inputTSOS_MS.get(),firstMS,X0ScaleMS,ElossScaleMS);
355 // update the original vector
356 Trk::TrkMaterialProviderTool::updateVector(inputTSOS_MS.get(), firstCALO, firstMS, caloTSOS);
357
358 extrapolatedTrack.setTrackStateOnSurfaces (std::move (inputTSOS_MS));
359 myLocal_resetTrack(extrapolatedTrack);
360}
void myLocal_resetTrack(Trk::Track &track)
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
void setTrackStateOnSurfaces(std::unique_ptr< Trk::TrackStates > input)
Set the TrackStateOnSurfaces.
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
static void updateVector(Trk::TrackStates *inputTSOS, Trk::TrackStates::iterator lastID, Trk::TrackStates::iterator firstMS, Trk::TrackStates *caloTSOS)
Helper to update entries in the vector.

◆ updateCaloTSOS() [2/2]

void TrkMaterialProviderTool::updateCaloTSOS ( Trk::Track & track,
const Trk::TrackParameters * startParamaters = nullptr ) const
virtual

Update Calorimeter TSOS from input MS/CB track.

Implements Trk::ITrkMaterialProviderTool.

Definition at line 131 of file TrkMaterialProviderTool.cxx.

132{
133 ATH_MSG_VERBOSE("updateCaloTSOS(Trk::Track& track, const Trk::TrackParameters* startParameters)");
134
135 // back extrapolate to perigee, get pAtCaloEntry from list of TSOSs
136 // and update/add calo+ID material to mstrack to be refitted.
137 const Trk::TrackStates* inputTSOS_orig = track.trackStateOnSurfaces();
138
139 auto inputTSOS = std::make_unique<Trk::TrackStates>();
140 for (const Trk::TrackStateOnSurface* tsos : *inputTSOS_orig) {
141 inputTSOS->push_back (tsos->clone());
142 }
143
144 // Iterators
145 Trk::TrackStates::iterator lastIDwP = inputTSOS->end();
146 Trk::TrackStates::iterator firstCALO = inputTSOS->end();
147 Trk::TrackStates::iterator firstMS = inputTSOS->end();
148 Trk::TrackStates::iterator firstMSwP = inputTSOS->end();
149
150 // find first MS TSOS (handling the case of TSOS w/o TP) and the last ID (or perigee)
151 Trk::TrackStates::iterator it = inputTSOS->begin();
152 Trk::TrackStates::iterator itEnd = inputTSOS->end();
153 for(; it!=itEnd; ++it) {
154
155#ifdef DEBUGON
156 printTSOS(*it, "TSOS ON TRACK");
157#endif
158
159 if(this->getVolumeByGeo(*it)==1 && (*it)->trackParameters())
160 lastIDwP = it;
161 if(firstCALO==inputTSOS->end() && this->getVolumeByGeo(*it)==2 && firstMS==itEnd)
162 firstCALO = it;
163 else if(this->getVolumeByGeo(*it)==3 && firstCALO!=inputTSOS->end()) {//&& !(*it)->type(Trk::TrackStateOnSurface::Perigee)) {
164 if(firstMS==itEnd)
165 firstMS = it;
166 if((*it)->trackParameters() && (*it)->trackParameters()->covariance()) {
167 firstMSwP = it;
168 break;
169 }
170 }
171 }
172
173 // if we have last ID TSOS from the list on track (i.e. combined muon) then use this as start parameters
174 if(lastIDwP != inputTSOS->end()) {
175#ifdef DEBUGON
176 printTSOS(*lastIDwP, "LAST IDwP");
177#endif
178 startParameters = (*lastIDwP)->trackParameters();
179 }
180
181 if(lastIDwP == inputTSOS->end() && !startParameters) {
182 ATH_MSG_WARNING("Unable to find starting parameters for extrapolation");
183 ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
184 return;
185 }
186 if(firstCALO == inputTSOS->end()) {
187 ATH_MSG_DEBUG("Track without CALO TSOS!");
188 firstCALO = firstMS;
189 }
190 if(firstMS == inputTSOS->end()) {
191 ATH_MSG_WARNING("Unable to find first MS TSOS");
192 ATH_MSG_WARNING("Unable to update Calorimeter TSOS");
193 return;
194 }
195
196 // check that first MS TSOS is not a PerigeeSurface
197 //bool removeOoC = false;
198 Trk::TrackStates::const_iterator firstMSnotPerigee = firstMS;
199 if( (*firstMS)->type(Trk::TrackStateOnSurface::Perigee) && (firstMS+1)!=inputTSOS->end()) {
200 firstMSnotPerigee=firstMS+1;
201 //removeOoC = true;
202 }
203
204#ifdef DEBUGON
205 printTSOS(*firstCALO, "FIRST CALO");
206 printTSOS(*firstMSnotPerigee, "FIRST MS");
207#endif
208 double Eloss = 0.;
209 double X0ScaleMS = 0.;
210 double ElossScaleMS = 0.;
211 // get calorimeter TSOS from TG extrapolating from last ID to MS
212 Trk::TrackStates* caloTSOS = this->getCaloTSOS (*startParameters,
213 track,
214 (*firstMSnotPerigee)->surface(),
216 Trk::muon,
217 Eloss, X0ScaleMS, ElossScaleMS,
218 (firstMSwP == inputTSOS->end()) ? nullptr : (*firstMSwP)->trackParameters(),
219 false,
220 true);
221
222 if(!caloTSOS || caloTSOS->size()!=3) {
223 ATH_MSG_WARNING("Unable to retrieve Calorimeter TSOS from extrapolateM (null or <3)");
224 if(caloTSOS) deleteTSOS(caloTSOS);
225 return;
226 }
227
228#ifdef DEBUGON
229 ATH_MSG_VERBOSE("OLD TSOS multiplicity : " << inputTSOS->size());
230 for(auto m : *inputTSOS) this->printTSOS(m, "OLD TSOS");
231#endif
232
233 // apply X0 and Eloss scale to MuonSpectrometer
234 this->updateVectorMS(inputTSOS.get(),firstMS,X0ScaleMS,ElossScaleMS);
235 // update the original vector
236 Trk::TrkMaterialProviderTool::updateVector(inputTSOS.get(), firstCALO, firstMS, caloTSOS);
237 track.setTrackStateOnSurfaces (std::move (inputTSOS));
238 myLocal_resetTrack(track);
239}

◆ updateVector()

void TrkMaterialProviderTool::updateVector ( Trk::TrackStates * inputTSOS,
Trk::TrackStates::iterator lastID,
Trk::TrackStates::iterator firstMS,
Trk::TrackStates * caloTSOS )
staticprivate

Helper to update entries in the vector.

Definition at line 1057 of file TrkMaterialProviderTool.cxx.

1061{
1062 //printTSOS(*firstCALO, "UPD->FIRST CALO");
1063 //printTSOS(*firstMS, "UPD->FIRST MS");
1064 unsigned int ntoupdate=0;
1065 Trk::TrackStates::iterator it = firstCALO;
1066 while(it!=firstMS) {
1067 ++it;
1068 ntoupdate++;
1069 }
1070
1071 // replace calo TSOS elements in input vector
1072 if(ntoupdate==caloTSOS->size()) {
1073 std::copy(caloTSOS->begin(), caloTSOS->end(), firstCALO);
1074 }else{
1075 it = firstCALO;
1076 unsigned int i=0;
1077 while(i<ntoupdate) {
1078 it = inputTSOS->erase(it);
1079 ++i;
1080 --firstMS;
1081 }
1082 inputTSOS->insert(firstMS, caloTSOS->begin(), caloTSOS->end());
1083 }
1084 // delete the view container
1085 delete caloTSOS;
1086}
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
iterator erase(iterator position)
Remove element at a given position.

◆ updateVectorMS()

void TrkMaterialProviderTool::updateVectorMS ( Trk::TrackStates * inputTSOS,
const Trk::TrackStates::iterator & firstMS,
double X0ScaleMS,
double ElossScaleMS ) const
private

update the TSOS vector for the Muon Spectrometer applying X0 and Eloss scaling

Definition at line 1087 of file TrkMaterialProviderTool.cxx.

1090{
1091
1092 bool debug = false;
1093
1094// Scale the X0 and Energy loss in the Muon Spectrometer
1095
1096 std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes> meotPattern(0);
1099 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1101 typePattern.set(Trk::TrackStateOnSurface::Scatterer);
1102
1103 if(X0ScaleMS<0.5||ElossScaleMS<0.5||X0ScaleMS>2.||ElossScaleMS>2.) {
1104 ATH_MSG_WARNING("Too large or too small X0ScaleMS " << X0ScaleMS << " ElossScaleMS " << ElossScaleMS);
1105 }
1106
1108 int msStates = 0;
1109 int msMatStates = 0;
1110 int msMatParStates = 0;
1111
1112// In the MuonSpectrometer the TSOS for the MaterialEffectsOnTrack do NOT have trackParameters
1113
1114 for(;it!= inputTSOS->end();++it) {
1115 msStates++;
1116 if((*it)->materialEffectsOnTrack()) {
1117 msMatStates++;
1118// if((*it)->trackParameters()) {
1119// ATH_MSG_WARNING("No trackparameters on TrackStateOnSurface ");
1120// continue;
1121// }
1122 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>((*it)->materialEffectsOnTrack());
1123 if(meot) {
1124 msMatParStates++;
1125 const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1126 if(energyLoss) {
1127 const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1128 if(scatAngles) {
1129 auto scatNew = Trk::ScatteringAngles(
1130 0,
1131 0,
1132 std::sqrt(X0ScaleMS) * scatAngles->sigmaDeltaTheta(),
1133 std::sqrt(X0ScaleMS) * scatAngles->sigmaDeltaPhi());
1134 double deltaE = (ElossScaleMS * energyLoss->deltaE());
1135 double sigmaDeltaE = (ElossScaleMS * energyLoss->sigmaDeltaE());
1136 double sigmaPlusDeltaE =
1137 (ElossScaleMS * energyLoss->sigmaPlusDeltaE());
1138 double sigmaMinusDeltaE =
1139 (ElossScaleMS * energyLoss->sigmaMinusDeltaE());
1140 double deltaE_ioni = (ElossScaleMS * energyLoss->meanIoni());
1141 double sigmaDeltaE_ioni = (ElossScaleMS * energyLoss->sigmaIoni());
1142 double deltaE_rad = (ElossScaleMS * energyLoss->meanRad());
1143 double sigmaDeltaE_rad = (ElossScaleMS * energyLoss->sigmaRad());
1144 double depth = energyLoss->length();
1145
1146 if (debug)
1147 std::cout << " updateVectorMS Old Eloss " << energyLoss->deltaE()
1148 << " new Eloss " << deltaE << std::endl;
1149
1150 auto energyLossNew = std::make_unique<Trk::EnergyLoss>(deltaE,
1151 sigmaDeltaE,
1152 sigmaMinusDeltaE,
1153 sigmaPlusDeltaE,
1154 deltaE_ioni,
1155 sigmaDeltaE_ioni,
1156 deltaE_rad,
1157 sigmaDeltaE_rad,
1158 depth);
1159 const Trk::Surface& surf = meot->associatedSurface();
1160 auto newMeot =
1161 std::make_unique<Trk::MaterialEffectsOnTrack>(X0ScaleMS * meot->thicknessInX0(),
1162 scatNew,
1163 std::move(energyLossNew),
1164 surf,
1165 meotPattern);
1166 std::unique_ptr<Trk::TrackParameters> pars{};
1167 if ((*it)->trackParameters())
1168 pars = (*it)->trackParameters()->uniqueClone();
1169 // make new TSOS
1170 const Trk::TrackStateOnSurface* newTSOS =
1171 new Trk::TrackStateOnSurface(
1172 nullptr, std::move(pars), std::move(newMeot), typePattern);
1173 Trk::TrackStates* newTSOSvector =
1175 newTSOSvector->push_back(&(*newTSOS));
1176 // replace TSOS in MS with new one
1177 std::copy(newTSOSvector->begin(), newTSOSvector->end(), it);
1178 delete newTSOSvector;
1179 }
1180 }
1181 }
1182 }
1183 }
1184
1185
1186 if(debug) {
1187 std::cout << " msStates " << msStates << " msMatStates " << msMatStates << " msMatParStates " << msMatParStates << std::endl;
1188
1189// dump (new) energy loss
1190 for(it = firstMS;it!= inputTSOS->end();++it) {
1191 if((*it)->materialEffectsOnTrack()) {
1192 const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>((*it)->materialEffectsOnTrack());
1193 if(meot) {
1194 const Trk::EnergyLoss* energyLoss = meot->energyLoss();
1195 if(energyLoss) {
1196 const Trk::ScatteringAngles* scatAngles = meot->scatteringAngles();
1197 if(scatAngles) {
1198 std::cout << " updateVectorMS dump NEW Eloss " << energyLoss->deltaE() << std::endl;
1199 }
1200 }
1201 }
1202 }
1203 }
1204
1205 } // end debug
1206
1207
1208}
const bool debug

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_aggregateTSOS

bool Trk::TrkMaterialProviderTool::m_aggregateTSOS
private

Definition at line 225 of file TrkMaterialProviderTool.h.

◆ m_applyTGScaling

bool Trk::TrkMaterialProviderTool::m_applyTGScaling
private

Definition at line 223 of file TrkMaterialProviderTool.h.

◆ m_caloMeasTool

ToolHandle<Rec::IMuidCaloEnergyMeas> Trk::TrkMaterialProviderTool::m_caloMeasTool {this, "CaloMeasTool", "Rec::MuidCaloEnergyMeas/MuidCaloEnergyMeas"}
private

Definition at line 206 of file TrkMaterialProviderTool.h.

207{this, "CaloMeasTool", "Rec::MuidCaloEnergyMeas/MuidCaloEnergyMeas"};

◆ m_caloParamTool

ToolHandle<Rec::IMuidCaloEnergyParam> Trk::TrkMaterialProviderTool::m_caloParamTool {this, "CaloParamTool", "Rec::MuidCaloEnergyParam/MuidCaloEnergyParam"}
private

Definition at line 208 of file TrkMaterialProviderTool.h.

209{this, "CaloParamTool", "Rec::MuidCaloEnergyParam/MuidCaloEnergyParam"};

◆ m_calorimeterVolume

std::unique_ptr<Trk::Volume> Trk::TrkMaterialProviderTool::m_calorimeterVolume
private

Definition at line 216 of file TrkMaterialProviderTool.h.

◆ m_DetID

const AtlasDetectorID* Trk::TrkMaterialProviderTool::m_DetID
private

Definition at line 215 of file TrkMaterialProviderTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_elossupdator

PublicToolHandle<Trk::IEnergyLossUpdator> Trk::TrkMaterialProviderTool::m_elossupdator {this,"EnergyLossUpdator","Trk::EnergyLossUpdator/AtlasEnergyLossUpdator",""}
private

Definition at line 193 of file TrkMaterialProviderTool.h.

194{this,"EnergyLossUpdator","Trk::EnergyLossUpdator/AtlasEnergyLossUpdator",""};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fieldCacheCondObjInputKey

SG::ReadCondHandleKey<AtlasFieldCacheCondObj> Trk::TrkMaterialProviderTool::m_fieldCacheCondObjInputKey
private
Initial value:
{this, "AtlasFieldCacheCondObj", "fieldCondObj",
"Name of the Magnetic Field conditions object key"}

Definition at line 220 of file TrkMaterialProviderTool.h.

220 {this, "AtlasFieldCacheCondObj", "fieldCondObj",
221 "Name of the Magnetic Field conditions object key"};

◆ m_indetVolume

std::unique_ptr<Trk::Volume> Trk::TrkMaterialProviderTool::m_indetVolume
private

Definition at line 217 of file TrkMaterialProviderTool.h.

◆ m_maxNTracksIso

int Trk::TrkMaterialProviderTool::m_maxNTracksIso
private

Definition at line 228 of file TrkMaterialProviderTool.h.

◆ m_muonCaloEnergyTool

ToolHandle<Rec::IMuonCaloEnergyTool> Trk::TrkMaterialProviderTool::m_muonCaloEnergyTool
private
Initial value:
{this,
"MuonCaloEnergyTool", ""}

Definition at line 212 of file TrkMaterialProviderTool.h.

212 {this,
213 "MuonCaloEnergyTool", ""};

◆ m_muonExtrapolator

PublicToolHandle<Trk::IExtrapolator> Trk::TrkMaterialProviderTool::m_muonExtrapolator {this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator",""}
private

Definition at line 191 of file TrkMaterialProviderTool.h.

192{this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator",""};

◆ m_overwriteElossParam

bool Trk::TrkMaterialProviderTool::m_overwriteElossParam
private

Definition at line 232 of file TrkMaterialProviderTool.h.

◆ m_paramPtCut

double Trk::TrkMaterialProviderTool::m_paramPtCut
private

Definition at line 229 of file TrkMaterialProviderTool.h.

◆ m_repositionTSOS

bool Trk::TrkMaterialProviderTool::m_repositionTSOS
private

Definition at line 224 of file TrkMaterialProviderTool.h.

◆ m_scattool

ToolHandle< Trk::IMultipleScatteringUpdator > Trk::TrkMaterialProviderTool::m_scattool
private
Initial value:
{this, "MultipleScatteringTool",
"Trk::MultipleScatteringUpdator/AtlasMultipleScatteringUpdator"}

Definition at line 202 of file TrkMaterialProviderTool.h.

203 {this, "MultipleScatteringTool",
204 "Trk::MultipleScatteringUpdator/AtlasMultipleScatteringUpdator"};

◆ m_trackingGeometryReadKey

SG::ReadCondHandleKey<TrackingGeometry> Trk::TrkMaterialProviderTool::m_trackingGeometryReadKey {this, "TrackingGeometryReadKey", "", "Key of the TrackingGeometry conditions data."}
private

Definition at line 199 of file TrkMaterialProviderTool.h.

200{this, "TrackingGeometryReadKey", "", "Key of the TrackingGeometry conditions data."};

◆ m_trackingGeometrySvc

ServiceHandle<ITrackingGeometrySvc> Trk::TrkMaterialProviderTool::m_trackingGeometrySvc {this, "TrackingGeometrySvc", "", ""}
private

Definition at line 197 of file TrkMaterialProviderTool.h.

197{this, "TrackingGeometrySvc", "", ""};

◆ m_trackingVolumesSvc

ServiceHandle<Trk::ITrackingVolumesSvc> Trk::TrkMaterialProviderTool::m_trackingVolumesSvc {this, "TrackingVolumeSvc", "Trk::TrackingVolumesSvc/TrackingVolumesSvc"}
private

Definition at line 195 of file TrkMaterialProviderTool.h.

196{this, "TrackingVolumeSvc", "Trk::TrackingVolumesSvc/TrackingVolumesSvc"};

◆ m_trackIsolationTool

ToolHandle<Rec::IMuidTrackIsolation> Trk::TrkMaterialProviderTool::m_trackIsolationTool {this, "TrackIsolationTool", "Rec::MuidTrackIsolation/MuidTrackIsolation"}
private

Definition at line 210 of file TrkMaterialProviderTool.h.

211{this, "TrackIsolationTool", "Rec::MuidTrackIsolation/MuidTrackIsolation"};

◆ m_updateTSOS

bool Trk::TrkMaterialProviderTool::m_updateTSOS
private

Definition at line 226 of file TrkMaterialProviderTool.h.

◆ m_useCaloEnergyMeasurement

bool Trk::TrkMaterialProviderTool::m_useCaloEnergyMeasurement
private

Definition at line 230 of file TrkMaterialProviderTool.h.

◆ m_useMuonCaloEnergyTool

bool Trk::TrkMaterialProviderTool::m_useMuonCaloEnergyTool
private

Definition at line 231 of file TrkMaterialProviderTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: