CMS 3D CMS Logo

DTRecSegment4DProducer.cc
Go to the documentation of this file.
1 
8 
14 
17 
20 
22 
23 using namespace edm;
24 using namespace std;
25 
27  // Get the concrete 4D-segments reconstruction algo from the factory
28  the4DAlgo{DTRecSegment4DAlgoFactory::get()->create(pset.getParameter<string>("Reco4DAlgoName"),
29  pset.getParameter<ParameterSet>("Reco4DAlgoConfig"))}
30 {
31  produces<DTRecSegment4DCollection>();
32 
33  // debug parameter
34  debug = pset.getUntrackedParameter<bool>("debug", false);
35 
36  if(debug)
37  cout << "[DTRecSegment4DProducer] Constructor called" << endl;
38 
39  // the name of the 1D rec hits collection
40  recHits1DToken_ = consumes<DTRecHitCollection>(pset.getParameter<InputTag>("recHits1DLabel"));
41 
42  // the name of the 2D rec hits collection
43  recHits2DToken_ = consumes<DTRecSegment2DCollection>(pset.getParameter<InputTag>("recHits2DLabel"));
44 
45  if(debug) cout << "the Reco4D AlgoName is " << pset.getParameter<string>("Reco4DAlgoName") << endl;
46 }
47 
50  if(debug)
51  cout << "[DTRecSegment4DProducer] Destructor called" << endl;
52 }
53 
55 
56  // Get the 1D rechits from the event
57  Handle<DTRecHitCollection> all1DHits;
58  event.getByToken(recHits1DToken_, all1DHits);
59 
60  // Get the 2D rechits from the event
62  if(the4DAlgo->wants2DSegments())
63  event.getByToken(recHits2DToken_, all2DSegments);
64 
65  // Create the pointer to the collection which will store the rechits
66  auto segments4DCollection = std::make_unique<DTRecSegment4DCollection>();
67 
68  // get the geometry
69  ESHandle<DTGeometry> theGeom;
70  setup.get<MuonGeometryRecord>().get(theGeom);
71 
72  // Percolate the setup
73  the4DAlgo->setES(setup);
74 
75  // Iterate over all hit collections ordered by layerId
77 
78  DTChamberId oldChId;
79 
80  for (dtLayerIt = all1DHits->id_begin(); dtLayerIt != all1DHits->id_end(); ++dtLayerIt){
81 
82  // Check the DTChamberId
83  const DTChamberId chId = (*dtLayerIt).chamberId();
84  if (chId==oldChId) continue; // I'm on the same Chamber as before
85  oldChId = chId;
86  if(debug) cout << "ChamberId: "<< chId << endl;
87  the4DAlgo->setChamber(chId);
88 
89  if(debug) cout<<"Take the DTRecHits1D and set them in the reconstructor"<<endl;
90 
91  the4DAlgo->setDTRecHit1DContainer(all1DHits);
92 
93  if(debug) cout<<"Take the DTRecSegments2D and set them in the reconstructor"<<endl;
94 
95  the4DAlgo->setDTRecSegment2DContainer(all2DSegments);
96 
97  if(debug) cout << "Start 4D-Segments Reco " << endl;
98 
99  OwnVector<DTRecSegment4D> segments4D = the4DAlgo->reconstruct();
100 
101  if(debug) {
102  cout << "Number of reconstructed 4D-segments " << segments4D.size() << endl;
103  copy(segments4D.begin(), segments4D.end(),
104  ostream_iterator<DTRecSegment4D>(cout, "\n"));
105  }
106 
107  if (!segments4D.empty() )
108  // convert the OwnVector into a Collection
109  segments4DCollection->put(chId, segments4D.begin(),segments4D.end());
110  }
111  // Load the output in the Event
112  event.put(std::move(segments4DCollection));
113 }
T getParameter(std::string const &) const
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
size_type size() const
Definition: OwnVector.h:264
std::unique_ptr< DTRecSegment4DBaseAlgo > the4DAlgo
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
identifier iterator
Definition: RangeMap.h:135
iterator begin()
Definition: OwnVector.h:244
DTRecSegment4DProducer(const edm::ParameterSet &)
Constructor.
bool empty() const
Definition: OwnVector.h:269
edm::EDGetTokenT< DTRecSegment2DCollection > recHits2DToken_
~DTRecSegment4DProducer() override
Destructor.
iterator end()
Definition: OwnVector.h:249
edm::EDGetTokenT< DTRecHitCollection > recHits1DToken_
HLT enums.
T get() const
Definition: EventSetup.h:71
void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the 4D rec segments.
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1