CMS 3D CMS Logo

CTPPSPixelLocalTrackProducer.cc
Go to the documentation of this file.
2 
12 
17 
19 
23 
26 
27 #include <memory>
28 
29 #include <string>
30 #include <vector>
31 
33 
35 
37 
40 
42 public:
44 
46 
47  void produce(edm::Event &, const edm::EventSetup &) override;
48  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
49 
50 private:
56 
62  std::vector<uint32_t> listOfAllPlanes_;
63 
64  std::unique_ptr<RPixDetPatternFinder> patternFinder_;
65  std::unique_ptr<RPixDetTrackFinder> trackFinder_;
66 
68 };
69 
70 //------------------------------------------------------------------------------------------------//
71 
74  verbosity_ = parameterSet.getUntrackedParameter<int>("verbosity");
75  maxHitPerRomanPot_ = parameterSet.getParameter<int>("maxHitPerRomanPot");
76  maxHitPerPlane_ = parameterSet.getParameter<int>("maxHitPerPlane");
77  maxTrackPerRomanPot_ = parameterSet.getParameter<int>("maxTrackPerRomanPot");
78  maxTrackPerPattern_ = parameterSet.getParameter<int>("maxTrackPerPattern");
79  numberOfPlanesPerPot_ = parameterSet.getParameter<int>("numberOfPlanesPerPot");
80 
81  std::string patternFinderAlgorithm = parameterSet.getParameter<std::string>("patternFinderAlgorithm");
82  std::string trackFitterAlgorithm = parameterSet.getParameter<std::string>("trackFinderAlgorithm");
83 
84  // pattern algorithm selector
85  if (patternFinderAlgorithm == "RPixRoadFinder") {
86  patternFinder_ = std::make_unique<RPixRoadFinder>(parameterSet);
87  } else {
88  throw cms::Exception("CTPPSPixelLocalTrackProducer")
89  << "Pattern finder algorithm" << patternFinderAlgorithm << " does not exist";
90  }
91 
92  listOfAllPlanes_.reserve(6);
93  for (uint32_t i = 0; i < numberOfPlanesPerPot_; ++i) {
94  listOfAllPlanes_.push_back(i);
95  }
96 
97  //tracking algorithm selector
98  if (trackFitterAlgorithm == "RPixPlaneCombinatoryTracking") {
99  trackFinder_ = std::make_unique<RPixPlaneCombinatoryTracking>(parameterSet);
100  } else {
101  throw cms::Exception("CTPPSPixelLocalTrackProducer")
102  << "Tracking fitter algorithm" << trackFitterAlgorithm << " does not exist";
103  }
104  trackFinder_->setListOfPlanes(listOfAllPlanes_);
105  trackFinder_->initialize();
106 
107  tokenCTPPSPixelRecHit_ = consumes<edm::DetSetVector<CTPPSPixelRecHit>>(edm::InputTag(inputTag_));
108  tokenCTPPSGeometry_ = esConsumes<CTPPSGeometry, VeryForwardRealGeometryRecord>();
109 
110  produces<edm::DetSetVector<CTPPSPixelLocalTrack>>();
111 }
112 
113 //------------------------------------------------------------------------------------------------//
114 
116 
117 //------------------------------------------------------------------------------------------------//
118 
121 
122  desc.add<std::string>("label", "ctppsPixelRecHits")
123  ->setComment("label of the RecHits input for the tracking algorithm");
124  desc.add<std::string>("patternFinderAlgorithm", "RPixRoadFinder")->setComment("algorithm type for pattern finder");
125  desc.add<std::string>("trackFinderAlgorithm", "RPixPlaneCombinatoryTracking")
126  ->setComment("algorithm type for track finder");
127  desc.add<uint>("trackMinNumberOfPoints", 3)->setComment("minimum number of planes to produce a track");
128  desc.addUntracked<int>("verbosity", 0)->setComment("verbosity for track producer");
129  desc.add<double>("maximumChi2OverNDF", 5.)->setComment("maximum Chi2OverNDF for accepting the track");
130  desc.add<double>("maximumXLocalDistanceFromTrack", 0.2)
131  ->setComment("maximum x distance in mm to associate a point not used for fit to the track");
132  desc.add<double>("maximumYLocalDistanceFromTrack", 0.3)
133  ->setComment("maximum y distance in mm to associate a point not used for fit to the track");
134  desc.add<int>("maxHitPerPlane", 20)
135  ->setComment("maximum hits per plane, events with higher number will not be fitted");
136  desc.add<int>("maxHitPerRomanPot", 60)
137  ->setComment("maximum hits per roman pot, events with higher number will not be fitted");
138  desc.add<int>("maxTrackPerRomanPot", 10)
139  ->setComment("maximum tracks per roman pot, events with higher track will not be saved");
140  desc.add<int>("maxTrackPerPattern", 5)
141  ->setComment("maximum tracks per pattern, events with higher track will not be saved");
142  desc.add<int>("numberOfPlanesPerPot", 6)->setComment("number of planes per pot");
143  desc.add<double>("roadRadius", 1.0)->setComment("radius of pattern search window");
144  desc.add<int>("minRoadSize", 3)->setComment("minimum number of points in a pattern");
145  desc.add<int>("maxRoadSize", 20)->setComment("maximum number of points in a pattern");
146 
147  descriptions.add("ctppsPixelLocalTracks", desc);
148 }
149 
150 //------------------------------------------------------------------------------------------------//
151 
153  // Step A: get inputs
154 
158 
159  // get geometry
161  const CTPPSGeometry &geometry = *geometryHandler;
162  geometryWatcher_.check(iSetup);
163 
164  std::vector<CTPPSPixelDetId> listOfPotWithHighOccupancyPlanes;
165  std::map<CTPPSPixelDetId, uint32_t> mapHitPerPot;
166 
167  for (const auto &recHitSet : recHitVector) {
168  if (verbosity_ > 2)
169  edm::LogInfo("CTPPSPixelLocalTrackProducer")
170  << "Hits found in plane = " << recHitSet.detId() << " number = " << recHitSet.size();
171  CTPPSPixelDetId tmpRomanPotId = CTPPSPixelDetId(recHitSet.detId()).rpId();
172  uint32_t hitOnPlane = recHitSet.size();
173 
174  //Get the number of hits per pot
175  if (mapHitPerPot.find(tmpRomanPotId) == mapHitPerPot.end()) {
176  mapHitPerPot[tmpRomanPotId] = hitOnPlane;
177  } else
178  mapHitPerPot[tmpRomanPotId] += hitOnPlane;
179 
180  //check is the plane occupancy is too high and save the corresponding pot
181  if (maxHitPerPlane_ >= 0 && hitOnPlane > (uint32_t)maxHitPerPlane_) {
182  if (verbosity_ > 2)
183  edm::LogInfo("CTPPSPixelLocalTrackProducer")
184  << " ---> To many hits in the plane, pot will be excluded from tracking cleared";
185  listOfPotWithHighOccupancyPlanes.push_back(tmpRomanPotId);
186  }
187  }
188 
189  //remove rechit for pot with too many hits or containing planes with too many hits
190  for (const auto &recHitSet : recHitVector) {
191  const auto tmpDetectorId = CTPPSPixelDetId(recHitSet.detId());
192  const auto tmpRomanPotId = tmpDetectorId.rpId();
193 
194  if ((maxHitPerRomanPot_ >= 0 && mapHitPerPot[tmpRomanPotId] > (uint32_t)maxHitPerRomanPot_) ||
195  find(listOfPotWithHighOccupancyPlanes.begin(), listOfPotWithHighOccupancyPlanes.end(), tmpRomanPotId) !=
196  listOfPotWithHighOccupancyPlanes.end()) {
197  edm::DetSet<CTPPSPixelRecHit> &tmpDetSet = recHitVector[tmpDetectorId];
198  tmpDetSet.clear();
199  }
200  }
201 
203 
204  // Pattern finder
205 
206  patternFinder_->clear();
207  patternFinder_->setHits(&recHitVector);
208  patternFinder_->setGeometry(&geometry);
209  patternFinder_->findPattern();
210  std::vector<RPixDetPatternFinder::Road> patternVector = patternFinder_->getPatterns();
211 
212  //loop on all the patterns
213  int numberOfTracks = 0;
214 
215  for (const auto &pattern : patternVector) {
216  CTPPSPixelDetId firstHitDetId = CTPPSPixelDetId(pattern.at(0).detId);
217  CTPPSPixelDetId romanPotId = firstHitDetId.rpId();
218 
219  std::map<CTPPSPixelDetId, std::vector<RPixDetPatternFinder::PointInPlane>>
220  hitOnPlaneMap; //hit of the pattern organized by plane
221 
222  //loop on all the hits of the pattern
223  for (const auto &hit : pattern) {
224  CTPPSPixelDetId hitDetId = CTPPSPixelDetId(hit.detId);
225  CTPPSPixelDetId tmpRomanPotId = hitDetId.rpId();
226 
227  if (tmpRomanPotId != romanPotId) { //check that the hits belong to the same tracking station
228  throw cms::Exception("CTPPSPixelLocalTrackProducer")
229  << "Hits in the pattern must belong to the same tracking station";
230  }
231 
232  if (hitOnPlaneMap.find(hitDetId) ==
233  hitOnPlaneMap.end()) { //add the plane key in case it is the first hit of that plane
234  std::vector<RPixDetPatternFinder::PointInPlane> hitOnPlane;
235  hitOnPlane.push_back(hit);
236  hitOnPlaneMap[hitDetId] = hitOnPlane;
237  } else
238  hitOnPlaneMap[hitDetId].push_back(hit); //add the hit to an existing plane key
239  }
240 
241  trackFinder_->clear();
242  trackFinder_->setRomanPotId(romanPotId);
243  trackFinder_->setHits(&hitOnPlaneMap);
244  trackFinder_->setGeometry(&geometry);
245  trackFinder_->setZ0(geometry.rpTranslation(romanPotId).z());
246  trackFinder_->findTracks(iEvent.getRun().id().run());
247  std::vector<CTPPSPixelLocalTrack> tmpTracksVector = trackFinder_->getLocalTracks();
248 
249  if (verbosity_ > 2)
250  edm::LogInfo("CTPPSPixelLocalTrackProducer") << "tmpTracksVector = " << tmpTracksVector.size();
251  if (maxTrackPerPattern_ >= 0 && tmpTracksVector.size() > (uint32_t)maxTrackPerPattern_) {
252  if (verbosity_ > 2)
253  edm::LogInfo("CTPPSPixelLocalTrackProducer") << " ---> To many tracks in the pattern, cleared";
254  continue;
255  }
256 
257  for (const auto &track : tmpTracksVector) {
258  ++numberOfTracks;
259  edm::DetSet<CTPPSPixelLocalTrack> &tmpDetSet = foundTracks.find_or_insert(romanPotId);
260  tmpDetSet.push_back(track);
261  }
262  }
263 
264  if (verbosity_ > 1)
265  edm::LogInfo("CTPPSPixelLocalTrackProducer") << "Number of tracks will be saved = " << numberOfTracks;
266 
267  for (const auto &track : foundTracks) {
268  if (verbosity_ > 1)
269  edm::LogInfo("CTPPSPixelLocalTrackProducer")
270  << "Track found in detId = " << track.detId() << " number = " << track.size();
271  if (maxTrackPerRomanPot_ >= 0 && track.size() > (uint32_t)maxTrackPerRomanPot_) {
272  if (verbosity_ > 1)
273  edm::LogInfo("CTPPSPixelLocalTrackProducer") << " ---> Too many tracks in the pot, cleared";
274  CTPPSPixelDetId tmpRomanPotId = CTPPSPixelDetId(track.detId());
275  edm::DetSet<CTPPSPixelLocalTrack> &tmpDetSet = foundTracks[tmpRomanPotId];
276  tmpDetSet.clear();
277  }
278  }
279 
280  iEvent.put(std::make_unique<edm::DetSetVector<CTPPSPixelLocalTrack>>(foundTracks));
281 
282  return;
283 }
284 
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::DetSet::push_back
void push_back(const T &t)
Definition: DetSet.h:66
edm::DetSetVector< CTPPSPixelRecHit >
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
input
static const std::string input
Definition: EdmProvDump.cc:48
CTPPSPixelLocalTrack.h
MessageLogger.h
CTPPSGeometry
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:29
CTPPSPixelLocalTrackProducer::maxHitPerRomanPot_
int maxHitPerRomanPot_
Definition: CTPPSPixelLocalTrackProducer.cc:53
edm::ESWatcher< VeryForwardRealGeometryRecord >
ESHandle.h
edm::DetSet
Definition: DetSet.h:23
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::DetSet::clear
void clear()
Definition: DetSet.h:71
geometry
Definition: geometry.py:1
CTPPSPixelDetId.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CTPPSPixelLocalTrackProducer::trackFinder_
std::unique_ptr< RPixDetTrackFinder > trackFinder_
Definition: CTPPSPixelLocalTrackProducer.cc:65
EDProducer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
CTPPSPixelLocalTrackProducer::maxTrackPerPattern_
int maxTrackPerPattern_
Definition: CTPPSPixelLocalTrackProducer.cc:55
edm::Handle
Definition: AssociativeIterator.h:50
parallelization.uint
uint
Definition: parallelization.py:124
CTPPSPixelRecHit.h
ESGetToken.h
CTPPSPixelLocalTrackProducer::maxHitPerPlane_
int maxHitPerPlane_
Definition: CTPPSPixelLocalTrackProducer.cc:52
MakerMacros.h
CTPPSPixelLocalTrackProducer::~CTPPSPixelLocalTrackProducer
~CTPPSPixelLocalTrackProducer() override
Definition: CTPPSPixelLocalTrackProducer.cc:115
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
RPixDetPatternFinder.h
CTPPSPixelLocalTrackProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CTPPSPixelLocalTrackProducer.cc:152
edm::ESHandle< CTPPSGeometry >
CTPPSPixelLocalTrackProducer::verbosity_
int verbosity_
Definition: CTPPSPixelLocalTrackProducer.cc:51
CTPPSPixelLocalTrackProducer::maxTrackPerRomanPot_
int maxTrackPerRomanPot_
Definition: CTPPSPixelLocalTrackProducer.cc:54
CTPPSPixelLocalTrackProducer::listOfAllPlanes_
std::vector< uint32_t > listOfAllPlanes_
Definition: CTPPSPixelLocalTrackProducer.cc:62
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
CTPPSPixelLocalTrackProducer::CTPPSPixelLocalTrackProducer
CTPPSPixelLocalTrackProducer(const edm::ParameterSet &parameterSet)
Definition: CTPPSPixelLocalTrackProducer.cc:72
edm::ParameterSet
Definition: ParameterSet.h:47
RPixRoadFinder.h
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSPixelLocalTrackProducer::patternFinder_
std::unique_ptr< RPixDetPatternFinder > patternFinder_
Definition: CTPPSPixelLocalTrackProducer.cc:64
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
CTPPSPixelLocalTrackProducer::numberOfPlanesPerPot_
uint32_t numberOfPlanesPerPot_
Definition: CTPPSPixelLocalTrackProducer.cc:61
edm::EventSetup
Definition: EventSetup.h:57
CTPPSPixelLocalTrackProducer::geometryWatcher_
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher_
Definition: CTPPSPixelLocalTrackProducer.cc:60
DetSetVector.h
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
VeryForwardRealGeometryRecord.h
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord >
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
DetId.h
Frameworkfwd.h
ESWatcher.h
Exception
Definition: hltDiff.cc:246
CTPPSPixelLocalTrackProducer::tokenCTPPSPixelRecHit_
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelRecHit > > tokenCTPPSPixelRecHit_
Definition: CTPPSPixelLocalTrackProducer.cc:58
RPixPlaneCombinatoryTracking.h
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
CTPPSPixelLocalTrackProducer
Definition: CTPPSPixelLocalTrackProducer.cc:41
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CTPPSPixelLocalTrackProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSPixelLocalTrackProducer.cc:119
edm::DetSetVector::find_or_insert
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:234
DetSet.h
ParameterSet.h
CTPPSDetId::rpId
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:82
CTPPSPixelLocalTrackProducer::tokenCTPPSGeometry_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > tokenCTPPSGeometry_
Definition: CTPPSPixelLocalTrackProducer.cc:59
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
RPixDetTrackFinder.h
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CTPPSPixelLocalTrackProducer::run
void run(const edm::DetSetVector< CTPPSPixelRecHit > &input, edm::DetSetVector< CTPPSPixelLocalTrack > &output)
CTPPSPixelLocalTrackProducer::inputTag_
edm::InputTag inputTag_
Definition: CTPPSPixelLocalTrackProducer.cc:57