45 #include "TLorentzVector.h" 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];
160 if(name.Contains(
"Filter") && hltConfig.
moduleEDMType(moduleNames[j]) ==
"EDFilter"){
162 if(name.Contains(
"L1"))
164 if(name.Contains(
"L2"))
166 if(name.Contains(
"L3"))
168 if(name.Contains(
"mumuFilter") || name.Contains(
"DiMuon") || name.Contains(
"MuonL3Filtered") || name.Contains(
"TrackMassFiltered"))
170 if(name.Contains(
"Vertex") || name.Contains(
"Dz"))
173 os<<
" "<<moduleNames[j];
279 vector<double> sizeBins; sizeBins.push_back(10); sizeBins.push_back(0); sizeBins.push_back(10);
280 myBook1D(ibooker,
"genMuon_size", sizeBins,
"container size" );
281 myBook1D(ibooker,
"globMuon_size", sizeBins,
"container size" );
297 for(GenParticleCollection::const_iterator
p=genParticles->begin();
p!= genParticles->end(); ++
p){
298 if(
p->status() == 1 &&
std::abs(
p->pdgId())==13 &&
300 genMuons.push_back( *
p );
304 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access GenParticleCollection"<<endl;
307 ME[
"genMuon_size"]->Fill(genMuons.size());
308 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"GenParticleCollection from "<<
genParticlesTag<<
" has size: "<<genMuons.size()<<endl;
310 vector<LeafCandidate> globMuons;
311 vector<LeafCandidate> globMuons_position;
315 for(MuonCollection::const_iterator
p=recoMuonsHandle->begin();
p!= recoMuonsHandle->end(); ++
p){
316 if(
p->isGlobalMuon()){
317 globMuons.push_back(*
p);
318 globMuons_position.push_back(
LeafCandidate(
p->charge(),
math::XYZTLorentzVector(
p->outerTrack()->innerPosition().x(),
p->outerTrack()->innerPosition().y(),
p->outerTrack()->innerPosition().z(), 0.) ) );
322 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access reco Muons"<<endl;
324 ME[
"globMuon_size"]->Fill(globMuons.size());
325 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Global Muons from "<<
recoMuonsTag<<
" has size: "<<globMuons.size()<<endl;
328 vector<vector<LeafCandidate> > muonsAtFilter;
329 vector<vector<LeafCandidate> > muonPositionsAtFilter;
331 muonsAtFilter.push_back(vector<LeafCandidate>());
332 muonPositionsAtFilter.push_back(vector<LeafCandidate>());
336 if( rawTriggerEvent.
isValid() ){
339 if ( index < rawTriggerEvent->
size() ){
341 vector<L1MuonParticleRef> l1Cands;
343 for(
size_t j=0; j<l1Cands.size(); j++){
344 muonsAtFilter[
i].push_back(*l1Cands[j]);
347 vector<RecoChargedCandidateRef> hltCands;
349 for(
size_t j=0; j<hltCands.size(); j++){
350 muonsAtFilter[
i].push_back(*hltCands[j]);
357 ME[TString::Format(
"filt%dMuon_size",
int(
i+1))]->Fill(muonsAtFilter[
i].
size());
358 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Filter \""<<
filterNamesLevels[
i].first<<
"\" has "<<muonsAtFilter[
i].size()<<
" muons"<<endl;
361 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access RAWTriggerEvent"<<endl;
365 vector<LeafCandidate> pathMuons;
373 for(
size_t j=0; j<keys.size(); j++){
378 ME[
"pathMuon_size"]->Fill(pathMuons.size());
381 LogDebug(
"HLTriggerOfflineHeavyFlavor")<<
"Could not access AODTriggerEvent"<<endl;
385 bool triggerFired =
false;
391 bool hlt_exists =
false;
392 for (
unsigned int i=0;
i!=triggerNames.
size();
i++) {
395 triggerFired = triggerResults->
accept(
i );
408 vector<int> glob_gen(genMuons.size(),-1);
410 vector<vector<int> > filt_glob;
412 filt_glob.push_back( vector<int>(globMuons.size(),-1) );
421 vector<int> path_glob(globMuons.size(),-1);
432 for(
size_t i=0;
i<genMuons.size();
i++){
433 ME[
"genMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
434 ME[
"genMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
435 if(glob_gen[
i] != -1) {
436 ME[
"resGlobGen_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt(), (globMuons[glob_gen[
i]].
pt()-genMuons[
i].
pt())/genMuons[
i].
pt() );
437 ME[
"globMuon_genEtaPt"]->Fill(genMuons[
i].
eta(), genMuons[
i].
pt());
438 ME[
"globMuon_genEtaPhi"]->Fill(genMuons[
i].
eta(), genMuons[
i].
phi());
439 ME[
"globMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
440 ME[
"globMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
442 if(filt_glob[
f][glob_gen[
i]] != -1) {
443 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() );
444 ME[TString::Format(
"filt%dMuon_recoEtaPt",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
445 ME[TString::Format(
"filt%dMuon_recoEtaPhi",
int(
f+1))]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
450 if(path_glob[glob_gen[
i]] != -1){
451 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() );
452 ME[
"pathMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
453 ME[
"pathMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
459 ME[
"resultMuon_recoEtaPt"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
pt());
460 ME[
"resultMuon_recoEtaPhi"]->Fill(globMuons[glob_gen[
i]].
eta(), globMuons[glob_gen[
i]].
phi());
468 for(
size_t j=1; j<genMuons.size(); j++){
469 if(genMuons[0].
charge()*genMuons[j].charge()==-1){
476 double genDimuonPt = (genMuons[0].p4()+genMuons[secondMuon].p4()).
pt();
477 double genDimuonEta = (genMuons[0].p4()+genMuons[secondMuon].p4()).
eta();
478 double genDimuonRap = (genMuons[0].p4()+genMuons[secondMuon].p4()).Rapidity();
479 double genDimuonDR = deltaR<LeafCandidate,LeafCandidate>( genMuons[0], genMuons[secondMuon] );
480 bool highPt = genMuons[0].pt()>7. && genMuons[secondMuon].pt()>7;
481 ME[
"genDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
482 ME[
"genDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
483 if(highPt)
ME[
"genDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
485 if(glob_gen[0]!=-1 && glob_gen[secondMuon]!=-1){
486 ME[
"globDimuon_genEtaPt"]->Fill( genDimuonEta, genDimuonPt );
487 ME[
"globDimuon_genRapPt"]->Fill( genDimuonRap, genDimuonPt );
488 if(highPt)
ME[
"globDimuon_genPtDR"]->Fill( genDimuonPt, genDimuonDR );
489 double globDimuonPt = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
pt();
490 double globDimuonEta = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).
eta();
491 double globDimuonRap = (globMuons[glob_gen[0]].p4()+globMuons[glob_gen[secondMuon]].p4()).Rapidity();
492 double globDimuonDR = deltaR<LeafCandidate,LeafCandidate>( globMuons[glob_gen[0]], globMuons[glob_gen[secondMuon]] );
493 double globDimuonDRpos = deltaR<LeafCandidate,LeafCandidate>( globMuons_position[glob_gen[0]], globMuons_position[glob_gen[secondMuon]] );
494 ME[
"globDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
495 ME[
"globDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
496 if(highPt)
ME[
"globDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
497 if(highPt)
ME[
"globDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
500 if(filt_glob[
f][glob_gen[0]] != -1 && filt_glob[
f][glob_gen[secondMuon]] != -1){
501 ME[TString::Format(
"diFilt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
502 ME[TString::Format(
"diFilt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
503 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
504 if(highPt)
ME[TString::Format(
"diFilt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
511 if(filt_glob[
f][glob_gen[0]] != -1 || filt_glob[
f][glob_gen[secondMuon]] != -1){
512 ME[TString::Format(
"filt%dDimuon_recoEtaPt",
int(
f+1))]->Fill( globDimuonEta, globDimuonPt );
513 ME[TString::Format(
"filt%dDimuon_recoRapPt",
int(
f+1))]->Fill( globDimuonRap, globDimuonPt );
514 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDR",
int(
f+1))]->Fill( globDimuonPt, globDimuonDR );
515 if(highPt)
ME[TString::Format(
"filt%dDimuon_recoPtDRpos",
int(
f+1))]->Fill( globDimuonPt, globDimuonDRpos );
521 if(path_glob[glob_gen[0]] != -1 && path_glob[glob_gen[secondMuon]] != -1){
522 ME[
"diPathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
523 ME[
"diPathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
524 if(highPt)
ME[
"diPathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
525 if(highPt)
ME[
"diPathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
528 if(path_glob[glob_gen[0]] != -1 || path_glob[glob_gen[secondMuon]] != -1){
529 ME[
"pathDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
530 ME[
"pathDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
531 if(highPt)
ME[
"pathDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
532 if(highPt)
ME[
"pathDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
536 ME[
"resultDimuon_recoEtaPt"]->Fill( globDimuonEta, globDimuonPt );
537 ME[
"resultDimuon_recoRapPt"]->Fill( globDimuonRap, globDimuonPt );
538 if(highPt)
ME[
"resultDimuon_recoPtDR"]->Fill( globDimuonPt, globDimuonDR );
539 if(highPt)
ME[
"resultDimuon_recoPtDRpos"]->Fill( globDimuonPt, globDimuonDRpos );
551 return mother->
pdgId();
559 vector<double>
dR(from.size());
560 for(
size_t i=0;
i<from.size();
i++){
564 for(
size_t j=0; j<to.size(); j++){
565 double dRtmp = deltaR<double>(from[
i].eta(), from[
i].phi(), to[j].eta(), to[j].phi());
576 if(
dR[
i] > dRMatchingCut ){
581 for(
size_t k=0;
k<
i;
k++){
582 if( map[
k] != -1 && map[i] == map[
k] ){
598 int ptN = ptBins.size()==3 ? (
int)ptBins[0]+1 : ptBins.size();
599 Double_t *
pt =
new Double_t[ ptN ];
600 for(
int i=0;
i<ptN;
i++){
601 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
603 int etaN = etaBins.size()==3 ? (
int)etaBins[0]+1 : etaBins.size();
604 Double_t *
eta =
new Double_t[ etaN ];
605 for(
int i=0;
i<etaN;
i++){
606 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
608 TH2F *
h =
new TH2F( name, name, ptN-1, pt, etaN-1, eta );
609 h->SetXTitle(ptLabel);
610 h->SetYTitle(etaLabel);
619 int ptN = ptBins.size()==3 ? (
int)ptBins[0]+1 : ptBins.size();
620 Double_t *
pt =
new Double_t[ ptN ];
621 for(
int i=0;
i<ptN;
i++){
622 pt[
i] = ptBins.size()==3 ? ptBins[1] +
i*(ptBins[2]-ptBins[1])/ptBins[0] : ptBins[
i] ;
624 int etaN = etaBins.size()==3 ? (
int)etaBins[0]+1 : etaBins.size();
625 Double_t *
eta =
new Double_t[ etaN ];
626 for(
int i=0;
i<etaN;
i++){
627 eta[
i] = etaBins.size()==3 ? etaBins[1] +
i*(etaBins[2]-etaBins[1])/etaBins[0] : etaBins[
i] ;
629 TProfile2D *
h =
new TProfile2D( name, name, ptN-1, pt, etaN-1, eta );
630 h->SetXTitle(ptLabel);
631 h->SetYTitle(etaLabel);
640 int binsN = bins.size()==3 ? (
int)bins[0]+1 : bins.size();
641 Double_t *myBins =
new Double_t[ binsN ];
642 for(
int i=0;
i<binsN;
i++){
643 myBins[
i] = bins.size()==3 ? bins[1] +
i*(bins[2]-bins[1])/bins[0] : bins[
i] ;
645 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
trigger::size_type sizeFilters() 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 void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
def analyze(function, filename, filter=None)
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)
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
const Keys & filterKeys(trigger::size_type index) const
vector< pair< string, int > > filterNamesLevels
const std::string moduleEDMType(const std::string &module) const
C++ base class name of module.
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
Strings::size_type size() const
double globL3DeltaRMatchingCut
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
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)
const TriggerObjectCollection & getObjects() const
MonitorElement * bookProfile2D(Args &&...args)
virtual int pdgId() const =0
PDG identifier.
EDGetTokenT< TriggerEventWithRefs > triggerSummaryRAWTag
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
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 &)
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
double globL2DeltaRMatchingCut
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
const edm::InputTag filterTag(trigger::size_type index) const
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
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
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
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
vector< double > muonEtaBins