CMS 3D CMS Logo

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

#include <DTClusterer.h>

Inheritance diagram for DTClusterer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  sortClusterByX
 

Public Member Functions

 DTClusterer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &event, const edm::EventSetup &setup)
 
virtual ~DTClusterer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::vector< DTSLRecClusterbuildClusters (const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
 
unsigned int differentLayers (std::vector< DTRecHit1DPair > &hits)
 
std::vector< std::pair< float, DTRecHit1DPair > > initHits (const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
 

Private Attributes

bool debug
 
edm::EDGetTokenT< DTRecHitCollectionrecHits1DToken_
 
unsigned int theMinHits
 
unsigned int theMinLayers
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
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

Description:

detailed description

Author
: Stefano Lacaprara - INFN LNL stefa.nosp@m.no.l.nosp@m.acapr.nosp@m.ara@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t

Modification:

Definition at line 40 of file DTClusterer.h.

Constructor & Destructor Documentation

DTClusterer::DTClusterer ( const edm::ParameterSet pset)

Definition at line 39 of file DTClusterer.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

39  {
40  // Set verbose output
41  debug = pset.getUntrackedParameter<bool>("debug");
42 
43  // the name of the 1D rec hits collection
44  recHits1DToken_ = consumes<DTRecHitCollection>(pset.getParameter<InputTag>("recHits1DLabel"));
45  // min number of hits to build a cluster
46  theMinHits = pset.getParameter<unsigned int>("minHits");
47  // min number of hits to build a cluster
48  theMinLayers = pset.getParameter<unsigned int>("minLayers");
49 
50  if(debug)
51  cout << "[DTClusterer] Constructor called" << endl;
52 
53  produces<DTRecClusterCollection>();
54 }
unsigned int theMinLayers
Definition: DTClusterer.h:77
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
Definition: DTClusterer.h:78
unsigned int theMinHits
Definition: DTClusterer.h:76
DTClusterer::~DTClusterer ( )
virtual

Definition at line 57 of file DTClusterer.cc.

57  {
58 }

Member Function Documentation

vector< DTSLRecCluster > DTClusterer::buildClusters ( const DTSuperLayer sl,
std::vector< DTRecHit1DPair > &  pairs 
)
private

Definition at line 104 of file DTClusterer.cc.

References funct::abs(), gather_cfg::cout, debug, hfClusterShapes_cfi::hits, DTSuperLayer::id(), RecoTauDiscriminantConfiguration::mean, mps_fire::result, and combinedConstraintHelpers::sum2().

105  {
106  // create a vector of hits with wire position in SL frame
107  vector<pair<float, DTRecHit1DPair> > hits = initHits(sl, pairs);
108 
109  vector<DTSLRecCluster> result;
110  // loop over pairs
111  vector<DTRecHit1DPair> adiacentPairs;
112  float lastPos=hits.front().first;
113  const float cellWidth=4.2; // cm
114  float sum=0.;
115  float sum2=0.;
116 
117  for (vector<pair<float, DTRecHit1DPair> >::const_iterator hit=hits.begin(); hit!=hits.end();
118  ++hit) {
119  if(debug) cout << "Hit: " << (*hit).first << " lastPos: " << lastPos << endl;
120  // start from first hits
121  // two cells are adiacente if their position is closer than cell width
122  if(abs((*hit).first-lastPos)>cellWidth ) {
123  if (adiacentPairs.size() >= theMinHits && differentLayers(adiacentPairs)>=theMinLayers) {
124  // if not, build the cluster with so far collection hits and go on
125  float mean=sum/adiacentPairs.size();
126  float err2=sum2/adiacentPairs.size()-mean*mean;
127  DTSLRecCluster cluster(sl->id(),
128  LocalPoint(mean,0.,0.),
129  LocalError(err2,0.,0.),
130  adiacentPairs);
131  if(debug) cout << "Cluster " << cluster << endl;
132  result.push_back(cluster);
133  }
134  // clean the vector
135  adiacentPairs.clear();
136  sum=0.;
137  sum2=0.;
138  }
139  // if adiacente, add them to a vector
140  adiacentPairs.push_back((*hit).second);
141  if(debug) cout << "adiacentPairs " << adiacentPairs.size() << endl;
142  sum+=(*hit).first;
143  sum2+=(*hit).first*(*hit).first;
144 
145  lastPos=(*hit).first;
146  }
147  // build the last cluster
148  if (adiacentPairs.size() >= theMinHits && differentLayers(adiacentPairs)>=theMinLayers) {
149  float mean=sum/adiacentPairs.size();
150  float err2=sum2/adiacentPairs.size()-mean*mean;
151  DTSLRecCluster cluster(sl->id(),
152  LocalPoint(mean,0.,0.),
153  LocalError(err2,0.,0.),
154  adiacentPairs);
155  if(debug) cout << "Cluster " << cluster << endl;
156  result.push_back(cluster);
157  }
158 
159  return result;
160 }
unsigned int theMinLayers
Definition: DTClusterer.h:77
unsigned int differentLayers(std::vector< DTRecHit1DPair > &hits)
Definition: DTClusterer.cc:185
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
unsigned int theMinHits
Definition: DTClusterer.h:76
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::pair< float, DTRecHit1DPair > > initHits(const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
Definition: DTClusterer.cc:162
unsigned int DTClusterer::differentLayers ( std::vector< DTRecHit1DPair > &  hits)
private

Definition at line 185 of file DTClusterer.cc.

References LayerTriplets::layers(), and mps_fire::result.

185  {
186 // Count the number of different layers
187  int layers=0;
188  unsigned int result=0;
189  for (vector<DTRecHit1DPair>::const_iterator hit=hits.begin(); hit!=hits.end();
190  ++hit) {
191  int pos = (1 << ((*hit).wireId().layer() -1 ));
192  if (! (pos & layers)) {
193  result++;
194  layers |= pos;
195  }
196  }
197  return result;
198 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
vector< pair< float, DTRecHit1DPair > > DTClusterer::initHits ( const DTSuperLayer sl,
std::vector< DTRecHit1DPair > &  pairs 
)
private

Definition at line 162 of file DTClusterer.cc.

References DTLayerId::layer(), DTSuperLayer::layer(), mps_fire::result, DTLayer::specificTopology(), GeomDet::toGlobal(), GeomDet::toLocal(), DTWireId::wire(), DTTopology::wirePosition(), and PV3DBase< T, PVType, FrameType >::x().

163  {
164  vector<pair<float, DTRecHit1DPair> > result;
165  for (vector<DTRecHit1DPair>::const_iterator pair=pairs.begin();
166  pair!=pairs.end(); ++pair ) {
167 
168  // get wire
169  DTWireId wid = (*pair).wireId();
170  // get Layer
171  const DTLayer* lay= sl->layer(wid.layer());
172  // get wire position in SL (only x)
173  LocalPoint
174  posInLayer(lay->specificTopology().wirePosition(wid.wire()),0.,0.);
175  LocalPoint posInSL = sl->toLocal(lay->toGlobal(posInLayer));
176  // put the pair into result
177  result.push_back(make_pair(posInSL.x(), *pair));
178  }
179  // sorted by x
180  sort(result.begin(), result.end(), sortClusterByX());
181 
182  return result;
183 }
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
const DTLayer * layer(DTLayerId id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:68
int wire() const
Return the wire number.
Definition: DTWireId.h:56
T x() const
Definition: PV3DBase.h:62
void DTClusterer::produce ( edm::Event event,
const edm::EventSetup setup 
)
virtual

Definition at line 61 of file DTClusterer.cc.

References fastPrimaryVertexProducer_cfi::clusters, gather_cfg::cout, debug, edm::EventSetup::get(), DTSuperLayer::id(), DTRangeMapAccessor::layersBySuperLayer(), eostools::move(), DTGeometry::superLayer(), and DTLayerId::superlayerId().

61  {
62  if(debug)
63  cout << "[DTClusterer] produce called" << endl;
64  // Get the DT Geometry
65  ESHandle<DTGeometry> dtGeom;
66  setup.get<MuonGeometryRecord>().get(dtGeom);
67 
68  // Get the 1D rechits from the event
70  event.getByToken(recHits1DToken_, allHits);
71 
72  // Create the pointer to the collection which will store the rechits
73  auto clusters = std::make_unique<DTRecClusterCollection>();
74 
75  // Iterate through all hit collections ordered by LayerId
76  DTRecHitCollection::id_iterator dtLayerIt;
77  DTSuperLayerId oldSlId;
78  for (dtLayerIt = allHits->id_begin(); dtLayerIt != allHits->id_end(); ++dtLayerIt){
79  // The layerId
80  DTLayerId layerId = (*dtLayerIt);
81  const DTSuperLayerId SLId = layerId.superlayerId();
82  if (SLId==oldSlId) continue; // I'm on the same SL as before
83  oldSlId = SLId;
84 
85  if(debug) cout <<"Reconstructing the clusters in "<< SLId << endl;
86 
87  const DTSuperLayer* sl = dtGeom->superLayer(SLId);
88 
89  // Get all the rec hit in the same superLayer in which layerId relies
91  allHits->get(DTRangeMapAccessor::layersBySuperLayer(SLId));
92 
93  // Fill the vector with the 1D RecHit
94  vector<DTRecHit1DPair> pairs(range.first,range.second);
95  if(debug) cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
96  vector<DTSLRecCluster> clus=buildClusters(sl, pairs);
97  if(debug) cout << "Number of clusters build " << clus.size() << endl;
98  if (clus.size() > 0 )
99  clusters->put(sl->id(), clus.begin(), clus.end());
100  }
101  event.put(std::move(clusters));
102 }
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
Definition: DTClusterer.h:78
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:36
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:105
std::vector< DTSLRecCluster > buildClusters(const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
Definition: DTClusterer.cc:104
const T & get() const
Definition: EventSetup.h:56
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

bool DTClusterer::debug
private

Definition at line 74 of file DTClusterer.h.

edm::EDGetTokenT<DTRecHitCollection> DTClusterer::recHits1DToken_
private

Definition at line 78 of file DTClusterer.h.

unsigned int DTClusterer::theMinHits
private

Definition at line 76 of file DTClusterer.h.

unsigned int DTClusterer::theMinLayers
private

Definition at line 77 of file DTClusterer.h.