-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
primaryVertexValidationTemplates.py
344 lines (291 loc) · 18.5 KB
/
primaryVertexValidationTemplates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
PrimaryVertexValidationTemplate="""
isDA = .oO[isda]Oo.
isMC = .oO[ismc]Oo.
###################################################################
# Runs and events
###################################################################
runboundary = .oO[runboundary]Oo.
isMultipleRuns=False
if(isinstance(runboundary, (list, tuple))):
isMultipleRuns=True
print "Multiple Runs are selected"
if(isMultipleRuns):
process.source.firstRun = cms.untracked.uint32(int(runboundary[0]))
else:
process.source.firstRun = cms.untracked.uint32(int(runboundary))
###################################################################
# JSON Filtering
###################################################################
if isMC:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is simulation!"
runboundary = 1
else:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is real DATA!"
if ('.oO[lumilist]Oo.'):
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: JSON filtering with: .oO[lumilist]Oo. "
import FWCore.PythonUtilities.LumiList as LumiList
process.source.lumisToProcess = LumiList.LumiList(filename ='.oO[lumilist]Oo.').getVLuminosityBlockRange()
####################################################################
# Produce the Transient Track Record in the event
####################################################################
process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
####################################################################
# Load and Configure event selection
####################################################################
process.primaryVertexFilter = cms.EDFilter("VertexSelector",
src = cms.InputTag(".oO[VertexCollection]Oo."),
cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
filter = cms.bool(True)
)
process.noscraping = cms.EDFilter("FilterOutScraping",
applyfilter = cms.untracked.bool(True),
src = cms.untracked.InputTag(".oO[TrackCollection]Oo."),
debugOn = cms.untracked.bool(False),
numtrack = cms.untracked.uint32(10),
thresh = cms.untracked.double(0.25)
)
process.load("Alignment.CommonAlignment.filterOutLowPt_cfi")
process.filterOutLowPt.src = ".oO[TrackCollection]Oo."
process.filterOutLowPt.ptmin = .oO[ptCut]Oo.
process.filterOutLowPt.runControl = .oO[runControl]Oo.
if(isMultipleRuns):
process.filterOutLowPt.runControlNumber.extend((runboundary))
else:
process.filterOutLowPt.runControlNumber = [runboundary]
if isMC:
process.goodvertexSkim = cms.Sequence(process.noscraping + process.filterOutLowPt)
else:
process.goodvertexSkim = cms.Sequence(process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
####################################################################
# Deterministic annealing clustering
####################################################################
if isDA:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running DA Algorithm!"
process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
Debug = cms.bool(False),
storeNtuple = cms.bool(False),
useTracksFromRecoVtx = cms.bool(False),
isLightNtuple = cms.bool(True),
askFirstLayerHit = cms.bool(False),
forceBeamSpot = cms.untracked.bool(.oO[forceBeamSpot]Oo.),
probePt = cms.untracked.double(.oO[ptCut]Oo.),
probeEta = cms.untracked.double(.oO[etaCut]Oo.),
doBPix = cms.untracked.bool(.oO[doBPix]Oo.),
doFPix = cms.untracked.bool(.oO[doFPix]Oo.),
numberOfBins = cms.untracked.int32(.oO[numberOfBins]Oo.),
runControl = cms.untracked.bool(.oO[runControl]Oo.),
runControlNumber = cms.untracked.vuint32(runboundary),
TkFilterParameters = cms.PSet(algorithm=cms.string('filter'),
maxNormalizedChi2 = cms.double(5.0), # chi2ndof < 5
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
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
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)
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
)
)
)
####################################################################
# GAP clustering
####################################################################
else:
print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!"
process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
Debug = cms.bool(False),
isLightNtuple = cms.bool(True),
storeNtuple = cms.bool(False),
useTracksFromRecoVtx = cms.bool(False),
askFirstLayerHit = cms.bool(False),
forceBeamSpot = cms.untracked.bool(.oO[forceBeamSpot]Oo.),
probePt = cms.untracked.double(.oO[ptCut]Oo.),
probeEta = cms.untracked.double(.oO[etaCut]Oo.),
doBPix = cms.untracked.bool(.oO[doBPix]Oo.),
doFPix = cms.untracked.bool(.oO[doFPix]Oo.),
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
maxD0Significance = cms.double(5.0), # fake cut (requiring 1 PXB hit)
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
)
)
)
"""
####################################################################
####################################################################
PVValidationPath="""
process.p = cms.Path(process.goodvertexSkim*
process.seqTrackselRefit*
process.PVValidation)
"""
####################################################################
####################################################################
PVValidationScriptTemplate="""
#!/bin/bash
source /afs/cern.ch/cms/caf/setup.sh
export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
echo -----------------------
echo Job started at `date`
echo -----------------------
export theLabel=.oO[alignmentName]Oo.
export theDate=.oO[runboundary]Oo.
cwd=`pwd`
cd .oO[CMSSW_BASE]Oo./src
export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
eval `scram runtime -sh`
cd $cwd
rfmkdir -p .oO[datadir]Oo.
rfmkdir -p .oO[workingdir]Oo.
rfmkdir -p .oO[logdir]Oo.
rm -f .oO[logdir]Oo./*.stdout
rm -f .oO[logdir]Oo./*.stderr
if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
then
rfmkdir -p .oO[workdir]Oo.
rm -f .oO[workdir]Oo./*
cd .oO[workdir]Oo.
else
mkdir -p $cwd/TkAllInOneTool
cd $cwd/TkAllInOneTool
fi
.oO[CommandLine]Oo.
ls -lh .
eos mkdir -p /store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
for RootOutputFile in $(ls *root )
do
xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./${RootOutputFile}
rfcp ${RootOutputFile} .oO[workingdir]Oo.
done
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.
for PngOutputFile in $(ls *png ); do
xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
rfcp ${PngOutputFile} .oO[plotsdir]Oo.
done
for PdfOutputFile in $(ls *pdf ); do
xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
rfcp ${PdfOutputFile} .oO[plotsdir]Oo.
done
mkdir .oO[plotsdir]Oo./Biases/
mkdir .oO[plotsdir]Oo./Biases/dzPhi
mkdir .oO[plotsdir]Oo./Biases/dxyPhi
mkdir .oO[plotsdir]Oo./Biases/dzEta
mkdir .oO[plotsdir]Oo./Biases/dxyEta
mkdir .oO[plotsdir]Oo./Fit
mkdir .oO[plotsdir]Oo./dxyVsEta
mkdir .oO[plotsdir]Oo./dzVsEta
mkdir .oO[plotsdir]Oo./dxyVsPhi
mkdir .oO[plotsdir]Oo./dzVsPhi
mkdir .oO[plotsdir]Oo./dxyVsEtaNorm
mkdir .oO[plotsdir]Oo./dzVsEtaNorm
mkdir .oO[plotsdir]Oo./dxyVsPhiNorm
mkdir .oO[plotsdir]Oo./dzVsPhiNorm
mv .oO[plotsdir]Oo./BiasesCanvas* .oO[plotsdir]Oo./Biases/
mv .oO[plotsdir]Oo./dzPhiBiasCanvas* .oO[plotsdir]Oo./Biases/dzPhi
mv .oO[plotsdir]Oo./dxyPhiBiasCanvas* .oO[plotsdir]Oo./Biases/dxyPhi
mv .oO[plotsdir]Oo./dzEtaBiasCanvas* .oO[plotsdir]Oo./Biases/dzEta
mv .oO[plotsdir]Oo./dxyEtaBiasCanvas* .oO[plotsdir]Oo./Biases/dxyEta
mv .oO[plotsdir]Oo./dzPhiTrendFit* .oO[plotsdir]Oo./Fit
mv .oO[plotsdir]Oo./dxyEtaTrendNorm* .oO[plotsdir]Oo./dxyVsEtaNorm
mv .oO[plotsdir]Oo./dzEtaTrendNorm* .oO[plotsdir]Oo./dzVsEtaNorm
mv .oO[plotsdir]Oo./dxyPhiTrendNorm* .oO[plotsdir]Oo./dxyVsPhiNorm
mv .oO[plotsdir]Oo./dzPhiTrendNorm* .oO[plotsdir]Oo./dzVsPhiNorm
mv .oO[plotsdir]Oo./dxyEtaTrend* .oO[plotsdir]Oo./dxyVsEta
mv .oO[plotsdir]Oo./dzEtaTrend* .oO[plotsdir]Oo./dzVsEta
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
cp index.php .oO[plotsdir]Oo./Biases/
cp index.php .oO[plotsdir]Oo./Biases/dzPhi
cp index.php .oO[plotsdir]Oo./Biases/dxyPhi
cp index.php .oO[plotsdir]Oo./Biases/dzEta
cp index.php .oO[plotsdir]Oo./Biases/dxyEta
cp index.php .oO[plotsdir]Oo./Fit
cp index.php .oO[plotsdir]Oo./dxyVsEta
cp index.php .oO[plotsdir]Oo./dzVsEta
cp index.php .oO[plotsdir]Oo./dxyVsPhi
cp index.php .oO[plotsdir]Oo./dzVsPhi
cp index.php .oO[plotsdir]Oo./dxyVsEtaNorm
cp index.php .oO[plotsdir]Oo./dzVsEtaNorm
cp index.php .oO[plotsdir]Oo./dxyVsPhiNorm
cp index.php .oO[plotsdir]Oo./dzVsPhiNorm
echo -----------------------
echo Job ended at `date`
echo -----------------------
"""
######################################################################
######################################################################
PrimaryVertexPlotExecution="""
#make primary vertex validation plots
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/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
rfcp ${PdfOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
done
for PngOutputFile in $(ls *png ); do
xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
rfcp ${PngOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
done
"""
######################################################################
######################################################################
PrimaryVertexPlotTemplate="""
/****************************************
This can be run directly in root, or you
can run ./TkAlMerge.sh in this directory
****************************************/
#include "Alignment/OfflineValidation/macros/FitPVResiduals.C"
void TkAlPrimaryVertexValidationPlot()
{
// 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
.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)
.oO[w_dzEtaNormMax]Oo. // width of dz vs Eta (norm)
);
.oO[PlottingInstantiation]Oo.
FitPVResiduals("",.oO[stdResiduals]Oo.,.oO[doMaps]Oo.,"",.oO[autoLimits]Oo.);
}
"""