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