Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:30:44

0001 #include "RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusterizer.h"
0002 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0003 #include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithmFactory.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Utilities/interface/transform.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 SiStripClusterizer::SiStripClusterizer(const edm::ParameterSet& conf)
0009     : inputTags(conf.getParameter<std::vector<edm::InputTag>>("DigiProducersList")),
0010       algorithm(StripClusterizerAlgorithmFactory::create(consumesCollector(),
0011                                                          conf.getParameter<edm::ParameterSet>("Clusterizer"))) {
0012   produces<edmNew::DetSetVector<SiStripCluster>>();
0013   inputTokens = edm::vector_transform(
0014       inputTags, [this](edm::InputTag const& tag) { return consumes<edm::DetSetVector<SiStripDigi>>(tag); });
0015 }
0016 
0017 void SiStripClusterizer::produce(edm::Event& event, const edm::EventSetup& es) {
0018   auto output = std::make_unique<edmNew::DetSetVector<SiStripCluster>>();
0019   output->reserve(10000, 4 * 10000);
0020 
0021   edm::Handle<edm::DetSetVector<SiStripDigi>> inputOld;
0022   //   edm::Handle< edmNew::DetSetVector<SiStripDigi> >  inputNew;
0023 
0024   algorithm->initialize(es);
0025 
0026   for (auto const& token : inputTokens) {
0027     if (findInput(token, inputOld, event))
0028       algorithm->clusterize(*inputOld, *output);
0029     //     else if( findInput( tag, inputNew, event) ) algorithm->clusterize(*inputNew, *output);
0030     else
0031       edm::LogError("Input Not Found") << "[SiStripClusterizer::produce] ";  // << tag;
0032   }
0033 
0034   LogDebug("Output") << output->dataSize() << " clusters from " << output->size() << " modules";
0035   output->shrink_to_fit();
0036   event.put(std::move(output));
0037 }
0038 
0039 template <class T>
0040 inline bool SiStripClusterizer::findInput(const edm::EDGetTokenT<T>& tag, edm::Handle<T>& handle, const edm::Event& e) {
0041   e.getByToken(tag, handle);
0042   return handle.isValid();
0043 }