Alignment
OfflineValidation
python
TkAlAllInOneTool
zMuMuValidationTemplates.py
Go to the documentation of this file.
1
ZMuMuValidationTemplate=
"""
2
3
###### MuSclFit SETTINGS ##############################################
4
5
6
### MuScleFit specific configuration
7
8
process.looper = cms.Looper(
9
"MuScleFit",
10
# Only used when reading events from a root tree
11
MaxEventsFromRootTree = cms.int32(-1),
12
13
# Specify a file if you want to read events from a root tree in a local file.
14
# In this case the input source should be an empty source with 0 events.
15
16
InputRootTreeFileName = cms.string(""),
17
18
# Specify the file name where you want to save a root tree with the muon pairs.
19
# Leave empty if no file should be written.
20
21
OutputRootTreeFileName = cms.string(""),
22
23
24
# Choose the kind of muons you want to run on
25
# -------------------------------------------
26
MuonLabel = cms.InputTag("TrackRefitter"),
27
28
29
#MuonType = cms.int32(11),
30
MuonType = cms.int32(5),
31
32
# This line allows to switch to PAT muons. Default is false.
33
# Note that the onia selection works only with onia patTuples.
34
PATmuons = cms.untracked.bool(False),
35
36
# ---------------- #
37
# Select resonance #
38
# ---------------- #
39
# The resonances are to be specified in this order:
40
# Z0, Y(3S), Y(2S), Y(1S), Psi(2S), J/Psi
41
# -------------------------------------------------
42
resfind = cms.vint32(
43
int(".oO[resonance]Oo." == "Z"),
44
int(".oO[resonance]Oo." == "Y3S"),
45
int(".oO[resonance]Oo." == "Y2S"),
46
int(".oO[resonance]Oo." == "Y1S"),
47
int(".oO[resonance]Oo." == "Psi2S"),
48
int(".oO[resonance]Oo." == "JPsi")
49
),
50
51
# Likelihood settings
52
# -------------------
53
maxLoopNumber = cms.untracked.int32(1),
54
# Select which fits to do in which loop (0 = do not, 1 = do)
55
doResolFit = cms.vint32(0),
56
doScaleFit = cms.vint32(0),
57
doBackgroundFit = cms.vint32(0),
58
doCrossSectionFit = cms.vint32(0),
59
60
# Use the probability file or not. If not it will perform a simpler selection taking the muon pair with
61
# invariant mass closer to the pdf value and will crash if some fit is attempted.
62
UseProbsFile = cms.untracked.bool(False),
63
64
# False = use also MC information
65
speedup = cms.bool(True),
66
# Set this to false if you do not want to use simTracks.
67
# (Note that this is skipped anyway if speedup == True).
68
compareToSimTracks = cms.bool(False),
69
70
# Output settings
71
# ---------------
72
# Use compressions settings of TFile
73
# see https://root.cern.ch/root/html534/TFile.html#TFile:SetCompressionSettings
74
# settings = 100 * algorithm + level
75
# level is from 1 (small) to 9 (large compression)
76
# algo: 1 (ZLIB), 2 (LMZA)
77
# see more about compression & performance: https://root.cern.ch/root/html534/guides/users-guide/InputOutput.html#compression-and-performance
78
79
OutputFileName = cms.untracked.string("zmumuHisto.root"),
80
compressionSettings = cms.untracked.int32(compressionSettings),
81
82
# BiasType=0 means no bias to muon momenta
83
# ----------------------------------------
84
BiasType = cms.int32(0),
85
parBias = cms.vdouble(),
86
87
# SmearType=0 means no smearing applied to muon momenta
88
# -----------------------------------------------------
89
SmearType = cms.int32(0),
90
parSmear = cms.vdouble(),
91
92
### taken from J/Psi #########################
93
# ResolFitType = cms.int32(14),
94
# parResol = cms.vdouble(0.007,0.015, -0.00077, 0.0063, 0.0018, 0.0164),
95
# parResolFix = cms.vint32(0, 0, 0,0, 0,0),
96
# parResolOrder = cms.vint32(0, 0, 0, 0, 0, 0),
97
ResolFitType = cms.int32(0),
98
parResol = cms.vdouble(0),
99
parResolFix = cms.vint32(0),
100
parResolOrder = cms.vint32(0),
101
102
103
# -------------------- #
104
# Scale fit parameters #
105
# -------------------- #
106
107
# -----------------------------------------------------------------------------------
108
# ScaleFitType = cms.int32(18),
109
# parScaleOrder = cms.vint32(0, 0, 0, 0),
110
# parScaleFix = cms.vint32(0, 0, 0, 0),
111
# parScale = cms.vdouble(1, 1, 1, 1),
112
ScaleFitType = cms.int32(0),
113
parScaleOrder = cms.vint32(0),
114
parScaleFix = cms.vint32(0),
115
parScale = cms.vdouble(0),
116
117
118
119
# ---------------------------- #
120
# Cross section fit parameters #
121
# ---------------------------- #
122
# Note that the cross section fit works differently than the others, it
123
# fits ratios of parameters. Fix and Order should not be used as is, they
124
# are there mainly for compatibility.
125
parCrossSectionOrder = cms.vint32(0, 0, 0, 0, 0, 0),
126
parCrossSectionFix = cms.vint32(0, 0, 0, 0, 0, 0),
127
parCrossSection = cms.vdouble(1.233, 2.07, 6.33, 13.9, 2.169, 127.2),
128
129
# ------------------------- #
130
# Background fit parameters #
131
# ------------------------- #
132
133
# Window factors for: Z, Upsilons and (J/Psi,Psi2S) regions
134
LeftWindowBorder = cms.vdouble(70., 8., 1.391495),
135
RightWindowBorder = cms.vdouble(110., 12., 5.391495),
136
137
# The two parameters of BgrFitType=2 are respectively:
138
# bgr fraction, (negative of) bgr exp. slope, bgr constant
139
# --------------------------------------------------------
140
# The function types for resonances in a region must be the same
141
BgrFitType = cms.vint32(2, 2, 2), # regions
142
# These empty parameters should be used when there is no background
143
parBgr = cms.vdouble(0., 0., 0., 0., 0., 0.,
144
0., 0., 0., 0., 0., 0., 0.,0., 0.,0., 0.,0.),
145
parBgrFix = cms.vint32(0, 0, 0, 0, 0, 0,
146
# The rest of the parameters is used for the resonance regions. They are automatically fixed in the code
147
# because they are never used to fit the background, but only after the rescaling.
148
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
149
parBgrOrder = cms.vint32(0, 0, 0, 0, 0, 0,
150
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
151
152
153
# ----------------------- #
154
155
# Set Minuit fit strategy
156
FitStrategy = cms.int32(1),
157
158
159
# Fit accuracy and debug parameters
160
StartWithSimplex = cms.bool(True),
161
ComputeMinosErrors = cms.bool(False),
162
MinimumShapePlots = cms.bool(True),
163
164
########## TO BE ENABLED ################################
165
# Set the cuts on muons to be used in the fit
166
MinMuonPt = cms.untracked.double(.oO[minpt]Oo.),
167
MaxMuonPt = cms.untracked.double(.oO[maxpt]Oo.),
168
MinMuonEtaFirstRange = cms.untracked.double(.oO[etaminneg]Oo.),
169
MaxMuonEtaFirstRange = cms.untracked.double(.oO[etamaxneg]Oo.),
170
MinMuonEtaSecondRange = cms.untracked.double(.oO[etaminpos]Oo.),
171
MaxMuonEtaSecondRange = cms.untracked.double(.oO[etamaxpos]Oo.),
172
PileUpSummaryInfo = cms.untracked.InputTag("addPileupInfo"),
173
PrimaryVertexCollection = cms.untracked.InputTag("offlinePrimaryVertices"),
174
175
# The following parameters can be used to filter events
176
TriggerResultsLabel = cms.untracked.string("TriggerResults"),
177
TriggerResultsProcess = cms.untracked.string("HLT"),
178
TriggerPath = cms.untracked.vstring(""),
179
# Negate the result of the trigger
180
NegateTrigger = cms.untracked.bool(False),
181
debug = cms.untracked.int32(0),
182
)
183
184
"""
185
186
187
189
LoadMuonModules =
"""
190
process.load("RecoMuon.DetLayers.muonDetLayerGeometry_cfi")
191
process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi")
192
process.load("RecoMuon.TrackingTools.MuonServiceProxy_cff")
193
process.load("Configuration.StandardSequences.Reconstruction_cff")
194
"""
195
196
197
199
ZMuMuPath =
"""
200
process.p = cms.Path(
201
process.offlineBeamSpot*process.TrackRefitter
202
)
203
"""
204
205
206
208
zMuMuScriptTemplate=
"""#!/bin/bash
209
source /afs/cern.ch/cms/caf/setup.sh
210
export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
211
212
echo -----------------------
213
echo Job started at `date`
214
echo -----------------------
215
216
cwd=`pwd`
217
cd .oO[CMSSW_BASE]Oo./src
218
export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
219
eval `scram runtime -sh`
220
cd $cwd
221
222
mkdir -p .oO[datadir]Oo.
223
mkdir -p .oO[workingdir]Oo.
224
mkdir -p .oO[logdir]Oo.
225
rm -f .oO[logdir]Oo./*.stdout
226
rm -f .oO[logdir]Oo./*.stderr
227
228
if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
229
then
230
mkdir -p .oO[workdir]Oo.
231
rm -f .oO[workdir]Oo./*
232
cd .oO[workdir]Oo.
233
else
234
mkdir -p $cwd/TkAllInOneTool
235
cd $cwd/TkAllInOneTool
236
fi
237
238
239
.oO[CommandLine]Oo.
240
241
ls -lh .
242
243
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/CompareBias.oO[resonance]Oo.Validation.cc .
244
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/Legend.h .
245
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitMassSlices.cc .
246
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitSlices.cc .
247
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitXslices.cc .
248
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitWithRooFit.cc .
249
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitMass1D.cc .
250
251
root -q -b -l "CompareBias.oO[resonance]Oo.Validation.cc+(.oO[rebinphi]Oo., .oO[rebinetadiff]Oo., .oO[rebineta]Oo., .oO[rebinpt]Oo.)"
252
253
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/tdrstyle.C .
254
cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/MultiHistoOverlap_.oO[resonance]Oo..C .
255
256
if [[ .oO[zmumureference]Oo. == *store* ]]; then xrdcp -f .oO[zmumureference]Oo. BiasCheck_Reference.root; else ln -fs .oO[zmumureference]Oo. ./BiasCheck_Reference.root; fi
257
root -q -b -l MultiHistoOverlap_.oO[resonance]Oo..C
258
259
eos mkdir -p /store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
260
for RootOutputFile in $(ls *root )
261
do
262
xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./
263
cp ${RootOutputFile} .oO[workingdir]Oo.
264
done
265
266
mkdir -p .oO[plotsdir]Oo.
267
for PngOutputFile in $(ls *png ); do
268
xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
269
cp ${PngOutputFile} .oO[plotsdir]Oo.
270
done
271
272
273
echo -----------------------
274
echo Job ended at `date`
275
echo -----------------------
276
277
"""
278
279
281
282
mergeZmumuPlotsExecution=
"""
283
#merge Z->mumu histograms
284
285
cp .oO[mergeZmumuPlotsScriptPath]Oo. .
286
root -l -x -b -q TkAlMergeZmumuPlots.C++
287
288
"""
289
290
292
293
mergeZmumuPlotsTemplate=
"""
294
#include "MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_.oO[resonance]Oo..C"
295
#include <sstream>
296
#include <vector>
297
298
template <typename T> string separatebycommas(vector<T> v){
299
if (v.size()==0) return "";
300
stringstream s;
301
s << v[0];
302
for (unsigned int i = 1; i < v.size(); i++) s << "," << v[i];
303
return s.str();
304
}
305
306
void TkAlMergeZmumuPlots(){
307
vector<string> filenames; vector<string> titles; vector<int> colors; vector<int> linestyles;
308
309
.oO[PlottingInstantiation]Oo.
310
311
vector<int> linestyles_new, markerstyles_new;
312
for (unsigned int j=0; j<linestyles.size(); j++){ linestyles_new.push_back(linestyles.at(j) % 100); markerstyles_new.push_back(linestyles.at(j) / 100); }
313
314
TkAlStyle::legendheader = ".oO[legendheader]Oo.";
315
TkAlStyle::set(.oO[publicationstatus]Oo., .oO[era]Oo., ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.");
316
317
MultiHistoOverlapAll_.oO[resonance]Oo.(separatebycommas(filenames), separatebycommas(titles), separatebycommas(colors), separatebycommas(linestyles_new), separatebycommas(markerstyles_new), ".oO[datadir]Oo./.oO[PlotsDirName]Oo.", .oO[switchONfit]Oo., .oO[AutoSetRange]Oo., .oO[CustomMinY]Oo., .oO[CustomMaxY]Oo.);
318
}
319
"""
Generated for CMSSW Reference Manual by
1.8.16