CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DTRecHitProducer.cc
Go to the documentation of this file.
1 
6 #include "DTRecHitProducer.h"
7 
12 
14 
20 
24 #include <string>
25 
26 using namespace edm;
27 using namespace std;
28 
30  : // Set verbose output
31  debug(config.getUntrackedParameter<bool>("debug", false)),
32  dtGeomToken_(esConsumes()),
33  // Get the concrete reconstruction algo from the factory
34  theAlgo{DTRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
35  config.getParameter<ParameterSet>("recAlgoConfig"),
36  consumesCollector())} {
37  if (debug)
38  cout << "[DTRecHitProducer] Constructor called" << endl;
39 
40  produces<DTRecHitCollection>();
41 
42  DTDigiToken_ = consumes<DTDigiCollection>(config.getParameter<InputTag>("dtDigiLabel"));
43 }
44 
46  if (debug)
47  cout << "[DTRecHitProducer] Destructor called" << endl;
48 }
49 
51  // Get the DT Geometry
52  const DTGeometry& dtGeom = setup.getData(dtGeomToken_);
53 
54  // Get the digis from the event
56  event.getByToken(DTDigiToken_, digis);
57 
58  // Pass the EventSetup to the algo
59  theAlgo->setES(setup);
60 
61  // Create the pointer to the collection which will store the rechits
62  auto recHitCollection = std::make_unique<DTRecHitCollection>();
63 
64  // Iterate through all digi collections ordered by LayerId
66  for (dtLayerIt = digis->begin(); dtLayerIt != digis->end(); ++dtLayerIt) {
67  // The layerId
68  const DTLayerId& layerId = (*dtLayerIt).first;
69  // Get the GeomDet from the setup
70  const DTLayer* layer = dtGeom.layer(layerId);
71 
72  // Get the iterators over the digis associated with this LayerId
73  const DTDigiCollection::Range& range = (*dtLayerIt).second;
74 
75  OwnVector<DTRecHit1DPair> recHits = theAlgo->reconstruct(layer, layerId, range);
76 
77  if (debug)
78  cout << "Number of hits in this layer: " << recHits.size() << endl;
79  if (!recHits.empty()) //FIXME: is it really needed?
80  recHitCollection->put(layerId, recHits.begin(), recHits.end());
81  }
82 
83  event.put(std::move(recHitCollection));
84 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< DTDigiCollection > DTDigiToken_
Definition: config.py:1
~DTRecHitProducer() override
Destructor.
#define debug
Definition: HDRShower.cc:19
DTRecHitProducer(const edm::ParameterSet &)
Constructor.
std::pair< const_iterator, const_iterator > Range
HLT enums.
#define get
void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the rechits.
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
std::unique_ptr< DTRecHitBaseAlgo > theAlgo
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_