Skip to content
Snippets Groups Projects
Commit 9974ff12 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

Merge branch 'master' of cepcgit.ihep.ac.cn:cepc-prototype/CEPCSW

parents 7a855d4e 0549bb57
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +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")
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")
......@@ -14,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;
......@@ -80,6 +82,8 @@ private:
int m_eventNum{0};
/// Number of events in the file / to process
int m_eventMax{-1};
/// the current file index in the m_filenames vector
int m_fileIndex{0};
SmartIF<IConversionSvc> m_cnvSvc;
......
This diff is collapsed.
......@@ -9,15 +9,35 @@
#include "lcio.h"
// #include "IO/LCReader.h"
// #include "EVENT/LCCollection.h"
#include "EVENT/MCParticle.h"
#include "EVENT/Vertex.h"
#include "EVENT/SimTrackerHit.h"
#include "EVENT/SimCalorimeterHit.h"
#include "plcio/SimTrackerHit.h"
#include "plcio/SimTrackerHitCollection.h"
#include "EVENT/SimCalorimeterHit.h"
#include "plcio/SimCalorimeterHit.h"
#include "plcio/SimCalorimeterHitCollection.h"
#include "EVENT/MCParticle.h"
#include "plcio/MCParticle.h"
#include "plcio/MCParticleCollection.h"
#include "plcio/VertexCollection.h"
#include "EVENT/TPCHit.h"
#include "plcio/TPCHit.h"
#include "plcio/TPCHitCollection.h"
#include "EVENT/Cluster.h"
#include "plcio/Cluster.h"
#include "plcio/ClusterCollection.h"
#include "EVENT/ParticleID.h"
#include "EVENT/CalorimeterHit.h"
#include "plcio/CalorimeterHit.h"
#include "podio/CollectionIDTable.h"
#include "EVENT/Track.h"
#include "EVENT/TrackerHit.h"
#include "EVENT/TrackState.h"
#include "plcio/Track.h"
#include "plcio/TrackCollection.h"
#include "EVENT/ReconstructedParticle.h"
#include "plcio/ReconstructedParticle.h"
#include "plcio/ReconstructedParticleCollection.h"
#include <utility>
// Forward declarations
......@@ -53,16 +73,21 @@ public:
static podio::CollectionBase* Convertor_LCRunHeader(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_SimTrackerHit(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_SimCalorimeterHit(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_Cluster(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_Track(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_ReconstructedParticle(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_LCRelation(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_Vertex(EVENT::LCCollection*);
static podio::CollectionBase* Convertor_TPCHit(EVENT::LCCollection*);
static void void_Core_MCParticle(EVENT::MCParticle*, plcio::MCParticle&);
static plcio::MCParticleCollection* Core_MCParticle(EVENT::LCCollection*);
static void setMCParticle(EVENT::MCParticle*, plcio::MCParticle&);
void setCollName(const std::string &collName){ CollName = collName; };
bool isReady(const std::string&);
void setPlcioMCParticleCollection(plcio::MCParticleCollection*);
void setLCIOMCParticleCollection(EVENT::LCCollection*);
private:
std::string TypeName;
static std::string CollName;
// maintain a log vec about data read;
std::vector<std::string> vec_Types;
......
......@@ -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 != "") {
......@@ -34,11 +42,10 @@ StatusCode LCIODataSvc::initialize() {
}
if (m_filenames.size() > 0) {
if (m_filenames[0] != "") {
m_reader->open(m_filenames);
m_eventMax = m_reader->getNumberOfEvents();
}
m_reader->open(m_filenames[0]);
m_eventMax = m_reader->getNumberOfEvents();
}
return status;
}
/// Service reinitialisation
......@@ -48,6 +55,9 @@ StatusCode LCIODataSvc::reinitialize() {
}
/// Service finalization
StatusCode LCIODataSvc::finalize() {
m_reader->close();
delete m_reader;
m_reader = nullptr;
m_cnvSvc = 0; // release
DataSvc::finalize().ignore();
return StatusCode::SUCCESS;
......@@ -75,10 +85,17 @@ void LCIODataSvc::endOfRead() {
// m_provider.clearCaches();
// m_reader.endOfEvent();
if ( ++m_eventNum >= m_eventMax ) {
info() << "Reached end of file with event " << m_eventMax << endmsg;
IEventProcessor* eventProcessor;
service("ApplicationMgr", eventProcessor);
eventProcessor->stopRun();
if ( ++m_fileIndex < m_filenames.size() ) { // move to next file
m_reader->close();
m_reader->open( m_filenames[m_fileIndex] );
m_eventMax += m_reader->getNumberOfEvents();
}
else { // reach to the end of the file list
info() << "Reached end of file with event " << m_eventMax << endmsg;
IEventProcessor* eventProcessor;
service("ApplicationMgr", eventProcessor);
eventProcessor->stopRun();
}
}
}
evt = nullptr;
......@@ -106,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 ){
......@@ -126,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;
......@@ -138,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();
......@@ -149,6 +174,7 @@ StatusCode LCIODataSvc::readCollection(const std::string& collName, int collecti
// LCIO2Plcio::setLCIOMCParticleCollection(mcpcol_lc);
// LCIO2Plcio::setPlcioMCParticleCollection(mcpcol_pl);
// }
cvtor.setCollName(collName);
collection = cvtor.Convertor_getPlcio( lc_col );
pl_evtcol->at(0)->addCollectionName(collName);
pl_evtcol->at(0)->addCollectionType(TypeName);
......@@ -157,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