55 ATH_MSG_DEBUG(
"Initializing the Global Sequential Calibration tool");
59 return StatusCode::FAILURE;
93 if (
m_jetAlgo.EqualTo(
"") ) {
ATH_MSG_FATAL(
"No jet algorithm specified. Aborting.");
return StatusCode::FAILURE; }
96 TString GSCFile =
m_config->GetValue(
"GSCFactorsFile",
"empty");
97 if ( GSCFile.EqualTo(
"empty") ) {
99 return StatusCode::FAILURE;
102 GSCFile.Remove(0,33);
103 GSCFile.Insert(0,
"JetCalibTools/");
107 std::unique_ptr<TFile> inputFile(TFile::Open(fileName));
110 return StatusCode::FAILURE;
113 TString depthString =
"";
115 else depthString =
m_config->GetValue(
"GSCDepth",
"Full");
116 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") ) {
117 ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
118 return StatusCode::FAILURE;
123 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");
124 return StatusCode::FAILURE;
128 if (
m_caloBased && (depthString.Contains(
"nTrk")||depthString.Contains(
"trackWIDTH")||depthString.Contains(
"ChargedFraction")||depthString.Contains(
"PunchThrough"))){
129 ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file. nTrk, trackWIDTH, PunchThrough and ChargedFraction corrections not available for trigger jets");
130 return StatusCode::FAILURE;
136 if ( depthString.Contains(
"PunchThrough") || depthString.Contains(
"Full") ) {
148 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
156 else {
ATH_MSG_FATAL(
"depthString flag for calo based GSC not properly set, please check your config file.");
return StatusCode::FAILURE; }
164 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
172 else {
ATH_MSG_FATAL(
"depthString flag not properly set, please check your config file.");
return StatusCode::FAILURE; }
178 TList *keys = inputFile->GetListOfKeys();
179 std::vector<TString> histoNames;
182 while ( TKey *iterobj = (TKey*)ikeys() ) { histoNames.emplace_back(iterobj->GetName() ); }
185 for (
uint ihisto=0; ihisto<histoNames.size(); ++ihisto) {
186 if ( !histoNames[ihisto].Contains(
m_jetAlgo.Data() ) )
continue;
187 else if ( ihisto>0 && histoNames[ihisto].Contains( histoNames[ihisto-1].
Data() ) )
continue;
198 else if ( histoNames[ihisto].Contains(
"PunchThrough") )
211 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
212 return StatusCode::FAILURE;
215 ATH_MSG_FATAL(
"Vector of nTrk histograms may be empty. Please check your GSCFactors file: " << GSCFile);
216 return StatusCode::FAILURE;
219 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
220 return StatusCode::FAILURE;
223 ATH_MSG_FATAL(
"Vector of trackWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
224 return StatusCode::FAILURE;
227 ATH_MSG_FATAL(
"Vector of PunchThrough histograms may be empty. Please check your GSCFactors file: " << GSCFile);
228 return StatusCode::FAILURE;
230 else ATH_MSG_DEBUG(
"GSC Tool has been initialized with binning and eta fit factors from: " << fileName);
234 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
235 return StatusCode::FAILURE;
238 ATH_MSG_FATAL(
"Vector of N90Constituents histograms may be empty. Please check your GSCFactors file: " << GSCFile);
239 return StatusCode::FAILURE;
242 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
243 return StatusCode::FAILURE;
246 ATH_MSG_FATAL(
"Vector of caloWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
247 return StatusCode::FAILURE;
250 ATH_MSG_FATAL(
"Vector of TileGap3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
251 return StatusCode::FAILURE;
254 else ATH_MSG_DEBUG(
"GSC Tool has been initialized with binning and eta fit factors from: " << fileName <<
"\n");
258 ATH_MSG_FATAL(
"Vector of ChargedFraction histograms may be empty. Please check your GSCFactors file: " << GSCFile);
259 return StatusCode::FAILURE;
262 ATH_MSG_FATAL(
"Vector of EM3 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
263 return StatusCode::FAILURE;
266 ATH_MSG_FATAL(
"Vector of Tile0 histograms may be empty. Please check your GSCFactors file: " << GSCFile);
267 return StatusCode::FAILURE;
270 ATH_MSG_FATAL(
"Vector of nTrk histograms may be empty. Please check your GSCFactors file: " << GSCFile);
271 return StatusCode::FAILURE;
274 ATH_MSG_FATAL(
"Vector of trackWIDTH histograms may be empty. Please check your GSCFactors file: " << GSCFile);
275 return StatusCode::FAILURE;
278 ATH_MSG_FATAL(
"Vector of PunchThrough histograms may be empty. Please check your GSCFactors file: " << GSCFile);
279 return StatusCode::FAILURE;
281 else ATH_MSG_DEBUG(
"GSC Tool has been initialized with binning and eta fit factors from: " << fileName);
283 return StatusCode::SUCCESS;
288 int pTbin = respFactors.GetXaxis()->FindBin(pT);
289 int pTMinbin = respFactors.GetXaxis()->GetFirst();
290 int pTMaxbin = respFactors.GetXaxis()->GetLast();
291 int jetPropbin = respFactors.GetYaxis()->FindBin(jetProperty);
292 int jetPropMinbin = respFactors.GetYaxis()->GetFirst();
293 int jetPropMaxbin = respFactors.GetYaxis()->GetLast();
295 if (pTbin < pTMinbin) pT = respFactors.GetXaxis()->GetBinLowEdge(pTMinbin)+1e-6;
296 else if (pTbin > pTMaxbin) pT = respFactors.GetXaxis()->GetBinUpEdge(pTMaxbin)-1e-6;
297 if (jetPropbin < jetPropMinbin) jetProperty = respFactors.GetYaxis()->GetBinLowEdge(jetPropMinbin)+1e-6;
298 else if (jetPropbin > jetPropMaxbin) jetProperty = respFactors.GetYaxis()->GetBinUpEdge(jetPropMaxbin)-1e-6;
300 return respFactors.Interpolate(pT, jetProperty);
304 if (trackWIDTH<=0)
return 1;
307 double trackWIDTHResponse;
312 trackWIDTHResponse *= pT;
314 return trackWIDTHResponse;
319 return trackWIDTHResponse;
323 if (nTrk<=0)
return 1;
341 if (Tile0<0)
return 1;
344 return Tile0Response;
348 if (EM3<=0)
return 1;
355 if (ChargedFraction<=0)
return 1;
358 return ChargedFractionResponse;
365 ATH_MSG_WARNING(
"Please check that the punch through eta binning is properly set in your config file");
371 ATH_MSG_WARNING(
"There was a problem determining the eta bin to use for the punch through correction.");
377 return PunchThroughResponse;
381 if (caloWIDTH<=0)
return 1;
384 return caloWIDTHResponse;
388 if (N90Constituents<=0)
return 1;
391 return N90ConstituentsResponse;
395 if (TileGap3<0)
return 1;
398 return TileGap3Response;
402 double trackWIDTH,
double nTrk,
double Tile0,
double EM3,
int Nsegments,
double ChargedFraction,
double caloWIDTH,
double N90Constituents,
double TileGap3)
const {
488 std::vector<float> samplingFrac =
jet.getAttribute<std::vector<float> >(
"EnergyPerSampling");
490 std::vector<int> nTrk;
492 if( !
jet.getAttribute<std::vector<int> >(
"NumTrkPt1000",nTrk) ) {
494 return StatusCode::FAILURE;
498 std::vector<float> trackWIDTH;
500 if( !
jet.getAttribute<std::vector<float> >(
"TrackWidthPt1000",trackWIDTH) ) {
502 return StatusCode::FAILURE;
520 int PVindex = jetEventInfo.
PVIndex();
527 double ChargedFraction = 0;
528 if(
m_PFlow ) ChargedFraction = (
jet.getAttribute<std::vector<float> >(
"SumPtChargedPFOPt500"))[PVindex]/jetconstitP4.Pt();
532 jetStartP4 =
jet.jetP4();
534 float jetE_constitscale = jetconstitP4.e();
535 float detectorEta =
jet.getAttribute<
float>(
"DetectorEta");
542 float EM3 = (samplingFrac[3]+samplingFrac[7])/jetE_constitscale;
543 float Tile0 = (samplingFrac[12]+samplingFrac[18])/jetE_constitscale;
545 double N90Constituents = 0;
546 double caloWIDTH = 0;
551 N90Constituents =
jet.getAttribute<
float>(
"N90Constituents");
554 caloWIDTH =
jet.getAttribute<
double>(
"Width");
558 TG3 = (samplingFrac[17])/jetE_constitscale;
562 xAOD::JetFourMom_t calibP4 = jetStartP4*
getGSCCorrection( jetStartP4, fabs(detectorEta), trackWIDTHPVX, nTrkPVX, Tile0, EM3, Nsegments, ChargedFraction, caloWIDTH, N90Constituents, TG3);
566 jet.setJetP4( calibP4 );
568 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_FATAL(x,...)
Helper class to provide constant type-safe access to aux data.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
GlobalSequentialCorrection()
bool m_turnOffTrackCorrections
int m_punchThroughMinNseg
VecTH2 m_respFactorsPunchThrough
double getChargedFractionResponse(double pT, uint etabin, double ChargedFraction) const
VecTH2 m_respFactorsTileGap3
void setPunchThroughEtaBins(const VecD &etabins)
double getEM3Response(double pT, uint etabin, double EM3) const
uint m_caloWIDTHMaxEtaBin
double getGSCCorrection(xAOD::JetFourMom_t jetP4, double eta, double trackWIDTH, double nTrk, double Tile0, double EM3, int Nsegments, double ChargedFraction, double caloWIDTH, double N90Constituents, double TileGap3) const
double m_punchThroughMinPt
void setPunchThroughMinPt(double minPt)
double getN90ConstituentsResponse(double pT, uint etabin, double N90Constituents) const
VecTH2 m_respFactorsChargedFraction
uint m_N90ConstituentsMaxEtaBin
VecTH2 m_respFactorstrackWIDTH
VecD m_punchThroughEtaBins
double getCaloWIDTHResponse(double pT, uint etabin, double caloWIDTH) const
virtual StatusCode initialize() override
double readPtJetPropertyHisto(double pT, double jetProperty, const TH2 &respFactors) const
uint m_trackWIDTHMaxEtaBin
virtual StatusCode calibrate(xAOD::Jet &jet, JetEventInfo &) const override
double getTrackWIDTHResponse(double pT, uint etabin, double trackWIDTH) const
VecTH2 m_respFactorscaloWIDTH
double getTileGap3Response(double pT, uint etabin, double TileGap3) const
double getPunchThroughResponse(double E, double eta_det, int Nsegments) const
bool m_pTResponseRequirementOff
uint m_chargedFractionMaxEtaBin
double getNTrkResponse(double pT, uint etabin, double nTrk) const
double m_turnOffStartingpT
VecTH2 m_respFactorsTile0
SG::ConstAccessor< int > m_ghostMuSegCountAcc
VecTH2 m_respFactorsN90Constituents
std::string m_ghostMuSegCountName
double getTile0Response(double pT, uint etabin, double Tile0) const
std::string m_jetStartScale
virtual StatusCode setStartP4(xAOD::Jet &jet) const
JetCalibrationStep(const char *name="JetCalibrationStep")
Helper class to provide constant type-safe access to aux data.
std::string depth
tag string for intendation
std::unique_ptr< const TH2 > GetHisto2(TFile &file, const TString &hname)
VecD VectorizeD(const TString &str, const TString &sep=" ")
Jet_v1 Jet
Definition of the current "jet version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.