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

make LCIODataSvc be compatible with CEPCDataSvc

parent cd368d65
No related branches found
No related tags found
No related merge requests found
......@@ -2,9 +2,14 @@
from Gaudi.Configuration import *
from Configurables import LCIODataSvc
# 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")
from Configurables import LCIODataSvc, CEPCDataSvc
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
alg = PlcioReadAlg("PlcioReadAlg")
......@@ -15,33 +20,42 @@ from Configurables import LCIOInput
lcioinput = LCIOInput("LCIOReader", collections=[
"EventHeader",
"MCParticle",
"COILCollection",
"EcalBarrelSiliconCollection",
"EcalBarrelSiliconPreShowerCollection",
"EcalEndcapRingCollection",
"EcalEndcapRingPreShowerCollection",
"EcalEndcapSiliconCollection",
"EcalEndcapSiliconPreShowerCollection",
"FTD_PIXELCollection",
"FTD_STRIPCollection",
"HcalBarrelCollection",
"HcalEndCapRingsCollection",
"HcalEndCapsCollection",
"LumiCalCollection",
"MuonBarrelCollection",
"MuonEndCapCollection",
"SETCollection",
"SITCollection",
"TPCCollection",
"TPCSpacePointCollection",
"VXDCollection"
"TPCCollection"
#"EventHeader",
#"MCParticle",
#"COILCollection",
#"EcalBarrelSiliconCollection",
#"EcalBarrelSiliconPreShowerCollection",
#"EcalEndcapRingCollection",
#"EcalEndcapRingPreShowerCollection",
#"EcalEndcapSiliconCollection",
#"EcalEndcapSiliconPreShowerCollection",
#"FTD_PIXELCollection",
#"FTD_STRIPCollection",
#"HcalBarrelCollection",
#"HcalEndCapRingsCollection",
#"HcalEndCapsCollection",
#"LumiCalCollection",
#"MuonBarrelCollection",
#"MuonEndCapCollection",
#"SETCollection",
#"SITCollection",
#"TPCCollection",
#"TPCSpacePointCollection",
#"VXDCollection"
])
lcioinput.DataSvc = svcname
from Configurables import PodioOutput
plcioout = PodioOutput("PlcioWriter")
plcioout.filename = "lcio2plcio.root"
plcioout.outputCommands = ["keep *"]
# ApplicationMgr
from Configurables import ApplicationMgr
ApplicationMgr( TopAlg = [lcioinput, alg],
ApplicationMgr( TopAlg = [lcioinput, alg, plcioout],
EvtSel = 'NONE',
EvtMax = 10,
ExtSvc = [dsvc],
ExtSvc = [rsvc, wsvc],
OutputLevel=DEBUG
)
......@@ -73,6 +73,8 @@ private:
IO::LCReader* m_reader;
/// LCIO reader for ROOT files
plcio::EventHeaderCollection* pl_evtcol;
/// the handle of DataProvider
IDataProviderSvc* m_pIDP{nullptr};
/// podio::ROOTReader m_reader;
/// LCIO EventStore, used to initialise collections
/// podio::EventStore m_provider;
......
......@@ -27,6 +27,14 @@ StatusCode LCIODataSvc::initialize() {
m_cnvSvc = svc_loc->service("EventPersistencySvc");
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();
if (m_filename != "") {
......@@ -115,6 +123,8 @@ LCIODataSvc::~LCIODataSvc() {}
StatusCode LCIODataSvc::readCollection(const std::string& collName, int collectionID) {
StatusCode stat = StatusCode::SUCCESS;
podio::CollectionBase* collection(nullptr);
if( evt == nullptr ){
......@@ -135,9 +145,14 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
int id = m_collectionIDs->add("EventHeader");
pl_evtcol->setID(id);
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;
......@@ -147,7 +162,8 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
if( it != vec_colns.end() ){
lc_col = evt->getCollection(collName);
}
else return StatusCode::SUCCESS;
else
return stat;
// debug() << "Got collection: " << collName << "." << endmsg;
std::string TypeName = lc_col->getTypeName();
......@@ -167,11 +183,17 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
int id = m_collectionIDs->add(collName);
collection->setID(id);
wrapper->setData(collection);
m_readCollections.emplace_back(std::make_pair(collName, collection));
// 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) {
......
......@@ -14,7 +14,8 @@ StatusCode LCIOInput::initialize() {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
// 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;
auto idTable = m_LCIODataSvc->getCollectionIDs();
......
......@@ -33,6 +33,7 @@ public:
private:
/// 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"};
/// Collection IDs (retrieved with CollectionIDTable from ROOT file, using collection names)
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