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 );
100 map<TString, MonitorElement *>
ME;
107 dqmFolder(pset.getUntrackedParameter<
string>(
"DQMFolder")),
108 triggerProcessName(pset.getUntrackedParameter<
string>(
"TriggerProcessName")),
109 triggerPathName(pset.getUntrackedParameter<
string>(
"TriggerPathName")),
110 motherIDs(pset.getUntrackedParameter<vector<int> >(
"MotherIDs")),
111 genGlobDeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GenGlobDeltaRMatchingCut")),
112 globL1DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL1DeltaRMatchingCut")),
113 globL2DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL2DeltaRMatchingCut")),
114 globL3DeltaRMatchingCut(pset.getUntrackedParameter<double>(
"GlobL3DeltaRMatchingCut")),
115 deltaEtaBins(pset.getUntrackedParameter<vector<double> >(
"DeltaEtaBins")),
116 deltaPhiBins(pset.getUntrackedParameter<vector<double> >(
"DeltaPhiBins")),
117 muonPtBins(pset.getUntrackedParameter<vector<double> >(
"MuonPtBins")),
118 muonEtaBins(pset.getUntrackedParameter<vector<double> >(
"MuonEtaBins")),
119 muonPhiBins(pset.getUntrackedParameter<vector<double> >(
"MuonPhiBins")),
120 dimuonPtBins(pset.getUntrackedParameter<vector<double> >(
"DimuonPtBins")),
121 dimuonEtaBins(pset.getUntrackedParameter<vector<double> >(
"DimuonEtaBins")),
122 dimuonDRBins(pset.getUntrackedParameter<vector<double> >(
"DimuonDRBins")),
137 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Successfully initialized HLTConfigProvider with process name: "<<
triggerProcessName<<endl;
144 for(
size_t i = 0;
i < triggerNames.size();
i++) {
145 TString triggerName = triggerNames[
i];
147 vector<string> moduleNames = hltConfig.
moduleLabels( triggerNames[
i] );
148 for(
size_t j = 0;
j < moduleNames.size();
j++) {
149 TString
name = moduleNames[
j];
150 if(name.Contains(
"Filter")){
152 if(name.Contains(
"L1"))
154 if(name.Contains(
"L2"))
156 if(name.Contains(
"L3"))
158 if(name.Contains(
"mumuFilter") || name.Contains(
"DiMuon") || name.Contains(
"MuonL3Filtered") || name.Contains(
"TrackMassFiltered"))
160 if(name.Contains(
"Vertex") || name.Contains(
"Dz"))
163 os<<
" "<<moduleNames[
j];
269 vector<double> sizeBins; sizeBins.push_back(10); sizeBins.push_back(0); sizeBins.push_back(10);
270 myBook1D(ibooker,
"genMuon_size", sizeBins,
"container size" );
271 myBook1D(ibooker,
"globMuon_size", sizeBins,
"container size" );
283 vector<LeafCandidate> genMuons;
287 for(GenParticleCollection::const_iterator
p=genParticles->begin();
p!= genParticles->end(); ++
p){
288 if(
p->status() == 1 &&
std::abs(
p->pdgId())==13 &&
290 genMuons.push_back( *
p );
294 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access GenParticleCollection"<<endl;
297 ME[
"genMuon_size"]->Fill(genMuons.size());
298 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"GenParticleCollection from "<<
genParticlesTag<<
" has size: "<<genMuons.size()<<endl;
300 vector<LeafCandidate> globMuons;
301 vector<LeafCandidate> globMuons_position;
305 for(MuonCollection::const_iterator
p=recoMuonsHandle->begin();
p!= recoMuonsHandle->end(); ++
p){
306 if(
p->isGlobalMuon()){
307 globMuons.push_back(*
p);
308 globMuons_position.push_back(
LeafCandidate(
p->charge(),
math::XYZTLorentzVector(
p->outerTrack()->innerPosition().x(),
p->outerTrack()->innerPosition().y(),
p->outerTrack()->innerPosition().z(), 0.) ) );
312 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access reco Muons"<<endl;
314 ME[
"globMuon_size"]->Fill(globMuons.size());
315 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Global Muons from "<<
recoMuonsTag<<
" has size: "<<globMuons.size()<<endl;
318 vector<vector<LeafCandidate> > muonsAtFilter;
319 vector<vector<LeafCandidate> > muonPositionsAtFilter;
321 muonsAtFilter.push_back(vector<LeafCandidate>());
322 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
326 if( rawTriggerEvent.
isValid() ){
329 if ( index < rawTriggerEvent->
size() ){
331 vector<L1MuonParticleRef> l1Cands;
332 rawTriggerEvent->getObjects( index,
TriggerL1Mu, l1Cands );
333 for(
size_t j=0;
j<l1Cands.size();
j++){
334 muonsAtFilter[
i].push_back(*l1Cands[
j]);
337 vector<RecoChargedCandidateRef> hltCands;
338 rawTriggerEvent->getObjects( index,
TriggerMuon, hltCands );
339 for(
size_t j=0;
j<hltCands.size();
j++){
340 muonsAtFilter[
i].push_back(*hltCands[
j]);
342 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.) ) );
347 ME[TString::Format(
"filt%dMuon_size",
int(
i+1))]->Fill(muonsAtFilter[
i].
size());
348 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Filter \""<<
filterNamesLevels[
i].first<<
"\" has "<<muonsAtFilter[
i].size()<<
" muons"<<endl;
351 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access RAWTriggerEvent"<<endl;
355 vector<LeafCandidate> pathMuons;
360 for(
int i=0;
i<aodTriggerEvent->sizeFilters();
i++){
362 Keys keys = aodTriggerEvent->filterKeys(
i);
363 for(
size_t j=0;
j<keys.size();
j++){
368 ME[
"pathMuon_size"]->Fill(pathMuons.size());
371 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access AODTriggerEvent"<<endl;
375 bool triggerFired =
false;
381 bool hlt_exists =
false;
382 for (
unsigned int i=0;
i!=triggerNames.
size();
i++) {
385 triggerFired = triggerResults->accept(
i );
398 vector<int> glob_gen(genMuons.size(),-1);
400 vector<vector<int> > filt_glob;
402 filt_glob.push_back( vector<int>(globMuons.size(),-1) );
411 vector<int> path_glob(globMuons.size(),-1);
422 for(
size_t i=0;
i<genMuons.size();
i++){
423 ME[
"genMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
424 ME[
"genMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
425 if(glob_gen[
i] != -1) {
426 ME[
"resGlobGen_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt(), (globMuons[glob_gen[
i]].
pt()-genMuons[
i].
pt())/genMuons[
i].
pt() );
427 ME[
"globMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
428 ME[
"globMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
429 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
430 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
432 if(filt_glob[
f][glob_gen[
i]] != -1) {
433 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() );
434 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
435 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
440 if(path_glob[glob_gen[
i]] != -1){
441 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() );
442 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
443 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
449 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
450 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
458 for(
size_t j=1;
j<genMuons.size();
j++){
459 if(genMuons[0].charge()*genMuons[
j].charge()==-1){
466 double genDimuonPt = (genMuons[0].p4()+genMuons[secondMuon].p4()).
pt();
467 double genDimuonEta = (genMuons[0].p4()+genMuons[secondMuon].p4()).
eta();
468 double genDimuonRap = (genMuons[0].p4()+genMuons[secondMuon].p4()).Rapidity();
469 double genDimuonDR = deltaR<LeafCandidate,LeafCandidate>( genMuons[0], genMuons[secondMuon] );
470 bool highPt = genMuons[0].pt()>7. && genMuons[secondMuon].pt()>7;
471 ME[
"genDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
472 ME[
"genDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
473 if(highPt)
ME[
"genDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
475 if(glob_gen[0]!=-1 && glob_gen[secondMuon]!=-1){
476 ME[
"globDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
477 ME[
"globDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
478 if(highPt)
ME[
"globDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
479 double globDimuonPt = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
pt();
480 double globDimuonEta = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
eta();
481 double globDimuonRap = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).Rapidity();
482 double globDimuonDR = deltaR<LeafCandidate,LeafCandidate>( globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]] );
483 double globDimuonDRpos = deltaR<LeafCandidate,LeafCandidate>( globMuons_position[glob_gen[0]], globMuons_position[glob_gen[secondMuon]] );
484 ME[
"globDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
485 ME[
"globDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
486 if(highPt)
ME[
"globDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
487 if(highPt)
ME[
"globDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
490 if(filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1){
491 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
492 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
493 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
494 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
501 if(filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1){
502 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
503 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
504 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
505 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
511 if(path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1){
512 ME[
"diPathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
513 ME[
"diPathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
514 if(highPt)
ME[
"diPathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
515 if(highPt)
ME[
"diPathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
518 if(path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1){
519 ME[
"pathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
520 ME[
"pathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
521 if(highPt)
ME[
"pathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
522 if(highPt)
ME[
"pathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
526 ME[
"resultDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
527 ME[
"resultDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
528 if(highPt)
ME[
"resultDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
529 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
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)
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
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
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
EDGetTokenT< GenParticleCollection > genParticlesTag
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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
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)
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(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)
map< TString, MonitorElement * > ME
tuple size
Write out results.
vector< double > muonEtaBins
EDGetTokenT< MuonCollection > recoMuonsTag