Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-17 23:31:51

0001 // system includes
0002 #include <memory>
0003 
0004 // user includes
0005 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0006 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0007 #include "FWCore/Framework/interface/stream/EDProducer.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithm.h"
0014 #include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithmFactory.h"
0015 
0016 class StripByStripTestDriver : public edm::stream::EDProducer<> {
0017   typedef edmNew::DetSetVector<SiStripCluster> output_t;
0018 
0019 public:
0020   StripByStripTestDriver(const edm::ParameterSet&);
0021   ~StripByStripTestDriver();
0022 
0023 private:
0024   void produce(edm::Event&, const edm::EventSetup&);
0025 
0026   const edm::InputTag inputTag;
0027   const edm::EDGetTokenT<edm::DetSetVector<SiStripDigi>> siStripDigisToken;
0028   const bool hlt;
0029 
0030   std::unique_ptr<StripClusterizerAlgorithm> algorithm;
0031 };
0032 
0033 StripByStripTestDriver::StripByStripTestDriver(const edm::ParameterSet& conf)
0034     : inputTag(conf.getParameter<edm::InputTag>("DigiProducer")),
0035       siStripDigisToken(consumes<edm::DetSetVector<SiStripDigi>>(inputTag)),
0036       hlt(conf.getParameter<bool>("HLT")) {
0037   algorithm = StripClusterizerAlgorithmFactory::create(consumesCollector(), conf);
0038 
0039   produces<output_t>("");
0040 }
0041 
0042 StripByStripTestDriver::~StripByStripTestDriver() = default;
0043 
0044 void StripByStripTestDriver::produce(edm::Event& event, const edm::EventSetup& es) {
0045   auto output = std::make_unique<output_t>();
0046   output->reserve(10000, 4 * 10000);
0047 
0048   edm::Handle<edm::DetSetVector<SiStripDigi>> input;
0049   event.getByToken(siStripDigisToken, input);
0050 
0051   algorithm->initialize(es);
0052 
0053   for (auto const& inputDetSet : *input) {
0054     output_t::TSFastFiller filler(*output, inputDetSet.detId());
0055 
0056     auto const& det = algorithm->stripByStripBegin(inputDetSet.detId());
0057     if (!det.valid())
0058       continue;
0059     StripClusterizerAlgorithm::State state(det);
0060     for (auto const& digi : inputDetSet)
0061       algorithm->stripByStripAdd(state, digi.strip(), digi.adc(), filler);
0062     algorithm->stripByStripEnd(state, filler);
0063   }
0064 
0065   edm::LogInfo("Output") << output->dataSize() << " clusters from " << output->size() << " modules";
0066   event.put(std::move(output));
0067 }
0068 
0069 #include "FWCore/Framework/interface/MakerMacros.h"
0070 DEFINE_FWK_MODULE(StripByStripTestDriver);