00001
00002
00004 #include "HLTriggerOffline/Egamma/interface/EmDQMReco.h"
00005
00007
00009 #include "FWCore/Framework/interface/Frameworkfwd.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Framework/interface/MakerMacros.h"
00012 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00013 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00014 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00015
00016
00017 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00018 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
00019
00020 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "DataFormats/Common/interface/AssociationMap.h"
00023
00024 #include "DataFormats/Common/interface/Handle.h"
00025 #include "DataFormats/Common/interface/RefToBase.h"
00026 #include "FWCore/ServiceRegistry/interface/Service.h"
00027
00028 #include "FWCore/Utilities/interface/Exception.h"
00029 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00030 #include "DataFormats/Common/interface/TriggerResults.h"
00031 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00032 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00033 #include <boost/format.hpp>
00035
00037 #include "TFile.h"
00038 #include "TDirectory.h"
00039 #include "TH1F.h"
00040 #include <iostream>
00041 #include <string>
00042 #include <Math/VectorUtil.h>
00043 using namespace ROOT::Math::VectorUtil ;
00044
00045
00046
00047
00048 EmDQMReco::FourVectorMonitorElements::FourVectorMonitorElements(EmDQMReco *_parent,
00049 const std::string &histogramNameTemplate,
00050 const std::string &histogramTitleTemplate
00051 ) :
00052 parent(_parent)
00053 {
00054
00055 std::string histName;
00056 std::string histTitle;
00057
00058
00059 histName = boost::str(boost::format(histogramNameTemplate) % "et");
00060 histTitle = boost::str(boost::format(histogramTitleTemplate) % "E_{T}");
00061 etMonitorElement = parent->dbe->book1D(histName.c_str(),
00062 histTitle.c_str(),
00063 parent->plotBins,
00064 parent->plotPtMin,
00065 parent->plotPtMax);
00066
00067
00068 histName = boost::str(boost::format(histogramNameTemplate) % "eta");
00069 histTitle= boost::str(boost::format(histogramTitleTemplate) % "#eta");
00070 etaMonitorElement = parent->dbe->book1D(histName.c_str(),
00071 histTitle.c_str(),
00072 parent->plotBins,
00073 - parent->plotEtaMax,
00074 parent->plotEtaMax);
00075
00076
00077 histName = boost::str(boost::format(histogramNameTemplate) % "phi");
00078 histTitle= boost::str(boost::format(histogramTitleTemplate) % "#phi");
00079 phiMonitorElement = parent->dbe->book1D(histName.c_str(),
00080 histTitle.c_str(),
00081 parent->plotBins,
00082 - parent->plotPhiMax,
00083 parent->plotPhiMax);
00084 }
00085
00086
00087
00088 void
00089 EmDQMReco::FourVectorMonitorElements::fill(const math::XYZTLorentzVector &momentum)
00090 {
00091 etMonitorElement->Fill(momentum.Et());
00092 etaMonitorElement->Fill(momentum.eta() );
00093 phiMonitorElement->Fill(momentum.phi() );
00094 }
00095
00096
00097
00099
00101 EmDQMReco::EmDQMReco(const edm::ParameterSet& pset)
00102 {
00103
00104 dbe = edm::Service < DQMStore > ().operator->();
00105 dbe->setVerbose(0);
00106
00107
00109
00111 dirname_="HLT/HLTEgammaValidation/"+pset.getParameter<std::string>("@module_label");
00112 dbe->setCurrentFolder(dirname_);
00113
00114
00115 reqNum = pset.getParameter<unsigned int>("reqNum");
00116 pdgGen = pset.getParameter<int>("pdgGen");
00117 recoEtaAcc = pset.getParameter<double>("genEtaAcc");
00118 recoEtAcc = pset.getParameter<double>("genEtAcc");
00119
00120 plotPtMin = pset.getUntrackedParameter<double>("PtMin",0.);
00121 plotPtMax = pset.getUntrackedParameter<double>("PtMax",1000.);
00122 plotEtaMax = pset.getUntrackedParameter<double>("EtaMax", 2.7);
00123 plotPhiMax = pset.getUntrackedParameter<double>("PhiMax", 3.15);
00124 plotBins = pset.getUntrackedParameter<unsigned int>("Nbins",50);
00125 useHumanReadableHistTitles = pset.getUntrackedParameter<bool>("useHumanReadableHistTitles", false);
00126
00127 triggerNameRecoMonPath = pset.getUntrackedParameter<std::string>("triggerNameRecoMonPath","HLT_MinBias");
00128 processNameRecoMonPath = pset.getUntrackedParameter<std::string>("processNameRecoMonPath","HLT");
00129
00130 recoElectronsInputTag = pset.getUntrackedParameter<edm::InputTag>("recoElectrons",edm::InputTag("gsfElectrons"));
00131
00132
00133
00134 recocut_ = pset.getParameter<int>("cutnum");
00135
00136
00137 eventnum = 0;
00138
00139
00140 isHltConfigInitialized_ = false;
00141
00143
00144
00146 std::vector<edm::ParameterSet> filters =
00147 pset.getParameter<std::vector<edm::ParameterSet> >("filters");
00148
00149 int i = 0;
00150 for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++)
00151 {
00152
00153 theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
00154 theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
00155
00156 theHLTCollectionHumanNames.push_back(filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName",theHLTCollectionLabels[i].label()));
00157
00158 std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
00159
00160 assert(bounds.size() == 2);
00161 plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
00162 isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
00163
00164 assert(isoNames.back().size()>0);
00165 if (isoNames.back().at(0).label()=="none") {
00166 plotiso.push_back(false);
00167 } else {
00168 plotiso.push_back(true);
00169 }
00170 i++;
00171 }
00172
00173
00174 numOfHLTCollectionLabels = theHLTCollectionLabels.size();
00175
00176 }
00177
00178
00179
00183 void EmDQMReco::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup ) {
00184
00185 bool isHltConfigChanged = false;
00186 isHltConfigInitialized_ = hltConfig_.init( iRun, iSetup, "HLT", isHltConfigChanged );
00187
00188 }
00189
00190
00191
00192
00193
00195
00197 void
00198 EmDQMReco::beginJob()
00199 {
00200
00201 dbe->setCurrentFolder(dirname_);
00202
00204
00205
00206
00208
00209 std::string histName="total_eff";
00210 std::string histTitle = "total events passing";
00211
00212
00213 totalreco = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
00214 totalreco->setBinLabel(numOfHLTCollectionLabels+1,"Total");
00215 totalreco->setBinLabel(numOfHLTCollectionLabels+2,"Reco");
00216 for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
00217
00218 histName="total_eff_RECO_matched";
00219 histTitle="total events passing (Reco matched)";
00220 totalmatchreco = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
00221 totalmatchreco->setBinLabel(numOfHLTCollectionLabels+1,"Total");
00222 totalmatchreco->setBinLabel(numOfHLTCollectionLabels+2,"Reco");
00223 for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalmatchreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
00224
00225
00226 MonitorElement* tmpiso;
00227
00229
00231 std::string pdgIdString;
00232 switch(pdgGen) {
00233 case 11:
00234 pdgIdString="Electron";break;
00235 case 22:
00236 pdgIdString="Photon";break;
00237 default:
00238 pdgIdString="Particle";
00239 }
00240
00241
00242
00243
00244
00245 histReco.reset(
00246 new FourVectorMonitorElements(this,
00247 "reco_%s",
00248 "%s of " + pdgIdString + "s"
00249 ));
00250
00251
00252
00253
00254 histRecoMonpath.reset(
00255 new FourVectorMonitorElements(this,
00256 "reco_%s_monpath",
00257 "%s of " + pdgIdString + "s monpath"
00258 )
00259 );
00260
00261
00262
00263
00264
00265 histMonpath.reset(
00266 new FourVectorMonitorElements(this,
00267 "final_%s_monpath",
00268 "Final %s Monpath"
00269 )
00270 );
00271
00272
00273
00275
00277
00278
00279 std::vector<std::string> HltHistTitle;
00280 if ( theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles ) {
00281 HltHistTitle = theHLTCollectionHumanNames;
00282 } else {
00283 for (unsigned int i =0; i < numOfHLTCollectionLabels; i++) {
00284 HltHistTitle.push_back(theHLTCollectionLabels[i].label());
00285 }
00286 }
00287
00288 for(unsigned int i = 0; i< numOfHLTCollectionLabels ; i++){
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 standardHist.push_back(new FourVectorMonitorElements(this,
00312 theHLTCollectionLabels[i].label()+"%s_all",
00313 HltHistTitle[i]+" %s (ALL)"
00314 ));
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 histMatchReco.push_back(new FourVectorMonitorElements(this,
00338 theHLTCollectionLabels[i].label()+"%s_RECO_matched",
00339 HltHistTitle[i]+" %s (RECO matched)"
00340 ));
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 histMatchRecoMonPath.push_back(new FourVectorMonitorElements(this,
00365 theHLTCollectionLabels[i].label()+"%s_RECO_matched_monpath",
00366 HltHistTitle[i]+" %s (RECO matched, monpath)"
00367 ));
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 histHltObjMatchToReco.push_back(new FourVectorMonitorElements(this,
00391 theHLTCollectionLabels[i].label()+"%s_reco",
00392 HltHistTitle[i]+" %s (reco)"
00393 ));
00394
00395
00396
00397 if (!plotiso[i]) {
00398 tmpiso = NULL;
00399 etahistiso.push_back(tmpiso);
00400 ethistiso.push_back(tmpiso);
00401 phiHistIso.push_back(tmpiso);
00402
00403 etahistisomatchreco.push_back(tmpiso);
00404 ethistisomatchreco.push_back(tmpiso);
00405 phiHistIsoMatchReco.push_back(tmpiso);
00406
00407 histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
00408 histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
00409 histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
00410
00411 } else {
00412
00413
00414
00415
00416
00417
00418 histName = theHLTCollectionLabels[i].label()+"eta_isolation_all";
00419 histTitle = HltHistTitle[i]+" isolation vs #eta (all)";
00420 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00421 etahistiso.push_back(tmpiso);
00422
00423
00424 histName = theHLTCollectionLabels[i].label()+"et_isolation_all";
00425 histTitle = HltHistTitle[i]+" isolation vs Et (all)";
00426 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00427 ethistiso.push_back(tmpiso);
00428
00429
00430 histName = theHLTCollectionLabels[i].label()+"phi_isolation_all";
00431 histTitle = HltHistTitle[i]+" isolation vs #phi (all)";
00432 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00433 phiHistIso.push_back(tmpiso);
00434
00435
00436
00437
00438
00439
00440 histName = theHLTCollectionLabels[i].label()+"eta_isolation_RECO_matched";
00441 histTitle = HltHistTitle[i]+" isolation vs #eta (reco matched)";
00442 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00443 etahistisomatchreco.push_back(tmpiso);
00444
00445
00446 histName = theHLTCollectionLabels[i].label()+"et_isolation_RECO_matched";
00447 histTitle = HltHistTitle[i]+" isolation vs Et (reco matched)";
00448 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00449 ethistisomatchreco.push_back(tmpiso);
00450
00451
00452 histName = theHLTCollectionLabels[i].label()+"phi_isolation_RECO_matched";
00453 histTitle = HltHistTitle[i]+" isolation vs #phi (reco matched)";
00454 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00455 phiHistIsoMatchReco.push_back(tmpiso);
00456
00457
00458
00459
00460
00461
00462
00463 histName = theHLTCollectionLabels[i].label()+"eta_isolation_reco";
00464 histTitle = HltHistTitle[i]+" isolation vs #eta (reco)";
00465 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00466 histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
00467
00468
00469 histName = theHLTCollectionLabels[i].label()+"et_isolation_reco";
00470 histTitle = HltHistTitle[i]+" isolation vs Et (reco)";
00471 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00472 histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
00473
00474
00475 histName = theHLTCollectionLabels[i].label()+"phi_isolation_reco";
00476 histTitle = HltHistTitle[i]+" isolation vs #phi (reco)";
00477 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
00478 histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
00479
00480
00481 }
00482
00483 }
00484 }
00485
00486
00488
00490 EmDQMReco::~EmDQMReco(){
00491 }
00492
00493
00495
00497 void
00498 EmDQMReco::analyze(const edm::Event & event , const edm::EventSetup& setup)
00499 {
00500
00501
00502 if( !isHltConfigInitialized_ ) return;
00503
00504 eventnum++;
00505 bool plotMonpath = false;
00506 bool plotReco = true;
00507
00508 edm::Handle<edm::View<reco::Candidate> > recoObjects;
00509 edm::Handle<std::vector<reco::SuperCluster> > recoObjectsEB;
00510 edm::Handle<std::vector<reco::SuperCluster> > recoObjectsEE;
00511
00512 if (pdgGen == 11) {
00513
00514 event.getByLabel(recoElectronsInputTag, recoObjects);
00515
00516 if (recoObjects->size() < (unsigned int)recocut_) {
00517
00518 return;
00519 }
00520 } else if (pdgGen == 22) {
00521
00522 event.getByLabel("correctedHybridSuperClusters", recoObjectsEB);
00523 event.getByLabel("correctedMulti5x5SuperClustersWithPreshower", recoObjectsEE);
00524
00525 if (recoObjectsEB->size() + recoObjectsEE->size() < (unsigned int)recocut_) {
00526
00527 return;
00528 }
00529 }
00530
00531 edm::Handle<edm::TriggerResults> HLTR;
00532 event.getByLabel(edm::InputTag("TriggerResults","",processNameRecoMonPath), HLTR);
00533
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 unsigned int triggerIndex;
00550 triggerIndex = hltConfig_.triggerIndex(triggerNameRecoMonPath);
00551
00552
00553 bool isFired = false;
00554 if (triggerIndex < HLTR->size()){
00555 isFired = HLTR->accept(triggerIndex);
00556 }
00557
00558
00559
00560 edm::Handle<trigger::TriggerEventWithRefs> triggerObj;
00561 event.getByLabel("hltTriggerSummaryRAW",triggerObj);
00562 if(!triggerObj.isValid()) {
00563 edm::LogWarning("EmDQMReco") << "RAW-type HLT results not found, skipping event";
00564 return;
00565 }
00566
00568
00569
00571 totalreco->Fill(numOfHLTCollectionLabels+0.5);
00572 totalmatchreco->Fill(numOfHLTCollectionLabels+.5);
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00591
00592
00594
00595
00596
00597
00599
00601
00602
00603 std::vector<reco::Particle> sortedReco;
00604 if (plotReco == true) {
00605 if (pdgGen == 11) {
00606 for(edm::View<reco::Candidate>::const_iterator recopart = recoObjects->begin(); recopart != recoObjects->end();recopart++){
00607 reco::Particle tmpcand( recopart->charge(), recopart->p4(), recopart->vertex(),recopart->pdgId(),recopart->status() );
00608 sortedReco.push_back(tmpcand);
00609 }
00610 }
00611 else if (pdgGen == 22) {
00612 for(std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEB->begin(); recopart2 != recoObjectsEB->end();recopart2++){
00613 float en = recopart2->energy();
00614 float er = sqrt(pow(recopart2->x(),2) + pow(recopart2->y(),2) + pow(recopart2->z(),2) );
00615 float px = recopart2->energy()*recopart2->x()/er;
00616 float py = recopart2->energy()*recopart2->y()/er;
00617 float pz = recopart2->energy()*recopart2->z()/er;
00618 reco::Candidate::LorentzVector thisLV(px,py,pz,en);
00619 reco::Particle tmpcand( 0, thisLV, math::XYZPoint(0.,0.,0.), 22, 1 );
00620 sortedReco.push_back(tmpcand);
00621 }
00622 for(std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEE->begin(); recopart2 != recoObjectsEE->end();recopart2++){
00623 float en = recopart2->energy();
00624 float er = sqrt(pow(recopart2->x(),2) + pow(recopart2->y(),2) + pow(recopart2->z(),2) );
00625 float px = recopart2->energy()*recopart2->x()/er;
00626 float py = recopart2->energy()*recopart2->y()/er;
00627 float pz = recopart2->energy()*recopart2->z()/er;
00628 reco::Candidate::LorentzVector thisLV(px,py,pz,en);
00629 reco::Particle tmpcand( 0, thisLV, math::XYZPoint(0.,0.,0.), 22, 1 );
00630 sortedReco.push_back(tmpcand);
00631 }
00632 }
00633
00634 std::sort(sortedReco.begin(),sortedReco.end(),pTComparator_ );
00635
00636
00637
00638
00639
00640 sortedReco.erase(sortedReco.begin()+recocut_,sortedReco.end());
00641
00642 for (unsigned int i = 0 ; i < recocut_ ; i++ ) {
00643
00644 histReco->fill(sortedReco[i].p4());
00645
00646
00647
00648
00649
00650 if (isFired) {
00651 histRecoMonpath->fill(sortedReco[i].p4());
00652 plotMonpath = true;
00653 }
00654
00655 }
00656
00657 if (recocut_ >= reqNum) totalreco->Fill(numOfHLTCollectionLabels+1.5);
00658 if (recocut_ >= reqNum) totalmatchreco->Fill(numOfHLTCollectionLabels+1.5);
00659
00660 }
00661
00662
00663
00664
00666
00668 for(unsigned int n=0; n < numOfHLTCollectionLabels ; n++) {
00669
00670
00671 switch(theHLTOutputTypes[n])
00672 {
00673 case trigger::TriggerL1NoIsoEG:
00674 fillHistos<l1extra::L1EmParticleCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
00675 case trigger::TriggerL1IsoEG:
00676 fillHistos<l1extra::L1EmParticleCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
00677 case trigger::TriggerPhoton:
00678 fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
00679 case trigger::TriggerElectron:
00680 fillHistos<reco::ElectronCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
00681 case trigger::TriggerCluster:
00682 fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
00683 default:
00684 throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
00685 }
00686 }
00687 }
00688
00689
00691
00692
00694 template <class T> void EmDQMReco::fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& triggerObj,const edm::Event& iEvent ,unsigned int n, std::vector<reco::Particle>& sortedReco, bool plotReco, bool plotMonpath)
00695 {
00696 std::vector<edm::Ref<T> > recoecalcands;
00697 if ( ( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){
00698 return;
00699 }
00700
00702
00704 triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],recoecalcands);
00705
00706
00707 if (theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG){
00708 std::vector<edm::Ref<T> > isocands;
00709 triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
00710 if (isocands.size()>0)
00711 {
00712 for (unsigned int i=0; i < isocands.size(); i++)
00713 recoecalcands.push_back(isocands[i]);
00714 }
00715 }
00716
00717
00718 if (recoecalcands.size() < 1){
00719 return;
00720 }
00721
00722
00723 if (recoecalcands.size() >= reqNum )
00724 totalreco->Fill(n+0.5);
00725
00726
00728
00729
00731 for (unsigned int j=0; j<recoecalcands.size(); j++){
00732 if(!( recoecalcands.at(j).isAvailable())){
00733 edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl << "invalid refs for: " << theHLTCollectionLabels[n].label();
00734 return;
00735 }
00736 }
00737
00739
00740
00742
00743
00744 for (unsigned int i=0; i<recoecalcands.size(); i++) {
00745
00746 standardHist[n].fill(recoecalcands[i]->p4());
00747
00749
00750
00752 if ( n+1 < numOfHLTCollectionLabels ) {
00753 if (plotiso[n+1]) {
00754 for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
00755 edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap;
00756 iEvent.getByLabel(isoNames[n+1].at(j),depMap);
00757 if (depMap.isValid()){
00758 typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
00759 if (mapi!=depMap->end()){
00760 etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
00761 ethistiso[n+1]->Fill(recoecalcands[i]->et() ,mapi->val);
00762 phiHistIso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
00763 }
00764 }
00765 }
00766 }
00767 }
00768 }
00769
00771
00772
00774 if (plotReco == true) {
00775 for (unsigned int i=0; i < recocut_; i++) {
00776 math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
00777
00778
00779 float closestRecoDeltaR = 1000.;
00780 int closestRecoEcalCandIndex = -1;
00781 for (unsigned int j=0; j<recoecalcands.size(); j++) {
00782 float deltaR = DeltaR(recoecalcands[j]->momentum(),currentRecoParticleMomentum);
00783
00784 if (deltaR < closestRecoDeltaR) {
00785 closestRecoDeltaR = deltaR;
00786 closestRecoEcalCandIndex = j;
00787 }
00788 }
00789
00790
00791
00792 if ( closestRecoEcalCandIndex >= 0 ) {
00793
00794
00795
00796
00797 histHltObjMatchToReco[n].fill(recoecalcands[closestRecoEcalCandIndex]->p4());
00798
00799
00800 if (n+1 < numOfHLTCollectionLabels){
00801 if (plotiso[n+1] ){
00802 for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
00803 edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMap;
00804 iEvent.getByLabel(isoNames[n+1].at(j),depMap);
00805 if (depMap.isValid()){
00806 typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestRecoEcalCandIndex]);
00807 if (mapi!=depMap->end()) {
00808 histEtaIsoOfHltObjMatchToReco[n+1]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta(),mapi->val);
00809 histEtIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et(), mapi->val);
00810 histPhiIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->phi(), mapi->val);
00811 }
00812 }
00813 }
00814 }
00815 }
00816 }
00817 }
00818
00820
00822 unsigned int mtachedRecoParts = 0;
00823 float minrecodist=0.3;
00824 if(n==0) minrecodist=0.5;
00825 for(unsigned int i =0; i < recocut_; i++){
00826
00827 bool matchThis= false;
00828 math::XYZVector candDir=sortedReco[i].momentum();
00829 unsigned int closest = 0;
00830 double closestDr = 1000.;
00831 for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
00832 double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
00833 if (dr < closestDr) {
00834 closestDr = dr;
00835 closest = trigOb;
00836 }
00837 if (closestDr > minrecodist) {
00838 closest = -1;
00839 } else {
00840 mtachedRecoParts++;
00841 matchThis = true;
00842 }
00843 }
00844 if ( !matchThis ) continue;
00845
00846
00847
00848
00849 histMatchReco[n].fill(sortedReco[i].p4());
00850
00851 if (plotMonpath) {
00852
00853
00854
00855 histMatchRecoMonPath[n].fill(sortedReco[i].p4());
00856
00857 }
00859
00860
00862 if (n+1 < numOfHLTCollectionLabels){
00863 if (plotiso[n+1] ){
00864 for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
00865 edm::Handle<edm::AssociationMap<edm::OneToValue< T , float > > > depMapReco;
00866 iEvent.getByLabel(isoNames[n+1].at(j),depMapReco);
00867 if (depMapReco.isValid()){
00868 typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMapReco->find(recoecalcands[closest]);
00869 if (mapi!=depMapReco->end()){
00870 etahistisomatchreco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
00871 ethistisomatchreco[n+1]->Fill(sortedReco[i].et(),mapi->val);
00872 phiHistIsoMatchReco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
00873 }
00874 }
00875 }
00876 }
00877 }
00878 }
00879
00880 if (mtachedRecoParts >= reqNum )
00881 totalmatchreco->Fill(n+0.5);
00882 }
00883
00884 }
00885
00886
00888
00890 void EmDQMReco::endJob(){
00891
00892 }
00893
00894 DEFINE_FWK_MODULE(EmDQMReco);