Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-20 10:42:30

0001 #include "FWCore/Framework/interface/ESHandle.h"
0002 #include "FWCore/Framework/interface/ESProducer.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ModuleFactory.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "TrackingTools/GsfTools/interface/CloseComponentsMerger.h"
0007 #include "TrackingTools/GsfTools/interface/DistanceBetweenComponents.h"
0008 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0009 
0010 #include <iostream>
0011 #include <memory>
0012 #include <string>
0013 
0014 /** Provides the "CloseComponents" algorithm ("Merger") for reducing 
0015  * the number of components in a multi-
0016  */
0017 
0018 template <unsigned int N>
0019 class CloseComponentsMergerESProducer : public edm::ESProducer {
0020 public:
0021   CloseComponentsMergerESProducer(const edm::ParameterSet& p);
0022   ~CloseComponentsMergerESProducer() override;
0023   std::unique_ptr<MultiGaussianStateMerger<N> > produce(const TrackingComponentsRecord&);
0024 
0025   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0026 
0027 private:
0028   const int maxComp_;
0029   const edm::ESGetToken<DistanceBetweenComponents<N>, TrackingComponentsRecord> distToken_;
0030 };
0031 
0032 #include "FWCore/Framework/interface/ModuleFactory.h"
0033 typedef CloseComponentsMergerESProducer<5> CloseComponentsMergerESProducer5D;
0034 DEFINE_FWK_EVENTSETUP_MODULE(CloseComponentsMergerESProducer5D);
0035 
0036 template <unsigned int N>
0037 CloseComponentsMergerESProducer<N>::CloseComponentsMergerESProducer(const edm::ParameterSet& p)
0038     : maxComp_(p.getParameter<int>("MaxComponents")),
0039       distToken_(setWhatProduced(this, p.getParameter<std::string>("ComponentName"))
0040                      .consumes(edm::ESInputTag("", p.getParameter<std::string>("DistanceMeasure")))) {}
0041 
0042 template <unsigned int N>
0043 CloseComponentsMergerESProducer<N>::~CloseComponentsMergerESProducer() {
0044   //   std::cout << "MultiGaussianState: "
0045   //        << MultiGaussianState<5>::instances_ << " "
0046   //        << MultiGaussianState<5>::maxInstances_ << " "
0047   //        << MultiGaussianState<5>::constructsCombinedState_ << std::endl;
0048   //   std::cout << "SingleGaussianState: "
0049   //        << SingleGaussianState<5>::instances_ << " "
0050   //        << SingleGaussianState<5>::maxInstances_ << " "
0051   //        << SingleGaussianState<5>::constructsWeightMatrix_ << std::endl;
0052   //   std::cout << "SingleGaussianState: "
0053   //        << SingleGaussianState<5>::instances_ << " "
0054   //        << SingleGaussianState<5>::maxInstances_ << " "
0055   //        << SingleGaussianState<5>::constructsWeightMatrix_ << std::endl;
0056   //   std::cout << "CloseComponentsMergerESProducer deleted" << std::endl;
0057 }
0058 
0059 template <unsigned int N>
0060 typename std::unique_ptr<MultiGaussianStateMerger<N> > CloseComponentsMergerESProducer<N>::produce(
0061     const TrackingComponentsRecord& iRecord) {
0062   return std::unique_ptr<MultiGaussianStateMerger<N> >(
0063       new CloseComponentsMerger<N>(maxComp_, &iRecord.get(distToken_)));
0064 }
0065 
0066 template <unsigned int N>
0067 void CloseComponentsMergerESProducer<N>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0068   edm::ParameterSetDescription desc;
0069   desc.add<std::string>("ComponentName");
0070   desc.add<int>("MaxComponents");
0071   desc.add<std::string>("DistanceMeasure");
0072 
0073   descriptions.addDefault(desc);
0074 }