From db88cd2c84ecf91b3470fd4ed97960ca8da7ad52 Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Wed, 9 Jul 2014 14:51:20 +0000 Subject: [PATCH] Fix lcio conversion --- DDG4/examples/CLICSidSimu.py | 4 ++-- DDG4/lcio/LCIOConversions.cpp | 16 ++++++++++++++-- DDG4/plugins/Geant4SDActions.cpp | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/DDG4/examples/CLICSidSimu.py b/DDG4/examples/CLICSidSimu.py index afbd69536..ee1bc4332 100644 --- a/DDG4/examples/CLICSidSimu.py +++ b/DDG4/examples/CLICSidSimu.py @@ -66,11 +66,11 @@ def run(): # Setup particle gun gun = simple.setupGun('Gun','pi-',100*GeV,True) - + """ trk = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") kernel.generatorAction().add(trk) trk.enableUI() - + """ """ rdr = DDG4.GeneratorAction(kernel,"LcioGeneratorAction/Reader") diff --git a/DDG4/lcio/LCIOConversions.cpp b/DDG4/lcio/LCIOConversions.cpp index 05d4932cf..ef099f64b 100644 --- a/DDG4/lcio/LCIOConversions.cpp +++ b/DDG4/lcio/LCIOConversions.cpp @@ -165,8 +165,14 @@ namespace DD4hep { pair<VolMgr,Geant4HitCollection*>, lcio::SimTrackerHitImpl>::operator()(const arg_t& args) const { - lcio::LCCollectionVec* lc = new lcio::LCCollectionVec(lcio::LCIO::SIMTRACKERHIT); - return moveEntries<lcio::SimTrackerHitImpl>(args.second,lc); + Geant4HitCollection* coll = args.second; + lcio::SimTrackerHitImpl* hit = coll->hit(0); + long long int id1 = hit->getCellID1(), id0=hit->getCellID0(); + long long int cellID = (((id1<<32)&0xFFFFFFFF00000000)|(id0&0xFFFFFFFF)); + string dsc = encoding(args.first, cellID); + lcio::LCCollectionVec* lc_coll = new lcio::LCCollectionVec(lcio::LCIO::SIMTRACKERHIT); + UTIL::CellIDEncoder<SimTrackerHit> decoder(dsc,lc_coll); + return moveEntries<lcio::SimTrackerHitImpl>(args.second,lc_coll); } /// Data conversion interface moving lcio::SimCalorimeterHitImpl objects from a Geant4HitCollection to a LCCollectionVec @@ -187,7 +193,13 @@ namespace DD4hep { pair<VolMgr,Geant4HitCollection*>, lcio::SimCalorimeterHitImpl>::operator()(const arg_t& args) const { + Geant4HitCollection* coll = args.second; + lcio::SimCalorimeterHitImpl* hit = coll->hit(0); output_t* lc = new lcio::LCCollectionVec(lcio::LCIO::SIMCALORIMETERHIT); + long long int id1 = hit->getCellID1(), id0=hit->getCellID0(); + long long int cellID = (((id1<<32)&0xFFFFFFFF00000000)|(id0&0xFFFFFFFF)); + string dsc = encoding(args.first, cellID); + UTIL::CellIDEncoder<SimCalorimeterHit> decoder(dsc,lc); lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP)); return moveEntries<tag_t>(args.second,lc); } diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 5633a393b..7e0d9ec0d 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -182,12 +182,12 @@ namespace DD4hep { Geant4TouchableHandler handler(step); //hit = new Hit(pos); hit = new Hit(h.prePos()); - hit->cellID = volumeID(step); + hit->cellID = cellID(step); coll->add(hit); print("SimpleCalorimeter","%s> CREATE hit with deposit:%7.3f MeV Pos:%8.2f %8.2f %8.2f %s", c_name(),contrib.deposit,pos.X(),pos.Y(),pos.Z(),handler.path().c_str()); if ( 0 == hit->cellID ) { - hit->cellID = volumeID(step); + hit->cellID = cellID(step); throw runtime_error("Invalid CELL ID for hit!"); } } @@ -196,7 +196,7 @@ namespace DD4hep { c_name(),contrib.deposit,pos.X(),pos.Y(),pos.Z()); } hit->truth.push_back(contrib); - hit->energyDeposit += contrib.deposit; + hit->energyDeposit += contrib.deposit; mark(h.track); return true; } -- GitLab