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_condDBv2_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 ###########################################
31 ##necessary fix for the moment to avoid
32 ##Assymmetric forward layers in TrackerException going through path p
33 ##---- ScheduleExecutionFailure END
34 ##an exception occurred during current event processing
35 ##cms::Exception caught in EventProcessor and rethrown
36 ##---- EventProcessorFailure END
37 ############################################
38 #import CalibTracker.Configuration.Common.PoolDBESSource_cfi
39 from CondCore.DBCommon.CondDBSetup_cfi import *
40 #load the Global Position Rcd
41 process.globalPosition = cms.ESSource("PoolDBESSource", CondDBSetup,
42  toGet = cms.VPSet(cms.PSet(
43  record =cms.string('GlobalPositionRcd'),
44  tag= cms.string('IdealGeometry')
45  )),
46  connect = cms.string('frontier://FrontierProd/CMS_COND_31X_FROM21X')
47  )
48 process.es_prefer_GPRcd = cms.ESPrefer("PoolDBESSource","globalPosition")
49 ##########################################
50 
51 
52 # track selectors and refitting
53 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
54 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
55 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
56 
57 # including data...
58 .oO[datasetDefinition]Oo.
59 
60 ## for craft SP skim v5
61 #process.source.inputCommands = cms.untracked.vstring("keep *","drop *_*_*_FU","drop *_*_*_HLT","drop *_MEtoEDMConverter_*_*","drop *_lumiProducer_*_REPACKER")
62 #process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool( False )
63 
64 
65 # magnetic field
66 process.load("Configuration.StandardSequences..oO[magneticField]Oo._cff")
67 
68 # adding geometries
69 from CondCore.DBCommon.CondDBSetup_cfi import *
70 
71 # for craft
72 ## tracker alignment for craft...............................................................
73 .oO[condLoad]Oo.
74 
75 ## track hit filter.............................................................
76 
77 # refit tracks first
78 import RecoTracker.TrackProducer.TrackRefitters_cff
79 process.TrackRefitter1 = RecoTracker.TrackProducer.TrackRefitterP5_cfi.TrackRefitterP5.clone(
80  src = '.oO[TrackCollection]Oo.',
81  TrajectoryInEvent = True,
82  TTRHBuilder = "WithTrackAngle",
83  NavigationSchool = ""
84  )
85 
86 process.FittingSmootherRKP5.EstimateCut = -1
87 
88 # module configuration
89 # alignment track selector
90 process.AlignmentTrackSelector.src = "TrackRefitter1"
91 process.AlignmentTrackSelector.filter = True
92 process.AlignmentTrackSelector.applyBasicCuts = True
93 process.AlignmentTrackSelector.ptMin = 0.
94 process.AlignmentTrackSelector.pMin = 4.
95 process.AlignmentTrackSelector.ptMax = 9999.
96 process.AlignmentTrackSelector.pMax = 9999.
97 process.AlignmentTrackSelector.etaMin = -9999.
98 process.AlignmentTrackSelector.etaMax = 9999.
99 process.AlignmentTrackSelector.nHitMin = 10
100 process.AlignmentTrackSelector.nHitMin2D = 2
101 process.AlignmentTrackSelector.minHitsPerSubDet.inBPIX=4 ##skip tracks not passing the pixel
102 process.AlignmentTrackSelector.chi2nMax = 9999.
103 process.AlignmentTrackSelector.applyMultiplicityFilter = True
104 process.AlignmentTrackSelector.maxMultiplicity = 1
105 process.AlignmentTrackSelector.applyNHighestPt = False
106 process.AlignmentTrackSelector.nHighestPt = 1
107 process.AlignmentTrackSelector.seedOnlyFrom = 0
108 process.AlignmentTrackSelector.applyIsolationCut = False
109 process.AlignmentTrackSelector.minHitIsolation = 0.8
110 process.AlignmentTrackSelector.applyChargeCheck = False
111 process.AlignmentTrackSelector.minHitChargeStrip = 50.
112 process.AlignmentTrackSelector.minHitsPerSubDet.inBPIX = 2
113 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
114 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
115 process.KFFittingSmootherWithOutliersRejectionAndRK.EstimateCut=30.0
116 process.KFFittingSmootherWithOutliersRejectionAndRK.MinNumberOfHits=4
117 #process.FittingSmootherRKP5.EstimateCut = 20.0
118 #process.FittingSmootherRKP5.MinNumberOfHits = 4
119 
120 # configuration of the track spitting module
121 # new cuts allow for cutting on the impact parameter of the original track
122 process.load("RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi")
123 process.cosmicTrackSplitter.tracks = 'AlignmentTrackSelector'
124 process.cosmicTrackSplitter.tjTkAssociationMapTag = 'TrackRefitter1'
125 #process.cosmicTrackSplitter.excludePixelHits = False
126 
127 #---------------------------------------------------------------------
128 # the output of the track hit filter are track candidates
129 # give them to the TrackProducer
130 process.load("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff")
131 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff.ctfWithMaterialTracksCosmics.clone(
132  src = 'cosmicTrackSplitter',
133  TrajectoryInEvent = True,
134  TTRHBuilder = "WithTrackAngle",
135  NavigationSchool = ""
136 )
137 # second refit
138 process.TrackRefitter2 = process.TrackRefitter1.clone(
139  src = 'HitFilteredTracks'
140  )
141 
142 ### Now adding the construction of global Muons
143 # what Chang did...
144 # In 74X it no longer works if ReconstructionCosmics is imported
145 # Results in 73X are identical with or without it so it seems safe to remove
146 #process.load("Configuration.StandardSequences.ReconstructionCosmics_cff")
147 
148 process.cosmicValidation = cms.EDAnalyzer("CosmicSplitterValidation",
149  ifSplitMuons = cms.bool(False),
150  ifTrackMCTruth = cms.bool(False),
151  checkIfGolden = cms.bool(False),
152  splitTracks = cms.InputTag("TrackRefitter2","","splitter"),
153  splitGlobalMuons = cms.InputTag("muons","","splitter"),
154  originalTracks = cms.InputTag("TrackRefitter1","","splitter"),
155  originalGlobalMuons = cms.InputTag("muons","","Rec")
156 )
157 
158 process.TFileService = cms.Service("TFileService",
159  fileName = cms.string('.oO[outputFile]Oo.')
160 )
161 
162 process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter1*process.AlignmentTrackSelector*process.cosmicTrackSplitter*process.HitFilteredTracks*process.TrackRefitter2*process.cosmicValidation)
163 """
164 
165 
166 ######################################################################
167 ######################################################################
168 
169 trackSplitPlotExecution="""
170 #make track splitting plots
171 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
172 then
173  rfmkdir -p .oO[workdir]Oo./TrackSplittingPlots
174 else
175  mkdir -p TrackSplittingPlots
176 fi
177 
178 rfcp .oO[trackSplitPlotScriptPath]Oo. .
179 root -x -b -q TkAlTrackSplitPlot.C++
180 rfmkdir -p .oO[datadir]Oo./TrackSplittingPlots
181 
182 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
183 then
184  image_files=$(find .oO[workdir]Oo./TrackSplittingPlots/* -maxdepth 0)
185  echo ${image_files}
186  ls .oO[workdir]Oo./TrackSplittingPlots
187 else
188  image_files=$(find TrackSplittingPlots/* -maxdepth 0)
189  echo ${image_files}
190  ls TrackSplittingPlots
191 fi
192 
193 for image in ${image_files}
194 do
195  cp -r ${image} .oO[datadir]Oo./TrackSplittingPlots
196 done
197 """
198 
199 ######################################################################
200 ######################################################################
201 
202 trackSplitPlotTemplate="""
203 #include ".oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/trackSplitPlot.C"
204 
205 /****************************************
206 This can be run directly in root, or you
207  can run ./TkAlMerge.sh in this directory
208 It can be run as is, or adjusted to fit
209  for misalignments or to only make
210  certain plots
211 ****************************************/
212 
213 /********************************
214 To make ALL plots (313 in total):
215  leave this file as is
216 ********************************/
217 
218 /**************************************************************************
219 to make all plots involving a single x or y variable, or both:
220 Uncomment the line marked (B), and fill in for xvar and yvar
221 
222 Examples:
223 
224  xvar = "nHits", yvar = "ptrel" - makes plots of nHits vs Delta_pt/pt_org
225  (4 total - profile and resolution,
226  of Delta_pt/pt_org and its pull
227  distribution)
228  xvar = "all", yvar = "pt" - makes all plots involving Delta_pt
229  (not Delta_pt/pt_org)
230  (38 plots total:
231  histogram and pull distribution, and
232  their mean and width as a function
233  of the 9 x variables)
234  xvar = "", yvar = "all" - makes all histograms of all y variables
235  (including Delta_pt/pt_org)
236  (16 plots total - 8 y variables,
237  regular and pull histograms)
238 **************************************************************************/
239 
240 /**************************************************************************************
241 To make a custom selection of plots:
242 Uncomment the lines marked (C) and this section, and fill in matrix however you want */
243 
244 /*
245 Bool_t plotmatrix[xsize][ysize];
246 void fillmatrix()
247 {
248  for (int x = 0; x < xsize; x++)
249  for (int y = 0; y < ysize; y++)
250  plotmatrix[x][y] = (.............................);
251 }
252 */
253 
254 /*
255 The variables are defined in Alignment/OfflineValidation/macros/trackSplitPlot.h
256  as follows:
257 TString xvariables[xsize] = {"pt", "eta", "phi", "dz", "dxy", "theta",
258  "qoverpt", "runNumber","nHits",""};
259 
260 TString yvariables[ysize] = {"pt", "pt", "eta", "phi", "dz", "dxy", "theta",
261  "qoverpt", ""};
262 Bool_t relativearray[ysize] = {true, false, false, false, false, false, false,
263  false, false};
264 Use matrix[x][y] = true to make that plot, and false not to make it.
265 **************************************************************************************/
266 
267 /*************************************************************************************
268 To fit for a misalignment, which can be combined with any other option:
269 Uncomment the line marked (A) and this section, and choose your misalignment */
270 
271 /*
272 TString misalignment = "choose one";
273 double *values = 0;
274 double *phases = 0;
275 //or:
276 // double values[number of files] = {...};
277 // double phases[number of files] = {...};
278 */
279 
280 /*
281 The options for misalignment are sagitta, elliptical, skew, telescope, or layerRot.
282 If the magnitude and phase of the misalignment are known (i.e. Monte Carlo data using
283  a geometry produced by the systematic misalignment tool), make values and phases into
284  arrays, with one entry for each file, to make a plot of the result of the fit vs. the
285  misalignment value.
286 phases must be filled in for sagitta, elliptical, and skew if values is;
287  for the others it has no effect
288 *************************************************************************************/
289 
290 void TkAlTrackSplitPlot()
291 {
292  //fillmatrix(); //(C)
293  makePlots(".oO[trackSplitPlotInstantiation]Oo.",
294  //misalignment,values,phases, //(A)
295  "TrackSplittingPlots"
296  //,"xvar","yvar" //(B)
297  //,plotmatrix //(C)
298  );
299 }
300 """
301