CMS 3D CMS Logo

KVFTest Class Reference

This is a very simple test analyzer mean to test the KalmanVertexFitter. More...

#include <RecoVertex/KVFTest/src/KVFTest.cc>

Inheritance diagram for KVFTest:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (edm::EventSetup const &)
virtual void endJob ()
 KVFTest (const edm::ParameterSet &)
 ~KVFTest ()

Private Member Functions

TrackingVertex getSimVertex (const edm::Event &iEvent) const

Private Attributes

TrackAssociatorByChi2associatorForParamAtPca
edm::ParameterSet kvfPSet
std::string outputFile_
TFile * rootFile_
edm::ParameterSet theConfig
std::string trackLabel_
SimpleVertexTreetree


Detailed Description

This is a very simple test analyzer mean to test the KalmanVertexFitter.

Description: steers tracker primary vertex reconstruction and storage.

Implementation: <Notes on="" implementation>="">

Definition at line 42 of file KVFTest.h.


Constructor & Destructor Documentation

KVFTest::KVFTest ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 27 of file KVFTest.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), kvfPSet, outputFile_, rootFile_, and trackLabel_.

00028   : theConfig(iConfig)
00029 {
00030   trackLabel_ = iConfig.getParameter<std::string>("TrackLabel");
00031   outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile");
00032   kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters");
00033   rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE"); 
00034   edm::LogInfo("RecoVertex/KVFTest") 
00035     << "Initializing KVF TEST analyser  - Output file: " << outputFile_ <<"\n";
00036 }

KVFTest::~KVFTest (  ) 

Definition at line 39 of file KVFTest.cc.

References rootFile_.

00039                   {
00040   delete rootFile_;
00041 }


Member Function Documentation

void KVFTest::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 61 of file KVFTest.cc.

References TrackAssociatorByChi2::associateRecoToSim(), associatorForParamAtPca, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), SimpleVertexTree::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), getSimVertex(), edm::Event::id(), edm::Handle< T >::isValid(), TransientVertex::position(), edm::Handle< T >::product(), sv, trackLabel_, tree, and KalmanVertexFitter::vertex().

00062 {
00063   edm::LogInfo("RecoVertex/KVFTest") 
00064     << "Reconstructing event number: " << iEvent.id() << "\n";
00065     
00066   // get RECO tracks from the event
00067   // `tks` can be used as a ptr to a reco::TrackCollection
00068   edm::Handle<edm::View<reco::Track> > tks;
00069   iEvent.getByLabel(trackLabel_, tks);
00070   if (!tks.isValid()) {
00071     edm::LogInfo("RecoVertex/KVFTest") 
00072       << "Exception during event number: " << iEvent.id()
00073       << "\n";
00074   } else {
00075     edm::LogInfo("RecoVertex/KVFTest") 
00076       << "Found: " << (*tks).size() << " reconstructed tracks" << "\n";
00077     cout << "got " << (*tks).size() << " tracks " << endl;
00078     
00079     // Transform Track to TransientTrack
00080 
00081     //get the builder:
00082     edm::ESHandle<TransientTrackBuilder> theB;
00083     iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
00084     //do the conversion:
00085     vector<TransientTrack> t_tks = (*theB).build(tks);
00086 
00087     edm::LogInfo("RecoVertex/KVFTest") 
00088       << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
00089     
00090     // Call the KalmanVertexFitter if more than 1 track
00091     if (t_tks.size() > 1) {
00092       //      KalmanVertexFitter kvf(kvfPSet);
00093       KalmanVertexFitter kvf(true);
00094       TransientVertex tv = kvf.vertex(t_tks);
00095 
00096       std::cout << "Position: " << Vertex::Point(tv.position()) << "\n";
00097 
00098       // For the analysis: compare to your SimVertex
00099       TrackingVertex sv = getSimVertex(iEvent);
00100       edm::Handle<TrackingParticleCollection>  TPCollectionH ;
00101       iEvent.getByLabel("trackingtruth","TrackTruth",TPCollectionH);
00102       if (!TPCollectionH.isValid()) {
00103         edm::LogInfo("RecoVertex/KVFTest") 
00104           << "Exception during event number: " << iEvent.id() 
00105           << "\n";
00106       } else {
00107         const TrackingParticleCollection tPC = *(TPCollectionH.product());
00108         reco::RecoToSimCollection recSimColl=associatorForParamAtPca->associateRecoToSim(tks,
00109                                                                                          TPCollectionH,
00110                                                                                          &iEvent);    
00111         tree->fill(tv, &sv, &recSimColl);
00112       }
00113     }
00114   }  
00115 }

void KVFTest::beginJob ( edm::EventSetup const &  setup  )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file KVFTest.cc.

References associatorForParamAtPca, edm::EventSetup::get(), edm::ESHandle< T >::product(), and tree.

00043                                                 {
00044   edm::ESHandle<TrackAssociatorBase> theAssociatorForParamAtPca;
00045   setup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2",theAssociatorForParamAtPca);
00046   associatorForParamAtPca = (TrackAssociatorByChi2 *) theAssociatorForParamAtPca.product();
00047 
00048   tree = new SimpleVertexTree("VertexFitter", associatorForParamAtPca);
00049 }

void KVFTest::endJob ( void   )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file KVFTest.cc.

References tree.

00052                      {
00053   delete tree;
00054 }

TrackingVertex KVFTest::getSimVertex ( const edm::Event iEvent  )  const [private]

Definition at line 119 of file KVFTest.cc.

References edm::Event::getByLabel(), and edm::Handle< T >::product().

Referenced by analyze().

00120 {
00121    // get the simulated vertices
00122   edm::Handle<TrackingVertexCollection>  TVCollectionH ;
00123   iEvent.getByLabel("trackingtruth","VertexTruth",TVCollectionH);
00124   const TrackingVertexCollection tPC = *(TVCollectionH.product());
00125 
00126 //    Handle<edm::SimVertexContainer> simVtcs;
00127 //    iEvent.getByLabel("g4SimHits", simVtcs);
00128 //    std::cout << "SimVertex " << simVtcs->size() << std::endl;
00129 //    for(edm::SimVertexContainer::const_iterator v=simVtcs->begin();
00130 //        v!=simVtcs->end(); ++v){
00131 //      std::cout << "simvtx "
00132 //             << v->position().x() << " "
00133 //             << v->position().y() << " "
00134 //             << v->position().z() << " "
00135 //             << v->parentIndex() << " "
00136 //             << v->noParent() << " "
00137 //               << std::endl;
00138 //    }
00139    return *(tPC.begin());
00140 }


Member Data Documentation

TrackAssociatorByChi2* KVFTest::associatorForParamAtPca [private]

Definition at line 58 of file KVFTest.h.

Referenced by analyze(), and beginJob().

edm::ParameterSet KVFTest::kvfPSet [private]

Definition at line 57 of file KVFTest.h.

Referenced by KVFTest().

std::string KVFTest::outputFile_ [private]

Definition at line 62 of file KVFTest.h.

Referenced by KVFTest().

TFile* KVFTest::rootFile_ [private]

Definition at line 60 of file KVFTest.h.

Referenced by KVFTest(), and ~KVFTest().

edm::ParameterSet KVFTest::theConfig [private]

Definition at line 56 of file KVFTest.h.

std::string KVFTest::trackLabel_ [private]

Definition at line 63 of file KVFTest.h.

Referenced by analyze(), and KVFTest().

SimpleVertexTree* KVFTest::tree [private]

Definition at line 59 of file KVFTest.h.

Referenced by analyze(), beginJob(), and endJob().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:23 2009 for CMSSW by  doxygen 1.5.4