00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "DQMOffline/Muon/interface/MuonIsolationDQM.h"
00033
00034
00035 #include <memory>
00036 #include <string>
00037 #include <typeinfo>
00038 #include <utility>
00039
00040
00041 #include "TH1.h"
00042 #include "TH2.h"
00043 #include "TProfile.h"
00044
00045
00046 #include "FWCore/Framework/interface/MakerMacros.h"
00047 #include "FWCore/Framework/interface/Event.h"
00048 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00049
00050
00051 #include "DataFormats/TrackReco/interface/Track.h"
00052
00053
00054 using std::vector;
00055 using std::pair;
00056 using std::string;
00057
00058
00059
00060
00061
00062
00063 MuonIsolationDQM::MuonIsolationDQM(const edm::ParameterSet& iConfig)
00064 {
00065
00066
00067 requireSTAMuon = iConfig.getUntrackedParameter<bool>("requireSTAMuon");
00068 requireTRKMuon = iConfig.getUntrackedParameter<bool>("requireTRKMuon");
00069 requireGLBMuon = iConfig.getUntrackedParameter<bool>("requireGLBMuon");
00070 dirName = iConfig.getParameter<std::string>("directory");
00071
00072
00073
00074
00075
00076 Muon_Tag = iConfig.getUntrackedParameter<edm::InputTag>("Global_Muon_Label");
00077
00078
00079 nEvents = 0;
00080 nSTAMuons = 0;
00081 nTRKMuons = 0;
00082 nGLBMuons = 0;
00083
00084 InitStatics();
00085
00086
00087 dbe = 0;
00088 dbe = edm::Service<DQMStore>().operator->();
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 h_1D.resize (NUM_VARS);
00101
00102
00103 dbe->cd();
00104 }
00105
00106
00107
00108
00109 MuonIsolationDQM::~MuonIsolationDQM(){
00110
00111
00112
00113 }
00114
00115
00116
00117
00118 void MuonIsolationDQM::InitStatics(){
00119
00120
00121 S_BIN_WIDTH = 1.0;
00122 L_BIN_WIDTH = 2.0;
00123 LOG_BINNING_ENABLED = 1;
00124 NUM_LOG_BINS = 15;
00125 LOG_BINNING_RATIO = 1.1;
00126
00127
00128
00129
00130 title_sam = "";
00131 title_cone = "";
00132
00133
00134
00135
00136
00137 main_titles.resize(NUM_VARS);
00138 axis_titles.resize(NUM_VARS);
00139 names.resize(NUM_VARS);
00140 param.resize(NUM_VARS, vector<double>(3) );
00141 isContinuous.resize(NUM_VARS);
00142
00143
00144 main_titles[0 ] = "Total Tracker Momentum, #Delta R = 0.3";
00145 main_titles[1 ] = "Total EM Cal Energy, #Delta R = 0.3";
00146 main_titles[2 ] = "Total Had Cal Energy, #Delta R = 0.3";
00147 main_titles[3 ] = "Total HO Cal Energy, #Delta R = 0.3";
00148 main_titles[4 ] = "Number of Tracker Tracks, #Delta R = 0.3";
00149 main_titles[5 ] = "Number of Jets around Muon, #Delta R = 0.3";
00150 main_titles[6 ] = "Tracker p_{T} within veto cone, #Delta R = 0.3";
00151 main_titles[7 ] = "EM E_{T} within veto cone, #Delta R = 0.3";
00152 main_titles[8 ] = "Had E_{T} within veto cone, #Delta R = 0.3";
00153 main_titles[9 ] = "HO E_{T} within veto cone, #Delta R = 0.3";
00154 main_titles[10] = "Average Momentum per Track, #Delta R = 0.3";
00155 main_titles[11] = "Weighted Energy, #Delta R = 0.3";
00156
00157 main_titles[12] = "Total Tracker Momentum, #Delta R = 0.5";
00158 main_titles[13] = "Total EM Cal Energy, #Delta R = 0.5";
00159 main_titles[14] = "Total Had Cal Energy, #Delta R = 0.5";
00160 main_titles[15] = "Total HO Cal Energy, #Delta R = 0.5";
00161 main_titles[16] = "Number of Tracker Tracks, #Delta R = 0.5";
00162 main_titles[17] = "Number of Jets around Muon, #Delta R = 0.5";
00163 main_titles[18] = "Tracker p_{T} within veto cone, #Delta R = 0.5";
00164 main_titles[19] = "EM E_{T} within veto cone, #Delta R = 0.5";
00165 main_titles[20] = "Had E_{T} within veto cone, #Delta R = 0.5";
00166 main_titles[21] = "HO E_{T} within veto cone, #Delta R = 0.5";
00167 main_titles[22] = "Average Momentum per Track, #Delta R = 0.5";
00168 main_titles[23] = "Weighted Energy, #Delta R = 0.5";
00169
00170
00171 axis_titles[0 ] = "#Sigma p_{T} (GeV)";
00172 axis_titles[1 ] = "#Sigma E_{T}^{EM} (GeV)";
00173 axis_titles[2 ] = "#Sigma E_{T}^{Had} (GeV)";
00174 axis_titles[3 ] = "#Sigma E_{T}^{HO} (GeV)";
00175 axis_titles[4 ] = "N_{Tracks}";
00176 axis_titles[5 ] = "N_{Jets}";
00177 axis_titles[6 ] = "#Sigma p_{T,veto} (GeV)";
00178 axis_titles[7 ] = "#Sigma E_{T,veto}^{EM} (GeV)";
00179 axis_titles[8 ] = "#Sigma E_{T,veto}^{Had} (GeV)";
00180 axis_titles[9 ] = "#Sigma E_{T,veto}^{HO} (GeV)";
00181 axis_titles[10] = "#Sigma p_{T} / N_{Tracks} (GeV)";
00182 axis_titles[11] = "(1.5) X #Sigma E_{T}^{EM} + #Sigma E_{T}^{Had}";
00183
00184 axis_titles[12] = "#Sigma p_{T} (GeV)";
00185 axis_titles[13] = "#Sigma E_{T}^{EM} (GeV)";
00186 axis_titles[14] = "#Sigma E_{T}^{Had} (GeV)";
00187 axis_titles[15] = "#Sigma E_{T}^{HO} (GeV)";
00188 axis_titles[16] = "N_{Tracks}";
00189 axis_titles[17] = "N_{Jets}";
00190 axis_titles[18] = "#Sigma p_{T,veto} (GeV)";
00191 axis_titles[19] = "#Sigma E_{T,veto}^{EM} (GeV)";
00192 axis_titles[20] = "#Sigma E_{T,veto}^{Had} (GeV)";
00193 axis_titles[21] = "#Sigma E_{T,veto}^{HO} (GeV)";
00194 axis_titles[22] = "#Sigma p_{T} / N_{Tracks} (GeV)";
00195 axis_titles[23] = "(1.5) X #Sigma E_{T}^{EM} + #Sigma E_{T}^{Had}";
00196
00197
00198 names[0 ] = "sumPt_R03";
00199 names[1 ] = "emEt_R03";
00200 names[2 ] = "hadEt_R03";
00201 names[3 ] = "hoEt_R03";
00202 names[4 ] = "nTracks_R03";
00203 names[5 ] = "nJets_R03";
00204 names[6 ] = "trackerVetoPt_R03";
00205 names[7 ] = "emVetoEt_R03";
00206 names[8 ] = "hadVetoEt_R03";
00207 names[9 ] = "hoVetoEt_R03";
00208 names[10] = "avgPt_R03";
00209 names[11] = "weightedEt_R03";
00210
00211 names[12] = "sumPt_R05";
00212 names[13] = "emEt_R05";
00213 names[14] = "hadEt_R05";
00214 names[15] = "hoEt_R05";
00215 names[16] = "nTracks_R05";
00216 names[17] = "nJets_R05";
00217 names[18] = "trackerVetoPt_R05";
00218 names[19] = "emVetoEt_R05";
00219 names[20] = "hadVetoEt_R05";
00220 names[21] = "hoVetoEt_R05";
00221 names[22] = "avgPt_R05";
00222 names[23] = "weightedEt_R05";
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 param[0 ][0]= (int)( 20.0/S_BIN_WIDTH); param[0 ][1]= 0.0; param[0 ][2]= param[0 ][0]*S_BIN_WIDTH;
00233 param[1 ][0]= (int)( 20.0/S_BIN_WIDTH); param[1 ][1]= 0.0; param[1 ][2]= param[1 ][0]*S_BIN_WIDTH;
00234 param[2 ][0]= (int)( 20.0/S_BIN_WIDTH); param[2 ][1]= 0.0; param[2 ][2]= param[2 ][0]*S_BIN_WIDTH;
00235 param[3 ][0]= 20; param[3 ][1]= 0.0; param[3 ][2]= 2.0;
00236 param[4 ][0]= 16; param[4 ][1]= -0.5; param[4 ][2]= param[4 ][0]-0.5;
00237 param[5 ][0]= 4; param[5 ][1]= -0.5; param[5 ][2]= param[5 ][0]-0.5;
00238 param[6 ][0]= (int)( 40.0/S_BIN_WIDTH); param[6 ][1]= 0.0; param[6 ][2]= param[6 ][0]*S_BIN_WIDTH;
00239 param[7 ][0]= 20; param[7 ][1]= 0.0; param[7 ][2]= 10.0;
00240 param[8 ][0]= (int)( 20.0/S_BIN_WIDTH); param[8 ][1]= 0.0; param[8 ][2]= param[8 ][0]*S_BIN_WIDTH;
00241 param[9 ][0]= 20; param[9 ][1]= 0.0; param[9 ][2]= 5.0;
00242 param[10][0]= (int)( 15.0/S_BIN_WIDTH); param[10][1]= 0.0; param[10][2]= param[10][0]*S_BIN_WIDTH;
00243 param[11][0]= (int)( 20.0/S_BIN_WIDTH); param[11][1]= 0.0; param[11][2]= param[11][0]*S_BIN_WIDTH;
00244
00245 param[12][0]= (int)( 20.0/S_BIN_WIDTH); param[12][1]= 0.0; param[12][2]= param[12][0]*S_BIN_WIDTH;
00246 param[13][0]= (int)( 20.0/S_BIN_WIDTH); param[13][1]= 0.0; param[13][2]= param[13][0]*S_BIN_WIDTH;
00247 param[14][0]= (int)( 20.0/S_BIN_WIDTH); param[14][1]= 0.0; param[14][2]= param[14][0]*S_BIN_WIDTH;
00248 param[15][0]= 20; param[15][1]= 0.0; param[15][2]= 2.0;
00249 param[16][0]= 16; param[16][1]= -0.5; param[16][2]= param[16][0]-0.5;
00250 param[17][0]= 4; param[17][1]= -0.5; param[17][2]= param[17][0]-0.5;
00251 param[18][0]= (int)( 40.0/S_BIN_WIDTH); param[18][1]= 0.0; param[18][2]= param[18][0]*S_BIN_WIDTH;
00252 param[19][0]= 20; param[19][1]= 0.0; param[19][2]= 10.0;
00253 param[20][0]= (int)( 20.0/S_BIN_WIDTH); param[20][1]= 0.0; param[20][2]= param[20][0]*S_BIN_WIDTH;
00254 param[21][0]= 20; param[21][1]= 0.0; param[21][2]= 5.0;
00255 param[22][0]= (int)( 15.0/S_BIN_WIDTH); param[22][1]= 0.0; param[22][2]= param[22][0]*S_BIN_WIDTH;
00256 param[23][0]= (int)( 20.0/S_BIN_WIDTH); param[23][1]= 0.0; param[23][2]= param[23][0]*S_BIN_WIDTH;
00257
00258
00259
00260 isContinuous[0 ] = 1;
00261 isContinuous[1 ] = 1;
00262 isContinuous[2 ] = 1;
00263 isContinuous[3 ] = 1;
00264 isContinuous[4 ] = 0;
00265 isContinuous[5 ] = 0;
00266 isContinuous[6 ] = 1;
00267 isContinuous[7 ] = 1;
00268 isContinuous[8 ] = 1;
00269 isContinuous[9 ] = 1;
00270 isContinuous[10] = 1;
00271 isContinuous[11] = 1;
00272
00273 isContinuous[12] = 1;
00274 isContinuous[13] = 1;
00275 isContinuous[14] = 1;
00276 isContinuous[15] = 1;
00277 isContinuous[16] = 0;
00278 isContinuous[17] = 0;
00279 isContinuous[18] = 1;
00280 isContinuous[19] = 1;
00281 isContinuous[20] = 1;
00282 isContinuous[21] = 1;
00283 isContinuous[22] = 1;
00284 isContinuous[23] = 1;
00285
00286 }
00287
00288
00289
00290 void MuonIsolationDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00291
00292 ++nEvents;
00293 edm::LogInfo("Tutorial") << "\nInvestigating event #" << nEvents<<"\n";
00294
00295
00296 edm::Handle<edm::View<reco::Muon> > muonsHandle;
00297 iEvent.getByLabel(Muon_Tag, muonsHandle);
00298
00299
00300 edm::LogInfo("Tutorial") << "Number of Muons: " << muonsHandle->size();
00301 theMuonData = muonsHandle->size();
00302 h_nMuons->Fill(theMuonData);
00303
00304
00305 uint iMuon=0;
00306 dbe->setCurrentFolder(dirName.c_str());
00307 for (MuonIterator muon = muonsHandle->begin(); muon != muonsHandle->end(); ++muon, ++iMuon ) {
00308
00309 if (requireSTAMuon && muon->isStandAloneMuon()) {
00310 ++nSTAMuons;
00311 RecordData(muon);
00312 FillHistos();
00313 }
00314 else if (requireTRKMuon && muon->isTrackerMuon()) {
00315 ++nTRKMuons;
00316 RecordData(muon);
00317 FillHistos();
00318 }
00319 else if (requireGLBMuon && muon->isGlobalMuon()) {
00320 ++nGLBMuons;
00321 RecordData(muon);
00322 FillHistos();
00323 }
00324 }
00325 dbe->cd();
00326
00327 }
00328
00329
00330 void MuonIsolationDQM::RecordData(MuonIterator muon){
00331
00332
00333 theData[0] = muon->isolationR03().sumPt;
00334 theData[1] = muon->isolationR03().emEt;
00335 theData[2] = muon->isolationR03().hadEt;
00336 theData[3] = muon->isolationR03().hoEt;
00337
00338 theData[4] = muon->isolationR03().nTracks;
00339 theData[5] = muon->isolationR03().nJets;
00340 theData[6] = muon->isolationR03().trackerVetoPt;
00341 theData[7] = muon->isolationR03().emVetoEt;
00342 theData[8] = muon->isolationR03().hadVetoEt;
00343 theData[9] = muon->isolationR03().hoVetoEt;
00344
00345
00346 if (theData[4] != 0) theData[10] = (double)theData[0] / (double)theData[4];
00347 else theData[10] = -99;
00348
00349 theData[11] = 1.5 * theData[1] + theData[2];
00350
00351 theData[12] = muon->isolationR05().sumPt;
00352 theData[13] = muon->isolationR05().emEt;
00353 theData[14] = muon->isolationR05().hadEt;
00354 theData[15] = muon->isolationR05().hoEt;
00355
00356 theData[16] = muon->isolationR05().nTracks;
00357 theData[17] = muon->isolationR05().nJets;
00358 theData[18] = muon->isolationR05().trackerVetoPt;
00359 theData[19] = muon->isolationR05().emVetoEt;
00360 theData[20] = muon->isolationR05().hadVetoEt;
00361 theData[21] = muon->isolationR05().hoVetoEt;
00362
00363
00364 if (theData[16] != 0) theData[22] = (double)theData[12] / (double)theData[16];
00365 else theData[22] = -99;
00366
00367 theData[23] = 1.5 * theData[13] + theData[14];
00368
00369 }
00370
00371
00372 void
00373 MuonIsolationDQM::beginJob(void)
00374 {
00375
00376 edm::LogInfo("Tutorial") << "\n#########################################\n\n"
00377 << "Lets get started! "
00378 << "\n\n#########################################\n";
00379 dbe->setCurrentFolder(dirName.c_str());
00380 InitHistos();
00381 dbe->cd();
00382
00383 }
00384
00385
00386 void
00387 MuonIsolationDQM::endJob() {
00388
00389
00390 if( dbe )
00391 {
00392
00393 if (! dbe->get(dirName+"/nMuons")) return;
00394 }
00395 else
00396 return;
00397
00398 edm::LogInfo("Tutorial") << "\n#########################################\n\n"
00399 << "Total Number of Events: " << nEvents
00400 << "\n\n#########################################\n"
00401 << "\nInitializing Histograms...\n";
00402
00403 edm::LogInfo("Tutorial") << "\nIntializing Finished. Filling...\n";
00404 NormalizeHistos();
00405 edm::LogInfo("Tutorial") << "\nFilled. Saving...\n";
00406
00407 edm::LogInfo("Tutorial") << "\nSaved. Peace, homie, I'm out.\n";
00408
00409 }
00410
00411 void MuonIsolationDQM::InitHistos(){
00412
00413
00414 h_nMuons = dbe->book1D("nMuons", title_sam + "Number of Muons", 20, 0., 20.);
00415 h_nMuons->setAxisTitle("Number of Muons",XAXIS);
00416 h_nMuons->setAxisTitle("Fraction of Events",YAXIS);
00417
00418
00419
00420 for(int var = 0; var < NUM_VARS; var++){
00421 h_1D[var] = dbe->book1D(
00422 names[var],
00423 title_sam + main_titles[var] + title_cone,
00424 (int)param[var][0],
00425 param[var][1],
00426 param[var][2]
00427 );
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 h_1D[var]->setAxisTitle(axis_titles[var],XAXIS);
00438
00439 GetTH1FromMonitorElement(h_1D[var])->Sumw2();
00440
00441
00442
00443
00444
00445
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455 }
00456
00457 void MuonIsolationDQM::NormalizeHistos() {
00458 for(int var=0; var<NUM_VARS; var++){
00459
00460
00461
00462
00463 double entries = GetTH1FromMonitorElement(h_1D[var])->GetEntries();
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 GetTH1FromMonitorElement(h_1D[var])->Scale(1./entries);
00478
00479 }
00480 }
00481
00482 void MuonIsolationDQM::FillHistos() {
00483
00484 int overFlowBin;
00485 double overFlow = 0;
00486
00487
00488 for(int var=0; var<NUM_VARS; var++){
00489 h_1D[var]->Fill(theData[var]);
00490
00491 if (theData[var] > param[var][2]) {
00492
00493 overFlowBin = (int) param[var][0] + 1;
00494 overFlow = GetTH1FromMonitorElement(h_1D[var])->GetBinContent(overFlowBin);
00495 GetTH1FromMonitorElement(h_1D[var])->SetBinContent(overFlowBin, overFlow + 1);
00496 }
00497 }
00498
00499 }
00500
00501 TH1* MuonIsolationDQM::GetTH1FromMonitorElement(MonitorElement* me) {
00502 return me->getTH1();
00503 }
00504
00505
00506 DEFINE_FWK_MODULE(MuonIsolationDQM);