ATLAS Offline Software
JetSubStructureHistos.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "TString.h"
7 #include <map>
8 
9 #define toGeV 1/1000.
10 
12  ,m_jetScale("JetAssignedScaleMomentum")
13 {
14  declareProperty("JetScale", m_jetScale);
15 }
16 
18 
19  // -------------- Modify histo names/titles --------
20  // if we're plotting a defined scale, modify the Histo titles and names
21 
22  std::map<std::string, std::string> scale2str( {
23  { "JetEMScaleMomentum" , "EMScale" } ,
24  { "JetConstitScaleMomentum" , "ConstitScale" } } );
25  TString scaleTag = scale2str[ m_jetScale ] ; // defaults to ""
26 
27  TString prefixn = scaleTag;
28  if(prefixn != "") prefixn +="_";
29  // --------------
30 
31  // Build and register the histos in this group :
32  TH1::AddDirectory(kFALSE); // Turn off automatic addition to gDirectory to avoid Warnings. Histos are anyway placed in their own dir later.
33  m_tau21 = bookHisto( new TH1F(prefixn+"Tau21" , "Jet Tau21 ;Entries", 100, 0, 1) );
34  m_tau32 = bookHisto( new TH1F(prefixn+"Tau32" , "Jet Tau32 ;Entries", 100, 0, 1) );
35  m_tau21_wta = bookHisto( new TH1F(prefixn+"Tau21_wta" , "Jet Tau21_wta ;Entries", 100, 0, 1) );
36  m_tau32_wta = bookHisto( new TH1F(prefixn+"Tau32_wta" , "Jet Tau32_wta ;Entries", 100, 0, 1) );
37  m_C1 = bookHisto( new TH1F(prefixn+"C1" , "Jet C1;Entries", 100, -1, 1) );
38  m_C2 = bookHisto( new TH1F(prefixn+"C2" , "Jet C2;Entries", 100, -1, 1) );
39  m_D2 = bookHisto( new TH1F(prefixn+"D2" , "Jet D2;Entries", 100, 0, 10) );
40 
41 
42 
43  TH1::AddDirectory(kTRUE); // Turn on automatic addition to gDirectory in case others needs it.
44 
45  // -------------- Modify histo titles.
46  if(prefixn != "" ){
47 
48  // build a qualifier in the form "(EMScale, Leading Jet, ...)"
49  TString qualif = "(";
50  TString tags[] = { scaleTag};
51  for(const auto& t : tags ) { if(qualif != "(") qualif+=",";qualif += t; }
52  qualif += ")";
53  // reset all titles :
54  for(auto& hdata : m_vBookedHistograms ){
55  TString t = hdata.hist->GetTitle(); t+=" "+qualif;
56  hdata.hist->SetTitle(t );
57  }
58  }
59 
60 
61  return 0;
62 }
63 
64 
65 
67  //For definitions see JetSubStructureMomentTools
68 
69  static const SG::ConstAccessor<float> Tau1Acc("Tau1");
70  static const SG::ConstAccessor<float> Tau2Acc("Tau2");
71  static const SG::ConstAccessor<float> Tau3Acc("Tau3");
72  static const SG::ConstAccessor<float> Tau1_wtaAcc("Tau1_wta");
73  static const SG::ConstAccessor<float> Tau2_wtaAcc("Tau2_wta");
74  static const SG::ConstAccessor<float> Tau3_wtaAcc("Tau3_wta");
75  static const SG::ConstAccessor<float> ECF1Acc("ECF1");
76  static const SG::ConstAccessor<float> ECF2Acc("ECF2");
77  static const SG::ConstAccessor<float> ECF3Acc("ECF3");
78  if( Tau1Acc.isAvailable(j) && Tau2Acc.isAvailable(j) && Tau3Acc.isAvailable(j)){
79  if( Tau1Acc(j) > 1e-8 ) m_tau21->Fill( Tau2Acc(j) / Tau1Acc(j), weight );
80  if( Tau2Acc(j) > 1e-8 ) m_tau32->Fill( Tau3Acc(j) / Tau2Acc(j), weight );
81  }
82  if( Tau1_wtaAcc.isAvailable(j) && Tau2_wtaAcc(j) && Tau3_wtaAcc(j)){
83  if( Tau1_wtaAcc(j) > 1e-8 ) m_tau21_wta->Fill( Tau2_wtaAcc(j) / Tau1_wtaAcc(j), weight );
84  if( Tau2_wtaAcc(j) > 1e-8 ) m_tau32_wta->Fill( Tau3_wtaAcc(j) / Tau2_wtaAcc(j), weight );
85  }
86  if( ECF1Acc.isAvailable(j) && ECF2Acc.isAvailable(j) && ECF3Acc.isAvailable(j)){
87  if( ECF1Acc(j) > 1e-8 ) m_C1->Fill( ECF2Acc(j) / pow( ECF1Acc(j), 2.0), weight );
88  if( ECF2Acc(j) > 1e-8 ) {
89  m_C2->Fill( ( ECF3Acc(j) * ECF1Acc(j) ) / pow( ECF2Acc(j), 2.0), weight );
90  m_D2->Fill( ( ECF3Acc(j) * pow( ECF1Acc(j), 3.0 ) ) / pow( ECF2Acc(j), 3.0), weight );
91  }
92  }
93 
94  return 0;
95 }
96 
JetSubStructureHistos::m_D2
TH1F * m_D2
Definition: JetSubStructureHistos.h:40
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
JetSubStructureHistos.h
JetSubStructureHistos::JetSubStructureHistos
JetSubStructureHistos(const std::string &t)
Definition: JetSubStructureHistos.cxx:11
JetSubStructureHistos::m_jetScale
std::string m_jetScale
Definition: JetSubStructureHistos.h:42
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JetSubStructureHistos::buildHistos
virtual int buildHistos()
Definition: JetSubStructureHistos.cxx:17
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
JetSubStructureHistos::fillHistosFromJet
virtual int fillHistosFromJet(const xAOD::Jet &j, float weight)
Definition: JetSubStructureHistos.cxx:66
SG::ConstAccessor< float >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
JetSubStructureHistos::m_tau21_wta
TH1F * m_tau21_wta
Definition: JetSubStructureHistos.h:35
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
JetHistoBase
Definition: JetHistoBase.h:27
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
JetSubStructureHistos::m_tau21
TH1F * m_tau21
Definition: JetSubStructureHistos.h:33
JetSubStructureHistos::m_tau32
TH1F * m_tau32
Definition: JetSubStructureHistos.h:34
JetSubStructureHistos::m_tau32_wta
TH1F * m_tau32_wta
Definition: JetSubStructureHistos.h:36
JetSubStructureHistos::m_C1
TH1F * m_C1
Definition: JetSubStructureHistos.h:38
JetSubStructureHistos::m_C2
TH1F * m_C2
Definition: JetSubStructureHistos.h:39
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
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
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
HistoGroupBase::m_vBookedHistograms
std::vector< HistData > m_vBookedHistograms
The list of histos in this group.
Definition: HistoGroupBase.h:90