diff --git a/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx b/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx index 18f6138b8b6a2570b5ace7c16acc657cd0e0c90b..c2f750eede8e9cd93bea44085bd8b7d93450977f 100644 --- a/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx +++ b/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx @@ -26,6 +26,4 @@ DECLARE_COMPONENT(LumiBlockMuWriter) #endif DECLARE_COMPONENT( LumiBlockMetaDataTool ) -#include "../xAOD2NtupLumiSvc.h" -DECLARE_COMPONENT( xAOD2NtupLumiSvc ) diff --git a/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.cxx b/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.cxx deleted file mode 100644 index 6e628711404459478a1b773d4b3e5d130475a90f..0000000000000000000000000000000000000000 --- a/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "xAOD2NtupLumiSvc.h" - -#include "GaudiKernel/ITHistSvc.h" - -#include "TKey.h" -#include "TTree.h" -#include "TFile.h" - -#include "xAODLuminosity/LumiBlockRangeContainer.h" -#include "xAODLuminosity/LumiBlockRangeAuxContainer.h" -#include "xAODRootAccess/TEvent.h" - -#include "StoreGate/StoreGateSvc.h" -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/IIncidentSvc.h" - -// Constructor -xAOD2NtupLumiSvc::xAOD2NtupLumiSvc(const std::string& name, ISvcLocator *svcLoc) : - AthService(name, svcLoc) -{ - -} - - - -StatusCode xAOD2NtupLumiSvc::initialize() { - - ServiceHandle<IIncidentSvc> isvc("IncidentSvc",name()); - isvc->addListener( this, "MetaDataStop", 0, true); - - return StatusCode::SUCCESS; - -} - -void xAOD2NtupLumiSvc::handle(const Incident& inc) { - if (inc.type() == "MetaDataStop") { - finish().ignore(); - } -} - -StatusCode xAOD2NtupLumiSvc::finish(){ - - ServiceHandle<StoreGateSvc> metastore("StoreGateSvc/MetaDataStore",name()); - - //see if we have any luminosity to propagate to ntuples - std::vector<std::string> keys; - metastore->keys<xAOD::LumiBlockRangeContainer>(keys); - //if there is no lumi, then we are done - if(!keys.size()) return StatusCode::SUCCESS; - - - - //use xAOD::RootAccess to create a metadata file - //put all lumiblock types into output so that hadd merging the ntuples is 'safe' - xAOD::TEvent evt; - TFile* outFile = new TFile("metadata.out.root","RECREATE"); - if(evt.writeTo( outFile ).isFailure()) return StatusCode::FAILURE; - std::vector<std::string> allKeys = {"LumiBlocks","IncompleteLumiBlocks","SuspectLumiBlocks"}; - for(auto& key : allKeys) { - bool foundKey(false);for(uint i=0;i<keys.size();i++) {if(keys[i]==key) {foundKey=true;break;}} - if(foundKey) { - auto lbs = metastore->retrieveUniquePrivateCopy<xAOD::LumiBlockRangeContainer>(key); //returns unique_ptr - auto lbsAux = metastore->retrieveUniquePrivateCopy<xAOD::LumiBlockRangeAuxContainer>(key+"Aux."); //returns unique_ptr - if( evt.recordMeta( lbs.release() , key ).isFailure() ) return StatusCode::FAILURE; //technically we wont need to store the interface container, but doesnt harm us - if( evt.recordMeta( lbsAux.release() , key+"Aux.").isFailure() ) return StatusCode::FAILURE; - } else { - //record a dummy interface and aux container - xAOD::LumiBlockRangeContainer* dummy = new xAOD::LumiBlockRangeContainer; - xAOD::LumiBlockRangeAuxContainer* dummyAux = new xAOD::LumiBlockRangeAuxContainer; - dummy->setStore(dummyAux); - if( evt.recordMeta( dummy , key).isFailure() ) return StatusCode::FAILURE; - if( evt.recordMeta( dummyAux , key+"Aux.").isFailure() ) return StatusCode::FAILURE; - } - } - - if( evt.finishWritingTo( outFile ).isFailure() ) return StatusCode::FAILURE; - - TTree* metatree = dynamic_cast<TTree*>(outFile->Get("MetaData"))->CloneTree(); - metatree->SetDirectory(0); - - //copy this MetaData tree to every output stream that contains a Tree - ServiceHandle<ITHistSvc> histSvc("THistSvc",name()); - std::vector<std::string> histsvcTrees = histSvc->getTrees(); - std::set<TString> doneStreams; - for(unsigned int i=0;i<histsvcTrees.size();i++) { - //strip the tree name (all after last /) - TString ss(histsvcTrees[i].c_str()); - int secondSlash = TString(ss(1,ss.Length())).First('/'); - TString ssPath = ss(0,secondSlash+1); - if(doneStreams.find(ssPath)!=doneStreams.end()) continue; - TString sss = ssPath;sss += "/MetaData"; - ATH_CHECK(histSvc->regTree(sss.Data(),metatree->CloneTree())); - doneStreams.insert(ssPath); - } - - outFile->Close(); - delete outFile; - //now delete the actual file - std::remove("metadata.out.root"); - - return StatusCode::SUCCESS; -} - diff --git a/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.h b/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.h deleted file mode 100644 index 750ad96c9ceae903397ec06ecf320d9f75801f8e..0000000000000000000000000000000000000000 --- a/LumiBlock/LumiBlockComps/src/xAOD2NtupLumiSvc.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef __XAOD2NTUPLUMISVC__ -#define __XAOD2NTUPLUMISVC__ - -///Use this service to write out luminosity bookkeeping information -///to ntuples (managed by THistSvc) that can then be used with -///getLumi.exe to check luminosity covered -/// -///Usage ... only needed when running on data: -/// theApp.CreateSvc += ['xAOD2NtupLumiSvc'] -/// svcMgr.MetaDataSvc.MetaDataTools += [ "LumiBlockMetaDataTool" ] - - - -#include "AthenaBaseComps/AthService.h" -#include "GaudiKernel/IIncidentListener.h" - - - - -class xAOD2NtupLumiSvc : public AthService, - virtual public IIncidentListener { - -public: - xAOD2NtupLumiSvc(const std::string& name, ISvcLocator *svcLoc); - - virtual void handle(const Incident& inc); - - virtual StatusCode initialize(); - - StatusCode finish(); - - -}; - - -#endif -