/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Attributes
GtBeamerTool Class Reference

A parallel beam of particles with some transverse extent. More...

#include <GtBeamerTool.h>

Inheritance diagram for GtBeamerTool:
Inheritance graph
Collaboration diagram for GtBeamerTool:
Collaboration graph

List of all members.

Public Member Functions

 GtBeamerTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~GtBeamerTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode mutate (HepMC::GenEvent &event)
 Modify the event.

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Attributes

double m_radius
 Property: Radius: Radial size of disk.
int m_particlesPerEvent
 Property: ParticlesPerEvent.
double m_momentum
 Property: Momentum.
std::string m_particleName
 Property: ParticleName.
std::string m_targetElement
 Property: TargetElement: specify the DetectorElement to aim for.
std::vector< double > m_targetOffset
 Property: TargetOffset: apply an offset from the targets origin, in the target's local coordinate frame.
std::vector< double > m_sourceDirection
 Property: SourceDirection:
double m_distance
 Property: SourceDistance.
Rndm::Numbers m_uni
CLHEP::Hep3Vector m_position
CLHEP::Hep3Vector m_direction
int m_pid
CLHEP::HepLorentzVector m_fourmom

Detailed Description

A parallel beam of particles with some transverse extent.

This will position and direct a beam of ParticlesPerEvent particles of type ParticleType and momentum Momentum. The cross sectional disk radius is specified by the Radius property.

The alignment of the beam is accomplished by specifying a target DetectorElement (TargetElement), an optional offset from the Target's coordinate system origin at which to aim (TargetOffset) and the distance (SourceDistance) and direction (SourceDirection) FROM source TO target, expressed in the target's local coordinate system.

bv@bnl.gov Fri Jun 27 15:26:11 2008

Definition at line 35 of file GtBeamerTool.h.

Constructor & Destructor Documentation

GtBeamerTool::GtBeamerTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 

Definition at line 20 of file GtBeamerTool.cc.

    : GaudiTool(type,name,parent)
    , m_radius(0)
    , m_particlesPerEvent(1)
    , m_particleName("opticalphoton")
    , m_targetOffset(3,0)
    , m_sourceDirection(3,0)
    , m_distance(CLHEP::meter)
    , m_position(3,0)
    , m_direction(3,0)
    , m_pid(0)

                    "Radius of source disk.");

                    "Number of particles per event");

                    "Name of particle.");

                    "Momentum of particles in beam.");

                    "DetecorElement to aim at.");
                    "Offset from target origin to aim for.");

                    "Direction from target to source.");

                    "Distance from target to source.");

GtBeamerTool::~GtBeamerTool ( ) [virtual]

Definition at line 62 of file GtBeamerTool.cc.


Member Function Documentation

StatusCode GtBeamerTool::initialize ( ) [virtual]

Definition at line 66 of file GtBeamerTool.cc.

    // Initialize random numbers
    IRndmGenSvc *rgs = 0;
    if (service("RndmGenSvc",rgs,true).isFailure()) {
        fatal() << "Failed to get random service" << endreq;
        return StatusCode::FAILURE;        

    StatusCode sc = m_uni.initialize(rgs, Rndm::Flat(0,1));
    if (sc.isFailure()) {
        fatal() << "Failed to initialize uniform random numbers" << endreq;
        return StatusCode::FAILURE;

    // Get mass of particle for later calculation of energy
    IParticlePropertySvc * ppSvc = 
    ParticleProperty* particle = 0;

    // First try to find via PID
    double mass = 0;
    if (m_pid) {
        particle = ppSvc->findByStdHepID(m_pid);
        if (particle) {
            mass = particle->mass();
            m_particleName = particle->particle();
    // If failed, then try via name
    if (!particle) {
        particle = ppSvc->find(m_particleName);
        if (particle) {
            mass = particle->mass();
            m_pid = particle->pdgID();
    // If still fail, complain
    if (!particle) {
        fatal() << "Failed to find particle named \"" 
                << m_particleName << "\" and with ID " 
                << m_pid << endreq;
        return StatusCode::FAILURE;

    if ("" == m_targetElement) {
        error() << "TargetElement not given" << endreq;
        return StatusCode::FAILURE;
    IDetectorElement* targetDE =

    // Convert local direction to global coordinates
    Gaudi::XYZVector local_direction(m_sourceDirection[0],
    Gaudi::XYZVector global_direction = 
    m_direction = m_direction.unit();

    // Convert target point to global coordinates
    Gaudi::XYZPoint local_target(m_targetOffset[0],
    Gaudi::XYZPoint global_target = 

    m_position.setX(global_target.x() - m_distance*global_direction.x());
    m_position.setY(global_target.y() - m_distance*global_direction.y());
    m_position.setZ(global_target.z() - m_distance*global_direction.z());

    m_fourmom = HepLorentzVector(m_momentum*m_direction,
                                 sqrt(m_momentum*m_momentum + mass*mass));

    return StatusCode::SUCCESS;
StatusCode GtBeamerTool::finalize ( ) [virtual]

Definition at line 151 of file GtBeamerTool.cc.

    return StatusCode::SUCCESS;
StatusCode GtBeamerTool::mutate ( HepMC::GenEvent event) [virtual]

Modify the event.

Implements IHepMCEventMutator.

Definition at line 156 of file GtBeamerTool.cc.

    for (int ind=0; ind<m_particlesPerEvent; ++ind) {

        Hep3Vector ortho = m_direction.orthogonal();
        double angle = m_uni()*360*CLHEP::degree;
        ortho = ortho.rotate(angle,m_direction).unit();
        double ran_radius = sqrt(m_uni()*m_radius*m_radius);
        ortho = ran_radius*ortho + m_position;

        HepLorentzVector position(ortho,0);
        HepMC::GenVertex* vertex = new HepMC::GenVertex(position);

        HepMC::GenParticle* part = 
            new HepMC::GenParticle(m_fourmom,m_pid,1/*=status*/);
        double phi = m_uni()*360*CLHEP::degree;

        if (!event.vertices_size()) 

    return StatusCode::SUCCESS;
const InterfaceID & IHepMCEventMutator::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file IHepMCEventMutator.cc.

    return IID_IHepMCEventMutator; 

Member Data Documentation

double GtBeamerTool::m_radius [private]

Property: Radius: Radial size of disk.

Definition at line 55 of file GtBeamerTool.h.

Property: ParticlesPerEvent.

Definition at line 58 of file GtBeamerTool.h.

double GtBeamerTool::m_momentum [private]

Property: Momentum.

Definition at line 61 of file GtBeamerTool.h.

std::string GtBeamerTool::m_particleName [private]

Property: ParticleName.

Definition at line 64 of file GtBeamerTool.h.

std::string GtBeamerTool::m_targetElement [private]

Property: TargetElement: specify the DetectorElement to aim for.

Definition at line 68 of file GtBeamerTool.h.

std::vector<double> GtBeamerTool::m_targetOffset [private]

Property: TargetOffset: apply an offset from the targets origin, in the target's local coordinate frame.

Definition at line 72 of file GtBeamerTool.h.

std::vector<double> GtBeamerTool::m_sourceDirection [private]

Property: SourceDirection:

Definition at line 75 of file GtBeamerTool.h.

double GtBeamerTool::m_distance [private]

Property: SourceDistance.

Definition at line 78 of file GtBeamerTool.h.

Rndm::Numbers GtBeamerTool::m_uni [private]

Definition at line 82 of file GtBeamerTool.h.

CLHEP::Hep3Vector GtBeamerTool::m_position [private]

Definition at line 83 of file GtBeamerTool.h.

CLHEP::Hep3Vector GtBeamerTool::m_direction [private]

Definition at line 83 of file GtBeamerTool.h.

int GtBeamerTool::m_pid [private]

Definition at line 84 of file GtBeamerTool.h.

Definition at line 85 of file GtBeamerTool.h.

The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:18:51 for GenTools by doxygen 1.7.4