Commit 03215119 authored by Frank Gaede's avatar Frank Gaede
Browse files

create unique hits per calo cell

parent 021d3d8b
......@@ -198,28 +198,34 @@ void SimpleCaloEDM4hepEventAction::EndOfEventAction(const G4Event *evt)
mcp.setCharge( pparticle->GetCharge() ) ;
/// For now simply convert all Hits in sensitive detector
std::map<unsigned long long, edm4hep::SimCalorimeterHit> hits ;
for (int i=0;i<n_hit;i++)
{
G4double estep = (*THC)[i]->GetEdep()/GeV;
if (estep >0.0)
{
auto hit = fSHC->create() ;
int layerNum = (*THC)[i]->GetLayerNum() ;
G4ThreeVector hitpos=(*THC)[i]->GetPos();
seg.setPositionAndLayer( hitpos , layerNum ) ;
hit.setCellID( seg.getCellID() ) ;
unsigned long long cellID = seg.getCellID() ;
totE += estep ;
auto it = hits.find( cellID ) ;
if( it != hits.end() ) {
// already have a hit for this cell - simply update the energy
double e = it->second.getEnergy() ;
it->second.setEnergy( e + estep ) ;
continue ;
}
auto hit = fSHC->create() ;
hit.setCellID( cellID ) ;
hit.setEnergy( estep ) ;
// hit.setPosition( { (float) hitpos.x(), (float) hitpos.y(), (float) hitpos.z() } ) ;
totE += estep ;
hit.setPosition( seg.getCellPosition() ) ;
hits[ cellID ] = hit ;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment