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  doRhoCorrection_( config.getParameter<bool>("doRhoCorrection") ),
28  rhoScale_( config.getParameter<double>("rhoScale") ),
29  rhoMax_( config.getParameter<double>("rhoMax") ),
30  doEtSum_( config.getParameter<bool>("doEtSum") ),
31  etMin_( config.getParameter<double>("etMin") ),
32  innerCone_( config.getParameter<double>("innerCone") ),
33  outerCone_( config.getParameter<double>("outerCone") ),
34  depth_( config.getParameter<int>("depth") ),
35  effectiveAreaBarrel_( config.getParameter<double>("effectiveAreaBarrel") ),
36  effectiveAreaEndcap_( config.getParameter<double>("effectiveAreaEndcap") ),
37  useSingleTower_( config.getParameter<bool>("useSingleTower") ),
38  recoEcalCandidateProducer_( consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer")) ),
39  caloTowerProducer_( consumes<CaloTowerCollection>(config.getParameter<edm::InputTag>("caloTowerProducer")) ),
40  rhoProducer_( doRhoCorrection_ ? consumes<double>(config.getParameter<edm::InputTag>("rhoProducer")) : edm::EDGetTokenT<double>() )
41 {
43  hcalCfg.hOverEConeSize = outerCone_;
44  hcalCfg.useTowers = true;
46  hcalCfg.hOverEPtMin = etMin_;
47  hcalHelper_ = new ElectronHcalHelper(hcalCfg);
48 
49  produces<reco::RecoEcalCandidateIsolationMap>();
50 }
51 
53  delete hcalHelper_;
54 }
55 
57 
59 
60  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate"));
61  desc.add<edm::InputTag>(("caloTowerProducer"), edm::InputTag("hltTowerMakerForAll"));
62  desc.add<edm::InputTag>(("rhoProducer"), edm::InputTag("fixedGridRhoFastjetAllCalo"));
63  desc.add<bool>(("doRhoCorrection"), false);
64  desc.add<double>(("rhoMax"), 999999.);
65  desc.add<double>(("rhoScale"), 1.0);
66  desc.add<double>(("etMin"), -1.0);
67  desc.add<double>(("innerCone"), 0);
68  desc.add<double>(("outerCone"), 0.15);
69  desc.add<int>(("depth"), -1);
70  desc.add<bool>(("doEtSum"), false);
71  desc.add<double>(("effectiveAreaBarrel"), 0.021);
72  desc.add<double>(("effectiveAreaEndcap"), 0.040);
73  desc.add<bool>(("useSingleTower"), false);
74  descriptions.add(("hltEgammaHLTBcHcalIsolationProducersRegional"), desc);
75 }
76 
78 
79  // Get the HLT filtered objects
81  iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle);
82 
83  edm::Handle<CaloTowerCollection> caloTowersHandle;
84  iEvent.getByToken(caloTowerProducer_, caloTowersHandle);
85 
86  edm::Handle<double> rhoHandle;
87  double rho = 0.0;
88 
89  if (doRhoCorrection_) {
90  iEvent.getByToken(rhoProducer_, rhoHandle);
91  rho = *(rhoHandle.product());
92  }
93 
94  if (rho > rhoMax_)
95  rho = rhoMax_;
96 
97  rho = rho*rhoScale_;
98 
99  hcalHelper_->checkSetup(iSetup);
100  hcalHelper_->readEvent(iEvent);
101 
103 
104  for(unsigned int iRecoEcalCand=0; iRecoEcalCand <recoEcalCandHandle->size(); iRecoEcalCand++) {
105 
106  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
107 
108  float isol = 0;
109 
110  std::vector<CaloTowerDetId> towersBehindCluster;
111 
112  if (useSingleTower_)
113  towersBehindCluster = hcalHelper_->hcalTowersBehindClusters(*(recoEcalCandRef->superCluster()));
114 
115  if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E
116  EgammaTowerIsolation isolAlgo(outerCone_, innerCone_, etMin_, depth_, caloTowersHandle.product());
117  if (useSingleTower_)
118  isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef), &(towersBehindCluster)); // towersBehindCluster are excluded from the isolation sum
119  else
120  isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef));
121 
122  if (doRhoCorrection_) {
123  if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442)
124  isol = isol - rho*effectiveAreaBarrel_;
125  else
126  isol = isol - rho*effectiveAreaEndcap_;
127  }
128  } else { //calcuate H for H/E
129  if (useSingleTower_)
130  isol = hcalHelper_->hcalESumDepth1BehindClusters(towersBehindCluster) + hcalHelper_->hcalESumDepth2BehindClusters(towersBehindCluster);
131  else
132  isol = hcalHelper_->hcalESum(*(recoEcalCandRef->superCluster()));
133  }
134 
135  isoMap.insert(recoEcalCandRef, isol);
136  }
137 
138  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
139  iEvent.put(isolMap);
140 }
double hcalESum(const reco::SuperCluster &, const std::vector< CaloTowerDetId > *excludeTowers=0)
void readEvent(const edm::Event &)
const edm::EDGetTokenT< CaloTowerCollection > caloTowerProducer_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
Definition: DDAxes.h:10
double hcalESumDepth2BehindClusters(const std::vector< CaloTowerDetId > &towers)
virtual void produce(edm::Event &, const edm::EventSetup &) overridefinal
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:113
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T const * product() const
Definition: Handle.h:81
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
double getTowerEtSum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::EDGetTokenT< CaloTowerCollection > hcalTowers
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_