CMS 3D CMS Logo

SiPixelRecHitConverter.cc
Go to the documentation of this file.
1 
12 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 
42 //--- Base class for CPEs:
43 
45 
46 //--- Geometry + DataFormats
51 
52 //--- Framework
57 
64 
65 // Geometry
68 
69 // Data Formats
73 
74 // STL
75 #include <vector>
76 #include <memory>
77 #include <string>
78 #include <iostream>
79 
80 // MessageLogger
82 
84 
85 // Make heterogeneous framework happy
88 
89 using namespace std;
90 
91 namespace cms {
92 
94  public:
95  //--- Constructor, virtual destructor (just in case)
96  explicit SiPixelRecHitConverter(const edm::ParameterSet& conf);
97  ~SiPixelRecHitConverter() override;
98 
99  //--- Factory method to make CPE's depending on the ParameterSet
100  //--- Not sure if we need to make more than one CPE to run concurrently
101  //--- on different parts of the detector (e.g., one for the barrel and the
102  //--- one for the forward). The way the CPE's are written now, it's
103  //--- likely we can use one (and they will switch internally), or
104  //--- make two of the same but configure them differently. We need a more
105  //--- realistic use case...
106 
107  //--- The top-level event method.
108  void produce(edm::Event& e, const edm::EventSetup& c) override;
109 
110  //--- Execute the position estimator algorithm(s).
111  void run(edm::Event& e,
114  TrackerGeometry const& geom);
115 
116  private:
118 
119  // TO DO: maybe allow a map of pointers?
121  PixelCPEBase const* cpe_ = nullptr; // What we got (for now, one ptr to base class)
128  bool m_newCont; // save also in emdNew::DetSetVector
129  };
130 
131  //---------------------------------------------------------------------------
133  //---------------------------------------------------------------------------
134  SiPixelRecHitConverter::SiPixelRecHitConverter(edm::ParameterSet const& conf)
135  : src_(conf.getParameter<edm::InputTag>("src")),
136  tPixelCluster_(consumes<edmNew::DetSetVector<SiPixelCluster>>(src_)),
137  tPut_(produces<SiPixelRecHitCollection>()),
138  tHost_(produces<HMSstorage>()),
141  edm::ESInputTag("", conf.getParameter<std::string>("CPE")))) {}
142 
143  // Destructor
145 
146  //---------------------------------------------------------------------------
148  //---------------------------------------------------------------------------
150  // Step A.1: get input data
152  e.getByToken(tPixelCluster_, input);
153 
154  // Step A.2: get event setup
155  auto const& geom = es.getData(tTrackerGeom_);
156 
157  // Step B: create empty output collection
159 
160  // Step B*: create CPE
161  cpe_ = dynamic_cast<const PixelCPEBase*>(&es.getData(tCPE_));
162 
163  // Step C: Iterate over DetIds and invoke the strip CPE algorithm
164  // on each DetUnit
165 
166  run(e, input, output, geom);
167 
168  output.shrink_to_fit();
169  e.emplace(tPut_, std::move(output));
170  }
171 
172  //---------------------------------------------------------------------------
176  //---------------------------------------------------------------------------
180  TrackerGeometry const& geom) {
181  if (!cpe_) {
182  edm::LogError("SiPixelRecHitConverter") << " at least one CPE is not ready -- can't run!";
183  // TO DO: throw an exception here? The user may want to know...
184  assert(0);
185  return; // clusterizer is invalid, bail out
186  }
187 
188  int numberOfDetUnits = 0;
189  int numberOfClusters = 0;
190 
191  const edmNew::DetSetVector<SiPixelCluster>& input = *inputhandle;
192 
193  // allocate a buffer for the indices of the clusters
194  auto hmsp = std::make_unique<uint32_t[]>(gpuClustering::maxNumModules + 1);
195  // hitsModuleStart is a non-owning pointer to the buffer
196  auto hitsModuleStart = hmsp.get();
197  // fill cluster arrays
198  std::array<uint32_t, gpuClustering::maxNumModules + 1> clusInModule{};
199  for (auto const& dsv : input) {
200  unsigned int detid = dsv.detId();
201  DetId detIdObject(detid);
202  const GeomDetUnit* genericDet = geom.idToDetUnit(detIdObject);
203  auto gind = genericDet->index();
204  // FIXME to be changed to support Phase2
205  if (gind >= int(gpuClustering::maxNumModules))
206  continue;
207  auto const nclus = dsv.size();
208  assert(nclus > 0);
209  clusInModule[gind] = nclus;
210  numberOfClusters += nclus;
211  }
212  hitsModuleStart[0] = 0;
213  assert(clusInModule.size() > gpuClustering::maxNumModules);
214  for (int i = 1, n = clusInModule.size(); i < n; ++i)
215  hitsModuleStart[i] = hitsModuleStart[i - 1] + clusInModule[i - 1];
216  assert(numberOfClusters == int(hitsModuleStart[gpuClustering::maxNumModules]));
217 
218  // wrap the buffer in a HostProduct, and move it to the Event, without reallocating the buffer or affecting hitsModuleStart
219  iEvent.emplace(tHost_, std::move(hmsp));
220 
221  numberOfClusters = 0;
222  for (auto const& dsv : input) {
223  numberOfDetUnits++;
224  unsigned int detid = dsv.detId();
225  DetId detIdObject(detid);
226  const GeomDetUnit* genericDet = geom.idToDetUnit(detIdObject);
227  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
228  assert(pixDet);
229  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(output, detid);
230 
231  edmNew::DetSet<SiPixelCluster>::const_iterator clustIt = dsv.begin(), clustEnd = dsv.end();
232 
233  for (; clustIt != clustEnd; clustIt++) {
234  numberOfClusters++;
235  std::tuple<LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType> tuple =
236  cpe_->getParameters(*clustIt, *genericDet);
237  LocalPoint lp(std::get<0>(tuple));
238  LocalError le(std::get<1>(tuple));
239  SiPixelRecHitQuality::QualWordType rqw(std::get<2>(tuple));
240  // Create a persistent edm::Ref to the cluster
242  edmNew::makeRefTo(inputhandle, clustIt);
243  // Make a RecHit and add it to the DetSet
244  // old : recHitsOnDetUnit.push_back( new SiPixelRecHit( lp, le, detIdObject, &*clustIt) );
245  SiPixelRecHit hit(lp, le, rqw, *genericDet, cluster);
246  //
247  // Now save it =================
248  recHitsOnDetUnit.push_back(hit);
249  // =============================
250 
251  // std::cout << "SiPixelRecHitConverterVI " << numberOfClusters << ' '<< lp << " " << le << std::endl;
252  } // <-- End loop on Clusters
253 
254  // LogDebug("SiPixelRecHitConverter")
255  //std::cout << "SiPixelRecHitConverterVI "
256  // << " Found " << recHitsOnDetUnit.size() << " RecHits on " << detid //;
257  // << std::endl;
258 
259  } // <-- End loop on DetUnits
260 
261  // LogDebug ("SiPixelRecHitConverter")
262  // std::cout << "SiPixelRecHitConverterVI "
263  // << cpeName_ << " converted " << numberOfClusters
264  // << " SiPixelClusters into SiPixelRecHits, in "
265  // << numberOfDetUnits << " DetUnits." //;
266  // << std::endl;
267  }
268 } // end of namespace cms
269 
271 
PixelClusterParameterEstimator
Definition: PixelClusterParameterEstimator.h:15
PixelCPEBase::getParameters
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const override
Definition: PixelCPEBase.h:133
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
cms::SiPixelRecHitConverter::run
void run(edm::Event &e, edm::Handle< edmNew::DetSetVector< SiPixelCluster >> inputhandle, SiPixelRecHitCollectionNew &output, TrackerGeometry const &geom)
Definition: SiPixelRecHitConverter.cc:177
MessageLogger.h
cms::SiPixelRecHitConverter::src_
const edm::InputTag src_
Definition: SiPixelRecHitConverter.cc:122
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
TrackerGeometry.h
cms::SiPixelRecHitConverter::cpe_
PixelCPEBase const * cpe_
const PixelClusterParameterEstimator * cpe_; // what we got (for now, one ptr to base class)
Definition: SiPixelRecHitConverter.cc:121
GeomDet
Definition: GeomDet.h:27
cms::SiPixelRecHitConverter::tPut_
const edm::EDPutTokenT< SiPixelRecHitCollection > tPut_
Definition: SiPixelRecHitConverter.cc:124
ESHandle.h
ESInputTag
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
SiPixelCluster.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edmNew::makeRefTo
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
Definition: DetSetVectorNew.h:704
TkPixelCPERecord
Definition: TkPixelCPERecord.h:18
cms::cuda::assert
assert(be >=bs)
EDProducer.h
PixelCPEBase.h
HostProduct.h
GeomDet::index
int index() const
Definition: GeomDet.h:83
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
edmNew::DetSetVector::FastFiller::push_back
void push_back(data_type const &d)
Definition: DetSetVectorNew.h:283
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edmNew
Definition: DetSet2RangeMap.h:11
edm::Ref
Definition: AssociativeIterator.h:58
DetId
Definition: DetId.h:17
MakerMacros.h
cms::SiPixelRecHitConverter::tCPE_
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > tCPE_
Definition: SiPixelRecHitConverter.cc:127
cms::SiPixelRecHitConverter::~SiPixelRecHitConverter
~SiPixelRecHitConverter() override
Definition: SiPixelRecHitConverter.cc:144
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelRecHitQuality::QualWordType
unsigned int QualWordType
Definition: SiPixelRecHitQuality.h:9
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:16
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, LocalTag >
gpuClustering::maxNumModules
constexpr uint16_t maxNumModules
Definition: gpuClusteringConstants.h:18
TrackerDigiGeometryRecord.h
SiPixelRecHitCollection.h
edm::ParameterSet
Definition: ParameterSet.h:47
HostProduct
Definition: HostProduct.h:8
Event.h
EDPutToken.h
LocalError
Definition: LocalError.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
gpuClusteringConstants.h
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
cms::SiPixelRecHitConverter
Definition: SiPixelRecHitConverter.cc:93
DetSetVector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord >
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
edmNew::DetSetVector
Definition: DetSetNew.h:13
cms::SiPixelRecHitConverter::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
The "Event" entrypoint: gets called by framework for every event.
Definition: SiPixelRecHitConverter.cc:149
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Ref.h
DetId.h
cms::SiPixelRecHitConverter::tPixelCluster_
const edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > tPixelCluster_
Definition: SiPixelRecHitConverter.cc:123
PixelCPEBase
Definition: PixelCPEBase.h:43
PixelGeomDetUnit.h
EventSetup.h
DetSet2RangeMap.h
TkPixelCPERecord.h
cms::SiPixelRecHitConverter::m_newCont
bool m_newCont
Definition: SiPixelRecHitConverter.cc:128
edmNew::DetSetVector::FastFiller
Definition: DetSetVectorNew.h:202
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
cms::SiPixelRecHitConverter::tHost_
const edm::EDPutTokenT< HMSstorage > tHost_
Definition: SiPixelRecHitConverter.cc:125
cms::SiPixelRecHitConverter::tTrackerGeom_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tTrackerGeom_
Definition: SiPixelRecHitConverter.cc:126
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TrackerGeometry
Definition: TrackerGeometry.h:14
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31