00001 #ifndef DQMOffline_Trigger_HLTMuonMatchAndPlot_H
00002 #define DQMOffline_Trigger_HLTMuonMatchAndPlot_H
00003
00015
00016
00017 #include "FWCore/Framework/interface/EDAnalyzer.h"
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 #include "FWCore/Utilities/interface/InputTag.h"
00023 #include "DataFormats/Common/interface/RefToBase.h"
00024 #include "DataFormats/TrackReco/interface/Track.h"
00025 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00026 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00027 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00028 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
00029 #include "DataFormats/Candidate/interface/Candidate.h"
00030
00031 #include "DQMServices/Core/interface/DQMStore.h"
00032 #include "DQMServices/Core/interface/MonitorElement.h"
00033 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00034
00035 #include "DataFormats/Math/interface/LorentzVector.h"
00036
00037 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00038 #include "DataFormats/MuonReco/interface/Muon.h"
00039
00040 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
00041
00042 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00043
00044 #include <vector>
00045 #include "TFile.h"
00046 #include "TNtuple.h"
00047 #include "TString.h"
00048
00049
00050 typedef math::XYZTLorentzVector LorentzVector;
00051
00052
00053
00054
00055
00056
00057
00058 struct MuonSelectionStruct {
00059
00060
00061 MuonSelectionStruct(StringCutObjectSelector<reco::Muon> rsel, StringCutObjectSelector<trigger::TriggerObject> hltsel,
00062 std::string cl, double pD0cut, double pZ0cut, std::string trackCol, std::vector<std::string> reqTrigs)
00063 :recoMuonSelector(rsel), hltMuonSelector(hltsel), customLabel(cl),
00064 d0cut(pD0cut), z0cut(pZ0cut), trackCollection(trackCol),
00065 requiredTriggers(reqTrigs) {};
00066
00067 StringCutObjectSelector<reco::Muon> recoMuonSelector;
00068 StringCutObjectSelector<trigger::TriggerObject> hltMuonSelector;
00069 std::string customLabel;
00070
00071
00072
00073
00074
00075
00076
00077
00078 double d0cut;
00079 double z0cut;
00080
00081
00082
00083 std::string trackCollection;
00084
00085
00086
00087
00088
00089 std::vector<std::string> requiredTriggers;
00090
00091
00092
00093
00094 };
00095
00096
00097
00098 class HLTMuonMatchAndPlot {
00099
00100 public:
00101
00103 HLTMuonMatchAndPlot( const edm::ParameterSet& pset, std::string triggerName,
00104 std::vector<std::string> moduleNames, MuonSelectionStruct inputSelection,
00105 std::string customName,
00106 std::vector<std::string> validTriggers,
00107 const edm::Run & currentRun,
00108 const edm::EventSetup & currentEventSetup );
00109
00110
00111 virtual void begin ( );
00112 virtual void analyze( const edm::Event & iEvent );
00113 virtual void finish ( );
00114 virtual void endRun (const edm::Run& r, const edm::EventSetup& c);
00115 virtual MonitorElement* bookIt ( TString name, TString title, std::vector<double> );
00116 virtual MonitorElement* bookIt ( TString name, TString title, int nbins, float* xBinLowEdges);
00117
00118 TString calcHistoSuffix (std::string moduleName);
00119
00120
00121
00122
00123
00124
00125 struct MatchStruct {
00126
00127
00128 const reco::Muon* recCand;
00129
00130
00131
00132
00133
00134 trigger::TriggerObject l1Cand;
00135
00136
00137
00138
00139 trigger::TriggerObject l1Seed;
00140
00141
00142
00143
00144 LorentzVector l1RawCand;
00145
00146
00147
00148
00149 std::vector<trigger::TriggerObject> hltCands;
00150
00151
00152
00153
00154 std::vector<LorentzVector> hltRawCands;
00155
00156 };
00157
00158
00159
00160
00161 struct HltFakeStruct {
00162 trigger::TriggerObject myHltCand;
00163 bool isAFake;
00164 };
00165
00166
00167 std::vector<MatchStruct> recMatches;
00168
00169 std::vector< std::vector<HltFakeStruct> > hltFakeCands;
00170
00171 virtual ~HLTMuonMatchAndPlot() {} ;
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 bool virtual selectAndMatchMuons(const edm::Event & iEvent,
00184 std::vector<MatchStruct> & myRecMatches,
00185 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands
00186 );
00187
00188
00189 bool selectAndMatchMuons(const edm::Event & iEvent,
00190 std::vector<MatchStruct> & myRecMatches,
00191 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands,
00192 MuonSelectionStruct muonSelection
00193 );
00194
00195
00196 void virtual fillPlots(std::vector<MatchStruct> & myRecMatches,
00197 std::vector< std::vector<HltFakeStruct> > & myHltFakeCands);
00198
00199 protected:
00200
00202
00203 const reco::Candidate* findMother( const reco::Candidate* );
00204 int findGenMatch( double eta, double phi, double maxDeltaR,
00205 std::vector<MatchStruct> matches );
00206 int findRecMatch( double eta, double phi, double maxdeltaR,
00207 std::vector<MatchStruct> matches );
00208
00209 bool virtual applyTrackSelection (MuonSelectionStruct mySelection, reco::Muon candMuon);
00210 reco::TrackRef getCandTrackRef (MuonSelectionStruct mySelection, reco::Muon candMuon);
00211
00212 bool virtual applyTriggerSelection (MuonSelectionStruct mySelection, const edm::Event & event);
00213
00214
00215
00216 bool includeOverflow;
00217 void moveOverflow (MonitorElement * myElement);
00218
00219
00220
00221
00222 void getAodTriggerObjectsForModule (edm::InputTag collectionTag,
00223 edm::Handle<trigger::TriggerEvent> aodTriggerEvent,
00224 trigger::TriggerObjectCollection trigObjs,
00225 std::vector<trigger::TriggerObject> & foundObjects,
00226 MuonSelectionStruct muonSelection);
00227
00228
00229
00230 std::vector<MonitorElement*> booked1DMonitorElements;
00231
00232
00233
00234
00235
00236
00237 bool useOldLabels;
00238 bool useFullDebugInformation;
00239 int HLT_PLOT_OFFSET;
00240 bool isL1Path, isL2Path, isL3Path;
00241
00242 unsigned int numL1Cands;
00243
00244 bool makeNtuple;
00245 float theNtuplePars[100];
00246 TNtuple *theNtuple;
00247 TFile *theFile;
00248
00249 reco::BeamSpot beamSpot;
00250 bool foundBeamSpot;
00251
00252
00253
00254
00255 std::string theHltProcessName;
00256 std::string theTriggerName;
00257 std::string theL1CollectionLabel;
00258 std::vector<std::string> theHltCollectionLabels;
00259 unsigned int theNumberOfObjects;
00260
00261
00262 bool useMuonFromReco;
00263
00264
00265
00266 edm::InputTag RecoMuonInputTag;
00267 edm::InputTag BeamSpotInputTag;
00268 edm::InputTag HltRawInputTag;
00269 edm::InputTag HltAodInputTag;
00270
00271 bool useAod;
00272 std::string theAodL1Label;
00273 std::string theAodL2Label;
00274
00275 bool requireL1SeedForHLTPaths;
00276
00277
00278 std::string matchType;
00279
00280 MuonSelectionStruct mySelection;
00281
00282
00283 edm::InputTag TriggerResultLabel;
00284
00285 std::vector<std::string> selectedValidTriggers;
00286
00287 std::string theL1SeedModuleForHLTPath;
00288
00289
00290
00291
00292
00293
00294
00295 static const int POS_CHARGE = 1;
00296 static const int NEG_CHARGE = -1;
00297 int getCharge (int pdgId);
00298
00299
00300 std::vector<double> theMaxPtParameters;
00301 std::vector<double> thePtParameters;
00302 std::vector<double> theEtaParameters;
00303 std::vector<double> thePhiParameters;
00304 std::vector<double> thePhiParameters0Pi;
00305 std::vector<double> theD0Parameters;
00306 std::vector<double> theZ0Parameters;
00307 std::vector<double> theChargeParameters;
00308 std::vector<double> theDRParameters;
00309 std::vector<double> theChargeFlipParameters;
00310
00311
00312
00313 float ptBins[100];
00314 int numBinsInPtHisto;
00315
00316
00317 std::vector<double> thePhiEtaParameters2d;
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 std::vector<double> theResParameters;
00330
00331
00332 std::vector<double> theIsolationParameters;
00333
00334
00335
00336 double theMinPtCut;
00337 double theMaxEtaCut;
00338 double theL1DrCut;
00339 double theL2DrCut;
00340 double theL3DrCut;
00341 int theMotherParticleId;
00342 std::vector<double> theNSigmas;
00343
00344 std::string theNtupleFileName;
00345 std::string theNtuplePath;
00346
00347
00348
00349 int eventNumber;
00350 unsigned int numHltLabels;
00351 bool isIsolatedPath;
00352
00353
00354
00355 DQMStore* dbe_;
00356
00357 bool createStandAloneHistos;
00358 std::string histoFileName;
00359
00360
00361
00362
00363
00364 std::vector <MonitorElement*> hPassMaxPtRec;
00365 std::vector <MonitorElement*> hPassEtaRec;
00366 std::vector <MonitorElement*> hPassPhiRec;
00367 std::vector <MonitorElement*> hPassMatchPtRec;
00368 std::vector <MonitorElement*> hPassExaclyOneMuonMaxPtRec;
00369
00370
00371
00372 std::vector <MonitorElement*> hPhiVsEtaRec;
00373 std::vector <MonitorElement*> hPassPtRec;
00374 std::vector <MonitorElement*> hPassPtRecExactlyOne;
00375 std::vector <MonitorElement*> hResoPtAodRec;
00376 std::vector <MonitorElement*> hResoEtaAodRec;
00377 std::vector <MonitorElement*> hResoPhiAodRec;
00378 std::vector <MonitorElement*> hPassD0Rec;
00379 std::vector <MonitorElement*> hPassZ0Rec;
00380 std::vector <MonitorElement*> hPassCharge;
00381 std::vector <MonitorElement*> hPassD0BeamRec;
00382 std::vector <MonitorElement*> hPassZ0BeamRec;
00383 std::vector <MonitorElement*> hBeamSpotZ0Rec;
00384
00385
00386 std::vector <MonitorElement*> hMatchedDeltaPhi;
00387
00388
00389
00390
00391
00392
00393 std::vector <MonitorElement*> hDeltaRMatched;
00394 std::vector <MonitorElement*> hIsolationRec;
00395 std::vector <MonitorElement*> hChargeFlipMatched;
00396
00397 std::vector <MonitorElement*> allHltCandPt;
00398 std::vector <MonitorElement*> allHltCandEta;
00399 std::vector <MonitorElement*> allHltCandPhi;
00400
00401
00402
00403
00404 std::vector <MonitorElement*> fakeHltCandPt;
00405 std::vector <MonitorElement*> fakeHltCandEta;
00406 std::vector <MonitorElement*> fakeHltCandPhi;
00407
00408
00409
00410
00411
00412
00413
00414
00415 std::vector <MonitorElement*> rawMatchHltCandPt;
00416 std::vector <MonitorElement*> rawMatchHltCandEta;
00417 std::vector <MonitorElement*> rawMatchHltCandPhi;
00418
00419
00420
00421
00422
00423 MonitorElement *hNumObjects;
00424
00425 MonitorElement *hNumOrphansRec;
00426 MonitorElement *meNumberOfEvents;
00427
00428 };
00429 #endif