ATLAS Offline Software
JetKinematicHistos.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "TProfile2D.h"
8 #include "TString.h"
9 #include <map>
10 
11 #define toGeV 1/1000.
12 
14  ,m_pt(nullptr)
15  ,m_eta(nullptr)
16  ,m_phi(nullptr)
17  ,m_m(nullptr)
18  ,m_e(nullptr)
19  ,m_jetScale("JetAssignedScaleMomentum")
20 {
21  declareProperty("JetScale", m_jetScale);
22  declareProperty("PlotNJet", m_doN = false);
23  declareProperty("PlotM", m_doM = true);
24  declareProperty("PlotE", m_doE = false);
25  declareProperty("PlotOccupancy", m_doOccupancy = false);
26  declareProperty("PlotAveragePt", m_doAveragePt = false);
27  declareProperty("PlotAverageE", m_doAverageE = false);
28  declareProperty("PlotNConstit", m_doNConstit = true);
29 
30 }
31 
32 
34 
35  // -------------- Modify histo names/titles --------
36  // if we're plotting a defined scale, modify the Histo titles and names
37 
38  std::map<std::string, std::string> scale2str( {
39  { "JetEMScaleMomentum" , "EMScale" } ,
40  { "JetConstitScaleMomentum" , "ConstitScale" } } );
41  TString scaleTag = scale2str[ m_jetScale ] ; // defaults to ""
42 
43  TString prefixn = scaleTag;
44  if(prefixn != "") prefixn +="_";
45  // --------------
46 
47  // Build and register the histos in this group :
48  TH1::AddDirectory(kFALSE); // Turn off automatic addition to gDirectory to avoid Warnings. Histos are anyway placed in their own dir later.
49  m_pt = bookHisto( new TH1F(prefixn+"pt" , "Jet P_{T};P_{T} (GeV);Entries", 100,0,200) );
50  m_eta = bookHisto( new TH1F(prefixn+"eta" , "Jet #eta;#eta;Entries", 50,-6,6) );
51  m_phi = bookHisto( new TH1F(prefixn+"phi" , "Jet #phi;#phi;Entries", 50,-3.3,3.3) );
52 
53  // high pT jets in a new histogram range
54  m_pt_high = bookHisto( new TH1F(prefixn+"pt_high" , "Jet P_{T} pT.gt.200 GeV;P_{T} (GeV);Entries", 100,0,4000) );
55  m_eta_high = bookHisto( new TH1F(prefixn+"eta_high" , "Jet #eta pT.gt.200 GeV;#eta;Entries", 50,-6,6) );
56 
57 
58  if(m_doM) {
59  m_m = bookHisto( new TH1F(prefixn+"M" , "Jet Mass;Mass (GeV);Entries", 80,-5, 400) );
60  m_m_high = bookHisto( new TH1F(prefixn+"M_high" , "Jet Mass pT.gt.200;Mass (GeV) pT.gt.200 GeV;Entries", 80,-5, 400) );
61  }
62 
63  if(m_doE) {
64  m_e = bookHisto( new TH1F(prefixn+"E" , "Jet Energy;Energy (GeV);Entries", 100,1, 400) );
65  m_e_high = bookHisto( new TH1F(prefixn+"E_high" , "Jet Energy pT.gt.200 GeV;Energy (GeV);Entries", 100,1, 2000) );
66  }
67 
68  if(m_doN){
69  m_njet = bookHisto( new TH1F(prefixn+"num" , "Jet multiplicity;Number of jets;Entries", 40,0,40) );
70  m_njet_passJVT = bookHisto( new TH1F(prefixn+"num_passJVT" , "Jet multiplicity (passing JVT cut);Number of jets (passing JVT);Entries", 40,0,40) );
71  m_njet_failJVT = bookHisto( new TH1F(prefixn+"num_failJVT" , "Jet multiplicity (failing JVT cut);Number of jets (failing JVT);Entries", 40,0,40) );
72  }
73  if(m_doOccupancy) m_occupancyEtaPhi = bookHisto( new TH2F(prefixn+"OccupancyEtaPhi", "Occupancy;#eta;#phi;Entries", 50,-5,5,50,-3.1416,3.1416) );
74  if(m_doAveragePt) m_averagePtEtaPhi = bookHisto( new TProfile2D(prefixn+"AveragePtEtaPhi", "Average P_{T};#eta;#phi;Entries", 50,-5,5,50,-3.1416,3.1416) );
75  if(m_doAverageE) m_averageE_EtaPhi = bookHisto( new TProfile2D(prefixn+"AverageE_EtaPhi", "Average E;#eta;#phi;Entries", 50,-5,5,50,-3.1416,3.1416) );
76 
77  if(m_doNConstit) {
78  m_nConstit = bookHisto( new TH1F(prefixn+"numconstit", "Number of constituents;N;",100,0,100) );
79  m_nConstit_high = bookHisto( new TH1F(prefixn+"numconstit_high", "Number of constituents pT.gt.200 GeV;N;",100,0,200) );
80  }
81  TH1::AddDirectory(kTRUE); // Turn on automatic addition to gDirectory in case others needs it.
82 
83  // -------------- Modify histo titles.
84  if(prefixn != "" ){
85 
86  // build a qualifier in the form "(EMScale, Leading Jet, ...)"
87  TString qualif = "(";
88  TString tags[] = { scaleTag};
89  for(const auto& t : tags ) { if(qualif != "(") qualif+=",";qualif += t; }
90  qualif += ")";
91  // reset all titles :
92  for(auto& hdata : m_vBookedHistograms ){
93  TString t = hdata.hist->GetTitle(); t+=" "+qualif;
94  hdata.hist->SetTitle(t );
95  }
96  }
97 
98 
99  return 0;
100 }
101 
102 
103 
105  // fill the N if needed.
106  if (m_doN){
107  m_njet->Fill( cont.size(), weight );
108 
109  int counter_passJVT = 0;
110  int counter_failJVT = 0;
111 
112  float JVT_cut = 0.50;
113 
114  static const SG::ConstAccessor<float> JvtAcc("Jvt");
115  if(!cont.empty()){
116  if(JvtAcc.isAvailable(*cont[0])){
117  xAOD::JetInput::Type inputtype = cont[0]->getInputType();
118  if(inputtype == xAOD::JetInput::EMTopoOrigin || inputtype == xAOD::JetInput::LCTopoOrigin)
119  JVT_cut = 0.59;
120  }
121  }
122 
123  for(const auto *jet : cont){
124  if(JvtAcc.isAvailable(*jet)) {
125  if(JvtAcc(*jet) > JVT_cut) counter_passJVT++;
126  else counter_failJVT++;
127  }
128  }
129 
130  m_njet_passJVT->Fill( counter_passJVT, weight);
131  m_njet_failJVT->Fill( counter_failJVT, weight);
132  }
133 
134  // Perform the loop over jets in the base class :
136 }
137 
138 
140 
141  SG::ConstAccessor<float> momAcc(m_jetScale+"_pt");
142  if(m_jetScale != "JetAssignedScaleMomentum" && !momAcc.isAvailable(j)){
143  if(m_doNConstit) m_nConstit->Fill( j.numConstituents(), weight );
144  return 0;
145  }
146 
147  // m_jetScale is a property of the base tool
148  const xAOD::JetFourMom_t p4 = j.jetP4(m_jetScale);
149  m_pt->Fill( p4.Pt()*toGeV, weight );
150  m_eta->Fill( p4.Eta(), weight );
151  m_phi->Fill( p4.Phi(), weight );
152  if (p4.Pt()*toGeV > 200.0){ // high eta
153  m_pt_high->Fill( p4.Pt()*toGeV, weight );
154  m_eta_high->Fill( p4.Eta(), weight );
155  if(m_doE) m_e_high->Fill( p4.E()*toGeV, weight );
156  if(m_doM) m_m_high->Fill( p4.M()*toGeV, weight );
158  }
159 
160  if(m_doE) m_e->Fill( p4.E()*toGeV, weight );
161  if(m_doM) m_m->Fill( p4.M()*toGeV, weight );
162 
163  if(m_doOccupancy) m_occupancyEtaPhi->Fill( p4.Eta(), p4.Phi(), weight );
164  if(m_doAveragePt) m_averagePtEtaPhi->Fill( p4.Eta(), p4.Phi() , p4.Pt()*toGeV, weight);
165  if(m_doAverageE) m_averageE_EtaPhi->Fill( p4.Eta(), p4.Phi() , p4.E()*toGeV, weight);
166 
167  if(m_doNConstit) m_nConstit->Fill( j.numConstituents(), weight );
168  return 0;
169 }
170 
JetKinematicHistos::fillHistosFromContainer
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
Definition: JetKinematicHistos.cxx:104
xAOD::JetInput::LCTopoOrigin
@ LCTopoOrigin
Definition: JetContainerInfo.h:67
JetKinematicHistos::m_njet_passJVT
TH1F * m_njet_passJVT
Definition: JetKinematicHistos.h:38
JetKinematicHistos::m_nConstit
TH1F * m_nConstit
Definition: JetKinematicHistos.h:45
JetKinematicHistos::m_njet_failJVT
TH1F * m_njet_failJVT
Definition: JetKinematicHistos.h:39
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JetKinematicHistos::m_averageE_EtaPhi
TProfile2D * m_averageE_EtaPhi
Definition: JetKinematicHistos.h:56
JetKinematicHistos::m_pt
TH1F * m_pt
Definition: JetKinematicHistos.h:40
JetKinematicHistos::m_e_high
TH1F * m_e_high
Definition: JetKinematicHistos.h:51
xAOD::Jet_v1::jetP4
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition: Jet_v1.cxx:76
JetKinematicHistos::m_m
TH1F * m_m
Definition: JetKinematicHistos.h:43
JetKinematicHistos::m_doE
bool m_doE
Definition: JetKinematicHistos.h:62
SG::ConstAccessor< float >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
JetKinematicHistos::JetKinematicHistos
JetKinematicHistos(const std::string &t)
Definition: JetKinematicHistos.cxx:13
JetHistoBase::fillHistosFromContainer
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
Definition: JetHistoBase.cxx:24
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
JetKinematicHistos::m_doAveragePt
bool m_doAveragePt
Definition: JetKinematicHistos.h:64
toGeV
#define toGeV
Definition: JetKinematicHistos.cxx:11
JetKinematicHistos::m_averagePtEtaPhi
TProfile2D * m_averagePtEtaPhi
Definition: JetKinematicHistos.h:55
JetKinematicHistos::m_eta_high
TH1F * m_eta_high
Definition: JetKinematicHistos.h:49
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
xAOD::JetInput::EMTopoOrigin
@ EMTopoOrigin
Definition: JetContainerInfo.h:68
JetHistoBase
Definition: JetHistoBase.h:27
JetKinematicHistos::m_phi
TH1F * m_phi
Definition: JetKinematicHistos.h:42
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JetKinematicHistos::m_doAverageE
bool m_doAverageE
Definition: JetKinematicHistos.h:65
JetKinematicHistos::m_doN
bool m_doN
Definition: JetKinematicHistos.h:60
JetKinematicHistos::buildHistos
virtual int buildHistos()
Definition: JetKinematicHistos.cxx:33
xAOD::JetInput::Type
Type
Definition: JetContainerInfo.h:54
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
JetKinematicHistos::m_pt_high
TH1F * m_pt_high
Definition: JetKinematicHistos.h:48
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
JetKinematicHistos::m_doM
bool m_doM
Definition: JetKinematicHistos.h:61
JetKinematicHistos::m_doOccupancy
bool m_doOccupancy
Definition: JetKinematicHistos.h:63
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetKinematicHistos::fillHistosFromJet
virtual int fillHistosFromJet(const xAOD::Jet &j, float weight)
Definition: JetKinematicHistos.cxx:139
JetKinematicHistos::m_eta
TH1F * m_eta
Definition: JetKinematicHistos.h:41
JetKinematicHistos::m_jetScale
std::string m_jetScale
Definition: JetKinematicHistos.h:58
HistoGroupBase::bookHisto
T * bookHisto(T *h, Interval_t ityp=useToolInterval)
register the histo h in this group (if h!=NULL). The histo name is changed if m_prefixedHistoName==tr...
Definition: HistoGroupBase.h:69
JetKinematicHistos::m_e
TH1F * m_e
Definition: JetKinematicHistos.h:44
JetKinematicHistos::m_occupancyEtaPhi
TH2F * m_occupancyEtaPhi
Definition: JetKinematicHistos.h:54
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
JetKinematicHistos::m_m_high
TH1F * m_m_high
Definition: JetKinematicHistos.h:50
JetKinematicHistos::m_nConstit_high
TH1F * m_nConstit_high
Definition: JetKinematicHistos.h:52
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
xAOD::Jet_v1::numConstituents
size_t numConstituents() const
Number of constituents in this jets (this is valid even when reading a file where the constituents ha...
Definition: Jet_v1.cxx:153
JetKinematicHistos::m_doNConstit
bool m_doNConstit
Definition: JetKinematicHistos.h:66
JetKinematicHistos.h
HistoGroupBase::m_vBookedHistograms
std::vector< HistData > m_vBookedHistograms
The list of histos in this group.
Definition: HistoGroupBase.h:90
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
JetKinematicHistos::m_njet
TH1F * m_njet
Definition: JetKinematicHistos.h:37
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.