![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
27 TempInterface (
size_t size) : m_size (
size) {}
36 virtual size_t size_v()
const {
return m_size; }
37 virtual size_t capacity_v()
const {
return m_size; }
60 switch( typeidType ) {
98 msg << MSG::ERROR <<
"Received an unknown type: " << typeidType
110 bool auxItemExists(
const std::string&
key ) {
115 return reg.findAuxID(
key ) != SG::null_auxid;
122 ISvcLocator* svcLoc )
123 :
EL::AnaAlgorithm(
name, svcLoc ) {
131 return StatusCode::FAILURE;
141 return StatusCode::SUCCESS;
153 return StatusCode::FAILURE;
169 return StatusCode::SUCCESS;
175 return StatusCode::SUCCESS;
182 for(
const std::string& branchDecl :
m_branches ) {
194 for(
const std::string& branchDecl :
m_branches ) {
200 return StatusCode::SUCCESS;
217 re(
"\\s*([\\w%]+)\\.([\\w%]+)\\s*->\\s*([\\w%]+)" );
221 if( ! std::regex_match( branchDecl,
match,
re ) ) {
223 <<
"\" doesn't match \"<object>.<variable> ->"
225 return StatusCode::FAILURE;
231 bool systematicsContainer{
false};
232 bool systematicsDecoration{
false};
233 bool affectedContainer{
true};
234 bool affectedDecoration{
true};
238 if(
key.find(
"%SYS%" ) != std::string::npos )
240 systematicsContainer =
true;
245 ATH_MSG_VERBOSE(
"Container \"" <<
key <<
"\" is not affected by systematics \"" <<
sys.name() <<
"\"" );
246 affectedContainer =
false;
251 std::string auxName =
match[ 2 ];
252 if( auxName.find(
"%SYS%" ) != std::string::npos )
254 systematicsDecoration =
true;
256 if( affecting.
empty() )
262 const auto nosysInKey =
key.find(
"NOSYS" );
263 if( nosysInKey != std::string::npos )
265 std::string sysKey =
key;
266 sysKey.replace (nosysInKey, 5,
"%SYS%");
273 if( affectingObject.
find( variation ) == affectingObject.
end() )
275 affecting.
insert( variation );
283 ATH_MSG_VERBOSE(
"Decoration \"" << auxName <<
"\" is not affected by systematics \"" <<
sys.name() <<
"\"" );
284 affectedDecoration =
false;
291 && ( ( systematicsContainer && systematicsDecoration && !affectedContainer && !affectedDecoration )
292 || ( !systematicsContainer && systematicsDecoration && !affectedDecoration )
293 || ( systematicsContainer && !systematicsDecoration && !affectedContainer ) ) )
295 ANA_MSG_VERBOSE(
"Neither container nor decoration are affected by systematics \"" <<
sys.name() <<
"\""
296 <<
" for branch rule \"" << branchDecl <<
"\"" );
297 return StatusCode::SUCCESS;
302 if(
brName.find(
"%SYS%" ) != std::string::npos )
310 return StatusCode::SUCCESS;
319 "inconsistently in: \"" << branchDecl
321 return StatusCode::FAILURE;
325 static const bool ALLOW_MISSING =
false;
326 bool branchCreated =
false;
329 bool created =
false;
337 <<
"\" from object/variable \"" <<
key
338 <<
"." << auxName <<
"\"" );
339 branchCreated =
true;
342 <<
"\" from object/variable \"" <<
key
343 <<
"." << auxName <<
"\"" );
348 if( ! branchCreated ) {
350 << branchDecl <<
"\""
351 <<
" and systematics: \""
352 <<
sys.name() <<
"\"" );
353 return StatusCode::FAILURE;
357 return StatusCode::SUCCESS;
361 :
asg::AsgMessaging(
"CP::AsgxAODMetNTupleMakerAlg::ElementProcessor" ) {
374 return StatusCode::SUCCESS;
379 const std::string& branchName,
389 BranchFinder(
const std::string& branchName ) :
m_name( branchName ) {}
391 bool operator()( argument_type bp )
const {
392 return ( bp.m_branchName ==
m_name );
399 bool validAuxItem = auxItemExists( auxName );
400 if( ! validAuxItem ) {
404 <<
"\" not readable for branch \""
405 << branchName <<
"\"" );
406 return StatusCode::SUCCESS;
410 <<
"\" not readable for branch \""
411 << branchName <<
"\"" );
412 return StatusCode::FAILURE;
418 BranchFinder( branchName ) );
420 ATH_MSG_WARNING(
"Duplicate setup received for branch: " << branchName );
421 return StatusCode::SUCCESS;
431 return StatusCode::SUCCESS;
436 setup( TTree&
tree,
const std::string& auxName,
437 const std::string& branchName, MsgStream&
msg ) {
440 m_branchName = branchName;
447 const std::type_info* ti =
reg.getType( m_acc->auxid() );
450 <<
"No std::type_info available for auxiliary variable: "
452 return StatusCode::FAILURE;
454 m_factory =
reg.getFactory( m_acc->auxid() );
456 msg << MSG::ERROR <<
"No factory found for auxiliary variable: "
458 return StatusCode::FAILURE;
462 m_data = m_factory->create( m_acc->auxid(), 1, 1,
false );
465 TBranch*
br =
nullptr;
468 if( strlen( ti->name() ) == 1 ) {
473 const char rType =
rootType( ti->name()[ 0 ],
msg );
474 if( rType ==
'\0' ) {
475 msg << MSG::ERROR <<
"Type not recognised for variable: "
477 return StatusCode::FAILURE;
481 std::ostringstream typeDesc;
482 typeDesc << branchName <<
"/" << rType;
486 typeDesc.str().c_str() );
496 TClass*
cl = TClass::GetClass( *ti );
501 msg << MSG::ERROR <<
"Couldn't find dictionary for type: "
503 return StatusCode::FAILURE;
505 if( !
cl->GetStreamerInfo() ) {
506 msg << MSG::ERROR <<
"No streamer info available for type: "
508 return StatusCode::FAILURE;
512 m_dataPtr =
m_data->toPtr();
513 br =
tree.Branch( branchName.c_str(),
cl->GetName(), &m_dataPtr );
519 msg << MSG::ERROR <<
"Failed to create branch: " << branchName
521 return StatusCode::FAILURE;
525 return StatusCode::SUCCESS;
533 if( ( ! m_acc ) || ( ! m_factory ) || ( !
m_data ) ) {
535 return StatusCode::FAILURE;
542 TempInterface dstiface (
m_data->size(), m_acc->auxid(),
m_data->toPtr());
543 m_factory->copy( m_acc->auxid(), dstiface, 0,
547 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
static AuxTypeRegistry & instance()
Return the singleton registry instance.
std::unordered_map< std::string, ElementProcessor > m_elements
Objects to write branches from.
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Gaudi::Property< std::vector< std::string > > m_branches
The branches to write into this output tree.
Base class for elements of a container that can have aux data.
StatusCode addBranch(TTree &tree, const std::string &auxName, const std::string &branchName, bool allowMissing, bool &created)
Add one branch to the output tree.
bool empty() const
returns: whether the set is empty
StatusCode execute() override
Function executed once per event.
Class to wrap a set of SystematicVariations.
Helper class to provide const generic access to aux data.
#define ATH_MSG_VERBOSE(x)
StatusCode setupBranch(const std::string &branchDecl, const CP::SystematicSet &sys)
Function setting up an individual branch on the first event.
reg
globals -----------------------------------------------------------------—
Select isolated Photons, Electrons and Muons.
StatusCode setupTree()
Function setting up the internal data structures on the first event.
StatusCode setup(TTree &tree, const std::string &auxName, const std::string &branchName, MsgStream &msg)
Function setting up the object, and the branch.
Handle mappings between names and auxid_t.
void setStore(SG::IAuxStore *store)
Set the store associated with this object.
Gaudi::Property< std::string > m_termName
StatusCode initialize() override
Function executed as part of the job initialisation.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
size_t auxid_t
Identifier for a particular aux data item.
void setCache(SG::auxid_t auxid, void *ptr)
Explicitly set a cache pointer.
bool m_isInitialized
Internal status flag, showing whether the algorithm is initialised.
::StatusCode StatusCode
StatusCode definition for legacy code.
StatusCode process(const SG::AuxElement &element)
Process the object.
StatusCode finalize() override
Function executed as part of the job finalisation.
const_iterator end() const
description: const iterator to the end of the set
This module defines the arguments passed from the BATCH driver to the BATCH worker.
ElementProcessor()
Default constructor.
size_t index() const
Return the index of this element within its container.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Container for xAOD::MissingET_v1 objects.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
TTree * m_tree
The tree being written.
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
Class writing one variable from an xAOD object into a branch.
iterator find(const SystematicVariation &sys) const
description: find an element in the set
#define ATH_MSG_WARNING(x)
const boost::regex re(r_e)
AsgxAODMetNTupleMakerAlg(const std::string &name, ISvcLocator *svcLoc)
Algorithm constructor.
Manage lookup of vectors of auxiliary data.
const SG::AuxVectorData * container() const
Return the container holding this element.
Gaudi::Property< std::string > m_treeName
The name of the output tree to write.
std::string m_name
Instance name.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
virtual size_t capacity_v() const =0
Return the capacity of the container.
virtual size_t size_v() const =0
Return the size of the container.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
StatusCode process(const SG::AuxElement &element, MsgStream &msg)
Function processing the object, filling the variable.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.