ATLAS Offline Software
FlowElement_LinkerPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include "AthLinks/ElementLink.h"
11 
12 namespace PFO {
13 
14  FlowElement_LinkerPlots::FlowElement_LinkerPlots(PlotBase* pParent, const std::string & sDir, const std::string & sFEContainerName, bool doNeutralFE):
15  PlotBase(pParent, sDir),
16  m_sFEContainerName(sFEContainerName),
17  m_doNeutralFE(doNeutralFE)
18  {
19  }
20 
22  // init only the histograms we're going to use (m_doNeutralFE is the switch)
23  //tau
24  if(m_sFEContainerName==""){ // skip init if container not used.
25  return;
26  }
27  if(!m_doNeutralFE){
28  m_CFE_tau_dR=Book1D("_CFE_tau_dR",m_sFEContainerName+"_CFE_tau_dR",10,0,1);
29  m_CFE_tau_NMatchedTau=Book1D("_CFE_tau_NMatchedTau",m_sFEContainerName+"_CFE_tau_NMatchedTau",5,0,5);
30  }
31  else{
32  m_NFE_tau_dR=Book1D("_NFE_tau_dR",m_sFEContainerName+"_NFE_tau_dR",10,0,1);
33  m_NFE_tau_NMatchedTau=Book1D("_NFE_tau_NMatchedTau",m_sFEContainerName+"_NFE_tau_NMatchedTau",5,0,5);
34  }
35  //electron
36  if(!m_doNeutralFE){
37  m_CFE_electron_dR=Book1D("_CFE_electron_dR",m_sFEContainerName+"_CFE_electron_dR",15,0,1.5);
38  m_CFE_electron_NMatchedElectron=Book1D("_CFE_electron_NMatchedElectron",m_sFEContainerName+"_CFE_electron_NMatchedElectron",10,0,10);
39  }
40  else{
41  m_NFE_electron_dR=Book1D("_NFE_electron_dR",m_sFEContainerName+"_NFE_electron_dR",10,0,1);
42  m_NFE_electron_NMatchedElectron=Book1D("_NFE_electron_NMatchedElectron",m_sFEContainerName+"_NFE_electron_NMatchedElectron",5,0,5);
43  }
44  //muon
45  if(!m_doNeutralFE){
46  m_CFE_muon_dR=Book1D("_CFE_muon_dR",m_sFEContainerName+"_CFE_muon_dR",10,0,1);
47  m_CFE_muon_NMatchedMuon=Book1D("_CFE_muon_NMatchedMuon",m_sFEContainerName+"_CFE_muon_NMatchedMuon",5,0,5);
48  m_CFE_muon_largeDR_debug_author=Book1D("_CFE_muon_largeDR_debug_author",m_sFEContainerName+"_CFE_muon_largeDR_debug_author",20,0,20);
49  m_CFE_muon_largeDR_debug_type=Book1D("_CFE_muon_largeDR_debug_type",m_sFEContainerName+"_CFE_muon_largeDR_debug_type",20,0,20);
50  }
51  else{
52  m_NFE_muon_dR=Book1D("_NFE_muon_dR",m_sFEContainerName+"_NFE_muon_dR",10,0,1);
53  m_NFE_muon_NMatchedMuon=Book1D("_NFE_muon_NMatchedMuon",m_sFEContainerName+"_NFE_muon_NMatchedMuon",10,0,10);
54  }
55  //photon
56  if(!m_doNeutralFE){
57  m_CFE_photon_dR=Book1D("_CFE_photon_dR",m_sFEContainerName+"_CFE_photon_dR",10,0,1);
58  m_CFE_photon_NMatchedPhoton=Book1D("_CFE_photon_NMatchedPhoton",m_sFEContainerName+"_CFE_photon_NMatchedPhoton",5,0,5);
59  }
60  else{
61  m_NFE_photon_dR=Book1D("_NFE_photon_dR",m_sFEContainerName+"_NFE_photon_dR",10,0,1);
62  m_NFE_photon_NMatchedPhoton=Book1D("_NFE_photon_NMatchedPhoton",m_sFEContainerName+"_NFE_photon_NMatchedPhoton",5,0,5);
63  }
64  }
66  // methods work for both CFE and NFE since the auxvars are named the same
71 
72  TLorentzVector FE_fourvec=FE.p4();
73  // Muon block
74  if(acc_muon_FE_Link.isAvailable(FE)){
75  std::vector< ElementLink < xAOD::MuonContainer > > MuonLinks=acc_muon_FE_Link(FE);
76  int nMuons_per_FE=MuonLinks.size();
77  if(nMuons_per_FE>0){ // skip cases w/o match
78  if(m_doNeutralFE)
79  m_NFE_muon_NMatchedMuon->Fill(nMuons_per_FE,eventInfo.beamSpotWeight());
80  else
81  m_CFE_muon_NMatchedMuon->Fill(nMuons_per_FE,eventInfo.beamSpotWeight());
82  }
83 
85 
86  //get Muon from link by de-referencing it
87  if (!MuonLink.isValid()){
88  std::cerr << "FlowElement_LinkerPlots encountered an invalid muon element link. Skipping. "<<std::endl;
89  continue;
90  }
91  const xAOD::Muon* muon = *MuonLink;
92  TLorentzVector muon_fourvec=muon->p4();
93  double deltaR=muon_fourvec.DeltaR(FE_fourvec);
94  if(muon->muonType()==4) // skip forward muons, as have tracklets which mis-link to FE.
95  continue;
96  if(m_doNeutralFE)
97  m_NFE_muon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
98  else{
99  m_CFE_muon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
100  if(deltaR>1){// should never happen, but catch for extreme cases
101  int auth=muon->author();
102  int type=muon->muonType();
105  }
106  }// end of CFE fill block for muon_dR code
107  }
108  }// end of muon acc block
109 
110  // Electron block
111  if(acc_electron_FE_Link.isAvailable(FE)){
112  std::vector< ElementLink < xAOD::ElectronContainer > > ElectronLinks=acc_electron_FE_Link(FE);
113  int nElectrons_per_FE=ElectronLinks.size();
114  if(nElectrons_per_FE>0){ // skip cases w/o match
115  if(m_doNeutralFE)
116  m_NFE_electron_NMatchedElectron->Fill(nElectrons_per_FE,eventInfo.beamSpotWeight());
117  else
118  m_CFE_electron_NMatchedElectron->Fill(nElectrons_per_FE,eventInfo.beamSpotWeight());
119  }
120 
122  //get Electron from link by de-referencing it
123  if (!ElectronLink.isValid()){
124  std::cerr << "FlowElement_LinkerPlots encountered an invalid electron element link. Skipping. "<<std::endl;
125  continue;
126  }
128  TLorentzVector electron_fourvec=electron->p4();
129  double deltaR=electron_fourvec.DeltaR(FE_fourvec);
130  if(m_doNeutralFE)
131  m_NFE_electron_dR->Fill(deltaR,eventInfo.beamSpotWeight());
132  else
133  m_CFE_electron_dR->Fill(deltaR,eventInfo.beamSpotWeight());
134  }
135  }// end of electron acc block
136 
137  // Photon block
138  if(acc_photon_FE_Link.isAvailable(FE)){
139  std::vector< ElementLink < xAOD::PhotonContainer > > PhotonLinks=acc_photon_FE_Link(FE);
140  int nPhotons_per_FE=PhotonLinks.size();
141  if(nPhotons_per_FE>0){ // skip cases w/o match
142  if(m_doNeutralFE)
143  m_NFE_photon_NMatchedPhoton->Fill(nPhotons_per_FE,eventInfo.beamSpotWeight());
144  else
145  m_CFE_photon_NMatchedPhoton->Fill(nPhotons_per_FE,eventInfo.beamSpotWeight());
146  }
147 
148  for (ElementLink<xAOD::PhotonContainer> PhotonLink: PhotonLinks){
149  //get Photon from link by de-referencing it
150  if (!PhotonLink.isValid()){
151  std::cerr << "FlowElement_LinkerPlots encountered an invalid photon element link. Skipping. "<<std::endl;
152  continue;
153  }
154  const xAOD::Photon* photon = *PhotonLink;
155  TLorentzVector photon_fourvec=photon->p4();
156  double deltaR=photon_fourvec.DeltaR(FE_fourvec);
157  if(m_doNeutralFE)
158  m_NFE_photon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
159  else
160  m_CFE_photon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
161  }
162  }// end of photon acc block
163 
164  // Taujet block
165  if(acc_tau_FE_Link.isAvailable(FE)){
166  std::vector< ElementLink < xAOD::TauJetContainer > > TaujetLinks=acc_tau_FE_Link(FE);
167  int nTaujets_per_FE=TaujetLinks.size();
168  if(nTaujets_per_FE>0){ // skip cases w/o match
169  if(m_doNeutralFE)
170  m_NFE_tau_NMatchedTau->Fill(nTaujets_per_FE,eventInfo.beamSpotWeight());
171  else
172  m_CFE_tau_NMatchedTau->Fill(nTaujets_per_FE,eventInfo.beamSpotWeight());
173  }
174 
175  TLorentzVector FE_fourvec=FE.p4();
176  for (ElementLink<xAOD::TauJetContainer> TaujetLink: TaujetLinks){
177  //get Taujet from link by de-referencing it
178  if (!TaujetLink.isValid()){
179  std::cerr << "FlowElement_LinkerPlots encountered an invalid tau jet element link. Skipping. "<<std::endl;
180  continue;
181  }
182  const xAOD::TauJet* taujet = *TaujetLink;
183  TLorentzVector taujet_fourvec=taujet->p4();
184  double deltaR=taujet_fourvec.DeltaR(FE_fourvec);
185  if(m_doNeutralFE)
186  m_NFE_tau_dR->Fill(deltaR,eventInfo.beamSpotWeight());
187  else
188  m_CFE_tau_dR->Fill(deltaR,eventInfo.beamSpotWeight());
189  }
190  }// end of taujet acc block
191  } // end of fill statement
192 } // end of PFO namespace
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
PFO::FlowElement_LinkerPlots::m_CFE_photon_NMatchedPhoton
TH1 * m_CFE_photon_NMatchedPhoton
Definition: FlowElement_LinkerPlots.h:44
MuonLink
ElementLink< xAOD::MuonContainer > MuonLink
Definition: BPhysHelper.cxx:21
PFO::FlowElement_LinkerPlots::m_CFE_muon_largeDR_debug_type
TH1 * m_CFE_muon_largeDR_debug_type
Definition: FlowElement_LinkerPlots.h:38
PFO::FlowElement_LinkerPlots::m_NFE_muon_NMatchedMuon
TH1 * m_NFE_muon_NMatchedMuon
Definition: FlowElement_LinkerPlots.h:41
PFO::FlowElement_LinkerPlots::m_NFE_tau_NMatchedTau
TH1 * m_NFE_tau_NMatchedTau
Definition: FlowElement_LinkerPlots.h:33
PFO::FlowElement_LinkerPlots::FlowElement_LinkerPlots
FlowElement_LinkerPlots(PlotBase *pParent, const std::string &sDir, const std::string &sFEContainerName, bool doNeutralFE)
Definition: FlowElement_LinkerPlots.cxx:14
PlotBase
Definition: PlotBase.h:34
PFO::FlowElement_LinkerPlots::m_doNeutralFE
bool m_doNeutralFE
Definition: FlowElement_LinkerPlots.h:57
python.base_data.auth
auth
Definition: base_data.py:57
ElectronLink
ElementLink< xAOD::ElectronContainer > ElectronLink
Definition: BPhysHelper.cxx:23
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
PFO::FlowElement_LinkerPlots::m_CFE_muon_largeDR_debug_author
TH1 * m_CFE_muon_largeDR_debug_author
Definition: FlowElement_LinkerPlots.h:37
PFO::FlowElement_LinkerPlots::m_NFE_electron_dR
TH1 * m_NFE_electron_dR
Definition: FlowElement_LinkerPlots.h:52
FlowElement_LinkerPlots.h
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
PFO::FlowElement_LinkerPlots::m_CFE_muon_dR
TH1 * m_CFE_muon_dR
Definition: FlowElement_LinkerPlots.h:35
PFO::FlowElement_LinkerPlots::initializePlots
void initializePlots()
Definition: FlowElement_LinkerPlots.cxx:21
PFO::FlowElement_LinkerPlots::m_CFE_electron_dR
TH1 * m_CFE_electron_dR
Definition: FlowElement_LinkerPlots.h:49
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
PFO::FlowElement_LinkerPlots::m_CFE_tau_NMatchedTau
TH1 * m_CFE_tau_NMatchedTau
Definition: FlowElement_LinkerPlots.h:30
PlotBase::Book1D
TH1D * Book1D(const std::string &name, const std::string &labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition: PlotBase.cxx:94
PFO::FlowElement_LinkerPlots::m_sFEContainerName
std::string m_sFEContainerName
Definition: FlowElement_LinkerPlots.h:56
PFO::FlowElement_LinkerPlots::fill
void fill(const xAOD::FlowElement &FE, const xAOD::EventInfo &eventInfo)
Definition: FlowElement_LinkerPlots.cxx:65
PFO::FlowElement_LinkerPlots::m_NFE_photon_dR
TH1 * m_NFE_photon_dR
Definition: FlowElement_LinkerPlots.h:46
ElectronContainer.h
PFO::FlowElement_LinkerPlots::m_CFE_photon_dR
TH1 * m_CFE_photon_dR
Definition: FlowElement_LinkerPlots.h:43
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
PFO::FlowElement_LinkerPlots::m_CFE_electron_NMatchedElectron
TH1 * m_CFE_electron_NMatchedElectron
Definition: FlowElement_LinkerPlots.h:50
TauJetContainer.h
PFO::FlowElement_LinkerPlots::m_NFE_photon_NMatchedPhoton
TH1 * m_NFE_photon_NMatchedPhoton
Definition: FlowElement_LinkerPlots.h:47
PFO
Definition: ClusterMomentPlots.h:15
PFO::FlowElement_LinkerPlots::m_NFE_electron_NMatchedElectron
TH1 * m_NFE_electron_NMatchedElectron
Definition: FlowElement_LinkerPlots.h:53
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
MuonContainer.h
PFO::FlowElement_LinkerPlots::m_NFE_muon_dR
TH1 * m_NFE_muon_dR
Definition: FlowElement_LinkerPlots.h:40
xAOD::FlowElement_v1::p4
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Definition: FlowElement_v1.cxx:33
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
PFO::FlowElement_LinkerPlots::m_CFE_muon_NMatchedMuon
TH1 * m_CFE_muon_NMatchedMuon
Definition: FlowElement_LinkerPlots.h:36
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:97
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
PhotonContainer.h
xAOD::EventInfo_v1::beamSpotWeight
float beamSpotWeight() const
Weight for beam spot size reweighting.
Definition: EventInfo_v1.cxx:970
PFO::FlowElement_LinkerPlots::m_NFE_tau_dR
TH1 * m_NFE_tau_dR
Definition: FlowElement_LinkerPlots.h:32
PFO::FlowElement_LinkerPlots::m_CFE_tau_dR
TH1 * m_CFE_tau_dR
Definition: FlowElement_LinkerPlots.h:29
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25