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 
8 
12 
22 
27 {
28 public:
29 
32  {
33  edm::LogInfo ("TrackingRegionsFromBeamSpotAndL2Tau") << "Enter the TrackingRegionsFromBeamSpotAndL2Tau";
34 
35  edm::ParameterSet regionPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
36 
37  m_ptMin = regionPSet.getParameter<double>("ptMin");
38  m_originRadius = regionPSet.getParameter<double>("originRadius");
39  m_originHalfLength = regionPSet.getParameter<double>("originHalfLength");
40  m_deltaEta = regionPSet.getParameter<double>("deltaEta");
41  m_deltaPhi = regionPSet.getParameter<double>("deltaPhi");
42  token_jet = iC.consumes<reco::CandidateView>(regionPSet.getParameter<edm::InputTag>("JetSrc"));
43  m_jetMinPt = regionPSet.getParameter<double>("JetMinPt");
44  m_jetMaxEta = regionPSet.getParameter<double>("JetMaxEta");
45  m_jetMaxN = regionPSet.getParameter<int>("JetMaxN");
46  token_beamSpot = iC.consumes<reco::BeamSpot>(regionPSet.getParameter<edm::InputTag>("beamSpot"));
47  m_precise = regionPSet.getParameter<bool>("precise");
48 
49  if (regionPSet.exists("searchOpt")) m_searchOpt = regionPSet.getParameter<bool>("searchOpt");
50  else m_searchOpt = false;
51 
54  token_measurementTracker = iC.consumes<MeasurementTrackerEvent>(regionPSet.getParameter<edm::InputTag>("measurementTrackerName"));
55  }
56  }
57 
59 
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
62 
63  desc.add<double>("ptMin", 5.0);
64  desc.add<double>("originRadius", 0.2);
65  desc.add<double>("originHalfLength", 24.0);
66  desc.add<double>("deltaEta", 0.3);
67  desc.add<double>("deltaPhi", 0.3);
68  desc.add<edm::InputTag>("JetSrc", edm::InputTag("hltFilterL2EtCutDoublePFIsoTau25Trk5"));
69  desc.add<double>("JetMinPt", 25.0);
70  desc.add<double>("JetMaxEta", 2.1);
71  desc.add<int>("JetMaxN", 10);
72  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
73  desc.add<bool>("precise", true);
74  desc.add<std::string>("howToUseMeasurementTracker", "Never");
75  desc.add<edm::InputTag>("measurementTrackerName", edm::InputTag("MeasurementTrackerEvent"));
76 
77  // Only for backwards-compatibility
79  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
80 
81  descriptions.add("trackingRegionsFromBeamSpotAndL2Tau", descRegion);
82  }
83 
84  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const override
85  {
86  std::vector<std::unique_ptr<TrackingRegion> > result;
87 
88  // use beam spot to pick up the origin
90  e.getByToken( token_beamSpot, bsHandle);
91  if(!bsHandle.isValid()) return result;
92  const reco::BeamSpot & bs = *bsHandle;
93  GlobalPoint origin(bs.x0(), bs.y0(), bs.z0());
94 
95  // pick up the candidate objects of interest
97  e.getByToken( token_jet, objects );
98  size_t n_objects = objects->size();
99  if (n_objects == 0) return result;
100 
101  const MeasurementTrackerEvent *measurementTracker = nullptr;
105  measurementTracker = hmte.product();
106  }
107 
108  // create maximum JetMaxN tracking regions in directions of
109  // highest pt jets that are above threshold and are within allowed eta
110  // (we expect that jet collection was sorted in decreasing pt order)
111  int n_regions = 0;
112  for (size_t i =0; i < n_objects && n_regions < m_jetMaxN; ++i)
113  {
114  const reco::Candidate & jet = (*objects)[i];
115  if ( jet.pt() < m_jetMinPt || std::abs(jet.eta()) > m_jetMaxEta ) continue;
116 
117  GlobalVector direction(jet.momentum().x(), jet.momentum().y(), jet.momentum().z());
118 
119  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
120  direction,
121  origin,
122  m_ptMin,
125  m_deltaEta,
126  m_deltaPhi,
128  m_precise,
129  measurementTracker,
131  ));
132  ++n_regions;
133  }
134  //std::cout<<"nregions = "<<n_regions<<std::endl;
135  return result;
136  }
137 
138 private:
139 
140  float m_ptMin;
143  float m_deltaEta;
144  float m_deltaPhi;
146  float m_jetMinPt;
147  float m_jetMaxEta;
153  bool m_precise;
154 };
155 
156 #endif
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:68
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &e, const edm::EventSetup &es) const override
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
edm::EDGetTokenT< reco::CandidateView > token_jet
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
virtual double eta() const =0
momentum pseudorapidity
T const * product() const
Definition: Handle.h:74
virtual double pt() const =0
transverse momentum
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual Vector momentum() const =0
spatial momentum vector
double y0() const
y coordinate
Definition: BeamSpot.h:66
bool isUninitialized() const
Definition: EDGetToken.h:70
TrackingRegionsFromBeamSpotAndL2Tau(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
double x0() const
x coordinate
Definition: BeamSpot.h:64