File indexing completed on 2023-03-28 01:34:33
0001
0002
0003 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0004 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0005
0006 #include "FWCore/Framework/interface/stream/EDProducer.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0010 #include "FWCore/Utilities/interface/InputTag.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015
0016 #include "CUDADataFormats/SiStripCluster/interface/SiStripClustersCUDA.h"
0017
0018 #include <memory>
0019
0020 class SiStripClustersFromSOA final : public edm::stream::EDProducer<> {
0021 public:
0022 explicit SiStripClustersFromSOA(const edm::ParameterSet& conf)
0023 : inputToken_(consumes<SiStripClustersCUDAHost>(conf.getParameter<edm::InputTag>("ProductLabel"))),
0024 outputToken_(produces<edmNew::DetSetVector<SiStripCluster>>()) {}
0025
0026 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0027 edm::ParameterSetDescription desc;
0028
0029 desc.add("ProductLabel", edm::InputTag("siStripClustersSOAtoHost"));
0030 descriptions.addWithDefaultLabel(desc);
0031 }
0032
0033 private:
0034 void produce(edm::Event& ev, const edm::EventSetup& es) override {
0035 const auto& clust_data = ev.get(inputToken_);
0036
0037 const int nSeedStripsNC = clust_data.nClusters();
0038 const auto clusterSize = clust_data.clusterSize().get();
0039 const auto clusterADCs = clust_data.clusterADCs().get();
0040 const auto detIDs = clust_data.clusterDetId().get();
0041 const auto stripIDs = clust_data.firstStrip().get();
0042 const auto trueCluster = clust_data.trueCluster().get();
0043
0044 const unsigned int initSeedStripsSize = 15000;
0045
0046 using out_t = edmNew::DetSetVector<SiStripCluster>;
0047 auto output{std::make_unique<out_t>(edmNew::DetSetVector<SiStripCluster>())};
0048 output->reserve(initSeedStripsSize, nSeedStripsNC);
0049
0050 std::vector<uint8_t> adcs;
0051
0052 for (int i = 0; i < nSeedStripsNC;) {
0053 const auto detid = detIDs[i];
0054 out_t::FastFiller record(*output, detid);
0055
0056 while (i < nSeedStripsNC && detIDs[i] == detid) {
0057 if (trueCluster[i]) {
0058 const auto size = clusterSize[i];
0059 const auto firstStrip = stripIDs[i];
0060
0061 adcs.clear();
0062 adcs.reserve(size);
0063
0064 for (uint32_t j = 0; j < size; ++j) {
0065 adcs.push_back(clusterADCs[i + j * nSeedStripsNC]);
0066 }
0067 record.push_back(SiStripCluster(firstStrip, std::move(adcs)));
0068 }
0069 i++;
0070 }
0071 }
0072
0073 output->shrink_to_fit();
0074 ev.put(std::move(output));
0075 }
0076
0077 private:
0078 edm::EDGetTokenT<SiStripClustersCUDAHost> inputToken_;
0079 edm::EDPutTokenT<edmNew::DetSetVector<SiStripCluster>> outputToken_;
0080 };
0081
0082 #include "FWCore/Framework/interface/MakerMacros.h"
0083 DEFINE_FWK_MODULE(SiStripClustersFromSOA);