CMS 3D CMS Logo

VertexConstraintProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: VertexConstraintProducer
4 // Class: VertexConstraintProducer
5 //
13 //
14 // Original Author: Giuseppe Cerati
15 // Created: Tue Jul 10 15:05:02 CEST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
37 
38 //
39 // class decleration
40 //
41 
43 public:
45  ~VertexConstraintProducer() override = default;
46 
47 private:
48  void produce(edm::StreamID streamid, edm::Event&, const edm::EventSetup&) const override;
49 
50  // ----------member data ---------------------------
53 
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
70  : srcTrkTag_(iConfig.getParameter<edm::InputTag>("srcTrk")),
71  srcVtxTag_(iConfig.getParameter<edm::InputTag>("srcVtx")) {
72  //declare the consumes
73  trkToken_ = consumes<reco::TrackCollection>(edm::InputTag(srcTrkTag_));
74  vtxToken_ = consumes<reco::VertexCollection>(edm::InputTag(srcVtxTag_));
75 
76  //register your products
77  produces<std::vector<VertexConstraint> >();
78  produces<TrackVtxConstraintAssociationCollection>();
79 
80  //now do what ever other initialization is needed
81 }
82 
83 //
84 // member functions
85 //
86 
87 // ------------ method called to produce the data ------------
90  const edm::EventSetup& iSetup) const {
91  using namespace edm;
92 
93  Handle<reco::TrackCollection> theTCollection;
94  iEvent.getByToken(trkToken_, theTCollection);
95 
96  Handle<reco::VertexCollection> theVertexHandle;
97  iEvent.getByToken(vtxToken_, theVertexHandle);
98 
99  edm::RefProd<std::vector<VertexConstraint> > rPairs = iEvent.getRefBeforePut<std::vector<VertexConstraint> >();
100  std::unique_ptr<std::vector<VertexConstraint> > pairs(new std::vector<VertexConstraint>);
101  std::unique_ptr<TrackVtxConstraintAssociationCollection> output(
102  new TrackVtxConstraintAssociationCollection(theTCollection, rPairs));
103 
104  int index = 0;
105 
106  //primary vertex extraction
107 
108  if (!theVertexHandle->empty()) {
109  const reco::Vertex& pv = theVertexHandle->front();
110  for (reco::TrackCollection::const_iterator i = theTCollection->begin(); i != theTCollection->end(); i++) {
111  VertexConstraint tmp(GlobalPoint(pv.x(), pv.y(), pv.z()),
112  GlobalError(pv.covariance(0, 0),
113  pv.covariance(1, 0),
114  pv.covariance(1, 1),
115  pv.covariance(2, 0),
116  pv.covariance(2, 1),
117  pv.covariance(2, 2)));
118  pairs->push_back(tmp);
119  output->insert(reco::TrackRef(theTCollection, index), edm::Ref<std::vector<VertexConstraint> >(rPairs, index));
120  index++;
121  }
122  }
123 
124  iEvent.put(std::move(pairs));
125  iEvent.put(std::move(output));
126 }
127 
128 //define this as a plug-in
edm::RefProd
Definition: EDProductfwd.h:25
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:428
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
VertexConstraintProducer::vtxToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: VertexConstraintProducer.cc:55
VertexConstraintProducer::trkToken_
edm::EDGetTokenT< reco::TrackCollection > trkToken_
Definition: VertexConstraintProducer.cc:52
TrackVtxConstraintAssociationCollection
edm::AssociationMap< edm::OneToOne< reco::TrackCollection, std::vector< VertexConstraint > > > TrackVtxConstraintAssociationCollection
Definition: TrackConstraintAssociation.h:31
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::Handle< reco::TrackCollection >
VertexConstraintProducer::VertexConstraintProducer
VertexConstraintProducer(const edm::ParameterSet &)
Definition: VertexConstraintProducer.cc:69
edm::Ref< TrackCollection >
GlobalError
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
VertexConstraintProducer::srcTrkTag_
const edm::InputTag srcTrkTag_
Definition: VertexConstraintProducer.cc:51
edm::EventSetup
Definition: EventSetup.h:58
VertexConstraintProducer::srcVtxTag_
const edm::InputTag srcVtxTag_
Definition: VertexConstraintProducer.cc:54
InputTag.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
VertexConstraintProducer::~VertexConstraintProducer
~VertexConstraintProducer() override=default
Vertex.h
Frameworkfwd.h
VertexConstraintProducer::produce
void produce(edm::StreamID streamid, edm::Event &, const edm::EventSetup &) const override
Definition: VertexConstraintProducer.cc:88
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ParameterSet.h
EDProducer.h
TrackConstraintAssociation.h
edm::Event
Definition: Event.h:73
VertexConstraint
std::pair< GlobalPoint, GlobalError > VertexConstraint
Definition: TrackConstraintAssociation.h:19
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
VertexConstraintProducer
Definition: VertexConstraintProducer.cc:42