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 ()
 
virtual ~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
 
bool m_Override
 
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
 
std::auto_ptr< SimTrackManagerm_trackManager
 
G4UserRunAction * m_userRunAction
 
std::vector< boost::shared_ptr
< SimWatcher > > 
m_watchers
 

Detailed Description

Definition at line 52 of file RunManager.h.

Constructor & Destructor Documentation

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

Definition at line 116 of file RunManager.cc.

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

117  : m_generator(0), m_nonBeam(p.getParameter<bool>("NonBeamEvent")),
119  m_managerInitialized(false),
120  //m_geometryInitialized(true), m_physicsInitialized(true),
121  m_runInitialized(false), m_runTerminated(false), m_runAborted(false),
122  firstRun(true),
123  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
125  m_PhysicsTablesDir(p.getParameter<std::string>("PhysicsTablesDirectory")),
126  m_StorePhysicsTables(p.getParameter<bool>("StorePhysicsTables")),
127  m_RestorePhysicsTables(p.getParameter<bool>("RestorePhysicsTables")),
128  m_EvtMgrVerbosity(p.getUntrackedParameter<int>("G4EventManagerVerbosity",0)),
129  m_Override(p.getParameter<bool>("OverrideUserStackingAction")),
130  m_pField(p.getParameter<edm::ParameterSet>("MagneticField")),
131  m_pGenerator(p.getParameter<edm::ParameterSet>("Generator")),
132  m_pPhysics(p.getParameter<edm::ParameterSet>("Physics")),
133  m_pRunAction(p.getParameter<edm::ParameterSet>("RunAction")),
134  m_pEventAction(p.getParameter<edm::ParameterSet>("EventAction")),
135  m_pStackingAction(p.getParameter<edm::ParameterSet>("StackingAction")),
136  m_pTrackingAction(p.getParameter<edm::ParameterSet>("TrackingAction")),
137  m_pSteppingAction(p.getParameter<edm::ParameterSet>("SteppingAction")),
138  m_G4Commands(p.getParameter<std::vector<std::string> >("G4Commands")),
139  m_p(p), m_fieldBuilder(0)
140 
141 {
142  m_kernel = G4RunManagerKernel::GetRunManagerKernel();
143  if (m_kernel==0) m_kernel = new G4RunManagerKernel();
144 
146 
147  m_check = p.getUntrackedParameter<bool>("CheckOverlap",false);
148 
149  //Look for an outside SimActivityRegistry
150  // this is used by the visualization code
151  edm::Service<SimActivityRegistry> otherRegistry;
152  if(otherRegistry){
153  m_registry.connect(*otherRegistry);
154  }
155 
157 }
bool m_check
Definition: RunManager.h:111
edm::ParameterSet m_pGenerator
Definition: RunManager.h:114
G4Event * m_currentEvent
Definition: RunManager.h:103
SimActivityRegistry m_registry
Definition: RunManager.h:130
edm::ParameterSet m_p
Definition: RunManager.h:123
void connect(Observer< const BeginOfJob * > *iObject)
Generator * m_generator
Definition: RunManager.h:87
bool m_pUseMagneticField
Definition: RunManager.h:101
ExceptionHandler * m_CustomExceptionHandler
Definition: RunManager.h:124
bool m_nonBeam
Definition: RunManager.h:91
bool m_Override
Definition: RunManager.h:110
int m_EvtMgrVerbosity
Definition: RunManager.h:109
bool firstRun
Definition: RunManager.h:100
bool m_RestorePhysicsTables
Definition: RunManager.h:108
G4Run * m_currentRun
Definition: RunManager.h:102
edm::ParameterSet m_pStackingAction
Definition: RunManager.h:119
edm::ParameterSet m_pEventAction
Definition: RunManager.h:118
bool m_runTerminated
Definition: RunManager.h:98
edm::ParameterSet m_pField
Definition: RunManager.h:113
edm::ParameterSet m_pPhysics
Definition: RunManager.h:116
edm::ParameterSet m_pSteppingAction
Definition: RunManager.h:121
bool m_runInitialized
Definition: RunManager.h:97
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:66
PrimaryTransformer * m_primaryTransformer
Definition: RunManager.h:93
sim::FieldBuilder * m_fieldBuilder
Definition: RunManager.h:135
std::string m_PhysicsTablesDir
Definition: RunManager.h:106
bool m_StorePhysicsTables
Definition: RunManager.h:107
std::vector< boost::shared_ptr< SimProducer > > m_producers
Definition: RunManager.h:132
std::vector< boost::shared_ptr< SimWatcher > > m_watchers
Definition: RunManager.h:131
edm::ParameterSet m_pRunAction
Definition: RunManager.h:117
edm::ParameterSet m_pTrackingAction
Definition: RunManager.h:120
std::vector< std::string > m_G4Commands
Definition: RunManager.h:122
G4SimEvent * m_simEvent
Definition: RunManager.h:104
bool m_managerInitialized
Definition: RunManager.h:94
G4RunManagerKernel * m_kernel
Definition: RunManager.h:85
bool m_runAborted
Definition: RunManager.h:99
RunManager::~RunManager ( )
virtual

Definition at line 159 of file RunManager.cc.

References m_kernel.

160 {
161  if (m_kernel!=0) delete m_kernel;
162 }
G4RunManagerKernel * m_kernel
Definition: RunManager.h:85

Member Function Documentation

void RunManager::abortEvent ( )

Definition at line 361 of file RunManager.cc.

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

Referenced by abortRun(), and OscarProducer::produce().

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

Definition at line 470 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().

471 {
472 
473  m_runAborted = false;
474  if (!softAbort) abortEvent();
475  if (m_currentRun!=0) { delete m_currentRun; m_currentRun = 0; }
476  m_runInitialized = false;
477  m_runAborted = true;
478 
479  return;
480 
481 }
void abortEvent()
Definition: RunManager.cc:361
G4Run * m_currentRun
Definition: RunManager.h:102
bool m_runInitialized
Definition: RunManager.h:97
bool m_runAborted
Definition: RunManager.h:99
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:103
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:102
G4Event * RunManager::generateEvent ( edm::Event inpevt)
protected

Definition at line 317 of file RunManager.cc.

References alignCSCRings::e, 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().

318 {
319 
320  if (m_currentEvent!=0) delete m_currentEvent;
321  m_currentEvent = 0;
322  if (m_simEvent!=0) delete m_simEvent;
323  m_simEvent = 0;
324  G4Event * e = new G4Event(inpevt.id().event());
325 
326  // std::vector< edm::Handle<edm::HepMCProduct> > AllHepMCEvt;
328 
329  // inpevt.getByType(HepMCEvt);
330  // inpevt.getManyByType(AllHepMCEvt);
331  inpevt.getByLabel( m_InTag, HepMCEvt ) ;
332 
333  // actually, it's a double protection - it's not even necessary
334  // because getByLabel will throw if the correct product isn't there
335  if (!HepMCEvt.isValid())
336  {
337  throw SimG4Exception("Unable to find HepMCProduct(HepMC::GenEvent) in edm::Event ");
338  }
339  else
340  {
341  m_generator->setGenEvent(HepMCEvt->GetEvent());
342 
343  // required to reset the GenParticle Id for particles transported along the beam pipe
344  // to their original value for SimTrack creation
345  resetGenParticleId( inpevt );
346 
347  if (!m_nonBeam)
348  {
349  m_generator->HepMC2G4(HepMCEvt->GetEvent(),e);
350  }
351  else
352  {
353  m_generator->nonBeamEvent2G4(HepMCEvt->GetEvent(),e);
354  }
355  }
356 
357  return e;
358 
359 }
EventNumber_t event() const
Definition: EventID.h:44
G4Event * m_currentEvent
Definition: RunManager.h:103
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:58
Generator * m_generator
Definition: RunManager.h:87
bool m_nonBeam
Definition: RunManager.h:91
void setGenEvent(const HepMC::GenEvent *inpevt)
Definition: Generator.h:27
void resetGenParticleId(edm::Event &inpevt)
Definition: RunManager.cc:483
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:368
std::string m_InTag
Definition: RunManager.h:89
edm::EventID id() const
Definition: EventBase.h:56
G4SimEvent * m_simEvent
Definition: RunManager.h:104
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:87
void RunManager::initG4 ( const edm::EventSetup es)

Definition at line 167 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(), 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, and m_trackManager.

Referenced by OscarProducer::beginRun().

168 {
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 
199  {
200  // setup the magnetic field
202  es.get<IdealMagneticFieldRecord>().get(pMF);
203  const GlobalPoint g(0.,0.,0.);
204 
205  // m_fieldBuilder = std::auto_ptr<sim::FieldBuilder>(new sim::FieldBuilder(&(*pMF), map_, m_pField));
206  m_fieldBuilder = (new sim::FieldBuilder(&(*pMF), m_pField));
207  G4TransportationManager * tM = G4TransportationManager::GetTransportationManager();
208  m_fieldBuilder->build( tM->GetFieldManager(),tM->GetPropagatorInField() ) ;
209  // m_fieldBuilder->configure("MagneticFieldType",tM->GetFieldManager(),tM->GetPropagatorInField());
210  }
211 
212  // we need the track manager now
213  m_trackManager = std::auto_ptr<SimTrackManager>(new SimTrackManager);
214 
215  m_attach = new AttachSD;
216  {
217  std::pair< std::vector<SensitiveTkDetector*>,
218  std::vector<SensitiveCaloDetector*> > sensDets = m_attach->create(*world,(*pDD),catalog_,m_p,m_trackManager.get(),m_registry);
219 
220  m_sensTkDets.swap(sensDets.first);
221  m_sensCaloDets.swap(sensDets.second);
222  }
223 
224 
225  edm::LogInfo("SimG4CoreApplication") << " RunManager: Sensitive Detector building finished; found " << m_sensTkDets.size()
226  << " Tk type Producers, and " << m_sensCaloDets.size() << " Calo type producers ";
227 
229  es.get<PDTRecord>().get(fTable);
230  const HepPDT::ParticleDataTable *fPDGTable = &(*fTable);
231 
233  // m_InTag = m_pGenerator.getParameter<edm::InputTag>("HepMCProductLabel") ;
234  m_InTag = m_pGenerator.getParameter<std::string>("HepMCProductLabel") ;
236 
237  std::auto_ptr<PhysicsListMakerBase> physicsMaker(
239  (m_pPhysics.getParameter<std::string> ("type")));
240  if (physicsMaker.get()==0) throw SimG4Exception("Unable to find the Physics list requested");
241  m_physicsList = physicsMaker->make(map_,fPDGTable,m_fieldBuilder,m_pPhysics,m_registry);
242  if (m_physicsList.get()==0) throw SimG4Exception("Physics list construction failed!");
243  m_kernel->SetPhysics(m_physicsList.get());
244  m_kernel->InitializePhysics();
245 
246  m_physicsList->ResetStoredInAscii();
247  std::string tableDir = m_PhysicsTablesDir;
248  if (m_RestorePhysicsTables) m_physicsList->SetPhysicsTableRetrieved(tableDir);
249 
250  if (m_kernel->RunInitialization()) m_managerInitialized = true;
251  else throw SimG4Exception("G4RunManagerKernel initialization failed!");
252 
254  {
255  std::ostringstream dir;
256  dir << tableDir << '\0';
257  std::string cmd = std::string("/control/shell mkdir -p ")+tableDir;
258  if (!std::ifstream(dir.str().c_str(), std::ios::in))
259  G4UImanager::GetUIpointer()->ApplyCommand(cmd);
260  m_physicsList->StorePhysicsTable(tableDir);
261  }
262 
263  //tell all interesting parties that we are beginning the job
264  BeginOfJob aBeginOfJob(&es);
265  m_registry.beginOfJobSignal_(&aBeginOfJob);
266 
268 
269  for (unsigned it=0; it<m_G4Commands.size(); it++) {
270  edm::LogInfo("SimG4CoreApplication") << "RunManager:: Requests UI: "
271  << m_G4Commands[it];
272  G4UImanager::GetUIpointer()->ApplyCommand(m_G4Commands[it]);
273  }
274 
275  // If the Geant4 particle table is needed, decomment the lines below
276  //
277  // G4cout << "Output of G4ParticleTable DumpTable:" << G4endl;
278  // G4ParticleTable::GetParticleTable()->DumpTable("ALL");
279 
280  initializeRun();
281  firstRun= false;
282 
283 }
T getParameter(std::string const &) const
bool m_check
Definition: RunManager.h:111
edm::ParameterSet m_pGenerator
Definition: RunManager.h:114
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:134
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:138
SimActivityRegistry m_registry
Definition: RunManager.h:130
edm::ParameterSet m_p
Definition: RunManager.h:123
HepPDT::ParticleDataTable ParticleDataTable
void initializeRun()
Definition: RunManager.cc:437
void initializeUserActions()
Definition: RunManager.cc:397
Generator * m_generator
Definition: RunManager.h:87
void build(G4FieldManager *fM=0, G4PropagatorInField *fP=0)
Definition: FieldBuilder.cc:49
bool m_pUseMagneticField
Definition: RunManager.h:101
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
Definition: RunManager.h:137
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:128
std::vector< SensitiveTkDetector * > m_sensTkDets
Definition: RunManager.h:127
BeginOfJobSignal beginOfJobSignal_
std::auto_ptr< PhysicsList > m_physicsList
Definition: RunManager.h:92
bool firstRun
Definition: RunManager.h:100
string cmd
Definition: asciidump.py:19
bool m_RestorePhysicsTables
Definition: RunManager.h:108
edm::ParameterSet m_pField
Definition: RunManager.h:113
edm::ParameterSet m_pPhysics
Definition: RunManager.h:116
DDDWorldSignal dddWorldSignal_
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
std::string m_InTag
Definition: RunManager.h:89
AttachSD * m_attach
Definition: RunManager.h:126
PrimaryTransformer * m_primaryTransformer
Definition: RunManager.h:93
sim::FieldBuilder * m_fieldBuilder
Definition: RunManager.h:135
std::string m_PhysicsTablesDir
Definition: RunManager.h:106
bool m_StorePhysicsTables
Definition: RunManager.h:107
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< std::string > m_G4Commands
Definition: RunManager.h:122
SurfaceDeformation * create(int type, const std::vector< double > &params)
bool m_managerInitialized
Definition: RunManager.h:94
T get(const Candidate &c)
Definition: component.h:56
G4RunManagerKernel * m_kernel
Definition: RunManager.h:85
void RunManager::initializeRun ( )

Definition at line 437 of file RunManager.cc.

References m_currentRun, m_runAborted, m_runInitialized, m_userRunAction, and hitfit::return.

Referenced by initG4().

438 {
439 
440  m_runInitialized = false;
441  if (m_currentRun==0) m_currentRun = new G4Run();
442  // m_currentRun->SetRunID(m_RunNumber); // run on default runID=0; doesn't matter...
443  G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
444  if (m_userRunAction!=0) m_userRunAction->BeginOfRunAction(m_currentRun);
445  m_runAborted = false;
446  m_runInitialized = true;
447 
448  return ;
449 
450 }
G4UserRunAction * m_userRunAction
Definition: RunManager.h:105
G4Run * m_currentRun
Definition: RunManager.h:102
bool m_runInitialized
Definition: RunManager.h:97
bool m_runAborted
Definition: RunManager.h:99
void RunManager::initializeUserActions ( )

Definition at line 397 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_Override, m_pEventAction, m_pRunAction, m_pStackingAction, m_pSteppingAction, m_pTrackingAction, m_registry, m_trackManager, and m_userRunAction.

Referenced by initG4().

398 {
399 
400  RunAction* userRunAction = new RunAction(m_pRunAction,this);
401  m_userRunAction = userRunAction;
404 
405  G4EventManager * eventManager = m_kernel->GetEventManager();
406  eventManager->SetVerboseLevel(m_EvtMgrVerbosity);
407  if (m_generator!=0)
408  {
409  EventAction * userEventAction = new EventAction(m_pEventAction,this,m_trackManager.get());
410  //userEventAction->SetRunManager(this) ;
413  eventManager->SetUserAction(userEventAction);
414  TrackingAction* userTrackingAction = new TrackingAction(userEventAction,m_pTrackingAction);
417  eventManager->SetUserAction(userTrackingAction);
418 
419  SteppingAction* userSteppingAction = new SteppingAction(userEventAction,m_pSteppingAction);
420  userSteppingAction->m_g4StepSignal.connect(m_registry.g4StepSignal_);
421  eventManager->SetUserAction(userSteppingAction);
422  if (m_Override)
423  {
424  edm::LogInfo("SimG4CoreApplication") << " RunManager: user StackingAction overridden " ;
425  eventManager->SetUserAction(new StackingAction(m_pStackingAction));
426  }
427  }
428  else
429  {
430  edm::LogWarning("SimG4CoreApplication") << " RunManager: WARNING : No generator; initialized only RunAction!";
431  }
432 
433  return;
434 
435 }
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:134
G4UserRunAction * m_userRunAction
Definition: RunManager.h:105
SimActivityRegistry m_registry
Definition: RunManager.h:130
SimActivityRegistry::G4StepSignal m_g4StepSignal
EndOfEventSignal endOfEventSignal_
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Definition: RunAction.h:23
Generator * m_generator
Definition: RunManager.h:87
BeginOfRunSignal beginOfRunSignal_
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:44
bool m_Override
Definition: RunManager.h:110
int m_EvtMgrVerbosity
Definition: RunManager.h:109
BeginOfEventSignal beginOfEventSignal_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
EndOfRunSignal endOfRunSignal_
edm::ParameterSet m_pStackingAction
Definition: RunManager.h:119
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:60
edm::ParameterSet m_pEventAction
Definition: RunManager.h:118
edm::ParameterSet m_pSteppingAction
Definition: RunManager.h:121
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Definition: RunAction.h:22
EndOfTrackSignal endOfTrackSignal_
edm::ParameterSet m_pRunAction
Definition: RunManager.h:117
edm::ParameterSet m_pTrackingAction
Definition: RunManager.h:120
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:43
BeginOfTrackSignal beginOfTrackSignal_
G4RunManagerKernel * m_kernel
Definition: RunManager.h:85
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
void RunManager::produce ( edm::Event inpevt,
const edm::EventSetup es 
)

Definition at line 285 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().

Referenced by OscarProducer::produce().

286 {
287  m_currentEvent = generateEvent(inpevt);
288  m_simEvent = new G4SimEvent;
291  if (m_generator->genVertex()!=0)
293  m_generator->genVertex()->y()/centimeter,
294  m_generator->genVertex()->z()/centimeter,
295  m_generator->genVertex()->t()/second));
296 
297  if (m_currentEvent->GetNumberOfPrimaryVertex()==0)
298  {
299 
300  edm::LogError("SimG4CoreApplication")
301  << " RunManager::produce event " << inpevt.id().event()
302  << " with no G4PrimaryVertices \n Aborting Run" ;
303 
304  abortRun(false);
305  }
306  else
307  m_kernel->GetEventManager()->ProcessOneEvent(m_currentEvent);
308 
309 
310  edm::LogInfo("SimG4CoreApplication")
311  << " RunManager: saved : Event " << inpevt.id().event() << " of weight " << m_simEvent->weight()
312  << " with " << m_simEvent->nTracks() << " tracks and " << m_simEvent->nVertices()
313  << " vertices, generated by " << m_simEvent->nGenParts() << " particles " ;
314 
315 }
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:15
G4Event * m_currentEvent
Definition: RunManager.h:103
void abortRun(bool softAbort=false)
Definition: RunManager.cc:470
virtual const HepMC::GenEvent * genEvent() const
Definition: Generator.h:30
Generator * m_generator
Definition: RunManager.h:87
U second(std::pair< T, U > const &p)
void weight(float w)
Definition: G4SimEvent.h:27
void collisionPoint(math::XYZTLorentzVectorD v)
Definition: G4SimEvent.h:29
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:317
edm::EventID id() const
Definition: EventBase.h:56
G4SimEvent * m_simEvent
Definition: RunManager.h:104
G4RunManagerKernel * m_kernel
Definition: RunManager.h:85
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:132
void RunManager::resetGenParticleId ( edm::Event inpevt)
protected

Definition at line 483 of file RunManager.cc.

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

Referenced by generateEvent().

483  {
484 
486  inpevt.getByType( theLHCTlink );
487  if ( theLHCTlink.isValid() ) {
488  m_trackManager->setLHCTransportLink( theLHCTlink.product() );
489  }
490 
491 }
std::auto_ptr< SimTrackManager > m_trackManager
Definition: RunManager.h:134
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
bool isValid() const
Definition: HandleBase.h:76
T const * product() const
Definition: Handle.h:74
std::vector<SensitiveCaloDetector*>& RunManager::sensCaloDetectors ( )
inline

Definition at line 71 of file RunManager.h.

References m_sensCaloDets.

Referenced by OscarProducer::produce().

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

Definition at line 70 of file RunManager.h.

References m_sensTkDets.

Referenced by OscarProducer::produce().

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

Definition at line 69 of file RunManager.h.

References m_simEvent.

Referenced by EventAction::EndOfEventAction(), and OscarProducer::produce().

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

Definition at line 452 of file RunManager.cc.

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

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

Member Data Documentation

bool RunManager::firstRun
private

Definition at line 100 of file RunManager.h.

Referenced by initG4().

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

Definition at line 137 of file RunManager.h.

Referenced by initG4().

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

Definition at line 138 of file RunManager.h.

Referenced by initG4().

AttachSD* RunManager::m_attach
private

Definition at line 126 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_check
private

Definition at line 111 of file RunManager.h.

Referenced by initG4(), and RunManager().

G4Event* RunManager::m_currentEvent
private

Definition at line 103 of file RunManager.h.

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

G4Run* RunManager::m_currentRun
private

Definition at line 102 of file RunManager.h.

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

ExceptionHandler* RunManager::m_CustomExceptionHandler
private

Definition at line 124 of file RunManager.h.

Referenced by RunManager().

int RunManager::m_EvtMgrVerbosity
private

Definition at line 109 of file RunManager.h.

Referenced by initializeUserActions().

sim::FieldBuilder* RunManager::m_fieldBuilder
private

Definition at line 135 of file RunManager.h.

Referenced by initG4().

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

Definition at line 122 of file RunManager.h.

Referenced by initG4().

Generator* RunManager::m_generator
private

Definition at line 87 of file RunManager.h.

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

std::string RunManager::m_InTag
private

Definition at line 89 of file RunManager.h.

Referenced by generateEvent(), and initG4().

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

Definition at line 94 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_nonBeam
private

Definition at line 91 of file RunManager.h.

Referenced by generateEvent().

bool RunManager::m_Override
private

Definition at line 110 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_p
private

Definition at line 123 of file RunManager.h.

Referenced by initG4(), and RunManager().

edm::ParameterSet RunManager::m_pEventAction
private

Definition at line 118 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pField
private

Definition at line 113 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pGenerator
private

Definition at line 114 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pGeometry
private

Definition at line 112 of file RunManager.h.

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

Definition at line 92 of file RunManager.h.

Referenced by initG4().

std::string RunManager::m_PhysicsTablesDir
private

Definition at line 106 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pPhysics
private

Definition at line 116 of file RunManager.h.

Referenced by initG4().

PrimaryTransformer* RunManager::m_primaryTransformer
private

Definition at line 93 of file RunManager.h.

Referenced by initG4().

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

Definition at line 132 of file RunManager.h.

Referenced by producers(), and RunManager().

edm::ParameterSet RunManager::m_pRunAction
private

Definition at line 117 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pStackingAction
private

Definition at line 119 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pSteppingAction
private

Definition at line 121 of file RunManager.h.

Referenced by initializeUserActions().

edm::ParameterSet RunManager::m_pTrackingAction
private

Definition at line 120 of file RunManager.h.

Referenced by initializeUserActions().

bool RunManager::m_pUseMagneticField
private

Definition at line 101 of file RunManager.h.

Referenced by initG4().

edm::ParameterSet RunManager::m_pVertexGenerator
private

Definition at line 115 of file RunManager.h.

SimActivityRegistry RunManager::m_registry
private

Definition at line 130 of file RunManager.h.

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

bool RunManager::m_RestorePhysicsTables
private

Definition at line 108 of file RunManager.h.

Referenced by initG4().

bool RunManager::m_runAborted
private

Definition at line 99 of file RunManager.h.

Referenced by abortRun(), and initializeRun().

bool RunManager::m_runInitialized
private

Definition at line 97 of file RunManager.h.

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

bool RunManager::m_runTerminated
private

Definition at line 98 of file RunManager.h.

Referenced by terminateRun().

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

Definition at line 128 of file RunManager.h.

Referenced by initG4(), and sensCaloDetectors().

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

Definition at line 127 of file RunManager.h.

Referenced by initG4(), and sensTkDetectors().

G4SimEvent* RunManager::m_simEvent
private

Definition at line 104 of file RunManager.h.

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

bool RunManager::m_StorePhysicsTables
private

Definition at line 107 of file RunManager.h.

Referenced by initG4().

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

Definition at line 134 of file RunManager.h.

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

G4UserRunAction* RunManager::m_userRunAction
private

Definition at line 105 of file RunManager.h.

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

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

Definition at line 131 of file RunManager.h.

Referenced by RunManager().