CMS 3D CMS Logo

primaryVertexValidationTemplates.py
Go to the documentation of this file.
1 PrimaryVertexValidationTemplate="""
2 
3 process.HighPurityTrackSelector.trackQualities = cms.vstring()
4 process.HighPurityTrackSelector.pMin = cms.double(0.)
5 process.AlignmentTrackSelector.pMin = cms.double(0.)
6 process.AlignmentTrackSelector.ptMin = cms.double(0.)
7 process.AlignmentTrackSelector.nHitMin2D = cms.uint32(0)
8 process.AlignmentTrackSelector.nHitMin = cms.double(0.)
9 process.AlignmentTrackSelector.d0Min = cms.double(-999999.0)
10 process.AlignmentTrackSelector.d0Max = cms.double(+999999.0)
11 process.AlignmentTrackSelector.dzMin = cms.double(-999999.0)
12 process.AlignmentTrackSelector.dzMax = cms.double(+999999.0)
13 
14 isDA = .oO[isda]Oo.
15 isMC = .oO[ismc]Oo.
16 
17 ###################################################################
18 # Runs and events
19 ###################################################################
20 runboundary = .oO[runboundary]Oo.
21 isMultipleRuns=False
22 if(isinstance(runboundary, (list, tuple))):
23  isMultipleRuns=True
24  print "Multiple Runs are selected"
25 
26 if(isMultipleRuns):
27  process.source.firstRun = cms.untracked.uint32(int(runboundary[0]))
28 else:
29  process.source.firstRun = cms.untracked.uint32(int(runboundary))
30 
31 ###################################################################
32 # JSON Filtering
33 ###################################################################
34 if isMC:
35  print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is simulation!"
36  runboundary = 1
37 else:
38  print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is real DATA!"
39  if ('.oO[lumilist]Oo.'):
40  print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: JSON filtering with: .oO[lumilist]Oo. "
41  import FWCore.PythonUtilities.LumiList as LumiList
42  process.source.lumisToProcess = LumiList.LumiList(filename ='.oO[lumilist]Oo.').getVLuminosityBlockRange()
43 
44 ####################################################################
45 # Produce the Transient Track Record in the event
46 ####################################################################
47 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
48 
49 ####################################################################
50 # Load and Configure event selection
51 ####################################################################
52 process.primaryVertexFilter = cms.EDFilter("VertexSelector",
53  src = cms.InputTag(".oO[VertexCollection]Oo."),
54  cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
55  filter = cms.bool(True)
56  )
57 
58 process.noscraping = cms.EDFilter("FilterOutScraping",
59  applyfilter = cms.untracked.bool(True),
60  src = cms.untracked.InputTag(".oO[TrackCollection]Oo."),
61  debugOn = cms.untracked.bool(False),
62  numtrack = cms.untracked.uint32(10),
63  thresh = cms.untracked.double(0.25)
64  )
65 
66 
67 process.load("Alignment.CommonAlignment.filterOutLowPt_cfi")
68 process.filterOutLowPt.src = ".oO[TrackCollection]Oo."
69 process.filterOutLowPt.ptmin = .oO[ptCut]Oo.
70 process.filterOutLowPt.runControl = .oO[runControl]Oo.
71 if(isMultipleRuns):
72  process.filterOutLowPt.runControlNumber.extend((runboundary))
73 else:
74  process.filterOutLowPt.runControlNumber = [runboundary]
75 
76 if isMC:
77  process.goodvertexSkim = cms.Sequence(process.noscraping + process.filterOutLowPt)
78 else:
79  process.goodvertexSkim = cms.Sequence(process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
80 
81 ####################################################################
82 # Deterministic annealing clustering
83 ####################################################################
84 if isDA:
85  print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running DA Algorithm!"
86  process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
87  TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
88  VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
89  Debug = cms.bool(False),
90  storeNtuple = cms.bool(False),
91  useTracksFromRecoVtx = cms.bool(False),
92  isLightNtuple = cms.bool(True),
93  askFirstLayerHit = cms.bool(False),
94  probePt = cms.untracked.double(.oO[ptCut]Oo.),
95  probeEta = cms.untracked.double(.oO[etaCut]Oo.),
96  doBPix = cms.untracked.bool(.oO[doBPix]Oo.),
97  doFPix = cms.untracked.bool(.oO[doFPix]Oo.),
98  numberOfBins = cms.untracked.int32(.oO[numberOfBins]Oo.),
99  runControl = cms.untracked.bool(.oO[runControl]Oo.),
100  runControlNumber = cms.untracked.vuint32(runboundary),
101 
102  TkFilterParameters = cms.PSet(algorithm=cms.string('filter'),
103  maxNormalizedChi2 = cms.double(5.0), # chi2ndof < 5
104  minPixelLayersWithHits = cms.int32(2), # PX hits > 2
105  minSiliconLayersWithHits = cms.int32(5), # TK hits > 5
106  maxD0Significance = cms.double(5.0), # fake cut (requiring 1 PXB hit)
107  minPt = cms.double(0.0), # better for softish events
108  maxEta = cms.double(5.0), # as per recommendation in PR #18330
109  trackQuality = cms.string("any")
110  ),
111 
112  ## MM 04.05.2017 (use settings as in: https://github.com/cms-sw/cmssw/pull/18330)
113  TkClusParameters=cms.PSet(algorithm=cms.string('DA_vect'),
114  TkDAClusParameters = cms.PSet(coolingFactor = cms.double(0.6), # moderate annealing speed
115  Tmin = cms.double(2.0), # end of vertex splitting
116  Tpurge = cms.double(2.0), # cleaning
117  Tstop = cms.double(0.5), # end of annealing
118  vertexSize = cms.double(0.006), # added in quadrature to track-z resolutions
119  d0CutOff = cms.double(3.), # downweight high IP tracks
120  dzCutOff = cms.double(3.), # outlier rejection after freeze-out (T<Tmin)
121  zmerge = cms.double(1e-2), # merge intermediat clusters separated by less than zmerge
122  uniquetrkweight = cms.double(0.8) # require at least two tracks with this weight at T=Tpurge
123  )
124  )
125  )
126 
127 ####################################################################
128 # GAP clustering
129 ####################################################################
130 else:
131  print ">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!"
132  process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
133  TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
134  VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
135  Debug = cms.bool(False),
136  isLightNtuple = cms.bool(True),
137  storeNtuple = cms.bool(False),
138  useTracksFromRecoVtx = cms.bool(False),
139  askFirstLayerHit = cms.bool(False),
140  probePt = cms.untracked.double(.oO[ptCut]Oo.),
141  probeEta = cms.untracked.double(.oO[etaCut]Oo.),
142  doBPix = cms.untracked.bool(.oO[doBPix]Oo.),
143  doFPix = cms.untracked.bool(.oO[doFPix]Oo.),
144  numberOfBins = cms.untracked.int32(.oO[numberOfBins]Oo.),
145  runControl = cms.untracked.bool(.oO[runControl]Oo.),
146  runControlNumber = cms.untracked.vuint32(int(.oO[runboundary]Oo.)),
147 
148  TkFilterParameters = cms.PSet(algorithm=cms.string('filter'),
149  maxNormalizedChi2 = cms.double(5.0), # chi2ndof < 20
150  minPixelLayersWithHits=cms.int32(2), # PX hits > 2
151  minSiliconLayersWithHits = cms.int32(5), # TK hits > 5
152  maxD0Significance = cms.double(5.0), # fake cut (requiring 1 PXB hit)
153  minPt = cms.double(0.0), # better for softish events
154  maxEta = cms.double(5.0), # as per recommendation in PR #18330
155  trackQuality = cms.string("any")
156  ),
157 
158  TkClusParameters = cms.PSet(algorithm = cms.string('gap'),
159  TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2) # 0.2 cm max separation betw. clusters
160  )
161  )
162  )
163 
164 """
165 
166 ####################################################################
167 ####################################################################
168 PVValidationPath="""
169 process.p = cms.Path(process.goodvertexSkim*
170  process.seqTrackselRefit*
171  process.PVValidation)
172 """
173 
174 ####################################################################
175 ####################################################################
176 PVValidationScriptTemplate="""
177 #!/bin/bash
178 source /afs/cern.ch/cms/caf/setup.sh
179 
180 echo -----------------------
181 echo Job started at `date`
182 echo -----------------------
183 
184 export theLabel=.oO[alignmentName]Oo.
185 export theDate=.oO[runboundary]Oo.
186 
187 cwd=`pwd`
188 cd .oO[CMSSW_BASE]Oo./src
189 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
190 eval `scram runtime -sh`
191 cd $cwd
192 
193 rfmkdir -p .oO[datadir]Oo.
194 rfmkdir -p .oO[workingdir]Oo.
195 rfmkdir -p .oO[logdir]Oo.
196 rm -f .oO[logdir]Oo./*.stdout
197 rm -f .oO[logdir]Oo./*.stderr
198 
199 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
200 then
201  rfmkdir -p .oO[workdir]Oo.
202  rm -f .oO[workdir]Oo./*
203  cd .oO[workdir]Oo.
204 else
205  mkdir -p $cwd/TkAllInOneTool
206  cd $cwd/TkAllInOneTool
207 fi
208 
209 .oO[CommandLine]Oo.
210 
211 ls -lh .
212 
213 eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo./plots/
214 for RootOutputFile in $(ls *root )
215 do
216  xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./
217  rfcp ${RootOutputFile} .oO[workingdir]Oo.
218 done
219 
220 cp .oO[Alignment/OfflineValidation]Oo./macros/FitPVResiduals.C .
221 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.C .
222 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.h .
223 
224  if [[ .oO[pvvalidationreference]Oo. == *store* ]]; then xrdcp -f .oO[pvvalidationreference]Oo. PVValidation_reference.root; else ln -fs .oO[pvvalidationreference]Oo. ./PVValidation_reference.root; fi
225 
226 root -b -q "FitPVResiduals.C(\\"${PWD}/${RootOutputFile}=${theLabel},${PWD}/PVValidation_reference.root=Design simulation\\",true,true,\\"$theDate\\")"
227 
228 mkdir -p .oO[plotsdir]Oo.
229 for PngOutputFile in $(ls *png ); do
230  xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
231  rfcp ${PngOutputFile} .oO[plotsdir]Oo.
232 done
233 
234 for PdfOutputFile in $(ls *pdf ); do
235  xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
236  rfcp ${PdfOutputFile} .oO[plotsdir]Oo.
237 done
238 
239 mkdir .oO[plotsdir]Oo./Biases/
240 mkdir .oO[plotsdir]Oo./Biases/dzPhi
241 mkdir .oO[plotsdir]Oo./Biases/dxyPhi
242 mkdir .oO[plotsdir]Oo./Biases/dzEta
243 mkdir .oO[plotsdir]Oo./Biases/dxyEta
244 mkdir .oO[plotsdir]Oo./Fit
245 mkdir .oO[plotsdir]Oo./dxyVsEta
246 mkdir .oO[plotsdir]Oo./dzVsEta
247 mkdir .oO[plotsdir]Oo./dxyVsPhi
248 mkdir .oO[plotsdir]Oo./dzVsPhi
249 mkdir .oO[plotsdir]Oo./dxyVsEtaNorm
250 mkdir .oO[plotsdir]Oo./dzVsEtaNorm
251 mkdir .oO[plotsdir]Oo./dxyVsPhiNorm
252 mkdir .oO[plotsdir]Oo./dzVsPhiNorm
253 
254 mv .oO[plotsdir]Oo./BiasesCanvas* .oO[plotsdir]Oo./Biases/
255 mv .oO[plotsdir]Oo./dzPhiBiasCanvas* .oO[plotsdir]Oo./Biases/dzPhi
256 mv .oO[plotsdir]Oo./dxyPhiBiasCanvas* .oO[plotsdir]Oo./Biases/dxyPhi
257 mv .oO[plotsdir]Oo./dzEtaBiasCanvas* .oO[plotsdir]Oo./Biases/dzEta
258 mv .oO[plotsdir]Oo./dxyEtaBiasCanvas* .oO[plotsdir]Oo./Biases/dxyEta
259 mv .oO[plotsdir]Oo./dzPhiTrendFit* .oO[plotsdir]Oo./Fit
260 mv .oO[plotsdir]Oo./dxyEtaTrendNorm* .oO[plotsdir]Oo./dxyVsEtaNorm
261 mv .oO[plotsdir]Oo./dzEtaTrendNorm* .oO[plotsdir]Oo./dzVsEtaNorm
262 mv .oO[plotsdir]Oo./dxyPhiTrendNorm* .oO[plotsdir]Oo./dxyVsPhiNorm
263 mv .oO[plotsdir]Oo./dzPhiTrendNorm* .oO[plotsdir]Oo./dzVsPhiNorm
264 mv .oO[plotsdir]Oo./dxyEtaTrend* .oO[plotsdir]Oo./dxyVsEta
265 mv .oO[plotsdir]Oo./dzEtaTrend* .oO[plotsdir]Oo./dzVsEta
266 mv .oO[plotsdir]Oo./dxyPhiTrend* .oO[plotsdir]Oo./dxyVsPhi
267 mv .oO[plotsdir]Oo./dzPhiTrend* .oO[plotsdir]Oo./dzVsPhi
268 
269 wget https://raw.githubusercontent.com/mmusich/PVToolScripts/master/PolishedScripts/index.php
270 
271 cp index.php .oO[plotsdir]Oo./Biases/
272 cp index.php .oO[plotsdir]Oo./Biases/dzPhi
273 cp index.php .oO[plotsdir]Oo./Biases/dxyPhi
274 cp index.php .oO[plotsdir]Oo./Biases/dzEta
275 cp index.php .oO[plotsdir]Oo./Biases/dxyEta
276 cp index.php .oO[plotsdir]Oo./Fit
277 cp index.php .oO[plotsdir]Oo./dxyVsEta
278 cp index.php .oO[plotsdir]Oo./dzVsEta
279 cp index.php .oO[plotsdir]Oo./dxyVsPhi
280 cp index.php .oO[plotsdir]Oo./dzVsPhi
281 cp index.php .oO[plotsdir]Oo./dxyVsEtaNorm
282 cp index.php .oO[plotsdir]Oo./dzVsEtaNorm
283 cp index.php .oO[plotsdir]Oo./dxyVsPhiNorm
284 cp index.php .oO[plotsdir]Oo./dzVsPhiNorm
285 
286 
287 echo -----------------------
288 echo Job ended at `date`
289 echo -----------------------
290 
291 """
292 
293 ######################################################################
294 ######################################################################
295 
296 PrimaryVertexPlotExecution="""
297 #make primary vertex validation plots
298 
299 rfcp .oO[plottingscriptpath]Oo. .
300 root -x -b -q .oO[plottingscriptname]Oo.++
301 
302 for PdfOutputFile in $(ls *pdf ); do
303  xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
304  rfcp ${PdfOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
305 done
306 
307 for PngOutputFile in $(ls *png ); do
308  xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./plots/
309  rfcp ${PngOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
310 done
311 
312 """
313 
314 ######################################################################
315 ######################################################################
316 
317 PrimaryVertexPlotTemplate="""
318 /****************************************
319 This can be run directly in root, or you
320  can run ./TkAlMerge.sh in this directory
321 ****************************************/
322 
323 #include "Alignment/OfflineValidation/macros/FitPVResiduals.C"
324 
325 void TkAlPrimaryVertexValidationPlot()
326 {
327 
328  // initialize the plot y-axis ranges
329  thePlotLimits->init(.oO[m_dxyPhiMax]Oo., // mean of dxy vs Phi
330  .oO[m_dzPhiMax]Oo., // mean of dz vs Phi
331  .oO[m_dxyEtaMax]Oo., // mean of dxy vs Eta
332  .oO[m_dzEtaMax]Oo., // mean of dz vs Eta
333  .oO[m_dxyPhiNormMax]Oo., // mean of dxy vs Phi (norm)
334  .oO[m_dzPhiNormMax]Oo., // mean of dz vs Phi (norm)
335  .oO[m_dxyEtaNormMax]Oo., // mean of dxy vs Eta (norm)
336  .oO[m_dzEtaNormMax]Oo., // mean of dz vs Eta (norm)
337  .oO[w_dxyPhiMax]Oo., // width of dxy vs Phi
338  .oO[w_dzPhiMax]Oo., // width of dz vs Phi
339  .oO[w_dxyEtaMax]Oo., // width of dxy vs Eta
340  .oO[w_dzEtaMax]Oo., // width of dz vs Eta
341  .oO[w_dxyPhiNormMax]Oo., // width of dxy vs Phi (norm)
342  .oO[w_dzPhiNormMax]Oo., // width of dz vs Phi (norm)
343  .oO[w_dxyEtaNormMax]Oo., // width of dxy vs Eta (norm)
344  .oO[w_dzEtaNormMax]Oo. // width of dz vs Eta (norm)
345  );
346 
347  .oO[PlottingInstantiation]Oo.
348  FitPVResiduals("",.oO[stdResiduals]Oo.,.oO[doMaps]Oo.,"",.oO[autoLimits]Oo.);
349 }
350 """
351 
352