CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTBcHcalIsolationProducersRegional.cc
Go to the documentation of this file.
1 /* \class EgammaHLTBcHcalIsolationProducersRegional
2  *
3  * \author Matteo Sani (UCSD)
4  *
5  */
6 
9 
12 
16 
21 
25 
27 
28  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
29  caloTowerProducer_ = consumes<CaloTowerCollection>(config.getParameter<edm::InputTag>("caloTowerProducer"));
30 
31  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
32  if (doRhoCorrection_)
33  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
34 
35  rhoMax_ = config.getParameter<double>("rhoMax");
36  rhoScale_ = config.getParameter<double>("rhoScale");
37 
38  etMin_ = config.getParameter<double>("etMin");
39  innerCone_ = config.getParameter<double>("innerCone");
40  outerCone_ = config.getParameter<double>("outerCone");
41  depth_ = config.getParameter<int>("depth");
42  doEtSum_ = config.getParameter<bool>("doEtSum");
43  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
44  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
45 
46  useSingleTower_ = config.getParameter<bool>("useSingleTower");
47 
49  hcalCfg_.useTowers = true;
52 
54 
55  produces <reco::RecoEcalCandidateIsolationMap>();
56 }
57 
59  delete hcalHelper_;
60 }
61 
63 
65 
66  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate"));
67  desc.add<edm::InputTag>(("caloTowerProducer"), edm::InputTag("hltTowerMakerForAll"));
68  desc.add<edm::InputTag>(("rhoProducer"), edm::InputTag("fixedGridRhoFastjetAllCalo"));
69  desc.add<bool>(("doRhoCorrection"), false);
70  desc.add<double>(("rhoMax"), 999999.);
71  desc.add<double>(("rhoScale"), 1.0);
72  desc.add<double>(("etMin"), -1.0);
73  desc.add<double>(("innerCone"), 0);
74  desc.add<double>(("outerCone"), 0.15);
75  desc.add<int>(("depth"), -1);
76  desc.add<bool>(("doEtSum"), false);
77  desc.add<double>(("effectiveAreaBarrel"), 0.021);
78  desc.add<double>(("effectiveAreaEndcap"), 0.040);
79  desc.add<bool>(("useSingleTower"), false);
80  descriptions.add(("hltEgammaHLTBcHcalIsolationProducersRegional"), desc);
81 }
82 
84 
85  // Get the HLT filtered objects
87  iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle);
88 
89  edm::Handle<CaloTowerCollection> caloTowersHandle;
90  iEvent.getByToken(caloTowerProducer_, caloTowersHandle);
91 
92  edm::Handle<double> rhoHandle;
93  double rho = 0.0;
94 
95  if (doRhoCorrection_) {
96  iEvent.getByToken(rhoProducer_, rhoHandle);
97  rho = *(rhoHandle.product());
98  }
99 
100  if (rho > rhoMax_)
101  rho = rhoMax_;
102 
103  rho = rho*rhoScale_;
104 
105  hcalHelper_->checkSetup(iSetup);
106  hcalHelper_->readEvent(iEvent);
107 
109 
110  for(unsigned int iRecoEcalCand=0; iRecoEcalCand <recoEcalCandHandle->size(); iRecoEcalCand++) {
111 
112  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
113 
114  float isol = 0;
115 
116  std::vector<CaloTowerDetId> towersBehindCluster;
117 
118  if (useSingleTower_)
119  towersBehindCluster = hcalHelper_->hcalTowersBehindClusters(*(recoEcalCandRef->superCluster()));
120 
121  if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E
122  EgammaTowerIsolation isolAlgo(outerCone_, innerCone_, etMin_, depth_, caloTowersHandle.product());
123  if (useSingleTower_)
124  isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef), &(towersBehindCluster)); // towersBehindCluster are excluded from the isolation sum
125  else
126  isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef));
127 
128  if (doRhoCorrection_) {
129  if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442)
130  isol = isol - rho*effectiveAreaBarrel_;
131  else
132  isol = isol - rho*effectiveAreaEndcap_;
133  }
134  } else { //calcuate H for H/E
135  if (useSingleTower_)
136  isol = hcalHelper_->hcalESumDepth1BehindClusters(towersBehindCluster) + hcalHelper_->hcalESumDepth2BehindClusters(towersBehindCluster);
137  else
138  isol = hcalHelper_->hcalESum(*(recoEcalCandRef->superCluster()));
139  }
140 
141  isoMap.insert(recoEcalCandRef, isol);
142  }
143 
144  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
145  iEvent.put(isolMap);
146 }
T getParameter(std::string const &) const
double hcalESum(const reco::SuperCluster &, const std::vector< CaloTowerDetId > *excludeTowers=0)
void readEvent(const edm::Event &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: DDAxes.h:10
double hcalESumDepth2BehindClusters(const std::vector< CaloTowerDetId > &towers)
std::vector< CaloTowerDetId > hcalTowersBehindClusters(const reco::SuperCluster &sc)
void checkSetup(const edm::EventSetup &)
double hcalESumDepth1BehindClusters(const std::vector< CaloTowerDetId > &towers)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void insert(const key_type &k, const data_type &v)
insert an association
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T const * product() const
Definition: Handle.h:81
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::EDGetTokenT< CaloTowerCollection > hcalTowers