Skip to content
Snippets Groups Projects
Commit 9ba0215a authored by Vincent Pascuzzi's avatar Vincent Pascuzzi Committed by Frank Winklmeier
Browse files

Update DigitizationTests pile-up event info

Pile-up is now managed by `xAOD::EventInfo`. `PileUpEventInfo`
is therefore no longer used, so `PileUpEventInfoTest` and
associated tool are renamed to reflect the changes:
`PileUpEventInfoTest{Tool}` -> `EventInfoTest{Tool}`

Also took this opportunity to adopt use of new-style
`StoreGate` retrieves.

Closes ATLASSIM-4467
parent 0c42dc64
No related branches found
No related tags found
No related merge requests found
Showing
with 234 additions and 252 deletions
......@@ -11,7 +11,7 @@ atlas_depends_on_subdirs( PUBLIC
GaudiKernel
PRIVATE
Control/AthenaKernel
Event/EventInfo
Event/xAOD/xAODEventInfo
Generators/GeneratorObjects
InnerDetector/InDetDetDescr/InDetIdentifier
InnerDetector/InDetRawEvent/InDetRawData
......@@ -26,7 +26,7 @@ atlas_add_component( DigitizationTests
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel AthenaKernel EventInfo GeneratorObjects InDetIdentifier InDetRawData InDetSimData )
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel AthenaKernel GeneratorObjects InDetIdentifier InDetRawData InDetSimData xAODEventInfo )
# Install files from the package:
atlas_install_headers( DigitizationTests )
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef DIGITIZATIONTESTS_EVENTINFOTEST_H
#define DIGITIZATIONTESTS_EVENTINFOTEST_H
#include "AthenaBaseComps/AthAlgorithm.h"
#include "xAODEventInfo/EventInfo.h"
class EventInfoTest : public AthAlgorithm {
public:
EventInfoTest(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize();
StatusCode execute();
private:
// SG::ReadHandleKey<xAOD::EventInfo> m_rhkEventInfo;
SG::ReadHandleKey<xAOD::EventInfo> m_rhkEventInfo{
this, "EventInfoName", "EventInfo", "EventInfo name"};
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef DIGITIZATIONTESTS_PILEUPEVENTINFOTEST_H
#define DIGITIZATIONTESTS_PILEUPEVENTINFOTEST_H
#include "AthenaBaseComps/AthAlgorithm.h"
class PileUpEventInfoTest : public AthAlgorithm {
public:
PileUpEventInfoTest(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize();
StatusCode execute();
StringProperty m_pileupInfo;
};
#endif
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from AthenaCommon import CfgMgr
def McEventCollectionTestTool(name="McEventCollectionTestTool", **kwargs):
return CfgMgr.McEventCollectionTestTool(name, **kwargs)
def PileUpEventInfoTestTool(name="PileUpEventInfoTestTool", **kwargs):
return CfgMgr.PileUpEventInfoTestTool(name, **kwargs)
def EventInfoTestTool(name="EventInfoTestTool", **kwargs):
return CfgMgr.EventInfoTestTool(name, **kwargs)
def PixelRDOsTestTool(name="PixelRDOsTestTool", **kwargs):
return CfgMgr.PixelRDOsTestTool(name, **kwargs)
def SCT_RDOsTestTool(name="SCT_RDOsTestTool", **kwargs):
return CfgMgr.SCT_RDOsTestTool(name, **kwargs)
def TRT_RDOsTestTool(name="TRT_RDOsTestTool", **kwargs):
return CfgMgr.TRT_RDOsTestTool(name, **kwargs)
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from AthenaCommon.CfgGetter import addTool
addTool("DigitizationTests.DigitizationTestsConfig.McEventCollectionTestTool", "McEventCollectionTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.PileUpEventInfoTestTool", "PileUpEventInfoTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.PixelRDOsTestTool", "PixelRDOsTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.SCT_RDOsTestTool", "SCT_RDOsTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.TRT_RDOsTestTool", "TRT_RDOsTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.McEventCollectionTestTool",
"McEventCollectionTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.EventInfoTestTool",
"EventInfoTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.PixelRDOsTestTool",
"PixelRDOsTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.SCT_RDOsTestTool",
"SCT_RDOsTestTool")
addTool("DigitizationTests.DigitizationTestsConfig.TRT_RDOsTestTool",
"TRT_RDOsTestTool")
from DigitizationTests.DigitizationTestsConf import DigiTestAlg, McEventCollectionTestTool, PixelRDOsTestTool, SCT_RDOsTestTool, TRT_RDOsTestTool
from AthenaCommon import CfgGetter
from AthenaCommon.AlgSequence import AlgSequence
from AthenaCommon.AppMgr import ServiceMgr
from GaudiSvc.GaudiSvcConf import THistSvc
ServiceMgr += THistSvc("THistSvc")
#ServiceMgr.THistSvc.Output = ["atlasTest DATAFILE='atlasTest.muons.histo.root' OPT='RECREATE'"];
ServiceMgr.THistSvc.Output = ["truth DATAFILE='RDO_truth.root' OPT='RECREATE'"];
ServiceMgr.THistSvc.Output = ["truth DATAFILE='RDO_truth.root' OPT='RECREATE'"]
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
from AthenaCommon import CfgGetter
from DigitizationTests.DigitizationTestsConf import DigiTestAlg,McEventCollectionTestTool,PixelRDOsTestTool,SCT_RDOsTestTool,TRT_RDOsTestTool
job += DigiTestAlg()
if DetFlags.Truth_on():
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool("McEventCollectionTestTool", checkType=True)]
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool(
"McEventCollectionTestTool", checkType=True)]
if DetFlags.Truth_on():
if DetFlags.pileup.any_on():
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool("PileUpEventInfoTestTool", checkType=True)]
if DetFlags.pileup.any_on():
job.DigiTestAlg.DigiTestTools += [
CfgGetter.getPublicTool("EventInfoTestTool", checkType=True)]
if DetFlags.pixel_on():
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool("PixelRDOsTestTool", checkType=True)]
job.DigiTestAlg.DigiTestTools += [
CfgGetter.getPublicTool("PixelRDOsTestTool", checkType=True)]
if DetFlags.SCT_on():
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool("SCT_RDOsTestTool", checkType=True)]
job.DigiTestAlg.DigiTestTools += [
CfgGetter.getPublicTool("SCT_RDOsTestTool", checkType=True)]
if DetFlags.TRT_on():
job.DigiTestAlg.DigiTestTools += [CfgGetter.getPublicTool("TRT_RDOsTestTool", checkType=True)]
job.DigiTestAlg.DigiTestTools += [
CfgGetter.getPublicTool("TRT_RDOsTestTool", checkType=True)]
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "DigitizationTests/EventInfoTest.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"
#include "AthenaKernel/errorcheck.h"
EventInfoTest::EventInfoTest(const std::string& name, ISvcLocator* pSvcLocator)
: AthAlgorithm(name, pSvcLocator) {
declareProperty("EventInfoName", m_rhkEventInfo);
}
StatusCode EventInfoTest::initialize() {
ATH_MSG_INFO("Initializing " << name() << " - package version "
<< PACKAGE_VERSION);
ATH_CHECK(m_rhkEventInfo.initialize());
return StatusCode::SUCCESS;
}
StatusCode EventInfoTest::execute() {
SG::ReadHandle<xAOD::EventInfo> pevt(m_rhkEventInfo);
if (!pevt.isValid()) {
ATH_MSG_ERROR("Could not get xAOD::EventInfo with key "
<< m_rhkEventInfo.key());
return StatusCode::SUCCESS;
}
ATH_MSG_DEBUG("Successfully retrieved event info as xAOD::EventInfo");
//+++ Get sub-event info object
ATH_MSG_DEBUG("Main Event Info: ");
ATH_MSG_INFO("RunNumber = " << pevt->runNumber());
ATH_MSG_INFO("Event Number = " << pevt->eventNumber());
ATH_MSG_INFO("LumiBlock = " << pevt->lumiBlock());
ATH_MSG_INFO("TimeStamp = " << pevt->timeStamp());
ATH_MSG_INFO("BCID = " << pevt->bcid());
ATH_MSG_INFO("mu = " << pevt->actualInteractionsPerCrossing());
ATH_MSG_INFO("<mu> = " << pevt->averageInteractionsPerCrossing());
ATH_MSG_INFO("xAOD::EventInfo::SubEvent info: ");
std::vector<xAOD::EventInfo::SubEvent>::const_iterator it =
pevt->subEvents().begin();
std::vector<xAOD::EventInfo::SubEvent>::const_iterator end =
pevt->subEvents().end();
if (it == end) ATH_MSG_INFO("No xAOD::EventInfo::SubEvent found");
for (auto sevt : pevt->subEvents()) {
if (sevt.ptr() != NULL) {
ATH_MSG_INFO("SubEvent info:");
ATH_MSG_INFO(" Time : "
<< (*it).time() << endmsg
<< " Index : " << (*it).index() << endmsg
<< " Run Number : " << sevt.ptr()->runNumber() << endmsg
<< " Event Number : " << sevt.ptr()->eventNumber() << endmsg
<< " ns Offset : " << sevt.ptr()->timeStampNSOffset()
<< endmsg << " Lumi Block : " << sevt.ptr()->lumiBlock()
<< endmsg << " BCID : " << sevt.ptr()->bcid()
<< endmsg << " PileUpType : " << (*it).type());
++it;
} else
ATH_MSG_INFO("xAOD::EventInfo::SubEvent is null");
}
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "EventInfoTestTool.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"
#include "AthenaKernel/errorcheck.h"
EventInfoTestTool::EventInfoTestTool(const std::string& type,
const std::string& name,
const IInterface* parent)
: DigiTestToolBase(type, name, parent) {
declareProperty("EventInfoName", m_rhkEventInfo);
}
StatusCode EventInfoTestTool::initialize() {
ATH_MSG_INFO("Initializing " << name() << " - package version "
<< PACKAGE_VERSION);
ATH_CHECK(m_rhkEventInfo.initialize());
return StatusCode::SUCCESS;
}
StatusCode EventInfoTestTool::processEvent() {
SG::ReadHandle<xAOD::EventInfo> pevt(m_rhkEventInfo);
if (!pevt.isValid()) {
ATH_MSG_ERROR("Could not get xAOD::EventInfo with key "
<< m_rhkEventInfo.key());
return StatusCode::SUCCESS;
}
ATH_MSG_DEBUG("Successfully retrieved event info as xAOD::EventInfo");
//+++ Get sub-event info object
ATH_MSG_DEBUG("Main Event Info: ");
ATH_MSG_INFO("RunNumber = " << pevt->runNumber());
ATH_MSG_INFO("Event Number = " << pevt->eventNumber());
ATH_MSG_INFO("LumiBlock = " << pevt->lumiBlock());
ATH_MSG_INFO("TimeStamp = " << pevt->timeStamp());
ATH_MSG_INFO("BCID = " << pevt->bcid());
ATH_MSG_INFO("mu = " << pevt->actualInteractionsPerCrossing());
ATH_MSG_INFO("<mu> = " << pevt->averageInteractionsPerCrossing());
ATH_MSG_INFO("xAOD::EventInfo::SubEvent info: ");
std::vector<xAOD::EventInfo::SubEvent>::const_iterator it =
pevt->subEvents().begin();
std::vector<xAOD::EventInfo::SubEvent>::const_iterator end =
pevt->subEvents().end();
if (it == end) ATH_MSG_INFO("No xAOD::EventInfo::SubEvent found");
for (auto sevt : pevt->subEvents()) {
if (sevt.ptr() != NULL) {
ATH_MSG_INFO("SubEvent info:");
ATH_MSG_INFO(" Time : "
<< (*it).time() << endmsg
<< " Index : " << (*it).index() << endmsg
<< " Run Number : " << sevt.ptr()->runNumber() << endmsg
<< " Event Number : " << sevt.ptr()->eventNumber() << endmsg
<< " ns Offset : " << sevt.ptr()->timeStampNSOffset()
<< endmsg << " Lumi Block : " << sevt.ptr()->lumiBlock()
<< endmsg << " BCID : " << sevt.ptr()->bcid()
<< endmsg << " PileUpType : " << (*it).type());
++it;
} else
ATH_MSG_INFO("xAOD::EventInfo::SubEvent is null");
}
return StatusCode::SUCCESS;
}
StatusCode EventInfoTestTool::finalize() { return StatusCode::SUCCESS; }
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4AT_EVENTINFOTESTTOOL
#define G4AT_EVENTINFOTESTTOOL
#include "DigiTestToolBase.h"
#include "xAODEventInfo/EventInfo.h"
class EventInfoTestTool : public DigiTestToolBase {
public:
EventInfoTestTool(const std::string& name, const std::string& type,
const IInterface* parent);
StatusCode initialize();
StatusCode processEvent();
StatusCode finalize();
private:
SG::ReadHandleKey<xAOD::EventInfo> m_rhkEventInfo{
this, "EventInfoName", "EventInfo", "EventInfo name"};
};
#endif
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include "DigitizationTests/PileUpEventInfoTest.h"
#include "EventInfo/PileUpEventInfo.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h"
#include "EventInfo/PileUpTimeEventIndex.h"
#include "EventInfo/EventType.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"
#include "AthenaKernel/errorcheck.h"
PileUpEventInfoTest::PileUpEventInfoTest(const std::string& name, ISvcLocator* pSvcLocator)
: AthAlgorithm(name, pSvcLocator),
m_pileupInfo("McEventInfo")
{
declareProperty("EventInfoName", m_pileupInfo);
}
StatusCode PileUpEventInfoTest::initialize()
{
ATH_MSG_INFO ( "Initializing " << name() << " - package version " << PACKAGE_VERSION );
return StatusCode::SUCCESS;
}
StatusCode PileUpEventInfoTest::execute()
{
const PileUpEventInfo* pevt = 0;
if ( evtStore()->retrieve(pevt, m_pileupInfo.value()).isFailure() ) {
ATH_MSG_ERROR ( "** Could not get pileup event info" );
return StatusCode::SUCCESS;
}
else {
ATH_MSG_DEBUG ( "Pileup Info Retrieved Successfully as 'PileUpEventInfo' Object " );
//+++ Get sub-event info object
const EventID *eventid = pevt->event_ID();
ATH_MSG_DEBUG ( "Main Event Info: " );
ATH_MSG_INFO ( "RunNumber = " << eventid->run_number() );
ATH_MSG_INFO ( "Event Number = " << eventid->event_number() );
ATH_MSG_INFO ( "LumiBlock = " << eventid->lumi_block() );
ATH_MSG_INFO ( "TimeStamp = " << eventid->time_stamp() );
ATH_MSG_INFO ( "BCID = " << eventid->bunch_crossing_id() );
ATH_MSG_INFO ( "mu = " << pevt->actualInteractionsPerCrossing() );
ATH_MSG_INFO ( "<mu> = " << pevt->averageInteractionsPerCrossing() );
ATH_MSG_INFO ( "Sub Event Infos: " );
PileUpEventInfo::SubEvent::const_iterator it = pevt->beginSubEvt();
PileUpEventInfo::SubEvent::const_iterator end = pevt->endSubEvt();
if (it == end) ATH_MSG_INFO ( "None found" );
for (; it != end; ++it) {
const EventInfo* sevt = (*it).pSubEvt;
if (sevt!=NULL) {
ATH_MSG_INFO ( "Sub Event Info:" );
ATH_MSG_INFO ( " Time : " << (*it).time() << endmsg
<< " Index : " << (*it).index() << endmsg
<< " Provenance : " << (*it).type() << endmsg // This is the provenance stuff: signal, minbias, cavern, etc
<< " Run Number : " << sevt->event_ID()->run_number() << endmsg
<< " Event Number : " << sevt->event_ID()->event_number() << endmsg
<< " ns Offset : " << sevt->event_ID()->time_stamp_ns_offset() << endmsg
<< " Lumi Block : " << sevt->event_ID()->lumi_block() << endmsg
<< " BCID : " << sevt->event_ID()->bunch_crossing_id() << endmsg
<< " User Type : " << sevt->event_type()->user_type() );
// if ((*it).time() == 0) {
// NInTimeEvents++;
// if ((*it).index() > 0) NInTimePileup++;
// }
}
else ATH_MSG_INFO ( "Subevent is null ptr " );
}
}
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include "PileUpEventInfoTestTool.h"
#include "EventInfo/PileUpEventInfo.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h"
#include "EventInfo/PileUpTimeEventIndex.h"
#include "EventInfo/EventType.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"
#include "AthenaKernel/errorcheck.h"
PileUpEventInfoTestTool::PileUpEventInfoTestTool(const std::string& type,
const std::string& name,
const IInterface* parent)
: DigiTestToolBase(type, name, parent),
//m_numberOfEventsSelected(0),
//m_collection("TruthEvent"), //("GEN_EVENT"),
m_pileupInfo("McEventInfo")
{
declareProperty("PileUpEventInfoName", m_pileupInfo);
}
StatusCode PileUpEventInfoTestTool::initialize()
{
ATH_MSG_INFO ( "Initializing " << name() << " - package version " << PACKAGE_VERSION );
return StatusCode::SUCCESS;
}
StatusCode PileUpEventInfoTestTool::processEvent() {
const PileUpEventInfo* pevt;
if ( evtStore()->retrieve(pevt, m_pileupInfo.value()).isFailure() ) {
ATH_MSG_ERROR ( "** Could not get pileup event info" );
return StatusCode::SUCCESS;
}
ATH_MSG_DEBUG ( "Pileup Info Retrieved Successfully as 'PileUpEventInfo' Object " );
//+++ Get sub-event info object
const EventID *eventid = pevt->event_ID();
ATH_MSG_DEBUG ( "Main Event Info: " );
ATH_MSG_INFO ( "RunNumber = " << eventid->run_number() );
ATH_MSG_INFO ( "Event Number = " << eventid->event_number() );
ATH_MSG_INFO ( "LumiBlock = " << eventid->lumi_block() );
ATH_MSG_INFO ( "TimeStamp = " << eventid->time_stamp() );
ATH_MSG_INFO ( "BCID = " << eventid->bunch_crossing_id() );
ATH_MSG_INFO ( "mu = " << pevt->actualInteractionsPerCrossing() );
ATH_MSG_INFO ( "<mu> = " << pevt->averageInteractionsPerCrossing() );
ATH_MSG_INFO ( "Sub Event Infos: " );
PileUpEventInfo::SubEvent::const_iterator it = pevt->beginSubEvt();
PileUpEventInfo::SubEvent::const_iterator end = pevt->endSubEvt();
if (it == end) ATH_MSG_INFO ( "None found" );
for (; it != end; ++it) {
const EventInfo* sevt = (*it).pSubEvt;
if (sevt!=NULL) {
ATH_MSG_INFO ( "Sub Event Info:" );
ATH_MSG_INFO ( " Time : " << (*it).time() << endmsg
<< " Index : " << (*it).index() << endmsg
<< " Provenance : " << (*it).type() << endmsg // This is the provenance stuff: signal, minbias, cavern, etc
<< " Run Number : " << sevt->event_ID()->run_number() << endmsg
<< " Event Number : " << sevt->event_ID()->event_number() << endmsg
<< " ns Offset : " << sevt->event_ID()->time_stamp_ns_offset() << endmsg
<< " Lumi Block : " << sevt->event_ID()->lumi_block() << endmsg
<< " BCID : " << sevt->event_ID()->bunch_crossing_id() << endmsg
<< " User Type : " << sevt->event_type()->user_type() );
// if ((*it).time() == 0) {
// NInTimeEvents++;
// if ((*it).index() > 0) NInTimePileup++;
// }
}
else ATH_MSG_INFO ( "Subevent is null ptr " );
}
return StatusCode::SUCCESS;
}
StatusCode PileUpEventInfoTestTool::finalize()
{
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4AT_PILEUPEVENTINFOTESTTOOL
#define G4AT_PILEUPEVENTINFOTESTTOOL
#include "DigiTestToolBase.h"
class PixelID;
class PileUpEventInfoTestTool : public DigiTestToolBase {
public:
PileUpEventInfoTestTool(const std::string& name,
const std::string& type,
const IInterface* parent);
StatusCode initialize();
StatusCode processEvent();
StatusCode finalize();
private:
StringProperty m_pileupInfo;
};
#endif
#include "DigitizationTests/DigiTestAlg.h"
//#include "DigitizationTests/PileUpEventInfoTest.h"
#include "../EventInfoTestTool.h"
#include "../McEventCollectionTestTool.h"
#include "../PileUpEventInfoTestTool.h"
#include "../PixelRDOsTestTool.h"
#include "../SCT_RDOsTestTool.h"
#include "../TRT_RDOsTestTool.h"
#include "DigitizationTests/DigiTestAlg.h"
DECLARE_COMPONENT( McEventCollectionTestTool )
DECLARE_COMPONENT( PileUpEventInfoTestTool )
DECLARE_COMPONENT( PixelRDOsTestTool )
DECLARE_COMPONENT( SCT_RDOsTestTool )
DECLARE_COMPONENT( TRT_RDOsTestTool )
DECLARE_COMPONENT( DigiTestAlg )
//DECLARE_COMPONENT( PileUpEventInfoTest )
DECLARE_COMPONENT(McEventCollectionTestTool)
DECLARE_COMPONENT(EventInfoTestTool)
DECLARE_COMPONENT(PixelRDOsTestTool)
DECLARE_COMPONENT(SCT_RDOsTestTool)
DECLARE_COMPONENT(TRT_RDOsTestTool)
DECLARE_COMPONENT(DigiTestAlg)
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