Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:00

0001 #include "DQM/L1TMonitorClient/interface/L1TStage2CaloLayer2DEClientSummary.h"
0002 
0003 L1TStage2CaloLayer2DEClientSummary::L1TStage2CaloLayer2DEClientSummary(const edm::ParameterSet &ps)
0004     : monitor_dir_(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0005       hlSummary(nullptr),
0006       jetSummary(nullptr),
0007       egSummary(nullptr),
0008       tauSummary(nullptr),
0009       sumSummary(nullptr) {}
0010 
0011 L1TStage2CaloLayer2DEClientSummary::~L1TStage2CaloLayer2DEClientSummary() {}
0012 
0013 void L1TStage2CaloLayer2DEClientSummary::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker,
0014                                                                DQMStore::IGetter &igetter,
0015                                                                const edm::LuminosityBlock &lumiSeg,
0016                                                                const edm::EventSetup &c) {
0017   book(ibooker);
0018   processHistograms(igetter);
0019 }
0020 
0021 void L1TStage2CaloLayer2DEClientSummary::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0022   book(ibooker);
0023   processHistograms(igetter);
0024 }
0025 
0026 void L1TStage2CaloLayer2DEClientSummary::book(DQMStore::IBooker &ibooker) {
0027   ibooker.setCurrentFolder(monitor_dir_);
0028   if (hlSummary == nullptr) {
0029     hlSummary = ibooker.book1D("High level summary", "Event by event comparison summary", 5, 1, 6);
0030     hlSummary->setBinLabel(1, "good events");
0031     hlSummary->setBinLabel(2, "good jets");
0032     hlSummary->setBinLabel(3, "good e/gs");
0033     hlSummary->setBinLabel(4, "good taus");
0034     hlSummary->setBinLabel(5, "good sums");
0035   } else {
0036     hlSummary->Reset();
0037   }
0038 
0039   if (jetSummary == nullptr) {
0040     jetSummary = ibooker.book1D("Jet Agreement Summary", "Jet Agreement Summary", 4, 1, 5);
0041     jetSummary->setBinLabel(1, "good jets");
0042     jetSummary->setBinLabel(2, "jets pos off only");
0043     jetSummary->setBinLabel(3, "jets Et off only ");
0044     jetSummary->setBinLabel(4, "jets qual off only ");
0045   } else {
0046     jetSummary->Reset();
0047   }
0048 
0049   if (egSummary == nullptr) {
0050     egSummary = ibooker.book1D("EG Agreement Summary", "EG Agreement Summary", 7, 1, 8);
0051     egSummary->setBinLabel(1, "good non-iso e/gs");
0052     egSummary->setBinLabel(2, "non-iso e/gs pos off");
0053     egSummary->setBinLabel(3, "non-iso e/gs Et off");
0054     egSummary->setBinLabel(4, "good iso e/gs");
0055     egSummary->setBinLabel(5, "iso e/gs pos off");
0056     egSummary->setBinLabel(6, "iso e/gs Et off");
0057     egSummary->setBinLabel(7, "e/gs Iso off");
0058   } else {
0059     egSummary->Reset();
0060   }
0061 
0062   if (tauSummary == nullptr) {
0063     tauSummary = ibooker.book1D("Tau Agreement Summary", "Tau Agremeent Summary", 7, 1, 8);
0064     tauSummary->setBinLabel(1, "good non-iso taus");
0065     tauSummary->setBinLabel(2, "non-iso taus pos off");
0066     tauSummary->setBinLabel(3, "non-iso taus Et off");
0067     tauSummary->setBinLabel(4, "good iso taus");
0068     tauSummary->setBinLabel(5, "iso taus pos off");
0069     tauSummary->setBinLabel(6, "iso taus Et off");
0070     tauSummary->setBinLabel(7, "taus Iso off");
0071   } else {
0072     tauSummary->Reset();
0073   }
0074 
0075   if (sumSummary == nullptr) {
0076     sumSummary = ibooker.book1D("Energy Sum Agreement Summary", "Sum Agreement Summary", 9, 1, 10);
0077     sumSummary->setBinLabel(1, "good sums");
0078     sumSummary->setBinLabel(2, "good ETT sums");
0079     sumSummary->setBinLabel(3, "good HTT sums");
0080     sumSummary->setBinLabel(4, "good MET sums");
0081     sumSummary->setBinLabel(5, "good MHT sums");
0082     sumSummary->setBinLabel(6, "good MBHF sums");
0083     sumSummary->setBinLabel(7, "good TowCount sums");
0084     sumSummary->setBinLabel(8, "good AsymCount sums");
0085     sumSummary->setBinLabel(9, "good CentrCount sums");
0086   } else {
0087     sumSummary->Reset();
0088   }
0089 }
0090 
0091 void L1TStage2CaloLayer2DEClientSummary::processHistograms(DQMStore::IGetter &igetter) {
0092   // get reference to relevant summary MonitorElement instances
0093   // - high level summary
0094   // - eg agreement summary
0095   // - energy sum agreement summary
0096   // - jet agreement summary
0097   // - tau agreement summary
0098 
0099   MonitorElement *hlSummary_ = igetter.get(monitor_dir_ + "/expert/CaloL2 Object Agreement Summary");
0100   MonitorElement *jetSummary_ = igetter.get(monitor_dir_ + "/expert/Jet Agreement Summary");
0101   MonitorElement *egSummary_ = igetter.get(monitor_dir_ + "/expert/EG Agreement Summary");
0102   MonitorElement *tauSummary_ = igetter.get(monitor_dir_ + "/expert/Tau Agreement Summary");
0103   MonitorElement *sumSummary_ = igetter.get(monitor_dir_ + "/expert/Energy Sum Agreement Summary");
0104 
0105   // check for existance of object
0106   if (hlSummary_) {
0107     // by default show 0% agreement (for edge case when no objects are found)
0108     double evtRatio = 0, jetRatio = 0, egRatio = 0, tauRatio = 0, sumRatio = 0;
0109 
0110     double totalEvents = hlSummary_->getBinContent(1);
0111     double goodEvents = hlSummary_->getBinContent(2);
0112     double totalJets = hlSummary_->getBinContent(3);
0113     double goodJets = hlSummary_->getBinContent(4);
0114     double totalEg = hlSummary_->getBinContent(5);
0115     double goodEg = hlSummary_->getBinContent(6);
0116     double totalTau = hlSummary_->getBinContent(7);
0117     double goodTau = hlSummary_->getBinContent(8);
0118     double totalSums = hlSummary_->getBinContent(9);
0119     double goodSums = hlSummary_->getBinContent(10);
0120 
0121     if (totalEvents != 0)
0122       evtRatio = goodEvents / totalEvents;
0123 
0124     if (totalJets != 0)
0125       jetRatio = goodJets / totalJets;
0126 
0127     if (totalEg != 0)
0128       egRatio = goodEg / totalEg;
0129 
0130     if (totalTau != 0)
0131       tauRatio = goodTau / totalTau;
0132 
0133     if (totalSums != 0)
0134       sumRatio = goodSums / totalSums;
0135 
0136     hlSummary->setBinContent(1, evtRatio);
0137     hlSummary->setBinContent(2, jetRatio);
0138     hlSummary->setBinContent(3, egRatio);
0139     hlSummary->setBinContent(4, tauRatio);
0140     hlSummary->setBinContent(5, sumRatio);
0141   }
0142 
0143   if (jetSummary_) {
0144     // by default show 0% agreement (for edge case when no objects are found)
0145     double goodRatio = 0, posOffRatio = 0, etOffRatio = 0, qualOffRatio = 0;
0146 
0147     double totalJets = jetSummary_->getBinContent(1);
0148     double goodJets = jetSummary_->getBinContent(2);
0149     double jetPosOff = jetSummary_->getBinContent(3);
0150     double jetEtOff = jetSummary_->getBinContent(4);
0151     double jetQualOff = jetSummary_->getBinContent(5);
0152 
0153     if (totalJets != 0) {
0154       goodRatio = goodJets / totalJets;
0155       posOffRatio = jetPosOff / totalJets;
0156       etOffRatio = jetEtOff / totalJets;
0157       qualOffRatio = jetQualOff / totalJets;
0158     }
0159 
0160     jetSummary->setBinContent(1, goodRatio);
0161     jetSummary->setBinContent(2, posOffRatio);
0162     jetSummary->setBinContent(3, etOffRatio);
0163     jetSummary->setBinContent(4, qualOffRatio);
0164   }
0165 
0166   if (egSummary_) {
0167     // by default show 0% agreement (for edge case when no objects are found)
0168     double goodEgRatio = 0, egPosOffRatio = 0, egEtOffRatio = 0, goodIsoEgRatio = 0, isoEgPosOffRatio = 0,
0169            isoEgEtOffRatio = 0, egIsoOffRatio = 0;
0170 
0171     double totalEgs = egSummary_->getBinContent(1);
0172     double goodEgs = egSummary_->getBinContent(2);
0173     double egPosOff = egSummary_->getBinContent(3);
0174     double egEtOff = egSummary_->getBinContent(4);
0175 
0176     double totalIsoEgs = egSummary_->getBinContent(5);
0177     double goodIsoEgs = egSummary_->getBinContent(6);
0178     double isoEgPosOff = egSummary_->getBinContent(7);
0179     double isoEgEtOff = egSummary_->getBinContent(8);
0180 
0181     double egIsoOff = egSummary_->getBinContent(9);
0182 
0183     if (totalEgs != 0) {
0184       goodEgRatio = goodEgs / totalEgs;
0185       egPosOffRatio = egPosOff / totalEgs;
0186       egEtOffRatio = egEtOff / totalEgs;
0187     }
0188 
0189     if (totalIsoEgs != 0) {
0190       goodIsoEgRatio = goodIsoEgs / totalIsoEgs;
0191       isoEgPosOffRatio = isoEgPosOff / totalIsoEgs;
0192       isoEgEtOffRatio = isoEgEtOff / totalIsoEgs;
0193     }
0194 
0195     if ((totalEgs + totalIsoEgs) > 0)
0196       egIsoOffRatio = egIsoOff / (totalEgs + totalIsoEgs);
0197 
0198     egSummary->setBinContent(1, goodEgRatio);
0199     egSummary->setBinContent(2, egPosOffRatio);
0200     egSummary->setBinContent(3, egEtOffRatio);
0201 
0202     egSummary->setBinContent(4, goodIsoEgRatio);
0203     egSummary->setBinContent(5, isoEgPosOffRatio);
0204     egSummary->setBinContent(6, isoEgEtOffRatio);
0205 
0206     egSummary->setBinContent(7, egIsoOffRatio);
0207   }
0208 
0209   if (tauSummary_) {
0210     // by default show 0% agreement (for edge case when no objects are found)
0211     double goodTauRatio = 0, tauPosOffRatio = 0, tauEtOffRatio = 0, goodIsoTauRatio = 0, isoTauPosOffRatio = 0,
0212            isoTauEtOffRatio = 0, tauIsoOffRatio = 0;
0213 
0214     double totalTaus = tauSummary_->getBinContent(1);
0215     double goodTaus = tauSummary_->getBinContent(2);
0216     double tauPosOff = tauSummary_->getBinContent(3);
0217     double tauEtOff = tauSummary_->getBinContent(4);
0218 
0219     double totalIsoTaus = tauSummary_->getBinContent(5);
0220     double goodIsoTaus = tauSummary_->getBinContent(6);
0221     double isoTauPosOff = tauSummary_->getBinContent(7);
0222     double isoTauEtOff = tauSummary_->getBinContent(8);
0223 
0224     double tauIsoOff = tauSummary_->getBinContent(9);
0225 
0226     if (totalTaus != 0) {
0227       goodTauRatio = goodTaus / totalTaus;
0228       tauPosOffRatio = tauPosOff / totalTaus;
0229       tauEtOffRatio = tauEtOff / totalTaus;
0230     }
0231 
0232     if (totalIsoTaus != 0) {
0233       goodIsoTauRatio = goodIsoTaus / totalIsoTaus;
0234       isoTauPosOffRatio = isoTauPosOff / totalIsoTaus;
0235       isoTauEtOffRatio = isoTauEtOff / totalIsoTaus;
0236     }
0237 
0238     if ((totalTaus + totalIsoTaus) > 0)
0239       tauIsoOffRatio = tauIsoOff / (totalTaus + totalIsoTaus);
0240 
0241     tauSummary->setBinContent(1, goodTauRatio);
0242     tauSummary->setBinContent(2, tauPosOffRatio);
0243     tauSummary->setBinContent(3, tauEtOffRatio);
0244 
0245     tauSummary->setBinContent(4, goodIsoTauRatio);
0246     tauSummary->setBinContent(5, isoTauPosOffRatio);
0247     tauSummary->setBinContent(6, isoTauEtOffRatio);
0248 
0249     tauSummary->setBinContent(7, tauIsoOffRatio);
0250   }
0251 
0252   if (sumSummary_) {
0253     // by default show 0% agreement (for edge case when no objects are found)
0254     double goodSumRatio = 0, goodETTRatio = 0, goodHTTRatio = 0, goodMETRatio = 0, goodMHTRatio = 0, goodMBHFRatio = 0,
0255            goodTowCountRatio = 0, goodAsymCountRatio = 0, goodCentrCountRatio = 0;
0256 
0257     double totalSums = sumSummary_->getBinContent(1);
0258     double goodSums = sumSummary_->getBinContent(2);
0259     double totalETT = sumSummary_->getBinContent(3);
0260     double goodETT = sumSummary_->getBinContent(4);
0261     double totalHTT = sumSummary_->getBinContent(5);
0262     double goodHTT = sumSummary_->getBinContent(6);
0263     double totalMET = sumSummary_->getBinContent(7);
0264     double goodMET = sumSummary_->getBinContent(8);
0265     double totalMHT = sumSummary_->getBinContent(9);
0266     double goodMHT = sumSummary_->getBinContent(10);
0267     double totalMBHF = sumSummary_->getBinContent(11);
0268     double goodMBHF = sumSummary_->getBinContent(12);
0269     double totalTowCount = sumSummary_->getBinContent(13);
0270     double goodTowCount = sumSummary_->getBinContent(14);
0271     double totalAsymCount = sumSummary_->getBinContent(15);
0272     double goodAsymCount = sumSummary_->getBinContent(16);
0273     double totalCentrCount = sumSummary_->getBinContent(17);
0274     double goodCentrCount = sumSummary_->getBinContent(18);
0275     if (totalSums)
0276       goodSumRatio = goodSums / totalSums;
0277 
0278     if (totalETT)
0279       goodETTRatio = goodETT / totalETT;
0280 
0281     if (totalHTT)
0282       goodHTTRatio = goodHTT / totalHTT;
0283 
0284     if (totalMET)
0285       goodMETRatio = goodMET / totalMET;
0286 
0287     if (totalMHT)
0288       goodMHTRatio = goodMHT / totalMHT;
0289 
0290     if (totalMBHF)
0291       goodMBHFRatio = goodMBHF / totalMBHF;
0292 
0293     if (totalTowCount)
0294       goodTowCountRatio = goodTowCount / totalTowCount;
0295 
0296     if (totalAsymCount)
0297       goodAsymCountRatio = goodAsymCount / totalAsymCount;
0298 
0299     if (totalCentrCount)
0300       goodCentrCountRatio = goodCentrCount / totalCentrCount;
0301 
0302     sumSummary->setBinContent(1, goodSumRatio);
0303     sumSummary->setBinContent(2, goodETTRatio);
0304     sumSummary->setBinContent(3, goodHTTRatio);
0305     sumSummary->setBinContent(4, goodMETRatio);
0306     sumSummary->setBinContent(5, goodMHTRatio);
0307     sumSummary->setBinContent(6, goodMBHFRatio);
0308     sumSummary->setBinContent(7, goodTowCountRatio);
0309     sumSummary->setBinContent(8, goodAsymCountRatio);
0310     sumSummary->setBinContent(9, goodCentrCountRatio);
0311   }
0312 }