49 InDetTrackSmearingTool::InDetTrackSmearingTool(
const std::string&
name )
50 :
InDet::InDetTrackSystematicsTool(
name )
53 #ifndef XAOD_STANDALONE
54 declareInterface<IInDetTrackSmearingTool>(
this);
57 declareProperty(
"Seed", m_seed);
59 declareProperty(
"calibFileD0Dead", m_calibFileD0Dead =
"InDetTrackSystematicsTools/CalibData_21.2_2018-v18/res_diff_d0_vs_pt.hist.root");
60 declareProperty(
"calibFileZ0Dead", m_calibFileZ0Dead =
"InDetTrackSystematicsTools/CalibData_21.2_2018-v18/res_diff_z0_vs_pt.hist.root");
62 declareProperty(
"calibFileIP_lowpt", m_calibFileIP_lowpt =
"InDetTrackSystematicsTools/CalibData_21.2_2018-v18/trackIPAlign_dec2017.root");
63 declareProperty(
"calibFileIP_highpt_Data16", m_calibFileIP_highpt_Data16 =
"InDetTrackSystematicsTools/CalibData_21.2_2018-v18/trackIPAlignTight.root");
64 declareProperty(
"calibFileIP_highpt_Data17", m_calibFileIP_highpt_Data17 =
"InDetTrackSystematicsTools/CalibData_21.2_2018-v19/trackIPAlignTight_data2017.root");
65 declareProperty(
"calibFileIP_CTIDE", m_calibFileIP_CTIDE =
"InDetTrackSystematicsTools/CalibData_22.0_2022-v00/d0z0_smearing_factors.root");
66 declareProperty(
"runNumber", m_runNumber);
67 declareProperty(
"doCTIDE", m_doCTIDE);
77 ATH_MSG_INFO(
"Using seed of " << m_seed <<
" to initialize RNG" );
78 m_rnd = std::make_unique<TRandom3>(m_seed);
84 ATH_MSG_INFO(
"Using dedicated CTIDE smearing maps for tracks in jets" );
96 return StatusCode::SUCCESS;
99 InDetTrackSmearingTool::~InDetTrackSmearingTool()
101 delete m_smearD0Dead; m_smearD0Dead =
nullptr;
102 delete m_smearZ0Dead; m_smearZ0Dead =
nullptr;
104 delete m_smearD0_lowpt; m_smearD0_lowpt =
nullptr;
105 delete m_smearZ0_lowpt; m_smearZ0_lowpt =
nullptr;
106 delete m_smearD0_lowpt_sys_up; m_smearD0_lowpt_sys_up =
nullptr;
107 delete m_smearZ0_lowpt_sys_up; m_smearZ0_lowpt_sys_up =
nullptr;
108 delete m_smearD0_lowpt_sys_dw; m_smearD0_lowpt_sys_dw =
nullptr;
109 delete m_smearZ0_lowpt_sys_dw; m_smearZ0_lowpt_sys_dw =
nullptr;
111 delete m_smearD0_highpt; m_smearD0_highpt =
nullptr;
112 delete m_smearZ0_highpt; m_smearZ0_highpt =
nullptr;
113 delete m_smearD0_highpt_sys_up; m_smearD0_highpt_sys_up =
nullptr;
114 delete m_smearZ0_highpt_sys_up; m_smearZ0_highpt_sys_up =
nullptr;
115 delete m_smearD0_highpt_sys_dw; m_smearD0_highpt_sys_dw =
nullptr;
116 delete m_smearZ0_highpt_sys_dw; m_smearZ0_highpt_sys_dw =
nullptr;
122 float sigma_D0 = 0.f;
124 if ( isActive(TRK_RES_D0_DEAD) ) {
125 float d0Smear = m_smearD0Dead->GetBinContent(std::as_const(m_smearD0Dead)->
FindBin(
pt));
126 sigma_D0 += d0Smear*d0Smear;
129 bool isActiveD0Meas = isActive(TRK_RES_D0_MEAS);
130 bool isActiveD0MeasUp = isActive(TRK_RES_D0_MEAS_UP);
131 bool isActiveD0MeasDown = isActive(TRK_RES_D0_MEAS_DOWN);
133 if (isActiveD0Meas + isActiveD0MeasUp + isActiveD0MeasDown > 1) {
135 throw std::runtime_error(
"Multiple incompatible D0 systematics are activated." );
136 }
else if (isActiveD0Meas + isActiveD0MeasUp + isActiveD0MeasDown == 0) {
138 return std::sqrt(sigma_D0);
141 TH2* d0hist_lowpt =
nullptr;
142 TH2* d0hist_highpt =
nullptr;
145 d0hist_lowpt = m_smearD0_lowpt;
146 d0hist_highpt = m_smearD0_highpt;
147 }
else if(isActiveD0MeasUp) {
148 d0hist_lowpt = m_smearD0_lowpt_sys_up;
149 d0hist_highpt = m_smearD0_highpt_sys_up;
150 }
else if(isActiveD0MeasDown) {
151 d0hist_lowpt = m_smearD0_lowpt_sys_dw;
152 d0hist_highpt = m_smearD0_highpt_sys_dw;
155 if (d0hist_lowpt ==
nullptr)
ATH_MSG_ERROR(
"d0 lowpt histogram is null!" );
156 if (d0hist_highpt ==
nullptr)
ATH_MSG_ERROR(
"d0 highpt histogram is null!" );
160 d0Smear = readHistogram(d0hist_lowpt,
pt,
eta);
162 d0Smear = readHistogram(d0hist_highpt,
pt,
eta);
171 sigma_D0 += d0Smear*d0Smear;
173 return std::sqrt(sigma_D0);
180 float sigma_Z0 = 0.f;
182 if ( isActive(TRK_RES_Z0_DEAD) ) {
184 float z0Smear = m_smearZ0Dead->GetBinContent(std::as_const(m_smearZ0Dead)->
FindBin(
pt))/
std::sin(
track.theta());
185 sigma_Z0 += z0Smear*z0Smear;
189 bool isActiveZ0Meas = isActive(TRK_RES_Z0_MEAS);
190 bool isActiveZ0MeasUp = isActive(TRK_RES_Z0_MEAS_UP);
191 bool isActiveZ0MeasDown = isActive(TRK_RES_Z0_MEAS_DOWN);
193 if (isActiveZ0Meas + isActiveZ0MeasUp + isActiveZ0MeasDown > 1) {
195 throw std::runtime_error(
"Multiple incompatible Z0 systematics are activated." );
196 }
else if (isActiveZ0Meas + isActiveZ0MeasUp + isActiveZ0MeasDown == 0) {
198 return std::sqrt(sigma_Z0);
201 TH2* z0hist_lowpt =
nullptr;
202 TH2* z0hist_highpt =
nullptr;
205 z0hist_lowpt = m_smearZ0_lowpt;
206 z0hist_highpt = m_smearZ0_highpt;
207 }
else if(isActiveZ0MeasUp) {
208 z0hist_lowpt = m_smearZ0_lowpt_sys_up;
209 z0hist_highpt = m_smearZ0_highpt_sys_up;
210 }
else if(isActiveZ0MeasDown) {
211 z0hist_lowpt = m_smearZ0_lowpt_sys_dw;
212 z0hist_highpt = m_smearZ0_highpt_sys_dw;
215 if (z0hist_lowpt ==
nullptr)
ATH_MSG_ERROR(
"z0 lowpt histogram is null!" );
216 if (z0hist_highpt ==
nullptr)
ATH_MSG_ERROR(
"z0 highpt histogram is null!" );
220 z0Smear = readHistogram(z0hist_lowpt,
pt,
eta);
222 z0Smear = readHistogram(z0hist_highpt,
pt,
eta);
231 sigma_Z0 += z0Smear*z0Smear;
233 return std::sqrt(sigma_Z0);
238 [[maybe_unused]]
static const bool firstTime = [&]() {
239 if ( ! firstCall().isSuccess() ) {
240 throw std::runtime_error(
"Error calling InDetTrackBiasingTool::firstCall");
245 float sigmaD0 = GetSmearD0Sigma(
track );
246 float sigmaZ0 = GetSmearZ0Sigma(
track );
252 if ( sigmaD0 > 0. ) accD0(
track ) = m_rnd->Gaus(
track.d0(), sigmaD0 );
253 if ( sigmaZ0 > 0. ) accZ0(
track ) = m_rnd->Gaus(
track.z0(), sigmaZ0 );
262 ATH_CHECK( initObject<TH1>(m_smearD0Dead, m_calibFileD0Dead,
"res_pt_d0_0") );
263 ATH_CHECK( initObject<TH1>(m_smearZ0Dead, m_calibFileZ0Dead,
"res_pt_z0_0") );
266 bool useData17Maps =
false;
271 ATH_MSG_INFO(
"runNumber corresponds to 2017/2018 - using the Data17 smearing maps where appropriate" );
272 useData17Maps =
true;
274 ATH_MSG_INFO(
"using the Data16 smearing maps where appropriate" );
277 std::string rootfileName_lowpt;
278 std::string rootfileName_highpt;
285 rootfileName_lowpt = m_calibFileIP_CTIDE;
286 rootfileName_highpt = m_calibFileIP_CTIDE;
288 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt, rootfileName_lowpt,
"d0quaddiff_Pt_Eta" ) );
289 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt, rootfileName_lowpt,
"z0quaddiff_Pt_Eta" ) );
290 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt_sys_up, rootfileName_lowpt,
"d0quaddiff_Pt_Eta_up" ) );
291 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt_sys_up, rootfileName_lowpt,
"z0quaddiff_Pt_Eta_up" ) );
292 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt_sys_dw, rootfileName_lowpt,
"d0quaddiff_Pt_Eta_down" ) );
293 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt_sys_dw, rootfileName_lowpt,
"z0quaddiff_Pt_Eta_down" ) );
294 ATH_CHECK( initObject<TH2>(m_smearD0_highpt, rootfileName_highpt,
"d0quaddiff_Pt_Eta" ) );
295 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt, rootfileName_highpt,
"z0quaddiff_Pt_Eta" ) );
296 ATH_CHECK( initObject<TH2>(m_smearD0_highpt_sys_up, rootfileName_highpt,
"d0quaddiff_Pt_Eta_up" ) );
297 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt_sys_up, rootfileName_highpt,
"z0quaddiff_Pt_Eta_up" ) );
298 ATH_CHECK( initObject<TH2>(m_smearD0_highpt_sys_dw, rootfileName_highpt,
"d0quaddiff_Pt_Eta_down" ) );
299 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt_sys_dw, rootfileName_highpt,
"z0quaddiff_Pt_Eta_down" ) );
306 rootfileName_lowpt = m_calibFileIP_lowpt;
307 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt, rootfileName_lowpt,
"d0quaddiff_comb_Pt_Eta" ) );
308 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt, rootfileName_lowpt,
"z0quaddiff_comb_Pt_Eta" ) );
309 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt_sys_up, rootfileName_lowpt,
"d0quaddiff_comb_Pt_Eta_sys_up" ) );
310 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt_sys_up, rootfileName_lowpt,
"z0quaddiff_comb_Pt_Eta_sys_up" ) );
311 ATH_CHECK( initObject<TH2>(m_smearD0_lowpt_sys_dw, rootfileName_lowpt,
"d0quaddiff_comb_Pt_Eta_sys_dw" ) );
312 ATH_CHECK( initObject<TH2>(m_smearZ0_lowpt_sys_dw, rootfileName_lowpt,
"z0quaddiff_comb_Pt_Eta_sys_dw" ) );
316 rootfileName_highpt = m_calibFileIP_highpt_Data17;
318 rootfileName_highpt = m_calibFileIP_highpt_Data16;
320 ATH_CHECK( initObject<TH2>(m_smearD0_highpt, rootfileName_highpt,
"quad_diff/d0quaddiff_comb_Pt_Eta" ) );
321 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt, rootfileName_highpt,
"quad_diff/z0quaddiff_comb_Pt_Eta" ) );
322 ATH_CHECK( initObject<TH2>(m_smearD0_highpt_sys_up, rootfileName_highpt,
"quad_diff/d0quaddiff_comb_Pt_Eta_sys_up" ) );
323 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt_sys_up, rootfileName_highpt,
"quad_diff/z0quaddiff_comb_Pt_Eta_sys_up" ) );
324 ATH_CHECK( initObject<TH2>(m_smearD0_highpt_sys_dw, rootfileName_highpt,
"quad_diff/d0quaddiff_comb_Pt_Eta_sys_dw" ) );
325 ATH_CHECK( initObject<TH2>(m_smearZ0_highpt_sys_dw, rootfileName_highpt,
"quad_diff/z0quaddiff_comb_Pt_Eta_sys_dw" ) );
329 return StatusCode::SUCCESS;
336 auto sc = evtStore()->retrieve( ei,
"EventInfo" );
337 if ( !
sc.isSuccess() ) {
338 if (m_runNumber <= 0) {
339 ATH_MSG_ERROR(
"Unable to retrieve from event store. Manually set run number." );
340 return StatusCode::FAILURE;
345 if (m_runNumber > 0) {
348 ") does not match that from the event store (" <<
runNumber <<
")." );
349 ATH_MSG_WARNING(
"Will use the manually set run number, but you must make sure this is the desired behaviour!" );
359 return TrackCorrTool_t::correctedCopy(in,
out);
364 return TrackCorrTool_t::applyContainerCorrection(cont);
369 return InDetTrackSystematicsTool::isAffectedBySystematic( syst );
374 return SmearingSystematics;
380 return RecommendedSystematics;
386 return InDetTrackSystematicsTool::applySystematicVariation(systs);
389 float InDetTrackSmearingTool::readHistogram(TH2*
histogram,
float pt,
float eta)
const {
391 if(
eta>2.499 )
eta= 2.499;
392 if(
eta<-2.499 )
eta=-2.499;
393 if ( pt < histogram->GetXaxis()->GetXmin() ) {