00001 #include "DQMOffline/Trigger/interface/HLTTauDQMCaloPlotter.h"
00002
00003 HLTTauDQMCaloPlotter::HLTTauDQMCaloPlotter( const edm::ParameterSet& iConfig, int etbins, int etabins, int phibins, double maxpt, bool ref, double dr, std::string dqmBaseFolder ) {
00004
00005 name_ = "HLTTauDQMCaloPlotter";
00006
00007
00008 try {
00009 l2preJets_ = iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("L2RegionalJets");
00010 l2TauInfoAssoc_ = iConfig.getUntrackedParameter<edm::InputTag>("L2InfoAssociationInput");
00011 triggerTag_ = iConfig.getUntrackedParameter<std::string>("DQMFolder");
00012 triggerTagAlias_ = iConfig.getUntrackedParameter<std::string>("Alias","");
00013 l2Isolated_ = iConfig.getUntrackedParameter<edm::InputTag>("L2IsolatedJets");
00014 matchDeltaRMC_ = dr;
00015 EtMax_ = maxpt;
00016 NPtBins_ = etbins;
00017 NEtaBins_ = etabins;
00018 NPhiBins_ = phibins;
00019 doRef_ = ref;
00020 dqmBaseFolder_ = dqmBaseFolder;
00021 validity_ = true;
00022 } catch ( cms::Exception &e ) {
00023 edm::LogInfo("HLTTauDQMCaloPlotter::HLTTauDQMCaloPlotter") << e.what() << std::endl;
00024 validity_ = false;
00025 return;
00026 }
00027
00028 if (store_) {
00029
00030 store_->setCurrentFolder(triggerTag());
00031 store_->removeContents();
00032
00033 preJetEt = store_->book1D("L2PreTauEt","L2 regional #tau E_{t};L2 regional Jet E_{T};entries",NPtBins_,0,EtMax_);
00034 preJetEta = store_->book1D("L2PreTauEta","L2 regional #tau #eta;L2 regional Jet #eta;entries",NEtaBins_,-2.5,2.5);
00035 preJetPhi = store_->book1D("L2PreTauPhi","L2 regional #tau #phi;L2 regional Jet #phi;entries",NPhiBins_,-3.2,3.2);
00036
00037 jetEt = store_->book1D("L2TauEt","L2 #tau E_{t};L2 selected Jet E_{T};entries",NPtBins_,0,EtMax_);
00038 jetEta = store_->book1D("L2TauEta","L2 #tau #eta;L2 selected Jet #eta;entries",NEtaBins_,-2.5,2.5);
00039 jetPhi = store_->book1D("L2TauPhi","L2 #tau #phi;L2 selected Jet #phi;entries",NPhiBins_,-3.2,3.2);
00040 jetEtRes = store_->book1D("L2TauEtResol","L2 #tau E_{t} resolution;L2 selected Jet #phi;entries",40,-2,2);
00041
00042 isoJetEt = store_->book1D("L2IsoTauEt","L2 isolated #tau E_{t};L2 isolated Jet E_{T};entries",NPtBins_,0,EtMax_);
00043 isoJetEta = store_->book1D("L2IsoTauEta","L2 isolated #tau #eta;L2 isolated Jet #eta;entries",NEtaBins_,-2.5,2.5);
00044 isoJetPhi = store_->book1D("L2IsoTauPhi","L2 isolated #tau #phi;L2 isolated Jet #phi;entries",NPhiBins_,-3.2,3.2);
00045
00046 ecalIsolEt = store_->book1D("L2EcalIsolation","ECAL Isolation;L2 ECAL isolation E_{T};entries",40,0,20);
00047 hcalIsolEt = store_->book1D("L2HcalIsolation","HCAL Isolation;L2 HCAL isolation E_{T};entries",40,0,20);
00048
00049 seedHcalEt = store_->book1D("L2HighestHCALCluster","Highest HCAL Cluster;HCAL seed E_{T};entries",40,0,80);
00050 seedEcalEt = store_->book1D("L2HighestECALCluster","Highest ECAL Cluster;ECAL seed E_{T};entries",25,0,50);
00051
00052 nEcalClusters = store_->book1D("L2NEcalClusters","Nucmber of ECAL Clusters;n. of ECAL Clusters;entries",20,0,20);
00053 ecalClusterEtaRMS = store_->book1D("L2EcalEtaRMS","ECAL Cluster #eta RMS;ECAL cluster #eta RMS;entries",15,0,0.05);
00054 ecalClusterPhiRMS = store_->book1D("L2EcalPhiRMS","ECAL Cluster #phi RMS;ECAL cluster #phi RMS;entries",30,0,0.1);
00055 ecalClusterDeltaRRMS = store_->book1D("L2EcalDeltaRRMS","ECAL Cluster #DeltaR RMS;ECAL cluster #DeltaR RMS;entries",30,0,0.1);
00056
00057 nHcalClusters = store_->book1D("L2NHcalClusters","Nucmber of HCAL Clusters;n. of ECAL Clusters;entries",20,0,20);
00058 hcalClusterEtaRMS = store_->book1D("L2HcalEtaRMS","HCAL Cluster #eta RMS;HCAL cluster #eta RMS;entries",15,0,0.05);
00059 hcalClusterPhiRMS = store_->book1D("L2HcalPhiRMS","HCAL Cluster #phi RMS;HCAL cluster #phi RMS;entries",30,0,0.1);
00060 hcalClusterDeltaRRMS = store_->book1D("L2HcalDeltaRRMS","HCAL Cluster #DeltaR RMS;HCAL cluster #DeltaR RMS;entries",30,0,0.1);
00061
00062
00063 store_->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
00064 store_->removeContents();
00065
00066 recoEtEffNum = store_->book1D("L2RecoTauEtEffNum","Efficiency vs E_{t}(Numerator)",NPtBins_,0,EtMax_);
00067 recoEtEffNum->getTH1F()->Sumw2();
00068
00069 recoEtEffDenom = store_->book1D("L2RecoTauEtEffDenom","Efficiency vs E_{t}(Denominator)",NPtBins_,0,EtMax_);
00070 recoEtEffDenom->getTH1F()->Sumw2();
00071
00072 recoEtaEffNum = store_->book1D("L2RecoTauEtaEffNum","Efficiency vs #eta (Numerator)",NEtaBins_,-2.5,2.5);
00073 recoEtaEffNum->getTH1F()->Sumw2();
00074
00075 recoEtaEffDenom = store_->book1D("L2RecoTauEtaEffDenom","Efficiency vs #eta(Denominator)",NEtaBins_,-2.5,2.5);
00076 recoEtaEffDenom->getTH1F()->Sumw2();
00077
00078 recoPhiEffNum = store_->book1D("L2RecoTauPhiEffNum","Efficiency vs #phi (Numerator)",NPhiBins_,-3.2,3.2);
00079 recoPhiEffNum->getTH1F()->Sumw2();
00080
00081 recoPhiEffDenom = store_->book1D("L2RecoTauPhiEffDenom","Efficiency vs #phi(Denominator)",NPhiBins_,-3.2,3.2);
00082 recoPhiEffDenom->getTH1F()->Sumw2();
00083
00084 isoEtEffNum = store_->book1D("L2IsoTauEtEffNum","Efficiency vs E_{t}(Numerator)",NPtBins_,0,EtMax_);
00085 isoEtEffNum->getTH1F()->Sumw2();
00086
00087 isoEtEffDenom = store_->book1D("L2IsoTauEtEffDenom","Efficiency vs E_{t}(Denominator)",NPtBins_,0,EtMax_);
00088 isoEtEffDenom->getTH1F()->Sumw2();
00089
00090 isoEtaEffNum = store_->book1D("L2IsoTauEtaEffNum","Efficiency vs #eta (Numerator)",NEtaBins_,-2.5,2.5);
00091 isoEtaEffNum->getTH1F()->Sumw2();
00092
00093 isoEtaEffDenom = store_->book1D("L2IsoTauEtaEffDenom","Efficiency vs #eta(Denominator)",NEtaBins_,-2.5,2.5);
00094 isoEtaEffDenom->getTH1F()->Sumw2();
00095
00096 isoPhiEffNum = store_->book1D("L2IsoTauPhiEffNum","Efficiency vs #phi (Numerator)",NPhiBins_,-3.2,3.2);
00097 isoPhiEffNum->getTH1F()->Sumw2();
00098
00099 isoPhiEffDenom = store_->book1D("L2IsoTauPhiEffDenom","Efficiency vs #phi(Denominator)",NPhiBins_,-3.2,3.2);
00100 isoPhiEffDenom->getTH1F()->Sumw2();
00101 }
00102 }
00103
00104 HLTTauDQMCaloPlotter::~HLTTauDQMCaloPlotter() {
00105 }
00106
00107 void HLTTauDQMCaloPlotter::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::map<int,LVColl>& McInfo ) {
00108 edm::Handle<reco::L2TauInfoAssociation> l2TauInfoAssoc;
00109 edm::Handle<reco::CaloJetCollection> l2Isolated;
00110 edm::Handle<reco::CaloJetCollection> l2Regional;
00111 reco::CaloJetCollection l2RegionalJets;
00112
00113
00114 reco::CaloJetCollection l2MergedJets;
00115
00116 for ( unsigned int j = 0; j < l2preJets_.size(); ++j ) {
00117 bool gotPreJets = iEvent.getByLabel(l2preJets_[j],l2Regional) && l2Regional.isValid();
00118
00119 if (gotPreJets) {
00120 if ( !l2Regional.failedToGet() ) {
00121 for ( unsigned int i = 0; i < l2Regional->size(); ++i ) {
00122 l2MergedJets.push_back(l2Regional->at(i));
00123 }
00124 }
00125 }
00126 }
00127
00128
00129 SorterByPt sorter;
00130 std::sort(l2MergedJets.begin(),l2MergedJets.end(),sorter);
00131
00132
00133 reco::CaloJetCollection l2CleanJets;
00134 while (l2MergedJets.size() > 0 ) {
00135 l2CleanJets.push_back(l2MergedJets.at(0));
00136 reco::CaloJetCollection tmp;
00137
00138 for ( unsigned int i = 1; i < l2MergedJets.size(); ++i ) {
00139 double DR = ROOT::Math::VectorUtil::DeltaR( l2MergedJets.at(0).p4(), l2MergedJets.at(i).p4() );
00140 if ( DR > 0.1 ) tmp.push_back(l2MergedJets.at(i));
00141 }
00142
00143 l2MergedJets.swap(tmp);
00144 tmp.clear();
00145 }
00146
00147
00148 std::map<int,LVColl>::const_iterator iref;
00149 iref = McInfo.find(15);
00150
00151
00152 if ( doRef_ ) {
00153 if ( iref != McInfo.end() ) {
00154 for ( LVColl::const_iterator iter = iref->second.begin(); iter != iref->second.end(); ++iter ) {
00155 std::pair<bool,reco::CaloJet> m = inverseMatch(*iter,l2CleanJets);
00156 if ( m.first ) {
00157 preJetEt->Fill(m.second.pt());
00158 preJetEta->Fill(m.second.eta());
00159 preJetPhi->Fill(m.second.phi());
00160 recoEtEffDenom->Fill(iter->pt());
00161 recoEtaEffDenom->Fill(iter->eta());
00162 recoPhiEffDenom->Fill(iter->phi());
00163 l2RegionalJets.push_back(m.second);
00164 }
00165 }
00166 }
00167 } else {
00168 for ( unsigned int i = 0; i < l2CleanJets.size(); ++i ) {
00169 reco::CaloJet jet = l2CleanJets.at(i);
00170 preJetEt->Fill(jet.pt());
00171 preJetEta->Fill(jet.eta());
00172 preJetPhi->Fill(jet.phi());
00173 recoEtEffDenom->Fill(jet.pt());
00174 recoEtaEffDenom->Fill(jet.eta());
00175 recoPhiEffDenom->Fill(jet.phi());
00176 l2RegionalJets.push_back(jet);
00177 }
00178 }
00179
00180 bool gotL2 = iEvent.getByLabel(l2TauInfoAssoc_,l2TauInfoAssoc) && l2TauInfoAssoc.isValid();
00181
00182
00183 if ( gotL2 && l2TauInfoAssoc->size() > 0 ) {
00184 for ( reco::L2TauInfoAssociation::const_iterator p = l2TauInfoAssoc->begin(); p != l2TauInfoAssoc->end(); ++p ) {
00185
00186 const reco::L2TauIsolationInfo l2info = p->val;
00187
00188
00189 const reco::Jet& jet =*(p->key);
00190
00191 std::pair<bool,LV> m(false,LV());
00192 if ( iref != McInfo.end() ) m = match(jet.p4(),iref->second,matchDeltaRMC_);
00193
00194 if ( (doRef_ && m.first) || (!doRef_) ) {
00195 ecalIsolEt->Fill(l2info.ecalIsolEt());
00196 hcalIsolEt->Fill(l2info.hcalIsolEt());
00197 seedEcalEt->Fill(l2info.seedEcalHitEt());
00198 seedHcalEt->Fill(l2info.seedHcalHitEt());
00199
00200 nEcalClusters->Fill(l2info.nEcalHits());
00201 ecalClusterEtaRMS->Fill(l2info.ecalClusterShape().at(0));
00202 ecalClusterPhiRMS->Fill(l2info.ecalClusterShape().at(1));
00203 ecalClusterDeltaRRMS->Fill(l2info.ecalClusterShape().at(2));
00204
00205 nHcalClusters->Fill(l2info.nHcalHits());
00206 hcalClusterEtaRMS->Fill(l2info.hcalClusterShape().at(0));
00207 hcalClusterPhiRMS->Fill(l2info.hcalClusterShape().at(1));
00208 hcalClusterDeltaRRMS->Fill(l2info.hcalClusterShape().at(2));
00209
00210 jetEt->Fill(jet.et());
00211 jetEta->Fill(jet.eta());
00212 jetPhi->Fill(jet.phi());
00213
00214 LV refLV;
00215 if ( doRef_ ) {
00216 refLV = m.second;
00217 } else {
00218 refLV = jet.p4();
00219 }
00220 if ( doRef_ ) {
00221 jetEtRes->Fill((jet.pt()-refLV.pt())/refLV.pt());
00222 }
00223 if ( matchJet(jet,l2RegionalJets) ) {
00224 recoEtEffNum->Fill(refLV.pt());
00225 recoEtaEffNum->Fill(refLV.eta());
00226 recoPhiEffNum->Fill(refLV.phi());
00227 }
00228
00229 isoEtEffDenom->Fill(refLV.pt());
00230 isoEtaEffDenom->Fill(refLV.eta());
00231 isoPhiEffDenom->Fill(refLV.phi());
00232
00233 bool gotIsoL2 = iEvent.getByLabel(l2Isolated_,l2Isolated) && l2Isolated.isValid();
00234
00235 if ( gotIsoL2 ) {
00236 if ( matchJet(jet,*l2Isolated) ) {
00237 isoJetEt->Fill(jet.et());
00238 isoJetEta->Fill(jet.eta());
00239 isoJetPhi->Fill(jet.phi());
00240
00241 isoEtEffNum->Fill(refLV.pt());
00242 isoEtaEffNum->Fill(refLV.eta());
00243 isoPhiEffNum->Fill(refLV.phi());
00244 }
00245 }
00246 }
00247 }
00248 }
00249 }
00250
00251 std::pair<bool,reco::CaloJet> HLTTauDQMCaloPlotter::inverseMatch( const LV& jet, const reco::CaloJetCollection& jets ) {
00252
00253
00254
00255 bool matched = false;
00256 reco::CaloJet mjet;
00257 double distance = 100000;
00258 for ( reco::CaloJetCollection::const_iterator it = jets.begin(); it != jets.end(); ++it ) {
00259 if ( ROOT::Math::VectorUtil::DeltaR(it->p4(),jet) < matchDeltaRMC_ ) {
00260 matched = true;
00261 double delta = fabs(jet.pt()-it->pt());
00262 if (delta < distance) {
00263 distance = delta;
00264 mjet = *it;
00265 }
00266 }
00267 }
00268
00269 std::pair<bool,reco::CaloJet> p = std::make_pair(matched,mjet);
00270 return p;
00271 }
00272
00273 bool HLTTauDQMCaloPlotter::matchJet( const reco::Jet& jet, const reco::CaloJetCollection& McInfo ) {
00274
00275
00276
00277 bool matched = false;
00278
00279 for ( reco::CaloJetCollection::const_iterator it = McInfo.begin(); it != McInfo.end(); ++it ) {
00280 if ( jet.p4() == it->p4() ) {
00281 matched = true;
00282 break;
00283 }
00284 }
00285 return matched;
00286 }