DiTauEfficiencyCorrectionsAlg.cxx 2.06 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/

/// @author Nils Krumnack



//
// includes
//

#include <TauAnalysisAlgorithms/DiTauEfficiencyCorrectionsAlg.h>

//
// method implementations
//

namespace CP
{
  DiTauEfficiencyCorrectionsAlg ::
  DiTauEfficiencyCorrectionsAlg (const std::string& name, 
                     ISvcLocator* pSvcLocator)
    : AnaAlgorithm (name, pSvcLocator)
    , m_efficiencyCorrectionsTool ("TauAnalysisTools::DiTauEfficiencyCorrectionsTool", this)
  {
    declareProperty ("efficiencyCorrectionsTool", m_efficiencyCorrectionsTool, "the calibration and smearing tool we apply");
  }



  StatusCode DiTauEfficiencyCorrectionsAlg ::
  initialize ()
  {
    if (m_scaleFactorDecoration.empty())
    {
      ANA_MSG_ERROR ("no scale factor decoration name set");
      return StatusCode::FAILURE;
    }

    ANA_CHECK (m_efficiencyCorrectionsTool.retrieve());
42
    ANA_CHECK (m_tauHandle.initialize (m_systematicsList));
43
    ANA_CHECK (m_scaleFactorDecoration.initialize (m_systematicsList, m_tauHandle));
44
    ANA_CHECK (m_systematicsList.addSystematics (*m_efficiencyCorrectionsTool));
45
46
47
48
49
50
51
52
53
54
55
    ANA_CHECK (m_systematicsList.initialize());
    ANA_CHECK (m_preselection.initialize());
    ANA_CHECK (m_outOfValidity.initialize());
    return StatusCode::SUCCESS;
  }



  StatusCode DiTauEfficiencyCorrectionsAlg ::
  execute ()
  {
56
57
58
    for (const auto& sys : m_systematicsList.systematicsVector())
    {
      ANA_CHECK (m_efficiencyCorrectionsTool->applySystematicVariation (sys));
59
60
61
      const xAOD::DiTauJetContainer *taus = nullptr;
      ANA_CHECK (m_tauHandle.retrieve (taus, sys));
      for (const xAOD::DiTauJet *tau : *taus)
62
63
      {
        if (m_preselection.getBool (*tau))
64
        {
65
66
          double sf = 0;
          ANA_CHECK_CORRECTION (m_outOfValidity, *tau, m_efficiencyCorrectionsTool->getEfficiencyScaleFactor (*tau, sf));
67
68
69
          m_scaleFactorDecoration.set (*tau, sf, sys);
        } else {
          m_scaleFactorDecoration.set (*tau, invalidScaleFactor(), sys);
70
        }
71
72
73
      }
    }
    return StatusCode::SUCCESS;
74
75
  }
}