ATLAS Offline Software
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 
12 using namespace std;
13 
14 Validator::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 
30 int Validator::execute() const
31 {
32  // Get leading jet
33  const xAOD::JetContainer* jets = nullptr;
34  if(!evtStore()->contains<xAOD::JetContainer>(m_InputContainer)) {
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 }
Validator.h
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Validator::execute
virtual int execute() const override
Method to be called for each event.
Definition: Validator.cxx:30
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
Validator::Validator
Validator(const std::string &name)
Definition: Validator.cxx:14
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
Validator::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: Validator.cxx:23
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Validator::m_InputContainer
std::string m_InputContainer
Definition: Validator.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CalculateHighPtTerm.outputHist
outputHist
Definition: ICHEP2016/CalculateHighPtTerm.py:49
Validator::m_FloatMoments
std::vector< std::string > m_FloatMoments
Definition: Validator.h:32
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
Validator::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: Validator.h:33