CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 

Private Member Functions

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

Private Attributes

edm::InputTag input_AssociationMap_
 
edm::InputTag input_AssociationType_
 
edm::InputTag input_generalTracksCollection_
 
int input_MinQuality_
 
edm::InputTag input_VertexCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 40 of file PF_PU_FirstVertexTracks.h.

Constructor & Destructor Documentation

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

Definition at line 61 of file PF_PU_FirstVertexTracks.cc.

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

62 {
63  //now do what ever other initialization is needed
64 
65  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
66 
67  input_AssociationMap_ = iConfig.getParameter<InputTag>("AssociationMap");
68 
69  input_generalTracksCollection_ = iConfig.getParameter<InputTag>("TrackCollection");
70 
71  input_VertexCollection_ = iConfig.getParameter<InputTag>("VertexCollection");
72 
73  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
74 
75  //register your products
76 
77  if ( input_AssociationType_.label() == "TracksToVertex" ) {
78  produces<TrackCollection>("T2V");
79  } else {
80  if ( input_AssociationType_.label() == "VertexToTracks" ) {
81  produces<TrackCollection>("V2T");
82  } else {
83  if ( input_AssociationType_.label() == "Both" ) {
84  produces<TrackCollection>("T2V");
85  produces<TrackCollection>("V2T");
86  } else {
87  std::cout << "No correct InputTag for AssociationType!" << std::endl;
88  std::cout << "Won't produce any TrackCollection!" << std::endl;
89  }
90  }
91  }
92 
93 }
T getParameter(std::string const &) const
edm::InputTag input_generalTracksCollection_
std::string const & label() const
Definition: InputTag.h:42
tuple cout
Definition: gather_cfg.py:121
PF_PU_FirstVertexTracks::~PF_PU_FirstVertexTracks ( )

Definition at line 96 of file PF_PU_FirstVertexTracks.cc.

97 {
98 
99  // do anything here that needs to be done at desctruction time
100  // (e.g. close files, deallocate resources etc.)
101 
102 }

Member Function Documentation

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

Definition at line 240 of file PF_PU_FirstVertexTracks.cc.

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

240  {
241  //The following says we do not know what parameters are allowed so do no validation
242  // Please change this to state exactly what you do use, even if it is no parameters
244  desc.setUnknown();
245  descriptions.addDefault(desc);
246 }
void addDefault(ParameterSetDescription const &psetDescription)
void PF_PU_FirstVertexTracks::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 111 of file PF_PU_FirstVertexTracks.cc.

References gather_cfg::cout, edm::first(), edm::Event::getByLabel(), edm::helpers::KeyVal< K, V >::key, edm::Event::put(), edm::second(), findQualityFiles::size, and edm::helpers::KeyVal< K, V >::val.

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

112 {
113 
114  auto_ptr<TrackCollection> t2v_firstvertextracks(new TrackCollection() );
115  auto_ptr<TrackCollection> v2t_firstvertextracks(new TrackCollection() );
116 
117  bool t2vassmap = false;
118  bool v2tassmap = false;
119 
120  //get the input vertex<->general track association map
123 
124  string asstype = input_AssociationType_.label();
125 
126  if ( ( asstype == "TracksToVertex" ) || ( asstype == "Both" ) ) {
127  if ( iEvent.getByLabel(input_AssociationMap_, t2vAM ) ) {
128  t2vassmap = true;
129  }
130  }
131 
132  if ( ( asstype == "VertexToTracks" ) || ( asstype == "Both" ) ) {
133  if ( iEvent.getByLabel(input_AssociationMap_, v2tAM ) ) {
134  v2tassmap = true;
135  }
136  }
137 
138  if ( !t2vassmap && !v2tassmap ) {
139  cout << "No input collection could be found" << endl;
140  return;
141  }
142 
143  //get the input track collection
144  Handle<TrackCollection> input_trckcollH;
145  iEvent.getByLabel(input_generalTracksCollection_,input_trckcollH);
146 
147  if ( t2vassmap ){
148 
149  const TrackQualityPairVector trckcoll = t2vAM->begin()->val;
150 
151  //get the tracks associated to the first vertex and store them in a track collection
152  for (unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++){
153 
154  float quality = trckcoll[trckcoll_ite].second;
155 
156  if ( quality>=input_MinQuality_ ) {
157 
158  TrackRef AMtrkref = trckcoll[trckcoll_ite].first;
159 
160  for(unsigned int index_input_trck=0; index_input_trck<input_trckcollH->size(); index_input_trck++){
161 
162  TrackRef input_trackref = TrackRef(input_trckcollH,index_input_trck);
163 
164  if( TrackMatch(*AMtrkref,*input_trackref) ){
165 
166  t2v_firstvertextracks->push_back(*AMtrkref);
167  break;
168 
169  }
170 
171  }
172 
173  }
174 
175  }
176 
177  iEvent.put( t2v_firstvertextracks, "T2V" );
178 
179  }
180 
181  if ( v2tassmap ) {
182 
183  //get the input vertex collection
184  Handle<VertexCollection> input_vtxcollH;
185  iEvent.getByLabel(input_VertexCollection_,input_vtxcollH);
186 
187  VertexRef firstVertexRef(input_vtxcollH,0);
188 
190 
191  for(v2t_ite=v2tAM->begin(); v2t_ite!=v2tAM->end(); v2t_ite++){
192 
193  TrackRef AMtrkref = v2t_ite->key;
194 
195  for(unsigned int index_input_trck=0; index_input_trck<input_trckcollH->size(); index_input_trck++){
196 
197  TrackRef input_trackref = TrackRef(input_trckcollH,index_input_trck);
198 
199  if(TrackMatch(*AMtrkref,*input_trackref)){
200 
201  for(unsigned v_ite = 0; v_ite<(v2t_ite->val).size(); v_ite++){
202 
203  VertexRef vtxref = (v2t_ite->val)[v_ite].first;
204  float quality = (v2t_ite->val)[v_ite].second;
205 
206  if ( (vtxref==firstVertexRef) && (quality>=input_MinQuality_) ){
207  v2t_firstvertextracks->push_back(*AMtrkref);
208  }
209 
210  }
211 
212  }
213 
214  }
215 
216  }
217 
218  iEvent.put( v2t_firstvertextracks, "V2T" );
219 
220  }
221 
222 }
std::vector< TrackQualityPair > TrackQualityPairVector
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
U second(std::pair< T, U > const &p)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag input_generalTracksCollection_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
std::string const & label() const
Definition: InputTag.h:42
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.
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 225 of file PF_PU_FirstVertexTracks.cc.

References eta(), AlCaHLTBitMon_ParallelJobs::p, and phi.

226 {
227 
228  return (
229  (track1).eta() == (track2).eta() &&
230  (track1).phi() == (track2).phi() &&
231  (track1).chi2() == (track2).chi2() &&
232  (track1).ndof() == (track2).ndof() &&
233  (track1).p() == (track2).p()
234  );
235 
236 }
T eta() const
Definition: DDAxes.h:10

Member Data Documentation

edm::InputTag PF_PU_FirstVertexTracks::input_AssociationMap_
private

Definition at line 55 of file PF_PU_FirstVertexTracks.h.

edm::InputTag PF_PU_FirstVertexTracks::input_AssociationType_
private

Definition at line 53 of file PF_PU_FirstVertexTracks.h.

edm::InputTag PF_PU_FirstVertexTracks::input_generalTracksCollection_
private

Definition at line 56 of file PF_PU_FirstVertexTracks.h.

int PF_PU_FirstVertexTracks::input_MinQuality_
private

Definition at line 59 of file PF_PU_FirstVertexTracks.h.

edm::InputTag PF_PU_FirstVertexTracks::input_VertexCollection_
private

Definition at line 57 of file PF_PU_FirstVertexTracks.h.