00001
00015 #include "DQMOffline/Trigger/interface/HLTMuonMatchAndPlot.h"
00016
00017 #include "DataFormats/Math/interface/deltaR.h"
00018
00019 #include "FWCore/Framework/interface/Run.h"
00020 #include "FWCore/Framework/interface/EventSetup.h"
00021
00022 #include "FWCore/ServiceRegistry/interface/Service.h"
00023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00024 #include "DataFormats/Common/interface/Handle.h"
00025 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00026 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00027 #include "DataFormats/Candidate/interface/CandMatchMap.h"
00028 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00029 #include "DataFormats/VertexReco/interface/Vertex.h"
00030 #include "DataFormats/Common/interface/TriggerResults.h"
00031 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00032
00033
00034 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00035 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00036
00037 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00038
00039 #include "TPRegexp.h"
00040 #include <iostream>
00041
00042 using namespace std;
00043 using namespace edm;
00044 using namespace reco;
00045 using namespace trigger;
00046 using namespace l1extra;
00047
00048 typedef std::vector< edm::ParameterSet > Parameters;
00049 typedef std::vector<reco::Muon> MuonCollection;
00050
00051 const int numCones = 3;
00052 const int numMinPtCuts = 1;
00053 double coneSizes[] = { 0.20, 0.24, 0.30 };
00054 double minPtCuts[] = { 0. };
00055
00056 const int HLTMuonMatchAndPlot::POS_CHARGE;
00057 const int HLTMuonMatchAndPlot::NEG_CHARGE;
00058
00060 HLTMuonMatchAndPlot::HLTMuonMatchAndPlot
00061 ( const ParameterSet& pset, string triggerName, vector<string> moduleNames,
00062 MuonSelectionStruct inputSelection, string customName,
00063 vector<string> validTriggers, edm::Run const& currentRun, edm::EventSetup const& currentEventSetup )
00064 : mySelection(inputSelection), selectedValidTriggers(validTriggers)
00065 {
00066
00067
00068 LogTrace ("HLTMuonVal") << "\n\n Inside HLTMuonMatchAndPlot Constructor";
00069 LogTrace ("HLTMuonVal") << "The trigger name is " << triggerName
00070 << " and the module names are listed";
00071
00072 for (vector<string>::iterator iMod = moduleNames.begin();
00073 iMod != moduleNames.end(); iMod++){
00074 LogTrace ("HLTMuonVal") << (*iMod);
00075 }
00076
00077
00078 theHltProcessName = pset.getParameter<string>("HltProcessName");
00079
00080 LogTrace ("HLTMuonVal") << "HLTMuonMatchAndPlot: Constructor: Initializing HLTConfigProvider with HLT process name: " << theHltProcessName << endl;
00081
00082
00083 HLTConfigProvider hltConfig;
00084 bool hltConfigChanged;
00085 bool hltConfigInitSuccess = hltConfig.init(currentRun, currentEventSetup, theHltProcessName, hltConfigChanged);
00086
00087 theNumberOfObjects = ( TString(triggerName).Contains("Double") ) ? 2 : 1;
00088 theTriggerName = triggerName;
00089
00090 useAod = true;
00091
00092 requireL1SeedForHLTPaths = pset.getUntrackedParameter<bool>("RequireRecoToMatchL1Seed", false);
00093
00094 matchType = pset.getUntrackedParameter<string>("matchType");
00095
00096
00097 createStandAloneHistos = pset.getUntrackedParameter<bool>("createStandAloneHistos");
00098 histoFileName = pset.getUntrackedParameter<string> ("histoFileName");
00099
00100 theHltCollectionLabels.clear();
00101
00102
00103 useOldLabels = false;
00104 useFullDebugInformation = false;
00105
00106 if (useFullDebugInformation) {
00107
00108
00109 HLT_PLOT_OFFSET = 2;
00110 } else {
00111
00112
00113
00114 HLT_PLOT_OFFSET = 1;
00115 }
00116
00117 isL1Path = false;
00118 isL2Path = false;
00119 isL3Path = true;
00120
00121 if (TString(triggerName).Contains("L1")) {
00122 isL1Path = true;
00123 isL3Path = false;
00124 }
00125
00126 if (TString(triggerName).Contains("L2")) {
00127 isL2Path = true;
00128 isL3Path = false;
00129 }
00130 if (TString(triggerName).Contains("L3")) {
00131 isL3Path = true;
00132 isL3Path = false;
00133 }
00134
00135
00136
00137 LogTrace ("HLTMuonVal") << "Parsing Module names... useOldLabels? "
00138 << useOldLabels
00139 << ", useFullDebugInformation? "
00140 << useFullDebugInformation
00141 << endl;
00142
00143
00144 TPRegexp l1Regexp("L1.*Filtered");
00145 TPRegexp l2Regexp("L2.*Filtered");
00146
00147 string theLastHltFilter = "";
00148
00149 theL1SeedModuleForHLTPath = "" ;
00150
00151
00152 for ( size_t i = 0; i < moduleNames.size(); i++ ) {
00153 string module = moduleNames[i];
00154
00155 if (hltConfigInitSuccess) {
00156 LogTrace ("HLTMuonVal") << "Considering Module named "
00157 << module
00158 << " which has type = "
00159 << hltConfig.moduleType(module);
00160
00161 if ( hltConfig.moduleType(module) == "HLTLevel1GTSeed" ) {
00162 LogTrace ("HLTMuonVal") << "Module = " << module
00163 << " is a HLTLevel1GTSeed!!"
00164 << endl
00165 << "Storing it as L1Seed"
00166 << endl;
00167 theL1SeedModuleForHLTPath = module;
00168 }
00169 }
00170
00171
00172 if ( TString(module).Contains(l1Regexp) ) {
00173
00174
00175 theL1CollectionLabel = module;
00176 LogTrace ("HLTMuonVal") << "... module is L1 collection";
00177
00178
00179 } else if ( TString(module).Contains(l2Regexp) ) {
00180
00181
00182
00183 if (useFullDebugInformation) {
00184 theHltCollectionLabels.push_back(module);
00185 LogTrace ("HLTMuonVal") << "... module added to HLT collection list";
00186 } else if (isL2Path) {
00187 LogTrace ("HLTMuonVal") << "... module saved for later";
00188 theLastHltFilter = module;
00189 }
00190
00191
00192 } else if (TString(module).Contains("Filtered") ) {
00193
00194
00195
00196
00197
00198 if (useFullDebugInformation) {
00199 LogTrace ("HLTMuonVal") << "... module added to HLT collection list" << endl;
00200 theHltCollectionLabels.push_back(module);
00201 } else if (isL3Path) {
00202 LogTrace ("HLTMuonVal") << "... module saved for later" << endl;
00203 theLastHltFilter = module;
00204 }
00205
00206 }
00207 }
00208
00209 if (!useFullDebugInformation && theLastHltFilter != "" ) {
00210
00211 LogTrace("HLTMuonVal") << "\nAfter running over labels, we find hlt label coll size = "
00212 << theHltCollectionLabels.size() << endl
00213 << "\n\nwill only use the final hlt label = "
00214 << theLastHltFilter << endl;
00215
00216 theHltCollectionLabels.push_back (theLastHltFilter);
00217 }
00218
00219
00220 numHltLabels = theHltCollectionLabels.size();
00221 isIsolatedPath = ( numHltLabels == 4 ) ? true : false;
00222
00223
00224
00225
00226
00227
00228 RecoMuonInputTag = pset.getParameter<edm::InputTag>("RecoMuonInputTag");
00229 BeamSpotInputTag = pset.getParameter<edm::InputTag>("BeamSpotInputTag");
00230 HltRawInputTag = pset.getParameter<edm::InputTag>("HltRawInputTag");
00231 HltAodInputTag = pset.getParameter<edm::InputTag>("HltAodInputTag");
00232
00233 TriggerResultLabel = pset.getParameter<edm::InputTag>("TriggerResultLabel");
00234
00235
00236 useMuonFromReco = true;
00237
00238
00239
00240 vector <double> etaDefault;
00241 etaDefault.push_back(15);
00242 etaDefault.push_back(-2.1);
00243 etaDefault.push_back(2.1);
00244
00245 theEtaParameters = pset.getUntrackedParameter< vector<double> >("EtaParameters", etaDefault);
00246
00247 vector <double> phiDefault;
00248 phiDefault.push_back(15);
00249 phiDefault.push_back(-3.2);
00250 phiDefault.push_back(3.2);
00251
00252 thePhiParameters = pset.getUntrackedParameter< vector<double> >("PhiParameters", phiDefault);
00253
00254
00255 vector <double> ptDefault;
00256
00257
00258
00259
00260 thePtParameters = pset.getUntrackedParameter< vector<double> >("PtParameters", ptDefault);
00261
00262
00263 vector <double> resDefault;
00264 resDefault.push_back(10);
00265 resDefault.push_back(-0.1);
00266 resDefault.push_back(0.1);
00267 theResParameters = pset.getUntrackedParameter < vector<double> >("ResParameters", resDefault);
00268
00269 vector <double> d0Default;
00270 d0Default.push_back(10);
00271 d0Default.push_back(-2.0);
00272 d0Default.push_back(2.0);
00273
00274 theD0Parameters = pset.getUntrackedParameter <vector<double> > ("D0Parameters", d0Default);
00275
00276 vector <double> z0Default;
00277 z0Default.push_back(10);
00278 z0Default.push_back(-25);
00279 z0Default.push_back(25);
00280
00281 theZ0Parameters = pset.getUntrackedParameter < vector<double> > ("Z0Parameters", z0Default);
00282
00283
00284
00285 int numPtBinEdge = 0;
00286 if ( thePtParameters.size() > 100) {
00287 LogInfo ("HLTMuonVal") << "Warning!!! You specified a list of pt bin edges that is > 100 bins"
00288 << "This is too many bins!! Truncating the list!!! " << endl;
00289 numPtBinEdge = 100;
00290 } else if (thePtParameters.size() < 1) {
00291
00292 numPtBinEdge = 5;
00293 numBinsInPtHisto = numPtBinEdge - 1;
00294 ptBins[0] = 0;
00295 ptBins[1] = 20;
00296 ptBins[2] = 50;
00297 ptBins[3] = 100;
00298 ptBins[4] = 150;
00299
00300 } else {
00301 numPtBinEdge = thePtParameters.size();
00302
00303
00304 numBinsInPtHisto = numPtBinEdge - 1;
00305
00306 for (int iBin = 0; iBin < numPtBinEdge; iBin++){
00307 ptBins[iBin] = (float) thePtParameters[iBin];
00308
00309 }
00310
00311 }
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
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
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 theL1DrCut = pset.getUntrackedParameter<double>("L1DrCut", 0.4);
00389 theL2DrCut = pset.getUntrackedParameter<double>("L2DrCut", 0.1);
00390 theL3DrCut = pset.getUntrackedParameter<double>("L3DrCut", 0.05);
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400 thePhiEtaParameters2d.push_back(10);
00401 thePhiEtaParameters2d.push_back(-2.2);
00402 thePhiEtaParameters2d.push_back(2.2);
00403
00404 thePhiEtaParameters2d.push_back(10);
00405 thePhiEtaParameters2d.push_back(-3.15);
00406 thePhiEtaParameters2d.push_back(3.15);
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 theChargeParameters.push_back(3);
00418 theChargeParameters.push_back(-1.5);
00419 theChargeParameters.push_back(1.5);
00420
00421 theDRParameters.push_back(10);
00422 theDRParameters.push_back(0.0);
00423 theDRParameters.push_back(theL2DrCut);
00424
00425 theChargeFlipParameters.push_back(2);
00426 theChargeFlipParameters.push_back(-1.0);
00427 theChargeFlipParameters.push_back(1.0);
00428 theChargeFlipParameters.push_back(2);
00429 theChargeFlipParameters.push_back(-1.0);
00430 theChargeFlipParameters.push_back(1.0);
00431
00432 theIsolationParameters.push_back(10);
00433 theIsolationParameters.push_back(0.0);
00434 theIsolationParameters.push_back(1.0);
00435
00436 thePhiParameters0Pi.push_back(10);
00437 thePhiParameters0Pi.push_back(0);
00438 thePhiParameters0Pi.push_back(3.2);
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 dbe_ = 0 ;
00465 if ( pset.getUntrackedParameter<bool>("DQMStore", false) ) {
00466 dbe_ = Service<DQMStore>().operator->();
00467 dbe_->setVerbose(0);
00468 }
00469
00470 if (!dbe_) {
00471
00472 LogInfo ("HLTMuonVal") << "===WARNING=== Couldn't find DQMStore..."
00473 << "Won't be able to book ME's..."
00474 << "The rest of the run will probably not be useful..."
00475 << endl;
00476
00477 }
00478
00479 eventNumber = 0;
00480
00481 LogTrace ("HLTMuonVal") << "exiting constructor\n\n";
00482
00483 }
00484
00485
00486
00487 void HLTMuonMatchAndPlot::endRun (const edm::Run& r, const edm::EventSetup& c)
00488 {
00489
00490 LogTrace ("HLTMuonVal") << "\n\nInside HLTMuonMatchAndPlot endRun()";
00491
00492
00493
00494
00495
00496
00497 vector<MonitorElement*>::iterator iMonitorEl;
00498
00499 for ( iMonitorEl = booked1DMonitorElements.begin();
00500 iMonitorEl != booked1DMonitorElements.end();
00501 iMonitorEl++ ) {
00502
00503 moveOverflow((*iMonitorEl));
00504
00505 }
00506
00507
00508 }
00509
00510
00511 void HLTMuonMatchAndPlot::finish()
00512 {
00513
00514 LogTrace ("HLTMuonVal") << "\n\nInside HLTMuonMatchAndPlot finish()" << endl;
00515
00516 if (createStandAloneHistos && histoFileName != "") {
00517 dbe_->save(histoFileName);
00518 }
00519
00520 }
00521
00522
00523 void HLTMuonMatchAndPlot::analyze( const Event & iEvent )
00524 {
00525
00526 LogTrace( "HLTMuonVal" ) << "\n\nIn analyze for trigger path " <<
00527 theTriggerName << ", Event:" << eventNumber <<"\n\n\n";
00528
00529
00530
00531 bool validSelection = selectAndMatchMuons (iEvent, recMatches, hltFakeCands, mySelection);
00532 if (validSelection) fillPlots (recMatches, hltFakeCands);
00533
00534 eventNumber++;
00535
00536 }
00537
00538 bool HLTMuonMatchAndPlot::selectAndMatchMuons (const Event & iEvent, vector<MatchStruct> & myRecMatches,
00539 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands
00540 ){
00541
00542 LogTrace ("HLTMuonVal") << "\n\nInside selectAndMatchMuons, called with no selection argument"
00543 << endl
00544 << "Calling function using mySelection"
00545 << endl;
00546
00547 return selectAndMatchMuons (iEvent, myRecMatches, myHltFakeCands, mySelection);
00548
00549 }
00550
00551
00552 bool HLTMuonMatchAndPlot::selectAndMatchMuons (const Event & iEvent, vector<MatchStruct> & myRecMatches,
00553 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands,
00554 MuonSelectionStruct muonSelection){
00555
00556
00557 myRecMatches.clear();
00558
00559
00560
00561
00562
00563 myHltFakeCands.clear();
00564 for (unsigned iLabel = 0; iLabel < numHltLabels; iLabel++){
00565
00566 std::vector<HltFakeStruct> tempFake;
00567
00568 myHltFakeCands.push_back(tempFake);
00569
00570 }
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583 LogTrace("HLTMuonVal") << "Checking trigger result for "
00584 << "trigger information stored in the following block "
00585 << TriggerResultLabel;
00586
00587 bool passedRequiredTrigger = applyTriggerSelection ( muonSelection, iEvent);
00588
00589 if (!passedRequiredTrigger) {
00590 LogTrace ("HLTMuonVal") << "You didn't pass the required trigger"
00591 << "skipping event"
00592 << endl;
00593 return false;
00594 }
00595
00597
00598
00599
00600 double genMuonPt = -1;
00601 double recMuonPt = -1;
00602
00603
00604 LogTrace ("HLTMuonVal") << "\n\nStarting to look for gen muons\n\n";
00605
00606
00607
00608
00609
00610 LogTrace ("HLTMuonVal") << "\n\n\n\nDone getting gen, now getting reco\n\n\n";
00611
00612
00613
00614
00615
00616
00617 foundBeamSpot = false;
00618
00619 if ( useMuonFromReco ) {
00620
00621 Handle<MuonCollection> muTracks;
00622 iEvent.getByLabel(RecoMuonInputTag, muTracks);
00623
00624 MuonCollection::const_iterator muon;
00625 if ( muTracks.failedToGet() ) {
00626 LogWarning("HLTMuonVal") << "WARNING: failed to get the RECO Muon collection named " << RecoMuonInputTag
00627 << "\nYou have tracks to compare to... ignoring RECO muons"
00628 << " for the rest of this job";
00629 useMuonFromReco = false;
00630 } else {
00631
00632 LogTrace ("HLTMuonVal") << "Beginning loop over reco muons" << endl;
00633
00634 for ( muon = muTracks->begin(); muon != muTracks->end(); ++muon ) {
00635
00636
00637
00638
00639 LogTrace ("HLTMuonVal") << "... Applying selection" << endl;
00640 if ( muonSelection.recoMuonSelector((*muon)) ) {
00641
00642
00643 LogTrace ("HLTMuonVal") << "Passed selection!" << endl;
00644
00645 if ( applyTrackSelection( muonSelection, (*muon) ) ){
00646
00647
00648
00649 float pt = muon->pt();
00650 float eta = muon->eta();
00651 MatchStruct newMatchStruct;
00652 newMatchStruct.recCand = &*muon;
00653 myRecMatches.push_back(newMatchStruct);
00654
00655 LogTrace ("HLTMuonVal") << "\n\nFound a muon track in " << muonSelection.customLabel
00656 << " with pt = " << pt
00657 << ", eta = " << eta;
00658
00659
00660
00661 if (pt > recMuonPt )
00662 recMuonPt = pt;
00663
00664 }
00665 }
00666 }
00667 }
00668
00669
00670 LogTrace ("HLTMuonVal") << "Print out all rec cands for " << muonSelection.customLabel
00671 << endl;
00672
00673 for (unsigned iMatch = 0; iMatch < myRecMatches.size(); iMatch++) {
00674 LogTrace ("HLTMuonVal") << "Cand #" << iMatch << " ";
00675 LogTrace ("HLTMuonVal") << "Pt = " << myRecMatches[iMatch].recCand->pt()
00676 << endl;
00677 }
00678
00679 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00680 iEvent.getByLabel(BeamSpotInputTag,recoBeamSpotHandle);
00681 if (!recoBeamSpotHandle.failedToGet()) {
00682
00683 beamSpot = *recoBeamSpotHandle;
00684 foundBeamSpot = true;
00685
00686 LogTrace ("HLTMuonVal") << "\n\n\nSUCESS finding beamspot\n\n\n" << endl;
00687
00688 } else {
00689 LogWarning ("HLTMuonVal") << "FAILED to get the beamspot for this event";
00690 }
00691
00692
00693 }
00694
00695 LogTrace("HLTMuonVal") << "\n\n\n\ngenMuonPt: " << genMuonPt << ", "
00696 << "recMuonPt: " << recMuonPt
00697 << "\nCustom name = " << muonSelection.customLabel << endl
00698 << "\nNow preparing to get trigger objects"
00699 << "\n\n\n\n";
00700
00702
00703
00704 edm::Handle<trigger::TriggerEventWithRefs> rawTriggerEvent;
00705 edm::Handle<trigger::TriggerEvent> aodTriggerEvent;
00706 vector<TriggerObject> l1Particles;
00707 vector<TriggerObject> l1RawParticles;
00708 vector<TriggerObject> l1Seeds;
00709
00710
00711
00712
00713 vector< vector<TriggerObject> > hltParticles(numHltLabels);
00714
00715
00716 vector< vector<RecoChargedCandidateRef> > hltCands(numHltLabels);
00717
00718
00719 vector<L1MuonParticleRef> l1Cands;
00720
00721 InputTag collectionTag;
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00788
00789
00790 LogTrace ("HLTMuonVal") << "\n\n\nLooking for AOD branch named "
00791 << "hltTriggerSummaryAOD\n\n\n";
00792
00793 iEvent.getByLabel(HltAodInputTag, aodTriggerEvent);
00794 if ( !aodTriggerEvent.isValid() ) {
00795 LogInfo("HLTMuonVal") << "No AOD trigger summary found! Returning...";
00796 return false;
00797 }
00798
00799 LogTrace ("HLTMuonVal") << "\n\n\nFound a branch! Getting objects\n\n\n";
00800
00801
00802
00803
00804 const TriggerObjectCollection objects = aodTriggerEvent->getObjects();
00805
00806 LogTrace ("HLTMuonVal") << "\n\n\nFound a collection with size "
00807 << objects.size() << "\n\n\n";
00808
00809 if (objects.size() < 1) {
00810 LogTrace ("HLTMuonVal")
00811 << "You found the collection, but doesn't have any entries";
00812
00813 return false;
00814 }
00815
00816
00817
00818
00819
00820
00821
00822 collectionTag = InputTag( theL1CollectionLabel, "", theHltProcessName );
00823
00824 LogTrace ("HLTMuonVal") << "Trigger Name is " << theTriggerName;
00825
00826 LogTrace ("HLTMuonVal") << "\n\n L1Collection tag is "
00827 << collectionTag << endl
00828 << " and size filters is "
00829 << aodTriggerEvent->sizeFilters()
00830 << "Looking up L1 information in trigSummaryAod";
00831
00832
00833 getAodTriggerObjectsForModule ( collectionTag, aodTriggerEvent, objects, l1Particles, muonSelection);
00834
00835 int indexHltColl = 0;
00836 vector<string>::const_iterator iHltColl;
00837 for (iHltColl = theHltCollectionLabels.begin();
00838 iHltColl != theHltCollectionLabels.end();
00839 iHltColl++ ){
00840 collectionTag = InputTag((*iHltColl) , "",
00841 theHltProcessName );
00842
00843
00844 getAodTriggerObjectsForModule ( collectionTag, aodTriggerEvent, objects, hltParticles[indexHltColl] , muonSelection);
00845
00846
00847 indexHltColl++;
00848 }
00849
00850
00851
00852
00853 LogTrace ("HLTMuonVal") << "At the end of parsing the L2/L3 filters, you have found "
00854 << "L2 = " << ((hltParticles.size() > 0) ? hltParticles[0].size() : 0)
00855 << "L3 = " << ((hltParticles.size() > 1) ? hltParticles[1].size() : 0)
00856 << endl;
00857
00859
00860
00861
00863
00864 collectionTag = InputTag( theL1SeedModuleForHLTPath, "", theHltProcessName );
00865
00866 LogTrace ("HLTMuonVal") << "\n\n L1Seed colelction tag is "
00867 << collectionTag << endl
00868 << " and size filters is "
00869 << aodTriggerEvent->sizeFilters()
00870 << "Looking up L1 Seed information in trigSummaryAod";
00871
00872
00873 getAodTriggerObjectsForModule ( collectionTag, aodTriggerEvent, objects, l1Seeds, muonSelection);
00874
00875 LogTrace ("HLTMuonVal") << "At the end of parsing the L1 filter, you have found "
00876 << l1Particles.size() << " objects: ";
00877
00878
00880
00881
00882 LorentzVector nullLorentzVector( 0., 0., 0., -999. );
00883
00884
00885 TriggerObject nullTriggerObject (-9999, -9e10, -20, 0, 0);
00886
00887
00888
00889
00890
00891 for ( size_t i = 0; i < myRecMatches.size(); i++ ) {
00892 myRecMatches[i].l1Cand = nullTriggerObject;
00893 myRecMatches[i].l1Seed = nullTriggerObject;
00894 myRecMatches[i].hltCands. assign( numHltLabels, nullTriggerObject );
00895
00896
00897 myRecMatches[i].hltRawCands.assign(numHltLabels, nullLorentzVector);
00898 myRecMatches[i].l1RawCand = nullLorentzVector;
00899 }
00900
00901
00902
00903
00904
00906
00907
00908 numL1Cands = 0;
00909
00910
00911 for ( size_t i = 0; i < l1Particles.size(); i++ ) {
00912
00913 TriggerObject l1Cand = l1Particles[i];
00914 double eta = l1Cand.eta();
00915 double phi = l1Cand.phi();
00916
00917
00918
00919 double maxDeltaR = theL1DrCut;
00920 numL1Cands++;
00921
00922
00923 if ( useMuonFromReco ){
00924 int match = findRecMatch( eta, phi, maxDeltaR, myRecMatches );
00925 if ( match != -1 && myRecMatches[match].l1Cand.pt() < 0 ) {
00926 myRecMatches[match].l1Cand = l1Cand;
00927 LogTrace ("HLTMuonVal") << "Found a rec match to L1 particle (aod) "
00928 << " rec pt = " << myRecMatches[match].recCand->pt()
00929 << ", l1 pt = " << myRecMatches[match].l1Cand.pt();
00930 } else {
00931
00932 }
00933 }
00934
00935 }
00936
00937
00938
00939
00940
00941
00942 for ( size_t i = 0; i < l1Seeds.size(); i++ ) {
00943
00944 TriggerObject l1Cand = l1Seeds[i];
00945 double eta = l1Cand.eta();
00946 double phi = l1Cand.phi();
00947
00948
00949
00950 double maxDeltaR = theL1DrCut;
00951
00952
00953
00954 if ( useMuonFromReco ){
00955 int match = findRecMatch( eta, phi, maxDeltaR, myRecMatches );
00956 if ( match != -1 && myRecMatches[match].l1Seed.pt() < 0 ) {
00957 myRecMatches[match].l1Seed = l1Cand;
00958 LogTrace ("HLTMuonVal") << "Found a rec match to L1 particle (aod) "
00959 << " rec pt = " << myRecMatches[match].recCand->pt()
00960 << ", l1 pt = " << myRecMatches[match].l1Seed.pt();
00961 } else {
00962
00963 }
00964 }
00965
00966 }
00967
00968
00969
00971
00972
00974
00975 for ( size_t i = 0; i < l1Cands.size(); i++ ) {
00976
00977 LorentzVector l1Cand = l1Cands[i]->p4();
00978
00979 double eta = l1Cand.eta();
00980 double phi = l1Cand.phi();
00981
00982
00983
00984 double maxDeltaR = theL1DrCut;
00985
00986
00987
00988 if ( useMuonFromReco ){
00989 int match = findRecMatch( eta, phi, maxDeltaR, myRecMatches );
00990 if ( match != -1 && myRecMatches[match].l1RawCand.energy() < 0 ) {
00991 myRecMatches[match].l1RawCand = l1Cand;
00992 LogTrace ("HLTMuonVal") << "Found an L1 match to a RAW object";
00993 } else {
00994
00995 }
00996 }
00997
00998 }
00999
01000
01001
01002 LogTrace("HLTMuonVal") << "Number of L1 Cands: " << numL1Cands;
01003
01005
01006
01007 vector<unsigned int> numHltCands( numHltLabels, 0) ;
01008
01009 LogTrace ("HLTMuonVal") << "Looking for HLT matches for numHltLabels = "
01010 << numHltLabels;
01011
01012 for ( size_t i = 0; i < numHltLabels; i++ ) {
01013
01014 int triggerLevel = ( i < ( numHltLabels / 2 ) ) ? 2 : 3;
01015 double maxDeltaR = ( triggerLevel == 2 ) ? theL2DrCut : theL3DrCut;
01016
01017 LogTrace ("HLTMuonVal") << "Looking at 4-vectors for " << theHltCollectionLabels[i];
01018
01019 for ( size_t candNum = 0; candNum < hltParticles[i].size(); candNum++ ) {
01020
01021 TriggerObject hltCand = hltParticles[i][candNum];
01022 double eta = hltCand.eta();
01023 double phi = hltCand.phi();
01024
01025 numHltCands[i]++;
01026
01027
01028 if ( useMuonFromReco ){
01029
01030 HltFakeStruct tempFakeCand;
01031 tempFakeCand.myHltCand = hltCand;
01032
01033 int match = findRecMatch( eta, phi, maxDeltaR, myRecMatches );
01034
01035
01036
01037 if ( match != -1 && myRecMatches[match].hltCands[i].pt() < 0 ) {
01038 myRecMatches[match].hltCands[i] = hltCand;
01039
01040 LogTrace ("HLTMuonVal") << "Found a HLT cand match! "
01041 << " rec pt = " << myRecMatches[match].recCand->pt()
01042 << ", hlt pt = " << myRecMatches[match].hltCands[i].pt();
01043
01044
01045
01046 tempFakeCand.isAFake = false;
01047
01048
01049
01050
01051
01052
01053 } else if (match == -1){
01054 tempFakeCand.isAFake = true;
01055
01056 }
01057
01058
01059 myHltFakeCands[i].push_back(tempFakeCand);
01060 LogTrace ("HLTMuonVal") << "\n\nWas this a fake hlt cand? "
01061 << tempFakeCand.isAFake;
01062
01063 }
01064
01065
01066
01067 LogTrace("HLTMuonVal") << "Number of HLT Cands: " << numHltCands[i];
01068
01069 }
01070
01071
01072 LogTrace ("HLTMuonVal") << "Looking at RAW Candidates for "
01073 << theHltCollectionLabels[i];
01074
01075
01076 for ( size_t candNum = 0; candNum < hltCands[i].size(); candNum++ ) {
01077
01078 LorentzVector hltCand = hltCands[i][candNum]->p4();
01079 double eta = hltCand.eta();
01080 double phi = hltCand.phi();
01081
01082 numHltCands[i]++;
01083
01084
01085 if ( useMuonFromReco ){
01086
01087
01088
01089
01090 int match = findRecMatch( eta, phi, maxDeltaR, myRecMatches );
01091
01092
01093
01094 if ( match != -1 && myRecMatches[match].hltCands[i].pt() < 0 ) {
01095 myRecMatches[match].hltRawCands[i] = hltCand;
01096 LogTrace ("HLTMuonVal") << "Found a RAW hlt match to reco";
01097 }
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109 }
01110
01111
01112
01113
01114
01115 }
01116
01117
01118 }
01119
01120
01121
01122
01123
01124 return true;
01125
01126 }
01127
01128
01129 void HLTMuonMatchAndPlot::fillPlots (vector<MatchStruct> & myRecMatches,
01130 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands) {
01131
01132
01133 if (!dbe_) {
01134
01135 LogTrace ("HLTMuonVal")
01136 << "===Warning=== You've tried to call fill plots, "
01137 << "but no DQMStore object exists... refusing to fill plots"
01138 << endl;
01139
01140 return;
01141
01142 }
01143
01144 int numRecMatches = myRecMatches.size();
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 if ((theNumberOfObjects == 2) && (myRecMatches.size() < 2)) return;
01159
01161
01162
01164
01165
01166
01168
01169 double maxMatchPtRec = -10.0;
01170
01171
01172
01173
01174
01175 for ( size_t i = 0; i < myRecMatches.size(); i++ ) {
01176
01177 LogTrace("HLTMuonVal") << "Reco Candidate loop:"
01178 << "looking at cand " << i
01179 << " out of " << myRecMatches.size()
01180 << endl;
01181
01182
01183 if ((isL3Path || isL2Path) && requireL1SeedForHLTPaths) {
01184
01185 LogTrace ("HLTMuonVal") << "Checking to see if your RECO muon matched to an L1 seed"
01186 << endl;
01187
01188 if (myRecMatches[i].l1Seed.pt() < 0) {
01189 LogTrace ("HLTMuonVal") << "No match to L1 seed, skipping this RECO muon" << endl;
01190 continue;
01191 }
01192 }
01193
01194
01195
01196 double pt = myRecMatches[i].recCand->pt();
01197 double eta = myRecMatches[i].recCand->eta();
01198 double phi = myRecMatches[i].recCand->phi();
01199 int recPdgId = myRecMatches[i].recCand->pdgId();
01200
01201 LogTrace ("HLTMuonVal") << "trying to get a global track for this muon" << endl;
01202
01203
01204
01205
01206 TrackRef theMuonTrack = getCandTrackRef (mySelection, (*myRecMatches[i].recCand));
01207
01208 double d0 = -9e20;
01209 double z0 = -9e20;
01210 int charge = -99999;
01211 int plottedCharge = -99999;
01212
01213 double d0beam = -9e20;
01214 double z0beam = -9e20;
01215
01216 if (theMuonTrack.isNonnull() ) {
01217 d0 = theMuonTrack->d0();
01218 z0 = theMuonTrack->dz();
01219
01220
01221
01222 charge = theMuonTrack->charge();
01223 plottedCharge = getCharge (recPdgId);
01224
01225
01226 if (foundBeamSpot) {
01227 d0beam = theMuonTrack->dxy(beamSpot.position());
01228 z0beam = theMuonTrack->dz(beamSpot.position());
01229
01230 hBeamSpotZ0Rec[0]->Fill(beamSpot.z0());
01231 }
01232
01233
01234 } else {
01235 LogTrace ("HLTMuonVal") << "... oops! that wasn't a global muon" << endl;
01236 }
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248 hPassEtaRec[0]->Fill(eta);
01249 hPassPhiRec[0]->Fill(phi);
01250 hPassPtRec[0]->Fill(pt);
01251 hPhiVsEtaRec[0]->Fill(eta,phi);
01252 hPassD0Rec[0]->Fill(d0);
01253 hPassD0BeamRec[0]->Fill(d0beam);
01254 hPassZ0Rec[0]->Fill(z0);
01255 hPassZ0BeamRec[0]->Fill(z0beam);
01256 hPassCharge[0]->Fill(charge);
01257
01258 MuonIsolation thisIso = myRecMatches[i].recCand->isolationR03();
01259 double emEnergy = thisIso.emEt;
01260 double hadEnergy = thisIso.hadEt;
01261 double myMuonIso = (emEnergy + hadEnergy) / pt;
01262
01263 hIsolationRec[0]->Fill(myMuonIso);
01264
01265 if (numRecMatches == 1) {
01266 hPassPtRecExactlyOne[0]->Fill(pt);
01267 }
01268
01269
01270
01271
01272 if ( (myRecMatches[i].l1Cand.pt() > 0) && ((useFullDebugInformation) || (isL1Path)) ) {
01273 hPassEtaRec[1]->Fill(eta);
01274 hPassPhiRec[1]->Fill(phi);
01275 hPassPtRec[1]->Fill(pt);
01276 hPhiVsEtaRec[1]->Fill(eta,phi);
01277 hPassD0Rec[1]->Fill(d0);
01278 hPassD0BeamRec[1]->Fill(d0beam);
01279 hPassZ0Rec[1]->Fill(z0);
01280 hPassZ0BeamRec[1]->Fill(z0beam);
01281 hPassCharge[1]->Fill(charge);
01282 hIsolationRec[1]->Fill(myMuonIso);
01283
01284 double l1eta = myRecMatches[i].l1Cand.eta();
01285 double l1phi = myRecMatches[i].l1Cand.phi();
01286 double l1pt = myRecMatches[i].l1Cand.energy();
01287
01288
01289
01290 int l1plottedCharge = getCharge (myRecMatches[i].l1Cand.id());
01291 LogTrace ("HLTMuonVal") << "The pdg id is (L1) "
01292 << myRecMatches[i].l1Cand.id()
01293 << " and the L1 plotted charge is "
01294 << l1plottedCharge;
01295
01296
01297 double deltaR = reco::deltaR (l1eta, l1phi, eta, phi);
01298
01299 double deltaPhi = reco::deltaPhi (l1phi, phi);
01300
01301
01302
01303
01304
01305 hDeltaRMatched[0]->Fill(deltaR);
01306 hPassMatchPtRec[0]->Fill(pt);
01307
01308
01309
01310 hMatchedDeltaPhi[0]->Fill(deltaPhi);
01311
01312
01313
01314
01315
01316 hResoPtAodRec[0]->Fill((pt - l1pt)/pt);
01317 hResoEtaAodRec[0]->Fill((eta - l1eta)/fabs(eta));
01318 hResoPhiAodRec[0]->Fill((phi - l1phi)/fabs(phi));
01319
01320
01321 hChargeFlipMatched[0]->Fill(l1plottedCharge, plottedCharge);
01322
01323 if (numRecMatches == 1) {
01324 hPassExaclyOneMuonMaxPtRec[1]->Fill(pt);
01325 hPassPtRecExactlyOne[1]->Fill(pt);
01326 }
01327 }
01328
01329
01330
01331
01332
01333
01334 for ( size_t j = 0; j < myRecMatches[i].hltCands.size(); j++ ) {
01335 if ( myRecMatches[i].hltCands[j].pt() > 0 ) {
01336 double hltCand_pt = myRecMatches[i].hltCands[j].pt();
01337 double hltCand_eta = myRecMatches[i].hltCands[j].eta();
01338 double hltCand_phi = myRecMatches[i].hltCands[j].phi();
01339 int hltCand_plottedCharge = getCharge(myRecMatches[i].hltCands[j].id());
01340
01341
01342 if (theHltCollectionLabels.size() > j) {
01343 TString tempString = theHltCollectionLabels[j];
01344 if (tempString.Contains("L3")) {
01345
01346 maxMatchPtRec = (pt > maxMatchPtRec)? pt : maxMatchPtRec;
01347 }
01348 }
01349
01350
01351
01352
01353
01354 hPassEtaRec[j+HLT_PLOT_OFFSET]->Fill(eta);
01355 hPassPhiRec[j+HLT_PLOT_OFFSET]->Fill(phi);
01356 hPassPtRec[j+HLT_PLOT_OFFSET]->Fill(pt);
01357 hPhiVsEtaRec[j+HLT_PLOT_OFFSET]->Fill(eta,phi);
01358 hPassD0Rec[j+HLT_PLOT_OFFSET]->Fill(d0);
01359 hPassD0BeamRec[j+HLT_PLOT_OFFSET]->Fill(d0beam);
01360 hPassZ0Rec[j+HLT_PLOT_OFFSET]->Fill(z0);
01361 hPassZ0BeamRec[j+HLT_PLOT_OFFSET]->Fill(z0beam);
01362 hPassCharge[j+HLT_PLOT_OFFSET]->Fill(charge);
01363 hIsolationRec[j+HLT_PLOT_OFFSET]->Fill(myMuonIso);
01364
01365
01366
01367
01368
01369
01370
01371 double deltaR = reco::deltaR (hltCand_eta, hltCand_phi,
01372 eta, phi);
01373
01374 double deltaPhi = reco::deltaPhi (hltCand_phi, phi);
01375
01376 hDeltaRMatched[j+HLT_PLOT_OFFSET-1]->Fill(deltaR);
01377 hPassMatchPtRec[j+HLT_PLOT_OFFSET-1]->Fill(pt);
01378
01379
01380
01381 hMatchedDeltaPhi[j+HLT_PLOT_OFFSET-1]->Fill(deltaPhi);
01382
01383
01384
01385
01386
01387 LogTrace ("HLTMuonVal") << "The pdg id is (hlt [" << j << "]) "
01388 << myRecMatches[i].hltCands[j].id()
01389 << " and the plotted charge is "
01390 << hltCand_plottedCharge
01391 << ", w/ rec charge "
01392 << charge
01393 << ", and plotted charge "
01394 << plottedCharge
01395 << "\n "
01396 << "and rec pdg id = "
01397 << recPdgId;
01398
01399
01400
01401 hChargeFlipMatched[j+HLT_PLOT_OFFSET-1]->Fill( hltCand_plottedCharge, plottedCharge);
01402
01403
01404
01405
01406 hResoPtAodRec[j+HLT_PLOT_OFFSET-1]->Fill((pt - hltCand_pt)/pt);
01407 hResoEtaAodRec[j+HLT_PLOT_OFFSET-1]->Fill((eta - hltCand_eta)/fabs(eta));
01408 hResoPhiAodRec[j+HLT_PLOT_OFFSET-1]->Fill((phi - hltCand_phi)/fabs(phi));
01409
01410 if (numRecMatches == 1 && (myRecMatches[i].hltCands.size()== 1)) {
01411 hPassExaclyOneMuonMaxPtRec[j+HLT_PLOT_OFFSET]->Fill(pt);
01412 hPassPtRecExactlyOne[j+HLT_PLOT_OFFSET]->Fill(pt);
01413 }
01414 }
01415 }
01416
01418
01420 if (useFullDebugInformation) {
01421 LogTrace ("HLTMuonVal") << "\n.... now Filling Raw Histos";
01422 if ( myRecMatches[i].l1RawCand.energy() > 0 ) {
01423
01424
01425 rawMatchHltCandPt[1]->Fill(pt);
01426 rawMatchHltCandEta[1]->Fill(eta);
01427 rawMatchHltCandPhi[1]->Fill(phi);
01428 }
01429
01430 LogTrace ("HLTMuonVal") << "There are " << myRecMatches[i].hltCands.size()
01431 << " hltRaw candidates that could match, starting loop"
01432 << endl;
01433
01434 for ( size_t j = 0; j < myRecMatches[i].hltCands.size(); j++ ) {
01435 if ( myRecMatches[i].hltCands[j].pt() > 0 ) {
01436 rawMatchHltCandPt[j+HLT_PLOT_OFFSET]->Fill(pt);
01437 rawMatchHltCandEta[j+HLT_PLOT_OFFSET]->Fill(eta);
01438 rawMatchHltCandPhi[j+HLT_PLOT_OFFSET]->Fill(phi);
01439 }
01440 }
01441
01442 }
01443 }
01444
01446
01447
01448
01450
01451 LogTrace ("HLTMuonVal") << "\n.... now looping over fake cands";
01452 for (unsigned int iHltModule = 0; iHltModule < numHltLabels; iHltModule++) {
01453 for(size_t iCand = 0; iCand < myHltFakeCands[iHltModule].size() ; iCand ++){
01454 LogTrace ("HLTMuonVal") << "Label number : " << iHltModule
01455 << "(max = " << numHltLabels << ")\n"
01456 << "Candidate number: " << iCand
01457 << "(max = " << myHltFakeCands[iHltModule].size()
01458 << " )\n";
01459
01460
01461 TriggerObject candVect = myHltFakeCands[iHltModule][iCand].myHltCand;
01462 bool candIsFake = myHltFakeCands[iHltModule][iCand].isAFake;
01463
01464 allHltCandPt[iHltModule]->Fill(candVect.pt());
01465 allHltCandEta[iHltModule]->Fill(candVect.eta());
01466 allHltCandPhi[iHltModule]->Fill(candVect.phi());
01467
01468 if (candIsFake) {
01469 fakeHltCandPt[iHltModule]->Fill(candVect.pt());
01470 fakeHltCandEta[iHltModule]->Fill(candVect.eta());
01471 fakeHltCandPhi[iHltModule]->Fill(candVect.phi());
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484 }
01485
01486 }
01487
01488 }
01489
01490
01491 LogTrace ("HLTMuonVal") << "There are " << myRecMatches.size()
01492 << " RECO muons in this event"
01493 << endl;
01494
01495 LogTrace ("HLTMuonVal") << "The max pt found by looking at candiates is "
01496 << maxMatchPtRec
01497
01498
01499 << endl;
01500
01502
01503
01504
01506
01507
01508
01509
01510
01511 if ( maxMatchPtRec > 0 ) hPassMaxPtRec[0]->Fill( maxMatchPtRec );
01512
01513
01514
01515
01516
01517 if (numRecMatches == 1) {
01518 if (maxMatchPtRec >0) hPassExaclyOneMuonMaxPtRec[0]->Fill(maxMatchPtRec);
01519 }
01520
01521
01522 if (useFullDebugInformation || isL1Path) {
01523 if ( numL1Cands >= theNumberOfObjects ) {
01524
01525 if ( maxMatchPtRec > 0 ) hPassMaxPtRec[1]->Fill( maxMatchPtRec );
01526 if (numRecMatches == 1 && numL1Cands == 1) {
01527 if (maxMatchPtRec >0) hPassExaclyOneMuonMaxPtRec[1]->Fill(maxMatchPtRec);
01528 }
01529 }
01530 }
01531
01532
01533
01534 for ( size_t i = 0; i < numHltLabels; i++ ) {
01535
01536
01537
01538 if (maxMatchPtRec > 0) hPassMaxPtRec[i+HLT_PLOT_OFFSET]->Fill(maxMatchPtRec);
01539
01540 }
01541
01542
01543
01544
01545 }
01546
01547
01548
01549 const reco::Candidate* HLTMuonMatchAndPlot::
01550 findMother( const reco::Candidate* p )
01551 {
01552 const reco::Candidate* mother = p->mother();
01553 if ( mother ) {
01554 if ( mother->pdgId() == p->pdgId() ) return findMother(mother);
01555 else return mother;
01556 }
01557 else return 0;
01558 }
01559
01560
01562
01563
01565
01566 int HLTMuonMatchAndPlot::findGenMatch
01567 ( double eta, double phi, double maxDeltaR, vector<MatchStruct> matches )
01568 {
01569 double bestDeltaR = maxDeltaR;
01570 int bestMatch = -1;
01571 for ( size_t i = 0; i < matches.size(); i++ ) {
01572
01573
01574
01575
01576
01577 double dR = 10;
01578
01579 if ( dR < bestDeltaR ) {
01580 bestMatch = i;
01581 bestDeltaR = dR;
01582 }
01583 }
01584 return bestMatch;
01585 }
01586
01587
01588
01589 int HLTMuonMatchAndPlot::findRecMatch
01590 ( double eta, double phi, double maxDeltaR, vector<MatchStruct> matches)
01591 {
01592 double bestDeltaR = maxDeltaR;
01593 int bestMatch = -1;
01594
01595
01596
01597 if (matchType != "cosmic" || matchType == "dr" ) {
01598 for ( size_t i = 0; i < matches.size(); i++ ) {
01599 double dR = reco::deltaR( eta, phi,
01600 matches[i].recCand->eta(),
01601 matches[i].recCand->phi() );
01602 if ( dR < bestDeltaR ) {
01603 bestMatch = i;
01604 bestDeltaR = dR;
01605 }
01606 }
01607 return bestMatch;
01608 }
01609
01610 if (matchType == "cosmic") {
01611
01612
01613
01614
01615
01616
01617
01618
01619 double bestDphi = 100.0;
01620 for ( size_t i = 0; i < matches.size(); i++ ) {
01621
01622 double recCandPhi = matches[i].recCand->phi();
01623
01624
01625 if (recCandPhi < 0 && phi < 0) {
01626 if ( reco::deltaPhi(phi, recCandPhi) < bestDphi) {
01627 bestDphi = reco::deltaPhi(phi, recCandPhi);
01628 bestMatch = i;
01629 }
01630 }
01631
01632
01633 if (recCandPhi > 0 && phi > 0) {
01634
01635 if ( reco::deltaPhi(phi, recCandPhi) < bestDphi) {
01636 bestDphi = reco::deltaPhi(phi, recCandPhi);
01637 bestMatch = i;
01638 }
01639
01640 }
01641
01642 }
01643 return bestMatch;
01644 }
01645
01646
01647
01648
01649 LogWarning ("HLTMuonVal") << "WARNING: You have improperly set matchType" << endl
01650 << "valid choices are 'dr' and 'cosmic', " <<endl
01651 << "but you provided " << matchType << endl;
01652
01653 return bestMatch;
01654
01655 }
01656
01657
01658 bool HLTMuonMatchAndPlot::applyTrackSelection (MuonSelectionStruct mySelection, Muon candMuon) {
01659
01660 LogTrace ("HLTMuonVal") << "Applying track selection to your muon"
01661 << endl;
01662
01663
01664 TrackRef theMuonTrack = getCandTrackRef (mySelection, candMuon);
01665
01666 bool passedSelection = false;
01667
01668 if ( theMuonTrack.isNonnull() ) {
01669 double d0 = theMuonTrack->d0();
01670 double z0 = theMuonTrack->dz();
01671
01672
01673 LogTrace ("HLTMuonVal") << "d0 = " << d0
01674 << ", d0 cut = " << mySelection.d0cut << endl
01675 << "z0 = " << z0
01676 << ", z0 cut = " << mySelection.z0cut << endl;
01677
01678
01679
01680 if (fabs(d0) < mySelection.d0cut &&
01681 fabs(z0) < mySelection.z0cut ) {
01682 passedSelection = true;
01683 }
01684 } else {
01685 LogTrace ("HLTMuonVal") << "This event didn't have a valid track of type "
01686 << mySelection.trackCollection;
01687 }
01688
01689 return passedSelection;
01690
01691 }
01692
01693 bool HLTMuonMatchAndPlot::applyTriggerSelection(MuonSelectionStruct mySelection, const Event & event) {
01694
01695 bool passedAnyTrigger = false;
01696
01697
01698
01699
01700
01701 LogTrace ("HLTMuonVal") << "Checking to see if you have non-empty triggers to match"
01702 << endl;
01703
01704 if (mySelection.requiredTriggers.size() < 1)
01705 return true;
01706
01707 vector<string>::const_iterator iTargetTrig;
01708
01709 bool everythingIsEmpty = true;
01710 for ( iTargetTrig = mySelection.requiredTriggers.begin();
01711 iTargetTrig != mySelection.requiredTriggers.end();
01712 iTargetTrig ++ ) {
01713
01714 if ( (*iTargetTrig) != "" ) {
01715 everythingIsEmpty = false;
01716 }
01717
01718 }
01719
01720 if (everythingIsEmpty) {
01721 LogTrace ("HLTMuonVal") << "Only empty triggers, skipping match";
01722 return true;
01723 }
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738 Handle<TriggerResults> trigRes;
01739 event.getByLabel(TriggerResultLabel, trigRes);
01740 if (!trigRes.isValid()){
01741 edm::InputTag triggerResultsLabelFU(TriggerResultLabel.label(),TriggerResultLabel.instance(), "FU");
01742 event.getByLabel(triggerResultsLabelFU,trigRes);
01743 if(!trigRes.isValid()) {
01744 LogTrace("HLTMuonVal")<< "Trigger Results WARNING: No trigger Results in event info, but you wanted to check a trigger";
01745
01746
01747
01748 return false;
01749 }
01750 }
01751 unsigned size = trigRes->size();
01752
01753 unsigned int Ntp = 0;
01754
01755 LogTrace("HLTMuonVal")<< "Ntp=" << Ntp <<" Size of trigger results="<<size;
01756
01757
01758
01759
01760 map<string,bool> firedTrigger;
01761
01762 for ( iTargetTrig = mySelection.requiredTriggers.begin();
01763 iTargetTrig != mySelection.requiredTriggers.end();
01764 iTargetTrig++ ) {
01765
01766 std::string targetName = (*iTargetTrig);
01767
01768 LogTrace("HLTMuonVal") << "Looking to see if " << targetName << " has fired... ";
01769
01770 firedTrigger[targetName] = false;
01771 vector<string>::const_iterator iValidTrig;
01772 unsigned int trigIndex = 0;
01773 for ( iValidTrig = selectedValidTriggers.begin();
01774 iValidTrig != selectedValidTriggers.end();
01775 iValidTrig ++) {
01776
01777 if ( targetName == (*iValidTrig)){
01778
01779 LogTrace ("HLTMuonVal") << "Trigger " << targetName
01780 << " was part of the hlt configuration at index"
01781 << trigIndex
01782 << endl;
01783
01784 firedTrigger[targetName] = trigRes->accept(trigIndex);
01785
01786 LogTrace ("HLTMuonVal") << "Did the trigger fire? "
01787 << ((firedTrigger[targetName]) ? "PASSED" : "FAILED")
01788 << endl;
01789
01790 }
01791
01792 trigIndex++;
01793 }
01794 }
01795
01796
01797 map<string,bool>::const_iterator iResult;
01798
01799 passedAnyTrigger = false;
01800
01801 LogTrace ("HLTMuonVal") << "OR-ing trigger results together" <<endl;
01802
01803
01804 for (iResult = firedTrigger.begin();
01805 iResult != firedTrigger.end();
01806 iResult ++) {
01807
01808 passedAnyTrigger = passedAnyTrigger || iResult->second;
01809
01810 }
01811
01812 LogTrace ("HLTMuonVal") << "Returning " << passedAnyTrigger;
01813
01814 return passedAnyTrigger;
01815
01816 }
01817
01818
01819
01820 TrackRef HLTMuonMatchAndPlot::getCandTrackRef (MuonSelectionStruct mySelection, Muon candMuon) {
01821
01822 string trackCollection = mySelection.trackCollection;
01823 TrackRef theTrack;
01824
01825 LogTrace ("HLTMuonVal") << "Getting the track reference for coll "
01826 << trackCollection
01827 << endl;
01828
01829 LogTrace ("HLTMuonVal") << "Muon information" << endl
01830 << "pt = " << candMuon.pt()
01831 << ", phi = " << candMuon.phi()
01832 << ", eta = " << candMuon.eta()
01833 << ", global muon? = " << candMuon.isGlobalMuon()
01834 << ", standalone muon = " << candMuon.isStandAloneMuon()
01835 << ", tracker muon = " << candMuon.isTrackerMuon()
01836 << endl;
01837
01838 if (trackCollection == "innerTrack") {
01839 LogTrace ("HLTMuonVal") << "----> GET " << trackCollection;
01840
01841 if ( candMuon.isTrackerMuon() ) {
01842 theTrack = candMuon.innerTrack();
01843 }
01844
01845 } else if ( trackCollection == "outerTrack" ) {
01846
01847 LogTrace ("HLTMuonVal") << "----> GET " << trackCollection;
01848
01849 if ( candMuon.isStandAloneMuon() ) {
01850 theTrack = candMuon.outerTrack();
01851 }
01852
01853 } else if ( trackCollection == "globalTrack") {
01854
01855 LogTrace ("HLTMuonVal") << "----> GET " << trackCollection;
01856 if (candMuon.isGlobalMuon()) {
01857 theTrack = candMuon.globalTrack();
01858 }
01859 }
01860
01861 if (theTrack.isNonnull()) {
01862 LogTrace ("HLTMuonVal") << "Found the desired track";
01863 } else {
01864 LogTrace ("HLTMuonVal") << "No track for this candidate";
01865 }
01866
01867 return theTrack;
01868 }
01869
01870
01871 void HLTMuonMatchAndPlot::begin()
01872 {
01873 LogTrace ("HLTMuonVal") << "\n\nInside HLTMuonMatchAndPlot begin()";
01874
01875 TString myLabel, newFolder;
01876 vector<TH1F*> h;
01877
01878 if ( dbe_ ) {
01879 dbe_->cd();
01880 dbe_->setCurrentFolder("HLT/Muon");
01881
01882
01883
01884
01885
01886
01887 if (useOldLabels) {
01888 myLabel = theL1CollectionLabel;
01889 myLabel = myLabel(myLabel.Index("L1"),myLabel.Length());
01890 myLabel = myLabel(0,myLabel.Index("Filtered")+8);
01891 } else {
01892 myLabel = "L1Filtered";
01893 }
01894
01895
01896 newFolder = "HLT/Muon/Distributions/" + theTriggerName + "/" + mySelection.customLabel;
01897
01898
01899
01900 dbe_->setCurrentFolder( newFolder.Data() );
01901
01902
01903
01904
01905
01906
01907
01908 vector<string> binLabels;
01909 binLabels.push_back( theL1CollectionLabel.c_str() );
01910 for ( size_t i = 0; i < theHltCollectionLabels.size(); i++ )
01911 binLabels.push_back( theHltCollectionLabels[i].c_str() );
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921 if ( useMuonFromReco ){
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932 hPassMaxPtRec.push_back( bookIt( "recPassMaxPt_All", "pt of Leading Reco Muon" , numBinsInPtHisto, ptBins) );
01933
01934 if (useFullDebugInformation || isL1Path) hPassMaxPtRec.push_back( bookIt( "recPassMaxPt_" + myLabel, "pt of Leading Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
01935
01936 hPassEtaRec.push_back( bookIt( "recPassEta_All", "#eta of Reco Muons", theEtaParameters) );
01937 if (useFullDebugInformation || isL1Path) hPassEtaRec.push_back( bookIt( "recPassEta_" + myLabel, "#eta of Reco Muons matched to " + myLabel, theEtaParameters) );
01938
01939 hPassPhiRec.push_back( bookIt( "recPassPhi_All", "#phi of Reco Muons", thePhiParameters) );
01940 if (useFullDebugInformation || isL1Path) hPassPhiRec.push_back( bookIt( "recPassPhi_" + myLabel, "#phi of Reco Muons matched to " + myLabel, thePhiParameters) );
01941
01942
01943
01944 hPassPtRec.push_back( bookIt( "recPassPt_All", "Pt of Reco Muon" , numBinsInPtHisto, ptBins) );
01945 if (useFullDebugInformation || isL1Path) hPassPtRec.push_back( bookIt( "recPassPt_" + myLabel, "pt Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
01946
01947 hPassPtRecExactlyOne.push_back( bookIt( "recPassPtExactlyOne_All", "pt of Leading Reco Muon (==1 muon)" , numBinsInPtHisto, ptBins) );
01948 if (useFullDebugInformation || isL1Path) hPassPtRecExactlyOne.push_back( bookIt( "recPassPtExactlyOne_" + myLabel, "pt of Leading Reco Muon (==1 muon), if matched to " + myLabel, numBinsInPtHisto, ptBins) );
01949
01950 hPassExaclyOneMuonMaxPtRec.push_back( bookIt("recPassExactlyOneMuonMaxPt_All", "pt of Leading Reco Muon in events with exactly one muon" , numBinsInPtHisto, ptBins) );
01951 if (useFullDebugInformation || isL1Path) hPassExaclyOneMuonMaxPtRec.push_back( bookIt("recPassExactlyOneMuonMaxPt_" + myLabel, "pt of Leading Reco Muon in events with exactly one muon match to " + myLabel , numBinsInPtHisto, ptBins) );
01952
01953 hPassD0Rec.push_back( bookIt("recPassD0_All", "Track 2-D impact parameter wrt (0,0,0)(d0) ALL", theD0Parameters));
01954 if (useFullDebugInformation || isL1Path) hPassD0Rec.push_back( bookIt("recPassD0_" + myLabel, "Track 2-D impact parameter (0,0,0)(d0) " + myLabel, theD0Parameters));
01955 hPassD0BeamRec.push_back( bookIt("recPassD0Beam_All", "Track 2-D impact parameter wrt (beam)(d0) ALL", theD0Parameters));
01956 if (useFullDebugInformation || isL1Path) hPassD0BeamRec.push_back( bookIt("recPassD0Beam_" + myLabel, "Track 2-D impact parameter (beam)(d0) " + myLabel, theD0Parameters));
01957
01958 hPassZ0Rec.push_back( bookIt("recPassZ0_All", "Track Z0 wrt (0,0,0) ALL", theZ0Parameters));
01959 if (useFullDebugInformation || isL1Path) hPassZ0Rec.push_back( bookIt("recPassZ0_" + myLabel, "Track Z0 (0,0,0) " + myLabel, theZ0Parameters));
01960 hPassZ0BeamRec.push_back( bookIt("recPassZ0Beam_All", "Track Z0 wrt (beam) ALL", theZ0Parameters));
01961 if (useFullDebugInformation || isL1Path) hPassZ0BeamRec.push_back( bookIt("recPassZ0Beam_" + myLabel, "Track Z0 (beam) " + myLabel, theZ0Parameters));
01962
01963 hPassCharge.push_back( bookIt("recPassCharge_All", "Track Charge ALL", theChargeParameters));
01964 if (useFullDebugInformation || isL1Path) hPassCharge.push_back( bookIt("recPassCharge_" + myLabel, "Track Charge " + myLabel, theChargeParameters));
01965
01966 hIsolationRec.push_back ( bookIt("recPassIsolation_ALL", "Muon Isolation cone 0.3", theIsolationParameters));
01967 if (useFullDebugInformation || isL1Path) hIsolationRec.push_back ( bookIt("recPassIsolation_" + myLabel, "Muon Isolation cone 0.3 " + myLabel, theIsolationParameters));
01968
01969
01970 hBeamSpotZ0Rec.push_back ( bookIt("recBeamSpotZ0_All", "Z0 of beamspot for this event", theZ0Parameters));
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980 if (useFullDebugInformation || isL1Path) hDeltaRMatched.push_back ( bookIt("recDeltaRMatched_" + myLabel, "#Delta R between matched HLTCand", theDRParameters));
01981
01982
01983 if (useFullDebugInformation || isL1Path) hChargeFlipMatched.push_back ( bookIt("recChargeFlipMatched_" + myLabel, "Charge Flip from hlt to RECO;HLT Charge (-,+);Reco (-,+)", theChargeFlipParameters));
01984
01985 if (useFullDebugInformation || isL1Path) hPassMatchPtRec.push_back( bookIt( "recPassMatchPt_" + myLabel, "Pt of Reco Muon that is matched to Trigger Muon " + myLabel, numBinsInPtHisto, ptBins) );
01986
01987
01988
01989
01990 if (useFullDebugInformation || isL1Path) hResoPtAodRec.push_back ( bookIt ("recResoPt_" + myLabel, "TrigSumAOD to RECO P_T resolution", theResParameters));
01991 if (useFullDebugInformation || isL1Path) hResoEtaAodRec.push_back ( bookIt ("recResoEta_" + myLabel, "TrigSumAOD to RECO #eta resolution", theResParameters));
01992 if (useFullDebugInformation || isL1Path) hResoPhiAodRec.push_back ( bookIt ("recResoPhi_" + myLabel, "TrigSumAOD to RECO #phi resolution", theResParameters));
01993
01994
01995 if (useFullDebugInformation || isL1Path) hMatchedDeltaPhi.push_back ( bookIt( "recDeltaPhiMatched_" + myLabel, "Reco #phi vs HLT #phi " + myLabel, thePhiParameters0Pi) );
01996
01997
01998
01999
02001
02003
02004 if (useFullDebugInformation) {
02005 rawMatchHltCandPt.push_back( bookIt( "rawPassPt_All", "Pt of Reco Muon" , numBinsInPtHisto, ptBins) );
02006 rawMatchHltCandPt.push_back( bookIt( "rawPassPt_" + myLabel, "pt Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
02007
02008 rawMatchHltCandEta.push_back( bookIt( "rawPassEta_All", "#eta of Reco Muons", theEtaParameters) );
02009 rawMatchHltCandEta.push_back( bookIt( "rawPassEta_" + myLabel, "#eta of Reco Muons matched to " + myLabel, theEtaParameters) );
02010
02011 rawMatchHltCandPhi.push_back( bookIt( "rawPassPhi_All", "#phi of Reco Muons", thePhiParameters) );
02012 rawMatchHltCandPhi.push_back( bookIt( "rawPassPhi_" + myLabel, "#phi of Reco Muons matched to " + myLabel, thePhiParameters) );
02013 }
02014
02015
02016
02017
02018
02019 hPhiVsEtaRec.push_back ( bookIt ("recPhiVsRecEta_All", "Reco #phi vs Reco #eta ", thePhiEtaParameters2d));
02020 if (useFullDebugInformation || isL1Path) hPhiVsEtaRec.push_back ( bookIt ("recPhiVsRecEta_" + myLabel, "Reco #phi vs Reco #eta " +myLabel, thePhiEtaParameters2d));
02021
02022 }
02023
02024
02025
02026 for ( unsigned int i = 0; i < theHltCollectionLabels.size(); i++ ) {
02027
02028 if (useOldLabels) {
02029 myLabel = theHltCollectionLabels[i];
02030 TString level = ( myLabel.Contains("L2") ) ? "L2" : "L3";
02031 myLabel = myLabel(myLabel.Index(level),myLabel.Length());
02032 myLabel = myLabel(0,myLabel.Index("Filtered")+8);
02033 } else {
02034 TString tempString = theHltCollectionLabels[i];
02035 TString level = ( tempString.Contains("L2") ) ? "L2" : "L3";
02036 myLabel = level + "Filtered";
02037 }
02038
02039 if ( useMuonFromReco ) {
02040
02041
02042 hPassMaxPtRec.push_back( bookIt( "recPassMaxPt_" + myLabel, "pt of Leading Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
02043 hPassEtaRec.push_back( bookIt( "recPassEta_" + myLabel, "#eta of Reco Muons matched to " + myLabel, theEtaParameters) );
02044 hPassPhiRec.push_back( bookIt( "recPassPhi_" + myLabel, "#phi of Reco Muons matched to " + myLabel, thePhiParameters) );
02045
02046 hPassPtRec.push_back ( bookIt( "recPassPt_" + myLabel, "Pt of Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
02047 hPassPtRecExactlyOne.push_back (bookIt( "recPassPtExactlyOne__" + myLabel, "pt of Leading Reco Muon (==1 muon), if matched to " + myLabel, numBinsInPtHisto, ptBins) );
02048
02049 hPassExaclyOneMuonMaxPtRec.push_back( bookIt("recPassExactlyOneMuonMaxPt_" + myLabel, "pt of Leading Reco Muon in events with exactly one muon match to " + myLabel , numBinsInPtHisto, ptBins) );
02050 hPhiVsEtaRec.push_back ( bookIt ("recPhiVsRecEta_" + myLabel, "Reco #phi vs Reco #eta " +myLabel, thePhiEtaParameters2d));
02051
02052
02053 hPassD0Rec.push_back( bookIt("recPassD0_" + myLabel, "Track 2-D impact parameter (Z0) " + myLabel, theD0Parameters));
02054 hPassD0BeamRec.push_back( bookIt("recPassD0Beam_" + myLabel, "Track 2-D impact parameter (beam)(d0) " + myLabel, theD0Parameters));
02055 hPassZ0Rec.push_back( bookIt("recPassZ0_" + myLabel, "Track Z0 " + myLabel, theZ0Parameters));
02056 hPassZ0BeamRec.push_back( bookIt("recPassZ0Beam_" + myLabel, "Track Z0 (0,0,0) " + myLabel, theZ0Parameters));
02057 hPassCharge.push_back( bookIt("recPassCharge_" + myLabel, "Track Charge " + myLabel, theChargeParameters));
02058
02059 hIsolationRec.push_back ( bookIt("recPassIsolation_" + myLabel, "Muon Isolation cone 0.3 " + myLabel, theIsolationParameters));
02060
02061
02062 hPassMatchPtRec.push_back( bookIt( "recPassMatchPt_" + myLabel, "Pt of Reco Muon that is matched to Trigger Muon " + myLabel, numBinsInPtHisto, ptBins) );
02063
02064
02065
02066
02067
02068 hResoPtAodRec.push_back ( bookIt ("recResoPt_" + myLabel, "TrigSumAOD to RECO P_T resolution", theResParameters));
02069 hResoEtaAodRec.push_back ( bookIt ("recResoEta_" + myLabel, "TrigSumAOD to RECO #eta resolution", theResParameters));
02070 hResoPhiAodRec.push_back ( bookIt ("recResoPhi_" + myLabel, "TrigSumAOD to RECO #phi resolution", theResParameters));
02071
02072 hDeltaRMatched.push_back ( bookIt("recDeltaRMatched_" + myLabel, "#Delta R between matched HLTCand", theDRParameters));
02073 hChargeFlipMatched.push_back ( bookIt("recChargeFlipMatched_" + myLabel, "Charge Flip from hlt to RECO;HLT (-,+);Reco (-,+)", theChargeFlipParameters));
02074
02075
02076
02077 hMatchedDeltaPhi.push_back ( bookIt( "recDeltaPhiMatched_" + myLabel, "Reco #phi vs HLT #phi " + myLabel, thePhiParameters0Pi) );
02078
02079
02080
02081
02082
02083
02084 allHltCandPt.push_back( bookIt("allHltCandPt_" + myLabel, "Pt of all HLT Muon Cands, for HLT " + myLabel, numBinsInPtHisto, ptBins));
02085 allHltCandEta.push_back( bookIt("allHltCandEta_" + myLabel, "Eta of all HLT Muon Cands, for HLT " + myLabel, theEtaParameters));
02086 allHltCandPhi.push_back( bookIt("allHltCandPhi_" + myLabel, "Phi of all HLT Muon Cands, for HLT " + myLabel, thePhiParameters));
02087
02088 fakeHltCandPt.push_back( bookIt("fakeHltCandPt_" + myLabel, "Pt of fake HLT Muon Cands, for HLT " + myLabel, numBinsInPtHisto, ptBins));
02089 fakeHltCandEta.push_back( bookIt("fakeHltCandEta_" + myLabel, "Eta of fake HLT Muon Cands, for HLT " + myLabel, theEtaParameters));
02090 fakeHltCandPhi.push_back( bookIt("fakeHltCandPhi_" + myLabel, "Phi of fake HLT Muon Cands, for HLT " + myLabel, thePhiParameters));
02091
02092
02093
02094
02095
02096 if (useFullDebugInformation) {
02097 rawMatchHltCandPt.push_back( bookIt( "rawPassPt_" + myLabel, "pt Reco Muon, if matched to " + myLabel, numBinsInPtHisto, ptBins) );
02098 rawMatchHltCandEta.push_back( bookIt( "rawPassEta_" + myLabel, "#eta of Reco Muons matched to " + myLabel, theEtaParameters) );
02099 rawMatchHltCandPhi.push_back( bookIt( "rawPassPhi_" + myLabel, "#phi of Reco Muons matched to " + myLabel, thePhiParameters) );
02100 }
02101 }
02102
02103 }
02104 }
02105
02106 }
02107
02108
02109
02110 MonitorElement* HLTMuonMatchAndPlot::bookIt
02111 ( TString name, TString title, vector<double> parameters )
02112 {
02113 LogTrace("HLTMuonVal") << "Directory " << dbe_->pwd() << " Name " <<
02114 name << " Title:" << title;
02115 int nBins = (int)parameters[0];
02116 double min = parameters[1];
02117 double max = parameters[2];
02118
02119
02120 if (parameters.size() == 3) {
02121 TH1F *h = new TH1F( name, title, nBins, min, max );
02122 h->Sumw2();
02123 MonitorElement * returnedME = dbe_->book1D( name.Data(), h );
02124 delete h;
02125 booked1DMonitorElements.push_back(returnedME);
02126 return returnedME;
02127
02128
02129 } else if (parameters.size() == 6) {
02130
02131 int nBins2 = (int)parameters[3];
02132 double min2 = parameters[4];
02133 double max2 = parameters[5];
02134
02135 TH2F *h = new TH2F (name, title, nBins, min, max, nBins2, min2, max2);
02136 h->Sumw2();
02137 MonitorElement * returnedME = dbe_->book2D (name.Data(), h);
02138 delete h;
02139 return returnedME;
02140
02141 } else {
02142 LogInfo ("HLTMuonVal") << "Directory" << dbe_->pwd() << " Name "
02143 << name << " had an invalid number of paramters";
02144 return 0;
02145 }
02146
02147 }
02148
02149 MonitorElement* HLTMuonMatchAndPlot::bookIt
02150 ( TString name, TString title, int nbins, float * xBinLowEdges )
02151 {
02152 LogTrace("HLTMuonVal") << "Directory " << dbe_->pwd() << " Name " <<
02153 name << " Title:" << title;
02154
02155 TH1F *tempHist = new TH1F(name, title, nbins, xBinLowEdges);
02156 tempHist->Sumw2();
02157 MonitorElement * returnedME = dbe_->book1D(name.Data(), tempHist);
02158 delete tempHist;
02159
02160 booked1DMonitorElements.push_back(returnedME);
02161 return returnedME;
02162
02163 }
02164
02165
02166
02167
02168 int HLTMuonMatchAndPlot::getCharge (int pdgId) {
02169
02170 int resultCharge = (pdgId > 0) ? POS_CHARGE : NEG_CHARGE;
02171
02172 return resultCharge;
02173
02174 }
02175
02176 TString HLTMuonMatchAndPlot::calcHistoSuffix (string moduleName) {
02177
02178 TString level = "L3";
02179 TString myLabel = moduleName;
02180
02181
02182 if ( myLabel.Contains("L1") ) {
02183 level = "L1";
02184 } else if (myLabel.Contains("L2")) {
02185 level = "L2";
02186 } else if (myLabel.Contains("L3")) {
02187 level = "L3";
02188 }
02189
02190 if (useOldLabels) {
02191 myLabel = myLabel(myLabel.Index(level),myLabel.Length());
02192 myLabel = myLabel(0,myLabel.Index("Filtered")+8);
02193
02194 } else {
02195 myLabel = level + "Filtered";
02196 }
02197
02198 return myLabel;
02199
02200 }
02201
02202 void HLTMuonMatchAndPlot::moveOverflow (MonitorElement * myElement) {
02203
02204 LogTrace ("HLTMuonVal") << "MOVEOVERFLOW" << endl;
02205
02206
02207
02208
02209
02210
02211 int maxBin = myElement->getNbinsX();
02212
02213 double originalEntries = myElement->getEntries();
02214
02215 LogTrace ("HLTMuonVal") << "==MOVEOVERFLOW== "
02216 << "maxBin = " << maxBin
02217 << ", calling underflow"
02218 << endl;
02219
02220 myElement->setBinContent(1, myElement->getBinContent(0) + myElement->getBinContent(1));
02221
02222 LogTrace ("HLTMuonVal") << "reseting underflow to zero" << endl;
02223 myElement->setBinContent(0,0.0);
02224 LogTrace ("HLTMuonVal") << "calling overflow" << endl;
02225 myElement->setBinContent(maxBin,myElement->getBinContent(maxBin) + myElement->getBinContent(maxBin+1));
02226 LogTrace ("HLTMuonVal") << "seting overflow to zero" << endl;
02227 myElement->setBinContent(maxBin+1,0.0);
02228
02229 myElement->setEntries(originalEntries);
02230
02231 }
02232
02233
02234 void HLTMuonMatchAndPlot::getAodTriggerObjectsForModule (edm::InputTag collectionTag,
02235 edm::Handle<trigger::TriggerEvent> aodTriggerEvent,
02236 trigger::TriggerObjectCollection trigObjs,
02237 std::vector<TriggerObject> & foundObjects,
02238 MuonSelectionStruct muonSelection) {
02239
02240
02241
02242
02243 size_t filterIndex = aodTriggerEvent->filterIndex( collectionTag );
02244
02245 LogTrace ("HLTMuonVal") << "\n\n filterIndex is "
02246 << filterIndex;
02247
02248 if ( filterIndex < aodTriggerEvent->sizeFilters() ) {
02249 const Keys &keys = aodTriggerEvent->filterKeys( filterIndex );
02250
02251 LogTrace ("HLTMuonVal") << "\n\nGot keys";
02252 LogTrace ("HLTMuonVal") << "Key size is " << keys.size();
02253
02254
02255
02256
02257
02258
02259 for ( size_t j = 0; j < keys.size(); j++ ){
02260 TriggerObject foundObject = trigObjs[keys[j]];
02261
02262
02263 LogTrace ("HLTMuonVal") << "Testing to see if object in key passes selection"
02264 << endl ;
02265
02266 if (muonSelection.hltMuonSelector(foundObject)){
02267
02268 LogTrace ("HLTMuonVal") << "OBJECT FOUND!!! - Storing a trigger object with id = "
02269 << foundObject.id()
02270 << ", eta = " << foundObject.eta()
02271 << ", pt = " << foundObject.pt()
02272 << ", custom name = " << muonSelection.customLabel
02273 << "\n\n" << endl;
02274
02275 foundObjects.push_back( foundObject );
02276 }
02277 }
02278 }
02279
02280
02281
02282 }