| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GtBeamerTool Class Reference

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

#include <GtBeamerTool.h>

Inheritance diagram for GtBeamerTool:

[legend]
Collaboration diagram for GtBeamerTool:
[legend]
List of all members.

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

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.
INTupleSvcntupleSvc () const
INTupleSvcevtColSvc () const
IDataProviderSvcdetSvc () const
IDataProviderSvcevtSvc () const
IIncidentSvcincSvc () const
IChronoStatSvcchronoSvc () const
IHistogramSvchistoSvc () const
IAlgContextSvccontextSvc () const
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (const std::string &location, const bool useRootInTES=true) const
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
TYPE * getDet (const std::string &location) const
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
bool exist (const std::string &location, const bool useRootInTES=true) const
bool existDet (IDataProviderSvc *svc, const std::string &location) const
bool existDet (const std::string &location) const
TYPE * getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
TYPE * getOrCreate (const std::string &location, const bool useRootInTES=true) const
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
SERVICE * svc (const std::string &name, const bool create=true) const
IUpdateManagerSvcupdMgrSvc () const
IDataProviderSvcfastContainersSvc () const
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
StatusCode Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
MsgStreammsgStream (const MSG::Level level) const
MsgStreamalways () const
MsgStreamfatal () const
MsgStreamerr () const
MsgStreamerror () const
MsgStreamwarning () const
MsgStreaminfo () const
MsgStreamdebug () const
MsgStreamverbose () const
MsgStreammsg () const
const Statisticscounters () const
StatEntitycounter (const std::string &tag) const
MSG::Level msgLevel () const
bool msgLevel (const MSG::Level level) const
void resetMsgStream () const
bool typePrint () const
bool propsPrint () const
bool statPrint () const
bool errorsPrint () const
long printStat (const MSG::Level level=MSG::ALWAYS) const
long printErrors (const MSG::Level level=MSG::ALWAYS) const
long printProps (const MSG::Level level=MSG::ALWAYS) const
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
StatusCode runUpdate ()
TransientFastContainer< T > * getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0)
StatusCode release (const IInterface *interface) const
virtual unsigned long release ()
const std::string & context () const
const std::string & rootInTES () const
double globalTimeOffset () const
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual unsigned long addRef ()
virtual const std::string & name () const
virtual const std::string & type () const
virtual const IInterfaceparent () const
virtual StatusCode configure ()
virtual StatusCode start ()
virtual StatusCode stop ()
virtual StatusCode terminate ()
virtual StatusCode reinitialize ()
virtual StatusCode restart ()
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysStart ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
PropertyMgrgetPropertyMgr ()
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
IMessageSvcmsgSvc () const
IToolSvctoolSvc () const
StatusCode setProperties ()
StatusCode service (const std::string &name, T *&svc, bool createIf=true) const
StatusCode service (const std::string &type, const std::string &name, T *&svc) const
void declInterface (const InterfaceID &, void *)
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const
IMonitorSvcmonitorSvc () const
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
virtual const std::string & type () const =0
virtual const IInterfaceparent () const =0
virtual StatusCode configure ()=0
virtual StatusCode start ()=0
virtual StatusCode stop ()=0
virtual StatusCode terminate ()=0
virtual StatusCode reinitialize ()=0
virtual StatusCode restart ()=0
virtual Gaudi::StateMachine::State FSMState () const =0
virtual StatusCode sysInitialize ()=0
virtual StatusCode sysStart ()=0
virtual StatusCode sysStop ()=0
virtual StatusCode sysFinalize ()=0
virtual StatusCode sysReinitialize ()=0
virtual StatusCode sysRestart ()=0
virtual unsigned long refCount () const =0
virtual const std::string & name () const =0
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)=0
virtual unsigned long addRef ()=0
virtual unsigned long release ()=0

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
 Retrieve interface ID.

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Types

typedef std::map< std::string,
StatEntity
Statistics
typedef std::map< std::string,
unsigned int > 
Counter
typedef std::vector< IAlgTool * > AlgTools
typedef std::pair< IInterface *,
std::string > 
ServiceEntry
typedef std::vector< ServiceEntryServices

Protected Member Functions

StatusCode releaseTool (const IAlgTool *tool) const
StatusCode releaseSvc (const IInterface *svc) const
int outputLevel () const
virtual unsigned long refCount () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Static Protected Attributes

static const bool IgnoreRootInTES
static const bool UseRootInTES

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.

00023     : GaudiTool(type,name,parent)
00024     , m_radius(0)
00025     , m_particlesPerEvent(1)
00026     , m_particleName("opticalphoton")
00027     , m_targetOffset(3,0)
00028     , m_sourceDirection(3,0)
00029     , m_distance(CLHEP::meter)
00030     , m_position(3,0)
00031     , m_direction(3,0)
00032     , m_pid(0)
00033 {
00034     declareInterface<IHepMCEventMutator>(this);
00035 
00036     declareProperty("Radius",m_radius=CLHEP::meter,
00037                     "Radius of source disk.");
00038 
00039     declareProperty("ParticlesPerEvent",m_particlesPerEvent=1,
00040                     "Number of particles per event");
00041 
00042     declareProperty("ParticleName",m_particleName="opticalphoton",
00043                     "Name of particle.");
00044 
00045     declareProperty("Momentum",m_momentum=2.5*CLHEP::eV,
00046                     "Momentum of particles in beam.");
00047 
00048     declareProperty("TargetElement",m_targetElement="",
00049                     "DetecorElement to aim at.");
00050     
00051     declareProperty("TargetOffset",m_targetOffset,
00052                     "Offset from target origin to aim for.");
00053 
00054     declareProperty("SourceDirection",m_sourceDirection,
00055                     "Direction from target to source.");
00056 
00057     declareProperty("SourceDistance",m_distance,
00058                     "Distance from target to source.");
00059 
00060 }

GtBeamerTool::~GtBeamerTool (  )  [virtual]

Definition at line 62 of file GtBeamerTool.cc.

00063 {
00064 }


Member Function Documentation

StatusCode GtBeamerTool::initialize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 66 of file GtBeamerTool.cc.

00067 {
00068     // Initialize random numbers
00069     IRndmGenSvc *rgs = 0;
00070     if (service("RndmGenSvc",rgs,true).isFailure()) {
00071         fatal() << "Failed to get random service" << endreq;
00072         return StatusCode::FAILURE;        
00073     }
00074 
00075     StatusCode sc = m_uni.initialize(rgs, Rndm::Flat(0,1));
00076     if (sc.isFailure()) {
00077         fatal() << "Failed to initialize uniform random numbers" << endreq;
00078         return StatusCode::FAILURE;
00079     }
00080 
00081     // Get mass of particle for later calculation of energy
00082     IParticlePropertySvc * ppSvc = 
00083         svc<IParticlePropertySvc>("ParticlePropertySvc",true);
00084     ParticleProperty* particle = 0;
00085 
00086     // First try to find via PID
00087     double mass = 0;
00088     if (m_pid) {
00089         particle = ppSvc->findByStdHepID(m_pid);
00090         if (particle) {
00091             mass = particle->mass();
00092             m_particleName = particle->particle();
00093         }
00094     }
00095     // If failed, then try via name
00096     if (!particle) {
00097         particle = ppSvc->find(m_particleName);
00098         if (particle) {
00099             mass = particle->mass();
00100             m_pid = particle->pdgID();
00101         }
00102     }
00103     // If still fail, complain
00104     if (!particle) {
00105         fatal() << "Failed to find particle named \"" 
00106                 << m_particleName << "\" and with ID " 
00107                 << m_pid << endreq;
00108         return StatusCode::FAILURE;
00109     }
00110 
00111 
00112     if ("" == m_targetElement) {
00113         error() << "TargetElement not given" << endreq;
00114         return StatusCode::FAILURE;
00115     }
00116     IDetectorElement* targetDE =
00117         getDet<IDetectorElement>(m_targetElement);
00118 
00119 
00120     // Convert local direction to global coordinates
00121     Gaudi::XYZVector local_direction(m_sourceDirection[0],
00122                                      m_sourceDirection[1],
00123                                      m_sourceDirection[2]);
00124     Gaudi::XYZVector global_direction = 
00125         targetDE->geometry()->toGlobal(local_direction);
00126     m_direction.setX(global_direction.x());
00127     m_direction.setY(global_direction.y());
00128     m_direction.setZ(global_direction.z());
00129     m_direction = m_direction.unit();
00130 
00131 
00132     // Convert target point to global coordinates
00133     Gaudi::XYZPoint local_target(m_targetOffset[0],
00134                                  m_targetOffset[1],
00135                                  m_targetOffset[2]);
00136     Gaudi::XYZPoint global_target = 
00137         targetDE->geometry()->toGlobal(local_target);
00138 
00139     m_position.setX(global_target.x() - m_distance*global_direction.x());
00140     m_position.setY(global_target.y() - m_distance*global_direction.y());
00141     m_position.setZ(global_target.z() - m_distance*global_direction.z());
00142 
00143 
00144     m_fourmom = HepLorentzVector(m_momentum*m_direction,
00145                                  sqrt(m_momentum*m_momentum + mass*mass));
00146 
00147 
00148     return StatusCode::SUCCESS;
00149 }

StatusCode GtBeamerTool::finalize (  )  [virtual]

Reimplemented from GaudiTool.

Definition at line 151 of file GtBeamerTool.cc.

00152 {
00153     return StatusCode::SUCCESS;
00154 }

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

Modify the event.

Implements IHepMCEventMutator.

Definition at line 156 of file GtBeamerTool.cc.

00157 {
00158     for (int ind=0; ind<m_particlesPerEvent; ++ind) {
00159 
00160         Hep3Vector ortho = m_direction.orthogonal();
00161         
00162         double angle = m_uni()*360*CLHEP::degree;
00163         ortho = ortho.rotate(angle,m_direction).unit();
00164         
00165         double ran_radius = sqrt(m_uni()*m_radius*m_radius);
00166         ortho = ran_radius*ortho + m_position;
00167 
00168         HepLorentzVector position(ortho,0);
00169         HepMC::GenVertex* vertex = new HepMC::GenVertex(position);
00170 
00171         HepMC::GenParticle* part = 
00172             new HepMC::GenParticle(m_fourmom,m_pid,1/*=status*/);
00173         double phi = m_uni()*360*CLHEP::degree;
00174         part->set_polarization(HepMC::Polarization(0.5*HepMC::HepMC_pi,phi));
00175         vertex->add_particle_out(part);
00176 
00177         if (!event.vertices_size()) 
00178             event.set_signal_process_vertex(vertex);
00179         event.add_vertex(vertex);
00180     }
00181 
00182     return StatusCode::SUCCESS;
00183 }

const InterfaceID & IHepMCEventMutator::interfaceID (  )  [static, inherited]

Retrieve interface ID.

Reimplemented from IAlgTool.

Definition at line 8 of file IHepMCEventMutator.cc.

00009 { 
00010     return IID_IHepMCEventMutator; 
00011 }


Member Data Documentation

double GtBeamerTool::m_radius [private]

Property: Radius: Radial size of disk.

Definition at line 55 of file GtBeamerTool.h.

int GtBeamerTool::m_particlesPerEvent [private]

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.

CLHEP::HepLorentzVector GtBeamerTool::m_fourmom [private]

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 Mon Apr 11 20:55:37 2011 for GenTools by doxygen 1.4.7