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