ATLAS Offline Software
Loading...
Searching...
No Matches
ConstituentSubtractorTool Class Reference

Constituent modifier implementing the Constituent Substraction technique. More...

#include <ConstituentSubtractorTool.h>

Inheritance diagram for ConstituentSubtractorTool:
Collaboration diagram for ConstituentSubtractorTool:

Public Member Functions

 ConstituentSubtractorTool (const std::string &name)
StatusCode initialize () override final
 Dummy implementation of the initialisation function.
StatusCode process (xAOD::IParticleContainer *cont, const EventContext &ctx) const override final
void setInputContainer (const std::string &cont)
void setOutputContainer (const std::string &cont)
void setInputChargedContainer (const std::string &cont)
void setOutputChargedContainer (const std::string &cont)
void setInputNeutralContainer (const std::string &cont)
void setOutputNeutralContainer (const std::string &cont)
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

StatusCode setEtaPhi (xAOD::IParticle *obj, float eta, float phi) const
StatusCode setEnergyPt (xAOD::IParticle *obj, float e, float pt) const
StatusCode setP4 (xAOD::IParticle *obj, const xAOD::JetFourMom_t &p4) const
float getCorrectionFactor (xAOD::IParticle *obj, const float &corrected_energy, const float &corrected_pt) const
float getCorrectionFactor (xAOD::IParticle *obj, const xAOD::JetFourMom_t &corrected_p4) const
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

unsigned int m_inputType =xAOD::Type::Other
std::string m_inputContainer
std::string m_outputContainer
std::string m_inputChargedContainer
std::string m_inputNeutralContainer
std::string m_outputChargedContainer
std::string m_outputNeutralContainer
bool m_applyToChargedPFO =true
bool m_applyToNeutralPFO =true

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode process_impl (xAOD::IParticleContainer *cont, const EventContext &ctx) const override final
StatusCode configure_decor_handle_keys () override final
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::EventInfo > m_eventinfokey {"EventInfo"}
 Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.
Gaudi::Property< float > m_maxDeltaR = {this, "MaxDeltaR",0.25,""}
Gaudi::Property< float > m_alpha = {this, "Alpha",0.,""}
Gaudi::Property< float > m_ghostArea = {this, "GhostArea",0.01,""}
Gaudi::Property< float > m_maxEta = {this, "MaxEta",5.5,""}
Gaudi::Property< float > m_maxRapForRhoComputation = {this, "MaxRapForRhoComputation", 2.0, ""}
Gaudi::Property< float > m_gridSize = {this, "GridSize", 0.5, ""}
Gaudi::Property< bool > m_commonBgeForRhoAndRhom = {this, "CommonBgeForRhoAndRhom",false, ""}
Gaudi::Property< bool > m_doRapidityRescaling = {this, "DoRapidityRescaling",false, ""}
Gaudi::Property< bool > m_doRapidityPhiRescaling = {this, "DoRapidityPhiRescaling",false, ""}
Gaudi::Property< std::string > m_rescalingFileName = {this, "RescalingFileName","", ""}
Gaudi::Property< std::string > m_rescalingHistogramName = {this, "RescalingHistogramName","", ""}
Gaudi::Property< bool > m_ignoreChargedPFOs = {this, "IgnoreChargedPFO",0.,"Option to disregard cPFOs in the weight calculation"}
std::unique_ptr< fastjet::FunctionOfPseudoJet< double > > m_rescaling =nullptr
std::unique_ptr< TH1D > m_hist =nullptr
std::unique_ptr< TH2D > m_hist2D =nullptr
WriteDecorHandleKeyTriplet< float > m_csWeightKeys
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Constituent modifier implementing the Constituent Substraction technique.

Author
P-A Delsart, T.J. Khoo, others ??

Definition at line 31 of file ConstituentSubtractorTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ConstituentSubtractorTool()

ConstituentSubtractorTool::ConstituentSubtractorTool ( const std::string & name)

Definition at line 26 of file ConstituentSubtractorTool.cxx.

27}
JetConstituentModifierBase(const std::string &name)

Member Function Documentation

◆ configure_decor_handle_keys()

StatusCode ConstituentSubtractorTool::configure_decor_handle_keys ( )
finaloverrideprivatevirtual

Reimplemented from JetConstituentModifierBase.

Definition at line 103 of file ConstituentSubtractorTool.cxx.

104{
109
110 return StatusCode::SUCCESS;
111}
#define ATH_CHECK
Evaluate an expression and check for errors.
WriteDecorHandleKeyTriplet< float > m_csWeightKeys

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getCorrectionFactor() [1/2]

float JetConstituentModifierBase::getCorrectionFactor ( xAOD::IParticle * obj,
const float & corrected_energy,
const float & corrected_pt ) const
protectedinherited

Definition at line 158 of file JetConstituentModifierBase.cxx.

158 {
159 float factor = 0.;
160 switch(m_inputType) {
162 {
163 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
164 factor = clus->calE() > 0. ? corrected_energy / clus->calE() : 0.;
165 }
166 break;
168 {
169 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
170 factor = pfo->pt() > 0. ? corrected_pt / pfo->pt() : 0.;
171 }
172 break;
174 {
175 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
176 factor = pfo->pt() > 0. ? corrected_pt / pfo->pt() : 0.;
177 }
178 break;
180 {
182 factor = tcc->pt() > 0. ? corrected_pt / tcc->pt() : 0.;
183 }
184 break;
185 default:
186 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
187 }
188 return factor;
189}
#define ATH_MSG_ERROR(x,...)
flt_t calE() const
Geet Energy in signal state CALIBRATED.
virtual double pt() const override
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition PFO_v1.cxx:52
virtual double pt() const
The transverse momentum ( ) of the particle.
@ 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
@ TrackCaloCluster
The object is a track-calo-cluster.
Definition ObjectType.h:51
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
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
TrackCaloCluster_v1 TrackCaloCluster
Reference the current persistent version:

◆ getCorrectionFactor() [2/2]

float JetConstituentModifierBase::getCorrectionFactor ( xAOD::IParticle * obj,
const xAOD::JetFourMom_t & corrected_p4 ) const
protectedinherited

Definition at line 191 of file JetConstituentModifierBase.cxx.

191 {
192 float weight = 0.;
193 switch(m_inputType) {
195 {
196 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
197 weight = clus->calE() > 0. ? corrected_p4.e() / clus->calE() : 0.;
198 }
199 break;
201 {
202 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
203 // The PFO setter defaults to m=0
204 if( (m_applyToChargedPFO && pfo->isCharged()) || (m_applyToNeutralPFO && !pfo->isCharged()) ) {
205 weight = pfo->pt() > 0. ? corrected_p4.pt() / pfo->pt() : 0.;
206 }
207 }
208 break;
210 {
211 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
212 if( (m_applyToChargedPFO && pfo->isCharged()) || (m_applyToNeutralPFO && !pfo->isCharged()) ) {
213 weight = pfo->pt() > 0. ? corrected_p4.pt() / pfo->pt() : 0.;
214 }
215 }
216 break;
218 {
220 if( tcc->taste() != 0) {
221 weight = tcc->pt() > 0. ? corrected_p4.pt() / tcc->pt() : 0.;
222 }
223 break;
224 }
225
226 default:
227 throw std::runtime_error("No specialisation for object type " + std::to_string(m_inputType));
228 }
229 return weight;
230}
bool isCharged() const
is a charged PFO
Definition PFO_v1.cxx:251
virtual int taste() const
The taste of the particle.

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ initialize()

StatusCode ConstituentSubtractorTool::initialize ( void )
finaloverridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 30 of file ConstituentSubtractorTool.cxx.

30 {
31
34 ATH_MSG_ERROR("Incompatible configuration: setting both IgnoreChargedPFO and ApplyToChargedPFO to true"
35 << "will set all cPFOs to zero");
36 return StatusCode::FAILURE;
37 }
39 ATH_MSG_ERROR("Incompatible configuration: ApplyToNeutralPFO=False -- what kind of pileup do you wish to suppress?");
40 return StatusCode::FAILURE;
41 }
42 }
43 ATH_CHECK( m_eventinfokey.initialize() );
44
45
47 ATH_MSG_ERROR("Incompatible configuration: You set both, DoRapidityRescaling and DoRapidityPhiRescaling, to true. Use maximally only one of them.");
48 return StatusCode::FAILURE;
49 }
50
52 ATH_MSG_ERROR("Incompatible configuration: You have chosen a background rescaling, but you have not specified the path to the file with rescaling histograms or the name of the histogram. Specify properties FileRescaling and HistogramRescaling.");
53 return StatusCode::FAILURE;
54 }
55
57 std::string fullPathToFile=PathResolverFindCalibFile(m_rescalingFileName); // returns "" if file not found
58 if (fullPathToFile.empty()){
59 ATH_MSG_ERROR("Incompatible configuration: The provided file for rescaling was not found using PathResolver.");
60 return StatusCode::FAILURE;
61 }
62 std::unique_ptr<TFile> file(TFile::Open(fullPathToFile.data(), "READ"));
63 if (file->IsZombie()){
64 ATH_MSG_ERROR("Incompatible configuration: The file for rescaling has been tried to open, but it was found it is zombie.");
65 return StatusCode::FAILURE;
66 }
67 std::unique_ptr<TObject> object(file->Get(m_rescalingHistogramName.value().data()));
68 if (!object){
69 ATH_MSG_ERROR("Incompatible configuration: The provided histogram name was not found in the root file.");
70 return StatusCode::FAILURE;
71 }
72
74 if (object->InheritsFrom(TH1D::Class())){
75 m_hist.reset(static_cast<TH1D*>(object->Clone("hist_cloned")));
76 m_hist->SetDirectory(nullptr);
77 m_rescaling.reset(static_cast<fastjet::FunctionOfPseudoJet<double>*>(new contrib::BackgroundRescalingYFromRoot<TH1D>(m_hist.get())));
78 }
79 else{
80 ATH_MSG_ERROR("Incompatible configuration: You want to do rapidity rescaling, but the provided histogram name is not a TH1D.");
81 return StatusCode::FAILURE;
82 }
83 }
85 if (object->InheritsFrom(TH2D::Class())){
86 m_hist2D.reset(static_cast<TH2D*>(object->Clone("hist_cloned")));
87 m_hist2D->SetDirectory(nullptr);
88 m_rescaling.reset(static_cast<fastjet::FunctionOfPseudoJet<double>*>(new contrib::BackgroundRescalingYPhiFromRoot<TH2D>(m_hist2D.get())));
89 }
90 else{
91 ATH_MSG_ERROR("Incompatible configuration: You want to do rapidity-phi rescaling, but the provided histogram name is not a TH2D.");
92 return StatusCode::FAILURE;
93 }
94 }
95 }
96
97 ATH_CHECK(m_csWeightKeys.initialize());
98
99 return StatusCode::SUCCESS;
100}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< bool > m_ignoreChargedPFOs
Gaudi::Property< std::string > m_rescalingHistogramName
Gaudi::Property< std::string > m_rescalingFileName
std::unique_ptr< fastjet::FunctionOfPseudoJet< double > > m_rescaling
Gaudi::Property< bool > m_doRapidityPhiRescaling
SG::ReadHandleKey< xAOD::EventInfo > m_eventinfokey
Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.
Gaudi::Property< bool > m_doRapidityRescaling
TFile * file

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

Print the state of the tool.

Implements asg::IAsgTool.

Reimplemented in AsgHelloTool, HI::HIPileupTool, JetFromPseudojet, JetPileupLabelingTool, JetPseudojetRetriever, JetSubStructureMomentToolsBase, JetTruthLabelingTool, and KtDeltaRTool.

Definition at line 131 of file AsgTool.cxx.

131 {
132
133 ATH_MSG_INFO( "AsgTool " << name() << " @ " << this );
134 return;
135 }
#define ATH_MSG_INFO(x,...)

◆ process()

StatusCode JetConstituentModifierBase::process ( xAOD::IParticleContainer * cont,
const EventContext & ctx ) const
finaloverridevirtualinherited

Implements IJetConstituentModifier.

Definition at line 25 of file JetConstituentModifierBase.cxx.

26{
27 // Test that we are operating on the type of object that
28 // we will be writing out.
29 // By implication, any supporting containers should not
30 // be the ones passed to this method...
31 if(!cont->empty() && cont->front()->type() != m_inputType) {
32 ATH_MSG_ERROR("Object type mismatch! This tool expects " << m_inputType
33 << ", but received " << cont->front()->type());
34 return StatusCode::FAILURE;
35 }
36
37 ATH_CHECK(process_impl(cont, ctx));
38
39 return StatusCode::SUCCESS;
40}
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.
virtual StatusCode process_impl(xAOD::IParticleContainer *, const EventContext &) const

◆ process_impl()

StatusCode ConstituentSubtractorTool::process_impl ( xAOD::IParticleContainer * cont,
const EventContext & ctx ) const
finaloverrideprivatevirtual

Reimplemented from JetConstituentModifierBase.

Definition at line 115 of file ConstituentSubtractorTool.cxx.

115 {
116
117 contrib::ConstituentSubtractor subtractor;
118
119 // free parameter for the maximal allowed distance sqrt((y_i-y_k)^2+(phi_i-phi_k)^2) between particle i and ghost k
120 subtractor.set_max_standardDeltaR(m_maxDeltaR);
121
122 // free parameter for the distance measure (the exponent of particle pt). The larger the parameter alpha, the more are favoured the lower pt particles in the subtraction process
123 subtractor.set_alpha(m_alpha);
124
125 // free parameter for the density of ghosts. The smaller, the better - but also the computation is slower.
126 subtractor.set_ghost_area(m_ghostArea);
127
128 // This is added to fix ATR-23552. It has no effect on the performance. Once the bug is fixed in fastjet-contrib, it can be removed.
129 subtractor.set_use_nearby_hard(-1,-1);
130
131 // prepare PseudoJet input
132 std::vector<PseudoJet> inputs_to_correct, inputs_to_not_correct;
133 inputs_to_correct.reserve(cont->size());
134 inputs_to_not_correct.reserve(cont->size());
135 size_t i =0; // Corresponds to the index in the input container
136 // We don't use part->index() because it might be a view container
137 // combining more than one owning container
138
139 // Minimal and maximum rapidities needed for the workaround for the bug in fastjet-contrib ConstituentSubtractor, see ATLASG-1417
140 double minRap=1000;
141 double maxRap=-1000;
142
143 for(xAOD::IParticle * part: *cont){
144 // Only use positive E
145 bool accept = part->e() > -1*FLT_MIN;
146 // For PFlow we would only want to apply the correction to neutral PFOs,
147 // because charged hadron subtraction handles the charged PFOs.
148 // However, we might still want to use the cPFOs for the min pt calculation
151 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(part);
152 accept &= fabs(pfo->charge())<FLT_MIN;
153 }
155 xAOD::FlowElement* fe = static_cast<xAOD::FlowElement*>(part);
156 accept &= !(fe->isCharged());
157 }
158 }
161 accept &= (tcc->taste()!= 0)*(tcc->pt()>-1.*FLT_MIN);
162 }
163 // Reject object if outside maximum eta range
164 accept &= fabs(part->eta()) <= m_maxEta;
165
166 PseudoJet pj( part->p4() );
167 pj.set_user_index( i );
168 if(accept) {
169 ATH_MSG_VERBOSE("Using " << part->type() << " with pt " << part->pt());
170 inputs_to_correct.push_back(pj);
171 // Minimal and maximum rapidities needed for the workaround for the bug in fastjet-contrib ConstituentSubtractor, see ATLASG-1417
172 if (pj.rap()<minRap) minRap = pj.rap();
173 if (pj.rap()>maxRap) maxRap = pj.rap();
174 } else {
175 ATH_MSG_VERBOSE("Will not correct " << part->type() << " with pt " << part->pt());
176 inputs_to_not_correct.push_back(pj);
177 }
178
179 ++i;
180 }
181
182 // create what we need for the background estimation
183 //----------------------------------------------------------
184 // maximal rapidity is used (not pseudo-rapidity). Since the inputs are massless, it does not matter
185 GridMedianBackgroundEstimator bge_rho(m_maxRapForRhoComputation, m_gridSize);
186 bge_rho.set_rescaling_class(m_rescaling.get());
187 bge_rho.set_particles(inputs_to_correct);
188 subtractor.set_background_estimator(&bge_rho);
189
190 // for massless input particles it does not make any difference (rho_m is always zero)
191
192 ATH_MSG_DEBUG("Subtracting event density from constituents");
193 std::vector<PseudoJet> corrected_event=subtractor.subtract_event(inputs_to_correct,m_maxEta);
194
195 // Define a vector holding the corrected four-momenta for all output constituents
196 // This is defaulted to zero, because fastjet will only return non-zero pseudojets
197 std::vector<xAOD::JetFourMom_t> corrected_p4s(cont->size(),xAOD::JetFourMom_t(0.,0.,0.,0.));
198 // Set the corrected four-vectors
199 for(PseudoJet & pj : corrected_event) {
200 ATH_MSG_VERBOSE("Setting four-mom for constituent " << pj.user_index() << ", pt = " << pj.pt());
201 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
202 }
203 for(PseudoJet & pj : inputs_to_not_correct) {
204 ATH_MSG_VERBOSE("Setting four-mom for constituent " << pj.user_index() << ", pt = " << pj.pt());
205 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
206 }
207 for(PseudoJet & pj : inputs_to_not_correct) {
208 ATH_MSG_VERBOSE("Setting four-mom for constituent " << pj.user_index() << ", pt = " << pj.pt());
209 corrected_p4s[pj.user_index()].SetCoordinates(pj.pt(),pj.eta(),pj.phi(),pj.m());
210 }
211
212
213 auto csWeightHandle = m_csWeightKeys.makeHandles(m_inputType, ctx);
214
215 // Set every constituent's four-vector in the output container
216 i = 0; // Again, we need to track the input container index, not the owning container index
217 for(xAOD::IParticle * part: *cont){
218 ATH_MSG_VERBOSE("Now on constituent " << i);
219 ATH_MSG_VERBOSE("Initial pt: " << part->pt() << ", subtracted pt: " << corrected_p4s[i].Pt());
220 ATH_MSG_VERBOSE("Initial eta: " << part->eta() << ", subtracted pt: " << corrected_p4s[i].Eta());
221 ATH_MSG_VERBOSE("Initial phi: " << part->phi() << ", subtracted pt: " << corrected_p4s[i].Phi());
222 float weight = getCorrectionFactor(part, corrected_p4s[i]);
223 csWeightHandle(*part) = weight;
224 ATH_CHECK( setP4(part,corrected_p4s[i]) );
225 ++i;
226 }
227
228
229
230 return StatusCode::SUCCESS;
231}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
Gaudi::Property< float > m_maxRapForRhoComputation
Gaudi::Property< float > m_maxEta
Gaudi::Property< float > m_alpha
Gaudi::Property< float > m_ghostArea
Gaudi::Property< float > m_maxDeltaR
Gaudi::Property< float > m_gridSize
size_type size() const noexcept
Returns the number of elements in the collection.
float getCorrectionFactor(xAOD::IParticle *obj, const float &corrected_energy, const float &corrected_pt) const
StatusCode setP4(xAOD::IParticle *obj, const xAOD::JetFourMom_t &p4) const
float charge() const
get charge of PFO
StatusCode accept(const xAOD::Muon *mu)
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setEnergyPt()

StatusCode JetConstituentModifierBase::setEnergyPt ( xAOD::IParticle * obj,
float e,
float pt ) const
protectedinherited

Definition at line 63 of file JetConstituentModifierBase.cxx.

64{
65 switch(m_inputType) {
67 {
68 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
69 // Clusters get pt via the energy
70 // This currently leaves the mass unaltered.
71 clus->setCalE(e);
72 }
73 break;
75 {
76 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
77 if( (m_applyToChargedPFO && pfo->isCharged()) ||
78 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
79 // KTJ: Temporary fix
80 // Defeats the purpose, but we need to use this to reset the 4-vec cache
81 pfo->setP4(pt, pfo->eta(), pfo->phi());
82 }
83 }
84 break;
86 {
87 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
88 if( (m_applyToChargedPFO && pfo->isCharged()) ||
89 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
90 pfo->setP4(pt, pfo->eta(), pfo->phi(), 0.);
91 }
92 }
93 break;
95 {
97 if( tcc->taste() != 0) {
98 tcc->setParameters(pt, tcc->eta(), tcc->phi(), tcc->m(), xAOD::TrackCaloCluster::Taste(tcc->taste()), tcc->trackParticleLink(), tcc->caloClusterLinks());
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}
void setCalE(flt_t)
Set Energy for signal state CALIBRATED.
void setP4(float pt, float eta, float phi, float m)
virtual double phi() const override
The azimuthal angle ( ) of the particle.
virtual double eta() const override
The pseudorapidity ( ) of the particle.
void setP4(const FourMom_t &vec)
set the 4-vec
Definition PFO_v1.cxx:107
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition PFO_v1.cxx:60
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition PFO_v1.cxx:67
virtual double m() const
The invariant mass of the particle..
virtual double phi() const
The azimuthal angle ( ) of the particle (has range to .).
Taste
Type of TrackCaloCluster - Charged - Neutral - Combined.
const ElementLink< xAOD::TrackParticleContainer > & trackParticleLink() const
virtual double eta() const
The pseudorapidity ( ) of the particle.
const std::vector< ElementLink< xAOD::CaloClusterContainer > > & caloClusterLinks() const
Returns a vector to the links (which can be invalid) to the xAOD::CaloClusters associated with this T...
void setParameters(float pt, float eta, float phi, float m, TrackCaloCluster_v1::Taste taste, const ElementLink< xAOD::TrackParticleContainer > &particle, const std::vector< ElementLink< xAOD::CaloClusterContainer > > &clusters)

◆ setEtaPhi()

StatusCode JetConstituentModifierBase::setEtaPhi ( xAOD::IParticle * obj,
float eta,
float phi ) const
protectedinherited

Definition at line 43 of file JetConstituentModifierBase.cxx.

44{
45 switch(m_inputType) {
46 // The main (only?) application is origin-correcting LC topoclusters
47 // By convention we leave the raw p4 unmodified
49 {
50 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
51 clus->setCalEta(eta);
52 clus->setCalPhi(phi);
53 }
54 break;
55 default:
56 // Should not get here, because type-checking should happen in process()
57 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
58 return StatusCode::FAILURE;
59 }
60 return StatusCode::SUCCESS;
61}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
void setCalPhi(flt_t)
Set for signal state CALIBRATED.
void setCalEta(flt_t)
Set for signal state CALIBRATED.

◆ setInputChargedContainer()

void JetConstituentModifierBase::setInputChargedContainer ( const std::string & cont)
inlineinherited

Definition at line 47 of file JetConstituentModifierBase.h.

◆ setInputContainer()

void JetConstituentModifierBase::setInputContainer ( const std::string & cont)
inlineinherited

Definition at line 45 of file JetConstituentModifierBase.h.

◆ setInputNeutralContainer()

void JetConstituentModifierBase::setInputNeutralContainer ( const std::string & cont)
inlineinherited

Definition at line 49 of file JetConstituentModifierBase.h.

◆ setOutputChargedContainer()

void JetConstituentModifierBase::setOutputChargedContainer ( const std::string & cont)
inlineinherited

Definition at line 48 of file JetConstituentModifierBase.h.

◆ setOutputContainer()

void JetConstituentModifierBase::setOutputContainer ( const std::string & cont)
inlineinherited

Definition at line 46 of file JetConstituentModifierBase.h.

46{m_outputContainer = cont;}

◆ setOutputNeutralContainer()

void JetConstituentModifierBase::setOutputNeutralContainer ( const std::string & cont)
inlineinherited

Definition at line 50 of file JetConstituentModifierBase.h.

◆ setP4()

StatusCode JetConstituentModifierBase::setP4 ( xAOD::IParticle * obj,
const xAOD::JetFourMom_t & p4 ) const
protectedinherited

Definition at line 110 of file JetConstituentModifierBase.cxx.

110 {
111 switch(m_inputType) {
113 {
114 xAOD::CaloCluster* clus = static_cast<xAOD::CaloCluster*>(obj);
115 // This currently leaves the mass unaltered
116 clus->setCalE(p4.e());
117 clus->setCalEta(p4.eta());
118 clus->setCalPhi(p4.phi());
119 }
120 break;
122 {
123 xAOD::PFO* pfo = static_cast<xAOD::PFO*>(obj);
124 // The PFO setter defaults to m=0
125 if( (m_applyToChargedPFO && pfo->isCharged()) ||
126 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
127 pfo->setP4(p4.pt(),p4.eta(),p4.phi(),p4.mass());
128 }
129 }
130 break;
132 {
133 xAOD::FlowElement* pfo = static_cast<xAOD::FlowElement*>(obj);
134 if( (m_applyToChargedPFO && pfo->isCharged()) ||
135 (m_applyToNeutralPFO && !pfo->isCharged()) ) {
136 pfo->setP4(p4.pt(),p4.eta(),p4.phi(),p4.mass());
137 }
138 }
139 break;
141 {
143 if( tcc->taste() != 0) {
144 tcc->setParameters(p4.pt(), p4.eta(), p4.phi(), p4.mass(), xAOD::TrackCaloCluster::Taste(tcc->taste()), tcc->trackParticleLink(), tcc->caloClusterLinks());
145 }
146 break;
147 }
148
149 default:
150 // Should not get here, because type-checking should happen in process()
151 ATH_MSG_ERROR("No specialisation for object type " << m_inputType);
152 return StatusCode::FAILURE;
153 }
154 return StatusCode::SUCCESS;
155}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_alpha

Gaudi::Property<float> ConstituentSubtractorTool::m_alpha = {this, "Alpha",0.,""}
private

Definition at line 49 of file ConstituentSubtractorTool.h.

49{this, "Alpha",0.,""};

◆ m_applyToChargedPFO

bool JetConstituentModifierBase::m_applyToChargedPFO =true
protectedinherited

Definition at line 84 of file JetConstituentModifierBase.h.

◆ m_applyToNeutralPFO

bool JetConstituentModifierBase::m_applyToNeutralPFO =true
protectedinherited

Definition at line 85 of file JetConstituentModifierBase.h.

◆ m_commonBgeForRhoAndRhom

Gaudi::Property<bool> ConstituentSubtractorTool::m_commonBgeForRhoAndRhom = {this, "CommonBgeForRhoAndRhom",false, ""}
private

Definition at line 55 of file ConstituentSubtractorTool.h.

55{this, "CommonBgeForRhoAndRhom",false, ""};

◆ m_csWeightKeys

WriteDecorHandleKeyTriplet<float> ConstituentSubtractorTool::m_csWeightKeys
private
Initial value:
{
this,
"CSWeightKey",
"CSWeight",
"CSWeight decoration"
}

Definition at line 68 of file ConstituentSubtractorTool.h.

68 {
69 this,
70 "CSWeightKey",
71 "CSWeight",
72 "CSWeight decoration"
73 };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_doRapidityPhiRescaling

Gaudi::Property<bool> ConstituentSubtractorTool::m_doRapidityPhiRescaling = {this, "DoRapidityPhiRescaling",false, ""}
private

Definition at line 57 of file ConstituentSubtractorTool.h.

57{this, "DoRapidityPhiRescaling",false, ""};

◆ m_doRapidityRescaling

Gaudi::Property<bool> ConstituentSubtractorTool::m_doRapidityRescaling = {this, "DoRapidityRescaling",false, ""}
private

Definition at line 56 of file ConstituentSubtractorTool.h.

56{this, "DoRapidityRescaling",false, ""};

◆ m_eventinfokey

SG::ReadHandleKey<xAOD::EventInfo> ConstituentSubtractorTool::m_eventinfokey {"EventInfo"}
private

Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.

Definition at line 46 of file ConstituentSubtractorTool.h.

46{"EventInfo"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_ghostArea

Gaudi::Property<float> ConstituentSubtractorTool::m_ghostArea = {this, "GhostArea",0.01,""}
private

Definition at line 50 of file ConstituentSubtractorTool.h.

50{this, "GhostArea",0.01,""};

◆ m_gridSize

Gaudi::Property<float> ConstituentSubtractorTool::m_gridSize = {this, "GridSize", 0.5, ""}
private

Definition at line 54 of file ConstituentSubtractorTool.h.

54{this, "GridSize", 0.5, ""}; // grid size (not area) for GridMedianBackgroundEstimator

◆ m_hist

std::unique_ptr<TH1D> ConstituentSubtractorTool::m_hist =nullptr
private

Definition at line 64 of file ConstituentSubtractorTool.h.

◆ m_hist2D

std::unique_ptr<TH2D> ConstituentSubtractorTool::m_hist2D =nullptr
private

Definition at line 65 of file ConstituentSubtractorTool.h.

◆ m_ignoreChargedPFOs

Gaudi::Property<bool> ConstituentSubtractorTool::m_ignoreChargedPFOs = {this, "IgnoreChargedPFO",0.,"Option to disregard cPFOs in the weight calculation"}
private

Definition at line 61 of file ConstituentSubtractorTool.h.

61{this, "IgnoreChargedPFO",0.,"Option to disregard cPFOs in the weight calculation"};

◆ m_inputChargedContainer

std::string JetConstituentModifierBase::m_inputChargedContainer
protectedinherited

Definition at line 78 of file JetConstituentModifierBase.h.

◆ m_inputContainer

std::string JetConstituentModifierBase::m_inputContainer
protectedinherited

Definition at line 76 of file JetConstituentModifierBase.h.

◆ m_inputNeutralContainer

std::string JetConstituentModifierBase::m_inputNeutralContainer
protectedinherited

Definition at line 79 of file JetConstituentModifierBase.h.

◆ m_inputType

unsigned int JetConstituentModifierBase::m_inputType =xAOD::Type::Other
protectedinherited

Definition at line 74 of file JetConstituentModifierBase.h.

◆ m_maxDeltaR

Gaudi::Property<float> ConstituentSubtractorTool::m_maxDeltaR = {this, "MaxDeltaR",0.25,""}
private

Definition at line 48 of file ConstituentSubtractorTool.h.

48{this, "MaxDeltaR",0.25,""};

◆ m_maxEta

Gaudi::Property<float> ConstituentSubtractorTool::m_maxEta = {this, "MaxEta",5.5,""}
private

Definition at line 51 of file ConstituentSubtractorTool.h.

51{this, "MaxEta",5.5,""};

◆ m_maxRapForRhoComputation

Gaudi::Property<float> ConstituentSubtractorTool::m_maxRapForRhoComputation = {this, "MaxRapForRhoComputation", 2.0, ""}
private

Definition at line 53 of file ConstituentSubtractorTool.h.

53{this, "MaxRapForRhoComputation", 2.0, ""};

◆ m_outputChargedContainer

std::string JetConstituentModifierBase::m_outputChargedContainer
protectedinherited

Definition at line 80 of file JetConstituentModifierBase.h.

◆ m_outputContainer

std::string JetConstituentModifierBase::m_outputContainer
protectedinherited

Definition at line 77 of file JetConstituentModifierBase.h.

◆ m_outputNeutralContainer

std::string JetConstituentModifierBase::m_outputNeutralContainer
protectedinherited

Definition at line 81 of file JetConstituentModifierBase.h.

◆ m_rescaling

std::unique_ptr<fastjet::FunctionOfPseudoJet<double> > ConstituentSubtractorTool::m_rescaling =nullptr
private

Definition at line 63 of file ConstituentSubtractorTool.h.

◆ m_rescalingFileName

Gaudi::Property<std::string> ConstituentSubtractorTool::m_rescalingFileName = {this, "RescalingFileName","", ""}
private

Definition at line 58 of file ConstituentSubtractorTool.h.

58{this, "RescalingFileName","", ""};

◆ m_rescalingHistogramName

Gaudi::Property<std::string> ConstituentSubtractorTool::m_rescalingHistogramName = {this, "RescalingHistogramName","", ""}
private

Definition at line 59 of file ConstituentSubtractorTool.h.

59{this, "RescalingHistogramName","", ""};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: