Skip to content
Snippets Groups Projects
Commit 9ab24596 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay Committed by Graeme Stewart
Browse files

Making the code capable of retrieving the mu values from LuminosityTool (xAODEventInfoCnv-00-00-17)

parent c837bd4c
No related branches found
No related tags found
No related merge requests found
Showing with 205 additions and 15 deletions
package xAODEventInfoCnv
# $Id: requirements 615394 2014-09-06 06:10:04Z dquarrie $
# $Id: requirements 670837 2015-05-29 10:17:08Z krasznaa $
author Attila Krasznahorkay
......@@ -17,6 +17,7 @@ use AthenaKernel AthenaKernel-* Control
use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL
use InDetBeamSpotService InDetBeamSpotService-* InnerDetector/InDetConditions
use LumiBlockComps LumiBlockComps-* LumiBlock
use EventInfo EventInfo-* Event
......
# $Id: xAODEventDuplicateFinder_jobOptions.py 663741 2015-04-29 11:52:21Z krasznaa $
# Set up the reading of a file:
FNAME = "xAOD.pool.root"
import AthenaPoolCnvSvc.ReadAthenaPool
ServiceMgr.EventSelector.InputCollections = [ FNAME ]
# Access the algorithm sequence:
from AthenaCommon.AlgSequence import AlgSequence
theJob = AlgSequence()
# Add the event duplicate finder algorithm:
theJob += CfgMgr.xAODReader__EventDuplicateFinderAlg( "EventDuplicateFinderAlg",
OutputLevel = 2 )
# Do some additional tweaking:
from AthenaCommon.AppMgr import theApp
theApp.EvtMax = -1
ServiceMgr.MessageSvc.OutputLevel = INFO
ServiceMgr.MessageSvc.defaultLimit = 1000000
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EventDuplicateFinderAlg.cxx 663741 2015-04-29 11:52:21Z krasznaa $
// EDM include(s):
#include "xAODEventInfo/EventInfo.h"
// Local include(s):
#include "EventDuplicateFinderAlg.h"
namespace xAODReader {
EventDuplicateFinderAlg::EventDuplicateFinderAlg( const std::string& name,
ISvcLocator* svcLoc )
: AthAlgorithm( name, svcLoc ),
m_seenEvents() {
declareProperty( "EventInfoKey", m_key = "EventInfo",
"StoreGate key of the xAOD::EventInfo object to be "
"used" );
}
StatusCode EventDuplicateFinderAlg::initialize() {
// Greet the user:
ATH_MSG_INFO( "Initialising - Package version: " << PACKAGE_VERSION );
ATH_MSG_DEBUG( "EventInfoKey = " << m_key );
// Reset the internal variable:
m_seenEvents.clear();
// Return gracefully:
return StatusCode::SUCCESS;
}
StatusCode EventDuplicateFinderAlg::execute() {
// Retrieve the EI object:
const xAOD::EventInfo* ei = 0;
ATH_CHECK( evtStore()->retrieve( ei, m_key ) );
// Check if we saw this event already or not:
if( ! m_seenEvents.insert(
std::make_pair( ei->runNumber(),
ei->eventNumber() ) ).second ) {
ATH_MSG_FATAL( "Seeing run #" << ei->runNumber() << ", event #"
<< ei->eventNumber() << " for the second time" );
return StatusCode::FAILURE;
}
// No, we just saw it now for the first time:
ATH_MSG_VERBOSE( "Saw run #" << ei->runNumber() << ", event #"
<< ei->eventNumber() << " for the first time" );
// Return gracefully:
return StatusCode::SUCCESS;
}
} // namespace xAODReader
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EventDuplicateFinderAlg.h 663741 2015-04-29 11:52:21Z krasznaa $
#ifndef XAODEVENTINFOCNV_EVENTDUPLICATEFINDERALG_H
#define XAODEVENTINFOCNV_EVENTDUPLICATEFINDERALG_H
// System include(s):
#include <string>
#include <map> // For std::pair...
#include <set>
// Gaudi/Athena include(s):
#include "AthenaBaseComps/AthAlgorithm.h"
namespace xAODReader {
/**
* @short Algorithm for finding event duplicates in xAOD files
*
* This algorithm is used in simple validation jobs to make sure
* that we didn't put the same event multiple times into an output
* dataset in the production system.
*
* @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
*
* $Revision: 663741 $
* $Date: 2015-04-29 13:52:21 +0200 (Wed, 29 Apr 2015) $
*/
class EventDuplicateFinderAlg : public AthAlgorithm {
public:
/// Regular Algorithm constructor
EventDuplicateFinderAlg( const std::string& name, ISvcLocator* svcLoc );
/// Function initialising the algorithm
virtual StatusCode initialize();
/// Function executing the algorithm
virtual StatusCode execute();
private:
/// StoreGate key of the EI object to be tested
std::string m_key;
/// Variable keeping track of the events seen
std::set< std::pair< unsigned int, unsigned int > > m_seenEvents;
}; // class EventDuplicateFinderAlg
} // namespace xAODReader
#endif // XAODEVENTINFOCNV_EVENTDUPLICATEFINDERALG_H
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EventInfoCnvAlg.cxx 634394 2014-12-08 11:10:34Z krasznaa $
// $Id: EventInfoCnvAlg.cxx 644234 2015-02-04 17:24:51Z leggett $
// Gaudi/Athena include(s):
#include "AthenaKernel/errorcheck.h"
......@@ -107,11 +107,13 @@ namespace xAODMaker {
StatusCode EventInfoCnvAlg::beginRun() {
#ifndef ATHENAHIVE
// Let the user know what's happening:
ATH_MSG_DEBUG( "Preparing xAOD::EventInfo object in beginRun()" );
// Run the conversion using the execute function:
CHECK( execute() );
#endif
// Return gracefully:
return StatusCode::SUCCESS;
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EventInfoCnvTool.cxx 636755 2014-12-18 14:59:03Z cranshaw $
// $Id: EventInfoCnvTool.cxx 670837 2015-05-29 10:17:08Z krasznaa $
// Gaudi/Athena include(s):
#include "AthenaKernel/errorcheck.h"
......@@ -14,6 +14,7 @@
#include "EventInfo/TriggerInfo.h"
#include "EventInfo/PileUpEventInfo.h"
#include "AthenaPoolUtilities/AthenaAttributeList.h"
#include "AthenaPoolUtilities/CondAttrListCollection.h"
#include "xAODEventInfo/EventInfo.h"
#include "xAODEventInfo/EventInfoContainer.h"
......@@ -25,18 +26,27 @@ namespace xAODMaker {
/// Hard-coded location of the beam position information
static const std::string INDET_BEAMPOS = "/Indet/Beampos";
/// Hard-coded location of the luminosity information
static const std::string LUMI_FOLDER_RUN11 = "/TRIGGER/OFLLUMI/LBLESTOFL";
static const std::string LUMI_FOLDER_RUN12 = "/TRIGGER/LUMI/LBLESTONL";
static const std::string LUMI_FOLDER_RUN21 = "/TRIGGER/OFLLUMI/OflPrefLumi";
static const std::string LUMI_FOLDER_RUN22 = "/TRIGGER/LUMI/OnlPrefLumi";
EventInfoCnvTool::EventInfoCnvTool( const std::string& type,
const std::string& name,
const IInterface* parent )
: AthAlgTool( type, name, parent ),
m_beamCondSvc( "BeamCondSvc", name ),
m_beamCondSvcAvailable( false ) {
m_beamCondSvcAvailable( false ),
m_lumiTool( "LuminosityTool" ),
m_lumiToolAvailable( false ) {
// Declare the interface(s) provided by the tool:
declareInterface< IEventInfoCnvTool >( this );
// Declare the tool's properties:
declareProperty( "BeamCondSvc", m_beamCondSvc );
declareProperty( "LuminosityTool", m_lumiTool );
}
StatusCode EventInfoCnvTool::initialize() {
......@@ -59,6 +69,24 @@ namespace xAODMaker {
CHECK( m_beamCondSvc.retrieve() );
}
// Check if the luminosity tool will be available or not:
if( detStore()->contains< CondAttrListCollection >( LUMI_FOLDER_RUN11 ) ||
detStore()->contains< CondAttrListCollection >( LUMI_FOLDER_RUN12 ) ||
detStore()->contains< CondAttrListCollection >( LUMI_FOLDER_RUN21 ) ||
detStore()->contains< CondAttrListCollection >( LUMI_FOLDER_RUN22 ) ) {
ATH_MSG_INFO( "Taking luminosity information from: " << m_lumiTool );
m_lumiToolAvailable = true;
} else {
ATH_MSG_INFO( "Luminosity information not available" );
ATH_MSG_INFO( "Will take information from the EventInfo object" );
m_lumiToolAvailable = false;
}
// Try to access the luminosity tool:
if( m_lumiToolAvailable ) {
CHECK( m_lumiTool.retrieve() );
}
// Return gracefully:
return StatusCode::SUCCESS;
}
......@@ -145,12 +173,23 @@ namespace xAODMaker {
xaod->setStreamTags( streamTags );
}
// Copy the pileup information:
// Copy/calculate the pileup information:
if( ! pileUpInfo ) {
xaod->setActualInteractionsPerCrossing(
aod->actualInteractionsPerCrossing() );
xaod->setAverageInteractionsPerCrossing(
aod->averageInteractionsPerCrossing() );
if( m_lumiToolAvailable ) {
float actualMu = 0.0;
const float muToLumi = m_lumiTool->muToLumi();
if( std::abs( muToLumi ) > 0.00001 ) {
actualMu = m_lumiTool->lbLuminosityPerBCID() / muToLumi;
}
xaod->setActualInteractionsPerCrossing( actualMu );
xaod->setAverageInteractionsPerCrossing(
m_lumiTool->lbAverageInteractionsPerCrossing() );
} else {
xaod->setActualInteractionsPerCrossing(
aod->actualInteractionsPerCrossing() );
xaod->setAverageInteractionsPerCrossing(
aod->averageInteractionsPerCrossing() );
}
}
// Construct the maps for the flag copying:
......@@ -186,7 +225,7 @@ namespace xAODMaker {
for( ; sd_itr != sd_end; ++sd_itr ) {
// Lumi does not store event flags, or an error state:
if( sd_itr->first == EventInfo::Lumi ) {
if( (int)sd_itr->first == (int)EventInfo::Lumi ) {
continue;
}
......@@ -275,7 +314,7 @@ namespace xAODMaker {
}
// Finish with some printout:
ATH_MSG_VERBOSE( "Finished converting: " << *xaod );
ATH_MSG_VERBOSE( "Finished conversion" << *xaod );
// Return gracefully:
return StatusCode::SUCCESS;
......
......@@ -4,17 +4,21 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EventInfoCnvTool.h 603159 2014-06-23 13:53:47Z krasznaa $
// $Id: EventInfoCnvTool.h 670837 2015-05-29 10:17:08Z krasznaa $
#ifndef XAODEVENTINFOCNV_EVENTINFOCNVTOOL_H
#define XAODEVENTINFOCNV_EVENTINFOCNVTOOL_H
// Gaudi/Athena include(s):
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
// Beam condition include(s):
#include "InDetBeamSpotService/IBeamCondSvc.h"
// Luminosity include(s):
#include "LumiBlockComps/ILuminosityTool.h"
// Local include(s):
#include "xAODEventInfoCnv/IEventInfoCnvTool.h"
......@@ -28,8 +32,8 @@ namespace xAODMaker {
*
* @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
*
* $Revision: 603159 $
* $Date: 2014-06-23 15:53:47 +0200 (Mon, 23 Jun 2014) $
* $Revision: 670837 $
* $Date: 2015-05-29 12:17:08 +0200 (Fri, 29 May 2015) $
*/
class EventInfoCnvTool : public AthAlgTool,
public virtual IEventInfoCnvTool {
......@@ -53,6 +57,11 @@ namespace xAODMaker {
/// Internal flag for the availability of the beam conditions service
bool m_beamCondSvcAvailable;
/// Connection to the luminosity tool
ToolHandle< ILuminosityTool > m_lumiTool;
/// Internal flag for the availability of the luminosity tool
bool m_lumiToolAvailable;
}; // class EventInfoCnvTool
} // namespace xAODMaker
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
// $Id: xAODEventInfoCnv_entries.cxx 638573 2015-01-09 16:15:16Z cranshaw $
// $Id: xAODEventInfoCnv_entries.cxx 663741 2015-04-29 11:52:21Z krasznaa $
// Gaudi/Athena include(s):
#include "GaudiKernel/DeclareFactoryEntries.h"
......@@ -8,11 +8,13 @@
#include "../EventInfoSelectorTool.h"
#include "../EventInfoCnvAlg.h"
#include "../EventInfoReaderAlg.h"
#include "../EventDuplicateFinderAlg.h"
DECLARE_NAMESPACE_TOOL_FACTORY( xAODMaker, EventInfoCnvTool )
DECLARE_NAMESPACE_TOOL_FACTORY( xAODMaker, EventInfoSelectorTool )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( xAODMaker, EventInfoCnvAlg )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( xAODReader, EventInfoReaderAlg )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( xAODReader, EventDuplicateFinderAlg )
DECLARE_FACTORY_ENTRIES( xAODEventInfoCnv ) {
......@@ -20,5 +22,6 @@ DECLARE_FACTORY_ENTRIES( xAODEventInfoCnv ) {
DECLARE_NAMESPACE_TOOL( xAODMaker, EventInfoSelectorTool )
DECLARE_NAMESPACE_ALGORITHM( xAODMaker, EventInfoCnvAlg )
DECLARE_NAMESPACE_ALGORITHM( xAODReader, EventInfoReaderAlg )
DECLARE_NAMESPACE_ALGORITHM( xAODReader, EventDuplicateFinderAlg )
}
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