CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTCombinedIsolationProducer.cc
Go to the documentation of this file.
1 
10 
11 // Framework
18 
21 
24 
26 {
27  // use configuration file to setup input/output collection names
28  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
29 
30  IsolTag_ = conf_.getParameter< std::vector<edm::InputTag> > ("IsolationMapTags");
31  IsolWeight_ = conf_.getParameter< std::vector<double> > ("IsolationWeight");
32 
33  //register your products
34  produces < reco::RecoEcalCandidateIsolationMap >();
35 
36  if ( IsolTag_.size() != IsolWeight_.size()){
37  throw cms::Exception("BadConfig") << "vectors IsolationMapTags and IsolationWeight need to have the same size";
38  }
39 
40 }
41 
42 
44 
45 
46 //
47 // member functions
48 //
49 
50 // ------------ method called to produce the data ------------
51 void
53 {
54 
56  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
57 
59  double TotalIso=0;
60 
61  std::vector< edm::Handle<reco::RecoEcalCandidateIsolationMap> > IsoMap;
62  for( unsigned int u=0; u < IsolWeight_.size(); u++){
64  if(IsolWeight_[u] != 0){ iEvent.getByLabel (IsolTag_[u],depMapTemp);}
65  IsoMap.push_back(depMapTemp);
66  }
67 
68  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
69  reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin());
70  TotalIso = 0;
71  for( unsigned int u=0; u < IsolWeight_.size(); u++){
72  if(IsolWeight_[u]==0){continue;}
73  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*IsoMap[u]).find( recoecalcandref );
74  TotalIso += mapi->val * IsolWeight_[u];
75  }
76  TotalIsolMap.insert(recoecalcandref, TotalIso);
77 
78  }
79 
80  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> Map(new reco::RecoEcalCandidateIsolationMap(TotalIsolMap));
81  iEvent.put(Map);
82 
83 }
84 
85 //define this as a plug-in
86 //DEFINE_FWK_MODULE(EgammaHLTCombinedIsolationProducer);
T getParameter(std::string const &) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void insert(const key_type &k, const data_type &v)
insert an association