CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFDisplacedVertexCandidateProducer.cc
Go to the documentation of this file.
2 
4 
8 
10 
13 
14 
15 #include <set>
16 
17 using namespace std;
18 using namespace edm;
19 
21 
22  // --- Setup input collection names --- //
23  inputTagTracks_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trackCollection"));
24 
25  inputTagMainVertex_=consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"));
26 
27  inputTagBeamSpot_ =consumes<reco::BeamSpot>(iConfig.getParameter<InputTag>("offlineBeamSpotLabel"));
28 
29  verbose_ =
30  iConfig.getUntrackedParameter<bool>("verbose");
31 
32  bool debug =
33  iConfig.getUntrackedParameter<bool>("debug");
34 
35  // ------ Algo Parameters ------ //
36 
37  // Distance of minimal approach below which
38  // two tracks are considered as linked together
39  double dcaCut
40  = iConfig.getParameter< double >("dcaCut");
41 
42  // Do not reconstruct vertices wich are
43  // too close to the beam pipe
44  double primaryVertexCut
45  = iConfig.getParameter< double >("primaryVertexCut");
46 
47  //maximum distance between the DCA Point and the inner hit of the track
48  double dcaPInnerHitCut
49  = iConfig.getParameter< double >("dcaPInnerHitCut");
50 
51  edm::ParameterSet ps_trk
52  = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
53 
54  // Collection to be produced
55  produces<reco::PFDisplacedVertexCandidateCollection>();
56 
57  // Vertex Finder parameters -----------------------------------
58  pfDisplacedVertexCandidateFinder_.setDebug(debug);
59  pfDisplacedVertexCandidateFinder_.setParameters(dcaCut, primaryVertexCut, dcaPInnerHitCut, ps_trk);
60 
61 }
62 
63 
65 
66 
67 void
69  const EventSetup& iSetup) {
70 
71  LogDebug("PFDisplacedVertexCandidateProducer")<<"START event: "<<iEvent.id().event()
72  <<" in run "<<iEvent.id().run()<<endl;
73 
74  // Prepare and fill useful event information for the Finder
76  iSetup.get<IdealMagneticFieldRecord>().get(magField);
77  const MagneticField* theMagField = magField.product();
78 
80  iEvent.getByToken(inputTagTracks_, trackCollection);
81 
82  Handle< reco::VertexCollection > mainVertexHandle;
83  iEvent.getByToken(inputTagMainVertex_, mainVertexHandle);
84 
85  Handle< reco::BeamSpot > beamSpotHandle;
86  iEvent.getByToken(inputTagBeamSpot_, beamSpotHandle);
87 
88  pfDisplacedVertexCandidateFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
89  pfDisplacedVertexCandidateFinder_.setInput( trackCollection, theMagField );
90 
91 
92  // Run the finder
93  pfDisplacedVertexCandidateFinder_.findDisplacedVertexCandidates();
94 
95 
96  if(verbose_) {
97  ostringstream str;
98  str<<pfDisplacedVertexCandidateFinder_<<endl;
99  cout << pfDisplacedVertexCandidateFinder_<<endl;
100  LogInfo("PFDisplacedVertexCandidateProducer") << str.str()<<endl;
101  }
102 
103 
104  auto_ptr< reco::PFDisplacedVertexCandidateCollection >
105  pOutputDisplacedVertexCandidateCollection(
106  pfDisplacedVertexCandidateFinder_.transferVertexCandidates() );
107 
108 
109  iEvent.put(pOutputDisplacedVertexCandidateCollection);
110 
111  LogDebug("PFDisplacedVertexCandidateProducer")<<"STOP event: "<<iEvent.id().event()
112  <<" in run "<<iEvent.id().run()<<endl;
113 
114 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
virtual void produce(edm::Event &, const edm::EventSetup &) override
#define debug
Definition: HDRShower.cc:19
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
edm::EventID id() const
Definition: EventBase.h:60
tuple cout
Definition: gather_cfg.py:121