CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ShallowRechitClustersProducer.cc
Go to the documentation of this file.
2 
8 
10 
12  : Suffix(iConfig.getParameter<std::string>("Suffix")),
13  Prefix(iConfig.getParameter<std::string>("Prefix")),
15  clusters_token_(consumes<edmNew::DetSetVector<SiStripCluster>>(iConfig.getParameter<edm::InputTag>("Clusters"))) {
16  std::vector<edm::InputTag> rec_hits_tags = iConfig.getParameter<std::vector<edm::InputTag>>("InputTags");
17  for (const auto& itag : rec_hits_tags) {
18  rec_hits_tokens_.push_back(consumes<SiStripRecHit2DCollection>(itag));
19  }
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 
34 
35  int size = clustermap.size();
36  auto strip = std::make_unique<std::vector<float>>(size, -10000);
37  auto merr = std::make_unique<std::vector<float>>(size, -10000);
38  auto localx = std::make_unique<std::vector<float>>(size, -10000);
39  auto localy = std::make_unique<std::vector<float>>(size, -10000);
40  auto localxerr = std::make_unique<std::vector<float>>(size, -1);
41  auto localyerr = std::make_unique<std::vector<float>>(size, -1);
42  auto globalx = std::make_unique<std::vector<float>>(size, -10000);
43  auto globaly = std::make_unique<std::vector<float>>(size, -10000);
44  auto globalz = std::make_unique<std::vector<float>>(size, -10000);
45 
46  edm::ESHandle<TrackerGeometry> theTrackerGeometry = iSetup.getHandle(geomToken_);
47 
48  for (auto recHit_token : rec_hits_tokens_) {
50  iEvent.getByToken(recHit_token, recHits);
51  for (auto const& ds : *recHits) {
52  for (auto const& hit : ds) {
53  shallow::CLUSTERMAP::iterator cluster =
54  clustermap.find(std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip()));
55  if (cluster != clustermap.end()) {
56  const StripGeomDetUnit* theStripDet =
57  dynamic_cast<const StripGeomDetUnit*>(theTrackerGeometry->idToDet(hit.geographicalId()));
58  unsigned int i = cluster->second;
59  strip->at(i) = theStripDet->specificTopology().strip(hit.localPosition());
60  merr->at(i) = sqrt(
61  theStripDet->specificTopology().measurementError(hit.localPosition(), hit.localPositionError()).uu());
62  localx->at(i) = hit.localPosition().x();
63  localy->at(i) = hit.localPosition().y();
64  localxerr->at(i) = sqrt(hit.localPositionError().xx());
65  localyerr->at(i) = sqrt(hit.localPositionError().yy());
66  globalx->at(i) = theStripDet->toGlobal(hit.localPosition()).x();
67  globaly->at(i) = theStripDet->toGlobal(hit.localPosition()).y();
68  globalz->at(i) = theStripDet->toGlobal(hit.localPosition()).z();
69  } else {
70  throw cms::Exception("cluster not found");
71  }
72  }
73  }
74  }
75 
76  iEvent.put(std::move(strip), Prefix + "strip" + Suffix);
77  iEvent.put(std::move(merr), Prefix + "merr" + Suffix);
78  iEvent.put(std::move(localx), Prefix + "localx" + Suffix);
79  iEvent.put(std::move(localy), Prefix + "localy" + Suffix);
80  iEvent.put(std::move(localxerr), Prefix + "localxerr" + Suffix);
81  iEvent.put(std::move(localyerr), Prefix + "localyerr" + Suffix);
82  iEvent.put(std::move(globalx), Prefix + "globalx" + Suffix);
83  iEvent.put(std::move(globaly), Prefix + "globaly" + Suffix);
84  iEvent.put(std::move(globalz), Prefix + "globalz" + Suffix);
85 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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:49
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
virtual float strip(const LocalPoint &) const =0
int iEvent
Definition: GenABIO.cc:224
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
std::vector< edm::EDGetTokenT< SiStripRecHit2DCollection > > rec_hits_tokens_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CLUSTERMAP make_cluster_map(const edm::Event &, const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > &)
Definition: ShallowTools.cc:12
std::map< std::pair< uint32_t, uint16_t >, unsigned int > CLUSTERMAP
Definition: ShallowTools.h:21
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tuple size
Write out results.