46 const TString& jetType,
47 const TString& analysisRootFileName,
48 const TString& defaultAnalysisRootFileName,
50 const TString& calibArea,
51 const bool absEtaGluonFraction,
52 const TString& analysisHistPattern,
53 const TString& NjetAccessorName
65 ,
m_secondUncName(component.uncNames.size()>1 ? component.uncNames.at(1) :
"")
145 return StatusCode::FAILURE;
153 return StatusCode::FAILURE;
159 return StatusCode::FAILURE;
164 return StatusCode::FAILURE;
183 ATH_MSG_ERROR(
"Component is FlavourComposition, but histogram names are unexpected (need to discriminate gluon vs quark response histograms): " <<
m_uncHistName.Data() <<
" and " <<
m_secondUncName.Data());
184 return StatusCode::FAILURE;
196 return StatusCode::FAILURE;
198 if (
m_secondUncHist->initialize(histFile).isFailure())
return StatusCode::FAILURE;
205 if (!analysisFile || analysisFile->IsZombie())
208 return StatusCode::FAILURE;
214 std::vector<TString> gluonFractionKeys;
215 std::vector<TString> gluonFractionErrorKeys;
216 getGluonKeys(analysisFile,gluonFractionKeys,gluonFractionErrorKeys);
220 if (gluonFractionKeys.empty() || gluonFractionErrorKeys.empty())
222 ATH_MSG_ERROR(Form(
"Failed to find gluon fraction histogram(s), found %zu nominal and %zu error hists in file %s",gluonFractionKeys.size(),gluonFractionErrorKeys.size(),
m_analysisFileName.Data()));
223 return StatusCode::FAILURE;
228 for (
size_t iKey = 0; iKey < gluonFractionKeys.size(); ++iKey)
232 return StatusCode::FAILURE;
233 if (nJets > nJetsMax && nJets < 1000)
238 if (nJetsMax < 0 && gluonFractionKeys.size() == 1 && gluonFractionErrorKeys.size() == 1)
244 else if (nJetsMax < 0 && gluonFractionKeys.size() > 1)
246 ATH_MSG_ERROR(Form(
"Found %zu gluon fraction histograms, but they do not appear to be binned by nJets:",gluonFractionKeys.size()));
247 for (
size_t iKey = 0; iKey < gluonFractionKeys.size(); ++iKey)
248 ATH_MSG_ERROR(Form(
"\tKey %zu: %s",iKey,gluonFractionKeys.at(iKey).Data()));
249 return StatusCode::FAILURE;
254 for (
int nJets = 0; nJets <= nJetsMax; ++nJets)
260 return StatusCode::FAILURE;
262 return StatusCode::FAILURE;
270 ATH_MSG_ERROR(Form(
"nJets = %zu was specified for the gluon fraction, but not the error",iJet));
271 return StatusCode::FAILURE;
275 ATH_MSG_ERROR(Form(
"nJets = %zu was specified for the error, but not the gluon fraction",iJet));
276 return StatusCode::FAILURE;
285 return StatusCode::FAILURE;
287 return StatusCode::FAILURE;
291 analysisFile->Close();
300 if (!defAnaFile || defAnaFile->IsZombie())
303 return StatusCode::FAILURE;
309 std::vector<TString> gluonFractionDefaultKeys;
310 std::vector<TString> gluonFractionErrorDefaultKeys;
311 getGluonKeys(defAnaFile,gluonFractionDefaultKeys,gluonFractionErrorDefaultKeys);
314 if (gluonFractionDefaultKeys.size() != 1 || gluonFractionErrorDefaultKeys.size() != 1)
316 ATH_MSG_ERROR(Form(
"When using the default file to fill unspecified nJets histograms, exactly one gluon fraction and one gluon fraction uncertainty histogram are required. Instead, we found %zu and %zu respectively in the file %s",gluonFractionDefaultKeys.size(),gluonFractionErrorDefaultKeys.size(),
m_defAnaFileName.Data()));
317 return StatusCode::FAILURE;
326 return StatusCode::FAILURE;
328 return StatusCode::FAILURE;
336 return StatusCode::SUCCESS;
386 ATH_MSG_ERROR(
"UNKNOWN LargeRJetTruthLabel on the jet. Please use JetTruthLabeling before calling this function or check the jet for irregularities.");
390 bool relevantLabel =
false;
393 if (aLabel == largeRJetTruthLabel)
394 relevantLabel =
true;
442 ATH_MSG_ERROR(
"Specified Njets treatment, but did not decorate EventInfo object");
481 ATH_MSG_ERROR(
"Specified Njets treatment, but did not decorate EventInfo object");
499 const double Rsample = gluonFrac * Rg + (1-gluonFrac) * Rq;
511 const double flavorCompUnc = gluonFracError*fabs(Rq-Rg)/Rsample;
513 return flavorCompUnc;
594 for (
size_t iKey = 0; iKey < histKeys.size(); ++iKey)
596 const TString& histName = histKeys.at(iKey);
599 return StatusCode::FAILURE;
600 if (nJets < 0 || nJets >=
static_cast<int>(hists.size()))
602 ATH_MSG_ERROR(Form(
"Unexpected gluon fraction nJet %d of index %zu: %s",nJets,iKey,histName.Data()));
603 return StatusCode::FAILURE;
607 ATH_MSG_ERROR(Form(
"A histo for nJets of %d was already found, blocking double-creation of %s",nJets,histName.Data()));
608 return StatusCode::FAILURE;
612 return StatusCode::SUCCESS;
618 if (tokens.size() > 2 && tokens.at(tokens.size()-1).Contains(
"nJet",TString::kIgnoreCase))
620 TString nJetStr = tokens.at(tokens.size()-1).ReplaceAll(
"nJet",
"");
621 nJetStr = nJetStr.ReplaceAll(
"njet",
"");
622 nJetStr = nJetStr.ReplaceAll(
"Njet",
"");
625 ATH_MSG_ERROR(
"Found nJets histogram, but failed to parse the index: " << key.Data());
626 return StatusCode::FAILURE;
629 return StatusCode::SUCCESS;
649 ATH_MSG_ERROR(
"nJets of " << nJets <<
" is invalid, and default does not exist to fall back on, for " <<
getName().
Data());
650 return StatusCode::FAILURE;
658 return StatusCode::SUCCESS;
673 TList* keys = analysisFile->GetListOfKeys();
679 while (TKey* key =
dynamic_cast<TKey*
>(nextkey()))
681 const TString keyName = key->GetName();
684 if (keyName.Contains(
m_jetType) && !keyName.Contains(
"valid"))
686 if (keyName.Contains(
"gluonFractionError"))
687 gluonFractionErrorKeys.push_back(keyName);
688 else if (keyName.Contains(
"gluonFraction"))
689 gluonFractionKeys.push_back(keyName);
Scalar eta() const
pseudorapidity method
#define JESUNC_ERROR_CODE
#define JESUNC_NO_DEFAULT_CONSTRUCTOR
#define JESUNC_SAFE_DELETE(T)
StatusCode checkNjetsInput(int &nJets) const
FlavourRespType m_secondRespType
const TString m_analysisFileName
SG::AuxElement::Accessor< int > m_largeRJetTruthLabelAccessor
SG::AuxElement::Accessor< char > m_BjetAccessor
SG::AuxElement::Accessor< int > m_NjetAccessor
std::vector< UncertaintyHistogram * > m_gluonFractionErrorHists
const FlavourComp::TypeEnum m_flavourType
double getGluonFractionError(const double pT, const double eta, const int nJets) const
StatusCode getNjetFromKey(const TString &key, int &nJets) const
double getBJESUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
const TString m_defAnaFileName
virtual FlavourUncertaintyComponent * clone() const
virtual StatusCode initialize(TFile *histFile)
std::string m_largeRJetTruthLabelName
double getGluonFraction(const double pT, const double eta, const int nJets) const
double getGluonResponseBaseline(const double pT, const double eta) const
const TString m_secondUncName
FlavourRespType m_respType
std::vector< UncertaintyHistogram * > m_gluonFractionHists
const TString m_analysisHistPattern
const TString m_calibArea
virtual ~FlavourUncertaintyComponent()
UncertaintyHistogram * m_secondUncHist
std::vector< LargeRJetTruthLabel::TypeEnum > m_largeRJetTruthLabels
void getGluonKeys(TFile *analysisFile, std::vector< TString > &gluonFractionKeys, std::vector< TString > &gluonFractionErrorKeys) const
double getQuarkResponseBaseline(const double pT, const double eta) const
FlavourUncertaintyComponent(const ComponentHelper &component, const TString &jetType, const TString &analysisRootFileName, const TString &defaultAnalysisRootFileName, const TString &path, const TString &calibArea, const bool absEtaGluonFraction, const TString &analysisHistPattern="", const TString &NjetAccessorName="Njet")
StatusCode readNjetsHistograms(std::vector< UncertaintyHistogram * > &hists, const std::vector< TString > &histKeys)
double getFlavourResponseUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
double getGluonResponseDifference(const double pT, const double eta) const
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
bool isBjet(const xAOD::Jet &jet) const
const bool m_absEtaGluonFraction
double getFlavourCompositionUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
const Interpolate::TypeEnum m_interpolate
const float m_energyScale
UncertaintyComponent(const ComponentHelper &component, const size_t numHist=1)
virtual TString getName() const
virtual bool getValidBool(const double validity) const
const TString m_uncHistName
UncertaintyHistogram * m_validHist
virtual StatusCode initialize(TFile *histFile)
UncertaintyHistogram * m_uncHist
TypeEnum intToEnum(const int type)
bool getTypeObjFromString(const std::string &str, T &obj)
TFile * readRootFile(const TString &fileName, const TString &path="", const TString &calibArea="")
bool vectorize(const TString &str, const TString &sep, std::vector< T > &result)
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.