Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:38

0001 #include <iostream>
0002 
0003 #include "DQMOffline/EGamma/plugins/PhotonDataCertification.h"
0004 #include "FWCore/Framework/interface/Run.h"
0005 #include "RooGlobalFunc.h"
0006 #include "RooRealVar.h"
0007 #include "RooDataSet.h"
0008 #include "RooBreitWigner.h"
0009 #include "RooDataHist.h"
0010 #include "RooFitResult.h"
0011 
0012 /**\class PhotonDataCertification
0013 */
0014 //
0015 // Original Author:  Louis James Antonelli
0016 //         Created:  Thu Jan 22 13:42:28CET 2009
0017 //
0018 
0019 using namespace std;
0020 
0021 PhotonDataCertification::PhotonDataCertification(const edm::ParameterSet& pset)
0022 
0023 {
0024   parameters_ = pset;
0025   verbose_ = parameters_.getParameter<bool>("verbose");
0026 
0027   if (verbose_)
0028     cout << ">>> Constructor (PhotonDataCertification) <<<" << endl;
0029 }
0030 
0031 PhotonDataCertification::~PhotonDataCertification() {}
0032 
0033 // ------------ method called right after a run ends ------------
0034 void PhotonDataCertification::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0035   using namespace RooFit;
0036   if (verbose_)
0037     std::cout << ">>> endJob (PhotonDataCertification) <<<" << std::endl;
0038 
0039   //booking histograms according to naming conventions
0040   ibooker.setCurrentFolder("Egamma/EventInfo/");
0041   reportSummary_ = ibooker.bookFloat("reportSummary");
0042   reportSummaryMap_ = ibooker.book2D("reportSummaryMap", "reportSummaryMap", 3, 0, 3, 1, 0, 1);
0043 
0044   TH2F* reportSummaryMapTH2 = reportSummaryMap_->getTH2F();
0045   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1, "EB");
0046   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2, "EE");
0047   reportSummaryMapTH2->GetXaxis()->SetBinLabel(3, "Total");
0048   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1, "InvMassTest");
0049 
0050   float EBResult = invMassZtest(
0051       "Egamma/stdPhotonAnalyzer/InvMass/h_02_invMassIsoPhotonsEBarrel", "invMassIsolatedPhotonsEB", igetter);
0052 
0053   float EEResult = invMassZtest(
0054       "Egamma/stdPhotonAnalyzer/InvMass/h_03_invMassIsoPhotonsEEndcap", "invMassIsolatedPhotonsEE", igetter);
0055 
0056   float AllResult = invMassZtest(
0057       "Egamma/stdPhotonAnalyzer/InvMass/h_01_invMassAllIsolatedPhotons", "invMassAllIsolatedPhotons", igetter);
0058 
0059   if (verbose_) {
0060     std::cout << "EBResult: " << EBResult << std::endl;
0061     std::cout << "EEResult: " << EEResult << std::endl;
0062     std::cout << "AllResult: " << AllResult << std::endl;
0063   }
0064 
0065   reportSummaryMapTH2->SetBinContent(1, 1, EBResult);
0066   reportSummaryMapTH2->SetBinContent(2, 1, EEResult);
0067   reportSummaryMapTH2->SetBinContent(3, 1, AllResult);
0068   reportSummary_->Fill(AllResult);
0069 }
0070 
0071 float PhotonDataCertification::invMassZtest(string path, TString name, DQMStore::IGetter& igetter) {
0072   float ZMass = 91.2;
0073   float ZWidth = 2.5;
0074   MonitorElement* TestElem = nullptr;
0075   TestElem = igetter.get(path);
0076   if (TestElem == nullptr)
0077     return 0;
0078   TH1F* TestHist = TestElem->getTH1F();
0079   if (TestHist == nullptr)
0080     return 0;
0081   RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
0082   RooRealVar mass("mass", "Mass_{2#gamma}", 0, 200, "GeV");
0083   RooRealVar mRes("M_{Z}", "Z Mass", ZMass, 70, 110);
0084   RooRealVar gamma("#Gamma", "#Gamma", ZWidth, 0, 10.0);
0085   RooBreitWigner BreitWigner("BreitWigner", "Breit-Wigner", mass, mRes, gamma);
0086   RooDataHist test(name, name, mass, TestHist);
0087 
0088   BreitWigner.fitTo(test, RooFit::Range(80, 100), RooFit::PrintLevel(-1000));
0089 
0090   if (std::abs(mRes.getValV() - ZMass) < ZWidth) {
0091     return 1.0;
0092   } else if (std::abs(mRes.getValV() - ZMass) < gamma.getValV()) {
0093     return 0.9;
0094   } else {
0095     return 0.0;
0096   }
0097 }