ATLAS Offline Software
FlowElement_LinkerPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <iostream>
11 #include "AthLinks/ElementLink.h"
12 
13 namespace PFO {
14 
15  FlowElement_LinkerPlots::FlowElement_LinkerPlots(PlotBase* pParent, std::string sDir, std::string sFEContainerName, bool doNeutralFE):
16  PlotBase(pParent, sDir),
17  m_sFEContainerName(sFEContainerName),
18  m_doNeutralFE(doNeutralFE)
19  {
20  m_CFE_tau_dR=nullptr;
21  m_CFE_tau_NMatchedTau=nullptr;
22 
23  m_NFE_tau_dR=nullptr;
24  m_NFE_tau_NMatchedTau=nullptr;
25 
26  m_CFE_muon_dR=nullptr;
30 
31  m_NFE_muon_dR=nullptr;
33 
34  m_CFE_photon_dR=nullptr;
36 
37  m_NFE_photon_dR=nullptr;
39 
40  m_CFE_electron_dR=nullptr;
42 
43  m_NFE_electron_dR=nullptr;
45 
46 
47  }
48 
50  // init only the histograms we're going to use (m_doNeutralFE is the switch)
51  //tau
52  if(m_sFEContainerName==""){ // skip init if container not used.
53  return;
54  }
55  if(!m_doNeutralFE){
56  m_CFE_tau_dR=Book1D("_CFE_tau_dR",m_sFEContainerName+"_CFE_tau_dR",10,0,1);
57  m_CFE_tau_NMatchedTau=Book1D("_CFE_tau_NMatchedTau",m_sFEContainerName+"_CFE_tau_NMatchedTau",5,0,5);
58  }
59  else{
60  m_NFE_tau_dR=Book1D("_NFE_tau_dR",m_sFEContainerName+"_NFE_tau_dR",10,0,1);
61  m_NFE_tau_NMatchedTau=Book1D("_NFE_tau_NMatchedTau",m_sFEContainerName+"_NFE_tau_NMatchedTau",5,0,5);
62  }
63  //electron
64  if(!m_doNeutralFE){
65  m_CFE_electron_dR=Book1D("_CFE_electron_dR",m_sFEContainerName+"_CFE_electron_dR",15,0,1.5);
66  m_CFE_electron_NMatchedElectron=Book1D("_CFE_electron_NMatchedElectron",m_sFEContainerName+"_CFE_electron_NMatchedElectron",10,0,10);
67  }
68  else{
69  m_NFE_electron_dR=Book1D("_NFE_electron_dR",m_sFEContainerName+"_NFE_electron_dR",10,0,1);
70  m_NFE_electron_NMatchedElectron=Book1D("_NFE_electron_NMatchedElectron",m_sFEContainerName+"_NFE_electron_NMatchedElectron",5,0,5);
71  }
72  //muon
73  if(!m_doNeutralFE){
74  m_CFE_muon_dR=Book1D("_CFE_muon_dR",m_sFEContainerName+"_CFE_muon_dR",10,0,1);
75  m_CFE_muon_NMatchedMuon=Book1D("_CFE_muon_NMatchedMuon",m_sFEContainerName+"_CFE_muon_NMatchedMuon",5,0,5);
76  m_CFE_muon_largeDR_debug_author=Book1D("_CFE_muon_largeDR_debug_author",m_sFEContainerName+"_CFE_muon_largeDR_debug_author",20,0,20);
77  m_CFE_muon_largeDR_debug_type=Book1D("_CFE_muon_largeDR_debug_type",m_sFEContainerName+"_CFE_muon_largeDR_debug_type",20,0,20);
78  }
79  else{
80  m_NFE_muon_dR=Book1D("_NFE_muon_dR",m_sFEContainerName+"_NFE_muon_dR",10,0,1);
81  m_NFE_muon_NMatchedMuon=Book1D("_NFE_muon_NMatchedMuon",m_sFEContainerName+"_NFE_muon_NMatchedMuon",10,0,10);
82  }
83  //photon
84  if(!m_doNeutralFE){
85  m_CFE_photon_dR=Book1D("_CFE_photon_dR",m_sFEContainerName+"_CFE_photon_dR",10,0,1);
86  m_CFE_photon_NMatchedPhoton=Book1D("_CFE_photon_NMatchedPhoton",m_sFEContainerName+"_CFE_photon_NMatchedPhoton",5,0,5);
87  }
88  else{
89  m_NFE_photon_dR=Book1D("_NFE_photon_dR",m_sFEContainerName+"_NFE_photon_dR",10,0,1);
90  m_NFE_photon_NMatchedPhoton=Book1D("_NFE_photon_NMatchedPhoton",m_sFEContainerName+"_NFE_photon_NMatchedPhoton",5,0,5);
91  }
92  }
94  // methods work for both CFE and NFE since the auxvars are named the same
99 
100  TLorentzVector FE_fourvec=FE.p4();
101  // Muon block
102  if(acc_muon_FE_Link.isAvailable(FE)){
103  std::vector< ElementLink < xAOD::MuonContainer > > MuonLinks=acc_muon_FE_Link(FE);
104  int nMuons_per_FE=MuonLinks.size();
105  if(nMuons_per_FE>0){ // skip cases w/o match
106  if(m_doNeutralFE)
107  m_NFE_muon_NMatchedMuon->Fill(nMuons_per_FE,eventInfo.beamSpotWeight());
108  else
109  m_CFE_muon_NMatchedMuon->Fill(nMuons_per_FE,eventInfo.beamSpotWeight());
110  }
111 
113 
114  //get Muon from link by de-referencing it
115  if (!MuonLink.isValid()){
116  std::cerr << "FlowElement_LinkerPlots encountered an invalid muon element link. Skipping. "<<std::endl;
117  continue;
118  }
119  const xAOD::Muon* muon = *MuonLink;
120  TLorentzVector muon_fourvec=muon->p4();
121  double deltaR=muon_fourvec.DeltaR(FE_fourvec);
122  if(muon->muonType()==4) // skip forward muons, as have tracklets which mis-link to FE.
123  continue;
124  if(m_doNeutralFE)
125  m_NFE_muon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
126  else{
127  m_CFE_muon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
128  if(deltaR>1){// should never happen, but catch for extreme cases
129  int auth=muon->author();
130  int type=muon->muonType();
133  }
134  }// end of CFE fill block for muon_dR code
135  }
136  }// end of muon acc block
137 
138  // Electron block
139  if(acc_electron_FE_Link.isAvailable(FE)){
140  std::vector< ElementLink < xAOD::ElectronContainer > > ElectronLinks=acc_electron_FE_Link(FE);
141  int nElectrons_per_FE=ElectronLinks.size();
142  if(nElectrons_per_FE>0){ // skip cases w/o match
143  if(m_doNeutralFE)
144  m_NFE_electron_NMatchedElectron->Fill(nElectrons_per_FE,eventInfo.beamSpotWeight());
145  else
146  m_CFE_electron_NMatchedElectron->Fill(nElectrons_per_FE,eventInfo.beamSpotWeight());
147  }
148 
150  //get Electron from link by de-referencing it
151  if (!ElectronLink.isValid()){
152  std::cerr << "FlowElement_LinkerPlots encountered an invalid electron element link. Skipping. "<<std::endl;
153  continue;
154  }
156  TLorentzVector electron_fourvec=electron->p4();
157  double deltaR=electron_fourvec.DeltaR(FE_fourvec);
158  if(m_doNeutralFE)
160  else
162  }
163  }// end of electron acc block
164 
165  // Photon block
166  if(acc_photon_FE_Link.isAvailable(FE)){
167  std::vector< ElementLink < xAOD::PhotonContainer > > PhotonLinks=acc_photon_FE_Link(FE);
168  int nPhotons_per_FE=PhotonLinks.size();
169  if(nPhotons_per_FE>0){ // skip cases w/o match
170  if(m_doNeutralFE)
171  m_NFE_photon_NMatchedPhoton->Fill(nPhotons_per_FE,eventInfo.beamSpotWeight());
172  else
173  m_CFE_photon_NMatchedPhoton->Fill(nPhotons_per_FE,eventInfo.beamSpotWeight());
174  }
175 
176  for (ElementLink<xAOD::PhotonContainer> PhotonLink: PhotonLinks){
177  //get Photon from link by de-referencing it
178  if (!PhotonLink.isValid()){
179  std::cerr << "FlowElement_LinkerPlots encountered an invalid photon element link. Skipping. "<<std::endl;
180  continue;
181  }
182  const xAOD::Photon* photon = *PhotonLink;
183  TLorentzVector photon_fourvec=photon->p4();
184  double deltaR=photon_fourvec.DeltaR(FE_fourvec);
185  if(m_doNeutralFE)
187  else
188  m_CFE_photon_dR->Fill(deltaR,eventInfo.beamSpotWeight());
189  }
190  }// end of photon acc block
191 
192  // Taujet block
193  if(acc_tau_FE_Link.isAvailable(FE)){
194  std::vector< ElementLink < xAOD::TauJetContainer > > TaujetLinks=acc_tau_FE_Link(FE);
195  int nTaujets_per_FE=TaujetLinks.size();
196  if(nTaujets_per_FE>0){ // skip cases w/o match
197  if(m_doNeutralFE)
198  m_NFE_tau_NMatchedTau->Fill(nTaujets_per_FE,eventInfo.beamSpotWeight());
199  else
200  m_CFE_tau_NMatchedTau->Fill(nTaujets_per_FE,eventInfo.beamSpotWeight());
201  }
202 
203  TLorentzVector FE_fourvec=FE.p4();
204  for (ElementLink<xAOD::TauJetContainer> TaujetLink: TaujetLinks){
205  //get Taujet from link by de-referencing it
206  if (!TaujetLink.isValid()){
207  std::cerr << "FlowElement_LinkerPlots encountered an invalid tau jet element link. Skipping. "<<std::endl;
208  continue;
209  }
210  const xAOD::TauJet* taujet = *TaujetLink;
211  TLorentzVector taujet_fourvec=taujet->p4();
212  double deltaR=taujet_fourvec.DeltaR(FE_fourvec);
213  if(m_doNeutralFE)
214  m_NFE_tau_dR->Fill(deltaR,eventInfo.beamSpotWeight());
215  else
216  m_CFE_tau_dR->Fill(deltaR,eventInfo.beamSpotWeight());
217  }
218  }// end of taujet acc block
219  } // end of fill statement
220 } // 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:41
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:35
PFO::FlowElement_LinkerPlots::m_NFE_muon_NMatchedMuon
TH1 * m_NFE_muon_NMatchedMuon
Definition: FlowElement_LinkerPlots.h:38
PFO::FlowElement_LinkerPlots::m_NFE_tau_NMatchedTau
TH1 * m_NFE_tau_NMatchedTau
Definition: FlowElement_LinkerPlots.h:30
PlotBase
Definition: PlotBase.h:34
PFO::FlowElement_LinkerPlots::m_doNeutralFE
bool m_doNeutralFE
Definition: FlowElement_LinkerPlots.h:54
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:34
PFO::FlowElement_LinkerPlots::m_NFE_electron_dR
TH1 * m_NFE_electron_dR
Definition: FlowElement_LinkerPlots.h:49
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:32
PFO::FlowElement_LinkerPlots::initializePlots
void initializePlots()
Definition: FlowElement_LinkerPlots.cxx:49
PFO::FlowElement_LinkerPlots::m_CFE_electron_dR
TH1 * m_CFE_electron_dR
Definition: FlowElement_LinkerPlots.h:46
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:27
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::FlowElement_LinkerPlots
FlowElement_LinkerPlots(PlotBase *pParent, std::string sDir, std::string sFEContainerName, bool doNeutralFE)
Definition: FlowElement_LinkerPlots.cxx:15
PFO::FlowElement_LinkerPlots::m_sFEContainerName
std::string m_sFEContainerName
Definition: FlowElement_LinkerPlots.h:53
PFO::FlowElement_LinkerPlots::fill
void fill(const xAOD::FlowElement &FE, const xAOD::EventInfo &eventInfo)
Definition: FlowElement_LinkerPlots.cxx:93
PFO::FlowElement_LinkerPlots::m_NFE_photon_dR
TH1 * m_NFE_photon_dR
Definition: FlowElement_LinkerPlots.h:43
ElectronContainer.h
PFO::FlowElement_LinkerPlots::m_CFE_photon_dR
TH1 * m_CFE_photon_dR
Definition: FlowElement_LinkerPlots.h:40
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:47
TauJetContainer.h
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
PFO::FlowElement_LinkerPlots::m_NFE_photon_NMatchedPhoton
TH1 * m_NFE_photon_NMatchedPhoton
Definition: FlowElement_LinkerPlots.h:44
PFO
Definition: ClusterMomentPlots.h:13
PFO::FlowElement_LinkerPlots::m_NFE_electron_NMatchedElectron
TH1 * m_NFE_electron_NMatchedElectron
Definition: FlowElement_LinkerPlots.h:50
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:37
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:33
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:29
PFO::FlowElement_LinkerPlots::m_CFE_tau_dR
TH1 * m_CFE_tau_dR
Definition: FlowElement_LinkerPlots.h:26
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25