CMS 3D CMS Logo

EgammaHLTCombinedIsolationProducer.cc
Go to the documentation of this file.
1 
10 
12 
17 
19 {
20  // use configuration file to setup input/output collection names
21  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
22 
23  std::vector<edm::InputTag> tempIsolTag = conf_.getParameter< std::vector<edm::InputTag> > ("IsolationMapTags");
24  for (unsigned int i=0; i<tempIsolTag.size(); i++)
25  IsolTag_.push_back(consumes<reco::RecoEcalCandidateIsolationMap>(tempIsolTag[i]));
26 
27  IsolWeight_ = conf_.getParameter< std::vector<double> > ("IsolationWeight");
28 
29  //register your products
30  produces < reco::RecoEcalCandidateIsolationMap >();
31 
32  if (IsolTag_.size() != IsolWeight_.size()){
33  throw cms::Exception("BadConfig") << "vectors IsolationMapTags and IsolationWeight need to have the same size";
34  }
35 }
36 
38 {}
39 
41 
43  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate"));
44  desc.add<std::vector<edm::InputTag>>("IsolationMapTags", std::vector<edm::InputTag>());
45  desc.add<std::vector<double>>("IsolationWeight", std::vector<double>());
46  descriptions.add("hltEgammaHLTCombinedIsolationProducer", desc);
47 }
48 
49 
50 // ------------ method called to produce the data ------------
51 void
53 
55  iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle);
56 
58  double TotalIso=0;
59 
60  std::vector< edm::Handle<reco::RecoEcalCandidateIsolationMap> > IsoMap;
61  for( unsigned int u=0; u < IsolWeight_.size(); u++){
63  if(IsolWeight_[u] != 0)
64  iEvent.getByToken(IsolTag_[u], depMapTemp);
65 
66  IsoMap.push_back(depMapTemp);
67  }
68 
69  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
70  reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin());
71  TotalIso = 0;
72  for( unsigned int u=0; u < IsolWeight_.size(); u++){
73  if(IsolWeight_[u]==0){continue;}
74  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*IsoMap[u]).find( recoecalcandref );
75  TotalIso += mapi->val * IsolWeight_[u];
76  }
77  TotalIsolMap.insert(recoecalcandref, TotalIso);
78 
79  }
80 
81  iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(TotalIsolMap));
82 
83 }
84 
85 //define this as a plug-in
86 //DEFINE_FWK_MODULE(EgammaHLTCombinedIsolationProducer);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > > IsolTag_
Definition: config.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
int iEvent
Definition: GenABIO.cc:230
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::Event &, const edm::EventSetup &) override
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)