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>
10#include "xAODPFlow/PFODefs.h"
12
13using namespace std;
14
15
17{
18 declareProperty("LambdaCalDivide", m_lambdaCalDivide = 317);
19 declareProperty("QualityCut", m_qualityCut = 0.02);
20 declareProperty("TimeCutLargeQ", m_timeCutLargeQ = 5);
21 declareProperty("TimeCutSmallQ", m_timeCutSmallQ = 15);
22 declareProperty("MaxEtaForCut", m_etaMax = 2.5);
23
24}
25
27
30 ATH_MSG_ERROR("Incompatible configuration: ApplyToNeutralPFO=False -- what kind of pileup do you wish to suppress?");
31 return StatusCode::FAILURE;
32 }
33
34 } else {
36 ATH_MSG_ERROR("Incompatible configuration: ConstitTimeCutTool is not specialised for inputs of type "
37 << m_inputType);
38 return StatusCode::FAILURE;
39 }
40 }
41 return StatusCode::SUCCESS;
42}
43
44// Determine the appropriate input type and extract the timing, then
45// call the applyTimingCut method
47 switch(m_inputType) {
49 {
50 xAOD::CaloClusterContainer* clusters = static_cast<xAOD::CaloClusterContainer*> (cont);
51 const static SG::AuxElement::ConstAccessor<float> acc_larq("AVG_LAR_Q");
52 const static SG::AuxElement::ConstAccessor<float> acc_clambda("CENTER_LAMBDA");
53
54 for(xAOD::CaloCluster* cl : *clusters) {
55 //quality is on [0,2^16-1] scale
56 ATH_CHECK( applyTimingCut(cl, cl->time(), acc_larq(*cl)/65535, acc_clambda(*cl)));
57 }
58 }
59 break;
61 {
62 xAOD::PFOContainer* pfos = static_cast<xAOD::PFOContainer*> (cont);
63 for(xAOD::PFO* pfo : *pfos) {
64 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.
65 float time(0.);
66 float quality(0.);
67 float lambda_center(0.);
68 // Only apply cut if retrieval succeeded, else warn
69 if(pfo->attribute(xAOD::PFODetails::eflowRec_TIMING,time) &&
70 pfo->attribute(xAOD::PFODetails::eflowRec_AVG_LAR_Q,quality) &&
71 pfo->attribute(xAOD::PFODetails::eflowRec_CENTER_LAMBDA,lambda_center)
72 ) {
73 //quality is on [0,2^16-1] scale
74 ATH_CHECK( applyTimingCut(pfo, time, quality/65535, lambda_center) );
75 } else {
76 ATH_MSG_WARNING("Failed to retrieve the PFO informations necessary for timing cut at PFO #" << pfo->index());
77 }
78 }
79 }
80 }
81 break;
83 {
85 if(!fes->empty() && !(fes->front()->signalType() & xAOD::FlowElement::PFlow)){
86 ATH_MSG_ERROR("ConstitTimeCutTool received FlowElements that aren't PFOs, this isn't supported!");
87 return StatusCode::FAILURE;
88 }
89 for(xAOD::FlowElement* fe : *fes){
90 if(!fe->isCharged() || m_applyToChargedPFO){
91 const static SG::AuxElement::ConstAccessor<float> acc_timing("TIMING");
92 const static SG::AuxElement::ConstAccessor<float> acc_larq("AVG_LAR_Q");
93 const static SG::AuxElement::ConstAccessor<float> acc_clambda("CENTER_LAMBDA");
94 float time = acc_timing(*fe);
95 float quality = acc_larq(*fe);
96 float lambda_center = acc_clambda(*fe);
97 ATH_CHECK( applyTimingCut(fe, time, quality/65535, lambda_center) );
98 }
99 }
100 }
101 break;
102 default:
103 // Should not get here, because type-checking should happen in process()
104 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
105 return StatusCode::FAILURE;
106 }
107 return StatusCode::SUCCESS;
108}
109
110StatusCode ConstitTimeCutTool::applyTimingCut(xAOD::IParticle* part, const float& time, const float& quality, const float& lambda_center) const {
111 if(abs( part->eta() ) < m_etaMax){
112
113 // Only apply to ECal by default (with depth cut)
114 // Should switch to a test on the dominant sampling??
115 if(lambda_center < m_lambdaCalDivide) {
116 // Apply variable timing cut based on he cluster quality
117 // -- a larger spread is observed for clusters with small Q
118 float timeCut = quality > m_qualityCut ? m_timeCutLargeQ : m_timeCutSmallQ;
119 if( abs(time) > timeCut ) { ATH_CHECK( setEnergyPt( part, 0., 0. )); }
120 }
121 }
122
123 return StatusCode::SUCCESS;
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ConstitTimeCutTool(const std::string &name)
StatusCode applyTimingCut(xAOD::IParticle *part, const float &time, const float &quality, const float &lambda_center) const
StatusCode process_impl(xAOD::IParticleContainer *cont) const
StatusCode initialize()
Dummy implementation of the initialisation function.
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.
JetConstituentModifierBase(const std::string &name)
StatusCode setEnergyPt(xAOD::IParticle *obj, float e, float pt, const SG::AuxElement::Accessor< float > *weightAcc=nullptr) const
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
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.