ATLAS Offline Software
CutFlowSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Header file for class CutFlowSvc
6 // Authors:
7 // Tadej Novak <tadej@cern.ch>
8 // Joao Firmino da Costa <joao.costa@cern.ch> and David Cote <david.cote@cern.ch>
9 
11 #ifndef EVENT_BOOKKEEPER_TOOLS__CUT_FLOW_SVC_H
12 #define EVENT_BOOKKEEPER_TOOLS__CUT_FLOW_SVC_H
13 
14 // Not dual use at the moment
15 #ifndef XAOD_STANDALONE
16 
22 // STL includes
23 #include <mutex>
24 #include <string>
25 #include <unordered_map>
26 
27 // FrameWork includes
28 #include <GaudiKernel/ISvcLocator.h>
29 #include <GaudiKernel/IIncidentListener.h>
30 #include <GaudiKernel/ServiceHandle.h>
31 
32 // Athena includes
36 #include <StoreGate/StoreGateSvc.h>
37 
38 // EDM includes
41 
42 
43 class CutFlowSvc :
44  virtual public ICutFlowSvc,
45  virtual public IIncidentListener,
46  public AthService
47 {
48 
49 public:
51  CutFlowSvc(const std::string& name, ISvcLocator* pSvcLocator );
52 
54 
55  virtual StatusCode initialize() override final;
56  virtual StatusCode queryInterface(const InterfaceID& riid,
57  void** ppvi) override final;
58 
60  static const InterfaceID& interfaceID();
62 
63 
65  virtual void handle(const Incident& incident) override final;
66 
67 public:
68 
72  virtual CutIdentifier registerFilter(const std::string& name,
73  const std::string& description,
74  bool nominalOnly) override final;
75 
79  virtual CutIdentifier registerTopFilter ATLAS_NOT_THREAD_SAFE (const std::string& name,
80  const std::string& description,
81  unsigned int logic,
82  const std::string& outputStream,
83  bool nominalOnly) override final;
84 
88  virtual CutIdentifier registerCut(const std::string& name,
89  const std::string& description,
90  CutIdentifier parentCutID,
91  bool nominalOnly) override final;
92 
94  virtual void setFilterDescription(CutIdentifier cutID,
95  const std::string& descr) override final;
96 
99  virtual void addEvent(CutIdentifier cutID,
100  const std::vector<float>& weights) override final;
101 
104  virtual void addEvent(CutIdentifier cutID,
105  double weight) override final;
106 
108  virtual uint64_t getNAcceptedEvents(const CutIdentifier cutID) const override final;
109 
112 
115 
116 
117 private:
120  void addEvent(CutIdentifier cutID,
121  size_t index,
122  double weight);
123 
126  StatusCode determineCycleNumberFromInput(const std::string& collName);
127 
130 
133  size_t index) const;
134 
136  Gaudi::Property<bool> m_configured{this, "Configured", true, "configuration check"};
137 
139  ServiceHandle<StoreGateSvc> m_inMetaDataStore{this, "InputMetaDataStore", "StoreGateSvc/InputMetaDataStore", ""};
140 
142  Gaudi::Property<std::string> m_completeCollName{this, "OutputCollName", "CutBookkeepers", ""};
143 
146 
148  Gaudi::Property<int> m_skimmingCycle{this, "SkimmingCycle", 0, "Skimming cycle of current job"};
149 
151  Gaudi::Property<std::string> m_inputStream{this, "InputStream", "N/A", "The name of the input file stream"};
152 
154  mutable std::recursive_mutex m_addEventMutex;
155 
157  std::unordered_set<CutIdentifier> m_nominalOnlyCuts;
158 };
159 
160 
161 
163 // Inline methods:
165 
166 inline const InterfaceID& CutFlowSvc::interfaceID() {
167  return ICutFlowSvc::interfaceID();
168 }
169 
170 #endif // dual use
171 
172 #endif // EVENT_BOOKKEEPER_TOOLS__CUT_FLOW_SVC_H
CutFlowSvc::interfaceID
static const InterfaceID & interfaceID()
Publish the interface for this service.
Definition: CutFlowSvc.h:166
CutFlowSvc::m_inMetaDataStore
ServiceHandle< StoreGateSvc > m_inMetaDataStore
The input meta-data store.
Definition: CutFlowSvc.h:139
CutFlowSvc::registerCut
virtual CutIdentifier registerCut(const std::string &name, const std::string &description, CutIdentifier parentCutID, bool nominalOnly) override final
Register cut as child of a filter in the CutFlowSvc and returns the CutID of the corresponding EventB...
Definition: CutFlowSvc.cxx:130
CutBookkeeper.h
CutFlowSvc::determineCycleNumberFromInput
StatusCode determineCycleNumberFromInput(const std::string &collName)
Helper function to determine the processing cycle number from the input meta-data store.
Definition: CutFlowSvc.cxx:309
CutFlowSvc::m_configured
Gaudi::Property< bool > m_configured
CutFlow service should be explicitly configured.
Definition: CutFlowSvc.h:136
ICutFlowSvc
This class provides an interface between event filtering algorithms and athena input/output streams,...
Definition: ICutFlowSvc.h:38
CutFlowSvc::getCutBookkeepers
const CutBookkeepersLocalCache & getCutBookkeepers() const
Get CutBookkeepers cache.
Definition: CutFlowSvc.cxx:385
CutFlowSvc::getCutBookkeeper
xAOD::CutBookkeeper * getCutBookkeeper(const CutIdentifier cutID, size_t index) const
Get a CutBookkeeper given a CutID.
Definition: CutFlowSvc.cxx:392
index
Definition: index.py:1
xAOD::CutBookkeeper_v1
Description of the class that is used to keep track of event counts.
Definition: CutBookkeeper_v1.h:29
CutFlowSvc::createContainers
StatusCode createContainers(size_t count)
Helper function to create an empty containers (and its aux store)
Definition: CutFlowSvc.cxx:336
CutFlowSvc::m_addEventMutex
std::recursive_mutex m_addEventMutex
Mutex to protect adding an event.
Definition: CutFlowSvc.h:154
CutFlowSvc::m_containers
CutBookkeepersLocalCache m_containers
Local CutBookkeeperContainers.
Definition: CutFlowSvc.h:145
CutFlowSvc::m_inputStream
Gaudi::Property< std::string > m_inputStream
The name of the currently used input file stream.
Definition: CutFlowSvc.h:151
RunGeantinoStepRecordingITk.outputStream
outputStream
Definition: RunGeantinoStepRecordingITk.py:126
CutFlowSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvi) override final
Definition: CutFlowSvc.cxx:420
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
CutFlowSvc::initialize
virtual StatusCode initialize() override final
Gaudi Service Implementation.
Definition: CutFlowSvc.cxx:32
CutBookkeepersLocalCache
Helper in-memory structure.
Definition: CutBookkeepersLocalCache.h:15
CutFlowSvc
This implements the methods for ICutFlowSvc.
Definition: CutFlowSvc.h:47
CutFlowSvc::CutFlowSvc
CutFlowSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CutFlowSvc.cxx:23
CutFlowSvc::setFilterDescription
virtual void setFilterDescription(CutIdentifier cutID, const std::string &descr) override final
Set the description of an existing CutBookkeeper.
Definition: CutFlowSvc.cxx:162
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
CutFlowSvc::registerFilter
virtual CutIdentifier registerFilter(const std::string &name, const std::string &description, bool nominalOnly) override final
Register filter in the CutFlowSvc and returns the CutID of the corresponding CutBookkeeper.
Definition: CutFlowSvc.cxx:64
CutFlowSvc::m_completeCollName
Gaudi::Property< std::string > m_completeCollName
The name of the completed, i.e., fully processed, CutBookkeeperContainer.
Definition: CutFlowSvc.h:142
CutFlowSvc::getNAcceptedEvents
virtual uint64_t getNAcceptedEvents(const CutIdentifier cutID) const override final
Get number of accepted events for a cut.
Definition: CutFlowSvc.cxx:409
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
CutBookkeepersLocalCache.h
CutIdentifier
uint32_t CutIdentifier
InstanceIdentifier is a unique identifer used for every AthFilterAlgorithm instance.
Definition: ICutFlowSvc.h:22
CutFlowSvc::ATLAS_NOT_THREAD_SAFE
virtual CutIdentifier registerTopFilter ATLAS_NOT_THREAD_SAFE(const std::string &name, const std::string &description, unsigned int logic, const std::string &outputStream, bool nominalOnly) override final
Tells CutFlowSvc that a filter is used directly by an outputStream with a given logical context.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ICutFlowSvc.h
CutFlowSvc::handle
virtual void handle(const Incident &incident) override final
Incident service handle listening for BeginInputFile, EndInputFile and MetaDataStop.
Definition: CutFlowSvc.cxx:231
CutFlowSvc::m_skimmingCycle
Gaudi::Property< int > m_skimmingCycle
The current skimming cycle, i.e., how many processing stages we already had.
Definition: CutFlowSvc.h:148
ICutFlowSvc::interfaceID
static const InterfaceID & interfaceID()
Gaudi boilerplate.
Definition: ICutFlowSvc.h:98
CutFlowSvc::setNumberOfWeightVariations
StatusCode setNumberOfWeightVariations(size_t count)
Set number of weight variations.
Definition: CutFlowSvc.cxx:377
AthService.h
checker_macros.h
Define macros for attributes used to control the static checker.
StoreGateSvc.h
CutFlowSvc::addEvent
virtual void addEvent(CutIdentifier cutID, const std::vector< float > &weights) override final
Tells CutFlowSvc to update the weighted event counter of a CutIdentifier cutID, using CutIdentifier r...
Definition: CutFlowSvc.cxx:178
CutFlowSvc::m_nominalOnlyCuts
std::unordered_set< CutIdentifier > m_nominalOnlyCuts
List of nominal-only filters.
Definition: CutFlowSvc.h:157
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
ServiceHandle< StoreGateSvc >