27 TempInterface (
size_t size) : m_size (size) {}
28 TempInterface (
size_t size,
SG::auxid_t auxid,
void* ptr) :
31 setCache (auxid, ptr);
34 using AuxVectorData::setStore;
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 ) {
122 ISvcLocator* 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;
216 static const std::regex
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;
229 bool nominal = sys.empty();
231 bool systematicsContainer{
false};
232 bool systematicsDecoration{
false};
233 bool affectedContainer{
true};
234 bool affectedDecoration{
true};
237 std::string key =
match[ 1 ];
238 if( key.find(
"%SYS%" ) != std::string::npos )
240 systematicsContainer =
true;
244 if( !nominal && matching.
empty() ) {
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 );
282 if( !nominal && matching.
empty() ) {
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;
301 std::string brName =
match[ 3 ];
302 if( brName.find(
"%SYS%" ) != std::string::npos )
308 ( key ==
match[ 1 ] ) && ( auxName ==
match[ 2 ] ) &&
309 ( brName ==
match[ 3 ] ) ) {
310 return StatusCode::SUCCESS;
314 if( ( ( key ==
match[ 1 ] ) && ( auxName ==
match[ 2 ] ) &&
315 ( brName !=
match[ 3 ] ) ) ||
316 ( ( ( key !=
match[ 1 ] ) || ( auxName !=
match[ 2 ] ) ) &&
317 ( brName ==
match[ 3 ] ) ) ) {
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 ) {
447 const std::type_info* ti = reg.getType(
m_acc->auxid() );
450 <<
"No std::type_info available for auxiliary variable: "
452 return StatusCode::FAILURE;
456 msg << MSG::ERROR <<
"No factory found for auxiliary variable: "
458 return StatusCode::FAILURE;
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;
485 br =
tree.Branch( branchName.c_str(),
m_data->toPtr(),
486 typeDesc.str().c_str() );
496 TClass* cl = TClass::GetClass( *ti );
498 cl = TClass::GetClass( typeName.c_str() );
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: "
507 << cl->GetName() <<
endmsg;
508 return StatusCode::FAILURE;
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;
534 msg << MSG::FATAL <<
"Internal logic error detected" <<
endmsg;
535 return StatusCode::FAILURE;
547 return StatusCode::SUCCESS;
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ServiceHandle< StoreGateSvc > & evtStore()
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
std::string m_name
Instance name.
Class writing one variable from an xAOD object into a branch.
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
StatusCode setup(TTree &tree, const std::string &auxName, const std::string &branchName, MsgStream &msg)
Function setting up the object, and the branch.
std::unique_ptr< SG::TypelessConstAccessor > m_acc
Object accessing the variable in question.
const SG::IAuxTypeVectorFactory * m_factory
Pointer to the helper object that handles this variable.
StatusCode process(const SG::AuxElement &element, MsgStream &msg)
Function processing the object, filling the variable.
std::string m_branchName
Name of the branch being written.
void * m_dataPtr
Helper variable, pointing at the object to be written.
StatusCode addBranch(TTree &tree, const std::string &auxName, const std::string &branchName, bool allowMissing, bool &created)
Add one branch to the output tree.
StatusCode process(const SG::AuxElement &element)
Process the object.
ElementProcessor()
Default constructor.
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
TTree * m_tree
The tree being written.
std::unordered_map< std::string, ElementProcessor > m_elements
Objects to write branches from.
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
StatusCode setupBranch(const std::string &branchDecl, const CP::SystematicSet &sys)
Function setting up an individual branch on the first event.
Gaudi::Property< std::vector< std::string > > m_branches
The branches to write into this output tree.
bool m_isInitialized
Internal status flag, showing whether the algorithm is initialised.
Gaudi::Property< std::string > m_treeName
The name of the output tree to write.
StatusCode finalize() override
Function executed as part of the job finalisation.
AsgxAODMetNTupleMakerAlg(const std::string &name, ISvcLocator *svcLoc)
Algorithm constructor.
StatusCode initialize() override
Function executed as part of the job initialisation.
StatusCode setupTree()
Function setting up the internal data structures on the first event.
StatusCode execute() override
Function executed once per event.
Gaudi::Property< std::string > m_termName
Class to wrap a set of SystematicVariations.
bool empty() const
returns: whether the set is empty
const_iterator end() const
description: const iterator to the end of the set
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
iterator find(const SystematicVariation &sys) const
description: find an element in the set
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Base class for elements of a container that can have aux data.
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Manage lookup of vectors of auxiliary data.
Helper class to provide const generic access to aux data.
MsgStream & msg() const
The standard message stream.
AsgMessaging(const std::string &name)
Constructor with a name.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
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...
static const auxid_t null_auxid
To signal no aux data item.
size_t auxid_t
Identifier for a particular aux data item.
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
MissingETContainer_v1 MissingETContainer
Convert a type_info to a normalized string representation (matching the names used in the root dictio...