ATLAS Offline Software
PhotonAssociation.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 PhotonAssociation( *this );
18  }
19 
21  {
22  //get photon 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 Photon* the_photon,
34  double weight)
35  {
36  double newWeight = weight;
37  // photon already in collection
38  if ( this->contains(the_photon) )
39  {
40  // update weight
41  newWeight *= this->getPhotonWeight(the_photon);
42  // remove the previous photon
43  this->remove(the_photon);
44  }
45 
46  // from Navigable base
47  this->putElement(theContainer,the_photon,newWeight);
48  }
49 
51  const index_type& theIndex,
52  double weight)
53  {
54  double newWeight = weight;
55  // photon already in collection
56  if ( this->contains(theContainer,theIndex) )
57  {
58  // update weight
59  newWeight *= this->getPhotonWeight(theContainer,theIndex);
60  // remove the previous photon
61  this->remove(theContainer,theIndex);
62  }
63 
64  // from Navigable base
65  this->putElement(theContainer,theIndex,newWeight);
66  }
67 
68  double PhotonAssociation::getPhotonWeight(const Photon* the_photon) const
69  {
70  // from Navigable
71  return (this->contains(the_photon) )
72  ? this->getParameter(the_photon)
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
Navigable< PhotonContainer, double >::getConstituentPtr
virtual const constituent_type * getConstituentPtr(constituent_iter iter) const
Navigable< PhotonContainer, double >::putElement
void putElement(const PhotonContainer *objectContainer, const constituent_type *constituentObject, const double &objectParameter=double(), size_t sizeHint=0)
Analysis::PhotonAssociation::clone
virtual JetAssociationBase * clone() const
a clone method for the proper workings of the copy constructor
Definition: PhotonAssociation.cxx:15
Navigable< PhotonContainer, double >::begin
virtual object_iter begin() const
Analysis::Photon
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/Photon.h:20
PhotonAssociation.h
Navigable< PhotonContainer, double >::contains
bool contains(const constituent_type *aConstituent) const
PhotonContainer
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/PhotonContainer.h:30
JetAssociationBase::setName
void setName(const name_t &name)
Definition: JetAssociationBase.cxx:15
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
Navigable< PhotonContainer, double >::getConstituents
const constituent_coll & getConstituents() const
Definition: Navigable.h:290
Analysis::PhotonAssociation::index_type
Navigable< PhotonContainer, double >::external_index_type index_type
Definition: PhotonAssociation.h:29
Navigable< PhotonContainer, double >::remove
bool remove(const constituent_type *aConstituent)
Analysis::PhotonAssociation::getPhotonWeight
double getPhotonWeight(const Photon *the_photon) const
Definition: PhotonAssociation.cxx:68
Analysis::PhotonAssociation::set_photon
void set_photon(const PhotonContainer *theContainer, const Photon *the_photon, double weight=1)
Definition: PhotonAssociation.cxx:32
JetAssociationBase
Definition: JetAssociationBase.h:21
Analysis::PhotonAssociation::PhotonAssociation
PhotonAssociation()=default
constructor
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
Analysis::PhotonAssociation::photon
const Photon * photon() const
get photon directly without token
Definition: PhotonAssociation.cxx:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Navigable< PhotonContainer, double >::getParameter
double getParameter(const constituent_type *aConstituent) const
Navigable< PhotonContainer, double >::size
virtual unsigned int size() const