CMS 3D CMS Logo

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  OutputFileName = cms.untracked.string("zmumuHisto.root"),
73 
74  # BiasType=0 means no bias to muon momenta
75  # ----------------------------------------
76  BiasType = cms.int32(0),
77  parBias = cms.vdouble(),
78 
79  # SmearType=0 means no smearing applied to muon momenta
80  # -----------------------------------------------------
81  SmearType = cms.int32(0),
82  parSmear = cms.vdouble(),
83 
84  ### taken from J/Psi #########################
85 # ResolFitType = cms.int32(14),
86 # parResol = cms.vdouble(0.007,0.015, -0.00077, 0.0063, 0.0018, 0.0164),
87 # parResolFix = cms.vint32(0, 0, 0,0, 0,0),
88 # parResolOrder = cms.vint32(0, 0, 0, 0, 0, 0),
89  ResolFitType = cms.int32(0),
90  parResol = cms.vdouble(0),
91  parResolFix = cms.vint32(0),
92  parResolOrder = cms.vint32(0),
93 
94 
95  # -------------------- #
96  # Scale fit parameters #
97  # -------------------- #
98 
99  # -----------------------------------------------------------------------------------
100 # ScaleFitType = cms.int32(18),
101 # parScaleOrder = cms.vint32(0, 0, 0, 0),
102 # parScaleFix = cms.vint32(0, 0, 0, 0),
103 # parScale = cms.vdouble(1, 1, 1, 1),
104  ScaleFitType = cms.int32(0),
105  parScaleOrder = cms.vint32(0),
106  parScaleFix = cms.vint32(0),
107  parScale = cms.vdouble(0),
108 
109 
110 
111  # ---------------------------- #
112  # Cross section fit parameters #
113  # ---------------------------- #
114  # Note that the cross section fit works differently than the others, it
115  # fits ratios of parameters. Fix and Order should not be used as is, they
116  # are there mainly for compatibility.
117  parCrossSectionOrder = cms.vint32(0, 0, 0, 0, 0, 0),
118  parCrossSectionFix = cms.vint32(0, 0, 0, 0, 0, 0),
119  parCrossSection = cms.vdouble(1.233, 2.07, 6.33, 13.9, 2.169, 127.2),
120 
121  # ------------------------- #
122  # Background fit parameters #
123  # ------------------------- #
124 
125  # Window factors for: Z, Upsilons and (J/Psi,Psi2S) regions
126  LeftWindowBorder = cms.vdouble(70., 8., 1.391495),
127  RightWindowBorder = cms.vdouble(110., 12., 5.391495),
128 
129  # The two parameters of BgrFitType=2 are respectively:
130  # bgr fraction, (negative of) bgr exp. slope, bgr constant
131  # --------------------------------------------------------
132  # The function types for resonances in a region must be the same
133  BgrFitType = cms.vint32(2, 2, 2), # regions
134  # These empty parameters should be used when there is no background
135  parBgr = cms.vdouble(0., 0., 0., 0., 0., 0.,
136  0., 0., 0., 0., 0., 0., 0.,0., 0.,0., 0.,0.),
137  parBgrFix = cms.vint32(0, 0, 0, 0, 0, 0,
138  # The rest of the parameters is used for the resonance regions. They are automatically fixed in the code
139  # because they are never used to fit the background, but only after the rescaling.
140  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
141  parBgrOrder = cms.vint32(0, 0, 0, 0, 0, 0,
142  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
143 
144 
145  # ----------------------- #
146 
147  # Set Minuit fit strategy
148  FitStrategy = cms.int32(1),
149 
150 
151  # Fit accuracy and debug parameters
152  StartWithSimplex = cms.bool(True),
153  ComputeMinosErrors = cms.bool(False),
154  MinimumShapePlots = cms.bool(True),
155 
156  ########## TO BE ENABLED ################################
157  # Set the cuts on muons to be used in the fit
158  MinMuonPt = cms.untracked.double(.oO[minpt]Oo.),
159  MaxMuonPt = cms.untracked.double(.oO[maxpt]Oo.),
160  MinMuonEtaFirstRange = cms.untracked.double(.oO[etaminneg]Oo.),
161  MaxMuonEtaFirstRange = cms.untracked.double(.oO[etamaxneg]Oo.),
162  MinMuonEtaSecondRange = cms.untracked.double(.oO[etaminpos]Oo.),
163  MaxMuonEtaSecondRange = cms.untracked.double(.oO[etamaxpos]Oo.),
164  PileUpSummaryInfo = cms.untracked.InputTag("addPileupInfo"),
165  PrimaryVertexCollection = cms.untracked.InputTag("offlinePrimaryVertices"),
166 
167  # The following parameters can be used to filter events
168  TriggerResultsLabel = cms.untracked.string("TriggerResults"),
169  TriggerResultsProcess = cms.untracked.string("HLT"),
170  TriggerPath = cms.untracked.vstring(""),
171  # Negate the result of the trigger
172  NegateTrigger = cms.untracked.bool(False),
173  debug = cms.untracked.int32(0),
174 )
175 
176 """
177 
178 
179 ####################################################################
180 ####################################################################
181 LoadMuonModules = """
182 process.load("RecoMuon.DetLayers.muonDetLayerGeometry_cfi")
183 process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi")
184 process.load("RecoMuon.TrackingTools.MuonServiceProxy_cff")
185 process.load("Configuration.StandardSequences.Reconstruction_cff")
186 """
187 
188 
189 ####################################################################
190 ####################################################################
191 ZMuMuPath = """
192 process.p = cms.Path(
193  process.offlineBeamSpot*process.TrackRefitter
194  )
195 """
196 
197 
198 ####################################################################
199 ####################################################################
200 zMuMuScriptTemplate="""#!/bin/bash
201 source /afs/cern.ch/cms/caf/setup.sh
202 export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
203 
204 echo -----------------------
205 echo Job started at `date`
206 echo -----------------------
207 
208 cwd=`pwd`
209 cd .oO[CMSSW_BASE]Oo./src
210 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
211 eval `scram runtime -sh`
212 cd $cwd
213 
214 mkdir -p .oO[datadir]Oo.
215 mkdir -p .oO[workingdir]Oo.
216 mkdir -p .oO[logdir]Oo.
217 rm -f .oO[logdir]Oo./*.stdout
218 rm -f .oO[logdir]Oo./*.stderr
219 
220 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
221 then
222  mkdir -p .oO[workdir]Oo.
223  rm -f .oO[workdir]Oo./*
224  cd .oO[workdir]Oo.
225 else
226  mkdir -p $cwd/TkAllInOneTool
227  cd $cwd/TkAllInOneTool
228 fi
229 
230 
231 .oO[CommandLine]Oo.
232 
233 ls -lh .
234 
235 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/CompareBias.oO[resonance]Oo.Validation.cc .
236 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/Legend.h .
237 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitMassSlices.cc .
238 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitSlices.cc .
239 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitXslices.cc .
240 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitWithRooFit.cc .
241 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/FitMass1D.cc .
242 
243 root -q -b -l "CompareBias.oO[resonance]Oo.Validation.cc+(.oO[rebinphi]Oo., .oO[rebinetadiff]Oo., .oO[rebineta]Oo., .oO[rebinpt]Oo.)"
244 
245 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/tdrstyle.C .
246 cp .oO[MuonAnalysis/MomentumScaleCalibration]Oo./test/Macros/RooFit/MultiHistoOverlap_.oO[resonance]Oo..C .
247 
248 if [[ .oO[zmumureference]Oo. == *store* ]]; then xrdcp -f .oO[zmumureference]Oo. BiasCheck_Reference.root; else ln -fs .oO[zmumureference]Oo. ./BiasCheck_Reference.root; fi
249 root -q -b -l MultiHistoOverlap_.oO[resonance]Oo..C
250 
251 eos mkdir -p /store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
252 for RootOutputFile in $(ls *root )
253 do
254  xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./
255  cp ${RootOutputFile} .oO[workingdir]Oo.
256 done
257 
258 mkdir -p .oO[plotsdir]Oo.
259 for PngOutputFile in $(ls *png ); do
260  xrdcp -f ${PngOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
261  cp ${PngOutputFile} .oO[plotsdir]Oo.
262 done
263 
264 
265 echo -----------------------
266 echo Job ended at `date`
267 echo -----------------------
268 
269 """
270 
271 ######################################################################
272 ######################################################################
273 
274 mergeZmumuPlotsExecution="""
275 #merge Z->mumu histograms
276 
277 cp .oO[mergeZmumuPlotsScriptPath]Oo. .
278 root -l -x -b -q TkAlMergeZmumuPlots.C++
279 
280 """
281 
282 ######################################################################
283 ######################################################################
284 
285 mergeZmumuPlotsTemplate="""
286 #include "MuonAnalysis/MomentumScaleCalibration/test/Macros/RooFit/MultiHistoOverlapAll_.oO[resonance]Oo..C"
287 #include <sstream>
288 #include <vector>
289 
290 template <typename T> string separatebycommas(vector<T> v){
291  if (v.size()==0) return "";
292  stringstream s;
293  s << v[0];
294  for (unsigned int i = 1; i < v.size(); i++) s << "," << v[i];
295  return s.str();
296 }
297 
298 void TkAlMergeZmumuPlots(){
299  vector<string> filenames; vector<string> titles; vector<int> colors; vector<int> linestyles;
300 
301 .oO[PlottingInstantiation]Oo.
302 
303  vector<int> linestyles_new, markerstyles_new;
304  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); }
305 
306  TkAlStyle::legendheader = ".oO[legendheader]Oo.";
307  TkAlStyle::set(.oO[publicationstatus]Oo., .oO[era]Oo., ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.");
308 
309  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.);
310 }
311 """