Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:30

0001 #ifndef IsolationAlgos_CalIsolationAlgo_h
0002 #define IsolationAlgos_CalIsolationAlgo_h
0003 /* Partial spacialization of parameter set adapeter helper
0004  *
0005  */
0006 #include "PhysicsTools/IsolationAlgos/interface/CalIsolationAlgo.h"
0007 #include "PhysicsTools/IsolationAlgos/interface/IsolationProducer.h"
0008 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 
0013 namespace helper {
0014 
0015   template <typename Alg>
0016   struct BFieldIsolationAlgorithmSetup {
0017     using ESConsumesToken = edm::ESGetToken<MagneticField, IdealMagneticFieldRecord>;
0018     static ESConsumesToken esConsumes(edm::ConsumesCollector cc) {
0019       return cc.esConsumes<MagneticField, IdealMagneticFieldRecord>();
0020     }
0021     static void init(Alg& algo, const edm::EventSetup& es, const ESConsumesToken& token) {
0022       algo.setBfield(&es.getData(token));
0023     }
0024   };
0025 
0026   template <typename T1, typename C2>
0027   struct IsolationAlgorithmSetup<CalIsolationAlgo<T1, C2> > {
0028     typedef BFieldIsolationAlgorithmSetup<CalIsolationAlgo<T1, C2> > type;
0029   };
0030 }  // namespace helper
0031 
0032 namespace reco {
0033   namespace modules {
0034 
0035     template <typename T, typename C>
0036     struct ParameterAdapter<CalIsolationAlgo<T, C> > {
0037       static CalIsolationAlgo<T, C> make(const edm::ParameterSet& cfg) {
0038         bool propagate = cfg.template getParameter<bool>("PropagateToCal");
0039         double r = 0.0, minz = 0.0, maxz = 0.0;
0040         bool material = false;
0041         //allow for undefined propagation-parameters, if no propagation is wanted
0042         if (propagate) {
0043           r = cfg.template getParameter<double>("CalRadius");
0044           minz = cfg.template getParameter<double>("CalMinZ");
0045           maxz = cfg.template getParameter<double>("CalMaxZ");
0046           material = cfg.template getParameter<bool>("IgnoreMaterial");
0047         }
0048         return CalIsolationAlgo<T, C>(cfg.template getParameter<double>("dRMin"),
0049                                       cfg.template getParameter<double>("dRMax"),
0050                                       propagate,
0051                                       r,
0052                                       minz,
0053                                       maxz,
0054                                       material);
0055       }
0056     };
0057   }  // namespace modules
0058 }  // namespace reco
0059 
0060 #endif