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 
40 
42 {
43  // use configuration file to setup input/output collection names
44  //inputs
45  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
46  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
47  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
48  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
49  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
50 
51  //vetos
52  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
53  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
54  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
55  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
56  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
57  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
58  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
59  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
60 
61 
62  // options
63  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
64  tryBoth_ = conf_.getParameter<bool>("tryBoth");
65  subtract_ = conf_.getParameter<bool>("subtract");
66  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
67 
68  //register your products
69  produces < reco::RecoEcalCandidateIsolationMap >();
70 
71 }
72 
74 
75 // ------------ method called to produce the data ------------
76 
78 
79  // Get the RecoEcalCandidate Collection
81  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
82 
83  // Next get Ecal hits barrel
84  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
86 
87  // Next get Ecal hits endcap
88  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
90 
91  //create the meta hit collections inorder that we can pass them into the isolation objects
92 
93  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
94  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
95 
96  //Get Calo Geometry
98  iSetup.get<CaloGeometryRecord>().get(pG);
99  const CaloGeometry* caloGeom = pG.product();
100 
102  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
103  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
104 
105  //prepare product
107 
108  //create algorithm objects
110  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
112  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
113 
114  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
115 
116  //create reference for storage in isolation map
117  reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
118 
119  //ecal isolation is centered on supecluster
120  reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
121 
122  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
123  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
124  //this can be safely replaced by another method which determines where the emobject is
125  //then we either get the isolation Et or isolation Energy depending on user selection
126  float isol =0.;
127 
128  if(tryBoth_){ //barrel + endcap
129  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
130  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
131  }
132  else if( fabs(superClus->eta())<1.479) { //barrel
133  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
134  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
135  }
136  else{ //endcap
137  if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
138  else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
139  }
140 
141  //we subtract off the electron energy here as well
142  double subtractVal=0;
143 
144  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
145  else subtractVal = superClus.get()->rawEnergy();
146 
147  if(subtract_) isol-= subtractVal;
148 
149 
150 
151  isoMap.insert(recoecalcandref, isol);
152 
153  }
154 
155  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
156  iEvent.put(isolMap);
157 
158 }
159 
160 
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:355
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
EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet &)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:241