CMS 3D CMS Logo

primaryVertexResolutionTemplates.py
Go to the documentation of this file.
1 PrimaryVertexResolutionTemplate="""
2 
3 HLTSel = .oO[doTriggerSelection]Oo.
4 
5 ###################################################################
6 # Runs and events
7 ###################################################################
8 runboundary = .oO[runboundary]Oo.
9 isMultipleRuns=False
10 if(isinstance(runboundary, (list, tuple))):
11  isMultipleRuns=True
12  print("Multiple Runs are selected")
13 
14 if(isMultipleRuns):
15  process.source.firstRun = cms.untracked.uint32(int(runboundary[0]))
16 else:
17  process.source.firstRun = cms.untracked.uint32(int(runboundary))
18 
19 
20 ###################################################################
21 # The trigger filter module
22 ###################################################################
23 from HLTrigger.HLTfilters.triggerResultsFilter_cfi import *
24 process.theHLTFilter = triggerResultsFilter.clone(
25  triggerConditions = cms.vstring(.oO[triggerBits]Oo.),
26  hltResults = cms.InputTag( "TriggerResults", "", "HLT" ),
27  l1tResults = cms.InputTag( "" ),
28  throw = cms.bool(False)
29 )
30 
31 ###################################################################
32 # PV refit
33 ###################################################################
34 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
35 
36 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
37 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
38 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag("TrackRefitter")
39 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
40 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
41 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
42 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
43 # as it was prior to https://github.com/cms-sw/cmssw/commit/c8462ae4313b6be3bbce36e45373aa6e87253c59
44 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Error = 1.0
45 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxDzError = 1.0
46 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
47 
48 # Use compressions settings of TFile
49 # see https://root.cern.ch/root/html534/TFile.html#TFile:SetCompressionSettings
50 # settings = 100 * algorithm + level
51 # level is from 1 (small) to 9 (large compression)
52 # algo: 1 (ZLIB), 2 (LMZA)
53 # see more about compression & performance: https://root.cern.ch/root/html534/guides/users-guide/InputOutput.html#compression-and-performance
54 compressionSettings = 207
55 
56 ###################################################################
57 # The PV resolution module
58 ###################################################################
59 process.PrimaryVertexResolution = cms.EDAnalyzer('SplitVertexResolution',
60  compressionSettings = cms.untracked.int32(compressionSettings),
61  storeNtuple = cms.bool(False),
62  vtxCollection = cms.InputTag("offlinePrimaryVerticesFromRefittedTrks"),
63  trackCollection = cms.InputTag("TrackRefitter"),
64  minVertexNdf = cms.untracked.double(10.),
65  minVertexMeanWeight = cms.untracked.double(0.5),
66  runControl = cms.untracked.bool(.oO[runControl]Oo.),
67  runControlNumber = cms.untracked.vuint32(runboundary),
68  sumpTStartScale = cms.untracked.double(.oO[startScale]Oo.),
69  sumpTEndScale = cms.untracked.double(.oO[endScale]Oo.),
70  nTrackBins = cms.untracked.double(.oO[nTracksBins]Oo.),
71  nVtxBins = cms.untracked.double(.oO[nVtxBins]Oo.)
72  )
73 """
74 
75 
77 PVResolutionPath="""
78 
79 process.theValidSequence = cms.Sequence(process.offlineBeamSpot +
80  process.TrackRefitter +
81  process.offlinePrimaryVerticesFromRefittedTrks +
82  process.PrimaryVertexResolution)
83 if (HLTSel):
84  process.p = cms.Path(process.theHLTFilter + process.theValidSequence)
85 else:
86  process.p = cms.Path(process.theValidSequence)
87 """
88 
89 
91 PVResolutionScriptTemplate="""#!/bin/bash
92 source /afs/cern.ch/cms/caf/setup.sh
93 export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
94 
95 source /afs/cern.ch/cms/caf/setup.sh
96 
97 echo -----------------------
98 echo Job started at `date`
99 echo -----------------------
100 
101 export theLabel=.oO[alignmentName]Oo.
102 export theDate=.oO[runboundary]Oo.
103 
104 cwd=`pwd`
105 cd .oO[CMSSW_BASE]Oo./src
106 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
107 eval `scram runtime -sh`
108 cd $cwd
109 
110 mkdir -p .oO[datadir]Oo.
111 mkdir -p .oO[workingdir]Oo.
112 mkdir -p .oO[logdir]Oo.
113 rm -f .oO[logdir]Oo./*.stdout
114 rm -f .oO[logdir]Oo./*.stderr
115 
116 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
117 then
118  mkdir -p .oO[workdir]Oo.
119  rm -f .oO[workdir]Oo./*
120  cd .oO[workdir]Oo.
121 else
122  mkdir -p $cwd/TkAllInOneTool
123  cd $cwd/TkAllInOneTool
124 fi
125 
126 .oO[CommandLine]Oo.
127 
128 ls -lh .
129 
130 eos mkdir -p /store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
131 
132 for RootOutputFile in $(ls *root )
133 do
134  xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./${RootOutputFile}
135  cp ${RootOutputFile} .oO[workingdir]Oo.
136 done
137 
138 cp .oO[Alignment/OfflineValidation]Oo./macros/FitPVResolution.C .
139 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.C .
140 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.h .
141 
142  if [[ .oO[pvresolutionreference]Oo. == *store* ]]; then xrdcp -f .oO[pvresolutionreference]Oo. PVValidation_reference.root; else ln -fs .oO[pvresolutionreference]Oo. ./PVResolution_reference.root; fi
143 
144 root -b -q "FitPVResolution.C(\\"${PWD}/${RootOutputFile}=${theLabel},${PWD}/PVValidation_reference.root=Design simulation\\",\\"$theDate\\")"
145 
146 mkdir -p .oO[plotsdir]Oo.
147 for PngOutputFile in $(ls *png ); do
148  xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
149  cp ${PngOutputFile} .oO[plotsdir]Oo.
150 done
151 
152 for PdfOutputFile in $(ls *pdf ); do
153  xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
154  cp ${PdfOutputFile} .oO[plotsdir]Oo.
155 done
156 
157 echo -----------------------
158 echo Job ended at `date`
159 echo -----------------------
160 
161 """
162 
163 
165 
166 PVResolutionPlotExecution="""
167 #make primary vertex validation plots
168 
169 cp .oO[plottingscriptpath]Oo. .
170 root -x -b -q .oO[plottingscriptname]Oo.++
171 
172 for PdfOutputFile in $(ls *pdf ); do
173  xrdcp -f ${PdfOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
174  cp ${PdfOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
175 done
176 
177 for PngOutputFile in $(ls *png ); do
178  xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
179  cp ${PngOutputFile} .oO[datadir]Oo./.oO[PlotsDirName]Oo.
180 done
181 
182 """
183 
184 
186 
187 PVResolutionPlotTemplate="""
188 /****************************************
189 This can be run directly in root, or you
190  can run ./TkAlMerge.sh in this directory
191 ****************************************/
192 
193 #include "Alignment/OfflineValidation/macros/FitPVResolution.C"
194 
195 void TkAlPrimaryVertexResolutionPlot()
196 {
197 
198  // initialize the plot y-axis ranges
199  .oO[PlottingInstantiation]Oo.
200  FitPVResolution("","");
201 
202 }
203 """
204 
205