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 24 of file BPhysBlindingTool.cxx.

25 : asg::AsgTool( name ),
26 m_vtxContainer(nullptr), m_vtxAuxContainer(nullptr),
36
37#ifdef ASGTOOL_ATHENA
38 declareInterface< IBPhysBlindingTool >( this );
39#endif // ASGTOOL_ATHENA
40
41 // Vertex container
42 declareProperty("VertexContainerName", m_vertexContainerName = "");
43
44 // List of variables to blind
45 // (as concatenated string using . as delimiter)
46 declareProperty("VarToBlindNames", m_varToBlindNames = "");
47
48 // Flag to indicate candidates for blinding
49 // Left empty: Blind values for all candidates.
50 declareProperty("BlindingFlag" , m_blindingFlag = "");
51
52 // Offsets applied to values before blinding
53 // List must have same length as VarToBlindNames or zero.
54 declareProperty("BlindingOffsets", m_vOffsets);
55
56 // Scale factors applied before blinding
57 // List must have same length as VarToBlindNames or zero.
58 declareProperty("BlindingFactors", m_vFactors);
59
60 // Flip signs to negative range?
61 declareProperty("NegativeSigns" , m_vNegSigns);
62
63 // Key for blinding
64 declareProperty("BlindingKey" , m_blindKey = "");
65
66 // Key for unblinding
67 declareProperty("UnblindingKey" , m_unblindKey = "");
68
69 }
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 350 of file BPhysBlindingTool.cxx.

350 {
351
352 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent -- begin");
353
354 const xAOD::EventInfo* eventInfo = NULL;
355 ATH_CHECK(evtStore()->retrieve(eventInfo, "EventInfo"));
356
357 if ( m_cachedRun != (int)eventInfo->runNumber() ||
358 m_cachedEvent != (int)eventInfo->eventNumber() ) {
359
360 // note update
361 m_cachedRun = eventInfo->runNumber();
362 m_cachedEvent = eventInfo->eventNumber();
363
364 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent: caching now: "
365 << "run " << m_cachedRun << " event " << m_cachedEvent);
366
367 // retrieve vertices container
368 m_vtxContainer = nullptr;
369 m_vtxAuxContainer = nullptr;
370
371 if ( evtStore()->transientContains<xAOD::VertexContainer>(m_vertexContainerName) ) {
372 ATH_MSG_DEBUG("In transient store: " << m_vertexContainerName);
376 m_vertexContainerName+"Aux."));
377 } else {
378 ATH_MSG_DEBUG("Not in transient store: " << m_vertexContainerName);
379 const xAOD::VertexContainer* constVtxContainer = nullptr;
380 const xAOD::VertexAuxContainer* constVtxAuxContainer = nullptr;
381 ATH_CHECK(evtStore()->retrieve(constVtxContainer,
383 ATH_CHECK(evtStore()->retrieve(constVtxAuxContainer,
384 m_vertexContainerName+"Aux."));
385 // create a copy
389 for (const xAOD::Vertex* constVtx : *constVtxContainer) {
390 xAOD::Vertex* vtx = new xAOD::Vertex();
391 m_vtxContainer->push_back(vtx);
392 *vtx = *constVtx;
393 }
397 m_vertexContainerName+"Aux."));
398 }
399
400 ATH_MSG_DEBUG("Found vertex collection with key "
402
403 } // if new run/event
404
405 ATH_MSG_DEBUG("BPhysBlindingTool::cacheEvent -- end");
406
407 // Return gracefully:
408 return StatusCode::SUCCESS;
409 }
#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.
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 236 of file BPhysBlindingTool.cxx.

236 {
237
238 if ( m_blindKey == "" ) {
239 ATH_MSG_WARNING("Can not blind without blinding key!");
240 } else {
241 ATH_CHECK( doBlindingAction(false) );
242 }
243
244 // Return gracefully:
245 return StatusCode::SUCCESS;
246 }
#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 171 of file BPhysBlindingTool.cxx.

171 {
172
173 return m_senc.encrypt(val);
174 }
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 185 of file BPhysBlindingTool.cxx.

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

◆ doBlindingAction()

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

Definition at line 270 of file BPhysBlindingTool.cxx.

270 {
271
273
274 // counters
275 if ( unblind ) {
277 } else {
279 }
280
281 if ( m_vVarNames.size() > 0 ) {
282 long candidatesBlinded(0);
283 long candidatesUnblinded(0);
284 // loop over vertices
285 // int ivtx(0);
287 vtxItr = m_vtxContainer->begin();
288 vtxItr != m_vtxContainer->end(); ++vtxItr) {
289 // counters
290 if ( unblind ) {
292 } else {
294 }
295 const xAOD::Vertex* vtx = *vtxItr;
296 // check whether to apply (un-)blinding to this candidate
297 if ( m_blindingFlag == "" || pass(*vtx, m_blindingFlag) ) {
298 // counters
299 if ( unblind ) {
300 ++candidatesUnblinded;
301 } else {
302 ++candidatesBlinded;
303 }
304 // loop over variable names
305 for (size_t iv=0; iv<m_vVarNames.size(); ++iv) {
306 SG::AuxElement::Decorator<float> floatDec(m_vVarNames[iv]);
307 // check for variable
308 if ( floatDec.isAvailable(*vtx) ) {
309 float val = floatDec(*vtx);
310 if ( unblind ) {
311 // unblinding
312 floatDec(*vtx) = doUnblind(val, m_vNegSigns[iv],
313 m_vOffsets[iv], m_vFactors[iv]);
314 ATH_MSG_DEBUG("Unblind: " << val << Form(" (%a) -> ", val)
315 << floatDec(*vtx)
316 << Form(" (%a)", floatDec(*vtx)));
317 } else {
318 // blinding
319 floatDec(*vtx) = doBlind(val, m_vNegSigns[iv],
320 m_vOffsets[iv], m_vFactors[iv]);
321 ATH_MSG_DEBUG("Blind: " << val << Form(" (%a) -> ", val)
322 << floatDec(*vtx)
323 << Form(" (%a)", floatDec(*vtx)));
324 } // if unblind
325 } else {
326 ATH_MSG_WARNING("Missing variable " << m_vVarNames[iv]);
327 } // if isAvailable
328 } // for m_vVarNames
329 } // if blinding
330 } // for iv
331 // counters
332 if ( unblind ) {
333 m_candidatesUnblinded += candidatesUnblinded;
334 if ( candidatesUnblinded > 0 ) ++m_eventsUnblinded;
335 } else {
336 m_candidatesBlinded += candidatesBlinded;
337 if ( candidatesBlinded > 0 ) ++m_eventsBlinded;
338 }
339 } // if m_vVarNames.size()
340
341 // Return gracefully:
342 return StatusCode::SUCCESS;
343 }
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 250 of file BPhysBlindingTool.cxx.

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

◆ doUnblind() [2/3]

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

Simply unblind one positive float value.

Implements xAOD::IBPhysBlindingTool.

Definition at line 178 of file BPhysBlindingTool.cxx.

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

◆ 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 208 of file BPhysBlindingTool.cxx.

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

◆ 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 143 of file BPhysBlindingTool.cxx.

143 {
144
145 ATH_MSG_DEBUG( "Finalizing xAOD::BPhysBlindingTool" );
146
147 ATH_MSG_INFO("Statistics for " << name() << ":");
148 ATH_MSG_INFO(Form("N_eventsForBlindingSeen : %10ld",
150 ATH_MSG_INFO(Form("N_eventsBlinded : %10ld",
152 ATH_MSG_INFO(Form("N_eventsForUnblindingSeen : %10ld",
154 ATH_MSG_INFO(Form("N_eventsUnblinded : %10ld",
156 ATH_MSG_INFO(Form("N_candidatesForBlindingSeen : %10ld",
158 ATH_MSG_INFO(Form("N_candidatesBlinded : %10ld",
160 ATH_MSG_INFO(Form("N_candidatesForUnblindingSeen : %10ld",
162 ATH_MSG_INFO(Form("N_candidatesUnblinded : %10ld",
164
165 // Return gracefully:
166 return StatusCode::SUCCESS;
167 }
#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::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

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

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

Definition at line 119 of file AsgTool.cxx.

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

◆ getName()

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

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

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

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

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

Definition at line 106 of file AsgTool.cxx.

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

◆ getProperty()

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

Get one of the tool's properties.

◆ getTokens()

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

Tokenize a string using certain separators.

Definition at line 425 of file BPhysBlindingTool.cxx.

425 {
426
427 return CxxUtils::tokenize(input, seperators);
428 }
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.

◆ initialize()

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

Method initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 71 of file BPhysBlindingTool.cxx.

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

414 {
415
416 if ( !hypo.starts_with( "passed_") )
417 hypo = "passed_" + hypo;
418 SG::AuxElement::Accessor<Char_t> flagAcc(hypo);
419 return flagAcc.isAvailable(em) && flagAcc(em) != 0;
420 }

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

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 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 445 of file BPhysBlindingTool.cxx.

446 {
447 std::string str("[");
448 for (unsigned int i=0; i<v.size(); ++i) {
449 str += std::to_string(v[i]);
450 if ( i < v.size()-1 ) str += ",";
451 }
452 str += "]";
453 return str;
454 }

◆ vecToString() [2/2]

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

Convert vector of floats to string.

Definition at line 432 of file BPhysBlindingTool.cxx.

433 {
434 std::string str("[");
435 for (unsigned int i=0; i<v.size(); ++i) {
436 str += std::to_string(v[i]);
437 if ( i < v.size()-1 ) str += ",";
438 }
439 str += "]";
440 return str;
441 }

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: