CMS 3D CMS Logo

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