CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
trackSplittingValidationTemplates.py
Go to the documentation of this file.
1 ######################################################################
2 ######################################################################
3 TrackSplittingTemplate="""
4 import FWCore.ParameterSet.Config as cms
5 
6 process = cms.Process("splitter")
7 
8 # CMSSW.2.2.3
9 
10 # message logger
11 process.load("FWCore.MessageLogger.MessageLogger_cfi")
12 MessageLogger = cms.Service("MessageLogger",
13  destinations = cms.untracked.vstring('LOGFILE_TrackSplitting_.oO[name]Oo.',
14  'cout')
15 )
16 ## report only every 100th record
17 process.MessageLogger.cerr.FwkReport.reportEvery = 100
18 
19 process.load('Configuration.StandardSequences.Services_cff')
20 process.load("Configuration.Geometry.GeometryDB_cff")
21 
22 # including global tag
23 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
24 # setting global tag
25 #process.GlobalTag.connect = "frontier://FrontierProd/CMS_COND_21X_GLOBALTAG"
26 # process.GlobalTag.connect="frontier://FrontierProd/CMS_COND_31X_GLOBALTAG"
27 process.GlobalTag.globaltag = ".oO[GlobalTag]Oo."
28 
29 
30 # track selectors and refitting
31 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
32 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
33 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
34 
35 # including data...
36 .oO[datasetDefinition]Oo.
37 
38 ## for craft SP skim v5
39 #process.source.inputCommands = cms.untracked.vstring("keep *","drop *_*_*_FU","drop *_*_*_HLT","drop *_MEtoEDMConverter_*_*","drop *_lumiProducer_*_REPACKER")
40 #process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool( False )
41 
42 
43 # magnetic field
44 process.load("Configuration.StandardSequences..oO[magneticField]Oo._cff")
45 
46 # adding geometries
47 from CondCore.CondDB.CondDB_cfi import *
48 
49 # for craft
50 ## tracker alignment for craft...............................................................
51 .oO[condLoad]Oo.
52 
53 ## track hit filter.............................................................
54 
55 # refit tracks first
56 import RecoTracker.TrackProducer.TrackRefitters_cff
57 process.TrackRefitter1 = RecoTracker.TrackProducer.TrackRefitterP5_cfi.TrackRefitterP5.clone(
58  src = '.oO[TrackCollection]Oo.',
59  TrajectoryInEvent = True,
60  TTRHBuilder = "WithTrackAngle",
61  NavigationSchool = ""
62  )
63 
64 process.FittingSmootherRKP5.EstimateCut = -1
65 
66 # module configuration
67 # alignment track selector
68 process.AlignmentTrackSelector.src = "TrackRefitter1"
69 process.AlignmentTrackSelector.filter = True
70 process.AlignmentTrackSelector.applyBasicCuts = True
71 process.AlignmentTrackSelector.ptMin = 0.
72 process.AlignmentTrackSelector.pMin = 4.
73 process.AlignmentTrackSelector.ptMax = 9999.
74 process.AlignmentTrackSelector.pMax = 9999.
75 process.AlignmentTrackSelector.etaMin = -9999.
76 process.AlignmentTrackSelector.etaMax = 9999.
77 process.AlignmentTrackSelector.nHitMin = 10
78 process.AlignmentTrackSelector.nHitMin2D = 2
79 process.AlignmentTrackSelector.chi2nMax = 9999.
80 process.AlignmentTrackSelector.applyMultiplicityFilter = True
81 process.AlignmentTrackSelector.maxMultiplicity = 1
82 process.AlignmentTrackSelector.applyNHighestPt = False
83 process.AlignmentTrackSelector.nHighestPt = 1
84 process.AlignmentTrackSelector.seedOnlyFrom = 0
85 process.AlignmentTrackSelector.applyIsolationCut = False
86 process.AlignmentTrackSelector.minHitIsolation = 0.8
87 process.AlignmentTrackSelector.applyChargeCheck = False
88 process.AlignmentTrackSelector.minHitChargeStrip = 50.
89 .oO[subdetselection]Oo.
90 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
91 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
92 process.KFFittingSmootherWithOutliersRejectionAndRK.EstimateCut=30.0
93 process.KFFittingSmootherWithOutliersRejectionAndRK.MinNumberOfHits=4
94 #process.FittingSmootherRKP5.EstimateCut = 20.0
95 #process.FittingSmootherRKP5.MinNumberOfHits = 4
96 
97 # configuration of the track spitting module
98 # new cuts allow for cutting on the impact parameter of the original track
99 process.load("RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi")
100 process.cosmicTrackSplitter.tracks = 'AlignmentTrackSelector'
101 process.cosmicTrackSplitter.tjTkAssociationMapTag = 'TrackRefitter1'
102 #process.cosmicTrackSplitter.excludePixelHits = False
103 
104 #---------------------------------------------------------------------
105 # the output of the track hit filter are track candidates
106 # give them to the TrackProducer
107 process.load("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff")
108 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff.ctfWithMaterialTracksCosmics.clone(
109  src = 'cosmicTrackSplitter',
110  TrajectoryInEvent = True,
111  TTRHBuilder = "WithTrackAngle",
112  NavigationSchool = ""
113 )
114 # second refit
115 process.TrackRefitter2 = process.TrackRefitter1.clone(
116  src = 'HitFilteredTracks'
117  )
118 
119 ### Now adding the construction of global Muons
120 # what Chang did...
121 # In 74X it no longer works if ReconstructionCosmics is imported
122 # Results in 73X are identical with or without it so it seems safe to remove
123 #process.load("Configuration.StandardSequences.ReconstructionCosmics_cff")
124 
125 process.cosmicValidation = cms.EDAnalyzer("CosmicSplitterValidation",
126  ifSplitMuons = cms.bool(False),
127  ifTrackMCTruth = cms.bool(False),
128  checkIfGolden = cms.bool(False),
129  splitTracks = cms.InputTag("TrackRefitter2","","splitter"),
130  splitGlobalMuons = cms.InputTag("muons","","splitter"),
131  originalTracks = cms.InputTag("TrackRefitter1","","splitter"),
132  originalGlobalMuons = cms.InputTag("muons","","Rec")
133 )
134 
135 process.TFileService = cms.Service("TFileService",
136  fileName = cms.string('.oO[outputFile]Oo.')
137 )
138 
139 process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter1*process.AlignmentTrackSelector*process.cosmicTrackSplitter*process.HitFilteredTracks*process.TrackRefitter2*process.cosmicValidation)
140 """
141 
142 
143 ######################################################################
144 ######################################################################
145 
146 trackSplitPlotExecution="""
147 #make track splitting plots
148 
149 rfcp .oO[trackSplitPlotScriptPath]Oo. .
150 root -x -b -q TkAlTrackSplitPlot.C++
151 
152 """
153 
154 ######################################################################
155 ######################################################################
156 
157 trackSplitPlotTemplate="""
158 #include "Alignment/OfflineValidation/macros/trackSplitPlot.C"
159 
160 /****************************************
161 This can be run directly in root, or you
162  can run ./TkAlMerge.sh in this directory
163 It can be run as is, or adjusted to fit
164  for misalignments or to only make
165  certain plots
166 ****************************************/
167 
168 /********************************
169 To make ALL plots (247 in total):
170  leave this file as is
171 ********************************/
172 
173 /**************************************************************************
174 to make all plots involving a single x or y variable, or both:
175 Uncomment the line marked (B), and fill in for xvar and yvar
176 
177 Examples:
178 
179  xvar = "dxy", yvar = "ptrel" - makes plots of dxy vs Delta_pT/pT
180  (4 total - profile and resolution,
181  of Delta_pT/pT and its pull
182  distribution)
183  xvar = "all", yvar = "pt" - makes all plots involving Delta_pT
184  (not Delta_pT/pT)
185  (30 plots total:
186  histogram and pull distribution, and
187  their mean and width as a function
188  of the 7 x variables)
189  xvar = "", yvar = "all" - makes all histograms of all y variables
190  (including Delta_pT/pT)
191  (16 plots total - 8 y variables,
192  regular and pull histograms)
193 **************************************************************************/
194 
195 /**************************************************************************************
196 To make a custom selection of plots:
197 Uncomment the lines marked (C) and this section, and fill in matrix however you want */
198 
199 /*
200 Bool_t plotmatrix[xsize][ysize];
201 void fillmatrix()
202 {
203  for (int x = 0; x < xsize; x++)
204  for (int y = 0; y < ysize; y++)
205  plotmatrix[x][y] = (.............................);
206 }
207 */
208 
209 /*
210 The variables are defined in Alignment/OfflineValidation/macros/trackSplitPlot.h
211  as follows:
212 TString xvariables[xsize] = {"", "pt", "eta", "phi", "dz", "dxy", "theta",
213  "qoverpt"};
214 
215 TString yvariables[ysize] = {"pt", "pt", "eta", "phi", "dz", "dxy", "theta",
216  "qoverpt", ""};
217 Bool_t relativearray[ysize] = {true, false, false, false, false, false, false,
218  false, false};
219 Use matrix[x][y] = true to make that plot, and false not to make it.
220 **************************************************************************************/
221 
222 /*************************************************************************************
223 To fit for a misalignment, which can be combined with any other option:
224 Uncomment the line marked (A) and this section, and choose your misalignment */
225 
226 /*
227 TString misalignment = "choose one";
228 double *values = 0;
229 double *phases = 0;
230 //or:
231 // double values[number of files] = {...};
232 // double phases[number of files] = {...};
233 */
234 
235 /*
236 The options for misalignment are sagitta, elliptical, skew, telescope, or layerRot.
237 If the magnitude and phase of the misalignment are known (i.e. Monte Carlo data using
238  a geometry produced by the systematic misalignment tool), make values and phases into
239  arrays, with one entry for each file, to make a plot of the result of the fit vs. the
240  misalignment value.
241 phases must be filled in for sagitta, elliptical, and skew if values is;
242  for the others it has no effect
243 *************************************************************************************/
244 
245 void TkAlTrackSplitPlot()
246 {
247  TkAlStyle::legendheader = ".oO[legendheader]Oo.";
248  TkAlStyle::legendoptions = ".oO[legendoptions]Oo.";
249  TkAlStyle::set(.oO[publicationstatus]Oo., .oO[era]Oo., ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.");
250  outliercut = .oO[outliercut]Oo.;
251  //fillmatrix(); //(C)
252  subdetector = ".oO[subdetector]Oo.";
253  makePlots(
254  ".oO[trackSplitPlotInstantiation]Oo.",
255  //misalignment,values,phases, //(A)
256  ".oO[datadir]Oo./TrackSplittingPlots"
257  //,"xvar","yvar" //(B)
258  //,plotmatrix //(C)
259  );
260 }
261 """