CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

HLTTauDQMLitePathPlotter Class Reference

#include <HLTTauDQMLitePathPlotter.h>

Inheritance diagram for HLTTauDQMLitePathPlotter:
HLTTauDQMPlotter

List of all members.

Classes

class  LVSorter

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &, const std::map< int, LVColl > &)
 HLTTauDQMLitePathPlotter (const edm::ParameterSet &, int, int, int, double, bool, double, std::string)
const std::string name ()
 ~HLTTauDQMLitePathPlotter ()

Private Member Functions

void endJob ()
LVColl getFilterCollection (size_t, int, const trigger::TriggerEvent &)
LVColl getObjectCollection (int, const trigger::TriggerEvent &)

Private Attributes

MonitorElementaccepted_events
MonitorElementaccepted_events_matched
int binsEt_
int binsEta_
int binsPhi_
bool doRefAnalysis_
std::vector
< HLTTauDQMPlotter::FilterObject
filterObjs_
std::vector< edm::ParameterSetfilters_
std::map< std::string,
MonitorElement * > 
mass_distribution
double matchDeltaR_
double maxEt_
double minEt_
MonitorElementref_events
double refLeptonPt_
double refTauPt_
MonitorElementtauEt
MonitorElementtauEta
MonitorElementtauEtaEffDenom
MonitorElementtauEtaEffNum
MonitorElementtauEtEffDenom
MonitorElementtauEtEffNum
MonitorElementtauPhi
MonitorElementtauPhiEffDenom
MonitorElementtauPhiEffNum
edm::InputTag triggerEvent_
 InputTag of TriggerEventWithRefs to analyze.

Detailed Description

Definition at line 15 of file HLTTauDQMLitePathPlotter.h.


Constructor & Destructor Documentation

HLTTauDQMLitePathPlotter::HLTTauDQMLitePathPlotter ( const edm::ParameterSet ps,
int  etbins,
int  etabins,
int  phibins,
double  maxpt,
bool  ref,
double  dr,
std::string  dqmBaseFolder 
)

Definition at line 3 of file HLTTauDQMLitePathPlotter.cc.

References accepted_events, accepted_events_matched, binsEt_, binsEta_, binsPhi_, DQMStore::book1D(), doRefAnalysis_, HLTTauDQMPlotter::dqmBaseFolder_, alignCSCRings::e, filterObjs_, filters_, MonitorElement::getTH1F(), edm::ParameterSet::getUntrackedParameter(), HLTTauDQMPlotter::FilterObject::isValid(), gen::k, mass_distribution, matchDeltaR_, maxEt_, HLTTauDQMPlotter::name_, ref_events, refLeptonPt_, refTauPt_, DQMStore::removeContents(), MonitorElement::setBinLabel(), DQMStore::setCurrentFolder(), HLTTauDQMPlotter::store_, tauEt, tauEta, tauEtaEffDenom, tauEtaEffNum, tauEtEffDenom, tauEtEffNum, tauPhi, tauPhiEffDenom, tauPhiEffNum, tmp, triggerEvent_, HLTTauDQMPlotter::triggerTag(), HLTTauDQMPlotter::triggerTag_, HLTTauDQMPlotter::triggerTagAlias_, HLTTauDQMPlotter::validity_, and cms::Exception::what().

                                                                                                                                                                                {
    //Initialize Plotter
    name_ = "HLTTauDQMLitePathPlotter";
    
    //Process PSet
    try {
        triggerEvent_    = ps.getUntrackedParameter<edm::InputTag>("TriggerEventObject");
        triggerTag_      = ps.getUntrackedParameter<std::string>("DQMFolder");
        triggerTagAlias_ = ps.getUntrackedParameter<std::string>("Alias","");
        filters_         = ps.getUntrackedParameter<std::vector<edm::ParameterSet> >("Filters");        
        refTauPt_        = ps.getUntrackedParameter<double>("refTauPt",20);
        refLeptonPt_     = ps.getUntrackedParameter<double>("refLeptonPt",15);
        doRefAnalysis_   = ref;
        dqmBaseFolder_   = dqmBaseFolder;
        matchDeltaR_     = dr;
        maxEt_           = maxpt;
        binsEt_          = etbins;
        binsEta_         = etabins;
        binsPhi_         = phibins;
        validity_        = true;
    } catch ( cms::Exception &e ) {
        edm::LogInfo("HLTTauDQMLitePathPlotter::HLTTauDQMLitePathPlotter") << e.what() << std::endl;
        validity_ = false;
        return;
    }
    
    for ( std::vector<edm::ParameterSet>::const_iterator iter = filters_.begin(); iter != filters_.end(); ++iter ) {
        HLTTauDQMPlotter::FilterObject tmp(*iter);
        if (tmp.isValid()) filterObjs_.push_back(tmp);
    }
    
    if (store_) {
        //Create the histograms
        store_->setCurrentFolder(triggerTag());
        store_->removeContents();
        
        accepted_events = store_->book1D("PathTriggerBits","Accepted Events per Path;;entries",filterObjs_.size(),0,filterObjs_.size());
        
        for ( size_t k = 0; k < filterObjs_.size(); ++k ) {
            accepted_events->setBinLabel(k+1,filterObjs_[k].getAlias(),1);
            if ( filterObjs_[k].getNTriggeredTaus() >= 2 || (filterObjs_[k].getNTriggeredTaus() >= 1 && filterObjs_[k].getNTriggeredLeptons() >= 1) ) { 
                mass_distribution.insert(std::make_pair(filterObjs_[k].getAlias(), store_->book1D(("mass_"+filterObjs_[k].getAlias()).c_str(),("Mass Distribution for "+filterObjs_[k].getAlias()).c_str(),100,0,500))); 
            }
        }
        
        if (doRefAnalysis_) {
            accepted_events_matched = store_->book1D("MatchedPathTriggerBits","Accepted+Matched Events per Path;;entries",filterObjs_.size(),0,filterObjs_.size());
            accepted_events_matched->getTH1F()->Sumw2();
            
            for ( size_t k = 0; k < filterObjs_.size(); ++k ) {
                accepted_events_matched->setBinLabel(k+1,filterObjs_[k].getAlias(),1);
            }
            ref_events = store_->book1D("RefEvents","Reference Events per Path",filterObjs_.size(),0,filterObjs_.size());
            ref_events->getTH1F()->Sumw2();
            
            for ( size_t k = 0; k < filterObjs_.size(); ++k ) {
                ref_events->setBinLabel(k+1,filterObjs_[k].getAlias(),1);
            }
        }
        
        tauEt = store_->book1D("TrigTauEt","#tau E_{t}",binsEt_,0,maxEt_);
        tauEta = store_->book1D("TrigTauEta","#tau #eta",binsEta_,-2.5,2.5);
        tauPhi = store_->book1D("TrigTauPhi","#tau #phi",binsPhi_,-3.2,3.2);
        
        if (doRefAnalysis_) {
            store_->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
            store_->removeContents();
            
            tauEtEffNum = store_->book1D("TrigTauEtEffNum","#tau E_{T} Efficiency",binsEt_,0,maxEt_);
            tauEtEffNum->getTH1F()->Sumw2();
            
            tauEtEffDenom = store_->book1D("TrigTauEtEffDenom","#tau E_{T} Denominator",binsEt_,0,maxEt_);
            tauEtEffDenom->getTH1F()->Sumw2();
            
            tauEtaEffNum = store_->book1D("TrigTauEtaEffNum","#tau #eta Efficiency",binsEta_,-2.5,2.5);
            tauEtaEffNum->getTH1F()->Sumw2();
            
            tauEtaEffDenom = store_->book1D("TrigTauEtaEffDenom","#tau #eta Denominator",binsEta_,-2.5,2.5);
            tauEtaEffDenom->getTH1F()->Sumw2();
            
            tauPhiEffNum = store_->book1D("TrigTauPhiEffNum","#tau #phi Efficiency",binsPhi_,-3.2,3.2);
            tauPhiEffNum->getTH1F()->Sumw2();
            
            tauPhiEffDenom = store_->book1D("TrigTauPhiEffDenom","#tau #phi Denominator",binsPhi_,-3.2,3.2);
            tauPhiEffDenom->getTH1F()->Sumw2();
        }
    }
}
HLTTauDQMLitePathPlotter::~HLTTauDQMLitePathPlotter ( )

Definition at line 92 of file HLTTauDQMLitePathPlotter.cc.

                                                    {
}

Member Function Documentation

void HLTTauDQMLitePathPlotter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const std::map< int, LVColl > &  refC 
)

Definition at line 99 of file HLTTauDQMLitePathPlotter.cc.

References accepted_events, accepted_events_matched, doRefAnalysis_, MonitorElement::Fill(), filterObjs_, edm::Event::getByLabel(), getFilterCollection(), i, edm::HandleBase::isValid(), j, EgammaValidation_Wenu_cff::leptons, mass_distribution, HLTTauDQMPlotter::match(), matchDeltaR_, ref_events, refLeptonPt_, refTauPt_, tauEt, tauEta, tauEtaEffDenom, tauEtaEffNum, tauEtEffDenom, tauEtEffNum, tauPhi, tauPhiEffDenom, tauPhiEffNum, and triggerEvent_.

                                                                                                                            {
    std::vector<bool> isGoodReferenceEvent;
    
    LV highestRefTau(0.,0.,0.,0.0001);
    LVColl triggeredTaus, refTaus, refElectrons, refMuons;
    
    std::map<int,LVColl>::const_iterator iref;
    
    //Tau reference
    iref = refC.find(15);
    if ( iref != refC.end() ) {
        for ( LVColl::const_iterator lvi = iref->second.begin(); lvi != iref->second.end(); ++lvi ) {
            if ( lvi->Et() > highestRefTau.pt() ) {
                highestRefTau = *lvi;
            }
        }
    }
        
    //Fill ref collection for the filters
    if (doRefAnalysis_) {
        unsigned int highPtTaus = 0;
        unsigned int highPtElectrons = 0;
        unsigned int highPtMuons = 0;
        
        std::map<int,LVColl>::const_iterator iref;
        
        //Tau reference
        iref = refC.find(15);
        if ( iref != refC.end() ) {
            for ( LVColl::const_iterator lvi = iref->second.begin(); lvi != iref->second.end(); ++lvi ) {
                if ( lvi->Et() > refTauPt_ ) {
                    highPtTaus++;
                }
                refTaus.push_back(*lvi);
            }
        }
        //Electron reference
        iref = refC.find(11);
        if ( iref != refC.end() ) {
            for ( LVColl::const_iterator lvi = iref->second.begin(); lvi != iref->second.end(); ++lvi ) {
                if ( lvi->Et() > refLeptonPt_ ) {
                    highPtElectrons++;
                }
                refElectrons.push_back(*lvi);
            }
        }
        //Muon reference
        iref = refC.find(13);
        if ( iref != refC.end() ) {
            for ( LVColl::const_iterator lvi = iref->second.begin(); lvi != iref->second.end(); ++lvi ) {
                if ( lvi->Et() > refLeptonPt_ ) {
                    highPtMuons++;
                }
                refMuons.push_back(*lvi);
            }
        }
        
        for ( size_t i = 0; i < filterObjs_.size(); ++i ) {
            bool tau_ok = true;
            bool leptons_ok = true;
            
            if ( highPtTaus < filterObjs_[i].getNTriggeredTaus() ) tau_ok = false;
            if ( filterObjs_[i].leptonId() == 11 && highPtElectrons < filterObjs_[i].getNTriggeredLeptons() ) leptons_ok = false;
            if ( filterObjs_[i].leptonId() == 13 && highPtMuons < filterObjs_[i].getNTriggeredLeptons() ) leptons_ok = false;

            if ( tau_ok && leptons_ok ) {
                ref_events->Fill(i+0.5);
                isGoodReferenceEvent.push_back(true);
            } else {
                isGoodReferenceEvent.push_back(false);
            }
        }
    }
    
    //Get the TriggerEvent
    edm::Handle<trigger::TriggerEvent> trigEv;
    bool gotTEV = iEvent.getByLabel(triggerEvent_,trigEv) && trigEv.isValid();
    
    if ( gotTEV ) {
        //Loop through the filters
        for ( size_t i = 0; i < filterObjs_.size(); ++i ) {
            std::map<std::string, MonitorElement*>::iterator thisMassDist = mass_distribution.find(filterObjs_[i].getAlias());
            size_t ID = trigEv->filterIndex(filterObjs_[i].getFilterName());
            if ( ID != trigEv->sizeFilters() ) {
                LVColl leptons = getFilterCollection(ID,filterObjs_[i].getLeptonType(),*trigEv);
                LVColl taus = getFilterCollection(ID,filterObjs_[i].getTauType(),*trigEv);
                
                //If this is the single tau trigger copy the collection for the turn on
                if ( filterObjs_[i].getNTriggeredTaus() == 1 && filterObjs_[i].getNTriggeredLeptons() == 0 ) {
                    triggeredTaus = taus;
                }
                
                //Fired
                if ( leptons.size() >= filterObjs_[i].getNTriggeredLeptons() && taus.size() >= filterObjs_[i].getNTriggeredTaus() ) {
                    accepted_events->Fill(i+0.5);
                    
                    //Now do the matching only though if we have a good reference event
                    if ( doRefAnalysis_ ) {
                        if ( isGoodReferenceEvent.at(i) ) {
                            size_t nT = 0;
                            for ( size_t j = 0; j < taus.size(); ++j ) {
                                if (match(taus[j],refTaus,matchDeltaR_).first) nT++;
                            }
                            size_t nL = 0;
                            for ( size_t j = 0; j < leptons.size(); ++j ) {
                                if (match(leptons[j],refElectrons,matchDeltaR_).first) nL++;
                                if (match(leptons[j],refMuons,matchDeltaR_).first) nL++;
                            }
                            if ( nT >= filterObjs_[i].getNTriggeredTaus() && nL >= filterObjs_[i].getNTriggeredLeptons() ) {
                                accepted_events_matched->Fill(i+0.5);
                                if ( filterObjs_[i].getNTriggeredTaus() >= 2 && refTaus.size() >= 2 ) {
                                    if (thisMassDist != mass_distribution.end()) thisMassDist->second->Fill( (refTaus[0]+refTaus[1]).M() );
                                } else if ( filterObjs_[i].getNTriggeredTaus() >= 1 && filterObjs_[i].getNTriggeredLeptons() >= 1 ) {
                                    if ( filterObjs_[i].leptonId() == 11 && refElectrons.size() >= 1 ) {
                                        if (thisMassDist != mass_distribution.end()) thisMassDist->second->Fill( (refTaus[0]+refElectrons[0]).M() );
                                    }                                 
                                    if ( filterObjs_[i].leptonId() == 13 && refMuons.size() >= 1 ) {
                                        if (thisMassDist != mass_distribution.end()) thisMassDist->second->Fill( (refTaus[0]+refMuons[0]).M() );
                                    }
                                }
                            }
                        }
                    } else {
                        if ( filterObjs_[i].getNTriggeredTaus() >= 2 ) {
                            if (thisMassDist != mass_distribution.end()) thisMassDist->second->Fill( (taus[0]+taus[1]).M() );
                        } else if ( filterObjs_[i].getNTriggeredTaus() >= 1 && filterObjs_[i].getNTriggeredLeptons() >= 1 ) {
                            if (thisMassDist != mass_distribution.end()) thisMassDist->second->Fill( (taus[0]+leptons[0]).M() );
                        }
                    }
                }
            }
        }
        
        //Do the object thing for the highest tau!
        if ( triggeredTaus.size() > 0 ) {
            LV highestTriggeredTau(0.,0.,0.,0.0001);
            for ( unsigned int i = 0; i < triggeredTaus.size(); ++i ) {
                if ( triggeredTaus[i].pt() > highestTriggeredTau.pt() ) {
                    highestTriggeredTau = triggeredTaus[i];
                }
            }
            
            tauEt->Fill(highestTriggeredTau.pt());
            tauEta->Fill(highestTriggeredTau.eta());
            tauPhi->Fill(highestTriggeredTau.phi());
            
            if ( doRefAnalysis_ && highestRefTau.pt() > 5.0 ) {
                tauEtEffDenom->Fill(highestRefTau.pt());
                tauEtaEffDenom->Fill(highestRefTau.eta());
                tauPhiEffDenom->Fill(highestRefTau.phi());
                
                if ( ROOT::Math::VectorUtil::DeltaR(highestRefTau,highestTriggeredTau) < matchDeltaR_ ) {
                    tauEtEffNum->Fill(highestRefTau.pt());
                    tauEtaEffNum->Fill(highestRefTau.eta());
                    tauPhiEffNum->Fill(highestRefTau.phi());
                }
            }
        }
    }
}
void HLTTauDQMLitePathPlotter::endJob ( ) [private]
LVColl HLTTauDQMLitePathPlotter::getFilterCollection ( size_t  index,
int  id,
const trigger::TriggerEvent trigEv 
) [private]

Definition at line 274 of file HLTTauDQMLitePathPlotter.cc.

References a, trigger::TriggerEvent::filterKeys(), trigger::TriggerEvent::getObjects(), i, dbtoconf::out, trigger::TriggerObject::px(), trigger::TriggerObject::py(), trigger::TriggerObject::pz(), trigger::TriggerEvent::sizeFilters(), and mathSSE::sqrt().

Referenced by analyze().

                                                                                                              {
    //Create output collection
    LVColl out;
    //Get all the final trigger objects
    const trigger::TriggerObjectCollection& TOC(trigEv.getObjects());
    
    //Filter index
    if ( index != trigEv.sizeFilters() ) {
        const trigger::Keys& KEYS = trigEv.filterKeys(index);
        for ( size_t i = 0; i < KEYS.size(); ++i ) {
            const trigger::TriggerObject& TO(TOC[KEYS[i]]);
            LV a(TO.px(),TO.py(),TO.pz(),sqrt(TO.px()*TO.px()+TO.py()*TO.py()+TO.pz()*TO.pz()));
            out.push_back(a);
            }
        }
    return out;
}
LVColl HLTTauDQMLitePathPlotter::getObjectCollection ( int  id,
const trigger::TriggerEvent trigEv 
) [private]

Definition at line 260 of file HLTTauDQMLitePathPlotter.cc.

References a, abs, relval_parameters_module::energy, trigger::TriggerEvent::getObjects(), i, errorMatrix2Lands_multiChannel::id, and dbtoconf::out.

                                                                                                {
    trigger::TriggerObjectCollection triggerObjects;
        triggerObjects = trigEv.getObjects();
    
        LVColl out;
        for ( unsigned int i = 0; i < triggerObjects.size(); ++i ) {
        if ( abs(triggerObjects[i].id()) == id ) {
            LV a(triggerObjects[i].px(),triggerObjects[i].py(),triggerObjects[i].pz(),triggerObjects[i].energy());
            out.push_back(a);
        }
    }
        return out;
}
const std::string HLTTauDQMLitePathPlotter::name ( void  ) [inline, virtual]

Implements HLTTauDQMPlotter.

Definition at line 20 of file HLTTauDQMLitePathPlotter.h.

References HLTTauDQMPlotter::name_.

{ return name_; }

Member Data Documentation

Definition at line 47 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 48 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 39 of file HLTTauDQMLitePathPlotter.h.

Referenced by HLTTauDQMLitePathPlotter().

Definition at line 40 of file HLTTauDQMLitePathPlotter.h.

Referenced by HLTTauDQMLitePathPlotter().

Definition at line 41 of file HLTTauDQMLitePathPlotter.h.

Referenced by HLTTauDQMLitePathPlotter().

Definition at line 35 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 33 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 32 of file HLTTauDQMLitePathPlotter.h.

Referenced by HLTTauDQMLitePathPlotter().

Definition at line 51 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 36 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 38 of file HLTTauDQMLitePathPlotter.h.

Referenced by HLTTauDQMLitePathPlotter().

Definition at line 37 of file HLTTauDQMLitePathPlotter.h.

Definition at line 49 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 44 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 43 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 54 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 55 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 63 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 59 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 62 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 58 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 56 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 64 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

Definition at line 60 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().

InputTag of TriggerEventWithRefs to analyze.

Definition at line 29 of file HLTTauDQMLitePathPlotter.h.

Referenced by analyze(), and HLTTauDQMLitePathPlotter().