diff --git a/PhysicsAnalysis/EventTag/EventTagUtils/EventTagUtils/EventInfoTagTool.h b/PhysicsAnalysis/EventTag/EventTagUtils/EventTagUtils/EventInfoTagTool.h index 69fbb0fc046b05034ba82ae94346b4f6290569b8..4a87861b8dc83d2c9ed4777b4da381bfcad69d9f 100755 --- a/PhysicsAnalysis/EventTag/EventTagUtils/EventTagUtils/EventInfoTagTool.h +++ b/PhysicsAnalysis/EventTag/EventTagUtils/EventTagUtils/EventInfoTagTool.h @@ -22,12 +22,13 @@ Purpose : Tool to buid the Global Event Tags #include "TagEvent/TagFragmentCollection.h" #include "AthenaPoolUtilities/AthenaAttributeSpecification.h" #include "xAODEventInfo/EventInfo.h" -#include "EventInfo/EventInfo.h" #include <map> #include <vector> #include <string> +// forward declarations +class ILumiBlockMuTool; /** Interface ID for EventInfoTagTool */ static const InterfaceID IID_EventInfoTagTool("EventInfoTagTool", 1, 0); @@ -63,9 +64,8 @@ protected: StatusCode eventTagFlags (TagFragmentCollection& eventTagCol, const DataHandle<xAOD::EventInfo> eventInfo); StatusCode eventExtrasTag (TagFragmentCollection& eventTagCol, const DataHandle<xAOD::EventInfo> eventInfo); - StatusCode eventTag (TagFragmentCollection& eventTagCol, const DataHandle<EventInfo> eventInfo); - StatusCode eventTagFlags (TagFragmentCollection& eventTagCol, const DataHandle<EventInfo> eventInfo); - StatusCode eventExtrasTag (TagFragmentCollection& eventTagCol, const DataHandle<EventInfo> eventInfo); + // LumiBlockMuTool + ToolHandle<ILumiBlockMuTool> m_lumiBlockMuTool; unsigned int m_runNumber,m_condRunNumber,m_lumiBlock; unsigned long long m_eventNumber; diff --git a/PhysicsAnalysis/EventTag/EventTagUtils/cmt/requirements b/PhysicsAnalysis/EventTag/EventTagUtils/cmt/requirements index f3dabe490b922f398c96a0d87acc8b6e787416d7..3dbcfc79e4fd4cb9a6754cc61977876e80a1ef18 100755 --- a/PhysicsAnalysis/EventTag/EventTagUtils/cmt/requirements +++ b/PhysicsAnalysis/EventTag/EventTagUtils/cmt/requirements @@ -14,7 +14,6 @@ use AthenaBaseComps AthenaBaseComps-* Control use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL -use EventInfo EventInfo-* Event use xAODEventInfo xAODEventInfo-* Event/xAOD use TagEvent TagEvent-* PhysicsAnalysis/EventTag @@ -28,14 +27,18 @@ use AthenaKernel AthenaKernel-* Control use AtlasCLHEP AtlasCLHEP-* External use RecEvent RecEvent-* Reconstruction -use Particle Particle-* Reconstruction -use VxVertex VxVertex-* Tracking/TrkEvent -use CaloEvent CaloEvent-* Calorimeter -use LumiCalc LumiCalc-* LumiBlock -use LumiBlockData LumiBlockData-* LumiBlock +use xAODTracking xAODTracking-* Event/xAOD + +use xAODCaloEvent xAODCaloEvent-* Event/xAOD + + +use LumiCalc LumiCalc-* LumiBlock +use LumiBlockData LumiBlockData-* LumiBlock use TrigConfInterfaces TrigConfInterfaces-* Trigger/TrigConfiguration + +use LumiBlockComps LumiBlockComps-* LumiBlock end_private apply_pattern dual_use_library files=*.cxx diff --git a/PhysicsAnalysis/EventTag/EventTagUtils/share/GlobalEventTagTool_jobOptions.py b/PhysicsAnalysis/EventTag/EventTagUtils/share/GlobalEventTagTool_jobOptions.py index f499232dc3a943b34858725bd4447bac552cd3bd..8fb1717a75057ed73ddb876d924b28b31cebbc05 100755 --- a/PhysicsAnalysis/EventTag/EventTagUtils/share/GlobalEventTagTool_jobOptions.py +++ b/PhysicsAnalysis/EventTag/EventTagUtils/share/GlobalEventTagTool_jobOptions.py @@ -10,9 +10,9 @@ include ("EventTagUtils/EventInfoTagTool_jobOptions.py") from EventTagUtils.EventTagUtilsConf import GlobalEventTagTool as ConfiguredGlobalEventTagTool GlobalEventTagTool=ConfiguredGlobalEventTagTool( - CaloClusterContainer = "CaloCalTopoCluster", - TrackContainer = "TrackParticleCandidate", - VertexContainer = "VxPrimaryCandidate", + CaloClusterContainer = "CaloCalTopoClusters", + TrackContainer = "InDetTrackParticles", + VertexContainer = "PrimaryVertices", IncludeEventFlag = True, IncludeVertexFlag = True, UseMC = False, diff --git a/PhysicsAnalysis/EventTag/EventTagUtils/src/EventInfoTagTool.cxx b/PhysicsAnalysis/EventTag/EventTagUtils/src/EventInfoTagTool.cxx index 1212fc65701be467f58688c5ee2f9cf10336ef31..2522c26771fdf4fa55bf02417e4a81fe956965ae 100755 --- a/PhysicsAnalysis/EventTag/EventTagUtils/src/EventInfoTagTool.cxx +++ b/PhysicsAnalysis/EventTag/EventTagUtils/src/EventInfoTagTool.cxx @@ -21,10 +21,8 @@ Purpose : create a EventInfoTag - The Tag information associated to the event #include "CLHEP/Random/RandFlat.h" +#include "LumiBlockComps/ILumiBlockMuTool.h" #include "xAODEventInfo/EventInfo.h" -#include "EventInfo/EventInfo.h" -#include "EventInfo/EventID.h" -#include "EventInfo/EventType.h" #include "AthenaPoolUtilities/AthenaAttributeSpecification.h" @@ -42,9 +40,11 @@ Purpose : create a EventInfoTag - The Tag information associated to the event EventInfoTagTool::EventInfoTagTool (const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool( type, name, parent ), + m_lumiBlockMuTool("LumiBlockMuTool/LumiBlockMuTool"), m_isMC(false), m_weightSum(0) { + declareProperty("LumiBlockMuTool", m_lumiBlockMuTool); /** AOD Object Name */ declareProperty("IncludeEventFlag", m_includeEventFlag=true); declareProperty("IncludeExtras", m_includeExtras=true); @@ -65,6 +65,9 @@ StatusCode EventInfoTagTool::initialize() { return(sc); } + // retrieve LumiBlockMuTool + CHECK(m_lumiBlockMuTool.retrieve()); + return AthAlgTool::initialize(); } @@ -142,29 +145,8 @@ StatusCode EventInfoTagTool::execute(TagFragmentCollection& eventTag) { StatusCode sc = evtStore()->retrieve(eventInfo); if (sc.isFailure()) { - const DataHandle<EventInfo> oeventInfo; - sc = evtStore()->retrieve(oeventInfo); - if (sc.isFailure()) { - ATH_MSG_ERROR("Could not retrieve event info from TDS."); - } - else { - // set monte carlo flag - m_isMC = oeventInfo->event_type()->test(xAOD::EventInfo::IS_SIMULATION); - - sc = this->eventTag (eventTag, oeventInfo); - if (sc.isFailure()) ATH_MSG_WARNING("Unable to build Tag Fragments for the Event"); - if ( m_includeEventFlag ) { - StatusCode sc = eventTagFlags (eventTag, oeventInfo); - if (sc.isFailure()) ATH_MSG_WARNING("Unable to build Tag Fragments for the Flags"); - } - if ( m_includeExtras ) { - StatusCode sc = eventExtrasTag (eventTag, oeventInfo); - if (sc.isFailure()) ATH_MSG_WARNING("Unable to build Tag Fragments for the Extras"); - } - } - } - else { - + ATH_MSG_ERROR("Could not retrieve event info from TDS."); + } else { // set monte carlo flag m_isMC = eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION); @@ -220,8 +202,8 @@ StatusCode EventInfoTagTool::eventTag(TagFragmentCollection& eventTag, eventTag.insert (EventAttributeSpecs[Evt::Weight].name(), evweight ); // interaction counts - float actualInt = eventInfo->actualInteractionsPerCrossing(); - float avgInt = eventInfo->averageInteractionsPerCrossing(); + float actualInt = m_lumiBlockMuTool->actualInteractionsPerCrossing(); + float avgInt = m_lumiBlockMuTool->averageInteractionsPerCrossing(); eventTag.insert (EventAttributeSpecs[Evt::ActualInt].name(), actualInt ); eventTag.insert (EventAttributeSpecs[Evt::AvgInt].name() , avgInt ); @@ -236,7 +218,7 @@ StatusCode EventInfoTagTool::eventTagFlags(TagFragmentCollection& eventTag, ATH_MSG_DEBUG("in execute() - eventTag"); //Fill Detector status: Pixel, SCT, TRT, LAr, Tile, Muon, ForwardDet, Core - for (unsigned int i = 0; i < EventInfo::nDets; ++i) { + for (unsigned int i = 0; i <= xAOD::EventInfo::Core; ++i) { unsigned int result = 0x0; result = eventInfo->eventFlags(xAOD::EventInfo::EventFlagSubDet(i)); xAOD::EventInfo::EventFlagErrorState error = eventInfo->errorState(xAOD::EventInfo::EventFlagSubDet(i)); @@ -271,92 +253,6 @@ StatusCode EventInfoTagTool::eventExtrasTag(TagFragmentCollection& eventTag, } -/** build the tag associate to the event information */ -StatusCode EventInfoTagTool::eventTag(TagFragmentCollection& eventTag, - const DataHandle<EventInfo> eventInfo) -{ - - ATH_MSG_DEBUG("in execute() - eventTag"); - - /** run number and Event number */ - m_runNumber = eventInfo->event_ID()->run_number(); - m_condRunNumber = m_runNumber; - m_lumiBlock = eventInfo->event_ID()->lumi_block(); - m_eventNumber = eventInfo->event_ID()->event_number(); - eventTag.insert (EventAttributeSpecs[Evt::Run].name(), m_runNumber ); - eventTag.insert (EventAttributeSpecs[Evt::ConditionsRun].name(), m_condRunNumber ); - eventTag.insert (EventAttributeSpecs[Evt::NLumiBlock].name(), m_lumiBlock ); - eventTag.insert (EventAttributeSpecs[Evt::Event].name(), m_eventNumber ); - - unsigned long timeStamp = eventInfo->event_ID()->time_stamp(); - unsigned long timeStampNS = eventInfo->event_ID()->time_stamp_ns_offset(); - unsigned long bunchId = eventInfo->event_ID()->bunch_crossing_id(); - eventTag.insert (EventAttributeSpecs[Evt::Time].name(), timeStamp ); - eventTag.insert (EventAttributeSpecs[Evt::TimeNS].name(), timeStampNS ); - eventTag.insert (EventAttributeSpecs[Evt::BunchId].name(), bunchId ); - - - // event weight - // used for event weighting in monte carlo or just an event count in data - double evweight = 1; - bool isSimulation = eventInfo->event_type()->test(EventType::IS_SIMULATION); - if (isSimulation) evweight = eventInfo->event_type()->mc_event_weight(); - if (isSimulation) m_runNumber = eventInfo->event_type()->mc_channel_number(); - m_weightSum += evweight; - eventTag.insert (EventAttributeSpecs[Evt::Weight].name(), evweight ); - - // interaction counts - float actualInt = eventInfo->actualInteractionsPerCrossing(); - float avgInt = eventInfo->averageInteractionsPerCrossing(); - eventTag.insert (EventAttributeSpecs[Evt::ActualInt].name(), actualInt ); - eventTag.insert (EventAttributeSpecs[Evt::AvgInt].name() , avgInt ); - - return StatusCode::SUCCESS; - -} - -StatusCode EventInfoTagTool::eventTagFlags(TagFragmentCollection& eventTag, - const DataHandle<EventInfo> eventInfo) -{ - - ATH_MSG_DEBUG("in execute() - eventTag"); - - //Fill Detector status: Pixel, SCT, TRT, LAr, Tile, Muon, ForwardDet, Core - for (unsigned int i = 0; i < EventInfo::nDets; ++i) { - unsigned int result = 0x0; - result = eventInfo->eventFlags(EventInfo::EventFlagSubDet(i)); - EventInfo::EventFlagErrorState error = eventInfo->errorState(EventInfo::EventFlagSubDet(i)); - result = result | (error << 28); - eventTag.insert(EventAttributeSpecs[Evt::Pixel+i].name(), result); - } - - return StatusCode::SUCCESS; - -} - -/** build the tag associate to the event information */ -StatusCode EventInfoTagTool::eventExtrasTag(TagFragmentCollection& eventTag, - const DataHandle<EventInfo> eventInfo) -{ - - ATH_MSG_DEBUG("in execute() - eventTag"); - - /** Event Type */ - bool isSimulation = eventInfo->event_type()->test(xAOD::EventInfo::IS_SIMULATION); - m_isMC = isSimulation; - bool isTestBeam = eventInfo->event_type()->test(xAOD::EventInfo::IS_TESTBEAM); - bool isCalibration = eventInfo->event_type()->test(xAOD::EventInfo::IS_CALIBRATION); - eventTag.insert(EventAttributeSpecs[Evt::Simu].name(), isSimulation ); - eventTag.insert(EventAttributeSpecs[Evt::Test].name(), isTestBeam ); - eventTag.insert(EventAttributeSpecs[Evt::Calib].name(), isCalibration ); - - double rand = CLHEP::RandFlat::shoot(); - eventTag.insert(EventAttributeSpecs[Evt::Random].name(), rand); - - return StatusCode::SUCCESS; - -} - /** finialize - called once at the end */ StatusCode EventInfoTagTool::finalize() { ATH_MSG_DEBUG("in finalize()"); diff --git a/PhysicsAnalysis/EventTag/EventTagUtils/src/GlobalEventTagTool.cxx b/PhysicsAnalysis/EventTag/EventTagUtils/src/GlobalEventTagTool.cxx index a3ca4eb6624bd8c56058010743a044a0366f503a..e45de8d607d6e371fc5df8d81fce23f0b8c096a2 100755 --- a/PhysicsAnalysis/EventTag/EventTagUtils/src/GlobalEventTagTool.cxx +++ b/PhysicsAnalysis/EventTag/EventTagUtils/src/GlobalEventTagTool.cxx @@ -17,10 +17,10 @@ Purpose : create a GlobalEventTag - The Tag information associated to the event #include "CLHEP/Units/SystemOfUnits.h" #include "StoreGate/StoreGateSvc.h" -#include "CaloEvent/CaloClusterContainer.h" -#include "Particle/TrackParticleContainer.h" -#include "VxVertex/VxContainer.h" -#include "VxVertex/VxTrackAtVertex.h" +#include "xAODCaloEvent/CaloClusterContainer.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODTracking/VertexContainer.h" +//#include "VxVertex/VxTrackAtVertex.h" #include "EventTagUtils/GlobalEventTagTool.h" #include "TagEvent/GlobalEventAttributeNames.h" @@ -37,9 +37,9 @@ Purpose : create a GlobalEventTag - The Tag information associated to the event GlobalEventTagTool::GlobalEventTagTool (const std::string& type, const std::string& name, const IInterface* parent) : EventInfoTagTool( type, name, parent ) - , m_caloClusterContainerName("CaloCalTopoCluster") - , m_trackContainerName("TrackParticleCandidate") - , m_vertexContainerName("VxPrimaryCandidate") + , m_caloClusterContainerName("CaloCalTopoClusters") + , m_trackContainerName("InDetTrackParticles") + , m_vertexContainerName("PrimaryVertices") , m_mc(false) , m_includeVertexFlag(true) , m_vertexTrackCut(4) @@ -263,7 +263,7 @@ StatusCode GlobalEventTagTool::caloTag(TagFragmentCollection& globalEventTag) { ATH_MSG_DEBUG("in execute() - caloTag"); // retrieve CaloClusters - const CaloClusterContainer* clusterContainer; + const xAOD::CaloClusterContainer* clusterContainer; StatusCode sc = evtStore()->retrieve( clusterContainer, m_caloClusterContainerName ); if (sc.isFailure()) { ATH_MSG_WARNING("No CaloCluster found in SG"); @@ -284,7 +284,7 @@ StatusCode GlobalEventTagTool::trackTag(TagFragmentCollection& globalEventTag) { ATH_MSG_DEBUG("in execute() - trackTag"); // retrieve TrackParticle - const Rec::TrackParticleContainer *tpc; + const xAOD::TrackParticleContainer *tpc; StatusCode sc = evtStore()->retrieve( tpc, m_trackContainerName); if (sc.isFailure()) { ATH_MSG_WARNING("No TrackParticleContainer found in SG"); @@ -304,45 +304,48 @@ StatusCode GlobalEventTagTool::vertexTag(TagFragmentCollection& globalEventTag) ATH_MSG_DEBUG("in execute() - vertexTag"); - const VxContainer *vxc; + const xAOD::VertexContainer *vxc; StatusCode sc = evtStore()->retrieve( vxc, m_vertexContainerName); if (sc.isFailure()) { - ATH_MSG_WARNING("No VxContainer found in SG"); + ATH_MSG_WARNING("No VertexContainer found in SG"); return StatusCode::SUCCESS; } ATH_MSG_DEBUG("Primary Vertex Container successfully retrieved"); int NtightVtx=0; - if (vxc->size() > 0) { - const Trk::RecVertex thisVx = (*vxc)[0]->recVertex(); - globalEventTag.insert ( EventAttributeSpecs[Evt::VtxX].name(), (thisVx.position()).x() ); - globalEventTag.insert ( EventAttributeSpecs[Evt::VtxY].name(), (thisVx.position()).y() ); - globalEventTag.insert ( EventAttributeSpecs[Evt::VtxZ].name(), (thisVx.position()).z() ); - globalEventTag.insert ( EventAttributeSpecs[Evt::VtxChiSq].name(), (thisVx.fitQuality().chiSquared()) ); - globalEventTag.insert ( EventAttributeSpecs[Evt::VtxNdof].name(), (thisVx.fitQuality().numberDoF()) ); - - VxContainer::const_iterator vtxList_end=vxc->end(); - //excluding dummy vertex - --vtxList_end; - for(VxContainer::const_iterator vtxList=vxc->begin(); vtxList != vtxList_end; ++vtxList) { - if((*vtxList)!=0) { - int nGoodTracks=0; - std::vector<Trk::VxTrackAtVertex*>::const_iterator begin=(*vtxList)->vxTrackAtVertex()->begin(); - std::vector<Trk::VxTrackAtVertex*>::const_iterator end=(*vtxList)->vxTrackAtVertex()->end(); - for (std::vector<Trk::VxTrackAtVertex*>::const_iterator iter=begin;iter!=end;++iter){ - if ((*iter)->weight()>0.01){ - nGoodTracks+=1; - } - } - if (nGoodTracks>m_vertexTrackCut) NtightVtx++; + xAOD::VertexContainer::const_iterator vtxList=vxc->begin(); + xAOD::VertexContainer::const_iterator vtxList_end=vxc->end(); + //excluding dummy vertex + --vtxList_end; + for(; vtxList != vtxList_end; ++vtxList) { + if((*vtxList)!=0) { + + if((*vtxList)->vertexType()==xAOD::VxType::PriVtx ){ + NtightVtx++; + // const Trk::RecVertex thisVx = (*vxc)[0]->recVertex(); + globalEventTag.insert ( EventAttributeSpecs[Evt::VtxX].name(), (*vtxList)->x() ); + globalEventTag.insert ( EventAttributeSpecs[Evt::VtxY].name(), (*vtxList)->y() ); + globalEventTag.insert ( EventAttributeSpecs[Evt::VtxZ].name(), (*vtxList)->z() ); + globalEventTag.insert ( EventAttributeSpecs[Evt::VtxChiSq].name(), (*vtxList)->chiSquared() ); + globalEventTag.insert ( EventAttributeSpecs[Evt::VtxNdof].name(), (*vtxList)->numberDoF()); } + int nGoodTracks=0; + // std::vector<Trk::VxTrackAtVertex*>::const_iterator begin=(*vtxList)->vxTrackAtVertex()->begin(); + // std::vector<Trk::VxTrackAtVertex*>::const_iterator end=(*vtxList)->vxTrackAtVertex()->end(); + // for (std::vector<Trk::VxTrackAtVertex*>::const_iterator iter=begin;iter!=end;++iter){ + // if ((*iter)->weight()>0.01){ + // nGoodTracks+=1; + // } + // } + if (nGoodTracks>m_vertexTrackCut) NtightVtx++; } } + globalEventTag.insert ( EventAttributeSpecs[Evt::NVx].name(), vxc->size()-1 ); globalEventTag.insert ( EventAttributeSpecs[Evt::NVxTight].name(), NtightVtx ); - - - + + + return StatusCode::SUCCESS; }