CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEgamma.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 #include <cstdlib>
10 #include <cstring>
11 
16 
17 
18 
20 
24 
26 
27 #include "HLTMessages.h"
28 
29 static const size_t kMaxEl = 10000;
30 static const size_t kMaxPhot = 10000;
31 static const size_t kMaxhPhot = 500;
32 static const size_t kMaxhEle = 500;
33 
35 }
36 
37 /* Setup the analysis to put the branch-variables size_to the tree. */
38 void HLTEgamma::setup(const edm::ParameterSet& pSet, TTree* HltTree)
39 {
40  elpt = new float[kMaxEl];
41  elphi = new float[kMaxEl];
42  eleta = new float[kMaxEl];
43  elet = new float[kMaxEl];
44  ele = new float[kMaxEl];
45  eleId = new int[kMaxEl];// RL + 2*RT + 4*L + 4*T
46  elIP = new float[kMaxEl];
47  elNLostHits = new int[kMaxEl];
48  elTrkChi2NDF = new float[kMaxEl];
49  elTrkIsoR03 = new float[kMaxEl];
50  elECaloIsoR03 = new float[kMaxEl];
51  elHCaloIsoR03 = new float[kMaxEl];
52  elIsEcalDriven = new bool[kMaxEl];
53  elFbrem = new float[kMaxEl];
54  elmishits = new int[kMaxEl];
55  eldist = new float[kMaxEl];
56  eldcot = new float[kMaxEl];
57  eltrkiso = new float[kMaxEl];
58  elecaliso = new float[kMaxEl];
59  elhcaliso = new float[kMaxEl];
60  elsigmaietaieta = new float[kMaxEl];
61  eldeltaPhiIn = new float[kMaxEl];
62  eldeltaEtaIn = new float[kMaxEl];
63  elhOverE = new float[kMaxEl];
64  elscEt = new float[kMaxEl];
65  eld0corr = new float[kMaxEl];
66  elqGsfCtfScPixConsistent = new bool[kMaxEl];
67 
68  photonpt = new float[kMaxPhot];
69  photonphi = new float[kMaxPhot];
70  photoneta = new float[kMaxPhot];
71  photonet = new float[kMaxPhot];
72  photone = new float[kMaxPhot];
73 
74  hphotet = new float[kMaxhPhot];
75  hphoteta = new float[kMaxhPhot];
76  hphotphi = new float[kMaxhPhot];
77  hphoteiso = new float[kMaxhPhot];
78  hphothiso = new float[kMaxhPhot];
79  hphottiso = new float[kMaxhPhot];
80  hphotl1iso = new int[kMaxhPhot];
81  hphotClusShap = new float[kMaxhPhot];
82  hphotR9 = new float[kMaxhPhot];
83  hphothovereh = new float[kMaxhPhot];
84  hphotR9ID = new float[kMaxhPhot];
85 
86  heleet = new float[kMaxhEle];
87  heleeta = new float[kMaxhEle];
88  helephi = new float[kMaxhEle];
89  heleE = new float[kMaxhEle];
90  helep = new float[kMaxhEle];
91  helehiso = new float[kMaxhEle];
92  heleeiso = new float[kMaxhEle];
93  heletiso = new float[kMaxhEle];
94  helel1iso = new int[kMaxhEle];
95  helePixelSeeds = new int[kMaxhEle];
96  heleNewSC = new int[kMaxhEle];
97  heleClusShap = new float[kMaxhEle];
98  heleDeta = new float[kMaxhEle];
99  heleDphi = new float[kMaxhEle];
100  heleR9 = new float[kMaxhEle];
101  helehovereh = new float[kMaxhEle];
102  heleR9ID = new float[kMaxhEle];
103 
104  hhfelept = new float[kMaxhEle];
105  hhfeleeta = new float[kMaxhEle];
106  hhfclustere9e25 = new float[kMaxhEle];
107  hhfcluster2Dcut = new float[kMaxhEle];
108 
109  nele = 0;
110  nphoton = 0;
111  nhltgam = 0;
112  nhltele = 0;
113  nhlthfele = 0;
114  nhlthfeclus = 0;
115 
116  // Egamma-specific branches of the tree
117  HltTree->Branch("NrecoElec", & nele, "NrecoElec/I");
118  HltTree->Branch("recoElecPt", elpt, "recoElecPt[NrecoElec]/F");
119  HltTree->Branch("recoElecPhi", elphi, "recoElecPhi[NrecoElec]/F");
120  HltTree->Branch("recoElecEta", eleta, "recoElecEta[NrecoElec]/F");
121  HltTree->Branch("recoElecEt", elet, "recoElecEt[NrecoElec]/F");
122  HltTree->Branch("recoElecE", ele, "recoElecE[NrecoElec]/F");
123  HltTree->Branch("recoElecEleID", eleId, "recoElecEleID[NrecoElec]/I");
124  HltTree->Branch("recoElecIP", elIP, "recoElecIP[NrecoElec]/F");
125  HltTree->Branch("recoElecNLostHits", elNLostHits, "recoElecNLostHits[NrecoElec]/I");
126  HltTree->Branch("recoElecChi2NDF", elTrkChi2NDF, "recoElecChi2NDF[NrecoElec]/F");
127  HltTree->Branch("recoElecTrkIsoR03", elTrkIsoR03, "recoElecTrkIsoR03[NrecoElec]/F");
128  HltTree->Branch("recoElecECaloIsoR03", elECaloIsoR03, "recoElecECaloIsoR03[NrecoElec]/F");
129  HltTree->Branch("recoElecHCaloIsoR03", elHCaloIsoR03, "recoElecHCaloIsoR03[NrecoElec]/F");
130  HltTree->Branch("recoElecIsEcalDriven", elIsEcalDriven, "recoElecIsEcalDriven[NrecoElec]/O");
131  HltTree->Branch("recoElecFbrem", elFbrem, "recoElecFbrem[NrecoElec]/F");
132  HltTree->Branch("recoElecmishits", elmishits, "recoElecmishits[NrecoElec]/I");
133  HltTree->Branch("recoElecdist", eldist, "recoElecdist[NrecoElec]/F");
134  HltTree->Branch("recoElecdcot", eldcot, "recoElecdcot[NrecoElec]/F");
135  HltTree->Branch("recoElectrkiso", eltrkiso, "recoElectrkiso[NrecoElec]/F");
136  HltTree->Branch("recoElececaliso", elecaliso, "recoElececaliso[NrecoElec]/F");
137  HltTree->Branch("recoElechcaliso", elhcaliso, "recoElechcaliso[NrecoElec]/F");
138  HltTree->Branch("recoElecsigmaietaieta", elsigmaietaieta, "recoElecsigmaietaieta[NrecoElec]/F");
139  HltTree->Branch("recoElecdeltaPhiIn", eldeltaPhiIn, "recoElecdeltaPhiIn[NrecoElec]/F");
140  HltTree->Branch("recoElecdeltaEtaIn", eldeltaEtaIn, "recoElecdeltaEtaIn[NrecoElec]/F");
141  HltTree->Branch("recoElechOverE", elhOverE, "recoElechOverE[NrecoElec]/F");
142  HltTree->Branch("recoElecscEt", elscEt, "recoElecscEt[NrecoElec]/F");
143  HltTree->Branch("recoElecd0corr", eld0corr, "recoElecd0corr[NrecoElec]/F");
144  HltTree->Branch("recoElecqGsfCtfScPixConsistent", elqGsfCtfScPixConsistent, "recoElecqGsfCtfScPixConsistent[NrecoElec]/O");
145 
146  HltTree->Branch("NrecoPhot", &nphoton, "NrecoPhot/I");
147  HltTree->Branch("recoPhotPt", photonpt, "recoPhotPt[NrecoPhot]/F");
148  HltTree->Branch("recoPhotPhi", photonphi, "recoPhotPhi[NrecoPhot]/F");
149  HltTree->Branch("recoPhotEta", photoneta, "recoPhotEta[NrecoPhot]/F");
150  HltTree->Branch("recoPhotEt", photonet, "recoPhotEt[NrecoPhot]/F");
151  HltTree->Branch("recoPhotE", photone, "recoPhotE[NrecoPhot]/F");
152 
153  HltTree->Branch("NohPhot", & nhltgam, "NohPhot/I");
154  HltTree->Branch("ohPhotEt", hphotet, "ohPhotEt[NohPhot]/F");
155  HltTree->Branch("ohPhotEta", hphoteta, "ohPhotEta[NohPhot]/F");
156  HltTree->Branch("ohPhotPhi", hphotphi, "ohPhotPhi[NohPhot]/F");
157  HltTree->Branch("ohPhotEiso", hphoteiso, "ohPhotEiso[NohPhot]/F");
158  HltTree->Branch("ohPhotHiso", hphothiso, "ohPhotHiso[NohPhot]/F");
159  HltTree->Branch("ohPhotTiso", hphottiso, "ohPhotTiso[NohPhot]/F");
160  HltTree->Branch("ohPhotL1iso", hphotl1iso, "ohPhotL1iso[NohPhot]/I");
161  HltTree->Branch("ohPhotClusShap", hphotClusShap, "ohPhotClusShap[NohPhot]/F");
162  HltTree->Branch("ohPhotR9", hphotR9, "ohPhotR9[NohPhot]/F");
163  HltTree->Branch("ohPhotHforHoverE", hphothovereh, "ohPhotHforHoverE[NohPhot]/F");
164  HltTree->Branch("ohPhotR9ID", hphotR9ID, "ohPhotR9ID[NohPhot]/F");
165 
166  HltTree->Branch("NohEle", & nhltele, "NohEle/I");
167  HltTree->Branch("ohEleEt", heleet, "ohEleEt[NohEle]/F");
168  HltTree->Branch("ohEleEta", heleeta, "ohEleEta[NohEle]/F");
169  HltTree->Branch("ohElePhi", helephi, "ohElePhi[NohEle]/F");
170  HltTree->Branch("ohEleE", heleE, "ohEleE[NohEle]/F");
171  HltTree->Branch("ohEleP", helep, "ohEleP[NohEle]/F");
172  HltTree->Branch("ohEleHiso", helehiso, "ohEleHiso[NohEle]/F");
173  HltTree->Branch("ohEleTiso", heletiso, "ohEleTiso[NohEle]/F");
174  HltTree->Branch("ohEleEiso", heleeiso, "ohEleEiso[NohEle]/F");
175  HltTree->Branch("ohEleL1iso", helel1iso, "ohEleLiso[NohEle]/I");
176  HltTree->Branch("ohElePixelSeeds", helePixelSeeds, "ohElePixelSeeds[NohEle]/I");
177  HltTree->Branch("ohEleNewSC", heleNewSC, "ohEleNewSC[NohEle]/I");
178  HltTree->Branch("ohEleClusShap", heleClusShap, "ohEleClusShap[NohEle]/F");
179  HltTree->Branch("ohEleDeta", heleDeta, "ohEleDeta[NohEle]/F");
180  HltTree->Branch("ohEleDphi", heleDphi, "ohEleDphi[NohEle]/F");
181  HltTree->Branch("ohEleR9", heleR9, "ohEleR9[NohEle]/F");
182  HltTree->Branch("ohEleHforHoverE", helehovereh, "ohEleHforHoverE[NohEle]/F");
183  HltTree->Branch("ohEleR9ID", heleR9ID, "ohEleR9ID[NohEle]/F");
184  HltTree->Branch("NohHFEle", &nhlthfele , "NohHFEle/I");
185  HltTree->Branch("ohHFElePt", hhfelept, "ohHFElePt[NohHFEle]/F");
186  HltTree->Branch("ohHFEleEta", hhfeleeta, "ohHFElePt[NohHFEle]/F");
187  HltTree->Branch("NohHFECALClus", &nhlthfeclus, "NohHFECALClus/I");
188  HltTree->Branch("ohHFElee9e25", hhfclustere9e25, "ohHFElePt[NohHFECALClus]/F");
189  HltTree->Branch("ohHFEle2Dcut", hhfcluster2Dcut, "ohHFElePt[NohHFECALClus]/F");
190 
191 }
192 
194 {
195  std::memset(elpt, '\0', kMaxEl * sizeof(float));
196  std::memset(elphi, '\0', kMaxEl * sizeof(float));
197  std::memset(eleta, '\0', kMaxEl * sizeof(float));
198  std::memset(elet, '\0', kMaxEl * sizeof(float));
199  std::memset(ele, '\0', kMaxEl * sizeof(float));
200  std::memset(ele, '\0', kMaxEl * sizeof(int));
201  std::memset(elIP, '\0', kMaxEl * sizeof(float));
202  std::memset(elNLostHits, '\0', kMaxEl * sizeof(int));
203  std::memset(elTrkChi2NDF, '\0', kMaxEl * sizeof(float));
204  std::memset(elTrkIsoR03, '\0', kMaxEl * sizeof(float));
205  std::memset(elECaloIsoR03, '\0', kMaxEl * sizeof(float));
206  std::memset(elHCaloIsoR03, '\0', kMaxEl * sizeof(float));
207  std::memset(elIsEcalDriven, '\0', kMaxEl * sizeof(bool));
208  std::memset(elFbrem, '\0', kMaxEl * sizeof(float));
209 
210  std::memset(photonpt, '\0', kMaxPhot * sizeof(float));
211  std::memset(photonphi, '\0', kMaxPhot * sizeof(float));
212  std::memset(photoneta, '\0', kMaxPhot * sizeof(float));
213  std::memset(photonet, '\0', kMaxPhot * sizeof(float));
214  std::memset(photone, '\0', kMaxPhot * sizeof(float));
215 
216  std::memset(hphotet, '\0', kMaxhPhot * sizeof(float));
217  std::memset(hphoteta, '\0', kMaxhPhot * sizeof(float));
218  std::memset(hphotphi, '\0', kMaxhPhot * sizeof(float));
219  std::memset(hphoteiso, '\0', kMaxhPhot * sizeof(float));
220  std::memset(hphothiso, '\0', kMaxhPhot * sizeof(float));
221  std::memset(hphottiso, '\0', kMaxhPhot * sizeof(float));
222  std::memset(hphotl1iso, '\0', kMaxhPhot * sizeof(int));
223  std::memset(hphotClusShap, '\0', kMaxhPhot * sizeof(float));
224 
225  std::memset(heleet, '\0', kMaxhEle * sizeof(float));
226  std::memset(heleeta, '\0', kMaxhEle * sizeof(float));
227  std::memset(helephi, '\0', kMaxhEle * sizeof(float));
228  std::memset(heleE, '\0', kMaxhEle * sizeof(float));
229  std::memset(helep, '\0', kMaxhEle * sizeof(float));
230  std::memset(helehiso, '\0', kMaxhEle * sizeof(float));
231  std::memset(heletiso, '\0', kMaxhEle * sizeof(float));
232  std::memset(heleeiso, '\0', kMaxhEle * sizeof(float));
233  std::memset(helehovereh, '\0', kMaxhEle * sizeof(float));
234  std::memset(helel1iso, '\0', kMaxhEle * sizeof(int));
235  std::memset(helePixelSeeds, '\0', kMaxhEle * sizeof(int));
236  std::memset(heleNewSC, '\0', kMaxhEle * sizeof(int));
237  std::memset(heleClusShap, '\0', kMaxhEle * sizeof(float));
238  std::memset(heleDeta, '\0', kMaxhEle * sizeof(float));
239  std::memset(heleDphi, '\0', kMaxhEle * sizeof(float));
240 
241  std::memset(hhfelept, '\0', kMaxhEle * sizeof(float));
242  std::memset(hhfeleeta, '\0', kMaxhEle * sizeof(float));
243  std::memset(hhfclustere9e25, '\0', kMaxhEle * sizeof(float));
244  std::memset(hhfcluster2Dcut, '\0', kMaxhEle * sizeof(float));
245 
246 
247  nele = 0;
248  nphoton = 0;
249  nhltgam = 0;
250  nhltele = 0;
251  nhlthfele = 0;
252  nhlthfeclus = 0;
253 }
254 
255 /* **Analyze the event** */
258  const edm::Handle<reco::ElectronCollection> & electronIsoHandle,
259  const edm::Handle<reco::ElectronCollection> & electronNonIsoHandle,
260  const edm::Handle<reco::ElectronIsolationMap> & NonIsoTrackEleIsolMap,
261  const edm::Handle<reco::ElectronIsolationMap> & TrackEleIsolMap,
262  const edm::Handle<reco::ElectronSeedCollection> & L1IsoPixelSeedsMap,
263  const edm::Handle<reco::ElectronSeedCollection> & L1NonIsoPixelSeedsMap,
264  const edm::Handle<reco::RecoEcalCandidateCollection> & recoIsolecalcands,
265  const edm::Handle<reco::RecoEcalCandidateCollection> & recoNonIsolecalcands,
269  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalEleNonIsolMap,
273  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackNonIsolMap,
274  EcalClusterLazyTools& lazyTools,
275  const edm::ESHandle<MagneticField>& theMagField,
276  reco::BeamSpot::Point & BSPosition,
277  std::vector<edm::Handle<edm::ValueMap<float> > > & eIDValueMap,
278  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IsoMap,
279  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9NonIsoMap,
280  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IsoMap,
281  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9NonIsoMap,
282  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,
283  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,
284  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDIsoMap,
285  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDNonIsoMap,
286  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDIsoMap,
287  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDNonIsoMap,
288  const edm::Handle<reco::SuperClusterCollection> & electronHFECALClusters,
289  const edm::Handle<reco::RecoEcalCandidateCollection> & electronHFElectrons,
290  TTree* HltTree)
291 {
292  // reset the tree variables
293  clear();
294 
295  if (electrons.isValid()) {
296  reco::GsfElectronCollection myelectrons( electrons->begin(), electrons->end() );
297  nele = myelectrons.size();
298  std::sort(myelectrons.begin(), myelectrons.end(), EtGreater());
299  int iel = 0;
300  for (reco::GsfElectronCollection::const_iterator i = myelectrons.begin(); i != myelectrons.end(); i++) {
301  elpt[iel] = i->pt();
302  elphi[iel] = i->phi();
303  eleta[iel] = i->eta();
304  elet[iel] = i->et();
305  ele[iel] = i->energy();
306 
307  if(i->gsfTrack().isNonnull()){
308  elNLostHits[iel] = i->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits();
309  elIP[iel] = i->gsfTrack()->dxy(BSPosition);
310  elTrkChi2NDF[iel] = i->gsfTrack()->normalizedChi2();
311  }
312  else {
313  elNLostHits[iel] = -99.;
314  elIP[iel] = -99.;
315  elTrkChi2NDF[iel] = -99.;
316  }
317 
318  elTrkIsoR03[iel] = i->dr03TkSumPt();
319  elECaloIsoR03[iel] = i->dr03EcalRecHitSumEt();
320  elHCaloIsoR03[iel] = i->dr03HcalTowerSumEt();
321  elIsEcalDriven[iel] = i->ecalDrivenSeed();
322  elFbrem[iel] = i->fbrem();
323  elscEt[iel] = i->superCluster()->energy()*sin((2*atan(exp(-i->superCluster()->eta()))));
324  elhOverE[iel] = i->hadronicOverEm();
325  elsigmaietaieta[iel] = i->sigmaIetaIeta();
326  eldeltaPhiIn[iel] = i->deltaPhiSuperClusterTrackAtVtx();
327  eldeltaEtaIn[iel] = i->deltaEtaSuperClusterTrackAtVtx();
328  elmishits[iel] = i->gsfTrack()->trackerExpectedHitsInner().numberOfHits();
329  eltrkiso[iel] = i->dr03TkSumPt();
330  elecaliso[iel] = i->dr03EcalRecHitSumEt();
331  elhcaliso[iel] = i->dr03HcalTowerSumEt();
332  eld0corr[iel]= - (i->gsfTrack()->dxy(BSPosition));
333  elqGsfCtfScPixConsistent[iel]=i->isGsfCtfScPixChargeConsistent();;
334 
335  // conversion info will be available after 3_10_X
336  eldist[iel] = 0;// fabs(i->convDist());
337  eldcot[iel] = 0; //fabs(i->convDcot());
338 
339  iel++;
340  }
341  } else {
342  nele = 0;
343  }
344 
345  if (photons.isValid()) {
346  reco::PhotonCollection myphotons(* photons);
347  nphoton = myphotons.size();
348  std::sort(myphotons.begin(), myphotons.end(), EtGreater());
349  int ipho = 0;
350  for (reco::PhotonCollection::const_iterator i = myphotons.begin(); i!= myphotons.end(); i++) {
351  photonpt[ipho] = i->pt();
352  photonphi[ipho] = i->phi();
353  photoneta[ipho] = i->eta();
354  photonet[ipho] = i->et();
355  photone[ipho] = i->energy();
356  ipho++;
357  }
358  } else {
359  nphoton = 0;
360  }
361 
363 
365  std::vector<OpenHLTPhoton> theHLTPhotons;
367  theHLTPhotons,
368  recoIsolecalcands,
369  EcalIsolMap,
370  HcalIsolMap,
371  TrackIsolMap,
372  photonR9IsoMap,
373  photonHoverEHIsoMap,
374  photonR9IDIsoMap,
375  lazyTools);
377  theHLTPhotons,
378  recoNonIsolecalcands,
379  EcalNonIsolMap,
380  HcalNonIsolMap,
381  TrackNonIsolMap,
382  photonR9NonIsoMap,
383  photonHoverEHNonIsoMap,
384  photonR9IDNonIsoMap,
385  lazyTools);
386 
387  std::sort(theHLTPhotons.begin(), theHLTPhotons.end(), EtGreater());
388  nhltgam = theHLTPhotons.size();
389 
390  for (int u = 0; u < nhltgam; u++) {
391  hphotet[u] = theHLTPhotons[u].Et;
392  hphoteta[u] = theHLTPhotons[u].eta;
393  hphotphi[u] = theHLTPhotons[u].phi;
394  hphoteiso[u] = theHLTPhotons[u].ecalIsol;
395  hphothiso[u] = theHLTPhotons[u].hcalIsol;
396  hphottiso[u] = theHLTPhotons[u].trackIsol;
397  hphotl1iso[u] = theHLTPhotons[u].L1Isolated;
398  hphotClusShap[u] = theHLTPhotons[u].clusterShape;
399  hphothovereh[u] = theHLTPhotons[u].hovereh;
400  hphotR9[u] = theHLTPhotons[u].r9;
401  hphotR9ID[u] = theHLTPhotons[u].r9ID;
402  }
403 
405  std::vector<OpenHLTElectron> theHLTElectrons;
407  theHLTElectrons,
408  electronIsoHandle,
409  recoIsolecalcands,
410  HcalEleIsolMap,
411  L1IsoPixelSeedsMap,
412  TrackEleIsolMap,
413  electronR9IsoMap,
414  photonHoverEHIsoMap,
415  EcalIsolMap,
416  electronR9IDIsoMap,
417  lazyTools,
418  theMagField,
419  BSPosition);
421  theHLTElectrons,
422  electronNonIsoHandle,
423  recoNonIsolecalcands,
424  HcalEleNonIsolMap,
425  L1NonIsoPixelSeedsMap,
426  NonIsoTrackEleIsolMap,
427  electronR9NonIsoMap,
428  photonHoverEHNonIsoMap,
429  EcalNonIsolMap,
430  electronR9IDNonIsoMap,
431  lazyTools,
432  theMagField,
433  BSPosition);
434 
435  std::sort(theHLTElectrons.begin(), theHLTElectrons.end(), EtGreater());
436  nhltele = theHLTElectrons.size();
437 
438  for (int u = 0; u < nhltele; u++) {
439  heleet[u] = theHLTElectrons[u].Et;
440  heleeta[u] = theHLTElectrons[u].eta;
441  helephi[u] = theHLTElectrons[u].phi;
442  heleE[u] = theHLTElectrons[u].E;
443  helep[u] = theHLTElectrons[u].p;
444  helehiso[u] = theHLTElectrons[u].hcalIsol;
445  helePixelSeeds[u] = theHLTElectrons[u].pixelSeeds;
446  heletiso[u] = theHLTElectrons[u].trackIsol;
447  heleeiso[u] = theHLTElectrons[u].ecalIsol;
448  helel1iso[u] = theHLTElectrons[u].L1Isolated;
449  heleNewSC[u] = theHLTElectrons[u].newSC;
450  heleClusShap[u] = theHLTElectrons[u].clusterShape;
451  heleDeta[u] = theHLTElectrons[u].Deta;
452  heleDphi[u] = theHLTElectrons[u].Dphi;
453  heleR9[u] = theHLTElectrons[u].r9;
454  helehovereh[u] = theHLTElectrons[u].hovereh;
455  heleR9ID[u] = theHLTElectrons[u].r9ID;
456  }
457 
458  if(electronHFElectrons.isValid()) {
459  for (reco::RecoEcalCandidateCollection::const_iterator hfelecand = electronHFElectrons->begin();
460  hfelecand!= electronHFElectrons->end(); hfelecand++) {
461  hhfelept[nhlthfele] = hfelecand->pt();
462  hhfeleeta[nhlthfele] = hfelecand->eta();
463  nhlthfele++;
464  }
465  }
466  if(electronHFECALClusters.isValid()) {
467  for(reco::SuperClusterCollection::const_iterator hfeleclus = electronHFECALClusters->begin();
468  hfeleclus!= electronHFECALClusters->end(); hfeleclus++) {
469  hhfclustere9e25[nhlthfeclus] = -999.;
470  hhfcluster2Dcut[nhlthfeclus] = -999.;
471  nhlthfeclus++;
472  }
473  }
474 }
475 
477  std::vector<OpenHLTPhoton> & theHLTPhotons,
478  const edm::Handle<reco::RecoEcalCandidateCollection> & recoIsolecalcands,
482  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IsoMap,
483  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,
484  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDIsoMap,
485  EcalClusterLazyTools& lazyTools )
486 {
487  // Iterator to the isolation-map
489 
490  if (recoIsolecalcands.isValid()) {
491  // loop over SuperCluster and fill the HLTPhotons
492 
493 
494  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoIsolecalcands->begin();
495  recoecalcand!= recoIsolecalcands->end(); recoecalcand++) {
496 
497  OpenHLTPhoton pho;
498  pho.ecalIsol = -999;
499  pho.hcalIsol = -999;
500  pho.trackIsol = -999;
501  pho.clusterShape = -999;
502  pho.L1Isolated = true;
503  pho.Et = recoecalcand->et();
504  pho.eta = recoecalcand->eta();
505  pho.phi = recoecalcand->phi();
506  pho.r9 = -999.;
507  pho.hovereh = -999.;
508  pho.r9ID = -999.;
509 
510  //Get the cluster shape
511  // std::vector<float> vCov = lazyTools.covariances( *(recoecalcand->superCluster()->seed()) );
512  std::vector<float> vCov = lazyTools.localCovariances( *(recoecalcand->superCluster()->seed()) );
513  double sigmaee = sqrt(vCov[0]);
514  // float EtaSC = fabs(recoecalcand->eta());
515  // if(EtaSC > 1.479 ) {//Endcap
516  // sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
517  // }
518  pho.clusterShape = sigmaee;
519 
520  // Method to get the reference to the candidate
521  reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand));
522 
523  // First/Second member of the Map: Ref-to-Candidate(mapi)/Isolation(->val)
524  // fill the ecal Isolation
525  if (EcalIsolMap.isValid()) {
526  mapi = (*EcalIsolMap).find(ref);
527  if (mapi !=(*EcalIsolMap).end()) { pho.ecalIsol = mapi->val;}
528  }
529  // fill the hcal Isolation
530  if (HcalIsolMap.isValid()) {
531  mapi = (*HcalIsolMap).find(ref);
532  if (mapi !=(*HcalIsolMap).end()) { pho.hcalIsol = mapi->val;}
533  }
534  // fill the track Isolation
535  if (TrackIsolMap.isValid()) {
536  mapi = (*TrackIsolMap).find(ref);
537  if (mapi !=(*TrackIsolMap).end()) { pho.trackIsol = mapi->val;}
538  }
539  // fill the R9
540  if (photonR9IsoMap.isValid()) {
541  mapi = (*photonR9IsoMap).find(ref);
542  if (mapi !=(*photonR9IsoMap).end()) { pho.r9 = mapi->val;}
543  }
544  // fill the H for H/E
545  if (photonHoverEHIsoMap.isValid()) {
546  mapi = (*photonHoverEHIsoMap).find(ref);
547  if (mapi !=(*photonHoverEHIsoMap).end()) { pho.hovereh = mapi->val;}
548  }
549  // fill the R9ID
550  if (photonR9IDIsoMap.isValid()) {
551  mapi = (*photonR9IDIsoMap).find(ref);
552  if (mapi !=(*photonR9IDIsoMap).end()) { pho.r9ID = mapi->val;}
553  }
554 
555  // store the photon into the vector
556  theHLTPhotons.push_back(pho);
557  }
558  }
559 }
560 
562  std::vector<OpenHLTPhoton> & theHLTPhotons,
563  const edm::Handle<reco::RecoEcalCandidateCollection> & recoNonIsolecalcands,
566  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackNonIsolMap,
567  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9NonIsoMap,
568  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,
569  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDNonIsoMap,
570  EcalClusterLazyTools& lazyTools )
571 {
573 
574  if (recoNonIsolecalcands.isValid()) {
575  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoNonIsolecalcands->begin();
576  recoecalcand!= recoNonIsolecalcands->end(); recoecalcand++) {
577  // loop over SuperCluster and fill the HLTPhotons
578  OpenHLTPhoton pho;
579  pho.ecalIsol = -999;
580  pho.hcalIsol = -999;
581  pho.trackIsol = -999;
582  pho.clusterShape = -999;
583  pho.L1Isolated = false;
584  pho.Et = recoecalcand->et();
585  pho.eta = recoecalcand->eta();
586  pho.phi = recoecalcand->phi();
587  pho.r9 = -999;
588  pho.hovereh = -999.;
589  pho.r9ID = -999.;
590 
591  //Get the cluster shape
592  // std::vector<float> vCov = lazyTools.covariances( *(recoecalcand->superCluster()->seed()) );
593  std::vector<float> vCov = lazyTools.localCovariances( *(recoecalcand->superCluster()->seed()) );
594  double sigmaee = sqrt(vCov[0]);
595  // float EtaSC = fabs(recoecalcand->eta());
596  // if(EtaSC > 1.479 ) {//Endcap
597  // sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
598  // }
599  pho.clusterShape = sigmaee;
600 
601  reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand));
602 
603  // fill the ecal Isolation
604  if (EcalNonIsolMap.isValid()) {
605  mapi = (*EcalNonIsolMap).find(ref);
606  if (mapi !=(*EcalNonIsolMap).end()) { pho.ecalIsol = mapi->val;}
607  }
608  // fill the hcal Isolation
609  if (HcalNonIsolMap.isValid()) {
610  mapi = (*HcalNonIsolMap).find(ref);
611  if (mapi !=(*HcalNonIsolMap).end()) { pho.hcalIsol = mapi->val;}
612  }
613  // fill the track Isolation
614  if (TrackNonIsolMap.isValid()) {
615  mapi = (*TrackNonIsolMap).find(ref);
616  if (mapi !=(*TrackNonIsolMap).end()) { pho.trackIsol = mapi->val;}
617  }
618  // fill the R9
619  if (photonR9NonIsoMap.isValid()) {
620  mapi = (*photonR9NonIsoMap).find(ref);
621  if (mapi !=(*photonR9NonIsoMap).end()) { pho.r9 = mapi->val;}
622  }
623  // fill the H for H/E
624  if (photonHoverEHNonIsoMap.isValid()) {
625  mapi = (*photonHoverEHNonIsoMap).find(ref);
626  if (mapi !=(*photonHoverEHNonIsoMap).end()) { pho.hovereh = mapi->val;}
627  }
628  // fill the R9ID
629  if (photonR9IDNonIsoMap.isValid()) {
630  mapi = (*photonR9IDNonIsoMap).find(ref);
631  if (mapi !=(*photonR9IDNonIsoMap).end()) { pho.r9ID = mapi->val;}
632  }
633 
634  // store the photon into the vector
635  theHLTPhotons.push_back(pho);
636  }
637  }
638 }
639 
641  std::vector<OpenHLTElectron> & theHLTElectrons,
642  const edm::Handle<reco::ElectronCollection> & electronIsoHandle,
643  const edm::Handle<reco::RecoEcalCandidateCollection> & recoIsolecalcands,
645  const edm::Handle<reco::ElectronSeedCollection> & L1IsoPixelSeedsMap,
646  const edm::Handle<reco::ElectronIsolationMap> & TrackEleIsolMap,
647  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IsoMap,
648  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,
650  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDIsoMap,
651  EcalClusterLazyTools& lazyTools,
652  const edm::ESHandle<MagneticField>& theMagField,
653  reco::BeamSpot::Point & BSPosition )
654 {
655  // if there are electrons, then the isolation maps and the SC should be in the event; if not it is an error
656  if (recoIsolecalcands.isValid()) {
657  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoIsolecalcands->begin();
658  recoecalcand!= recoIsolecalcands->end(); recoecalcand++) {
659  // get the ref to the SC:
660  reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand));
661  reco::SuperClusterRef recrSC = ref->superCluster();
662  //reco::SuperClusterRef recrSC = recoecalcand->superCluster();
663 
665  ele.hcalIsol = -999;
666  ele.trackIsol = -999;
667  ele.ecalIsol = -999;
668  ele.L1Isolated = true;
669  ele.p = -999;
670  ele.pixelSeeds = -999;
671  ele.newSC = true;
672  ele.clusterShape = -999;
673  ele.Dphi = 700;
674  ele.Deta = 700;
675  ele.hovereh = -999;
676  ele.Et = recoecalcand->et();
677  ele.eta = recoecalcand->eta();
678  ele.phi = recoecalcand->phi();
679  ele.E = recrSC->energy();
680  //Get the cluster shape
681  // std::vector<float> vCov = lazyTools.covariances( *(recrSC->seed()) );
682  std::vector<float> vCov = lazyTools.localCovariances( *(recrSC->seed()) );
683  double sigmaee = sqrt(vCov[0]);
684  // float EtaSC = fabs(recoecalcand->eta());
685  // if(EtaSC > 1.479 ) {//Endcap
686  // sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
687  // }
688  ele.clusterShape = sigmaee;
689  ele.r9 = -999.;
690  ele.r9ID = -999.;
691 
692  // fill the ecal Isolation
693  if (EcalIsolMap.isValid()) {
694  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*EcalIsolMap).find(ref);
695  if (mapi !=(*EcalIsolMap).end()) { ele.ecalIsol = mapi->val;}
696  }
697  // fill the hcal Isolation
698  if (HcalEleIsolMap.isValid()) {
699  //reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand)) );
700  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( ref );
701  if (mapi !=(*HcalEleIsolMap).end()) { ele.hcalIsol = mapi->val; }
702  }
703  // fill the R9
704  if (electronR9IsoMap.isValid()) {
705  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IsoMap).find( ref );
706  if (mapi !=(*electronR9IsoMap).end()) { ele.r9 = mapi->val; }
707  }
708  // fill the H for H/E
709  if (photonHoverEHIsoMap.isValid()) {
710  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*photonHoverEHIsoMap).find(ref);
711  if (mapi !=(*photonHoverEHIsoMap).end()) { ele.hovereh = mapi->val;}
712  }
713  // fill the R9ID
714  if (electronR9IDIsoMap.isValid()) {
715  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IDIsoMap).find( ref );
716  if (mapi !=(*electronR9IDIsoMap).end()) { ele.r9ID = mapi->val; }
717  }
718 
719  // look if the SC has associated pixelSeeds
720  int nmatch = 0;
721 
722  if (L1IsoPixelSeedsMap.isValid()) {
723  for (reco::ElectronSeedCollection::const_iterator it = L1IsoPixelSeedsMap->begin();
724  it != L1IsoPixelSeedsMap->end(); it++) {
725  edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ;
726  reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ;
727  if (&(*recrSC) == &(*scRef)) { nmatch++; }
728  }
729  }
730 
731  ele.pixelSeeds = nmatch;
732 
733  // look if the SC was promoted to an electron:
734  if (electronIsoHandle.isValid()) {
735  bool FirstElectron = true;
736  reco::ElectronRef electronref;
737  for (reco::ElectronCollection::const_iterator iElectron = electronIsoHandle->begin();
738  iElectron != electronIsoHandle->end(); iElectron++) {
739  // 1) find the SC from the electron
740  electronref = reco::ElectronRef(electronIsoHandle, iElectron - electronIsoHandle->begin());
741  const reco::SuperClusterRef theClus = electronref->superCluster(); // SC from the electron;
742  if (&(*recrSC) == &(*theClus)) { // ref is the RecoEcalCandidateRef corresponding to the electron
743  if (FirstElectron) { // the first electron is stored in ele, keeping the ele.newSC = true
744  FirstElectron = false;
745  ele.p = electronref->track()->momentum().R();
746  float deta=-100, dphi=-100;
747  CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
748  ele.Dphi=dphi; ele.Deta=deta;
749  // fill the track Isolation
750  if (TrackEleIsolMap.isValid()) {
751  reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find(electronref);
752  if (mapTr != (*TrackEleIsolMap).end()) { ele.trackIsol = mapTr->val; }
753  }
754  }
755  else {
756  // FirstElectron is false, i.e. the SC of this electron is common to another electron.
757  // A new OpenHLTElectron is inserted in the theHLTElectrons vector setting newSC = false
758  OpenHLTElectron ele2;
759  ele2.hcalIsol = ele.hcalIsol;
760  ele2.trackIsol = -999;
761  ele2.Dphi = 700;
762  ele2.Deta = 700;
763  ele2.Et = ele.Et;
764  ele2.eta = ele.eta;
765  ele2.phi = ele.phi;
766  ele2.E = ele.E;
767  ele2.L1Isolated = ele.L1Isolated;
768  ele2.pixelSeeds = ele.pixelSeeds;
769  ele2.clusterShape = ele.clusterShape;
770  ele2.newSC = false;
771  ele2.p = electronref->track()->momentum().R();
772  ele2.r9 = ele.r9;
773  ele2.hovereh = ele.hovereh;
774  ele2.ecalIsol = ele.ecalIsol;
775  ele2.r9ID = ele.r9ID;
776  float deta=-100, dphi=-100;
777  CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
778  ele2.Dphi=dphi; ele2.Deta=deta;
779  // fill the track Isolation
780  if (TrackEleIsolMap.isValid()) {
781  reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
782  if (mapTr !=(*TrackEleIsolMap).end()) { ele2.trackIsol = mapTr->val;}
783  }
784  theHLTElectrons.push_back(ele2);
785  }
786  }
787  } // end of loop over electrons
788  } // end of if (electronIsoHandle) {
789 
790  //store the electron into the vector
791  theHLTElectrons.push_back(ele);
792  } // end of loop over ecalCandidates
793  } // end of if (recoIsolecalcands) {
794 }
795 
796 
798  std::vector<OpenHLTElectron> & theHLTElectrons,
799  const edm::Handle<reco::ElectronCollection> & electronNonIsoHandle,
800  const edm::Handle<reco::RecoEcalCandidateCollection> & recoNonIsolecalcands,
802  const edm::Handle<reco::ElectronSeedCollection> & L1NonIsoPixelSeedsMap,
803  const edm::Handle<reco::ElectronIsolationMap> & TrackEleIsolMap,
804  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9NonIsoMap,
805  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,
806  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalNonIsolMap,
807  const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDNonIsoMap,
808  EcalClusterLazyTools& lazyTools,
809  const edm::ESHandle<MagneticField>& theMagField,
810  reco::BeamSpot::Point & BSPosition )
811 {
812  // if there are electrons, then the isolation maps and the SC should be in the event; if not it is an error
813  if (recoNonIsolecalcands.isValid()) {
814  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoNonIsolecalcands->begin();
815  recoecalcand!= recoNonIsolecalcands->end(); recoecalcand++) {
816  //get the ref to the SC:
817  reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand));
818  reco::SuperClusterRef recrSC = ref->superCluster();
819  //reco::SuperClusterRef recrSC = recoecalcand->superCluster();
820 
822  ele.hcalIsol = -999;
823  ele.trackIsol = -999;
824  ele.ecalIsol = -999;
825  ele.L1Isolated = false;
826  ele.p = -999;
827  ele.pixelSeeds = -999;
828  ele.newSC = true;
829  ele.clusterShape = -999;
830  ele.Dphi = 700;
831  ele.Deta = 700;
832  ele.r9 = -999.;
833  ele.r9ID = -999.;
834  ele.hovereh = -999;
835  ele.Et = recoecalcand->et();
836  ele.eta = recoecalcand->eta();
837  ele.phi = recoecalcand->phi();
838  ele.E = recrSC->energy();
839  //Get the cluster shape
840  // std::vector<float> vCov = lazyTools.covariances( *(recrSC->seed()) );
841  std::vector<float> vCov = lazyTools.localCovariances( *(recrSC->seed()) );
842  double sigmaee = sqrt(vCov[0]);
843  // float EtaSC = fabs(recoecalcand->eta());
844  // if(EtaSC > 1.479 ) {//Endcap
845  // sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
846  // }
847  ele.clusterShape = sigmaee;
848 
849  // fill the ecal Isolation
850  if (EcalNonIsolMap.isValid()) {
851  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*EcalNonIsolMap).find(ref);
852  if (mapi !=(*EcalNonIsolMap).end()) { ele.ecalIsol = mapi->val;}
853  }
854  // fill the hcal Isolation
855  if (HcalEleIsolMap.isValid()) {
856  // reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand)) );
857  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( ref );
858  if (mapi !=(*HcalEleIsolMap).end()) {ele.hcalIsol = mapi->val;}
859  }
860  // fill the R9
861  if (electronR9NonIsoMap.isValid()) {
862  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9NonIsoMap).find( ref );
863  if (mapi !=(*electronR9NonIsoMap).end()) { ele.r9 = mapi->val; }
864  }
865  // fill the H for H/E
866  if (photonHoverEHNonIsoMap.isValid()) {
867  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*photonHoverEHNonIsoMap).find(ref);
868  if (mapi !=(*photonHoverEHNonIsoMap).end()) { ele.hovereh = mapi->val;}
869  }
870  // fill the R9ID
871  if (electronR9IDNonIsoMap.isValid()) {
872  reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IDNonIsoMap).find( ref );
873  if (mapi !=(*electronR9IDNonIsoMap).end()) { ele.r9ID = mapi->val; }
874  }
875 
876  // look if the SC has associated pixelSeeds
877  int nmatch = 0;
878 
879  if (L1NonIsoPixelSeedsMap.isValid()) {
880  for (reco::ElectronSeedCollection::const_iterator it = L1NonIsoPixelSeedsMap->begin();
881  it != L1NonIsoPixelSeedsMap->end(); it++) {
882  edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ;
883  reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ;
884  if (&(*recrSC) == &(*scRef)) { nmatch++;}
885  }
886  }
887 
888  ele.pixelSeeds = nmatch;
889 
890  // look if the SC was promoted to an electron:
891  if (electronNonIsoHandle.isValid()) {
892  bool FirstElectron = true;
893  reco::ElectronRef electronref;
894  for (reco::ElectronCollection::const_iterator iElectron = electronNonIsoHandle->begin();
895  iElectron != electronNonIsoHandle->end();iElectron++) {
896  // 1) find the SC from the electron
897  electronref = reco::ElectronRef(electronNonIsoHandle, iElectron - electronNonIsoHandle->begin());
898  const reco::SuperClusterRef theClus = electronref->superCluster(); //SC from the electron;
899  if (&(*recrSC) == &(*theClus)) { // ref is the RecoEcalCandidateRef corresponding to the electron
900  if (FirstElectron) { //the first electron is stored in ele, keeping the ele.newSC = true
901  FirstElectron = false;
902  ele.p = electronref->track()->momentum().R();
903  float deta=-100, dphi=-100;
904  CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
905  ele.Dphi=dphi; ele.Deta=deta;
906 
907  // fill the track Isolation
908  if (TrackEleIsolMap.isValid()) {
909  reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
910  if (mapTr !=(*TrackEleIsolMap).end()) { ele.trackIsol = mapTr->val;}
911  }
912  } else {
913  // FirstElectron is false, i.e. the SC of this electron is common to another electron.
914  // A new OpenHLTElectron is inserted in the theHLTElectrons vector setting newSC = false
915  OpenHLTElectron ele2;
916  ele2.hcalIsol = ele.hcalIsol;
917  ele2.trackIsol =-999;
918  ele2.ecalIsol = ele.ecalIsol;
919  ele2.Dphi = 700;
920  ele2.Deta = 700;
921  ele2.Et = ele.Et;
922  ele2.eta = ele.eta;
923  ele2.phi = ele.phi;
924  ele2.E = ele.E;
925  ele2.L1Isolated = ele.L1Isolated;
926  ele2.pixelSeeds = ele.pixelSeeds;
927  ele2.clusterShape = ele.clusterShape;
928  ele2.newSC = false;
929  ele2.p = electronref->track()->momentum().R();
930  ele2.r9 = ele.r9;
931  ele2.hovereh = ele.hovereh;
932  ele2.r9ID = ele.r9ID;
933  float deta=-100, dphi=-100;
934  CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
935  ele2.Dphi=dphi; ele2.Deta=deta;
936 
937  // fill the track Isolation
938  if (TrackEleIsolMap.isValid()) {
939  reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
940  if (mapTr !=(*TrackEleIsolMap).end()) { ele2.trackIsol = mapTr->val;}
941  }
942  theHLTElectrons.push_back(ele2);
943  }
944  }
945  } // end of loop over electrons
946  } // end of if (electronNonIsoHandle) {
947 
948  // store the electron into the vector
949  theHLTElectrons.push_back(ele);
950  } // end of loop over ecalCandidates
951  } // end of if (recoNonIsolecalcands) {
952 }
953 
955  reco::BeamSpot::Point & BSPosition,
956  const reco::ElectronRef eleref,
957  float& deltaeta,
958  float& deltaphi, bool useTrackProjectionToEcal )
959 {
960 
961  const reco::SuperClusterRef theClus = eleref->superCluster();
962  math::XYZVector scv(theClus->x(), theClus->y(), theClus->z());
963 
964  const math::XYZVector trackMom = eleref->track()->momentum();
965 
966  math::XYZPoint SCcorrPosition(theClus->x()-BSPosition.x(), theClus->y()-BSPosition.y() , theClus->z()-eleref->track()->vz() );
967  deltaeta = SCcorrPosition.eta()-eleref->track()->eta();
968 
969  if(useTrackProjectionToEcal){
970  ECALPositionCalculator posCalc;
971  const math::XYZPoint vertex(BSPosition.x(),BSPosition.y(),eleref->track()->vz());
972 
973  float phi1= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,1);
974  float phi2= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,-1);
975 
976  float deltaphi1=fabs( phi1 - theClus->position().phi() );
977  if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
978  if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
979 
980  float deltaphi2=fabs( phi2 - theClus->position().phi() );
981  if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
982  if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
983 
984  deltaphi = deltaphi1;
985  if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
986  }
987  else {
988  deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
989  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
990  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
991  }
992 
993 }
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
float * eldcot
Definition: HLTEgamma.h:178
float * elet
Definition: HLTEgamma.h:172
float * hphothovereh
Definition: HLTEgamma.h:181
int i
Definition: DBlmapReader.cc:9
int * helel1iso
Definition: HLTEgamma.h:185
float * helephi
Definition: HLTEgamma.h:182
int nhltele
Definition: HLTEgamma.h:189
float * helehovereh
Definition: HLTEgamma.h:182
float * elTrkIsoR03
Definition: HLTEgamma.h:172
float * eltrkiso
Definition: HLTEgamma.h:173
float * elTrkChi2NDF
Definition: HLTEgamma.h:172
void MakeL1NonIsolatedElectrons(std::vector< OpenHLTElectron > &electrons, const edm::Handle< reco::ElectronCollection > &electronNonIsoHandle, const edm::Handle< reco::RecoEcalCandidateCollection > &recoNonIsolecalcands, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalEleIsolMap, const edm::Handle< reco::ElectronSeedCollection > &L1NonIsoPixelSeedsMap, const edm::Handle< reco::ElectronIsolationMap > &TrackEleIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9NonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IDNonIsoMap, EcalClusterLazyTools &lazyTools, const edm::ESHandle< MagneticField > &theMagField, reco::BeamSpot::Point &BSPosition)
Definition: HLTEgamma.cc:797
float * elIP
Definition: HLTEgamma.h:172
float * heleDeta
Definition: HLTEgamma.h:183
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float * photonphi
Definition: HLTEgamma.h:179
float * eldist
Definition: HLTEgamma.h:178
float * hphottiso
Definition: HLTEgamma.h:181
float * elphi
Definition: HLTEgamma.h:172
float * heleClusShap
Definition: HLTEgamma.h:183
edm::Ref< RecoEcalCandidateCollection > RecoEcalCandidateRef
reference to an object in a collection of RecoEcalCandidate objects
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
float * heleDphi
Definition: HLTEgamma.h:183
float * hphotet
Definition: HLTEgamma.h:181
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
float * photonet
Definition: HLTEgamma.h:179
static const size_t kMaxhPhot
Definition: HLTEgamma.cc:31
float * elhOverE
Definition: HLTEgamma.h:174
int * hphotl1iso
Definition: HLTEgamma.h:185
void CalculateDetaDphi(const edm::ESHandle< MagneticField > &theMagField, reco::BeamSpot::Point &BSPosition, const reco::ElectronRef eleref, float &deltaeta, float &deltaphi, bool useTrackProjectionToEcal)
Definition: HLTEgamma.cc:954
float * hhfcluster2Dcut
Definition: HLTEgamma.h:191
float * photonpt
Definition: HLTEgamma.h:179
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTEgamma.cc:38
float * hphoteiso
Definition: HLTEgamma.h:181
double ecalPhi(const MagneticField *magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
int * helePixelSeeds
Definition: HLTEgamma.h:185
float * ele
Definition: HLTEgamma.h:172
float * elECaloIsoR03
Definition: HLTEgamma.h:172
float * heleeiso
Definition: HLTEgamma.h:182
float * elpt
Definition: HLTEgamma.h:172
T sqrt(T t)
Definition: SSEVec.h:28
float * elscEt
Definition: HLTEgamma.h:175
float * helehiso
Definition: HLTEgamma.h:182
float * elHCaloIsoR03
Definition: HLTEgamma.h:172
float * heleet
Definition: HLTEgamma.h:182
float * eld0corr
Definition: HLTEgamma.h:175
float * hhfelept
Definition: HLTEgamma.h:191
float * heleeta
Definition: HLTEgamma.h:182
bool isValid() const
Definition: HandleBase.h:76
int nhlthfeclus
Definition: HLTEgamma.h:189
float * hphoteta
Definition: HLTEgamma.h:181
int * elmishits
Definition: HLTEgamma.h:177
int * heleNewSC
Definition: HLTEgamma.h:188
static const size_t kMaxEl
Definition: HLTEgamma.cc:29
float * eleta
Definition: HLTEgamma.h:172
static const size_t kMaxhEle
Definition: HLTEgamma.cc:32
float * elsigmaietaieta
Definition: HLTEgamma.h:174
float * hhfeleeta
Definition: HLTEgamma.h:191
float * heleE
Definition: HLTEgamma.h:182
void analyze(const edm::Handle< reco::GsfElectronCollection > &electrons, const edm::Handle< reco::PhotonCollection > &photons, const edm::Handle< reco::ElectronCollection > &electronIsoHandle, const edm::Handle< reco::ElectronCollection > &electronNonIsoHandle, const edm::Handle< reco::ElectronIsolationMap > &NonIsoTrackEleIsolMap, const edm::Handle< reco::ElectronIsolationMap > &TrackEleIsolMap, const edm::Handle< reco::ElectronSeedCollection > &L1IsoPixelSeedsMap, const edm::Handle< reco::ElectronSeedCollection > &L1NonIsoPixelSeedsMap, const edm::Handle< reco::RecoEcalCandidateCollection > &recoIsolecalcands, const edm::Handle< reco::RecoEcalCandidateCollection > &recoNonIsolecalcands, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalEleIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalEleNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &TrackIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &TrackNonIsolMap, EcalClusterLazyTools &lazyTools, const edm::ESHandle< MagneticField > &theMagField, reco::BeamSpot::Point &BSPosition, std::vector< edm::Handle< edm::ValueMap< float > > > &eIDValueMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9NonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9NonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHNonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IDIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IDNonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IDIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IDNonIsoMap, const edm::Handle< reco::SuperClusterCollection > &electronHFClusterHandle, const edm::Handle< reco::RecoEcalCandidateCollection > &electronHFElectronHandle, TTree *tree)
Definition: HLTEgamma.cc:256
float * photone
Definition: HLTEgamma.h:179
float * eldeltaPhiIn
Definition: HLTEgamma.h:174
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
float * helep
Definition: HLTEgamma.h:182
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:236
void MakeL1IsolatedElectrons(std::vector< OpenHLTElectron > &electrons, const edm::Handle< reco::ElectronCollection > &electronIsoHandle, const edm::Handle< reco::RecoEcalCandidateCollection > &recoIsolecalcands, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalEleIsolMap, const edm::Handle< reco::ElectronSeedCollection > &L1IsoPixelSeedsMap, const edm::Handle< reco::ElectronIsolationMap > &TrackEleIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &electronR9IDIsoMap, EcalClusterLazyTools &lazyTools, const edm::ESHandle< MagneticField > &theMagField, reco::BeamSpot::Point &BSPosition)
Definition: HLTEgamma.cc:640
T const * product() const
Definition: ESHandle.h:62
float * hphotR9ID
Definition: HLTEgamma.h:184
float * hphotR9
Definition: HLTEgamma.h:184
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
float * photoneta
Definition: HLTEgamma.h:179
int nhltgam
Definition: HLTEgamma.h:189
float * hphothiso
Definition: HLTEgamma.h:181
int * elNLostHits
Definition: HLTEgamma.h:186
bool * elIsEcalDriven
Definition: HLTEgamma.h:187
int * eleId
Definition: HLTEgamma.h:186
float * elecaliso
Definition: HLTEgamma.h:173
int nphoton
Definition: HLTEgamma.h:189
static const size_t kMaxPhot
Definition: HLTEgamma.cc:30
float * hhfclustere9e25
Definition: HLTEgamma.h:191
bool * elqGsfCtfScPixConsistent
Definition: HLTEgamma.h:176
int nele
Definition: HLTEgamma.h:189
void MakeL1NonIsolatedPhotons(std::vector< OpenHLTPhoton > &photons, const edm::Handle< reco::RecoEcalCandidateCollection > &recoNonIsolecalcands, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &TrackNonIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9NonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHNonIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IDNonIsoMap, EcalClusterLazyTools &lazyTools)
Definition: HLTEgamma.cc:561
float * heletiso
Definition: HLTEgamma.h:182
void MakeL1IsolatedPhotons(std::vector< OpenHLTPhoton > &photons, const edm::Handle< reco::RecoEcalCandidateCollection > &recoIsolecalcands, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &EcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &HcalIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &TrackIsolMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonHoverEHIsoMap, const edm::Handle< reco::RecoEcalCandidateIsolationMap > &photonR9IDIsoMap, EcalClusterLazyTools &lazyTools)
Definition: HLTEgamma.cc:476
int nhlthfele
Definition: HLTEgamma.h:189
float * hphotphi
Definition: HLTEgamma.h:181
float * heleR9
Definition: HLTEgamma.h:184
float * hphotClusShap
Definition: HLTEgamma.h:183
float * elhcaliso
Definition: HLTEgamma.h:173
float * eldeltaEtaIn
Definition: HLTEgamma.h:174
float * elFbrem
Definition: HLTEgamma.h:172
void clear(void)
Definition: HLTEgamma.cc:193
float * heleR9ID
Definition: HLTEgamma.h:184