Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-11 04:32:54

0001 #include <utility>
0002 
0003 #include "DQMOffline/Trigger/interface/EgHLTPhoHLTFilterMon.h"
0004 
0005 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
0006 #include "DQMOffline/Trigger/interface/EgHLTMonElemFuncs.h"
0007 #include "DQMOffline/Trigger/interface/EgHLTBinData.h"
0008 #include "DQMOffline/Trigger/interface/EgHLTCutMasks.h"
0009 
0010 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0011 
0012 #include "DataFormats/Math/interface/deltaR.h"
0013 
0014 using namespace egHLT;
0015 
0016 PhoHLTFilterMon::PhoHLTFilterMon(MonElemFuncs& monElemFuncs,
0017                                  std::string filterName,
0018                                  TrigCodes::TrigBitSet filterBit,
0019                                  const BinData& bins,
0020                                  const CutMasks& masks,
0021                                  bool doHEP)
0022     : filterName_(std::move(filterName)), filterBit_(filterBit), doHEP_(doHEP) {
0023   bool monHLTFailedPho = false;
0024   bool doN1andSingleEffsPho = false;
0025   std::string histname = "egamma";
0026 
0027   phoMonElems_.push_back(new MonElemContainer<OffPho>());
0028   //phoMonElems_.push_back(new MonElemContainer<OffPho>("_cut"," cut, debug hists ",new EgHLTDQMVarCut<OffPho>(~0x0,&OffPho::cutCode)));
0029   for (auto& phoMonElem : phoMonElems_) {
0030     if (doHEP_) {
0031       monElemFuncs.initStdPhoHistsHEP(
0032           phoMonElem->monElems(), filterName_, histname + "_passFilter" + phoMonElem->name(), bins);
0033     } else {
0034       monElemFuncs.initStdPhoHists(
0035           phoMonElem->monElems(), filterName_, filterName_ + "_pho_passFilter" + phoMonElem->name(), bins);
0036     }
0037   }
0038 
0039   if (monHLTFailedPho)
0040     phoFailMonElems_.push_back(new MonElemContainer<OffPho>());
0041 
0042   for (size_t i = 0; i < phoFailMonElems_.size(); i++) {
0043     if (doHEP_) {
0044       monElemFuncs.initStdPhoHistsHEP(
0045           phoFailMonElems_[i]->monElems(), filterName_, histname + "_failFilter" + phoMonElems_[i]->name(), bins);
0046     } else {
0047       monElemFuncs.initStdPhoHists(phoFailMonElems_[i]->monElems(),
0048                                    filterName_,
0049                                    filterName_ + "_pho_failFilter" + phoMonElems_[i]->name(),
0050                                    bins);
0051     }
0052   }
0053   phoEffHists_.push_back(new MonElemContainer<OffPho>());
0054   // phoEffHists_.push_back(new MonElemContainer<OffPho>("_jetTag"," Tag and Probe ",new EgJetB2BCut<OffPho>(-M_PI/12,M_PI/12,0.3)));
0055   if (doN1andSingleEffsPho) {
0056     for (auto& phoEffHist : phoEffHists_) {
0057       monElemFuncs.initStdEffHists(phoEffHist->cutMonElems(),
0058                                    filterName_,
0059                                    filterName_ + "_pho_effVsEt" + phoEffHist->name(),
0060                                    bins.et,
0061                                    &OffPho::et,
0062                                    masks);
0063       monElemFuncs.initStdEffHists(phoEffHist->cutMonElems(),
0064                                    filterName_,
0065                                    filterName_ + "_pho_effVsEta" + phoEffHist->name(),
0066                                    bins.eta,
0067                                    &OffPho::eta,
0068                                    masks);
0069       /* monElemFuncs.initStdEffHists(phoEffHists_[i]->cutMonElems(),filterName_,
0070      filterName_+"_pho_effVsPhi"+phoEffHists_[i]->name(),bins.phi,&OffPho::phi,masks);*/
0071     }
0072   }
0073   if (!doHEP_) {
0074     typedef MonElemManager<ParticlePair<OffPho>, float> DiPhoMon;
0075     diPhoMassBothME_ = new DiPhoMon(monElemFuncs.getIB(),
0076                                     filterName_ + "_diPho_bothPassFilter_mass",
0077                                     filterName_ + "_diPho_bothPassFilter Mass;M_{#gamma#gamma} (GeV/c^{2})",
0078                                     bins.mass.nr,
0079                                     bins.mass.min,
0080                                     bins.mass.max,
0081                                     &ParticlePair<OffPho>::mass);
0082     diPhoMassOnlyOneME_ = new DiPhoMon(monElemFuncs.getIB(),
0083                                        filterName_ + "_diPho_onlyOnePassFilter_mass",
0084                                        filterName_ + "_diPho_onlyOnePassFilter Mass;M_{#gamma#gamma} (GeV/c^{2})",
0085                                        bins.mass.nr,
0086                                        bins.mass.min,
0087                                        bins.mass.max,
0088                                        &ParticlePair<OffPho>::mass);
0089     diPhoMassBothHighME_ = new DiPhoMon(monElemFuncs.getIB(),
0090                                         filterName_ + "_diPho_bothPassFilter_massHigh",
0091                                         filterName_ + "_diPho_bothPassFilter Mass;M_{#gamma#gamma} (GeV/c^{2})",
0092                                         bins.massHigh.nr,
0093                                         bins.massHigh.min,
0094                                         bins.massHigh.max,
0095                                         &ParticlePair<OffPho>::mass);
0096     diPhoMassOnlyOneHighME_ = new DiPhoMon(monElemFuncs.getIB(),
0097                                            filterName_ + "_diPho_onlyOnePassFilter_massHigh",
0098                                            filterName_ + "_diPho_onlyOnePassFilter Mass;M_{#gamma#gamma} (GeV/c^{2})",
0099                                            bins.massHigh.nr,
0100                                            bins.massHigh.min,
0101                                            bins.massHigh.max,
0102                                            &ParticlePair<OffPho>::mass);
0103   }
0104 }
0105 
0106 PhoHLTFilterMon::~PhoHLTFilterMon() {
0107   for (auto& phoMonElem : phoMonElems_)
0108     delete phoMonElem;
0109   for (auto& phoFailMonElem : phoFailMonElems_)
0110     delete phoFailMonElem;
0111   for (auto& phoEffHist : phoEffHists_)
0112     delete phoEffHist;
0113   if (!doHEP_) {
0114     delete diPhoMassBothME_;
0115     delete diPhoMassOnlyOneME_;
0116     delete diPhoMassBothHighME_;
0117     delete diPhoMassOnlyOneHighME_;
0118   }
0119 }
0120 
0121 void PhoHLTFilterMon::fill(const OffEvt& evt, float weight) {
0122   for (size_t phoNr = 0; phoNr < evt.phos().size(); phoNr++) {
0123     const OffPho& pho = evt.phos()[phoNr];
0124     if ((pho.trigBits() & filterBit_) != 0) {  //pho passes
0125       for (auto& phoMonElem : phoMonElems_)
0126         phoMonElem->fill(pho, evt, weight);
0127       for (auto& phoEffHist : phoEffHists_)
0128         phoEffHist->fill(pho, evt, weight);
0129     } else {  //pho didnt pass trigger
0130       for (auto& phoFailMonElem : phoFailMonElems_)
0131         phoFailMonElem->fill(pho, evt, weight);
0132     }
0133   }  //end loop over photons
0134 
0135   if ((evt.evtTrigBits() & filterBit_) != 0) {
0136     for (size_t pho1Nr = 0; pho1Nr < evt.phos().size(); pho1Nr++) {
0137       for (size_t pho2Nr = pho1Nr + 1; pho2Nr < evt.phos().size(); pho2Nr++) {
0138         const OffPho& pho1 = evt.phos()[pho1Nr];
0139         const OffPho& pho2 = evt.phos()[pho2Nr];
0140         if (!doHEP_) {
0141           if ((pho1.trigBits() & pho2.trigBits() & filterBit_) == filterBit_)
0142             diPhoMassBothME_->fill(ParticlePair<OffPho>(pho1, pho2), weight);
0143           else if ((pho1.trigBits() & filterBit_) == filterBit_ || (pho2.trigBits() & filterBit_) == filterBit_) {
0144             diPhoMassOnlyOneME_->fill(ParticlePair<OffPho>(pho1, pho2), weight);
0145           }
0146         }
0147       }  //end inner pho loop
0148     }  //end outer pho loop
0149   }  //end check if filter is present
0150 }