CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoLocalMuon/DTSegment/src/DTSegment4DT0Corrector.cc

Go to the documentation of this file.
00001 
00009 #include "RecoLocalMuon/DTSegment/src/DTSegment4DT0Corrector.h"
00010 
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 
00016 #include "DataFormats/Common/interface/OwnVector.h"
00017 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00018 
00019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00020 
00021 using namespace edm;
00022 using namespace std;
00023 
00024 DTSegment4DT0Corrector::DTSegment4DT0Corrector(const ParameterSet& pset){
00025   produces<DTRecSegment4DCollection>();
00026   
00027   // debug parameter
00028   debug = pset.getUntrackedParameter<bool>("debug"); 
00029   
00030   if(debug)
00031     cout << "[DTSegment4DT0Corrector] Constructor called" << endl;
00032   
00033   // the name of the 4D rec hits collection
00034   theRecHits4DLabel = pset.getParameter<InputTag>("recHits4DLabel");
00035 
00036     // the updator
00037     theUpdator = new DTSegmentUpdator(pset);
00038 }
00039 
00041 DTSegment4DT0Corrector::~DTSegment4DT0Corrector(){
00042   if(debug)
00043     cout << "[DTSegment4DT0Corrector] Destructor called" << endl;
00044   delete theUpdator;
00045 }
00046 
00047 void DTSegment4DT0Corrector::produce(Event& event, const EventSetup& setup){
00048 
00049   // Get the 4D Segment from the event
00050   Handle<DTRecSegment4DCollection> all4DSegments;
00051   event.getByLabel(theRecHits4DLabel, all4DSegments);
00052 
00053   // get the geometry
00054   ESHandle<DTGeometry> theGeom;
00055   setup.get<MuonGeometryRecord>().get(theGeom);
00056 
00057  // Percolate the setup
00058   theUpdator->setES(setup);
00059 
00060 
00061   // Create the pointer to the collection which will store the rechits
00062   auto_ptr<DTRecSegment4DCollection> segments4DCollection(new DTRecSegment4DCollection());
00063 
00064   // Iterate over the input DTSegment4D
00065   DTRecSegment4DCollection::id_iterator chamberId;
00066 
00067   if(debug)
00068     cout << "[DTSegment4DT0Corrector] Starting to loop over segments" << endl;
00069 
00070   for (chamberId = all4DSegments->id_begin(); chamberId != all4DSegments->id_end(); ++chamberId){
00071 
00072     OwnVector<DTRecSegment4D> result;
00073 
00074     // Get the range for the corresponding ChamerId
00075     DTRecSegment4DCollection::range  range = all4DSegments->get(*chamberId);
00076 
00077     // Loop over the rechits of this ChamberId
00078     for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
00079          segment4D!=range.second; ++segment4D) {
00080 
00081       DTRecSegment4D tmpseg = *segment4D;
00082 
00083       DTRecSegment4D *newSeg = tmpseg.clone();
00084 
00085       if(newSeg == 0) continue;
00086 
00087       theUpdator->update(newSeg,true);
00088       result.push_back(*newSeg);
00089 
00090     }
00091 
00092     segments4DCollection->put(*chamberId, result.begin(), result.end());
00093 
00094   }
00095 
00096   if(debug)
00097     cout << "[DTSegment4DT0Corrector] Saving modified segments into the event" << endl;
00098 
00099   // Load the output in the Event
00100   event.put(segments4DCollection);
00101 }