CMS 3D CMS Logo

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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
 KVFTest (const edm::ParameterSet &)
 
 ~KVFTest () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

edm::ParameterSet kvfPSet
 
std::string outputFile_
 
TFile * rootFile_
 
edm::ParameterSet theConfig
 
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociatortoken_associatorForParamAtPca
 
edm::EDGetTokenT< reco::TrackCollectiontoken_tracks
 
edm::EDGetTokenT< TrackingParticleCollectiontoken_TrackTruth
 
edm::EDGetTokenT< TrackingVertexCollectiontoken_VertexTruth
 
std::unique_ptr< SimpleVertexTreetree
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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 36 of file KVFTest.h.

Constructor & Destructor Documentation

◆ KVFTest()

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

Definition at line 26 of file KVFTest.cc.

26  : theConfig(iConfig) {
27  token_tracks = consumes<TrackCollection>(iConfig.getParameter<string>("TrackLabel"));
28  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile");
29  kvfPSet = iConfig.getParameter<edm::ParameterSet>("KVFParameters");
30  rootFile_ = TFile::Open(outputFile_.c_str(), "RECREATE");
31  edm::LogInfo("RecoVertex/KVFTest") << "Initializing KVF TEST analyser - Output file: " << outputFile_ << "\n";
32 
33  token_TrackTruth = consumes<TrackingParticleCollection>(edm::InputTag("trackingtruth", "TrackTruth"));
34  token_VertexTruth = consumes<TrackingVertexCollection>(edm::InputTag("trackingtruth", "VertexTruth"));
36  consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag("trackAssociatorByChi2"));
37 }

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), kvfPSet, outputFile_, rootFile_, AlCaHLTBitMon_QueryRunRegistry::string, token_associatorForParamAtPca, token_tracks, token_TrackTruth, and token_VertexTruth.

◆ ~KVFTest()

KVFTest::~KVFTest ( )
override

Definition at line 39 of file KVFTest.cc.

39 { delete rootFile_; }

References rootFile_.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 49 of file KVFTest.cc.

49  {
51  iEvent.getByToken(token_associatorForParamAtPca, associatorForParamAtPca);
52 
53  if (not tree) {
55  iSetup.get<IdealMagneticFieldRecord>().get(magField);
56  tree = std::make_unique<SimpleVertexTree>("VertexFitter", magField.product());
57  }
58 
59  edm::LogInfo("RecoVertex/KVFTest") << "Reconstructing event number: " << iEvent.id() << "\n";
60 
61  // get RECO tracks from the event
62  // `tks` can be used as a ptr to a reco::TrackCollection
64  iEvent.getByToken(token_tracks, tks);
65  if (!tks.isValid()) {
66  edm::LogInfo("RecoVertex/KVFTest") << "Exception during event number: " << iEvent.id() << "\n";
67  } else {
68  edm::LogInfo("RecoVertex/KVFTest") << "Found: " << (*tks).size() << " reconstructed tracks"
69  << "\n";
70  std::cout << "got " << (*tks).size() << " tracks " << std::endl;
71 
72  // Transform Track to TransientTrack
73 
74  //get the builder:
76  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theB);
77  //do the conversion:
78  std::vector<TransientTrack> t_tks = (*theB).build(tks);
79 
80  edm::LogInfo("RecoVertex/KVFTest") << "Found: " << t_tks.size() << " reconstructed tracks"
81  << "\n";
82 
83  // Call the KalmanVertexFitter if more than 1 track
84  if (t_tks.size() > 1) {
85  // KalmanVertexFitter kvf(kvfPSet);
86  KalmanVertexFitter kvf(true);
87  TransientVertex tv = kvf.vertex(t_tks);
88 
89  std::cout << "Position: " << Vertex::Point(tv.position()) << "\n";
90 
91  // For the analysis: compare to your SimVertex
94  iEvent.getByToken(token_TrackTruth, TPCollectionH);
95  if (!TPCollectionH.isValid()) {
96  edm::LogInfo("RecoVertex/KVFTest") << "Exception during event number: " << iEvent.id() << "\n";
97  } else {
98  const TrackingParticleCollection tPC = *(TPCollectionH.product());
99  reco::RecoToSimCollection recSimColl = associatorForParamAtPca->associateRecoToSim(tks, TPCollectionH);
100  tree->fill(tv, &sv, &recSimColl);
101  }
102  }
103  }
104 }

References reco::TrackToTrackingParticleAssociator::associateRecoToSim(), gather_cfg::cout, edm::EventSetup::get(), get, getSimVertex(), iEvent, edm::HandleBase::isValid(), TransientVertex::position(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), pfDeepBoostedJetPreprocessParams_cfi::sv, token_associatorForParamAtPca, token_tracks, token_TrackTruth, and KalmanVertexFitter::vertex().

◆ beginJob()

void KVFTest::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 41 of file KVFTest.cc.

41 {}

◆ endJob()

void KVFTest::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file KVFTest.cc.

43 {}

◆ getSimVertex()

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

Definition at line 108 of file KVFTest.cc.

108  {
109  // get the simulated vertices
111  iEvent.getByToken(token_VertexTruth, TVCollectionH);
112  const TrackingVertexCollection tPC = *(TVCollectionH.product());
113 
114  // Handle<edm::SimVertexContainer> simVtcs;
115  // iEvent.getByLabel("g4SimHits", simVtcs);
116  // std::cout << "SimVertex " << simVtcs->size() << std::endl;
117  // for(edm::SimVertexContainer::const_iterator v=simVtcs->begin();
118  // v!=simVtcs->end(); ++v){
119  // std::cout << "simvtx "
120  // << v->position().x() << " "
121  // << v->position().y() << " "
122  // << v->position().z() << " "
123  // << v->parentIndex() << " "
124  // << v->noParent() << " "
125  // << std::endl;
126  // }
127  return *(tPC.begin());
128 }

References iEvent, edm::Handle< T >::product(), and token_VertexTruth.

Referenced by analyze().

Member Data Documentation

◆ kvfPSet

edm::ParameterSet KVFTest::kvfPSet
private

Definition at line 50 of file KVFTest.h.

Referenced by KVFTest().

◆ outputFile_

std::string KVFTest::outputFile_
private

Definition at line 54 of file KVFTest.h.

Referenced by KVFTest().

◆ rootFile_

TFile* KVFTest::rootFile_
private

Definition at line 52 of file KVFTest.h.

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

◆ theConfig

edm::ParameterSet KVFTest::theConfig
private

Definition at line 49 of file KVFTest.h.

◆ token_associatorForParamAtPca

edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> KVFTest::token_associatorForParamAtPca
private

Definition at line 58 of file KVFTest.h.

Referenced by analyze(), and KVFTest().

◆ token_tracks

edm::EDGetTokenT<reco::TrackCollection> KVFTest::token_tracks
private

Definition at line 55 of file KVFTest.h.

Referenced by analyze(), and KVFTest().

◆ token_TrackTruth

edm::EDGetTokenT<TrackingParticleCollection> KVFTest::token_TrackTruth
private

Definition at line 56 of file KVFTest.h.

Referenced by analyze(), and KVFTest().

◆ token_VertexTruth

edm::EDGetTokenT<TrackingVertexCollection> KVFTest::token_VertexTruth
private

Definition at line 57 of file KVFTest.h.

Referenced by getSimVertex(), and KVFTest().

◆ tree

std::unique_ptr<SimpleVertexTree> KVFTest::tree
private
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
KVFTest::rootFile_
TFile * rootFile_
Definition: KVFTest.h:52
edm::Handle::product
T const * product() const
Definition: Handle.h:70
tree
Definition: tree.py:1
reco::TrackToTrackingParticleAssociator::associateRecoToSim
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
Definition: TrackToTrackingParticleAssociator.h:64
gather_cfg.cout
cout
Definition: gather_cfg.py:144
KVFTest::theConfig
edm::ParameterSet theConfig
Definition: KVFTest.h:49
TransientVertex::position
GlobalPoint position() const
Definition: TransientVertex.h:169
TrackingVertexCollection
std::vector< TrackingVertex > TrackingVertexCollection
Definition: TrackingVertexContainer.h:8
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< reco::TrackToTrackingParticleAssociator >
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
KVFTest::token_associatorForParamAtPca
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > token_associatorForParamAtPca
Definition: KVFTest.h:58
Point
math::XYZPoint Point
Definition: TrackerDpgAnalysis.cc:106
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
KVFTest::token_tracks
edm::EDGetTokenT< reco::TrackCollection > token_tracks
Definition: KVFTest.h:55
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< MagneticField >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
TrackingVertex
Definition: TrackingVertex.h:22
iEvent
int iEvent
Definition: GenABIO.cc:224
KVFTest::kvfPSet
edm::ParameterSet kvfPSet
Definition: KVFTest.h:50
TransientVertex
Definition: TransientVertex.h:18
get
#define get
KVFTest::token_TrackTruth
edm::EDGetTokenT< TrackingParticleCollection > token_TrackTruth
Definition: KVFTest.h:56
KVFTest::getSimVertex
TrackingVertex getSimVertex(const edm::Event &iEvent) const
Definition: KVFTest.cc:108
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingParticleFwd.h:8
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
KVFTest::token_VertexTruth
edm::EDGetTokenT< TrackingVertexCollection > token_VertexTruth
Definition: KVFTest.h:57
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
KVFTest::outputFile_
std::string outputFile_
Definition: KVFTest.h:54
edm::InputTag
Definition: InputTag.h:15
KalmanVertexFitter
Definition: KalmanVertexFitter.h:22