ATLAS Offline Software
CutFlowSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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  public extends<AthService,
45  ICutFlowSvc,
46  IIncidentListener>
47 {
48 
49 public:
51  CutFlowSvc(const std::string& name, ISvcLocator* pSvcLocator );
52 
54 
55  virtual StatusCode initialize() override final;
57 
58 
60  virtual void handle(const Incident& incident) override final;
61 
62 public:
63 
67  virtual CutIdentifier registerFilter(const std::string& name,
68  const std::string& description,
69  bool nominalOnly) override final;
70 
74  virtual CutIdentifier registerTopFilter ATLAS_NOT_THREAD_SAFE (const std::string& name,
75  const std::string& description,
76  unsigned int logic,
77  const std::string& outputStream,
78  bool nominalOnly) override final;
79 
83  virtual CutIdentifier registerCut(const std::string& name,
84  const std::string& description,
85  CutIdentifier parentCutID,
86  bool nominalOnly) override final;
87 
89  virtual void setFilterDescription(CutIdentifier cutID,
90  const std::string& descr) override final;
91 
94  virtual void addEvent(CutIdentifier cutID,
95  const std::vector<float>& weights) override final;
96 
99  virtual void addEvent(CutIdentifier cutID,
100  double weight) override final;
101 
103  virtual uint64_t getNAcceptedEvents(const CutIdentifier cutID) const override final;
104 
107 
110 
111 
112 private:
115  void addEvent(CutIdentifier cutID,
116  size_t index,
117  double weight);
118 
121  StatusCode determineCycleNumberFromInput(const std::string& collName);
122 
125 
128  size_t index) const;
129 
131  Gaudi::Property<bool> m_configured{this, "Configured", true, "configuration check"};
132 
134  ServiceHandle<StoreGateSvc> m_inMetaDataStore{this, "InputMetaDataStore", "StoreGateSvc/InputMetaDataStore", ""};
135 
137  Gaudi::Property<std::string> m_completeCollName{this, "OutputCollName", "CutBookkeepers", ""};
138 
141 
143  Gaudi::Property<int> m_skimmingCycle{this, "SkimmingCycle", 0, "Skimming cycle of current job"};
144 
146  Gaudi::Property<std::string> m_inputStream{this, "InputStream", "N/A", "The name of the input file stream"};
147 
149  mutable std::recursive_mutex m_addEventMutex;
150 
152  std::unordered_set<CutIdentifier> m_nominalOnlyCuts;
153 };
154 
155 #endif // dual use
156 
157 #endif // EVENT_BOOKKEEPER_TOOLS__CUT_FLOW_SVC_H
CutFlowSvc::m_inMetaDataStore
ServiceHandle< StoreGateSvc > m_inMetaDataStore
The input meta-data store.
Definition: CutFlowSvc.h:134
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:131
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:149
CutFlowSvc::m_containers
CutBookkeepersLocalCache m_containers
Local CutBookkeeperContainers.
Definition: CutFlowSvc.h:140
CutFlowSvc::m_inputStream
Gaudi::Property< std::string > m_inputStream
The name of the currently used input file stream.
Definition: CutFlowSvc.h:146
RunGeantinoStepRecordingITk.outputStream
outputStream
Definition: RunGeantinoStepRecordingITk.py:126
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
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
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:137
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:221
weights
Definition: herwig7_interface.h:44
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:143
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:152
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
ServiceHandle< StoreGateSvc >