CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TotemRPUVPatternFinder Class Reference

Class to recognize straight line tracks, based on optimized Hough trasform. More...

Inheritance diagram for TotemRPUVPatternFinder:
edm::stream::EDProducer<>

Classes

struct  RPSettings
 block of (exceptional) settings for 1 RP More...
 

Public Member Functions

void produce (edm::Event &e, const edm::EventSetup &c) override
 
 TotemRPUVPatternFinder (const edm::ParameterSet &conf)
 
 ~TotemRPUVPatternFinder () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

void recognizeAndSelect (TotemRPUVPattern::ProjectionType proj, double z0, double threshold, unsigned int planes_required, const edm::DetSetVector< TotemRPRecHit > &hits, edm::DetSet< TotemRPUVPattern > &patterns)
 executes line recognition in a projection More...
 

Private Attributes

edm::EDGetTokenT< edm::DetSetVector< TotemRPRecHit > > detSetVectorTotemRPRecHitToken
 
std::map< unsigned int, RPSettingsexceptionalSettings
 exceptional settings: RP Id –> settings More...
 
edm::ESWatcher< VeryForwardRealGeometryRecordgeometryWatcher
 
FastLineRecognitionlrcgn
 the line recognition algorithm More...
 
double max_a_toFit
 maximal angle (in any projection) to mark candidate as fittable - controls track parallelity More...
 
unsigned int maxHitsPerPlaneToSearch
 above this limit, planes are considered noisy More...
 
unsigned char minPlanesPerProjectionToFit
 minimal required number of active planes per projection to mark track candidate as fittable More...
 
unsigned char minPlanesPerProjectionToSearch
 minimal required number of active planes per projection to even start track recognition More...
 
edm::InputTag tagRecHit
 
double threshold
 minimal weight of (Hough) cluster to accept it as candidate More...
 
unsigned int verbosity
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Class to recognize straight line tracks, based on optimized Hough trasform.

The search is perfomed in global U,V coordinates (wrt. beam). In this way (some of) the alignment corrections can be taken into account.

Definition at line 36 of file TotemRPUVPatternFinder.cc.

Constructor & Destructor Documentation

TotemRPUVPatternFinder::TotemRPUVPatternFinder ( const edm::ParameterSet conf)

Definition at line 95 of file TotemRPUVPatternFinder.cc.

References detSetVectorTotemRPRecHitToken, exceptionalSettings, edm::ParameterSet::getParameter(), TotemRPUVPatternFinder::RPSettings::minPlanesPerProjectionToFit_U, and tagRecHit.

95  :
96  tagRecHit(conf.getParameter<edm::InputTag>("tagRecHit")),
97  verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
98  minPlanesPerProjectionToSearch(conf.getParameter<unsigned int>("minPlanesPerProjectionToSearch")),
99  minPlanesPerProjectionToFit(conf.getParameter<unsigned int>("minPlanesPerProjectionToFit")),
100  maxHitsPerPlaneToSearch(conf.getParameter<unsigned int>("maxHitsPerPlaneToSearch")),
101  lrcgn(new FastLineRecognition(conf.getParameter<double>("clusterSize_a"), conf.getParameter<double>("clusterSize_b"))),
102  threshold(conf.getParameter<double>("threshold")),
103  max_a_toFit(conf.getParameter<double>("max_a_toFit"))
104 {
105  for (const auto &ps : conf.getParameter< vector<ParameterSet> >("exceptionalSettings"))
106  {
107  unsigned int rpId = ps.getParameter<unsigned int>("rpId");
108 
109  RPSettings settings;
110  settings.minPlanesPerProjectionToFit_U = ps.getParameter<unsigned int>("minPlanesPerProjectionToFit_U");
111  settings.minPlanesPerProjectionToFit_V = ps.getParameter<unsigned int>("minPlanesPerProjectionToFit_V");
112  settings.threshold_U = ps.getParameter<double>("threshold_U");
113  settings.threshold_V = ps.getParameter<double>("threshold_V");
114 
115  exceptionalSettings[rpId] = settings;
116  }
117 
118  detSetVectorTotemRPRecHitToken = consumes<edm::DetSetVector<TotemRPRecHit> >(tagRecHit);
119 
120  produces<DetSetVector<TotemRPUVPattern>>();
121 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
FastLineRecognition * lrcgn
the line recognition algorithm
std::map< unsigned int, RPSettings > exceptionalSettings
exceptional settings: RP Id –> settings
double threshold
minimal weight of (Hough) cluster to accept it as candidate
unsigned char minPlanesPerProjectionToFit
minimal required number of active planes per projection to mark track candidate as fittable ...
edm::EDGetTokenT< edm::DetSetVector< TotemRPRecHit > > detSetVectorTotemRPRecHitToken
Class performing optimized hough transform to recognize lines.
unsigned char minPlanesPerProjectionToSearch
minimal required number of active planes per projection to even start track recognition ...
unsigned int maxHitsPerPlaneToSearch
above this limit, planes are considered noisy
double max_a_toFit
maximal angle (in any projection) to mark candidate as fittable - controls track parallelity ...
TotemRPUVPatternFinder::~TotemRPUVPatternFinder ( )
override

Definition at line 125 of file TotemRPUVPatternFinder.cc.

References lrcgn.

126 {
127  delete lrcgn;
128 }
FastLineRecognition * lrcgn
the line recognition algorithm

Member Function Documentation

void TotemRPUVPatternFinder::fillDescriptions ( edm::ConfigurationDescriptions descr)
static

Definition at line 301 of file TotemRPUVPatternFinder.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::addVPSet(), DEFINE_FWK_MODULE, and funct::false.

302 {
304 
305  desc.add<edm::InputTag>( "tagRecHit", edm::InputTag( "totemRPRecHitProducer" ) )
306  ->setComment( "input rechits collection to retrieve" );
307  desc.addUntracked<unsigned int>( "verbosity", 0 );
308  desc.add<unsigned int>( "maxHitsPerPlaneToSearch", 5 )
309  ->setComment( "minimum threshold of hits multiplicity to flag the pattern as dirty" );
310  desc.add<unsigned int>( "minPlanesPerProjectionToSearch", 3 )
311  ->setComment( "minimal number of reasonable (= not empty and not dirty) planes per projection and per RP, to start the pattern search" );
312  desc.add<double>( "clusterSize_a", 0.02 /* rad */ )
313  ->setComment( "(full) cluster size (in rad) in slope-intercept space" );
314  desc.add<double>( "clusterSize_b", 0.3 /* mm */ );
315 
316  desc.add<double>( "threshold", 2.99 )
317  ->setComment( "minimal weight of (Hough) cluster to accept it as candidate\n"
318  " weight of cluster = sum of weights of contributing points\n"
319  " weight of point = sigma0 / sigma_of_point\n"
320  "most often: weight of point ~ 1, thus cluster weight is roughly number of contributing points" );
321 
322  desc.add<unsigned int>( "minPlanesPerProjectionToFit", 3 )
323  ->setComment( "minimal number of planes (in the recognised patterns) per projection and per RP, to tag the candidate as fittable" );
324 
325  desc.add<bool>( "allowAmbiguousCombination", false )
326  ->setComment( "whether to allow combination of most significant U and V pattern, in case there several of them.\n"
327  "don't set it to True, unless you have reason" );
328 
329  desc.add<double>( "max_a_toFit", 10.0 )
330  ->setComment( "maximal angle (in any projection) to mark the candidate as fittable -> controls track parallelity with beam\n"
331  "huge value -> no constraint" );
332 
333  edm::ParameterSetDescription exceptions_validator;
334  exceptions_validator.add<unsigned int>( "rpId" )
335  ->setComment( "RP id according to CTPPSDetId" );
336  exceptions_validator.add<unsigned int>( "minPlanesPerProjectionToFit_U" );
337  exceptions_validator.add<unsigned int>( "minPlanesPerProjectionToFit_V" );
338  exceptions_validator.add<double>( "threshold_U" );
339  exceptions_validator.add<double>( "threshold_V" );
340 
341  std::vector<edm::ParameterSet> exceptions_default;
342  desc.addVPSet( "exceptionalSettings", exceptions_validator, exceptions_default );
343 
344  descr.add( "totemRPUVPatternFinder", desc );
345 }
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void TotemRPUVPatternFinder::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 163 of file TotemRPUVPatternFinder.cc.

References edm::ESWatcher< T >::check(), data, detSetVectorTotemRPRecHitToken, exceptionalSettings, edm::DetSetVector< T >::find_or_insert(), geometry, geometryWatcher, edm::EventSetup::get(), CTPPSGeometry::getRP(), CTPPSDetId::getRPId(), h, input, lrcgn, maxHitsPerPlaneToSearch, minPlanesPerProjectionToFit, minPlanesPerProjectionToSearch, AlCaHLTBitMon_ParallelJobs::p, TotemRPDetId::plane(), edm::ESHandle< T >::product(), TotemRPUVPattern::projU, TotemRPUVPattern::projV, recognizeAndSelect(), FastLineRecognition::resetGeometry(), threshold, DetGeomDesc::translation(), and verbosity.

164 {
165  if (verbosity > 5)
166  LogVerbatim("TotemRPUVPatternFinder")
167  << ">> TotemRPUVPatternFinder::produce " << event.id().run() << ":" << event.id().event();
168 
169  // geometry
171  es.get<VeryForwardRealGeometryRecord>().get(geometry);
172  if (geometryWatcher.check(es))
173  lrcgn->resetGeometry(geometry.product());
174 
175  // get input
177  event.getByToken(detSetVectorTotemRPRecHitToken, input);
178 
179  // prepare output
180  DetSetVector<TotemRPUVPattern> patternsVector;
181 
182  // split input per RP and per U/V projection
183  struct RPData
184  {
185  DetSetVector<TotemRPRecHit> hits_U, hits_V;
186  map<uint8_t, uint16_t> planeOccupancy_U, planeOccupancy_V;
187  };
188  map<unsigned int, RPData> rpData;
189 
190  for (auto &ids : *input)
191  {
192  TotemRPDetId detId(ids.detId());
193  unsigned int plane = detId.plane();
194  bool uDir = detId.isStripsCoordinateUDirection();
195 
196  CTPPSDetId rpId = detId.getRPId();
197 
198  RPData &data = rpData[rpId];
199 
200  for (auto &h : ids)
201  {
202  if (uDir)
203  {
204  auto &ods = data.hits_U.find_or_insert(ids.detId());
205  ods.push_back(h);
206  data.planeOccupancy_U[plane]++;
207  } else {
208  auto &ods = data.hits_V.find_or_insert(ids.detId());
209  ods.push_back(h);
210  data.planeOccupancy_V[plane]++;
211  }
212  }
213  }
214 
215  // track recognition pot by pot
216  for (auto it : rpData)
217  {
218  CTPPSDetId rpId(it.first);
219  RPData &data = it.second;
220 
221  // merge default and exceptional settings (if available)
222  unsigned int minPlanesPerProjectionToFit_U = minPlanesPerProjectionToFit;
223  unsigned int minPlanesPerProjectionToFit_V = minPlanesPerProjectionToFit;
224  double threshold_U = threshold;
225  double threshold_V = threshold;
226 
227  auto setIt = exceptionalSettings.find(rpId);
228  if (setIt != exceptionalSettings.end())
229  {
230  minPlanesPerProjectionToFit_U = setIt->second.minPlanesPerProjectionToFit_U;
231  minPlanesPerProjectionToFit_V = setIt->second.minPlanesPerProjectionToFit_V;
232  threshold_U = setIt->second.threshold_U;
233  threshold_V = setIt->second.threshold_V;
234  }
235 
236  auto &uColl = data.planeOccupancy_U;
237  auto &vColl = data.planeOccupancy_V;
238 
239  if (verbosity > 5)
240  {
241  LogVerbatim("TotemRPUVPatternFinder")
242  << "\tRP " << rpId
243  << "\n\t\tall planes: u = " << uColl.size() << ", v = " << vColl.size();
244  }
245 
246  // count planes with clean data (no showers, noise, ...)
247  unsigned int uPlanes = 0, vPlanes = 0;
248  for (auto pit : uColl)
249  if (pit.second <= maxHitsPerPlaneToSearch)
250  uPlanes++;
251 
252  for (auto pit : vColl)
253  if (pit.second <= maxHitsPerPlaneToSearch)
254  vPlanes++;
255 
256  if (verbosity > 5)
257  LogVerbatim("TotemRPUVPatternFinder") << "\t\tplanes with clean data: u = " << uPlanes << ", v = " << vPlanes;
258 
259  // discard RPs with too few reasonable planes
261  continue;
262 
263  // prepare data containers
264  DetSet<TotemRPUVPattern> &patterns = patternsVector.find_or_insert(rpId);
265 
266  // "typical" z0 for the RP
267  double z0 = geometry->getRP(rpId)->translation().z();
268 
269  // u then v recognition
270  recognizeAndSelect(TotemRPUVPattern::projU, z0, threshold_U, minPlanesPerProjectionToFit_U, data.hits_U, patterns);
271 
272  recognizeAndSelect(TotemRPUVPattern::projV, z0, threshold_V, minPlanesPerProjectionToFit_V, data.hits_V, patterns);
273 
274  if (verbosity > 5)
275  {
276  LogVerbatim("TotemRPUVPatternFinder") << "\t\tpatterns:";
277  for (const auto &p : patterns)
278  {
279  unsigned int n_hits = 0;
280  for (auto &hds : p.getHits())
281  n_hits += hds.size();
282 
283  LogVerbatim("TotemRPUVPatternFinder")
284  << "\t\t\tproj = " << ((p.getProjection() == TotemRPUVPattern::projU) ? "U" : "V")
285  << ", a = " << p.getA()
286  << ", b = " << p.getB()
287  << ", w = " << p.getW()
288  << ", fittable = " << p.getFittable()
289  << ", hits = " << n_hits;
290  }
291  }
292  }
293 
294  // save output
295  event.put(make_unique<DetSetVector<TotemRPUVPattern>>(patternsVector));
296 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
FastLineRecognition * lrcgn
the line recognition algorithm
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
uint32_t plane() const
Definition: TotemRPDetId.h:49
Event setup record containing the real (actual) geometry information.
static std::string const input
Definition: EdmProvDump.cc:44
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:254
std::map< unsigned int, RPSettings > exceptionalSettings
exceptional settings: RP Id –> settings
double threshold
minimal weight of (Hough) cluster to accept it as candidate
void recognizeAndSelect(TotemRPUVPattern::ProjectionType proj, double z0, double threshold, unsigned int planes_required, const edm::DetSetVector< TotemRPRecHit > &hits, edm::DetSet< TotemRPUVPattern > &patterns)
executes line recognition in a projection
unsigned char minPlanesPerProjectionToFit
minimal required number of active planes per projection to mark track candidate as fittable ...
void resetGeometry(const CTPPSGeometry *_g)
DDTranslation translation() const
Definition: DetGeomDesc.h:84
CTPPSDetId getRPId() const
Definition: CTPPSDetId.h:97
edm::EDGetTokenT< edm::DetSetVector< TotemRPRecHit > > detSetVectorTotemRPRecHitToken
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
unsigned char minPlanesPerProjectionToSearch
minimal required number of active planes per projection to even start track recognition ...
ESHandle< TrackerGeometry > geometry
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int maxHitsPerPlaneToSearch
above this limit, planes are considered noisy
T const * product() const
Definition: ESHandle.h:86
const DetGeomDesc * getRP(unsigned int id) const
returns geometry of a RP box
void TotemRPUVPatternFinder::recognizeAndSelect ( TotemRPUVPattern::ProjectionType  proj,
double  z0,
double  threshold,
unsigned int  planes_required,
const edm::DetSetVector< TotemRPRecHit > &  hits,
edm::DetSet< TotemRPUVPattern > &  patterns 
)
private

executes line recognition in a projection

Definition at line 132 of file TotemRPUVPatternFinder.cc.

References FastLineRecognition::getPatterns(), lrcgn, max_a_toFit, AlCaHLTBitMon_ParallelJobs::p, and edm::DetSet< T >::push_back().

Referenced by produce().

135 {
136  // run recognition
137  DetSet<TotemRPUVPattern> newPatterns;
138  lrcgn->getPatterns(hits, z0, threshold_loc, newPatterns);
139 
140  // set pattern properties and copy to the global pattern collection
141  for (auto &p : newPatterns)
142  {
143  p.setProjection(proj);
144 
145  p.setFittable(true);
146 
147  set<unsigned int> planes;
148  for (const auto &ds : p.getHits())
149  planes.insert(TotemRPDetId(ds.detId()).plane());
150 
151  if (planes.size() < planes_required)
152  p.setFittable(false);
153 
154  if (fabs(p.getA()) > max_a_toFit)
155  p.setFittable(false);
156 
157  patterns.push_back(p);
158  }
159 }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
void push_back(const T &t)
Definition: DetSet.h:68
FastLineRecognition * lrcgn
the line recognition algorithm
void getPatterns(const edm::DetSetVector< TotemRPRecHit > &input, double _z0, double threshold, edm::DetSet< TotemRPUVPattern > &patterns)
double max_a_toFit
maximal angle (in any projection) to mark candidate as fittable - controls track parallelity ...

Member Data Documentation

edm::EDGetTokenT<edm::DetSetVector<TotemRPRecHit> > TotemRPUVPatternFinder::detSetVectorTotemRPRecHitToken
private

Definition at line 48 of file TotemRPUVPatternFinder.cc.

Referenced by produce(), and TotemRPUVPatternFinder().

std::map<unsigned int, RPSettings> TotemRPUVPatternFinder::exceptionalSettings
private

exceptional settings: RP Id –> settings

Definition at line 78 of file TotemRPUVPatternFinder.cc.

Referenced by produce(), and TotemRPUVPatternFinder().

edm::ESWatcher<VeryForwardRealGeometryRecord> TotemRPUVPatternFinder::geometryWatcher
private

Definition at line 80 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

FastLineRecognition* TotemRPUVPatternFinder::lrcgn
private

the line recognition algorithm

Definition at line 62 of file TotemRPUVPatternFinder.cc.

Referenced by produce(), recognizeAndSelect(), and ~TotemRPUVPatternFinder().

double TotemRPUVPatternFinder::max_a_toFit
private

maximal angle (in any projection) to mark candidate as fittable - controls track parallelity

Definition at line 68 of file TotemRPUVPatternFinder.cc.

Referenced by recognizeAndSelect().

unsigned int TotemRPUVPatternFinder::maxHitsPerPlaneToSearch
private

above this limit, planes are considered noisy

Definition at line 59 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

unsigned char TotemRPUVPatternFinder::minPlanesPerProjectionToFit
private

minimal required number of active planes per projection to mark track candidate as fittable

Definition at line 56 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

unsigned char TotemRPUVPatternFinder::minPlanesPerProjectionToSearch
private

minimal required number of active planes per projection to even start track recognition

Definition at line 53 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

edm::InputTag TotemRPUVPatternFinder::tagRecHit
private

Definition at line 47 of file TotemRPUVPatternFinder.cc.

Referenced by TotemRPUVPatternFinder().

double TotemRPUVPatternFinder::threshold
private

minimal weight of (Hough) cluster to accept it as candidate

Definition at line 65 of file TotemRPUVPatternFinder.cc.

Referenced by utils.StatisticalTest::get_status(), and produce().

unsigned int TotemRPUVPatternFinder::verbosity
private

Definition at line 50 of file TotemRPUVPatternFinder.cc.

Referenced by produce().