CMS 3D CMS Logo

ShallowRechitClustersProducer.cc
Go to the documentation of this file.
2 
10 
12 
14  : Suffix ( iConfig.getParameter<std::string>("Suffix") ),
15  Prefix ( iConfig.getParameter<std::string>("Prefix") ),
16  clusters_token_( consumes< edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("Clusters")))
17 {
18  std::vector<edm::InputTag> rec_hits_tags = iConfig.getParameter<std::vector<edm::InputTag> >("InputTags");
19  for(auto itag : rec_hits_tags) {
20  rec_hits_tokens_.push_back(
21  consumes< SiStripRecHit2DCollection >(itag)
22  );
23  }
24 
25  produces <std::vector<float> > ( Prefix + "strip" + Suffix );
26  produces <std::vector<float> > ( Prefix + "merr" + Suffix );
27  produces <std::vector<float> > ( Prefix + "localx" + Suffix );
28  produces <std::vector<float> > ( Prefix + "localy" + Suffix );
29  produces <std::vector<float> > ( Prefix + "localxerr" + Suffix );
30  produces <std::vector<float> > ( Prefix + "localyerr" + Suffix );
31  produces <std::vector<float> > ( Prefix + "globalx" + Suffix );
32  produces <std::vector<float> > ( Prefix + "globaly" + Suffix );
33  produces <std::vector<float> > ( Prefix + "globalz" + Suffix );
34 }
35 
39 
40  int size = clustermap.size();
41  auto strip = std::make_unique <std::vector<float>>(size, -10000 );
42  auto merr = std::make_unique <std::vector<float>>(size, -10000 );
43  auto localx = std::make_unique <std::vector<float>>(size, -10000 );
44  auto localy = std::make_unique <std::vector<float>>(size, -10000 );
45  auto localxerr = std::make_unique <std::vector<float>>(size, -1 );
46  auto localyerr = std::make_unique <std::vector<float>>(size, -1 );
47  auto globalx = std::make_unique <std::vector<float>>(size, -10000 );
48  auto globaly = std::make_unique <std::vector<float>>(size, -10000 );
49  auto globalz = std::make_unique <std::vector<float>>(size, -10000 );
50 
51  edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
52 
53  for(auto recHit_token : rec_hits_tokens_) {
55  iEvent.getByToken(recHit_token, recHits);
56  for(auto const& ds : *recHits) {
57  for(auto const& hit : ds) {
58 
59  shallow::CLUSTERMAP::iterator cluster = clustermap.find( std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip() ) );
60  if(cluster != clustermap.end() ) {
61  const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( hit.geographicalId() ) );
62  unsigned int i = cluster->second;
63  strip->at(i) = theStripDet->specificTopology().strip(hit.localPosition());
64  merr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit.localPosition(), hit.localPositionError()).uu());
65  localx->at(i) = hit.localPosition().x();
66  localy->at(i) = hit.localPosition().y();
67  localxerr->at(i) = sqrt(hit.localPositionError().xx());
68  localyerr->at(i) = sqrt(hit.localPositionError().yy());
69  globalx->at(i) = theStripDet->toGlobal(hit.localPosition()).x();
70  globaly->at(i) = theStripDet->toGlobal(hit.localPosition()).y();
71  globalz->at(i) = theStripDet->toGlobal(hit.localPosition()).z();
72  }
73  else {throw cms::Exception("cluster not found");}
74  }
75  }
76  }
77 
78  iEvent.put(std::move(strip), Prefix + "strip" + Suffix );
79  iEvent.put(std::move(merr), Prefix + "merr" + Suffix );
80  iEvent.put(std::move(localx), Prefix + "localx" + Suffix );
81  iEvent.put(std::move(localy), Prefix + "localy" + Suffix );
82  iEvent.put(std::move(localxerr), Prefix + "localxerr" + Suffix );
83  iEvent.put(std::move(localyerr), Prefix + "localyerr" + Suffix );
84  iEvent.put(std::move(globalx), Prefix + "globalx" + Suffix );
85  iEvent.put(std::move(globaly), Prefix + "globaly" + Suffix );
86  iEvent.put(std::move(globalz), Prefix + "globalz" + Suffix );
87 }
size
Write out results.
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
ShallowRechitClustersProducer(const edm::ParameterSet &)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
virtual float strip(const LocalPoint &) const =0
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< edm::EDGetTokenT< SiStripRecHit2DCollection > > rec_hits_tokens_
void produce(edm::Event &, const edm::EventSetup &) override
CLUSTERMAP make_cluster_map(const edm::Event &, const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > &)
Definition: ShallowTools.cc:13
HLT enums.
std::map< std::pair< uint32_t, uint16_t >, unsigned int > CLUSTERMAP
Definition: ShallowTools.h:19
T get() const
Definition: EventSetup.h:71
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
def move(src, dest)
Definition: eostools.py:511