00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DQM/Physics/src/QcdPhotonsDQM.h"
00010
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014
00015 #include "DQMServices/Core/interface/DQMStore.h"
00016 #include "DQMServices/Core/interface/MonitorElement.h"
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018
00019 #include "DataFormats/Common/interface/Handle.h"
00020
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023
00024 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00025 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00026 #include "DataFormats/JetReco/interface/CaloJet.h"
00027
00028
00029 #include "DataFormats/VertexReco/interface/Vertex.h"
00030 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00031
00032
00033 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00034 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00035 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00036 #include "FWCore/Framework/interface/ESHandle.h"
00037 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00038 #include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"
00039
00040
00041 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00042 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00043 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00044 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00045 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00046 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00047 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00048
00049
00050 #include "DataFormats/Math/interface/deltaR.h"
00051 #include "DataFormats/Math/interface/deltaPhi.h"
00052
00053 #include <vector>
00054
00055 #include <string>
00056 #include <cmath>
00057 using namespace std;
00058 using namespace edm;
00059 using namespace reco;
00060
00061
00062
00063 QcdPhotonsDQM::QcdPhotonsDQM(const ParameterSet& parameters) {
00064
00065 theTriggerPathToPass = parameters.getParameter<string>("triggerPathToPass");
00066 thePlotTheseTriggersToo = parameters.getParameter<vector<string> >("plotTheseTriggersToo");
00067 theHltMenu = parameters.getParameter<string>("hltMenu");
00068 theTriggerResultsCollection = parameters.getParameter<string>("triggerResultsCollection");
00069 thePhotonCollectionLabel = parameters.getParameter<InputTag>("photonCollection");
00070 theCaloJetCollectionLabel = parameters.getParameter<InputTag>("caloJetCollection");
00071 theVertexCollectionLabel = parameters.getParameter<InputTag>("vertexCollection");
00072 theMinCaloJetPt = parameters.getParameter<double>("minCaloJetPt");
00073 theMinPhotonEt = parameters.getParameter<double>("minPhotonEt");
00074 theRequirePhotonFound = parameters.getParameter<bool>("requirePhotonFound");
00075 thePlotPhotonMaxEt = parameters.getParameter<double>("plotPhotonMaxEt");
00076 thePlotPhotonMaxEta = parameters.getParameter<double>("plotPhotonMaxEta");
00077 thePlotJetMaxEta = parameters.getParameter<double>("plotJetMaxEta");
00078
00079 isValidHltConfig_ = false;
00080
00081 }
00082
00083 QcdPhotonsDQM::~QcdPhotonsDQM() {
00084 }
00085
00086
00087 void QcdPhotonsDQM::beginJob() {
00088
00089 logTraceName = "QcdPhotonAnalyzer";
00090
00091 LogTrace(logTraceName)<<"Parameters initialization";
00092 theDbe = Service<DQMStore>().operator->();
00093
00094 theDbe->setCurrentFolder("Physics/QcdPhotons");
00095
00096 std::stringstream aStringStream;
00097 std::string aString;
00098 aStringStream << theMinCaloJetPt;
00099 aString = aStringStream.str();
00100
00101
00102 int numOfTriggersToMonitor = thePlotTheseTriggersToo.size();
00103 h_triggers_passed = theDbe->book1D("h_triggers_passed", "Events passing these trigger paths", numOfTriggersToMonitor, 0, numOfTriggersToMonitor);
00104 for (int i=0; i<numOfTriggersToMonitor; i++) {
00105 h_triggers_passed->setBinLabel(i+1,thePlotTheseTriggersToo[i]);
00106 }
00107
00108
00109 h_photon_et = theDbe->book1D("h_photon_et", "#gamma with highest E_{T};E_{T}(#gamma) (GeV)", 20, 0., thePlotPhotonMaxEt);
00110 h_photon_eta = theDbe->book1D("h_photon_eta", "#gamma with highest E_{T};#eta(#gamma)", 40, -thePlotPhotonMaxEta, thePlotPhotonMaxEta);
00111 h_photon_count_bar = theDbe->book1D("h_photon_count_bar","Number of #gamma's passing selection (Barrel);Number of #gamma's", 8, -0.5, 7.5);
00112 h_photon_count_end = theDbe->book1D("h_photon_count_end","Number of #gamma's passing selection (Endcap);Number of #gamma's", 8, -0.5, 7.5);
00113
00114 h_jet_pt = theDbe->book1D("h_jet_pt", "Jet with highest p_{T} (from "+theCaloJetCollectionLabel.label()+");p_{T}(1^{st} jet) (GeV)", 20, 0., thePlotPhotonMaxEt);
00115 h_jet_eta = theDbe->book1D("h_jet_eta", "Jet with highest p_{T} (from "+theCaloJetCollectionLabel.label()+");#eta(1^{st} jet)", 20, -thePlotJetMaxEta, thePlotJetMaxEta);
00116 h_deltaPhi_photon_jet = theDbe->book1D("h_deltaPhi_photon_jet", "#Delta#phi between Highest E_{T} #gamma and jet;#Delta#phi(#gamma,1^{st} jet)", 20, 0, 3.1415926);
00117 h_deltaPhi_jet_jet2 = theDbe->book1D("h_deltaPhi_jet_jet2", "#Delta#phi between Highest E_{T} jet and 2^{nd} jet;#Delta#phi(1^{st} jet,2^{nd} jet)", 20, 0, 3.1415926);
00118 h_deltaEt_photon_jet = theDbe->book1D("h_deltaEt_photon_jet", "(E_{T}(#gamma)-p_{T}(jet))/E_{T}(#gamma) when #Delta#phi(#gamma,1^{st} jet) > 2.8;#DeltaE_{T}(#gamma,1^{st} jet)/E_{T}(#gamma)", 20, -1.0, 1.0);
00119 h_jet_count = theDbe->book1D("h_jet_count", "Number of "+theCaloJetCollectionLabel.label()+" (p_{T} > "+aString+" GeV);Number of Jets", 8, -0.5, 7.5);
00120 h_jet2_pt = theDbe->book1D("h_jet2_pt", "Jet with 2^{nd} highest p_{T} (from "+theCaloJetCollectionLabel.label()+");p_{T}(2^{nd} jet) (GeV)", 20, 0., thePlotPhotonMaxEt);
00121 h_jet2_eta = theDbe->book1D("h_jet2_eta", "Jet with 2^{nd} highest p_{T} (from "+theCaloJetCollectionLabel.label()+");#eta(2^{nd} jet)", 20, -thePlotJetMaxEta, thePlotJetMaxEta);
00122 h_jet2_ptOverPhotonEt = theDbe->book1D("h_jet2_ptOverPhotonEt", "p_{T}(2^{nd} highest jet) / E_{T}(#gamma);p_{T}(2^{nd} Jet)/E_{T}(#gamma)", 20, 0.0, 4.0);
00123 h_deltaPhi_photon_jet2 = theDbe->book1D("h_deltaPhi_photon_jet2","#Delta#phi between Highest E_{T} #gamma and 2^{nd} highest jet;#Delta#phi(#gamma,2^{nd} jet)", 20, 0, 3.1415926);
00124 h_deltaR_jet_jet2 = theDbe->book1D("h_deltaR_jet_jet2", "#DeltaR between Highest Jet and 2^{nd} Highest;#DeltaR(1^{st} jet,2^{nd} jet)", 30, 0, 6.0);
00125 h_deltaR_photon_jet2 = theDbe->book1D("h_deltaR_photon_jet2", "#DeltaR between Highest E_{T} #gamma and 2^{nd} jet;#DeltaR(#gamma, 2^{nd} jet)", 30, 0, 6.0);
00126
00127
00128 Float_t bins_et[] = {15,20,30,50,80};
00129 int num_bins_et = 4;
00130 h_photon_et_jetcs = theDbe->book1D("h_photon_et_jetcs", "#gamma with highest E_{T} (#eta(jet)<1.45, #eta(#gamma)#eta(jet)>0);E_{T}(#gamma) (GeV)", num_bins_et, bins_et);
00131 h_photon_et_jetco = theDbe->book1D("h_photon_et_jetco", "#gamma with highest E_{T} (#eta(jet)<1.45, #eta(#gamma)#eta(jet)<0);E_{T}(#gamma) (GeV)", num_bins_et, bins_et);
00132 h_photon_et_jetfs = theDbe->book1D("h_photon_et_jetfs", "#gamma with highest E_{T} (1.55<#eta(jet)<2.5, #eta(#gamma)#eta(jet)>0);E_{T}(#gamma) (GeV)", num_bins_et, bins_et);
00133 h_photon_et_jetfo = theDbe->book1D("h_photon_et_jetfo", "#gamma with highest E_{T} (1.55<#eta(jet)<2.5, #eta(#gamma)#eta(jet)<0);E_{T}(#gamma) (GeV)", num_bins_et, bins_et);
00134 h_photon_et_jetcs->getTH1F()->Sumw2();
00135 h_photon_et_jetco->getTH1F()->Sumw2();
00136 h_photon_et_jetfs->getTH1F()->Sumw2();
00137 h_photon_et_jetfo->getTH1F()->Sumw2();
00138
00139 h_photon_et_ratio_co_cs = theDbe->book1D("h_photon_et_ratio_00_co_cs", "D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)<0) / D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)>0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00140 h_photon_et_ratio_fo_fs = theDbe->book1D("h_photon_et_ratio_01_fo_fs", "D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)<0) / D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)>0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00141 h_photon_et_ratio_cs_fs = theDbe->book1D("h_photon_et_ratio_02_cs_fs", "D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)>0) / D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)>0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00142 h_photon_et_ratio_co_fs = theDbe->book1D("h_photon_et_ratio_03_co_fs", "D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)<0) / D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)>0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00143 h_photon_et_ratio_cs_fo = theDbe->book1D("h_photon_et_ratio_04_cs_fo", "D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)>0) / D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)<0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00144 h_photon_et_ratio_co_fo = theDbe->book1D("h_photon_et_ratio_05_co_fo", "D(|#eta(jet)|<1.45, #eta(jet)*#eta(#gamma)<0) / D(1.55<|#eta(jet)|<2.6, #eta(jet)*#eta(#gamma)<0);E_{T}(#gamma) (GeV); ratio", num_bins_et, bins_et);
00145 h_photon_et_ratio_co_cs->getTH1F()->Sumw2();
00146 h_photon_et_ratio_fo_fs->getTH1F()->Sumw2();
00147 h_photon_et_ratio_cs_fs->getTH1F()->Sumw2();
00148 h_photon_et_ratio_co_fs->getTH1F()->Sumw2();
00149 h_photon_et_ratio_cs_fo->getTH1F()->Sumw2();
00150 h_photon_et_ratio_co_fo->getTH1F()->Sumw2();
00151 }
00152
00153
00157 void QcdPhotonsDQM::beginRun( const edm::Run &r, const edm::EventSetup &iSetup ) {
00158
00159
00160 bool isConfigChanged = false;
00161
00162
00163 isValidHltConfig_ = hltConfigProvider_.init( r, iSetup, theHltMenu, isConfigChanged );
00164
00165 num_events_in_run = 0;
00166 }
00167
00168
00169 void QcdPhotonsDQM::analyze(const Event& iEvent, const EventSetup& iSetup) {
00170 num_events_in_run++;
00171
00172
00173 if( ! isValidHltConfig_ ) return;
00174
00175 LogTrace(logTraceName)<<"Analysis of event # ";
00176
00178
00179 Handle<TriggerResults> HLTresults;
00180 iEvent.getByLabel(InputTag(theTriggerResultsCollection, "", theHltMenu), HLTresults);
00181 if (!HLTresults.isValid()) return;
00182
00183 unsigned int triggerIndex;
00184 bool passed_HLT;
00185
00186
00187
00188 for (unsigned int i=0; i<thePlotTheseTriggersToo.size(); i++) {
00189 passed_HLT = false;
00190 triggerIndex = hltConfigProvider_.triggerIndex(thePlotTheseTriggersToo[i]);
00191 if (triggerIndex < HLTresults->size()) passed_HLT = HLTresults->accept(triggerIndex);
00192 if (passed_HLT) h_triggers_passed->Fill(i);
00193 }
00194
00195
00196 passed_HLT = false;
00197 triggerIndex = hltConfigProvider_.triggerIndex(theTriggerPathToPass);
00198 if (triggerIndex < HLTresults->size()) passed_HLT = HLTresults->accept(triggerIndex);
00199 if (!passed_HLT) return;
00201
00202
00204
00205
00206 Handle<VertexCollection> vertexHandle;
00207 iEvent.getByLabel(theVertexCollectionLabel, vertexHandle);
00208 VertexCollection vertexCollection = *(vertexHandle.product());
00209 double vtx_ndof = -1.0;
00210 double vtx_z = 0.0;
00211 bool vtx_isFake = true;
00212 if (vertexCollection.size()>0) {
00213 vtx_ndof = vertexCollection.begin()->ndof();
00214 vtx_z = vertexCollection.begin()->z();
00215 vtx_isFake = false;
00216 }
00217 if (vtx_isFake || fabs(vtx_z)>15 || vtx_ndof<4) return;
00219
00220
00222
00223
00224
00226
00227
00228 Handle<PhotonCollection> photonCollection;
00229 iEvent.getByLabel(thePhotonCollectionLabel, photonCollection);
00230
00231
00232 if (!photonCollection.isValid()) return;
00233
00234
00235 Handle<EcalRecHitCollection> EBReducedRecHits;
00236 iEvent.getByLabel("reducedEcalRecHitsEB", EBReducedRecHits);
00237 Handle<EcalRecHitCollection> EEReducedRecHits;
00238 iEvent.getByLabel("reducedEcalRecHitsEE", EEReducedRecHits);
00239 EcalClusterLazyTools lazyTool(iEvent, iSetup, InputTag("reducedEcalRecHitsEB"), InputTag("reducedEcalRecHitsEE") );
00240
00241 ESHandle<EcalChannelStatus> chStatus;
00242 iSetup.get<EcalChannelStatusRcd>().get(chStatus);
00243
00244
00245 float photon_et = -9.0;
00246 float photon_eta = -9.0;
00247 float photon_phi = -9.0;
00248 bool photon_passPhotonID = false;
00249 bool found_lead_pho = false;
00250 int photon_count_bar = 0;
00251 int photon_count_end = 0;
00252
00253 for (PhotonCollection::const_iterator recoPhoton = photonCollection->begin(); recoPhoton!=photonCollection->end(); recoPhoton++){
00254
00255
00256 if ( recoPhoton->et() < theMinPhotonEt ) break;
00257
00258
00259 const reco::CaloClusterPtr seed = recoPhoton->superCluster()->seed();
00260 DetId id = lazyTool.getMaximum(*seed).first;
00261 float time = -999., outOfTimeChi2 = -999., chi2 = -999.;
00262 int flags=-1, severity = -1;
00263 const EcalRecHitCollection & rechits = ( recoPhoton->isEB() ? *EBReducedRecHits : *EEReducedRecHits);
00264 EcalRecHitCollection::const_iterator it = rechits.find( id );
00265 if( it != rechits.end() ) {
00266 time = it->time();
00267 outOfTimeChi2 = it->outOfTimeChi2();
00268 chi2 = it->chi2();
00269 flags = it->recoFlag();
00270 severity = EcalSeverityLevelAlgo::severityLevel( id, rechits, *chStatus );
00271 }
00272 bool isNotSpike = ((recoPhoton->isEB() && (severity!=3 && severity!=4 ) && (flags != 2) ) || recoPhoton->isEE());
00273 if (!isNotSpike) continue;
00274
00275
00276 bool pho_current_passPhotonID = false;
00277 bool pho_current_isEB = recoPhoton->isEB();
00278 bool pho_current_isEE = recoPhoton->isEE();
00279
00280 if ( pho_current_isEB && (recoPhoton->sigmaIetaIeta() < 0.01 || recoPhoton->hadronicOverEm() < 0.05) ) {
00281
00282 pho_current_passPhotonID = true;
00283 photon_count_bar++;
00284 } else if ( pho_current_isEE && (recoPhoton->hadronicOverEm() < 0.05) ) {
00285
00286 pho_current_passPhotonID = true;
00287 photon_count_end++;
00288 }
00289
00290 if (!found_lead_pho) {
00291 found_lead_pho = true;
00292 photon_passPhotonID = pho_current_passPhotonID;
00293 photon_et = recoPhoton->et();
00294 photon_eta = recoPhoton->eta();
00295 photon_phi = recoPhoton->phi();
00296 }
00297 }
00298
00299
00300
00301
00302 if ( theRequirePhotonFound && (!photon_passPhotonID || photon_et<theMinPhotonEt) ) return;
00303
00304
00306
00307 Handle<CaloJetCollection> caloJetCollection;
00308 iEvent.getByLabel (theCaloJetCollectionLabel,caloJetCollection);
00309 if (!caloJetCollection.isValid()) return;
00310
00311 float jet_pt = -8.0;
00312 float jet_eta = -8.0;
00313 float jet_phi = -8.0;
00314 int jet_count = 0;
00315 float jet2_pt = -9.0;
00316 float jet2_eta = -9.0;
00317 float jet2_phi = -9.0;
00318
00319 for (CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin(); i_calojet != caloJetCollection->end(); i_calojet++) {
00320
00321 float jet_current_pt = i_calojet->pt();
00322
00323
00324 if ( deltaR(i_calojet->eta(), i_calojet->phi(), photon_eta, photon_phi) < 0.5 ) continue;
00325
00326 if (jet_current_pt < theMinCaloJetPt) break;
00327
00328 jet_count++;
00329 if (jet_current_pt > jet_pt) {
00330 jet2_pt = jet_pt;
00331 jet2_eta = jet_eta;
00332 jet2_phi = jet_phi;
00333 jet_pt = jet_current_pt;
00334 jet_eta = i_calojet->eta();
00335 jet_phi = i_calojet->phi();
00336 } else if (jet_current_pt > jet2_pt) {
00337 jet2_pt = jet_current_pt;
00338 jet2_eta = i_calojet->eta();
00339 jet2_phi = i_calojet->phi();
00340 }
00341 }
00343
00344
00346
00347
00348
00349 if ( jet_pt > 0.0 ) {
00350
00351
00352 h_photon_et ->Fill( photon_et );
00353 h_photon_eta ->Fill( photon_eta );
00354 h_photon_count_bar->Fill( photon_count_bar );
00355 h_photon_count_end->Fill( photon_count_end );
00356
00357
00358 if ( fabs(photon_eta)<1.45 && photon_passPhotonID ) {
00359 if (fabs(jet_eta)<1.45){
00360 if (photon_eta*jet_eta>0) {
00361 h_photon_et_jetcs->Fill(photon_et);
00362 } else {
00363 h_photon_et_jetco->Fill(photon_et);
00364 }
00365 } else if (jet_eta>1.55 && jet_eta<2.5) {
00366 if (photon_eta*jet_eta>0) {
00367 h_photon_et_jetfs->Fill(photon_et);
00368 } else {
00369 h_photon_et_jetfo->Fill(photon_et);
00370 }
00371 }
00372 }
00373
00374
00375 h_jet_pt ->Fill( jet_pt );
00376 h_jet_eta ->Fill( jet_eta );
00377 h_jet_count ->Fill( jet_count );
00378 h_deltaPhi_photon_jet ->Fill( abs(deltaPhi(photon_phi, jet_phi)) );
00379 if ( abs(deltaPhi(photon_phi,jet_phi))>2.8 ) h_deltaEt_photon_jet->Fill( (photon_et-jet_pt)/photon_et );
00380
00381
00382 if ( jet2_pt > 0.0 ) {
00383 h_jet2_pt ->Fill( jet2_pt );
00384 h_jet2_eta ->Fill( jet2_eta );
00385 h_jet2_ptOverPhotonEt ->Fill( jet2_pt/photon_et );
00386 h_deltaPhi_photon_jet2->Fill( abs(deltaPhi(photon_phi, jet2_phi)) );
00387 h_deltaPhi_jet_jet2 ->Fill( abs(deltaPhi( jet_phi, jet2_phi)) );
00388 h_deltaR_jet_jet2 ->Fill( deltaR( jet_eta, jet_phi, jet2_eta, jet2_phi) );
00389 h_deltaR_photon_jet2 ->Fill( deltaR(photon_eta, photon_phi, jet2_eta, jet2_phi) );
00390 }
00391 }
00392
00394 }
00395
00396
00397 void QcdPhotonsDQM::endJob(void) {}
00398
00399 void QcdPhotonsDQM::endRun(const edm::Run& run, const edm::EventSetup& es) {
00400 if (num_events_in_run>0) {
00401 h_triggers_passed->getTH1F()->Scale(1.0/num_events_in_run);
00402 }
00403 h_photon_et_ratio_co_cs->getTH1F()->Divide( h_photon_et_jetco->getTH1F(), h_photon_et_jetcs->getTH1F() );
00404 h_photon_et_ratio_fo_fs->getTH1F()->Divide( h_photon_et_jetfo->getTH1F(), h_photon_et_jetfs->getTH1F() );
00405 h_photon_et_ratio_cs_fs->getTH1F()->Divide( h_photon_et_jetcs->getTH1F(), h_photon_et_jetfs->getTH1F() );
00406 h_photon_et_ratio_co_fs->getTH1F()->Divide( h_photon_et_jetco->getTH1F(), h_photon_et_jetfs->getTH1F() );
00407 h_photon_et_ratio_cs_fo->getTH1F()->Divide( h_photon_et_jetcs->getTH1F(), h_photon_et_jetfo->getTH1F() );
00408 h_photon_et_ratio_co_fo->getTH1F()->Divide( h_photon_et_jetco->getTH1F(), h_photon_et_jetfo->getTH1F() );
00409 }
00410