CMS 3D CMS Logo

HLTTauDQMOfflineSource.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/HLTTauDQMOfflineSource.h"
00002 #include "Math/GenVector/VectorUtil.h"
00003 using namespace std;
00004 using namespace edm;
00005 using namespace trigger;
00006 
00007 
00008 //
00009 // constructors and destructor
00010 //
00011 HLTTauDQMOfflineSource::HLTTauDQMOfflineSource( const edm::ParameterSet& ps ) :counterEvt_(0)
00012 {
00013 
00014   //Get  Monitoring Parameters
00015   mainFolder_             = ps.getParameter < std::string > ("DQMFolder");
00016   monitorName_            = ps.getParameter<string>("monitorName");
00017   outputFile_             = ps.getParameter < std::string > ("outputFile");
00018   prescaleEvt_            = ps.getParameter<int>("prescaleEvt");
00019   disable_                = ps.getParameter < bool > ("disableROOToutput");
00020   verbose_                = ps.getParameter < bool > ("verbose");
00021   nTriggeredTaus_         = ps.getParameter < unsigned > ("NTriggeredTaus");
00022   nTriggeredLeptons_      = ps.getParameter < unsigned > ("NTriggeredLeptons");
00023   leptonPdgID_            = ps.getParameter < int > ("LeptonPDGId");
00024   tauPdgID_               = ps.getParameter < int > ("TauPDGId");
00025   triggerEvent_           = ps.getParameter < edm::InputTag > ("TriggerEvent");
00026   mainPath_               = ps.getParameter<edm::InputTag>("MainFilter");
00027   l1BackupPath_           = ps.getParameter<edm::InputTag>("L1BackupFilter");
00028   l2BackupPath_           = ps.getParameter<edm::InputTag>("L2BackupFilter");
00029   l25BackupPath_          = ps.getParameter<edm::InputTag>("L25BackupFilter");
00030   l3BackupPath_           = ps.getParameter<edm::InputTag>("L3BackupFilter");
00031   refTauObjects_          = ps.getParameter<edm::InputTag>("refTauObjects");
00032   refLeptonObjects_       = ps.getParameter<edm::InputTag>("refLeptonObjects");
00033   corrDeltaR_             = ps.getParameter<double>("matchingDeltaR");
00034   EtMin_                  = ps.getParameter < double > ("HistEtMin");
00035   EtMax_                  = ps.getParameter < double > ("HistEtMax");
00036   NEtBins_                = ps.getParameter < int > ("HistNEtBins");
00037   NEtaBins_               = ps.getParameter < int > ("HistNEtaBins");
00038 
00039 
00040   dbe_ = Service < DQMStore > ().operator->();
00041   dbe_->setVerbose(0);
00042  
00043    if (disable_) {
00044      outputFile_ = "";
00045    }
00046 
00047 
00048 }
00049 
00050 
00051 HLTTauDQMOfflineSource::~HLTTauDQMOfflineSource()
00052 {
00053    
00054   // do anything here that needs to be done at desctruction time
00055   // (e.g. close files, deallocate resources etc.)
00056   
00057 }
00058 
00059 
00060 //--------------------------------------------------------
00061 void 
00062 HLTTauDQMOfflineSource::beginJob(const EventSetup& context)
00063 {
00064    if (dbe_) 
00065      {
00066            dbe_->setCurrentFolder(mainFolder_);
00067          
00068            EventsPassed_ = (dbe_->book1D((monitorName_+"_Bits").c_str(),(monitorName_+"EvtsPassed").c_str(),11,0,11));
00069            EventsPassed_->setAxisTitle("#tau Trigger Paths");
00070            EventsPassed_->setBinLabel(1,"");
00071            EventsPassed_->setBinLabel(2,"Main Path");
00072            EventsPassed_->setBinLabel(3,"");
00073            EventsPassed_->setBinLabel(4,"noL1 Path");
00074            EventsPassed_->setBinLabel(5,"");
00075            EventsPassed_->setBinLabel(6,"no L2 Path");
00076            EventsPassed_->setBinLabel(7,"");
00077            EventsPassed_->setBinLabel(8,"no L25 Path");
00078            EventsPassed_->setBinLabel(9,"");
00079            EventsPassed_->setBinLabel(10,"no L3 Path");
00080            EventsPassed_->setBinLabel(11,"");
00081 
00082            EventsRef_ = (dbe_->book1D((monitorName_+"_Ref").c_str(),(monitorName_+"EvtsRef").c_str(),11,0,11));
00083            EventsRef_->setAxisTitle("#tau Trigger Paths");
00084            EventsRef_->setBinLabel(1,"");
00085            EventsRef_->setBinLabel(2,"Main Path");
00086            EventsRef_->setBinLabel(3,"");
00087            EventsRef_->setBinLabel(4,"noL1 Path");
00088            EventsRef_->setBinLabel(5,"");
00089            EventsRef_->setBinLabel(6,"no L2 Path");
00090            EventsRef_->setBinLabel(7,"");
00091            EventsRef_->setBinLabel(8,"no L25 Path");
00092            EventsRef_->setBinLabel(9,"");
00093            EventsRef_->setBinLabel(10,"no L3 Path");
00094            EventsRef_->setBinLabel(11,"");
00095         
00096            EventsPassedMatched_ = (dbe_->book1D((monitorName_+"_BitsMatched").c_str(),(monitorName_+"EvtsPassedAndMatched").c_str(),11,0,11));
00097            EventsPassedMatched_->setAxisTitle("#tau Trigger Paths");
00098            EventsPassedMatched_->setBinLabel(1,"");
00099            EventsPassedMatched_->setBinLabel(2,"Main Path");
00100            EventsPassedMatched_->setBinLabel(3,"");
00101            EventsPassedMatched_->setBinLabel(4,"Main AND L1 Path");
00102            EventsPassedMatched_->setBinLabel(5,"");
00103            EventsPassedMatched_->setBinLabel(6,"Main AND L2 Path");
00104            EventsPassedMatched_->setBinLabel(7,"");
00105            EventsPassedMatched_->setBinLabel(8,"Main AND L25 Path");
00106            EventsPassedMatched_->setBinLabel(9,"");
00107            EventsPassedMatched_->setBinLabel(10,"Main AND L3 Path");
00108            EventsPassedMatched_->setBinLabel(11,"");
00109 
00110            EventsPassedNotMatched_ = (dbe_->book1D((monitorName_+"_BitsNotMatched").c_str(),(monitorName_+"EvtsPassedAndNotMatched").c_str(),11,0,11));
00111            EventsPassedNotMatched_->setAxisTitle("#tau Trigger Paths");
00112            EventsPassedNotMatched_->setBinLabel(1,"");
00113            EventsPassedNotMatched_->setBinLabel(2,"Main Path");
00114            EventsPassedNotMatched_->setBinLabel(3,"");
00115            EventsPassedNotMatched_->setBinLabel(4,"Main AND L1 Path");
00116            EventsPassedNotMatched_->setBinLabel(5,"");
00117            EventsPassedNotMatched_->setBinLabel(6,"Main AND L2 Path");
00118            EventsPassedNotMatched_->setBinLabel(7,"");
00119            EventsPassedNotMatched_->setBinLabel(8,"Main AND L25 Path");
00120            EventsPassedNotMatched_->setBinLabel(9,"");
00121            EventsPassedNotMatched_->setBinLabel(10,"Main AND L3 Path");
00122            EventsPassedNotMatched_->setBinLabel(11,"");
00123 
00124      }     
00125 
00126         
00127 
00128 }
00129 
00130 //--------------------------------------------------------
00131 void HLTTauDQMOfflineSource::beginRun(const edm::Run& r, const EventSetup& context) {
00132 
00133 }
00134 
00135 //--------------------------------------------------------
00136 void HLTTauDQMOfflineSource::beginLuminosityBlock(const LuminosityBlock& lumiSeg, 
00137                                       const EventSetup& context) {
00138   
00139 }
00140 
00141 // ----------------------------------------------------------
00142 void 
00143 HLTTauDQMOfflineSource::analyze(const Event& iEvent, const EventSetup& iSetup )
00144 {  
00145   //Apply the prescaler
00146   if(counterEvt_ > prescaleEvt_)
00147     {
00148 
00149       //Do Reference Trigger Analysis
00150       bool tau_ok = false;
00151       bool lepton_ok = false;
00152 
00153       if(nTriggeredTaus_ ==0)
00154         tau_ok=true;
00155       if(nTriggeredLeptons_ ==0)
00156         lepton_ok=true;
00157 
00158       //Check Taus
00159       edm::Handle<LVColl> refTauObjects;
00160       if(iEvent.getByLabel(refTauObjects_,refTauObjects))
00161       {
00162         if(refTauObjects->size() >= nTriggeredTaus_)
00163           tau_ok = true;
00164       }
00165 
00166       //CheckLeptons
00167       edm::Handle<LVColl> refLeptonObjects;
00168       if(iEvent.getByLabel(refLeptonObjects_,refLeptonObjects))
00169       {
00170         if(refLeptonObjects->size() >= nTriggeredLeptons_)
00171           lepton_ok = true;
00172       }
00173 
00174       if(tau_ok&&lepton_ok)
00175         {
00176           EventsRef_->Fill(1.5);
00177           EventsRef_->Fill(3.5);
00178           EventsRef_->Fill(5.5);
00179           EventsRef_->Fill(7.5);
00180           EventsRef_->Fill(9.5);
00181 
00182         }
00183 
00184 
00185 
00186       //Do Backup trigger Analysis
00187       //Check if passed Main Filter
00188       bool passedMain = false;
00189       bool passedMainMatched = false;
00190       bool passedMainNotMatched = false;
00191 
00192 
00193       edm::Handle<TriggerEvent> tev;
00194       if(iEvent.getByLabel(triggerEvent_,tev))
00195         if(tev.isValid())
00196           {
00197             if(tev->filterIndex(mainPath_)!=tev->sizeFilters())
00198               {
00199                 passedMain = true;
00200                 EventsPassed_->Fill(1.5);
00201                 //Get The HLTTau Collection
00202                 LVColl HLTTaus = importFilterColl(mainPath_,tauPdgID_,iEvent);
00203                 //get the HLTLepton Collection
00204                 LVColl HLTLeptons = importFilterColl(mainPath_,leptonPdgID_,iEvent);
00205                 
00206                 //Loop On the Taus and match them
00207                 size_t nMatchedTaus = 0;
00208 
00209                 for(size_t i = 0;i<HLTTaus.size();++i)
00210                   {
00211                     if(refTauObjects->size()>0)
00212                     if(match(HLTTaus[i],*refTauObjects,corrDeltaR_))
00213                       {
00214                         nMatchedTaus++;
00215                       }
00216                   }
00217                 
00218                 size_t nMatchedLeptons = 0;
00219                 for(size_t i = 0;i<HLTLeptons.size();++i)
00220                   {
00221                     if(refLeptonObjects->size()>0)
00222                     if(match(HLTLeptons[i],*refLeptonObjects,corrDeltaR_))
00223                       {
00224                         nMatchedLeptons++;
00225                       }
00226                   }
00227         
00228                 if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_)
00229                   {
00230                     passedMainMatched=true;
00231                     EventsPassedMatched_->Fill(1.5);
00232                   }
00233                 else
00234                   {
00235                     passedMainNotMatched=true;
00236                     EventsPassedNotMatched_->Fill(1.5);
00237                   }
00238                         
00239               }
00240             if(tev->filterIndex(l1BackupPath_)!=tev->sizeFilters())
00241               {
00242                 passedMain = true;
00243                 EventsPassed_->Fill(3.5);
00244                 //Get The HLTTau Collection
00245                 LVColl HLTTaus = importFilterColl(l1BackupPath_,tauPdgID_,iEvent);
00246                 //get the HLTLepton Collection
00247                 LVColl HLTLeptons = importFilterColl(l1BackupPath_,leptonPdgID_,iEvent);
00248                 
00249                 //Loop On the Taus and match them
00250                 size_t nMatchedTaus = 0;
00251                 for(size_t i = 0;i<HLTTaus.size();++i)
00252                   {
00253                     if(refTauObjects->size()>0)
00254                     if(match(HLTTaus[i],*refTauObjects,corrDeltaR_))
00255                       {
00256                         nMatchedTaus++;
00257                       }
00258                   }
00259                 
00260                 size_t nMatchedLeptons = 0;
00261                 for(size_t i = 0;i<HLTLeptons.size();++i)
00262                   {
00263                     if(refLeptonObjects->size()>0)
00264                     if(match(HLTLeptons[i],*refLeptonObjects,corrDeltaR_))
00265                       {
00266                         nMatchedLeptons++;
00267                       }
00268                   }
00269         
00270                 if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&passedMain)
00271                   {
00272                     EventsPassedMatched_->Fill(3.5);
00273                   }
00274                 else if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&!passedMain)
00275                   {
00276                     EventsPassedNotMatched_->Fill(3.5);
00277                   }
00278 
00279               }
00280             if(tev->filterIndex(l2BackupPath_)!=tev->sizeFilters())
00281               {
00282                 passedMain = true;
00283                 EventsPassed_->Fill(5.5);
00284                 //Get The HLTTau Collection
00285                 LVColl HLTTaus = importFilterColl(l2BackupPath_,tauPdgID_,iEvent);
00286                 //get the HLTLepton Collection
00287                 LVColl HLTLeptons = importFilterColl(l2BackupPath_,leptonPdgID_,iEvent);
00288                 
00289                 //Loop On the Taus and match them
00290                 size_t nMatchedTaus = 0;
00291                 for(size_t i = 0;i<HLTTaus.size();++i)
00292                   {
00293                     if(refTauObjects->size()>0)
00294                     if(match(HLTTaus[i],*refTauObjects,corrDeltaR_))
00295                       {
00296                         nMatchedTaus++;
00297                       }
00298                   }
00299                 
00300                 size_t nMatchedLeptons = 0;
00301                 for(size_t i = 0;i<HLTLeptons.size();++i)
00302                   {
00303                     if(refLeptonObjects->size()>0)
00304                     if(match(HLTLeptons[i],*refLeptonObjects,corrDeltaR_))
00305                       {
00306                         nMatchedLeptons++;
00307                       }
00308                   }
00309         
00310                 if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&passedMain)
00311                   {
00312                     EventsPassedMatched_->Fill(5.5);
00313                   }
00314                 else if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&!passedMain)
00315                   {
00316                     EventsPassedNotMatched_->Fill(5.5);
00317                   }
00318               }
00319             if(tev->filterIndex(l25BackupPath_)!=tev->sizeFilters())
00320               {
00321                 passedMain = true;
00322                 EventsPassed_->Fill(7.5);
00323                 //Get The HLTTau Collection
00324                 LVColl HLTTaus = importFilterColl(l25BackupPath_,tauPdgID_,iEvent);
00325                 //get the HLTLepton Collection
00326                 LVColl HLTLeptons = importFilterColl(l25BackupPath_,leptonPdgID_,iEvent);
00327                 
00328                 //Loop On the Taus and match them
00329                 size_t nMatchedTaus = 0;
00330                 for(size_t i = 0;i<HLTTaus.size();++i)
00331                   {
00332                     if(refTauObjects->size()>0)
00333                     if(match(HLTTaus[i],*refTauObjects,corrDeltaR_))
00334                       {
00335                         nMatchedTaus++;
00336                       }
00337                   }
00338                 
00339                 size_t nMatchedLeptons = 0;
00340                 for(size_t i = 0;i<HLTLeptons.size();++i)
00341                   {
00342                     if(refLeptonObjects->size()>0)
00343                     if(match(HLTLeptons[i],*refLeptonObjects,corrDeltaR_))
00344                       {
00345                         nMatchedLeptons++;
00346                       }
00347                   }
00348         
00349                 if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&passedMain)
00350                   {
00351                     EventsPassedMatched_->Fill(7.5);
00352                   }
00353                 else if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&!passedMain)
00354                   {
00355                     EventsPassedNotMatched_->Fill(7.5);
00356                   }
00357               }
00358             if(tev->filterIndex(l3BackupPath_)!=tev->sizeFilters())
00359               { 
00360                 passedMain = true;
00361                 EventsPassed_->Fill(10);
00362                 //Get The HLTTau Collection
00363                 LVColl HLTTaus = importFilterColl(l3BackupPath_,tauPdgID_,iEvent);
00364                 //get the HLTLepton Collection
00365                 LVColl HLTLeptons = importFilterColl(l3BackupPath_,leptonPdgID_,iEvent);
00366                 
00367                 //Loop On the Taus and match them
00368                 size_t nMatchedTaus = 0;
00369                 for(size_t i = 0;i<HLTTaus.size();++i)
00370                   {
00371                     if(refTauObjects->size()>0)
00372                     if(match(HLTTaus[i],*refTauObjects,corrDeltaR_))
00373                       {
00374                         nMatchedTaus++;
00375                       }
00376                   }
00377                 
00378                 size_t nMatchedLeptons = 0;
00379                 for(size_t i = 0;i<HLTLeptons.size();++i)
00380                   {
00381                     if(match(HLTLeptons[i],*refLeptonObjects,corrDeltaR_))
00382                       {
00383                         nMatchedLeptons++;
00384                       }
00385                   }
00386         
00387                 if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&passedMain)
00388                   {
00389                     EventsPassedMatched_->Fill(9.5);
00390                   }
00391                 else if(nMatchedTaus>=nTriggeredTaus_ && nMatchedLeptons>=nTriggeredLeptons_ &&!passedMain)
00392                   {
00393                     EventsPassedNotMatched_->Fill(9.5);
00394                   }
00395 
00396                 }
00397           }
00398       
00399       counterEvt_ = 0;
00400     }
00401   else
00402       counterEvt_++;
00403 
00404 }
00405 
00406 
00407 
00408 
00409 //--------------------------------------------------------
00410 void 
00411 HLTTauDQMOfflineSource::endLuminosityBlock(const LuminosityBlock& lumiSeg, 
00412                                     const EventSetup& context) {
00413 }
00414 //--------------------------------------------------------
00415 void 
00416 HLTTauDQMOfflineSource::endRun(const Run& r, const EventSetup& context){
00417 }
00418 //--------------------------------------------------------
00419 void 
00420 HLTTauDQMOfflineSource::endJob(){
00421 
00422    if (outputFile_.size() != 0 && dbe_)
00423    dbe_->save(outputFile_);
00424  
00425   return;
00426 }
00427 
00428 
00429 
00430 
00431 bool 
00432 HLTTauDQMOfflineSource::match(const LV& cand,const  LVColl&  electrons,double deltaR)
00433 {
00434     bool matched=false;
00435     for(size_t i = 0;i<electrons.size();++i)
00436       {
00437         double delta = ROOT::Math::VectorUtil::DeltaR(cand.Vect(),electrons[i].Vect());
00438         if((delta<deltaR))
00439           {
00440             matched=true;
00441           }
00442       }
00443 
00444     return matched;
00445 
00446 }
00447 
00448 LVColl 
00449 HLTTauDQMOfflineSource::importFilterColl(edm::InputTag& filter,int pdgID,const Event& iEvent)
00450 {
00451     //Create output Collection
00452     LVColl out;
00453 
00454     //Look at all Different triggers
00455     Handle<TriggerEvent> handle;
00456     if(iEvent.getByLabel(triggerEvent_,handle))
00457       {
00458 
00459         //get All the final trigger objects
00460         const TriggerObjectCollection& TOC(handle->getObjects());
00461       
00462         //filter index
00463         size_t index = handle->filterIndex(filter);
00464         if(index!=handle->sizeFilters())
00465           {
00466             const Keys& KEYS = handle->filterKeys(index);
00467             for(size_t i = 0;i<KEYS.size();++i)
00468               {
00469                 const TriggerObject& TO(TOC[KEYS[i]]);
00470                 LV a(TO.px(),TO.py(),TO.pz(),TO.energy());
00471                 if(abs(TO.id()) == pdgID)
00472                   out.push_back(a);
00473               }
00474           }
00475       }
00476     return out;
00477 }

Generated on Tue Jun 9 17:34:10 2009 for CMSSW by  doxygen 1.5.4