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

TRT_ToT_dEdx: pass EventContext to avoid lookups

parent 0ec33e5a
No related branches found
No related tags found
No related merge requests found
...@@ -280,7 +280,7 @@ TRT_ToT_dEdx::dEdx(const EventContext& ctx, ...@@ -280,7 +280,7 @@ TRT_ToT_dEdx::dEdx(const EventContext& ctx,
ToTsum = std::accumulate(vecToT.begin(), vecToT.end(), 0); ToTsum = std::accumulate(vecToT.begin(), vecToT.end(), 0);
if (m_correctionType == kTrackBased) { if (m_correctionType == kTrackBased) {
correctionFactor=trackOccupancyCorrection(track, useHitsHT); correctionFactor=trackOccupancyCorrection(ctx,track, useHitsHT);
} else { } else {
correctionFactor=correctNormalization(ctx,nVtx); correctionFactor=correctNormalization(ctx,nVtx);
} }
...@@ -383,7 +383,7 @@ TRT_ToT_dEdx::dEdx(const EventContext& ctx, ...@@ -383,7 +383,7 @@ TRT_ToT_dEdx::dEdx(const EventContext& ctx,
double ToTsum = ToTsumXe*nhitsXe + ToTsumAr*nhitsAr + ToTsumKr*nhitsKr; double ToTsum = ToTsumXe*nhitsXe + ToTsumAr*nhitsAr + ToTsumKr*nhitsKr;
if (m_correctionType == kTrackBased) { if (m_correctionType == kTrackBased) {
correctionFactor = trackOccupancyCorrection(track, useHitsHT); correctionFactor = trackOccupancyCorrection(ctx,track, useHitsHT);
} else { } else {
correctionFactor = correctNormalization(ctx,nVtx); correctionFactor = correctNormalization(ctx,nVtx);
} }
...@@ -846,34 +846,52 @@ TRT_ToT_dEdx::correctToT_corrRZ(const EventContext& ctx, ...@@ -846,34 +846,52 @@ TRT_ToT_dEdx::correctToT_corrRZ(const EventContext& ctx,
valToT = fitFuncEndcap_corrRZL(ctx,gasType, hitRtrack, hitPosR, Layer, hitZ>0?1:(hitZ<0?-1:0)); valToT = fitFuncEndcap_corrRZL(ctx,gasType, hitRtrack, hitPosR, Layer, hitZ>0?1:(hitZ<0?-1:0));
}else{ }else{
if (abs(hitPart)==1) // Barrel if (abs(hitPart)==1) // Barrel
valToT = fitFuncBarrel_corrRZ(gasType, hitRtrack, hitZ, Layer, StrawLayer); valToT = fitFuncBarrel_corrRZ(ctx,gasType, hitRtrack, hitZ, Layer, StrawLayer);
else // End-cap else // End-cap
valToT = fitFuncEndcap_corrRZ(gasType, hitRtrack, hitPosR, Layer, hitZ>0?1:(hitZ<0?-1:0)); valToT = fitFuncEndcap_corrRZ(ctx,gasType, hitRtrack, hitPosR, Layer, hitZ>0?1:(hitZ<0?-1:0));
} }
if (std::isinf(valToT)) return 0.; if (std::isinf(valToT)) return 0.;
if (valToT!=0) return ToTmip*timeOverThreshold/valToT; if (valToT!=0) return ToTmip*timeOverThreshold/valToT;
return 0.; return 0.;
} }
double TRT_ToT_dEdx::fitFuncBarrel_corrRZ(EGasType gasType, double driftRadius,double zPosition, int Layer, int StrawLayer) const double
TRT_ToT_dEdx::fitFuncBarrel_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double zPosition,
int Layer,
int StrawLayer) const
{ {
if (Layer == 0 && StrawLayer < 9) { if (Layer == 0 && StrawLayer < 9) {
return fitFuncBarrelShort_corrRZ(gasType, driftRadius, zPosition, StrawLayer); return fitFuncBarrelShort_corrRZ(ctx,gasType, driftRadius, zPosition, StrawLayer);
} }
return fitFuncBarrelLong_corrRZ(gasType, driftRadius, zPosition, Layer, StrawLayer); return fitFuncBarrelLong_corrRZ(ctx,gasType, driftRadius, zPosition, Layer, StrawLayer);
} }
double TRT_ToT_dEdx::fitFuncEndcap_corrRZ(EGasType gasType, double driftRadius,double radialPosition, int Layer, int sign) const double
TRT_ToT_dEdx::fitFuncEndcap_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double radialPosition,
int Layer,
int sign) const
{ {
/** /**
* T(r,R) = T0(r)+ a(r)*R * T(r,R) = T0(r)+ a(r)*R
*/ */
double T0 = fitFuncPol_corrRZ(gasType, 0,driftRadius,Layer,0,sign,2); double T0 = fitFuncPol_corrRZ(ctx,gasType, 0,driftRadius,Layer,0,sign,2);
double a = fitFuncPol_corrRZ(gasType, 1,driftRadius,Layer,0,sign,2); double a = fitFuncPol_corrRZ(ctx,gasType, 1,driftRadius,Layer,0,sign,2);
return T0+a*radialPosition; return T0+a*radialPosition;
} }
double TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadius,double zPosition, int Layer, int StrawLayer) const double
TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double zPosition,
int Layer,
int StrawLayer) const
{ {
/** /**
* |z| /|z| - l \ * |z| /|z| - l \
...@@ -885,9 +903,9 @@ double TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadi ...@@ -885,9 +903,9 @@ double TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadi
if(zPosition<0)sign=-1; if(zPosition<0)sign=-1;
double l = 704.6; double l = 704.6;
// define set of parameters for negative and positive z positions // define set of parameters for negative and positive z positions
double T0 = fitFuncPol_corrRZ(gasType, 0,driftRadius,Layer,StrawLayer,sign,0); double T0 = fitFuncPol_corrRZ(ctx,gasType, 0,driftRadius,Layer,StrawLayer,sign,0);
double v = fitFuncPol_corrRZ(gasType, 1,driftRadius,Layer,StrawLayer,sign,0); double v = fitFuncPol_corrRZ(ctx,gasType, 1,driftRadius,Layer,StrawLayer,sign,0);
double s = fitFuncPol_corrRZ(gasType, 2,driftRadius,Layer,StrawLayer,sign,0); double s = fitFuncPol_corrRZ(ctx,gasType, 2,driftRadius,Layer,StrawLayer,sign,0);
//_in theory_ For IEEE-compatible type double, argument causes exp to overflow if outside [-708.4, 709.8] //_in theory_ For IEEE-compatible type double, argument causes exp to overflow if outside [-708.4, 709.8]
//however, overflow still seen when argument is 702; so I restrict these to -600, 600 //however, overflow still seen when argument is 702; so I restrict these to -600, 600
const double expArg=(z-l)/s; const double expArg=(z-l)/s;
...@@ -897,7 +915,12 @@ double TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadi ...@@ -897,7 +915,12 @@ double TRT_ToT_dEdx::fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadi
return T0+(z/v)*std::exp(expArg); return T0+(z/v)*std::exp(expArg);
} }
double TRT_ToT_dEdx::fitFuncBarrelShort_corrRZ(EGasType gasType, double driftRadius,double zPosition, int StrawLayer) const double
TRT_ToT_dEdx::fitFuncBarrelShort_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double zPosition,
int StrawLayer) const
{ {
/** /**
* T(r,z) = T0(r)+ b(r)*|z| * T(r,z) = T0(r)+ b(r)*|z|
...@@ -905,15 +928,22 @@ double TRT_ToT_dEdx::fitFuncBarrelShort_corrRZ(EGasType gasType, double driftRad ...@@ -905,15 +928,22 @@ double TRT_ToT_dEdx::fitFuncBarrelShort_corrRZ(EGasType gasType, double driftRad
double z = std::abs(zPosition); double z = std::abs(zPosition);
int sign=1; int sign=1;
if(zPosition<0)sign=-1; if(zPosition<0)sign=-1;
double T0 = fitFuncPol_corrRZ(gasType, 0,driftRadius,0,StrawLayer,sign,1); double T0 = fitFuncPol_corrRZ(ctx,gasType, 0,driftRadius,0,StrawLayer,sign,1);
double b = fitFuncPol_corrRZ(gasType, 1,driftRadius,0,StrawLayer,sign,1); double b = fitFuncPol_corrRZ(ctx,gasType, 1,driftRadius,0,StrawLayer,sign,1);
return T0+b*z; return T0+b*z;
} }
double
double TRT_ToT_dEdx::fitFuncPol_corrRZ(EGasType gasType, int parameter, double driftRadius, int Layer, int Strawlayer, int sign, int set) const TRT_ToT_dEdx::fitFuncPol_corrRZ(const EventContext& ctx,
EGasType gasType,
int parameter,
double driftRadius,
int Layer,
int Strawlayer,
int sign,
int set) const
{ {
SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey,ctx};
const TRTDedxcorrection* dEdxCorrection{*readHandle}; const TRTDedxcorrection* dEdxCorrection{*readHandle};
if(dEdxCorrection==nullptr) if(dEdxCorrection==nullptr)
{ {
...@@ -1191,9 +1221,12 @@ TRT_ToT_dEdx::hitOccupancyCorrection(const EventContext& ctx, ...@@ -1191,9 +1221,12 @@ TRT_ToT_dEdx::hitOccupancyCorrection(const EventContext& ctx,
return ToTmip*valToT; return ToTmip*valToT;
} }
double TRT_ToT_dEdx::trackOccupancyCorrection(const Trk::Track* track, bool useHitsHT) const double
TRT_ToT_dEdx::trackOccupancyCorrection(const EventContext& ctx,
const Trk::Track* track,
bool useHitsHT) const
{ {
SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey,ctx};
const TRTDedxcorrection* dEdxCorrection{*readHandle}; const TRTDedxcorrection* dEdxCorrection{*readHandle};
double corr=-999.; double corr=-999.;
......
...@@ -260,7 +260,12 @@ private: ...@@ -260,7 +260,12 @@ private:
* @param bool variable to specify whether data or MC correction * @param bool variable to specify whether data or MC correction
* @return correction * @return correction
*/ */
double fitFuncEndcap_corrRZ(EGasType gas, double driftRadius, double rPosition, int Layer, int sign) const; double fitFuncEndcap_corrRZ(const EventContext& ctx,
EGasType gas,
double driftRadius,
double rPosition,
int Layer,
int sign) const;
/** /**
* @brief function to compute correction factor in barrel region * @brief function to compute correction factor in barrel region
* @param driftradius * @param driftradius
...@@ -270,22 +275,43 @@ private: ...@@ -270,22 +275,43 @@ private:
* @param bool variable to specify whether data or MC correction * @param bool variable to specify whether data or MC correction
* @return correction * @return correction
*/ */
double fitFuncBarrel_corrRZ(EGasType gas, double driftRadius,double zPosition,int Layer, int StrawLayer) const; double fitFuncBarrel_corrRZ(const EventContext& ctx,
EGasType gas,
double driftRadius,
double zPosition,
int Layer,
int StrawLayer) const;
/** /**
* @brief function called by fitFuncBarrel_corrRZ for long straws * @brief function called by fitFuncBarrel_corrRZ for long straws
*/ */
double fitFuncBarrelLong_corrRZ(EGasType gasType, double driftRadius,double zPosition,int Layer, int StrawLayer) const; double fitFuncBarrelLong_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double zPosition,
int Layer,
int StrawLayer) const;
/** /**
* @brief function called by fitFuncBarrel_corrRZ for short straws * @brief function called by fitFuncBarrel_corrRZ for short straws
*/ */
double fitFuncBarrelShort_corrRZ(EGasType gasType, double driftRadius,double zPosition, int StrawLayer) const; double fitFuncBarrelShort_corrRZ(const EventContext& ctx,
EGasType gasType,
double driftRadius,
double zPosition,
int StrawLayer) const;
/** /**
* @brief function called by fitFuncBarrel_corrRZ and fitFuncEndcap_corrRZ * @brief function called by fitFuncBarrel_corrRZ and fitFuncEndcap_corrRZ
*/ */
double fitFuncPol_corrRZ(EGasType gasType, int parameter, double driftRadius, int Layer, int Strawlayer, int sign, int set) const; double fitFuncPol_corrRZ(const EventContext& ctx,
EGasType gasType,
int parameter,
double driftRadius,
int Layer,
int Strawlayer,
int sign,
int set) const;
/** /**
* @brief function to compute correction factor in endcap region * @brief function to compute correction factor in endcap region
...@@ -323,7 +349,8 @@ private: ...@@ -323,7 +349,8 @@ private:
/* Calibration functions for occupancy corrections */ /* Calibration functions for occupancy corrections */
double hitOccupancyCorrection(const EventContext& ctx, double hitOccupancyCorrection(const EventContext& ctx,
const Trk::TrackStateOnSurface* itr) const; const Trk::TrackStateOnSurface* itr) const;
double trackOccupancyCorrection(const Trk::Track* track, double trackOccupancyCorrection(const EventContext& ctx,
const Trk::Track* track,
bool useHThits) const; bool useHThits) const;
public: public:
......
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