![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
113 ATH_MSG_ERROR(
"No config file provided OR you haven't manually specified all needed parameters" ) ;
115 return StatusCode::FAILURE;
126 ATH_MSG_ERROR(
"You need to specify where the calibarea is as either being Local or on CVMFS" );
127 return StatusCode::FAILURE;
130 std::string localCalibArea =
"BoostedJetTaggers/JSSWTopTaggerANN/";
131 ATH_MSG_INFO(
"Using Local calibarea " << localCalibArea );
151 if ( !input_cfg.is_open() ) {
153 ATH_MSG_ERROR(
"Are you sure that the file exists at this path?" );
154 return StatusCode::FAILURE;
159 for (
auto& input_node:
config.inputs ) {
161 for (
auto&
input: input_node.variables ) {
166 auto output_node_name =
config.outputs.begin()->first;
171 m_lwnn = std::make_unique< lwt::LightweightGraph >(
config, output_node_name);
175 m_lwnn = std::make_unique<lwt::LightweightGraph>(
config, output_node_name);
176 }
catch (lwt::NNConfigurationException& exc) {
178 return StatusCode::FAILURE;
186 else if ( !
m_tagType.compare(
"WBoson") ) {
190 else if ( !
m_tagType.compare(
"ZBoson") ) {
195 ATH_MSG_ERROR(
"I can't tell what kind of tagger your configuration is for." );
196 return StatusCode::FAILURE;
214 return StatusCode::SUCCESS;
244 return StatusCode::FAILURE;
251 if (
jets->size() == 0 ) {
252 ATH_MSG_WARNING(
"There are no jets in the container. Nothing to be done.");
286 decValidPtRangeHigh(*
jet) = acceptData.
getCutResult(
"ValidPtRangeHigh" );
287 decValidPtRangeLow(*
jet) = acceptData.
getCutResult(
"ValidPtRangeLow" );
295 float jet_pt =
jet->pt()/1000.;
296 float jet_mass =
jet->m()/1000.;
308 ATH_MSG_VERBOSE(
"Cut values : Mass window = [" << cut_mass_low <<
"," << cut_mass_high <<
"], score cut = " << cut_score );
309 ATH_MSG_VERBOSE(
"Jet values : Mass = " << jet_mass <<
", score = " << jet_score );
312 if ( !
m_calcSF )
return StatusCode::SUCCESS;
316 float sigeffSF = 1.0;
326 sigeffSF =
getSF(*
jet,
"t_qqb").first;
328 sigeffSF =
getSF(*
jet,
"V_qq").first;
343 if ( jet_score > cut_score ) {
362 decEffSF(*
jet) = effSF;
363 decSigeffSF(*
jet) = sigeffSF;
369 decCutMLow(*
jet) = cut_mass_low;
370 decCutMHigh(*
jet) = cut_mass_high;
371 decScoreCut(*
jet) = cut_score;
372 decScoreValue(*
jet) = jet_score;
375 bool passCuts =
true;
380 if ( jet_mass > cut_mass_low ) acceptData.
setCutResult(
"PassMassLow",
true );
381 if ( jet_mass < cut_mass_high ) acceptData.
setCutResult(
"PassMassHigh",
true );
382 if ( jet_score > cut_score ) acceptData.
setCutResult(
"PassScore",
true );
386 else if (
m_tagClass == TAGCLASS::TopQuark ) {
388 if( jet_mass > cut_mass_low ) acceptData.
setCutResult(
"PassMassLow",
true );
389 if( jet_score > cut_score ) acceptData.
setCutResult(
"PassScore",
true );
391 passCuts = passCuts && acceptData.
getCutResult(
"PassMassLow" );
396 passCuts = passCuts && acceptData.
getCutResult(
"PassScore" );
398 decTagged(*
jet) = passCuts;
403 return StatusCode::SUCCESS;
423 float jet_pt =
jet.pt()/1000.;
424 float jet_mass =
jet.m()/1000.;
435 ATH_MSG_VERBOSE(
"Cut values : Mass window = [" << cut_mass_low <<
"," << cut_mass_high <<
"], score cut = " << cut_score );
436 ATH_MSG_VERBOSE(
"Jet values : Mass = " << jet_mass <<
", score = " << jet_score );
455 decCutMLow(
jet) = cut_mass_low;
456 decCutMHigh(
jet) = cut_mass_high;
457 decScoreCut(
jet) = cut_score;
458 decScoreValue(
jet) = jet_score;
461 bool passCuts =
true;
466 if ( jet_mass > cut_mass_low ) acceptData.
setCutResult(
"PassMassLow",
true );
467 if ( jet_mass < cut_mass_high ) acceptData.
setCutResult(
"PassMassHigh",
true );
468 if ( jet_score > cut_score ) acceptData.
setCutResult(
"PassScore",
true );
472 else if (
m_tagClass == TAGCLASS::TopQuark ) {
474 if( jet_mass > cut_mass_low ) acceptData.
setCutResult(
"PassMassLow",
true );
475 if( jet_score > cut_score ) acceptData.
setCutResult(
"PassScore",
true );
477 passCuts = passCuts && acceptData.
getCutResult(
"PassMassLow" );
482 passCuts = passCuts && acceptData.
getCutResult(
"PassScore" );
484 decTagged(
jet) = passCuts;
486 return StatusCode::SUCCESS;
499 double ANNscore = -666.;
502 bool validVars =
true;
504 if ( readTau21WTA(
jet) < 0.0 ) validVars =
false;
507 if ( readTau32WTA(
jet) < 0.0 ) validVars =
false;
513 else ATH_MSG_WARNING(
"One (or more) tagger input variable has an out-of-range value, setting score to -666" );
527 std::map< std::string, std::map<std::string, double> > ANN_inputs;
528 std::map< std::string, double > ANN_inputValues;
543 ANN_inputValues[
"CaloTACombinedMassUncorrelated"] =
jet.m();
544 ANN_inputValues[
"JetpTCorrByCombinedMass"] =
jet.pt();
547 ANN_inputValues[
"Split12"] = readSplit12(
jet);
550 ANN_inputValues[
"C2"] = readC2(
jet);
551 ANN_inputValues[
"D2"] = readD2(
jet);
554 ANN_inputValues[
"Tau21_wta"] = readTau21WTA(
jet);
561 ANN_inputValues[
"FoxWolfram20"] =
jet.getAttribute<
float>(
"FoxWolfram2") /
jet.getAttribute<
float>(
"FoxWolfram0");
562 ANN_inputValues[
"PlanarFlow"] =
jet.getAttribute<
float>(
"PlanarFlow");
563 ANN_inputValues[
"Angularity"] =
jet.getAttribute<
float>(
"Angularity");
564 ANN_inputValues[
"Aplanarity"] =
jet.getAttribute<
float>(
"Aplanarity");
565 ANN_inputValues[
"ZCut12"] =
jet.getAttribute<
float>(
"ZCut12");
566 ANN_inputValues[
"KtDR"] =
jet.getAttribute<
float>(
"KtDR");
568 int pv_location =
findPV();
570 if(pv_location != -1){
575 ANN_inputValues[
"Ntrk500"] = readNtrk500(
jet);
578 ATH_MSG_ERROR(
"Either the ungroomed parent jet doesn't have 'NumTrkPt500' as an attribute or the parent link is broken");
579 ANN_inputValues[
"Ntrk500"] = -999;
584 ANN_inputValues[
"Ntrk500"] = -999;
588 else if (
m_tagClass == TAGCLASS::TopQuark ) {
602 ANN_inputValues[
"Split23"] = readSplit23(
jet);
605 ANN_inputValues[
"e3"] = readE3(
jet);
608 ANN_inputValues[
"Tau1_wta"] = readTau1WTA(
jet);
609 ANN_inputValues[
"Tau2_wta"] = readTau2WTA(
jet);
610 ANN_inputValues[
"Tau3_wta"] = readTau3WTA(
jet);
612 ANN_inputValues[
"Tau32_wta"] = readTau32WTA(
jet);
615 ANN_inputValues[
"Qw"] = readQw(
jet);
620 ATH_MSG_ERROR(
"Loading variables failed because the tagger type is not supported" );
623 ANN_inputs[
"node_0"] = ANN_inputValues;
JSSWTopTaggerANN(const std::string &name)
Constructor.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readSplit23Key
std::string getTruthLabelStr(const xAOD::Jet &jet, asg::AcceptData &acceptData) const
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decScoreCutKey
std::string m_strMassCutLow
Strings for cut functions.
std::unique_ptr< TF1 > m_funcScoreCut
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readTau32WTAKey
StatusCode resetCuts(asg::AcceptData &acceptData) const
Reset cuts.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readNtrk500Key
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainer_key
std::atomic< int > m_nWarnVar
Warning counters.
bool m_useMassCut
Flag to indicate if mass window cut is used.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decValidEtaRangeKey
std::string m_kerasCalibArea
std::string m_configFile
Configuration file name.
bool m_useScoreCut
Flag to indicate if a discriminant score is used.
TEnv m_configReader
TEnv instance to read config files.
const int m_nWarnMax
Maximum number of warnings.
std::string m_weightFileName
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decPassScoreKey
StatusCode getWeight(const xAOD::Jet &jet, bool passSel, asg::AcceptData &acceptData) const
Get SF weight.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readTau2WTAKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readSplit12Key
float m_jetPtMin
Kinematic bounds for the jet - the units are controlled by m_ptGeV.
std::unique_ptr< lwt::LightweightGraph > m_lwnn
ANN tools.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decCutMLowKey
WriteDecorHandle keys for cut values.
std::string m_decorationName
Decoration name.
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate jet collection with tagging info.
#define ATH_MSG_VERBOSE(x)
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readTau21WTAKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decValidPtRangeHighKey
std::unique_ptr< TF1 > m_funcMassCutHigh
std::string m_weightHistogramName
double getScore(const xAOD::Jet &jet) const
Retrieve score for a given ANN type (top/W)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decWeightKey
WriteDecorHandle keys for SF.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decSigeffSFKey
std::map< std::string, std::map< std::string, double > > getJetProperties(const xAOD::Jet &jet) const
Update the jet substructure variables for each jet to use in ANN.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::string m_truthLabelName
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decEfficiencyKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decCutMHighKey
bool m_ptGeV
Flag to indicate units pT is defined in Set to false by default.
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readQwKey
Handle class for reading a decoration on an object.
std::pair< double, double > getSF(const xAOD::Jet &jet, const std::string &truthLabelStr) const
Get scale factor and efficiency.
std::string m_kerasConfigOutputName
::StatusCode StatusCode
StatusCode definition for legacy code.
StatusCode checkKinRange(const xAOD::Jet &jet, asg::AcceptData &acceptData) const
Check and record if jet passes kinematic constraints.
Handle class for adding a decoration to an object.
std::string m_efficiencyHistogramName
std::string m_strScoreCut
int calculateJSSRatios(const xAOD::Jet &jet) const
Calculate JSS moment ratios in case they are not already saved TODO: Remove this once JSSMomentTools ...
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decEffSFKey
bool m_calcSF
Flag to calculate scale factor.
StatusCode GetUnGroomTracks(const xAOD::Jet &jet, int indexPV) const
Retrieve Ntrk variable from the ungroomed parent jet.
int findPV() const
Find the PV (to be used for Ntrk)
std::string m_kerasConfigFilePath
virtual StatusCode initialize() override
Initialize the tool.
asg::AcceptInfo m_acceptInfo
Object that stores the results for a jet.
virtual StatusCode initialize() override
Run once at the start of the job to setup everything.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decScoreValueKey
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void printCuts() const
Print configured cuts.
std::string m_weightDecorationName
String for scale factor decoration names.
std::vector< std::string > m_out_names
Internal stuff to keep track of the output node for the NN.
GraphConfig parse_json_graph(std::istream &json)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decValidKinRangeKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readTau1WTAKey
ReadDecorHandle keys for JSS moments.
std::map< std::string, std::unique_ptr< TH2D > > m_weightHistograms
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
bool passKinRange(const xAOD::Jet &jet) const
Check if jet passes kinematic constraints.
bool getCutResult(const std::string &cutName) const
Get the result of a cut, based on the cut name (safer)
#define ATH_MSG_WARNING(x)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decValidPtRangeLowKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readTau3WTAKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readD2Key
StatusCode getConfigReader()
Get configReader StatusCode.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decPassMassKey
virtual StatusCode tag(const xAOD::Jet &jet) const override
Decorate single jet with tagging info.
std::unique_ptr< TF1 > m_funcMassCutLow
TF1 for cut functions.
std::string m_strMassCutHigh
std::string m_kerasConfigFileName
Keras configurations for ML taggers.
std::string m_weightConfigPath
Path to the SF configuration root file.
std::string m_weightFlavors
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readE3Key
SG::ReadDecorHandleKey< xAOD::JetContainer > m_readC2Key
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decTaggedKey
WriteDecorHandle keys for tagging bools.
int addCut(const std::string &cutName, const std::string &cutDescription)
Add a cut; returning the cut position.