File indexing completed on 2024-06-22 02:24:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/stream/EDProducer.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/FileInPath.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0021 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0022 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0023 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0024 #include "MagneticField/Engine/interface/MagneticField.h"
0025 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0026 #include "RecoParticleFlow/PFTracking/interface/PFDisplacedVertexFinder.h"
0027
0028 class PFDisplacedVertexProducer : public edm::stream::EDProducer<> {
0029 public:
0030 explicit PFDisplacedVertexProducer(const edm::ParameterSet&);
0031
0032 ~PFDisplacedVertexProducer() override;
0033
0034 void produce(edm::Event&, const edm::EventSetup&) override;
0035 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0036
0037 private:
0038
0039
0040 const edm::EDGetTokenT<reco::PFDisplacedVertexCandidateCollection> inputTagVertexCandidates_;
0041
0042
0043
0044 const edm::EDGetTokenT<reco::VertexCollection> inputTagMainVertex_;
0045 const edm::EDGetTokenT<reco::BeamSpot> inputTagBeamSpot_;
0046
0047 const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0048 const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> globTkGeomToken_;
0049 const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tkerTopoToken_;
0050 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkerGeomToken_;
0051
0052
0053 bool verbose_;
0054
0055
0056 PFDisplacedVertexFinder pfDisplacedVertexFinder_;
0057 };
0058
0059 #include "FWCore/Framework/interface/MakerMacros.h"
0060 DEFINE_FWK_MODULE(PFDisplacedVertexProducer);
0061
0062 void PFDisplacedVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0063 edm::ParameterSetDescription desc;
0064 desc.add<edm::InputTag>("vertexCandidatesLabel", {"particleFlowDisplacedVertexCandidate"});
0065
0066 desc.addUntracked<bool>("verbose", false);
0067
0068 desc.addUntracked<bool>("debug", false);
0069
0070 desc.add<double>("transvSize", 1.0);
0071
0072 desc.add<double>("longSize", 5);
0073
0074
0075 desc.add<double>("primaryVertexCut", 1.8);
0076
0077
0078 desc.add<double>("tobCut", 100);
0079
0080
0081 desc.add<double>("tecCut", 220);
0082
0083
0084
0085 desc.add<double>("minAdaptWeight", 0.5);
0086
0087
0088 desc.addUntracked<bool>("switchOff2TrackVertex", true);
0089
0090
0091 desc.add<edm::InputTag>("mainVertexLabel", {"offlinePrimaryVertices", ""});
0092 desc.add<edm::InputTag>("offlineBeamSpotLabel", {"offlineBeamSpot", ""});
0093
0094 {
0095 edm::ParameterSetDescription pset;
0096 pset.add<bool>("bSelectTracks", true);
0097
0098 pset.add<std::string>("quality", "HighPurity");
0099
0100
0101 pset.add<double>("nChi2_max", 5.);
0102 pset.add<double>("pt_min", 0.2);
0103
0104
0105 pset.add<double>("nChi2_min", 0.5);
0106
0107 pset.add<double>("dxy_min", 0.2);
0108 pset.add<int>("nHits_min", 6);
0109 pset.add<int>("nOuterHits_max", 9);
0110 desc.add<edm::ParameterSetDescription>("tracksSelectorParameters", pset);
0111 }
0112
0113 {
0114 edm::ParameterSetDescription pset;
0115 pset.add<bool>("bIdentifyVertices", true);
0116
0117
0118
0119 pset.add<double>("pt_min", 0.5);
0120
0121
0122 pset.add<double>("pt_kink_min", 3.0);
0123 pset.add<double>("logPrimSec_min", 0.0);
0124
0125 pset.add<double>("looper_eta_max", 0.1);
0126
0127
0128 pset.add<std::vector<double>>("masses", {0.050, 0.485, 0.515, 0.480, 0.520, 1.107, 1.125, 0.200});
0129
0130
0131
0132 pset.add<std::vector<double>>("angles", {15, 15});
0133 desc.add<edm::ParameterSetDescription>("vertexIdentifierParameters", pset);
0134 }
0135
0136
0137
0138 {
0139 edm::ParameterSetDescription pset;
0140 pset.add<double>("sigmacut", 6.);
0141 pset.add<double>("Tini", 256.);
0142 pset.add<double>("ratio", 0.25);
0143 desc.add<edm::ParameterSetDescription>("avfParameters", pset);
0144 }
0145 descriptions.add("particleFlowDisplacedVertex", desc);
0146 }
0147
0148 using namespace std;
0149 using namespace edm;
0150
0151 PFDisplacedVertexProducer::PFDisplacedVertexProducer(const edm::ParameterSet& iConfig)
0152 : inputTagVertexCandidates_(consumes<reco::PFDisplacedVertexCandidateCollection>(
0153 iConfig.getParameter<InputTag>("vertexCandidatesLabel"))),
0154 inputTagMainVertex_(consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"))),
0155 inputTagBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<InputTag>("offlineBeamSpotLabel"))),
0156 magFieldToken_(esConsumes()),
0157 globTkGeomToken_(esConsumes()),
0158 tkerTopoToken_(esConsumes()),
0159 tkerGeomToken_(esConsumes()) {
0160
0161
0162 verbose_ = iConfig.getUntrackedParameter<bool>("verbose");
0163
0164 bool debug = iConfig.getUntrackedParameter<bool>("debug");
0165
0166
0167
0168
0169
0170 double transvSize = iConfig.getParameter<double>("transvSize");
0171
0172
0173
0174 double longSize = iConfig.getParameter<double>("longSize");
0175
0176
0177
0178 double primaryVertexCut = iConfig.getParameter<double>("primaryVertexCut");
0179
0180
0181
0182
0183
0184 double tobCut = iConfig.getParameter<double>("tobCut");
0185
0186
0187
0188 double tecCut = iConfig.getParameter<double>("tecCut");
0189
0190
0191
0192 double minAdaptWeight = iConfig.getParameter<double>("minAdaptWeight");
0193
0194 bool switchOff2TrackVertex = iConfig.getUntrackedParameter<bool>("switchOff2TrackVertex");
0195
0196 edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
0197 edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
0198 edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
0199
0200 produces<reco::PFDisplacedVertexCollection>();
0201
0202
0203 pfDisplacedVertexFinder_.setDebug(debug);
0204 pfDisplacedVertexFinder_.setParameters(
0205 transvSize, longSize, primaryVertexCut, tobCut, tecCut, minAdaptWeight, switchOff2TrackVertex);
0206 pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
0207 pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
0208 pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
0209 }
0210
0211 PFDisplacedVertexProducer::~PFDisplacedVertexProducer() {}
0212
0213 void PFDisplacedVertexProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0214 LogDebug("PFDisplacedVertexProducer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0215
0216
0217
0218 auto const& theMagField = &iSetup.getData(magFieldToken_);
0219 auto const& globTkGeom = &iSetup.getData(globTkGeomToken_);
0220 auto const& tkerTopo = &iSetup.getData(tkerTopoToken_);
0221 auto const& tkerGeom = &iSetup.getData(tkerGeomToken_);
0222
0223 auto const& vertexCandidates = iEvent.getHandle(inputTagVertexCandidates_);
0224 auto const& mainVertexHandle = iEvent.getHandle(inputTagMainVertex_);
0225 auto const& beamSpotHandle = iEvent.getHandle(inputTagBeamSpot_);
0226
0227
0228 pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeom, tkerTopo, tkerGeom);
0229 pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
0230 pfDisplacedVertexFinder_.setInput(vertexCandidates);
0231
0232
0233 pfDisplacedVertexFinder_.findDisplacedVertices();
0234
0235 if (verbose_) {
0236 ostringstream str;
0237 str << pfDisplacedVertexFinder_;
0238 edm::LogInfo("PFDisplacedVertexProducer") << str.str();
0239 }
0240
0241 std::unique_ptr<reco::PFDisplacedVertexCollection> pOutputDisplacedVertexCollection(
0242 pfDisplacedVertexFinder_.transferDisplacedVertices());
0243
0244 iEvent.put(std::move(pOutputDisplacedVertexCollection));
0245
0246 LogDebug("PFDisplacedVertexProducer") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0247 }