ATLAS Offline Software
Loading...
Searching...
No Matches
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
13#include <TH1.h>
14
15//
16// method implementations
17//
18
19namespace CP
20{
21
22 StatusCode MetadataHistAlg ::
23 initialize ()
24 {
25 if (m_histogramName.empty())
26 {
27 ANA_MSG_ERROR ("histogram name should not be empty");
28 return StatusCode::FAILURE;
29 }
30
31 if (m_dataType.empty())
32 {
33 ANA_MSG_ERROR ("dataType should not be empty");
34 return StatusCode::FAILURE;
35 }
36
37 if (m_campaign.empty())
38 {
39 ANA_MSG_ERROR ("campaign should not be empty");
40 return StatusCode::FAILURE;
41 }
42
43 if (m_mcChannelNumber.empty())
44 {
45 ANA_MSG_ERROR ("mcChannelNumber should not be empty");
46 return StatusCode::FAILURE;
47 }
48
49 if (m_etag.empty())
50 {
51 ANA_MSG_ERROR ("etag should not be empty");
52 return StatusCode::FAILURE;
53 }
54
55 return StatusCode::SUCCESS;
56 }
57
58
59
60 StatusCode MetadataHistAlg ::
61 execute ()
62 {
63 if (!m_firstEvent)
64 {
65 return StatusCode::SUCCESS;
66 }
67
68 m_firstEvent = false;
69
70 ANA_CHECK (book (TH1F (m_histogramName.value().c_str(), "Sample metadata", 4, 0.0, 4.0)));
72
73 // Please keep the bin order unchanged
74 histogram->GetXaxis()->SetBinLabel(1, m_dataType.value().c_str());
75 histogram->GetXaxis()->SetBinLabel(2, m_campaign.value().c_str());
76 histogram->GetXaxis()->SetBinLabel(3, m_mcChannelNumber.value().c_str());
77 histogram->GetXaxis()->SetBinLabel(4, m_etag.value().c_str());
78
79 return StatusCode::SUCCESS;
80 }
81
82
83 StatusCode MetadataHistAlg ::
84 finalize ()
85 {
86 return StatusCode::SUCCESS;
87 }
88}
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::string histogram
Definition chains.cxx:52
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Gaudi::Property< std::string > m_etag
the e-tag of the sample to store
Gaudi::Property< std::string > m_campaign
the campaign of the sample to store
bool m_firstEvent
whether the next event will be the first event
Gaudi::Property< std::string > m_mcChannelNumber
the mc channel number of the sample to store
Gaudi::Property< std::string > m_histogramName
the name of the histogram to use
Gaudi::Property< std::string > m_dataType
the data type of the sample to store
Select isolated Photons, Electrons and Muons.