00001
00002 #include "DybGenPrune.h"
00003 #include "Event/GenHeader.h"
00004
00005 #include "HepMC/GenEvent.h"
00006
00007 DybGenPrune::DybGenPrune(const std::string& name, ISvcLocator* pSvcLocator)
00008 : GaudiAlgorithm(name,pSvcLocator)
00009 , m_genPrune(0)
00010 {
00011 declareProperty("MaxVertices",m_maxVertices=0,
00012 "Maximum number of vertices to survive the pruning");
00013 declareProperty("Location",m_location = DayaBay::GenHeader::defaultLocation(),
00014 "Location in TES in which to look for the GenHeader");
00015 declareProperty("GenPruneName",m_genPruneName = "GenPruneTool", "Name of GenHeader pruner");
00016 }
00017
00018 DybGenPrune::~DybGenPrune()
00019 {
00020 }
00021
00022 StatusCode DybGenPrune::initialize()
00023 {
00024 this->GaudiAlgorithm::initialize();
00025
00026 m_genPrune = tool<IGenPruneTool>(m_genPruneName);
00027 if( !m_genPrune ) {
00028 error() << "Failed to retrive GenPruneTool" << endreq;
00029 return StatusCode::FAILURE;
00030 }
00031
00034 m_genPrune->setMaxVertices( m_maxVertices );
00035
00036 return StatusCode::SUCCESS;
00037 }
00038
00039 StatusCode DybGenPrune::execute()
00040 {
00041
00042 DayaBay::GenHeader* gh = get<DayaBay::GenHeader>(m_location);
00043 if (!gh) {
00044 warning() << "No GenHeader found at " << m_location
00045 << ", my work here is already done."
00046 << endreq;
00047 return StatusCode::SUCCESS;
00048 }
00049
00050 m_genPrune->prune( gh );
00051
00052 return StatusCode::SUCCESS;
00053 }
00054
00055 StatusCode DybGenPrune::finalize()
00056 {
00057
00058 return this->GaudiAlgorithm::finalize();
00059 }
00060