Skip to content
Snippets Groups Projects
Commit eb65694e authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

Make PixelToTPIDTool aware of the EventContext. Allow to pass it as argument to avoid lookups

parent 60531e64
No related branches found
No related tags found
No related merge requests found
...@@ -37,12 +37,23 @@ namespace InDet { ...@@ -37,12 +37,23 @@ namespace InDet {
virtual ~PixelToTPIDTool (); virtual ~PixelToTPIDTool ();
virtual StatusCode initialize() override; virtual StatusCode initialize() override;
virtual StatusCode finalize () override; virtual StatusCode finalize () override;
virtual float dEdx(const Trk::Track& track, int& nUsedHits, int& nUsedIBLOverflowHits) const override; virtual float dEdx(const EventContext& ctx,
const Trk::Track& track,
int& nUsedHits,
int& nUsedIBLOverflowHits) const override final;
virtual std::vector<float> getLikelihoods(double dedx, double p, int nGoodPixels) const override; virtual std::vector<float> getLikelihoods(
virtual float getMass(double dedx, double p, int nGoodPixels) const override; const EventContext& ctx,
double dedx,
double p,
int nGoodPixels) const override final;
virtual float getMass(const EventContext& ctx,
double dedx,
double p,
int nGoodPixels) const override final;
private: private:
ServiceHandle<IBLParameterSvc> m_IBLParameterSvc; ServiceHandle<IBLParameterSvc> m_IBLParameterSvc;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
// Pixels: // Pixels:
#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" #include "InDetRIO_OnTrack/PixelClusterOnTrack.h"
#include "InDetIdentifier/PixelID.h" #include "InDetIdentifier/PixelID.h"
#include "PixelGeoModel/IBLParameterSvc.h" #include "PixelGeoModel/IBLParameterSvc.h"
// CLHEP: // CLHEP:
#include "CLHEP/Matrix/Vector.h" #include "CLHEP/Matrix/Vector.h"
...@@ -41,10 +41,10 @@ InDet::PixelToTPIDTool::PixelToTPIDTool(const std::string& t, const std::string& ...@@ -41,10 +41,10 @@ InDet::PixelToTPIDTool::PixelToTPIDTool(const std::string& t, const std::string&
float energyPair = 3.68e-6; // Energy in MeV to create an electron-hole pair in silicon float energyPair = 3.68e-6; // Energy in MeV to create an electron-hole pair in silicon
float sidensity = 2.329; // silicon density in g cm^-3 float sidensity = 2.329; // silicon density in g cm^-3
//conversion Factor //conversion Factor
//{.025,.023,.020}; //{Old Planars,IBL_3Ds,IBL_Planars} the sensors thickness will be take into account in dEdx calculation //{.025,.023,.020}; //{Old Planars,IBL_3Ds,IBL_Planars} the sensors thickness will be take into account in dEdx calculation
m_conversionfactor=energyPair/sidensity; m_conversionfactor=energyPair/sidensity;
} }
...@@ -57,11 +57,11 @@ StatusCode InDet::PixelToTPIDTool::initialize() { ...@@ -57,11 +57,11 @@ StatusCode InDet::PixelToTPIDTool::initialize() {
ATH_CHECK(detStore()->retrieve(m_pixelid,"PixelID")); ATH_CHECK(detStore()->retrieve(m_pixelid,"PixelID"));
if (m_IBLParameterSvc.retrieve().isFailure()) { if (m_IBLParameterSvc.retrieve().isFailure()) {
ATH_MSG_FATAL("Could not retrieve IBLParameterSvc"); ATH_MSG_FATAL("Could not retrieve IBLParameterSvc");
return StatusCode::FAILURE; return StatusCode::FAILURE;
} else } else
ATH_MSG_INFO("Retrieved service " << m_IBLParameterSvc); ATH_MSG_INFO("Retrieved service " << m_IBLParameterSvc);
ATH_CHECK(m_moduleDataKey.initialize()); ATH_CHECK(m_moduleDataKey.initialize());
...@@ -82,19 +82,25 @@ StatusCode InDet::PixelToTPIDTool::finalize() ...@@ -82,19 +82,25 @@ StatusCode InDet::PixelToTPIDTool::finalize()
//============================================================================================ //============================================================================================
float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int& nUsedIBLOverflowHits) const { float
InDet::PixelToTPIDTool::dEdx(const EventContext& ctx,
const Trk::Track& track,
int& nUsedHits,
int& nUsedIBLOverflowHits) const
{
unsigned int pixelhits = 0; unsigned int pixelhits = 0;
nUsedHits=0; nUsedHits=0;
nUsedIBLOverflowHits=0; nUsedIBLOverflowHits=0;
float Pixel_sensorthickness=.025; //250 microns Pixel Planars float Pixel_sensorthickness=.025; //250 microns Pixel Planars
float IBL_3D_sensorthickness=.023; //230 microns IBL 3D float IBL_3D_sensorthickness=.023; //230 microns IBL 3D
float IBL_PLANAR_sensorthickness=.020;// 200 microns IBL Planars float IBL_PLANAR_sensorthickness=.020;// 200 microns IBL Planars
float dEdxValue=0; float dEdxValue=0;
//std::multimap<float,int> chargesMap; //second value keeps track if the cluster is in IBL and has at least an overflow hit //std::multimap<float,int> chargesMap;
////second value keeps track if the cluster is in IBL and has at least an overflow hit
std::multimap<float,int> dEdxMap; std::multimap<float,int> dEdxMap;
// Check for track states: // Check for track states:
const DataVector<const Trk::TrackStateOnSurface>* recoTrackStates = track.trackStateOnSurfaces(); const DataVector<const Trk::TrackStateOnSurface>* recoTrackStates = track.trackStateOnSurfaces();
if (recoTrackStates) { if (recoTrackStates) {
...@@ -125,22 +131,26 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int& ...@@ -125,22 +131,26 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int&
int bec=m_pixelid->barrel_ec(pixclus->identify()); int bec=m_pixelid->barrel_ec(pixclus->identify());
int layer=m_pixelid->layer_disk(pixclus->identify()); int layer=m_pixelid->layer_disk(pixclus->identify());
int eta_module=m_pixelid->eta_module(pixclus->identify());//check eta module to select thickness int eta_module=m_pixelid->eta_module(pixclus->identify());//check eta module to select thickness
float dotProd = (*tsosIter)->trackParameters()->momentum().dot((*tsosIter)->trackParameters()->associatedSurface().normal()); float dotProd = (*tsosIter)->trackParameters()->momentum().dot(
float cosalpha=fabs(dotProd/(*tsosIter)->trackParameters()->momentum().mag()); (*tsosIter)->trackParameters()->associatedSurface().normal());
float cosalpha =
fabs(dotProd / (*tsosIter)->trackParameters()->momentum().mag());
if (std::abs(cosalpha)<0.16) { continue; } if (std::abs(cosalpha)<0.16) { continue; }
float charge=pixclus->prepRawData()->totalCharge()*cosalpha; float charge=pixclus->prepRawData()->totalCharge()*cosalpha;
//keep track if this is an ibl cluster with overflow //keep track if this is an ibl cluster with overflow
int iblOverflow=0; int iblOverflow=0;
if ((m_IBLParameterSvc->containsIBL()) and (bec==0) and (layer==0)) { // check if IBL if ((m_IBLParameterSvc->containsIBL()) and (bec==0) and (layer==0)) { // check if IBL
//loop over ToT and check if anyone is overflow (ToT==14) check for IBL cluster overflow //loop over ToT and check if anyone is overflow (ToT==14) check for IBL cluster overflow
int overflowIBLToT = SG::ReadCondHandle<PixelModuleData>(m_moduleDataKey)->getFEI4OverflowToT(0,0); int overflowIBLToT =
SG::ReadCondHandle<PixelModuleData>(m_moduleDataKey, ctx)
->getFEI4OverflowToT(0, 0);
const std::vector<int>& ToTs = pixclus->prepRawData()->totList(); const std::vector<int>& ToTs = pixclus->prepRawData()->totList();
for (int pixToT : ToTs) { for (int pixToT : ToTs) {
if (pixToT >= overflowIBLToT) { if (pixToT >= overflowIBLToT) {
//overflow pixel hit -- flag cluster //overflow pixel hit -- flag cluster
...@@ -149,23 +159,35 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int& ...@@ -149,23 +159,35 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int&
} }
}// end }// end
//this is IBL layer -- @todo: check using proper service (safe against geometries) // this is IBL layer -- @todo: check using proper service (safe
if (((eta_module>=-10 && eta_module<=-7)||(eta_module>=6 && eta_module<=9)) && (fabs(locy)<10. && (locx>-8.33 && locx<8.3))) { //check if IBL 3D and good cluster selection // against geometries)
dEdxValue=charge*m_conversionfactor/IBL_3D_sensorthickness; if (((eta_module >= -10 && eta_module <= -7) ||
dEdxMap.insert(std::pair<float,int>(dEdxValue, iblOverflow)); (eta_module >= 6 && eta_module <= 9)) &&
(fabs(locy) < 10. &&
(locx > -8.33 &&
locx < 8.3))) { // check if IBL 3D and good cluster selection
dEdxValue = charge * m_conversionfactor / IBL_3D_sensorthickness;
dEdxMap.insert(std::pair<float, int>(dEdxValue, iblOverflow));
pixelhits++; pixelhits++;
if (iblOverflow==1) { nUsedIBLOverflowHits++; } if (iblOverflow == 1) {
} nUsedIBLOverflowHits++;
else if((eta_module>=-6 && eta_module<=5) && (fabs(locy)<20. &&(locx>-8.33 && locx<8.3))) { //check if IBL planar and good cluster selection }
dEdxValue=charge*m_conversionfactor/IBL_PLANAR_sensorthickness; } else if ((eta_module >= -6 && eta_module <= 5) &&
dEdxMap.insert(std::pair<float,int>(dEdxValue, iblOverflow)); (fabs(locy) < 20. &&
(locx > -8.33 &&
locx < 8.3))) { // check if IBL planar and good cluster
// selection
dEdxValue =
charge * m_conversionfactor / IBL_PLANAR_sensorthickness;
dEdxMap.insert(std::pair<float, int>(dEdxValue, iblOverflow));
pixelhits++; pixelhits++;
if (iblOverflow==1) { nUsedIBLOverflowHits++; } if (iblOverflow == 1) {
} nUsedIBLOverflowHits++;
else{ }
} else {
dEdxValue=-1; dEdxValue=-1;
} //end check which IBL Module } // end check which IBL Module
} }
//PIXEL layer and ENDCAP //PIXEL layer and ENDCAP
else if(bec==0 && fabs(locy)<30. && ((locx>-8.20 && locx<-0.60) || (locx>0.50 && locx<8.10))) { else if(bec==0 && fabs(locy)<30. && ((locx>-8.20 && locx<-0.60) || (locx>0.50 && locx<8.10))) {
...@@ -187,7 +209,7 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int& ...@@ -187,7 +209,7 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int&
float averagedEdx=0.; float averagedEdx=0.;
nUsedHits=0; nUsedHits=0;
int IBLOverflow=0; int IBLOverflow=0;
for (std::pair<float,int> itdEdx : dEdxMap) { for (std::pair<float,int> itdEdx : dEdxMap) {
if (itdEdx.second==0) { if (itdEdx.second==0) {
averagedEdx += itdEdx.first; averagedEdx += itdEdx.first;
...@@ -197,35 +219,47 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int& ...@@ -197,35 +219,47 @@ float InDet::PixelToTPIDTool::dEdx(const Trk::Track& track, int& nUsedHits, int&
//break, skipping last or the two last elements depending on total measurements //break, skipping last or the two last elements depending on total measurements
if (((int)pixelhits>=5) and ((int)nUsedHits>=(int)pixelhits-2)) { break; } if (((int)pixelhits>=5) and ((int)nUsedHits>=(int)pixelhits-2)) { break; }
//break, IBL Overflow case pixelhits==3 and 4 //break, IBL Overflow case pixelhits==3 and 4
if ((int)IBLOverflow>0 and ((int)pixelhits==3) and (int)nUsedHits==1) { break; } if ((int)IBLOverflow>0 and ((int)pixelhits==3) and (int)nUsedHits==1) { break; }
if ((int)IBLOverflow>0 and ((int)pixelhits==4) and (int)nUsedHits==2) { break; } if ((int)IBLOverflow>0 and ((int)pixelhits==4) and (int)nUsedHits==2) { break; }
if (((int)pixelhits > 1) and ((int)nUsedHits >=(int)pixelhits-1)) { break; } if (((int)pixelhits > 1) and ((int)nUsedHits >=(int)pixelhits-1)) { break; }
if ((int)IBLOverflow>0 and (int)pixelhits==1) { //only IBL in overflow if ((int)IBLOverflow>0 and (int)pixelhits==1) { //only IBL in overflow
averagedEdx=itdEdx.first; averagedEdx=itdEdx.first;
break; break;
} }
} }
if (nUsedHits>0 or (nUsedHits==0 and(int)IBLOverflow>0 and (int)pixelhits==1)) { if (nUsedHits>0 or (nUsedHits==0 and(int)IBLOverflow>0 and (int)pixelhits==1)) {
if (nUsedHits>0) { averagedEdx=averagedEdx/nUsedHits; } if (nUsedHits>0) { averagedEdx=averagedEdx/nUsedHits; }
ATH_MSG_DEBUG("NEW dEdx = " << averagedEdx); ATH_MSG_DEBUG("NEW dEdx = " << averagedEdx);
ATH_MSG_DEBUG("Used hits: " << nUsedHits << ", IBL overflows: " << IBLOverflow ); ATH_MSG_DEBUG("Used hits: " << nUsedHits << ", IBL overflows: " << IBLOverflow );
ATH_MSG_DEBUG("Original number of measurements = " << pixelhits << "( map size = " << dEdxMap.size() << ")"); ATH_MSG_DEBUG("Original number of measurements = " << pixelhits << "( map size = " << dEdxMap.size() << ")");
return averagedEdx; return averagedEdx;
} }
return -1; return -1;
} }
std::vector<float> InDet::PixelToTPIDTool::getLikelihoods(double dedx2, double p2, int nGoodPixels) const { std::vector<float>
return SG::ReadCondHandle<PixeldEdxData>(m_dedxKey)->getLikelihoods(dedx2,p2,nGoodPixels); InDet::PixelToTPIDTool::getLikelihoods(const EventContext& ctx,
double dedx2,
double p2,
int nGoodPixels) const
{
return SG::ReadCondHandle<PixeldEdxData>(m_dedxKey, ctx)
->getLikelihoods(dedx2, p2, nGoodPixels);
} }
float InDet::PixelToTPIDTool::getMass(double dedx, double p, int nGoodPixels) const { float
return SG::ReadCondHandle<PixeldEdxData>(m_dedxKey)->getMass(dedx,p/1000,nGoodPixels); InDet::PixelToTPIDTool::getMass(const EventContext& ctx,
double dedx,
double p,
int nGoodPixels) const
{
return SG::ReadCondHandle<PixeldEdxData>(m_dedxKey, ctx)
->getMass(dedx, p / 1000, nGoodPixels);
} }
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#ifndef TRK_IPIXELTOTPIDTOOL_H #ifndef TRK_IPIXELTOTPIDTOOL_H
#define TRK_IPIXELTOTPIDTOOL_H #define TRK_IPIXELTOTPIDTOOL_H
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/ThreadLocalContext.h"
#include "GaudiKernel/IAlgTool.h" #include "GaudiKernel/IAlgTool.h"
#include <vector> #include <vector>
...@@ -29,11 +31,30 @@ namespace Trk { ...@@ -29,11 +31,30 @@ namespace Trk {
@param[in] track the track to be identified @param[in] track the track to be identified
@returns probability @returns probability
*/ */
virtual float dEdx(const Trk::Track& track, virtual float dEdx(const EventContext& ctx,
const Trk::Track& track,
int& nUsedHits, int& nUsedHits,
int& nUsedIBLOverflowHits) const = 0; int& nUsedIBLOverflowHits) const = 0;
virtual std::vector<float> getLikelihoods(double dedx, double p, int nGoodPixels) const = 0;
virtual float getMass(double dedx, double p, int nGoodPixels) const = 0; float dEdx(const Trk::Track& track,
int& nUsedHits,
int& nUsedIBLOverflowHits) const;
virtual std::vector<float> getLikelihoods(const EventContext& ctx,
double dedx,
double p,
int nGoodPixels) const = 0;
std::vector<float> getLikelihoods(double dedx,
double p,
int nGoodPixels) const;
virtual float getMass(const EventContext& ctx,
double dedx,
double p,
int nGoodPixels) const = 0;
float getMass(double dedx, double p, int nGoodPixels) const;
}; };
inline const InterfaceID& Trk::IPixelToTPIDTool::interfaceID() inline const InterfaceID& Trk::IPixelToTPIDTool::interfaceID()
...@@ -42,5 +63,6 @@ namespace Trk { ...@@ -42,5 +63,6 @@ namespace Trk {
} }
} // end of namespace } // end of namespace
#include "TrkToolInterfaces/IPixelToTPIDTool.icc"
#endif #endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
namespace Trk {
inline float
IPixelToTPIDTool::dEdx(const Trk::Track& track,
int& nUsedHits,
int& nUsedIBLOverflowHits) const
{
return dEdx(
Gaudi::Hive::currentContext(), track, nUsedHits, nUsedIBLOverflowHits);
}
inline std::vector<float>
IPixelToTPIDTool::getLikelihoods(double dedx, double p, int nGoodPixels) const
{
return getLikelihoods(Gaudi::Hive::currentContext(), dedx, p, nGoodPixels);
}
inline float
IPixelToTPIDTool::getMass(double dedx, double p, int nGoodPixels) const
{
return getMass(Gaudi::Hive::currentContext(), dedx, p, nGoodPixels);
}
}
...@@ -198,7 +198,7 @@ Trk::TrackSummaryTool::fillSummary(const EventContext& ctx, ...@@ -198,7 +198,7 @@ Trk::TrackSummaryTool::fillSummary(const EventContext& ctx,
}; };
setTheseElements(information, atPixelIndices, toZero); setTheseElements(information, atPixelIndices, toZero);
if (track.info().trackFitter() != TrackInfo::Unknown && !m_dedxtool.empty()) { if (track.info().trackFitter() != TrackInfo::Unknown && !m_dedxtool.empty()) {
dedx = m_dedxtool->dEdx(track, nHitsUsed_dEdx, nOverflowHits_dEdx); dedx = m_dedxtool->dEdx(ctx,track, nHitsUsed_dEdx, nOverflowHits_dEdx);
} }
information[Trk::numberOfDBMHits] = 0; information[Trk::numberOfDBMHits] = 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment