Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inclusion of muon timing plots in the DQMOffline/Muon package #18267

Merged
merged 4 commits into from May 11, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions DQMOffline/Muon/interface/DiMuonHistograms.h
Expand Up @@ -65,6 +65,7 @@ class DiMuonHistograms : public DQMEDAnalyzer {
double etaECMin;
double etaECMax;


//Defining the relevant invariant mass regions
double LowMassMin;
double LowMassMax;
Expand All @@ -78,6 +79,8 @@ class DiMuonHistograms : public DQMEDAnalyzer {
std::vector<MonitorElement*> TrkTrkMuon_LM;
std::vector<MonitorElement*> TrkTrkMuon_HM;

std::vector<MonitorElement*> LooseLooseMuon;
std::vector<MonitorElement*> MediumMediumMuon;
std::vector<MonitorElement*> TightTightMuon;
std::vector<MonitorElement*> SoftSoftMuon;

Expand All @@ -91,6 +94,8 @@ class DiMuonHistograms : public DQMEDAnalyzer {
std::string theFolder;

int nTightTight;
int nMediumMedium;
int nLooseLoose;
int nGlbGlb;

};
Expand Down
85 changes: 85 additions & 0 deletions DQMOffline/Muon/interface/MuonTiming.h
@@ -0,0 +1,85 @@
#ifndef MuonTiming_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @parbol - sorry I missed this before - the include guard should have the package name to ensure no conflicts - eg
ifndef DQMOffline_Muon_MuonTiming_H

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks again. This has been adapted.

#define MuonTiming_H

/** \class MuRecoAnalyzer
*
* DQM monitoring source for muon reco track
*
* \author G. Mila - INFN Torino
*/

#include <memory>
#include <fstream>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"

#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

class MuonTiming : public DQMEDAnalyzer {
public:

/// Constructor
MuonTiming(const edm::ParameterSet&);

/// Destructor
virtual ~MuonTiming();

/// Inizialize parameters for histo binning
void analyze(const edm::Event&, const edm::EventSetup&) override;
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;

private:
// ----------member data ---------------------------
MuonServiceProxy *theService;
edm::ParameterSet parameters;

edm::EDGetTokenT<edm::View<reco::Muon> > theMuonCollectionLabel_;
// Switch for verbosity
std::string metname;


//histo binning parameters
int tnbins;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow a naming convention for variables that make up a class. Eg, in CMS its often an '_' at the end of the variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a '_' at the end of all of them.

int tnbinsrpc;
int terrnbins;
int terrnbinsrpc;
int ndofnbins;
int ptnbins;
int etanbins;
double tmax, tmin;
double tmaxrpc, tminrpc;
double terrmax, terrmin;
double terrmaxrpc, terrminrpc;
double ndofmax, ndofmin;
double ptmax, ptmin;
double etamax, etamin;
double etaBarrelMin, etaBarrelMax, etaEndcapMin, etaEndcapMax, etaOverlapMin, etaOverlapMax;

std::string theFolder;
std::vector<std::string> EtaName, ObjectName;
enum eta {overlap, barrel, endcap};
enum object {sta, glb};
//the histos
std::vector<std::vector<MonitorElement*>> timeNDof;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the sizes of these are known (and hardwired), please use std::array<std::array<MonitorElement*,1>,3> to avoid both the extra memory of the vectors and the need to first declare a vector and then push_back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, yes. That's way smarter. Sorry for not having thought about it in the first place. It's now implemented.

std::vector<std::vector<MonitorElement*>> timeAtIpInOut;
std::vector<std::vector<MonitorElement*>> timeAtIpInOutRPC;
std::vector<std::vector<MonitorElement*>> timeAtIpInOutErr;
std::vector<std::vector<MonitorElement*>> timeAtIpInOutErrRPC;
std::vector<MonitorElement*> etaptVeto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated as well.

std::vector<MonitorElement*> etaVeto;
std::vector<MonitorElement*> ptVeto;
std::vector<MonitorElement*> yields;

};
#endif
24 changes: 12 additions & 12 deletions DQMOffline/Muon/python/diMuonHistograms_cfi.py
Expand Up @@ -7,39 +7,39 @@
VertexLabel = cms.InputTag("offlinePrimaryVertices"),
BeamSpotLabel = cms.InputTag("offlineBeamSpot"),

etaBin = cms.int32(400),
etaBBin = cms.int32(400),
etaEBin = cms.int32(200),
etaBin = cms.int32(40),
etaBBin = cms.int32(40),
etaEBin = cms.int32(40),

etaBMin = cms.double(0.),
etaBMax = cms.double(1.1),
etaECMin = cms.double(0.9),
etaECMax = cms.double(2.4),

LowMassMin = cms.double(2.0),
LowMassMax = cms.double(55.0),
HighMassMin = cms.double(55.0),
HighMassMax = cms.double(155.0),
LowMassMax = cms.double(12.0),
HighMassMin = cms.double(70.0),
HighMassMax = cms.double(110.0),
folder = cms.string("Muons/diMuonHistograms")
)
diMuonHistos_miniAOD = cms.EDAnalyzer("DiMuonHistograms",
MuonCollection = cms.InputTag("slimmedMuons"),
VertexLabel = cms.InputTag("offlineSlimmedPrimaryVertices"),
BeamSpotLabel = cms.InputTag("offlineBeamSpot"),

etaBin = cms.int32(400),
etaBBin = cms.int32(400),
etaEBin = cms.int32(200),
etaBin = cms.int32(40),
etaBBin = cms.int32(40),
etaEBin = cms.int32(40),

etaBMin = cms.double(0.),
etaBMax = cms.double(1.1),
etaECMin = cms.double(0.9),
etaECMax = cms.double(2.4),

LowMassMin = cms.double(2.0),
LowMassMax = cms.double(55.0),
HighMassMin = cms.double(55.0),
HighMassMax = cms.double(155.0),
LowMassMax = cms.double(12.0),
HighMassMin = cms.double(70.0),
HighMassMax = cms.double(110.0),
folder = cms.string("Muons_miniAOD/diMuonHistograms")
)

Expand Down
74 changes: 74 additions & 0 deletions DQMOffline/Muon/python/muonTiming_cfi.py
@@ -0,0 +1,74 @@
import FWCore.ParameterSet.Config as cms

from RecoMuon.TrackingTools.MuonServiceProxy_cff import *

muonTiming = cms.EDAnalyzer("MuonTiming",
MuonServiceProxy,
MuonCollection = cms.InputTag("muons"),
# histograms parameters
tnbins = cms.int32(40),
tnbinsrpc = cms.int32(20),
terrnbins = cms.int32(20),
terrnbinsrpc = cms.int32(20),
ndofnbins = cms.int32(40),
ptnbins = cms.int32(20),
etanbins = cms.int32(20),
tmax = cms.double(300),
tmaxrpc = cms.double(30),
terrmax = cms.double(10),
terrmaxrpc = cms.double(10),
ndofmax = cms.double(40),
ptmax = cms.double(200),
etamax = cms.double(2.4),
tmin = cms.double(-300),
tminrpc = cms.double(-30),
terrmin = cms.double(0),
terrminrpc = cms.double(0),
ndofmin = cms.double(0),
ptmin = cms.double(0),
etamin = cms.double(-2.4),
etaBarrelMin = cms.double(0),
etaBarrelMax = cms.double(1.1),
etaOverlapMin = cms.double(0.9),
etaOverlapMax = cms.double(1.1),
etaEndcapMin = cms.double(0.9),
etaEndcapMax = cms.double(2.4),
folder = cms.string("Muons/MuonTiming")
)

muonTiming_miniAOD = cms.EDAnalyzer("MuonTiming",
MuonServiceProxy,
MuonCollection = cms.InputTag("slimmedMuons"),
# histograms parameters
tnbins = cms.int32(40),
tnbinsrpc = cms.int32(20),
terrnbins = cms.int32(20),
terrnbinsrpc = cms.int32(20),
ndofnbins = cms.int32(40),
ptnbins = cms.int32(20),
etanbins = cms.int32(20),
tmax = cms.double(300),
tmaxrpc = cms.double(30),
terrmax = cms.double(10),
terrmaxrpc = cms.double(10),
ndofmax = cms.double(40),
ptmax = cms.double(200),
etamax = cms.double(2.4),
tmin = cms.double(-300),
tminrpc = cms.double(-30),
terrmin = cms.double(0),
terrminrpc = cms.double(0),
ndofmin = cms.double(0),
ptmin = cms.double(0),
etamin = cms.double(-2.4),
etaBarrelMin = cms.double(0),
etaBarrelMax = cms.double(1.1),
etaOverlapMin = cms.double(0.9),
etaOverlapMax = cms.double(1.1),
etaEndcapMin = cms.double(0.9),
etaEndcapMax = cms.double(2.4),
folder = cms.string("Muons_miniAOD/MuonTiming")
)



46 changes: 43 additions & 3 deletions DQMOffline/Muon/src/DiMuonHistograms.cc
Expand Up @@ -36,6 +36,8 @@ DiMuonHistograms::DiMuonHistograms(const edm::ParameterSet& pSet){

// counter
nTightTight = 0;
nMediumMedium = 0;
nLooseLoose = 0;
nGlbGlb = 0;

// declare consumes:
Expand All @@ -47,7 +49,7 @@ DiMuonHistograms::DiMuonHistograms(const edm::ParameterSet& pSet){
etaBin = parameters.getParameter<int>("etaBin");
etaBBin = parameters.getParameter<int>("etaBBin");
etaEBin = parameters.getParameter<int>("etaEBin");

etaBMin = parameters.getParameter<double>("etaBMin");
etaBMax = parameters.getParameter<double>("etaBMax");
etaECMin = parameters.getParameter<double>("etaECMin");
Expand Down Expand Up @@ -84,7 +86,9 @@ void DiMuonHistograms::bookHistograms(DQMStore::IBooker & ibooker,
StaTrkMuon_HM.push_back(ibooker.book1D("StaTrkMuon_HM"+EtaName[iEtaRegion],"InvMass_{STA,TRK}"+EtaName[iEtaRegion],nBin[iEtaRegion], HighMassMin, HighMassMax));

// arround the Z peak
TightTightMuon.push_back(ibooker.book1D("TightTightMuon"+EtaName[iEtaRegion],"InvMass_{Tight,Tight}"+EtaName[iEtaRegion],nBin[iEtaRegion], 55.0, 125.0));
TightTightMuon.push_back(ibooker.book1D("TightTightMuon"+EtaName[iEtaRegion],"InvMass_{Tight,Tight}"+EtaName[iEtaRegion], nBin[iEtaRegion], LowMassMin, LowMassMax));
MediumMediumMuon.push_back(ibooker.book1D("MediumMediumMuon"+EtaName[iEtaRegion],"InvMass_{Medium,Medium}"+EtaName[iEtaRegion],nBin[iEtaRegion], LowMassMin, LowMassMax));
LooseLooseMuon.push_back(ibooker.book1D("LooseLooseMuon"+EtaName[iEtaRegion],"InvMass_{Loose,Loose}"+EtaName[iEtaRegion], nBin[iEtaRegion], LowMassMin, LowMassMax));

// low-mass resonances
SoftSoftMuon.push_back(ibooker.book1D("SoftSoftMuon"+EtaName[iEtaRegion],"InvMass_{Soft,Soft}"+EtaName[iEtaRegion],nBin[iEtaRegion], 0.0, 55.0));
Expand Down Expand Up @@ -172,7 +176,7 @@ void DiMuonHistograms::analyze(const edm::Event & iEvent,const edm::EventSetup&
}
}
}
// Also Tight-Tight Muon Selection
// Also Tight-Tight Muon Selection
if ( muon::isTightMuon(*muon1, vtx) &&
muon::isTightMuon(*muon2, vtx) ) {
test->Fill(InvMass);
Expand All @@ -190,6 +194,42 @@ void DiMuonHistograms::analyze(const edm::Event & iEvent,const edm::EventSetup&
}
}
}
// Also Medium-Medium Muon Selection
if ( muon::isMediumMuon(*muon1) &&
muon::isMediumMuon(*muon2) ) {
test->Fill(InvMass);
LogTrace(metname)<<"[DiMuonHistograms] Medium-Medium pair"<<endl;
if (charge < 0){
for (unsigned int iEtaRegion=0; iEtaRegion<3; iEtaRegion++){
if (iEtaRegion==0) {EtaCutMin= 0.; EtaCutMax=2.4; }
if (iEtaRegion==1) {EtaCutMin= etaBMin; EtaCutMax=etaBMax; }
if (iEtaRegion==2) {EtaCutMin= etaECMin; EtaCutMax=etaECMax; }

if(fabs(recoCombinedGlbTrack1->eta())>EtaCutMin && fabs(recoCombinedGlbTrack1->eta())<EtaCutMax &&
fabs(recoCombinedGlbTrack2->eta())>EtaCutMin && fabs(recoCombinedGlbTrack2->eta())<EtaCutMax){
if (InvMass > 55. && InvMass < 125.) MediumMediumMuon[iEtaRegion]->Fill(InvMass);
}
}
}
}
// Also Loose-Loose Muon Selection
if ( muon::isLooseMuon(*muon1) &&
muon::isLooseMuon(*muon2) ) {
test->Fill(InvMass);
LogTrace(metname)<<"[DiMuonHistograms] Loose-Loose pair"<<endl;
if (charge < 0){
for (unsigned int iEtaRegion=0; iEtaRegion<3; iEtaRegion++){
if (iEtaRegion==0) {EtaCutMin= 0.; EtaCutMax=2.4; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please declare the etacutMin/Max vales in const arrays to avoid the needless if statements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the advice. It has been corrected in the new version.

if (iEtaRegion==1) {EtaCutMin= etaBMin; EtaCutMax=etaBMax; }
if (iEtaRegion==2) {EtaCutMin= etaECMin; EtaCutMax=etaECMax; }

if(fabs(recoCombinedGlbTrack1->eta())>EtaCutMin && fabs(recoCombinedGlbTrack1->eta())<EtaCutMax &&
fabs(recoCombinedGlbTrack2->eta())>EtaCutMin && fabs(recoCombinedGlbTrack2->eta())<EtaCutMax){
if (InvMass > 55. && InvMass < 125.) LooseLooseMuon[iEtaRegion]->Fill(InvMass);
}
}
}
}
}

// Now check for STA-TRK
Expand Down
16 changes: 8 additions & 8 deletions DQMOffline/Muon/src/MuonKinVsEtaAnalyzer.cc
Expand Up @@ -211,7 +211,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pGlbTrack[iEtaRegion]->Fill(recoCombinedGlbTrack->p());
ptGlbTrack[iEtaRegion]->Fill(recoCombinedGlbTrack->pt());
chi2GlbTrack[iEtaRegion]->Fill(recoCombinedGlbTrack->normalizedChi2());
chi2probGlbTrack[iEtaRegion]->Fill(TMath::Prob(recoCombinedGlbTrack->normalizedChi2(),recoCombinedGlbTrack->ndof()));
chi2probGlbTrack[iEtaRegion]->Fill(TMath::Prob(recoCombinedGlbTrack->chi2(),recoCombinedGlbTrack->ndof()));
}
}

Expand All @@ -228,7 +228,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pTrack[iEtaRegion]->Fill(recoTrack->p());
ptTrack[iEtaRegion]->Fill(recoTrack->pt());
chi2Track[iEtaRegion]->Fill(recoTrack->normalizedChi2());
chi2probTrack[iEtaRegion]->Fill(TMath::Prob(recoTrack->normalizedChi2(),recoTrack->ndof()));
chi2probTrack[iEtaRegion]->Fill(TMath::Prob(recoTrack->chi2(),recoTrack->ndof()));
}
}

Expand All @@ -245,7 +245,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pStaTrack[iEtaRegion]->Fill(recoStaTrack->p());
ptStaTrack[iEtaRegion]->Fill(recoStaTrack->pt());
chi2StaTrack[iEtaRegion]->Fill(recoStaTrack->normalizedChi2());
chi2probStaTrack[iEtaRegion]->Fill(TMath::Prob(recoStaTrack->normalizedChi2(),recoStaTrack->ndof()));
chi2probStaTrack[iEtaRegion]->Fill(TMath::Prob(recoStaTrack->chi2(),recoStaTrack->ndof()));
}
}

Expand All @@ -261,7 +261,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pTightTrack[iEtaRegion]->Fill(recoTightTrack->p());
ptTightTrack[iEtaRegion]->Fill(recoTightTrack->pt());
chi2TightTrack[iEtaRegion]->Fill(recoTightTrack->normalizedChi2());
chi2probTightTrack[iEtaRegion]->Fill(TMath::Prob(recoTightTrack->normalizedChi2(),recoTightTrack->ndof()));
chi2probTightTrack[iEtaRegion]->Fill(TMath::Prob(recoTightTrack->chi2(),recoTightTrack->ndof()));
}
}

Expand All @@ -282,7 +282,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pLooseTrack[iEtaRegion]->Fill(recoLooseTrack->p());
ptLooseTrack[iEtaRegion]->Fill(recoLooseTrack->pt());
chi2LooseTrack[iEtaRegion]->Fill(recoLooseTrack->normalizedChi2());
chi2probLooseTrack[iEtaRegion]->Fill(TMath::Prob(recoLooseTrack->normalizedChi2(),recoLooseTrack->ndof()));
chi2probLooseTrack[iEtaRegion]->Fill(TMath::Prob(recoLooseTrack->chi2(),recoLooseTrack->ndof()));
}
}

Expand All @@ -302,7 +302,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pMediumTrack[iEtaRegion]->Fill(recoMediumTrack->p());
ptMediumTrack[iEtaRegion]->Fill(recoMediumTrack->pt());
chi2MediumTrack[iEtaRegion]->Fill(recoMediumTrack->normalizedChi2());
chi2probMediumTrack[iEtaRegion]->Fill(TMath::Prob(recoMediumTrack->normalizedChi2(),recoMediumTrack->ndof()));
chi2probMediumTrack[iEtaRegion]->Fill(TMath::Prob(recoMediumTrack->chi2(),recoMediumTrack->ndof()));
}
}

Expand All @@ -318,7 +318,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pSoftTrack[iEtaRegion]->Fill(recoSoftTrack->p());
ptSoftTrack[iEtaRegion]->Fill(recoSoftTrack->pt());
chi2SoftTrack[iEtaRegion]->Fill(recoSoftTrack->normalizedChi2());
chi2probSoftTrack[iEtaRegion]->Fill(TMath::Prob(recoSoftTrack->normalizedChi2(),recoSoftTrack->ndof()));
chi2probSoftTrack[iEtaRegion]->Fill(TMath::Prob(recoSoftTrack->chi2(),recoSoftTrack->ndof()));
}
}

Expand All @@ -334,7 +334,7 @@ void MuonKinVsEtaAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
pHighPtTrack[iEtaRegion]->Fill(recoHighPtTrack->p());
ptHighPtTrack[iEtaRegion]->Fill(recoHighPtTrack->pt());
chi2HighPtTrack[iEtaRegion]->Fill(recoHighPtTrack->normalizedChi2());
chi2probHighPtTrack[iEtaRegion]->Fill(TMath::Prob(recoHighPtTrack->normalizedChi2(),recoHighPtTrack->ndof()));
chi2probHighPtTrack[iEtaRegion]->Fill(TMath::Prob(recoHighPtTrack->chi2(),recoHighPtTrack->ndof()));
}
}
} //end iEtaRegions
Expand Down