Skip to content
Snippets Groups Projects
Commit 6d05ac32 authored by Audrey Katherine Kvam's avatar Audrey Katherine Kvam
Browse files

FPE fix to MSVertexTrackletTool.cxx

Former-commit-id: ab332766
parent 8369c68b
No related branches found
No related tags found
No related merge requests found
Showing
with 1164 additions and 0 deletions
from AthenaConfiguration.ConfigFlags import makeFlag
doTwoGaussianNoise=makeFlag("doTwoGaussianNoise",True)
doTreatEnergyCutAsAbsolute=makeFlag("doTreatEnergyCutAsAbsolute",False)
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from IOVDbSvc.IOVDbSvcConfig import addFolders
from CaloTools.CaloToolsConf import CaloNoiseToolDB
from AthenaConfiguration.CfgLogMsg import cfgLogMsg
def CaloNoiseToolCfg(inputFlags):
result=ComponentAccumulator()
isMC=inputFlags.get("AthenaConfiguration.GlobalConfigFlags.isMC")
fixedLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.fixedLumiForNoise")
useCaloLumi=inputFlags.get("CaloRec.CaloRecConfigFlags.useCaloNoiseLumi")
caloNoiseToolDB=CaloNoiseToolDB("CaloNoiseTool")
if inputFlags.get("AthenaConfiguration.GlobalConfigFlags.isOnline"):
#online mode:
folder = "/CALO/Noise/CellNoise"
result.executeModule(addFolders,inputFlags,folder,'CALO_ONL')
caloNoiseToolDB.FolderNames=[folder,]
if fixedLumi >= 0 :
caloNoiseToolDB.Luminosity = fixedLumi
cfgLogMsg.info("online mode: use fixed luminosity for scaling pileup noise: %f"%fixedLumi)
else:
if useCaloLumi:
lumiFolder='/CALO/Noise/PileUpNoiseLumi'
result.executeModule(addFolders,inputFlags,lumiFolder,'CALO')
caloNoiseToolDB.LumiFolderName = lumiFolder
caloNoiseToolDB.Luminosity = -1.
cfgLogMsg.info("online mode: use luminosity from /CALO/Noise/PileUpNoiseLumi to scale pileup noise")
else:
caloNoiseToolDB.Luminosity = 0.
mlog.info("online mode: ignore pileup noise")
pass
result.addPublicTool(caloNoiseToolDB)
return result
#The not-online case:
if isMC:
if fixedLumi >= 0 :
caloNoiseToolDB.Luminosity=fixedLumi
cfgLogMsg.info("Luminosity (in 10**33) units used for pileup noise from CaloNoiseFlags : %f" % fixedLumi)
else:
if useCaloLumi:
lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
result.executeModule(addFolders,inputFlags,lumiFolder,'CALO_OFL')
cfgLogMsg.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileuUpNoiseLumi to scale pileup noise")
caloNoiseToolDB.LumiFolderName = lumiFolder
caloNoiseToolDB.Luminosity=-1.
else:
estimatedLumi=inputFlags.get("AthenaConfiguration.GlobalFlags.estimatedLuminosity")
caloNoiseToolDB.Luminosity=estimatedLumi/1e+33
cfgLogMsg.info(" Luminosity (in 10**33) units used for pileup noise from global flags: %f"%caloNoiseToolDB.Luminosity)
folders = (("CALO_OFL","/CALO/Ofl/Noise/CellNoise"),
("LAR_OFL","/LAR/NoiseOfl/CellNoise"),
("TILE_OFL","/TILE/OFL02/NOISE/CELL")
)
pass
else: # Real data case:
# for luminosity
if fixedLumi >= 0 :
caloNoiseToolDB.Luminosity = fixedLumi
mlog.info("offline mode: use fixed luminosity for scaling pileup noise: %f"%fixedLumi)
else :
caloNoiseToolDB.Luminosity = -1
if useCaloLumi:
lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
result.executeModule(addFolders,inputFlags,lumiFolder,'CALO_OFL')
cfgLogMsg.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileUpNoiseLumi to scale pileup noise")
else:
lumiFolder = '/TRIGGER/LUMI/LBLESTONL'
result.executeModule(addFolders,inputFlags,lumiFolder,'TRIGGER_ONL');
cfgLogMsg.info("offline mode: use luminosity = f(Lumiblock) to scale pileup noise")
caloNoiseToolDB.LumiFolderName = lumiFolder
folders=[("LAR_OFL","/LAR/NoiseOfl/CellNoise"),
("TILE_OFL","/TILE/OFL02/NOISE/CELL")
]
if inputFlags.get("IOVDbSvc.IOVDbConfigFlags.DatabaseInstance")=="COMP200":
folders.append(("CALO_OFL","/CALO/Ofl/Noise/CellNoise")),
#Fixme: Add rescaling of noise based on HV!
pass #end of real data case
for (db,fldr) in folders:
result.executeModule(addFolders,inputFlags,fldr,db)
caloNoiseToolDB.FolderNames=[f[1] for f in folders]
result.addPublicTool(caloNoiseToolDB)
return result
AthContainers
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration.
*/
// $Id$
/**
* @file AthContainersInterfaces/IConstAuxStoreMeta.h
* @author scott snyder <snyder@bnl.gov>
* @date Jan, 2018
* @brief Assign a CLID for MetaCont<IConstAuxStore>.
*/
#ifndef ATHCONTAINERSINTERFACES_ICONSTAUXSTOREMETA_H
#define ATHCONTAINERSINTERFACES_ICONSTAUXSTOREMETA_H
#include "AthContainersInterfaces/IConstAuxStore.h"
#include "AthenaKernel/MetaCont.h"
METACONT_DEF( SG::IConstAuxStore, 140922162 );
#endif // not ATHCONTAINERSINTERFACES_ICONSTAUXSTOREMETA_H
#
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
###############################################################
#
# Job options file
#
# Based on AthExStoreGateExamples
#
#==============================================================
#--------------------------------------------------------------
# ATLAS default Application Configuration options
#--------------------------------------------------------------
# Configure the scheduler
from AthenaCommon.AlgScheduler import AlgScheduler
AlgScheduler.ShowControlFlow( True )
AlgScheduler.ShowDataDependencies( True )
# Control flow
from AthenaCommon.AlgSequence import AthSequencer
allViewAlgorithms = AthSequencer( "allViewAlgorithms" )
allViewAlgorithms.ModeOR = False
allViewAlgorithms.Sequential = False
allViewAlgorithms.StopOverride = False
makeViewSequence = AthSequencer( "makeViewSequence" )
makeViewSequence.ModeOR = False
makeViewSequence.Sequential = True
makeViewSequence.StopOverride = False
# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
# Make views
makeViewSequence += CfgMgr.AthViews__ViewSubgraphAlg("make_alg")
makeViewSequence.make_alg.ViewBaseName = "view"
makeViewSequence.make_alg.ViewNumber = 10
makeViewSequence.make_alg.ViewNodeName = "allViewAlgorithms"
makeViewSequence.make_alg.Scheduler = AlgScheduler.getScheduler()
# View algorithm
ViewTest = CfgMgr.AthViews__ViewTestAlg("view_test")
allViewAlgorithms += ViewTest
# Add the view algorithms to the job
makeViewSequence += allViewAlgorithms
job += makeViewSequence
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
theApp.EvtMax = 10
#==============================================================
#
# End of job options file
#
###############################################################
#
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
###############################################################
#
# Job options file
#
# Based on AthExStoreGateExamples
#
#==============================================================
#--------------------------------------------------------------
# ATLAS default Application Configuration options
#--------------------------------------------------------------
# Configure the scheduler
from AthenaCommon.AlgScheduler import AlgScheduler
AlgScheduler.ShowControlFlow( True )
AlgScheduler.ShowDataDependencies( True )
# Control flow
from AthenaCommon.AlgSequence import AthSequencer
l2ViewAlgorithms = AthSequencer( "l2ViewAlgorithms" )
l2ViewAlgorithms.ModeOR = False
l2ViewAlgorithms.Sequential = False
l2ViewAlgorithms.StopOverride = False
l1ViewAlgorithms = AthSequencer( "l1ViewAlgorithms" )
l1ViewAlgorithms.ModeOR = False
l1ViewAlgorithms.Sequential = True
l1ViewAlgorithms.StopOverride = False
makeViewSequence = AthSequencer( "makeViewSequence" )
makeViewSequence.ModeOR = False
makeViewSequence.Sequential = True
makeViewSequence.StopOverride = False
# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
# Make views
makeViewSequence += CfgMgr.AthViews__ViewSubgraphAlg("make_alg")
makeViewSequence.make_alg.ViewBaseName = "view"
makeViewSequence.make_alg.ViewNumber = 10
makeViewSequence.make_alg.ViewNodeName = l1ViewAlgorithms.name()
makeViewSequence.make_alg.Scheduler = AlgScheduler.getScheduler()
# View algorithms
ViewTest = CfgMgr.AthViews__ViewTestAlg("view_test")
l1ViewAlgorithms += ViewTest
#
l1ViewAlgorithms += CfgMgr.AthViews__ViewSubgraphAlg("nest_alg")
l1ViewAlgorithms.nest_alg.ViewBaseName = "viewView"
l1ViewAlgorithms.nest_alg.ViewNumber = 10
l1ViewAlgorithms.nest_alg.ViewNodeName = l2ViewAlgorithms.name()
l1ViewAlgorithms.nest_alg.Scheduler = AlgScheduler.getScheduler()
#
ViewViewTest = CfgMgr.AthViews__ViewTestAlg("viewView_test")
l2ViewAlgorithms += ViewViewTest
# Add the view algorithms to the job
l1ViewAlgorithms += l2ViewAlgorithms
makeViewSequence += l1ViewAlgorithms
# Merge views
makeViewSequence += CfgMgr.AthViews__ViewMergeAlg("merge_alg")
job += makeViewSequence
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
theApp.EvtMax = 10
#==============================================================
#
# End of job options file
#
###############################################################
#
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
###############################################################
#
# Job options file
#
# Based on AthExStoreGateExamples
#
#==============================================================
#--------------------------------------------------------------
# ATLAS default Application Configuration options
#--------------------------------------------------------------
# Configure the scheduler
from AthenaCommon.AlgScheduler import AlgScheduler
AlgScheduler.ShowControlFlow( True )
AlgScheduler.ShowDataDependencies( True )
# Control flow
from AthenaCommon.AlgSequence import AthSequencer
allViewAlgorithms = AthSequencer( "allViewAlgorithms" )
allViewAlgorithms.ModeOR = False
allViewAlgorithms.Sequential = False
allViewAlgorithms.StopOverride = False
makeViewSequence = AthSequencer( "makeViewSequence" )
makeViewSequence.ModeOR = False
makeViewSequence.Sequential = True
makeViewSequence.StopOverride = False
# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
# Make views
makeViewSequence += CfgMgr.AthViews__ViewSubgraphAlg("make_alg")
makeViewSequence.make_alg.ViewBaseName = "view"
makeViewSequence.make_alg.ViewNumber = 10
makeViewSequence.make_alg.ViewNodeName = "allViewAlgorithms"
makeViewSequence.make_alg.Scheduler = AlgScheduler.getScheduler()
# View algorithms
ViewTest = CfgMgr.AthViews__ViewTestAlg("view_test")
allViewAlgorithms += ViewTest
#
ViewVerify = CfgMgr.AthViews__ViewDataVerifier("view_verify")
ViewVerify.DataObjects = [ ('int','view_start') ]
allViewAlgorithms += ViewVerify
#
dflow_alg1 = CfgMgr.AthViews__DFlowAlg1("dflow_alg1")
allViewAlgorithms += dflow_alg1
#
dflow_alg2 = CfgMgr.AthViews__DFlowAlg2("dflow_alg2")
allViewAlgorithms += dflow_alg2
#
dflow_alg3 = CfgMgr.AthViews__DFlowAlg3("dflow_alg3")
allViewAlgorithms += dflow_alg3
# Add the view algorithms to the job
makeViewSequence += allViewAlgorithms
# Merge views
makeViewSequence += CfgMgr.AthViews__ViewMergeAlg("merge_alg")
job += makeViewSequence
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
theApp.EvtMax = 10
#==============================================================
#
# End of job options file
#
###############################################################
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "RoiCollectionToViews.h"
#include "AthViews/ViewHelper.h"
// STL includes
// FrameWork includes
#include "GaudiKernel/Property.h"
#include "CxxUtils/make_unique.h"
#include "AthContainers/ConstDataVector.h"
namespace AthViews {
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
// Constructors
////////////////
RoiCollectionToViews::RoiCollectionToViews( const std::string& name,
ISvcLocator* pSvcLocator ) :
::AthAlgorithm( name, pSvcLocator )
{
}
// Destructor
///////////////
RoiCollectionToViews::~RoiCollectionToViews()
{
}
// Athena Algorithm's Hooks
////////////////////////////
StatusCode RoiCollectionToViews::initialize()
{
ATH_MSG_INFO ("Initializing " << name() << "...");
CHECK( m_trigRoIs.initialize() );
CHECK( m_viewRoIs.initialize() );
CHECK( m_w_views.initialize() );
CHECK( m_scheduler.retrieve() );
return StatusCode::SUCCESS;
}
StatusCode RoiCollectionToViews::finalize()
{
ATH_MSG_INFO ("Finalizing " << name() << "...");
return StatusCode::SUCCESS;
}
StatusCode RoiCollectionToViews::execute()
{
ATH_MSG_DEBUG ("Executing " << name() << "...");
#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
const EventContext& ctx = getContext();
#else
const EventContext& ctx = *getContext();
#endif
//Load the collection of RoI descriptors
SG::ReadHandle< TrigRoiDescriptorCollection > inputRoIs( m_trigRoIs, ctx );
ATH_CHECK( inputRoIs.isValid() );
//Skip if there's nothing to do
//if ( inputRoIs->empty() ) return StatusCode::SUCCESS;
//NB: don't do this any more. Calling the helper with an empty collection is now correct
//as this will deactivate the node in the scheduler
std::vector< ConstDataVector<TrigRoiDescriptorCollection> > outputRoICollectionVector;
for ( auto roi: *inputRoIs )
{
ATH_MSG_DEBUG( "RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord() );
ConstDataVector<TrigRoiDescriptorCollection> oneRoIColl (SG::VIEW_ELEMENTS);
oneRoIColl.push_back( roi );
outputRoICollectionVector.push_back( std::move(oneRoIColl) );
}
//Create the views and populate them
std::vector< SG::View* > viewVector;
CHECK( ViewHelper::MakeAndPopulate( m_viewBaseName, //Base name for all views to use
viewVector, //Vector to store views
m_viewRoIs, //A writehandlekey to use to access the views
ctx, //The context of this algorithm
outputRoICollectionVector, //Data to initialise each view - one view will be made per entry
m_viewFallThrough ) ); //Allow fall through from view to storegate
//Run the algorithms in views
CHECK( ViewHelper::ScheduleViews( viewVector, //View vector
m_viewNodeName, //CF node to attach views to
ctx, //Context to attach the views to
m_scheduler.get() ) ); //Scheduler
//Store the collection of views
SG::WriteHandle< std::vector< SG::View* > > outputViewHandle( m_w_views, ctx );
outputViewHandle.record( CxxUtils::make_unique< std::vector< SG::View* > >( viewVector ) );
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
#define ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
// STL includes
#include <string>
#include <vector>
// FrameWork includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "AthViews/View.h"
#include "StoreGate/WriteHandleKey.h"
#include "StoreGate/ReadHandleKey.h"
#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h"
#include "AthContainers/ConstDataVector.h"
#include "GaudiKernel/IScheduler.h"
namespace AthViews {
class RoiCollectionToViews
: public ::AthAlgorithm
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
RoiCollectionToViews( const std::string& name, ISvcLocator* pSvcLocator );
/// Destructor:
virtual ~RoiCollectionToViews();
// Athena algorithm's Hooks
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Private data:
///////////////////////////////////////////////////////////////////
private:
/// Default constructor:
RoiCollectionToViews();
/// Containers
// vars
ServiceHandle< IScheduler > m_scheduler{ this, "Scheduler", "AvalancheSchedulerSvc", "The Athena scheduler" };
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_trigRoIs { this, "InputRoICollection", "input_rois", "Collection of RoIs to split into views" };
SG::WriteHandleKey< std::vector< SG::View* > > m_w_views { this, "AllViews", "all_views", "Output view collection" };
SG::WriteHandleKey< ConstDataVector<TrigRoiDescriptorCollection> > m_viewRoIs { this, "OutputRoICollection", "output_rois", "RoI collection to use inside views" };
Gaudi::Property< std::string > m_viewBaseName { this, "ViewBaseName", "", "Name to use for all views - number will be appended" };
Gaudi::Property< std::string > m_viewNodeName { this, "ViewNodeName", "", "Name of the CF node to attach views to" };
Gaudi::Property< bool > m_viewFallThrough { this, "ViewFallThrough", true, "Set whether views may access StoreGate directly to retrieve data" };
};
///////////////////////////////////////////////////////////////////
// I/O operators
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Inline methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
#endif //> !ATHVIEWS_ATHVIEWS_ROICOLLECTIONTOVIEWS_H
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ViewDataVerifier.cxx
// Implementation file for class ViewDataVerifier
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#include "ViewDataVerifier.h"
// STL includes
// FrameWork includes
#include "AthenaKernel/ExtendedEventContext.h"
namespace AthViews {
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
// Constructors
////////////////
ViewDataVerifier::ViewDataVerifier( const std::string& name,
ISvcLocator* pSvcLocator ) :
::AthAlgorithm( name, pSvcLocator )
{
}
// Destructor
///////////////
ViewDataVerifier::~ViewDataVerifier()
{}
// Athena Algorithm's Hooks
////////////////////////////
StatusCode ViewDataVerifier::initialize()
{
ATH_MSG_INFO ("Initializing " << name() << "...");
StatusCode sc = StatusCode::SUCCESS;
// Debug message indicating what containers will be loaded
// Code copied from SGInputLoader
if ( m_load.value().size() > 0 ) {
std::ostringstream str;
str << "Will explicitly preload the following DataObjects:";
for ( auto &obj : m_load.value() ) {
str << "\n + " << obj;
if ( obj.key() == "" ) {
sc = StatusCode::FAILURE;
str << " ERROR: empty key is not allowed!";
}
}
ATH_MSG_INFO( str.str() );
}
// Inform the scheduler that these containers will be available
if ( !setProperty( "ExtraOutputs", m_load.toString() ).isSuccess() ) {
ATH_MSG_WARNING( "Failed setting property ExtraOutputs" );
}
return sc;
}
StatusCode ViewDataVerifier::finalize()
{
ATH_MSG_INFO ("Finalizing " << name() << "...");
return StatusCode::SUCCESS;
}
StatusCode ViewDataVerifier::execute()
{
ATH_MSG_DEBUG ("Executing " << name() << "...");
// Retrieve the current view from the EventContext
auto viewProxy = getContext().getExtension<Atlas::ExtendedEventContext>()->proxy();
ATH_MSG_INFO( name() << " running with store " << viewProxy->name() );
// Test each container
for ( auto &obj : m_load.value() ) {
// Create a VarHandleKey (copied from SGInputLoader)
SG::VarHandleKey vhk( obj.clid(), obj.key(), Gaudi::DataHandle::Writer );
// Create a test proxy
SG::DataProxy* dp = viewProxy->proxy( obj.clid(), vhk.key() );
// Test if the proxy is valid
if ( dp ) {
ATH_MSG_INFO( "Found " << obj.key() << " in " << viewProxy->name() );
} else {
ATH_MSG_ERROR( "Did not find " << obj.key() << " in " << viewProxy->name() );
}
}
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ViewDataVerifier.h
// Header file for class ViewDataVerifier
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ATHVIEWS_VIEWDATAVERIFIER_H
#define ATHVIEWS_VIEWDATAVERIFIER_H 1
// STL includes
#include <string>
// FrameWork includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/DataObjID.h"
namespace AthViews {
class ViewDataVerifier
: public ::AthAlgorithm
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
ViewDataVerifier( const std::string& name, ISvcLocator* pSvcLocator );
/// Destructor:
virtual ~ViewDataVerifier();
// Assignment operator:
//ViewDataVerifier &operator=(const ViewDataVerifier &alg);
// Athena algorithm's Hooks
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Private data:
///////////////////////////////////////////////////////////////////
private:
/// Default constructor:
ViewDataVerifier();
/// Containers to verify
Gaudi::Property< DataObjIDColl > m_load{ this, "DataObjects", DataObjIDColl(), "Objects to confirm are found in this view" };
// vars
};
// I/O operators
//////////////////////
///////////////////////////////////////////////////////////////////
// Inline methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
#endif //> !ATHVIEWS_VIEWDATAVERIFIER_H
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ViewTestAlg.cxx
// Implementation file for class ViewTestAlg
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#include "ViewTestAlg.h"
// STL includes
// FrameWork includes
#include "AthenaKernel/ExtendedEventContext.h"
namespace AthViews {
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
// Constructors
////////////////
ViewTestAlg::ViewTestAlg( const std::string& name,
ISvcLocator* pSvcLocator ) :
::AthAlgorithm( name, pSvcLocator )
{
//
// Property declaration
//
//declareProperty( "Property", m_nProperty );
}
// Destructor
///////////////
ViewTestAlg::~ViewTestAlg()
{}
// Athena Algorithm's Hooks
////////////////////////////
StatusCode ViewTestAlg::initialize()
{
ATH_MSG_INFO ("Initializing " << name() << "...");
return StatusCode::SUCCESS;
}
StatusCode ViewTestAlg::finalize()
{
ATH_MSG_INFO ("Finalizing " << name() << "...");
return StatusCode::SUCCESS;
}
StatusCode ViewTestAlg::execute()
{
ATH_MSG_DEBUG ("Executing " << name() << "...");
#ifdef GAUDI_SYSEXECUTE_WITHCONTEXT
const EventContext& ctx = getContext();
#else
const EventContext& ctx = *getContext();
#endif
ATH_MSG_INFO( name() << " running with store " << ctx.getExtension<Atlas::ExtendedEventContext>()->proxy()->name() );
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ViewTestAlg.h
// Header file for class ViewTestAlg
// Author: B. Wynne <bwynne@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ATHVIEWS_VIEWTESTALG_H
#define ATHVIEWS_VIEWTESTALG_H 1
// STL includes
#include <string>
// FrameWork includes
#include "AthenaBaseComps/AthAlgorithm.h"
namespace AthViews {
class ViewTestAlg
: public ::AthAlgorithm
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
ViewTestAlg( const std::string& name, ISvcLocator* pSvcLocator );
/// Destructor:
virtual ~ViewTestAlg();
// Assignment operator:
//ViewTestAlg &operator=(const ViewTestAlg &alg);
// Athena algorithm's Hooks
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Private data:
///////////////////////////////////////////////////////////////////
private:
/// Default constructor:
ViewTestAlg();
/// Containers
// vars
};
// I/O operators
//////////////////////
///////////////////////////////////////////////////////////////////
// Inline methods:
///////////////////////////////////////////////////////////////////
} //> end namespace AthViews
#endif //> !ATHVIEWS_VIEWTESTALG_H
#include "../ViewDataVerifier.h"
#include "../ViewTestAlg.h"
#include "../RoiCollectionToViews.h"
DECLARE_COMPONENT( AthViews::ViewDataVerifier )
DECLARE_COMPONENT( AthViews::ViewTestAlg )
DECLARE_COMPONENT( AthViews::RoiCollectionToViews )
#!/bin/sh
# art-type: build
# art-ci: master
athena.py --threads=1 AthViews/SimpleViewExample.py
#!/bin/sh
# art-type: build
# art-ci: master
# We expect this command to fail, so invert the exit code
if athena.py --threads=1 AthViews/ViewNest.py; then
exit 1
else
exit 0
fi
#!/bin/sh
# art-type: build
# art-ci: master
athena.py --threads=1 AthViews/ViewScheduling.py
import os, inspect
class CfgLogMsg():
def __init__(self,level="info"):
self._lvl=self._lvlFromString(level)
pass
def _lvlFromString(self,level):
#No ERROR message: Errors reported via exceptions!
if (level.lower()=="none"):
return 0
elif (level.lower()=="warning"):
return 1
elif (level.lower()=="info"):
return 2
elif (level.lower()=="debug"):
return 3
else:
raise TypeError('Allowed message levels are only "none", "info" or "debug", got %s' % level)
pass
def setLevel(self,level):
self._lvl=self._lvlFromString(level)
pass
def warning(self,message):
if self._lvl>=1:
(callfile,callfunc)=self.getCaller()
print "%s:%s WARN %s" % (callfile,callfunc,message)
def info(self,message):
if self._lvl>=2:
(callfile,callfunc)=self.getCaller()
print "%s:%s INFO %s" % (callfile,callfunc,message)
def debug(self,message):
if self._lvl>=3:
(callfile,callfunc)=self.getCaller()
print "%s:%s DEBUG %s" % (callfile,callfunc,message)
def getCaller(self):
try:
#print inspect.stack()
callfile=inspect.stack()[2][1].split("/")[-1]
callfunc=inspect.stack()[2][3]
except Exception, e:
print e
(callfile,callfunc)=("","")
pass
return (callfile,callfunc)
_level=None
if 'ATH_CFG_MSG_LVL' in os.environ:
_level=os.environ["ATH_CFG_MSG_LVL"]
else:
_level="info"
cfgLogMsg=CfgLogMsg(_level)
del _level
from copy import deepcopy
from AthenaConfiguration.CfgLogMsg import cfgLogMsg
class ConfigFlag(object):
def __init__(self,initialValue=None):
self._value=initialValue
self._alreadySet=False
pass
#def getDefault(self,prevContainer):
# pass
def set_Value(self,newvalue):
if not self._alreadySet:
self._value=newvalue
self._alreadySet=True
return True
else:
print("Config Flag '%s' already set" % self.__class__.__name__)
return False
def get_Value(self):
return deepcopy(self._value)
def __call__(self):
return self.get_Value()
def wasSet(self):
return self._alreadySet
class pseudomodule(object):
def __init__(self,flagsContainer,upstream):
self._fc=flagsContainer
self._location=upstream
def __getattr__(self,nextLevel):
newloc=self._location+"."+nextLevel
#print "NewLoc=",newloc
if len(newloc.split("."))==3:
return self._fc.get(newloc)
else:
return pseudomodule(self._fc,newloc)
class ConfigFlagContainer(object):
def __init__(self,otherFlags=None):
if otherFlags is None:
self._flagdict=dict()
else:
self._flagdict=deepcopy(otherFlags._flagdict)
def importFlag(self,fullname):
if not len(fullname.split(".")):
raise KeyError("Flag name format is <package>.<module>.<flag>")
(p,m,f)=fullname.split(".")
cfgLogMsg.debug("Importing flag %s from module %s.%s" % (f,p,m))
exec "import %s.%s as newmodule" % (p,m)
if not hasattr(newmodule,f):
raise ImportError("Module %s.%s has no class called %s" % (p,m,f))
flagclass=getattr(newmodule,f)
if not issubclass(flagclass,ConfigFlag):
raise TypeError("Class %s is not a subclass of ConfigFlag" % f)
return flagclass
def get(self,name):
if not self._flagdict.has_key(name):
newFlag_t=self.importFlag(name)
newFlag=newFlag_t()
#"Simple"-flags have no getDefault function but a _defaultvalue attr
if hasattr(newFlag_t,'_defaultvalue'):
newFlag._value=newFlag_t._defaultvalue
if hasattr(newFlag,"getDefault"):
newFlag._value=newFlag.getDefault(self)
self._flagdict[name]=newFlag
pass
f=self._flagdict[name]
return f.get_Value()
def set(self,name,value):
if not self._flagdict.has_key(name):
newFlag=self.importFlag(name)
self._flagdict[name]=newFlag()
return self._flagdict[name].set_Value(value)
def dump(self):
print "Content of ConfigFlagContainer:"
for n,f in self._flagdict.iteritems():
state = "( set )" if f.wasSet() else "(default)"
print " ",n,state,":",f.get_Value()
#Decorator to emulate pass-by-value behavior of flags
def cloneflags( configFunc ):
def copied_flags( *args ):
cargs = [ deepcopy( a ) if issubclass(a,ConfigFlagContainer) else a for a in args ]
return configFunc( *cargs )
return copied_flags
#A function returning a class to create a job config-class in one line
def makeFlag(name, defaultvalue,doc=None):
return type(name,(ConfigFlag,),{'_defaultvalue':defaultvalue,'__doc__':doc})
from AthenaConfiguration.ConfigFlags import ConfigFlag,makeFlag
from AthenaCommon.SystemOfUnits import TeV
isMC=makeFlag('isMC',True)
isOnline=makeFlag('isOnline',False)
GeoLayout=makeFlag('GeoLayout',"atlas")
projectName=makeFlag("ProjectName","data17_13TeV") #should autoconfigure!
InputFiles=makeFlag("InputFiles",["_ATHENA_GENERIC_INPUTFILE_NAME_",])
#Beam-related flags:
bunchSpacing=makeFlag("BunchSpacing",25,"Bunch spacing in ns")
numberOfCollisions=makeFlag("numberOfCollisions",0, "Number of collisions per beam crossing. Should be 2.3*(L/10**33)*(bunchSpacing/25 ns)")
beamType=makeFlag("beamType",'collisions', "Specify data taking type: 'collisions' (default), 'singlebeam','cosmics'")
beamEnergy=makeFlag("beamEnergy",7*TeV)
class estimatedLuminosity(ConfigFlag):
def getDefault(self,prevFlags):
return 1E33*(prevFlags.get("AthenaConfiguration.GlobalConfigFlags.numberOfCollisions")/2.3)* \
(25./prevFlags.get("AthenaConfiguration.GlobalConfigFlags.bunchSpacing"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment