CMS 3D CMS Logo

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