ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ShallowTools/plugins/ShallowRechitClustersProducer.cc
Revision: 1.4
Committed: Tue Sep 29 10:16:31 2009 UTC (15 years, 7 months ago) by bbetchar
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -0 lines
Log Message:
updates for CMSSW_3_3_X

File Contents

# User Rev Content
1 bbetchar 1.1 #include "UserCode/ShallowTools/interface/ShallowRechitClustersProducer.h"
2    
3     #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
4    
5     #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
6     #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
7     #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
8     #include "Geometry/CommonTopologies/interface/StripTopology.h"
9     #include "FWCore/Framework/interface/ESHandle.h"
10 bbetchar 1.4 #include "FWCore/Framework/interface/Event.h"
11 bbetchar 1.1
12     #include "UserCode/ShallowTools/interface/ShallowTools.h"
13 bbetchar 1.2 #include "boost/foreach.hpp"
14 bbetchar 1.1
15     ShallowRechitClustersProducer::ShallowRechitClustersProducer(const edm::ParameterSet& iConfig)
16     : Suffix ( iConfig.getParameter<std::string>("Suffix") ),
17     Prefix ( iConfig.getParameter<std::string>("Prefix") ),
18 bbetchar 1.3 theClustersLabel( iConfig.getParameter<edm::InputTag>("Clusters")),
19 bbetchar 1.1 inputTags ( iConfig.getParameter<std::vector<edm::InputTag> >("InputTags"))
20     {
21     produces <std::vector<float> > ( Prefix + "strip" + Suffix );
22     produces <std::vector<float> > ( Prefix + "merr" + Suffix );
23     produces <std::vector<float> > ( Prefix + "localx" + Suffix );
24     produces <std::vector<float> > ( Prefix + "localy" + Suffix );
25     produces <std::vector<float> > ( Prefix + "localxerr" + Suffix );
26     produces <std::vector<float> > ( Prefix + "localyerr" + Suffix );
27     produces <std::vector<float> > ( Prefix + "globalx" + Suffix );
28     produces <std::vector<float> > ( Prefix + "globaly" + Suffix );
29     produces <std::vector<float> > ( Prefix + "globalz" + Suffix );
30     }
31    
32     void ShallowRechitClustersProducer::
33     produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
34 bbetchar 1.3 shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel);
35 bbetchar 1.1
36     int size = clustermap.size();
37     std::auto_ptr<std::vector<float> > strip ( new std::vector<float>(size, -10000 ));
38     std::auto_ptr<std::vector<float> > merr ( new std::vector<float>(size, -10000 ));
39     std::auto_ptr<std::vector<float> > localx ( new std::vector<float>(size, -10000 ));
40     std::auto_ptr<std::vector<float> > localy ( new std::vector<float>(size, -10000 ));
41     std::auto_ptr<std::vector<float> > localxerr ( new std::vector<float>(size, -1 ));
42     std::auto_ptr<std::vector<float> > localyerr ( new std::vector<float>(size, -1 ));
43     std::auto_ptr<std::vector<float> > globalx ( new std::vector<float>(size, -10000 ));
44     std::auto_ptr<std::vector<float> > globaly ( new std::vector<float>(size, -10000 ));
45     std::auto_ptr<std::vector<float> > globalz ( new std::vector<float>(size, -10000 ));
46    
47     edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
48    
49     BOOST_FOREACH(const edm::InputTag& input, inputTags ) { edm::Handle<SiStripRecHit2DCollection> recHits; iEvent.getByLabel(input, recHits);
50     BOOST_FOREACH( const SiStripRecHit2DCollection::value_type& ds, *recHits) {
51     BOOST_FOREACH( const SiStripRecHit2D& hit, ds) {
52    
53     shallow::CLUSTERMAP::iterator cluster = clustermap.find( std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip() ) );
54     if(cluster != clustermap.end() ) {
55     const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( hit.geographicalId() ) );
56     unsigned int i = cluster->second;
57     strip->at(i) = theStripDet->specificTopology().strip(hit.localPosition());
58     merr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit.localPosition(), hit.localPositionError()).uu());
59     localx->at(i) = hit.localPosition().x();
60     localy->at(i) = hit.localPosition().y();
61     localxerr->at(i) = sqrt(hit.localPositionError().xx());
62     localyerr->at(i) = sqrt(hit.localPositionError().yy());
63     globalx->at(i) = theStripDet->toGlobal(hit.localPosition()).x();
64     globaly->at(i) = theStripDet->toGlobal(hit.localPosition()).y();
65     globalz->at(i) = theStripDet->toGlobal(hit.localPosition()).z();
66     }
67     else {throw cms::Exception("cluster not found");}
68     }
69     }
70     }
71    
72     iEvent.put( strip, Prefix + "strip" + Suffix );
73     iEvent.put( merr, Prefix + "merr" + Suffix );
74     iEvent.put( localx , Prefix + "localx" + Suffix );
75     iEvent.put( localy , Prefix + "localy" + Suffix );
76     iEvent.put( localxerr , Prefix + "localxerr" + Suffix );
77     iEvent.put( localyerr , Prefix + "localyerr" + Suffix );
78     iEvent.put( globalx , Prefix + "globalx" + Suffix );
79     iEvent.put( globaly , Prefix + "globaly" + Suffix );
80     iEvent.put( globalz , Prefix + "globalz" + Suffix );
81     }