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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "ElectroWeakAnalysis/WENu/interface/WenuPlots.h"
00046
00047 WenuPlots::WenuPlots(const edm::ParameterSet& iConfig)
00048
00049 {
00051
00053
00055
00056
00057
00058 wenuCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>
00059 ("wenuCollectionTag");
00060
00061
00062
00063 std::string outputFile_D = "histos.root";
00064 outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile",
00065 outputFile_D);
00066
00067
00068
00069 trackIso_EB_ = iConfig.getUntrackedParameter<Double_t>("trackIso_EB");
00070 ecalIso_EB_ = iConfig.getUntrackedParameter<Double_t>("ecalIso_EB");
00071 hcalIso_EB_ = iConfig.getUntrackedParameter<Double_t>("hcalIso_EB");
00072
00073 trackIso_EE_ = iConfig.getUntrackedParameter<Double_t>("trackIso_EE");
00074 ecalIso_EE_ = iConfig.getUntrackedParameter<Double_t>("ecalIso_EE");
00075 hcalIso_EE_ = iConfig.getUntrackedParameter<Double_t>("hcalIso_EE");
00076
00077 sihih_EB_ = iConfig.getUntrackedParameter<Double_t>("sihih_EB");
00078 dphi_EB_ = iConfig.getUntrackedParameter<Double_t>("dphi_EB");
00079 deta_EB_ = iConfig.getUntrackedParameter<Double_t>("deta_EB");
00080 hoe_EB_ = iConfig.getUntrackedParameter<Double_t>("hoe_EB");
00081 userIso_EB_ = iConfig.getUntrackedParameter<Double_t>("userIso_EB", 1000.);
00082
00083 sihih_EE_ = iConfig.getUntrackedParameter<Double_t>("sihih_EE");
00084 dphi_EE_ = iConfig.getUntrackedParameter<Double_t>("dphi_EE");
00085 deta_EE_ = iConfig.getUntrackedParameter<Double_t>("deta_EE");
00086 hoe_EE_ = iConfig.getUntrackedParameter<Double_t>("hoe_EE");
00087 userIso_EE_ = iConfig.getUntrackedParameter<Double_t>("userIso_EE", 1000.);
00088
00089 trackIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("trackIso_EB_inv",
00090 false);
00091 ecalIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIso_EB_inv",
00092 false);
00093 hcalIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIso_EB_inv",
00094 false);
00095
00096 trackIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("trackIso_EE_inv",
00097 false);
00098 ecalIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIso_EE_inv",
00099 false);
00100 hcalIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIso_EE_inv",
00101 false);
00102
00103
00104 sihih_EB_inv = iConfig.getUntrackedParameter<Bool_t>("sihih_EB_inv",
00105 false);
00106 dphi_EB_inv = iConfig.getUntrackedParameter<Bool_t>("dphi_EB_inv",
00107 false);
00108 deta_EB_inv = iConfig.getUntrackedParameter<Bool_t>("deta_EB_inv",
00109 false);
00110 hoe_EB_inv = iConfig.getUntrackedParameter<Bool_t>("hoe_EB_inv",
00111 false);
00112 userIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("userIso_EB_inv",
00113 false);
00114
00115 sihih_EE_inv = iConfig.getUntrackedParameter<Bool_t>("sihih_EE_inv",
00116 false);
00117 dphi_EE_inv = iConfig.getUntrackedParameter<Bool_t>("dphi_EE_inv",
00118 false);
00119 deta_EE_inv = iConfig.getUntrackedParameter<Bool_t>("deta_EE_inv",
00120 false);
00121 hoe_EE_inv = iConfig.getUntrackedParameter<Bool_t>("hoe_EE_inv",
00122 false);
00123 userIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("userIso_EE_inv",
00124 false);
00125
00126 }
00127
00128
00129
00130 WenuPlots::~WenuPlots()
00131 {
00132
00133
00134
00135
00136 }
00137
00138
00139
00140
00141
00142
00143
00144 void
00145 WenuPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& es)
00146 {
00147 using namespace std;
00148
00149
00150
00151 edm::Handle<pat::CompositeCandidateCollection> WenuCands;
00152 iEvent.getByLabel(wenuCollectionTag_, WenuCands);
00153
00154 if (not WenuCands.isValid()) {
00155 cout << "Warning: no wenu candidates in this event..." << endl;
00156 return;
00157 }
00158
00159
00160 const pat::CompositeCandidateCollection *wcands = WenuCands.product();
00161 const pat::CompositeCandidateCollection::const_iterator
00162 wenuIter = wcands->begin();
00163 const pat::CompositeCandidate wenu = *wenuIter;
00164
00165
00166 const pat::Electron * myElec=
00167 dynamic_cast<const pat::Electron*> (wenu.daughter("electron"));
00168 const pat::MET * myMet=
00169 dynamic_cast<const pat::MET*> (wenu.daughter("met"));
00170
00171 double scEta = myElec->superCluster()->eta();
00172 double scPhi = myElec->superCluster()->phi();
00173 double scEt = myElec->superCluster()->energy()/cosh(scEta);
00174 double met = myMet->et();
00175 double metPhi = myMet->phi();
00176 double mt = sqrt(2.0*scEt*met*(1.0-(cos(scPhi)*cos(metPhi)+sin(scPhi)*sin(metPhi))));
00177
00178 double trackIso = myElec->userIsolation(pat::TrackIso);
00179 double ecalIso = myElec->userIsolation(pat::EcalIso);
00180 double hcalIso = myElec->userIsolation(pat::HcalIso);
00181 double sihih = myElec->scSigmaIEtaIEta();
00182 double dphi = myElec->deltaPhiSuperClusterTrackAtVtx();
00183 double deta = myElec->deltaEtaSuperClusterTrackAtVtx();
00184 double HoE = myElec->hadronicOverEm();
00185
00186
00187
00188
00189
00190
00191
00192
00193 if (CheckCutsInverse(myElec)){
00194
00195 h_met_inverse->Fill(met);
00196 h_mt_inverse->Fill(mt);
00197 if(fabs(scEta)<1.479){
00198 h_met_inverse_EB->Fill(met);
00199 h_mt_inverse_EB->Fill(mt);
00200 }
00201 if(fabs(scEta)>1.479){
00202 h_met_inverse_EE->Fill(met);
00203 h_mt_inverse_EE->Fill(mt);
00204 }
00205 }
00206
00207
00209
00210
00211 if ( fabs(scEta) < 1.479) {
00212
00213 if (CheckCutsNminusOne(myElec, 0))
00214 h_trackIso_eb_NmOne->Fill(trackIso);
00215 }
00216 else {
00217 if (CheckCutsNminusOne(myElec, 0))
00218 h_trackIso_ee_NmOne->Fill(trackIso);
00219 }
00220
00221 if (not CheckCuts(myElec)) return;
00223
00224 h_met->Fill(met);
00225 h_mt->Fill(mt);
00226 if(fabs(scEta)<1.479){
00227 h_met_EB->Fill(met);
00228 h_mt_EB->Fill(mt);
00229
00230 h_EB_trkiso->Fill( trackIso );
00231 h_EB_ecaliso->Fill( ecalIso );
00232 h_EB_hcaliso->Fill( hcalIso );
00233 h_EB_sIetaIeta->Fill( sihih );
00234 h_EB_dphi->Fill( dphi );
00235 h_EB_deta->Fill( deta );
00236 h_EB_HoE->Fill( HoE );
00237
00238 }
00239 if(fabs(scEta)>1.479){
00240 h_met_EE->Fill(met);
00241 h_mt_EE->Fill(mt);
00242
00243 h_EE_trkiso->Fill( trackIso );
00244 h_EE_ecaliso->Fill( ecalIso );
00245 h_EE_hcaliso->Fill( hcalIso );
00246 h_EE_sIetaIeta->Fill( sihih );
00247 h_EE_dphi->Fill( dphi );
00248 h_EE_deta->Fill( deta );
00249 h_EE_HoE->Fill( HoE );
00250
00251 }
00252
00253
00254
00255 h_scEt->Fill(scEt);
00256 h_scEta->Fill(scEta);
00257 h_scPhi->Fill(scPhi);
00258
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 bool WenuPlots::CheckCuts( const pat::Electron *ele)
00277 {
00278 for (int i=0; i<nBarrelVars_; ++i) {
00279 if (not CheckCut(ele, i)) return false;
00280 }
00281 return true;
00282 }
00284
00285 bool WenuPlots::CheckCutsInverse(const pat::Electron *ele)
00286 {
00287 for (int i=0; i<nBarrelVars_; ++i){
00288 if ( CheckCutInv(ele, i) == false) return false;
00289 }
00290 return true;
00291
00292 }
00294 bool WenuPlots::CheckCutsNminusOne(const pat::Electron *ele, int jj)
00295 {
00296 for (int i=0; i<nBarrelVars_; ++i){
00297 if (i==jj) continue;
00298 if ( CheckCut(ele, i) == false) return false;
00299 }
00300 return true;
00301 }
00303 bool WenuPlots::CheckCut(const pat::Electron *ele, int i) {
00304 double fabseta = fabs(ele->superCluster()->eta());
00305 if ( fabseta<1.479) {
00306 return fabs(ReturnCandVar(ele, i)) < CutVars_[i];
00307 }
00308 return fabs(ReturnCandVar(ele, i)) < CutVars_[i+nBarrelVars_];
00309 }
00311 bool WenuPlots::CheckCutInv(const pat::Electron *ele, int i) {
00312 double fabseta = fabs(ele->superCluster()->eta());
00313 if ( fabseta<1.479) {
00314 if (InvVars_[i])
00315 return fabs(ReturnCandVar(ele, i))>CutVars_[i];
00316 return fabs(ReturnCandVar(ele, i)) < CutVars_[i];
00317 }
00318 if (InvVars_[i+nBarrelVars_]) {
00319 if (InvVars_[i])
00320 return fabs(ReturnCandVar(ele, i))>CutVars_[i+nBarrelVars_];
00321 }
00322 return fabs(ReturnCandVar(ele, i)) < CutVars_[i+nBarrelVars_];
00323 }
00325 double WenuPlots::ReturnCandVar(const pat::Electron *ele, int i) {
00326 if (i==0) return ele->userIsolation(pat::TrackIso);
00327 else if (i==1) return ele->userIsolation(pat::EcalIso);
00328 else if (i==2) return ele->userIsolation(pat::HcalIso);
00329 else if (i==3) return ele->scSigmaIEtaIEta();
00330 else if (i==4) return ele->deltaPhiSuperClusterTrackAtVtx();
00331 else if (i==5) return ele->deltaEtaSuperClusterTrackAtVtx();
00332 else if (i==6) return ele->hadronicOverEm();
00333 else if (i==7) return ele->userIsolation(pat::User1Iso);
00334 std::cout << "Error in WenuPlots::ReturnCandVar" << std::endl;
00335 return -1.;
00336
00337 }
00339
00340
00341 void
00342 WenuPlots::beginJob()
00343 {
00344
00345
00346
00347
00348
00349 h_met = new TH1F("h_met", "h_met", 200, 0, 200);
00350 h_met_inverse = new TH1F("h_met_inverse", "h_met_inverse", 200, 0, 200);
00351
00352 h_mt = new TH1F("h_mt", "h_mt", 200, 0, 200);
00353 h_mt_inverse = new TH1F("h_mt_inverse", "h_mt_inverse", 200, 0, 200);
00354
00355
00356 h_met_EB = new TH1F("h_met_EB", "h_met_EB", 200, 0, 200);
00357 h_met_inverse_EB = new TH1F("h_met_inverse_EB", "h_met_inverse_EB", 200, 0, 200);
00358
00359 h_mt_EB = new TH1F("h_mt_EB", "h_mt_EB", 200, 0, 200);
00360 h_mt_inverse_EB = new TH1F("h_mt_inverse_EB", "h_mt_inverse_EB", 200, 0, 200);
00361
00362
00363 h_met_EE = new TH1F("h_met_EE", "h_met_EE", 200, 0, 200);
00364 h_met_inverse_EE = new TH1F("h_met_inverse_EE", "h_met_inverse_EE", 200, 0, 200);
00365
00366 h_mt_EE = new TH1F("h_mt_EE", "h_mt_EE", 200, 0, 200);
00367 h_mt_inverse_EE = new TH1F("h_mt_inverse_EE", "h_mt_inverse_EE", 200, 0, 200);
00368
00369
00370 h_scEt = new TH1F("h_scEt", "h_scEt", 200, 0, 100);
00371 h_scEta = new TH1F("h_scEta", "h_scEta", 200, -3, 3);
00372 h_scPhi = new TH1F("h_scPhi", "h_scPhi", 200, -4, 4);
00373
00374
00375
00376
00377 h_EB_trkiso = new TH1F("h_EB_trkiso","h_EB_trkiso",200 , 0.0, 9.0);
00378 h_EB_ecaliso = new TH1F("h_EB_ecaliso","h_EB_ecaliso",200, 0.0 , 9.0);
00379 h_EB_hcaliso = new TH1F("h_EB_hcaliso","h_EB_hcaliso",200, 0.0 , 9.0);
00380 h_EB_sIetaIeta = new TH1F("h_EB_sIetaIeta","h_EB_sIetaIeta",200, 0.0 , 0.02 );
00381 h_EB_dphi = new TH1F("h_EB_dphi","h_EB_dphi",200, -0.03 , 0.03 );
00382 h_EB_deta = new TH1F("h_EB_deta","h_EB_deta",200, -0.01 , 0.01) ;
00383 h_EB_HoE = new TH1F("h_EB_HoE","h_EB_HoE",200, 0.0 , 0.2 );
00384
00385 h_EE_trkiso = new TH1F("h_EE_trkiso","h_EE_trkiso",200 , 0.0, 9.0);
00386 h_EE_ecaliso = new TH1F("h_EE_ecaliso","h_EE_ecaliso",200, 0.0 , 9.0);
00387 h_EE_hcaliso = new TH1F("h_EE_hcaliso","h_EE_hcaliso",200, 0.0 , 9.0);
00388 h_EE_sIetaIeta = new TH1F("h_EE_sIetaIeta","h_EE_sIetaIeta",200, 0.0 , 0.1 );
00389 h_EE_dphi = new TH1F("h_EE_dphi","h_EE_dphi",200, -0.03 , 0.03 );
00390 h_EE_deta = new TH1F("h_EE_deta","h_EE_deta",200, -0.01 , 0.01) ;
00391 h_EE_HoE = new TH1F("h_EE_HoE","h_EE_HoE",200, 0.0 , 0.2 );
00392
00393
00394
00395
00396 h_trackIso_eb_NmOne =
00397 new TH1F("h_trackIso_eb_NmOne","trackIso EB N-1 plot",80,0,8);
00398 h_trackIso_ee_NmOne =
00399 new TH1F("h_trackIso_ee_NmOne","trackIso EE N-1 plot",80,0,8);
00400
00401
00402
00403 nBarrelVars_ = 8;
00404
00405
00406
00407
00408 CutVars_.push_back( trackIso_EB_ );
00409 CutVars_.push_back( ecalIso_EB_ );
00410 CutVars_.push_back( hcalIso_EB_ );
00411 CutVars_.push_back( sihih_EB_ );
00412 CutVars_.push_back( dphi_EB_ );
00413 CutVars_.push_back( deta_EB_ );
00414 CutVars_.push_back( hoe_EB_ );
00415 CutVars_.push_back( userIso_EB_ );
00416
00417 CutVars_.push_back( trackIso_EE_);
00418 CutVars_.push_back( ecalIso_EE_);
00419 CutVars_.push_back( hcalIso_EE_);
00420 CutVars_.push_back( sihih_EE_);
00421 CutVars_.push_back( dphi_EE_);
00422 CutVars_.push_back( deta_EE_);
00423 CutVars_.push_back( hoe_EE_ );
00424 CutVars_.push_back( userIso_EE_ );
00425
00426 InvVars_.push_back( trackIso_EB_inv);
00427 InvVars_.push_back( ecalIso_EB_inv);
00428 InvVars_.push_back( hcalIso_EB_inv);
00429 InvVars_.push_back( sihih_EB_inv);
00430 InvVars_.push_back( dphi_EB_inv);
00431 InvVars_.push_back( deta_EB_inv);
00432 InvVars_.push_back( hoe_EB_inv);
00433 InvVars_.push_back( userIso_EB_inv);
00434
00435 InvVars_.push_back( trackIso_EE_inv);
00436 InvVars_.push_back( ecalIso_EE_inv);
00437 InvVars_.push_back( hcalIso_EE_inv);
00438 InvVars_.push_back( sihih_EE_inv);
00439 InvVars_.push_back( dphi_EE_inv);
00440 InvVars_.push_back( deta_EE_inv);
00441 InvVars_.push_back( hoe_EE_inv);
00442 InvVars_.push_back( userIso_EE_inv);
00443
00444
00445
00446 }
00447
00448
00449 void
00450 WenuPlots::endJob() {
00451 TFile * newfile = new TFile(TString(outputFile_),"RECREATE");
00452 h_met->Write();
00453 h_met_inverse->Write();
00454 h_mt->Write();
00455 h_mt_inverse->Write();
00456
00457 h_met_EB->Write();
00458 h_met_inverse_EB->Write();
00459 h_mt_EB->Write();
00460 h_mt_inverse_EB->Write();
00461
00462 h_met_EE->Write();
00463 h_met_inverse_EE->Write();
00464 h_mt_EE->Write();
00465 h_mt_inverse_EE->Write();
00466
00467 h_scEt->Write();
00468 h_scEta->Write();
00469 h_scPhi->Write();
00470
00471 h_EB_trkiso->Write();
00472 h_EB_ecaliso->Write();
00473 h_EB_hcaliso->Write();
00474 h_EB_sIetaIeta->Write();
00475 h_EB_dphi->Write();
00476 h_EB_deta->Write();
00477 h_EB_HoE->Write();
00478
00479 h_EE_trkiso->Write();
00480 h_EE_ecaliso->Write();
00481 h_EE_hcaliso->Write();
00482 h_EE_sIetaIeta->Write();
00483 h_EE_dphi->Write();
00484 h_EE_deta->Write();
00485 h_EE_HoE->Write();
00486
00487
00488 h_trackIso_eb_NmOne->Write();
00489 h_trackIso_ee_NmOne->Write();
00490
00491 newfile->Close();
00492
00493 }
00494
00495
00496
00497 DEFINE_FWK_MODULE(WenuPlots);