Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:59

0001 PrimaryVertexValidationTemplate="""
0002 
0003 isDA = .oO[isda]Oo.
0004 isMC = .oO[ismc]Oo.
0005 
0006 ###################################################################
0007 #  Runs and events
0008 ###################################################################
0009 runboundary = .oO[runboundary]Oo.
0010 isMultipleRuns=False
0011 if(isinstance(runboundary, (list, tuple))):
0012      isMultipleRuns=True
0013      print("Multiple Runs are selected")
0014        
0015 if(isMultipleRuns):
0016      process.source.firstRun = cms.untracked.uint32(int(runboundary[0]))
0017 else:
0018      process.source.firstRun = cms.untracked.uint32(int(runboundary)) 
0019 
0020 ###################################################################
0021 # JSON Filtering
0022 ###################################################################
0023 if isMC:
0024      print(">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is simulation!")
0025      runboundary = 1
0026 else:
0027      print(">>>>>>>>>> testPVValidation_cfg.py: msg%-i: This is real DATA!")
0028      if ('.oO[lumilist]Oo.'):
0029           print(">>>>>>>>>> testPVValidation_cfg.py: msg%-i: JSON filtering with: .oO[lumilist]Oo. ")
0030           import FWCore.PythonUtilities.LumiList as LumiList
0031           process.source.lumisToProcess = LumiList.LumiList(filename ='.oO[lumilist]Oo.').getVLuminosityBlockRange()
0032 
0033 ####################################################################
0034 # Produce the Transient Track Record in the event
0035 ####################################################################
0036 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0037 
0038 ####################################################################
0039 # Load and Configure event selection
0040 ####################################################################
0041 process.primaryVertexFilter = cms.EDFilter("VertexSelector",
0042                                            src = cms.InputTag(".oO[VertexCollection]Oo."),
0043                                            cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
0044                                            filter = cms.bool(True)
0045                                            )
0046 
0047 process.noscraping = cms.EDFilter("FilterOutScraping",
0048                                   applyfilter = cms.untracked.bool(True),
0049                                   src =  cms.untracked.InputTag(".oO[TrackCollection]Oo."),
0050                                   debugOn = cms.untracked.bool(False),
0051                                   numtrack = cms.untracked.uint32(10),
0052                                   thresh = cms.untracked.double(0.25)
0053                                   )
0054 
0055 
0056 process.load("Alignment.CommonAlignment.filterOutLowPt_cfi")
0057 process.filterOutLowPt.src = ".oO[TrackCollection]Oo."
0058 process.filterOutLowPt.ptmin = .oO[ptCut]Oo.
0059 process.filterOutLowPt.runControl = .oO[runControl]Oo.
0060 if(isMultipleRuns):
0061      process.filterOutLowPt.runControlNumber.extend((runboundary))
0062 else:
0063      process.filterOutLowPt.runControlNumber = [runboundary]
0064                                 
0065 if isMC:
0066      process.goodvertexSkim = cms.Sequence(process.noscraping + process.filterOutLowPt)
0067 else:
0068      process.goodvertexSkim = cms.Sequence(process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
0069 
0070 ####################################################################
0071 # Imports of parameters
0072 ####################################################################
0073 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0074 ## modify the parameters which differ
0075 FilteringParams = offlinePrimaryVertices.TkFilterParameters.clone(
0076      maxNormalizedChi2 = 5.0,  # chi2ndof < 5
0077      maxD0Significance = 5.0,  # fake cut (requiring 1 PXB hit)
0078      maxEta = 5.0,             # as per recommendation in PR #18330
0079 )
0080 
0081 ## MM 04.05.2017 (use settings as in: https://github.com/cms-sw/cmssw/pull/18330)
0082 from RecoVertex.PrimaryVertexProducer.TkClusParameters_cff import DA_vectParameters
0083 DAClusterizationParams = DA_vectParameters.clone()
0084 
0085 GapClusterizationParams = cms.PSet(algorithm   = cms.string('gap'),
0086                                    TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2))  # 0.2 cm max separation betw. clusters
0087                                    )
0088 
0089 ####################################################################
0090 # Deterministic annealing clustering or Gap clustering
0091 ####################################################################
0092 def switchClusterizerParameters(da):
0093      if da:
0094           print(">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running DA Algorithm!")
0095           return DAClusterizationParams
0096      else:
0097           print(">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!")
0098           return GapClusterizationParams
0099 
0100 # Use compressions settings of TFile
0101 # see https://root.cern.ch/root/html534/TFile.html#TFile:SetCompressionSettings
0102 # settings = 100 * algorithm + level
0103 # level is from 1 (small) to 9 (large compression)
0104 # algo: 1 (ZLIB), 2 (LMZA)
0105 # see more about compression & performance: https://root.cern.ch/root/html534/guides/users-guide/InputOutput.html#compression-and-performance
0106 compressionSettings = 207
0107 
0108 ####################################################################
0109 # Configure the PVValidation Analyzer module
0110 ####################################################################
0111 process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
0112                                       compressionSettings = cms.untracked.int32(compressionSettings),
0113                                       TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
0114                                       VertexCollectionTag = cms.InputTag(".oO[VertexCollection]Oo."),
0115                                       Debug = cms.bool(False),
0116                                       storeNtuple = cms.bool(False),
0117                                       useTracksFromRecoVtx = cms.bool(False),
0118                                       isLightNtuple = cms.bool(True),
0119                                       askFirstLayerHit = cms.bool(False),
0120                                       forceBeamSpot = cms.untracked.bool(.oO[forceBeamSpot]Oo.),
0121                                       probePt  = cms.untracked.double(.oO[ptCut]Oo.),
0122                                       probeEta = cms.untracked.double(.oO[etaCut]Oo.),
0123                                       doBPix   = cms.untracked.bool(.oO[doBPix]Oo.),
0124                                       doFPix   = cms.untracked.bool(.oO[doFPix]Oo.),
0125                                       numberOfBins = cms.untracked.int32(.oO[numberOfBins]Oo.),
0126                                       runControl = cms.untracked.bool(.oO[runControl]Oo.),
0127                                       runControlNumber = cms.untracked.vuint32(runboundary),
0128                                       TkFilterParameters = FilteringParams,
0129                                       TkClusParameters = switchClusterizerParameters(isDA)
0130                                       )
0131 """
0132 
0133 ####################################################################
0134 ####################################################################
0135 PVValidationPath="""
0136 process.p = cms.Path(process.goodvertexSkim*
0137                      process.seqTrackselRefit*
0138                      process.PVValidation)
0139 """
0140 
0141 ####################################################################
0142 ####################################################################
0143 PVValidationScriptTemplate="""#!/bin/bash
0144 source /afs/cern.ch/cms/caf/setup.sh
0145 export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
0146 
0147 echo  -----------------------
0148 echo  Job started at `date`
0149 echo  -----------------------
0150 
0151 export theLabel=.oO[alignmentName]Oo.
0152 export theDate=.oO[runboundary]Oo.
0153 
0154 cwd=`pwd`
0155 cd .oO[CMSSW_BASE]Oo./src
0156 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
0157 eval `scram runtime -sh`
0158 cd $cwd
0159 
0160 mkdir -p .oO[datadir]Oo.
0161 mkdir -p .oO[workingdir]Oo.
0162 mkdir -p .oO[logdir]Oo.
0163 rm -f .oO[logdir]Oo./*.stdout
0164 rm -f .oO[logdir]Oo./*.stderr
0165 
0166 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
0167 then
0168     mkdir -p .oO[workdir]Oo.
0169     rm -f .oO[workdir]Oo./*
0170     cd .oO[workdir]Oo.
0171 else
0172     mkdir -p $cwd/TkAllInOneTool
0173     cd $cwd/TkAllInOneTool
0174 fi
0175 
0176 .oO[CommandLine]Oo.
0177 
0178 ls -lh .
0179 
0180 eos mkdir -p /store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/
0181 for RootOutputFile in $(ls *root )
0182 do
0183     xrdcp -f ${RootOutputFile} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./${RootOutputFile}
0184     cp ${RootOutputFile}  .oO[workingdir]Oo.
0185 done
0186 
0187 cp .oO[Alignment/OfflineValidation]Oo./macros/FitPVResiduals.C .
0188 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.C .
0189 cp .oO[Alignment/OfflineValidation]Oo./macros/CMS_lumi.h .
0190 
0191  if [[ .oO[pvvalidationreference]Oo. == *store* ]]; then xrdcp -f .oO[pvvalidationreference]Oo. PVValidation_reference.root; else ln -fs .oO[pvvalidationreference]Oo. ./PVValidation_reference.root; fi
0192 
0193 echo "I am going to produce the comparison with IDEAL geometry of ${RootOutputFile}"
0194 root -b -q "FitPVResiduals.C++g(\\"${PWD}/${RootOutputFile}=${theLabel},${PWD}/PVValidation_reference.root=Design simulation\\",true,true,\\"$theDate\\")"
0195 
0196 mkdir -p .oO[plotsdir]Oo.
0197 for PngOutputFile in $(ls *png ); do
0198     xrdcp -f ${PngOutputFile}  root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
0199     cp ${PngOutputFile}  .oO[plotsdir]Oo.
0200 done
0201 
0202 for PdfOutputFile in $(ls *pdf ); do
0203     xrdcp -f ${PdfOutputFile}  root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
0204     cp ${PdfOutputFile}  .oO[plotsdir]Oo.
0205 done
0206 
0207 mkdir .oO[plotsdir]Oo./Biases/
0208 mkdir .oO[plotsdir]Oo./Biases/dzPhi
0209 mkdir .oO[plotsdir]Oo./Biases/dxyPhi
0210 mkdir .oO[plotsdir]Oo./Biases/dzEta
0211 mkdir .oO[plotsdir]Oo./Biases/dxyEta
0212 mkdir .oO[plotsdir]Oo./Fit
0213 mkdir .oO[plotsdir]Oo./dxyVsEta
0214 mkdir .oO[plotsdir]Oo./dzVsEta
0215 mkdir .oO[plotsdir]Oo./dxyVsPhi
0216 mkdir .oO[plotsdir]Oo./dzVsPhi
0217 mkdir .oO[plotsdir]Oo./dxyVsEtaNorm
0218 mkdir .oO[plotsdir]Oo./dzVsEtaNorm
0219 mkdir .oO[plotsdir]Oo./dxyVsPhiNorm
0220 mkdir .oO[plotsdir]Oo./dzVsPhiNorm
0221 
0222 mv .oO[plotsdir]Oo./BiasesCanvas*     .oO[plotsdir]Oo./Biases/
0223 mv .oO[plotsdir]Oo./dzPhiBiasCanvas*  .oO[plotsdir]Oo./Biases/dzPhi
0224 mv .oO[plotsdir]Oo./dxyPhiBiasCanvas* .oO[plotsdir]Oo./Biases/dxyPhi
0225 mv .oO[plotsdir]Oo./dzEtaBiasCanvas*  .oO[plotsdir]Oo./Biases/dzEta
0226 mv .oO[plotsdir]Oo./dxyEtaBiasCanvas* .oO[plotsdir]Oo./Biases/dxyEta
0227 mv .oO[plotsdir]Oo./dzPhiTrendFit*    .oO[plotsdir]Oo./Fit
0228 mv .oO[plotsdir]Oo./dxyEtaTrendNorm*  .oO[plotsdir]Oo./dxyVsEtaNorm
0229 mv .oO[plotsdir]Oo./dzEtaTrendNorm*   .oO[plotsdir]Oo./dzVsEtaNorm
0230 mv .oO[plotsdir]Oo./dxyPhiTrendNorm*  .oO[plotsdir]Oo./dxyVsPhiNorm
0231 mv .oO[plotsdir]Oo./dzPhiTrendNorm*   .oO[plotsdir]Oo./dzVsPhiNorm
0232 mv .oO[plotsdir]Oo./dxyEtaTrend*      .oO[plotsdir]Oo./dxyVsEta
0233 mv .oO[plotsdir]Oo./dzEtaTrend*       .oO[plotsdir]Oo./dzVsEta
0234 mv .oO[plotsdir]Oo./dxyPhiTrend*      .oO[plotsdir]Oo./dxyVsPhi
0235 mv .oO[plotsdir]Oo./dzPhiTrend*       .oO[plotsdir]Oo./dzVsPhi
0236 
0237 wget https://raw.githubusercontent.com/mmusich/PVToolScripts/master/PolishedScripts/index.php
0238 
0239 cp index.php .oO[plotsdir]Oo./Biases/
0240 cp index.php .oO[plotsdir]Oo./Biases/dzPhi
0241 cp index.php .oO[plotsdir]Oo./Biases/dxyPhi
0242 cp index.php .oO[plotsdir]Oo./Biases/dzEta
0243 cp index.php .oO[plotsdir]Oo./Biases/dxyEta
0244 cp index.php .oO[plotsdir]Oo./Fit
0245 cp index.php .oO[plotsdir]Oo./dxyVsEta
0246 cp index.php .oO[plotsdir]Oo./dzVsEta
0247 cp index.php .oO[plotsdir]Oo./dxyVsPhi
0248 cp index.php .oO[plotsdir]Oo./dzVsPhi
0249 cp index.php .oO[plotsdir]Oo./dxyVsEtaNorm
0250 cp index.php .oO[plotsdir]Oo./dzVsEtaNorm
0251 cp index.php .oO[plotsdir]Oo./dxyVsPhiNorm
0252 cp index.php .oO[plotsdir]Oo./dzVsPhiNorm
0253 
0254 
0255 echo  -----------------------
0256 echo  Job ended at `date`
0257 echo  -----------------------
0258 
0259 """
0260 
0261 ######################################################################
0262 ######################################################################
0263 
0264 PrimaryVertexPlotExecution="""
0265 #make primary vertex validation plots
0266 
0267 cp .oO[plottingscriptpath]Oo. .
0268 root -x -b -q .oO[plottingscriptname]Oo.++
0269 
0270 for PdfOutputFile in $(ls *pdf ); do
0271     xrdcp -f ${PdfOutputFile}  root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PdfOutputFile}
0272     cp ${PdfOutputFile}  .oO[datadir]Oo./.oO[PlotsDirName]Oo.
0273 done
0274 
0275 for PngOutputFile in $(ls *png ); do
0276     xrdcp -f ${PngOutputFile}  root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./plots/${PngOutputFile}
0277     cp ${PngOutputFile}  .oO[datadir]Oo./.oO[PlotsDirName]Oo.
0278 done
0279 
0280 """
0281 
0282 ######################################################################
0283 ######################################################################
0284 
0285 PrimaryVertexPlotTemplate="""
0286 /****************************************
0287 This can be run directly in root, or you
0288  can run ./TkAlMerge.sh in this directory
0289 ****************************************/
0290 
0291 #include "Alignment/OfflineValidation/macros/FitPVResiduals.C"
0292 
0293 void TkAlPrimaryVertexValidationPlot()
0294 {
0295 
0296   // initialize the plot y-axis ranges
0297   thePlotLimits->init(.oO[m_dxyPhiMax]Oo.,         // mean of dxy vs Phi
0298                       .oO[m_dzPhiMax]Oo.,          // mean of dz  vs Phi
0299                       .oO[m_dxyEtaMax]Oo.,         // mean of dxy vs Eta
0300                       .oO[m_dzEtaMax]Oo.,          // mean of dz  vs Eta
0301                       .oO[m_dxyPhiNormMax]Oo.,     // mean of dxy vs Phi (norm)
0302                       .oO[m_dzPhiNormMax]Oo.,      // mean of dz  vs Phi (norm)
0303                       .oO[m_dxyEtaNormMax]Oo.,     // mean of dxy vs Eta (norm)
0304                       .oO[m_dzEtaNormMax]Oo.,      // mean of dz  vs Eta (norm)
0305                       .oO[w_dxyPhiMax]Oo.,         // width of dxy vs Phi
0306                       .oO[w_dzPhiMax]Oo.,          // width of dz  vs Phi
0307                       .oO[w_dxyEtaMax]Oo.,         // width of dxy vs Eta
0308                       .oO[w_dzEtaMax]Oo.,          // width of dz  vs Eta
0309                       .oO[w_dxyPhiNormMax]Oo.,     // width of dxy vs Phi (norm)
0310                       .oO[w_dzPhiNormMax]Oo.,      // width of dz  vs Phi (norm)
0311                       .oO[w_dxyEtaNormMax]Oo.,     // width of dxy vs Eta (norm)
0312                       .oO[w_dzEtaNormMax]Oo.       // width of dz  vs Eta (norm)
0313               );
0314 
0315  .oO[PlottingInstantiation]Oo.
0316   FitPVResiduals("",.oO[stdResiduals]Oo.,.oO[doMaps]Oo.,"",.oO[autoLimits]Oo.);
0317 }
0318 """
0319 
0320