ATLAS Offline Software
Loading...
Searching...
No Matches
Validator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "xAODJet/Jet.h"
8#include <TFile.h>
9#include <TH1.h>
10
11using namespace std;
12
13Validator::Validator(const std::string& name) :
14 AsgTool(name),
15 m_histSvc("THistSvc", name)
16{
17 declareProperty("InputContainer", m_InputContainer = "");
18 declareProperty("FloatMoments", m_FloatMoments);
19}
20
21
23{
24 ATH_CHECK( m_histSvc.retrieve() );
25 return StatusCode::SUCCESS;
26}
27
28
30{
31 // Get leading jet
32 const xAOD::JetContainer* jets = nullptr;
34 ATH_MSG_ERROR("Unable to retrieve jets from collection: " << m_InputContainer);
35 return 1;
36 }
37 jets = evtStore()->retrieve<const xAOD::JetContainer>(m_InputContainer);
38 if (!jets)[[unlikely]]{
39 ATH_MSG_ERROR("'jets' pointer is nullptr.");
40 return 1;
41 }
42 if(jets->empty()) return 0;
43 const xAOD::Jet *jet = jets->at(0); // This assumes the container is sorted
44
45 // Loop over float moments
46 for(unsigned int i=0; i<m_FloatMoments.size(); i++) {
47 TH1 *outputHist{};
48 if(m_histSvc->exists("/JetSubstructureMoments/" + m_FloatMoments[i])) {
49 m_histSvc->getHist("/JetSubstructureMoments/" + m_FloatMoments[i], outputHist).ignore();
50 }
51 else {
52 unsigned int nbins = 100;
53 float xlow = 0, xhigh = 1.0;
54 if(m_FloatMoments[i].find("Split") != string::npos ||
55 m_FloatMoments[i] == "pt") {
56 nbins = 1000;
57 xhigh = 2000000;
58 }
59 else if(m_FloatMoments[i].find("Pull") != string::npos) {
60 if(m_FloatMoments[i].find("PullMag") != string::npos) {
61 xhigh = 0.1;
62 nbins = 100;
63 }
64 else {
65 xlow = -10;
66 xhigh = 10;
67 nbins = 200;
68 }
69 }
70 else if(m_FloatMoments[i].find("ShowerDeconstruction") != string::npos) {
71 xlow = -10;
72 xhigh = 10;
73 nbins = 100;
74 }
75
76 outputHist = new TH1F(m_FloatMoments[i].c_str(), "", nbins, xlow, xhigh);
77 StatusCode sc = m_histSvc->regHist("/JetSubstructureMoments/" + m_FloatMoments[i], outputHist);
78 if(sc.isFailure()) {
79 ATH_MSG_ERROR("Unable to register histogram");
80 return 1;
81 }
82 }
83
84 if(m_FloatMoments[i] == "pt") {
85 outputHist->Fill(jet->pt());
86 }
87 else {
88 outputHist->Fill(jet->getAttribute<float>(m_FloatMoments[i].c_str()));
89 }
90 }
91
92 return 0;
93}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
std::string m_InputContainer
Definition Validator.h:29
std::vector< std::string > m_FloatMoments
Definition Validator.h:30
ServiceHandle< ITHistSvc > m_histSvc
Definition Validator.h:31
Validator(const std::string &name)
Definition Validator.cxx:13
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition Validator.cxx:22
virtual int execute() const override
Method to be called for each event.
Definition Validator.cxx:29
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
STL namespace.
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
#define unlikely(x)