#include <RecoVertex/KVFTest/src/KVFTest.cc>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
KVFTest (const edm::ParameterSet &) | |
~KVFTest () | |
Private Member Functions | |
TrackingVertex | getSimVertex (const edm::Event &iEvent) const |
Private Attributes | |
TrackAssociatorByChi2 * | associatorForParamAtPca |
edm::ParameterSet | kvfPSet |
std::string | outputFile_ |
TFile * | rootFile_ |
edm::ParameterSet | theConfig |
std::string | trackLabel_ |
SimpleVertexTree * | tree |
This is a very simple test analyzer mean to test the KalmanVertexFitter
Description: steers tracker primary vertex reconstruction and storage
Implementation: <Notes on="" implementation>="">
KVFTest::KVFTest | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 25 of file KVFTest.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), kvfPSet, outputFile_, rootFile_, and trackLabel_.
: theConfig(iConfig), associatorForParamAtPca(0), tree(0) { trackLabel_ = iConfig.getParameter<std::string>("TrackLabel"); outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile"); kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters"); rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); edm::LogInfo("RecoVertex/KVFTest") << "Initializing KVF TEST analyser - Output file: " << outputFile_ <<"\n"; }
KVFTest::~KVFTest | ( | ) |
void KVFTest::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 54 of file KVFTest.cc.
References TrackAssociatorByChi2::associateRecoToSim(), associatorForParamAtPca, gather_cfg::cout, SimpleVertexTree::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), getSimVertex(), edm::EventBase::id(), edm::HandleBase::isValid(), TransientVertex::position(), edm::ESHandle< T >::product(), edm::Handle< T >::product(), trackLabel_, tree, and KalmanVertexFitter::vertex().
{ if ( associatorForParamAtPca==0 ) { edm::ESHandle<TrackAssociatorBase> theAssociatorForParamAtPca; iSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2",theAssociatorForParamAtPca); associatorForParamAtPca = (TrackAssociatorByChi2 *) theAssociatorForParamAtPca.product(); tree = new SimpleVertexTree("VertexFitter", associatorForParamAtPca); } edm::LogInfo("RecoVertex/KVFTest") << "Reconstructing event number: " << iEvent.id() << "\n"; // get RECO tracks from the event // `tks` can be used as a ptr to a reco::TrackCollection edm::Handle<edm::View<reco::Track> > tks; iEvent.getByLabel(trackLabel_, tks); if (!tks.isValid()) { edm::LogInfo("RecoVertex/KVFTest") << "Exception during event number: " << iEvent.id() << "\n"; } else { edm::LogInfo("RecoVertex/KVFTest") << "Found: " << (*tks).size() << " reconstructed tracks" << "\n"; std::cout << "got " << (*tks).size() << " tracks " << std::endl; // Transform Track to TransientTrack //get the builder: edm::ESHandle<TransientTrackBuilder> theB; iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB); //do the conversion: std::vector<TransientTrack> t_tks = (*theB).build(tks); edm::LogInfo("RecoVertex/KVFTest") << "Found: " << t_tks.size() << " reconstructed tracks" << "\n"; // Call the KalmanVertexFitter if more than 1 track if (t_tks.size() > 1) { // KalmanVertexFitter kvf(kvfPSet); KalmanVertexFitter kvf(true); TransientVertex tv = kvf.vertex(t_tks); std::cout << "Position: " << Vertex::Point(tv.position()) << "\n"; // For the analysis: compare to your SimVertex TrackingVertex sv = getSimVertex(iEvent); edm::Handle<TrackingParticleCollection> TPCollectionH ; iEvent.getByLabel("trackingtruth","TrackTruth",TPCollectionH); if (!TPCollectionH.isValid()) { edm::LogInfo("RecoVertex/KVFTest") << "Exception during event number: " << iEvent.id() << "\n"; } else { const TrackingParticleCollection tPC = *(TPCollectionH.product()); reco::RecoToSimCollection recSimColl=associatorForParamAtPca->associateRecoToSim(tks, TPCollectionH, &iEvent); tree->fill(tv, &sv, &recSimColl); } } } }
void KVFTest::beginJob | ( | void | ) | [virtual] |
void KVFTest::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 45 of file KVFTest.cc.
References tree.
{ delete tree; }
TrackingVertex KVFTest::getSimVertex | ( | const edm::Event & | iEvent | ) | const [private] |
Definition at line 122 of file KVFTest.cc.
References edm::Event::getByLabel(), and edm::Handle< T >::product().
Referenced by analyze().
{ // get the simulated vertices edm::Handle<TrackingVertexCollection> TVCollectionH ; iEvent.getByLabel("trackingtruth","VertexTruth",TVCollectionH); const TrackingVertexCollection tPC = *(TVCollectionH.product()); // Handle<edm::SimVertexContainer> simVtcs; // iEvent.getByLabel("g4SimHits", simVtcs); // std::cout << "SimVertex " << simVtcs->size() << std::endl; // for(edm::SimVertexContainer::const_iterator v=simVtcs->begin(); // v!=simVtcs->end(); ++v){ // std::cout << "simvtx " // << v->position().x() << " " // << v->position().y() << " " // << v->position().z() << " " // << v->parentIndex() << " " // << v->noParent() << " " // << std::endl; // } return *(tPC.begin()); }
edm::ParameterSet KVFTest::kvfPSet [private] |
std::string KVFTest::outputFile_ [private] |
TFile* KVFTest::rootFile_ [private] |
Definition at line 60 of file KVFTest.h.
Referenced by KVFTest(), and ~KVFTest().
edm::ParameterSet KVFTest::theConfig [private] |
std::string KVFTest::trackLabel_ [private] |
SimpleVertexTree* KVFTest::tree [private] |