test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

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

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
 TotemRPUVPatternFinder (const edm::ParameterSet &conf)
 
virtual ~TotemRPUVPatternFinder ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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,
RPSettings
exceptionalSettings
 exceptional settings: RP Id –> settings More...
 
edm::ESWatcher
< VeryForwardRealGeometryRecord
geometryWatcher
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 94 of file TotemRPUVPatternFinder.cc.

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

94  :
95  tagRecHit(conf.getParameter<edm::InputTag>("tagRecHit")),
96  verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
97  minPlanesPerProjectionToSearch(conf.getParameter<unsigned int>("minPlanesPerProjectionToSearch")),
98  minPlanesPerProjectionToFit(conf.getParameter<unsigned int>("minPlanesPerProjectionToFit")),
99  maxHitsPerPlaneToSearch(conf.getParameter<unsigned int>("maxHitsPerPlaneToSearch")),
100  lrcgn(new FastLineRecognition(conf.getParameter<double>("clusterSize_a"), conf.getParameter<double>("clusterSize_b"))),
101  threshold(conf.getParameter<double>("threshold")),
102  max_a_toFit(conf.getParameter<double>("max_a_toFit"))
103 {
104  for (const auto &ps : conf.getParameter< vector<ParameterSet> >("exceptionalSettings"))
105  {
106  unsigned int rpId = ps.getParameter<unsigned int>("rpId");
107 
108  RPSettings settings;
109  settings.minPlanesPerProjectionToFit_U = ps.getParameter<unsigned int>("minPlanesPerProjectionToFit_U");
110  settings.minPlanesPerProjectionToFit_V = ps.getParameter<unsigned int>("minPlanesPerProjectionToFit_V");
111  settings.threshold_U = ps.getParameter<double>("threshold_U");
112  settings.threshold_V = ps.getParameter<double>("threshold_V");
113 
114  exceptionalSettings[rpId] = settings;
115  }
116 
117  detSetVectorTotemRPRecHitToken = consumes<edm::DetSetVector<TotemRPRecHit> >(tagRecHit);
118 
119  produces<DetSetVector<TotemRPUVPattern>>();
120 }
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 –&gt; 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 ( )
virtual

Definition at line 124 of file TotemRPUVPatternFinder.cc.

References lrcgn.

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

Member Function Documentation

void TotemRPUVPatternFinder::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 162 of file TotemRPUVPatternFinder.cc.

References edm::ESWatcher< T >::check(), data, detSetVectorTotemRPRecHitToken, exceptionalSettings, edm::DetSetVector< T >::find_or_insert(), geometry, geometryWatcher, edm::EventSetup::get(), h, input, TotemRPDetId::isStripsCoordinateUDirection(), lrcgn, maxHitsPerPlaneToSearch, minPlanesPerProjectionToFit, minPlanesPerProjectionToSearch, AlCaHLTBitMon_ParallelJobs::p, patterns, edm::ESHandle< class >::product(), TotemRPUVPattern::projU, TotemRPUVPattern::projV, TotemRPDetId::rawToDecId(), recognizeAndSelect(), FastLineRecognition::resetGeometry(), TotemRPDetId::rpOfDet(), threshold, and verbosity.

163 {
164  if (verbosity > 5)
165  LogVerbatim("TotemRPUVPatternFinder")
166  << ">> TotemRPUVPatternFinder::produce " << event.id().run() << ":" << event.id().event();
167 
168  // geometry
170  es.get<VeryForwardRealGeometryRecord>().get(geometry);
171  if (geometryWatcher.check(es))
172  lrcgn->resetGeometry(geometry.product());
173 
174  // get input
176  event.getByToken(detSetVectorTotemRPRecHitToken, input);
177 
178  // prepare output
179  DetSetVector<TotemRPUVPattern> patternsVector;
180 
181  // split input per RP and per U/V projection
182  struct RPData
183  {
184  DetSetVector<TotemRPRecHit> hits_U, hits_V;
185  map<uint8_t, uint16_t> planeOccupancy_U, planeOccupancy_V;
186  };
187  map<unsigned int, RPData> rpData;
188 
189  for (auto &ids : *input)
190  {
191  unsigned int detId = TotemRPDetId::rawToDecId(ids.detId());
192  unsigned int rpId = TotemRPDetId::rpOfDet(detId);
193  unsigned int plane = detId % 10;
195 
196  RPData &data = rpData[rpId];
197 
198  for (auto &h : ids)
199  {
200  if (uDir)
201  {
202  auto &ods = data.hits_U.find_or_insert(ids.detId());
203  ods.push_back(h);
204  data.planeOccupancy_U[plane]++;
205  } else {
206  auto &ods = data.hits_V.find_or_insert(ids.detId());
207  ods.push_back(h);
208  data.planeOccupancy_V[plane]++;
209  }
210  }
211  }
212 
213  // track recognition pot by pot
214  for (auto it : rpData)
215  {
216  unsigned int rpId = it.first;
217  RPData &data = it.second;
218 
219  // merge default and exceptional settings (if available)
220  unsigned int minPlanesPerProjectionToFit_U = minPlanesPerProjectionToFit;
221  unsigned int minPlanesPerProjectionToFit_V = minPlanesPerProjectionToFit;
222  double threshold_U = threshold;
223  double threshold_V = threshold;
224 
225  auto setIt = exceptionalSettings.find(rpId);
226  if (setIt != exceptionalSettings.end())
227  {
228  minPlanesPerProjectionToFit_U = setIt->second.minPlanesPerProjectionToFit_U;
229  minPlanesPerProjectionToFit_V = setIt->second.minPlanesPerProjectionToFit_V;
230  threshold_U = setIt->second.threshold_U;
231  threshold_V = setIt->second.threshold_V;
232  }
233 
234  auto &uColl = data.planeOccupancy_U;
235  auto &vColl = data.planeOccupancy_V;
236 
237  if (verbosity > 5)
238  {
239  LogVerbatim("TotemRPUVPatternFinder")
240  << "\tRP " << rpId
241  << "\n\t\tall planes: u = " << uColl.size() << ", v = " << vColl.size();
242  }
243 
244  // count planes with clean data (no showers, noise, ...)
245  unsigned int uPlanes = 0, vPlanes = 0;
246  for (auto pit : uColl)
247  if (pit.second <= maxHitsPerPlaneToSearch)
248  uPlanes++;
249 
250  for (auto pit : vColl)
251  if (pit.second <= maxHitsPerPlaneToSearch)
252  vPlanes++;
253 
254  if (verbosity > 5)
255  LogVerbatim("TotemRPUVPatternFinder") << "\t\tplanes with clean data: u = " << uPlanes << ", v = " << vPlanes;
256 
257  // discard RPs with too few reasonable planes
259  continue;
260 
261  // prepare data containers
262  DetSet<TotemRPUVPattern> &patterns = patternsVector.find_or_insert(rpId);
263 
264  // "typical" z0 for the RP
265  double z0 = geometry->GetRPDevice(rpId)->translation().z();
266 
267  // u then v recognition
268  recognizeAndSelect(TotemRPUVPattern::projU, z0, threshold_U, minPlanesPerProjectionToFit_U, data.hits_U, patterns);
269 
270  recognizeAndSelect(TotemRPUVPattern::projV, z0, threshold_V, minPlanesPerProjectionToFit_V, data.hits_V, patterns);
271 
272  if (verbosity > 5)
273  {
274  LogVerbatim("TotemRPUVPatternFinder") << "\t\tpatterns:";
275  for (const auto &p : patterns)
276  {
277  unsigned int n_hits = 0;
278  for (auto &hds : p.getHits())
279  n_hits += hds.size();
280 
281  LogVerbatim("TotemRPUVPatternFinder")
282  << "\t\t\tproj = " << ((p.getProjection() == TotemRPUVPattern::projU) ? "U" : "V")
283  << ", a = " << p.getA()
284  << ", b = " << p.getB()
285  << ", w = " << p.getW()
286  << ", fittable = " << p.getFittable()
287  << ", hits = " << n_hits;
288  }
289  }
290  }
291 
292  // save output
293  event.put(make_unique<DetSetVector<TotemRPUVPattern>>(patternsVector));
294 }
PhiMemoryImage patterns[9]
FastLineRecognition * lrcgn
the line recognition algorithm
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static unsigned int rpOfDet(unsigned int i)
returns ID of RP for given detector ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:141
void resetGeometry(const TotemRPGeometry *_g)
static unsigned int rawToDecId(unsigned int raw)
fast conversion Raw to Decimal ID
Definition: TotemRPDetId.h:120
bool isStripsCoordinateUDirection() const
Definition: TotemRPDetId.h:95
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 –&gt; 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 ...
edm::EDGetTokenT< edm::DetSetVector< TotemRPRecHit > > detSetVectorTotemRPRecHitToken
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher
T const * product() const
Definition: ESHandle.h:86
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
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
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 131 of file TotemRPUVPatternFinder.cc.

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

Referenced by produce().

134 {
135  // run recognition
136  DetSet<TotemRPUVPattern> newPatterns;
137  lrcgn->getPatterns(hits, z0, threshold_loc, newPatterns);
138 
139  // set pattern properties and copy to the global pattern collection
140  for (auto &p : newPatterns)
141  {
142  p.setProjection(proj);
143 
144  p.setFittable(true);
145 
146  set<unsigned int> planes;
147  for (const auto &ds : p.getHits())
148  planes.insert(TotemRPDetId::rawToDecId(ds.detId()) % 10);
149 
150  if (planes.size() < planes_required)
151  p.setFittable(false);
152 
153  if (fabs(p.getA()) > max_a_toFit)
154  p.setFittable(false);
155 
156  patterns.push_back(p);
157  }
158 }
void push_back(const T &t)
Definition: DetSet.h:68
FastLineRecognition * lrcgn
the line recognition algorithm
static unsigned int rawToDecId(unsigned int raw)
fast conversion Raw to Decimal ID
Definition: TotemRPDetId.h:120
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 47 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 77 of file TotemRPUVPatternFinder.cc.

Referenced by produce(), and TotemRPUVPatternFinder().

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

Definition at line 79 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

FastLineRecognition* TotemRPUVPatternFinder::lrcgn
private

the line recognition algorithm

Definition at line 61 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 67 of file TotemRPUVPatternFinder.cc.

Referenced by recognizeAndSelect().

unsigned int TotemRPUVPatternFinder::maxHitsPerPlaneToSearch
private

above this limit, planes are considered noisy

Definition at line 58 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 55 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 52 of file TotemRPUVPatternFinder.cc.

Referenced by produce().

edm::InputTag TotemRPUVPatternFinder::tagRecHit
private

Definition at line 46 of file TotemRPUVPatternFinder.cc.

Referenced by TotemRPUVPatternFinder().

double TotemRPUVPatternFinder::threshold
private

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

Definition at line 64 of file TotemRPUVPatternFinder.cc.

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

unsigned int TotemRPUVPatternFinder::verbosity
private

Definition at line 49 of file TotemRPUVPatternFinder.cc.

Referenced by produce().