Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DerivationFramework::ZeeVertexRefittingTool Class Reference

#include <ZeeVertexRefittingTool.h>

Inheritance diagram for DerivationFramework::ZeeVertexRefittingTool:
Collaboration diagram for DerivationFramework::ZeeVertexRefittingTool:

Public Member Functions

 ZeeVertexRefittingTool (const std::string &t, const std::string &n, const IInterface *p)
 
StatusCode initialize () override
 
StatusCode finalize () override
 
StatusCode addBranches () const override
 

Private Member Functions

StatusCode makeZeePairs (const xAOD::ElectronContainer *particles, std::vector< std::vector< unsigned int > > &ZeePairs) const
 

Private Attributes

std::string m_expression
 
float m_massCut
 
SG::ReadHandleKey< xAOD::VertexContainerm_primaryVertexKey {this, "PVContainerName", "PrimaryVertices", "" }
 
SG::ReadHandleKey< xAOD::ElectronContainerm_electronKey { this, "ElectronContainerName", "Electrons", "" }
 
SG::WriteHandleKey< xAOD::VertexContainerm_refitpvKey {this, "RefittedPVContainerName", "HggPrimaryVertices", "" }
 
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
 
std::vector< unsigned int > m_MCSamples
 
ToolHandle< Analysis::PrimaryVertexRefitterm_pvrefitter {this, "PrimaryVertexRefitterTool", "Analysis::PrimaryVertexRefitter"}
 

Detailed Description

Definition at line 36 of file ZeeVertexRefittingTool.h.

Constructor & Destructor Documentation

◆ ZeeVertexRefittingTool()

DerivationFramework::ZeeVertexRefittingTool::ZeeVertexRefittingTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 31 of file ZeeVertexRefittingTool.cxx.

33  :
34  base_class(t, n, p),
35  m_expression("true"),
36  m_massCut(0.0)
37  {
38  declareProperty("ObjectRequirements", m_expression);
39  declareProperty("LowMassCut", m_massCut);
40  declareProperty("MCSamples",m_MCSamples);
41  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::ZeeVertexRefittingTool::addBranches ( ) const
override

Definition at line 71 of file ZeeVertexRefittingTool.cxx.

72  {
73  // skip mc samples not included in the MCSamples list
75 
77  bool skipSample = true;
78  for (auto mcid : m_MCSamples) {
79  if (mcid==eventInfo->mcChannelNumber()) {
80  skipSample = false;
81  break;
82  }
83  }
84  if (skipSample) return StatusCode::SUCCESS;
85  }
86 
87  // check that container we want to write in SG does not yet exist
88  if (evtStore()->contains<xAOD::VertexContainer>(m_refitpvKey.key())) {
89  ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_refitpvKey.key() << " which already exists. Please use a different key");
90  return StatusCode::FAILURE;
91  }
92 
93 
95 
96  xAOD::VertexContainer* refittedPVContainer = new xAOD::VertexContainer;
97  xAOD::VertexAuxContainer* refittedPVAuxContainer = new xAOD::VertexAuxContainer;
98  refittedPVContainer->setStore( refittedPVAuxContainer );
99 
101  ATH_CHECK(vertexContainer.recordNonConst(std::unique_ptr< xAOD::VertexContainer >(refittedPVContainer),
102  std::unique_ptr< xAOD::VertexAuxContainer >(refittedPVAuxContainer)));
103 
104  const xAOD::Vertex* pv = nullptr;
105  for ( const auto *v : *pv_cont ) {
106  if (v->vertexType()==xAOD::VxType::PriVtx) {
107  pv = v;
108  break;
109  }
110  }
111  if (!pv) {
112  return StatusCode::SUCCESS;
113  }
114  ATH_MSG_DEBUG("Found PV");
115 
116  // retrieve particle collections
118 
119  // create the vector which will hold the Zee pairs
120  std::vector< std::vector<unsigned int> > eepairs;
121  CHECK( makeZeePairs( &*electrons, eepairs ) );
122 
123  ATH_MSG_DEBUG("ee pairs found: " << eepairs.size());
124 
125  for (auto pair : eepairs) {
126  std::vector<const xAOD::TrackParticle*> tps = {
129  };
130 
131  TLorentzVector v0, v1, egamVec;
132  if(electrons->at(pair[0])->caloCluster())
133  {
134  v0.SetPtEtaPhiM(electrons->at(pair[0])->e()/cosh(electrons->at(pair[0])->caloCluster()->etaBE(2)),
135  electrons->at(pair[0])->caloCluster()->etaBE(2),
136  electrons->at(pair[0])->caloCluster()->phiBE(2),
137  0.0);
138  }
139 
140  if(electrons->at(pair[1])->caloCluster())
141  {
142  v1.SetPtEtaPhiM(electrons->at(pair[1])->e()/cosh(electrons->at(pair[1])->caloCluster()->etaBE(2)),
143  electrons->at(pair[1])->caloCluster()->etaBE(2),
144  electrons->at(pair[1])->caloCluster()->phiBE(2),
145  0.0);
146  }
147 
148  egamVec = v0+v1;
149 
150  ATH_MSG_DEBUG("Refitting PV for e tracks: " << tps[0] << " " << tps[1]);
151  xAOD::Vertex* pv_ref = m_pvrefitter->refitVertex(pv,tps);
152  if (pv_ref) {
153  refittedPVContainer->push_back(pv_ref);
154 
155  int ipv = 0;
156  for (const xAOD::Vertex* v : *pv_cont) {
157  xAOD::Vertex * nv = new xAOD::Vertex();
158  nv->makePrivateStore(v);
159  if(ipv !=0 ) refittedPVContainer->push_back(nv);
160  ipv++;
161  }
162 
163  for ( xAOD::Vertex *v : *refittedPVContainer )
164  {
165  float vert_sumpt = (log10(xAOD::PVHelpers::getVertexSumPt(v)));
166  float vert_sumpt2 = (log10(xAOD::PVHelpers::getVertexSumPt(v,2, false)));
167 
168  TLorentzVector vtxmom = xAOD::PVHelpers::getVertexMomentum(v, true, "");
169  float vert_dphi = (fabs(vtxmom.DeltaPhi(egamVec)));
170  //fill vertex variables
171  vertices_sumPt(*v) = vert_sumpt;
172  vertices_sumPt2(*v) = vert_sumpt2;
173  vertices_dPhi(*v) = vert_dphi;
174  }
175 
176 
177  ATH_MSG_DEBUG("refitted PV nTP: " << pv_ref->nTrackParticles() << " -- " << pv->nTrackParticles());
178  ATH_MSG_DEBUG("refitted PV z: " << pv_ref->z() << " -- " << pv->z());
179 
180  if (pv_ref->nTrackParticles() < pv->nTrackParticles()) {
181  sumPt2(*pv_ref) = xAOD::PVHelpers::getVertexSumPt(pv_ref, 2, false);
182  //set links to electrons, used only for matching, not for vertexing
183  std::vector<ElementLink<xAOD::TrackParticleContainer> > electronTrackLinks = {
184  electrons->at(pair[0])->trackParticleLink(),
185  electrons->at(pair[1])->trackParticleLink()
186  };
187  electronTrackLinksDecor(*pv_ref) = electronTrackLinks;
188  } else {
189  ATH_MSG_DEBUG("Electrons from pair not used in the refitting ");
190  }
191  }
192  else {
193  ATH_MSG_DEBUG("refitting failed");
194  }
195  }
196 
197  ATH_MSG_DEBUG("Vertex container size: " << refittedPVContainer->size());
198 
199  return StatusCode::SUCCESS;
200  }

◆ finalize()

StatusCode DerivationFramework::ZeeVertexRefittingTool::finalize ( )
override

Definition at line 65 of file ZeeVertexRefittingTool.cxx.

66  {
67  ATH_CHECK( finalizeParser() );
68  return StatusCode::SUCCESS;
69  }

◆ initialize()

StatusCode DerivationFramework::ZeeVertexRefittingTool::initialize ( )
override

Definition at line 43 of file ZeeVertexRefittingTool.cxx.

44  {
45 
46  CHECK( m_pvrefitter.retrieve() );
47 
48  if (!m_expression.empty()) {
49  ATH_CHECK(initializeParser(m_expression));
50  } else {
51  ATH_CHECK(initializeParser("true"));
52  }
54  ATH_CHECK( m_primaryVertexKey.initialize() );
56  ATH_CHECK( m_refitpvKey.initialize() );
57  if (m_refitpvKey.key().empty()) {
58  ATH_MSG_ERROR("No SG name provided for the output of ZeeVertexRefittingTool!");
59  return StatusCode::FAILURE;
60  }
61 
62  return StatusCode::SUCCESS;
63  }

◆ makeZeePairs()

StatusCode DerivationFramework::ZeeVertexRefittingTool::makeZeePairs ( const xAOD::ElectronContainer particles,
std::vector< std::vector< unsigned int > > &  ZeePairs 
) const
private

Definition at line 202 of file ZeeVertexRefittingTool.cxx.

203  {
204  if (particles->size()<2) return StatusCode::SUCCESS;
205 
206  // flags for the result of selection for each electron
207  std::vector<int> isSelected = m_parser->evaluateAsVector();
208  unsigned int nEntries = isSelected.size();
209 
210  // if there are no particles in one of the two lists to combine, just leave function
211  if (nEntries==0) return StatusCode::SUCCESS;
212 
213  // check the sizes are compatible
214  if (particles->size() != nEntries ) {
215  ATH_MSG_ERROR("Branch sizes incompatible - returning zero");
216  return StatusCode::FAILURE;
217  }
218 
219  // Double loop to get the opposite-charge pairs with m>50 GeV
220  for (unsigned int i=0; i<nEntries-1; ++i) {
221  if (isSelected[i]!=1) continue;
222  float qi = particles->at(i)->charge();
223 
224  for (unsigned int j=i+1; j<nEntries; ++j) {
225  if (isSelected[j]!=1) continue;
226  //std::vector<int> tmpPair; tmpPair.clear();
227  float qj = particles->at(j)->charge();
228  // opposite charge
229  if (qi*qj>=0) continue;
230 
231  //invariant mass
232  float mass = (particles->at(i)->p4()+particles->at(j)->p4()).M();
233  if (mass<m_massCut) continue;
234 
235  ZeePairs.push_back( {i, j} );
236  }
237  }
238  return StatusCode::SUCCESS;
239  }

Member Data Documentation

◆ m_electronKey

SG::ReadHandleKey<xAOD::ElectronContainer> DerivationFramework::ZeeVertexRefittingTool::m_electronKey { this, "ElectronContainerName", "Electrons", "" }
private

Definition at line 49 of file ZeeVertexRefittingTool.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::ZeeVertexRefittingTool::m_eventInfoKey { this, "EventInfoKey", "EventInfo", "" }
private

Definition at line 51 of file ZeeVertexRefittingTool.h.

◆ m_expression

std::string DerivationFramework::ZeeVertexRefittingTool::m_expression
private

Definition at line 45 of file ZeeVertexRefittingTool.h.

◆ m_massCut

float DerivationFramework::ZeeVertexRefittingTool::m_massCut
private

Definition at line 46 of file ZeeVertexRefittingTool.h.

◆ m_MCSamples

std::vector<unsigned int> DerivationFramework::ZeeVertexRefittingTool::m_MCSamples
private

Definition at line 53 of file ZeeVertexRefittingTool.h.

◆ m_primaryVertexKey

SG::ReadHandleKey<xAOD::VertexContainer> DerivationFramework::ZeeVertexRefittingTool::m_primaryVertexKey {this, "PVContainerName", "PrimaryVertices", "" }
private

Definition at line 48 of file ZeeVertexRefittingTool.h.

◆ m_pvrefitter

ToolHandle< Analysis::PrimaryVertexRefitter > DerivationFramework::ZeeVertexRefittingTool::m_pvrefitter {this, "PrimaryVertexRefitterTool", "Analysis::PrimaryVertexRefitter"}
private

Definition at line 55 of file ZeeVertexRefittingTool.h.

◆ m_refitpvKey

SG::WriteHandleKey<xAOD::VertexContainer> DerivationFramework::ZeeVertexRefittingTool::m_refitpvKey {this, "RefittedPVContainerName", "HggPrimaryVertices", "" }
private

Definition at line 50 of file ZeeVertexRefittingTool.h.


The documentation for this class was generated from the following files:
xAOD::PVHelpers::getVertexSumPt
float getVertexSumPt(const xAOD::Vertex *vertex, int power=1, bool useAux=true)
Loop over track particles associated with vertex and return scalar sum of pT^power in GeV (from auxda...
Definition: PhotonVertexHelpers.cxx:214
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition: VertexContainer.h:14
DerivationFramework::ZeeVertexRefittingTool::m_refitpvKey
SG::WriteHandleKey< xAOD::VertexContainer > m_refitpvKey
Definition: ZeeVertexRefittingTool.h:50
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::ZeeVertexRefittingTool::m_pvrefitter
ToolHandle< Analysis::PrimaryVertexRefitter > m_pvrefitter
Definition: ZeeVertexRefittingTool.h:55
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::ZeeVertexRefittingTool::m_massCut
float m_massCut
Definition: ZeeVertexRefittingTool.h:46
xAOD::VertexAuxContainer
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
Definition: VertexAuxContainer.h:19
parseMapping.v0
def v0
Definition: parseMapping.py:149
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::ZeeVertexRefittingTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZeeVertexRefittingTool.h:51
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
DerivationFramework::ZeeVertexRefittingTool::m_primaryVertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexKey
Definition: ZeeVertexRefittingTool.h:48
DerivationFramework::ZeeVertexRefittingTool::m_electronKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronKey
Definition: ZeeVertexRefittingTool.h:49
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::Vertex_v1::z
float z() const
Returns the z position.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::PVHelpers::getVertexMomentum
TLorentzVector getVertexMomentum(const xAOD::Vertex *vertex, bool useAux=true, const std::string &derivationPrefix="")
Return vector sum of tracks associated with vertex (from auxdata if available and useAux = true)
Definition: PhotonVertexHelpers.cxx:174
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
columnar::ContainerId::eventInfo
@ eventInfo
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
python.changerun.pv
pv
Definition: changerun.py:81
xAOD::EgammaHelpers::getOriginalTrackParticle
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
Definition: ElectronxAODHelpers.cxx:11
DerivationFramework::ZeeVertexRefittingTool::makeZeePairs
StatusCode makeZeePairs(const xAOD::ElectronContainer *particles, std::vector< std::vector< unsigned int > > &ZeePairs) const
Definition: ZeeVertexRefittingTool.cxx:202
DerivationFramework::ZeeVertexRefittingTool::m_MCSamples
std::vector< unsigned int > m_MCSamples
Definition: ZeeVertexRefittingTool.h:53
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::ZeeVertexRefittingTool::m_expression
std::string m_expression
Definition: ZeeVertexRefittingTool.h:45
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17