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 edm::EDConsumerBase

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 ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

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

26  : theConfig(iConfig), associatorForParamAtPca(0), tree(0)
27 {
28  trackLabel_ = iConfig.getParameter<std::string>("TrackLabel");
29  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile");
30  kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters");
31  rootFile_ = TFile::Open(outputFile_.c_str(),"RECREATE");
32  edm::LogInfo("RecoVertex/KVFTest")
33  << "Initializing KVF TEST analyser - Output file: " << outputFile_ <<"\n";
34 }
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 37 of file KVFTest.cc.

References rootFile_.

37  {
38  delete rootFile_;
39 }
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 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::Handle< T >::product(), edm::ESHandle< class >::product(), trackLabel_, tree, and KalmanVertexFitter::vertex().

55 {
56  if ( associatorForParamAtPca==0 ) {
57  edm::ESHandle<TrackAssociatorBase> theAssociatorForParamAtPca;
58  iSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByChi2",theAssociatorForParamAtPca);
59  associatorForParamAtPca = (TrackAssociatorByChi2 *) theAssociatorForParamAtPca.product();
60 
61  tree = new SimpleVertexTree("VertexFitter", associatorForParamAtPca);
62  }
63 
64 
65 
66  edm::LogInfo("RecoVertex/KVFTest")
67  << "Reconstructing event number: " << iEvent.id() << "\n";
68 
69  // get RECO tracks from the event
70  // `tks` can be used as a ptr to a reco::TrackCollection
72  iEvent.getByLabel(trackLabel_, tks);
73  if (!tks.isValid()) {
74  edm::LogInfo("RecoVertex/KVFTest")
75  << "Exception during event number: " << iEvent.id()
76  << "\n";
77  } else {
78  edm::LogInfo("RecoVertex/KVFTest")
79  << "Found: " << (*tks).size() << " reconstructed tracks" << "\n";
80  std::cout << "got " << (*tks).size() << " tracks " << std::endl;
81 
82  // Transform Track to TransientTrack
83 
84  //get the builder:
86  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
87  //do the conversion:
88  std::vector<TransientTrack> t_tks = (*theB).build(tks);
89 
90  edm::LogInfo("RecoVertex/KVFTest")
91  << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
92 
93  // Call the KalmanVertexFitter if more than 1 track
94  if (t_tks.size() > 1) {
95  // KalmanVertexFitter kvf(kvfPSet);
96  KalmanVertexFitter kvf(true);
97  TransientVertex tv = kvf.vertex(t_tks);
98 
99  std::cout << "Position: " << Vertex::Point(tv.position()) << "\n";
100 
101  // For the analysis: compare to your SimVertex
102  TrackingVertex sv = getSimVertex(iEvent);
104  iEvent.getByLabel("trackingtruth","TrackTruth",TPCollectionH);
105  if (!TPCollectionH.isValid()) {
106  edm::LogInfo("RecoVertex/KVFTest")
107  << "Exception during event number: " << iEvent.id()
108  << "\n";
109  } else {
110  const TrackingParticleCollection tPC = *(TPCollectionH.product());
112  TPCollectionH,
113  &iEvent);
114  tree->fill(tv, &sv, &recSimColl);
115  }
116  }
117  }
118 }
TrackAssociatorByChi2 * associatorForParamAtPca
Definition: KVFTest.h:58
std::vector< TrackingParticle > TrackingParticleCollection
TrackingVertex getSimVertex(const edm::Event &iEvent) const
Definition: KVFTest.cc:122
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:361
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:121
void KVFTest::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 41 of file KVFTest.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 45 of file KVFTest.cc.

References tree.

45  {
46  delete tree;
47 }
SimpleVertexTree * tree
Definition: KVFTest.h:59
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().

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