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  {
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 
46  if(debug)
47  cout << "[DTRecSegment2DProducer] Constructor called" << endl;
48 
49  produces<DTRecSegment2DCollection>();
50 
51  // Get the concrete reconstruction algo from the factory
52  if(debug) 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 */
64  if(debug)
65  cout << "[DTRecSegment2DProducer] produce called" << endl;
66  // Get the DT Geometry
67  ESHandle<DTGeometry> dtGeom;
68  setup.get<MuonGeometryRecord>().get(dtGeom);
69 
70  theAlgo->setES(setup);
71 
72  // Get the 1D rechits from the event
74  event.getByToken(recHits1DToken_, allHits);
75 
76  // Create the pointer to the collection which will store the rechits
77  auto segments = std::make_unique<DTRecSegment2DCollection>();
78 
79  // Iterate through all hit collections ordered by LayerId
81  DTSuperLayerId oldSlId;
82  for (dtLayerIt = allHits->id_begin(); dtLayerIt != allHits->id_end(); ++dtLayerIt){
83  // The layerId
84  DTLayerId layerId = (*dtLayerIt);
85  const DTSuperLayerId SLId = layerId.superlayerId();
86  if (SLId==oldSlId) continue; // I'm on the same SL as before
87  oldSlId = SLId;
88 
89  if(debug) cout <<"Reconstructing the 2D segments in "<< SLId << endl;
90 
91  const DTSuperLayer* sl = dtGeom->superLayer(SLId);
92 
93  // Get all the rec hit in the same superLayer in which layerId relies
95  allHits->get(DTRangeMapAccessor::layersBySuperLayer(SLId));
96 
97  // Fill the vector with the 1D RecHit
98  vector<DTRecHit1DPair> pairs(range.first,range.second);
99 
100  if(debug) cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
101 
102  if(debug) cout << "Start the 2D-segments Reco "<< endl;
103  OwnVector<DTSLRecSegment2D> segs = theAlgo->reconstruct(sl, pairs);
104  if(debug) cout << "Number of Reconstructed segments: " << segs.size() << endl;
105 
106  if (!segs.empty() )
107  segments->put(SLId, segs.begin(),segs.end());
108  }
109  event.put(std::move(segments));
110 }
111 
112 
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:264
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
identifier iterator
Definition: RangeMap.h:135
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
iterator begin()
Definition: OwnVector.h:244
std::unique_ptr< DTRecSegment2DBaseAlgo > theAlgo
bool empty() const
Definition: OwnVector.h:269
iterator end()
Definition: OwnVector.h:249
HLT enums.
T get() const
Definition: EventSetup.h:71
DTRecSegment2DProducer(const edm::ParameterSet &)
Constructor.
~DTRecSegment2DProducer() override
Destructor.
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:122