CMS 3D CMS Logo

DTRecSegment2DProducer.cc
Go to the documentation of this file.
1 
7 /* This Class Header */
9 
10 /* Collaborating Class Header */
15 using namespace edm;
16 
20 
26 
28 
29 /* C++ Headers */
30 #include <string>
31 using namespace std;
32 
33 /* ====================================================================== */
34 
37  : theAlgo{DTRecSegment2DAlgoFactory::get()->create(pset.getParameter<string>("Reco2DAlgoName"),
38  pset.getParameter<ParameterSet>("Reco2DAlgoConfig"))} {
39  // Set verbose output
40  debug = pset.getUntrackedParameter<bool>("debug");
41 
42  // the name of the 1D rec hits collection
43  recHits1DToken_ = consumes<DTRecHitCollection>(pset.getParameter<InputTag>("recHits1DLabel"));
44 
45  if (debug)
46  cout << "[DTRecSegment2DProducer] Constructor called" << endl;
47 
48  produces<DTRecSegment2DCollection>();
49 
50  // Get the concrete reconstruction algo from the factory
51  if (debug)
52  cout << "the Reco2D AlgoName is " << pset.getParameter<string>("Reco2DAlgoName") << endl;
53 }
54 
57  if (debug)
58  cout << "[DTRecSegment2DProducer] Destructor called" << endl;
59 }
60 
61 /* Operations */
63  if (debug)
64  cout << "[DTRecSegment2DProducer] produce called" << endl;
65  // Get the DT Geometry
66  ESHandle<DTGeometry> dtGeom;
67  setup.get<MuonGeometryRecord>().get(dtGeom);
68 
69  theAlgo->setES(setup);
70 
71  // Get the 1D rechits from the event
73  event.getByToken(recHits1DToken_, allHits);
74 
75  // Create the pointer to the collection which will store the rechits
76  auto segments = std::make_unique<DTRecSegment2DCollection>();
77 
78  // Iterate through all hit collections ordered by LayerId
80  DTSuperLayerId oldSlId;
81  for (dtLayerIt = allHits->id_begin(); dtLayerIt != allHits->id_end(); ++dtLayerIt) {
82  // The layerId
83  DTLayerId layerId = (*dtLayerIt);
84  const DTSuperLayerId SLId = layerId.superlayerId();
85  if (SLId == oldSlId)
86  continue; // I'm on the same SL as before
87  oldSlId = SLId;
88 
89  if (debug)
90  cout << "Reconstructing the 2D segments in " << SLId << endl;
91 
92  const DTSuperLayer* sl = dtGeom->superLayer(SLId);
93 
94  // Get all the rec hit in the same superLayer in which layerId relies
96 
97  // Fill the vector with the 1D RecHit
98  vector<DTRecHit1DPair> pairs(range.first, range.second);
99 
100  if (debug)
101  cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
102 
103  if (debug)
104  cout << "Start the 2D-segments Reco " << endl;
105  OwnVector<DTSLRecSegment2D> segs = theAlgo->reconstruct(sl, pairs);
106  if (debug)
107  cout << "Number of Reconstructed segments: " << segs.size() << endl;
108 
109  if (!segs.empty())
110  segments->put(SLId, segs.begin(), segs.end());
111  }
112  event.put(std::move(segments));
113 }
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
T getParameter(std::string const &) const
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the 2D-segments.
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
size_type size() const
Definition: OwnVector.h:300
identifier iterator
Definition: RangeMap.h:130
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
iterator begin()
Definition: OwnVector.h:280
std::unique_ptr< DTRecSegment2DBaseAlgo > theAlgo
bool empty() const
Definition: OwnVector.h:305
iterator end()
Definition: OwnVector.h:285
HLT enums.
T get() const
Definition: EventSetup.h:73
DTRecSegment2DProducer(const edm::ParameterSet &)
Constructor.
~DTRecSegment2DProducer() override
Destructor.
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:92