CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/HLTEvF/plugins/HLTTauDQMSource.cc

Go to the documentation of this file.
00001 #include "DQM/HLTEvF/interface/HLTTauDQMSource.h"
00002 
00003 
00004 //
00005 // constructors and destructor
00006 //
00007 HLTTauDQMSource::HLTTauDQMSource( const edm::ParameterSet& ps ) :counterEvt_(0)
00008 {
00009 
00010   //Get General Monitoring Parameters
00011   config_                 = ps.getParameter<std::vector<edm::ParameterSet> >("MonitorSetup");
00012   configType_             = ps.getParameter<std::vector<std::string> >("ConfigType");
00013   doRefAnalysis_          = ps.getParameter<bool>("doMatching");
00014   NPtBins_                = ps.getUntrackedParameter<int>("PtHistoBins",20);
00015   NEtaBins_               = ps.getUntrackedParameter<int>("EtaHistoBins",20);
00016   NPhiBins_               = ps.getUntrackedParameter<int>("PhiHistoBins",32);
00017   EtMax_                  = ps.getUntrackedParameter<double>("EtHistoMax",100);
00018   L1MatchDr_              = ps.getUntrackedParameter<double>("L1MatchDeltaR",0.5);
00019   HLTMatchDr_             = ps.getUntrackedParameter<double>("HLTMatchDeltaR",0.3);
00020 
00021   refFilter_              = ps.getUntrackedParameter<std::vector<edm::InputTag> >("matchFilter");
00022   refID_                  = ps.getUntrackedParameter<std::vector<int> >("matchObjectID");
00023   ptThres_                = ps.getUntrackedParameter<std::vector<double> >("matchObjectMinPt");
00024   prescaleEvt_            = ps.getUntrackedParameter<int>("prescaleEvt", -1);
00025 
00026   triggerEvent_           = ps.getParameter < edm::InputTag > ("TriggerEvent");
00027 
00028   //Read The Configuration
00029   for(unsigned int i=0;i<config_.size();++i)
00030     {
00031 
00032       if(configType_[i] == "L1")
00033         {
00034           HLTTauDQML1Plotter tmp(config_[i],NPtBins_,NEtaBins_,NPhiBins_,EtMax_,doRefAnalysis_,L1MatchDr_);
00035           l1Plotters.push_back(tmp);
00036         }
00037 
00038       if(configType_[i] == "Calo")
00039         {
00040           HLTTauDQMCaloPlotter tmp(config_[i],NPtBins_,NEtaBins_,NPhiBins_,EtMax_,doRefAnalysis_,HLTMatchDr_);
00041           caloPlotters.push_back(tmp);
00042         }
00043 
00044       else if(configType_[i] == "Track")
00045         {
00046           HLTTauDQMTrkPlotter tmp(config_[i],NPtBins_,NEtaBins_,NPhiBins_,EtMax_,doRefAnalysis_,HLTMatchDr_);
00047           trackPlotters.push_back(tmp);
00048         }
00049 
00050       else if(configType_[i] == "Path")
00051         {
00052           HLTTauDQMPathPlotter tmp(config_[i],doRefAnalysis_);
00053           pathPlotters.push_back(tmp);
00054         }
00055 
00056       else if(configType_[i] == "LitePath")
00057         {
00058           HLTTauDQMLitePathPlotter tmp(config_[i],NPtBins_,NEtaBins_,NPhiBins_,EtMax_,doRefAnalysis_,HLTMatchDr_);
00059           litePathPlotters.push_back(tmp);
00060         }
00061 
00062 
00063       else if(configType_[i] == "Summary")
00064         {
00065           HLTTauDQMSummaryPlotter tmp(config_[i]);
00066           summaryPlotters.push_back(tmp);
00067         }
00068 
00069 
00070     }
00071 }
00072 
00073 HLTTauDQMSource::~HLTTauDQMSource()
00074 {
00075    
00076   // do anything here that needs to be done at desctruction time
00077   // (e.g. close files, deallocate resources etc.)
00078   
00079 }
00080 
00081 
00082 //--------------------------------------------------------
00083 void 
00084 HLTTauDQMSource::beginJob(){
00085 
00086 }
00087 
00088 //--------------------------------------------------------
00089 void HLTTauDQMSource::beginRun(const edm::Run& r, const edm::EventSetup& context) {
00090 
00091 }
00092 
00093 //--------------------------------------------------------
00094 void HLTTauDQMSource::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00095                                            const edm::EventSetup& context) {
00096   
00097 }
00098 
00099 // ----------------------------------------------------------
00100 void 
00101 HLTTauDQMSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup )
00102 {  
00103   using namespace std;
00104   using namespace edm;
00105   using namespace reco;
00106   using namespace l1extra;
00107   using namespace trigger;
00108 
00109 
00110   //Apply the prescaler
00111   if(counterEvt_ > prescaleEvt_)
00112     {
00113       //Do Analysis here
00114       
00115       //Create dummy Match Collections
00116       std::vector<LVColl> refC;
00117 
00118       if(doRefAnalysis_)
00119         {
00120           Handle<TriggerEvent> trigEv;
00121 
00122           //get The triggerEvent
00123           bool gotTEV =true;
00124           try {
00125              gotTEV*= iEvent.getByLabel(triggerEvent_,trigEv);
00126               }
00127           catch (cms::Exception& exception) {
00128             gotTEV =false;
00129           }
00130 
00131 
00132 
00133             if(gotTEV)
00134               for(unsigned int i=0;i<refFilter_.size();++i)
00135                 {
00136                   size_t ID =trigEv->filterIndex(refFilter_[i]);
00137                   refC.push_back(getFilterCollection(ID,refID_[i],*trigEv,ptThres_[i]));
00138                 }
00139         }
00140 
00141       //fill the empty slots with empty collections
00142       LVColl dummy;
00143       for(int k=refFilter_.size();k<3;k++)
00144         {
00145           refC.push_back(dummy);
00146         }
00147 
00148      
00149       
00150       //Path Plotters
00151       for(unsigned int i=0;i<pathPlotters.size();++i)
00152         pathPlotters[i].analyze(iEvent,iSetup,refC);
00153 
00154       //Lite Path Plotters
00155       for(unsigned int i=0;i<litePathPlotters.size();++i)
00156         litePathPlotters[i].analyze(iEvent,iSetup,refC);
00157 
00158       //L1  Plotters
00159       for(unsigned int i=0;i<l1Plotters.size();++i)
00160         l1Plotters[i].analyze(iEvent,iSetup,refC);
00161 
00162       //Calo Plotters
00163       for(unsigned int i=0;i<caloPlotters.size();++i)
00164         caloPlotters[i].analyze(iEvent,iSetup,refC[0]);
00165 
00166       //Track Plotters
00167       for(unsigned int i=0;i<trackPlotters.size();++i)
00168         trackPlotters[i].analyze(iEvent,iSetup,refC[0]);
00169 
00170     }
00171   else
00172       counterEvt_++;
00173 
00174 }
00175 
00176 
00177 
00178 
00179 //--------------------------------------------------------
00180 void HLTTauDQMSource::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00181                                          const edm::EventSetup& context) {
00182                                          
00183         //Summary Plotters
00184      for(unsigned int i=0;i<summaryPlotters.size();++i) summaryPlotters[i].plot();
00185      
00186 }
00187 //--------------------------------------------------------
00188 void HLTTauDQMSource::endRun(const edm::Run& r, const edm::EventSetup& context){
00189 }
00190 //--------------------------------------------------------
00191 void HLTTauDQMSource::endJob(){
00192   return;
00193 }
00194 
00195 
00196 LVColl 
00197 HLTTauDQMSource::getFilterCollection(size_t index,int id,const trigger::TriggerEvent& trigEv,double ptCut)
00198 {
00199   using namespace trigger;
00200   //Create output Collection
00201   LVColl out;
00202       //get All the final trigger objects
00203       const TriggerObjectCollection& TOC(trigEv.getObjects());
00204 
00205      
00206       //filter index
00207       if(index!=trigEv.sizeFilters())
00208         {
00209           const Keys& KEYS = trigEv.filterKeys(index);
00210           for(size_t i = 0;i<KEYS.size();++i)
00211             {
00212               const TriggerObject& TO(TOC[KEYS[i]]);
00213               LV a(TO.px(),TO.py(),TO.pz(),sqrt(TO.px()*TO.px()+TO.py()*TO.py()+TO.pz()*TO.pz()));
00214             if(abs(TO.id()) == id)
00215                 if(a.pt()>ptCut)
00216                   out.push_back(a);
00217             }
00218         }
00219   return out;
00220 }
00221 
00222 
00223 
00224 
00225 //LVColl HLTTauDQMSource::getFilterCollection(size_t filterID,int id,const trigger::TriggerEventWithRefs& trigEv,double ptMin)
00226 //{
00227 //  using namespace trigger;
00228 //
00229 //  LVColl out;
00230 //
00231 //
00232 //        if(id==trigger::TriggerL1IsoEG ||trigger::TriggerL1NoIsoEG) 
00233 //          {
00234 //            VRl1em obj;
00235 //            trigEv.getObjects(filterID,id,obj);
00236 //            for(size_t i=0;i<obj.size();++i)
00237 //              if(&obj[i])
00238 //                if(obj[i]->pt()>ptMin)
00239 //                  out.push_back(obj[i]->p4());
00240 //          }
00241 //
00242 //        if(id==trigger::TriggerL1Mu) 
00243 //          {
00244 //            VRl1muon obj;
00245 //            trigEv.getObjects(filterID,id,obj);
00246 //            for(size_t i=0;i<obj.size();++i)
00247 //              if(&obj[i])
00248 //                if(obj[i]->pt()>ptMin)
00249 //                  out.push_back(obj[i]->p4());
00250 //          }
00251 //
00252 //
00253 //         if(id==trigger::TriggerMuon) 
00254 //          {
00255 //            VRmuon obj;
00256 //            trigEv.getObjects(filterID,id,obj);
00257 //            for(size_t i=0;i<obj.size();++i)
00258 //              if(&obj[i])
00259 //        if(obj[i]->pt()>ptMin)
00260 //                  out.push_back(obj[i]->p4());
00261 //          }
00262 //
00263 //        if(id==trigger::TriggerElectron) 
00264 //          {
00265 //            VRelectron obj;
00266 //            trigEv.getObjects(filterID,id,obj);
00267 //            for(size_t i=0;i<obj.size();++i)
00268 //              if(&obj[i])
00269 //                if(obj[i]->pt()>ptMin)
00270 //                  out.push_back(obj[i]->p4());
00271 //          }
00272 
00273 //        if(id==trigger::TriggerL1TauJet) 
00274 //          {
00275 //            VRl1jet obj;
00276 //            trigEv.getObjects(filterID,id,obj);
00277 //            for(size_t i=0;i<obj.size();++i)
00278 //              if(&obj[i])
00279 //                if(obj[i]->pt()>ptMin)
00280 //                  out.push_back(obj[i]->p4());
00281 //          }
00282 
00283 //        if(id==trigger::TriggerTau) 
00284 //          {
00285 //            VRjet obj;
00286 //            trigEv.getObjects(filterID,id,obj);
00287 //            for(size_t i=0;i<obj.size();++i)
00288 //              if(&obj[i])
00289 //                if(obj[i]->pt()>ptMin)
00290 //                  out.push_back(obj[i]->p4());
00291 //          }
00292 
00293 //        return out;
00294 //