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