CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFDisplacedVertexProducer.cc
Go to the documentation of this file.
2 
4 
8 
10 
13 
18 
21 
22 #include <set>
23 
24 using namespace std;
25 using namespace edm;
26 
28 
29  // --- Setup input collection names --- //
30 
31  inputTagVertexCandidates_= consumes<reco::PFDisplacedVertexCandidateCollection>(iConfig.getParameter<InputTag>("vertexCandidatesLabel"));
32 
33  inputTagMainVertex_ = consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"));
34 
35 
36  inputTagBeamSpot_ =consumes<reco::BeamSpot> (iConfig.getParameter<InputTag>("offlineBeamSpotLabel"));
37 
38  verbose_ =
39  iConfig.getUntrackedParameter<bool>("verbose");
40 
41  bool debug =
42  iConfig.getUntrackedParameter<bool>("debug");
43 
44  // ------ Algo Parameters ------ //
45 
46  // Maximal transverse distance between two minimal
47  // approach points to be used together
48  double transvSize
49  = iConfig.getParameter< double >("transvSize");
50 
51  // Maximal longitudinal distance between two minimal
52  // approach points to be used together
53  double longSize
54  = iConfig.getParameter< double >("longSize");
55 
56  // Minimal radius below which we do not reconstruct interactions
57  // Typically the position of the first Pixel layer
58  double primaryVertexCut
59  = iConfig.getParameter< double >("primaryVertexCut");
60 
61  // Radius at which no secondary tracks are availables
62  // in the barrel.For the moment we exclude the TOB barrel
63  // since 5-th track step starts the latest at first TOB
64  // layer.
65  double tobCut
66  = iConfig.getParameter< double >("tobCut");
67 
68  // Radius at which no secondary tracks are availables
69  // in the endcaps.For the moment we exclude the TEC wheel.
70  double tecCut
71  = iConfig.getParameter< double >("tecCut");
72 
73  // The minimal accepted weight for the tracks calculated in the
74  // adaptive vertex fitter to be associated to the displaced vertex
75  double minAdaptWeight
76  = iConfig.getParameter< double >("minAdaptWeight");
77 
78  bool switchOff2TrackVertex
79  = iConfig.getUntrackedParameter< bool >("switchOff2TrackVertex");
80 
81  edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
82  edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
83  edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
84 
85  produces<reco::PFDisplacedVertexCollection>();
86 
87  // Vertex Finder parameters -----------------------------------
88  pfDisplacedVertexFinder_.setDebug(debug);
89  pfDisplacedVertexFinder_.setParameters(transvSize, longSize,
90  primaryVertexCut, tobCut,
91  tecCut, minAdaptWeight, switchOff2TrackVertex);
92  pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
93  pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
94  pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
95 
96 }
97 
98 
99 
101 
102 
103 
104 void
106  const EventSetup& iSetup) {
107 
108  LogDebug("PFDisplacedVertexProducer")<<"START event: "<<iEvent.id().event()
109  <<" in run "<<iEvent.id().run()<<endl;
110 
111  // Prepare useful information for the Finder
112 
113  ESHandle<MagneticField> magField;
114  iSetup.get<IdealMagneticFieldRecord>().get(magField);
115  const MagneticField* theMagField = magField.product();
116 
117  ESHandle<GlobalTrackingGeometry> globTkGeomHandle;
118  iSetup.get<GlobalTrackingGeometryRecord>().get(globTkGeomHandle);
119 
120  ESHandle<TrackerGeometry> tkerGeomHandle;
121  iSetup.get<TrackerDigiGeometryRecord>().get(tkerGeomHandle);
122 
124  iEvent.getByToken(inputTagVertexCandidates_, vertexCandidates);
125 
126  Handle< reco::VertexCollection > mainVertexHandle;
127  iEvent.getByToken(inputTagMainVertex_, mainVertexHandle);
128 
129  Handle< reco::BeamSpot > beamSpotHandle;
130  iEvent.getByToken(inputTagBeamSpot_, beamSpotHandle);
131 
132  // Fill useful event information for the Finder
133  pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeomHandle, tkerGeomHandle);
134  pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
135  pfDisplacedVertexFinder_.setInput(vertexCandidates);
136 
137  // Run the finder
138  pfDisplacedVertexFinder_.findDisplacedVertices();
139 
140 
141  if(verbose_) {
142  ostringstream str;
143  //str<<pfDisplacedVertexFinder_<<endl;
144  cout << pfDisplacedVertexFinder_<<endl;
145  LogInfo("PFDisplacedVertexProducer") << str.str()<<endl;
146  }
147 
148 
149  auto_ptr< reco::PFDisplacedVertexCollection >
150  pOutputDisplacedVertexCollection(
151  pfDisplacedVertexFinder_.transferDisplacedVertices() );
152 
153 
154 
155  iEvent.put(pOutputDisplacedVertexCollection);
156 
157  LogDebug("PFDisplacedVertexProducer")<<"STOP event: "<<iEvent.id().event()
158  <<" in run "<<iEvent.id().run()<<endl;
159 
160 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
PFDisplacedVertexProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
#define debug
Definition: HDRShower.cc:19
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
virtual void produce(edm::Event &, const edm::EventSetup &) override
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121