CMS 3D CMS Logo

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