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 &)
 
void produce (edm::Event &event, const edm::EventSetup &setup) override
 
 ~DTClusterer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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::DTClusterer ( const edm::ParameterSet pset)

Definition at line 39 of file DTClusterer.cc.

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 }

References gather_cfg::cout, debug, and muonDTDigis_cfi::pset.

◆ ~DTClusterer()

DTClusterer::~DTClusterer ( )
override

Definition at line 57 of file DTClusterer.cc.

57 {}

Member Function Documentation

◆ buildClusters()

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

Definition at line 106 of file DTClusterer.cc.

106  {
107  // create a vector of hits with wire position in SL frame
108  vector<pair<float, DTRecHit1DPair> > hits = initHits(sl, pairs);
109 
110  vector<DTSLRecCluster> result;
111  // loop over pairs
112  vector<DTRecHit1DPair> adiacentPairs;
113  float lastPos = hits.front().first;
114  const float cellWidth = 4.2; // cm
115  float sum = 0.;
116  float sum2 = 0.;
117 
118  for (vector<pair<float, DTRecHit1DPair> >::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
119  if (debug)
120  cout << "Hit: " << (*hit).first << " lastPos: " << lastPos << endl;
121  // start from first hits
122  // two cells are adiacente if their position is closer than cell width
123  if (abs((*hit).first - lastPos) > cellWidth) {
124  if (adiacentPairs.size() >= theMinHits && differentLayers(adiacentPairs) >= theMinLayers) {
125  // if not, build the cluster with so far collection hits and go on
126  float mean = sum / adiacentPairs.size();
127  float err2 = sum2 / adiacentPairs.size() - mean * mean;
128  DTSLRecCluster cluster(sl->id(), LocalPoint(mean, 0., 0.), LocalError(err2, 0., 0.), adiacentPairs);
129  if (debug)
130  cout << "Cluster " << cluster << endl;
131  result.push_back(cluster);
132  }
133  // clean the vector
134  adiacentPairs.clear();
135  sum = 0.;
136  sum2 = 0.;
137  }
138  // if adiacente, add them to a vector
139  adiacentPairs.push_back((*hit).second);
140  if (debug)
141  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(), LocalPoint(mean, 0., 0.), LocalError(err2, 0., 0.), adiacentPairs);
152  if (debug)
153  cout << "Cluster " << cluster << endl;
154  result.push_back(cluster);
155  }
156 
157  return result;
158 }

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

◆ differentLayers()

unsigned int DTClusterer::differentLayers ( std::vector< DTRecHit1DPair > &  hits)
private

Definition at line 179 of file DTClusterer.cc.

179  {
180  // Count the number of different layers
181  int layers = 0;
182  unsigned int result = 0;
183  for (vector<DTRecHit1DPair>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
184  int pos = (1 << ((*hit).wireId().layer() - 1));
185  if (!(pos & layers)) {
186  result++;
187  layers |= pos;
188  }
189  }
190  return result;
191 }

References hfClusterShapes_cfi::hits, hgcalTopologyTester_cfi::layers, and mps_fire::result.

◆ initHits()

vector< pair< float, DTRecHit1DPair > > DTClusterer::initHits ( const DTSuperLayer sl,
std::vector< DTRecHit1DPair > &  pairs 
)
private

Definition at line 160 of file DTClusterer.cc.

160  {
161  vector<pair<float, DTRecHit1DPair> > result;
162  for (vector<DTRecHit1DPair>::const_iterator pair = pairs.begin(); pair != pairs.end(); ++pair) {
163  // get wire
164  DTWireId wid = (*pair).wireId();
165  // get Layer
166  const DTLayer* lay = sl->layer(wid.layer());
167  // get wire position in SL (only x)
168  LocalPoint posInLayer(lay->specificTopology().wirePosition(wid.wire()), 0., 0.);
169  LocalPoint posInSL = sl->toLocal(lay->toGlobal(posInLayer));
170  // put the pair into result
171  result.push_back(make_pair(posInSL.x(), *pair));
172  }
173  // sorted by x
174  sort(result.begin(), result.end(), sortClusterByX());
175 
176  return result;
177 }

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

◆ produce()

void DTClusterer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 60 of file DTClusterer.cc.

60  {
61  if (debug)
62  cout << "[DTClusterer] produce called" << endl;
63  // Get the DT Geometry
64  ESHandle<DTGeometry> dtGeom;
65  setup.get<MuonGeometryRecord>().get(dtGeom);
66 
67  // Get the 1D rechits from the event
69  event.getByToken(recHits1DToken_, allHits);
70 
71  // Create the pointer to the collection which will store the rechits
72  auto clusters = std::make_unique<DTRecClusterCollection>();
73 
74  // Iterate through all hit collections ordered by LayerId
76  DTSuperLayerId oldSlId;
77  for (dtLayerIt = allHits->id_begin(); dtLayerIt != allHits->id_end(); ++dtLayerIt) {
78  // The layerId
79  DTLayerId layerId = (*dtLayerIt);
80  const DTSuperLayerId SLId = layerId.superlayerId();
81  if (SLId == oldSlId)
82  continue; // I'm on the same SL as before
83  oldSlId = SLId;
84 
85  if (debug)
86  cout << "Reconstructing the clusters in " << SLId << endl;
87 
88  const DTSuperLayer* sl = dtGeom->superLayer(SLId);
89 
90  // Get all the rec hit in the same superLayer in which layerId relies
92 
93  // Fill the vector with the 1D RecHit
94  vector<DTRecHit1DPair> pairs(range.first, range.second);
95  if (debug)
96  cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
97  vector<DTSLRecCluster> clus = buildClusters(sl, pairs);
98  if (debug)
99  cout << "Number of clusters build " << clus.size() << endl;
100  if (!clus.empty())
101  clusters->put(sl->id(), clus.begin(), clus.end());
102  }
103  event.put(std::move(clusters));
104 }

References bsc_activity_cfg::clusters, gather_cfg::cout, debug, edm::get(), DTSuperLayer::id(), DTRangeMapAccessor::layersBySuperLayer(), eostools::move(), FastTimerService_cff::range, singleTopDQM_cfi::setup, DTGeometry::superLayer(), and DTLayerId::superlayerId().

Member Data Documentation

◆ debug

bool DTClusterer::debug
private

◆ recHits1DToken_

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

Definition at line 73 of file DTClusterer.h.

◆ theMinHits

unsigned int DTClusterer::theMinHits
private

Definition at line 71 of file DTClusterer.h.

◆ theMinLayers

unsigned int DTClusterer::theMinLayers
private

Definition at line 72 of file DTClusterer.h.

DTSuperLayerId
Definition: DTSuperLayerId.h:12
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
DTClusterer::theMinLayers
unsigned int theMinLayers
Definition: DTClusterer.h:72
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
DTSLRecCluster
Definition: DTSLRecCluster.h:30
DTClusterer::differentLayers
unsigned int differentLayers(std::vector< DTRecHit1DPair > &hits)
Definition: DTClusterer.cc:179
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
DTSuperLayer::id
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:34
DTSuperLayer
Definition: DTSuperLayer.h:24
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
edm::Handle< DTRecHitCollection >
edm::RangeMap::id_iterator
identifier iterator
Definition: RangeMap.h:130
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTClusterer::recHits1DToken_
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
Definition: DTClusterer.h:73
DTTopology::wirePosition
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
DTClusterer::theMinHits
unsigned int theMinHits
Definition: DTClusterer.h:71
DTWireId
Definition: DTWireId.h:12
edm::ESHandle< DTGeometry >
DTClusterer::buildClusters
std::vector< DTSLRecCluster > buildClusters(const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
Definition: DTClusterer.cc:106
Point3DBase< float, LocalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
DTLayerId
Definition: DTLayerId.h:12
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
DTRangeMapAccessor::layersBySuperLayer
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
Definition: DTRangeMapAccessor.cc:15
LocalError
Definition: LocalError.h:12
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
combinedConstraintHelpers::sum2
void sum2(T &x, T y)
Definition: CombinedKinematicConstraintT.h:74
get
#define get
DTLayer
Definition: DTLayer.h:25
DTClusterer::initHits
std::vector< std::pair< float, DTRecHit1DPair > > initHits(const DTSuperLayer *sl, std::vector< DTRecHit1DPair > &pairs)
Definition: DTClusterer.cc:160
DTClusterer::debug
bool debug
Definition: DTClusterer.h:69
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
eostools.move
def move(src, dest)
Definition: eostools.py:511
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
DTSuperLayer::layer
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:54
DTLayer::specificTopology
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
mps_fire.result
result
Definition: mps_fire.py:311
DTGeometry::superLayer
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:92
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
hit
Definition: SiStripHitEffFromCalibTree.cc:88
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27