ATLAS Offline Software
ElectronAssociation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
8 namespace Analysis
9 {
11  {
12  this->setName(name);
13  }
14 
16  {
17  return new ElectronAssociation( *this );
18  }
19 
21  {
22  //get electron from Navigable
23  if (this->size() ==0)
24  return nullptr;
25  if (this->size() > 1)
26  return nullptr;
27  // this shouldn't happen
28  else
29  return getConstituentPtr((this->getConstituents()).begin());
30  }
31 
33  const Electron* the_electron,
34  double weight)
35  {
36  double newWeight = weight;
37  // electron already in collection
38  if ( this->contains(the_electron) )
39  {
40  // update weight
41  newWeight *= this->getElectronWeight(the_electron);
42  // remove the previous electron
43  this->remove(the_electron);
44  }
45 
46  // from Navigable base
47  this->putElement(theContainer,the_electron,newWeight);
48  }
49 
51  const index_type& theIndex,
52  double weight)
53  {
54  double newWeight = weight;
55  // electron already in collection
56  if ( this->contains(theContainer,theIndex) )
57  {
58  // update weight
59  newWeight *= this->getElectronWeight(theContainer,theIndex);
60  // remove the previous electron
61  this->remove(theContainer,theIndex);
62  }
63 
64  // from Navigable base
65  this->putElement(theContainer,theIndex,newWeight);
66  }
67 
68  double ElectronAssociation::getElectronWeight(const Electron* the_electron) const
69  {
70  // from Navigable
71  return (this->contains(the_electron) )
72  ? this->getParameter(the_electron)
73  : 0.;
74  }
75 
77  const index_type& theIndex) const
78  {
79  // from Navigable
80  return (this->contains(theContainer,theIndex))
81  ? this->getParameter(theContainer,theIndex)
82  : 0.;
83  }
84 }
JetAssociationBase::NameType
name_t NameType
Definition: JetAssociationBase.h:29
ElectronAssociation.h
Navigable< ElectronContainer, double >::getConstituentPtr
virtual const constituent_type * getConstituentPtr(constituent_iter iter) const
Navigable< ElectronContainer, double >::putElement
void putElement(const ElectronContainer *objectContainer, const constituent_type *constituentObject, const double &objectParameter=double(), size_t sizeHint=0)
Analysis::ElectronAssociation::getElectronWeight
double getElectronWeight(const Electron *the_electron) const
Definition: ElectronAssociation.cxx:68
Analysis::Electron
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/Electron.h:20
Navigable< ElectronContainer, double >::begin
virtual object_iter begin() const
Analysis::ElectronAssociation::electron
const Electron * electron() const
get electron directly without token
Definition: ElectronAssociation.cxx:20
Navigable< ElectronContainer, double >::contains
bool contains(const constituent_type *aConstituent) const
JetAssociationBase::setName
void setName(const name_t &name)
Definition: JetAssociationBase.cxx:15
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
Navigable< ElectronContainer, double >::getConstituents
const constituent_coll & getConstituents() const
Definition: Navigable.h:290
Analysis::ElectronAssociation::set_electron
void set_electron(const ElectronContainer *theContainer, const Electron *the_electron, double weight=1)
Definition: ElectronAssociation.cxx:32
Navigable< ElectronContainer, double >::remove
bool remove(const constituent_type *aConstituent)
JetAssociationBase
Definition: JetAssociationBase.h:21
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Analysis::ElectronAssociation::ElectronAssociation
ElectronAssociation()=default
constructor
Navigable< ElectronContainer, double >::getParameter
double getParameter(const constituent_type *aConstituent) const
Navigable< ElectronContainer, double >::size
virtual unsigned int size() const
ElectronContainer
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/ElectronContainer.h:32
Analysis::ElectronAssociation::clone
virtual JetAssociationBase * clone() const
a clone method for the proper workings of the copy constructor
Definition: ElectronAssociation.cxx:15
Analysis::ElectronAssociation::index_type
Navigable< ElectronContainer, double >::external_index_type index_type
Definition: ElectronAssociation.h:29