CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQMOffline/Trigger/src/HLTTauDQML1Plotter.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/HLTTauDQML1Plotter.h"
00002 
00003 HLTTauDQML1Plotter::HLTTauDQML1Plotter( const edm::ParameterSet& ps, int etbins, int etabins, int phibins, double maxpt, bool ref, double dr, std::string dqmBaseFolder ) {
00004     //Initialize Plotter
00005     name_ = "HLTTauDQML1Plotter";
00006     
00007     //Process PSet
00008     try {
00009         triggerTag_       = ps.getUntrackedParameter<std::string>("DQMFolder");
00010         triggerTagAlias_  = ps.getUntrackedParameter<std::string>("Alias","");
00011         l1ExtraTaus_      = ps.getParameter<edm::InputTag>("L1Taus");
00012         l1ExtraJets_      = ps.getParameter<edm::InputTag>("L1Jets");
00013         l1ExtraElectrons_ = ps.getParameter<edm::InputTag>("L1Electrons");
00014         l1ExtraMuons_     = ps.getParameter<edm::InputTag>("L1Muons");
00015         doRefAnalysis_    = ref;
00016         dqmBaseFolder_    = dqmBaseFolder;
00017         matchDeltaR_      = dr;
00018         maxEt_            = maxpt;
00019         binsEt_           = etbins;
00020         binsEta_          = etabins;
00021         binsPhi_          = phibins;
00022         validity_         = true;
00023     } catch ( cms::Exception &e ) {
00024         edm::LogInfo("HLTTauDQML1Plotter::HLTTauDQML1Plotter") << e.what() << std::endl;
00025         validity_ = false;
00026         return;
00027     }
00028     
00029     if (store_) {
00030         //Create the histograms
00031         store_->setCurrentFolder(triggerTag());
00032         store_->removeContents();
00033         
00034         l1tauEt_ = store_->book1D("L1TauEt","L1 #tau E_{T};L1 #tau E_{T};entries",binsEt_,0,maxEt_);
00035         l1tauEta_ = store_->book1D("L1TauEta","L1 #tau #eta;L1 #tau #eta;entries",binsEta_,-2.5,2.5);
00036         l1tauPhi_ = store_->book1D("L1TauPhi","L1 #tau #phi;L1 #tau #phi;entries",binsPhi_,-3.2,3.2);
00037         
00038         l1jetEt_ = store_->book1D("L1JetEt","L1 jet E_{T};L1 Central Jet E_{T};entries",binsEt_,0,maxEt_);
00039         l1jetEta_ = store_->book1D("L1JetEta","L1 jet #eta;L1 Central Jet #eta;entries",binsEta_,-2.5,2.5);
00040         l1jetPhi_ = store_->book1D("L1JetPhi","L1 jet #phi;L1 Central Jet #phi;entries",binsPhi_,-3.2,3.2);
00041         
00042         inputEvents_ = store_->book1D("InputEvents","Events Read;;entries",2,0,2);
00043         
00044         l1electronEt_ = store_->book1D("L1ElectronEt","L1 electron E_{T};L1 e/#gamma  E_{T};entries",binsEt_,0,maxEt_);
00045         l1electronEta_ = store_->book1D("L1ElectronEta","L1 electron #eta;L1 e/#gamma  #eta;entries",binsEta_,-2.5,2.5);
00046         l1electronPhi_ = store_->book1D("L1ElectronPhi","L1 electron #phi;L1 e/#gamma  #phi;entries",binsPhi_,-3.2,3.2);
00047         
00048         l1muonEt_ = store_->book1D("L1MuonEt","L1 muon p_{T};L1 #mu p_{T};entries",binsEt_,0,maxEt_);
00049         l1muonEta_ = store_->book1D("L1MuonEta","L1 muon #eta;L1 #mu #eta;entries",binsEta_,-2.5,2.5);
00050         l1muonPhi_ = store_->book1D("L1MuonPhi","L1 muon #phi;L1 #mu #phi;entries",binsPhi_,-3.2,3.2);
00051         
00052         l1doubleTauPath_ = store_->book2D("L1DoubleTau","L1 Double Tau Path E_{T};first L1 #tau p_{T};second L1 #tau p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
00053         l1muonTauPath_ = store_->book2D("L1MuonTau","L1 Muon Tau Path E_{T};first L1 #tau p_{T};first L1 #gamma p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
00054         l1electronTauPath_ = store_->book2D("L1ElectronTau","L1 Electron Tau Path E_{T};first L1 #mu p_{T};second L1 #mu p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
00055         
00056         firstTauEt_ = store_->book1D("L1LeadTauEt","L1 lead #tau E_{T}",binsEt_,0,maxEt_);
00057         firstTauEt_->getTH1F()->Sumw2();
00058         
00059         secondTauEt_ = store_->book1D("L1SecondTauEt","L1 second #tau E_{T}",binsEt_,0,maxEt_);
00060         secondTauEt_->getTH1F()->Sumw2();
00061         
00062         if (doRefAnalysis_) {
00063             l1tauEtRes_ = store_->book1D("L1TauEtResol","L1 #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",40,-2,2);
00064             
00065             store_->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
00066             store_->removeContents();
00067             
00068             l1tauEtEffNum_ = store_->book1D("L1TauEtEffNum","L1 #tau E_{T} Efficiency Numerator",binsEt_,0,maxEt_);
00069             l1tauEtEffNum_->getTH1F()->Sumw2();
00070             
00071             l1tauEtEffDenom_ = store_->book1D("L1TauEtEffDenom","L1 #tau E_{T} Denominator",binsEt_,0,maxEt_);
00072             l1tauEtEffDenom_->getTH1F()->Sumw2();
00073             
00074             l1tauEtaEffNum_ = store_->book1D("L1TauEtaEffNum","L1 #tau #eta Efficiency",binsEta_,-2.5,2.5);
00075             l1tauEtaEffNum_->getTH1F()->Sumw2();
00076             
00077             l1tauEtaEffDenom_ = store_->book1D("L1TauEtaEffDenom","L1 #tau #eta Denominator",binsEta_,-2.5,2.5);
00078             l1tauEtaEffDenom_->getTH1F()->Sumw2();
00079             
00080             l1tauPhiEffNum_ = store_->book1D("L1TauPhiEffNum","L1 #tau #phi Efficiency",binsPhi_,-3.2,3.2);
00081             l1tauPhiEffNum_->getTH1F()->Sumw2();
00082             
00083             l1tauPhiEffDenom_ = store_->book1D("L1TauPhiEffDenom","L1 #tau #phi Denominator",binsPhi_,-3.2,3.2);
00084             l1tauPhiEffDenom_->getTH1F()->Sumw2();
00085             
00086             l1jetEtEffNum_ = store_->book1D("L1JetEtEffNum","L1 jet E_{T} Efficiency",binsEt_,0,maxEt_);
00087             l1jetEtEffNum_->getTH1F()->Sumw2();
00088             
00089             l1jetEtEffDenom_ = store_->book1D("L1JetEtEffDenom","L1 jet E_{T} Denominator",binsEt_,0,maxEt_);
00090             l1jetEtEffDenom_->getTH1F()->Sumw2();
00091             
00092             l1jetEtaEffNum_ = store_->book1D("L1JetEtaEffNum","L1 jet #eta Efficiency",binsEta_,-2.5,2.5);
00093             l1jetEtaEffNum_->getTH1F()->Sumw2();
00094             
00095             l1jetEtaEffDenom_ = store_->book1D("L1JetEtaEffDenom","L1 jet #eta Denominator",binsEta_,-2.5,2.5);
00096             l1jetEtaEffDenom_->getTH1F()->Sumw2();
00097             
00098             l1jetPhiEffNum_ = store_->book1D("L1JetPhiEffNum","L1 jet #phi Efficiency",binsPhi_,-3.2,3.2);
00099             l1jetPhiEffNum_->getTH1F()->Sumw2();
00100             
00101             l1jetPhiEffDenom_ = store_->book1D("L1JetPhiEffDenom","L1 jet #phi Denominator",binsPhi_,-3.2,3.2);
00102             l1jetPhiEffDenom_->getTH1F()->Sumw2();
00103         }
00104     }
00105 }
00106 
00107 HLTTauDQML1Plotter::~HLTTauDQML1Plotter() {
00108 }
00109 
00110 //
00111 // member functions
00112 //
00113 
00114 void HLTTauDQML1Plotter::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::map<int,LVColl>& refC ) {
00115     LVColl refTaus, refElectrons, refMuons;
00116     
00117     if ( doRefAnalysis_ ) {
00118         std::map<int,LVColl>::const_iterator iref;
00119 
00120         //Tau reference
00121         iref = refC.find(15);
00122         if ( iref != refC.end() ) refTaus = iref->second;
00123         
00124         //Electron reference
00125         iref = refC.find(11);
00126         if ( iref != refC.end() ) refElectrons = iref->second;
00127         
00128         //Muon reference
00129         iref = refC.find(13);
00130         if ( iref != refC.end() ) refMuons = iref->second;
00131         
00132         for ( LVColl::const_iterator iter = refTaus.begin(); iter != refTaus.end(); ++iter ) {
00133             l1tauEtEffDenom_->Fill(iter->pt());
00134             l1jetEtEffDenom_->Fill(iter->pt());
00135             
00136             l1tauEtaEffDenom_->Fill(iter->eta());
00137             l1jetEtaEffDenom_->Fill(iter->eta());
00138             
00139             l1tauPhiEffDenom_->Fill(iter->phi());
00140             l1jetPhiEffDenom_->Fill(iter->phi());
00141         }
00142     }
00143     
00144     //Analyze L1 Objects (Tau+Jets)
00145     edm::Handle<l1extra::L1JetParticleCollection> taus;
00146     edm::Handle<l1extra::L1JetParticleCollection> jets;
00147     edm::Handle<l1extra::L1EmParticleCollection> electrons;
00148     edm::Handle<l1extra::L1MuonParticleCollection> muons;
00149     
00150     LVColl pathTaus;
00151     LVColl pathMuons;
00152     LVColl pathElectrons;
00153     
00154     //Set Variables for the threshold plot
00155     LVColl l1taus;
00156     LVColl l1electrons;
00157     LVColl l1muons;
00158     LVColl l1jets;
00159 
00160     bool gotL1Taus = iEvent.getByLabel(l1ExtraTaus_,taus) && taus.isValid();
00161     bool gotL1Jets = iEvent.getByLabel(l1ExtraJets_,jets) && jets.isValid();
00162     bool gotL1Electrons = iEvent.getByLabel(l1ExtraElectrons_,electrons) && electrons.isValid();
00163     bool gotL1Muons = iEvent.getByLabel(l1ExtraMuons_,muons) && muons.isValid();
00164     
00165     if ( gotL1Taus ) {
00166         if ( taus->size() > 0 ) {
00167             if ( !doRefAnalysis_ ) {
00168                 firstTauEt_->Fill((*taus)[0].pt());
00169                 if ( taus->size() > 1 ) secondTauEt_->Fill((*taus)[0].pt());
00170             }
00171             for ( l1extra::L1JetParticleCollection::const_iterator i = taus->begin(); i != taus->end(); ++i ) {
00172                 l1taus.push_back(i->p4());
00173                 if ( !doRefAnalysis_ ) {
00174                     l1tauEt_->Fill(i->et());
00175                     l1tauEta_->Fill(i->eta());
00176                     l1tauPhi_->Fill(i->phi());
00177                     pathTaus.push_back(i->p4());
00178                 }
00179             }
00180         }
00181     }
00182     if ( gotL1Jets ) {
00183         if ( jets->size() > 0 ) {
00184             for( l1extra::L1JetParticleCollection::const_iterator i = jets->begin(); i != jets->end(); ++i ) {  
00185                 l1jets.push_back(i->p4());
00186                 if ( !doRefAnalysis_ ) {
00187                     l1jetEt_->Fill(i->et());
00188                     l1jetEta_->Fill(i->eta());
00189                     l1jetPhi_->Fill(i->phi());
00190                     pathTaus.push_back(i->p4());
00191                 }
00192             }
00193         }
00194     }
00195     if ( gotL1Electrons ) {
00196         if( electrons->size() > 0 ) {
00197             for ( l1extra::L1EmParticleCollection::const_iterator i = electrons->begin(); i != electrons->end(); ++i ) {
00198                 l1electrons.push_back(i->p4());
00199                 l1electronEt_->Fill(i->et());
00200                 l1electronEta_->Fill(i->eta());
00201                 l1electronPhi_->Fill(i->phi());
00202                 pathElectrons.push_back(i->p4());
00203             }
00204         }
00205     }
00206     if ( gotL1Muons ) {
00207         if ( muons->size() > 0 ) {
00208             for ( l1extra::L1MuonParticleCollection::const_iterator i = muons->begin(); i != muons->end(); ++i ) {
00209                 l1muons.push_back(i->p4());
00210                 l1muonEt_->Fill(i->et());
00211                 l1muonEta_->Fill(i->eta());
00212                 l1muonPhi_->Fill(i->phi());
00213                 pathMuons.push_back(i->p4());
00214             }
00215         }
00216     }
00217     
00218     //Now do the efficiency matching
00219     if ( doRefAnalysis_ ) {
00220         for ( LVColl::const_iterator i = refTaus.begin(); i != refTaus.end(); ++i ) {
00221             std::pair<bool,LV> m = match(*i,l1taus,matchDeltaR_);
00222             if ( m.first ) {
00223                 l1tauEt_->Fill(m.second.pt());
00224                 l1tauEta_->Fill(m.second.eta());
00225                 l1tauPhi_->Fill(m.second.phi());
00226                 l1tauEtEffNum_->Fill(i->pt());
00227                 l1tauEtaEffNum_->Fill(i->eta());
00228                 l1tauPhiEffNum_->Fill(i->phi());
00229                 l1tauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
00230                 pathTaus.push_back(m.second);
00231             }
00232         }
00233         
00234         for ( LVColl::const_iterator i = refTaus.begin(); i != refTaus.end(); ++i ) {
00235             std::pair<bool,LV> m = match(*i,l1jets,matchDeltaR_);
00236             if ( m.first ) {
00237                 l1jetEt_->Fill(m.second.pt());
00238                 l1jetEta_->Fill(m.second.eta());
00239                 l1jetPhi_->Fill(m.second.phi());
00240                 l1jetEtEffNum_->Fill(i->pt());
00241                 l1jetEtaEffNum_->Fill(i->eta());
00242                 l1jetPhiEffNum_->Fill(i->phi());
00243             }
00244         }
00245         
00246         for ( LVColl::const_iterator i = refElectrons.begin(); i != refElectrons.end(); ++i ) {
00247             std::pair<bool,LV> m = match(*i,l1electrons,matchDeltaR_);
00248             if( m.first ) {
00249                 l1electronEt_->Fill(m.second.pt());
00250                 l1electronEta_->Fill(m.second.eta());
00251                 l1electronPhi_->Fill(m.second.phi());
00252                 pathElectrons.push_back(m.second);
00253             }
00254         }
00255         
00256         for ( LVColl::const_iterator i = refMuons.begin(); i != refMuons.end(); ++i ) {
00257             std::pair<bool,LV> m = match(*i,l1muons,matchDeltaR_);
00258             if ( m.first ) {
00259                 l1muonEt_->Fill(m.second.pt());
00260                 l1muonEta_->Fill(m.second.eta());
00261                 l1muonPhi_->Fill(m.second.phi());
00262                 pathMuons.push_back(m.second);
00263             }
00264         }
00265     }
00266     
00267     
00268     //Fill the Threshold Monitoring
00269     if(pathTaus.size() > 1) std::sort(pathTaus.begin(),pathTaus.end(),ptSort);
00270     if(pathElectrons.size() > 1) std::sort(pathElectrons.begin(),pathElectrons.end(),ptSort);
00271     if(pathMuons.size() > 1) std::sort(pathMuons.begin(),pathMuons.end(),ptSort);
00272     
00273     if ( pathTaus.size() > 0 ) {
00274         firstTauEt_->Fill(pathTaus[0].pt());
00275         inputEvents_->Fill(0.5);
00276     }
00277     if ( pathTaus.size() > 1 ) {
00278         secondTauEt_->Fill(pathTaus[1].pt());
00279         inputEvents_->Fill(1.5);
00280     }
00281     if ( pathTaus.size() >= 2 ) {
00282         l1doubleTauPath_->Fill(pathTaus[0].pt(),pathTaus[1].pt());
00283     }
00284     if ( pathTaus.size() >= 1 && pathElectrons.size() >= 1 ) {
00285         l1electronTauPath_->Fill(pathTaus[0].pt(),pathElectrons[0].pt());
00286     }
00287     if ( pathTaus.size() >= 1 && pathMuons.size() >= 1 ) {
00288         l1muonTauPath_->Fill(pathTaus[0].pt(),pathMuons[0].pt());
00289     }
00290 }