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

#include <IRCSafeLabelTool.h>

Inheritance diagram for IRCSafeLabelTool:
Collaboration diagram for IRCSafeLabelTool:

Public Member Functions

 IRCSafeLabelTool (const std::string &name)
 Constructor.
StatusCode initialize () override
 Dummy implementation of the initialisation function.
StatusCode decorate (const xAOD::JetContainer &jets) const override
 Decorate a jet collection without otherwise modifying it.
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
virtual StatusCode modify (xAOD::JetContainer &jets) const override final
 Concrete implementation of the function inherited from IJetModifier.
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

std::vector< std::vector< fastjet::PseudoJet > > getJetInputs (const xAOD::TruthParticleContainer &parts, const xAOD::TruthParticleContainer &label_bs, const xAOD::TruthParticleContainer &label_cs) const
std::vector< std::vector< const fastjet::PseudoJet * > > match (std::vector< fastjet::PseudoJet > &tagged_jets, const xAOD::JetContainer &jets) const
 Function matching truth pseudojets to reco jets.
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

ParticleJetTools::IRCSafeLabelNames m_ircsafelabelnames
 Name of jet label attributes.
std::unique_ptr< ParticleJetTools::IRCSafeLabelDecoratorsm_ircsafelabeldecs
SG::ReadHandleKey< xAOD::TruthParticleContainerm_bottomPartCollectionKey {this,"BParticleCollection","","ReadHandleKey for bottomPartCollection"}
 Read handles particle collections for labeling. We need all inputs used for jet clustering.
SG::ReadHandleKey< xAOD::TruthParticleContainerm_charmPartCollectionKey {this,"CParticleCollection","","ReadHandleKey for charmPartCollection"}
SG::ReadHandleKey< xAOD::TruthParticleContainerm_outTruthPartKey {this, "TruthParticleCollection","", "ReadHandleKey of the TruthParticle collection"}
double m_truthjetptmin
 Minimum pT for truth jet to be matched (in MeV)
double m_jetptmin
 Minimum pT for jet selection (in MeV)
double m_drmax
 Maximum dR for matching criterion.
double m_truthR
 Radius of truth jets with undecayed B and D hadrons.
std::vector< std::string > m_enabledAlgos
 Enabled algorithms (subset of: IFN, CMP, GHS, SDF, AKT)
bool m_doIFN {true}
bool m_doCMP {true}
bool m_doGHS {true}
bool m_doSDF {true}
bool m_doAKT {true}
std::unique_ptr< fastjet::Selector > m_selectPt
std::unique_ptr< fastjet::contrib::FlavRecombiner > m_flavRecombiner
std::unique_ptr< fastjet::JetDefinition > m_aktJetDef
std::unique_ptr< fastjet::JetDefinition > m_ifnJetDef
std::unique_ptr< fastjet::JetDefinition > m_cmpJetDef

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

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

Definition at line 21 of file IRCSafeLabelTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ IRCSafeLabelTool()

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

Constructor.

Definition at line 140 of file IRCSafeLabelTool.cxx.

140 : AsgTool(name) {
141 m_ircsafelabelnames.IFNsingleint = "IRCSafeLabelIFN";
142 m_ircsafelabelnames.CMPsingleint = "IRCSafeLabelCMP";
143 m_ircsafelabelnames.GHSsingleint = "IRCSafeLabelGHS";
144 m_ircsafelabelnames.SDFsingleint = "IRCSafeLabelSDFlav";
145 m_ircsafelabelnames.AKTsingleint = "IRCSafeLabelAKT";
146
147 declareProperty("LabelNameIFN", m_ircsafelabelnames.IFNsingleint, "Name of the jet label attribute to be added (IFN)");
148 declareProperty("LabelNameCMP", m_ircsafelabelnames.CMPsingleint, "Name of the jet label attribute to be added (CMP)");
149 declareProperty("LabelNameGHS", m_ircsafelabelnames.GHSsingleint, "Name of the jet label attribute to be added (GHS)");
150 declareProperty("LabelNameSDF", m_ircsafelabelnames.SDFsingleint, "Name of the jet label attribute to be added (SDF, Marzani et al.)");
151 declareProperty("LabelNameAKT", m_ircsafelabelnames.AKTsingleint, "Name of the jet label attribute to be added (anti-kt with net flavour - NOT IRC SAFE)");
152 declareProperty("EnabledAlgorithms", m_enabledAlgos = {"IFN","CMP","GHS","SDF","AKT"}, "Subset of IRCSafe algorithms to run (IFN, CMP, GHS, SDF, AKT)");
153 declareProperty("TruthJetPtMin", m_truthjetptmin=5000, "Minimum pT of truth jets that are matched to reco for labeling [MeV]");
154 declareProperty("JetPtMin", m_jetptmin=10000, "Minimum pT of reco jets to be labeled [MeV]");
155 declareProperty("DRMax", m_drmax=0.3, "Maximum deltaR between a particle and jet to be labeled");
156 declareProperty("TruthR", m_truthR=0.4, "Radius with which truth particles will be clustered when determining the flavour "
157 "(should be equal to the radius of the tagged jets)");
158
159}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
double m_jetptmin
Minimum pT for jet selection (in MeV)
double m_truthjetptmin
Minimum pT for truth jet to be matched (in MeV)
ParticleJetTools::IRCSafeLabelNames m_ircsafelabelnames
Name of jet label attributes.
std::vector< std::string > m_enabledAlgos
Enabled algorithms (subset of: IFN, CMP, GHS, SDF, AKT)
double m_truthR
Radius of truth jets with undecayed B and D hadrons.
double m_drmax
Maximum dR for matching criterion.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58

Member Function Documentation

◆ 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 }

◆ 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>

◆ decorate()

StatusCode IRCSafeLabelTool::decorate ( const xAOD::JetContainer & jets) const
overridevirtual

Decorate a jet collection without otherwise modifying it.

Implements IJetDecorator.

Definition at line 406 of file IRCSafeLabelTool.cxx.

406 {
407
408 ATH_MSG_VERBOSE("In " << name() << "::modify()");
409 // Retrieve the particle and jet containers
410 SG::ReadHandle<xAOD::TruthParticleContainer> truthPartReadHandle(m_outTruthPartKey);
411 SG::ReadHandle<xAOD::TruthParticleContainer> truthbsReadHandle(m_bottomPartCollectionKey);
412 SG::ReadHandle<xAOD::TruthParticleContainer> truthcsReadHandle(m_charmPartCollectionKey);
413 if (!truthbsReadHandle.isValid()){
414 ATH_MSG_DEBUG(" Invalid ReadHandle for xAOD::ParticleContainer with key: " << truthbsReadHandle.key());
415 return StatusCode::FAILURE;
416 }
417 if (!truthcsReadHandle.isValid()){
418 ATH_MSG_DEBUG(" Invalid ReadHandle for xAOD::ParticleContainer with key: " << truthcsReadHandle.key());
419 return StatusCode::FAILURE;
420 }
421 if (!truthPartReadHandle.isValid()){
422 ATH_MSG_DEBUG(" Invalid ReadHandle for xAOD::ParticleContainer with key: " << truthPartReadHandle.key());
423 return StatusCode::FAILURE;
424 }
425
426 vector< vector<PseudoJet> > all_pseudojets = getJetInputs(*truthPartReadHandle, *truthbsReadHandle, *truthcsReadHandle);
427 vector<PseudoJet> btagged_pseudojetsIFN, ctagged_pseudojetsIFN;
428 vector<PseudoJet> btagged_pseudojetsCMP, ctagged_pseudojetsCMP;
429 vector<PseudoJet> btagged_pseudojetsGHS, ctagged_pseudojetsGHS;
430 vector<PseudoJet> btagged_pseudojetsSDF, ctagged_pseudojetsSDF;
431 vector<PseudoJet> btagged_pseudojetsAKT, ctagged_pseudojetsAKT;
432
433 vector<PseudoJet> selected_pseudojets = all_pseudojets[0];
434 for (unsigned int i_jets = 0; i_jets < selected_pseudojets.size(); i_jets++) {
435 PseudoJet p = selected_pseudojets[i_jets];
436 if(p.user_info<FlavHistory>().current_flavour()[5] != 0) btagged_pseudojetsIFN.push_back(p);
437 if(p.user_info<FlavHistory>().current_flavour()[4] != 0) ctagged_pseudojetsIFN.push_back(p);
438 }
439
440 selected_pseudojets = all_pseudojets[1];
441 for (unsigned int i_jets = 0; i_jets < selected_pseudojets.size(); i_jets++) {
442 PseudoJet p = selected_pseudojets[i_jets];
443 if(p.user_info<FlavHistory>().current_flavour()[5] != 0) btagged_pseudojetsCMP.push_back(p);
444 if(p.user_info<FlavHistory>().current_flavour()[4] != 0) ctagged_pseudojetsCMP.push_back(p);
445 }
446
447 selected_pseudojets = all_pseudojets[2];
448 for (unsigned int i_jets = 0; i_jets < selected_pseudojets.size(); i_jets++) {
449 PseudoJet p = selected_pseudojets[i_jets];
450 if(p.user_info<FlavHistory>().current_flavour()[5] != 0) btagged_pseudojetsGHS.push_back(p);
451 if(p.user_info<FlavHistory>().current_flavour()[4] != 0) ctagged_pseudojetsGHS.push_back(p);
452 }
453
454 selected_pseudojets = all_pseudojets[3];
455 for (unsigned int i_jets = 0; i_jets < selected_pseudojets.size(); i_jets++) {
456 PseudoJet p = selected_pseudojets[i_jets];
457 if(p.user_info<FlavHistory>().current_flavour()[5] != 0) btagged_pseudojetsSDF.push_back(p);
458 if(p.user_info<FlavHistory>().current_flavour()[4] != 0) ctagged_pseudojetsSDF.push_back(p);
459 }
460
461 selected_pseudojets = all_pseudojets[4];
462 for (unsigned int i_jets = 0; i_jets < selected_pseudojets.size(); i_jets++) {
463 PseudoJet p = selected_pseudojets[i_jets];
464 if(p.user_info<FlavHistory>().current_flavour()[5] != 0) btagged_pseudojetsAKT.push_back(p);
465 if(p.user_info<FlavHistory>().current_flavour()[4] != 0) ctagged_pseudojetsAKT.push_back(p);
466 }
467
468 // match the tagged pseudojets to reco jets
469 vector< vector<const PseudoJet*> > jetlabelIFN_b = m_doIFN ? match(btagged_pseudojetsIFN, jets) : vector< vector<const PseudoJet*> >(jets.size());
470 vector< vector<const PseudoJet*> > jetlabelIFN_c = m_doIFN ? match(ctagged_pseudojetsIFN, jets) : vector< vector<const PseudoJet*> >(jets.size());
471 vector< vector<const PseudoJet*> > jetlabelCMP_b = m_doCMP ? match(btagged_pseudojetsCMP, jets) : vector< vector<const PseudoJet*> >(jets.size());
472 vector< vector<const PseudoJet*> > jetlabelCMP_c = m_doCMP ? match(ctagged_pseudojetsCMP, jets) : vector< vector<const PseudoJet*> >(jets.size());
473 vector< vector<const PseudoJet*> > jetlabelGHS_b = m_doGHS ? match(btagged_pseudojetsGHS, jets) : vector< vector<const PseudoJet*> >(jets.size());
474 vector< vector<const PseudoJet*> > jetlabelGHS_c = m_doGHS ? match(ctagged_pseudojetsGHS, jets) : vector< vector<const PseudoJet*> >(jets.size());
475 vector< vector<const PseudoJet*> > jetlabelSDF_b = m_doSDF ? match(btagged_pseudojetsSDF, jets) : vector< vector<const PseudoJet*> >(jets.size());
476 vector< vector<const PseudoJet*> > jetlabelSDF_c = m_doSDF ? match(ctagged_pseudojetsSDF, jets) : vector< vector<const PseudoJet*> >(jets.size());
477 vector< vector<const PseudoJet*> > jetlabelAKT_b = m_doAKT ? match(btagged_pseudojetsAKT, jets) : vector< vector<const PseudoJet*> >(jets.size());
478 vector< vector<const PseudoJet*> > jetlabelAKT_c = m_doAKT ? match(ctagged_pseudojetsAKT, jets) : vector< vector<const PseudoJet*> >(jets.size());
479
480 for (unsigned int iJet = 0; iJet < jets.size(); iJet++) {
481 const Jet& jet = *jets.at(iJet);
482 if (jet.pt() < m_jetptmin) {
483 m_ircsafelabeldecs->IFNsingleint(jet) = 0;
484 m_ircsafelabeldecs->CMPsingleint(jet) = 0;
485 m_ircsafelabeldecs->GHSsingleint(jet) = 0;
486 m_ircsafelabeldecs->SDFsingleint(jet) = 0;
487 m_ircsafelabeldecs->AKTsingleint(jet) = 0;
488 continue;
489 }
490
491 // set truth label for jets above pt threshold
492 // hierarchy: b > c > light
493 ParticleJetTools::Tag_PseudoJets tag_pjet;
494 tag_pjet.IFN_b = jetlabelIFN_b.at(iJet);
495 tag_pjet.IFN_c = jetlabelIFN_c.at(iJet);
496
497 tag_pjet.CMP_b = jetlabelCMP_b.at(iJet);
498 tag_pjet.CMP_c = jetlabelCMP_c.at(iJet);
499
500 tag_pjet.GHS_b = jetlabelGHS_b.at(iJet);
501 tag_pjet.GHS_c = jetlabelGHS_c.at(iJet);
502
503 tag_pjet.SDF_b = jetlabelSDF_b.at(iJet);
504 tag_pjet.SDF_c = jetlabelSDF_c.at(iJet);
505
506 tag_pjet.AKT_b = jetlabelAKT_b.at(iJet);
507 tag_pjet.AKT_c = jetlabelAKT_c.at(iJet);
508
510 }
511
512 return StatusCode::SUCCESS;
513
514}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
void setJetIRCSafeLabels(const xAOD::Jet &jet, const ParticleJetTools::Tag_PseudoJets &tag_pjets, const ParticleJetTools::IRCSafeLabelDecorators &decs, bool doIFN, bool doCMP, bool doGHS, bool doSDF, bool doAKT)
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_bottomPartCollectionKey
Read handles particle collections for labeling. We need all inputs used for jet clustering.
std::unique_ptr< ParticleJetTools::IRCSafeLabelDecorators > m_ircsafelabeldecs
std::vector< std::vector< fastjet::PseudoJet > > getJetInputs(const xAOD::TruthParticleContainer &parts, const xAOD::TruthParticleContainer &label_bs, const xAOD::TruthParticleContainer &label_cs) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_charmPartCollectionKey
std::vector< std::vector< const fastjet::PseudoJet * > > match(std::vector< fastjet::PseudoJet > &tagged_jets, const xAOD::JetContainer &jets) const
Function matching truth pseudojets to reco jets.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_outTruthPartKey
virtual double pt() const
transverse momentum
Jet_v1 Jet
Definition of the current "jet version".
std::vector< const fastjet::PseudoJet * > CMP_b
std::vector< const fastjet::PseudoJet * > CMP_c
std::vector< const fastjet::PseudoJet * > AKT_b
std::vector< const fastjet::PseudoJet * > AKT_c
std::vector< const fastjet::PseudoJet * > IFN_b
std::vector< const fastjet::PseudoJet * > GHS_b
std::vector< const fastjet::PseudoJet * > SDF_c
std::vector< const fastjet::PseudoJet * > IFN_c
std::vector< const fastjet::PseudoJet * > SDF_b
std::vector< const fastjet::PseudoJet * > GHS_c

◆ 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

◆ getJetInputs()

vector< vector< PseudoJet > > IRCSafeLabelTool::getJetInputs ( const xAOD::TruthParticleContainer & parts,
const xAOD::TruthParticleContainer & label_bs,
const xAOD::TruthParticleContainer & label_cs ) const
protected

Definition at line 161 of file IRCSafeLabelTool.cxx.

163 {
164
165 // collect all particles needed
166 vector<const TruthParticle*> bs, cs, truthparts;
167 for (TruthParticleContainer::const_iterator part_itr = parts.begin();
168 part_itr != parts.end(); ++part_itr) {
169 const TruthParticle* part = (*part_itr);
170 truthparts.push_back(part);
171 }
172 for (TruthParticleContainer::const_iterator labels_itr = label_bs.begin();
173 labels_itr != label_bs.end(); ++labels_itr) {
174 const TruthParticle* part = (*labels_itr);
175 bs.push_back(part);
176 }
177 for (TruthParticleContainer::const_iterator labels_itr = label_cs.begin();
178 labels_itr != label_cs.end(); ++labels_itr) {
179 const TruthParticle* part = (*labels_itr);
180 cs.push_back(part);
181 }
182 // remove all children of B and D hadrons
184 childrenRemoved(bs, bs);
185 childrenRemoved(bs, cs);
186 childrenRemoved(bs, truthparts);
187 childrenRemoved(cs, cs);
188 childrenRemoved(cs, truthparts);
189
190 // add original B and D hadrons to the truth particles
191 if (bs.size() > 0) truthparts.insert(truthparts.end(), bs.begin(), bs.end());
192 if (cs.size() > 0) truthparts.insert(truthparts.end(), cs.begin(), cs.end());
193
194 // now, create the PseudoJet event from them
195 vector<PseudoJet> fullevent(truthparts.size());
196 for (unsigned int ip = 0; ip < truthparts.size(); ip++) {
197 const TruthParticle* part = truthparts[ip];
198 double px = part->px();
199 double py = part->py();
200 double pz = part->pz();
201 double E = part->e();
202 fullevent[ip] = PseudoJet(px,py,pz,E);
203 FlavInfo partFlavInfo = HeavyFlavourContent(part->pdgId());
204 fullevent[ip].set_user_info(new FlavInfo(partFlavInfo));
205 }
206
207 vector< vector<PseudoJet> > all_pseudojets(5);
208 if (!(m_doIFN || m_doCMP || m_doGHS || m_doSDF || m_doAKT)) {
209 return all_pseudojets;
210 }
211
212 const Selector& selectpt = *m_selectPt;
213 const FlavRecombiner& flav_recombiner = *m_flavRecombiner;
214 const JetDefinition& akt_jet_def = *m_aktJetDef;
215
216 if (m_doIFN) {
217 const JetDefinition& ifn_jet_def = *m_ifnJetDef;
218 all_pseudojets[0] = selectpt(ifn_jet_def(fullevent));
219 }
220
221 if (m_doCMP) {
222 const JetDefinition& cmp_jet_def = *m_cmpJetDef;
223 all_pseudojets[1] = selectpt(cmp_jet_def(fullevent));
224 }
225
226 vector<PseudoJet> base_jets;
227 if (m_doAKT || m_doGHS || m_doSDF) {
228 base_jets = selectpt(akt_jet_def(fullevent));
229 }
230
231 // GHS parameters:
232 double GHS_alpha = 1.0; // < flav-kt distance parameter alpha
233 double GHS_omega = 0.0; // < omega parameter for GHS_Omega (omega = 0 uses DeltaR_ij^2)
234 double ptcut = 5000.0; // < overall ptcut which is an input to GHS; same as the cut on truth-level jets
235 if (m_doGHS) {
236 all_pseudojets[2] = run_GHS(base_jets, ptcut, GHS_alpha, GHS_omega, flav_recombiner);
237 }
238
239 if (m_doSDF) {
240 SDFlavourCalc sdFlavCalc;
241 vector<PseudoJet> SDF_jets = base_jets;
242 sdFlavCalc(SDF_jets);
243 all_pseudojets[3] = std::move(SDF_jets);
244 }
245
246 if (m_doAKT) {
247 all_pseudojets[4] = std::move(base_jets);
248 }
249
250 return all_pseudojets;
251
252}
FlavInfo HeavyFlavourContent(int pdgId)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::unique_ptr< fastjet::JetDefinition > m_ifnJetDef
std::unique_ptr< fastjet::Selector > m_selectPt
std::unique_ptr< fastjet::JetDefinition > m_aktJetDef
std::unique_ptr< fastjet::contrib::FlavRecombiner > m_flavRecombiner
std::unique_ptr< fastjet::JetDefinition > m_cmpJetDef
void childrenRemoved(const std::vector< const xAOD::TruthParticle * > &parents, std::vector< const xAOD::TruthParticle * > &children)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ 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::TEvent 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::TEvent, 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::TEvent 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::TEvent, 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 IRCSafeLabelTool::initialize ( void )
overridevirtual

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 278 of file IRCSafeLabelTool.cxx.

278 {
279
280 ATH_MSG_DEBUG(" Initializing... ");
281 // initialize truth jet inputs key
282 ATH_CHECK(m_outTruthPartKey.initialize());
285 // build label decorators
287 std::make_unique<ParticleJetTools::IRCSafeLabelDecorators>(m_ircsafelabelnames);
288
289 std::unordered_set<std::string> enabled;
290 for (auto name : m_enabledAlgos) {
291 std::transform(name.begin(), name.end(), name.begin(),
292 [](unsigned char c){ return std::tolower(c); });
293 enabled.insert(name);
294 }
295 m_doIFN = enabled.count("ifn") > 0;
296 m_doCMP = enabled.count("cmp") > 0;
297 m_doGHS = enabled.count("ghs") > 0;
298 m_doSDF = enabled.count("sdf") > 0 || enabled.count("sdflav") > 0;
299 m_doAKT = enabled.count("akt") > 0;
300
301 for (const auto& name : m_enabledAlgos) {
302 std::string lowered = name;
303 std::transform(lowered.begin(), lowered.end(), lowered.begin(),
304 [](unsigned char c){ return std::tolower(c); });
305 if (!(lowered == "ifn" || lowered == "cmp" || lowered == "ghs" ||
306 lowered == "sdf" || lowered == "sdflav" || lowered == "akt")) {
307 ATH_MSG_WARNING("Unknown algorithm in EnabledAlgorithms: " << name);
308 }
309 }
310
311 if (!(m_doIFN || m_doCMP || m_doGHS || m_doSDF || m_doAKT)) {
312 ATH_MSG_WARNING("EnabledAlgorithms is empty; no IRCSafe labelling will be performed.");
313 return StatusCode::SUCCESS;
314 }
315
316 // build algos and other fastjet objects:
317 // pt-cut selector and flavour recombination scheme (b + bbar = no flavour, b + b = 2b)
318 // another option if modulo_2 (b + bbar = b + b = no flavour), but the CMP and SDFlav algorithms are
319 // not set up to work with it.
320 m_selectPt = std::make_unique<Selector>(SelectorPtMin(m_truthjetptmin));
321 m_flavRecombiner = std::make_unique<FlavRecombiner>(FlavRecombiner::net);
322 // anti-kt with net flavour
323 m_aktJetDef = std::make_unique<JetDefinition>(antikt_algorithm, m_truthR);
324 m_aktJetDef->set_recombiner(m_flavRecombiner.get());
325 // interleaved flavour neutralisation - IFN (2306.07314)
326 if (m_doIFN) {
327 auto ifn_plugin = std::make_unique<IFNPlugin>(*m_aktJetDef, 1.0, 2.0, FlavRecombiner::net);
328 m_ifnJetDef = std::make_unique<JetDefinition>(ifn_plugin.get());
329 m_ifnJetDef->delete_plugin_when_unused();
330 ifn_plugin.release();
331 }
332 // Czakon, Mitov, Poncelet (CMP) algorithm - flavour anti-kt (2205.11879)
333 if (m_doCMP) {
334 const double CMP_a = 0.1;
335 // correction to original CMP algo: do not change this if you want IRC safety!
336 const CMPPlugin::CorrectionType CMP_corr = CMPPlugin::CorrectionType::OverAllCoshyCosPhi_a2;
337 // Dynamic definition of ktmax
338 const CMPPlugin::ClusteringType CMP_clust = CMPPlugin::ClusteringType::DynamicKtMax;
339 auto cmp_plugin = std::make_unique<CMPPlugin>(m_truthR, CMP_a, CMP_corr, CMP_clust);
340 m_cmpJetDef = std::make_unique<JetDefinition>(cmp_plugin.get());
341 // enable it to track flavours (default is net flavour)
342 m_cmpJetDef->set_recombiner(m_flavRecombiner.get());
343 m_cmpJetDef->delete_plugin_when_unused();
344 cmp_plugin.release();
345 }
346 // Other algorithms - Gauld, Huss, Stagnitto (GHS) - flavour dressing (2208.11138) and
347 // SDFlav (Caletti, Larkoski, Marzani, Reichelt, 2205.01109) are simple functions of
348 // final-state particles and don't need to be set up externally.
349 return StatusCode::SUCCESS;
350
351}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)

◆ 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.

◆ match()

vector< vector< const PseudoJet * > > IRCSafeLabelTool::match ( std::vector< fastjet::PseudoJet > & tagged_jets,
const xAOD::JetContainer & jets ) const
protected

Function matching truth pseudojets to reco jets.

Definition at line 353 of file IRCSafeLabelTool.cxx.

354 {
355 ATH_MSG_VERBOSE("In " << name() << "::match()");
356
357 vector< vector<const PseudoJet*> > jetlabelparts(jets.size(), vector<const PseudoJet*>());
358
359 // loop over pseudojets and find the best matched jet
360 for (unsigned int i_tj = 0; i_tj < tagged_pseudojets.size(); i_tj++) {
361
362 const PseudoJet* tag_pjet = static_cast<const PseudoJet*>(&tagged_pseudojets[i_tj]);
363
364 double mindr = DBL_MAX;
365 double maxpt = 0;
366 int mindrjetidx = -1;
367 int maxptjetidx = -1;
368 for (unsigned int iJet = 0; iJet < jets.size(); iJet++) {
369
370 const Jet& jet = *jets.at(iJet);
371
372 double pt = jet.pt();
373 if (pt < m_jetptmin)
374 continue;
375
376 double drap = abs(jet.rapidity() - tag_pjet->rap());
377 double dphi = abs(jet.phi() - tag_pjet->phi());
378 if (dphi > numbers::pi) dphi = 2*numbers::pi - dphi;
379 double dr = pow(drap*drap + dphi*dphi, 0.5);
380 // too far for matching criterion
381 if (dr > m_drmax)
382 continue;
383
384 // store the matched jet
385 if (dr < mindr) {
386 mindr = dr;
387 mindrjetidx = iJet;
388 }
389
390 if (pt > maxpt) {
391 maxpt = pt;
392 maxptjetidx = iJet;
393 }
394
395 }
396
397 // store the label particle with the jet
398 if (mindrjetidx >= 0) jetlabelparts.at(mindrjetidx).push_back(tag_pjet);
399 else if (maxptjetidx >= 0) jetlabelparts.at(maxptjetidx).push_back(tag_pjet);
400 }
401
402 return jetlabelparts;
403
404}
virtual double rapidity() const
rapidity
virtual double phi() const
phi in [-pi,pi[
constexpr int pow(int x)
Definition conifer.h:27
setRcore setEtHad setFside pt

◆ modify()

virtual StatusCode IJetDecorator::modify ( xAOD::JetContainer & jets) const
inlinefinaloverridevirtualinherited

Concrete implementation of the function inherited from IJetModifier.

Implements IJetModifier.

Definition at line 32 of file IJetDecorator.h.

32{return decorate(jets);};
virtual StatusCode decorate(const xAOD::JetContainer &jets) const =0
Decorate a jet collection without otherwise modifying it.

◆ 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

◆ 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 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
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 364 of file AthCommonDataStore.h.

364 {
366 }

◆ 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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_aktJetDef

std::unique_ptr<fastjet::JetDefinition> IRCSafeLabelTool::m_aktJetDef
protected

Definition at line 78 of file IRCSafeLabelTool.h.

◆ m_bottomPartCollectionKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> IRCSafeLabelTool::m_bottomPartCollectionKey {this,"BParticleCollection","","ReadHandleKey for bottomPartCollection"}
protected

Read handles particle collections for labeling. We need all inputs used for jet clustering.

Definition at line 50 of file IRCSafeLabelTool.h.

50{this,"BParticleCollection","","ReadHandleKey for bottomPartCollection"};

◆ m_charmPartCollectionKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> IRCSafeLabelTool::m_charmPartCollectionKey {this,"CParticleCollection","","ReadHandleKey for charmPartCollection"}
protected

Definition at line 51 of file IRCSafeLabelTool.h.

51{this,"CParticleCollection","","ReadHandleKey for charmPartCollection"};

◆ m_cmpJetDef

std::unique_ptr<fastjet::JetDefinition> IRCSafeLabelTool::m_cmpJetDef
protected

Definition at line 80 of file IRCSafeLabelTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doAKT

bool IRCSafeLabelTool::m_doAKT {true}
protected

Definition at line 73 of file IRCSafeLabelTool.h.

73{true};

◆ m_doCMP

bool IRCSafeLabelTool::m_doCMP {true}
protected

Definition at line 70 of file IRCSafeLabelTool.h.

70{true};

◆ m_doGHS

bool IRCSafeLabelTool::m_doGHS {true}
protected

Definition at line 71 of file IRCSafeLabelTool.h.

71{true};

◆ m_doIFN

bool IRCSafeLabelTool::m_doIFN {true}
protected

Definition at line 69 of file IRCSafeLabelTool.h.

69{true};

◆ m_doSDF

bool IRCSafeLabelTool::m_doSDF {true}
protected

Definition at line 72 of file IRCSafeLabelTool.h.

72{true};

◆ m_drmax

double IRCSafeLabelTool::m_drmax
protected

Maximum dR for matching criterion.

Definition at line 61 of file IRCSafeLabelTool.h.

◆ m_enabledAlgos

std::vector<std::string> IRCSafeLabelTool::m_enabledAlgos
protected

Enabled algorithms (subset of: IFN, CMP, GHS, SDF, AKT)

Definition at line 67 of file IRCSafeLabelTool.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_flavRecombiner

std::unique_ptr<fastjet::contrib::FlavRecombiner> IRCSafeLabelTool::m_flavRecombiner
protected

Definition at line 77 of file IRCSafeLabelTool.h.

◆ m_ifnJetDef

std::unique_ptr<fastjet::JetDefinition> IRCSafeLabelTool::m_ifnJetDef
protected

Definition at line 79 of file IRCSafeLabelTool.h.

◆ m_ircsafelabeldecs

std::unique_ptr<ParticleJetTools::IRCSafeLabelDecorators> IRCSafeLabelTool::m_ircsafelabeldecs
protected

Definition at line 47 of file IRCSafeLabelTool.h.

◆ m_ircsafelabelnames

ParticleJetTools::IRCSafeLabelNames IRCSafeLabelTool::m_ircsafelabelnames
protected

Name of jet label attributes.

Definition at line 46 of file IRCSafeLabelTool.h.

◆ m_jetptmin

double IRCSafeLabelTool::m_jetptmin
protected

Minimum pT for jet selection (in MeV)

Definition at line 58 of file IRCSafeLabelTool.h.

◆ m_outTruthPartKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> IRCSafeLabelTool::m_outTruthPartKey {this, "TruthParticleCollection","", "ReadHandleKey of the TruthParticle collection"}
protected

Definition at line 52 of file IRCSafeLabelTool.h.

52{this, "TruthParticleCollection","", "ReadHandleKey of the TruthParticle collection"};

◆ m_selectPt

std::unique_ptr<fastjet::Selector> IRCSafeLabelTool::m_selectPt
protected

Definition at line 76 of file IRCSafeLabelTool.h.

◆ m_truthjetptmin

double IRCSafeLabelTool::m_truthjetptmin
protected

Minimum pT for truth jet to be matched (in MeV)

Definition at line 55 of file IRCSafeLabelTool.h.

◆ m_truthR

double IRCSafeLabelTool::m_truthR
protected

Radius of truth jets with undecayed B and D hadrons.

Definition at line 64 of file IRCSafeLabelTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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