CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTEcalRecIsolationProducer.cc
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // File: EgammaHLTEcalRecIsolationProducer.cc
4 // ----------------------------------------------------------------------------
5 // OrigAuth: Matthias Mozer , adapted from EgammaHcalIsolationProducer by S. Harper
6 // Institute: IIHE-VUB
7 //=============================================================================
8 //*****************************************************************************
9 
10 
12 
13 
14 // Framework
21 
24 
27 
30 
32 
36 
38 
39 
41 {
42  // use configuration file to setup input/output collection names
43  //inputs
44  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
45  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
46  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
47  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
48  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
49 
50  //vetos
51  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
52  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
53  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
54  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
55  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
56  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
57  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
58  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
59 
60 
61  // options
62  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
63  tryBoth_ = conf_.getParameter<bool>("tryBoth");
64  subtract_ = conf_.getParameter<bool>("subtract");
65  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
66 
67  //register your products
68  produces < reco::RecoEcalCandidateIsolationMap >();
69 
70 }
71 
73 
74 // ------------ method called to produce the data ------------
75 
77 
78  // Get the RecoEcalCandidate Collection
80  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
81 
82  // Next get Ecal hits barrel
83  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
85 
86  // Next get Ecal hits endcap
87  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
89 
90  //create the meta hit collections inorder that we can pass them into the isolation objects
91 
92  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
93  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
94 
95  //Get Calo Geometry
97  iSetup.get<CaloGeometryRecord>().get(pG);
98  const CaloGeometry* caloGeom = pG.product();
99 
100  //prepare product
102 
103  //create algorithm objects
105  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
107  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
108 
109  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
110 
111  //create reference for storage in isolation map
112  reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
113 
114  //ecal isolation is centered on supecluster
115  reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
116 
117  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
118  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
119  //this can be safely replaced by another method which determines where the emobject is
120  //then we either get the isolation Et or isolation Energy depending on user selection
121  float isol =0.;
122 
123  if(tryBoth_){ //barrel + endcap
124  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
125  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
126  }
127  else if( fabs(superClus->eta())<1.479) { //barrel
128  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
129  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
130  }
131  else{ //endcap
132  if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
133  else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
134  }
135 
136  //we subtract off the electron energy here as well
137  double subtractVal=0;
138 
139  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
140  else subtractVal = superClus.get()->rawEnergy();
141 
142  if(subtract_) isol-= subtractVal;
143 
144 
145 
146  isoMap.insert(recoecalcandref, isol);
147 
148  }
149 
150  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
151  iEvent.put(isolMap);
152 
153 }
154 
155 
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
double getEtSum(const reco::Candidate *emObject) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double getEnergySum(const reco::Candidate *emObject) const
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::string const & label() const
Definition: InputTag.h:25
#define begin
Definition: vmac.h:31
tuple config
Definition: cmsDriver.py:17
EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet &)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239