CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TemplatedVertexArbitrator.h
Go to the documentation of this file.
1 #ifndef TemplatedVertexArbitrator_h
2 #define TemplatedVertexArbitrator_h
3 #include <memory>
4 #include <set>
5 
6 
11 
12 
18 
25 
26 
32 
38 
39 
43 
45 
46 //#define VTXDEBUG
47 
48 const unsigned int nTracks(const reco::Vertex & sv) {return sv.nTracks();}
49 const unsigned int nTracks(const reco::VertexCompositePtrCandidate & sv) {return sv.numberOfSourceCandidatePtrs();}
50 
51 template <class InputContainer, class VTX>
53  public:
54  typedef std::vector<VTX> Product;
56 
57 
58  virtual void produce(edm::Event &event, const edm::EventSetup &es) override ;
59 
60  private:
61  bool trackFilter(const reco::TrackRef &track) const;
62 
67  std::unique_ptr<TrackVertexArbitration<VTX> > theArbitrator;
68 };
69 
70 
71 template <class InputContainer, class VTX>
73 {
74  token_primaryVertex = consumes<reco::VertexCollection>(params.getParameter<edm::InputTag>("primaryVertices"));
75  token_secondaryVertex = consumes<Product>(params.getParameter<edm::InputTag>("secondaryVertices"));
76  token_beamSpot = consumes<reco::BeamSpot>(params.getParameter<edm::InputTag>("beamSpot"));
77  token_tracks = consumes<InputContainer>(params.getParameter<edm::InputTag>("tracks"));
78  produces<Product>();
79  theArbitrator.reset( new TrackVertexArbitration<VTX>(params) );
80 }
81 
82 template <class InputContainer, class VTX>
84 {
85  using namespace reco;
86 
88  event.getByToken(token_secondaryVertex, secondaryVertices);
89  Product theSecVertexColl = *(secondaryVertices.product());
90 
92  event.getByToken(token_primaryVertex, primaryVertices);
93 
94  std::auto_ptr<Product> recoVertices(new Product);
95  if(primaryVertices->size()!=0){
96  const reco::Vertex &pv = (*primaryVertices)[0];
97 
99  event.getByToken(token_tracks, tracks);
100 
102  es.get<TransientTrackRecord>().get("TransientTrackBuilder",
103  trackBuilder);
104 
106  event.getByToken(token_beamSpot,beamSpot);
107 
108  std::vector<TransientTrack> selectedTracks;
109  for(typename InputContainer::const_iterator track = tracks->begin();
110  track != tracks->end(); ++track) {
111  selectedTracks.push_back(tthelpers::buildTT(tracks,trackBuilder,track - tracks->begin()));
112  }
113 
114 
115  // const edm::RefVector< TrackCollection > tracksForArbitration= selectedTracks;
116  Product theRecoVertices = theArbitrator->trackVertexArbitrator(beamSpot, pv, selectedTracks,
117  theSecVertexColl);
118 
119  for(unsigned int ivtx=0; ivtx < theRecoVertices.size(); ivtx++){
120  if ( !(nTracks(theRecoVertices[ivtx]) > 1) ) continue;
121  recoVertices->push_back(theRecoVertices[ivtx]);
122  }
123 
124  }
125  event.put(recoVertices);
126 
127 
128 
129 }
130 
131 
132 
133 #endif
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
T getParameter(std::string const &) const
const unsigned int nTracks(const reco::Vertex &sv)
tuple primaryVertices
edm::EDGetTokenT< Product > token_secondaryVertex
virtual void produce(edm::Event &event, const edm::EventSetup &es) override
std::unique_ptr< TrackVertexArbitration< VTX > > theArbitrator
edm::EDGetTokenT< InputContainer > token_tracks
TemplatedVertexArbitrator(const edm::ParameterSet &params)
virtual size_type numberOfSourceCandidatePtrs() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
unsigned int nTracks(float minWeight=0.5) const
Returns the number of tracks in the vertex with weight above minWeight.
Definition: Vertex.cc:132
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:56
bool trackFilter(const reco::TrackRef &track) const
tuple secondaryVertices
reco::TransientTrack buildTT(edm::Handle< reco::TrackCollection > &tracks, edm::ESHandle< TransientTrackBuilder > &trackbuilder, unsigned int k)
Definition: TTHelpers.h:4