ATLAS Offline Software
Loading...
Searching...
No Matches
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 :
135 return JetHistoBase::fillHistosFromContainer(cont, weight);
136}
137
138
140
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 );
157 if(m_doNConstit) m_nConstit_high->Fill( j.numConstituents(), 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
Helper class to provide constant type-safe access to aux data.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
std::vector< HistData > m_vBookedHistograms
The list of histos in this group.
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...
JetHistoBase(const std::string &t)
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
JetKinematicHistos(const std::string &t)
virtual int fillHistosFromJet(const xAOD::Jet &j, float weight)
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
TProfile2D * m_averageE_EtaPhi
TProfile2D * m_averagePtEtaPhi
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
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
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition Jet_v1.cxx:76
std::vector< std::string > tags
Definition hcg.cxx:105
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17