44 #include "TLorentzVector.h"
49 using namespace l1extra;
50 using namespace trigger;
57 virtual void beginRun(
const Run & iRun,
const EventSetup & iSetup)
override;
59 virtual void endJob()
override;
61 void match(
MonitorElement * me, vector<LeafCandidate> & from, vector<LeafCandidate> &
to,
double deltaRMatchingCut, vector<int> &
map );
62 void myBook2D( TString
name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel, TString
title);
63 void myBook2D( TString name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel){
64 myBook2D( name, xBins, xLabel, yBins, yLabel, name);
66 void myBookProfile2D( TString name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel, TString title);
67 void myBookProfile2D( TString name, vector<double> &xBins, TString xLabel, vector<double> &yBins, TString yLabel){
68 myBookProfile2D( name, xBins, xLabel, yBins, yLabel, name);
70 void myBook1D( TString name, vector<double> &xBins, TString
label, TString title );
72 myBook1D( name, xBins, label, name );
98 map<TString, MonitorElement *>
ME;
105 dqmFolder(pset.getUntrackedParameter<
string>(
"DQMFolder")),
106 triggerProcessName(pset.getUntrackedParameter<
string>(
"TriggerProcessName")),
107 triggerPathName(pset.getUntrackedParameter<
string>(
"TriggerPathName")),
108 motherIDs(pset.getUntrackedParameter<vector<int> >(
"MotherIDs")),
109 genGlobDeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
110 globL1DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
111 globL2DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
112 globL3DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
113 deltaEtaBins(pset.getUntrackedParameter<vector<double> >(
"DeltaEtaBins")),
114 deltaPhiBins(pset.getUntrackedParameter<vector<double> >(
"DeltaPhiBins")),
115 muonPtBins(pset.getUntrackedParameter<vector<double> >(
"MuonPtBins")),
116 muonEtaBins(pset.getUntrackedParameter<vector<double> >(
"MuonEtaBins")),
117 muonPhiBins(pset.getUntrackedParameter<vector<double> >(
"MuonPhiBins")),
118 dimuonPtBins(pset.getUntrackedParameter<vector<double> >(
"DimuonPtBins")),
119 dimuonEtaBins(pset.getUntrackedParameter<vector<double> >(
"DimuonEtaBins")),
120 dimuonDRBins(pset.getUntrackedParameter<vector<double> >(
"DimuonDRBins")),
135 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Successfully initialized HLTConfigProvider with process name: "<<
triggerProcessName<<endl;
142 for(
size_t i = 0;
i < triggerNames.size();
i++) {
143 TString triggerName = triggerNames[
i];
145 vector<string> moduleNames = hltConfig.
moduleLabels( triggerNames[
i] );
146 for(
size_t j = 0;
j < moduleNames.size();
j++) {
147 TString
name = moduleNames[
j];
148 if(name.Contains(
"Filter")){
150 if(name.Contains(
"L1"))
152 else if(name.Contains(
"L2"))
154 else if(name.Contains(
"L3"))
156 else if(name.Contains(
"mumuFilter") || name.Contains(
"JpsiTrackMass"))
159 os<<
" "<<moduleNames[
j];
175 LogError(
"HLTriggerOfflineHeavyFlavor") <<
"Could not find DQMStore service\n";
271 vector<double> sizeBins; sizeBins.push_back(10); sizeBins.push_back(0); sizeBins.push_back(10);
272 myBook1D(
"genMuon_size", sizeBins,
"container size" );
273 myBook1D(
"globMuon_size", sizeBins,
"container size" );
282 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access DQM Store service"<<endl;
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){
474 double genDimuonPt = (genMuons[0].p4()+genMuons[secondMuon].p4()).
pt();
475 double genDimuonEta = (genMuons[0].p4()+genMuons[secondMuon].p4()).
eta();
476 double genDimuonRap = (genMuons[0].p4()+genMuons[secondMuon].p4()).Rapidity();
477 double genDimuonDR = deltaR<LeafCandidate,LeafCandidate>( genMuons[0], genMuons[secondMuon] );
478 bool highPt = genMuons[0].pt()>7. && genMuons[secondMuon].pt()>7;
479 ME[
"genDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
480 ME[
"genDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
481 if(highPt)
ME[
"genDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
483 if(glob_gen[0]!=-1 && glob_gen[secondMuon]!=-1){
484 ME[
"globDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
485 ME[
"globDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
486 if(highPt)
ME[
"globDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
487 double globDimuonPt = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
pt();
488 double globDimuonEta = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
eta();
489 double globDimuonRap = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).Rapidity();
490 double globDimuonDR = deltaR<LeafCandidate,LeafCandidate>( globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]] );
491 double globDimuonDRpos = deltaR<LeafCandidate,LeafCandidate>( globMuons_position[glob_gen[0]], globMuons_position[glob_gen[secondMuon]] );
492 ME[
"globDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
493 ME[
"globDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
494 if(highPt)
ME[
"globDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
495 if(highPt)
ME[
"globDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
498 if(filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1){
499 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
500 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
501 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
502 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
509 if(filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1){
510 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
511 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
512 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
513 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
519 if(path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1){
520 ME[
"diPathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
521 ME[
"diPathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
522 if(highPt)
ME[
"diPathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
523 if(highPt)
ME[
"diPathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
526 if(path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1){
527 ME[
"pathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
528 ME[
"pathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
529 if(highPt)
ME[
"pathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
530 if(highPt)
ME[
"pathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
534 ME[
"resultDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
535 ME[
"resultDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
536 if(highPt)
ME[
"resultDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
537 if(highPt)
ME[
"resultDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
552 return mother->
pdgId();
560 vector<double>
dR(from.size());
561 for(
size_t i=0;
i<from.size();
i++){
565 for(
size_t j=0;
j<to.size();
j++){
566 double dRtmp = deltaR<double>(from[
i].eta(), from[
i].phi(), to[
j].eta(), to[
j].phi());
577 if(
dR[
i] > dRMatchingCut ){
582 for(
size_t k=0;
k<
i;
k++){
583 if( map[
k] != -1 && map[i] == map[
k] ){
599 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
600 Double_t *
pt =
new Double_t[ ptN ];
601 for(
int i=0;
i<ptN;
i++){
602 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
604 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
605 Double_t *
eta =
new Double_t[ etaN ];
606 for(
int i=0;
i<etaN;
i++){
607 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
609 TH2F *
h =
new TH2F( name, name, ptN-1, pt, etaN-1, eta );
610 h->SetXTitle(ptLabel);
611 h->SetYTitle(etaLabel);
620 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
621 Double_t *
pt =
new Double_t[ ptN ];
622 for(
int i=0;
i<ptN;
i++){
623 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
625 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
626 Double_t *
eta =
new Double_t[ etaN ];
627 for(
int i=0;
i<etaN;
i++){
628 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
630 TProfile2D *
h =
new TProfile2D( name, name, ptN-1, pt, etaN-1, eta );
631 h->SetXTitle(ptLabel);
632 h->SetYTitle(etaLabel);
641 int binsN = bins.size()==3 ? (int)bins[0]+1 : bins.size();
642 Double_t *myBins =
new Double_t[ binsN ];
643 for(
int i=0;
i<binsN;
i++){
644 myBins[
i] = bins.size()==3 ? bins[1] +
i*(bins[2]-bins[1])/bins[0] : bins[
i] ;
646 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
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
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
vector< double > deltaPhiBins
#define DEFINE_FWK_MODULE(type)
const std::vector< std::string > & triggerNames() const
names of trigger paths
vector< pair< string, int > > filterNamesLevels
void myBook1D(TString name, vector< double > &xBins, TString label, TString title)
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)
EDGetTokenT< TriggerEvent > triggerSummaryAODTag
EDGetTokenT< GenParticleCollection > genParticlesTag
void myBook2D(TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
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.
virtual void endJob() override
vector< double > dimuonDRBins
int getMotherId(const Candidate *p)
void match(MonitorElement *me, vector< LeafCandidate > &from, vector< LeafCandidate > &to, double deltaRMatchingCut, vector< int > &map)
EDGetTokenT< TriggerEventWithRefs > triggerSummaryRAWTag
Abs< T >::type abs(const T &t)
void setVerbose(unsigned level)
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)
EDGetTokenT< TriggerResults > triggerResultsTag
vector< double > deltaEtaBins
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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
void myBookProfile2D(TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
void myBook1D(TString name, vector< double > &xBins, TString label)
void myBook2D(TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel, TString title)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
map< TString, MonitorElement * > ME
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
virtual void beginRun(const Run &iRun, const EventSetup &iSetup) override
tuple size
Write out results.
void myBookProfile2D(TString name, vector< double > &xBins, TString xLabel, vector< double > &yBins, TString yLabel)
vector< double > muonEtaBins
void setCurrentFolder(const std::string &fullpath)
EDGetTokenT< MuonCollection > recoMuonsTag
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")