ATLAS Offline Software
MuonTPMetaDataAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONPERFORMANCEALGS_MUONTPMETADATAALG_H
5 #define MUONPERFORMANCEALGS_MUONTPMETADATAALG_H
12 
13 namespace MuonVal{
14 
16 public:
17  MuonTPMetaDataAlg(const std::string& name, ISvcLocator* pSvcLocator);
18  virtual ~MuonTPMetaDataAlg() = default;
19 
20  StatusCode initialize() override;
21  StatusCode execute() override;
22  StatusCode finalize() override;
23  StatusCode beginInputFile() override;
24  unsigned int cardinality() const override final { return 1; }
25 
26 private:
27  SG::ReadHandleKey<xAOD::EventInfo> m_infoKey{this, "EvtInfoKey", "EventInfo"};
29  Gaudi::Property<std::string> m_stream{this, "OutStream", "MUONTP"};
30 
31  //
32  Gaudi::Property<bool> m_isData{this, "isData", false};
34  Gaudi::Property<bool> m_isDerivedAOD{this, "isDAOD", false};
36  Gaudi::Property<bool> m_isAF2{this, "isAF2", false};
38  Gaudi::Property<bool> m_storeLHE{this, "writeLHE", false};
39 
40  ToolHandle<CP::IPileupReweightingTool> m_prwTool{this, "prwTool", ""};
41  bool m_hasPrwTool{false};
43  std::unique_ptr<MuonTesterTree> m_MetaDataTree{nullptr};
44 
47  struct RunMetaData {
48  ~RunMetaData() = default;
49  RunMetaData(unsigned int __run, const std::string& __stream) : run_number{__run}, trigger_stream{__stream} {}
50  bool operator<(const RunMetaData& other) const { return run_number < other.run_number; }
52  unsigned int run_number{0};
54  Long64_t tot_events{0};
56  Long64_t proc_events{0};
58  std::string trigger_stream{};
60  std::set<unsigned int> total_lumi_blocks{};
62  std::set<unsigned int> processed_blocks{};
63 
64  bool has_book_keeper{false};
65  };
66  struct SimMetaData {
67  ~SimMetaData() = default;
68  SimMetaData(int __dsid, unsigned int __prw) : mc_channel{__dsid}, prw_channel{__prw} {}
69  bool operator<(const SimMetaData& other) const {
70  if (other.mc_channel != mc_channel) return mc_channel < other.mc_channel;
71  if (other.prw_channel != prw_channel) return prw_channel < other.prw_channel;
72  return variation_number < other.variation_number;
73  }
75  int mc_channel{0};
77  unsigned int prw_channel{0};
79  double prw_lumi{0};
81  Long64_t tot_events{0};
83  Long64_t proc_events{0};
85  double sum_w{0.};
86  double sum_w_squared{0.};
87 
89  std::string weight_name{};
91  unsigned int variation_number{0};
93  bool has_book_keeper{false};
95  bool warned{false};
96  };
99 
100 
101  std::vector<SimMetaData> m_sim_meta{};
102  std::vector<RunMetaData> m_run_meta{};
103 
104  const xAOD::CutBookkeeper* RetrieveCutBookKeeper(const std::string& stream, const std::string& cbk_name = "AllExecutedEvents") const;
105 };
106 }
107 #endif //> !MUONPERFORMANCEALGS_MUONTPMETADATAALG_H
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
MuonVal::MuonTPMetaDataAlg::SimMetaData::proc_events
Long64_t proc_events
Number of processed events in the file itself.
Definition: MuonTPMetaDataAlg.h:83
CutBookkeeper.h
MuonVal::MuonTPMetaDataAlg
Definition: MuonTPMetaDataAlg.h:15
AthAnalysisAlgorithm
Definition: AthAnalysisAlgorithm.h:34
MuonVal::MuonTPMetaDataAlg::RunMetaData::RunMetaData
RunMetaData(unsigned int __run, const std::string &__stream)
Definition: MuonTPMetaDataAlg.h:49
MuonVal::MuonTPMetaDataAlg::RunMetaData
Helper structs to cache the meta-data for simulation and recorded data.
Definition: MuonTPMetaDataAlg.h:47
MuonVal::MuonTPMetaDataAlg::m_hasPrwTool
bool m_hasPrwTool
Definition: MuonTPMetaDataAlg.h:41
xAOD::CutBookkeeper_v1
Description of the class that is used to keep track of event counts.
Definition: CutBookkeeper_v1.h:29
MuonVal::MuonTPMetaDataAlg::RunMetaData::proc_events
Long64_t proc_events
Processed Events.
Definition: MuonTPMetaDataAlg.h:56
MuonVal::MuonTPMetaDataAlg::cardinality
unsigned int cardinality() const override final
Definition: MuonTPMetaDataAlg.h:24
MuonVal::MuonTPMetaDataAlg::SimMetaData::SimMetaData
SimMetaData(int __dsid, unsigned int __prw)
Definition: MuonTPMetaDataAlg.h:68
MuonVal::MuonTPMetaDataAlg::m_isDerivedAOD
Gaudi::Property< bool > m_isDerivedAOD
Is derived DAOD property.
Definition: MuonTPMetaDataAlg.h:34
MuonVal::MuonTPMetaDataAlg::SimMetaData::mc_channel
int mc_channel
Mc channel number.
Definition: MuonTPMetaDataAlg.h:75
MuonTesterTree.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ReadHandleKey< xAOD::EventInfo >
MuonVal::MuonTPMetaDataAlg::RunMetaData::run_number
unsigned int run_number
run number of the current file
Definition: MuonTPMetaDataAlg.h:52
MuonVal::MuonTPMetaDataAlg::SimMetaData::prw_channel
unsigned int prw_channel
run number used for the pile-up campaign
Definition: MuonTPMetaDataAlg.h:77
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
MuonVal::MuonTPMetaDataAlg::RunMetaData::has_book_keeper
bool has_book_keeper
Definition: MuonTPMetaDataAlg.h:64
MuonVal::MuonTPMetaDataAlg::finalize
StatusCode finalize() override
Definition: MuonTPMetaDataAlg.cxx:47
MuonVal::MuonTPMetaDataAlg::m_sim_meta
std::vector< SimMetaData > m_sim_meta
Definition: MuonTPMetaDataAlg.h:101
MuonVal::MuonTPMetaDataAlg::beginInputFile
StatusCode beginInputFile() override
Function called when a new input file is opened user can read input metadata from inputMetaStore()
Definition: MuonTPMetaDataAlg.cxx:148
MuonVal::MuonTPMetaDataAlg::MuonTPMetaDataAlg
MuonTPMetaDataAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonTPMetaDataAlg.cxx:26
MuonVal::MuonTPMetaDataAlg::SimMetaData::warned
bool warned
Make sure that the WARNING is only printed once.
Definition: MuonTPMetaDataAlg.h:95
MuonVal::MuonTPMetaDataAlg::SimMetaData::sum_w_squared
double sum_w_squared
Definition: MuonTPMetaDataAlg.h:86
IPileupReweightingTool.h
MuonVal::MuonTPMetaDataAlg::RunMetaData::total_lumi_blocks
std::set< unsigned int > total_lumi_blocks
Luminosity blocks from the cache upstream.
Definition: MuonTPMetaDataAlg.h:60
MuonVal::MuonTPMetaDataAlg::SimMetaData::prw_lumi
double prw_lumi
Expected luminosity.
Definition: MuonTPMetaDataAlg.h:79
MuonVal::MuonTPMetaDataAlg::m_stream
Gaudi::Property< std::string > m_stream
Output file stream.
Definition: MuonTPMetaDataAlg.h:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonVal::MuonTPMetaDataAlg::RetrieveCutBookKeeper
const xAOD::CutBookkeeper * RetrieveCutBookKeeper(const std::string &stream, const std::string &cbk_name="AllExecutedEvents") const
Definition: MuonTPMetaDataAlg.cxx:128
MuonVal::MuonTPMetaDataAlg::~MuonTPMetaDataAlg
virtual ~MuonTPMetaDataAlg()=default
MuonVal::MuonTPMetaDataAlg::m_storeLHE
Gaudi::Property< bool > m_storeLHE
Store LHE weights.
Definition: MuonTPMetaDataAlg.h:38
AthAnalysisAlgorithm.h
MuonVal::MuonTPMetaDataAlg::SimMetaData::~SimMetaData
~SimMetaData()=default
MuonVal::MuonTPMetaDataAlg::RunMetaData::operator<
bool operator<(const RunMetaData &other) const
Definition: MuonTPMetaDataAlg.h:50
MuonVal::MuonTPMetaDataAlg::execute
StatusCode execute() override
Definition: MuonTPMetaDataAlg.cxx:63
MuonVal::MuonTPMetaDataAlg::RunMetaData::processed_blocks
std::set< unsigned int > processed_blocks
Luminosity blocks from the file.
Definition: MuonTPMetaDataAlg.h:62
MuonVal::MuonTPMetaDataAlg::m_infoKey
SG::ReadHandleKey< xAOD::EventInfo > m_infoKey
Definition: MuonTPMetaDataAlg.h:27
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonVal::MuonTPMetaDataAlg::SimMetaData::operator<
bool operator<(const SimMetaData &other) const
Definition: MuonTPMetaDataAlg.h:69
MuonVal::MuonTPMetaDataAlg::SimMetaData::tot_events
Long64_t tot_events
Number of total events from the file upstream.
Definition: MuonTPMetaDataAlg.h:81
MuonVal::MuonTPMetaDataAlg::RunMetaData::trigger_stream
std::string trigger_stream
Name of the trigger stream.
Definition: MuonTPMetaDataAlg.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonVal::MuonTPMetaDataAlg::m_prwTool
ToolHandle< CP::IPileupReweightingTool > m_prwTool
Definition: MuonTPMetaDataAlg.h:40
EventInfo.h
MuonVal::MuonTPMetaDataAlg::SimMetaData::variation_number
unsigned int variation_number
Position inside the weight vector.
Definition: MuonTPMetaDataAlg.h:91
MuonVal::MuonTPMetaDataAlg::m_MetaDataTree
std::unique_ptr< MuonTesterTree > m_MetaDataTree
Meta data tree object.
Definition: MuonTPMetaDataAlg.h:43
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
MuonVal::MuonTPMetaDataAlg::SimMetaData::weight_name
std::string weight_name
Name of the weight variation.
Definition: MuonTPMetaDataAlg.h:89
MuonVal::MuonTPMetaDataAlg::fillSimulationTree
StatusCode fillSimulationTree()
Definition: MuonTPMetaDataAlg.cxx:296
MuonVal::MuonTPMetaDataAlg::fillDataTree
StatusCode fillDataTree()
Definition: MuonTPMetaDataAlg.cxx:275
MuonVal::MuonTPMetaDataAlg::initialize
StatusCode initialize() override
Definition: MuonTPMetaDataAlg.cxx:29
MuonVal::MuonTPMetaDataAlg::m_isAF2
Gaudi::Property< bool > m_isAF2
On AFII simulation.
Definition: MuonTPMetaDataAlg.h:36
MuonVal::MuonTPMetaDataAlg::SimMetaData::has_book_keeper
bool has_book_keeper
Print the WARNING.
Definition: MuonTPMetaDataAlg.h:93
MuonVal::MuonTPMetaDataAlg::RunMetaData::tot_events
Long64_t tot_events
Total events from the upstream AOD.
Definition: MuonTPMetaDataAlg.h:54
MuonVal::MuonTPMetaDataAlg::m_isData
Gaudi::Property< bool > m_isData
Definition: MuonTPMetaDataAlg.h:32
MuonVal::MuonTPMetaDataAlg::RunMetaData::~RunMetaData
~RunMetaData()=default
MuonVal::MuonTPMetaDataAlg::SimMetaData::sum_w
double sum_w
Sum of weights.
Definition: MuonTPMetaDataAlg.h:85
MuonVal::MuonTPMetaDataAlg::m_run_meta
std::vector< RunMetaData > m_run_meta
Definition: MuonTPMetaDataAlg.h:102
MuonVal::MuonTPMetaDataAlg::SimMetaData
Definition: MuonTPMetaDataAlg.h:66