00001
00002 #include "DQM/HLTEvF/interface/HLTTauDQMPathPlotter.h"
00003 #include "Math/GenVector/VectorUtil.h"
00004
00005 HLTTauDQMPathPlotter::HLTTauDQMPathPlotter(const edm::ParameterSet& ps,bool ref) :
00006 triggerEventObject_(ps.getUntrackedParameter<edm::InputTag>("triggerEventObject")),
00007 triggerTag_(ps.getUntrackedParameter<std::string>("DQMFolder","DoubleTau")),
00008 filter_(ps.getUntrackedParameter<std::vector<edm::InputTag> >("Filter")),
00009 TauType_(ps.getUntrackedParameter<std::vector<int> >("TauType")),
00010 LeptonType_(ps.getUntrackedParameter<std::vector<int> >("LeptonType")),
00011 nTriggeredTaus_(ps.getUntrackedParameter<std::vector<unsigned> >("NTriggeredTaus")),
00012 nTriggeredLeptons_(ps.getUntrackedParameter<std::vector<unsigned> >("NTriggeredLeptons")),
00013 doRefAnalysis_(ref),
00014 matchDeltaR_(ps.getUntrackedParameter<std::vector<double> >("MatchDeltaR")),
00015 refTauPt_(ps.getUntrackedParameter<double>("refTauPt",20)),
00016 refLeptonPt_(ps.getUntrackedParameter<double>("refLeptonPt",15))
00017 {
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 DQMStore* store = &*edm::Service<DQMStore>();
00028
00029 if(store)
00030 {
00031
00032 store->setCurrentFolder(triggerTag_);
00033 accepted_events = store->book1D("TriggerBits","Accepted Events per path",filter_.size(),0,filter_.size());
00034 for(size_t k=0;k<filter_.size();++k)
00035 accepted_events->setBinLabel(k+1,filter_[k].label(),1);
00036
00037 if(doRefAnalysis_)
00038 {
00039 accepted_events_matched = store->book1D("MatchedTriggerBits","Accepted +Matched Events per path",filter_.size()+1,0,filter_.size()+1);
00040 accepted_events_matched->setBinLabel(1,"RefEvents",1);
00041 for(size_t k=0;k<filter_.size();++k)
00042 accepted_events_matched->setBinLabel(k+2,filter_[k].label(),1);
00043 }
00044
00045
00046
00047 }
00048
00049 }
00050
00051 HLTTauDQMPathPlotter::~HLTTauDQMPathPlotter()
00052 {
00053 }
00054
00055
00056
00057
00058
00059 void
00060 HLTTauDQMPathPlotter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup,const std::vector<LVColl>& refC )
00061 {
00062 using namespace std;
00063 using namespace edm;
00064 using namespace reco;
00065 using namespace l1extra;
00066 using namespace trigger;
00067
00068 bool tau_ok=true;
00069 bool lepton_ok=true;
00070
00071 bool isGoodReferenceEvent=false;
00072
00073 if(doRefAnalysis_)
00074 {
00075
00076 if(refC.size()>0)
00077 {
00078 if(refC[0].size()<nTriggeredTaus_[0])
00079 {
00080 tau_ok = false;
00081 }
00082 else
00083 {
00084 unsigned int highPtTaus=0;
00085 for(size_t j = 0;j<refC[0].size();++j)
00086 {
00087 if((refC[0])[j].Et()>refTauPt_)
00088 highPtTaus++;
00089 }
00090 if(highPtTaus<nTriggeredTaus_[0])
00091 {
00092 tau_ok = false;
00093 }
00094
00095
00096 }
00097 }
00098
00099 unsigned int highPtElectrons=0;
00100 unsigned int highPtMuons=0;
00101 if(refC.size()>1){
00102 for(size_t j = 0;j<refC[1].size();++j)
00103 {
00104 if((refC[1])[j].Et()>refLeptonPt_)
00105 highPtElectrons++;
00106 }
00107 }
00108 if(refC.size()>2){
00109 for(size_t j = 0;j<refC[2].size();++j)
00110 {
00111 if((refC[2])[j].Et()>refLeptonPt_)
00112 highPtMuons++;
00113 }
00114 }
00115 if(highPtElectrons<nTriggeredLeptons_[0]&&LeptonType_[1]==82)
00116 {
00117 lepton_ok = false;
00118 }
00119 if(highPtMuons<nTriggeredLeptons_[0]&&LeptonType_[1]==83)
00120 {
00121 lepton_ok = false;
00122 }
00123 if(lepton_ok&&tau_ok)
00124 {
00125 accepted_events_matched->Fill(0.5);
00126 isGoodReferenceEvent=true;
00127 }
00128
00129
00130 }
00131
00132
00133 Handle<TriggerEventWithRefs> trigEv;
00134 bool gotTEV=iEvent.getByLabel(triggerEventObject_,trigEv) &&trigEv.isValid();
00135
00136 if(gotTEV)
00137 {
00138
00139 if (trigEv.isValid())
00140 {
00141
00142
00143
00144 for(size_t i=0;i<filter_.size();++i)
00145 {
00146 size_t ID =trigEv->filterIndex(filter_[i]);
00147
00148 if(ID!=trigEv->size())
00149 {
00150 LVColl leptons = getFilterCollection(ID,LeptonType_[i],*trigEv);
00151 LVColl taus = getFilterCollection(ID,TauType_[i],*trigEv);
00152
00153 if(leptons.size()>=nTriggeredLeptons_[i+1] && taus.size()>=nTriggeredTaus_[i+1])
00154 {
00155 accepted_events->Fill(i+0.5);
00156
00157 if(doRefAnalysis_)
00158 if(isGoodReferenceEvent)
00159 {
00160
00161 size_t nT=0;
00162 for(size_t j=0;j<taus.size();++j)
00163 {
00164 if(match(taus[j],refC[0],matchDeltaR_[i]))
00165 nT++;
00166
00167 }
00168 size_t nL=0;
00169 for(size_t j=0;j<leptons.size();++j)
00170 {
00171 if(refC[1].size()>0){
00172
00173 if(match(leptons[j],refC[1],matchDeltaR_[i]))
00174 nL++;
00175 }
00176
00177 if(refC[2].size()>0){
00178 if(match(leptons[j],refC[2],matchDeltaR_[i]))
00179 nL++;
00180 }
00181
00182 }
00183
00184 if(nT>=nTriggeredTaus_[i+1]&&nL>=nTriggeredLeptons_[i+1])
00185 accepted_events_matched->Fill(i+1.5);
00186 }
00187 }
00188 }
00189 }
00190 }
00191 }
00192 }
00193
00194
00195
00196
00197
00198 bool
00199 HLTTauDQMPathPlotter::match(const LV& jet,const LVColl& McInfo,double dr)
00200 {
00201
00202 bool matched=false;
00203
00204 if(McInfo.size()>0)
00205 for(std::vector<LV>::const_iterator it = McInfo.begin();it!=McInfo.end();++it)
00206 {
00207 double delta = ROOT::Math::VectorUtil::DeltaR(jet,*it);
00208 if(delta<dr)
00209 {
00210 matched=true;
00211 }
00212 }
00213
00214 return matched;
00215 }
00216
00217
00218
00219 LVColl HLTTauDQMPathPlotter::getFilterCollection(size_t filterID,int id,const trigger::TriggerEventWithRefs& trigEv)
00220 {
00221 using namespace trigger;
00222
00223 LVColl out;
00224
00225
00226 if(id==trigger::TriggerL1IsoEG ||trigger::TriggerL1NoIsoEG)
00227 {
00228 VRl1em obj;
00229 trigEv.getObjects(filterID,id,obj);
00230 for(size_t i=0;i<obj.size();++i)
00231 if(obj.at(i).isAvailable())
00232 out.push_back(obj[i]->p4());
00233 }
00234
00235 if(id==trigger::TriggerL1Mu)
00236 {
00237 VRl1muon obj;
00238 trigEv.getObjects(filterID,id,obj);
00239 for(size_t i=0;i<obj.size();++i)
00240 if(obj.at(i).isAvailable())
00241
00242 out.push_back(obj[i]->p4());
00243 }
00244
00245
00246 if(id==trigger::TriggerMuon)
00247 {
00248 VRmuon obj;
00249 trigEv.getObjects(filterID,id,obj);
00250 for(size_t i=0;i<obj.size();++i)
00251 if(obj.at(i).isAvailable())
00252
00253 out.push_back(obj[i]->p4());
00254 }
00255
00256 if(id==trigger::TriggerElectron)
00257 {
00258 VRelectron obj;
00259 trigEv.getObjects(filterID,id,obj);
00260 for(size_t i=0;i<obj.size();++i)
00261 if(obj.at(i).isAvailable())
00262 out.push_back(obj[i]->p4());
00263 }
00264
00265 if(id==trigger::TriggerL1TauJet)
00266 {
00267 VRl1jet obj;
00268 trigEv.getObjects(filterID,id,obj);
00269 for(size_t i=0;i<obj.size();++i)
00270 if(obj.at(i).isAvailable())
00271 out.push_back(obj[i]->p4());
00272 trigEv.getObjects(filterID,trigger::TriggerL1CenJet,obj);
00273 for(size_t i=0;i<obj.size();++i)
00274 if(obj.at(i).isAvailable())
00275 out.push_back(obj[i]->p4());
00276
00277 }
00278
00279 if(id==trigger::TriggerTau)
00280 {
00281 VRjet obj;
00282 trigEv.getObjects(filterID,id,obj);
00283 for(size_t i=0;i<obj.size();++i)
00284 if(obj.at(i).isAvailable())
00285 out.push_back(obj[i]->p4());
00286 }
00287
00288 return out;
00289 }