CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
KVFTest Class Reference

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

Inheritance diagram for KVFTest:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 KVFTest (const edm::ParameterSet &)
 
 ~KVFTest ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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 26 of file KVFTest.cc.

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

27  : theConfig(iConfig), associatorForParamAtPca(0), tree(0)
28 {
29  trackLabel_ = iConfig.getParameter<std::string>("TrackLabel");
30  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile");
31  kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters");
32  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
33  edm::LogInfo("RecoVertex/KVFTest")
34  << "Initializing KVF TEST analyser - Output file: " << outputFile_ <<"\n";
35 }
TrackAssociatorByChi2 * associatorForParamAtPca
Definition: KVFTest.h:58
T getParameter(std::string const &) const
std::string outputFile_
Definition: KVFTest.h:62
T getUntrackedParameter(std::string const &, T const &) const
SimpleVertexTree * tree
Definition: KVFTest.h:59
edm::ParameterSet theConfig
Definition: KVFTest.h:56
std::string trackLabel_
Definition: KVFTest.h:63
TFile * rootFile_
Definition: KVFTest.h:60
edm::ParameterSet kvfPSet
Definition: KVFTest.h:57
KVFTest::~KVFTest ( )

Definition at line 38 of file KVFTest.cc.

References rootFile_.

38  {
39  delete rootFile_;
40 }
TFile * rootFile_
Definition: KVFTest.h:60

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 55 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::Handle< T >::product(), edm::ESHandle< class >::product(), trackLabel_, tree, and KalmanVertexFitter::vertex().

56 {
57  if ( associatorForParamAtPca==0 ) {
58  edm::ESHandle<TrackAssociatorBase> theAssociatorForParamAtPca;
59  iSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2",theAssociatorForParamAtPca);
60  associatorForParamAtPca = (TrackAssociatorByChi2 *) theAssociatorForParamAtPca.product();
61 
62  tree = new SimpleVertexTree("VertexFitter", associatorForParamAtPca);
63  }
64 
65 
66 
67  edm::LogInfo("RecoVertex/KVFTest")
68  << "Reconstructing event number: " << iEvent.id() << "\n";
69 
70  // get RECO tracks from the event
71  // `tks` can be used as a ptr to a reco::TrackCollection
73  iEvent.getByLabel(trackLabel_, tks);
74  if (!tks.isValid()) {
75  edm::LogInfo("RecoVertex/KVFTest")
76  << "Exception during event number: " << iEvent.id()
77  << "\n";
78  } else {
79  edm::LogInfo("RecoVertex/KVFTest")
80  << "Found: " << (*tks).size() << " reconstructed tracks" << "\n";
81  std::cout << "got " << (*tks).size() << " tracks " << std::endl;
82 
83  // Transform Track to TransientTrack
84 
85  //get the builder:
87  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
88  //do the conversion:
89  std::vector<TransientTrack> t_tks = (*theB).build(tks);
90 
91  edm::LogInfo("RecoVertex/KVFTest")
92  << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
93 
94  // Call the KalmanVertexFitter if more than 1 track
95  if (t_tks.size() > 1) {
96  // KalmanVertexFitter kvf(kvfPSet);
97  KalmanVertexFitter kvf(true);
98  TransientVertex tv = kvf.vertex(t_tks);
99 
100  std::cout << "Position: " << Vertex::Point(tv.position()) << "\n";
101 
102  // For the analysis: compare to your SimVertex
103  TrackingVertex sv = getSimVertex(iEvent);
105  iEvent.getByLabel("trackingtruth","TrackTruth",TPCollectionH);
106  if (!TPCollectionH.isValid()) {
107  edm::LogInfo("RecoVertex/KVFTest")
108  << "Exception during event number: " << iEvent.id()
109  << "\n";
110  } else {
111  const TrackingParticleCollection tPC = *(TPCollectionH.product());
113  TPCollectionH,
114  &iEvent);
115  tree->fill(tv, &sv, &recSimColl);
116  }
117  }
118  }
119 }
TrackAssociatorByChi2 * associatorForParamAtPca
Definition: KVFTest.h:58
TrackingVertex getSimVertex(const edm::Event &iEvent) const
Definition: KVFTest.cc:123
SimpleVertexTree * tree
Definition: KVFTest.h:59
void fill(const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0.)
std::pair< double, double > Point
Definition: CaloEllipse.h:18
GlobalPoint position() const
std::string trackLabel_
Definition: KVFTest.h:63
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
double associateRecoToSim(reco::TrackCollection::const_iterator, TrackingParticleCollection::const_iterator, const reco::BeamSpot &) const
compare reco::TrackCollection and TrackingParticleCollection iterators: returns the chi2 ...
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:41
std::vector< TrackingParticle > TrackingParticleCollection
void KVFTest::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 42 of file KVFTest.cc.

42  {
43 }
void KVFTest::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 46 of file KVFTest.cc.

References tree.

46  {
47  delete tree;
48 }
SimpleVertexTree * tree
Definition: KVFTest.h:59
TrackingVertex KVFTest::getSimVertex ( const edm::Event iEvent) const
private

Definition at line 123 of file KVFTest.cc.

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

Referenced by analyze().

124 {
125  // get the simulated vertices
127  iEvent.getByLabel("trackingtruth","VertexTruth",TVCollectionH);
128  const TrackingVertexCollection tPC = *(TVCollectionH.product());
129 
130 // Handle<edm::SimVertexContainer> simVtcs;
131 // iEvent.getByLabel("g4SimHits", simVtcs);
132 // std::cout << "SimVertex " << simVtcs->size() << std::endl;
133 // for(edm::SimVertexContainer::const_iterator v=simVtcs->begin();
134 // v!=simVtcs->end(); ++v){
135 // std::cout << "simvtx "
136 // << v->position().x() << " "
137 // << v->position().y() << " "
138 // << v->position().z() << " "
139 // << v->parentIndex() << " "
140 // << v->noParent() << " "
141 // << std::endl;
142 // }
143  return *(tPC.begin());
144 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::vector< TrackingVertex > TrackingVertexCollection
T const * product() const
Definition: Handle.h:74

Member Data Documentation

TrackAssociatorByChi2* KVFTest::associatorForParamAtPca
private

Definition at line 58 of file KVFTest.h.

Referenced by analyze().

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