CMS 3D CMS Logo

TrackingRegionsFromBeamSpotAndL2Tau.h
Go to the documentation of this file.
1 #ifndef TrackingRegionsFromBeamSpotAndL2Tau_h
2 #define TrackingRegionsFromBeamSpotAndL2Tau_h
3 
4 //
5 // Class: TrackingRegionsFromBeamSpotAndL2Tau
6 //
7 
11 
21 
26 public:
28  edm::LogInfo("TrackingRegionsFromBeamSpotAndL2Tau") << "Enter the TrackingRegionsFromBeamSpotAndL2Tau";
29 
30  edm::ParameterSet regionPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
31 
32  m_ptMin = regionPSet.getParameter<double>("ptMin");
33  m_originRadius = regionPSet.getParameter<double>("originRadius");
34  m_originHalfLength = regionPSet.getParameter<double>("originHalfLength");
35  m_deltaEta = regionPSet.getParameter<double>("deltaEta");
36  m_deltaPhi = regionPSet.getParameter<double>("deltaPhi");
37  token_jet = iC.consumes<reco::CandidateView>(regionPSet.getParameter<edm::InputTag>("JetSrc"));
38  m_jetMinPt = regionPSet.getParameter<double>("JetMinPt");
39  m_jetMaxEta = regionPSet.getParameter<double>("JetMaxEta");
40  m_jetMaxN = regionPSet.getParameter<int>("JetMaxN");
41  token_beamSpot = iC.consumes<reco::BeamSpot>(regionPSet.getParameter<edm::InputTag>("beamSpot"));
42  m_precise = regionPSet.getParameter<bool>("precise");
43 
44  if (regionPSet.exists("searchOpt"))
45  m_searchOpt = regionPSet.getParameter<bool>("searchOpt");
46  else
47  m_searchOpt = false;
48 
50  regionPSet.getParameter<std::string>("whereToUseMeasurementTracker"));
53  iC.consumes<MeasurementTrackerEvent>(regionPSet.getParameter<edm::InputTag>("measurementTrackerName"));
54  }
55  token_field = iC.esConsumes();
56  if (m_precise) {
57  token_msmaker = iC.esConsumes();
58  }
59  }
60 
62 
63  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
65 
66  desc.add<double>("ptMin", 5.0);
67  desc.add<double>("originRadius", 0.2);
68  desc.add<double>("originHalfLength", 24.0);
69  desc.add<double>("deltaEta", 0.3);
70  desc.add<double>("deltaPhi", 0.3);
71  desc.add<edm::InputTag>("JetSrc", edm::InputTag("hltFilterL2EtCutDoublePFIsoTau25Trk5"));
72  desc.add<double>("JetMinPt", 25.0);
73  desc.add<double>("JetMaxEta", 2.1);
74  desc.add<int>("JetMaxN", 10);
75  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
76  desc.add<bool>("precise", true);
77  desc.add<std::string>("howToUseMeasurementTracker", "Never");
78  desc.add<edm::InputTag>("measurementTrackerName", edm::InputTag("MeasurementTrackerEvent"));
79 
80  // Only for backwards-compatibility
82  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
83 
84  descriptions.add("trackingRegionsFromBeamSpotAndL2Tau", descRegion);
85  }
86 
87  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const override {
88  std::vector<std::unique_ptr<TrackingRegion> > result;
89 
90  // use beam spot to pick up the origin
92  e.getByToken(token_beamSpot, bsHandle);
93  if (!bsHandle.isValid())
94  return result;
95  const reco::BeamSpot& bs = *bsHandle;
96  GlobalPoint origin(bs.x0(), bs.y0(), bs.z0());
97 
98  // pick up the candidate objects of interest
100  e.getByToken(token_jet, objects);
101  size_t n_objects = objects->size();
102  if (n_objects == 0)
103  return result;
104 
108  e.getByToken(token_measurementTracker, hmte);
109  measurementTracker = hmte.product();
110  }
111 
112  const auto& field = es.getData(token_field);
113  const MultipleScatteringParametrisationMaker* msmaker = nullptr;
114  if (m_precise) {
115  msmaker = &es.getData(token_msmaker);
116  }
117 
118  // create maximum JetMaxN tracking regions in directions of
119  // highest pt jets that are above threshold and are within allowed eta
120  // (we expect that jet collection was sorted in decreasing pt order)
121  int n_regions = 0;
122  for (size_t i = 0; i < n_objects && n_regions < m_jetMaxN; ++i) {
123  const reco::Candidate& jet = (*objects)[i];
124  if (jet.pt() < m_jetMinPt || std::abs(jet.eta()) > m_jetMaxEta)
125  continue;
126 
127  GlobalVector direction(jet.momentum().x(), jet.momentum().y(), jet.momentum().z());
128 
129  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(direction,
130  origin,
131  m_ptMin,
134  m_deltaEta,
135  m_deltaPhi,
136  field,
137  msmaker,
138  m_precise,
141  m_searchOpt));
142  ++n_regions;
143  }
144  //std::cout<<"nregions = "<<n_regions<<std::endl;
145  return result;
146  }
147 
148 private:
149  float m_ptMin;
152  float m_deltaEta;
153  float m_deltaPhi;
155  float m_jetMinPt;
156  float m_jetMaxEta;
164  bool m_precise;
165 };
166 
167 #endif
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > token_msmaker
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool exists(std::string const &parameterName) const
checks if a parameter exists
T const * product() const
Definition: Handle.h:70
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
edm::EDGetTokenT< reco::CandidateView > token_jet
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &e, const edm::EventSetup &es) const override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_field
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
TrackingRegionsFromBeamSpotAndL2Tau(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)