44 #include "TLorentzVector.h"
49 using namespace l1extra;
50 using namespace trigger;
57 virtual void beginRun(
const Run & iRun,
const EventSetup & iSetup);
59 virtual void endJob();
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 );
96 map<TString, MonitorElement *>
ME;
103 dqmFolder(pset.getUntrackedParameter<string>(
"DQMFolder")),
104 triggerProcessName(pset.getUntrackedParameter<string>(
"TriggerProcessName")),
105 triggerPathName(pset.getUntrackedParameter<string>(
"TriggerPathName")),
106 triggerSummaryRAWTag(
InputTag( pset.getUntrackedParameter<string>(
"TriggerSummaryRAW"),
"", triggerProcessName)),
107 triggerSummaryAODTag(
InputTag( pset.getUntrackedParameter<string>(
"TriggerSummaryAOD"),
"", triggerProcessName)),
108 triggerResultsTag(
InputTag( pset.getUntrackedParameter<string>(
"TriggerResults"),
"", triggerProcessName)),
109 recoMuonsTag(pset.getParameter<
InputTag>(
"RecoMuons")),
110 genParticlesTag(pset.getParameter<
InputTag>(
"GenParticles")),
111 motherIDs(pset.getUntrackedParameter<vector<int> >(
"MotherIDs")),
112 genGlobDeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
113 globL1DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
114 globL2DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
115 globL3DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
116 deltaEtaBins(pset.getUntrackedParameter<vector<double> >(
"DeltaEtaBins")),
117 deltaPhiBins(pset.getUntrackedParameter<vector<double> >(
"DeltaPhiBins")),
118 muonPtBins(pset.getUntrackedParameter<vector<double> >(
"MuonPtBins")),
119 muonEtaBins(pset.getUntrackedParameter<vector<double> >(
"MuonEtaBins")),
120 muonPhiBins(pset.getUntrackedParameter<vector<double> >(
"MuonPhiBins")),
121 dimuonPtBins(pset.getUntrackedParameter<vector<double> >(
"DimuonPtBins")),
122 dimuonEtaBins(pset.getUntrackedParameter<vector<double> >(
"DimuonEtaBins")),
123 dimuonDRBins(pset.getUntrackedParameter<vector<double> >(
"DimuonDRBins")),
132 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Successfully initialized HLTConfigProvider with process name: "<<
triggerProcessName<<endl;
139 for(
size_t i = 0;
i < triggerNames.size();
i++) {
140 TString triggerName = triggerNames[
i];
142 vector<string> moduleNames = hltConfig.
moduleLabels( triggerNames[
i] );
143 for(
size_t j = 0;
j < moduleNames.size();
j++) {
144 TString
name = moduleNames[
j];
145 if(name.Contains(
"Filtered")){
147 if(name.Contains(
"L1"))
149 else if(name.Contains(
"L2"))
151 else if(name.Contains(
"L3"))
154 os<<
" "<<moduleNames[
j];
170 LogError(
"HLTriggerOfflineHeavyFlavor") <<
"Could not find DQMStore service\n";
266 vector<double> sizeBins; sizeBins.push_back(10); sizeBins.push_back(0); sizeBins.push_back(10);
267 myBook1D(
"genMuon_size", sizeBins,
"container size" );
268 myBook1D(
"globMuon_size", sizeBins,
"container size" );
277 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access DQM Store service"<<endl;
284 vector<LeafCandidate> genMuons;
288 for(GenParticleCollection::const_iterator
p=genParticles->begin();
p!= genParticles->end(); ++
p){
289 if(
p->status() == 1 &&
std::abs(
p->pdgId())==13 &&
291 genMuons.push_back( *
p );
295 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access GenParticleCollection"<<endl;
298 ME[
"genMuon_size"]->Fill(genMuons.size());
299 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"GenParticleCollection from "<<
genParticlesTag<<
" has size: "<<genMuons.size()<<endl;
301 vector<LeafCandidate> globMuons;
302 vector<LeafCandidate> globMuons_position;
306 for(MuonCollection::const_iterator
p=recoMuonsHandle->begin();
p!= recoMuonsHandle->end(); ++
p){
307 if(
p->isGlobalMuon()){
308 globMuons.push_back(*
p);
309 globMuons_position.push_back(
LeafCandidate(
p->charge(),
math::XYZTLorentzVector(
p->outerTrack()->innerPosition().x(),
p->outerTrack()->innerPosition().y(),
p->outerTrack()->innerPosition().z(), 0.) ) );
313 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access reco Muons"<<endl;
315 ME[
"globMuon_size"]->Fill(globMuons.size());
316 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Global Muons from "<<
recoMuonsTag<<
" has size: "<<globMuons.size()<<endl;
319 vector<vector<LeafCandidate> > muonsAtFilter;
320 vector<vector<LeafCandidate> > muonPositionsAtFilter;
322 muonsAtFilter.push_back(vector<LeafCandidate>());
323 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
327 if( rawTriggerEvent.
isValid() ){
330 if ( index < rawTriggerEvent->
size() ){
332 vector<L1MuonParticleRef> l1Cands;
333 rawTriggerEvent->getObjects( index,
TriggerL1Mu, l1Cands );
334 for(
size_t j=0;
j<l1Cands.size();
j++){
335 muonsAtFilter[
i].push_back(*l1Cands[
j]);
338 vector<RecoChargedCandidateRef> hltCands;
339 rawTriggerEvent->getObjects( index,
TriggerMuon, hltCands );
340 for(
size_t j=0;
j<hltCands.size();
j++){
341 muonsAtFilter[
i].push_back(*hltCands[
j]);
343 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.) ) );
348 ME[TString::Format(
"filt%dMuon_size",
int(
i+1))]->Fill(muonsAtFilter[
i].
size());
349 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Filter \""<<
filterNamesLevels[
i].first<<
"\" has "<<muonsAtFilter[
i].size()<<
" muons"<<endl;
352 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access RAWTriggerEvent"<<endl;
356 vector<LeafCandidate> pathMuons;
361 for(
int i=0;
i<aodTriggerEvent->sizeFilters();
i++){
363 Keys keys = aodTriggerEvent->filterKeys(
i);
364 for(
size_t j=0;
j<keys.size();
j++){
369 ME[
"pathMuon_size"]->Fill(pathMuons.size());
372 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access AODTriggerEvent"<<endl;
376 bool triggerFired =
false;
383 if( index < triggerNames.
size() ){
384 triggerFired = triggerResults->accept( index );
393 vector<int> glob_gen(genMuons.size(),-1);
395 vector<vector<int> > filt_glob;
397 filt_glob.push_back( vector<int>(globMuons.size(),-1) );
406 vector<int> path_glob(globMuons.size(),-1);
417 for(
size_t i=0;
i<genMuons.size();
i++){
418 ME[
"genMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].pt());
419 ME[
"genMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
420 if(glob_gen[
i] != -1){
421 ME[
"resGlobGen_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].pt(), (globMuons[glob_gen[
i]].pt()-genMuons[
i].pt())/genMuons[
i].pt() );
422 ME[
"globMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].pt());
423 ME[
"globMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
424 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].pt());
425 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
427 if(filt_glob[
f][glob_gen[
i]] != -1){
428 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() );
429 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].pt());
430 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
435 if(path_glob[glob_gen[
i]] != -1){
436 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() );
437 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].pt());
438 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
444 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].pt());
445 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
453 for(
size_t j=1;
j<genMuons.size();
j++){
454 if(genMuons[0].
charge()*genMuons[
j].charge()==-1){
463 double genDimuonPt = (genMuons[0].p4()+genMuons[secondMuon].p4()).pt();
464 double genDimuonEta = (genMuons[0].p4()+genMuons[secondMuon].p4()).
eta();
465 double genDimuonRap = (genMuons[0].p4()+genMuons[secondMuon].p4()).Rapidity();
466 double genDimuonDR = deltaR<LeafCandidate,LeafCandidate>( genMuons[0], genMuons[secondMuon] );
467 bool highPt = genMuons[0].pt()>7. && genMuons[secondMuon].pt()>7;
468 ME[
"genDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
469 ME[
"genDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
470 if(highPt)
ME[
"genDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
472 if(glob_gen[0]!=-1 && glob_gen[secondMuon]!=-1){
473 ME[
"globDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
474 ME[
"globDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
475 if(highPt)
ME[
"globDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
476 double globDimuonPt = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).pt();
477 double globDimuonEta = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
eta();
478 double globDimuonRap = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).Rapidity();
479 double globDimuonDR = deltaR<LeafCandidate,LeafCandidate>( globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]] );
480 double globDimuonDRpos = deltaR<LeafCandidate,LeafCandidate>( globMuons_position[glob_gen[0]], globMuons_position[glob_gen[secondMuon]] );
481 ME[
"globDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
482 ME[
"globDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
483 if(highPt)
ME[
"globDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
484 if(highPt)
ME[
"globDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
487 if(filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1){
488 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
489 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
490 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
491 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
498 if(filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1){
499 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
500 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
501 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
502 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
508 if(path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1){
509 ME[
"diPathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
510 ME[
"diPathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
511 if(highPt)
ME[
"diPathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
512 if(highPt)
ME[
"diPathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
515 if(path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1){
516 ME[
"pathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
517 ME[
"pathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
518 if(highPt)
ME[
"pathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
519 if(highPt)
ME[
"pathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
523 ME[
"resultDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
524 ME[
"resultDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
525 if(highPt)
ME[
"resultDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
526 if(highPt)
ME[
"resultDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
541 return mother->
pdgId();
549 vector<double> dR(from.size());
550 for(
size_t i=0;
i<from.size();
i++){
554 for(
size_t j=0;
j<to.size();
j++){
555 double dRtmp = deltaR<double>(from[
i].eta(), from[
i].phi(), to[
j].eta(), to[
j].phi());
566 if( dR[
i] > dRMatchingCut ){
571 for(
size_t k=0;
k<
i;
k++){
572 if( map[
k] != -1 && map[i] == map[
k] ){
588 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
589 Double_t *pt =
new Double_t[ ptN ];
590 for(
int i=0;
i<ptN;
i++){
591 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
593 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
594 Double_t *
eta =
new Double_t[ etaN ];
595 for(
int i=0;
i<etaN;
i++){
596 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
598 TH2F *
h =
new TH2F( name, name, ptN-1, pt, etaN-1, eta );
599 h->SetXTitle(ptLabel);
600 h->SetYTitle(etaLabel);
609 int ptN = ptBins.size()==3 ? (int)ptBins[0]+1 : ptBins.size();
610 Double_t *pt =
new Double_t[ ptN ];
611 for(
int i=0;
i<ptN;
i++){
612 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
614 int etaN = etaBins.size()==3 ? (int)etaBins[0]+1 : etaBins.size();
615 Double_t *
eta =
new Double_t[ etaN ];
616 for(
int i=0;
i<etaN;
i++){
617 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
619 TProfile2D *
h =
new TProfile2D( name, name, ptN-1, pt, etaN-1, eta );
620 h->SetXTitle(ptLabel);
621 h->SetYTitle(etaLabel);
630 int binsN = bins.size()==3 ? (int)bins[0]+1 : bins.size();
631 Double_t *myBins =
new Double_t[ binsN ];
632 for(
int i=0;
i<binsN;
i++){
633 myBins[
i] = bins.size()==3 ? bins[1] +
i*(bins[2]-bins[1])/bins[0] : bins[
i] ;
635 TH1F *
h =
new TH1F( name, name, binsN-1, myBins );
double globL1DeltaRMatchingCut
vector< double > dimuonPtBins
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
InputTag triggerSummaryAODTag
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.
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)
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.
vector< double > dimuonDRBins
int getMotherId(const Candidate *p)
InputTag triggerSummaryRAWTag
unsigned int triggerIndex(std::string const &name) const
void match(MonitorElement *me, vector< LeafCandidate > &from, vector< LeafCandidate > &to, double deltaRMatchingCut, vector< int > &map)
void setVerbose(unsigned level)
double genGlobDeltaRMatchingCut
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
static std::string from(" from ")
vector< double > deltaEtaBins
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
vector< double > muonPhiBins
virtual void beginRun(const Run &iRun, const EventSetup &iSetup)
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.
InputTag triggerResultsTag
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.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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")