CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/RecoLocalMuon/DTSegment/src/DTRecSegment2DExtendedProducer.cc

Go to the documentation of this file.
00001 
00008 /* This Class Header */
00009 #include "RecoLocalMuon/DTSegment/src/DTRecSegment2DExtendedProducer.h"
00010 
00011 /* Collaborating Class Header */
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 using namespace edm;
00016 
00017 #include "Geometry/DTGeometry/interface/DTLayer.h"
00018 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00020 
00021 #include "DataFormats/DTRecHit/interface/DTRecHit1DPair.h"
00022 #include "DataFormats/DTRecHit/interface/DTRecHit1D.h"
00023 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00024 #include "DataFormats/DTRecHit/interface/DTRecClusterCollection.h"
00025 #include "DataFormats/DTRecHit/interface/DTSLRecSegment2D.h"
00026 #include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h"
00027 #include "DataFormats/DTRecHit/interface/DTRangeMapAccessor.h"
00028 
00029 #include "RecoLocalMuon/DTSegment/src/DTCombinatorialExtendedPatternReco.h"
00030 
00031 /* C++ Headers */
00032 #include <string>
00033 using namespace std;
00034 
00035 /* ====================================================================== */
00036 
00038 DTRecSegment2DExtendedProducer::DTRecSegment2DExtendedProducer(const edm::ParameterSet& pset) {
00039   // Set verbose output
00040   debug = pset.getUntrackedParameter<bool>("debug"); 
00041 
00042   // the name of the 1D rec hits collection
00043   theRecHits1DLabel = pset.getParameter<InputTag>("recHits1DLabel");
00044   theRecClusLabel = pset.getParameter<InputTag>("recClusLabel");
00045 
00046   if(debug)
00047     cout << "[DTRecSegment2DExtendedProducer] Constructor called" << endl;
00048 
00049   produces<DTRecSegment2DCollection>();
00050 
00051   // Get the concrete reconstruction algo from the factory
00052   theAlgo = new DTCombinatorialExtendedPatternReco(pset.getParameter<ParameterSet>("Reco2DAlgoConfig"));
00053 }
00054 
00056 DTRecSegment2DExtendedProducer::~DTRecSegment2DExtendedProducer() {
00057   if(debug)
00058     cout << "[DTRecSegment2DExtendedProducer] Destructor called" << endl;
00059   delete theAlgo;
00060 }
00061 
00062 /* Operations */ 
00063 void DTRecSegment2DExtendedProducer::produce(edm::Event& event, const
00064                                      edm::EventSetup& setup) {
00065   if(debug)
00066     cout << "[DTRecSegment2DExtendedProducer] produce called" << endl;
00067   // Get the DT Geometry
00068   ESHandle<DTGeometry> dtGeom;
00069   setup.get<MuonGeometryRecord>().get(dtGeom);
00070 
00071   theAlgo->setES(setup);
00072   
00073   // Get the 1D rechits from the event
00074   Handle<DTRecHitCollection> allHits; 
00075   event.getByLabel(theRecHits1DLabel, allHits);
00076 
00077   // Get the 1D clusters from the event
00078   Handle<DTRecClusterCollection> dtClusters; 
00079   event.getByLabel(theRecClusLabel, dtClusters);
00080   theAlgo->setClusters(vector<DTSLRecCluster>(dtClusters->begin(),
00081                                               dtClusters->end()));
00082 
00083   // Create the pointer to the collection which will store the rechits
00084   auto_ptr<DTRecSegment2DCollection> segments(new DTRecSegment2DCollection());
00085 
00086   // Iterate through all hit collections ordered by LayerId
00087   DTRecHitCollection::id_iterator dtLayerIt;
00088   DTSuperLayerId oldSlId;
00089   for (dtLayerIt = allHits->id_begin(); dtLayerIt != allHits->id_end(); ++dtLayerIt){
00090     // The layerId
00091     DTLayerId layerId = (*dtLayerIt);
00092     const DTSuperLayerId SLId = layerId.superlayerId();
00093     if (SLId==oldSlId) continue; // I'm on the same SL as before
00094     oldSlId = SLId;
00095 
00096     if(debug) cout <<"Reconstructing the 2D segments in "<< SLId << endl;
00097 
00098     const DTSuperLayer* sl = dtGeom->superLayer(SLId);
00099 
00100     // Get all the rec hit in the same superLayer in which layerId relies 
00101     DTRecHitCollection::range range =
00102       allHits->get(DTRangeMapAccessor::layersBySuperLayer(SLId));
00103 
00104     // Fill the vector with the 1D RecHit
00105     vector<DTRecHit1DPair> pairs(range.first,range.second);
00106 
00107     if(debug) cout << "Number of 1D-RecHit pairs " << pairs.size() << endl;
00108 
00109     //if(debug) cout << "Start the 2D-segments Reco "<< endl;
00110     OwnVector<DTSLRecSegment2D> segs = theAlgo->reconstruct(sl, pairs);
00111     if(debug) {
00112       cout << "Number of Reconstructed segments: " << segs.size() << endl;
00113       copy(segs.begin(), segs.end(),
00114            ostream_iterator<DTSLRecSegment2D>(cout, "\n"));
00115     }
00116 
00117     if (segs.size() > 0 )
00118       segments->put(SLId, segs.begin(),segs.end());
00119   }
00120   event.put(segments);
00121 }
00122 
00123