CMS 3D CMS Logo

HITrackingRegionForPrimaryVtxProducer.h
Go to the documentation of this file.
1 #ifndef RecoHI_HiTracking_HITrackingRegionForPrimaryVtxProducer_H
2 #define RecoHI_HiTracking_HITrackingRegionForPrimaryVtxProducer _H
3 
6 
13 
18 
21 
24 
28 
31 
32 #include "TMath.h"
33 
35 public:
38  edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet");
39  thePtMin = regionPSet.getParameter<double>("ptMin");
40  theOriginRadius = regionPSet.getParameter<double>("originRadius");
41  theNSigmaZ = regionPSet.getParameter<double>("nSigmaZ");
42  theBeamSpotTag = regionPSet.getParameter<edm::InputTag>("beamSpot");
44  thePrecise = regionPSet.getParameter<bool>("precise");
45  theSiPixelRecHits = regionPSet.getParameter<edm::InputTag>("siPixelRecHits");
47  doVariablePtMin = regionPSet.getParameter<bool>("doVariablePtMin");
48  double xDir = regionPSet.getParameter<double>("directionXCoord");
49  double yDir = regionPSet.getParameter<double>("directionYCoord");
50  double zDir = regionPSet.getParameter<double>("directionZCoord");
51  theDirection = GlobalVector(xDir, yDir, zDir);
52 
53  // for using vertex instead of beamspot
54  theSigmaZVertex = regionPSet.getParameter<double>("sigmaZVertex");
55  theFixedError = regionPSet.getParameter<double>("fixedError");
56  theUseFoundVertices = regionPSet.getParameter<bool>("useFoundVertices");
57  theUseFixedError = regionPSet.getParameter<bool>("useFixedError");
58  vertexCollName = regionPSet.getParameter<edm::InputTag>("VertexCollection");
60 
61  if (thePrecise) {
62  theMSMakerToken = iC.esConsumes();
63  }
64  }
65 
66  ~HITrackingRegionForPrimaryVtxProducer() override = default;
67 
68  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
70 
71  desc.add<double>("ptMin", 0.7);
72  desc.add<bool>("doVariablePtMin", true);
73  desc.add<double>("originRadius", 0.2);
74  desc.add<double>("nSigmaZ", 3.0);
75  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
76  desc.add<bool>("precise", true);
77  desc.add<bool>("useMultipleScattering", false);
78  desc.add<bool>("useFakeVertices", false);
79  desc.add<edm::InputTag>("siPixelRecHits", edm::InputTag("siPixelRecHits"));
80  desc.add<double>("directionXCoord", 1.0);
81  desc.add<double>("directionYCoord", 1.0);
82  desc.add<double>("directionZCoord", 0.0);
83  desc.add<bool>("useFoundVertices", true);
84  desc.add<edm::InputTag>("VertexCollection", edm::InputTag("hiPixelClusterVertex"));
85  desc.add<bool>("useFixedError", true);
86  desc.add<double>("fixedError", 3.0);
87  desc.add<double>("sigmaZVertex", 3.0);
88 
89  // Only for backwards-compatibility
91  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
92 
93  descriptions.add("hiTrackingRegionFromClusterVtx", descRegion);
94  }
95 
96  int estimateMultiplicity(const edm::Event& ev, const edm::EventSetup& es) const {
97  //rechits
99  ev.getByToken(theSiPixelRecHitsToken, recHitColl);
100 
101  auto const& ttopo = es.getData(theTtopoToken);
102 
103  std::vector<const TrackingRecHit*> theChosenHits;
104  edmNew::copyDetSetRange(*recHitColl, theChosenHits, ttopo.pxbDetIdLayerComparator(1));
105  return theChosenHits.size();
106  }
107 
108  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& ev,
109  const edm::EventSetup& es) const override {
110  int estMult = estimateMultiplicity(ev, es);
111 
112  // from MC relating first layer pixel hits to "findable" sim tracks with pt>1 GeV
113  float cc = -38.6447;
114  float bb = 0.0581765;
115  float aa = 1.34306e-06;
116 
117  float estTracks = aa * estMult * estMult + bb * estMult + cc;
118 
119  LogTrace("heavyIonHLTVertexing") << "[HIVertexing]";
120  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: hits in the 1. layer:" << estMult << "]";
121  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: estimated number of tracks:" << estTracks << "]";
122 
123  float regTracking = 60.; //if we have more tracks -> regional tracking
124  float etaB = 10.;
125  float phiB = TMath::Pi() / 2.;
126 
127  float decEta = estTracks / 90.;
128  etaB = 2.5 / decEta;
129 
130  if (estTracks > regTracking) {
131  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Regional Tracking]";
132  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: eta range: -" << etaB << ", " << etaB << "]";
133  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: phi range: -" << phiB << ", " << phiB << "]";
134  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: factor of decrease: " << decEta * 2.
135  << "]"; // 2:from phi
136  }
137 
138  float minpt = thePtMin;
139  float varPtCutoff = 1500; //cutoff
140  if (doVariablePtMin && estMult < varPtCutoff) {
141  minpt = 0.075;
142  if (estMult > 0)
143  minpt += estMult * (thePtMin - 0.075) / varPtCutoff; // lower ptMin linearly with pixel hit multiplicity
144  }
145 
146  // tracking region selection
147  std::vector<std::unique_ptr<TrackingRegion> > result;
148  double halflength;
149  GlobalPoint origin;
151  ev.getByToken(theBeamSpotToken, bsHandle);
152  if (bsHandle.isValid()) {
153  const reco::BeamSpot& bs = *bsHandle;
154  origin = GlobalPoint(bs.x0(), bs.y0(), bs.z0());
155  halflength = theNSigmaZ * bs.sigmaZ();
156 
157  if (theUseFoundVertices) {
159  ev.getByToken(vertexCollToken, vertexCollection);
160 
161  for (reco::VertexCollection::const_iterator iV = vertexCollection->begin(); iV != vertexCollection->end();
162  iV++) {
163  if (iV->isFake() || !iV->isValid())
164  continue;
165  origin = GlobalPoint(bs.x0(), bs.y0(), iV->z());
166  halflength = (theUseFixedError ? theFixedError : (iV->zError()) * theSigmaZVertex);
167  }
168  }
169 
170  if (estTracks > regTracking) { // regional tracking
171  const auto& field = es.getData(theFieldToken);
172  const MultipleScatteringParametrisationMaker* msmaker = nullptr;
173  if (thePrecise) {
174  msmaker = &es.getData(theMSMakerToken);
175  }
176 
177  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
178  theDirection, origin, thePtMin, theOriginRadius, halflength, etaB, phiB, field, msmaker, thePrecise));
179  } else { // global tracking
180  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Global Tracking]";
181  result.push_back(
182  std::make_unique<GlobalTrackingRegion>(minpt, origin, theOriginRadius, halflength, thePrecise));
183  }
184  }
185  return result;
186  }
187 
188 private:
189  double thePtMin;
191  double theNSigmaZ;
199 
209 };
210 
211 #endif
const double Pi
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void copyDetSetRange(DSTV const &dstv, std::vector< T const *> &v, std::pair< A, B > const &sel)
edm::EDGetTokenT< SiPixelRecHitCollection > theSiPixelRecHitsToken
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
#define LogTrace(id)
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &es) const override
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTtopoToken
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > theMSMakerToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HITrackingRegionForPrimaryVtxProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theFieldToken
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
int estimateMultiplicity(const edm::Event &ev, const edm::EventSetup &es) const
edm::EDGetTokenT< reco::VertexCollection > vertexCollToken
~HITrackingRegionForPrimaryVtxProducer() override=default
Global3DVector GlobalVector
Definition: GlobalVector.h:10