/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
GtTransformTool Class Reference

#include <GtTransformTool.h>

Inheritance diagram for GtTransformTool:
Inheritance graph
[legend]
Collaboration diagram for GtTransformTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GtTransformTool (const std::string &type, const std::string &name, const IInterface *parent)
 GtTransformTool - transform existing event vertices and momenta from local to global coordinates.
virtual ~GtTransformTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode mutate (HepMC::GenEvent &event)
 Modify the event.
const IDetectorElement * detelem ()

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Attributes

std::string m_volume
 Volume property.
std::vector< double > m_offset
bool m_ignorePosition
bool m_ignoreDirection
IDetectorElement * m_detelem

Detailed Description

Definition at line 33 of file GtTransformTool.h.


Constructor & Destructor Documentation

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

GtTransformTool - transform existing event vertices and momenta from local to global coordinates.

bv@bnl.gov 2008/6/6 move transformations into dedicated tool

Definition at line 20 of file GtTransformTool.cc.

    : GaudiTool(type,name,parent)
    , m_offset(3,0)
    , m_detelem(0)
{
    declareInterface<IHepMCEventMutator>(this);

    declareProperty("Volume",m_volume="",
                    "Name of the DetectorElement to provide the local coordinate system.");

    declareProperty("Offset",m_offset,
                    "Spatial offset to apply to vertices before transformation");

    declareProperty("IgnorePosition",m_ignorePosition = false,
                    "Do not transform the position.");

    declareProperty("IgnoreDirection",m_ignoreDirection = false,
                    "Do not transform the direction.");
}
GtTransformTool::~GtTransformTool ( ) [virtual]

Definition at line 54 of file GtTransformTool.cc.

{
}

Member Function Documentation

StatusCode GtTransformTool::initialize ( ) [virtual]

Definition at line 58 of file GtTransformTool.cc.

{
    this->GaudiTool::initialize();

    const IDetectorElement* detelem = this->detelem();
    if (!detelem) {
        fatal() << "Could not get detector element: \"" << m_volume << "\"" << endreq;
        return StatusCode::FAILURE;
    }

    return StatusCode::SUCCESS;
}
StatusCode GtTransformTool::finalize ( ) [virtual]

Definition at line 122 of file GtGunGenTool.cc.

{

    return this->GaudiTool::finalize();
}
StatusCode GtTransformTool::mutate ( HepMC::GenEvent event) [virtual]

Modify the event.

Implements IHepMCEventMutator.

Definition at line 73 of file GtTransformTool.cc.

{
    if (!m_ignorePosition) {

        debug() << "Transforming " << event.vertices_size() << " vertices:\n";
        HepMC::GenEvent::vertex_iterator vtx, done = event.vertices_end();
        for (vtx = event.vertices_begin(); vtx != done; ++vtx) {
            HepMC::FourVector pos = (*vtx)->position();

            // Note XYZPoint, not XYZVector
            Gaudi::XYZPoint local_point(pos.x()+m_offset[0],pos.y()+m_offset[1],pos.z()+m_offset[2]);
            Gaudi::XYZPoint global_point = m_detelem->geometry()->toGlobal(local_point);

            debug() << "\ttransform("<< pos.x()<<","<<pos.y()<<","<<pos.z() << ")\n"
                    << "\tlocal: " << local_point 
                    << "\tglobal: " << global_point << '\n'
                    << "\t detelem: " << *m_detelem << "\n"
                //<< "\t with lvolume: " << *(m_detelem->geometry()->lvolume())  
                    << "\n";

            pos.setX(global_point.x()); 
            pos.setY(global_point.y()); 
            pos.setZ(global_point.z());
            (*vtx)->set_position(pos);
            debug() << "\tvertex @ " << "("
                    << (*vtx)->position().x()/CLHEP::cm << ","
                    << (*vtx)->position().y()/CLHEP::cm << ","
                    << (*vtx)->position().z()/CLHEP::cm << ","
                    << (*vtx)->position().t()/CLHEP::second << ") [cm,cm,cm,second]";
        }
        debug () << endreq;
    }

    if (!m_ignoreDirection) {

        HepMC::GenEvent::particle_iterator pit, pdone = event.particles_end();
        for (pit = event.particles_begin(); pit != pdone; ++pit) {
            HepMC::FourVector mom = (*pit)->momentum();

            // Note XYZVector, not XYZPoint
            Gaudi::XYZVector lmom(mom.px(),mom.py(),mom.pz());
            Gaudi::XYZVector gmom = m_detelem->geometry()->toGlobal(lmom);
            mom.set(gmom.x(),gmom.y(),gmom.z(),mom.e());

            (*pit)->set_momentum(mom);
        }
    }

    return StatusCode::SUCCESS;
}
const IDetectorElement * GtTransformTool::detelem ( )

Definition at line 42 of file GtTransformTool.cc.

{
    if (m_detelem) return m_detelem;

    if ("" == m_volume) return 0;

    if (!existDet<IDetectorElement>(m_volume)) return 0;

    m_detelem = getDet<IDetectorElement>(m_volume);
    return m_detelem;
}
const InterfaceID & IHepMCEventMutator::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file IHepMCEventMutator.cc.

{ 
    return IID_IHepMCEventMutator; 
}

Member Data Documentation

std::string GtTransformTool::m_volume [private]

Volume property.

Definition at line 54 of file GtTransformTool.h.

std::vector<double> GtTransformTool::m_offset [private]

Definition at line 57 of file GtTransformTool.h.

Definition at line 60 of file GtTransformTool.h.

Definition at line 63 of file GtTransformTool.h.

IDetectorElement* GtTransformTool::m_detelem [private]

Definition at line 65 of file GtTransformTool.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