ATLAS Offline Software
PFNeutralFlowElementCreatorAlgorithm.cxx
Go to the documentation of this file.
4 #include "xAODCore/ShallowCopy.h"
6 #include "xAODPFlow/FEHelpers.h"
7 
9 
12 
13  return StatusCode::SUCCESS;
14 }
15 
17 
18  ATH_MSG_DEBUG("Executing");
19 
20  /* Create Neutral PFOs from all eflowCaloObjects */
21  SG::ReadHandle<eflowCaloObjectContainer> eflowCaloObjectContainerReadHandle(
23 
24  // Always create at least one FlowElement container & aux
25  auto neutralFEContainer = std::make_unique<xAOD::FlowElementContainer>();
26  auto neutralFEContainerAux = std::make_unique<xAOD::FlowElementAuxContainer>();
27  neutralFEContainer->setStore(neutralFEContainerAux.get());
28 
29  ATH_MSG_DEBUG("Looping over eflowCaloObjects");
30  // Create FlowElements and fill the containers
31  for (const auto *thisEflowCaloObject : *eflowCaloObjectContainerReadHandle) {
32  if( createNeutralFlowElement(*thisEflowCaloObject, neutralFEContainer.get()).isFailure()) {
33  ATH_MSG_WARNING("Problem encountered while creating neutral FlowElements");
34  return StatusCode::SUCCESS;
35  }
36  }
37 
38  // Record the output containers
39  SG::WriteHandle<xAOD::FlowElementContainer> neutralFEContainerWriteHandle(
41  std::sort(neutralFEContainer->begin(),
42  neutralFEContainer->end(),
43  [](const xAOD::FlowElement* fe1, const xAOD::FlowElement* fe2) {
44  return fe1->pt() > fe2->pt();
45  });
46  ATH_CHECK(neutralFEContainerWriteHandle.record(
47  std::move(neutralFEContainer), std::move(neutralFEContainerAux)));
48 
49  return StatusCode::SUCCESS;
50 }
51 
54  const eflowCaloObject& energyFlowCaloObject,
55  xAOD::FlowElementContainer* neutralFEContainer) const
56 {
57 
58  for (unsigned int iCluster = 0; iCluster < energyFlowCaloObject.nClusters(); ++iCluster){
59  const eflowRecCluster* thisEfRecCluster = energyFlowCaloObject.efRecCluster(iCluster);
60 
61  /* Skip empty clusters (presumably subtraction remnants) */
62  const CaloClusterCellLink* theCellLink = energyFlowCaloObject.efRecCluster(iCluster)->getCluster()->getCellLinks();
64  CaloClusterCellLink::const_iterator it_e=theCellLink->end();
65  if (it == it_e) {
66  continue;
67  }
68  //this vetoes rare examples where only two cells are left, and they have equal and opposite energy
69  if (0.0 == energyFlowCaloObject.efRecCluster(iCluster)->getCluster()->e() ) continue;
70 
71  /* Create the FlowElement, add the cluster and set the four-momentum, charge and type */
72 
73  ATH_MSG_VERBOSE("Creating FlowElement");
74  xAOD::FlowElement* thisFE = new xAOD::FlowElement();
75  neutralFEContainer->push_back(thisFE);
76 
77  ATH_MSG_VERBOSE("Get original cluster link");
78 
79  //if we are using the CP data, we want to use the modified cluster link,
80  //given by getClusElementLink and not the non-modified cluster link
81  //given by getOriginalClusElementLink
82  ElementLink<xAOD::CaloClusterContainer> theOriginalClusterLink;
83  if (m_addCPData) theOriginalClusterLink = thisEfRecCluster->getClusElementLink();
84  else theOriginalClusterLink = thisEfRecCluster->getOriginalClusElementLink();
85 
86  ATH_MSG_VERBOSE("Cluster link valid? "<<theOriginalClusterLink.isValid()<<"");
87  ATH_MSG_VERBOSE("Get sister cluster link");
88  ElementLink<xAOD::CaloClusterContainer> theSisterClusterLink = (*theOriginalClusterLink)->getSisterClusterLink();
89  ATH_MSG_VERBOSE("Sister cluster link valid? "<<theSisterClusterLink.isValid()<<"");
90 
91  std::vector<ElementLink<xAOD::IParticleContainer>> theClusters;
92  if (theSisterClusterLink.isValid() && !m_addCPData){
93  theClusters.emplace_back(theSisterClusterLink);
94  }
95  else{
96  theClusters.emplace_back(theOriginalClusterLink);
97  }
98  thisFE->setOtherObjectLinks(theClusters);
99 
100  const static SG::AuxElement::Accessor<
102  accShowerSubtractedClusterLink("FEShowerSubtractedClusterLink");
103  accShowerSubtractedClusterLink(*thisFE) =
104  thisEfRecCluster->getClusElementLink();
105 
106  ATH_MSG_VERBOSE(" Sucessfully set cluster link");
107 
108  const xAOD::CaloCluster* cluster = thisEfRecCluster->getCluster();
109  ATH_MSG_VERBOSE("Got CaloCluster from EfRecCluster");
110  // be careful here - cluster p4 methods do not store sign. Thus -ve energy
111  // clusters have +ve pt and hence +ve energy we use eta,phi at EM scale for
112  // both 4-vectors - standard FE are at EM scale
113  thisFE->setP4(cluster->rawE() / cosh(cluster->rawEta()),
114  cluster->rawEta(),
115  cluster->rawPhi(),
116  cluster->rawM());
117 
118  ATH_MSG_DEBUG("Created neutral FlowElement with E, pt, eta and phi of "
119  << thisFE->e() << ", " << thisFE->pt() << ", "
120  << thisFE->eta() << " and " << thisFE->phi());
121 
122  thisFE->setCharge(0);
124 
126  FEFiller.addStandardMoments(*thisFE,*cluster);
127 
128  if (m_useCalibHitTruth) FEFiller.addStandardCalHitMoments(*thisFE,*cluster);
129 
130  FEFiller.addStandardSamplingEnergies(*thisFE,*cluster);
131 
132  float layerEnergy_TileBar0 = cluster->eSample(xAOD::CaloCluster::CaloSample::TileBar0);
133  float layerEnergy_TileExt0 = cluster->eSample(xAOD::CaloCluster::CaloSample::TileExt0);
134  const static SG::AuxElement::Accessor<float> accFloatTIle0E("LAYERENERGY_TILE0");
135  accFloatTIle0E(*thisFE) = layerEnergy_TileBar0 + layerEnergy_TileExt0;
136 
137  const static SG::AuxElement::Accessor<float> accFloatTiming("TIMING");
138  accFloatTiming(*thisFE) = cluster->time();
139 
140  if (m_addCPData){
141  PFClusterWidthCalculator widthCalc;
142  const CaloClusterCellLink* theCellLinks = cluster->getCellLinks();
143  std::vector<double> eta,phi;
144  for (CaloClusterCellLink::const_iterator it=theCellLinks->begin(); it!=theCellLinks->end(); ++it){
145  const CaloCell* cell = *it;
146  eta.push_back(cell->eta());
147  phi.push_back(cell->phi());
148  }
149 
150  std::pair<double,double> width = widthCalc.getPFClusterCoordinateWidth(eta,phi,cluster->eta(),cluster->phi(),theCellLinks->size());
151  const static SG::AuxElement::Accessor<float> accFloatWidthEta("ClusterWidthEta");
152  accFloatWidthEta(*thisFE) = width.first;
153  const static SG::AuxElement::Accessor<float> accFloatWidthPhi("ClusterWidthPhi");
154  accFloatWidthPhi(*thisFE) = width.second;
155  }
156 
157  }//cluster loop
158  return StatusCode::SUCCESS;
159 }
ShallowCopy.h
eflowRecCluster
This class extends the information about a xAOD::CaloCluster.
Definition: eflowRecCluster.h:40
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
xAOD::CaloCluster_v1::rawE
flt_t rawE() const
xAOD::CaloCluster_v1::time
flt_t time() const
Access cluster time.
eflowCaloObject::nClusters
unsigned nClusters() const
Definition: eflowCaloObject.h:59
xAOD::FlowElement_v1::NeutralPFlow
@ NeutralPFlow
Definition: FlowElement_v1.h:46
FEHelpers::FillNeutralFlowElements::addStandardSamplingEnergies
void addStandardSamplingEnergies(xAOD::FlowElement &theFE, const xAOD::CaloCluster &theCluster)
Definition: FEHelpers.cxx:246
xAOD::CaloCluster_v1::rawEta
flt_t rawEta() const
Get in signal state UNCALIBRATED.
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
FEHelpers::FillNeutralFlowElements::addStandardMoments
void addStandardMoments(xAOD::FlowElement &theFE, const xAOD::CaloCluster &theCluster)
Definition: FEHelpers.cxx:213
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CaloCell_ID_FCS::TileExt0
@ TileExt0
Definition: FastCaloSim_CaloCell_ID.h:37
xAOD::FlowElement_v1::setSignalType
void setSignalType(signal_t t)
skel.it
it
Definition: skel.GENtoEVGEN.py:423
FEHelpers::FillNeutralFlowElements::addStandardCalHitMoments
void addStandardCalHitMoments(xAOD::FlowElement &theFE, const xAOD::CaloCluster &theCluster)
Definition: FEHelpers.cxx:233
PFNeutralFlowElementCreatorAlgorithm::m_eflowCaloObjectContainerReadHandleKey
SG::ReadHandleKey< eflowCaloObjectContainer > m_eflowCaloObjectContainerReadHandleKey
ReadHandleKey for eflowCaloObjectContainer.
Definition: PFNeutralFlowElementCreatorAlgorithm.h:45
xAOD::FlowElement_v1::phi
virtual double phi() const override
The azimuthal angle ( ) of the particle.
xAOD::FlowElement_v1::pt
virtual double pt() const override
eflowCaloObject
An internal EDM object which stores information about systems of associated tracks and calorimeter cl...
Definition: eflowCaloObject.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::FlowElement_v1::setOtherObjectLinks
void setOtherObjectLinks(const std::vector< ElementLink< IParticleContainer >> &elV)
xAOD::FlowElement_v1::setCharge
void setCharge(float c)
FEHelpers::FillNeutralFlowElements
Definition: Event/xAOD/xAODPFlow/xAODPFlow/FEHelpers.h:27
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
PFClusterWidthCalculator
Definition: PFClusterWidthCalculator.h:6
FlowElementAuxContainer.h
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition: FlowElement.h:16
PFNeutralFlowElementCreatorAlgorithm::m_addCPData
Gaudi::Property< bool > m_addCPData
Toggle whether to decorate FlowElements with addutional data for Combined Performance studies.
Definition: PFNeutralFlowElementCreatorAlgorithm.h:41
PFNeutralFlowElementCreatorAlgorithm::createNeutralFlowElement
StatusCode createNeutralFlowElement(const eflowCaloObject &energyFlowCaloObject, xAOD::FlowElementContainer *neutralFEContainer) const
Create the chargedneutral FE.
Definition: PFNeutralFlowElementCreatorAlgorithm.cxx:53
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PFNeutralFlowElementCreatorAlgorithm::initialize
StatusCode initialize()
Definition: PFNeutralFlowElementCreatorAlgorithm.cxx:8
eflowRecCluster::getCluster
xAOD::CaloCluster * getCluster()
Definition: eflowRecCluster.h:49
eflowRecCluster::getOriginalClusElementLink
ElementLink< xAOD::CaloClusterContainer > getOriginalClusElementLink() const
Definition: eflowRecCluster.h:58
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
PFNeutralFlowElementCreatorAlgorithm::m_useCalibHitTruth
Gaudi::Property< bool > m_useCalibHitTruth
Toggle usage of calibration hit truth - false by default.
Definition: PFNeutralFlowElementCreatorAlgorithm.h:33
eflowRecCluster.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:905
PFNeutralFlowElementCreatorAlgorithm::m_neutralFEContainerWriteHandleKey
SG::WriteHandleKey< xAOD::FlowElementContainer > m_neutralFEContainerWriteHandleKey
WriteHandleKey for neutral FE.
Definition: PFNeutralFlowElementCreatorAlgorithm.h:54
xAOD::CaloCluster_v1::rawM
flt_t rawM() const
Get mass in signal state UNCALIBRATED.
FEHelpers.h
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition: FlowElement_v1.cxx:25
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
xAOD::FlowElement_v1::eta
virtual double eta() const override
The pseudorapidity ( ) of the particle.
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition: CaloCluster_v1.cxx:521
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
xAOD::CaloCluster_v1::rawPhi
flt_t rawPhi() const
Get in signal state UNCALIBRATED.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
eflowCaloObject::efRecCluster
const eflowRecCluster * efRecCluster(int i) const
Definition: eflowCaloObject.h:57
PFClusterWidthCalculator.h
PFNeutralFlowElementCreatorAlgorithm::execute
StatusCode execute(const EventContext &ctx) const
Definition: PFNeutralFlowElementCreatorAlgorithm.cxx:16
xAOD::FlowElement_v1::setP4
void setP4(float pt, float eta, float phi, float m)
Definition: FlowElement_v1.cxx:39
PFNeutralFlowElementCreatorAlgorithm.h
PFClusterWidthCalculator::getPFClusterCoordinateWidth
std::pair< double, double > getPFClusterCoordinateWidth(const std::vector< double > &eta, const std::vector< double > &phi, const double &clusterEta, const double &clusterPhi, unsigned int nCells)
Definition: PFClusterWidthCalculator.cxx:11
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
eflowRecCluster::getClusElementLink
ElementLink< xAOD::CaloClusterContainer > getClusElementLink() const
Definition: eflowRecCluster.h:54
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25