Program Listing for File MuonEfficiencyCorrector.h

Return to documentation for file (xAODAnaHelpers/MuonEfficiencyCorrector.h)

#ifndef xAODAnaHelpers_MuonEfficiencyCorrector_H
#define xAODAnaHelpers_MuonEfficiencyCorrector_H

// CP interface includes
#include "PATInterfaces/SystematicRegistry.h"
#include "PATInterfaces/SystematicSet.h"
#include "PATInterfaces/SystematicsUtil.h"
#include "PATInterfaces/SystematicVariation.h"
#include "PATInterfaces/ISystematicsTool.h"
#include "MuonAnalysisInterfaces/IMuonEfficiencyScaleFactors.h"
#include "MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h"

// external tools include(s):
#include "AsgTools/AnaToolHandle.h"
#include "PileupReweighting/PileupReweightingTool.h"

// algorithm wrapper
#include "xAODAnaHelpers/Algorithm.h"

namespace CP {
  class MuonEfficiencyScaleFactors;
  class MuonTriggerScaleFactors;
}

class MuonEfficiencyCorrector : public xAH::Algorithm
{
  // put your configuration variables here as public variables.
  // that way they can be set directly from CINT and python.

public:

  // configuration variables
  std::string   m_inContainerName = "";

  std::string   m_overrideCalibRelease = "";

  // Reco efficiency SF
  std::string   m_WorkingPointReco = "Loose";

  // Iso efficiency SF
  std::string   m_WorkingPointIso = "LooseTrackOnly";

  bool          m_AllowZeroSF = false;

  std::string   m_MuTrigLegs = "HLT_mu26_imedium";
  bool          m_usePerMuonTriggerSFs = true;

  // TTVA efficiency SF
  std::string   m_WorkingPointTTVA = "TTVA";

  // systematics
  std::string   m_inputSystNamesMuons = "";

  bool          m_writeSystToMetadata = false;

  float         m_systValReco = 0.0;
  float         m_systValIso = 0.0;
  float         m_systValTrig = 0.0;
  float         m_systValTTVA = 0.0;
  std::string   m_systNameReco = "";
  std::string   m_systNameIso = "";
  std::string   m_systNameTrig = "";
  std::string   m_systNameTTVA = "";
  std::string   m_outputSystNamesReco = "MuonEfficiencyCorrector_RecoSyst";
  std::string   m_outputSystNamesIso = "MuonEfficiencyCorrector_IsoSyst";
  std::string   m_outputSystNamesTrig = "MuonEfficiencyCorrector_TrigSyst";
  std::string   m_outputSystNamesTTVA = "MuonEfficiencyCorrector_TTVASyst";

  bool          m_doLRT = false;

private:
  int m_numEvent;
  int m_numObject;

  // To include the nominal in the Recp/Iso/Trig/TTVA efficiency SFs output, use "All", or include "Nominal" in the list
  std::vector<CP::SystematicSet> m_systListReco;
  std::vector<CP::SystematicSet> m_systListIso;
  std::vector<CP::SystematicSet> m_systListTrig;
  std::vector<CP::SystematicSet> m_systListTTVA;

  std::string m_outputSystNamesTrigBase;

  // tools
  asg::AnaToolHandle<CP::IPileupReweightingTool> m_pileup_tool_handle{"CP::PileupReweightingTool/Pileup"};
  asg::AnaToolHandle<CP::IMuonEfficiencyScaleFactors> m_muRecoSF_tool;
  std::string m_recoEffSF_tool_name;
  asg::AnaToolHandle<CP::IMuonEfficiencyScaleFactors> m_muIsoSF_tool;
  std::string m_isoEffSF_tool_name;
  asg::AnaToolHandle<CP::IMuonTriggerScaleFactors> m_muTrigSF_tool;
  std::string m_trigEffSF_tool_name;
  asg::AnaToolHandle<CP::IMuonEfficiencyScaleFactors> m_muTTVASF_tool;
  std::string m_TTVAEffSF_tool_name;
  std::map<std::string, std::string> m_SingleMuTriggerMap;

  // variables that don't get filled at submission time should be
  // protected from being send from the submission node to the worker
  // node (done by the //!)

public:

  // Tree *myTree; //!
  // TH1 *myHist;  //!

  // this is a standard constructor
  MuonEfficiencyCorrector ();

  // these are the functions inherited from Algorithm
  virtual EL::StatusCode setupJob (EL::Job& job);
  virtual EL::StatusCode fileExecute ();
  virtual EL::StatusCode histInitialize ();
  virtual EL::StatusCode changeInput (bool firstFile);
  virtual EL::StatusCode initialize ();
  virtual EL::StatusCode execute ();
  virtual EL::StatusCode postExecute ();
  virtual EL::StatusCode finalize ();
  virtual EL::StatusCode histFinalize ();

  // these are the functions not inherited from Algorithm
  virtual EL::StatusCode executeSF ( const xAOD::EventInfo* eventInfo, const xAOD::MuonContainer* inputMuons, bool nominal, bool writeSystNames );

  // this is needed to distribute the algorithm to the workers
  ClassDef(MuonEfficiencyCorrector, 1);

};

#endif