ATLAS Offline Software
Loading...
Searching...
No Matches
SimKernel.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ISF_Algs includes
6#include "SimKernel.h"
7// ISF_Event includes
9// ISF_Interfaces includes
16// FrameWork includes
17#include "Gaudi/Property.h"
18// ATLAS cxx utils
21// ROOT includes
22#include "TTree.h"
23// DetectorDescription
25// GeneratorObjects
28// std includes
29#include <memory>
30
31#undef ISFDEBUG
32
34// Public methods:
36
37// Constructors
39ISF::SimKernel::SimKernel( const std::string& name, ISvcLocator* pSvcLocator ) :
40 ::AthAlgorithm( name, pSvcLocator ),
45 m_inputConverter("",name),
46 m_particleBroker("ISF_ParticleBroker", name),
47 m_truthRecordSvc("ISF_TruthRecordSvc", name),
48 m_qspatcher("", name),
49 m_doMemMon(true),
50 m_memMon("MemMonitoringTool"),
51 m_memUsageEvts(1000),
54 m_numSimSvcs(ISF::fFirstAtlasSimID), // ==1 since UndefinedSimID is always there
56 m_doCPUMon(true),
57 //m_benchPDGCode(0), TODO: implement this if feasible
58 //m_benchGeoID(0), TODO: implement this if feasible
59 m_benchSimID(0),
62{
63 declareProperty("InputHardScatterCollection",
65 "Input Hard Scatter EVGEN collection.");
66 declareProperty("InputPileupCollection",
68 "Input Pileup EVGEN collection.");
69 declareProperty("OutputHardScatterTruthCollection",
71 "Output Hard Scatter Truth collection.");
72 declareProperty("OutputPileupTruthCollection",
74 "Output Pileup Truth collection.");
75 declareProperty("InputConverter",
77 "Input McEventCollection->ISFParticleContainer conversion service.");
78
79 // the general services and tools needed
80 declareProperty("ParticleBroker" , m_particleBroker );
81 declareProperty("TruthRecordService" , m_truthRecordSvc );
82 declareProperty("DoCPUMonitoring" , m_doCPUMon );
83 declareProperty("DoMemoryMonitoring" , m_doMemMon );
84 declareProperty("MemoryMonitoringTool" , m_memMon );
85 declareProperty("SummarizeMemUsageEveryNEvts", m_memUsageEvts );
86 // Quasi-stable particle sim
87 declareProperty("QuasiStablePatcher", m_qspatcher);
88 // event filter
89 declareProperty("EventFilterTools" , m_eventFilters );
90 // tuning parameters
91 declareProperty("MaximumParticleVectorSize" , m_maxParticleVectorSize );
92}
93
94// Destructor
98
99// Athena Algorithm's Hooks
102{
103
104 ATH_MSG_VERBOSE ( "--------------------------------------------------------" );
105 ATH_MSG_INFO( "Initializing the ISF KERNEL " );
106
107 // setup memory monitoring Tool
108 if ( m_doMemMon) {
109 // memory monitoring tool given -> do memory monitoring
110 ATH_CHECK( m_memMon.retrieve() );
111 ATH_MSG_INFO( "- MemoryMonitoring : " << m_memMon.typeAndName() );
112 // record current memory usage
113 m_memMon->recordCurrent("at beginning of SimKernel initialize()");
114 }
115
116
117 // setup CPU Benchmarks
118 if (m_doCPUMon) {
119 //if (!m_benchPDGCode)
120 // m_benchPDGCode = new PMonUtils::CustomBenchmark(ISF::fMaxBenchmarkPDGCode);
121 //if (!m_benchGeoID)
122 // m_benchGeoID = new PMonUtils::CustomBenchmark(AtlasDetDescr::fNumAtlasRegions );
123 if (!m_benchSimID)
125 }
126
127 // retrieve the stack service
128 ATH_CHECK ( m_particleBroker.retrieve() );
129 ATH_MSG_INFO( "- ParticleBroker : " << m_particleBroker.typeAndName() );
130
131 // the truth service
132 ATH_CHECK ( m_truthRecordSvc.retrieve() );
133 ATH_MSG_INFO( "- TruthRecordSvc : " << m_truthRecordSvc.typeAndName() );
134
135 // initialize all SimulationServices
136 //
137 for ( short geoID=AtlasDetDescr::fFirstAtlasRegion; geoID<AtlasDetDescr::fNumAtlasRegions ; ++geoID) {
139 }
140
141 ATH_CHECK( m_inputConverter.retrieve() );
142 if ( not m_truthPreselectionTool.empty() ) {
144 }
145
146 if(!m_qspatcher.empty()) {
147 ATH_CHECK(m_qspatcher.retrieve());
148 }
149
150 // initialize all the EventFilterTools
151 ATH_CHECK ( m_eventFilters.retrieve() );
152 ATH_MSG_INFO( "The following Event Filters are defined:");
154
155 // free unused space
156 m_simSvcs.resize( m_numSimSvcs);
158 // some screen output
159 ATH_MSG_INFO ( "The following SimulationSvc are registered to ISF:");
161 ATH_MSG_INFO ( "ID: " << id << "\t Name: '" << m_simSvcNames[id]
162 << "'");
163
164 // setup the simulation selectors
165 //
166 for ( short geoID=AtlasDetDescr::fFirstAtlasRegion; geoID<AtlasDetDescr::fNumAtlasRegions ; ++geoID) {
167 ATH_CHECK ( m_particleBroker->registerSimSelector( m_simSelectors[geoID], (AtlasDetDescr::AtlasRegion)geoID) );
168 }
169 // screen output
170 ATH_MSG_INFO( "The following routing chains are defined:");
171 for ( short geoID = 0; geoID<AtlasDetDescr::fNumAtlasRegions ; ++geoID) {
173 << " (GeoID=" << geoID << "): \t" << m_simSelectors[geoID]);
174 }
175
176 // record current memory usage
177 if (m_doMemMon) m_memMon->recordCurrent("at end of ISF SimKernel initialize()");
178
179 ATH_CHECK ( m_inputHardScatterEvgen.initialize() );
180 ATH_CHECK ( m_inputPileupEvgen.initialize( !m_inputPileupEvgen.key().empty() ) );
181 ATH_CHECK ( m_outputHardScatterTruth.initialize() );
182 ATH_CHECK ( m_outputPileupTruth.initialize( !m_outputPileupTruth.key().empty() ) );
183
184 // intialziation successful
185 return StatusCode::SUCCESS;
186}
187
188
190{
191 ATH_MSG_INFO ( "Finalizing ..." );
192
193 // record current memory usage
194 if (m_doMemMon) m_memMon->recordCurrent("at beginning of ISF SimKernel finalize()");
195
196 // statistics: number of particles handled
197 ATH_MSG_INFO(" Number of particles handled by the ISF SimKernel: " << m_numParticles );
198
199 ATH_MSG_INFO(" ========================= ISF Timing Stats =========================");
200 // Benchmarking: by SimID
201 if (m_benchSimID) {
202 ATH_MSG_INFO("Breakdown of simulation loop by SimulatorID:");
203 //TODO: for (unsigned simID=0;simID<m_benchSimID->size();++simID) {
204 for (unsigned simID=0;simID<ISF::fMaxNumAtlasSimIDs;++simID) {
205 uint64_t count;
206 double time_ms;
207 m_benchSimID->getData(simID, count, time_ms);
208 if (count>0)
209 ATH_MSG_INFO(" "<<std::setprecision(4)
210 <<m_simSvcNames[simID]<<" (id="<<simID<<")"
211 <<"\t\tn="<<count<<"\t\tt=" <<time_ms<<" ms\t\tt/n="<<time_ms/count<<" ms"
212 <<std::setprecision(-1) );
213 }
214
215 delete m_benchSimID;
216 m_benchSimID=0;
217 }
218
219 //TODO: implement this if feasible
220 // Benchmarking: by GeoID
221 //if (m_benchGeoID) {
222 // ATH_MSG_INFO("Breakdown of simulation loop by GeoID:");
223 // //TODO: for (unsigned geoID=0;geoID<m_benchGeoID->size();++simID) {
224 // for (unsigned geoID=AtlasDetDescr::fFirstAtlasRegion;geoID<AtlasDetDescr::fNumAtlasRegions;++geoID) {
225 // uint64_t count;
226 // double time_ms;
227 // m_benchGeoID->getData(geoID, count, time_ms);
228 // if (count>0)
229 // ATH_MSG_INFO(" "<<std::setprecision(4)
230 // <<AtlasDetDescr::AtlasRegionHelper::getName(geoID)<<" (id="<<geoID<<")"
231 // <<"\t\tn="<<count<<"\t\tt=" <<time_ms<<" ms\t\tt/n="<<time_ms/count<<" ms"
232 // <<std::setprecision(-1) );
233 // }
234
235 // delete m_benchGeoID;
236 // m_benchGeoID=0;
237 //}
238
239 //TODO: implement this if feasible
240 // Benchmarking: by PDGCode
241 //if (m_benchPDGCode) {
242 // ATH_MSG_INFO("Breakdown of simulation loop by PDG Particle Code:");
243 // //TODO: for (unsigned geoID=0;geoID<m_benchGeoID->size();++simID) {
244 // for (int pdgCode=ISF::fUndefinedPDGCode;pdgCode<ISF::fMaxBenchmarkPDGCode;++pdgCode) {
245 // uint64_t count;
246 // double time_ms;
247 // m_benchPDGCode->getData(pdgCode, count, time_ms);
248 // if (count>0)
249 // ATH_MSG_INFO( std::setprecision(4)
250 // << " |PDGCode|="<<pdgCode<<", n="
251 // <<count<<", t="<<time_ms<<" ms, t/n="<<time_ms/count<<" ms"
252 // <<std::setprecision(-1) );
253 // }
254
255 // delete m_benchPDGCode;
256 // m_benchPDGCode=0;
257 //}
258
259 // call the memory monitoring tool to print some memory stats
260 if (m_doMemMon) {
261 ATH_MSG_INFO(" ====================== ISF Memory Usage Stats =======================");
262 m_memMon->dumpSummary("end of ISF event");
263 }
264
265 ATH_MSG_INFO(" =====================================================================");
266
267 return StatusCode::SUCCESS;
268}
269
270
272{
273 // (1.) retrieve all SimulationSelector tools in the array
274 if ( simSelectorTools.retrieve().isFailure() ) {
275 ATH_MSG_FATAL( "Could not retrieve SimulatorSelector Tool Array. Abort." );
276 return StatusCode::FAILURE;
277 }
278
279 // (2.) loop over SimulationSelector tool array and retrieve simulators
280 SimSelectorToolArray::iterator fSimSelectorIter = simSelectorTools.begin();
281 SimSelectorToolArray::iterator fSimSelectorIterEnd = simSelectorTools.end();
282 for ( ; fSimSelectorIter != fSimSelectorIterEnd; ++fSimSelectorIter ) {
283
284 // take the simulator from the current SimulationSelector
285 ServiceHandle<ISimulationSvc> *curSimulator = (*fSimSelectorIter)->simulator();
286
287 if ( (*curSimulator).retrieve().isFailure() ){
288 ATH_MSG_FATAL( "Could not retrieve SimulatorSelector Tool. Abort." );
289 return StatusCode::FAILURE;
290 } else
291 ATH_MSG_INFO( "- SimulationSelector : " << fSimSelectorIter->typeAndName() );
292
293 // hand over particle broker to simulator
294 if ( (*curSimulator)->setParticleBroker( &*m_particleBroker).isFailure() ){
295 ATH_MSG_FATAL( "Unable to register ParticleService to SimulationService "
296 << *curSimulator );
297 return StatusCode::FAILURE;
298 }
299
300 // get the unique ID assigned to the Simulation Service
301 SimSvcID curID = (*curSimulator)->simSvcID();
302 // if no ID assigned yet -> new simulator
303 if ( curID == ISF::fUndefinedSimID) {
304 // assign a new new ID to the simulator
305 (*curSimulator)->assignSimSvcID( m_numSimSvcs);
306 // register current simulator to the simulatorArray
307 m_simSvcs[m_numSimSvcs] = (&**curSimulator);
308 m_simSvcNames[m_numSimSvcs] = (*curSimulator)->simSvcDescriptor();
309 ATH_MSG_DEBUG( "Assigned SimSvcID=" << m_numSimSvcs
310 << " to simulator '" << m_simSvcNames[m_numSimSvcs]
311 << "'");
312 // increment the total number of simulators registered (=used as IDs)
313 ++m_numSimSvcs;
314 }
315
316 } // loop over simulation Selectors
317
318
319 return StatusCode::SUCCESS;
320}
321
322
324{
325
326 ATH_MSG_DEBUG ("Executing ...");
327
328 // dump and record current memory stats
329 if ( m_doMemMon && (m_numISFEvents==0) ) {
330 m_memMon->dumpCurrent( "before 1st event", false );
331 m_memMon->recordCurrent("before 1st event");
332 }
333
334 auto hitCollections = std::make_shared<HitCollectionMap>();
335
336 // read and convert input
337 // a. hard-scatter
338 ISFParticleContainer simParticles{}; // particles for ISF simulation
339 std::unique_ptr<McEventCollection> shadowTruth{};
340 std::unique_ptr<McEventCollection> shadowPileUpTruth{};
342 // b. pileup
343 if (!m_inputPileupEvgen.key().empty()) {
344 ATH_CHECK( prepareInput(m_inputPileupEvgen, m_outputPileupTruth, shadowPileUpTruth, simParticles) );
345 }
346
347 // -----------------------------------------------------------------------------------------------
348 // Step 1: Initialize the particle stack and the TruthManager, ABORT if failure
349 ATH_CHECK ( m_particleBroker->initializeEvent( std::move(simParticles) ) );
350
351 const int largestGeneratedParticleBC = (m_outputHardScatterTruth->empty()) ? HepMC::UNDEFINED_ID
352 : HepMC::maxGeneratedParticleBarcode(m_outputHardScatterTruth->at(0)); // TODO make this more robust
353 const int largestGeneratedVertexBC = (m_outputHardScatterTruth->empty()) ? HepMC::UNDEFINED_ID
354 : HepMC::maxGeneratedVertexBarcode(m_outputHardScatterTruth->at(0)); // TODO make this more robust
355 // tell TruthService we're starting a new event
356 ATH_CHECK( m_truthRecordSvc->initializeTruthCollection(largestGeneratedParticleBC, largestGeneratedVertexBC) );
357 // -----------------------------------------------------------------------------------------------
358
359
360 // -----------------------------------------------------------------------------------------------
361 // Step 2: Initialize the Event
362 {
363 std::vector<ISimulationSvc*>::iterator fSimSvcIter = m_simSvcs.begin();
364 std::vector<ISimulationSvc*>::iterator fSimSvcIterEnd = m_simSvcs.end();
365 for ( ; fSimSvcIter != fSimSvcIterEnd; ++fSimSvcIter ){
366 ISimulationSvc *curSimSvc = (*fSimSvcIter);
367 // if simulation with current flavour is registered
368 // -> setupEvent
369 if ( curSimSvc){
370 auto status = [&] ATLAS_NOT_THREAD_SAFE {
371 if (auto* curSimSvcG4 =
372 dynamic_cast<ISF::BaseSimulationG4Svc*>(curSimSvc)) {
373 // if the simulator is a Geant4 one, we need to pass the event info
374 return curSimSvcG4->setupEvent(*hitCollections);
375 } else {
376 return curSimSvc->setupEvent();
377 }
378 }();
379
380 if (status.isFailure()) {
381 ATH_MSG_WARNING("Event setup failed for "
382 << curSimSvc->simSvcDescriptor());
383 } else {
384 ATH_MSG_DEBUG("Event setup done for "
385 << curSimSvc->simSvcDescriptor());
386 }
387 }
388 }
389 }
390 // -----------------------------------------------------------------------------------------------
391
392
393
394 // -----------------------------------------------------------------------------------------------
395 // Step 3: ISimulation KERNEL : loop over particle stack, until empty
396 unsigned int loopCounter{0};
397 ATH_MSG_DEBUG( "Starting simulation loop, initial particle stack size: " << m_particleBroker->numParticles());
398 while ( m_particleBroker->numParticles() ) {
399 ++loopCounter;
400 ATH_MSG_VERBOSE("Main Loop pass no. " << loopCounter);
401 ATH_MSG_VERBOSE("Queue starts with " << m_particleBroker->numParticles() << " particles.");
402 // get next vector of particles for simulation
404 const unsigned int numParticlesLeftInBroker = m_particleBroker->numParticles();
405 int numParticles = particles.size();
406
407 // particle vector empty -> end simulation
408 if (numParticles==0) break;
409
410 // for job statistics
411 m_numParticles += numParticles;
412
413 // retrieve the particle destination simulator (and geoID)
414 const ISFParticle *firstP = particles.front();
415 ISF::SimSvcID simID = firstP->nextSimID();
416 //AtlasDetDescr::AtlasRegion geoID = firstP->nextGeoID();
417
418 ATH_MSG_DEBUG ( "Took " << numParticles << " particles from queue (remaining: " << m_particleBroker->numParticles() << ")" );
419 ATH_MSG_VERBOSE( " -> All particles will be sent to '" << m_simSvcNames[simID] << "' simulator (SimSvcID=" << simID << ")" );
420
421 #ifdef ISFDEBUG
422 if (loopCounter>100 && numParticles<3) {
423 ATH_MSG_INFO("Main Loop pass no. " << loopCounter);
424 ATH_MSG_INFO("Selected " << numParticles << " particles to be processed by " << m_simSvcNames[simID]);
425 for ( const ISFParticle *particle : particles ) {
426 ATH_MSG_INFO(*particle);
427 }
428 }
429 #endif // ISFDEBUG
430
431 // ensure that all particles in the vector have the same SimID
432 for ( const ISFParticle *particle : particles ) {
433 if ( particle->nextSimID() != simID ) {
434 ATH_MSG_WARNING( "Particle with SimID " << particle->nextSimID() << " found in vector with expected ID " << simID );
435 }
436 }
437
438 // block defines scope for Benchmarks
439 // -> benchmarks will be stared/stopped automatically via the CustomBenchmarkGuard
440 // constructor and destructor, respectively
441 {
442 // setup sim svc benchmarks
443 PMonUtils::CustomBenchmarkGuard benchSimID( m_benchSimID , simID , numParticles );
444
445 // ===> simulate particle
446 // NB Passing only the hard-scatter McEventCollection is not
447 // correct if Geant4 simulation were to be used for pile-up Hits
448 // in Fast Chain.
449 ATH_MSG_VERBOSE("Selected " << particles.size() << " particles to be processed by " << m_simSvcNames[simID]);
450 if (auto* curSimSvcG4 =
451 dynamic_cast<ISF::BaseSimulationG4Svc*>(m_simSvcs[simID])) {
452 // if the simulator is a Geant4 one, we need to pass the event info
453 if (curSimSvcG4
454 ->simulateVector(particles, m_outputHardScatterTruth.ptr(),
455 hitCollections, shadowTruth.get())
456 .isFailure()) {
457 ATH_MSG_WARNING("Simulation of particles failed in Simulator: "
458 << m_simSvcNames[simID]);
459 }
460 } else if (m_simSvcs[simID]
461 ->simulateVector(particles, m_outputHardScatterTruth.ptr(),
462 shadowTruth.get())
463 .isFailure()) {
464 ATH_MSG_WARNING( "Simulation of particles failed in Simulator: " << m_simSvcNames[simID]);
465 }
466 ATH_MSG_VERBOSE(m_simSvcNames[simID] << " returned " << m_particleBroker->numParticles()-numParticlesLeftInBroker << " new particles to be added to the queue." );
467 }
468
469 }
470 ATH_MSG_VERBOSE("Final status: queue contains " << m_particleBroker->numParticles() << " particles.");
471 // -----------------------------------------------------------------------------------------------
472
473
474
475 // Step 4: Finalize the Event
476 // -> stack service
477 if ( m_particleBroker->finalizeEvent().isFailure()) {
478 ATH_MSG_WARNING( "ParticleBroker returned with an error in event finalization." );
479 }
480 // -> simulator services
481 {
482 std::vector<ISimulationSvc*>::iterator fSimSvcIter = m_simSvcs.begin();
483 std::vector<ISimulationSvc*>::iterator fSimSvcIterEnd = m_simSvcs.end();
484 for ( ; fSimSvcIter != fSimSvcIterEnd; ++fSimSvcIter ){
485 ISimulationSvc *curSimSvc = (*fSimSvcIter);
486 // if simulation with current flavour is registered
487 // -> releaseEvent()
488 if ( curSimSvc){
489 auto status = [&] ATLAS_NOT_THREAD_SAFE {
490 if (auto* curSimSvcG4 =
491 dynamic_cast<ISF::BaseSimulationG4Svc*>(curSimSvc)) {
492 // if the simulator is a Geant4 one, we need to pass the event info
493 return curSimSvcG4->releaseEvent(*hitCollections);
494 } else {
495 return curSimSvc->releaseEvent();
496 }
497 }();
498
499 if (status.isFailure()) {
500 ATH_MSG_WARNING("Event release failed for "
501 << curSimSvc->simSvcDescriptor());
502 } else {
503 ATH_MSG_DEBUG("Event release done for "
504 << curSimSvc->simSvcDescriptor());
505 }
506 }
507 } // -> loop over SimSvcs
508 }
509
510 if ( m_truthRecordSvc->releaseEvent().isFailure() ){
511 ATH_MSG_FATAL( "Event finalize failed for TruthService. Abort." );
512 return StatusCode::FAILURE;
513 }
514
515 // Step 4a: Remove QS patch if required
516 if(!m_qspatcher.empty()) {
517 for (HepMC::GenEvent* currentGenEvent : *m_outputHardScatterTruth ) {
518 ATH_CHECK(m_qspatcher->removeWorkaround(*currentGenEvent));
519 }
520 }
521
522 // Step 5: Check Any Filters
523 ToolHandleArray<IEventFilterTool>::iterator eventFilter(m_eventFilters.begin());
524 const ToolHandleArray<IEventFilterTool>::iterator endOfEventFilters(m_eventFilters.end());
525 while (eventFilter != endOfEventFilters) {
526 if (!((**eventFilter).eventPassesFilter())) {
527 setFilterPassed(false);
528 ATH_MSG_INFO("This event failed the " << (**eventFilter).name() << " Filter. Therefore it will not be recorded.");
529 break;
530 }
531 ++eventFilter;
532 }
533
534
535 // -----------------------------------------------------------------------------------------------
536
537 // dump current memory monitoring information
538 if (m_doMemMon) {
539 std::string evtStr = std::to_string( m_numISFEvents );
540 std::string descr("after event " + evtStr);
541 m_memMon->dumpCurrent( descr.c_str(), true);
542
543 // ISF internal event counting
545
546 // memory monitoring records for the final summary
547 if ( !(m_numISFEvents%m_memUsageEvts) ) m_memMon->recordCurrent( descr.c_str() );
548 else if ( m_numISFEvents==1) m_memMon->recordCurrent("after 1st event");
549 else if ( m_numISFEvents==2) m_memMon->recordCurrent("after 2nd event");
550 else if ( m_numISFEvents==10) m_memMon->recordCurrent("after 10th event");
551 else if ( m_numISFEvents==100) m_memMon->recordCurrent("after 100th event");
552 }
553
554 return StatusCode::SUCCESS;
555}
556
557
562 std::unique_ptr<McEventCollection>& shadowTruth,
563 ISFParticleContainer& simParticles) const {
564
565 if (!inputTruth.isValid()) {
566 ATH_MSG_FATAL("Unable to read input GenEvent collection '" << inputTruth.key() << "'");
567 return StatusCode::FAILURE;
568 }
569
570 if (m_useShadowEvent) {
571 outputTruth = std::make_unique<McEventCollection>();
572 // copy input Evgen collection to shadow Truth collection
573 shadowTruth = std::make_unique<McEventCollection>(*inputTruth);
574 for (HepMC::GenEvent* currentGenEvent : *shadowTruth ) {
575 // Apply QS patch if required
576 if ( not m_qspatcher.empty() ) {
577 ATH_CHECK(m_qspatcher->applyWorkaround(*currentGenEvent));
578 }
579 // Copy GenEvent and remove daughters of quasi-stable particles to be simulated
580 std::unique_ptr<HepMC::GenEvent> outputEvent = m_truthPreselectionTool->filterGenEvent(*currentGenEvent);
581 outputTruth->push_back(outputEvent.release());
582 }
583 }
584 else {
585 // copy input Evgen collection to output Truth collection
586 outputTruth = std::make_unique<McEventCollection>(*inputTruth);
587
588 // Apply QS patch if required
589 if(!m_qspatcher.empty()) {
590 for (HepMC::GenEvent* currentGenEvent : *outputTruth ) {
591 ATH_CHECK(m_qspatcher->applyWorkaround(*currentGenEvent));
592 }
593 }
594 }
595 ATH_CHECK( m_inputConverter->convert(*outputTruth, simParticles) );
596
597 return StatusCode::SUCCESS;
598}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool prepareInput(const std::string &name, const std::vector< int64_t > &shape, const std::vector< T > &data, std::vector< std::shared_ptr< tc::InferInput > > &inputs)
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
static const char * getName(int region)
Base class for an ISimulatorSvc which requires a Geant4 UserInfo object.
The generic ISF particle definition,.
Definition ISFParticle.h:42
SimSvcID nextSimID() const
the next simulation service the particle will be sent to
@ class ISimulationSvc
virtual const std::string & simSvcDescriptor()=0
Return the simulation service descriptor.
virtual StatusCode setupEvent()=0
Setup Event chain - in case of a begin-of event action is needed, to be called by simulation kernel.
virtual StatusCode releaseEvent()=0
Release Event chain - in case of an end-of event action is needed, to be called by simulation kernel.
bool m_doMemMon
The Memory Info Tool.
Definition SimKernel.h:128
StatusCode prepareInput(SG::ReadHandle< McEventCollection > &inputTruth, SG::WriteHandle< McEventCollection > &outputTruth, std::unique_ptr< McEventCollection > &shadowTruth, ISFParticleContainer &simParticles) const
Convert input generator particles to ISFParticles and copy input generator truth collection into outp...
virtual ~SimKernel()
Destructor.
Definition SimKernel.cxx:96
ServiceHandle< Simulation::IZeroLifetimePatcher > m_qspatcher
Quasi-Stable Particle Simulation Patcher.
Definition SimKernel.h:122
SG::WriteHandle< McEventCollection > m_outputPileupTruth
output pileup truth collection
Definition SimKernel.h:99
std::vector< ISimulationSvc * > m_simSvcs
Simulators to be used.
Definition SimKernel.h:133
bool m_doCPUMon
CPU Benchmarking.
Definition SimKernel.h:141
std::array< PublicToolHandleArray< ISimulationSelector >, AtlasDetDescr::fNumAtlasRegions > m_simSelectors
The Simulation Selector Chains.
Definition SimKernel.h:112
PMonUtils::CustomBenchmark * m_benchSimID
Definition SimKernel.h:144
StatusCode initialize()
Athena algorithm's interface method initialize()
long int m_numParticles
Statistics.
Definition SimKernel.h:147
BooleanProperty m_useShadowEvent
Definition SimKernel.h:104
ToolHandleArray< IEventFilterTool > m_eventFilters
The Event Filters.
Definition SimKernel.h:125
StatusCode finalize()
Athena algorithm's interface method finalize()
ServiceHandle< ITruthSvc > m_truthRecordSvc
Central truth service.
Definition SimKernel.h:109
std::vector< std::string > m_simSvcNames
SimSvc names.
Definition SimKernel.h:134
StatusCode execute()
Athena algorithm's interface method execute()
ToolHandle< IGenEventFilter > m_truthPreselectionTool
Definition SimKernel.h:102
SG::WriteHandle< McEventCollection > m_outputHardScatterTruth
output hard scatter truth collection
Definition SimKernel.h:98
SimKernel(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters.
Definition SimKernel.cxx:39
ISF::SimSvcID m_numSimSvcs
total number of SimSvcs used
Definition SimKernel.h:135
ServiceHandle< IInputConverter > m_inputConverter
input->ISFParticle converter
Definition SimKernel.h:100
SG::ReadHandle< McEventCollection > m_inputPileupEvgen
input pileup collection
Definition SimKernel.h:97
SG::ReadHandle< McEventCollection > m_inputHardScatterEvgen
Input/output truth collections and input conversion.
Definition SimKernel.h:96
unsigned int m_memUsageEvts
Definition SimKernel.h:130
unsigned int m_numISFEvents
keep track of the number of events processed
Definition SimKernel.h:138
StatusCode initSimSvcs(SimSelectorToolArray &simSelectorTools)
ToolHandle< IMonitoringTool > m_memMon
Definition SimKernel.h:129
size_t m_maxParticleVectorSize
tuning
Definition SimKernel.h:150
ServiceHandle< IParticleBroker > m_particleBroker
Central particle broker service.
Definition SimKernel.h:107
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
Definition AtlasRegion.h:21
int maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent)
Get the maximal absolute value of barcode of vertex present in the event. Returns a negative number.
constexpr int UNDEFINED_ID
int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent)
Get the maximal value of barcode of particle present in the event.
ISFParticleOrderedQueue.
@ fMaxNumAtlasSimIDs
Definition SimSvcID.h:39
@ fUndefinedSimID
Definition SimSvcID.h:32
@ fFirstAtlasSimID
Definition SimSvcID.h:36
ToolHandleArray< ISimulationSelector > SimSelectorToolArray
typedef for better readable code
uint8_t SimSvcID
Simulation service ID datatype.
Definition SimSvcID.h:28
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.