ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXML::BJetRetriever Class Reference

Retrieves Jet objects, filter from weight for BJet (JetEvent/Jet) More...

#include <BJetRetriever.h>

Inheritance diagram for JiveXML::BJetRetriever:
Collaboration diagram for JiveXML::BJetRetriever:

Public Member Functions

 BJetRetriever (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool)
 Retrieve all the data.
const DataMap getData (const JetCollection *)
 Retrieve basic parameters, mainly four-vectors.
virtual std::string dataTypeName () const
 Return the name of the data type.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Return the interface identifier.

Protected Member Functions

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.

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

const std::string m_typeName
 The data type that is generated by this retriever.
std::string m_sgKeyFavourite
std::vector< std::string > m_otherKeys
bool m_doWriteHLT {}
float m_weightCut {}
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

Retrieves Jet objects, filter from weight for BJet (JetEvent/Jet)

  • Properties
    • FavouriteJetCollection
    • OtherJetCollections
    • DoWriteHLT
  • Retrieved Data
    • Usual four-vector: phi, eta, et, mass, energy, px, py, pz . - Some extras for jet: flavourTagWeight, charge
    • No cells in AOD Jets.

Definition at line 32 of file BJetRetriever.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

◆ BJetRetriever()

JiveXML::BJetRetriever::BJetRetriever ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard Constructor.

This is the standard AthAlgTool constructor.

Parameters
typeAlgTool type name
nameAlgTool instance name
parentAlgTools parent owning this tool

Definition at line 19 of file BJetRetriever.cxx.

19 :
20 AthAlgTool(type,name,parent),
21 m_typeName("BJet"){
22
23 //Only declare the interface
24 declareInterface<IDataRetriever>(this);
25
26 declareProperty("FavouriteJetCollection" ,m_sgKeyFavourite = "AntiKt4TopoEMJets",
27 "Collection to be first in output, shown in Atlantis without switching");
28 declareProperty("OtherJetCollections" ,m_otherKeys,
29 "Other collections to be retrieved. If list left empty, all available retrieved");
30 declareProperty("DoWriteHLT", m_doWriteHLT = false,"Ignore HLTAutokey object by default."); // ignore HLTAutoKey objects
31 declareProperty("WeightCut", m_weightCut = 2.4,"Weight cut flavourTagWeight, to assign lhSig = 1. Currently: JetFitterCOMBNN");
32 // >2.4 is recommended cut for JetFitterCOMBNN. 30Nov11
33 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_sgKeyFavourite
const std::string m_typeName
The data type that is generated by this retriever.
std::vector< std::string > m_otherKeys

Member Function Documentation

◆ dataTypeName()

virtual std::string JiveXML::BJetRetriever::dataTypeName ( ) const
inlinevirtual

Return the name of the data type.

Implements JiveXML::IDataRetriever.

Definition at line 45 of file BJetRetriever.h.

45{ return m_typeName; };

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

◆ 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

◆ getData()

const DataMap JiveXML::BJetRetriever::getData ( const JetCollection * jets)

Retrieve basic parameters, mainly four-vectors.

AOD Jets have no cells (trying to access them without back-navigation causes Athena crash). Only written out if 'good' B-Jet, assigned from flavourTagWeight

Parameters
FormatToolthe tool that will create formated output from the DataMap

Definition at line 116 of file BJetRetriever.cxx.

116 {
117
118 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "retrieve()" << endmsg;
119
121
122 DataVect phi; phi.reserve(jets->size());
123 DataVect eta; eta.reserve(jets->size());
124 DataVect pt; pt.reserve(jets->size());
125 DataVect energy; energy.reserve(jets->size());
126
127 DataVect mass; mass.reserve(jets->size());
128 DataVect px; px.reserve(jets->size());
129 DataVect py; py.reserve(jets->size());
130 DataVect pz; pz.reserve(jets->size());
131
132 DataVect weight; weight.reserve(jets->size());
133 DataVect lhSig; lhSig.reserve(jets->size());
134 DataVect charge; charge.reserve(jets->size());
135 DataVect label; label.reserve(jets->size());
136
137 float dummyLhSig = 0.;
138
139 std::string myLabel ="none";
140
141 if ( jets->size() == 0 ){
142 ATH_MSG_DEBUG( "JetCollection for BJets is empty" );
143 }else{
144 JetCollection::const_iterator itr = jets->begin();
145 for (; itr != jets->end(); ++itr) {
146
147 // lhSig obsolete from 14.2.x ! Now: weight.
148 // for backwards compatibility: AtlantisJava uses still lhSig.
150 // if ( (*itr)->getFlavourTagWeight() > m_weightCut ){ // 'good' BJet
153 //
154 if ( (*itr)->getFlavourTagWeight("JetFitterCOMBNN") > m_weightCut ){ // 'good' BJet
155 dummyLhSig = 1.;
156 }else{
157 dummyLhSig = 0.;
158 }
159 std::string myLabel ="none";
160 myLabel =
161 "weight_JetFitterCOMBNN=" + DataType( (*itr)->getFlavourTagWeight("JetFitterCOMBNN") ).toString() + "_"
162 + "WeightJetFitterTagNN=" + DataType( (*itr)->getFlavourTagWeight("JetFitterTagNN") ).toString() + "_"
163 + "WeightIP3DSV1=" + DataType( (*itr)->getFlavourTagWeight() ).toString() + "_"
164 + "WeightIP2D=" + DataType( (*itr)->getFlavourTagWeight("IP2D") ).toString() + "_"
165 + "WeightIP3D=" + DataType( (*itr)->getFlavourTagWeight("IP3D") ).toString() + "_"
166 + "WeightSV1=" + DataType( (*itr)->getFlavourTagWeight("SV1") ).toString() + "_"
167 + "WeightSV2=" + DataType( (*itr)->getFlavourTagWeight("SV2") ).toString() + "_";
168
169 phi.emplace_back((*itr)->phi());
170 eta.emplace_back((*itr)->eta());
171 pt.emplace_back((*itr)->pt()/CLHEP::GeV);
172 energy.emplace_back( (*itr)->e()/CLHEP::GeV );
173 mass.emplace_back((*itr)->m()/CLHEP::GeV);
174 px.emplace_back( (*itr)->px()/CLHEP::GeV );
175 py.emplace_back( (*itr)->py()/CLHEP::GeV );
176 pz.emplace_back( (*itr)->pz()/CLHEP::GeV );
177 weight.emplace_back( (*itr)->getFlavourTagWeight("JetFitterCOMBNN")); // recommended choice 30Nov11
178 lhSig.emplace_back( dummyLhSig ); // dummy only ! See above.
179 charge.emplace_back( (*itr)->charge());
180 label.emplace_back( myLabel );
181 }
182 }
183 // Start with mandatory entries
184 const auto nEntries = phi.size();
185 DataMap["phi"] = std::move(phi);
186 DataMap["eta"] = std::move(eta);
187 DataMap["pt"] = std::move(pt);
188 DataMap["energy"] = std::move(energy);
189 // four-vectors
190 DataMap["mass"] = std::move(mass);
191 DataMap["px"] = std::move(px);
192 DataMap["py"] = std::move(py);
193 DataMap["pz"] = std::move(pz);
194
195 // further details
196 DataMap["weight"] = std::move(weight);
197 DataMap["lhSig"] = std::move(lhSig);
198 DataMap["charge"] = std::move(charge);
199 DataMap["label"] = std::move(label);
200
201 ATH_MSG_DEBUG( dataTypeName() << " BJets (AOD, no cells), collection: " << dataTypeName()
202 << " retrieved with " << nEntries << " entries, weight cut set to: "
203 << m_weightCut);
204
205 //All collections retrieved okay
206 return DataMap;
207
208 } // retrieve
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual std::string dataTypeName() const
Return the name of the data type.
std::string label(const std::string &format, int i)
Definition label.h:19
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58

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

◆ interfaceID()

const InterfaceID & JiveXML::IDataRetriever::interfaceID ( )
inlinestaticinherited

Return the interface identifier.

Definition at line 40 of file IDataRetriever.h.

40{ return IID_IDataRetriever; }
static const InterfaceID IID_IDataRetriever("JiveXML::IDataRetriever", 3, 0)

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

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

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

◆ retrieve()

StatusCode JiveXML::BJetRetriever::retrieve ( ToolHandle< IFormatTool > & FormatTool)
virtual

Retrieve all the data.

For each jet collections retrieve basic parameters.

'Favourite' jet collection first, then 'Other' jet collections.

Parameters
FormatToolthe tool that will create formated output from the DataMap

Implements JiveXML::IDataRetriever.

Definition at line 40 of file BJetRetriever.cxx.

40 {
41
42 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "in retrieveAll()" << endmsg;
43
44 SG::ConstIterator<JetCollection> iterator, end;
45 const JetCollection* jets;
46
47 //obtain the default collection first
48 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trying to retrieve " << dataTypeName() << " (" << m_sgKeyFavourite << ")" << endmsg;
49 StatusCode sc = evtStore()->retrieve(jets, m_sgKeyFavourite);
50 if (sc.isFailure() ) {
51 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << m_sgKeyFavourite << " not found in SG " << endmsg;
52 }else{
53 DataMap data = getData(jets);
54 if ( FormatTool->AddToEvent(dataTypeName(), m_sgKeyFavourite+"_AOD", &data).isFailure()){
55 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << m_sgKeyFavourite << " not found in SG " << endmsg;
56 }else{
57 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << " (" << m_sgKeyFavourite << ") BJet retrieved" << endmsg;
58 }
59 }
60
61 if ( m_otherKeys.empty() ) {
62 //obtain all other collections from StoreGate
63 if (( evtStore()->retrieve(iterator, end)).isFailure()){
64 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Unable to retrieve iterator for Jet collection" << endmsg;
65// return false;
66 }
67
68 for (; iterator!=end; ++iterator) {
69
70 std::string::size_type position = iterator.key().find("HLTAutoKey",0);
71 if ( m_doWriteHLT ){ position = 99; } // override SG key find
72
73// if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " BJet: HLTAutoKey in " << iterator.key() << " at position "
74// << position << endmsg;
75 if ( position != 0 ){ // SG key doesn't contain HLTAutoKey
76 if (iterator.key()!=m_sgKeyFavourite) {
77 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trying to retrieve all " << dataTypeName() << " (" << iterator.key() << ")" << endmsg;
78 DataMap data = getData(&(*iterator));
79 if ( FormatTool->AddToEvent(dataTypeName(), iterator.key()+"_AOD", &data).isFailure()){
80 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << iterator.key() << " not found in SG " << endmsg;
81 }else{
82 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << " (" << iterator.key() << ") BJet retrieved" << endmsg;
83 }
84 }
85 }
86 }
87 }else {
88 //obtain all collections with the given keys
89 std::vector<std::string>::const_iterator keyIter;
90 for ( keyIter=m_otherKeys.begin(); keyIter!=m_otherKeys.end(); ++keyIter ){
91 if ( !evtStore()->contains<JetCollection>( (*keyIter) ) ){ continue; } // skip if not in SG
92 StatusCode sc = evtStore()->retrieve( jets, (*keyIter) );
93 if (!sc.isFailure()) {
94 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trying to retrieve selected " << dataTypeName() << " (" << (*keyIter) << ")" << endmsg;
95 DataMap data = getData(jets);
96 if ( FormatTool->AddToEvent(dataTypeName(), (*keyIter)+"_AOD", &data).isFailure()){
97 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << (*keyIter) << " not found in SG " << endmsg;
98 }else{
99 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << " (" << (*keyIter) << ") retrieved" << endmsg;
100 }
101 }
102 }
103 }
104 //All collections retrieved okay
105 return StatusCode::SUCCESS;
106 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
JetCollection
static Double_t sc
ServiceHandle< StoreGateSvc > & evtStore()
const DataMap getData(const JetCollection *)
Retrieve basic parameters, mainly four-vectors.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
::StatusCode StatusCode
StatusCode definition for legacy code.
JetConstituentVector::iterator iterator

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

bool JiveXML::BJetRetriever::m_doWriteHLT {}
private

Definition at line 53 of file BJetRetriever.h.

53{};

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

std::vector<std::string> JiveXML::BJetRetriever::m_otherKeys
private

Definition at line 52 of file BJetRetriever.h.

◆ m_sgKeyFavourite

std::string JiveXML::BJetRetriever::m_sgKeyFavourite
private

Definition at line 51 of file BJetRetriever.h.

◆ m_typeName

const std::string JiveXML::BJetRetriever::m_typeName
private

The data type that is generated by this retriever.

Definition at line 49 of file BJetRetriever.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.

◆ m_weightCut

float JiveXML::BJetRetriever::m_weightCut {}
private

Definition at line 54 of file BJetRetriever.h.

54{};

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