Go to the documentation of this file.00001 #include "CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h"
00002
00003 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00004
00005 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00006 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00007 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00008 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012
00013 #include "CalibTracker/SiStripCommon/interface/ShallowTools.h"
00014 #include "boost/foreach.hpp"
00015
00016 ShallowRechitClustersProducer::ShallowRechitClustersProducer(const edm::ParameterSet& iConfig)
00017 : Suffix ( iConfig.getParameter<std::string>("Suffix") ),
00018 Prefix ( iConfig.getParameter<std::string>("Prefix") ),
00019 theClustersLabel( iConfig.getParameter<edm::InputTag>("Clusters")),
00020 inputTags ( iConfig.getParameter<std::vector<edm::InputTag> >("InputTags"))
00021 {
00022 produces <std::vector<float> > ( Prefix + "strip" + Suffix );
00023 produces <std::vector<float> > ( Prefix + "merr" + Suffix );
00024 produces <std::vector<float> > ( Prefix + "localx" + Suffix );
00025 produces <std::vector<float> > ( Prefix + "localy" + Suffix );
00026 produces <std::vector<float> > ( Prefix + "localxerr" + Suffix );
00027 produces <std::vector<float> > ( Prefix + "localyerr" + Suffix );
00028 produces <std::vector<float> > ( Prefix + "globalx" + Suffix );
00029 produces <std::vector<float> > ( Prefix + "globaly" + Suffix );
00030 produces <std::vector<float> > ( Prefix + "globalz" + Suffix );
00031 }
00032
00033 void ShallowRechitClustersProducer::
00034 produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00035 shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel);
00036
00037 int size = clustermap.size();
00038 std::auto_ptr<std::vector<float> > strip ( new std::vector<float>(size, -10000 ));
00039 std::auto_ptr<std::vector<float> > merr ( new std::vector<float>(size, -10000 ));
00040 std::auto_ptr<std::vector<float> > localx ( new std::vector<float>(size, -10000 ));
00041 std::auto_ptr<std::vector<float> > localy ( new std::vector<float>(size, -10000 ));
00042 std::auto_ptr<std::vector<float> > localxerr ( new std::vector<float>(size, -1 ));
00043 std::auto_ptr<std::vector<float> > localyerr ( new std::vector<float>(size, -1 ));
00044 std::auto_ptr<std::vector<float> > globalx ( new std::vector<float>(size, -10000 ));
00045 std::auto_ptr<std::vector<float> > globaly ( new std::vector<float>(size, -10000 ));
00046 std::auto_ptr<std::vector<float> > globalz ( new std::vector<float>(size, -10000 ));
00047
00048 edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
00049
00050 BOOST_FOREACH(const edm::InputTag& input, inputTags ) { edm::Handle<SiStripRecHit2DCollection> recHits; iEvent.getByLabel(input, recHits);
00051 BOOST_FOREACH( const SiStripRecHit2DCollection::value_type& ds, *recHits) {
00052 BOOST_FOREACH( const SiStripRecHit2D& hit, ds) {
00053
00054 shallow::CLUSTERMAP::iterator cluster = clustermap.find( std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip() ) );
00055 if(cluster != clustermap.end() ) {
00056 const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( hit.geographicalId() ) );
00057 unsigned int i = cluster->second;
00058 strip->at(i) = theStripDet->specificTopology().strip(hit.localPosition());
00059 merr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit.localPosition(), hit.localPositionError()).uu());
00060 localx->at(i) = hit.localPosition().x();
00061 localy->at(i) = hit.localPosition().y();
00062 localxerr->at(i) = sqrt(hit.localPositionError().xx());
00063 localyerr->at(i) = sqrt(hit.localPositionError().yy());
00064 globalx->at(i) = theStripDet->toGlobal(hit.localPosition()).x();
00065 globaly->at(i) = theStripDet->toGlobal(hit.localPosition()).y();
00066 globalz->at(i) = theStripDet->toGlobal(hit.localPosition()).z();
00067 }
00068 else {throw cms::Exception("cluster not found");}
00069 }
00070 }
00071 }
00072
00073 iEvent.put( strip, Prefix + "strip" + Suffix );
00074 iEvent.put( merr, Prefix + "merr" + Suffix );
00075 iEvent.put( localx , Prefix + "localx" + Suffix );
00076 iEvent.put( localy , Prefix + "localy" + Suffix );
00077 iEvent.put( localxerr , Prefix + "localxerr" + Suffix );
00078 iEvent.put( localyerr , Prefix + "localyerr" + Suffix );
00079 iEvent.put( globalx , Prefix + "globalx" + Suffix );
00080 iEvent.put( globaly , Prefix + "globaly" + Suffix );
00081 iEvent.put( globalz , Prefix + "globalz" + Suffix );
00082 }