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

In This Package:

SimPruneTool.cc

Go to the documentation of this file.
00001 #include "SimPruneTool.h"
00002 
00003 #include "Event/SimHeader.h"
00004 
00005 #include "DybKernel/ObjectReg.h"
00006 
00007 #include <string>
00008 using namespace std;
00009 using namespace DayaBay;
00010 
00011 SimPruneTool::SimPruneTool(const std::string& type,
00012                            const std::string& name,
00013                            const IInterface* parent)
00014     : GaudiTool(type,name,parent)
00015 {
00016     declareInterface<IRegSeqVisitor>(this);
00017 
00018     declareProperty("Location", m_location = SimHeader::defaultLocation(),
00019                     "Location of SimHeader that gets its hits pruned.");
00020 }
00021 
00022 SimPruneTool::~SimPruneTool()
00023 {
00024 }
00025  
00026 StatusCode SimPruneTool::visit(DayaBay::RegistrationSequence& rs)
00027 {
00028     debug () << "visit() with " << rs.size() << " registrations" << endreq;
00029 
00030     // vector<ObjectReg>
00031     IRegistrationSequence::Registrations regs = rs.registrations();
00032     for (size_t ind=0; ind<regs.size(); ++ind) {
00033         ObjectReg& objreg = regs[ind];
00034 
00035         const string& path = objreg.path();
00036         if (path != m_location) continue;
00037 
00038         DataObject* dobj = objreg.object();
00039         if (!dobj) continue;
00040 
00041         SimHeader* sh = dynamic_cast<SimHeader*>(dobj);
00042         if (!sh) {
00043             error() << "Data object at \"" << path << "\" not a SimHeader" << endreq;
00044             return StatusCode::FAILURE;
00045         }
00046 
00047         const SimHitHeader* chits = sh->hits();
00048         if (!chits) {
00049             debug() << "No SimHitHeader, my job is already done" << endreq;
00050             return StatusCode::SUCCESS;
00051         }
00052         SimHitHeader* shits = const_cast<SimHitHeader*>(chits);
00053         debug() << "Pruning " << shits->hitCollection().size() << " hit collections" << endreq;
00054         sh->setHits(0);
00055         delete shits;       // One usually uses TP for this operation.
00056 
00057         break;
00058     }
00059 
00060     return StatusCode::SUCCESS;
00061 }
00062 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:37:24 2011 for DybTool by doxygen 1.4.7