ATLAS Offline Software
MetadataHistAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
12 #include <regex>
14 #include <TH1.h>
15 
16 //
17 // method implementations
18 //
19 
20 namespace CP
21 {
22 
24  initialize ()
25  {
26  if (m_histogramName.empty())
27  {
28  ANA_MSG_ERROR ("histogram name should not be empty");
29  return StatusCode::FAILURE;
30  }
31 
32  if (m_dataType.empty())
33  {
34  ANA_MSG_ERROR ("dataType should not be empty");
35  return StatusCode::FAILURE;
36  }
37 
38  if (m_campaign.empty())
39  {
40  ANA_MSG_ERROR ("campaign should not be empty");
41  return StatusCode::FAILURE;
42  }
43 
44  if (m_mcChannelNumber.empty())
45  {
46  ANA_MSG_ERROR ("mcChannelNumber should not be empty");
47  return StatusCode::FAILURE;
48  }
49 
50  if (m_etag.empty())
51  {
52  ANA_MSG_ERROR ("etag should not be empty");
53  return StatusCode::FAILURE;
54  }
55 
56  return StatusCode::SUCCESS;
57  }
58 
59 
60 
62  execute ()
63  {
64  if (!m_firstEvent)
65  {
66  return StatusCode::SUCCESS;
67  }
68 
69  m_firstEvent = false;
70 
71  ANA_CHECK (book (TH1F (m_histogramName.value().c_str(), "Sample metadata", 4, 0.0, 4.0)));
73 
74  // Please keep the bin order unchanged
75  histogram->GetXaxis()->SetBinLabel(1, m_dataType.value().c_str());
76  histogram->GetXaxis()->SetBinLabel(2, m_campaign.value().c_str());
77  histogram->GetXaxis()->SetBinLabel(3, m_mcChannelNumber.value().c_str());
78  histogram->GetXaxis()->SetBinLabel(4, m_etag.value().c_str());
79 
80  return StatusCode::SUCCESS;
81  }
82 
83 
85  finalize ()
86  {
87  return StatusCode::SUCCESS;
88  }
89 }
CP::MetadataHistAlg::initialize
virtual ::StatusCode initialize() override
Definition: MetadataHistAlg.cxx:24
CP::MetadataHistAlg::m_etag
Gaudi::Property< std::string > m_etag
the e-tag of the sample to store
Definition: MetadataHistAlg.h:49
AthHistogramming::book
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition: AthHistogramming.h:303
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:25
CP::MetadataHistAlg::m_dataType
Gaudi::Property< std::string > m_dataType
the data type of the sample to store
Definition: MetadataHistAlg.h:37
CP::MetadataHistAlg::m_mcChannelNumber
Gaudi::Property< std::string > m_mcChannelNumber
the mc channel number of the sample to store
Definition: MetadataHistAlg.h:45
CP::MetadataHistAlg::m_histogramName
Gaudi::Property< std::string > m_histogramName
the name of the histogram to use
Definition: MetadataHistAlg.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::MetadataHistAlg::m_campaign
Gaudi::Property< std::string > m_campaign
the campaign of the sample to store
Definition: MetadataHistAlg.h:41
CP::MetadataHistAlg::execute
virtual ::StatusCode execute() override
Definition: MetadataHistAlg.cxx:62
AthHistogramming::hist
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Definition: AthHistogramming.cxx:198
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
CP::MetadataHistAlg::m_firstEvent
bool m_firstEvent
whether the next event will be the first event
Definition: MetadataHistAlg.h:54
CP::MetadataHistAlg::finalize
virtual ::StatusCode finalize() override
Definition: MetadataHistAlg.cxx:85
MetadataHistAlg.h
histogram
std::string histogram
Definition: chains.cxx:52