CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
RunManager Class Reference

#include <RunManager.h>

Public Member Functions

void abortEvent ()
 
void abortRun (bool softAbort=false)
 
const G4Event * currentEvent () const
 
const G4Run * currentRun () const
 
const Generatorgenerator () const
 
void initG4 (const edm::EventSetup &es)
 
void initializeRun ()
 
void initializeUserActions ()
 
void produce (edm::Event &inpevt, const edm::EventSetup &es)
 
std::vector< boost::shared_ptr
< SimProducer > > 
producers () const
 
 RunManager (edm::ParameterSet const &p)
 
std::vector
< SensitiveCaloDetector * > & 
sensCaloDetectors ()
 
std::vector
< SensitiveTkDetector * > & 
sensTkDetectors ()
 
G4SimEventsimEvent ()
 
void terminateRun ()
 
 ~RunManager ()
 

Protected Member Functions

G4Event * generateEvent (edm::Event &inpevt)
 
void resetGenParticleId (edm::Event &inpevt)
 

Private Attributes

bool firstRun
 
edm::ESWatcher
< IdealGeometryRecord
idealGeomRcdWatcher_
 
edm::ESWatcher
< IdealMagneticFieldRecord
idealMagRcdWatcher_
 
AttachSDm_attach
 
bool m_check
 
G4Event * m_currentEvent
 
G4Run * m_currentRun
 
ExceptionHandlerm_CustomExceptionHandler
 
int m_EvtMgrVerbosity
 
sim::FieldBuilderm_fieldBuilder
 
std::vector< std::string > m_G4Commands
 
Generatorm_generator
 
std::string m_InTag
 
G4RunManagerKernel * m_kernel
 
bool m_managerInitialized
 
bool m_nonBeam
 
edm::ParameterSet m_p
 
edm::ParameterSet m_pEventAction
 
edm::ParameterSet m_pField
 
edm::ParameterSet m_pGenerator
 
edm::ParameterSet m_pGeometry
 
std::auto_ptr< PhysicsListm_physicsList
 
std::string m_PhysicsTablesDir
 
edm::ParameterSet m_pPhysics
 
PrimaryTransformerm_primaryTransformer
 
std::vector< boost::shared_ptr
< SimProducer > > 
m_producers
 
edm::ParameterSet m_pRunAction
 
edm::ParameterSet m_pStackingAction
 
edm::ParameterSet m_pSteppingAction
 
edm::ParameterSet m_pTrackingAction
 
bool m_pUseMagneticField
 
edm::ParameterSet m_pVertexGenerator
 
SimActivityRegistry m_registry
 
bool m_RestorePhysicsTables
 
bool m_runAborted
 
bool m_runInitialized
 
bool m_runTerminated
 
std::vector
< SensitiveCaloDetector * > 
m_sensCaloDets
 
std::vector
< SensitiveTkDetector * > 
m_sensTkDets
 
G4SimEventm_simEvent
 
bool m_StorePhysicsTables
 
edm::InputTag m_theLHCTlinkTag
 
std::auto_ptr< SimTrackManagerm_trackManager
 
G4UserRunAction * m_userRunAction
 
std::vector< boost::shared_ptr
< SimWatcher > > 
m_watchers
 
std::string m_WriteFile
 

Detailed Description

Definition at line 53 of file RunManager.h.

Constructor & Destructor Documentation

RunManager::RunManager ( edm::ParameterSet const &  p)

Definition at line 119 of file RunManager.cc.

References SimActivityRegistry::connect(), createWatchers(), edm::ParameterSet::getUntrackedParameter(), m_check, m_CustomExceptionHandler, m_kernel, m_p, m_producers, m_registry, m_watchers, m_WriteFile, and AlCaHLTBitMon_QueryRunRegistry::string.

120  : m_generator(0), m_nonBeam(p.getParameter<bool>("NonBeamEvent")),
122  m_managerInitialized(false),
123  //m_geometryInitialized(true), m_physicsInitialized(true),
124  m_runInitialized(false), m_runTerminated(false), m_runAborted(false),
125  firstRun(true),
126  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
128  m_PhysicsTablesDir(p.getParameter<std::string>("PhysicsTablesDirectory")),
129  m_StorePhysicsTables(p.getParameter<bool>("StorePhysicsTables")),
130  m_RestorePhysicsTables(p.getParameter<bool>("RestorePhysicsTables")),
131  m_EvtMgrVerbosity(p.getUntrackedParameter<int>("G4EventManagerVerbosity",0)),
132  //m_Override(p.getParameter<bool>("OverrideUserStackingAction")),
133  m_pField(p.getParameter<edm::ParameterSet>("MagneticField")),
134  m_pGenerator(p.getParameter<edm::ParameterSet>("Generator")),
135  m_pPhysics(p.getParameter<edm::ParameterSet>("Physics")),
136  m_pRunAction(p.getParameter<edm::ParameterSet>("RunAction")),
137  m_pEventAction(p.getParameter<edm::ParameterSet>("EventAction")),
138  m_pStackingAction(p.getParameter<edm::ParameterSet>("StackingAction")),
139  m_pTrackingAction(p.getParameter<edm::ParameterSet>("TrackingAction")),
140  m_pSteppingAction(p.getParameter<edm::ParameterSet>("SteppingAction")),
141  m_G4Commands(p.getParameter<std::vector<std::string> >("G4Commands")),
142  m_p(p), m_fieldBuilder(0),
143  m_theLHCTlinkTag(p.getParameter<edm::InputTag>("theLHCTlinkTag"))
144 {
145  m_kernel = G4RunManagerKernel::GetRunManagerKernel();
146  if (m_kernel==0) m_kernel = new G4RunManagerKernel();
147 
149 
150  m_check = p.getUntrackedParameter<bool>("CheckOverlap",false);
151  m_WriteFile = p.getUntrackedParameter<std::string>("FileNameGDML","");
152 
153  //Look for an outside SimActivityRegistry
154  // this is used by the visualization code
155  edm::Service<SimActivityRegistry> otherRegistry;
156  if(otherRegistry){
157  m_registry.connect(*otherRegistry);
158  }
159 
161 }
bool m_check
Definition: RunManager.h:107
edm::ParameterSet m_pGenerator
Definition: RunManager.h:110
G4Event * m_currentEvent
Definition: RunManager.h:99
SimActivityRegistry m_registry
Definition: RunManager.h:126
edm::ParameterSet m_p
Definition: RunManager.h:119
Generator * m_generator
Definition: RunManager.h:84
bool m_pUseMagneticField
Definition: RunManager.h:97
ExceptionHandler * m_CustomExceptionHandler
Definition: RunManager.h:120
bool m_nonBeam
Definition: RunManager.h:87
int m_EvtMgrVerbosity
Definition: RunManager.h:105
std::string m_WriteFile
Definition: RunManager.h:138
bool firstRun
Definition: RunManager.h:96
bool m_RestorePhysicsTables
Definition: RunManager.h:104
G4Run * m_currentRun
Definition: RunManager.h:98
edm::ParameterSet m_pStackingAction
Definition: RunManager.h:115
edm::ParameterSet m_pEventAction
Definition: RunManager.h:114
bool m_runTerminated
Definition: RunManager.h:94
edm::ParameterSet m_pField
Definition: RunManager.h:109
edm::ParameterSet m_pPhysics
Definition: RunManager.h:112
edm::ParameterSet m_pSteppingAction
Definition: RunManager.h:117
bool m_runInitialized
Definition: RunManager.h:93
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< boost::shared_ptr< SimWatcher > > &oWatchers, std::vector< boost::shared_ptr< SimProducer > > &oProds)
Definition: RunManager.cc:69
PrimaryTransformer * m_primaryTransformer
Definition: RunManager.h:89
sim::FieldBuilder * m_fieldBuilder
Definition: RunManager.h:131
std::string m_PhysicsTablesDir
Definition: RunManager.h:102
bool m_StorePhysicsTables
Definition: RunManager.h:103
void connect(SimActivityRegistry &iOther)
forwards our signals to slots connected to iOther
std::vector< boost::shared_ptr< SimProducer > > m_producers
Definition: RunManager.h:128
std::vector< boost::shared_ptr< SimWatcher > > m_watchers
Definition: RunManager.h:127
edm::ParameterSet m_pRunAction
Definition: RunManager.h:113
edm::ParameterSet m_pTrackingAction
Definition: RunManager.h:116
std::vector< std::string > m_G4Commands
Definition: RunManager.h:118
G4SimEvent * m_simEvent
Definition: RunManager.h:100
bool m_managerInitialized
Definition: RunManager.h:90
edm::InputTag m_theLHCTlinkTag
Definition: RunManager.h:136
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82
bool m_runAborted
Definition: RunManager.h:95
RunManager::~RunManager ( )

Definition at line 163 of file RunManager.cc.

References m_kernel.

164 {
165  if (m_kernel!=0) delete m_kernel;
166 }
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82

Member Function Documentation

void RunManager::abortEvent ( )

Definition at line 367 of file RunManager.cc.

References m_currentEvent, m_kernel, TrackingAction::PostUserTrackingAction(), and lumiQTWidget::t.

Referenced by EventAction::abortEvent(), and abortRun().

368 {
369  G4Track* t =
370  m_kernel->GetEventManager()->GetTrackingManager()->GetTrack();
371  t->SetTrackStatus(fStopAndKill) ;
372 
373  // CMS-specific act
374  //
375  TrackingAction* uta =
376  (TrackingAction*)m_kernel->GetEventManager()->GetUserTrackingAction() ;
377  uta->PostUserTrackingAction(t) ;
378 
379  m_currentEvent->SetEventAborted();
380 
381  // do NOT call this method for now
382  // because it'll set abortRequested=true (withing G4EventManager)
383  // this will make Geant4, in the event *next* after the aborted one
384  // NOT to get the primamry, thus there's NOTHING to trace, and it goes
385  // to the end of G4Event::DoProcessing(G4Event*), where abortRequested
386  // will be reset to true again
387  //
388  //m_kernel->GetEventManager()->AbortCurrentEvent();
389  //
390  // instead, mimic what it does, except (re)setting abortRequested
391  //
392  m_kernel->GetEventManager()->GetStackManager()->clear() ;
393  m_kernel->GetEventManager()->GetTrackingManager()->EventAborted() ;
394 
395  G4StateManager* stateManager = G4StateManager::GetStateManager();
396  stateManager->SetNewState(G4State_GeomClosed);
397 
398  return;
399 }
G4Event * m_currentEvent
Definition: RunManager.h:99
virtual void PostUserTrackingAction(const G4Track *aTrack)
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82
void RunManager::abortRun ( bool  softAbort = false)

Definition at line 469 of file RunManager.cc.

References abortEvent(), m_currentRun, m_runAborted, and m_runInitialized.

Referenced by EventAction::BeginOfEventAction(), RunAction::BeginOfRunAction(), EventAction::EndOfEventAction(), RunAction::EndOfRunAction(), ExceptionHandler::Notify(), and produce().

470 {
471  m_runAborted = false;
472  if (!softAbort) { abortEvent(); }
473  if (m_currentRun!=0) { delete m_currentRun; m_currentRun = 0; }
474  m_runInitialized = false;
475  m_runAborted = true;
476  return;
477 }
void abortEvent()
Definition: RunManager.cc:367
G4Run * m_currentRun
Definition: RunManager.h:98
bool m_runInitialized
Definition: RunManager.h:93
bool m_runAborted
Definition: RunManager.h:95
const G4Event* RunManager::currentEvent ( ) const
inline

Definition at line 68 of file RunManager.h.

References m_currentEvent.

68 { return m_currentEvent; }
G4Event * m_currentEvent
Definition: RunManager.h:99
const G4Run* RunManager::currentRun ( ) const
inline

Definition at line 64 of file RunManager.h.

References m_currentRun.

64 { return m_currentRun; }
G4Run * m_currentRun
Definition: RunManager.h:98
G4Event * RunManager::generateEvent ( edm::Event inpevt)
protected

Definition at line 336 of file RunManager.cc.

References edm::EventID::event(), edm::Event::getByLabel(), Generator::HepMC2G4(), edm::EventBase::id(), m_currentEvent, m_generator, m_InTag, m_nonBeam, m_simEvent, Generator::nonBeamEvent2G4(), resetGenParticleId(), and Generator::setGenEvent().

Referenced by produce().

337 {
338  if (m_currentEvent!=0) { delete m_currentEvent; }
339  m_currentEvent = 0;
340  if (m_simEvent!=0) { delete m_simEvent; }
341  m_simEvent = 0;
342  G4Event * evt = new G4Event(inpevt.id().event());
343 
345 
346  inpevt.getByLabel( m_InTag, HepMCEvt ) ;
347 
348  m_generator->setGenEvent(HepMCEvt->GetEvent());
349 
350  // required to reset the GenParticle Id for particles transported
351  // along the beam pipe
352  // to their original value for SimTrack creation
353  resetGenParticleId( inpevt );
354 
355  if (!m_nonBeam)
356  {
357  m_generator->HepMC2G4(HepMCEvt->GetEvent(),evt);
358  }
359  else
360  {
361  m_generator->nonBeamEvent2G4(HepMCEvt->GetEvent(),evt);
362  }
363 
364  return evt;
365 }
EventNumber_t event() const
Definition: EventID.h:44
G4Event * m_currentEvent
Definition: RunManager.h:99
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:78
Generator * m_generator
Definition: RunManager.h:84
bool m_nonBeam
Definition: RunManager.h:87
void setGenEvent(const HepMC::GenEvent *inpevt)
Definition: Generator.h:26
void resetGenParticleId(edm::Event &inpevt)
Definition: RunManager.cc:479
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:421
std::string m_InTag
Definition: RunManager.h:85
edm::EventID id() const
Definition: EventBase.h:56
G4SimEvent * m_simEvent
Definition: RunManager.h:100
const Generator* RunManager::generator ( ) const
inline

Definition at line 67 of file RunManager.h.

References m_generator.

67 { return m_generator; }
Generator * m_generator
Definition: RunManager.h:84
void RunManager::initG4 ( const edm::EventSetup es)

Definition at line 168 of file RunManager.cc.

References SimActivityRegistry::beginOfJobSignal_, sim::FieldBuilder::build(), edm::ESWatcher< T >::check(), asciidump::cmd, AttachSD::create(), SurfaceDeformationFactory::create(), SimActivityRegistry::dddWorldSignal_, dir, edm::hlt::Exception, firstRun, g, edm::EventSetup::get(), reco::get(), edm::ParameterSet::getParameter(), DDDWorld::GetWorldVolume(), idealGeomRcdWatcher_, idealMagRcdWatcher_, recoMuon::in, initializeRun(), initializeUserActions(), m_attach, m_check, m_fieldBuilder, m_G4Commands, m_generator, m_InTag, m_kernel, m_managerInitialized, m_p, m_pField, m_pGenerator, m_physicsList, m_PhysicsTablesDir, m_pPhysics, m_primaryTransformer, m_pUseMagneticField, m_registry, m_RestorePhysicsTables, m_sensCaloDets, m_sensTkDets, m_StorePhysicsTables, m_trackManager, m_WriteFile, and AlCaHLTBitMon_QueryRunRegistry::string.

169 {
170  bool geomChanged = idealGeomRcdWatcher_.check(es);
171  if (geomChanged && (!firstRun)) {
172  throw cms::Exception("BadConfig")
173  << "[SimG4Core RunManager]\n"
174  << "The Geometry configuration is changed during the job execution\n"
175  << "this is not allowed, the geometry must stay unchanged\n";
176  }
177  if (m_pUseMagneticField) {
178  bool magChanged = idealMagRcdWatcher_.check(es);
179  if (magChanged && (!firstRun)) {
180  throw cms::Exception("BadConfig")
181  << "[SimG4Core RunManager]\n"
182  << "The MagneticField configuration is changed during the job execution\n"
183  << "this is not allowed, the MagneticField must stay unchanged\n";
184  }
185  }
186 
187  if (m_managerInitialized) return;
188 
189  // DDDWorld: get the DDCV from the ES and use it to build the World
191  es.get<IdealGeometryRecord>().get(pDD);
192 
194  SensitiveDetectorCatalog catalog_;
195  const DDDWorld * world = new DDDWorld(&(*pDD), map_, catalog_, m_check);
197 
198  if("" != m_WriteFile) {
199  G4GDMLParser gdml;
200  gdml.Write(m_WriteFile, world->GetWorldVolume());
201  }
202 
204  {
205  // setup the magnetic field
207  es.get<IdealMagneticFieldRecord>().get(pMF);
208  const GlobalPoint g(0.,0.,0.);
209 
210  m_fieldBuilder = new sim::FieldBuilder(&(*pMF), m_pField);
211  G4TransportationManager * tM =
212  G4TransportationManager::GetTransportationManager();
213  m_fieldBuilder->build( tM->GetFieldManager(),tM->GetPropagatorInField());
214  }
215 
216  // we need the track manager now
217  m_trackManager = std::auto_ptr<SimTrackManager>(new SimTrackManager);
218 
219  // attach sensitive detector
220  m_attach = new AttachSD;
221 
222  std::pair< std::vector<SensitiveTkDetector*>,
223  std::vector<SensitiveCaloDetector*> > sensDets =
224  m_attach->create(*world,(*pDD),catalog_,m_p,m_trackManager.get(),m_registry);
225 
226  m_sensTkDets.swap(sensDets.first);
227  m_sensCaloDets.swap(sensDets.second);
228 
229 
230 
231  edm::LogInfo("SimG4CoreApplication") << " RunManager: Sensitive Detector "
232  << "building finished; found "
233  << m_sensTkDets.size()
234  << " Tk type Producers, and "
235  << m_sensCaloDets.size()
236  << " Calo type producers ";
237 
239  es.get<PDTRecord>().get(fTable);
240  const HepPDT::ParticleDataTable *fPDGTable = &(*fTable);
241 
243  m_InTag = m_pGenerator.getParameter<std::string>("HepMCProductLabel") ;
245 
246  std::auto_ptr<PhysicsListMakerBase>
247  physicsMaker(PhysicsListFactory::get()->create(
248  m_pPhysics.getParameter<std::string> ("type")));
249  if (physicsMaker.get()==0) {
250  throw SimG4Exception("Unable to find the Physics list requested");
251  }
252  m_physicsList =
253  physicsMaker->make(map_,fPDGTable,m_fieldBuilder,m_pPhysics,m_registry);
254 
255  PhysicsList* phys = m_physicsList.get();
256  if (phys==0) { throw SimG4Exception("Physics list construction failed!"); }
257 
258  // adding GFlash, Russian Roulette for eletrons and gamma, step limiters
259  // on top of any Physics Lists
260  phys->RegisterPhysics(new ParametrisedEMPhysics("EMoptions",m_pPhysics));
261 
262  m_kernel->SetPhysics(phys);
263  m_kernel->InitializePhysics();
264 
265  m_physicsList->ResetStoredInAscii();
266  std::string tableDir = m_PhysicsTablesDir;
268  m_physicsList->SetPhysicsTableRetrieved(tableDir);
269  }
270  if (m_kernel->RunInitialization()) { m_managerInitialized = true; }
271  else { throw SimG4Exception("G4RunManagerKernel initialization failed!"); }
272 
274  {
275  std::ostringstream dir;
276  dir << tableDir << '\0';
277  std::string cmd = std::string("/control/shell mkdir -p ")+tableDir;
278  if (!std::ifstream(dir.str().c_str(), std::ios::in))
279  G4UImanager::GetUIpointer()->ApplyCommand(cmd);
280  m_physicsList->StorePhysicsTable(tableDir);
281  }
282 
283  //tell all interesting parties that we are beginning the job
284  BeginOfJob aBeginOfJob(&es);
285  m_registry.beginOfJobSignal_(&aBeginOfJob);
286 
288 
289  for (unsigned it=0; it<m_G4Commands.size(); it++) {
290  edm::LogInfo("SimG4CoreApplication") << "RunManager:: Requests UI: "
291  << m_G4Commands[it];
292  G4UImanager::GetUIpointer()->ApplyCommand(m_G4Commands[it]);
293  }
294 
295  // If the Geant4 particle table is needed, decomment the lines below
296  //
297  // G4cout << "Output of G4ParticleTable DumpTable:" << G4endl;
298  // G4ParticleTable::GetParticleTable()->DumpTable("ALL");
299 
300  initializeRun();
301  firstRun= false;
302 
303 }
T getParameter(std::string const &) const
bool m_check
Definition: RunManager.h:107
edm::ParameterSet m_pGenerator
Definition: RunManager.h:110
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:130
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const DDDWorld &w, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *m, SimActivityRegistry &reg) const
Definition: AttachSD.cc:23
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
Definition: RunManager.h:134
const G4VPhysicalVolume * GetWorldVolume() const
Definition: DDDWorld.h:17
SimActivityRegistry m_registry
Definition: RunManager.h:126
edm::ParameterSet m_p
Definition: RunManager.h:119
HepPDT::ParticleDataTable ParticleDataTable
void initializeRun()
Definition: RunManager.cc:438
void initializeUserActions()
Definition: RunManager.cc:401
Generator * m_generator
Definition: RunManager.h:84
void build(G4FieldManager *fM=0, G4PropagatorInField *fP=0)
Definition: FieldBuilder.cc:47
bool m_pUseMagneticField
Definition: RunManager.h:97
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
Definition: RunManager.h:133
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
std::vector< SensitiveCaloDetector * > m_sensCaloDets
Definition: RunManager.h:124
std::vector< SensitiveTkDetector * > m_sensTkDets
Definition: RunManager.h:123
BeginOfJobSignal beginOfJobSignal_
std::auto_ptr< PhysicsList > m_physicsList
Definition: RunManager.h:88
std::string m_WriteFile
Definition: RunManager.h:138
bool firstRun
Definition: RunManager.h:96
string cmd
Definition: asciidump.py:19
bool m_RestorePhysicsTables
Definition: RunManager.h:104
edm::ParameterSet m_pField
Definition: RunManager.h:109
edm::ParameterSet m_pPhysics
Definition: RunManager.h:112
DDDWorldSignal dddWorldSignal_
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
std::string m_InTag
Definition: RunManager.h:85
AttachSD * m_attach
Definition: RunManager.h:122
PrimaryTransformer * m_primaryTransformer
Definition: RunManager.h:89
sim::FieldBuilder * m_fieldBuilder
Definition: RunManager.h:131
std::string m_PhysicsTablesDir
Definition: RunManager.h:102
bool m_StorePhysicsTables
Definition: RunManager.h:103
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< std::string > m_G4Commands
Definition: RunManager.h:118
SurfaceDeformation * create(int type, const std::vector< double > &params)
bool m_managerInitialized
Definition: RunManager.h:90
T get(const Candidate &c)
Definition: component.h:55
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82
void RunManager::initializeRun ( )

Definition at line 438 of file RunManager.cc.

References m_currentRun, m_runAborted, m_runInitialized, and m_userRunAction.

Referenced by initG4().

439 {
440  m_runInitialized = false;
441  if (m_currentRun==0) { m_currentRun = new G4Run(); }
442  G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
443  if (m_userRunAction!=0) { m_userRunAction->BeginOfRunAction(m_currentRun); }
444  m_runAborted = false;
445  m_runInitialized = true;
446  return;
447 }
G4UserRunAction * m_userRunAction
Definition: RunManager.h:101
G4Run * m_currentRun
Definition: RunManager.h:98
bool m_runInitialized
Definition: RunManager.h:93
bool m_runAborted
Definition: RunManager.h:95
void RunManager::initializeUserActions ( )

Definition at line 401 of file RunManager.cc.

References SimActivityRegistry::beginOfEventSignal_, SimActivityRegistry::beginOfRunSignal_, SimActivityRegistry::beginOfTrackSignal_, sim_act::Signaler< T >::connect(), SimActivityRegistry::endOfEventSignal_, SimActivityRegistry::endOfRunSignal_, SimActivityRegistry::endOfTrackSignal_, SimActivityRegistry::g4StepSignal_, EventAction::m_beginOfEventSignal, RunAction::m_beginOfRunSignal, TrackingAction::m_beginOfTrackSignal, EventAction::m_endOfEventSignal, RunAction::m_endOfRunSignal, TrackingAction::m_endOfTrackSignal, m_EvtMgrVerbosity, SteppingAction::m_g4StepSignal, m_generator, m_kernel, m_pEventAction, m_pRunAction, m_pStackingAction, m_pSteppingAction, m_pTrackingAction, m_registry, m_trackManager, and m_userRunAction.

Referenced by initG4().

402 {
403  RunAction* userRunAction = new RunAction(m_pRunAction,this);
404  m_userRunAction = userRunAction;
407 
408  G4EventManager * eventManager = m_kernel->GetEventManager();
409  eventManager->SetVerboseLevel(m_EvtMgrVerbosity);
410 
411  if (m_generator!=0) {
412  EventAction * userEventAction =
413  new EventAction(m_pEventAction,this,m_trackManager.get());
416  eventManager->SetUserAction(userEventAction);
417 
418  TrackingAction* userTrackingAction =
419  new TrackingAction(userEventAction,m_pTrackingAction);
422  eventManager->SetUserAction(userTrackingAction);
423 
424  SteppingAction* userSteppingAction =
425  new SteppingAction(userEventAction,m_pSteppingAction);
426  userSteppingAction->m_g4StepSignal.connect(m_registry.g4StepSignal_);
427  eventManager->SetUserAction(userSteppingAction);
428  eventManager->SetUserAction(new StackingAction(userEventAction,m_pStackingAction));
429 
430  } else {
431  edm::LogWarning("SimG4CoreApplication") << " RunManager: WARNING : "
432  << "No generator; initialized "
433  << "only RunAction!";
434  }
435  return;
436 }
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:130
G4UserRunAction * m_userRunAction
Definition: RunManager.h:101
SimActivityRegistry m_registry
Definition: RunManager.h:126
SimActivityRegistry::G4StepSignal m_g4StepSignal
EndOfEventSignal endOfEventSignal_
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Definition: RunAction.h:23
Generator * m_generator
Definition: RunManager.h:84
BeginOfRunSignal beginOfRunSignal_
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:46
int m_EvtMgrVerbosity
Definition: RunManager.h:105
BeginOfEventSignal beginOfEventSignal_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
EndOfRunSignal endOfRunSignal_
edm::ParameterSet m_pStackingAction
Definition: RunManager.h:115
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:59
edm::ParameterSet m_pEventAction
Definition: RunManager.h:114
edm::ParameterSet m_pSteppingAction
Definition: RunManager.h:117
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Definition: RunAction.h:22
EndOfTrackSignal endOfTrackSignal_
edm::ParameterSet m_pRunAction
Definition: RunManager.h:113
edm::ParameterSet m_pTrackingAction
Definition: RunManager.h:116
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:45
BeginOfTrackSignal beginOfTrackSignal_
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
void RunManager::produce ( edm::Event inpevt,
const edm::EventSetup es 
)

Definition at line 305 of file RunManager.cc.

References abortRun(), G4SimEvent::collisionPoint(), edm::EventID::event(), Generator::eventWeight(), generateEvent(), Generator::genEvent(), Generator::genVertex(), G4SimEvent::hepEvent(), edm::EventBase::id(), m_currentEvent, m_generator, m_kernel, m_simEvent, G4SimEvent::nGenParts(), G4SimEvent::nTracks(), G4SimEvent::nVertices(), edm::second(), and G4SimEvent::weight().

306 {
307  m_currentEvent = generateEvent(inpevt);
308  m_simEvent = new G4SimEvent;
311  if (m_generator->genVertex() !=0 ) {
314  m_generator->genVertex()->y()/centimeter,
315  m_generator->genVertex()->z()/centimeter,
316  m_generator->genVertex()->t()/second));
317  }
318  if (m_currentEvent->GetNumberOfPrimaryVertex()==0) {
319  edm::LogError("SimG4CoreApplication")
320  << " RunManager::produce event " << inpevt.id().event()
321  << " with no G4PrimaryVertices \n Aborting Run" ;
322 
323  abortRun(false);
324  } else {
325  m_kernel->GetEventManager()->ProcessOneEvent(m_currentEvent);
326  }
327 
328  edm::LogInfo("SimG4CoreApplication")
329  << " RunManager: saved : Event " << inpevt.id().event()
330  << " of weight " << m_simEvent->weight()
331  << " with " << m_simEvent->nTracks() << " tracks and "
332  << m_simEvent->nVertices()
333  << " vertices, generated by " << m_simEvent->nGenParts() << " particles ";
334 }
EventNumber_t event() const
Definition: EventID.h:44
virtual const math::XYZTLorentzVector * genVertex() const
Definition: Generator.h:31
virtual const double eventWeight() const
Definition: Generator.h:32
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
G4Event * m_currentEvent
Definition: RunManager.h:99
void abortRun(bool softAbort=false)
Definition: RunManager.cc:469
virtual const HepMC::GenEvent * genEvent() const
Definition: Generator.h:30
Generator * m_generator
Definition: RunManager.h:84
U second(std::pair< T, U > const &p)
void weight(float w)
Definition: G4SimEvent.h:27
void hepEvent(const HepMC::GenEvent *r)
Definition: G4SimEvent.h:25
unsigned int nTracks() const
Definition: G4SimEvent.h:22
unsigned int nVertices() const
Definition: G4SimEvent.h:23
unsigned int nGenParts() const
Definition: G4SimEvent.h:24
G4Event * generateEvent(edm::Event &inpevt)
Definition: RunManager.cc:336
edm::EventID id() const
Definition: EventBase.h:56
void collisionPoint(const math::XYZTLorentzVectorD &v)
Definition: G4SimEvent.h:29
G4SimEvent * m_simEvent
Definition: RunManager.h:100
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82
std::vector<boost::shared_ptr<SimProducer> > RunManager::producers ( ) const
inline

Definition at line 73 of file RunManager.h.

References m_producers.

73  {
74  return m_producers;
75  }
std::vector< boost::shared_ptr< SimProducer > > m_producers
Definition: RunManager.h:128
void RunManager::resetGenParticleId ( edm::Event inpevt)
protected

Definition at line 479 of file RunManager.cc.

References edm::Event::getByLabel(), edm::HandleBase::isValid(), m_theLHCTlinkTag, m_trackManager, and edm::Handle< T >::product().

Referenced by generateEvent().

480 {
482  inpevt.getByLabel( m_theLHCTlinkTag, theLHCTlink );
483  if ( theLHCTlink.isValid() ) {
484  m_trackManager->setLHCTransportLink( theLHCTlink.product() );
485  }
486  return;
487 }
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:130
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
T const * product() const
Definition: Handle.h:81
edm::InputTag m_theLHCTlinkTag
Definition: RunManager.h:136
std::vector<SensitiveCaloDetector*>& RunManager::sensCaloDetectors ( )
inline

Definition at line 71 of file RunManager.h.

References m_sensCaloDets.

71 { return m_sensCaloDets; }
std::vector< SensitiveCaloDetector * > m_sensCaloDets
Definition: RunManager.h:124
std::vector<SensitiveTkDetector*>& RunManager::sensTkDetectors ( )
inline

Definition at line 70 of file RunManager.h.

References m_sensTkDets.

70 { return m_sensTkDets; }
std::vector< SensitiveTkDetector * > m_sensTkDets
Definition: RunManager.h:123
G4SimEvent* RunManager::simEvent ( )
inline

Definition at line 69 of file RunManager.h.

References m_simEvent.

Referenced by EventAction::EndOfEventAction().

69 { return m_simEvent; }
G4SimEvent * m_simEvent
Definition: RunManager.h:100
void RunManager::terminateRun ( )

Definition at line 449 of file RunManager.cc.

References m_currentRun, m_kernel, m_runInitialized, m_runTerminated, and m_userRunAction.

450 {
451  m_runTerminated = false;
452  if (m_userRunAction!=0) {
453  m_userRunAction->EndOfRunAction(m_currentRun);
454  delete m_userRunAction;
455  m_userRunAction = 0;
456  }
457  if (m_currentRun!=0) {
458  delete m_currentRun;
459  m_currentRun = 0;
460  }
461  if (m_kernel!=0) {
462  m_kernel->RunTermination();
463  m_runInitialized = false;
464  m_runTerminated = true;
465  }
466  return;
467 }
G4UserRunAction * m_userRunAction
Definition: RunManager.h:101
G4Run * m_currentRun
Definition: RunManager.h:98
bool m_runTerminated
Definition: RunManager.h:94
bool m_runInitialized
Definition: RunManager.h:93
G4RunManagerKernel * m_kernel
Definition: RunManager.h:82

Member Data Documentation

bool RunManager::firstRun
private

Definition at line 96 of file RunManager.h.

Referenced by initG4().

edm::ESWatcher<IdealGeometryRecord> RunManager::idealGeomRcdWatcher_
private

Definition at line 133 of file RunManager.h.

Referenced by initG4().

edm::ESWatcher<IdealMagneticFieldRecord> RunManager::idealMagRcdWatcher_
private

Definition at line 134 of file RunManager.h.

Referenced by initG4().

AttachSD* RunManager::m_attach
private

Definition at line 122 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_check
private

Definition at line 107 of file RunManager.h.

Referenced by initG4(), and RunManager().

G4Event* RunManager::m_currentEvent
private

Definition at line 99 of file RunManager.h.

Referenced by abortEvent(), currentEvent(), generateEvent(), and produce().

G4Run* RunManager::m_currentRun
private

Definition at line 98 of file RunManager.h.

Referenced by abortRun(), currentRun(), initializeRun(), and terminateRun().

ExceptionHandler* RunManager::m_CustomExceptionHandler
private

Definition at line 120 of file RunManager.h.

Referenced by RunManager().

int RunManager::m_EvtMgrVerbosity
private

Definition at line 105 of file RunManager.h.

Referenced by initializeUserActions().

sim::FieldBuilder* RunManager::m_fieldBuilder
private

Definition at line 131 of file RunManager.h.

Referenced by initG4().

std::vector<std::string> RunManager::m_G4Commands
private

Definition at line 118 of file RunManager.h.

Referenced by initG4().

Generator* RunManager::m_generator
private

Definition at line 84 of file RunManager.h.

Referenced by generateEvent(), generator(), initG4(), initializeUserActions(), and produce().

std::string RunManager::m_InTag
private

Definition at line 85 of file RunManager.h.

Referenced by generateEvent(), and initG4().

G4RunManagerKernel* RunManager::m_kernel
private
bool RunManager::m_managerInitialized
private

Definition at line 90 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_nonBeam
private

Definition at line 87 of file RunManager.h.

Referenced by generateEvent().

edm::ParameterSet RunManager::m_p
private

Definition at line 119 of file RunManager.h.

Referenced by initG4(), and RunManager().

edm::ParameterSet RunManager::m_pEventAction
private

Definition at line 114 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pField
private

Definition at line 109 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pGenerator
private

Definition at line 110 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pGeometry
private

Definition at line 108 of file RunManager.h.

std::auto_ptr<PhysicsList> RunManager::m_physicsList
private

Definition at line 88 of file RunManager.h.

Referenced by initG4().

std::string RunManager::m_PhysicsTablesDir
private

Definition at line 102 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pPhysics
private

Definition at line 112 of file RunManager.h.

Referenced by initG4().

PrimaryTransformer* RunManager::m_primaryTransformer
private

Definition at line 89 of file RunManager.h.

Referenced by initG4().

std::vector<boost::shared_ptr<SimProducer> > RunManager::m_producers
private

Definition at line 128 of file RunManager.h.

Referenced by producers(), and RunManager().

edm::ParameterSet RunManager::m_pRunAction
private

Definition at line 113 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pStackingAction
private

Definition at line 115 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pSteppingAction
private

Definition at line 117 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pTrackingAction
private

Definition at line 116 of file RunManager.h.

Referenced by initializeUserActions().

bool RunManager::m_pUseMagneticField
private

Definition at line 97 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pVertexGenerator
private

Definition at line 111 of file RunManager.h.

SimActivityRegistry RunManager::m_registry
private

Definition at line 126 of file RunManager.h.

Referenced by initG4(), initializeUserActions(), and RunManager().

bool RunManager::m_RestorePhysicsTables
private

Definition at line 104 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_runAborted
private

Definition at line 95 of file RunManager.h.

Referenced by abortRun(), and initializeRun().

bool RunManager::m_runInitialized
private

Definition at line 93 of file RunManager.h.

Referenced by abortRun(), initializeRun(), and terminateRun().

bool RunManager::m_runTerminated
private

Definition at line 94 of file RunManager.h.

Referenced by terminateRun().

std::vector<SensitiveCaloDetector*> RunManager::m_sensCaloDets
private

Definition at line 124 of file RunManager.h.

Referenced by initG4(), and sensCaloDetectors().

std::vector<SensitiveTkDetector*> RunManager::m_sensTkDets
private

Definition at line 123 of file RunManager.h.

Referenced by initG4(), and sensTkDetectors().

G4SimEvent* RunManager::m_simEvent
private

Definition at line 100 of file RunManager.h.

Referenced by generateEvent(), produce(), and simEvent().

bool RunManager::m_StorePhysicsTables
private

Definition at line 103 of file RunManager.h.

Referenced by initG4().

edm::InputTag RunManager::m_theLHCTlinkTag
private

Definition at line 136 of file RunManager.h.

Referenced by resetGenParticleId().

std::auto_ptr<SimTrackManager> RunManager::m_trackManager
private

Definition at line 130 of file RunManager.h.

Referenced by initG4(), initializeUserActions(), and resetGenParticleId().

G4UserRunAction* RunManager::m_userRunAction
private

Definition at line 101 of file RunManager.h.

Referenced by initializeRun(), initializeUserActions(), and terminateRun().

std::vector<boost::shared_ptr<SimWatcher> > RunManager::m_watchers
private

Definition at line 127 of file RunManager.h.

Referenced by RunManager().

std::string RunManager::m_WriteFile
private

Definition at line 138 of file RunManager.h.

Referenced by initG4(), and RunManager().