ATLAS Offline Software
Loading...
Searching...
No Matches
KinematicHistAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
11
13
15#include <TH1.h>
16
17//
18// method implementations
19//
20
21namespace CP
22{
23
24 StatusCode KinematicHistAlg ::
25 initialize ()
26 {
29 ANA_CHECK (m_systematicsList.initialize());
30 return StatusCode::SUCCESS;
31 }
32
33
34
35 StatusCode KinematicHistAlg ::
36 execute ()
37 {
38 for (const auto& sys : m_systematicsList.systematicsVector())
39 {
40 const xAOD::IParticleContainer *input = nullptr;
41 ANA_CHECK (m_inputHandle.retrieve (input, sys));
42
43 auto histIter = m_hist.find (sys);
44 if (histIter == m_hist.end())
45 {
46 std::string name;
47 HistGroup group;
48
49 name = RCU::substitute (m_histPattern, "%VAR%", "multiplicity");
50 ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
51 ANA_CHECK (book (TH1F (name.c_str(), "multiplicity", 20, 0, 20)));
52 group.multiplicity = hist (name);
53
54 m_hist.insert (std::make_pair (sys, group));
55 histIter = m_hist.find (sys);
56 assert (histIter != m_hist.end());
57 }
58
59 std::size_t count = 0;
60 for (std::size_t iter = 0; iter != input->size(); ++ iter)
61 {
62 const xAOD::IParticle *particle = (*input)[iter];
63 if (m_preselection.getBool (*particle, sys))
64 {
65 while (histIter->second.perObject.size() <= count)
66 {
67 std::string name;
68 HistSubgroup group;
69
70 name = RCU::substitute (m_histPattern, "%VAR%", "pt" + std::to_string(histIter->second.perObject.size()));
71 ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
72 ANA_CHECK (book (TH1F (name.c_str(), "pt", 20, 0, 200e3)));
73 group.pt = hist (name);
74
75 name = RCU::substitute (m_histPattern, "%VAR%", "eta" + std::to_string(histIter->second.perObject.size()));
76 ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
77 ANA_CHECK (book (TH1F (name.c_str(), "eta", 20, -5, 5)));
78 group.eta = hist (name);
79
80 name = RCU::substitute (m_histPattern, "%VAR%", "phi" + std::to_string(histIter->second.perObject.size()));
81 ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, name, sys));
82 ANA_CHECK (book (TH1F (name.c_str(), "phi", 20, -M_PI, M_PI)));
83 group.phi = hist (name);
84
85 histIter->second.perObject.push_back (group);
86 }
87
88 HistSubgroup& group = histIter->second.perObject[count];
89
90 group.pt->Fill (particle->pt());
91 group.eta->Fill (particle->eta());
92 group.phi->Fill (particle->phi());
93 count += 1;
94 }
95 }
96
97 histIter->second.multiplicity->Fill (count);
98 }
99 return StatusCode::SUCCESS;
100 }
101}
#define M_PI
#define ANA_CHECK(EXP)
check whether the given expression was successful
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.
SysListHandle m_systematicsList
the systematics list we run
Gaudi::Property< std::string > m_histPattern
the pattern for histogram names
std::unordered_map< CP::SystematicSet, HistGroup > m_hist
the created histograms
SysReadHandle< xAOD::IParticleContainer > m_inputHandle
the jet collection we run on
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Class providing the definition of the 4-vector interface.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Select isolated Photons, Electrons and Muons.
std::string substitute(const std::string &str, const std::string &pattern, const std::string &with)
effects: substitute all occurences of "pattern" with "with" in the string "str" returns: the substitu...
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
the histograms we fill per systematic
the histograms we fill per systematic and object