/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 | Private Member Functions | Private Attributes
GenHists Class Reference

#include <GenHists.h>

List of all members.

Public Member Functions

 GenHists (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~GenHists ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()

Private Member Functions

StatusCode BookVertices ()

Private Attributes

std::string m_location
 Property: Location - TES path to the generated kinematics.
std::string m_volume
 Property: Volume - TDS path to the physical volume (detector element) used when generating kinematic vertex locations.
std::string m_filepath
 Property: FilePath - path to use when registering histograms.
double m_maxEnergy
 Property MaxEnergy - max value for energy histogram.
double m_energyUnits
 Property EnergyUnits - units for energy.
ITHistSvc * m_hsvc
IGeometryInfo * m_geo
TH1I * m_nKineParts
TH1F * m_kineEnergy
TH1F * m_vtxTime
TH2F * m_xy
TH2F * m_yz
TH2F * m_xz

Detailed Description

Definition at line 25 of file GenHists.h.


Constructor & Destructor Documentation

GenHists::GenHists ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 33 of file GenHists.cc.

    : GaudiAlgorithm(name,pSvcLocator)
    , m_hsvc(0)
    , m_nKineParts(0)
    , m_kineEnergy(0)
    , m_xy(0), m_yz(0), m_xz(0)
{
    declareProperty("Location",m_location=DayaBay::GenHeaderLocation::Default,
                    "Location in the TES to get GenHeader");
    declareProperty("Volume",m_volume="",
                    "TDS path of volume used to generated vertices");
    declareProperty("FilePath",m_filepath="/file1/gen/",
                    "File path with with to register histograms.");
    declareProperty("MaxEnergy",m_maxEnergy = 10*CLHEP::MeV,
                    "Maximum energy for plot bounds.");
    declareProperty("EnergyUnits",m_energyUnits = CLHEP::MeV,
                    "Energy units for plot bounds.");
}
GenHists::~GenHists ( ) [virtual]

Definition at line 52 of file GenHists.cc.

{
}

Member Function Documentation

StatusCode GenHists::initialize ( ) [virtual]

Definition at line 78 of file GenHists.cc.

{
    this->GaudiAlgorithm::initialize();

    // Get the histogram service
    if ( service("THistSvc", m_hsvc).isFailure()) {
        error() << " No THistSvc available." << endreq;
        return StatusCode::FAILURE;
    } 

    // Book some histograms, using CPP macro to help reduce typing

    REG1D(TH1I,m_nKineParts,"nKineParts","Total number of primaries",10,0,10);
    REG1D(TH1F,m_kineEnergy,"kineEnergy","Particle Energy (MeV)",100,0,m_maxEnergy);
    REG1D(TH1F,m_vtxTime,"kineVtxTime","Times of vertices (seconds)",1500,0,15*60);
    return this->BookVertices();
}
StatusCode GenHists::execute ( ) [virtual]

Definition at line 142 of file GenHists.cc.

{
    DayaBay::GenHeader* header = get<DayaBay::GenHeader>(m_location);
    
    HepMC::GenEvent* genevt = header->event();
    if (!genevt) { 
        warning() << "No event, giving up" << endreq;
        // we don't return failure as it is not fatal.
        return StatusCode::SUCCESS; 
    }

    HepMC::GenVertex* genvtx = genevt->signal_process_vertex();
    m_nKineParts->Fill(genvtx->particles_out_size());

    HepMC::GenVertex::particles_out_const_iterator 
        it = genvtx->particles_out_const_begin(), 
        done = genvtx->particles_out_const_end();

    double energy=0;
    for (; it != done; ++it) {
        HepMC::GenParticle* part = *it;
        HepMC::FourVector momentum = part->momentum();
        energy += momentum.e();
        m_kineEnergy->Fill(momentum.e()/m_energyUnits);
    }
    
    HepMC::FourVector r4 = genvtx->position();

    Gaudi::XYZPoint gp(r4.x(),r4.y(),r4.z());
    Gaudi::XYZPoint lp = m_geo->toLocal(gp);

    m_vtxTime->Fill(r4.t()/CLHEP::second);
    m_xy->Fill(lp.x()/CLHEP::meter,lp.y()/CLHEP::meter);
    m_yz->Fill(lp.y()/CLHEP::meter,lp.z()/CLHEP::meter);
    m_xz->Fill(lp.x()/CLHEP::meter,lp.z()/CLHEP::meter);

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

Definition at line 181 of file GenHists.cc.

{

    return this->GaudiAlgorithm::finalize();
}
StatusCode GenHists::BookVertices ( ) [private]

Definition at line 96 of file GenHists.cc.

{
    // Get volume of generation to get bounds later
    DetectorElement* detelem=0;
    if ("" == m_volume) {
        warning() << "No Volume property set, guessing at volume bounds." << endreq;
    }
    if (!existDet<DetectorElement>(m_volume)) {
        warning() << "Failed to get detector element " << m_volume 
                  << ", will guess at volume bounds" << endreq;
    }
    else {
        detelem = getDet<DetectorElement>(m_volume);
    }

    double minx = -25*CLHEP::meter, maxx = +25*CLHEP::meter;
    double miny = -25*CLHEP::meter, maxy = +25*CLHEP::meter;
    double minz = -25*CLHEP::meter, maxz = +25*CLHEP::meter;
    if (detelem) {
        m_geo = detelem->geometry();
        const ILVolume* lvol = m_geo->lvolume();
        if (!lvol) {
            error() << "Could not get logical volume for: \"" << m_volume << "\"" << endreq;
            return StatusCode::FAILURE;
        }

        const SolidBase* solid = dynamic_cast<const SolidBase*>(lvol->solid());
        minx = solid->xMin(); maxx = solid->xMax();
        miny = solid->yMin(); maxy = solid->yMax();
        minz = solid->zMin(); maxz = solid->zMax();        
        info () << "Volume bounded by: "
                << "X: [" << minx/CLHEP::meter << " " << maxx/CLHEP::meter << "], "
                << "Y: [" << miny/CLHEP::meter << " " << maxy/CLHEP::meter << "], "
                << "Z: [" << minz/CLHEP::meter << " " << maxz/CLHEP::meter << "]"
                << endreq;
    }
    REG2D(TH2F,m_xy,"kineVertexXY","Primary Vertices, X-Y",
          100,minx/CLHEP::meter,maxx/CLHEP::meter,100,miny/CLHEP::meter,maxy/CLHEP::meter);
    REG2D(TH2F,m_yz,"kineVertexYZ","Primary Vertices, Y-Z",
          100,miny/CLHEP::meter,maxy/CLHEP::meter,100,minz/CLHEP::meter,maxz/CLHEP::meter);
    REG2D(TH2F,m_xz,"kineVertexXZ","Primary Vertices, Z-X",
          100,minx/CLHEP::meter,maxx/CLHEP::meter,100,minz/CLHEP::meter,maxz/CLHEP::meter);

    return StatusCode::SUCCESS;
}

Member Data Documentation

std::string GenHists::m_location [private]

Property: Location - TES path to the generated kinematics.

Defaults to DayaBay::HepMCEventLocation::Default

Definition at line 41 of file GenHists.h.

std::string GenHists::m_volume [private]

Property: Volume - TDS path to the physical volume (detector element) used when generating kinematic vertex locations.

Definition at line 45 of file GenHists.h.

std::string GenHists::m_filepath [private]

Property: FilePath - path to use when registering histograms.

Must end in "/". Default "/file1/gen/"

Definition at line 49 of file GenHists.h.

double GenHists::m_maxEnergy [private]

Property MaxEnergy - max value for energy histogram.

Definition at line 52 of file GenHists.h.

double GenHists::m_energyUnits [private]

Property EnergyUnits - units for energy.

Definition at line 55 of file GenHists.h.

ITHistSvc* GenHists::m_hsvc [private]

Definition at line 63 of file GenHists.h.

IGeometryInfo* GenHists::m_geo [private]

Definition at line 66 of file GenHists.h.

TH1I* GenHists::m_nKineParts [private]

Definition at line 69 of file GenHists.h.

TH1F* GenHists::m_kineEnergy [private]

Definition at line 70 of file GenHists.h.

TH1F * GenHists::m_vtxTime [private]

Definition at line 70 of file GenHists.h.

TH2F* GenHists::m_xy [private]

Definition at line 71 of file GenHists.h.

TH2F * GenHists::m_yz [private]

Definition at line 71 of file GenHists.h.

TH2F * GenHists::m_xz [private]

Definition at line 71 of file GenHists.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:19:50 for SimHistsExample by doxygen 1.7.4