ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::BPhysBlindingTool Class Reference

#include <BPhysBlindingTool.h>

Inheritance diagram for xAOD::BPhysBlindingTool:
Collaboration diagram for xAOD::BPhysBlindingTool:

Public Member Functions

 BPhysBlindingTool (const std::string &name="BPhysBlindingTool")
 Declare the correct constructor for Athena.
virtual StatusCode initialize () override
 Method initialising the tool.
virtual StatusCode finalize () override
 Method finalizing the tool.
virtual float doBlind (const float &val) override
 Simply blind one positive float value.
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
Methods to be called by user classes

Simply unblind one (positive) float value with corrections

Parameters
[in]val: Blinded float value.
[in]negativeSign: flip sign before unblinding
[in]offset: after unblinding, shift by offset
[in]factor: after unblinding, stretch by factor
Returns
Unblinded positive float value; same value as input on error.
virtual float doUnblind (const float &val) override
 Simply unblind one positive float value.
virtual float doBlind (const float &val, const bool &negativeSign, const float &offset, const float &factor) override
 Simply blind one (positive) float value with corrections.
virtual float doUnblind (const float &val, const bool &negativeSign, const float &offset, const float &factor) override
 Simply unblind one (positive) float value with corrections.
virtual StatusCode doBlind () override
 Perform blinding of requested variables.
virtual StatusCode doUnblind () override
 Perform unblinding of requested variables.
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

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.
Perform blinding or unblinding action
virtual StatusCode doBlindingAction (bool unblind=false)
Utility methods

Check whether an element is marked as passing a hypothesis.

virtual bool pass (const SG::AuxElement &em, std::string hypo)
virtual std::vector< std::string > getTokens (std::string input, std::string seperators)
 Tokenize a string using certain separators.
virtual std::string vecToString (const std::vector< float > &v) const
 Convert vector of floats to string.
virtual std::string vecToString (const std::vector< bool > &v) const
 Convert vector of bools to string.
Cache current event.
virtual StatusCode cacheEvent ()

Protected Attributes

Job options

Vertex container name

std::string m_vertexContainerName
std::string m_varToBlindNames
 List of variables to blind.
std::string m_blindingFlag
 Flag to indicate candidates for blinding.
std::vector< floatm_vOffsets
 Offsets applied to values before blinding.
std::vector< floatm_vFactors
 Scale factors applied before blinding.
std::vector< boolm_vNegSigns
 Flip signs to negative range?
std::string m_blindKey
 Key for blinding.
std::string m_unblindKey
 Key for unblinding.
Containers
xAOD::VertexContainerm_vtxContainer
xAOD::VertexAuxContainerm_vtxAuxContainer
Event caching
int m_cachedRun
int m_cachedEvent
Counters
long m_eventsForBlindingSeen
long m_candidatesForBlindingSeen
long m_eventsForUnblindingSeen
long m_candidatesForUnblindingSeen
long m_eventsBlinded
long m_candidatesBlinded
long m_eventsUnblinded
long m_candidatesUnblinded

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

std::vector< std::string > m_vVarNames
 Vector of variable names.
SimpleEncrypter m_senc
 Instance of SimpleEncrypter.
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 85 of file BPhysBlindingTool.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

◆ BPhysBlindingTool()

xAOD::BPhysBlindingTool::BPhysBlindingTool ( const std::string & name = "BPhysBlindingTool")

Declare the correct constructor for Athena.

Regular AsgTool constructor

Definition at line 25 of file BPhysBlindingTool.cxx.

26 : asg::AsgTool( name ),
27 m_vtxContainer(nullptr), m_vtxAuxContainer(nullptr),
37
38#ifdef ASGTOOL_ATHENA
39 declareInterface< IBPhysBlindingTool >( this );
40#endif // ASGTOOL_ATHENA
41
42 // Vertex container
43 declareProperty("VertexContainerName", m_vertexContainerName = "");
44
45 // List of variables to blind
46 // (as concatenated string using . as delimiter)
47 declareProperty("VarToBlindNames", m_varToBlindNames = "");
48
49 // Flag to indicate candidates for blinding
50 // Left empty: Blind values for all candidates.
51 declareProperty("BlindingFlag" , m_blindingFlag = "");
52
53 // Offsets applied to values before blinding
54 // List must have same length as VarToBlindNames or zero.
55 declareProperty("BlindingOffsets", m_vOffsets);
56
57 // Scale factors applied before blinding
58 // List must have same length as VarToBlindNames or zero.
59 declareProperty("BlindingFactors", m_vFactors);
60
61 // Flip signs to negative range?
62 declareProperty("NegativeSigns" , m_vNegSigns);
63
64 // Key for blinding
65 declareProperty("BlindingKey" , m_blindKey = "");
66
67 // Key for unblinding
68 declareProperty("UnblindingKey" , m_unblindKey = "");
69
70 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< float > m_vFactors
Scale factors applied before blinding.
std::vector< bool > m_vNegSigns
Flip signs to negative range?
std::string m_varToBlindNames
List of variables to blind.
std::vector< float > m_vOffsets
Offsets applied to values before blinding.
std::string m_blindKey
Key for blinding.
xAOD::VertexContainer * m_vtxContainer
std::string m_blindingFlag
Flag to indicate candidates for blinding.
xAOD::VertexAuxContainer * m_vtxAuxContainer
std::string m_unblindKey
Key for unblinding.

Member Function Documentation

◆ cacheEvent()

StatusCode xAOD::BPhysBlindingTool::cacheEvent ( )
protectedvirtual

Definition at line 351 of file BPhysBlindingTool.cxx.

351 {
352
353 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent -- begin");
354
355 const xAOD::EventInfo* eventInfo = NULL;
356 ATH_CHECK(evtStore()->retrieve(eventInfo, "EventInfo"));
357
358 if ( m_cachedRun != (int)eventInfo->runNumber() ||
359 m_cachedEvent != (int)eventInfo->eventNumber() ) {
360
361 // note update
362 m_cachedRun = eventInfo->runNumber();
363 m_cachedEvent = eventInfo->eventNumber();
364
365 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent: caching now: "
366 << "run " << m_cachedRun << " event " << m_cachedEvent);
367
368 // retrieve vertices container
369 m_vtxContainer = nullptr;
370 m_vtxAuxContainer = nullptr;
371
372 if ( evtStore()->transientContains<xAOD::VertexContainer>(m_vertexContainerName) ) {
373 ATH_MSG_DEBUG("In transient store: " << m_vertexContainerName);
377 m_vertexContainerName+"Aux."));
378 } else {
379 ATH_MSG_DEBUG("Not in transient store: " << m_vertexContainerName);
380 const xAOD::VertexContainer* constVtxContainer = nullptr;
381 const xAOD::VertexAuxContainer* constVtxAuxContainer = nullptr;
382 ATH_CHECK(evtStore()->retrieve(constVtxContainer,
384 ATH_CHECK(evtStore()->retrieve(constVtxAuxContainer,
385 m_vertexContainerName+"Aux."));
386 // create a copy
390 for (const xAOD::Vertex* constVtx : *constVtxContainer) {
391 xAOD::Vertex* vtx = new xAOD::Vertex();
392 m_vtxContainer->push_back(vtx);
393 *vtx = *constVtx;
394 }
398 m_vertexContainerName+"Aux."));
399 }
400
401 ATH_MSG_DEBUG("Found vertex collection with key "
403
404 } // if new run/event
405
406 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent -- end");
407
408 // Return gracefully:
409 return StatusCode::SUCCESS;
410 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ServiceHandle< StoreGateSvc > & evtStore()
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.

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

◆ doBlind() [1/3]

StatusCode xAOD::BPhysBlindingTool::doBlind ( )
overridevirtual

Perform blinding of requested variables.

Implements xAOD::IBPhysBlindingTool.

Definition at line 237 of file BPhysBlindingTool.cxx.

237 {
238
239 if ( m_blindKey == "" ) {
240 ATH_MSG_WARNING("Can not blind without blinding key!");
241 } else {
242 ATH_CHECK( doBlindingAction(false) );
243 }
244
245 // Return gracefully:
246 return StatusCode::SUCCESS;
247 }
#define ATH_MSG_WARNING(x)
virtual StatusCode doBlindingAction(bool unblind=false)

◆ doBlind() [2/3]

float xAOD::BPhysBlindingTool::doBlind ( const float & val)
overridevirtual

Simply blind one positive float value.

Parameters
[in]val: positive float value to blind.
Returns
Blinded positive float value; same value as input on error.

Implements xAOD::IBPhysBlindingTool.

Definition at line 172 of file BPhysBlindingTool.cxx.

172 {
173
174 return m_senc.encrypt(val);
175 }
SimpleEncrypter m_senc
Instance of SimpleEncrypter.

◆ doBlind() [3/3]

float xAOD::BPhysBlindingTool::doBlind ( const float & val,
const bool & negativeSign,
const float & offset,
const float & factor )
overridevirtual

Simply blind one (positive) float value with corrections.

Parameters
[in]val: float value to blind.
[in]negativeSign: flip sign after blinding
[in]offset: before blinding, shift by offset
[in]factor: before blinding, stretch by factor
Returns
Blinded float value; same value as input on error.

Implements xAOD::IBPhysBlindingTool.

Definition at line 186 of file BPhysBlindingTool.cxx.

189 {
190
191 // adjustment if requested
192 float bval(val);
193 float cval = val*factor + offset;
194 if ( cval > 0. ) {
195 // perform actual blinding
196 bval = m_senc.encrypt(cval);
197 if (negativeSign) bval *= -1.;
198 } else {
199 ATH_MSG_WARNING("Blinding: Corrected value not positive: "
200 << val << Form(" (%a) -> ", val)
201 << cval << Form(" (%a)", cval));
202 } // if cval > 0
203
204 return bval;
205 }

◆ doBlindingAction()

StatusCode xAOD::BPhysBlindingTool::doBlindingAction ( bool unblind = false)
protectedvirtual

Definition at line 271 of file BPhysBlindingTool.cxx.

271 {
272
274
275 // counters
276 if ( unblind ) {
278 } else {
280 }
281
282 if ( m_vVarNames.size() > 0 ) {
283 long candidatesBlinded(0);
284 long candidatesUnblinded(0);
285 // loop over vertices
286 // int ivtx(0);
288 vtxItr = m_vtxContainer->begin();
289 vtxItr != m_vtxContainer->end(); ++vtxItr) {
290 // counters
291 if ( unblind ) {
293 } else {
295 }
296 const xAOD::Vertex* vtx = *vtxItr;
297 // check whether to apply (un-)blinding to this candidate
298 if ( m_blindingFlag == "" || pass(*vtx, m_blindingFlag) ) {
299 // counters
300 if ( unblind ) {
301 ++candidatesUnblinded;
302 } else {
303 ++candidatesBlinded;
304 }
305 // loop over variable names
306 for (size_t iv=0; iv<m_vVarNames.size(); ++iv) {
307 SG::AuxElement::Decorator<float> floatDec(m_vVarNames[iv]);
308 // check for variable
309 if ( floatDec.isAvailable(*vtx) ) {
310 float val = floatDec(*vtx);
311 if ( unblind ) {
312 // unblinding
313 floatDec(*vtx) = doUnblind(val, m_vNegSigns[iv],
314 m_vOffsets[iv], m_vFactors[iv]);
315 ATH_MSG_DEBUG("Unblind: " << val << Form(" (%a) -> ", val)
316 << floatDec(*vtx)
317 << Form(" (%a)", floatDec(*vtx)));
318 } else {
319 // blinding
320 floatDec(*vtx) = doBlind(val, m_vNegSigns[iv],
321 m_vOffsets[iv], m_vFactors[iv]);
322 ATH_MSG_DEBUG("Blind: " << val << Form(" (%a) -> ", val)
323 << floatDec(*vtx)
324 << Form(" (%a)", floatDec(*vtx)));
325 } // if unblind
326 } else {
327 ATH_MSG_WARNING("Missing variable " << m_vVarNames[iv]);
328 } // if isAvailable
329 } // for m_vVarNames
330 } // if blinding
331 } // for iv
332 // counters
333 if ( unblind ) {
334 m_candidatesUnblinded += candidatesUnblinded;
335 if ( candidatesUnblinded > 0 ) ++m_eventsUnblinded;
336 } else {
337 m_candidatesBlinded += candidatesBlinded;
338 if ( candidatesBlinded > 0 ) ++m_eventsBlinded;
339 }
340 } // if m_vVarNames.size()
341
342 // Return gracefully:
343 return StatusCode::SUCCESS;
344 }
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual StatusCode cacheEvent()
virtual StatusCode doBlind() override
Perform blinding of requested variables.
virtual StatusCode doUnblind() override
Perform unblinding of requested variables.
std::vector< std::string > m_vVarNames
Vector of variable names.
virtual bool pass(const SG::AuxElement &em, std::string hypo)

◆ doUnblind() [1/3]

StatusCode xAOD::BPhysBlindingTool::doUnblind ( )
overridevirtual

Perform unblinding of requested variables.

Implements xAOD::IBPhysBlindingTool.

Definition at line 251 of file BPhysBlindingTool.cxx.

251 {
252
253 if ( m_unblindKey == "" ) {
254 ATH_MSG_WARNING("Can not unblind without unblinding key!");
255 } else {
257 }
258
259 // Return gracefully:
260 return StatusCode::SUCCESS;
261 }

◆ doUnblind() [2/3]

float xAOD::BPhysBlindingTool::doUnblind ( const float & val)
overridevirtual

Simply unblind one positive float value.

Implements xAOD::IBPhysBlindingTool.

Definition at line 179 of file BPhysBlindingTool.cxx.

179 {
180
181 return m_senc.decrypt(val);
182 }

◆ doUnblind() [3/3]

float xAOD::BPhysBlindingTool::doUnblind ( const float & val,
const bool & negativeSign,
const float & offset,
const float & factor )
overridevirtual

Simply unblind one (positive) float value with corrections.

Implements xAOD::IBPhysBlindingTool.

Definition at line 209 of file BPhysBlindingTool.cxx.

212 {
213
214 float bval(val), cval(val);
215 if (negativeSign) bval *= -1.;
216 // if ( bval > 0. || isnan(bval) ) {
217 if ( bval > 0. || !std::isnormal(bval) ) {
218 // perform actual unblinding
219 cval = m_senc.decrypt(bval);
220 if ( factor != 0. ) {
221 cval = (cval - offset)/factor;
222 } else {
223 ATH_MSG_WARNING("Unblinding: BlindingFactor == 0!: "
224 << val << Form(" (%a)", val));
225 } // if m_vFactors[ivtx] != 0
226 } else {
227 ATH_MSG_WARNING("Unblinding: Corrected value not positive: "
228 << val << Form(" (%a) -> ", val)
229 << bval << Form(" (%a)", bval));
230 } // if bval > 0
231
232 return cval;
233 }

◆ 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

◆ finalize()

StatusCode xAOD::BPhysBlindingTool::finalize ( )
overridevirtual

Method finalizing the tool.

Implements xAOD::IBPhysBlindingTool.

Definition at line 144 of file BPhysBlindingTool.cxx.

144 {
145
146 ATH_MSG_DEBUG( "Finalizing xAOD::BPhysBlindingTool" );
147
148 ATH_MSG_INFO("Statistics for " << name() << ":");
149 ATH_MSG_INFO(Form("N_eventsForBlindingSeen : %10ld",
151 ATH_MSG_INFO(Form("N_eventsBlinded : %10ld",
153 ATH_MSG_INFO(Form("N_eventsForUnblindingSeen : %10ld",
155 ATH_MSG_INFO(Form("N_eventsUnblinded : %10ld",
157 ATH_MSG_INFO(Form("N_candidatesForBlindingSeen : %10ld",
159 ATH_MSG_INFO(Form("N_candidatesBlinded : %10ld",
161 ATH_MSG_INFO(Form("N_candidatesForUnblindingSeen : %10ld",
163 ATH_MSG_INFO(Form("N_candidatesUnblinded : %10ld",
165
166 // Return gracefully:
167 return StatusCode::SUCCESS;
168 }
#define ATH_MSG_INFO(x)

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

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

◆ getTokens()

std::vector< std::string > xAOD::BPhysBlindingTool::getTokens ( std::string input,
std::string seperators )
protectedvirtual

Tokenize a string using certain separators.

Definition at line 426 of file BPhysBlindingTool.cxx.

426 {
427
428 std::vector<std::string> tokens;
429 boost::char_separator<char> sep(seperators.c_str());
430 typedef boost::tokenizer<boost::char_separator<char> > Tokenizer_t;
431 Tokenizer_t tokenizer(input, sep);
432 for (auto& token : tokenizer) {
433 tokens.push_back(token);
434 }
435 return tokens;
436 }

◆ initialize()

StatusCode xAOD::BPhysBlindingTool::initialize ( void )
overridevirtual

Method initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 72 of file BPhysBlindingTool.cxx.

72 {
73
74 // Greet the user:
75 ATH_MSG_DEBUG( "Initializing xAOD::BPhysBlindingTool" );
76
77 // Setup of variables
78 if ( m_vertexContainerName == "" ) {
79 ATH_MSG_INFO("No vertex container name provided.");
80 }
81
82 if ( m_varToBlindNames != "" ) {
84 }
85
86 // Blinding and unblinding keys
87 if ( m_blindKey == "" && m_unblindKey == "" ) {
88 ATH_MSG_ERROR("You must at least set a key for blinding or unblinding!");
89 } else {
90 if ( m_blindKey != "" ) {
91 m_senc.setPubKey(m_blindKey);
92 ATH_MSG_INFO("Setting blinding key.");
93 }
94 if ( m_unblindKey != "" ) {
95 m_senc.setPrivKey(m_unblindKey);
96 ATH_MSG_INFO("Setting unblinding key.");
97 }
98 }
99
100 // make sure offsets vector is of correct length
101 if ( m_vOffsets.size() < m_vVarNames.size() ) {
102 for (uint i=m_vOffsets.size(); i<m_vVarNames.size(); ++i) {
103 m_vOffsets.push_back(0.);
104 }
105 ATH_MSG_INFO("Extending BlindingOffsets list ...");
106 } else if ( m_vOffsets.size() > m_vVarNames.size() ) {
107 ATH_MSG_WARNING("BlindingOffsets list longer than VarToBlindNames.");
108 }
109
110 // make sure scale factors vector is of correct length
111 if ( m_vFactors.size() < m_vVarNames.size() ) {
112 for (uint i=m_vFactors.size(); i<m_vVarNames.size(); ++i) {
113 m_vFactors.push_back(1.);
114 }
115 ATH_MSG_INFO("Extending BlindingOffsets list ...");
116 } else if ( m_vFactors.size() > m_vVarNames.size() ) {
117 ATH_MSG_WARNING("BlindingFactors list longer than VarToBlindNames.");
118 }
119
120 // make sure negative signs vector is of correct length
121 if ( m_vNegSigns.size() < m_vVarNames.size() ) {
122 for (uint i=m_vNegSigns.size(); i<m_vVarNames.size(); ++i) {
123 m_vNegSigns.push_back(1.);
124 }
125 ATH_MSG_INFO("Extending NegativeSigns list ...");
126 } else if ( m_vNegSigns.size() > m_vVarNames.size() ) {
127 ATH_MSG_WARNING("NegativeSigns list longer than VarToBlindNames.");
128 }
129
130 // some info for the job log
131 ATH_MSG_INFO("VertexContainerName : " << m_vertexContainerName);
132 ATH_MSG_INFO("BlindingFlag : " << m_blindingFlag);
133 ATH_MSG_INFO("VarToBlindNames : " << m_varToBlindNames);
134 ATH_MSG_INFO("BlindingOffsets : " << vecToString(m_vOffsets));
135 ATH_MSG_INFO("BlindingFactors : " << vecToString(m_vFactors));
136 ATH_MSG_INFO("NegativeSigns : " << vecToString(m_vNegSigns));
137 ATH_MSG_INFO("BlindingKey : " << m_blindKey);
138 ATH_MSG_INFO("UnblindingKey : " << m_unblindKey);
139
140 // Return gracefully:
141 return StatusCode::SUCCESS;
142 }
#define ATH_MSG_ERROR(x)
unsigned int uint
virtual std::string vecToString(const std::vector< float > &v) const
Convert vector of floats to string.
virtual std::vector< std::string > getTokens(std::string input, std::string seperators)
Tokenize a string using certain separators.

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

◆ pass()

bool xAOD::BPhysBlindingTool::pass ( const SG::AuxElement & em,
std::string hypo )
protectedvirtual

Definition at line 415 of file BPhysBlindingTool.cxx.

415 {
416
417 if ( !hypo.starts_with( "passed_") )
418 hypo = "passed_" + hypo;
420 return flagAcc.isAvailable(em) && flagAcc(em) != 0;
421 }
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572

◆ print()

◆ 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

◆ vecToString() [1/2]

std::string xAOD::BPhysBlindingTool::vecToString ( const std::vector< bool > & v) const
protectedvirtual

Convert vector of bools to string.

Definition at line 453 of file BPhysBlindingTool.cxx.

454 {
455 std::string str("[");
456 for (unsigned int i=0; i<v.size(); ++i) {
457 str += std::to_string(v[i]);
458 if ( i < v.size()-1 ) str += ",";
459 }
460 str += "]";
461 return str;
462 }

◆ vecToString() [2/2]

std::string xAOD::BPhysBlindingTool::vecToString ( const std::vector< float > & v) const
protectedvirtual

Convert vector of floats to string.

Definition at line 440 of file BPhysBlindingTool.cxx.

441 {
442 std::string str("[");
443 for (unsigned int i=0; i<v.size(); ++i) {
444 str += std::to_string(v[i]);
445 if ( i < v.size()-1 ) str += ",";
446 }
447 str += "]";
448 return str;
449 }

Member Data Documentation

◆ m_blindingFlag

std::string xAOD::BPhysBlindingTool::m_blindingFlag
protected

Flag to indicate candidates for blinding.

Left empty: Blind values for all candidates.

Definition at line 209 of file BPhysBlindingTool.h.

◆ m_blindKey

std::string xAOD::BPhysBlindingTool::m_blindKey
protected

Key for blinding.

Definition at line 230 of file BPhysBlindingTool.h.

◆ m_cachedEvent

int xAOD::BPhysBlindingTool::m_cachedEvent
protected

Definition at line 247 of file BPhysBlindingTool.h.

◆ m_cachedRun

int xAOD::BPhysBlindingTool::m_cachedRun
protected

Definition at line 246 of file BPhysBlindingTool.h.

◆ m_candidatesBlinded

long xAOD::BPhysBlindingTool::m_candidatesBlinded
protected

Definition at line 259 of file BPhysBlindingTool.h.

◆ m_candidatesForBlindingSeen

long xAOD::BPhysBlindingTool::m_candidatesForBlindingSeen
protected

Definition at line 255 of file BPhysBlindingTool.h.

◆ m_candidatesForUnblindingSeen

long xAOD::BPhysBlindingTool::m_candidatesForUnblindingSeen
protected

Definition at line 257 of file BPhysBlindingTool.h.

◆ m_candidatesUnblinded

long xAOD::BPhysBlindingTool::m_candidatesUnblinded
protected

Definition at line 261 of file BPhysBlindingTool.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_eventsBlinded

long xAOD::BPhysBlindingTool::m_eventsBlinded
protected

Definition at line 258 of file BPhysBlindingTool.h.

◆ m_eventsForBlindingSeen

long xAOD::BPhysBlindingTool::m_eventsForBlindingSeen
protected

Definition at line 254 of file BPhysBlindingTool.h.

◆ m_eventsForUnblindingSeen

long xAOD::BPhysBlindingTool::m_eventsForUnblindingSeen
protected

Definition at line 256 of file BPhysBlindingTool.h.

◆ m_eventsUnblinded

long xAOD::BPhysBlindingTool::m_eventsUnblinded
protected

Definition at line 260 of file BPhysBlindingTool.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_senc

SimpleEncrypter xAOD::BPhysBlindingTool::m_senc
private

Instance of SimpleEncrypter.

Definition at line 272 of file BPhysBlindingTool.h.

◆ m_unblindKey

std::string xAOD::BPhysBlindingTool::m_unblindKey
protected

Key for unblinding.

Definition at line 233 of file BPhysBlindingTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_varToBlindNames

std::string xAOD::BPhysBlindingTool::m_varToBlindNames
protected

List of variables to blind.

(as concatenated string using . as delimiter)

Definition at line 204 of file BPhysBlindingTool.h.

◆ m_vertexContainerName

std::string xAOD::BPhysBlindingTool::m_vertexContainerName
protected

Definition at line 199 of file BPhysBlindingTool.h.

◆ m_vFactors

std::vector<float> xAOD::BPhysBlindingTool::m_vFactors
protected

Scale factors applied before blinding.

List must have same length as VarToBlindNames or zero. Applied before blinding/after unblinding.

Definition at line 221 of file BPhysBlindingTool.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_vNegSigns

std::vector<bool> xAOD::BPhysBlindingTool::m_vNegSigns
protected

Flip signs to negative range?

List must have same length as VarToBlindNames or zero. Applied after blinding/before unblinding.

Definition at line 227 of file BPhysBlindingTool.h.

◆ m_vOffsets

std::vector<float> xAOD::BPhysBlindingTool::m_vOffsets
protected

Offsets applied to values before blinding.

List must have same length as VarToBlindNames or zero. Applied before blinding/after unblinding.

Definition at line 215 of file BPhysBlindingTool.h.

◆ m_vtxAuxContainer

xAOD::VertexAuxContainer* xAOD::BPhysBlindingTool::m_vtxAuxContainer
protected

Definition at line 240 of file BPhysBlindingTool.h.

◆ m_vtxContainer

xAOD::VertexContainer* xAOD::BPhysBlindingTool::m_vtxContainer
protected

Definition at line 239 of file BPhysBlindingTool.h.

◆ m_vVarNames

std::vector<std::string> xAOD::BPhysBlindingTool::m_vVarNames
private

Vector of variable names.

Definition at line 267 of file BPhysBlindingTool.h.


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