Skip to content
Snippets Groups Projects
Commit 0549bb57 authored by zoujh@ihep.ac.cn's avatar zoujh@ihep.ac.cn
Browse files

Merge branch 'master' into 'master'

make LCIODataSvc be compatible with CEPCDataSvc

See merge request cepc-prototype/CEPCSW!13
parents cd368d65 0d0350cb
No related branches found
No related tags found
No related merge requests found
...@@ -2,9 +2,14 @@ ...@@ -2,9 +2,14 @@
from Gaudi.Configuration import * from Gaudi.Configuration import *
from Configurables import LCIODataSvc from Configurables import LCIODataSvc, CEPCDataSvc
# dsvc = LCIODataSvc("EventDataSvc", input="/cefs/data/FullSim/CEPC240/CEPC_v4/higgs/E240.Pe2e2h_bb.e0.p0.whizard195/e2e2h_bb.e0.p0.00001_000000_sim.slcio")
dsvc = LCIODataSvc("EventDataSvc", input="/cefs/data/DstData/CEPC240/CEPC_v4/higgs/E240.Pe2e2h_X.e0.p0.whizard195/e2e2h_X.e0.p0.00001_001000_dst.slcio") svcname = "LCIODataSvc"
rsvc = LCIODataSvc(svcname, inputs = [
"/cefs/data/FullSim/CEPC240/CEPC_v4/higgs/smart_final_states/E240.Pffh_invi.e0.p0.whizard195//ffh_inv.e0.p0.00001_1000_sim.slcio"
])
wsvc = CEPCDataSvc("EventDataSvc")
from Configurables import PlcioReadAlg from Configurables import PlcioReadAlg
alg = PlcioReadAlg("PlcioReadAlg") alg = PlcioReadAlg("PlcioReadAlg")
...@@ -15,33 +20,42 @@ from Configurables import LCIOInput ...@@ -15,33 +20,42 @@ from Configurables import LCIOInput
lcioinput = LCIOInput("LCIOReader", collections=[ lcioinput = LCIOInput("LCIOReader", collections=[
"EventHeader", "EventHeader",
"MCParticle", "MCParticle",
"COILCollection", "TPCCollection"
"EcalBarrelSiliconCollection", #"EventHeader",
"EcalBarrelSiliconPreShowerCollection", #"MCParticle",
"EcalEndcapRingCollection", #"COILCollection",
"EcalEndcapRingPreShowerCollection", #"EcalBarrelSiliconCollection",
"EcalEndcapSiliconCollection", #"EcalBarrelSiliconPreShowerCollection",
"EcalEndcapSiliconPreShowerCollection", #"EcalEndcapRingCollection",
"FTD_PIXELCollection", #"EcalEndcapRingPreShowerCollection",
"FTD_STRIPCollection", #"EcalEndcapSiliconCollection",
"HcalBarrelCollection", #"EcalEndcapSiliconPreShowerCollection",
"HcalEndCapRingsCollection", #"FTD_PIXELCollection",
"HcalEndCapsCollection", #"FTD_STRIPCollection",
"LumiCalCollection", #"HcalBarrelCollection",
"MuonBarrelCollection", #"HcalEndCapRingsCollection",
"MuonEndCapCollection", #"HcalEndCapsCollection",
"SETCollection", #"LumiCalCollection",
"SITCollection", #"MuonBarrelCollection",
"TPCCollection", #"MuonEndCapCollection",
"TPCSpacePointCollection", #"SETCollection",
"VXDCollection" #"SITCollection",
#"TPCCollection",
#"TPCSpacePointCollection",
#"VXDCollection"
]) ])
lcioinput.DataSvc = svcname
from Configurables import PodioOutput
plcioout = PodioOutput("PlcioWriter")
plcioout.filename = "lcio2plcio.root"
plcioout.outputCommands = ["keep *"]
# ApplicationMgr # ApplicationMgr
from Configurables import ApplicationMgr from Configurables import ApplicationMgr
ApplicationMgr( TopAlg = [lcioinput, alg], ApplicationMgr( TopAlg = [lcioinput, alg, plcioout],
EvtSel = 'NONE', EvtSel = 'NONE',
EvtMax = 10, EvtMax = 10,
ExtSvc = [dsvc], ExtSvc = [rsvc, wsvc],
OutputLevel=DEBUG OutputLevel=DEBUG
) )
...@@ -73,6 +73,8 @@ private: ...@@ -73,6 +73,8 @@ private:
IO::LCReader* m_reader; IO::LCReader* m_reader;
/// LCIO reader for ROOT files /// LCIO reader for ROOT files
plcio::EventHeaderCollection* pl_evtcol; plcio::EventHeaderCollection* pl_evtcol;
/// the handle of DataProvider
IDataProviderSvc* m_pIDP{nullptr};
/// podio::ROOTReader m_reader; /// podio::ROOTReader m_reader;
/// LCIO EventStore, used to initialise collections /// LCIO EventStore, used to initialise collections
/// podio::EventStore m_provider; /// podio::EventStore m_provider;
......
...@@ -27,6 +27,14 @@ StatusCode LCIODataSvc::initialize() { ...@@ -27,6 +27,14 @@ StatusCode LCIODataSvc::initialize() {
m_cnvSvc = svc_loc->service("EventPersistencySvc"); m_cnvSvc = svc_loc->service("EventPersistencySvc");
status = setDataLoader(m_cnvSvc); status = setDataLoader(m_cnvSvc);
if ( name() != "EventDataSvc" ) {
service("EventDataSvc", m_pIDP, true);
if ( m_pIDP == nullptr ) {
error() << "Could not get the EventDataSvc instance" << endmsg;
return StatusCode::FAILURE;
}
}
m_reader = IOIMPL::LCFactory::getInstance()->createLCReader(); m_reader = IOIMPL::LCFactory::getInstance()->createLCReader();
if (m_filename != "") { if (m_filename != "") {
...@@ -115,6 +123,8 @@ LCIODataSvc::~LCIODataSvc() {} ...@@ -115,6 +123,8 @@ LCIODataSvc::~LCIODataSvc() {}
StatusCode LCIODataSvc::readCollection(const std::string& collName, int collectionID) { StatusCode LCIODataSvc::readCollection(const std::string& collName, int collectionID) {
StatusCode stat = StatusCode::SUCCESS;
podio::CollectionBase* collection(nullptr); podio::CollectionBase* collection(nullptr);
if( evt == nullptr ){ if( evt == nullptr ){
...@@ -135,9 +145,14 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti ...@@ -135,9 +145,14 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
int id = m_collectionIDs->add("EventHeader"); int id = m_collectionIDs->add("EventHeader");
pl_evtcol->setID(id); pl_evtcol->setID(id);
wrapper->setData(pl_evtcol); wrapper->setData(pl_evtcol);
m_readCollections.emplace_back(std::make_pair("EventHeader", pl_evtcol));
DataSvc::registerObject("EventHeader", wrapper); if ( m_pIDP ) {
m_pIDP->registerObject("EventHeader", wrapper);
}
else {
m_readCollections.emplace_back(std::make_pair("EventHeader", pl_evtcol));
DataSvc::registerObject("EventHeader", wrapper);
}
} }
debug() << "reading collection name: " << collName << "." << endmsg; debug() << "reading collection name: " << collName << "." << endmsg;
...@@ -147,7 +162,8 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti ...@@ -147,7 +162,8 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
if( it != vec_colns.end() ){ if( it != vec_colns.end() ){
lc_col = evt->getCollection(collName); lc_col = evt->getCollection(collName);
} }
else return StatusCode::SUCCESS; else
return stat;
// debug() << "Got collection: " << collName << "." << endmsg; // debug() << "Got collection: " << collName << "." << endmsg;
std::string TypeName = lc_col->getTypeName(); std::string TypeName = lc_col->getTypeName();
...@@ -167,11 +183,17 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti ...@@ -167,11 +183,17 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
int id = m_collectionIDs->add(collName); int id = m_collectionIDs->add(collName);
collection->setID(id); collection->setID(id);
wrapper->setData(collection); wrapper->setData(collection);
m_readCollections.emplace_back(std::make_pair(collName, collection));
// info() << "readCollection completed." << endmsg; // info() << "readCollection completed." << endmsg;
return DataSvc::registerObject(collName, wrapper); if ( m_pIDP ) {
stat = m_pIDP->registerObject(collName, wrapper);
}
else {
m_readCollections.emplace_back(std::make_pair(collName, collection));
stat = DataSvc::registerObject(collName, wrapper);
}
return stat;
} }
StatusCode LCIODataSvc::registerObject(const std::string& fullPath, DataObject* pObject) { StatusCode LCIODataSvc::registerObject(const std::string& fullPath, DataObject* pObject) {
......
...@@ -14,7 +14,8 @@ StatusCode LCIOInput::initialize() { ...@@ -14,7 +14,8 @@ StatusCode LCIOInput::initialize() {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE; if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
// check whether we have the LCIOEvtSvc active // check whether we have the LCIOEvtSvc active
m_LCIODataSvc = dynamic_cast<LCIODataSvc*>(evtSvc().get()); auto pSvc = service( m_dataSvc );
m_LCIODataSvc = dynamic_cast<LCIODataSvc*>(pSvc.get());
if (nullptr == m_LCIODataSvc) return StatusCode::FAILURE; if (nullptr == m_LCIODataSvc) return StatusCode::FAILURE;
auto idTable = m_LCIODataSvc->getCollectionIDs(); auto idTable = m_LCIODataSvc->getCollectionIDs();
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
private: private:
/// Name of collections to read. Set by option collections (this is temporary) /// Name of collections to read. Set by option collections (this is temporary)
Gaudi::Property<std::string> m_dataSvc{ this, "DataSvc", "LCIOInputSvc" };
Gaudi::Property<std::vector<std::string>> m_collectionNames{this, "collections", {}, "Places of collections to read"}; Gaudi::Property<std::vector<std::string>> m_collectionNames{this, "collections", {}, "Places of collections to read"};
/// Collection IDs (retrieved with CollectionIDTable from ROOT file, using collection names) /// Collection IDs (retrieved with CollectionIDTable from ROOT file, using collection names)
std::vector<int> m_collectionIDs; std::vector<int> m_collectionIDs;
......
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