Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:37

0001 #include "DQMOffline/Trigger/interface/EgHLTEleHLTFilterMon.h"
0002 #include "DQMOffline/Trigger/interface/EgHLTEgCutCodes.h"
0003 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
0004 #include "DQMOffline/Trigger/interface/EgHLTBinData.h"
0005 #include "DQMOffline/Trigger/interface/EgHLTCutMasks.h"
0006 
0007 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0008 
0009 #include "DataFormats/Math/interface/deltaR.h"
0010 
0011 using namespace egHLT;
0012 
0013 EleHLTFilterMon::EleHLTFilterMon(MonElemFuncs& monElemFuncs,
0014                                  const std::string& filterName,
0015                                  TrigCodes::TrigBitSet filterBit,
0016                                  const BinData& bins,
0017                                  const CutMasks& masks,
0018                                  bool doHEP)
0019     : filterName_(filterName), filterBit_(filterBit), doHEP_(doHEP) {
0020   bool doChargeSep = false;
0021   bool monHLTFailedEle = false;
0022   bool doFakeRate = false;
0023   bool doTagAndProbe = false;
0024   bool doN1andSingleEffs = false;
0025   std::string histname = "egamma";
0026 
0027   eleMonElems_.push_back(new MonElemContainer<OffEle>());
0028   //---Morse-------
0029   //eleMonElems_.push_back(new MonElemContainer<OffEle>("_cut"," cut, debug hists ",new EgHLTDQMVarCut<OffEle>(~0x0,&OffEle::cutCode)));
0030   //-----------------
0031   if (doChargeSep) {
0032     eleMonElems_.push_back(new MonElemContainer<OffEle>("_posCharge", " q=+1 ", new ChargeCut<OffEle>(1)));
0033     eleMonElems_.push_back(new MonElemContainer<OffEle>("_negCharge", " q=-1 ", new ChargeCut<OffEle>(-1)));
0034   }
0035 
0036   for (auto& eleMonElem : eleMonElems_) {
0037     if (doHEP_) {
0038       monElemFuncs.initStdEleHistsHEP(
0039           eleMonElem->monElems(), filterName, histname + "_passFilter" + eleMonElem->name(), bins);
0040     } else {
0041       monElemFuncs.initStdEleHists(
0042           eleMonElem->monElems(), filterName, filterName_ + "_gsfEle_passFilter" + eleMonElem->name(), bins);
0043     }
0044   }
0045   if (monHLTFailedEle) {
0046     eleFailMonElems_.push_back(new MonElemContainer<OffEle>());
0047     if (doChargeSep) {
0048       eleFailMonElems_.push_back(new MonElemContainer<OffEle>("_posCharge", " q=+1 ", new ChargeCut<OffEle>(1)));
0049       eleFailMonElems_.push_back(new MonElemContainer<OffEle>("_negCharge", " q=-1 ", new ChargeCut<OffEle>(-1)));
0050     }
0051   }
0052   for (size_t i = 0; i < eleFailMonElems_.size(); i++) {
0053     if (doHEP_) {
0054       monElemFuncs.initStdEleHistsHEP(
0055           eleMonElems_[i]->monElems(), filterName, histname + "_passFilter" + eleMonElems_[i]->name(), bins);
0056     } else {
0057       monElemFuncs.initStdEleHists(eleFailMonElems_[i]->monElems(),
0058                                    filterName,
0059                                    filterName_ + "_gsfEle_failFilter" + eleMonElems_[i]->name(),
0060                                    bins);
0061     }
0062   }
0063 
0064   int effProbeCutCode = masks.probeEle;
0065   int effTagCutCode = masks.stdEle;
0066   int fakeRateProbeCut = masks.fakeEle;
0067   eleEffHists_.push_back(new MonElemContainer<OffEle>());
0068   if (doTagAndProbe)
0069     eleEffHists_.push_back(new MonElemContainer<OffEle>(
0070         "_tagProbe",
0071         " Tag and Probe ",
0072         new EgTagProbeCut<OffEle>(effProbeCutCode, &OffEle::cutCode, effTagCutCode, &OffEle::cutCode)));
0073   if (doFakeRate)
0074     eleEffHists_.push_back(new MonElemContainer<OffEle>(
0075         "_fakeRate", " Fake Rate ", new EgJetTagProbeCut<OffEle>(fakeRateProbeCut, &OffEle::looseCutCode)));
0076   if (doN1andSingleEffs) {
0077     for (auto& eleEffHist : eleEffHists_) {
0078       monElemFuncs.initStdEffHists(eleEffHist->cutMonElems(),
0079                                    filterName,
0080                                    filterName_ + "_gsfEle_effVsEt" + eleEffHist->name(),
0081                                    bins.et,
0082                                    &OffEle::et,
0083                                    masks);
0084       monElemFuncs.initStdEffHists(eleEffHist->cutMonElems(),
0085                                    filterName,
0086                                    filterName_ + "_gsfEle_effVsEta" + eleEffHist->name(),
0087                                    bins.eta,
0088                                    &OffEle::eta,
0089                                    masks);
0090       /*  monElemFuncs.initStdEffHists(eleEffHists_[i]->cutMonElems(),filterName,
0091       filterName_+"_gsfEle_effVsPhi"+eleEffHists_[i]->name(),bins.phi,&OffEle::phi,masks); */
0092       // monElemFuncs.initStdEffHists(eleEffHists_[i]->cutMonElems(),filterName,
0093       //              filterName_+"_gsfEle_effVsCharge"+eleEffHists_[i]->name(),bins.charge,&OffEle::chargeF);
0094     }
0095   }
0096   if (!doHEP_) {
0097     typedef MonElemManager<ParticlePair<OffEle>, float> DiEleMon;
0098     diEleMassBothME_ = new DiEleMon(monElemFuncs.getIB(),
0099                                     filterName_ + "_diEle_bothPassFilter_mass",
0100                                     filterName_ + "_diEle_bothPassFilter Mass;M_{ee} (GeV/c^{2})",
0101                                     bins.mass.nr,
0102                                     bins.mass.min,
0103                                     bins.mass.max,
0104                                     &ParticlePair<OffEle>::mass);
0105     diEleMassOnlyOneME_ = new DiEleMon(monElemFuncs.getIB(),
0106                                        filterName_ + "_diEle_onlyOnePass Filter_mass",
0107                                        filterName_ + "_diEle_onlyOnePassFilter Mass;M_{ee} (GeV/c^{2})",
0108                                        bins.mass.nr,
0109                                        bins.mass.min,
0110                                        bins.mass.max,
0111                                        &ParticlePair<OffEle>::mass);
0112 
0113     diEleMassBothHighME_ = new DiEleMon(monElemFuncs.getIB(),
0114                                         filterName_ + "_diEle_bothPassFilter_massHigh",
0115                                         filterName_ + "_diEle_bothPassFilter Mass;M_{ee} (GeV/c^{2})",
0116                                         bins.massHigh.nr,
0117                                         bins.massHigh.min,
0118                                         bins.massHigh.max,
0119                                         &ParticlePair<OffEle>::mass);
0120     diEleMassOnlyOneHighME_ = new DiEleMon(monElemFuncs.getIB(),
0121                                            filterName_ + "_diEle_onlyOnePassFilter_massHigh",
0122                                            filterName_ + "_diEle_onlyOnePassFilter Mass;M_{ee} (GeV/c^{2})",
0123                                            bins.massHigh.nr,
0124                                            bins.massHigh.min,
0125                                            bins.massHigh.max,
0126                                            &ParticlePair<OffEle>::mass);
0127   }
0128 }
0129 
0130 EleHLTFilterMon::~EleHLTFilterMon() {
0131   for (auto& eleMonElem : eleMonElems_)
0132     delete eleMonElem;
0133   for (auto& eleFailMonElem : eleFailMonElems_)
0134     delete eleFailMonElem;
0135   for (auto& eleEffHist : eleEffHists_)
0136     delete eleEffHist;
0137   if (!doHEP_) {
0138     delete diEleMassBothME_;
0139     delete diEleMassOnlyOneME_;
0140     delete diEleMassBothHighME_;
0141     delete diEleMassOnlyOneHighME_;
0142   }
0143 }
0144 
0145 void EleHLTFilterMon::fill(const OffEvt& evt, float weight) {
0146   for (size_t eleNr = 0; eleNr < evt.eles().size(); eleNr++) {
0147     const OffEle& ele = evt.eles()[eleNr];
0148     if ((ele.trigBits() & filterBit_) != 0) {  //ele passes
0149       for (auto& eleMonElem : eleMonElems_)
0150         eleMonElem->fill(ele, evt, weight);
0151       for (auto& eleEffHist : eleEffHists_)
0152         eleEffHist->fill(ele, evt, weight);
0153     } else {  //ele didnt pass trigger
0154       for (auto& eleFailMonElem : eleFailMonElems_)
0155         eleFailMonElem->fill(ele, evt, weight);
0156     }
0157   }  //end loop over electrons
0158 
0159   if ((evt.evtTrigBits() & filterBit_) != 0) {
0160     for (size_t ele1Nr = 0; ele1Nr < evt.eles().size(); ele1Nr++) {
0161       for (size_t ele2Nr = ele1Nr + 1; ele2Nr < evt.eles().size(); ele2Nr++) {
0162         const OffEle& ele1 = evt.eles()[ele1Nr];
0163         const OffEle& ele2 = evt.eles()[ele2Nr];
0164         if (!doHEP_) {
0165           if ((ele1.trigBits() & ele2.trigBits() & filterBit_) == filterBit_) {
0166             diEleMassBothME_->fill(ParticlePair<OffEle>(ele1, ele2), weight);
0167             diEleMassBothHighME_->fill(ParticlePair<OffEle>(ele1, ele2), weight);
0168           } else if ((ele1.trigBits() & filterBit_) == filterBit_ || (ele2.trigBits() & filterBit_) == filterBit_) {
0169             diEleMassOnlyOneME_->fill(ParticlePair<OffEle>(ele1, ele2), weight);
0170             diEleMassOnlyOneHighME_->fill(ParticlePair<OffEle>(ele1, ele2), weight);
0171           }
0172         }
0173       }  //end inner ele loop
0174     }    //end outer ele loop
0175   }      //end check if filter is present
0176 }