Skip to content

Commit

Permalink
Merge pull request #19753 from hroskes/track-hit-filter-validation
Browse files Browse the repository at this point in the history
Use the common sequence for PV validation
  • Loading branch information
cmsbuild committed Aug 1, 2017
2 parents 65116d2 + a90ce8f commit 2a5c864
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 55 deletions.
Expand Up @@ -173,6 +173,8 @@
cosmicTrackSplitting=.oO[istracksplitting]Oo.,
use_d0cut=.oO[use_d0cut]Oo.,
)
.oO[trackhitfiltercommands]Oo.
"""


Expand Down
Expand Up @@ -507,18 +507,34 @@ class GenericValidationData_CTSR(GenericValidationData):
"momentumconstraint": "None",
"openmasswindow": "False",
"cosmicsdecomode": "True",
"removetrackhitfiltercommands": "",
"appendtrackhitfiltercommands": "",
}
def getRepMap(self):
result = super(GenericValidationData_CTSR, self).getRepMap()
def getRepMap(self, alignment=None):
result = super(GenericValidationData_CTSR, self).getRepMap(alignment)

from trackSplittingValidation import TrackSplittingValidation
result.update({
"ValidationSequence": self.ValidationSequence,
"istracksplitting": str(isinstance(self, TrackSplittingValidation)),
"cosmics0T": str(self.cosmics0T),
"use_d0cut": str("Cosmics" not in self.general["trackcollection"]), #use it for collisions only
"use_d0cut": str(self.use_d0cut),
})

commands = []
for removeorappend in "remove", "append":
optionname = removeorappend + "trackhitfiltercommands"
if result[optionname]:
for command in result[optionname].split(","):
command = command.strip()
commands.append('process.TrackerTrackHitFilter.commands.{}("{}")'.format(removeorappend, command))
result["trackhitfiltercommands"] = "\n".join(commands)

return result
@property
def use_d0cut(self):
return "Cosmics" not in self.general["trackcollection"] #use it for collisions only
@property
def TrackSelectionRefitting(self):
return configTemplates.CommonTrackSelectionRefitting
@property
Expand Down
Expand Up @@ -67,7 +67,7 @@ def createCrabCfg(self, path):
return super(OfflineValidation, self).createCrabCfg(path, self.crabCfgBaseName)

def getRepMap(self, alignment = None):
repMap = super(OfflineValidation, self).getRepMap()
repMap = super(OfflineValidation, self).getRepMap(alignment)
repMap.update({
"nEvents": self.general["maxevents"],
"offlineValidationMode": "Standalone",
Expand Down
@@ -1,11 +1,11 @@
import os
import configTemplates
import globalDictionaries
from genericValidation import GenericValidationData, ValidationWithPlots, pythonboolstring
from genericValidation import GenericValidationData_CTSR, ValidationWithPlots, pythonboolstring
from helperFunctions import replaceByMap
from TkAlExceptions import AllInOneError

class PrimaryVertexValidation(GenericValidationData, ValidationWithPlots):
class PrimaryVertexValidation(GenericValidationData_CTSR, ValidationWithPlots):
configBaseName = "TkAlPrimaryVertexValidation"
scriptBaseName = "TkAlPrimaryVertexValidation"
crabCfgBaseName = "TkAlPrimaryVertexValidation"
Expand Down Expand Up @@ -35,16 +35,21 @@ def ValidationTemplate(self):
return configTemplates.PrimaryVertexValidationTemplate

@property
def TrackSelectionRefitting(self):
return configTemplates.SingleTrackRefitter
def DefinePath(self):
return configTemplates.PVValidationPath

@property
def ProcessName(self):
return "PrimaryVertexValidation"
def ValidationSequence(self):
#never enters anywhere, since we use the custom DefinePath which includes the goodVertexSkim
return ""

@property
def DefinePath(self):
return configTemplates.PVValidationPath
def use_d0cut(self):
return False

@property
def ProcessName(self):
return "PrimaryVertexValidation"

def createScript(self, path):
return super(PrimaryVertexValidation, self).createScript(path, template = configTemplates.PVValidationScriptTemplate)
Expand Down
@@ -1,4 +1,16 @@
PrimaryVertexValidationTemplate="""
process.HighPurityTrackSelector.trackQualities = cms.vstring()
process.HighPurityTrackSelector.pMin = cms.double(0.)
process.AlignmentTrackSelector.pMin = cms.double(0.)
process.AlignmentTrackSelector.ptMin = cms.double(0.)
process.AlignmentTrackSelector.nHitMin2D = cms.uint32(0)
process.AlignmentTrackSelector.nHitMin = cms.double(0.)
process.AlignmentTrackSelector.d0Min = cms.double(-999999.0)
process.AlignmentTrackSelector.d0Max = cms.double(+999999.0)
process.AlignmentTrackSelector.dzMin = cms.double(-999999.0)
process.AlignmentTrackSelector.dzMax = cms.double(+999999.0)
isDA = .oO[isda]Oo.
isMC = .oO[ismc]Oo.
Expand Down Expand Up @@ -72,8 +84,8 @@
if isDA:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running DA Algorithm!"
process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
TrackCollectionTag = cms.InputTag("TrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
Debug = cms.bool(False),
storeNtuple = cms.bool(False),
useTracksFromRecoVtx = cms.bool(False),
Expand All @@ -96,16 +108,16 @@
maxEta = cms.double(5.0), # as per recommendation in PR #18330
trackQuality = cms.string("any")
),
## MM 04.05.2017 (use settings as in: https://github.com/cms-sw/cmssw/pull/18330)
TkClusParameters=cms.PSet(algorithm=cms.string('DA_vect'),
TkDAClusParameters = cms.PSet(coolingFactor = cms.double(0.6), # moderate annealing speed
Tmin = cms.double(2.0), # end of vertex splitting
Tpurge = cms.double(2.0), # cleaning
Tpurge = cms.double(2.0), # cleaning
Tstop = cms.double(0.5), # end of annealing
vertexSize = cms.double(0.006), # added in quadrature to track-z resolutions
d0CutOff = cms.double(3.), # downweight high IP tracks
dzCutOff = cms.double(3.), # outlier rejection after freeze-out (T<Tmin)
dzCutOff = cms.double(3.), # outlier rejection after freeze-out (T<Tmin)
zmerge = cms.double(1e-2), # merge intermediat clusters separated by less than zmerge
uniquetrkweight = cms.double(0.8) # require at least two tracks with this weight at T=Tpurge
)
Expand All @@ -118,8 +130,8 @@
else:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!"
process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
TrackCollectionTag = cms.InputTag("TrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
Debug = cms.bool(False),
isLightNtuple = cms.bool(True),
storeNtuple = cms.bool(False),
Expand All @@ -132,20 +144,20 @@
numberOfBins = cms.untracked.int32(.oO[numberOfBins]Oo.),
runControl = cms.untracked.bool(.oO[runControl]Oo.),
runControlNumber = cms.untracked.vuint32(int(.oO[runboundary]Oo.)),
TkFilterParameters = cms.PSet(algorithm=cms.string('filter'),
maxNormalizedChi2 = cms.double(5.0), # chi2ndof < 20
minPixelLayersWithHits=cms.int32(2), # PX hits > 2
minSiliconLayersWithHits = cms.int32(5), # TK hits > 5
TkFilterParameters = cms.PSet(algorithm=cms.string('filter'),
maxNormalizedChi2 = cms.double(5.0), # chi2ndof < 20
minPixelLayersWithHits=cms.int32(2), # PX hits > 2
minSiliconLayersWithHits = cms.int32(5), # TK hits > 5
maxD0Significance = cms.double(5.0), # fake cut (requiring 1 PXB hit)
minPt = cms.double(0.0), # better for softish events
minPt = cms.double(0.0), # better for softish events
maxEta = cms.double(5.0), # as per recommendation in PR #18330
trackQuality = cms.string("any")
),
TkClusParameters = cms.PSet(algorithm = cms.string('gap'),
TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2) # 0.2 cm max separation betw. clusters
)
)
)
)
Expand All @@ -155,15 +167,14 @@
####################################################################
PVValidationPath="""
process.p = cms.Path(process.goodvertexSkim*
process.offlineBeamSpot*
process.TrackRefitter*
process.seqTrackselRefit*
process.PVValidation)
"""

####################################################################
####################################################################
PVValidationScriptTemplate="""
#!/bin/bash
#!/bin/bash
source /afs/cern.ch/cms/caf/setup.sh
eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
Expand Down Expand Up @@ -198,7 +209,7 @@
.oO[CommandLine]Oo.
ls -lh .
ls -lh .
$eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo./plots/
for RootOutputFile in $(ls *root )
Expand All @@ -207,12 +218,12 @@
rfcp ${RootOutputFile} .oO[workingdir]Oo.
done
cp .oO[Alignment/OfflineValidation]Oo./macros/FitPVResiduals.C .
cp .oO[Alignment/OfflineValidation]Oo./macros/FitPVResiduals.C .
cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.C .
cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.h .
if [[ .oO[pvvalidationreference]Oo. == *store* ]]; then xrdcp -f .oO[pvvalidationreference]Oo. PVValidation_reference.root; else ln -fs .oO[pvvalidationreference]Oo. ./PVValidation_reference.root; fi
root -b -q "FitPVResiduals.C(\\"${PWD}/${RootOutputFile}=${theLabel},${PWD}/PVValidation_reference.root=Design simulation\\",true,true,\\"$theDate\\")"
mkdir -p .oO[plotsdir]Oo.
Expand All @@ -221,10 +232,10 @@
rfcp ${PngOutputFile} .oO[plotsdir]Oo.
done
for PdfOutputFile in $(ls *pdf ); do
xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
rfcp ${PdfOutputFile} .oO[plotsdir]Oo.
done
for PdfOutputFile in $(ls *pdf ); do
xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
rfcp ${PdfOutputFile} .oO[plotsdir]Oo.
done
mkdir .oO[plotsdir]Oo./Biases/
mkdir .oO[plotsdir]Oo./Biases/dzPhi
Expand Down Expand Up @@ -256,7 +267,7 @@
mv .oO[plotsdir]Oo./dxyPhiTrend* .oO[plotsdir]Oo./dxyVsPhi
mv .oO[plotsdir]Oo./dzPhiTrend* .oO[plotsdir]Oo./dzVsPhi
wget https://raw.githubusercontent.com/mmusich/PVToolScripts/master/PolishedScripts/index.php
wget https://raw.githubusercontent.com/mmusich/PVToolScripts/master/PolishedScripts/index.php
cp index.php .oO[plotsdir]Oo./Biases/
cp index.php .oO[plotsdir]Oo./Biases/dzPhi
Expand All @@ -276,7 +287,7 @@
echo -----------------------
echo Job ended at `date`
echo -----------------------
echo -----------------------
"""

Expand All @@ -289,10 +300,10 @@
rfcp .oO[plottingscriptpath]Oo. .
root -x -b -q .oO[plottingscriptname]Oo.++
for PdfOutputFile in $(ls *pdf ); do
xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
for PdfOutputFile in $(ls *pdf ); do
xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
rfcp ${PdfOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
done
done
for PngOutputFile in $(ls *png ); do
xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
Expand All @@ -316,18 +327,18 @@
{
// initialize the plot y-axis ranges
thePlotLimits->init(.oO[m_dxyPhiMax]Oo., // mean of dxy vs Phi
.oO[m_dzPhiMax]Oo., // mean of dz vs Phi
.oO[m_dxyEtaMax]Oo., // mean of dxy vs Eta
.oO[m_dzEtaMax]Oo., // mean of dz vs Eta
.oO[m_dxyPhiNormMax]Oo., // mean of dxy vs Phi (norm)
.oO[m_dzPhiNormMax]Oo., // mean of dz vs Phi (norm)
.oO[m_dxyEtaNormMax]Oo., // mean of dxy vs Eta (norm)
.oO[m_dzEtaNormMax]Oo., // mean of dz vs Eta (norm)
.oO[w_dxyPhiMax]Oo., // width of dxy vs Phi
.oO[w_dzPhiMax]Oo., // width of dz vs Phi
.oO[w_dxyEtaMax]Oo., // width of dxy vs Eta
.oO[w_dzEtaMax]Oo., // width of dz vs Eta
thePlotLimits->init(.oO[m_dxyPhiMax]Oo., // mean of dxy vs Phi
.oO[m_dzPhiMax]Oo., // mean of dz vs Phi
.oO[m_dxyEtaMax]Oo., // mean of dxy vs Eta
.oO[m_dzEtaMax]Oo., // mean of dz vs Eta
.oO[m_dxyPhiNormMax]Oo., // mean of dxy vs Phi (norm)
.oO[m_dzPhiNormMax]Oo., // mean of dz vs Phi (norm)
.oO[m_dxyEtaNormMax]Oo., // mean of dxy vs Eta (norm)
.oO[m_dzEtaNormMax]Oo., // mean of dz vs Eta (norm)
.oO[w_dxyPhiMax]Oo., // width of dxy vs Phi
.oO[w_dzPhiMax]Oo., // width of dz vs Phi
.oO[w_dxyEtaMax]Oo., // width of dxy vs Eta
.oO[w_dzEtaMax]Oo., // width of dz vs Eta
.oO[w_dxyPhiNormMax]Oo., // width of dxy vs Phi (norm)
.oO[w_dzPhiNormMax]Oo., // width of dz vs Phi (norm)
.oO[w_dxyEtaNormMax]Oo., // width of dxy vs Eta (norm)
Expand Down
Expand Up @@ -34,7 +34,7 @@ def createCrabCfg(self, path):
return super(TrackSplittingValidation, self).createCrabCfg(path, self.crabCfgBaseName)

def getRepMap( self, alignment = None ):
repMap = super(TrackSplittingValidation, self).getRepMap()
repMap = super(TrackSplittingValidation, self).getRepMap(alignment)
if repMap["subdetector"] == "none":
subdetselection = ""
else:
Expand Down

0 comments on commit 2a5c864

Please sign in to comment.