CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/HLTriggerOffline/special/src/DQMHcalIsoTrackHLT.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTriggerOffline/special
00004 // Class:      DQMHcalIsoTrackAlCaRaw
00005 // 
00013 //
00014 // Original Author:  Grigory SAFRONOV
00015 //         Created:  Mon Oct  6 10:10:22 CEST 2008
00016 // $Id: DQMHcalIsoTrackHLT.cc,v 1.3 2009/12/29 01:20:46 nuno Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 
00028 #include "FWCore/Framework/interface/Frameworkfwd.h"
00029 #include "FWCore/Framework/interface/EDAnalyzer.h"
00030 
00031 #include "FWCore/Framework/interface/Event.h"
00032 #include "FWCore/Framework/interface/MakerMacros.h"
00033 
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 
00036 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00037 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00038 
00039 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00040 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00041 
00042 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00043 #include "DataFormats/TrackReco/interface/Track.h"
00044 
00045 #include "DQMServices/Core/interface/DQMStore.h"
00046 #include "DQMServices/Core/interface/MonitorElement.h"
00047 #include "FWCore/ServiceRegistry/interface/Service.h"
00048 
00049 
00050 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h"
00051 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h"
00052 
00053 #include "TH1F.h"
00054 #include "TH2F.h"
00055 
00056 #include <fstream>
00057 
00058 class DQMHcalIsoTrackHLT : public edm::EDAnalyzer {
00059 public:
00060   explicit DQMHcalIsoTrackHLT(const edm::ParameterSet&);
00061   ~DQMHcalIsoTrackHLT();
00062   double getDist(double,double,double,double);
00063   
00064 private:
00065 
00066   int evtBuf;
00067 
00068   DQMStore* dbe_;  
00069 
00070   virtual void beginJob() ;
00071   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00072   virtual void endJob() ;
00073 
00074   std::string folderName_;
00075   std::string outRootFileName_;
00076 
00077   std::string hltRAWEventTag_;
00078   std::string hltAODEventTag_;
00079 
00080   std::string l2collectionLabel_;
00081   std::string l3collectionLabel_;
00082 
00083   std::string l3filterLabel_;
00084   std::string l1filterLabel_;
00085   std::string l2filterLabel_;
00086   std::string hltProcess_;
00087 
00088   bool useHLTDebug_;
00089 
00090   bool saveToRootFile_;
00091 
00092 
00093   //ONLINE
00094   MonitorElement* hL2TowerOccupancy;
00095   MonitorElement* hL2L3acc;
00096   MonitorElement* hL3L2rat;
00097 
00098   //OFFLINE
00099   //momentum distributions
00100   MonitorElement* hL3Pt;
00101   MonitorElement* hL3pVsEta;
00102 
00103   MonitorElement* hL3colP;
00104   MonitorElement* hL3colEta;
00105   
00106   MonitorElement* hL3eta;
00107   MonitorElement* hL3phi;
00108   MonitorElement* hL3candL2rat;
00109 
00110   //purity of rate
00111   MonitorElement* hL3etaAOD;
00112   MonitorElement* hL3pAOD;
00113   MonitorElement* hL3etaPureAOD;
00114   MonitorElement* hL3pPureAOD;
00115   
00116   //etc
00117   MonitorElement* hL1pT;
00118   MonitorElement* hL2eta;
00119   MonitorElement* hL2phi;
00120   MonitorElement* hL2pT;
00121   MonitorElement* hisopT;
00122   MonitorElement* hisopTvsEta;
00123   MonitorElement* hL3L2trackMatch;
00124 
00125 };
00126 
00127 double DQMHcalIsoTrackHLT::getDist(double eta1, double phi1, double eta2, double phi2)
00128 {
00129   double dphi = fabs(phi1 - phi2); 
00130   if(dphi>acos(-1)) dphi = 2*acos(-1)-dphi;
00131   double dr = sqrt(dphi*dphi + pow(eta1-eta2,2));
00132   return dr;
00133 }
00134 
00135 DQMHcalIsoTrackHLT::DQMHcalIsoTrackHLT(const edm::ParameterSet& iConfig)
00136 {
00137   folderName_ = iConfig.getParameter<std::string>("folderName");
00138   outRootFileName_=iConfig.getParameter<std::string>("outputRootFileName");
00139 
00140   useHLTDebug_=iConfig.getParameter<bool>("useHLTDebug");
00141   hltRAWEventTag_=iConfig.getParameter<std::string>("hltRAWTriggerEventLabel");
00142   hltAODEventTag_=iConfig.getParameter<std::string>("hltAODTriggerEventLabel");
00143 
00144   l2collectionLabel_=iConfig.getParameter<std::string>("l2collectionLabel");
00145   l3collectionLabel_=iConfig.getParameter<std::string>("l3collectionLabel");
00146 
00147   l3filterLabel_=iConfig.getParameter<std::string>("hltL3filterLabel");
00148   l1filterLabel_=iConfig.getParameter<std::string>("hltL1filterLabel");
00149   l2filterLabel_=iConfig.getParameter<std::string>("hltL2filterLabel");
00150   hltProcess_=iConfig.getParameter<std::string>("hltProcessName");
00151 
00152   saveToRootFile_=iConfig.getParameter<bool>("SaveToRootFile");
00153 
00154 }
00155 
00156 
00157 DQMHcalIsoTrackHLT::~DQMHcalIsoTrackHLT()
00158 {}
00159 
00160 void DQMHcalIsoTrackHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00161 {
00162   edm::Handle<trigger::TriggerEventWithRefs> triggerObj;
00163   edm::InputTag toLab=edm::InputTag(hltRAWEventTag_,"",hltProcess_);
00164   iEvent.getByLabel(toLab,triggerObj); 
00165   if(!triggerObj.isValid()) 
00166     { 
00167       edm::LogWarning("DQMHcalIsoTrack") << "RAW-type HLT results not found, skipping event";
00168       return;
00169     }
00170   
00171   std::vector<l1extra::L1JetParticleRef> l1CenJets;
00172   std::vector<l1extra::L1JetParticleRef> l1ForJets;
00173   std::vector<l1extra::L1JetParticleRef> l1TauJets;
00174   edm::InputTag l1Tag = edm::InputTag(l1filterLabel_, "",hltProcess_);
00175   trigger::size_type l1filterIndex=triggerObj->filterIndex(l1Tag);
00176   if (l1filterIndex<triggerObj->size())
00177     {
00178       triggerObj->getObjects(l1filterIndex, trigger::TriggerL1CenJet, l1CenJets);
00179       triggerObj->getObjects(l1filterIndex, trigger::TriggerL1ForJet, l1ForJets);
00180       triggerObj->getObjects(l1filterIndex, trigger::TriggerL1TauJet, l1TauJets);
00181     }
00182 
00183   std::vector<reco::IsolatedPixelTrackCandidateRef> l2tracks;
00184   edm::InputTag l2Tag = edm::InputTag(l2filterLabel_,"",hltProcess_);
00185   trigger::size_type l2filterIndex=triggerObj->filterIndex(l2Tag);
00186   if (l2filterIndex<triggerObj->size()) triggerObj->getObjects(l2filterIndex, trigger::TriggerTrack, l2tracks);
00187   
00188   std::vector<reco::IsolatedPixelTrackCandidateRef> l3tracks;
00189   edm::InputTag l3Tag = edm::InputTag(l3filterLabel_, "",hltProcess_);
00190   trigger::size_type l3filterIndex=triggerObj->filterIndex(l3Tag);
00191   if (l3filterIndex<triggerObj->size()) triggerObj->getObjects(l3filterIndex, trigger::TriggerTrack, l3tracks);
00192 
00193   if (l1CenJets.size()>0||l1ForJets.size()>0||l1CenJets.size()>0) hL2L3acc->Fill(1+0.0001,1);
00194   
00195   edm::Handle<reco::IsolatedPixelTrackCandidateCollection> l3col;
00196   edm::InputTag l3colTag=edm::InputTag(l3collectionLabel_,"",hltProcess_);
00197   
00198   if (l2tracks.size()>0) 
00199     {
00200       hL2L3acc->Fill(2+0.0001,1);
00201       if (useHLTDebug_)
00202         {
00203           iEvent.getByLabel(l3collectionLabel_,l3col);
00204           
00205           for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l3it=l3col->begin(); l3it!=l3col->end(); ++l3it)
00206             {
00207               hL3colP->Fill(l3it->track()->pt()*cosh(l3it->track()->eta()),1);
00208               hL3colEta->Fill(l3it->track()->eta(),1);
00209             }
00210         }
00211     }
00212   if (l3tracks.size()>0) hL2L3acc->Fill(3+0.0001,1);
00213 
00214   for (unsigned int i=0; i<l1CenJets.size(); i++)
00215     {
00216       hL1pT->Fill(l1CenJets[i]->pt(),1);
00217     }
00218   for (unsigned int i=0; i<l1ForJets.size(); i++)
00219     {
00220       hL1pT->Fill(l1ForJets[i]->pt(),1);
00221     }
00222   for (unsigned int i=0; i<l1TauJets.size(); i++)
00223     {
00224       hL1pT->Fill(l1TauJets[i]->pt(),1);
00225     }
00226   for (unsigned int i=0; i<l2tracks.size(); i++)
00227     {
00228       hL2eta->Fill(l2tracks[i]->track()->eta(),1);
00229       hL2phi->Fill(l2tracks[i]->track()->phi(),1);
00230       hL2pT->Fill(l2tracks[i]->track()->pt(),1);
00231       hL2TowerOccupancy->Fill((l2tracks[i]->towerIndex()).first,(l2tracks[i]->towerIndex()).second,1);
00232       hisopT->Fill(l2tracks[i]->maxPtPxl(),1);
00233       hisopTvsEta->Fill(l2tracks[i]->track()->eta(),l2tracks[i]->maxPtPxl(),1);
00234       if (useHLTDebug_)
00235         {
00236           reco::IsolatedPixelTrackCandidateCollection::const_iterator selTrIt;
00237           double drmin=0.3;
00238           for (reco::IsolatedPixelTrackCandidateCollection::const_iterator l3it=l3col->begin(); l3it!=l3col->end(); ++l3it)
00239             {
00240               double drl2l3=getDist(l3it->track()->eta(),l3it->track()->phi(),l2tracks[i]->track()->eta(),l2tracks[i]->track()->phi());
00241               if (drl2l3<drmin)
00242                 {
00243                   drmin=drl2l3;
00244                   selTrIt=l3it;
00245                 }
00246             }
00247           if (drmin!=0.3) hL3candL2rat->Fill(selTrIt->track()->p()/l2tracks[i]->track()->p(),1);
00248         }
00249     }
00250   for (unsigned int i=0; i<l3tracks.size(); i++)
00251     {
00252       
00253       hL3Pt->Fill(l3tracks[i]->track()->pt(),1);
00254       hL3eta->Fill(l3tracks[i]->track()->eta(),1);
00255       hL3phi->Fill(l3tracks[i]->track()->phi(),1);
00256       int seltr=-1;
00257       double drmin=100;
00258       for (unsigned int j=0; j<l2tracks.size(); j++)
00259         {
00260           double drl2l3=getDist(l3tracks[i]->track()->eta(),l3tracks[i]->track()->phi(),l2tracks[i]->track()->eta(),l2tracks[i]->track()->phi());
00261           if (drl2l3<drmin)
00262             {
00263               drmin=drl2l3;
00264               seltr=j;
00265             }
00266         }
00267       if (seltr!=-1)
00268         {
00269           hL3L2trackMatch->Fill(drmin,1);
00270           hL3L2rat->Fill(l3tracks[i]->track()->p()/l2tracks[seltr]->track()->p(),1);
00271         }
00272     }
00273   
00274   edm::Handle<trigger::TriggerEvent> trevt;
00275   edm::InputTag taodLab=edm::InputTag(hltAODEventTag_,"",hltProcess_);
00276   iEvent.getByLabel(taodLab,trevt);
00277   
00278   const trigger::TriggerObjectCollection& TOCol(trevt->getObjects());
00279   
00280   trigger::Keys KEYS;
00281   const trigger::size_type nFilt(trevt->sizeFilters());
00282   
00283   int nFired=0;
00284   
00285   edm::InputTag hltFilterTag_=edm::InputTag(l3filterLabel_,"",hltProcess_);
00286   for (trigger::size_type iFilt=0; iFilt!=nFilt; iFilt++) 
00287     {
00288       trigger::Keys KEYS1=trevt->filterKeys(iFilt);
00289       if (KEYS1.size()>0) nFired++;
00290       if (trevt->filterTag(iFilt)==hltFilterTag_) KEYS=trevt->filterKeys(iFilt);
00291     }
00292   
00293   trigger::size_type nReg=KEYS.size();
00294   
00295   for (trigger::size_type k=0; k<nReg; k++)
00296     {
00297       const trigger::TriggerObject& TObj(TOCol[KEYS[k]]);
00298       hL3etaAOD->Fill(TObj.eta(),1);
00299       hL3pAOD->Fill(TObj.pt()*cosh(TObj.eta()),1);
00300     }
00301   
00302   if (nFired==2&&nReg>0)  
00303     {
00304       for (trigger::size_type iReg=0; iReg<nReg; iReg++)
00305         {
00306           const trigger::TriggerObject& TObj(TOCol[KEYS[iReg]]);
00307           hL3etaPureAOD->Fill(TObj.eta(),1);
00308           hL3pPureAOD->Fill(TObj.pt()*cosh(TObj.eta()),1);
00309         }
00310     }
00311 }
00312 
00313 void DQMHcalIsoTrackHLT::beginJob()
00314 {
00315   dbe_ = edm::Service<DQMStore>().operator->();
00316   dbe_->setCurrentFolder(folderName_);
00317 
00318   hL2TowerOccupancy=dbe_->book2D("hL2TowerOccupancy","L2 tower occupancy",48,-25,25,73,0,73);
00319   hL2TowerOccupancy->setAxisTitle("ieta",1);
00320   hL2TowerOccupancy->setAxisTitle("iphi",2);
00321   hL2TowerOccupancy->getTH2F()->SetOption("colz");
00322   hL2TowerOccupancy->getTH2F()->SetStats(kFALSE);
00323 
00324   hL2L3acc=dbe_->book1D("hL2L3acc","number of L1, L2 and L3 accepts",3,1,4);
00325   hL2L3acc->setAxisTitle("level",1);
00326 
00327   hL3L2trackMatch=dbe_->book1D("hL3L2trackMatch","R from L3 object to L2 object ",1000,0,1);
00328   hL3L2trackMatch->setAxisTitle("R(eta,phi)",1);
00329  
00330   hL3colP=dbe_->book1D("hL3colP","P of L3 candidates",1000,0,100);
00331   hL3colP->setAxisTitle("P (GeV)",1);
00332 
00333   hL3colEta=dbe_->book1D("hL3colEta","eta of L3 candidates",100,-3,3);
00334   hL3colEta->setAxisTitle("eta",1);
00335 
00336   hL3candL2rat=dbe_->book1D("hL3candL2rat","ratio of L3 candidate to accepted L2",1000,0,10);  
00337   hL3candL2rat->setAxisTitle("P_L3/P_L2",1);
00338 
00339   hL3L2rat=dbe_->book1D("hL3L2rat","ratio of L3 to L2 measurement",1000,0,10);
00340   hL3L2rat->setAxisTitle("pT_L3/pT_L2",1);
00341 
00342   hL3Pt=dbe_->book1D("hl3Pt","pT of L3 objects",1000,0,100);
00343   hL3Pt->setAxisTitle("pT(GeV)",1);
00344 
00345   hL3eta=dbe_->book1D("hl3eta","eta of L3 objects",50,-2.5,2.5);
00346   hL3eta->setAxisTitle("eta",1);
00347 
00348   hL3phi=dbe_->book1D("hl3phi","phi of L3 objects",70,-3.5,3.5);
00349   hL3phi->setAxisTitle("phi(rad)",1);
00350 
00351   hL3etaAOD=dbe_->book1D("hL3etaAOD","eta of L3 objects (AOD)",50,-2.5,2.5);
00352   hL3etaAOD->setAxisTitle("eta",1);
00353 
00354   hL3etaPureAOD=dbe_->book1D("hL3etaPureAOD","eta of L3 objects (AOD, pure)",50,-2.5,2.5);
00355   hL3etaPureAOD->setAxisTitle("eta",1);
00356 
00357   hL3pAOD=dbe_->book1D("hl3pAOD","p of L3 objects (AOD)",1000,0,100);
00358   hL3pAOD->setAxisTitle("p(GeV)",1);
00359 
00360   hL3pPureAOD=dbe_->book1D("hl3pPureAOD","p of L3 objects (AOD, pure)",1000,0,100);
00361   hL3pPureAOD->setAxisTitle("p(GeV)",1);
00362 
00363   hL1pT=dbe_->book1D("hl1pT","pT of L1 objects",1000,0,1000);
00364   hL1pT->setAxisTitle("pT(GeV)",1);
00365 
00366   hL2pT=dbe_->book1D("hl2pT","pT of L2 objects",1000,0,1000);
00367   hL2pT->setAxisTitle("pT(GeV)",1);
00368 
00369   hL2eta=dbe_->book1D("hl2eta","eta of L2 objects",50,-2.5,2.5);
00370   hL2eta->setAxisTitle("eta",1);
00371 
00372   hL2phi=dbe_->book1D("hl2phi","phi of L2 objects",70,-3.5,3.5);
00373   hL2phi->setAxisTitle("phi(rad)",1);
00374 
00375   hisopT=dbe_->book1D("hisopT","isolation pT",100,0,5.5);
00376   hisopT->setAxisTitle("iso pT (GeV)",1);
00377 
00378   hisopTvsEta=dbe_->book2D("hisopTvsEta","isolation pT vs Eta",8,-2,2,100,0,5.5);
00379   hisopTvsEta->setAxisTitle("eta",1);
00380   hisopTvsEta->setAxisTitle("iso pT (GeV)",2);
00381 }
00382 
00383 void DQMHcalIsoTrackHLT::endJob() {
00384 
00385 if(dbe_&&saveToRootFile_) 
00386   {  
00387     dbe_->save(outRootFileName_);
00388   }
00389 }
00390 
00391 DEFINE_FWK_MODULE(DQMHcalIsoTrackHLT);