45 #include "TLorentzVector.h"
50 using namespace l1extra;
51 using namespace trigger;
63 void match(
MonitorElement *
me, vector<LeafCandidate> & from, vector<LeafCandidate> &
to,
double deltaRMatchingCut, vector<int> & map );
64 void myBook2D(
DQMStore::IBooker & ibooker, TString
name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel, TString
title);
65 void myBook2D(
DQMStore::IBooker & ibooker, TString name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel){
66 myBook2D(ibooker, name, xBins, xLabel, yBins, yLabel, name);
68 void myBookProfile2D(
DQMStore::IBooker & ibooker, TString name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel, TString title);
70 myBookProfile2D(ibooker, name, xBins, xLabel, yBins, yLabel, name);
72 void myBook1D(
DQMStore::IBooker & ibooker, TString name, vector<double> &xBins, TString
label, TString title );
74 myBook1D(ibooker, name, xBins, label, name );
103 map<TString, MonitorElement *>
ME;
110 dqmFolder(pset.getUntrackedParameter<
string>(
"DQMFolder")),
111 triggerProcessName(pset.getUntrackedParameter<
string>(
"TriggerProcessName")),
112 triggerPathName(pset.getUntrackedParameter<
string>(
"TriggerPathName")),
113 motherIDs(pset.getUntrackedParameter<vector<int> >(
"MotherIDs")),
114 genGlobDeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
115 globL1DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
116 globL2DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
117 globL3DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
118 deltaEtaBins(pset.getUntrackedParameter<vector<double> >(
"DeltaEtaBins")),
119 deltaPhiBins(pset.getUntrackedParameter<vector<double> >(
"DeltaPhiBins")),
120 muonPtBins(pset.getUntrackedParameter<vector<double> >(
"MuonPtBins")),
121 muonEtaBins(pset.getUntrackedParameter<vector<double> >(
"MuonEtaBins")),
122 muonPhiBins(pset.getUntrackedParameter<vector<double> >(
"MuonPhiBins")),
123 dimuonPtBins(pset.getUntrackedParameter<vector<double> >(
"DimuonPtBins")),
124 dimuonEtaBins(pset.getUntrackedParameter<vector<double> >(
"DimuonEtaBins")),
125 dimuonDRBins(pset.getUntrackedParameter<vector<double> >(
"DimuonDRBins")),
143 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Successfully initialized HLTConfigProvider with process name: "<<
triggerProcessName<<endl;
150 for(
size_t i = 0;
i < triggerNames.size();
i++) {
151 TString triggerName = triggerNames[
i];
153 vector<string> moduleNames = hltConfig.
moduleLabels( triggerNames[
i] );
154 for(
size_t j = 0;
j < moduleNames.size();
j++) {
155 TString
name = moduleNames[
j];
156 if(name.Contains(
"Filter")){
158 if(name.Contains(
"L1"))
160 if(name.Contains(
"L2"))
162 if(name.Contains(
"L3"))
164 if(name.Contains(
"mumuFilter") || name.Contains(
"DiMuon") || name.Contains(
"MuonL3Filtered") || name.Contains(
"TrackMassFiltered"))
166 if(name.Contains(
"Vertex") || name.Contains(
"Dz"))
169 os<<
" "<<moduleNames[
j];
275 vector<double> sizeBins; sizeBins.push_back(10); sizeBins.push_back(0); sizeBins.push_back(10);
276 myBook1D(ibooker,
"genMuon_size", sizeBins,
"container size" );
277 myBook1D(ibooker,
"globMuon_size", sizeBins,
"container size" );
289 vector<LeafCandidate> genMuons;
293 for(GenParticleCollection::const_iterator
p=genParticles->begin();
p!= genParticles->end(); ++
p){
294 if(
p->status() == 1 &&
std::abs(
p->pdgId())==13 &&
296 genMuons.push_back( *
p );
300 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access GenParticleCollection"<<endl;
303 ME[
"genMuon_size"]->Fill(genMuons.size());
304 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"GenParticleCollection from "<<
genParticlesTag<<
" has size: "<<genMuons.size()<<endl;
306 vector<LeafCandidate> globMuons;
307 vector<LeafCandidate> globMuons_position;
311 for(MuonCollection::const_iterator
p=recoMuonsHandle->begin();
p!= recoMuonsHandle->end(); ++
p){
312 if(
p->isGlobalMuon()){
313 globMuons.push_back(*
p);
314 globMuons_position.push_back(
LeafCandidate(
p->charge(),
math::XYZTLorentzVector(
p->outerTrack()->innerPosition().x(),
p->outerTrack()->innerPosition().y(),
p->outerTrack()->innerPosition().z(), 0.) ) );
318 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access reco Muons"<<endl;
320 ME[
"globMuon_size"]->Fill(globMuons.size());
321 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Global Muons from "<<
recoMuonsTag<<
" has size: "<<globMuons.size()<<endl;
324 vector<vector<LeafCandidate> > muonsAtFilter;
325 vector<vector<LeafCandidate> > muonPositionsAtFilter;
327 muonsAtFilter.push_back(vector<LeafCandidate>());
328 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
332 if( rawTriggerEvent.
isValid() ){
335 if ( index < rawTriggerEvent->
size() ){
337 vector<L1MuonParticleRef> l1Cands;
338 rawTriggerEvent->getObjects( index,
TriggerL1Mu, l1Cands );
339 for(
size_t j=0;
j<l1Cands.size();
j++){
340 muonsAtFilter[
i].push_back(*l1Cands[
j]);
343 vector<RecoChargedCandidateRef> hltCands;
344 rawTriggerEvent->getObjects( index,
TriggerMuon, hltCands );
345 for(
size_t j=0;
j<hltCands.size();
j++){
346 muonsAtFilter[
i].push_back(*hltCands[
j]);
348 muonPositionsAtFilter[
i].push_back(
LeafCandidate( hltCands[j]->
charge(),
math::XYZTLorentzVector(hltCands[j]->track()->innerPosition().
x(), hltCands[j]->track()->innerPosition().
y(), hltCands[j]->track()->innerPosition().
z(), 0.) ) );
353 ME[TString::Format(
"filt%dMuon_size",
int(
i+1))]->Fill(muonsAtFilter[
i].
size());
354 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Filter \""<<
filterNamesLevels[
i].first<<
"\" has "<<muonsAtFilter[
i].size()<<
" muons"<<endl;
357 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access RAWTriggerEvent"<<endl;
361 vector<LeafCandidate> pathMuons;
366 for(
int i=0;
i<aodTriggerEvent->sizeFilters();
i++){
368 Keys keys = aodTriggerEvent->filterKeys(
i);
369 for(
size_t j=0;
j<keys.size();
j++){
374 ME[
"pathMuon_size"]->Fill(pathMuons.size());
377 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access AODTriggerEvent"<<endl;
381 bool triggerFired =
false;
387 bool hlt_exists =
false;
388 for (
unsigned int i=0;
i!=triggerNames.
size();
i++) {
391 triggerFired = triggerResults->accept(
i );
404 vector<int> glob_gen(genMuons.size(),-1);
406 vector<vector<int> > filt_glob;
408 filt_glob.push_back( vector<int>(globMuons.size(),-1) );
417 vector<int> path_glob(globMuons.size(),-1);
428 for(
size_t i=0;
i<genMuons.size();
i++){
429 ME[
"genMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
430 ME[
"genMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
431 if(glob_gen[
i] != -1) {
432 ME[
"resGlobGen_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt(), (globMuons[glob_gen[
i]].
pt()-genMuons[
i].
pt())/genMuons[
i].
pt() );
433 ME[
"globMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
434 ME[
"globMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
435 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
436 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
438 if(filt_glob[
f][glob_gen[
i]] != -1) {
439 ME[TString::Format(
"resFilt%dGlob_recoEtaPt",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt(), (muonsAtFilter[
f][filt_glob[
f][glob_gen[
i]]].
pt()-globMuons[glob_gen[
i]].
pt())/globMuons[glob_gen[
i]].
pt() );
440 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
441 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
446 if(path_glob[glob_gen[
i]] != -1){
447 ME[
"resPathGlob_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt(), (pathMuons[path_glob[glob_gen[
i]]].
pt()-globMuons[glob_gen[
i]].
pt())/globMuons[glob_gen[
i]].
pt() );
448 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
449 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
455 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
456 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
464 for(
size_t j=1;
j<genMuons.size();
j++){
465 if(genMuons[0].
charge()*genMuons[
j].charge()==-1){
472 double genDimuonPt = (genMuons[0].p4()+genMuons[secondMuon].p4()).
pt();
473 double genDimuonEta = (genMuons[0].p4()+genMuons[secondMuon].p4()).
eta();
474 double genDimuonRap = (genMuons[0].p4()+genMuons[secondMuon].p4()).Rapidity();
475 double genDimuonDR = deltaR<LeafCandidate,LeafCandidate>( genMuons[0], genMuons[secondMuon] );
476 bool highPt = genMuons[0].pt()>7. && genMuons[secondMuon].pt()>7;
477 ME[
"genDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
478 ME[
"genDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
479 if(highPt)
ME[
"genDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
481 if(glob_gen[0]!=-1 && glob_gen[secondMuon]!=-1){
482 ME[
"globDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
483 ME[
"globDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
484 if(highPt)
ME[
"globDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
485 double globDimuonPt = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
pt();
486 double globDimuonEta = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
eta();
487 double globDimuonRap = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).Rapidity();
488 double globDimuonDR = deltaR<LeafCandidate,LeafCandidate>( globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]] );
489 double globDimuonDRpos = deltaR<LeafCandidate,LeafCandidate>( globMuons_position[glob_gen[0]], globMuons_position[glob_gen[secondMuon]] );
490 ME[
"globDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
491 ME[
"globDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
492 if(highPt)
ME[
"globDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
493 if(highPt)
ME[
"globDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
496 if(filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1){
497 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
498 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
499 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
500 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
507 if(filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1){
508 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
509 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
510 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
511 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
517 if(path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1){
518 ME[
"diPathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
519 ME[
"diPathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
520 if(highPt)
ME[
"diPathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
521 if(highPt)
ME[
"diPathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
524 if(path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1){
525 ME[
"pathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
526 ME[
"pathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
527 if(highPt)
ME[
"pathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
528 if(highPt)
ME[
"pathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
532 ME[
"resultDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
533 ME[
"resultDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
534 if(highPt)
ME[
"resultDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
535 if(highPt)
ME[
"resultDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
547 return mother->
pdgId();
555 vector<double>
dR(from.size());
556 for(
size_t i=0;
i<from.size();
i++){
560 for(
size_t j=0;
j<to.size();
j++){
561 double dRtmp = deltaR<double>(from[
i].eta(), from[
i].phi(), to[
j].eta(), to[
j].phi());
572 if(
dR[
i] > dRMatchingCut ){
577 for(
size_t k=0;
k<
i;
k++){
578 if( map[
k] != -1 && map[i] == map[
k] ){
594 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
595 Double_t *
pt =
new Double_t[ ptN ];
596 for(
int i=0;
i<ptN;
i++){
597 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
599 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
600 Double_t *
eta =
new Double_t[ etaN ];
601 for(
int i=0;
i<etaN;
i++){
602 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
604 TH2F *
h =
new TH2F( name, name, ptN-1, pt, etaN-1, eta );
605 h->SetXTitle(ptLabel);
606 h->SetYTitle(etaLabel);
615 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
616 Double_t *
pt =
new Double_t[ ptN ];
617 for(
int i=0;
i<ptN;
i++){
618 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
620 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
621 Double_t *
eta =
new Double_t[ etaN ];
622 for(
int i=0;
i<etaN;
i++){
623 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
625 TProfile2D *
h =
new TProfile2D( name, name, ptN-1, pt, etaN-1, eta );
626 h->SetXTitle(ptLabel);
627 h->SetYTitle(etaLabel);
636 int binsN = bins.size()==3 ? (int)bins[0]+1 : bins.size();
637 Double_t *myBins =
new Double_t[ binsN ];
638 for(
int i=0;
i<binsN;
i++){
639 myBins[
i] = bins.size()==3 ? bins[1] +
i*(bins[2]-bins[1])/bins[0] : bins[
i] ;
641 TH1F *
h =
new TH1F( name, name, binsN-1, myBins );
double globL1DeltaRMatchingCut
vector< double > dimuonPtBins
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
void myBook2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
vector< double > deltaPhiBins
#define DEFINE_FWK_MODULE(type)
const std::vector< std::string > & triggerNames() const
names of trigger paths
vector< pair< string, int > > filterNamesLevels
Strings::size_type size() const
double globL3DeltaRMatchingCut
string triggerProcessName
vector< double > dimuonEtaBins
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void bookHistograms(fwlite::EventContainer &eventCont)
EDGetTokenT< TriggerEvent > triggerSummaryAODTag
U second(std::pair< T, U > const &p)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void myBookProfile2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
vector< double > dimuonDRBins
int getMotherId(const Candidate *p)
void match(MonitorElement *me, vector< LeafCandidate > &from, vector< LeafCandidate > &to, double deltaRMatchingCut, vector< int > &map)
MonitorElement * bookProfile2D(Args &&...args)
EDGetTokenT< TriggerEventWithRefs > triggerSummaryRAWTag
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
void myBook1D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString label, TString title)
static std::string const triggerResults
double genGlobDeltaRMatchingCut
vector< double > muonPtBins
HeavyFlavorValidation(const edm::ParameterSet &)
double globL2DeltaRMatchingCut
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
virtual int pdgId() const =0
PDG identifier.
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
vector< double > deltaEtaBins
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
void myBook2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
EDGetTokenT< MuonCollection > recoMuonsToken
std::string const & triggerName(unsigned int index) const
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
vector< double > muonPhiBins
EDGetTokenT< GenParticleCollection > genParticlesToken
void myBookProfile2D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void myBook1D(DQMStore::IBooker &ibooker, TString name, vector< double > &xBins, TString label)
EDGetTokenT< TriggerResults > triggerResultsToken
InputTag triggerResultsTag
map< TString, MonitorElement * > ME
tuple size
Write out results.
vector< double > muonEtaBins