diff --git a/Detector/DetCRD/scripts/TDR_o1_v01/sim.py b/Detector/DetCRD/scripts/TDR_o1_v01/sim.py index ff650d725fb30ce53b5c19bdf2aad87e5142e07d..75d5e97c2399877d441b7550127b12a90491d456 100644 --- a/Detector/DetCRD/scripts/TDR_o1_v01/sim.py +++ b/Detector/DetCRD/scripts/TDR_o1_v01/sim.py @@ -83,6 +83,18 @@ detsimalg.RootDetElem = "WorldDetElemTool" from Configurables import TimeProjectionChamberSensDetTool tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") tpc_sensdettool.TypeOption = 1 +tpc_sensdettool.DoHeedSim = True +dedxoption = "TrackHeedSimTool" +tpc_sensdettool.DedxSimTool = dedxoption + +from Configurables import TrackHeedSimTool +dedx_simtool = TrackHeedSimTool("TrackHeedSimTool") +dedx_simtool.detector = "TPC" +dedx_simtool.only_primary = False#True +dedx_simtool.use_max_step = False#True +dedx_simtool.max_step = 1#mm +dedx_simtool.save_mc = True +#dedx_simtool.OutputLevel = DEBUG from Configurables import MarlinEvtSeeder evtseeder = MarlinEvtSeeder("EventSeeder") diff --git a/Detector/DetCRD/scripts/TDR_o1_v01/sim_Heed.py b/Detector/DetCRD/scripts/TDR_o1_v01/sim_Heed.py deleted file mode 100644 index aefaa8643254dd9c1c311f34adb941543abf892b..0000000000000000000000000000000000000000 --- a/Detector/DetCRD/scripts/TDR_o1_v01/sim_Heed.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -import os -from Gaudi.Configuration import * - -from Configurables import k4DataSvc -dsvc = k4DataSvc("EventDataSvc") - -from Configurables import RndmGenSvc, HepRndm__Engine_CLHEP__RanluxEngine_ -seed = [12340] -# rndmengine = HepRndm__Engine_CLHEP__RanluxEngine_() # The default engine in Gaudi -rndmengine = HepRndm__Engine_CLHEP__HepJamesRandom_("RndmGenSvc.Engine") # The default engine in Geant4 -rndmengine.SetSingleton = True -rndmengine.Seeds = seed - -rndmgensvc = RndmGenSvc("RndmGenSvc") -rndmgensvc.Engine = rndmengine.name() - -# option for standalone tracker study -geometry_option = "TDR_o1_v01/TDR_o1_v01.xml" - -if not os.getenv("DETCRDROOT"): - print("Can't find the geometry. Please setup envvar DETCRDROOT." ) - sys.exit(-1) - -geometry_path = os.path.join(os.getenv("DETCRDROOT"), "compact", geometry_option) -if not os.path.exists(geometry_path): - print("Can't find the compact geometry file: %s"%geometry_path) - sys.exit(-1) - -from Configurables import GeomSvc -geosvc = GeomSvc("GeomSvc") -geosvc.compact = geometry_path - -############################################################################## -# Physics Generator -############################################################################## -from Configurables import GenAlgo -from Configurables import GtGunTool -from Configurables import StdHepRdr -from Configurables import SLCIORdr -from Configurables import HepMCRdr -from Configurables import GenPrinter - -gun = GtGunTool("GtGunTool") -gun.PositionXs = [0] -gun.PositionYs = [0] -gun.PositionZs = [0] -gun.Particles = ["mu-"] -gun.EnergyMins = [1] -gun.EnergyMaxs = [100] -gun.ThetaMins = [8] -gun.ThetaMaxs = [172] -gun.PhiMins = [0] -gun.PhiMaxs = [360] - -genprinter = GenPrinter("GenPrinter") - -genalg = GenAlgo("GenAlgo") -genalg.GenTools = ["GtGunTool"] - -############################################################################## -# Detector Simulation -############################################################################## -from Configurables import DetSimSvc -detsimsvc = DetSimSvc("DetSimSvc") - -from Configurables import DetSimAlg -detsimalg = DetSimAlg("DetSimAlg") -detsimalg.RandomSeeds = seed -# detsimalg.VisMacs = ["vis.mac"] -detsimalg.RunCmds = [ -# "/tracking/verbose 1", -] -detsimalg.AnaElems = [ - # example_anatool.name() - # "ExampleAnaElemTool" - "Edm4hepWriterAnaElemTool" -] -detsimalg.RootDetElem = "WorldDetElemTool" - -from Configurables import TimeProjectionChamberSensDetTool -tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") -tpc_sensdettool.TypeOption = 1 -tpc_sensdettool.DoHeedSim = True -dedxoption = "TrackHeedSimTool" -tpc_sensdettool.DedxSimTool = dedxoption - -from Configurables import TrackHeedSimTool -dedx_simtool = TrackHeedSimTool("TrackHeedSimTool") -dedx_simtool.detector = "TPC" -dedx_simtool.only_primary = False#True -dedx_simtool.use_max_step = False#True -dedx_simtool.max_step = 1#mm -dedx_simtool.save_mc = True - - - -from Configurables import MarlinEvtSeeder -evtseeder = MarlinEvtSeeder("EventSeeder") - -# output -from Configurables import PodioOutput -out = PodioOutput("outputalg") -out.filename = "simHeed00.root" -out.outputCommands = ["keep *"] - -# ApplicationMgr -from Configurables import ApplicationMgr -mgr = ApplicationMgr( - TopAlg = [genalg, detsimalg, out], - EvtSel = 'NONE', - EvtMax = 10, - ExtSvc = [rndmengine, rndmgensvc, dsvc, geosvc], - HistogramPersistency = 'ROOT', - OutputLevel = ERROR -) diff --git a/Simulation/DetSimDedx/src/TrackHeedSimTool.cpp b/Simulation/DetSimDedx/src/TrackHeedSimTool.cpp index 3302887172281028c7f1795ceb14b72e2d5e82c4..ed1cbb9e2a6f65a55ad94ba1b9089a513980f16c 100644 --- a/Simulation/DetSimDedx/src/TrackHeedSimTool.cpp +++ b/Simulation/DetSimDedx/src/TrackHeedSimTool.cpp @@ -10,6 +10,7 @@ #include "DDG4/Geant4Converter.h" #include "DetSegmentation/GridDriftChamber.h" +#include "Garfield/Random.hh" #include <math.h> #include <cmath> @@ -316,6 +317,8 @@ void TrackHeedSimTool::getMom(float ee, float dx, float dy,float dz, float mom[3 StatusCode TrackHeedSimTool::initialize() { + // FIXME: fixed seed for TrackHeed now, union seed with other random generator? + randomEngine.Seed(4357); if(m_det=="DC"){ m_geosvc = service<IGeomSvc>("GeomSvc"); if ( !m_geosvc ) throw "TrackHeedSimTool :Failed to find GeomSvc ..."; @@ -617,8 +620,9 @@ float* TrackHeedSimTool::NNPred(std::vector<float>& inputs) void TrackHeedSimTool::endOfEvent() { + if (!m_SimPrimaryIonizationCol) m_SimPrimaryIonizationCol = m_SimPrimaryIonizationColWriter.createAndPut(); + debug() << "SimPrimaryIonizationCol size = " << m_SimPrimaryIonizationCol->size() << " for " << m_det << endmsg; if(m_sim_pulse && m_det=="DC"){ - if(m_debug) G4cout<<"SimPrimaryIonizationCol size="<<m_SimPrimaryIonizationCol->size()<<G4endl; clock_t t01 = clock(); std::vector<float> inputs; std::vector<unsigned long> indexs_c; @@ -710,6 +714,7 @@ void TrackHeedSimTool::endOfEvent() { if(m_debug) std::cout<<"time for Pulse Simulation=" << (double)(t02 - t01) / CLOCKS_PER_SEC <<" seconds"<< std::endl; } reset(); + m_SimPrimaryIonizationCol = nullptr; } StatusCode TrackHeedSimTool::finalize()