Skip to content
Snippets Groups Projects
Commit 43f40928 authored by John Chapman's avatar John Chapman
Browse files

Switch FastCaloSimParamAction to use SG::WriteHandle

Former-commit-id: f1ad59fa4d4d4c1eed51f8df689c1173cddec426
parent fa14f6f3
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
#include "GaudiKernel/ServiceHandle.h"
#include "LArG4Code/ILArCalculatorSvc.h"
#include "StoreGate/WriteHandle.h"
#include "TileG4Interfaces/ITileCalculator.h"
// CLHEP include for Hep3Vector
......@@ -76,6 +77,7 @@ namespace G4UA{
{
bool shift_lar_subhit=true;
bool shorten_lar_step=false;
std::string stepInfoCollName="ZHEventSteps";
// calculators
ServiceHandle<ILArCalculatorSvc> calculator_EMECIW_pos=ServiceHandle<ILArCalculatorSvc>("EMECPosInnerWheelCalculator", "FastCaloSimParamAction"); //!< handle to EMEC positive inner wheel calculator
ServiceHandle<ILArCalculatorSvc> calculator_EMECIW_neg=ServiceHandle<ILArCalculatorSvc>("EMECNegInnerWheelCalculator", "FastCaloSimParamAction"); //!< handle to EMEC negative inner wheel calculator
......@@ -118,8 +120,6 @@ namespace G4UA{
Config m_config;
typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
/// Pointer to StoreGate (event store by default)
mutable StoreGateSvc_t m_evtStore;
/// Pointer to StoreGate (detector store by default)
mutable StoreGateSvc_t m_detStore;
......@@ -141,7 +141,7 @@ namespace G4UA{
void update_map(const CLHEP::Hep3Vector & l_vec, const Identifier & l_cell, double l_energy, double l_time, bool l_valid, int l_detector);
std::map< Identifier , std::vector< ISF_FCS_Parametrization::FCS_StepInfo* >* > m_hit_map;
ISF_FCS_Parametrization::FCS_StepInfoCollection *m_eventSteps; //!< collection of StepInfo
SG::WriteHandle<ISF_FCS_Parametrization::FCS_StepInfoCollection> m_eventSteps; //!< collection of StepInfo
std::map<std::string,int> m_detectormap;
std::set<std::string> m_unuseddetector;
int m_ndetectors;
......
......@@ -7,6 +7,7 @@
#include <stdexcept>
#include <map>
#include <memory>
#include <string>
#include <stdlib.h>
#include <string.h>
......@@ -40,19 +41,19 @@
namespace G4UA{
FastCaloSimParamAction::FastCaloSimParamAction(const Config& config):
m_config(config),
m_evtStore("StoreGateSvc/StoreGateSvc","FastCaloSimParamAction"),
m_detStore("StoreGateSvc/DetectorStore","FastCaloSimParamAction"),
m_current_calculator(nullptr),
m_current_calculator_Tile(nullptr),
m_current_solid(nullptr),
m_current_transform(nullptr),
m_lar_helper(nullptr),
m_lar_emID(nullptr),
m_calo_dd_man(nullptr),
m_eventSteps(nullptr),
m_ndetectors(0){
FastCaloSimParamAction::FastCaloSimParamAction(const Config& config)
: m_config(config)
, m_detStore("StoreGateSvc/DetectorStore","FastCaloSimParamAction")
, m_current_calculator(nullptr)
, m_current_calculator_Tile(nullptr)
, m_current_solid(nullptr)
, m_current_transform(nullptr)
, m_lar_helper(nullptr)
, m_lar_emID(nullptr)
, m_calo_dd_man(nullptr)
, m_eventSteps(m_config.stepInfoCollName)
, m_ndetectors(0)
{
#ifdef _myDEBUG_
G4cout << "############################################" << G4endl
......@@ -114,22 +115,19 @@ namespace G4UA{
<< "############################################" << G4endl;
return;
}
void FastCaloSimParamAction::beginOfEvent(const G4Event*){
void FastCaloSimParamAction::beginOfEvent(const G4Event*)
{
//G4cout << "############################################" << G4endl
// << "## FastCaloSimParamAction - BeginOfEvent ##" << G4endl
// << "############################################" << G4endl;
if (m_current_transform == nullptr)
{
m_current_transform = new G4AffineTransform ();
}
m_eventSteps = new ISF_FCS_Parametrization::FCS_StepInfoCollection();
if (m_current_transform == nullptr) {
m_current_transform = new G4AffineTransform ();
}
if (!m_eventSteps.isValid()) m_eventSteps = std::make_unique<ISF_FCS_Parametrization::FCS_StepInfoCollection>();
//G4cout << "############################################" << G4endl
// << "## FastCaloSimParamAction - BeginOfEvent2 ##" << G4endl
// << "############################################" << G4endl;
......@@ -172,57 +170,6 @@ namespace G4UA{
if (m_eventSteps->size()==0) return; //don't need to play with it
G4cout << "FastCaloSimParamAction::EndOfEventAction: After initial cleanup, N=" << m_eventSteps->size() << G4endl;
//
// Put eventSteps into event store
//
std::string location("ZHEventSteps");
ISF_FCS_Parametrization::FCS_StepInfoCollection* test;
// std::cout <<"Check if already in StoreGate:"<<std::endl;
if (m_evtStore->contains<ISF_FCS_Parametrization::FCS_StepInfoCollection>(location))
{
StatusCode check = m_evtStore->retrieve(test,location);
if (check.isSuccess())
{
//std::cout <<"ZH, Already have in StoreGate : "<<test->size()<<std::endl;
//want to merge and overwrite!
for (ISF_FCS_Parametrization::FCS_StepInfoCollection::iterator iter = m_eventSteps->begin();iter != m_eventSteps->end();iter++)
{
test->push_back((*iter));
}
//std::cout <<"Now have: "<<test->size()<<std::endl;
// StatusCode sc = evtStore()->remove(
//check
check = m_evtStore->retrieve(test,location);
if (check.isSuccess())
{
std::cout <<"ZH, check in StoreGate : "<<test->size()<<std::endl;
}
/*
StatusCode sc = evtStore()->record( test, location); //want to overwrite? but current release doesn't have this method???
if( sc.isFailure() ) {
G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl;//
} else {
G4cout << "Info: Stored EventSteps object (size: " << test->size() << ")"
<< " in event store at location: " << location << G4endl;
}
*/
}
else
{
std::cout <<"ZH WTF ??"<<std::endl;
}
}
else
{
StatusCode sc = m_evtStore->record( m_eventSteps, location, true );
if( sc.isFailure() ) {
G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl;
} else {
G4cout << "Info: Stored EventSteps object (size: " << m_eventSteps->size() << ")"
<< " in event store at location: " << location << G4endl;
}
}
return;
}
......
......@@ -28,6 +28,7 @@ namespace G4UA{
{
declareProperty("shift_lar_subhit",m_config.shift_lar_subhit, "");
declareProperty("shorten_lar_step",m_config.shorten_lar_step, "");
declareProperty("stepInfoCollName",m_config.stepInfoCollName, "");
declareProperty("maxRadius",m_config.m_maxRadius, "");
declareProperty("maxRadiusLAr",m_config.m_maxRadiusLAr, "");
......@@ -53,7 +54,7 @@ namespace G4UA{
declareProperty("HECWheelCalculator", m_heccalc);
declareProperty("EMBPSCalculator",m_pscalc);
declareProperty("EMECPSCalculator", m_emepscalc);
declareProperty( "TileCalculator", m_tileCalculator);
declareProperty("TileCalculator", m_tileCalculator);
}
StatusCode FastCaloSimParamActionTool::initialize()
......
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