ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ShallowTools/plugins/ShallowRechitClustersProducer.cc
Revision: 1.1
Committed: Sat Jun 6 14:23:09 2009 UTC (15 years, 11 months ago) by bbetchar
Content type: text/plain
Branch: MAIN
CVS Tags: V03-00-02, V03-00-01, V03-00-00
Log Message:
Move directories around

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