CMS 3D CMS Logo

PhotonAnalyzer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 //
4 
6 
7 
18 using namespace std;
19 
21 {
22  fName_ = pset.getParameter<string>("analyzerName");
23  prescaleFactor_ = pset.getUntrackedParameter<int>("prescaleFactor",1);
24 
25  photon_token_ = consumes<vector<reco::Photon> >(pset.getParameter<edm::InputTag>("phoProducer"));
26  barrelRecHit_token_ = consumes<edm::SortedCollection<EcalRecHit,edm::StrictWeakOrdering<EcalRecHit> > >(pset.getParameter<edm::InputTag>("barrelRecHitProducer"));
27  PhotonIDLoose_token_ = consumes<edm::ValueMap<bool> >(pset.getParameter<edm::InputTag>("photonIDLoose"));
28  PhotonIDTight_token_ = consumes<edm::ValueMap<bool> >(pset.getParameter<edm::InputTag>("photonIDTight"));
29  endcapRecHit_token_ = consumes<edm::SortedCollection<EcalRecHit,edm::StrictWeakOrdering<EcalRecHit> > >(pset.getParameter<edm::InputTag>("endcapRecHitProducer"));
30  triggerEvent_token_ = consumes<trigger::TriggerEvent>(pset.getParameter<edm::InputTag>("triggerEvent"));
31  offline_pvToken_ = consumes<reco::VertexCollection>(pset.getUntrackedParameter<edm::InputTag>("offlinePV", edm::InputTag("offlinePrimaryVertices")));
32 
33  minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
34  photonMaxEta_ = pset.getParameter<double>("maxPhoEta");
35  invMassEtCut_ = pset.getParameter<double>("invMassEtCut");
36  cutStep_ = pset.getParameter<double>("cutStep");
37  numberOfSteps_ = pset.getParameter<int>("numberOfSteps");
38  useBinning_ = pset.getParameter<bool>("useBinning");
39  useTriggerFiltering_ = pset.getParameter<bool>("useTriggerFiltering");
40  minimalSetOfHistos_ = pset.getParameter<bool>("minimalSetOfHistos");
41  excludeBkgHistos_ = pset.getParameter<bool>("excludeBkgHistos");
42  standAlone_ = pset.getParameter<bool>("standAlone");
43  isolationStrength_ = pset.getParameter<int>("isolationStrength");
44  isHeavyIon_ = pset.getUntrackedParameter<bool>("isHeavyIon",false);
45 
46  histo_index_photons_ = 0;
47  histo_index_conversions_ = 0;
48  histo_index_efficiency_ = 0;
49  histo_index_invMass_ = 0;
50 
51  nEvt_=0;
52 
53  // Determining parts...
54  parts_.push_back("AllEcal");
55  parts_.push_back("Barrel");
56  parts_.push_back("Endcaps");
57  // ...and types
58  types_.push_back("All");
59  types_.push_back("GoodCandidate");
60  if (!excludeBkgHistos_)
61  {
62  types_.push_back("Background");
63  }
64 
65  // Histogram parameters
66  etaBin_ = pset.getParameter<int>("etaBin");
67  etaMin_ = pset.getParameter<double>("etaMin");
68  etaMax_ = pset.getParameter<double>("etaMax");
69 
70  etBin_ = pset.getParameter<int>("etBin");
71  etMin_ = pset.getParameter<double>("etMin");
72  etMax_ = pset.getParameter<double>("etMax");
73 
74  phiBin_ = pset.getParameter<int>("phiBin");
75  phiMin_ = pset.getParameter<double>("phiMin");
76  phiMax_ = pset.getParameter<double>("phiMax");
77 
78  eBin_ = pset.getParameter<int>("eBin");
79  eMin_ = pset.getParameter<double>("eMin");
80  eMax_ = pset.getParameter<double>("eMax");
81 
82  numberBin_ = pset.getParameter<int>("numberBin");
83  numberMin_ = pset.getParameter<double>("numberMin");
84  numberMax_ = pset.getParameter<double>("numberMax");
85 
86  r9Bin_ = pset.getParameter<int>("r9Bin");
87  r9Min_ = pset.getParameter<double>("r9Min");
88  r9Max_ = pset.getParameter<double>("r9Max");
89 
90  sigmaIetaBin_ = pset.getParameter<int>("sigmaIetaBin");
91  sigmaIetaMin_ = pset.getParameter<double>("sigmaIetaMin");
92  sigmaIetaMax_ = pset.getParameter<double>("sigmaIetaMax");
93 
94  sumBin_ = pset.getParameter<int>("sumBin");
95  sumMin_ = pset.getParameter<double>("sumMin");
96  sumMax_ = pset.getParameter<double>("sumMax");
97 
98  hOverEBin_ = pset.getParameter<int>("hOverEBin");
99  hOverEMin_ = pset.getParameter<double>("hOverEMin");
100  hOverEMax_ = pset.getParameter<double>("hOverEMax");
101 
102  eOverPBin_ = pset.getParameter<int>("eOverPBin");
103  eOverPMin_ = pset.getParameter<double>("eOverPMin");
104  eOverPMax_ = pset.getParameter<double>("eOverPMax");
105 
106  dPhiTracksBin_ = pset.getParameter<int>("dPhiTracksBin");
107  dPhiTracksMin_ = pset.getParameter<double>("dPhiTracksMin");
108  dPhiTracksMax_ = pset.getParameter<double>("dPhiTracksMax");
109 
110  dEtaTracksBin_ = pset.getParameter<int>("dEtaTracksBin");
111  dEtaTracksMin_ = pset.getParameter<double>("dEtaTracksMin");
112  dEtaTracksMax_ = pset.getParameter<double>("dEtaTracksMax");
113 
114  chi2Bin_ = pset.getParameter<int>("chi2Bin");
115  chi2Min_ = pset.getParameter<double>("chi2Min");
116  chi2Max_ = pset.getParameter<double>("chi2Max");
117 
118  zBin_ = pset.getParameter<int>("zBin");
119  zMin_ = pset.getParameter<double>("zMin");
120  zMax_ = pset.getParameter<double>("zMax");
121 
122  rBin_ = pset.getParameter<int>("rBin");
123  rMin_ = pset.getParameter<double>("rMin");
124  rMax_ = pset.getParameter<double>("rMax");
125 
126  xBin_ = pset.getParameter<int>("xBin");
127  xMin_ = pset.getParameter<double>("xMin");
128  xMax_ = pset.getParameter<double>("xMax");
129 
130  yBin_ = pset.getParameter<int>("yBin");
131  yMin_ = pset.getParameter<double>("yMin");
132  yMax_ = pset.getParameter<double>("yMax");
133 
134  reducedEtBin_ = etBin_/4;
135  reducedEtaBin_ = etaBin_/4;
136  reducedR9Bin_ = r9Bin_/4;
137  reducedSumBin_ = sumBin_/4;
138 }
139 
141 {
142 }
143 
145  edm::Run const & /* iRun */,
146  edm::EventSetup const & /* iSetup */)
147 {
148  bookHistogramsForHistogramCounts(iBooker);
149 
150  bookHistogramsEfficiency(iBooker);
151  bookHistogramsInvMass(iBooker);
152  bookHistogramsPhotons(iBooker);
153  bookHistogramsConversions(iBooker);
154 
155  fillHistogramsForHistogramCounts(iBooker);
156 }
157 
159 {
160  iBooker.setCurrentFolder("Egamma/"+fName_+"/");
161  // Int values stored in MEs to keep track of how many histograms are in each folder
162  totalNumberOfHistos_efficiencyFolder = iBooker.bookInt("numberOfHistogramsInEfficiencyFolder");
163  totalNumberOfHistos_invMassFolder = iBooker.bookInt("numberOfHistogramsInInvMassFolder");
164  totalNumberOfHistos_photonsFolder = iBooker.bookInt("numberOfHistogramsInPhotonsFolder");
165  totalNumberOfHistos_conversionsFolder = iBooker.bookInt("numberOfHistogramsInConversionsFolder");
166 }
167 
169 {
170  iBooker.setCurrentFolder("Egamma/"+fName_+"/");
171  totalNumberOfHistos_efficiencyFolder->Fill(histo_index_efficiency_);
172  totalNumberOfHistos_invMassFolder->Fill(histo_index_invMass_);
173  totalNumberOfHistos_photonsFolder->Fill(histo_index_photons_);
174  totalNumberOfHistos_conversionsFolder->Fill(histo_index_conversions_);
175 }
176 
178 {
179  // Set folder
180  iBooker.setCurrentFolder("Egamma/"+fName_+"/Efficiencies");
181 
182  // Don't number these histograms with the "bookHisto" method, since they'll be erased in the offline client
183  h_phoEta_Loose_ = iBooker.book1D("phoEtaLoose", "Loose Photon #eta", etaBin_, etaMin_, etaMax_);
184  h_phoEta_Tight_ = iBooker.book1D("phoEtaTight", "Tight Photon #eta", etaBin_, etaMin_, etaMax_);
185 
186  h_phoEt_Loose_ = iBooker.book1D("phoEtLoose", "Loose Photon E_{T}", etBin_, etMin_, etMax_);
187  h_phoEt_Tight_ = iBooker.book1D("phoEtTight", "Tight Photon E_{T}", etBin_, etMin_, etMax_);
188 
189  h_phoEta_preHLT_ = iBooker.book1D("phoEtaPreHLT", "Photon #eta: before HLT", etaBin_, etaMin_, etaMax_);
190  h_phoEta_postHLT_ = iBooker.book1D("phoEtaPostHLT", "Photon #eta: after HLT", etaBin_, etaMin_, etaMax_);
191  h_phoEt_preHLT_ = iBooker.book1D("phoEtPreHLT", "Photon E_{T}: before HLT", etBin_, etMin_, etMax_);
192  h_phoEt_postHLT_ = iBooker.book1D("phoEtPostHLT", "Photon E_{T}: after HLT", etBin_, etMin_, etMax_);
193 
194  h_convEta_Loose_ = iBooker.book1D("convEtaLoose", "Converted Loose Photon #eta", etaBin_, etaMin_, etaMax_);
195  h_convEta_Tight_ = iBooker.book1D("convEtaTight", "Converted Tight Photon #eta", etaBin_, etaMin_, etaMax_);
196  h_convEt_Loose_ = iBooker.book1D("convEtLoose", "Converted Loose Photon E_{T}", etBin_, etMin_, etMax_);
197  h_convEt_Tight_ = iBooker.book1D("convEtTight", "Converted Tight Photon E_{T}", etBin_, etMin_, etMax_);
198 
199  h_phoEta_Vertex_ = iBooker.book1D("phoEtaVertex", "Converted Photons before valid vertex cut: #eta", etaBin_, etaMin_, etaMax_);
200 
201  // Some temporary vectors
202  vector<MonitorElement*> temp1DVectorEta;
203  vector<MonitorElement*> temp1DVectorPhi;
204  vector<vector<MonitorElement*> > temp2DVectorPhi;
205 
206  for(int cut = 0; cut != numberOfSteps_; ++cut){ //looping over Et cut values
207  for(uint type=0;type!=types_.size();++type){ //looping over isolation type
208  currentFolder_.str("");
209  currentFolder_ << "Egamma/"+fName_+"/" << types_[type] << "Photons/Et above " << (cut+1)*cutStep_ << " GeV/Conversions";
210  iBooker.setCurrentFolder(currentFolder_.str());
211 
212  temp1DVectorEta.push_back(iBooker.book1D("phoConvEtaForEfficiency","Converted Photon #eta;#eta",etaBin_,etaMin_,etaMax_));
213  for(uint part=0;part!=parts_.size();++part){
214  temp1DVectorPhi.push_back(iBooker.book1D("phoConvPhiForEfficiency"+parts_[part],"Converted Photon #phi;#phi",phiBin_,phiMin_,phiMax_));
215  }
216  temp2DVectorPhi.push_back(temp1DVectorPhi);
217  temp1DVectorPhi.clear();
218  }
219  h_phoConvEtaForEfficiency_.push_back(temp1DVectorEta);
220  temp1DVectorEta.clear();
221  h_phoConvPhiForEfficiency_.push_back(temp2DVectorPhi);
222  temp2DVectorPhi.clear();
223  }
224 }
225 
227 {
228  // Set folder
229  iBooker.setCurrentFolder("Egamma/"+fName_+"/InvMass");
230 
231  h_invMassAllPhotons_ = bookHisto(iBooker, "invMassAllIsolatedPhotons", "Two photon invariant mass: All isolated photons;M (GeV)", etBin_, etMin_, etMax_);
232  h_invMassPhotonsEBarrel_ = bookHisto(iBooker, "invMassIsoPhotonsEBarrel", "Two photon invariant mass: isolated photons in barrel; M (GeV)", etBin_, etMin_, etMax_);
233  h_invMassPhotonsEEndcap_ = bookHisto(iBooker, "invMassIsoPhotonsEEndcap", "Two photon invariant mass: isolated photons in endcap; M (GeV)", etBin_, etMin_, etMax_);
234  h_invMassPhotonsEEndcapEBarrel_ = bookHisto(iBooker, "invMassIsoPhotonsEEndcapEBarrel", "Two photon invariant mass: isolated photons in endcap-barrel; M (GeV)", etBin_, etMin_, etMax_);
235 
236  h_invMassZeroWithTracks_ = bookHisto(iBooker, "invMassZeroWithTracks", "Two photon invariant mass: Neither has tracks;M (GeV)", etBin_, etMin_, etMax_);
237  h_invMassOneWithTracks_ = bookHisto(iBooker, "invMassOneWithTracks", "Two photon invariant mass: Only one has tracks;M (GeV)", etBin_, etMin_, etMax_);
238  h_invMassTwoWithTracks_ = bookHisto(iBooker, "invMassTwoWithTracks", "Two photon invariant mass: Both have tracks;M (GeV)", etBin_, etMin_, etMax_);
239 
240  h_nRecoVtx_ = bookHisto(iBooker, "nOfflineVtx", "# of Offline Vertices", 80, -0.5, 79.5);
241 }
242 
244 {
245  // Set folder
246  // Folder is set by the book2DHistoVector and book3DHistoVector methods
247 
248  //ENERGY VARIABLES
249  book3DHistoVector(iBooker, h_phoE_, "1D","phoE","Energy;E (GeV)",eBin_,eMin_,eMax_);
250  book3DHistoVector(iBooker, h_phoSigmaEoverE_, "1D","phoSigmaEoverE","#sigma_{E}/E; #sigma_{E}/E", 100,0.,0.08);
251  book3DHistoVector(iBooker, p_phoSigmaEoverEvsNVtx_, "Profile","phoSigmaEoverEvsNVtx","#sigma_{E}/E vs NVtx; N_{vtx}; #sigma_{E}/E",80, -0.5, 79.5, 100,0., 0.08);
252  book3DHistoVector(iBooker, h_phoEt_, "1D","phoEt","E_{T};E_{T} (GeV)", etBin_,etMin_,etMax_);
253 
254  //NUMBER OF PHOTONS
255  book3DHistoVector(iBooker, h_nPho_, "1D","nPho","Number of Photons per Event;# #gamma",numberBin_,numberMin_,numberMax_);
256 
257  //GEOMETRICAL VARIABLES
258  //photon eta/phi
259  book2DHistoVector(iBooker, h_phoEta_, "1D","phoEta","#eta;#eta",etaBin_,etaMin_,etaMax_) ;
260  book3DHistoVector(iBooker, h_phoPhi_, "1D","phoPhi","#phi;#phi",phiBin_,phiMin_,phiMax_) ;
261 
262  //supercluster eta/phi
263  book2DHistoVector(iBooker, h_scEta_, "1D","scEta","SuperCluster #eta;#eta",etaBin_,etaMin_,etaMax_) ;
264  book3DHistoVector(iBooker, h_scPhi_, "1D","scPhi","SuperCluster #phi;#phi",phiBin_,phiMin_,phiMax_) ;
265 
266  //SHOWER SHAPE VARIABLES
267  //r9
268  book3DHistoVector(iBooker, h_r9_, "1D","r9","R9;R9",r9Bin_,r9Min_, r9Max_);
269  if (standAlone_) {
270  book2DHistoVector(iBooker, h_r9VsEt_, "2D","r9VsEt2D","R9 vs E_{T};E_{T} (GeV);R9",reducedEtBin_,etMin_,etMax_,reducedR9Bin_,r9Min_,r9Max_);
271  }
272  book2DHistoVector(iBooker, p_r9VsEt_, "Profile","r9VsEt","Avg R9 vs E_{T};E_{T} (GeV);R9",etBin_,etMin_,etMax_,r9Bin_,r9Min_,r9Max_);
273  if (standAlone_) {
274  book2DHistoVector(iBooker, h_r9VsEta_, "2D","r9VsEta2D","R9 vs #eta;#eta;R9",reducedEtaBin_,etaMin_,etaMax_,reducedR9Bin_,r9Min_,r9Max_);
275  }
276  book2DHistoVector(iBooker, p_r9VsEta_, "Profile","r9VsEta","Avg R9 vs #eta;#eta;R9",etaBin_,etaMin_,etaMax_,r9Bin_,r9Min_,r9Max_);
277 
278  //sigma ieta ieta
279  book3DHistoVector(iBooker, h_phoSigmaIetaIeta_, "1D","phoSigmaIetaIeta","#sigma_{i#etai#eta};#sigma_{i#etai#eta}",sigmaIetaBin_,sigmaIetaMin_,sigmaIetaMax_);
280  if (standAlone_) {
281  book2DHistoVector(iBooker, h_sigmaIetaIetaVsEta_, "2D","sigmaIetaIetaVsEta2D","#sigma_{i#etai#eta} vs #eta;#eta;#sigma_{i#etai#eta}",reducedEtaBin_,etaMin_,etaMax_,sigmaIetaBin_,sigmaIetaMin_,sigmaIetaMax_);
282  }
283  book2DHistoVector(iBooker, p_sigmaIetaIetaVsEta_, "Profile","sigmaIetaIetaVsEta","Avg #sigma_{i#etai#eta} vs #eta;#eta;#sigma_{i#etai#eta}",etaBin_,etaMin_,etaMax_,sigmaIetaBin_,sigmaIetaMin_,sigmaIetaMax_);
284 
285  //e1x5
286  if (standAlone_) {
287  book2DHistoVector(iBooker, h_e1x5VsEt_, "2D","e1x5VsEt2D","E1x5 vs E_{T};E_{T} (GeV);E1X5 (GeV)",reducedEtBin_,etMin_,etMax_,reducedEtBin_,etMin_,etMax_);
288  }
289  book2DHistoVector(iBooker, p_e1x5VsEt_, "Profile","e1x5VsEt","Avg E1x5 vs E_{T};E_{T} (GeV);E1X5 (GeV)",etBin_,etMin_,etMax_,etBin_,etMin_,etMax_);
290  if (standAlone_) {
291  book2DHistoVector(iBooker, h_e1x5VsEta_, "2D","e1x5VsEta2D","E1x5 vs #eta;#eta;E1X5 (GeV)",reducedEtaBin_,etaMin_,etaMax_,reducedEtBin_,etMin_,etMax_);
292  }
293  book2DHistoVector(iBooker, p_e1x5VsEta_, "Profile","e1x5VsEta","Avg E1x5 vs #eta;#eta;E1X5 (GeV)",etaBin_,etaMin_,etaMax_,etBin_,etMin_,etMax_);
294 
295  //e2x5
296  if (standAlone_) {
297  book2DHistoVector(iBooker, h_e2x5VsEt_, "2D","e2x5VsEt2D","E2x5 vs E_{T};E_{T} (GeV);E2X5 (GeV)",reducedEtBin_,etMin_,etMax_,reducedEtBin_,etMin_,etMax_);
298  }
299  book2DHistoVector(iBooker, p_e2x5VsEt_, "Profile","e2x5VsEt","Avg E2x5 vs E_{T};E_{T} (GeV);E2X5 (GeV)",etBin_,etMin_,etMax_,etBin_,etMin_,etMax_);
300  if (standAlone_) {
301  book2DHistoVector(iBooker, h_e2x5VsEta_, "2D","e2x5VsEta2D","E2x5 vs #eta;#eta;E2X5 (GeV)",reducedEtaBin_,etaMin_,etaMax_,reducedEtBin_,etMin_,etMax_);
302  }
303  book2DHistoVector(iBooker, p_e2x5VsEta_, "Profile","e2x5VsEta","Avg E2x5 vs #eta;#eta;E2X5 (GeV)",etaBin_,etaMin_,etaMax_,etBin_,etMin_,etMax_);
304 
305  //r1x5
306  if (standAlone_) {
307  book2DHistoVector(iBooker, h_r1x5VsEt_, "2D","r1x5VsEt2D","R1x5 vs E_{T};E_{T} (GeV);R1X5",reducedEtBin_,etMin_,etMax_,reducedR9Bin_,r9Min_,r9Max_);
308  }
309  book2DHistoVector(iBooker, p_r1x5VsEt_, "Profile","r1x5VsEt","Avg R1x5 vs E_{T};E_{T} (GeV);R1X5",etBin_,etMin_,etMax_,r9Bin_,r9Min_,r9Max_);
310  if (standAlone_) {
311  book2DHistoVector(iBooker, h_r1x5VsEta_, "2D","r1x5VsEta2D","R1x5 vs #eta;#eta;R1X5",reducedEtaBin_,etaMin_,etaMax_,reducedR9Bin_,r9Min_,r9Max_);
312  }
313  book2DHistoVector(iBooker, p_r1x5VsEta_, "Profile","r1x5VsEta","Avg R1x5 vs #eta;#eta;R1X5",etaBin_,etaMin_,etaMax_,r9Bin_,r9Min_,r9Max_);
314 
315  //r2x5
316  if (standAlone_) {
317  book2DHistoVector(iBooker, h_r2x5VsEt_ ,"2D","r2x5VsEt2D","R2x5 vs E_{T};E_{T} (GeV);R2X5",reducedEtBin_,etMin_,etMax_,reducedR9Bin_,r9Min_,r9Max_);
318  }
319  book2DHistoVector(iBooker, p_r2x5VsEt_ ,"Profile","r2x5VsEt","Avg R2x5 vs E_{T};E_{T} (GeV);R2X5",etBin_,etMin_,etMax_,r9Bin_,r9Min_,r9Max_);
320  if (standAlone_) {
321  book2DHistoVector(iBooker, h_r2x5VsEta_ ,"2D","r2x5VsEta2D","R2x5 vs #eta;#eta;R2X5",reducedEtaBin_,etaMin_,etaMax_,reducedR9Bin_,r9Min_,r9Max_);
322  }
323  book2DHistoVector(iBooker, p_r2x5VsEta_ ,"Profile","r2x5VsEta","Avg R2x5 vs #eta;#eta;R2X5",etaBin_,etaMin_,etaMax_,r9Bin_,r9Min_,r9Max_);
324 
325  //maxEXtalOver3x3
326  if (standAlone_) {
327  book2DHistoVector(iBooker, h_maxEXtalOver3x3VsEt_ ,"2D","maxEXtalOver3x3VsEt2D","(Max Xtal E)/E3x3 vs E_{T};E_{T} (GeV);(Max Xtal E)/E3x3",reducedEtBin_,etMin_,etMax_,r9Bin_,r9Min_,r9Max_);
328  }
329  book2DHistoVector(iBooker, p_maxEXtalOver3x3VsEt_ ,"Profile","maxEXtalOver3x3VsEt","Avg (Max Xtal E)/E3x3 vs E_{T};E_{T} (GeV);(Max Xtal E)/E3x3",etBin_,etMin_,etMax_,r9Bin_,r9Min_,r9Max_);
330  if (standAlone_) {
331  book2DHistoVector(iBooker, h_maxEXtalOver3x3VsEta_ ,"2D","maxEXtalOver3x3VsEta2D","(Max Xtal E)/E3x3 vs #eta;#eta;(Max Xtal E)/E3x3",reducedEtaBin_,etaMin_,etaMax_,r9Bin_,r9Min_,r9Max_);
332  }
333  book2DHistoVector(iBooker, p_maxEXtalOver3x3VsEta_ ,"Profile","maxEXtalOver3x3VsEta","Avg (Max Xtal E)/E3x3 vs #eta;#eta;(Max Xtal E)/E3x3",etaBin_,etaMin_,etaMax_,r9Bin_,r9Min_,r9Max_);
334 
335  //TRACK ISOLATION VARIABLES
336  //nTrackIsolSolid
337  book2DHistoVector(iBooker, h_nTrackIsolSolid_ ,"1D","nIsoTracksSolid","Number Of Tracks in the Solid Iso Cone;# tracks",numberBin_,numberMin_,numberMax_);
338  if (standAlone_) {
339  book2DHistoVector(iBooker, h_nTrackIsolSolidVsEt_ ,"2D","nIsoTracksSolidVsEt2D","Number Of Tracks in the Solid Iso Cone vs E_{T};E_{T};# tracks",reducedEtBin_,etMin_, etMax_,numberBin_,numberMin_,numberMax_);
340  }
341  book2DHistoVector(iBooker, p_nTrackIsolSolidVsEt_ ,"Profile","nIsoTracksSolidVsEt","Avg Number Of Tracks in the Solid Iso Cone vs E_{T};E_{T};# tracks",etBin_,etMin_,etMax_,numberBin_,numberMin_,numberMax_);
342  if (standAlone_) {
343  book2DHistoVector(iBooker, h_nTrackIsolSolidVsEta_ ,"2D","nIsoTracksSolidVsEta2D","Number Of Tracks in the Solid Iso Cone vs #eta;#eta;# tracks",reducedEtaBin_,etaMin_, etaMax_,numberBin_,numberMin_,numberMax_);
344  }
345  book2DHistoVector(iBooker, p_nTrackIsolSolidVsEta_ ,"Profile","nIsoTracksSolidVsEta","Avg Number Of Tracks in the Solid Iso Cone vs #eta;#eta;# tracks",etaBin_,etaMin_, etaMax_,numberBin_,numberMin_,numberMax_);
346 
347  //nTrackIsolHollow
348  book2DHistoVector(iBooker, h_nTrackIsolHollow_ ,"1D","nIsoTracksHollow","Number Of Tracks in the Hollow Iso Cone;# tracks",numberBin_,numberMin_,numberMax_);
349  if (standAlone_) {
350  book2DHistoVector(iBooker, h_nTrackIsolHollowVsEt_ ,"2D","nIsoTracksHollowVsEt2D","Number Of Tracks in the Hollow Iso Cone vs E_{T};E_{T};# tracks",reducedEtBin_,etMin_, etMax_,numberBin_,numberMin_,numberMax_);
351  }
352  book2DHistoVector(iBooker, p_nTrackIsolHollowVsEt_ ,"Profile","nIsoTracksHollowVsEt","Avg Number Of Tracks in the Hollow Iso Cone vs E_{T};E_{T};# tracks",etBin_,etMin_,etMax_,numberBin_,numberMin_,numberMax_);
353  if (standAlone_) {
354  book2DHistoVector(iBooker, h_nTrackIsolHollowVsEta_ ,"2D","nIsoTracksHollowVsEta2D","Number Of Tracks in the Hollow Iso Cone vs #eta;#eta;# tracks",reducedEtaBin_,etaMin_, etaMax_,numberBin_,numberMin_,numberMax_);
355  }
356  book2DHistoVector(iBooker, p_nTrackIsolHollowVsEta_ ,"Profile","nIsoTracksHollowVsEta","Avg Number Of Tracks in the Hollow Iso Cone vs #eta;#eta;# tracks",etaBin_,etaMin_, etaMax_,numberBin_,numberMin_,numberMax_);
357 
358  //trackPtSumSolid
359  book2DHistoVector(iBooker, h_trackPtSumSolid_ ,"1D","isoPtSumSolid","Track P_{T} Sum in the Solid Iso Cone;P_{T} (GeV)",sumBin_,sumMin_,sumMax_);
360  if (standAlone_) {
361  book2DHistoVector(iBooker, h_trackPtSumSolidVsEt_ ,"2D","isoPtSumSolidVsEt2D","Track P_{T} Sum in the Solid Iso Cone;E_{T} (GeV);P_{T} (GeV)",reducedEtBin_,etMin_, etMax_,reducedSumBin_,sumMin_,sumMax_);
362  }
363  book2DHistoVector(iBooker, p_trackPtSumSolidVsEt_ ,"Profile","isoPtSumSolidVsEt","Avg Track P_{T} Sum in the Solid Iso Cone vs E_{T};E_{T} (GeV);P_{T} (GeV)",etBin_,etMin_,etMax_,sumBin_,sumMin_,sumMax_);
364  if (standAlone_) {
365  book2DHistoVector(iBooker, h_trackPtSumSolidVsEta_ ,"2D","isoPtSumSolidVsEta2D","Track P_{T} Sum in the Solid Iso Cone;#eta;P_{T} (GeV)",reducedEtaBin_,etaMin_, etaMax_,reducedSumBin_,sumMin_,sumMax_);
366  }
367  book2DHistoVector(iBooker, p_trackPtSumSolidVsEta_ ,"Profile","isoPtSumSolidVsEta","Avg Track P_{T} Sum in the Solid Iso Cone vs #eta;#eta;P_{T} (GeV)",etaBin_,etaMin_, etaMax_,sumBin_,sumMin_,sumMax_);
368 
369  //trackPtSumHollow
370  book2DHistoVector(iBooker, h_trackPtSumHollow_ ,"1D","isoPtSumHollow","Track P_{T} Sum in the Hollow Iso Cone;P_{T} (GeV)",sumBin_,sumMin_,sumMax_);
371  if (standAlone_) {
372  book2DHistoVector(iBooker, h_trackPtSumHollowVsEt_ ,"2D","isoPtSumHollowVsEt2D","Track P_{T} Sum in the Hollow Iso Cone;E_{T} (GeV);P_{T} (GeV)",reducedEtBin_,etMin_, etMax_,reducedSumBin_,sumMin_,sumMax_);
373  }
374  book2DHistoVector(iBooker, p_trackPtSumHollowVsEt_ ,"Profile","isoPtSumHollowVsEt","Avg Track P_{T} Sum in the Hollow Iso Cone vs E_{T};E_{T} (GeV);P_{T} (GeV)",etBin_,etMin_,etMax_,sumBin_,sumMin_,sumMax_);
375  if (standAlone_) {
376  book2DHistoVector(iBooker, h_trackPtSumHollowVsEta_ ,"2D","isoPtSumHollowVsEta2D","Track P_{T} Sum in the Hollow Iso Cone;#eta;P_{T} (GeV)",reducedEtaBin_,etaMin_, etaMax_,reducedSumBin_,sumMin_,sumMax_);
377  }
378  book2DHistoVector(iBooker, p_trackPtSumHollowVsEta_ ,"Profile","isoPtSumHollowVsEta","Avg Track P_{T} Sum in the Hollow Iso Cone vs #eta;#eta;P_{T} (GeV)",etaBin_,etaMin_, etaMax_,sumBin_,sumMin_,sumMax_);
379 
380  //CALORIMETER ISOLATION VARIABLES
381  //ecal sum
382  book2DHistoVector(iBooker, h_ecalSum_, "1D","ecalSum","Ecal Sum in the Iso Cone;E (GeV)",sumBin_,sumMin_,sumMax_);
383  book2DHistoVector(iBooker, h_ecalSumEBarrel_, "1D","ecalSumEBarrel","Ecal Sum in the IsoCone for Barrel;E (GeV)",sumBin_,sumMin_,sumMax_);
384  book2DHistoVector(iBooker, h_ecalSumEEndcap_, "1D","ecalSumEEndcap","Ecal Sum in the IsoCone for Endcap;E (GeV)",sumBin_,sumMin_,sumMax_);
385  if (standAlone_) {
386  book2DHistoVector(iBooker, h_ecalSumVsEt_, "2D","ecalSumVsEt2D","Ecal Sum in the Iso Cone;E_{T} (GeV);E (GeV)",reducedEtBin_,etMin_, etMax_,reducedSumBin_,sumMin_,sumMax_);
387  }
388  book3DHistoVector(iBooker, p_ecalSumVsEt_, "Profile","ecalSumVsEt","Avg Ecal Sum in the Iso Cone vs E_{T};E_{T} (GeV);E (GeV)",etBin_,etMin_, etMax_,sumBin_,sumMin_,sumMax_);
389  if (standAlone_) {
390  book2DHistoVector(iBooker, h_ecalSumVsEta_, "2D","ecalSumVsEta2D","Ecal Sum in the Iso Cone;#eta;E (GeV)",reducedEtaBin_,etaMin_, etaMax_,reducedSumBin_,sumMin_,sumMax_);
391  }
392  book2DHistoVector(iBooker, p_ecalSumVsEta_, "Profile","ecalSumVsEta","Avg Ecal Sum in the Iso Cone vs #eta;#eta;E (GeV)",etaBin_,etaMin_, etaMax_,sumBin_,sumMin_,sumMax_);
393 
394  //hcal sum
395  book2DHistoVector(iBooker, h_hcalSum_, "1D","hcalSum","Hcal Sum in the Iso Cone;E (GeV)",sumBin_,sumMin_,sumMax_);
396  book2DHistoVector(iBooker, h_hcalSumEBarrel_, "1D","hcalSumEBarrel","Hcal Sum in the IsoCone for Barrel;E (GeV)",sumBin_,sumMin_,sumMax_);
397  book2DHistoVector(iBooker, h_hcalSumEEndcap_, "1D","hcalSumEEndcap","Hcal Sum in the IsoCone for Endcap;E (GeV)",sumBin_,sumMin_,sumMax_);
398  if (standAlone_) {
399  book2DHistoVector(iBooker, h_hcalSumVsEt_, "2D","hcalSumVsEt2D","Hcal Sum in the Iso Cone;E_{T} (GeV);E (GeV)",reducedEtBin_,etMin_, etMax_,reducedSumBin_,sumMin_,sumMax_);
400  }
401  book3DHistoVector(iBooker, p_hcalSumVsEt_, "Profile","hcalSumVsEt","Avg Hcal Sum in the Iso Cone vs E_{T};E_{T} (GeV);E (GeV)",etBin_,etMin_, etMax_,sumBin_,sumMin_,sumMax_);
402  if (standAlone_) {
403  book2DHistoVector(iBooker, h_hcalSumVsEta_, "2D","hcalSumVsEta2D","Hcal Sum in the Iso Cone;#eta;E (GeV)",reducedEtaBin_,etaMin_, etaMax_,reducedSumBin_,sumMin_,sumMax_);
404  }
405  book2DHistoVector(iBooker, p_hcalSumVsEta_, "Profile","hcalSumVsEta","Avg Hcal Sum in the Iso Cone vs #eta;#eta;E (GeV)",etaBin_,etaMin_, etaMax_,sumBin_,sumMin_,sumMax_);
406 
407  //h over e
408  book3DHistoVector(iBooker, h_hOverE_, "1D","hOverE","H/E;H/E",hOverEBin_,hOverEMin_,hOverEMax_);
409  book2DHistoVector(iBooker, p_hOverEVsEt_, "Profile","hOverEVsEt","Avg H/E vs Et;E_{T} (GeV);H/E",etBin_,etMin_,etMax_,hOverEBin_,hOverEMin_,hOverEMax_);
410  book2DHistoVector(iBooker, p_hOverEVsEta_, "Profile","hOverEVsEta","Avg H/E vs #eta;#eta;H/E",etaBin_,etaMin_,etaMax_,hOverEBin_,hOverEMin_,hOverEMax_);
411  book3DHistoVector(iBooker, h_h1OverE_, "1D","h1OverE","H/E for Depth 1;H/E",hOverEBin_,hOverEMin_,hOverEMax_);
412  book3DHistoVector(iBooker, h_h2OverE_, "1D","h2OverE","H/E for Depth 2;H/E",hOverEBin_,hOverEMin_,hOverEMax_);
413 
414  // pf isolation
415  book2DHistoVector(iBooker, h_phoIsoBarrel_, "1D","phoIsoBarrel","PF photon iso Barrel;E (GeV)",reducedEtBin_,etMin_,25.);
416  book2DHistoVector(iBooker, h_phoIsoEndcap_, "1D","phoIsoEndcap","PF photon iso Endcap;E (GeV)",reducedEtBin_,etMin_,25.);
417  book2DHistoVector(iBooker, h_chHadIsoBarrel_, "1D","chHadIsoBarrel","PF charged Had iso Barrel;E (GeV)",reducedEtBin_,etMin_,25.);
418  book2DHistoVector(iBooker, h_chHadIsoEndcap_, "1D","chHadIsoEndcap","PF charged Had iso Endcap;E (GeV)",reducedEtBin_,etMin_,25.);
419  book2DHistoVector(iBooker, h_nHadIsoBarrel_, "1D","neutralHadIsoBarrel","PF neutral Had iso Barrel;E (GeV)",reducedEtBin_,etMin_,25.);
420  book2DHistoVector(iBooker, h_nHadIsoEndcap_, "1D","neutralHadIsoEndcap","PF neutral Had iso Endcap;E (GeV)",reducedEtBin_,etMin_,25.);
421 
422  //OTHER VARIABLES
423  //bad channel histograms
424  book2DHistoVector(iBooker, h_phoEt_BadChannels_ , "1D","phoEtBadChannels", "Fraction Containing Bad Channels: E_{T};E_{T} (GeV)",etBin_,etMin_,etMax_);
425  book2DHistoVector(iBooker, h_phoEta_BadChannels_ , "1D","phoEtaBadChannels","Fraction Containing Bad Channels: #eta;#eta",etaBin_,etaMin_,etaMax_);
426  book2DHistoVector(iBooker, h_phoPhi_BadChannels_ , "1D","phoPhiBadChannels","Fraction Containing Bad Channels: #phi;#phi",phiBin_,phiMin_,phiMax_);
427 }
428 
430 {
431  // Set folder
432  iBooker.setCurrentFolder("Egamma/"+fName_+"/AllPhotons/Et Above 0 GeV/Conversions");
433 
434  //ENERGY VARIABLES
435  book3DHistoVector(iBooker, h_phoConvE_ , "1D", "phoConvE","E;E (GeV)",eBin_,eMin_,eMax_);
436  book3DHistoVector(iBooker, h_phoConvEt_ , "1D", "phoConvEt","E_{T};E_{T} (GeV)",etBin_,etMin_,etMax_);
437 
438  //GEOMETRICAL VARIABLES
439  book2DHistoVector(iBooker, h_phoConvEta_ , "1D", "phoConvEta","#eta;#eta",etaBin_,etaMin_,etaMax_);
440  book3DHistoVector(iBooker, h_phoConvPhi_ , "1D", "phoConvPhi","#phi;#phi",phiBin_,phiMin_,phiMax_);
441 
442  //NUMBER OF PHOTONS
443  book3DHistoVector(iBooker, h_nConv_ , "1D", "nConv","Number Of Conversions per Event ;# conversions",numberBin_,numberMin_,numberMax_);
444 
445  //SHOWER SHAPE VARIABLES
446  book3DHistoVector(iBooker, h_phoConvR9_ , "1D", "phoConvR9","R9;R9",r9Bin_,r9Min_,r9Max_);
447 
448  //TRACK RELATED VARIABLES
449  book3DHistoVector(iBooker, h_eOverPTracks_ , "1D", "eOverPTracks","E/P;E/P",eOverPBin_,eOverPMin_,eOverPMax_);
450  book3DHistoVector(iBooker, h_pOverETracks_ , "1D", "pOverETracks","P/E;P/E",eOverPBin_,eOverPMin_,eOverPMax_);
451  book3DHistoVector(iBooker, h_dPhiTracksAtVtx_ , "1D", "dPhiTracksAtVtx", "#Delta#phi of Tracks at Vertex;#Delta#phi",dPhiTracksBin_,dPhiTracksMin_,dPhiTracksMax_);
452  book3DHistoVector(iBooker, h_dPhiTracksAtEcal_, "1D", "dPhiTracksAtEcal", "Abs(#Delta#phi) of Tracks at Ecal;#Delta#phi",dPhiTracksBin_,0.,dPhiTracksMax_);
453  book3DHistoVector(iBooker, h_dEtaTracksAtEcal_, "1D", "dEtaTracksAtEcal", "#Delta#eta of Tracks at Ecal;#Delta#eta",dEtaTracksBin_,dEtaTracksMin_,dEtaTracksMax_);
454  book3DHistoVector(iBooker, h_dCotTracks_ , "1D", "dCotTracks","#Deltacot(#theta) of Tracks;#Deltacot(#theta)",dEtaTracksBin_,dEtaTracksMin_,dEtaTracksMax_);
455  book2DHistoVector(iBooker, p_dCotTracksVsEta_ , "Profile", "dCotTracksVsEta","Avg #Deltacot(#theta) of Tracks vs #eta;#eta;#Deltacot(#theta)",etaBin_,etaMin_,etaMax_,dEtaTracksBin_,dEtaTracksMin_,dEtaTracksMax_);
456  book2DHistoVector(iBooker, p_nHitsVsEta_ , "Profile", "nHitsVsEta","Avg Number of Hits per Track vs #eta;#eta;# hits",etaBin_,etaMin_,etaMax_,etaBin_,0,16);
457  book2DHistoVector(iBooker, h_tkChi2_ , "1D", "tkChi2","#chi^{2} of Track Fitting;#chi^{2}",chi2Bin_,chi2Min_,chi2Max_);
458  book2DHistoVector(iBooker, p_tkChi2VsEta_ , "Profile", "tkChi2VsEta","Avg #chi^{2} of Track Fitting vs #eta;#eta;#chi^{2}",etaBin_,etaMin_,etaMax_,chi2Bin_,chi2Min_,chi2Max_);
459 
460  //VERTEX RELATED VARIABLES
461  book2DHistoVector(iBooker, h_convVtxRvsZ_ , "2D", "convVtxRvsZ","Vertex Position;Z (cm);R (cm)",500,zMin_,zMax_,rBin_,rMin_,rMax_);
462  book2DHistoVector(iBooker, h_convVtxZEndcap_ , "1D", "convVtxZEndcap", "Vertex Position: #eta > 1.5;Z (cm)",zBin_,zMin_,zMax_);
463  book2DHistoVector(iBooker, h_convVtxZ_ , "1D", "convVtxZ", "Vertex Position;Z (cm)",zBin_,zMin_,zMax_);
464  book2DHistoVector(iBooker, h_convVtxR_ , "1D", "convVtxR", "Vertex Position: #eta < 1;R (cm)",rBin_,rMin_,rMax_);
465  book2DHistoVector(iBooker, h_convVtxYvsX_ , "2D", "convVtxYvsX","Vertex Position: #eta < 1;X (cm);Y (cm)",xBin_,xMin_,xMax_,yBin_,yMin_,yMax_);
466  book2DHistoVector(iBooker, h_vertexChi2Prob_ , "1D", "vertexChi2Prob","#chi^{2} Probability of Vertex Fitting;#chi^{2}",100,0.,1.0);
467 }
468 
469 // Booking helper methods:
470 
472  string histoName, string title,
473  int bin, double min, double max)
474 {
475  int histo_index = 0;
476  stringstream histo_number_stream;
477 
478  //determining which folder we're in
479  if(iBooker.pwd().find( "InvMass" ) != string::npos){
480  histo_index_invMass_++;
481  histo_index = histo_index_invMass_;
482  }
483  if(iBooker.pwd().find( "Efficiencies" ) != string::npos){
484  histo_index_efficiency_++;
485  histo_index = histo_index_efficiency_;
486  }
487 
488  histo_number_stream << "h_";
489  if(histo_index<10) histo_number_stream << "0";
490  histo_number_stream << histo_index;
491 
492  return iBooker.book1D(histo_number_stream.str() + "_" + histoName,title,bin,min,max);
493 }
494 
496  vector<vector<MonitorElement*> > &temp2DVector,
497  string histoType, string histoName, string title,
498  int xbin, double xmin, double xmax,
499  int ybin, double ymin, double ymax)
500 {
501  int histo_index = 0;
502 
503  vector<MonitorElement*> temp1DVector;
504 
505  //determining which folder we're in
506  bool conversionPlot = false;
507  if(iBooker.pwd().find( "Conversions" ) != string::npos) conversionPlot = true;
508  bool TwoDPlot = false;
509  if(histoName.find( "2D" ) != string::npos) TwoDPlot = true;
510 
511  if(conversionPlot){
512  histo_index_conversions_++;
513  histo_index = histo_index_conversions_;
514  }
515  else{
516  histo_index_photons_++;
517  histo_index = histo_index_photons_;
518  }
519 
520  stringstream histo_number_stream;
521  histo_number_stream << "h_";
522  if(histo_index<10) histo_number_stream << "0";
523  histo_number_stream << histo_index << "_";
524 
525  for(int cut = 0; cut != numberOfSteps_; ++cut){ //looping over Et cut values
526  for(uint type=0;type!=types_.size();++type){ //looping over isolation type
527  currentFolder_.str("");
528  currentFolder_ << "Egamma/"+fName_+"/" << types_[type] << "Photons/Et above " << (cut+1)*cutStep_ << " GeV";
529  if(conversionPlot) currentFolder_ << "/Conversions";
530 
531  iBooker.setCurrentFolder(currentFolder_.str());
532 
533  string kind;
534  if(conversionPlot) kind = " Conversions: ";
535  else kind = " Photons: ";
536 
537  if(histoType=="1D") temp1DVector.push_back(iBooker.book1D( histo_number_stream.str()+histoName,types_[type]+kind+title,xbin,xmin,xmax));
538  else if(histoType=="2D"){
539  if((TwoDPlot && type==0) || !TwoDPlot){//only book the 2D plots in the "AllPhotons" folder
540  temp1DVector.push_back(iBooker.book2D( histo_number_stream.str()+histoName,types_[type]+kind+title,xbin,xmin,xmax,ybin,ymin,ymax));
541  }
542  }
543  else if(histoType=="Profile") temp1DVector.push_back(iBooker.bookProfile( histo_number_stream.str()+histoName,types_[type]+kind+title,xbin,xmin,xmax,ybin,ymin,ymax,""));
544  else cout << "bad histoType\n";
545  }
546 
547  temp2DVector.push_back(temp1DVector);
548  temp1DVector.clear();
549  }
550 }
551 
553  vector<vector<vector<MonitorElement*> > > &temp3DVector,
554  string histoType, string histoName, string title,
555  int xbin, double xmin,double xmax,
556  int ybin, double ymin, double ymax)
557 {
558  int histo_index = 0;
559 
560  vector<MonitorElement*> temp1DVector;
561  vector<vector<MonitorElement*> > temp2DVector;
562 
563  //determining which folder we're in
564  bool conversionPlot = false;
565  if(iBooker.pwd().find( "Conversions" ) != string::npos) conversionPlot = true;
566 
567  if(conversionPlot){
568  histo_index_conversions_++;
569  histo_index = histo_index_conversions_;
570  }
571  else{
572  histo_index_photons_++;
573  histo_index = histo_index_photons_;
574  }
575 
576  stringstream histo_number_stream;
577  histo_number_stream << "h_";
578  if(histo_index<10) histo_number_stream << "0";
579  histo_number_stream << histo_index << "_";
580 
581  for(int cut = 0; cut != numberOfSteps_; ++cut){ //looping over Et cut values
582  for(uint type=0;type!=types_.size();++type){ //looping over isolation type
583  for(uint part=0;part!=parts_.size();++part){ //looping over different parts of the ecal
584  currentFolder_.str("");
585  currentFolder_ << "Egamma/"+fName_+"/" << types_[type] << "Photons/Et above " << (cut+1)*cutStep_ << " GeV";
586  if(conversionPlot) currentFolder_ << "/Conversions";
587  iBooker.setCurrentFolder(currentFolder_.str());
588 
589  string kind;
590  if(conversionPlot) kind = " Conversions: ";
591  else kind = " Photons: ";
592 
593  if(histoType=="1D") temp1DVector.push_back(iBooker.book1D( histo_number_stream.str()+histoName+parts_[part],types_[type]+kind+parts_[part]+": "+title,xbin,xmin,xmax));
594  else if(histoType=="2D") temp1DVector.push_back(iBooker.book2D( histo_number_stream.str()+histoName+parts_[part],types_[type]+kind+parts_[part]+": "+title,xbin,xmin,xmax,ybin,ymin,ymax));
595  else if(histoType=="Profile") temp1DVector.push_back(iBooker.bookProfile( histo_number_stream.str()+histoName+parts_[part],types_[type]+kind+parts_[part]+": "+title,xbin,xmin,xmax,ybin,ymin,ymax,""));
596  else cout << "bad histoType\n";
597  }
598  temp2DVector.push_back(temp1DVector);
599  temp1DVector.clear();
600  }
601  temp3DVector.push_back(temp2DVector);
602  temp2DVector.clear();
603  }
604 }
605 
606 // Analysis:
607 
609 {
610  using namespace edm;
611 
612  if (nEvt_% prescaleFactor_ ) return;
613  nEvt_++;
614  LogInfo(fName_) << "PhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
615 
616  // Get the trigger results
617  bool validTriggerEvent=true;
618  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
619  const trigger::TriggerEvent dummyTE;
620  e.getByToken(triggerEvent_token_,triggerEventHandle);
621  if(!triggerEventHandle.isValid()) {
622  edm::LogInfo(fName_) << "Error! Can't get the product: triggerEvent_" << endl;
623  validTriggerEvent=false;
624  }
625  const trigger::TriggerEvent& triggerEvent(validTriggerEvent? *(triggerEventHandle.product()) : dummyTE);
626 
627  // Get the reconstructed photons
628  // bool validPhotons=true;
629  Handle<reco::PhotonCollection> photonHandle;
630  e.getByToken(photon_token_ , photonHandle);
631  if ( !photonHandle.isValid()) {
632  edm::LogInfo(fName_) << "Error! Can't get the product: photon_token_" << endl;
633  // validPhotons=false;
634  }
635  const reco::PhotonCollection& photonCollection(*(photonHandle.product()));
636 
637 
638  // Get the PhotonId objects
639  // bool validloosePhotonID=true;
640  Handle<edm::ValueMap<bool> > loosePhotonFlag;
641  e.getByToken(PhotonIDLoose_token_, loosePhotonFlag);
642  if ( !loosePhotonFlag.isValid()) {
643  edm::LogInfo(fName_) << "Error! Can't get the product: PhotonIDLoose_token_" << endl;
644  // validloosePhotonID=false;
645  }
646  // edm::ValueMap<bool> dummyLPID;
647  // const edm::ValueMap<bool>& loosePhotonID(validloosePhotonID? *(loosePhotonFlag.product()) : dummyLPID);
648 
649  // bool validtightPhotonID=true;
650  Handle<edm::ValueMap<bool> > tightPhotonFlag;
651  e.getByToken(PhotonIDTight_token_, tightPhotonFlag);
652  if ( !tightPhotonFlag.isValid()) {
653  edm::LogInfo(fName_) << "Error! Can't get the product: PhotonIDTight_token_" << endl;
654  // validtightPhotonID=false;
655  }
656  // edm::ValueMap<bool> dummyTPI;
657  // const edm::ValueMap<bool>& tightPhotonID(validtightPhotonID ? *(tightPhotonFlag.product()) : dummyTPI);
658 
659 
661  if ( !isHeavyIon_) {
662  e.getByToken(offline_pvToken_, vtxH);
663  h_nRecoVtx_ ->Fill (float(vtxH->size()));
664  }
665 
666  // Create array to hold #photons/event information
667  int nPho[100][3][3];
668 
669  for (int cut=0; cut!=100; ++cut){
670  for (unsigned int type=0; type!=types_.size(); ++type){
671  for (unsigned int part=0; part!=parts_.size(); ++part){
672  nPho[cut][type][part] = 0;
673  }
674  }
675  }
676  // Create array to hold #conversions/event information
677  int nConv[100][3][3];
678 
679  for (int cut=0; cut!=100; ++cut){
680  for (unsigned int type=0; type!=types_.size(); ++type){
681  for (unsigned int part=0; part!=parts_.size(); ++part){
682  nConv[cut][type][part] = 0;
683  }
684  }
685  }
686 
687  //Prepare list of photon-related HLT filter names
688  vector<int> Keys;
689 
690  for(uint filterIndex=0;filterIndex<triggerEvent.sizeFilters();++filterIndex){ //loop over all trigger filters in event (i.e. filters passed)
691  string label = triggerEvent.filterTag(filterIndex).label();
692  if(label.find( "Photon" ) != string::npos ) { //get photon-related filters
693  for(uint filterKeyIndex=0;filterKeyIndex<triggerEvent.filterKeys(filterIndex).size();++filterKeyIndex){ //loop over keys to objects passing this filter
694  Keys.push_back(triggerEvent.filterKeys(filterIndex)[filterKeyIndex]); //add keys to a vector for later reference
695  }
696  }
697  }
698 
699  // sort Keys vector in ascending order
700  // and erases duplicate entries from the vector
701  sort(Keys.begin(),Keys.end());
702  for ( uint i=0 ; i<Keys.size() ; )
703  {
704  if (i!=(Keys.size()-1))
705  {
706  if (Keys[i]==Keys[i+1]) Keys.erase(Keys.begin()+i+1) ;
707  else ++i ;
708  }
709  else ++i ;
710  }
711 
712  //We now have a vector of unique keys to TriggerObjects passing a photon-related filter
713 
714  // old int photonCounter = 0;
715 
717  for(unsigned int iPho=0; iPho < photonHandle->size(); iPho++) {
718  const reco::Photon* aPho = &photonCollection[iPho];
719  // for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
720 
721  //for HLT efficiency plots
722 
723  h_phoEta_preHLT_->Fill(aPho->eta());
724  h_phoEt_preHLT_->Fill( aPho->et());
725 
726  double deltaR=1000.;
727  double deltaRMin=1000.;
728  double deltaRMax=0.05;//sets deltaR threshold for matching photons to trigger objects
729 
730  for (vector<int>::const_iterator objectKey=Keys.begin();objectKey!=Keys.end();objectKey++){ //loop over keys to objects that fired photon triggers
731 
732  deltaR = reco::deltaR(triggerEvent.getObjects()[(*objectKey)].eta(),triggerEvent.getObjects()[(*objectKey)].phi(),aPho->superCluster()->eta(),aPho->superCluster()->phi());
733  if(deltaR < deltaRMin) deltaRMin = deltaR;
734 
735  }
736 
737  if(deltaRMin > deltaRMax) { //photon fails delta R cut
738  if(useTriggerFiltering_) continue; //throw away photons that haven't passed any photon filters
739  }
740 
741  if(deltaRMin <= deltaRMax) { //photon passes delta R cut
742  h_phoEta_postHLT_->Fill(aPho->eta() );
743  h_phoEt_postHLT_->Fill( aPho->et() );
744  }
745 
746  // if (aPho->et() < minPhoEtCut_) continue;
747  bool isLoosePhoton(false), isTightPhoton(false);
748  if ( photonSelection (aPho) ) isLoosePhoton=true ;
749 
750  //find out which part of the Ecal contains the photon
751  bool phoIsInBarrel=false;
752  bool phoIsInEndcap=false;
753  float etaPho = aPho->superCluster()->eta();
754  if ( fabs(etaPho) < 1.479 )
755  phoIsInBarrel=true;
756  else {
757  phoIsInEndcap=true;
758  }
759 
760  int part = 0;
761  if ( phoIsInBarrel ) part = 1;
762  if ( phoIsInEndcap ) part = 2;
763 
765  bool isIsolated=false;
766  if ( isolationStrength_ == 0) isIsolated = isLoosePhoton;
767  if ( isolationStrength_ == 1) isIsolated = isTightPhoton;
768  if ( isolationStrength_ == 2) isIsolated = photonSelectionSlimmed(aPho);
769 
770  int type=0;
771  if ( isIsolated ) type=1;
772  if ( !excludeBkgHistos_ && !isIsolated ) type=2;
773 
774  //get rechit collection containing this photon
775  bool validEcalRecHits=true;
776  edm::Handle<EcalRecHitCollection> ecalRecHitHandle;
777  EcalRecHitCollection ecalRecHitCollection;
778  if ( phoIsInBarrel ) {
779  // Get handle to barrel rec hits
780  e.getByToken(barrelRecHit_token_, ecalRecHitHandle);
781  if (!ecalRecHitHandle.isValid()) {
782  edm::LogError(fName_) << "Error! Can't get the product: barrelRecHit_token_";
783  validEcalRecHits=false;
784  }
785  }
786  else if ( phoIsInEndcap ) {
787  // Get handle to endcap rec hits
788  e.getByToken(endcapRecHit_token_, ecalRecHitHandle);
789  if (!ecalRecHitHandle.isValid()) {
790  edm::LogError(fName_) << "Error! Can't get the product: endcapRecHit_token";
791  validEcalRecHits=false;
792  }
793  }
794  if (validEcalRecHits) ecalRecHitCollection = *(ecalRecHitHandle.product());
795 
796  //if (aPho->isEBEEGap()) continue; //cut out gap photons
797 
798  //filling histograms to make isolation efficiencies
799  if(isLoosePhoton){
800  h_phoEta_Loose_->Fill(aPho->eta());
801  h_phoEt_Loose_->Fill( aPho->et() );
802  }
803  if(isTightPhoton){
804  h_phoEta_Tight_->Fill(aPho->eta());
805  h_phoEt_Tight_->Fill( aPho->et() );
806  }
807 
808  for (int cut = 0; cut !=numberOfSteps_; ++cut) { //loop over different transverse energy cuts
809  double Et = aPho->et();
810  bool passesCuts = false;
811 
812  //sorting the photon into the right Et-dependant folder
813  if ( useBinning_ && Et > (cut+1)*cutStep_ && ( (Et < (cut+2)*cutStep_) | (cut == numberOfSteps_-1) ) ){
814  passesCuts = true;
815  }
816  else if ( !useBinning_ && Et > (cut+1)*cutStep_ ){
817  passesCuts = true;
818  }
819 
820  if (passesCuts){
821  //filling isolation variable histograms
822 
823  //tracker isolation variables
824  fill2DHistoVector(h_nTrackIsolSolid_, aPho->nTrkSolidConeDR04(), cut,type);
825  fill2DHistoVector(h_nTrackIsolHollow_,aPho->nTrkHollowConeDR04(),cut,type);
826 
827  if (standAlone_) fill2DHistoVector(h_nTrackIsolSolidVsEta_, aPho->eta(),aPho->nTrkSolidConeDR04(), cut,type);
828  fill2DHistoVector(p_nTrackIsolSolidVsEta_, aPho->eta(),aPho->nTrkSolidConeDR04(), cut,type);
829  if (standAlone_) fill2DHistoVector(h_nTrackIsolHollowVsEta_,aPho->eta(),aPho->nTrkHollowConeDR04(),cut,type);
830  fill2DHistoVector(p_nTrackIsolHollowVsEta_,aPho->eta(),aPho->nTrkHollowConeDR04(),cut,type);
831 
832  if (standAlone_) fill2DHistoVector(h_nTrackIsolSolidVsEt_, aPho->et(), aPho->nTrkSolidConeDR04(), cut,type);
833  fill2DHistoVector(p_nTrackIsolSolidVsEt_, aPho->et(), aPho->nTrkSolidConeDR04(), cut,type);
834  if (standAlone_) fill2DHistoVector(h_nTrackIsolHollowVsEt_, aPho->et(), aPho->nTrkHollowConeDR04(),cut,type);
835  fill2DHistoVector(p_nTrackIsolHollowVsEt_, aPho->et(), aPho->nTrkHollowConeDR04(),cut,type);
836 
838  fill2DHistoVector(h_trackPtSumSolid_, aPho->trkSumPtSolidConeDR04(),cut,type);
839  fill2DHistoVector(h_trackPtSumHollow_,aPho->trkSumPtSolidConeDR04(),cut,type);
840 
841  if (standAlone_) fill2DHistoVector(h_trackPtSumSolidVsEta_, aPho->eta(),aPho->trkSumPtSolidConeDR04(), cut,type);
842  fill2DHistoVector(p_trackPtSumSolidVsEta_, aPho->eta(),aPho->trkSumPtSolidConeDR04(), cut,type);
843  if (standAlone_) fill2DHistoVector(h_trackPtSumHollowVsEta_,aPho->eta(),aPho->trkSumPtHollowConeDR04(),cut,type);
844  fill2DHistoVector(p_trackPtSumHollowVsEta_,aPho->eta(),aPho->trkSumPtHollowConeDR04(),cut,type);
845 
846  if (standAlone_) fill2DHistoVector(h_trackPtSumSolidVsEt_, aPho->et(), aPho->trkSumPtSolidConeDR04(), cut,type);
847  fill2DHistoVector(p_trackPtSumSolidVsEt_, aPho->et(), aPho->trkSumPtSolidConeDR04(), cut,type);
848  if (standAlone_) fill2DHistoVector(h_trackPtSumHollowVsEt_, aPho->et(), aPho->trkSumPtHollowConeDR04(),cut,type);
849  fill2DHistoVector(p_trackPtSumHollowVsEt_, aPho->et(), aPho->trkSumPtHollowConeDR04(),cut,type);
850  //calorimeter isolation variables
851 
852  fill2DHistoVector(h_ecalSum_,aPho->ecalRecHitSumEtConeDR04(),cut,type);
853  if(aPho->isEB()){fill2DHistoVector(h_ecalSumEBarrel_,aPho->ecalRecHitSumEtConeDR04(),cut,type);}
854  if(aPho->isEE()){fill2DHistoVector(h_ecalSumEEndcap_,aPho->ecalRecHitSumEtConeDR04(),cut,type);}
855  if (standAlone_) fill2DHistoVector(h_ecalSumVsEta_,aPho->eta(),aPho->ecalRecHitSumEtConeDR04(),cut,type);
856  fill2DHistoVector(p_ecalSumVsEta_,aPho->eta(),aPho->ecalRecHitSumEtConeDR04(),cut,type);
857  if (standAlone_) fill2DHistoVector(h_ecalSumVsEt_, aPho->et(), aPho->ecalRecHitSumEtConeDR04(),cut,type);
858  fill3DHistoVector(p_ecalSumVsEt_, aPho->et(), aPho->ecalRecHitSumEtConeDR04(),cut,type,part);
859 
861 
862  fill2DHistoVector(h_hcalSum_,aPho->hcalTowerSumEtConeDR04(),cut,type);
863  if(aPho->isEB()){fill2DHistoVector(h_hcalSumEBarrel_,aPho->hcalTowerSumEtConeDR04(),cut,type);}
864  if(aPho->isEE()){fill2DHistoVector(h_hcalSumEEndcap_,aPho->hcalTowerSumEtConeDR04(),cut,type);}
865  if (standAlone_) fill2DHistoVector(h_hcalSumVsEta_,aPho->eta(),aPho->hcalTowerSumEtConeDR04(),cut,type);
866  fill2DHistoVector(p_hcalSumVsEta_,aPho->eta(),aPho->hcalTowerSumEtConeDR04(),cut,type);
867  if (standAlone_) fill2DHistoVector(h_hcalSumVsEt_, aPho->et(), aPho->hcalTowerSumEtConeDR04(),cut,type);
868  fill3DHistoVector(p_hcalSumVsEt_, aPho->et(), aPho->hcalTowerSumEtConeDR04(),cut,type,part);
869 
870  fill3DHistoVector(h_hOverE_,aPho->hadronicOverEm(),cut,type,part);
871  fill2DHistoVector(p_hOverEVsEta_,aPho->eta(),aPho->hadronicOverEm(),cut,type);
872  fill2DHistoVector(p_hOverEVsEt_, aPho->et(), aPho->hadronicOverEm(),cut,type);
873 
874  fill3DHistoVector(h_h1OverE_,aPho->hadronicDepth1OverEm(),cut,type,part);
875  fill3DHistoVector(h_h2OverE_,aPho->hadronicDepth2OverEm(),cut,type,part);
876 
877  // filling pf isolation variables
878  if(aPho->isEB()) {
879  fill2DHistoVector( h_phoIsoBarrel_, aPho->photonIso(),cut,type);
880  fill2DHistoVector( h_chHadIsoBarrel_, aPho->chargedHadronIso(),cut,type);
881  fill2DHistoVector( h_nHadIsoBarrel_, aPho->neutralHadronIso(),cut,type);
882  }
883  if(aPho->isEE()) {
884  fill2DHistoVector( h_phoIsoEndcap_, aPho->photonIso(),cut,type);
885  fill2DHistoVector( h_chHadIsoEndcap_, aPho->chargedHadronIso(),cut,type);
886  fill2DHistoVector( h_nHadIsoEndcap_, aPho->neutralHadronIso(),cut,type);
887  }
888 
889  //filling photon histograms
890  nPho[cut][0][0]++;
891  nPho[cut][0][part]++;
892  if(type != 0)
893  {
894  nPho[cut][type][0]++;
895  nPho[cut][type][part]++;
896  }
897 
898  //energy variables
899 
900  fill3DHistoVector(h_phoE_, aPho->energy(),cut,type,part);
901  fill3DHistoVector(h_phoSigmaEoverE_, aPho->getCorrectedEnergyError(aPho->getCandidateP4type())/aPho->energy(),cut,type,part);
902 
903  if ( !isHeavyIon_) fill3DHistoVector(p_phoSigmaEoverEvsNVtx_, float(vtxH->size()), aPho->getCorrectedEnergyError(aPho->getCandidateP4type())/aPho->energy(),cut,type,part);
904 
905  fill3DHistoVector(h_phoEt_,aPho->et(), cut,type,part);
906 
907  //geometrical variables
908 
909  fill2DHistoVector(h_phoEta_,aPho->eta(),cut,type);
910  fill2DHistoVector(h_scEta_, aPho->superCluster()->eta(),cut,type);
911 
912  fill3DHistoVector(h_phoPhi_,aPho->phi(),cut,type,part);
913  fill3DHistoVector(h_scPhi_, aPho->superCluster()->phi(),cut,type,part);
914 
915  //shower shape variables
916 
917  fill3DHistoVector(h_r9_,aPho->r9(),cut,type,part);
918  if (standAlone_) fill2DHistoVector(h_r9VsEta_,aPho->eta(),aPho->r9(),cut,type);
919  fill2DHistoVector(p_r9VsEta_,aPho->eta(),aPho->r9(),cut,type);
920  if (standAlone_) fill2DHistoVector(h_r9VsEt_, aPho->et(), aPho->r9(),cut,type);
921  fill2DHistoVector(p_r9VsEt_, aPho->et(), aPho->r9(),cut,type);
922 
923  if (standAlone_) fill2DHistoVector(h_e1x5VsEta_,aPho->eta(),aPho->e1x5(),cut,type);
924  fill2DHistoVector(p_e1x5VsEta_,aPho->eta(),aPho->e1x5(),cut,type);
925  if (standAlone_) fill2DHistoVector(h_e1x5VsEt_, aPho->et(), aPho->e1x5(),cut,type);
926  fill2DHistoVector(p_e1x5VsEt_, aPho->et(), aPho->e1x5(),cut,type);
927 
928  if (standAlone_) fill2DHistoVector(h_e2x5VsEta_,aPho->eta(),aPho->e2x5(),cut,type);
929  fill2DHistoVector(p_e2x5VsEta_,aPho->eta(),aPho->e2x5(),cut,type);
930  if (standAlone_) fill2DHistoVector(h_e2x5VsEt_, aPho->et(), aPho->e2x5(),cut,type);
931  fill2DHistoVector(p_e2x5VsEt_, aPho->et(), aPho->e2x5(),cut,type);
932 
933  if (standAlone_) fill2DHistoVector(h_maxEXtalOver3x3VsEta_,aPho->eta(),aPho->maxEnergyXtal()/aPho->e3x3(),cut,type);
934  fill2DHistoVector(p_maxEXtalOver3x3VsEta_,aPho->eta(),aPho->maxEnergyXtal()/aPho->e3x3(),cut,type);
935  if (standAlone_) fill2DHistoVector(h_maxEXtalOver3x3VsEt_, aPho->et(), aPho->maxEnergyXtal()/aPho->e3x3(),cut,type);
936  fill2DHistoVector(p_maxEXtalOver3x3VsEt_, aPho->et(), aPho->maxEnergyXtal()/aPho->e3x3(),cut,type);
937 
938  if (standAlone_) fill2DHistoVector(h_r1x5VsEta_,aPho->eta(),aPho->r1x5(),cut,type);
939  fill2DHistoVector(p_r1x5VsEta_,aPho->eta(),aPho->r1x5(),cut,type);
940  if (standAlone_) fill2DHistoVector(h_r1x5VsEt_, aPho->et(), aPho->r1x5(),cut,type);
941  fill2DHistoVector(p_r1x5VsEt_, aPho->et(), aPho->r1x5(),cut,type);
942 
943  if (standAlone_) fill2DHistoVector(h_r2x5VsEta_,aPho->eta(),aPho->r2x5(),cut,type);
944  fill2DHistoVector(p_r2x5VsEta_,aPho->eta(),aPho->r2x5(),cut,type);
945  if (standAlone_) fill2DHistoVector(h_r2x5VsEt_, aPho->et(), aPho->r2x5(),cut,type);
946  fill2DHistoVector(p_r2x5VsEt_, aPho->et(), aPho->r2x5(),cut,type);
947 
948  fill3DHistoVector(h_phoSigmaIetaIeta_,aPho->sigmaIetaIeta(),cut,type,part);
949  if (standAlone_) fill2DHistoVector(h_sigmaIetaIetaVsEta_,aPho->eta(),aPho->sigmaIetaIeta(),cut,type);
950  fill2DHistoVector(p_sigmaIetaIetaVsEta_,aPho->eta(),aPho->sigmaIetaIeta(),cut,type);
951 
952  //filling histograms for photons containing a bad ECAL channel
953  bool atLeastOneDeadChannel=false;
954  for(reco::CaloCluster_iterator bcIt = aPho->superCluster()->clustersBegin();bcIt != aPho->superCluster()->clustersEnd(); ++bcIt) { //loop over basic clusters in SC
955  for(vector< pair<DetId, float> >::const_iterator rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) { //loop over rec hits in basic cluster
956 
957  for(EcalRecHitCollection::const_iterator it = ecalRecHitCollection.begin(); it != ecalRecHitCollection.end(); ++it) { //loop over all rec hits to find the right ones
958  if (rhIt->first == (*it).id() ) { //found the matching rechit
959  if ( (*it).recoFlag() == 9 ) { //has a bad channel
960  atLeastOneDeadChannel=true;
961  break;
962  }
963  }
964  }
965  }
966  }
967  if ( atLeastOneDeadChannel ) {
968  fill2DHistoVector(h_phoPhi_BadChannels_,aPho->phi(),cut,type);
969  fill2DHistoVector(h_phoEta_BadChannels_,aPho->eta(),cut,type);
970  fill2DHistoVector(h_phoEt_BadChannels_, aPho->et(), cut,type);
971  }
972 
973  // filling conversion-related histograms
974  if(aPho->hasConversionTracks()){
975  nConv[cut][0][0]++;
976  nConv[cut][0][part]++;
977  nConv[cut][type][0]++;
978  nConv[cut][type][part]++;
979  }
980 
981  //loop over conversions (don't forget, we're still inside the photon loop,
982  // i.e. these are all the conversions for this ONE photon, not for all the photons in the event)
984  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
985 
986  reco::ConversionRef aConv=conversions[iConv];
987 
988  if ( aConv->nTracks() <2 ) continue;
989 
990  //fill histogram for denominator of vertex reconstruction efficiency plot
991  if(cut==0) h_phoEta_Vertex_->Fill(aConv->refittedPairMomentum().eta());
992 
993  if ( !(aConv->conversionVertex().isValid()) ) continue;
994 
995  float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(), aConv->conversionVertex().ndof() );
996 
997  if(chi2Prob<0.0005) continue;
998 
999  fill2DHistoVector(h_vertexChi2Prob_,chi2Prob,cut,type);
1000 
1001  fill3DHistoVector(h_phoConvE_, aPho->energy(),cut,type,part);
1002  fill3DHistoVector(h_phoConvEt_,aPho->et(),cut,type,part);
1003  fill3DHistoVector(h_phoConvR9_,aPho->r9(),cut,type,part);
1004 
1005  if (cut==0 && isLoosePhoton){
1006  h_convEta_Loose_->Fill(aPho->eta());
1007  h_convEt_Loose_->Fill( aPho->et() );
1008  }
1009  if (cut==0 && isTightPhoton){
1010  h_convEta_Tight_->Fill(aPho->eta());
1011  h_convEt_Tight_->Fill( aPho->et() );
1012  }
1013 
1014  fill2DHistoVector(h_phoConvEta_,aConv->refittedPairMomentum().eta(),cut,type);
1015  fill3DHistoVector(h_phoConvPhi_,aConv->refittedPairMomentum().phi(),cut,type,part);
1016 
1017  //we use the photon position because we'll be dividing it by a photon histogram (not a conversion histogram)
1018  fill2DHistoVector(h_phoConvEtaForEfficiency_,aPho->eta(),cut,type);
1019  fill3DHistoVector(h_phoConvPhiForEfficiency_,aPho->phi(),cut,type,part);
1020 
1021  //vertex histograms
1022  double convR= sqrt(aConv->conversionVertex().position().perp2());
1023  double scalar = aConv->conversionVertex().position().x()*aConv->refittedPairMomentum().x() + aConv->conversionVertex().position().y()*aConv->refittedPairMomentum().y();
1024  if ( scalar < 0 ) convR= -convR;
1025 
1026  fill2DHistoVector(h_convVtxRvsZ_,aConv->conversionVertex().position().z(), convR,cut,type);//trying to "see" R-Z view of tracker
1027  fill2DHistoVector(h_convVtxZ_,aConv->conversionVertex().position().z(), cut,type);
1028 
1029 
1030  if( fabs(aPho->eta()) > 1.5){//trying to "see" tracker endcaps
1031  fill2DHistoVector(h_convVtxZEndcap_,aConv->conversionVertex().position().z(), cut,type);
1032  }
1033  else if(fabs(aPho->eta()) < 1){//trying to "see" tracker barrel
1034  fill2DHistoVector(h_convVtxR_,convR,cut,type);
1035  fill2DHistoVector(h_convVtxYvsX_,aConv->conversionVertex().position().x(),aConv->conversionVertex().position().y(),cut,type);
1036  }
1037 
1038 
1039  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
1040 
1041 
1042  for (unsigned int i=0; i<tracks.size(); i++) {
1043  fill2DHistoVector(h_tkChi2_,tracks[i]->normalizedChi2(),cut,type);
1044  fill2DHistoVector(p_tkChi2VsEta_,aPho->eta(),tracks[i]->normalizedChi2(),cut,type);
1045  fill2DHistoVector(p_dCotTracksVsEta_,aPho->eta(),aConv->pairCotThetaSeparation(),cut,type);
1046  fill2DHistoVector(p_nHitsVsEta_,aPho->eta(),float(tracks[i]->numberOfValidHits()),cut,type);
1047  }
1048 
1049  //calculating delta eta and delta phi of the two tracks
1050 
1051  float DPhiTracksAtVtx = -99;
1052  float dPhiTracksAtEcal= -99;
1053  float dEtaTracksAtEcal= -99;
1054 
1055  float phiTk1= aConv->tracksPin()[0].phi();
1056  float phiTk2= aConv->tracksPin()[1].phi();
1057  DPhiTracksAtVtx = phiTk1-phiTk2;
1058  DPhiTracksAtVtx = phiNormalization( DPhiTracksAtVtx );
1059 
1060  if (!aConv->bcMatchingWithTracks().empty() && aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
1061  float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
1062  float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
1063  float recoEta1 = aConv->ecalImpactPosition()[0].eta();
1064  float recoEta2 = aConv->ecalImpactPosition()[1].eta();
1065 
1066  recoPhi1 = phiNormalization(recoPhi1);
1067  recoPhi2 = phiNormalization(recoPhi2);
1068 
1069  dPhiTracksAtEcal = recoPhi1 -recoPhi2;
1070  dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
1071  dEtaTracksAtEcal = recoEta1 -recoEta2;
1072  }
1073 
1074  fill3DHistoVector(h_dPhiTracksAtVtx_,DPhiTracksAtVtx,cut,type,part);
1075  fill3DHistoVector(h_dPhiTracksAtEcal_,fabs(dPhiTracksAtEcal),cut,type,part);
1076  fill3DHistoVector(h_dEtaTracksAtEcal_, dEtaTracksAtEcal,cut,type,part);
1077  fill3DHistoVector(h_eOverPTracks_,aConv->EoverPrefittedTracks(),cut,type,part);
1078  fill3DHistoVector(h_pOverETracks_,1./aConv->EoverPrefittedTracks(),cut,type,part);
1079  fill3DHistoVector(h_dCotTracks_,aConv->pairCotThetaSeparation(),cut,type,part);
1080  }//end loop over conversions
1081  }//end loop over photons passing cuts
1082  }//end loop over transverse energy cuts
1083 
1084  //make invariant mass plots
1085 
1086  if (isIsolated && aPho->et()>=invMassEtCut_){
1087  for(unsigned int iPho2=iPho+1; iPho2 < photonHandle->size(); iPho2++) {
1088  const reco::Photon* aPho2 = &photonCollection[iPho2];
1089 
1090  // for (reco::PhotonCollection::const_iterator iPho2=iPho+1; iPho2!=photonCollection.end(); iPho2++){
1091 
1092  // edm::Ref<reco::PhotonCollection> photonref2(photonHandle, photonCounter); //note: it's correct to use photonCounter and not photonCounter+1
1093  //since it has already been incremented earlier
1094 
1095  bool isTightPhoton2(false), isLoosePhoton2(false);
1096  if ( photonSelection (aPho2) ) isLoosePhoton2=true;
1097 
1098  // Old if ( !isHeavyIon_ ) {
1099  // isTightPhoton2 = (tightPhotonID)[aPho2];
1100  // isLoosePhoton2 = (loosePhotonID)[aPho2];
1101  // }
1102 
1103  bool isIsolated2=false;
1104  if ( isolationStrength_ == 0) isIsolated2 = isLoosePhoton2;
1105  if ( isolationStrength_ == 1) isIsolated2 = isTightPhoton2;
1106  if ( isolationStrength_ == 2) isIsolated2 = photonSelectionSlimmed(aPho2);
1107 
1109  reco::ConversionRefVector conversions2 = aPho2->conversions();
1110 
1111  if(isIsolated2 && aPho2->et()>=invMassEtCut_){
1112 
1113  math::XYZTLorentzVector p12 = aPho->p4()+aPho2->p4();
1114  float gamgamMass2 = p12.Dot(p12);
1115 
1116 
1117  h_invMassAllPhotons_ -> Fill(sqrt( gamgamMass2 ));
1118  if(aPho->isEB() && aPho2->isEB()){h_invMassPhotonsEBarrel_ -> Fill(sqrt( gamgamMass2 ));}
1119  else if(aPho->isEE() && aPho2->isEE()){h_invMassPhotonsEEndcap_ -> Fill(sqrt( gamgamMass2 ));}
1120  else {h_invMassPhotonsEEndcapEBarrel_ -> Fill(sqrt( gamgamMass2 ));}
1121 
1122  if(!conversions.empty() && conversions[0]->nTracks() >= 2){
1123  if(!conversions2.empty() && conversions2[0]->nTracks() >= 2) h_invMassTwoWithTracks_ -> Fill(sqrt( gamgamMass2 ));
1124  else h_invMassOneWithTracks_ -> Fill(sqrt( gamgamMass2 ));
1125  }
1126  else if(!conversions2.empty() && conversions2[0]->nTracks() >= 2) h_invMassOneWithTracks_ -> Fill(sqrt( gamgamMass2 ));
1127  else h_invMassZeroWithTracks_ -> Fill(sqrt( gamgamMass2 ));
1128  }
1129  }
1130  }
1131  }
1132 
1133  //filling number of photons/conversions per event histograms
1134  for (int cut = 0; cut !=numberOfSteps_; ++cut) {
1135  for(uint type=0;type!=types_.size();++type){
1136  for(uint part=0;part!=parts_.size();++part){
1137  h_nPho_[cut][type][part]-> Fill (float(nPho[cut][type][part]));
1138  h_nConv_[cut][type][part]-> Fill (float(nConv[cut][type][part]));
1139  }
1140  }
1141  }
1142 }//End of Analyze method
1143 
1145 
1147 {
1148  const float PI = 3.1415927;
1149  const float TWOPI = 2.0*PI;
1150 
1151  if(phi > PI) {phi = phi - TWOPI;}
1152  if(phi < -PI) {phi = phi + TWOPI;}
1153 
1154  return phi;
1155 }
1156 
1157 void PhotonAnalyzer::fill2DHistoVector(vector<vector<MonitorElement*> >& histoVector,double x, double y, int cut, int type)
1158 {
1159  histoVector[cut][0]->Fill(x,y);
1160  if(histoVector[cut].size()>1) histoVector[cut][type]->Fill(x,y); //don't try to fill 2D histos that are only in the "AllPhotons" folder
1161 }
1162 
1163 void PhotonAnalyzer::fill2DHistoVector(vector<vector<MonitorElement*> >& histoVector, double x, int cut, int type)
1164 {
1165  histoVector[cut][0]->Fill(x);
1166  histoVector[cut][type]->Fill(x);
1167 }
1168 
1169 void PhotonAnalyzer::fill3DHistoVector(vector<vector<vector<MonitorElement*> > >& histoVector,double x, int cut, int type, int part)
1170 {
1171  histoVector[cut][0][0]->Fill(x);
1172  histoVector[cut][0][part]->Fill(x);
1173  histoVector[cut][type][0]->Fill(x);
1174  histoVector[cut][type][part]->Fill(x);
1175 }
1176 
1177 void PhotonAnalyzer::fill3DHistoVector(vector<vector<vector<MonitorElement*> > >& histoVector,double x, double y, int cut, int type, int part)
1178 {
1179  histoVector[cut][0][0]->Fill(x,y);
1180  histoVector[cut][0][part]->Fill(x,y);
1181  histoVector[cut][type][0]->Fill(x,y);
1182  histoVector[cut][type][part]->Fill(x,y);
1183 }
1184 
1186 {
1187  bool result=true;
1188  if ( pho->pt() < minPhoEtCut_ ) result=false;
1189  if ( fabs(pho->eta()) > photonMaxEta_ ) result=false;
1190  if ( pho->isEBEEGap() ) result=false;
1191 
1192  double EtCorrHcalIso = pho->hcalTowerSumEtConeDR03() - 0.005*pho->pt();
1193  double EtCorrTrkIso = pho->trkSumPtHollowConeDR03() - 0.002*pho->pt();
1194 
1195  if (pho->r9() <=0.9) {
1196  if (pho->isEB() && (pho->hadTowOverEm()>0.075 || pho->sigmaIetaIeta() > 0.014)) result=false;
1197  if (pho->isEE() && (pho->hadTowOverEm()>0.075 || pho->sigmaIetaIeta() > 0.034)) result=false;
1199  if (EtCorrHcalIso>4.0) result=false;
1200  if (EtCorrTrkIso>4.0) result=false ;
1201  if ( pho->chargedHadronIso() > 4 ) result=false;
1202  } else {
1203  if (pho->isEB() && (pho->hadTowOverEm()>0.082 || pho->sigmaIetaIeta() > 0.014)) result=false;
1204  if (pho->isEE() && (pho->hadTowOverEm()>0.075 || pho->sigmaIetaIeta() > 0.034)) result=false;
1206  if (EtCorrHcalIso>50.0) result=false;
1207  if (EtCorrTrkIso>50.0) result=false;
1208  if ( pho->chargedHadronIso() > 4 ) result=false;
1209  }
1210  return result;
1211 }
1212 
1214 {
1215  bool result=true;
1216 
1217  if ( pho->pt() < minPhoEtCut_ ) result=false;
1218  if ( fabs(pho->eta()) > photonMaxEta_ ) result=false;
1219  if ( pho->isEBEEGap() ) result=false;
1220 
1221  return result;
1222 }
size
Write out results.
bool photonSelection(const reco::Photon *p)
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
T getUntrackedParameter(std::string const &, T const &) const
void bookHistogramsPhotons(DQMStore::IBooker &)
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:406
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool isEE() const
Definition: Photon.h:123
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
float chargedHadronIso() const
Accessors for Particle Flow Isolation variables.
Definition: Photon.h:484
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
float neutralHadronIso() const
Definition: Photon.h:486
float hcalTowerSumEtConeDR03() const
Hcal isolation sum.
Definition: Photon.h:429
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
double deltaRMax
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const std::string & pwd(void)
Definition: DQMStore.cc:285
float trkSumPtSolidConeDR04() const
Definition: Photon.h:418
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:103
std::vector< EcalRecHit >::const_iterator const_iterator
float e1x5() const
Shower shape variables.
Definition: Photon.h:219
bool isEBEEGap() const
true if photon is in boundary between EB and EE
Definition: Photon.h:133
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:404
float trkSumPtHollowConeDR03() const
Definition: Photon.h:443
void fill3DHistoVector(std::vector< std::vector< std::vector< MonitorElement * > > > &histoVector, double x, int cut, int type, int part)
void bookHistogramsConversions(DQMStore::IBooker &)
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
float photonIso() const
Definition: Photon.h:487
float hadronicDepth2OverEm() const
the hadronic release in depth2 over electromagnetic fraction
Definition: Photon.h:208
virtual double phi() const final
momentum azimuthal angle
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T x() const
Cartesian x coordinate.
virtual double et() const final
transverse energy
MonitorElement * bookHisto(DQMStore::IBooker &, std::string histoName, std::string title, int bin, double min, double max)
void fill2DHistoVector(std::vector< std::vector< MonitorElement * > > &histoVector, double x, int cut, int type)
void fillHistogramsForHistogramCounts(DQMStore::IBooker &)
void analyze(const edm::Event &, const edm::EventSetup &) override
reco::ConversionRefVector conversions() const
vector of references to Conversion&#39;s
Definition: Photon.h:64
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:18
float sigmaIetaIeta() const
Definition: Photon.h:225
virtual double energy() const final
energy
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
#define TWOPI
EgammaCoreTools.
Definition: DQMSourcePi0.cc:40
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
float e2x5() const
Definition: Photon.h:220
float ChiSquaredProbability(double chiSquared, double nrDOF)
float hadTowOverEm() const
the ration of hadronic energy in towers behind the BCs in the SC and the SC energy ...
Definition: Photon.h:211
int nTrkHollowConeDR04() const
Definition: Photon.h:424
T min(T a, T b)
Definition: MathUtil.h:58
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:204
bool isValid() const
Definition: HandleBase.h:74
#define PI
Definition: QcdUeDQM.h:36
void bookHistogramsInvMass(DQMStore::IBooker &)
float r1x5() const
Definition: Photon.h:226
float phiNormalization(float &a)
float getCorrectedEnergyError(P4type type) const
P4type getCandidateP4type() const
Definition: Photon.h:306
bin
set the eta bin as selection string.
const_iterator end() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
float hadronicDepth1OverEm() const
the hadronic release in depth1 over electromagnetic fraction
Definition: Photon.h:206
bool hasConversionTracks() const
Bool flagging photons with a vector of refereces to conversions with size >0.
Definition: Photon.h:72
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
void book3DHistoVector(DQMStore::IBooker &, std::vector< std::vector< std::vector< MonitorElement * > > > &toFill, std::string histoType, std::string histoName, std::string title, int xbin, double xmin, double xmax, int ybin=1, double ymin=1, double ymax=2)
float e3x3() const
Definition: Photon.h:221
bool photonSelectionSlimmed(const reco::Photon *p)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::vector< size_type > Keys
part
Definition: HCALResponse.h:20
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
def uint(string)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int nTrkSolidConeDR04() const
Definition: Photon.h:422
const LorentzVector & p4(P4type type) const
std::string const & label() const
Definition: InputTag.h:36
bool isEB() const
Definition: Photon.h:121
float trkSumPtHollowConeDR04() const
Definition: Photon.h:420
float r2x5() const
Definition: Photon.h:227
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
void bookHistogramsForHistogramCounts(DQMStore::IBooker &)
float r9() const
Definition: Photon.h:228
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
void book2DHistoVector(DQMStore::IBooker &, std::vector< std::vector< MonitorElement * > > &toFill, std::string histoType, std::string histoName, std::string title, int xbin, double xmin, double xmax, int ybin=1, double ymin=1, double ymax=2)
void bookHistogramsEfficiency(DQMStore::IBooker &)
~PhotonAnalyzer() override
PhotonAnalyzer(const edm::ParameterSet &)
const_iterator begin() const
Definition: Run.h:42
double scalar(const CLHEP::HepGenMatrix &m)
Return the matrix as a scalar. Raise an assertion if the matris is not .
Definition: matutil.cc:183
float maxEnergyXtal() const
Definition: Photon.h:223