diff --git a/DDDigi/examples/TestFramework.py b/DDDigi/examples/TestFramework.py new file mode 100644 index 0000000000000000000000000000000000000000..8eda36d57621a19cdbb062a51a382451df121b11 --- /dev/null +++ b/DDDigi/examples/TestFramework.py @@ -0,0 +1,62 @@ + + +import os, sys, logging, DDDigi + +DDDigi.setPrintFormat('%-32s %5s %s') +kernel = DDDigi.Kernel() +install_dir = os.environ['DD4hepINSTALL'] +fname = "file:"+install_dir+"/examples/ClientTests/compact/MiniTel.xml" +kernel.loadGeometry(fname) +kernel.printProperties() +digi = DDDigi.Digitize(kernel) +digi.printDetectors() + + +def make_input(): + input_1 = DDDigi.TestAction(kernel,'input_01', 100) + input_2 = DDDigi.TestAction(kernel,'input_02', 200) + input_3 = DDDigi.TestAction(kernel,'input_03', 150) + input_4 = DDDigi.TestAction(kernel,'input_04', 60) + seq = kernel.inputAction() + seq.adopt(input_1) + seq.adopt(input_2) + seq.adopt(input_3) + seq.adopt(input_4) + return seq + +def make_subdetector(name): + action_1 = DDDigi.TestAction(kernel,name+'_deposits', 150) + action_2 = DDDigi.TestAction(kernel,name+'_rndmNoise', 100) + action_3 = DDDigi.TestAction(kernel,name+'_deadChan', 100) + action_4 = DDDigi.TestAction(kernel,name+'_noiseChan', 50) + action_5 = DDDigi.TestAction(kernel,name+'_merge', 200) + seq = DDDigi.ActionSequence(kernel,'DigiActionSequence/'+name+'_sequence',True) + seq.adopt(action_1) + seq.adopt(action_2) + seq.adopt(action_3) + seq.adopt(action_4) + seq.adopt(action_5) + return seq + +event_processor = DDDigi.Synchronize(kernel,'DigiSynchronize/MainDigitizer',True) +event_processor.parallel = True +detectors = DDDigi +# input +make_input() +# Subdetector digitization +dets = digi.activeDetectors() +for d in dets: + seq = make_subdetector(d['name']) + event_processor.adopt(seq) +kernel.eventAction().adopt(event_processor) +# Output +output = DDDigi.TestAction(kernel,'output_01', 200) +kernel.outputAction().adopt(output) + + +DDDigi.setPrintLevel(DDDigi.OutputLevel.DEBUG) +kernel.numThreads = 0 # = number of concurrent threads +kernel.numEvents = 10 +kernel.maxEventsParallel = 3 +kernel.run() +DDDigi.setPrintLevel(DDDigi.OutputLevel.INFO) diff --git a/DDDigi/src/DigiKernel.cpp b/DDDigi/src/DigiKernel.cpp index ed186124aa5a2470a4b15db7d440864732bf5cc5..b132a72655b68af465c69156e8ceb90cb4494868 100644 --- a/DDDigi/src/DigiKernel.cpp +++ b/DDDigi/src/DigiKernel.cpp @@ -270,6 +270,7 @@ void DigiKernel::submit(const DigiAction::Actors<DigiAction>& actions, DigiConte } #endif actions(&DigiAction::execute,context); + goto print_stamp; print_stamp: chrono::duration<double> secs = chrono::system_clock::now() - start; @@ -345,15 +346,14 @@ int DigiKernel::run() { } #endif if ( internals->eventsToDo > 0 ) { - for(int i=0; i<internals->numEvents; ++i) { - unique_ptr<DigiContext> context(new DigiContext(this)); - ++internals->eventsToDo; - executeEvent(context.release()); + for(int i=0; i<internals->numEvents && !internals->stop; ++i) { + Processor proc(*this); + proc(); } } chrono::duration<double> duration = chrono::system_clock::now() - start; double sec = chrono::duration_cast<chrono::seconds>(duration).count(); - printout(DEBUG,"DigiKernel","+++ Event processing finished. Total: %7.3f seconds %7.3f seconds/event", + printout(DEBUG,"DigiKernel","+++ Event processing finished. Total: %7.1f seconds %7.3f seconds/event", sec, sec/double(std::max(1,internals->numEvents))); return 1; } diff --git a/DDG4/src/Geant4SensitiveDetector.cpp b/DDG4/src/Geant4SensitiveDetector.cpp index f717d7ccf85d11f219922f92ce0bd922da07977e..669a06a06938cdd754a3f183505334d1230d6df0 100644 --- a/DDG4/src/Geant4SensitiveDetector.cpp +++ b/DDG4/src/Geant4SensitiveDetector.cpp @@ -30,7 +30,7 @@ #include "DD4hep/DD4hepUnits.h" #include "CLHEP/Units/SystemOfUnits.h" -static constexpr double MM_2_CM = (CLHEP::millimeter/dd4hep::millimeter); +static const double MM_2_CM = (CLHEP::millimeter/dd4hep::millimeter); #define DEBUG 0 diff --git a/DDG4/src/Geant4StepHandler.cpp b/DDG4/src/Geant4StepHandler.cpp index 79cff318c8a3beedaa2d4d4410c738d4bb6d47eb..58aaad378a6e09bb1daa9e6ba2e9712695c82199 100644 --- a/DDG4/src/Geant4StepHandler.cpp +++ b/DDG4/src/Geant4StepHandler.cpp @@ -17,8 +17,6 @@ #include "DD4hep/DD4hepUnits.h" #include "CLHEP/Units/SystemOfUnits.h" -static constexpr double MM_2_CM = (CLHEP::millimeter/dd4hep::millimeter); - namespace units = dd4hep; using namespace dd4hep; using namespace dd4hep::sim;