ATLAS Offline Software
Validator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 #include "GaudiKernel/ITHistSvc.h"
12 
13 using namespace std;
14 
15 Validator::Validator(const std::string& name) :
16  AsgTool(name)
17 {
18  declareProperty("InputContainer", m_InputContainer = "");
19  declareProperty("FloatMoments", m_FloatMoments);
20 }
21 
22 int Validator::execute() const
23 {
24  // Load histogram service
25  StatusCode sc;
26  ITHistSvc *histSvc;
27  sc = service("THistSvc", histSvc);
28  if(sc.isFailure()) {
29  ATH_MSG_ERROR("Unable to access the THistSvc");
30  return 1;
31  }
32 
33  // Get leading jet
34  const xAOD::JetContainer* jets = nullptr;
35  if(!evtStore()->contains<xAOD::JetContainer>(m_InputContainer)) {
36  ATH_MSG_ERROR("Unable to retrieve jets from collection: " << m_InputContainer);
37  return 1;
38  }
39  jets = evtStore()->retrieve<const xAOD::JetContainer>(m_InputContainer);
40  if(jets->empty()) return 0;
41  const xAOD::Jet *jet = jets->at(0); // This assumes the container is sorted
42 
43  // Loop over float moments
44  for(unsigned int i=0; i<m_FloatMoments.size(); i++) {
45  TH1 *outputHist;
46  if(histSvc->exists("/JetSubstructureMoments/" + m_FloatMoments[i])) {
47  sc = histSvc->getHist("/JetSubstructureMoments/" + m_FloatMoments[i], outputHist);
48  if(sc.isFailure()) {
49  ATH_MSG_ERROR("Unable to retrieve histogram");
50  return 1;
51  }
52  }
53  else {
54  unsigned int nbins = 100;
55  float xlow = 0, xhigh = 1.0;
56  if(m_FloatMoments[i].find("Split") != string::npos ||
57  m_FloatMoments[i] == "pt") {
58  nbins = 1000;
59  xhigh = 2000000;
60  }
61  else if(m_FloatMoments[i].find("Pull") != string::npos) {
62  if(m_FloatMoments[i].find("PullMag") != string::npos) {
63  xhigh = 0.1;
64  nbins = 100;
65  }
66  else {
67  xlow = -10;
68  xhigh = 10;
69  nbins = 200;
70  }
71  }
72  else if(m_FloatMoments[i].find("ShowerDeconstruction") != string::npos) {
73  xlow = -10;
74  xhigh = 10;
75  nbins = 100;
76  }
77 
78  outputHist = new TH1F(m_FloatMoments[i].c_str(), "", nbins, xlow, xhigh);
79  sc = histSvc->regHist("/JetSubstructureMoments/" + m_FloatMoments[i], outputHist);
80  if(sc.isFailure()) {
81  ATH_MSG_ERROR("Unable to register histogram");
82  return 1;
83  }
84  }
85 
86  if(m_FloatMoments[i] == "pt") {
87  outputHist->Fill(jet->pt());
88  }
89  else {
90  outputHist->Fill(jet->getAttribute<float>(m_FloatMoments[i].c_str()));
91  }
92  }
93 
94  return 0;
95 }
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
int execute() const
Method to be called for each event.
Definition: Validator.cxx:22
Validator::Validator
Validator(const std::string &name)
Definition: Validator.cxx:15
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
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:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Validator::m_InputContainer
std::string m_InputContainer
Definition: Validator.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:30
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