CMS 3D CMS Logo

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