CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  consumesCollector())},
40  dtGeomToken_{esConsumes()} {
41  // Set verbose output
42  debug = pset.getUntrackedParameter<bool>("debug");
43 
44  // the name of the 1D rec hits collection
45  recHits1DToken_ = consumes<DTRecHitCollection>(pset.getParameter<InputTag>("recHits1DLabel"));
46 
47  if (debug)
48  cout << "[DTRecSegment2DProducer] Constructor called" << endl;
49 
50  produces<DTRecSegment2DCollection>();
51 
52  // Get the concrete reconstruction algo from the factory
53  if (debug)
54  cout << "the Reco2D AlgoName is " << pset.getParameter<string>("Reco2DAlgoName") << endl;
55 }
56 
59  if (debug)
60  cout << "[DTRecSegment2DProducer] Destructor called" << endl;
61 }
62 
63 /* Operations */
65  if (debug)
66  cout << "[DTRecSegment2DProducer] produce called" << endl;
67  // Get the DT Geometry
68  DTGeometry const& dtGeom = setup.getData(dtGeomToken_);
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)
87  continue; // I'm on the same SL as before
88  oldSlId = SLId;
89 
90  if (debug)
91  cout << "Reconstructing the 2D segments in " << SLId << endl;
92 
93  const DTSuperLayer* sl = dtGeom.superLayer(SLId);
94 
95  // Get all the rec hit in the same superLayer in which layerId relies
97 
98  // Fill the vector with the 1D RecHit
99  vector<DTRecHit1DPair> pairs(range.first, range.second);
100 
101  if (debug)
102  cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
103 
104  if (debug)
105  cout << "Start the 2D-segments Reco " << endl;
106  OwnVector<DTSLRecSegment2D> segs = theAlgo->reconstruct(sl, pairs);
107  if (debug)
108  cout << "Number of Reconstructed segments: " << segs.size() << endl;
109 
110  if (!segs.empty())
111  segments->put(SLId, segs.begin(), segs.end());
112  }
113  event.put(std::move(segments));
114 }
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
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
const uint16_t range(const Frame &aFrame)
iterator begin()
Definition: OwnVector.h:280
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::unique_ptr< DTRecSegment2DBaseAlgo > theAlgo
bool empty() const
Definition: OwnVector.h:305
def move
Definition: eostools.py:511
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
iterator end()
Definition: OwnVector.h:285
#define debug
Definition: HDRShower.cc:19
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple cout
Definition: gather_cfg.py:144
DTRecSegment2DProducer(const edm::ParameterSet &)
Constructor.
~DTRecSegment2DProducer() override
Destructor.
#define get
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:92