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