36 m_config(nullptr), m_jetAlgo(
""), m_depthString(
"auto"), m_calibAreaTag(
""), m_dev(false),
37 m_binSize(0.1), m_depth(0),
38 m_trackWIDTHMaxEtaBin(25), m_nTrkMaxEtaBin(25), m_Tile0MaxEtaBin(17), m_EM3MaxEtaBin(35), m_chargedFractionMaxEtaBin(27), m_caloWIDTHMaxEtaBin(35), m_N90ConstituentsMaxEtaBin(35),
39 m_TileGap3MaxEtaBin(16), m_punchThroughMinPt(50), m_useOriginVertex(false)
45 m_config(
config), m_jetAlgo(std::move(jetAlgo)), m_depthString(
depth), m_calibAreaTag(std::move(calibAreaTag)), m_dev(dev),
46 m_binSize(0.1), m_depth(0),
47 m_trackWIDTHMaxEtaBin(25), m_nTrkMaxEtaBin(25), m_Tile0MaxEtaBin(17), m_EM3MaxEtaBin(35), m_chargedFractionMaxEtaBin(27), m_caloWIDTHMaxEtaBin(35), m_N90ConstituentsMaxEtaBin(35),
48 m_TileGap3MaxEtaBin(16), m_punchThroughMinPt(50), m_useOriginVertex(useOriginVertex)
55 ATH_MSG_INFO(
"Initializing the Global Sequential Calibration tool");
59 return StatusCode::FAILURE;
87 if (
m_jetAlgo.EqualTo(
"") ) {
ATH_MSG_FATAL(
"No jet algorithm specified. Aborting.");
return StatusCode::FAILURE; }
90 TString GSCFile =
m_config->GetValue(
"GSCFactorsFile",
"empty");
91 if ( GSCFile.EqualTo(
"empty") ) {
93 return StatusCode::FAILURE;
97 GSCFile.Insert(0,
"JetCalibTools/");
104 return StatusCode::FAILURE;
107 TString depthString =
"";
109 else depthString =
m_config->GetValue(
"GSCDepth",
"Full");
110 if ( !depthString.Contains(
"ChargedFraction") && !depthString.Contains(
"Tile0") && !depthString.Contains(
"EM3") && !depthString.Contains(
"nTrk") && !depthString.Contains(
"trackWIDTH") && !depthString.Contains(
"PunchThrough") && !depthString.Contains(
"N90Constituents") && !depthString.Contains(
"TileGap3") && !depthString.Contains(
"caloWIDTH") && !depthString.Contains(
"Full") ) {
111 ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
112 return StatusCode::FAILURE;
117 ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file. nTrkwTrk4PFlow should be set to true to apply nTrk or trackWIDTH corrections to PFlow jets");
118 return StatusCode::FAILURE;
122 if (
m_caloBased && (depthString.Contains(
"nTrk")||depthString.Contains(
"trackWIDTH")||depthString.Contains(
"ChargedFraction")||depthString.Contains(
"PunchThrough"))){
123 ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file. nTrk, trackWIDTH, PunchThrough and ChargedFraction corrections not available for trigger jets");
124 return StatusCode::FAILURE;
130 if ( depthString.Contains(
"PunchThrough") || depthString.Contains(
"Full") ) {
142 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
150 else {
ATH_MSG_FATAL(
"depthString flag for calo based GSC not properly set, please check your config file.");
return StatusCode::FAILURE; }
158 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
166 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
173 std::vector<TString> histoNames;
176 while ( TKey *iterobj = (TKey*)ikeys() ) { histoNames.emplace_back(iterobj->GetName() ); }
179 for (
uint ihisto=0; ihisto<histoNames.size(); ++ihisto) {
180 if ( !histoNames[ihisto].Contains(
m_jetAlgo.Data() ) )
continue;
181 else if ( ihisto>0 && histoNames[ihisto].Contains( histoNames[ihisto-1].
Data() ) )
continue;
192 else if ( histoNames[ihisto].Contains(
"PunchThrough") )
205 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
206 return StatusCode::FAILURE;
209 ATH_MSG_FATAL(
"Vector of nTrk histograms may be empty. Please check your GSCFactors file: " << GSCFile);
210 return StatusCode::FAILURE;
213 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
214 return StatusCode::FAILURE;
217 ATH_MSG_FATAL(
"Vector of trackWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
218 return StatusCode::FAILURE;
221 ATH_MSG_FATAL(
"Vector of PunchThrough histograms may be empty. Please check your GSCFactors file: " << GSCFile);
222 return StatusCode::FAILURE;
224 else ATH_MSG_INFO(
"GSC Tool has been initialized with binning and eta fit factors from: " <<
fileName);
228 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
229 return StatusCode::FAILURE;
232 ATH_MSG_FATAL(
"Vector of N90Constituents histograms may be empty. Please check your GSCFactors file: " << GSCFile);
233 return StatusCode::FAILURE;
236 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
237 return StatusCode::FAILURE;
240 ATH_MSG_FATAL(
"Vector of caloWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
241 return StatusCode::FAILURE;
244 ATH_MSG_FATAL(
"Vector of TileGap3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
245 return StatusCode::FAILURE;
248 else ATH_MSG_INFO(
"GSC Tool has been initialized with binning and eta fit factors from: " <<
fileName <<
"\n");
252 ATH_MSG_FATAL(
"Vector of ChargedFraction histograms may be empty. Please check your GSCFactors file: " << GSCFile);
253 return StatusCode::FAILURE;
256 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
257 return StatusCode::FAILURE;
260 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
261 return StatusCode::FAILURE;
264 ATH_MSG_FATAL(
"Vector of nTrk histograms may be empty. Please check your GSCFactors file: " << GSCFile);
265 return StatusCode::FAILURE;
268 ATH_MSG_FATAL(
"Vector of trackWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
269 return StatusCode::FAILURE;
272 ATH_MSG_FATAL(
"Vector of PunchThrough histograms may be empty. Please check your GSCFactors file: " << GSCFile);
273 return StatusCode::FAILURE;
275 else ATH_MSG_INFO(
"GSC Tool has been initialized with binning and eta fit factors from: " <<
fileName);
277 return StatusCode::SUCCESS;
282 int pTbin = respFactors.GetXaxis()->FindBin(
pT);
283 int pTMinbin = respFactors.GetXaxis()->GetFirst();
284 int pTMaxbin = respFactors.GetXaxis()->GetLast();
285 int jetPropbin = respFactors.GetYaxis()->FindBin(jetProperty);
286 int jetPropMinbin = respFactors.GetYaxis()->GetFirst();
287 int jetPropMaxbin = respFactors.GetYaxis()->GetLast();
289 if (pTbin < pTMinbin)
pT = respFactors.GetXaxis()->GetBinLowEdge(pTMinbin)+1
e-6;
290 else if (pTbin > pTMaxbin)
pT = respFactors.GetXaxis()->GetBinUpEdge(pTMaxbin)-1
e-6;
291 if (jetPropbin < jetPropMinbin) jetProperty = respFactors.GetYaxis()->GetBinLowEdge(jetPropMinbin)+1
e-6;
292 else if (jetPropbin > jetPropMaxbin) jetProperty = respFactors.GetYaxis()->GetBinUpEdge(jetPropMaxbin)-1
e-6;
294 return respFactors.Interpolate(
pT, jetProperty);
298 if (trackWIDTH<=0)
return 1;
301 double trackWIDTHResponse;
306 trackWIDTHResponse *=
pT;
308 return trackWIDTHResponse;
313 return trackWIDTHResponse;
317 if (nTrk<=0)
return 1;
335 if (Tile0<0)
return 1;
338 return Tile0Response;
342 if (
EM3<=0)
return 1;
349 if (ChargedFraction<=0)
return 1;
352 return ChargedFractionResponse;
359 ATH_MSG_WARNING(
"Please check that the punch through eta binning is properly set in your config file");
365 ATH_MSG_WARNING(
"There was a problem determining the eta bin to use for the punch through correction.");
371 return PunchThroughResponse;
375 if (caloWIDTH<=0)
return 1;
378 return caloWIDTHResponse;
382 if (N90Constituents<=0)
return 1;
385 return N90ConstituentsResponse;
392 return TileGap3Response;
396 double trackWIDTH,
double nTrk,
double Tile0,
double EM3,
int Nsegments,
double ChargedFraction,
double caloWIDTH,
double N90Constituents,
double TileGap3)
const {
482 std::vector<float> samplingFrac =
jet.getAttribute<std::vector<float> >(
"EnergyPerSampling");
484 std::vector<int> nTrk;
486 if( !
jet.getAttribute<std::vector<int> >(
"NumTrkPt1000",nTrk) ) {
488 return StatusCode::FAILURE;
492 std::vector<float> trackWIDTH;
494 if( !
jet.getAttribute<std::vector<float> >(
"TrackWidthPt1000",trackWIDTH) ) {
496 return StatusCode::FAILURE;
504 Nsegments = GhostMuonSegmentCountAcc(
jet);
506 ATH_MSG_WARNING(
"GhostMuonSegmentCount is not available, Nsegments=0 will be used, so NO PunchThrough Correction will be applied!");
515 int PVindex = jetEventInfo.
PVIndex();
522 double ChargedFraction = 0;
523 if(
m_PFlow ) ChargedFraction = (
jet.getAttribute<std::vector<float> >(
"SumPtChargedPFOPt500"))[PVindex]/jetconstitP4.Pt();
527 jetStartP4 =
jet.jetP4();
529 float jetE_constitscale = jetconstitP4.e();
530 float detectorEta =
jet.getAttribute<
float>(
"DetectorEta");
537 float EM3 = (samplingFrac[3]+samplingFrac[7])/jetE_constitscale;
538 float Tile0 = (samplingFrac[12]+samplingFrac[18])/jetE_constitscale;
540 double N90Constituents = 0;
541 double caloWIDTH = 0;
546 N90Constituents =
jet.getAttribute<
float>(
"N90Constituents");
549 caloWIDTH =
jet.getAttribute<
double>(
"Width");
553 TG3 = (samplingFrac[17])/jetE_constitscale;
557 xAOD::JetFourMom_t calibP4 = jetStartP4*
getGSCCorrection( jetStartP4, fabs(detectorEta), trackWIDTHPVX, nTrkPVX, Tile0,
EM3, Nsegments, ChargedFraction, caloWIDTH, N90Constituents, TG3);
561 jet.setJetP4( calibP4 );
563 return StatusCode::SUCCESS;