CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsolationProducerNew.h
Go to the documentation of this file.
1 #ifndef IsolationAlgos_IsolationProducer_h
2 #define IsolationAlgos_IsolationProducer_h
3 /* \class IsolationProducer<C1, C2, Algo>
4  *
5  * \author Francesco Fabozzi, INFN
6  *
7  * template class to store isolation
8  *
9  */
19 #include <vector>
20 
21 namespace helper {
22 
23  template<typename Alg>
24  struct NullIsolationAlgorithmSetup {
25  static void init( Alg &, const edm::EventSetup& ) { }
26  };
27 
28  template<typename Alg>
29  struct IsolationAlgorithmSetup {
31  };
32 }
33 
34 namespace reco {
35  namespace modulesNew {
36 
37  template <typename C1, typename C2, typename Alg,
39  typename Setup = typename helper::IsolationAlgorithmSetup<Alg>::type>
41  public:
44 
45  private:
46  void produce( edm::Event&, const edm::EventSetup& );
48  Alg alg_;
49  };
50 
51  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
53  src_( cfg.template getParameter<edm::InputTag>( "src" ) ),
54  elements_( cfg.template getParameter<edm::InputTag>( "elements" ) ),
55  alg_( reco::modules::make<Alg>( cfg ) ) {
56  produces<OutputCollection>();
57  }
58 
59  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
61  }
62 
63  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
65  using namespace edm;
66  using namespace std;
69  evt.getByLabel(src_, src);
70  evt.getByLabel(elements_, elements);
71 
72  Setup::init(alg_, es);
73 
75  auto_ptr<OutputCollection> isolations(new OutputCollection);
76  if(src->size()!= 0) {
77  typename OutputCollection::Filler filler(*isolations);
78  vector<double> iso(master.size(),-1);
79  size_t i = 0;
80  for( typename C1::const_iterator lep = src->begin(); lep != src->end(); ++ lep )
81  iso[master.index(i++)] = alg_(*lep, *elements);
82  filler.insert(master.get(), iso.begin(), iso.end());
83  filler.fill();
84  }
85  evt.put( isolations );
86  }
87 
88  }
89 }
90 
91 #endif
const edm::Handle< C1 > & get() const
Master< F > master(const F &f)
Definition: FunctClone.h:68
int i
Definition: DBlmapReader.cc:9
std::vector< ProtoJet > OutputCollection
Definition: JetRecoTypes.h:63
static void init(Alg &, const edm::EventSetup &)
int init
Definition: HydjetWrapper.h:63
S make(const edm::ParameterSet &cfg)
list elements
Definition: asciidump.py:414
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
size_t index(size_t i) const
void produce(edm::Event &, const edm::EventSetup &)
IsolationProducer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
NullIsolationAlgorithmSetup< Alg > type
def template
Definition: svgfig.py:520