CMS 3D CMS Logo

TTClusterBuilder.cc
Go to the documentation of this file.
1 
11 
13 template <>
16  auto ttClusterDSVForOutput = std::make_unique<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>();
17  std::map<DetId, std::vector<Ref_Phase2TrackerDigi_>> rawHits;
18  this->RetrieveRawHits(rawHits, iEvent);
19 
20  // Retrieve tracker topology from geometry
21  const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken);
22  const TrackerGeometry* const theTrackerGeom = &iSetup.getData(tGeomToken);
23  auto const& theClusterFindingAlgo = iSetup.getData(theClusterFindingAlgoToken);
24 
25  // Loop on the OT stacks
26  for (auto gd = theTrackerGeom->dets().begin(); gd != theTrackerGeom->dets().end(); gd++) {
27  DetId detid = (*gd)->geographicalId();
28  if (detid.subdetId() == 1 || detid.subdetId() == 2)
29  continue; // only run on OT
30  if (!tTopo->isLower(detid))
31  continue; // loop on the stacks: choose the lower arbitrarily
32  DetId lowerDetid = detid;
33  DetId upperDetid = tTopo->partnerDetId(detid);
34 
37  std::vector<std::vector<Ref_Phase2TrackerDigi_>> lowerHits, upperHits;
38 
40  typename std::map<DetId, std::vector<Ref_Phase2TrackerDigi_>>::const_iterator lowerHitFind =
41  rawHits.find(lowerDetid);
42  typename std::map<DetId, std::vector<Ref_Phase2TrackerDigi_>>::const_iterator upperHitFind =
43  rawHits.find(upperDetid);
44 
48  bool isPSP = (theTrackerGeom->getDetectorType(lowerDetid) == TrackerGeometry::ModuleType::Ph2PSP);
49  if (lowerHitFind != rawHits.end())
50  theClusterFindingAlgo.Cluster(lowerHits, lowerHitFind->second, isPSP);
51  if (upperHitFind != rawHits.end())
52  theClusterFindingAlgo.Cluster(upperHits, upperHitFind->second, false);
53 
56  {
57  edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>::FastFiller lowerOutputFiller(*ttClusterDSVForOutput,
58  lowerDetid);
59  for (unsigned int i = 0; i < lowerHits.size(); i++) {
60  TTCluster<Ref_Phase2TrackerDigi_> temp(lowerHits.at(i), lowerDetid, 0, storeLocalCoord);
61  lowerOutputFiller.push_back(temp);
62  }
63  if (lowerOutputFiller.empty())
64  lowerOutputFiller.abort();
65  }
66  {
67  edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>::FastFiller upperOutputFiller(*ttClusterDSVForOutput,
68  upperDetid);
69  for (unsigned int i = 0; i < upperHits.size(); i++) {
70  TTCluster<Ref_Phase2TrackerDigi_> temp(upperHits.at(i), upperDetid, 1, storeLocalCoord);
71  upperOutputFiller.push_back(temp);
72  }
73  if (upperOutputFiller.empty())
74  upperOutputFiller.abort();
75  }
76  }
77 
79  iEvent.put(std::move(ttClusterDSVForOutput), "ClusterInclusive");
80 }
81 
83 template <>
85  std::map<DetId, std::vector<Ref_Phase2TrackerDigi_>>& mRawHits, const edm::Event& iEvent) {
86  mRawHits.clear();
88  std::vector<edm::EDGetTokenT<edm::DetSetVector<Phase2TrackerDigi>>>::iterator it;
89  for (it = rawHitTokens.begin(); it != rawHitTokens.end(); ++it) {
92  iEvent.getByToken(*it, HitHandle);
95 
97  for (detsIter = HitHandle->begin(); detsIter != HitHandle->end(); detsIter++) {
98  DetId id = detsIter->id;
99  for (hitsIter = detsIter->data.begin(); hitsIter != detsIter->data.end(); hitsIter++) {
100  mRawHits[id].push_back(edm::makeRefTo(HitHandle, id, hitsIter));
101  }
102  }
103  }
104 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
Item & push_back(id_type iid)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
void RetrieveRawHits(std::map< DetId, std::vector< T > > &mRawHits, const edm::Event &iEvent)
Get hits.
int iEvent
Definition: GenABIO.cc:224
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::const_iterator itIter)
Definition: DetSetVector.h:409
ModuleType getDetectorType(DetId) const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Mandatory methods.
DetId partnerDetId(const DetId &id) const
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:316
Definition: DetId.h:17
bool isLower(const DetId &id) const
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:305
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
def move(src, dest)
Definition: eostools.py:511