ATLAS Offline Software
Loading...
Searching...
No Matches
ConstitTimeCutTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <vector>
8#include "xAODPFlow/PFODefs.h"
11
12using namespace std;
13
14
16{
17 declareProperty("LambdaCalDivide", m_lambdaCalDivide = 317);
18 declareProperty("QualityCut", m_qualityCut = 0.02);
19 declareProperty("TimeCutLargeQ", m_timeCutLargeQ = 5);
20 declareProperty("TimeCutSmallQ", m_timeCutSmallQ = 15);
21 declareProperty("MaxEtaForCut", m_etaMax = 2.5);
22
23}
24
26
29 ATH_MSG_ERROR("Incompatible configuration: ApplyToNeutralPFO=False -- what kind of pileup do you wish to suppress?");
30 return StatusCode::FAILURE;
31 }
32
33 } else {
35 ATH_MSG_ERROR("Incompatible configuration: ConstitTimeCutTool is not specialised for inputs of type "
36 << m_inputType);
37 return StatusCode::FAILURE;
38 }
39
40
42 ATH_CHECK(m_clusterLarQKey.initialize());
43 ATH_CHECK(m_clusterLambdaKey.initialize());
44 }
45
47 ATH_CHECK(m_feTimingKey.initialize());
48 ATH_CHECK(m_feLarQKey.initialize());
49 ATH_CHECK(m_feLambdaKey.initialize());
50 }
51
52 }
53 return StatusCode::SUCCESS;
54}
55
56// Determine the appropriate input type and extract the timing, then
57// call the applyTimingCut method
58StatusCode ConstitTimeCutTool::process_impl(xAOD::IParticleContainer* cont, const EventContext& ctx) const {
59 switch(m_inputType) {
61 {
62 xAOD::CaloClusterContainer* clusters = static_cast<xAOD::CaloClusterContainer*> (cont);
65
66 for(xAOD::CaloCluster* cl : *clusters) {
67 //quality is on [0,2^16-1] scale
68 ATH_CHECK( applyTimingCut(cl, cl->time(), larQ_handle(*cl)/65535, lambda_handle(*cl)));
69 }
70 }
71 break;
73 {
74 xAOD::PFOContainer* pfos = static_cast<xAOD::PFOContainer*> (cont);
75 for(xAOD::PFO* pfo : *pfos) {
76 if(fabs(pfo->charge())<FLT_MIN || m_applyToChargedPFO) { // only apply to neutrals if m_applyToChargedPFO is false. If m_applyToChargedPFO is true then apply to all POs.
77 float time(0.);
78 float quality(0.);
79 float lambda_center(0.);
80 // Only apply cut if retrieval succeeded, else warn
81 if(pfo->attribute(xAOD::PFODetails::eflowRec_TIMING,time) &&
82 pfo->attribute(xAOD::PFODetails::eflowRec_AVG_LAR_Q,quality) &&
83 pfo->attribute(xAOD::PFODetails::eflowRec_CENTER_LAMBDA,lambda_center)
84 ) {
85 //quality is on [0,2^16-1] scale
86 ATH_CHECK( applyTimingCut(pfo, time, quality/65535, lambda_center) );
87 } else {
88 ATH_MSG_WARNING("Failed to retrieve the PFO informations necessary for timing cut at PFO #" << pfo->index());
89 }
90 }
91 }
92 }
93 break;
95 {
97 if(!fes->empty() && !(fes->front()->signalType() & xAOD::FlowElement::PFlow)){
98 ATH_MSG_ERROR("ConstitTimeCutTool received FlowElements that aren't PFOs, this isn't supported!");
99 return StatusCode::FAILURE;
100 }
101
105
106 for(xAOD::FlowElement* fe : *fes){
107 if(!fe->isCharged() || m_applyToChargedPFO){
108 float time = timing_handle(*fe);
109 float quality = larQ_handle(*fe);
110 float lambda_center = lambda_handle(*fe);
111 ATH_CHECK( applyTimingCut(fe, time, quality/65535, lambda_center) );
112 }
113 }
114 }
115 break;
116 default:
117 // Should not get here, because type-checking should happen in process()
118 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
119 return StatusCode::FAILURE;
120 }
121 return StatusCode::SUCCESS;
122}
123
124StatusCode ConstitTimeCutTool::applyTimingCut(xAOD::IParticle* part, const float& time, const float& quality, const float& lambda_center) const {
125 if(abs( part->eta() ) < m_etaMax){
126
127 // Only apply to ECal by default (with depth cut)
128 // Should switch to a test on the dominant sampling??
129 if(lambda_center < m_lambdaCalDivide) {
130 // Apply variable timing cut based on he cluster quality
131 // -- a larger spread is observed for clusters with small Q
132 float timeCut = quality > m_qualityCut ? m_timeCutLargeQ : m_timeCutSmallQ;
133 if( abs(time) > timeCut ) { ATH_CHECK( setEnergyPt( part, 0., 0. )); }
134 }
135 }
136
137 return StatusCode::SUCCESS;
138}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
Handle class for reading a decoration on an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SG::ReadDecorHandleKey< xAOD::FlowElementContainer > m_feLarQKey
SG::ReadDecorHandleKey< xAOD::FlowElementContainer > m_feTimingKey
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_clusterLarQKey
ConstitTimeCutTool(const std::string &name)
StatusCode initialize() override final
Dummy implementation of the initialisation function.
StatusCode process_impl(xAOD::IParticleContainer *cont, const EventContext &ctx) const override final
StatusCode applyTimingCut(xAOD::IParticle *part, const float &time, const float &quality, const float &lambda_center) const
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_clusterLambdaKey
SG::ReadDecorHandleKey< xAOD::FlowElementContainer > m_feLambdaKey
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
StatusCode setEnergyPt(xAOD::IParticle *obj, float e, float pt) const
JetConstituentModifierBase(const std::string &name)
Handle class for reading a decoration on an object.
signal_t signalType() const
Class providing the definition of the 4-vector interface.
STL namespace.
@ ParticleFlow
The object is a particle-flow object.
Definition ObjectType.h:41
@ FlowElement
The object is a track-calo-cluster.
Definition ObjectType.h:52
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.