CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PF_PU_FirstVertexTracks Class Reference

#include <PF_PU_FirstVertexTracks.h>

Inheritance diagram for PF_PU_FirstVertexTracks:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PF_PU_FirstVertexTracks (const edm::ParameterSet &)
 
 ~PF_PU_FirstVertexTracks () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
virtual bool TrackMatch (const reco::Track &, const reco::Track &)
 

Private Attributes

edm::InputTag input_AssociationType_
 
int input_MinQuality_
 
edm::EDGetTokenT< reco::TrackCollectiontoken_generalTracksCollection_
 
edm::EDGetTokenT< TrackToVertexAssMaptoken_TrackToVertexAssMap_
 
edm::EDGetTokenT< reco::VertexCollectiontoken_VertexCollection_
 
edm::EDGetTokenT< VertexToTrackAssMaptoken_VertexToTrackAssMap_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

Definition at line 47 of file PF_PU_FirstVertexTracks.h.

Constructor & Destructor Documentation

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

Definition at line 53 of file PF_PU_FirstVertexTracks.cc.

References gather_cfg::cout, and edm::ParameterSet::getParameter().

54 {
55  //now do what ever other initialization is needed
56 
57  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
58 
59  token_TrackToVertexAssMap_ = mayConsume<TrackToVertexAssMap>(iConfig.getParameter<InputTag>("AssociationMap"));
60  token_VertexToTrackAssMap_ = mayConsume<VertexToTrackAssMap>(iConfig.getParameter<InputTag>("AssociationMap"));
61 
62  token_generalTracksCollection_ = consumes<TrackCollection>(iConfig.getParameter<InputTag>("TrackCollection"));
63 
64  token_VertexCollection_ = mayConsume<VertexCollection>(iConfig.getParameter<InputTag>("VertexCollection"));
65 
66  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
67 
68  //register your products
69 
70  if ( input_AssociationType_.label() == "TracksToVertex" ) {
71  produces<TrackCollection>("T2V");
72  } else {
73  if ( input_AssociationType_.label() == "VertexToTracks" ) {
74  produces<TrackCollection>("V2T");
75  } else {
76  if ( input_AssociationType_.label() == "Both" ) {
77  produces<TrackCollection>("T2V");
78  produces<TrackCollection>("V2T");
79  } else {
80  std::cout << "No correct InputTag for AssociationType!" << std::endl;
81  std::cout << "Won't produce any TrackCollection!" << std::endl;
82  }
83  }
84  }
85 
86 }
T getParameter(std::string const &) const
edm::EDGetTokenT< VertexToTrackAssMap > token_VertexToTrackAssMap_
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< TrackToVertexAssMap > token_TrackToVertexAssMap_
edm::EDGetTokenT< reco::TrackCollection > token_generalTracksCollection_
PF_PU_FirstVertexTracks::~PF_PU_FirstVertexTracks ( )
override

Definition at line 89 of file PF_PU_FirstVertexTracks.cc.

90 {
91 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 
95 }

Member Function Documentation

void PF_PU_FirstVertexTracks::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 233 of file PF_PU_FirstVertexTracks.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

233  {
234  //The following says we do not know what parameters are allowed so do no validation
235  // Please change this to state exactly what you do use, even if it is no parameters
237  desc.setUnknown();
238  descriptions.addDefault(desc);
239 }
void addDefault(ParameterSetDescription const &psetDescription)
void PF_PU_FirstVertexTracks::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 104 of file PF_PU_FirstVertexTracks.cc.

References edm::AssociationMap< Tag >::begin(), gather_cfg::cout, edm::AssociationMap< Tag >::end(), edm::first(), edm::Event::getByToken(), edm::helpers::KeyVal< K, V >::key, eostools::move(), edm::Event::put(), jets_cff::quality, edm::second(), findQualityFiles::size, and edm::helpers::KeyVal< K, V >::val.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

105 {
106 
107  unique_ptr<TrackCollection> t2v_firstvertextracks(new TrackCollection() );
108  unique_ptr<TrackCollection> v2t_firstvertextracks(new TrackCollection() );
109 
110  bool t2vassmap = false;
111  bool v2tassmap = false;
112 
113  //get the input vertex<->general track association map
116 
117  string asstype = input_AssociationType_.label();
118 
119  if ( ( asstype == "TracksToVertex" ) || ( asstype == "Both" ) ) {
120  if ( iEvent.getByToken(token_TrackToVertexAssMap_, t2vAM ) ) {
121  t2vassmap = true;
122  }
123  }
124 
125  if ( ( asstype == "VertexToTracks" ) || ( asstype == "Both" ) ) {
126  if ( iEvent.getByToken(token_VertexToTrackAssMap_, v2tAM ) ) {
127  v2tassmap = true;
128  }
129  }
130 
131  if ( !t2vassmap && !v2tassmap ) {
132  cout << "No input collection could be found" << endl;
133  return;
134  }
135 
136  //get the input track collection
137  Handle<TrackCollection> input_trckcollH;
138  iEvent.getByToken(token_generalTracksCollection_,input_trckcollH);
139 
140  if ( t2vassmap ){
141 
142  const TrackQualityPairVector trckcoll = t2vAM->begin()->val;
143 
144  //get the tracks associated to the first vertex and store them in a track collection
145  for (unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++){
146 
147  float quality = trckcoll[trckcoll_ite].second;
148 
149  if ( quality>=input_MinQuality_ ) {
150 
151  TrackRef AMtrkref = trckcoll[trckcoll_ite].first;
152 
153  for(unsigned int index_input_trck=0; index_input_trck<input_trckcollH->size(); index_input_trck++){
154 
155  TrackRef input_trackref = TrackRef(input_trckcollH,index_input_trck);
156 
157  if( TrackMatch(*AMtrkref,*input_trackref) ){
158 
159  t2v_firstvertextracks->push_back(*AMtrkref);
160  break;
161 
162  }
163 
164  }
165 
166  }
167 
168  }
169 
170  iEvent.put(std::move(t2v_firstvertextracks), "T2V" );
171 
172  }
173 
174  if ( v2tassmap ) {
175 
176  //get the input vertex collection
177  Handle<VertexCollection> input_vtxcollH;
178  iEvent.getByToken(token_VertexCollection_,input_vtxcollH);
179 
180  VertexRef firstVertexRef(input_vtxcollH,0);
181 
183 
184  for(v2t_ite=v2tAM->begin(); v2t_ite!=v2tAM->end(); v2t_ite++){
185 
186  TrackRef AMtrkref = v2t_ite->key;
187 
188  for(unsigned int index_input_trck=0; index_input_trck<input_trckcollH->size(); index_input_trck++){
189 
190  TrackRef input_trackref = TrackRef(input_trckcollH,index_input_trck);
191 
192  if(TrackMatch(*AMtrkref,*input_trackref)){
193 
194  for(unsigned v_ite = 0; v_ite<(v2t_ite->val).size(); v_ite++){
195 
196  VertexRef vtxref = (v2t_ite->val)[v_ite].first;
197  float quality = (v2t_ite->val)[v_ite].second;
198 
199  if ( (vtxref==firstVertexRef) && (quality>=input_MinQuality_) ){
200  v2t_firstvertextracks->push_back(*AMtrkref);
201  }
202 
203  }
204 
205  }
206 
207  }
208 
209  }
210 
211  iEvent.put(std::move(v2t_firstvertextracks), "V2T" );
212 
213  }
214 
215 }
size
Write out results.
std::vector< TrackQualityPair > TrackQualityPairVector
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< VertexToTrackAssMap > token_VertexToTrackAssMap_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:21
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< TrackToVertexAssMap > token_TrackToVertexAssMap_
edm::EDGetTokenT< reco::TrackCollection > token_generalTracksCollection_
const_iterator begin() const
first iterator over the map (read only)
def move(src, dest)
Definition: eostools.py:510
virtual bool TrackMatch(const reco::Track &, const reco::Track &)
bool PF_PU_FirstVertexTracks::TrackMatch ( const reco::Track track1,
const reco::Track track2 
)
privatevirtual

Definition at line 218 of file PF_PU_FirstVertexTracks.cc.

References vertices_cff::chi2, PVValHelper::eta, ndof, and AlCaHLTBitMon_ParallelJobs::p.

219 {
220 
221  return (
222  (track1).eta() == (track2).eta() &&
223  (track1).phi() == (track2).phi() &&
224  (track1).chi2() == (track2).chi2() &&
225  (track1).ndof() == (track2).ndof() &&
226  (track1).p() == (track2).p()
227  );
228 
229 }

Member Data Documentation

edm::InputTag PF_PU_FirstVertexTracks::input_AssociationType_
private

Definition at line 60 of file PF_PU_FirstVertexTracks.h.

int PF_PU_FirstVertexTracks::input_MinQuality_
private

Definition at line 67 of file PF_PU_FirstVertexTracks.h.

edm::EDGetTokenT<reco::TrackCollection> PF_PU_FirstVertexTracks::token_generalTracksCollection_
private

Definition at line 64 of file PF_PU_FirstVertexTracks.h.

edm::EDGetTokenT<TrackToVertexAssMap> PF_PU_FirstVertexTracks::token_TrackToVertexAssMap_
private

Definition at line 62 of file PF_PU_FirstVertexTracks.h.

edm::EDGetTokenT<reco::VertexCollection> PF_PU_FirstVertexTracks::token_VertexCollection_
private

Definition at line 65 of file PF_PU_FirstVertexTracks.h.

edm::EDGetTokenT<VertexToTrackAssMap> PF_PU_FirstVertexTracks::token_VertexToTrackAssMap_
private

Definition at line 63 of file PF_PU_FirstVertexTracks.h.