RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
experiment Class Reference

Makes a fresh event for each run from a template event. More...

#include <experiment.hpp>

Inheritance diagram for experiment:
experimentP

Public Member Functions

 experiment ()
 Empty experiment; the template must be set with SetTemplate().
 
 experiment (event *eventT_)
 Experiment with a template.
 
void SetTemplate (event *eventT_)
 Set (or replace) the template event.
 
void MakeEvent (Int_t ninparticle_,...)
 Create a new event as a copy of the template and add particles to it.
 
void OffEvent ()
 Mark the current event as off. The event itself is kept; only an internal flag changes (nothing else reads it).
 
void DelEvent ()
 Mark the current event as off and delete it (with its particles and inspectors).
 
event * GetEvent ()
 The event created by the last MakeEvent() (owned by the experiment's user: see DelEvent()).
 

Private Attributes

event * eventT = nullptr
 template event, not owned
 
Bool_t eventOn = false
 true after MakeEvent(), false after OffEvent()/DelEvent(); informational only
 
event * currentEvent = nullptr
 last created event (heap)
 

Friends

class experimentP
 

Detailed Description

Makes a fresh event for each run from a template event.

Template pattern: configure one event once (integrator, forces, volume, time step, ...) and give it with SetTemplate(). MakeEvent() then copies that template (the event copy constructor) and adds the particles of the run to the copy. The experiment keeps only the latest event, reachable with GetEvent().

Ownership: the template is not owned (the caller keeps it alive while the experiment is used). The created event is heap-allocated by MakeEvent() and the experiment holds the pointer but never deletes it by itself: call DelEvent() when the event is no longer needed (it also deletes the particles and inspectors added to the event, see event). The particles passed to MakeEvent() are owned by the event from then on, so create them with new and do not pass one particle to two events. Calling MakeEvent() again without DelEvent() leaks the previous event.

Warning
The default constructor (also used by experimentP) leaves the template and event pointers uninitialised; use experiment(event*) or call SetTemplate() before MakeEvent(). GetEvent() returns a null pointer only after the experiment(event*) constructor (and before the first MakeEvent()). DelEvent() does not reset the pointer: GetEvent() afterwards returns a dangling pointer, and a second DelEvent() deletes it twice.

Definition at line 37 of file experiment.hpp.

Constructor & Destructor Documentation

◆ experiment() [1/2]

experiment::experiment ( )
inline

Empty experiment; the template must be set with SetTemplate().

Definition at line 40 of file experiment.hpp.

◆ experiment() [2/2]

experiment::experiment ( event *  eventT_)

Experiment with a template.

Parameters
eventT_the template event (not owned, must outlive the experiment)

Definition at line 44 of file experiment.cpp.

Member Function Documentation

◆ DelEvent()

void experiment::DelEvent ( )
inline

Mark the current event as off and delete it (with its particles and inspectors).

Warning
The stored pointer is not reset, see the class description.

Definition at line 62 of file experiment.hpp.

◆ GetEvent()

event * experiment::GetEvent ( )
inline

The event created by the last MakeEvent() (owned by the experiment's user: see DelEvent()).

Definition at line 64 of file experiment.hpp.

◆ MakeEvent()

void experiment::MakeEvent ( Int_t  ninparticle_,
  ... 
)

Create a new event as a copy of the template and add particles to it.

Variadic C call: ninparticle_ must equal the number of particle* arguments that follow. There is no type or count check, a wrong count reads garbage from the stack (undefined behaviour). Each argument must be exactly of type particle* (cast a pointer to a derived class first); passing 0 / NULL literals as an int is also wrong. The new event replaces the previous one (the previous is not deleted).

Parameters
ninparticle_number of particle pointers that follow
...the particles, added in this order; owned by the new event

Definition at line 9 of file experiment.cpp.

◆ OffEvent()

void experiment::OffEvent ( )
inline

Mark the current event as off. The event itself is kept; only an internal flag changes (nothing else reads it).

Definition at line 59 of file experiment.hpp.

◆ SetTemplate()

void experiment::SetTemplate ( event *  eventT_)
inline

Set (or replace) the template event.

Parameters
eventT_the template event (not owned)

Definition at line 46 of file experiment.hpp.

Friends And Related Symbol Documentation

◆ experimentP

friend class experimentP
friend

Definition at line 66 of file experiment.hpp.

Member Data Documentation

◆ currentEvent

event* experiment::currentEvent = nullptr
private

last created event (heap)

Definition at line 71 of file experiment.hpp.

◆ eventOn

Bool_t experiment::eventOn = false
private

true after MakeEvent(), false after OffEvent()/DelEvent(); informational only

Definition at line 70 of file experiment.hpp.

◆ eventT

event* experiment::eventT = nullptr
private

template event, not owned

Definition at line 69 of file experiment.hpp.


The documentation for this class was generated from the following files: