CMS 3D CMS Logo

HITrackingRegionProducer.h
Go to the documentation of this file.
1 #ifndef RecoHI_HiTracking_HITrackingRegionProducer_H
2 #define RecoHI_HiTracking_HITrackingRegionProducer_H
3 
6 
20 
21 #include "TMath.h"
22 
24 public:
27  edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet");
28 
29  thePtMin = regionPSet.getParameter<double>("ptMin");
30  theOriginRadius = regionPSet.getParameter<double>("originRadius");
31  theOriginHalfLength = regionPSet.getParameter<double>("originHalfLength");
32  double xPos = regionPSet.getParameter<double>("originXPos");
33  double yPos = regionPSet.getParameter<double>("originYPos");
34  double zPos = regionPSet.getParameter<double>("originZPos");
35  double xDir = regionPSet.getParameter<double>("directionXCoord");
36  double yDir = regionPSet.getParameter<double>("directionYCoord");
37  double zDir = regionPSet.getParameter<double>("directionZCoord");
38  thePrecise = regionPSet.getParameter<bool>("precise");
39  theSiPixelRecHits = regionPSet.getParameter<edm::InputTag>("siPixelRecHits");
41  theOrigin = GlobalPoint(xPos, yPos, zPos);
42  theDirection = GlobalVector(xDir, yDir, zDir);
43  if (thePrecise) {
44  theMSMakerToken = iC.esConsumes();
45  }
46  }
47 
48  ~HITrackingRegionProducer() override = default;
49 
50  int estimateMultiplicity(const edm::Event& ev, const edm::EventSetup& es) const {
51  //rechits
53  ev.getByToken(theSiPixelRecHitsToken, recHitColl);
54 
55  //Retrieve tracker topology from geometry
56  const auto& tTopo = es.getData(theTtopoToken);
57 
58  int numRecHits = 0;
59  //FIXME: this can be optimized quite a bit by looping only on the per-det 'items' of DetSetVector
60  for (SiPixelRecHitCollection::const_iterator recHitIdIterator = recHitColl->begin(),
61  recHitIdIteratorEnd = recHitColl->end();
62  recHitIdIterator != recHitIdIteratorEnd;
63  recHitIdIterator++) {
64  SiPixelRecHitCollection::DetSet hits = *recHitIdIterator;
65  DetId detId = DetId(hits.detId()); // Get the Detid object
66  unsigned int detType = detId.det(); // det type, tracker=1
67  unsigned int subid = detId.subdetId(); //subdetector type, barrel=1, fpix=2
68 
69  unsigned int layer = 0;
70  layer = tTopo.pxbLayer(detId);
71  if (detType == 1 && subid == 1 && layer == 1) {
72  numRecHits += hits.size();
73  }
74  }
75  return numRecHits;
76  }
77 
78  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& ev,
79  const edm::EventSetup& es) const override {
80  int estMult = estimateMultiplicity(ev, es);
81 
82  // fit from MC information
83  float aa = 1.90935e-04;
84  float bb = -2.90167e-01;
85  float cc = 3.86125e+02;
86 
87  float estTracks = aa * estMult * estMult + bb * estMult + cc;
88 
89  LogTrace("heavyIonHLTVertexing") << "[HIVertexing]";
90  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: hits in the 1. layer:" << estMult << "]";
91  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: estimated number of tracks:" << estTracks << "]";
92 
93  float regTracking = 400.; //if we have more tracks -> regional tracking
94  float etaB = 10.;
95  float phiB = TMath::Pi() / 2.;
96 
97  float decEta = estTracks / 600.;
98  etaB = 2.5 / decEta;
99 
100  if (estTracks > regTracking) {
101  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Regional Tracking]";
102  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: eta range: -" << etaB << ", " << etaB << "]";
103  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: phi range: -" << phiB << ", " << phiB << "]";
104  LogTrace("heavyIonHLTVertexing") << " [Regional Tracking: factor of decrease: " << decEta * 2.
105  << "]"; // 2:from phi
106  }
107 
108  // tracking region selection
109  std::vector<std::unique_ptr<TrackingRegion> > result;
110  if (estTracks > regTracking) { // regional tracking
111  const auto& field = es.getData(theFieldToken);
112  const MultipleScatteringParametrisationMaker* msmaker = nullptr;
113  if (thePrecise) {
114  msmaker = &es.getData(theMSMakerToken);
115  }
116 
117  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(theDirection,
118  theOrigin,
119  thePtMin,
122  etaB,
123  phiB,
124  field,
125  msmaker,
126  thePrecise));
127  } else { // global tracking
128  LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Global Tracking]";
129  result.push_back(std::make_unique<GlobalTrackingRegion>(
131  }
132  return result;
133  }
134 
135 private:
141  double thePtMin;
147 };
148 
149 #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
HITrackingRegionProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< SiPixelRecHitCollection > theSiPixelRecHitsToken
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &es) const override
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
~HITrackingRegionProducer() override=default
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
#define LogTrace(id)
const_iterator end(bool update=false) const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
edm::ESGetToken< TrackerTopology, IdealGeometryRecord > theTtopoToken
int estimateMultiplicity(const edm::Event &ev, const edm::EventSetup &es) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
const_iterator begin(bool update=false) const
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > theMSMakerToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theFieldToken
Global3DVector GlobalVector
Definition: GlobalVector.h:10