ATLAS Offline Software
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"
11 #include "PFlowUtils/FEHelpers.h"
12 
13 using 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 
29  if(!m_applyToNeutralPFO) {
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  {
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  {
84  xAOD::FlowElementContainer* fes = static_cast<xAOD::FlowElementContainer*>(cont);
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 
110 StatusCode 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 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
FEHelpers.h
JetConstituentModifierBase::m_applyToNeutralPFO
bool m_applyToNeutralPFO
Definition: JetConstituentModifierBase.h:63
FlowElementContainer.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::PFODetails::eflowRec_TIMING
@ eflowRec_TIMING
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:58
PFOContainer.h
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
JetConstituentModifierBase::m_applyToChargedPFO
bool m_applyToChargedPFO
Definition: JetConstituentModifierBase.h:62
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::PFODetails::eflowRec_CENTER_LAMBDA
@ eflowRec_CENTER_LAMBDA
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:35
xAOD::FlowElement_v1::PFlow
@ PFlow
Definition: FlowElement_v1.h:45
ConstitTimeCutTool::process_impl
StatusCode process_impl(xAOD::IParticleContainer *cont) const
Definition: ConstitTimeCutTool.cxx:46
ConstitTimeCutTool::m_timeCutLargeQ
float m_timeCutLargeQ
Definition: ConstitTimeCutTool.h:37
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ConstitTimeCutTool::m_timeCutSmallQ
float m_timeCutSmallQ
Definition: ConstitTimeCutTool.h:38
ConstitTimeCutTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition: FlowElement.h:16
ConstitTimeCutTool::m_qualityCut
float m_qualityCut
Definition: ConstitTimeCutTool.h:36
ConstitTimeCutTool::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: ConstitTimeCutTool.cxx:26
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition: ObjectType.h:41
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::PFO_v1
Class describing a particle flow object.
Definition: PFO_v1.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JetConstituentModifierBase
Definition: JetConstituentModifierBase.h:22
ConstitTimeCutTool::ConstitTimeCutTool
ConstitTimeCutTool(const std::string &name)
Definition: ConstitTimeCutTool.cxx:16
JetConstituentModifierBase::setEnergyPt
StatusCode setEnergyPt(xAOD::IParticle *obj, float e, float pt, const SG::AuxElement::Accessor< float > *weightAcc=nullptr) const
Definition: JetConstituentModifierBase.cxx:61
ConstitTimeCutTool::m_etaMax
float m_etaMax
Definition: ConstitTimeCutTool.h:39
JetConstituentModifierBase::m_inputType
unsigned int m_inputType
Definition: JetConstituentModifierBase.h:60
ConstitTimeCutTool::applyTimingCut
StatusCode applyTimingCut(xAOD::IParticle *part, const float &time, const float &quality, const float &lambda_center) const
Definition: ConstitTimeCutTool.cxx:110
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
CaloClusterContainer.h
PFODefs.h
xAOD::PFODetails::eflowRec_AVG_LAR_Q
@ eflowRec_AVG_LAR_Q
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:52
ConstitTimeCutTool::m_lambdaCalDivide
float m_lambdaCalDivide
Definition: ConstitTimeCutTool.h:35
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25