Skip to content

Commit

Permalink
Merge pull request #38463 from mmusich/cleanALCARECOTkAlDQM
Browse files Browse the repository at this point in the history
Introduce more plots in `DiMuonVertexMonitor` and add unit tests
  • Loading branch information
cmsbuild authored Jun 24, 2022
2 parents 9946489 + b84219e commit 1a8e19c
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 2 deletions.
12 changes: 11 additions & 1 deletion DQMOffline/Alignment/interface/DiMuonVertexMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DiMuonVertexMonitor : public DQMEDAnalyzer {
const std::string MEFolderName_; // Top-level folder name
const float maxSVdist_;

// 1D
// vertex quantities
MonitorElement *hSVProb_;
MonitorElement *hSVDist_;
MonitorElement *hSVDistErr_;
Expand All @@ -62,5 +62,15 @@ class DiMuonVertexMonitor : public DQMEDAnalyzer {
MonitorElement *hCosPhiInv3D_;
MonitorElement *hTrackInvMass_;
MonitorElement *hCutFlow_;

// impact parameters information
MonitorElement *hdxy_;
MonitorElement *hdz_;
MonitorElement *hdxyErr_;
MonitorElement *hdzErr_;
MonitorElement *hIP2d_;
MonitorElement *hIP3d_;
MonitorElement *hIP2dsig_;
MonitorElement *hIP3dsig_;
};
#endif
29 changes: 28 additions & 1 deletion DQMOffline/Alignment/src/DiMuonVertexMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
#include "RecoVertex/VertexTools/interface/VertexDistance3D.h"
#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h"
#include "TrackingTools/IPTools/interface/IPTools.h"

#include "TLorentzVector.h"

Expand Down Expand Up @@ -45,6 +46,15 @@ void DiMuonVertexMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run co
hCosPhi3D_ = iBooker.book1D("CosPhi3D", ";cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);
hCosPhiInv_ = iBooker.book1D("CosPhiInv", ";inverted cos(#phi_{xy});N(#mu#mu pairs)", 50, -1., 1.);
hCosPhiInv3D_ = iBooker.book1D("CosPhiInv3D", ";inverted cos(#phi_{3D});N(#mu#mu pairs)", 50, -1., 1.);

hdxy_ = iBooker.book1D("dxy", ";muon track d_{xy}(PV) [#mum];muon tracks", 150, -300, 300);
hdz_ = iBooker.book1D("dz", ";muon track d_{z}(PV) [#mum];muon tracks", 150, -300, 300);
hdxyErr_ = iBooker.book1D("dxyErr", ";muon track err_{dxy} [#mum];muon tracks", 250, 0., 500.);
hdzErr_ = iBooker.book1D("dzErr", ";muon track err_{dz} [#mum];muon tracks", 250, 0., 500.);
hIP2d_ = iBooker.book1D("IP2d", ";muon track IP_{2D} [#mum];muon tracks", 150, -300, 300);
hIP3d_ = iBooker.book1D("IP3d", ";muon track IP_{3D} [#mum];muon tracks", 150, -300, 300);
hIP2dsig_ = iBooker.book1D("IP2Dsig", ";muon track IP_{2D} significance;muon tracks", 100, 0., 5.);
hIP3dsig_ = iBooker.book1D("IP3Dsig", ";muon track IP_{3D} significance;muon tracks", 100, 0., 5.);
}

void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
Expand Down Expand Up @@ -126,8 +136,25 @@ void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetu
theMainVtxPos.x() - myVertex.x(), theMainVtxPos.y() - myVertex.y(), theMainVtxPos.z() - myVertex.z());

if (theMainVertex.isValid()) {
// Z Vertex distance in the xy plane
// fill the impact parameter plots
for (const auto& track : myTracks) {
hdxy_->Fill(track->dxy(theMainVtxPos) * cmToum);
hdz_->Fill(track->dz(theMainVtxPos) * cmToum);
hdxyErr_->Fill(track->dxyError() * cmToum);
hdzErr_->Fill(track->dzError() * cmToum);

const auto& ttrk = theB->build(track);
Global3DVector dir(track->px(), track->py(), track->pz());
const auto& ip2d = IPTools::signedTransverseImpactParameter(ttrk, dir, theMainVertex);
const auto& ip3d = IPTools::signedImpactParameter3D(ttrk, dir, theMainVertex);

hIP2d_->Fill(ip2d.second.value() * cmToum);
hIP3d_->Fill(ip3d.second.value() * cmToum);
hIP2dsig_->Fill(ip2d.second.significance());
hIP3dsig_->Fill(ip3d.second.significance());
}

// Z Vertex distance in the xy plane
VertexDistanceXY vertTool;
double distance = vertTool.distance(mumuTransientVtx, theMainVertex).value();
double dist_err = vertTool.distance(mumuTransientVtx, theMainVertex).error();
Expand Down
4 changes: 4 additions & 0 deletions DQMOffline/Alignment/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<bin file="TestDriver.cpp" name="testDiMuonVertexMonitor">
<use name="FWCore/Utilities"/>
<flags TEST_RUNNER_ARGS="/bin/bash DQMOffline/Alignment/test testDiMuonVertexMonitor.sh"/>
</bin>
96 changes: 96 additions & 0 deletions DQMOffline/Alignment/test/DiMuonVertexValidator_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_cff import Run3

process = cms.Process('reRECO',Run3)

import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing()
options.register('maxEvents',
-1,
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"maximum events")
options.register('globalTag',
'auto:phase1_2022_realistic',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"conditions")
options.parseArguments()

# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 200

process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('DQMServices.Core.DQMStoreNonLegacy_cff')
process.load('DQMOffline.Configuration.DQMOffline_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(options.maxEvents),
output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
)

# Input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('/store/relval/CMSSW_12_5_0_pre2/RelValZMM_14/ALCARECO/TkAlDiMuonAndVertex-124X_mcRun3_2022_realistic_v3-v1/2580000/4f9aee02-35a2-49b7-93f5-831214cf32d8.root'),
secondaryFileNames = cms.untracked.vstring()
)

process.options = cms.untracked.PSet(
FailPath = cms.untracked.vstring(),
IgnoreCompletely = cms.untracked.vstring(),
Rethrow = cms.untracked.vstring(),
SkipEvent = cms.untracked.vstring(),
accelerators = cms.untracked.vstring('*'),
allowUnscheduled = cms.obsolete.untracked.bool,
canDeleteEarly = cms.untracked.vstring(),
deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
dumpOptions = cms.untracked.bool(False),
emptyRunLumiMode = cms.obsolete.untracked.string,
eventSetup = cms.untracked.PSet(
forceNumberOfConcurrentIOVs = cms.untracked.PSet(
allowAnyLabel_=cms.required.untracked.uint32
),
numberOfConcurrentIOVs = cms.untracked.uint32(0)
),
fileMode = cms.untracked.string('FULLMERGE'),
forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
makeTriggerResults = cms.obsolete.untracked.bool,
numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
numberOfConcurrentRuns = cms.untracked.uint32(1),
numberOfStreams = cms.untracked.uint32(0),
numberOfThreads = cms.untracked.uint32(1),
printDependencies = cms.untracked.bool(False),
sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
throwIfIllegalParameter = cms.untracked.bool(True),
wantSummary = cms.untracked.bool(False)
)

process.DQMoutput = cms.OutputModule("DQMRootOutputModule",
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('DQMIO'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string('file:step3_inDQM.root'),
outputCommands = process.DQMEventContent.outputCommands,
splitLevel = cms.untracked.int32(0)
)

from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, options.globalTag, '')

process.load("DQMOffline.Configuration.AlCaRecoDQM_cff")
process.seqALCARECOTkAlDiMuonAndVertex = cms.Sequence(process.ALCARECOTkAlDiMuonAndVertexVtxDQM)

process.dqmoffline_step = cms.EndPath(process.seqALCARECOTkAlDiMuonAndVertex)
process.DQMoutput_step = cms.EndPath(process.DQMoutput)

process.schedule = cms.Schedule(process.dqmoffline_step,process.DQMoutput_step)
106 changes: 106 additions & 0 deletions DQMOffline/Alignment/test/DiMuonVertex_HARVESTING.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Auto generated configuration file
# using:
# Revision: 1.19
# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v
# with command line options: DiMuonVertex -s HARVESTING:alcaHarvesting --conditions auto:phase1_2022_realistic --mc --filetype DQM --scenario pp --era Run3 -n -1 --filein file:step3_inDQM.root
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_cff import Run3

process = cms.Process('HARVESTING',Run3)

import FWCore.ParameterSet.VarParsing as VarParsing

options = VarParsing.VarParsing()
options.register('maxEvents',
-1,
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"maximum events")
options.register('globalTag',
'auto:phase1_2022_realistic',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"conditions")
options.parseArguments()

# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('SimGeneral.MixingModule.mixNoPU_cfi')
process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('Configuration.StandardSequences.DQMSaverAtRunEnd_cff')
process.load('Configuration.StandardSequences.Harvesting_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(options.maxEvents),
output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
)

# Input source
process.source = cms.Source("DQMRootSource",
fileNames = cms.untracked.vstring('file:step3_inDQM.root')
)

process.options = cms.untracked.PSet(
FailPath = cms.untracked.vstring(),
IgnoreCompletely = cms.untracked.vstring(),
Rethrow = cms.untracked.vstring('ProductNotFound'),
SkipEvent = cms.untracked.vstring(),
accelerators = cms.untracked.vstring('*'),
allowUnscheduled = cms.obsolete.untracked.bool,
canDeleteEarly = cms.untracked.vstring(),
deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
dumpOptions = cms.untracked.bool(False),
emptyRunLumiMode = cms.obsolete.untracked.string,
eventSetup = cms.untracked.PSet(
forceNumberOfConcurrentIOVs = cms.untracked.PSet(
allowAnyLabel_=cms.required.untracked.uint32
),
numberOfConcurrentIOVs = cms.untracked.uint32(0)
),
fileMode = cms.untracked.string('FULLMERGE'),
forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
makeTriggerResults = cms.obsolete.untracked.bool,
numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
numberOfConcurrentRuns = cms.untracked.uint32(1),
numberOfStreams = cms.untracked.uint32(0),
numberOfThreads = cms.untracked.uint32(1),
printDependencies = cms.untracked.bool(False),
sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
throwIfIllegalParameter = cms.untracked.bool(True),
wantSummary = cms.untracked.bool(False)
)

# Production Info
process.configurationMetadata = cms.untracked.PSet(
annotation = cms.untracked.string('DiMuonVertex nevts:-1'),
name = cms.untracked.string('Applications'),
version = cms.untracked.string('$Revision: 1.19 $')
)

# Output definition

# Additional output definition

# Other statements
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, options.globalTag, '')

process.dqmsave_step = cms.Path(process.DQMSaver)

# Schedule definition
process.schedule = cms.Schedule(process.alcaHarvesting,process.dqmsave_step)
from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
associatePatAlgosToolsTask(process)

# Customisation from command line

# Add early deletion of temporary data products to reduce peak memory need
from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
process = customiseEarlyDelete(process)
# End adding early deletion
2 changes: 2 additions & 0 deletions DQMOffline/Alignment/test/TestDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "FWCore/Utilities/interface/TestHelper.h"
RUNTEST()
11 changes: 11 additions & 0 deletions DQMOffline/Alignment/test/testDiMuonVertexMonitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

function die { echo $1: status $2; exit $2; }

if [ "${SCRAM_TEST_NAME}" != "" ] ; then
mkdir ${SCRAM_TEST_NAME}
cd ${SCRAM_TEST_NAME}
fi

cmsRun ${LOCAL_TEST_DIR}/DiMuonVertexValidator_cfg.py || die "Failure using DiMuonVertexValidator_cfg.py" $?
cmsRun ${LOCAL_TEST_DIR}/DiMuonVertex_HARVESTING.py || die "Failure using DiMuonVertex_HARVESTING.py" $?

0 comments on commit 1a8e19c

Please sign in to comment.