AsgClassificationDecorationAlg.cxx 1.57 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
/*
  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/

/// @author Tadej Novak <tadej@cern.ch>


#include <AsgAnalysisAlgorithms/AsgClassificationDecorationAlg.h>


namespace CP
{

AsgClassificationDecorationAlg::AsgClassificationDecorationAlg(const std::string &name,
                                               ISvcLocator *pSvcLocator)
    : AnaAlgorithm(name, pSvcLocator)
{
  declareProperty ("decoration", m_classificationDecoration, "the decoration for classification");
  declareProperty ("tool", m_tool, "classification tool");
}



StatusCode AsgClassificationDecorationAlg::initialize()
{
  if (m_classificationDecoration.empty())
  {
    ANA_MSG_ERROR ("Classification decoration name should not be empty.");
    return StatusCode::FAILURE;
  }

32
  m_classificationDecorator = std::make_unique<SG::AuxElement::Decorator<unsigned int> > (m_classificationDecoration);
33

34
  ANA_CHECK (m_particlesHandle.initialize (m_systematicsList));
35
36
37
38
39
40
41
42
43
44
45
  ANA_CHECK(m_systematicsList.initialize());

  ANA_CHECK(m_tool->initialize());

  return StatusCode::SUCCESS;
}



StatusCode AsgClassificationDecorationAlg::execute()
{
46
  for (const auto& sys : m_systematicsList.systematicsVector())
47
  {
48
49
    const xAOD::IParticleContainer *particles{};
    ANA_CHECK(m_particlesHandle.retrieve(particles, sys));
50

51
52
    for (const xAOD::IParticle *particle : *particles)
    {
53
54
      unsigned int classification{};
      ANA_CHECK(m_tool->classify(*particle, classification));
55
      (*m_classificationDecorator)(*particle) = classification;
56
    }
57
58
  }
  return StatusCode::SUCCESS;
59
60
61
}

} // namespace CP