CMS 3D CMS Logo

DTRecHitProducer.cc
Go to the documentation of this file.
1 
6 #include "DTRecHitProducer.h"
7 
8 
12 
14 
20 
24 #include <string>
25 
26 
27 using namespace edm;
28 using namespace std;
29 
30 
31 
32 
34  // Set verbose output
35  debug(config.getUntrackedParameter<bool>("debug", false)),
36  // Get the concrete reconstruction algo from the factory
37  theAlgo{DTRecHitAlgoFactory::get()->create(config.getParameter<string>("recAlgo"),
38  config.getParameter<ParameterSet>("recAlgoConfig"))}
39 {
40  if(debug)
41  cout << "[DTRecHitProducer] Constructor called" << endl;
42 
43  produces<DTRecHitCollection>();
44 
45  DTDigiToken_ = consumes<DTDigiCollection>(config.getParameter<InputTag>("dtDigiLabel"));
46 }
47 
49  if(debug)
50  cout << "[DTRecHitProducer] Destructor called" << endl;
51 }
52 
53 
54 
56  // Get the DT Geometry
57  ESHandle<DTGeometry> dtGeom;
58  setup.get<MuonGeometryRecord>().get(dtGeom);
59 
60  // Get the digis from the event
62  event.getByToken(DTDigiToken_, digis);
63 
64  // Pass the EventSetup to the algo
65  theAlgo->setES(setup);
66 
67  // Create the pointer to the collection which will store the rechits
68  auto recHitCollection = std::make_unique<DTRecHitCollection>();
69 
70 
71  // Iterate through all digi collections ordered by LayerId
73  for (dtLayerIt = digis->begin();
74  dtLayerIt != digis->end();
75  ++dtLayerIt){
76  // The layerId
77  const DTLayerId& layerId = (*dtLayerIt).first;
78  // Get the GeomDet from the setup
79  const DTLayer* layer = dtGeom->layer(layerId);
80 
81  // Get the iterators over the digis associated with this LayerId
82  const DTDigiCollection::Range& range = (*dtLayerIt).second;
83 
85  theAlgo->reconstruct(layer, layerId, range);
86 
87  if(debug)
88  cout << "Number of hits in this layer: " << recHits.size() << endl;
89  if(!recHits.empty()) //FIXME: is it really needed?
90  recHitCollection->put(layerId, recHits.begin(), recHits.end());
91  }
92 
93  event.put(std::move(recHitCollection));
94 }
T getParameter(std::string const &) const
edm::EDGetTokenT< DTDigiCollection > DTDigiToken_
size_type size() const
Definition: OwnVector.h:264
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
Definition: config.py:1
iterator begin()
Definition: OwnVector.h:244
~DTRecHitProducer() override
Destructor.
bool empty() const
Definition: OwnVector.h:269
iterator end()
Definition: OwnVector.h:249
#define debug
Definition: HDRShower.cc:19
DTRecHitProducer(const edm::ParameterSet &)
Constructor.
HLT enums.
T get() const
Definition: EventSetup.h:71
std::pair< const_iterator, const_iterator > Range
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the rechits.
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1
std::unique_ptr< DTRecHitBaseAlgo > theAlgo