CMS 3D CMS Logo

DTRecHitProducer.cc
Go to the documentation of this file.
1 
6 #include "DTRecHitProducer.h"
7 
11 
13 
19 
23 #include <string>
24 
25 using namespace edm;
26 using namespace std;
27 
29  : // Set verbose output
30  debug(config.getUntrackedParameter<bool>("debug", false)),
31  // Get the concrete reconstruction algo from the factory
32  theAlgo{DTRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
33  config.getParameter<ParameterSet>("recAlgoConfig"))} {
34  if (debug)
35  cout << "[DTRecHitProducer] Constructor called" << endl;
36 
37  produces<DTRecHitCollection>();
38 
39  DTDigiToken_ = consumes<DTDigiCollection>(config.getParameter<InputTag>("dtDigiLabel"));
40 }
41 
43  if (debug)
44  cout << "[DTRecHitProducer] Destructor called" << endl;
45 }
46 
48  // Get the DT Geometry
49  ESHandle<DTGeometry> dtGeom;
50  setup.get<MuonGeometryRecord>().get(dtGeom);
51 
52  // Get the digis from the event
54  event.getByToken(DTDigiToken_, digis);
55 
56  // Pass the EventSetup to the algo
57  theAlgo->setES(setup);
58 
59  // Create the pointer to the collection which will store the rechits
60  auto recHitCollection = std::make_unique<DTRecHitCollection>();
61 
62  // Iterate through all digi collections ordered by LayerId
64  for (dtLayerIt = digis->begin(); dtLayerIt != digis->end(); ++dtLayerIt) {
65  // The layerId
66  const DTLayerId& layerId = (*dtLayerIt).first;
67  // Get the GeomDet from the setup
68  const DTLayer* layer = dtGeom->layer(layerId);
69 
70  // Get the iterators over the digis associated with this LayerId
71  const DTDigiCollection::Range& range = (*dtLayerIt).second;
72 
73  OwnVector<DTRecHit1DPair> recHits = theAlgo->reconstruct(layer, layerId, range);
74 
75  if (debug)
76  cout << "Number of hits in this layer: " << recHits.size() << endl;
77  if (!recHits.empty()) //FIXME: is it really needed?
78  recHitCollection->put(layerId, recHits.begin(), recHits.end());
79  }
80 
81  event.put(std::move(recHitCollection));
82 }
T getParameter(std::string const &) const
edm::EDGetTokenT< DTDigiCollection > DTDigiToken_
size_type size() const
Definition: OwnVector.h:300
Definition: config.py:1
iterator begin()
Definition: OwnVector.h:280
~DTRecHitProducer() override
Destructor.
bool empty() const
Definition: OwnVector.h:305
iterator end()
Definition: OwnVector.h:285
#define debug
Definition: HDRShower.cc:19
DTRecHitProducer(const edm::ParameterSet &)
Constructor.
std::pair< const_iterator, const_iterator > Range
HLT enums.
T get() const
Definition: EventSetup.h:73
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
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