test
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 
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  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> Map(new reco::RecoEcalCandidateIsolationMap(TotalIsolMap));
82  iEvent.put(Map);
83 
84 }
85 
86 //define this as a plug-in
87 //DEFINE_FWK_MODULE(EgammaHLTCombinedIsolationProducer);
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > > IsolTag_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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)