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
00069
00070 bool tau_ok=true;
00071 bool lepton_ok=true;
00072
00073 bool isGoodReferenceEvent=false;
00074
00075 if(doRefAnalysis_)
00076 {
00077
00078 if(refC.size()>0)
00079 {
00080 if(refC[0].size()<nTriggeredTaus_[0])
00081 {
00082 tau_ok = false;
00083 }
00084 else
00085 {
00086 unsigned int highPtTaus=0;
00087 for(size_t j = 0;j<refC[0].size();++j)
00088 {
00089 if((refC[0])[j].Et()>refTauPt_)
00090 highPtTaus++;
00091 }
00092 if(highPtTaus<nTriggeredTaus_[0])
00093 {
00094 tau_ok = false;
00095 }
00096
00097
00098 }
00099 }
00100
00101 if(refC.size()>1) {
00102 if(refC[1].size()<nTriggeredLeptons_[0])
00103 {
00104 lepton_ok = false;
00105 }
00106 else {
00107 unsigned int highPtLeptons=0;
00108 for(size_t j = 0;j<refC[1].size();++j)
00109 {
00110 if((refC[1])[j].Et()>refLeptonPt_)
00111 highPtLeptons++;
00112 }
00113 if(highPtLeptons<nTriggeredLeptons_[0])
00114 {
00115 lepton_ok = false;
00116 }
00117
00118 }
00119
00120 if(lepton_ok&&tau_ok)
00121 {
00122 accepted_events_matched->Fill(0.5);
00123 isGoodReferenceEvent=true;
00124 }
00125 }
00126
00127 }
00128
00129
00130 Handle<TriggerEventWithRefs> trigEv;
00131 bool gotTEV=iEvent.getByLabel(triggerEventObject_,trigEv) &&trigEv.isValid();
00132
00133 if(gotTEV)
00134 {
00135
00136 if (trigEv.isValid())
00137 {
00138
00139
00140
00141 for(size_t i=0;i<filter_.size();++i)
00142 {
00143
00144 size_t ID =trigEv->filterIndex(filter_[i]);
00145 if(ID!=trigEv->size())
00146 {
00147 LVColl leptons = getFilterCollection(ID,LeptonType_[i],*trigEv);
00148 LVColl taus = getFilterCollection(ID,TauType_[i],*trigEv);
00149
00150
00151 if(leptons.size()>=nTriggeredLeptons_[i+1] && taus.size()>=nTriggeredTaus_[i+1])
00152 {
00153 accepted_events->Fill(i+0.5);
00154
00155 if(doRefAnalysis_)
00156 if(isGoodReferenceEvent)
00157 {
00158
00159 size_t nT=0;
00160 for(size_t j=0;j<taus.size();++j)
00161 {
00162 if(match(taus[j],refC[0],matchDeltaR_[i]))
00163 nT++;
00164
00165 }
00166 size_t nL=0;
00167 for(size_t j=0;j<leptons.size();++j)
00168 {
00169 if(match(leptons[j],refC[1],matchDeltaR_[i]))
00170 nL++;
00171
00172 }
00173 if(nT>=nTriggeredTaus_[i+1]&&nL>=nTriggeredLeptons_[i+1])
00174 accepted_events_matched->Fill(i+1.5);
00175 }
00176 }
00177 }
00178 }
00179 }
00180 }
00181 }
00182
00183
00184
00185
00186
00187 bool
00188 HLTTauDQMPathPlotter::match(const LV& jet,const LVColl& McInfo,double dr)
00189 {
00190
00191 bool matched=false;
00192
00193 if(McInfo.size()>0)
00194 for(std::vector<LV>::const_iterator it = McInfo.begin();it!=McInfo.end();++it)
00195 {
00196 double delta = ROOT::Math::VectorUtil::DeltaR(jet,*it);
00197 if(delta<dr)
00198 {
00199 matched=true;
00200 }
00201 }
00202
00203 return matched;
00204 }
00205
00206
00207
00208 LVColl HLTTauDQMPathPlotter::getFilterCollection(size_t filterID,int id,const trigger::TriggerEventWithRefs& trigEv)
00209 {
00210 using namespace trigger;
00211
00212 LVColl out;
00213
00214
00215 if(id==trigger::TriggerL1IsoEG ||trigger::TriggerL1NoIsoEG)
00216 {
00217 VRl1em obj;
00218 trigEv.getObjects(filterID,id,obj);
00219 for(size_t i=0;i<obj.size();++i)
00220 if(obj.at(i).isAvailable())
00221 out.push_back(obj[i]->p4());
00222 }
00223
00224 if(id==trigger::TriggerL1Mu)
00225 {
00226 VRl1muon obj;
00227 trigEv.getObjects(filterID,id,obj);
00228 for(size_t i=0;i<obj.size();++i)
00229 if(obj.at(i).isAvailable())
00230
00231 out.push_back(obj[i]->p4());
00232 }
00233
00234
00235 if(id==trigger::TriggerMuon)
00236 {
00237 VRmuon 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 if(id==trigger::TriggerElectron)
00246 {
00247 VRelectron obj;
00248 trigEv.getObjects(filterID,id,obj);
00249 for(size_t i=0;i<obj.size();++i)
00250 if(obj.at(i).isAvailable())
00251 out.push_back(obj[i]->p4());
00252 }
00253
00254 if(id==trigger::TriggerL1TauJet)
00255 {
00256 VRl1jet obj;
00257 trigEv.getObjects(filterID,id,obj);
00258 for(size_t i=0;i<obj.size();++i)
00259 if(obj.at(i).isAvailable())
00260 out.push_back(obj[i]->p4());
00261 trigEv.getObjects(filterID,trigger::TriggerL1CenJet,obj);
00262 for(size_t i=0;i<obj.size();++i)
00263 if(obj.at(i).isAvailable())
00264 out.push_back(obj[i]->p4());
00265
00266 }
00267
00268 if(id==trigger::TriggerTau)
00269 {
00270 VRjet obj;
00271 trigEv.getObjects(filterID,id,obj);
00272 for(size_t i=0;i<obj.size();++i)
00273 if(obj.at(i).isAvailable())
00274 out.push_back(obj[i]->p4());
00275 }
00276
00277 return out;
00278 }