AnaAlgorithmConfig.cxx 2.26 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4
5
6
*/

/// @author Nils Krumnack

7
8
9
10
11
12


//
// includes
//

13
#include <AnaAlgorithm/AnaAlgorithmConfig.h>
14

15
#include <AnaAlgorithm/AnaAlgorithm.h>
16
#include <AnaAlgorithm/AlgorithmWorkerData.h>
Nils Krumnack's avatar
Nils Krumnack committed
17
#include <AnaAlgorithm/MessageCheck.h>
18
#include <AsgTools/AsgTool.h>
19
20
21
22
23
24
25
26
27
28
29
30
31
32

//
// method implementations
//

namespace EL
{
  AnaAlgorithmConfig :: 
  AnaAlgorithmConfig ()
  {
  }



33
34
  AnaAlgorithmConfig ::
  AnaAlgorithmConfig (const std::string& val_typeAndName)
Nils Krumnack's avatar
Nils Krumnack committed
35
    : AsgComponentConfig (val_typeAndName)
36
  {
37
38
39
40
  }



41
42
43
44
45
46
47
48
  AnaAlgorithmConfig ::
  AnaAlgorithmConfig (const AsgComponentConfig& val_config)
    : AsgComponentConfig (val_config)
  {
  }



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  bool AnaAlgorithmConfig ::
  useXAODs () const noexcept
  {
    return m_useXAODs;
  }



  void AnaAlgorithmConfig ::
  setUseXAODs (bool val_useXAODs) noexcept
  {
    m_useXAODs = val_useXAODs;
  }



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  bool AnaAlgorithmConfig ::
  isPublicTool () const noexcept
  {
    return m_isPublicTool;
  }



  void AnaAlgorithmConfig ::
  setIsPublicTool (bool val_isPublicTool) noexcept
  {
    m_isPublicTool = val_isPublicTool;
  }



81
  ::StatusCode AnaAlgorithmConfig ::
82
83
  makeAlgorithm (std::unique_ptr<AnaAlgorithm>& algorithm,
                 const AlgorithmWorkerData& workerData) const
84
85
86
  {
    using namespace msgAlgorithmConfig;

87
    if (m_isPublicTool == false)
88
    {
89
      ANA_CHECK (makeComponentExpert (algorithm, "new %1% (\"%2%\", nullptr)", true, ""));
90
91
92
93
      algorithm->setHistogramWorker (workerData.m_histogramWorker);
      algorithm->setTreeWorker (workerData.m_treeWorker);
      algorithm->setFilterWorker (workerData.m_filterWorker);
      algorithm->setWk (workerData.m_wk);
94
95
      if (workerData.m_evtStore)
        algorithm->setEvtStore (workerData.m_evtStore);
96
      ANA_CHECK (algorithm->sysInitialize());
97
98
    } else
    {
Nils Krumnack's avatar
Nils Krumnack committed
99
      std::unique_ptr<asg::AsgTool> tool;
100
      ANA_CHECK (makeComponentExpert (tool, "new %1% (\"%2%\")", true, ""));
101
      ANA_CHECK (tool->initialize());
102

Nils Krumnack's avatar
Nils Krumnack committed
103
      AnaAlgorithmConfig dummyAlg ("EL::AnaAlgorithm/DummyAlg." + name());
104
      ANA_CHECK (dummyAlg.makeAlgorithm (algorithm, workerData));
Nils Krumnack's avatar
Nils Krumnack committed
105
      algorithm->addCleanup (std::move (tool));
106
107
    }

Nils Krumnack's avatar
Nils Krumnack committed
108
    ANA_MSG_DEBUG ("Created component of type " << type());
109
110
111
    return StatusCode::SUCCESS;
  }
}