From a0c415d55569cc12b33024003d87ec41a4838d29 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Fri, 23 Jan 2015 17:18:53 +0100 Subject: [PATCH 001/104] added new PromptCalibProdSiPixelAli alca reco Conflicts: Configuration/PyReleaseValidation/python/ConfigBuilder.py --- ...RECOPromptCalibProdSiPixelAli_Output_cff.py | 18 ++++++++++++++++++ .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 13 +++++++++++++ .../EventContent/python/AlCaRecoOutput_cff.py | 1 + .../python/AlCaRecoStreams_cff.py | 1 + 4 files changed, 33 insertions(+) create mode 100644 Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py create mode 100644 Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py new file mode 100644 index 0000000000000..d86bfaae23e53 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py @@ -0,0 +1,18 @@ +import FWCore.ParameterSet.Config as cms + + + + +OutALCARECOPromptCalibProd_noDrop = cms.PSet( + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOPromptCalibProd') + ), + outputCommands = cms.untracked.vstring( + 'keep *_alcaBeamSpotProducer_*_*', + 'keep *_MEtoEDMConvertSiStrip_*_*') +) + +import copy + +OutALCARECOPromptCalibProd=copy.deepcopy(OutALCARECOPromptCalibProd_noDrop) +OutALCARECOPromptCalibProd.outputCommands.insert(0, "drop *") diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py new file mode 100644 index 0000000000000..19c31bec43b34 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +# ------------------------------------------------------------------------------ +# configure a filter to run only on the events selected by TkAlMinBias AlcaReco +import copy +from HLTrigger.HLTfilters.hltHighLevel_cfi import * +ALCARECOTkAlMinBiasFilterForSiPixelAli = copy.deepcopy(hltHighLevel) +ALCARECOTkAlMinBiasFilterForSiPixelAli.HLTPaths = ['pathALCARECOTkAlMinBias'] +ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names +ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") + + +seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli) diff --git a/Configuration/EventContent/python/AlCaRecoOutput_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_cff.py index 69c00ea636cab..2eab5c0603146 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_cff.py @@ -107,6 +107,7 @@ from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiStripGains_Output_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripPCLHistos_Output_cff import * +from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAli_Output_cff import * # stream for the LumiPixels workflow from Calibration.TkAlCaRecoProducers.ALCARECOLumiPixels_Output_cff import * diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index 6ab78405a9185..faa2642b9530b 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -110,6 +110,7 @@ from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiStripGains_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripPCLHistos_cff import * +from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAli_cff import * ############################################################### # hotline skim workflows From b305f7ecbe7dbae23c2579f141db3fea786f5894 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 26 Jan 2015 12:12:50 +0100 Subject: [PATCH 002/104] Added path for SiPixelAli --- .../ALCARECOPromptCalibProdSiPixelAli_Output_cff.py | 11 ++++------- .../StandardSequences/python/AlCaRecoStreams_cff.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py index d86bfaae23e53..9d65d6feb7bb5 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py @@ -1,11 +1,8 @@ import FWCore.ParameterSet.Config as cms - - - -OutALCARECOPromptCalibProd_noDrop = cms.PSet( +OutALCARECOPromptCalibProdSiPixelAli_noDrop = cms.PSet( SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('pathALCARECOPromptCalibProd') + SelectEvents = cms.vstring('pathALCARECOPromptCalibProdSiPixelAli') ), outputCommands = cms.untracked.vstring( 'keep *_alcaBeamSpotProducer_*_*', @@ -14,5 +11,5 @@ import copy -OutALCARECOPromptCalibProd=copy.deepcopy(OutALCARECOPromptCalibProd_noDrop) -OutALCARECOPromptCalibProd.outputCommands.insert(0, "drop *") +OutALCARECOPromptCalibProdSiPixelAli=copy.deepcopy(OutALCARECOPromptCalibProd_noDrop) +OutALCARECOPromptCalibProdSiPixelAli.outputCommands.insert(0, "drop *") diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index faa2642b9530b..78973587aa297 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -184,6 +184,7 @@ pathALCARECOPromptCalibProd = cms.Path(seqALCARECOPromptCalibProd) pathALCARECOPromptCalibProdSiStrip = cms.Path(seqALCARECOPromptCalibProdSiStrip) pathALCARECOPromptCalibProdSiStripGains = cms.Path(seqALCARECOPromptCalibProdSiStripGains) +pathALCARECOPromptCalibProdSiPixelAli = cms.Path(seqALCARECOPromptCalibProdSiPixelAli) pathALCARECOSiStripPCLHistos = cms.Path(seqALCARECOSiStripPCLHistos) pathHotlineSkimSingleMuon = cms.Path(seqHotlineSkimSingleMuon) pathHotlineSkimDoubleMuon = cms.Path(seqHotlineSkimDoubleMuon) @@ -603,6 +604,16 @@ +ALCARECOStreamPromptCalibProdSiPixelAli = cms.FilteredStream( + responsible = 'Gianluca Cerminara', + name = 'PromptCalibProdSiPixelAli', + paths = (pathALCARECOPromptCalibProdSiPixelAli), + content = OutALCARECOPromptCalibProdSiPixelAli.outputCommands, + selectEvents = OutALCARECOPromptCalibProdSiPixelAli.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + + ALCARECOStreamSiStripPCLHistos = cms.FilteredStream( responsible = 'Gianluca Cerminara', name = 'SiStripPCLHistos', From f1e409b489846d14001ebf7cf54b0989410acee4 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 26 Jan 2015 15:23:53 +0100 Subject: [PATCH 003/104] Fixed problem with failing cmsDriver for SiPixelAli --- .../python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py index 9d65d6feb7bb5..0b161e11b5c80 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py @@ -11,5 +11,5 @@ import copy -OutALCARECOPromptCalibProdSiPixelAli=copy.deepcopy(OutALCARECOPromptCalibProd_noDrop) +OutALCARECOPromptCalibProdSiPixelAli=copy.deepcopy(OutALCARECOPromptCalibProdSiPixelAli_noDrop) OutALCARECOPromptCalibProdSiPixelAli.outputCommands.insert(0, "drop *") From 3877aa7930b47c62b9941c6fc37c35168b69e8f1 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Wed, 25 Feb 2015 18:52:56 +0100 Subject: [PATCH 004/104] Added all necessary ingredients to ALCARECOPromptCalibProdSiPixelAli_cff.py --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 200 +++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 19c31bec43b34..fee33087ac0d4 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -9,5 +9,203 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") +# So, should all our stuff come here??? +# I mean, all this thing does in the end is define a sequence... +# ... while step2_ALCA_tobe.py defines an entire process. +# The answer is YES -seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli) +# Start of what we imported + +# Ingredient: offlineBeamSpot +from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot + +# Ingredient: AlignmentTrackSelector +# track selection for alignment +from Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi import AlignmentTrackSelector +AlignmentTrackSelector.src = 'ALCARECOTkAlMinBias' #'SiPixelAliTrackFitter' #'ALCARECOTkAlCosmicsCTF0T' #TkAlZMuMu' #MinBias' #'generalTracks' ## ALCARECOTkAlMuonIsolated # adjust to input file +AlignmentTrackSelector.pMin = 4. +AlignmentTrackSelector.ptMin = 0. #HIGHER CUT, LESS TRACKS, MORE EVENTS, LESS TIME THOUGH????? +AlignmentTrackSelector.ptMax = 200. +AlignmentTrackSelector.etaMin = -999. +AlignmentTrackSelector.etaMax = 999. +AlignmentTrackSelector.nHitMin = 10 +AlignmentTrackSelector.nHitMin2D = 3 +AlignmentTrackSelector.chi2nMax = 100. +AlignmentTrackSelector.applyMultiplicityFilter = False# True +AlignmentTrackSelector.maxMultiplicity = 1 +AlignmentTrackSelector.minHitsPerSubDet.inPIXEL = 2 + + +# Ingredient: SiPixelAliTrackRefitter0 +# refitting +from RecoTracker.TrackProducer.TrackRefitters_cff import TrackReFitter +# In the following use +# TrackRefitter (normal tracks), TrackRefitterP5 (cosmics) or TrackRefitterBHM (beam halo) + +SiPixelAliTrackRefitter0 = TrackRefitter.clone( + src = 'AlignmentTrackSelector'#'ALCARECOTkAlMinBias'#'ALCARECOTkAlCosmicsCTF0T' #'ALCARECOTkAlMuonIsolated' + NavigationSchool = '' # to avoid filling hit pattern + ) + +# Alignment producer +process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff") +#process.AlignmentProducer.parameterTypes = cms.vstring('Selector,RigidBody') +#process.AlignmentProducer.ParameterBuilder.parameterTypes = [ +# 'SelectorRigid,RigidBody', +# 'SelectorBowed,BowedSurface' +# ,'Selector2Bowed,TwoBowedSurfaces' +# ] +process.AlignmentProducer.ParameterBuilder.Selector = cms.PSet( + alignParams = cms.vstring( + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', +# 'TrackerTPBLayer,111111', +# 'TrackerTPEHalfDisk,111111', + + 'TrackerTIBHalfBarrel,ffffff', # or fff fff? + 'TrackerTOBHalfBarrel,ffffff', # dito... + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' + ) + ) + +process.AlignmentProducer.doMisalignmentScenario = False #True + +# If the above is true, you might want to choose the scenario: +#from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario + + +process.AlignmentProducer.MisalignmentScenario = cms.PSet( + setRotations = cms.bool(True), + setTranslations = cms.bool(True), + seed = cms.int32(1234567), + distribution = cms.string('fixed'), # gaussian, uniform (or so...) + setError = cms.bool(True), #GF ??????? + TPBHalfBarrel1 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(-0.0015), + dZlocal = cms.double(0.0100), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-2.e-4), + phiZlocal = cms.double(5.e-4), + + ), + TPBHalfBarrel2 = cms.PSet( + dXlocal = cms.double(-0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.020), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(-2.e-4), + + ), + TPEEndcap1 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(0.0050), + dYlocal = cms.double(0.0020), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-5), + phiYlocal = cms.double(2.e-3), + phiZlocal = cms.double(2.e-5), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.01), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-1.e-4), + phiZlocal = cms.double(2.e-4), + ), + ), + TPEEndcap2 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(-0.0080), + dYlocal = cms.double(0.0050), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(-3.e-4), + phiZlocal = cms.double(2.e-4), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(3.e-4), + ), + ) + + + ) +process.AlignmentProducer.checkDbAlignmentValidity = False + +process.AlignmentProducer.applyDbAlignment = True + + +process.AlignmentProducer.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' + +# assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): +process.AlignmentProducer.algoConfig = process.MillePedeAlignmentAlgorithm + +#from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * +#process.AlignmentProducer.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) +process.AlignmentProducer.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' +#process.AlignmentProducer.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] +#process.AlignmentProducer.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] +process.AlignmentProducer.algoConfig.binaryFile = 'milleBinaryISN.dat' +process.AlignmentProducer.algoConfig.treeFile = 'treeFileISN.root' + +process.AlignmentProducer.algoConfig.TrajectoryFactory = process.BrokenLinesTrajectoryFactory +process.AlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +#process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' +process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' +#default is sparseMINRES 6 0.8: n(iter) Delta(F) +process.AlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) +process.AlignmentProducer.algoConfig.pedeSteerer.options = cms.vstring( + #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum + 'entries 500', + 'chisqcut 30.0 4.5', #, + 'threads 1 1' #, + #'outlierdownweighting 3','dwfractioncut 0.1' + #'outlierdownweighting 5','dwfractioncut 0.2' + ) + +process.AlignmentProducer.algoConfig.minNumHits = 8 + +process.AlignmentProducer.saveToDB = False + +# Ingredient: SiPixelAliTrackerTrackHitFilter +import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter +# Reference config at /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/aliConfigTemplates/Cosmics38T_BL_default_cfg.py +SiPixelAliTrackerTrackHitFilter = HitFilter.TrackerTrackHitFilter.clone( + src = 'SiPixelAliTrackRefitter0', #'ALCARECOTkAlCosmicsCTF0T', + useTrajectories= False,#True, # for angle selections + pixel cluster charge + minimumHits = 8, + commands = [], # Ref. has equivalent pharse... + detsToIgnore = [], #is default + replaceWithInactiveHits = True, # needed for multiple scattering + stripAllInvalidHits = False, #default + rejectBadStoNHits = True, + StoNcommands = ["ALL 18.0"], # 18 for tracker in peak mode, 5 for deconvolution mode +# rejectLowAngleHits = True, + TrackAngleCut = 0.1, # 0.35, # in rads, starting from the module surface; .35 for cosmcics ok, .17 for collision tracks + usePixelQualityFlag = True + ) + +# Ingredient: SiPixelAliSiPixelAliTrackFitter +import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff as fitWithMaterial +SiPixelAliTrackFitter = fitWithMaterial.ctfWithMaterialTracks.clone( + src = 'SiPixelAliTrackerTrackHitFilter', + # TTRHBuilder = 'WithAngleAndTemplate', #should already be default + NavigationSchool = '' + ) + +# End of what we imported + +seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* + offlineBeamSpot* + AlignmentTrackSelector* + SiPixelAliTrackRefitter0* + SiPixelAliTrackerTrackHitFilter* + SiPixelAliTrackFitter) From 6cdbc47a7cefd5daf39fa8fbf8968d946ebe1b84 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 2 Mar 2015 16:13:46 +0100 Subject: [PATCH 005/104] Minor bugfix for creation of TrackRefitter Conflicts: Configuration/StandardSequences/python/AlCaRecoStreams_cff.py --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 14 +++++++------- .../python/AlCaRecoStreams_cff.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index fee33087ac0d4..5fc68f29a5cb6 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -19,7 +19,7 @@ # Ingredient: offlineBeamSpot from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot -# Ingredient: AlignmentTrackSelector +# Ingredient: AlignmentTrackSelector # track selection for alignment from Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi import AlignmentTrackSelector AlignmentTrackSelector.src = 'ALCARECOTkAlMinBias' #'SiPixelAliTrackFitter' #'ALCARECOTkAlCosmicsCTF0T' #TkAlZMuMu' #MinBias' #'generalTracks' ## ALCARECOTkAlMuonIsolated # adjust to input file @@ -36,15 +36,15 @@ AlignmentTrackSelector.minHitsPerSubDet.inPIXEL = 2 -# Ingredient: SiPixelAliTrackRefitter0 +# Ingredient: SiPixelAliTrackRefitter0 # refitting -from RecoTracker.TrackProducer.TrackRefitters_cff import TrackReFitter +from RecoTracker.TrackProducer.TrackRefitters_cff import TrackRefitter # In the following use # TrackRefitter (normal tracks), TrackRefitterP5 (cosmics) or TrackRefitterBHM (beam halo) SiPixelAliTrackRefitter0 = TrackRefitter.clone( - src = 'AlignmentTrackSelector'#'ALCARECOTkAlMinBias'#'ALCARECOTkAlCosmicsCTF0T' #'ALCARECOTkAlMuonIsolated' - NavigationSchool = '' # to avoid filling hit pattern + src = 'AlignmentTrackSelector', #'ALCARECOTkAlMinBias'#'ALCARECOTkAlCosmicsCTF0T' #'ALCARECOTkAlMuonIsolated' + NavigationSchool = '', # to avoid filling hit pattern ) # Alignment producer @@ -175,7 +175,7 @@ process.AlignmentProducer.saveToDB = False -# Ingredient: SiPixelAliTrackerTrackHitFilter +# Ingredient: SiPixelAliTrackerTrackHitFilter import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter # Reference config at /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/aliConfigTemplates/Cosmics38T_BL_default_cfg.py SiPixelAliTrackerTrackHitFilter = HitFilter.TrackerTrackHitFilter.clone( @@ -193,7 +193,7 @@ usePixelQualityFlag = True ) -# Ingredient: SiPixelAliSiPixelAliTrackFitter +# Ingredient: SiPixelAliSiPixelAliTrackFitter import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff as fitWithMaterial SiPixelAliTrackFitter = fitWithMaterial.ctfWithMaterialTracks.clone( src = 'SiPixelAliTrackerTrackHitFilter', diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index 78973587aa297..42ab19ff85eae 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -112,12 +112,13 @@ from Calibration.TkAlCaRecoProducers.ALCARECOSiStripPCLHistos_cff import * from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAli_cff import * + ############################################################### # hotline skim workflows ############################################################### from Calibration.Hotline.hotlineSkims_cff import * -# NOTE: the ALCARECO DQM modules can not be placed together in a single path +# NOTE: the ALCARECO DQM modules can not be placed together in a single path # because the non-DQM sequences act as filters. # They are therefore inserted per ALCARECO path. from DQMOffline.Configuration.AlCaRecoDQM_cff import * From 9e9e8188a6262e489c7bf0d01451c007e0f1a7e6 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Wed, 25 Mar 2015 21:53:14 +0100 Subject: [PATCH 006/104] Bringing ALCARECOPromptCalibProdSiPixelAli_cff.py up to date --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 94 +++++++++---------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 5fc68f29a5cb6..cbb1a9c264efc 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -9,12 +9,9 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") -# So, should all our stuff come here??? -# I mean, all this thing does in the end is define a sequence... -# ... while step2_ALCA_tobe.py defines an entire process. -# The answer is YES - -# Start of what we imported +# Adding geometry here, since this was also added to the process in the +# original alignment_BASE.py that was the configuration template used for mille +from Configuration.Geometry.GeometryIdeal_cff import * # Ingredient: offlineBeamSpot from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot @@ -38,7 +35,7 @@ # Ingredient: SiPixelAliTrackRefitter0 # refitting -from RecoTracker.TrackProducer.TrackRefitters_cff import TrackRefitter +from RecoTracker.TrackProducer.TrackRefitters_cff import * # In the following use # TrackRefitter (normal tracks), TrackRefitterP5 (cosmics) or TrackRefitterBHM (beam halo) @@ -47,21 +44,20 @@ NavigationSchool = '', # to avoid filling hit pattern ) -# Alignment producer -process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff") -#process.AlignmentProducer.parameterTypes = cms.vstring('Selector,RigidBody') -#process.AlignmentProducer.ParameterBuilder.parameterTypes = [ +# Alignment producer (which is a cms.Looper module and hence not added to the sequence) +from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * +#looper.parameterTypes = cms.vstring('Selector,RigidBody') +#looper.ParameterBuilder.parameterTypes = [ # 'SelectorRigid,RigidBody', # 'SelectorBowed,BowedSurface' # ,'Selector2Bowed,TwoBowedSurfaces' # ] -process.AlignmentProducer.ParameterBuilder.Selector = cms.PSet( +looper.ParameterBuilder.Selector = cms.PSet( alignParams = cms.vstring( 'TrackerTPBHalfBarrel,111111', 'TrackerTPEHalfCylinder,111111', # 'TrackerTPBLayer,111111', # 'TrackerTPEHalfDisk,111111', - 'TrackerTIBHalfBarrel,ffffff', # or fff fff? 'TrackerTOBHalfBarrel,ffffff', # dito... 'TrackerTIDEndcap,ffffff', @@ -69,13 +65,12 @@ ) ) -process.AlignmentProducer.doMisalignmentScenario = False #True +looper.doMisalignmentScenario = False #True # If the above is true, you might want to choose the scenario: #from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario - -process.AlignmentProducer.MisalignmentScenario = cms.PSet( +looper.MisalignmentScenario = cms.PSet( setRotations = cms.bool(True), setTranslations = cms.bool(True), seed = cms.int32(1234567), @@ -88,7 +83,6 @@ phiXlocal = cms.double(1.e-4), phiYlocal = cms.double(-2.e-4), phiZlocal = cms.double(5.e-4), - ), TPBHalfBarrel2 = cms.PSet( dXlocal = cms.double(-0.0020), @@ -97,7 +91,6 @@ phiXlocal = cms.double(1.e-3), phiYlocal = cms.double(2.e-4), phiZlocal = cms.double(-2.e-4), - ), TPEEndcap1 = cms.PSet( TPEHalfCylinder1 = cms.PSet( @@ -107,7 +100,7 @@ phiXlocal = cms.double(-1.e-5), phiYlocal = cms.double(2.e-3), phiZlocal = cms.double(2.e-5), - ), + ), TPEHalfCylinder2 = cms.PSet( dXlocal = cms.double(0.0020), dYlocal = cms.double(0.0030), @@ -115,8 +108,8 @@ phiXlocal = cms.double(1.e-4), phiYlocal = cms.double(-1.e-4), phiZlocal = cms.double(2.e-4), + ), ), - ), TPEEndcap2 = cms.PSet( TPEHalfCylinder1 = cms.PSet( dXlocal = cms.double(-0.0080), @@ -125,7 +118,7 @@ phiXlocal = cms.double(1.e-3), phiYlocal = cms.double(-3.e-4), phiZlocal = cms.double(2.e-4), - ), + ), TPEHalfCylinder2 = cms.PSet( dXlocal = cms.double(0.0020), dYlocal = cms.double(0.0030), @@ -133,36 +126,32 @@ phiXlocal = cms.double(-1.e-3), phiYlocal = cms.double(2.e-4), phiZlocal = cms.double(3.e-4), - ), - ) - - + ), + ) ) -process.AlignmentProducer.checkDbAlignmentValidity = False -process.AlignmentProducer.applyDbAlignment = True - - -process.AlignmentProducer.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' +looper.checkDbAlignmentValidity = False +looper.applyDbAlignment = True +looper.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' # assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): -process.AlignmentProducer.algoConfig = process.MillePedeAlignmentAlgorithm +looper.algoConfig = MillePedeAlignmentAlgorithm #from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * -#process.AlignmentProducer.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) -process.AlignmentProducer.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' -#process.AlignmentProducer.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] -#process.AlignmentProducer.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] -process.AlignmentProducer.algoConfig.binaryFile = 'milleBinaryISN.dat' -process.AlignmentProducer.algoConfig.treeFile = 'treeFileISN.root' - -process.AlignmentProducer.algoConfig.TrajectoryFactory = process.BrokenLinesTrajectoryFactory -process.AlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' -#process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' -process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' +#looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) +looper.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' +#looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] +#looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] +looper.algoConfig.binaryFile = 'milleBinaryISN.dat' # BVB: Remove this after it's take care of for the reading +looper.algoConfig.treeFile = 'treeFileISN.root' # BVB: Remove this + +looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory +looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +#looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' +looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' #default is sparseMINRES 6 0.8: n(iter) Delta(F) -process.AlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) -process.AlignmentProducer.algoConfig.pedeSteerer.options = cms.vstring( +looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) +looper.algoConfig.pedeSteerer.options = cms.vstring( #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum 'entries 500', 'chisqcut 30.0 4.5', #, @@ -171,9 +160,9 @@ #'outlierdownweighting 5','dwfractioncut 0.2' ) -process.AlignmentProducer.algoConfig.minNumHits = 8 +looper.algoConfig.minNumHits = 8 -process.AlignmentProducer.saveToDB = False +looper.saveToDB = False # Ingredient: SiPixelAliTrackerTrackHitFilter import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter @@ -201,11 +190,20 @@ NavigationSchool = '' ) -# End of what we imported +# Ingredient: MillePedeFileConverter +from Alignment.CommonAlignmentProducer.MillePedeFileConverter_cfi import millePedeFileConverter +# We configure the input file name of the millePedeFileConverter +# with the output file name of the alignmentProducer (=looper). +# Like this we are sure that they are well connected. +SiPixelAliMillePedeFileConverter = millePedeFileConverter.clone( + fileDir = looper.algoConfig.fileDir, + binaryFile = looper.algoConfig.binaryFile, + ) seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* offlineBeamSpot* AlignmentTrackSelector* SiPixelAliTrackRefitter0* SiPixelAliTrackerTrackHitFilter* - SiPixelAliTrackFitter) + SiPixelAliTrackFitter* + SiPixelAliMillePedeFileConverter) From edf66a4bcd71e08607b7ab7e53b4cb4da76aba43 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Wed, 25 Mar 2015 22:00:03 +0100 Subject: [PATCH 007/104] commenting away the MillePedeFileConverter, since it doesn't exist yet --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index cbb1a9c264efc..71776c339dbbe 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -190,20 +190,20 @@ NavigationSchool = '' ) -# Ingredient: MillePedeFileConverter -from Alignment.CommonAlignmentProducer.MillePedeFileConverter_cfi import millePedeFileConverter -# We configure the input file name of the millePedeFileConverter -# with the output file name of the alignmentProducer (=looper). -# Like this we are sure that they are well connected. -SiPixelAliMillePedeFileConverter = millePedeFileConverter.clone( - fileDir = looper.algoConfig.fileDir, - binaryFile = looper.algoConfig.binaryFile, - ) +### Ingredient: MillePedeFileConverter +##from Alignment.CommonAlignmentProducer.MillePedeFileConverter_cfi import millePedeFileConverter +### We configure the input file name of the millePedeFileConverter +### with the output file name of the alignmentProducer (=looper). +### Like this we are sure that they are well connected. +##SiPixelAliMillePedeFileConverter = millePedeFileConverter.clone( +## fileDir = looper.algoConfig.fileDir, +## binaryFile = looper.algoConfig.binaryFile, +## ) seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* offlineBeamSpot* AlignmentTrackSelector* SiPixelAliTrackRefitter0* SiPixelAliTrackerTrackHitFilter* - SiPixelAliTrackFitter* - SiPixelAliMillePedeFileConverter) + SiPixelAliTrackFitter) + ##SiPixelAliMillePedeFileConverter) From 57117872a180eaafd2c550f049526b1a166fabb5 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 7 May 2015 13:07:27 +0200 Subject: [PATCH 008/104] remove the dependency from IdealGeometry when not running the muon alignment --- .../CommonAlignmentProducer/plugins/AlignmentProducer.cc | 5 +++-- .../python/ALCARECOPromptCalibProdSiPixelAli_cff.py | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc b/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc index beca73476f06b..46bd23d1903f0 100644 --- a/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc @@ -643,8 +643,6 @@ void AlignmentProducer::simpleMisalignment_(const Alignables &alivec, const std: //__________________________________________________________________________________________________ void AlignmentProducer::createGeometries_( const edm::EventSetup& iSetup ) { - edm::ESTransientHandle cpv; - iSetup.get().get( cpv ); if (doTracker_) { edm::ESHandle geometricDet; @@ -656,6 +654,9 @@ void AlignmentProducer::createGeometries_( const edm::EventSetup& iSetup ) } if (doMuon_) { + edm::ESTransientHandle cpv; + iSetup.get().get( cpv ); + edm::ESHandle mdc; iSetup.get().get(mdc); DTGeometryBuilderFromDDD DTGeometryBuilder; diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 71776c339dbbe..288419dac3ff5 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -9,9 +9,8 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") -# Adding geometry here, since this was also added to the process in the -# original alignment_BASE.py that was the configuration template used for mille -from Configuration.Geometry.GeometryIdeal_cff import * + + # Ingredient: offlineBeamSpot from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot From 80f5fc87c87222363e6d47f5120bdcc987760af0 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 21 May 2015 15:26:03 +0200 Subject: [PATCH 009/104] migrate the PEDE step to the Tier0 PCL infrastructure (AlCaHarvesting) --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 217 +++++++++--------- .../python/AlcaSiPixelAliHarvester_cff.py | 140 +++++++++++ .../FileConverterPlaceHolder/BuildFile.xml | 7 + .../fileconverterplaceholder_cfg.py | 20 ++ .../python/fileconverterplaceholder_cfi.py | 4 + .../src/FileConverterPlaceHolder.cc | 156 +++++++++++++ .../python/AlCaHarvesting_cff.py | 22 ++ 7 files changed, 459 insertions(+), 107 deletions(-) create mode 100644 Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py create mode 100644 Alignment/FileConverterPlaceHolder/BuildFile.xml create mode 100644 Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py create mode 100644 Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py create mode 100644 Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 288419dac3ff5..00dee7831b0a0 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -43,125 +43,128 @@ NavigationSchool = '', # to avoid filling hit pattern ) -# Alignment producer (which is a cms.Looper module and hence not added to the sequence) -from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * -#looper.parameterTypes = cms.vstring('Selector,RigidBody') -#looper.ParameterBuilder.parameterTypes = [ -# 'SelectorRigid,RigidBody', -# 'SelectorBowed,BowedSurface' -# ,'Selector2Bowed,TwoBowedSurfaces' -# ] -looper.ParameterBuilder.Selector = cms.PSet( - alignParams = cms.vstring( - 'TrackerTPBHalfBarrel,111111', - 'TrackerTPEHalfCylinder,111111', -# 'TrackerTPBLayer,111111', -# 'TrackerTPEHalfDisk,111111', - 'TrackerTIBHalfBarrel,ffffff', # or fff fff? - 'TrackerTOBHalfBarrel,ffffff', # dito... - 'TrackerTIDEndcap,ffffff', - 'TrackerTECEndcap,ffffff' +#FIXME: manually exclude the looper so that it doesn't interfere with the test of the Harvesting step for the time being. +if(False): + # Alignment producer (which is a cms.Looper module and hence not added to the sequence) + from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * + #looper.parameterTypes = cms.vstring('Selector,RigidBody') + #looper.ParameterBuilder.parameterTypes = [ + # 'SelectorRigid,RigidBody', + # 'SelectorBowed,BowedSurface' + # ,'Selector2Bowed,TwoBowedSurfaces' + # ] + looper.ParameterBuilder.Selector = cms.PSet( + alignParams = cms.vstring( + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', + # 'TrackerTPBLayer,111111', + # 'TrackerTPEHalfDisk,111111', + 'TrackerTIBHalfBarrel,ffffff', # or fff fff? + 'TrackerTOBHalfBarrel,ffffff', # dito... + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' + ) ) - ) -looper.doMisalignmentScenario = False #True - -# If the above is true, you might want to choose the scenario: -#from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario - -looper.MisalignmentScenario = cms.PSet( - setRotations = cms.bool(True), - setTranslations = cms.bool(True), - seed = cms.int32(1234567), - distribution = cms.string('fixed'), # gaussian, uniform (or so...) - setError = cms.bool(True), #GF ??????? - TPBHalfBarrel1 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(-0.0015), - dZlocal = cms.double(0.0100), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-2.e-4), - phiZlocal = cms.double(5.e-4), - ), - TPBHalfBarrel2 = cms.PSet( - dXlocal = cms.double(-0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.020), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(-2.e-4), - ), - TPEEndcap1 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(0.0050), - dYlocal = cms.double(0.0020), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-5), - phiYlocal = cms.double(2.e-3), - phiZlocal = cms.double(2.e-5), - ), - TPEHalfCylinder2 = cms.PSet( + looper.doMisalignmentScenario = False #True + + # If the above is true, you might want to choose the scenario: + #from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario + #FIXME: is the following really needed given the above parameter? + looper.MisalignmentScenario = cms.PSet( + setRotations = cms.bool(True), + setTranslations = cms.bool(True), + seed = cms.int32(1234567), + distribution = cms.string('fixed'), # gaussian, uniform (or so...) + setError = cms.bool(True), #GF ??????? + TPBHalfBarrel1 = cms.PSet( dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.01), + dYlocal = cms.double(-0.0015), + dZlocal = cms.double(0.0100), phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-1.e-4), - phiZlocal = cms.double(2.e-4), + phiYlocal = cms.double(-2.e-4), + phiZlocal = cms.double(5.e-4), ), - ), - TPEEndcap2 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(-0.0080), - dYlocal = cms.double(0.0050), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(-3.e-4), - phiZlocal = cms.double(2.e-4), - ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), + TPBHalfBarrel2 = cms.PSet( + dXlocal = cms.double(-0.0020), dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-3), + dZlocal = cms.double(-0.020), + phiXlocal = cms.double(1.e-3), phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(3.e-4), + phiZlocal = cms.double(-2.e-4), + ), + TPEEndcap1 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(0.0050), + dYlocal = cms.double(0.0020), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-5), + phiYlocal = cms.double(2.e-3), + phiZlocal = cms.double(2.e-5), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.01), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-1.e-4), + phiZlocal = cms.double(2.e-4), + ), ), + TPEEndcap2 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(-0.0080), + dYlocal = cms.double(0.0050), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(-3.e-4), + phiZlocal = cms.double(2.e-4), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(3.e-4), + ), + ) ) - ) -looper.checkDbAlignmentValidity = False -looper.applyDbAlignment = True -looper.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' - -# assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): -looper.algoConfig = MillePedeAlignmentAlgorithm - -#from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * -#looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) -looper.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' -#looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] -#looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] -looper.algoConfig.binaryFile = 'milleBinaryISN.dat' # BVB: Remove this after it's take care of for the reading -looper.algoConfig.treeFile = 'treeFileISN.root' # BVB: Remove this - -looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory -looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' -#looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' -looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' -#default is sparseMINRES 6 0.8: n(iter) Delta(F) -looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) -looper.algoConfig.pedeSteerer.options = cms.vstring( - #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum - 'entries 500', - 'chisqcut 30.0 4.5', #, - 'threads 1 1' #, - #'outlierdownweighting 3','dwfractioncut 0.1' - #'outlierdownweighting 5','dwfractioncut 0.2' - ) + looper.checkDbAlignmentValidity = False + looper.applyDbAlignment = True + looper.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' + + # assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): + looper.algoConfig = MillePedeAlignmentAlgorithm + + #from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * + #looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) + looper.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' + #looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] + #looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] + looper.algoConfig.binaryFile = 'milleBinaryISN.dat' # BVB: Remove this after it's take care of for the reading + looper.algoConfig.treeFile = 'treeFileISN.root' # BVB: Remove this + + looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory + looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' + #looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' + #FIXME: this needs to come from the release + looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' + #default is sparseMINRES 6 0.8: n(iter) Delta(F) + looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) + looper.algoConfig.pedeSteerer.options = cms.vstring( + #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum + 'entries 500', + 'chisqcut 30.0 4.5', #, + 'threads 1 1' #, + #'outlierdownweighting 3','dwfractioncut 0.1' + #'outlierdownweighting 5','dwfractioncut 0.2' + ) -looper.algoConfig.minNumHits = 8 + looper.algoConfig.minNumHits = 8 -looper.saveToDB = False + looper.saveToDB = False # Ingredient: SiPixelAliTrackerTrackHitFilter import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py new file mode 100644 index 0000000000000..6963325b60998 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -0,0 +1,140 @@ +import FWCore.ParameterSet.Config as cms + + + + +# Alignment producer +from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * + +#process.AlignmentProducer.parameterTypes = cms.vstring('Selector,RigidBody') +#process.AlignmentProducer.ParameterBuilder.parameterTypes = [ +# 'SelectorRigid,RigidBody', +# 'SelectorBowed,BowedSurface' +# ,'Selector2Bowed,TwoBowedSurfaces' +# ] +looper.ParameterBuilder.Selector = cms.PSet( + alignParams = cms.vstring( + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', +# 'TrackerTPBLayer,111111', +# 'TrackerTPEHalfDisk,111111', + + 'TrackerTIBHalfBarrel,ffffff', # or fff fff? + 'TrackerTOBHalfBarrel,ffffff', # dito... + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' + ) + ) + +looper.doMisalignmentScenario = False #True + +# If the above is true, you might want to choose the scenario: +#from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario + +#FIXME: is this needed given the above parameters? +looper.MisalignmentScenario = cms.PSet( + setRotations = cms.bool(True), + setTranslations = cms.bool(True), + seed = cms.int32(1234567), + distribution = cms.string('fixed'), # gaussian, uniform (or so...) + setError = cms.bool(True), #GF ??????? + TPBHalfBarrel1 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(-0.0015), + dZlocal = cms.double(0.0100), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-2.e-4), + phiZlocal = cms.double(5.e-4), + + ), + TPBHalfBarrel2 = cms.PSet( + dXlocal = cms.double(-0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.020), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(-2.e-4), + + ), + TPEEndcap1 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(0.0050), + dYlocal = cms.double(0.0020), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-5), + phiYlocal = cms.double(2.e-3), + phiZlocal = cms.double(2.e-5), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.01), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-1.e-4), + phiZlocal = cms.double(2.e-4), + ), + ), + TPEEndcap2 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(-0.0080), + dYlocal = cms.double(0.0050), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(-3.e-4), + phiZlocal = cms.double(2.e-4), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(3.e-4), + ), + ) + + + ) +looper.checkDbAlignmentValidity = False + +looper.applyDbAlignment = True + + +looper.tjTkAssociationMapTag = 'TrackFitter' + +# assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): +looper.algoConfig = MillePedeAlignmentAlgorithm + +#from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * +#looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) +looper.algoConfig.mode = 'pede' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' +#looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] +#looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] +looper.algoConfig.binaryFile = 'milleBinaryISN.dat' +looper.algoConfig.treeFile = 'treeFileISN.root' + + + + +looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory +looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +#looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' +#FIXME: this needs to come from the release +looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' +#default is sparseMINRES 6 0.8: n(iter) Delta(F) +looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) +looper.algoConfig.pedeSteerer.options = cms.vstring( + #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum + 'entries 500', + 'chisqcut 30.0 4.5', #, + 'threads 1 1' #, + #'outlierdownweighting 3','dwfractioncut 0.1' + #'outlierdownweighting 5','dwfractioncut 0.2' + ) + + +looper.algoConfig.minNumHits = 8 + +from Alignment.FileConverterPlaceHolder.fileconverterplaceholder_cfi import * + +ALCAHARVESTSiPixelAli = cms.Sequence(demo) diff --git a/Alignment/FileConverterPlaceHolder/BuildFile.xml b/Alignment/FileConverterPlaceHolder/BuildFile.xml new file mode 100644 index 0000000000000..e18030de98b84 --- /dev/null +++ b/Alignment/FileConverterPlaceHolder/BuildFile.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py b/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py new file mode 100644 index 0000000000000..d13348ce6ebab --- /dev/null +++ b/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py @@ -0,0 +1,20 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("Demo") + +process.load("FWCore.MessageService.MessageLogger_cfi") + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +process.source = cms.Source("PoolSource", + # replace 'myfile.root' with the source file you want to use + fileNames = cms.untracked.vstring( + 'file:myfile.root' + ) +) + +process.demo = cms.EDAnalyzer('FileConverterPlaceHolder' +) + + +process.p = cms.Path(process.demo) diff --git a/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py b/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py new file mode 100644 index 0000000000000..d86c96d6bec77 --- /dev/null +++ b/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +demo = cms.EDAnalyzer('FileConverterPlaceHolder' +) diff --git a/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc b/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc new file mode 100644 index 0000000000000..2730fbe44a7e1 --- /dev/null +++ b/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc @@ -0,0 +1,156 @@ +// -*- C++ -*- +// +// Package: FileConverterPlaceHolder +// Class: FileConverterPlaceHolder +// +/**\class FileConverterPlaceHolder FileConverterPlaceHolder.cc Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Gianluca Cerminara,40 5-A19,+41227679568, +// Created: Thu May 21 14:37:48 CEST 2015 +// $Id$ +// +// + + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +// +// class declaration +// + +class FileConverterPlaceHolder : public edm::EDAnalyzer { + public: + explicit FileConverterPlaceHolder(const edm::ParameterSet&); + ~FileConverterPlaceHolder(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&); + virtual void endRun(edm::Run const&, edm::EventSetup const&); + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + + // ----------member data --------------------------- +}; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +FileConverterPlaceHolder::FileConverterPlaceHolder(const edm::ParameterSet& iConfig) + +{ + //now do what ever initialization is needed + +} + + +FileConverterPlaceHolder::~FileConverterPlaceHolder() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void +FileConverterPlaceHolder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + + +#ifdef THIS_IS_AN_EVENT_EXAMPLE + Handle pIn; + iEvent.getByLabel("example",pIn); +#endif + +#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE + ESHandle pSetup; + iSetup.get().get(pSetup); +#endif +} + + +// ------------ method called once each job just before starting event loop ------------ +void +FileConverterPlaceHolder::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +FileConverterPlaceHolder::endJob() +{ +} + +// ------------ method called when starting to processes a run ------------ +void +FileConverterPlaceHolder::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a run ------------ +void +FileConverterPlaceHolder::endRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when starting to processes a luminosity block ------------ +void +FileConverterPlaceHolder::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a luminosity block ------------ +void +FileConverterPlaceHolder::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +FileConverterPlaceHolder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(FileConverterPlaceHolder); diff --git a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py index b23760c1beeab..e1db573d3d080 100644 --- a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py +++ b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py @@ -4,6 +4,7 @@ from Calibration.TkAlCaRecoProducers.AlcaBeamSpotHarvester_cff import * from Calibration.TkAlCaRecoProducers.AlcaSiStripQualityHarvester_cff import * from Calibration.TkAlCaRecoProducers.AlcaSiStripGainsHarvester_cff import * +from Alignment.CommonAlignmentProducer.AlcaSiPixelAliHarvester_cff import * from Calibration.TkAlCaRecoProducers.PCLMetadataWriter_cfi import * @@ -71,6 +72,24 @@ tag = cms.string('SiStripApvGain_pcl'), timetype = cms.untracked.string('runnumber')) + # +ALCAHARVESTSiPixelAli_metadata = cms.PSet(record = cms.untracked.string('TrackerAlignmentRcd'), +# destDB = cms.untracked.string("oracle://cms_orcon_prod/CMS_COND_31X_STRIP"), +# destDBValidation = cms.untracked.string("oracle://cms_orcoff_prep/CMS_COND_STRIP"), +# tag = cms.untracked.string("SiStripBadChannel_PCL_v0_offline"), +# Timetype = cms.untracked.string("runnumber"), +# IOVCheck = cms.untracked.string("All"), +# DuplicateTagHLT = cms.untracked.string("SiStripBadChannel_PCL_v0_hlt"), +# DuplicateTagEXPRESS = cms.untracked.string(""), +# DuplicateTagPROMPT = cms.untracked.string("SiStripBadChannel_PCL_v0_prompt"), + ) + + +ALCAHARVESTSiPixelAli_dbOutput = cms.PSet(record = cms.string('TrackerAlignmentRcd'), + tag = cms.string('SiPixelAli_pcl'), + timetype = cms.untracked.string('runnumber')) + + # define the paths @@ -79,6 +98,9 @@ BeamSpotByLumi = cms.Path(ALCAHARVESTBeamSpotByLumi) SiStripQuality = cms.Path(ALCAHARVESTSiStripQuality) SiStripGains = cms.Path(ALCAHARVESTSiStripGains) +SiPixelAli = cms.Path(ALCAHARVESTSiPixelAli) + + ALCAHARVESTDQMSaveAndMetadataWriter = cms.Path(dqmSaver+pclMetadataWriter) #promptCalibHarvest = cms.Path(alcaBeamSpotHarvester) From 92abe5f7d059dc4eb796152ef4593d25a849a9c1 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Fri, 22 May 2015 09:54:48 +0200 Subject: [PATCH 010/104] implemented new AlignmentProducer running on PCL * created in CMSSW_7_4_0_pre6 * aligns only tracker * AP is no longer an ESProducer but an EDAnalyzer * runs only with MillePede at the moment * uses EventSetup from first event for init-routines --- .gitignore | 2 + .../interface/AlignmentAlgorithmBase.h | 1 + .../plugins/BuildFile.xml | 12 + .../plugins/TrackerAlignmentProducerForPCL.cc | 875 ++++++++++++++++++ .../plugins/TrackerAlignmentProducerForPCL.h | 154 +++ .../TrackerAlignmentProducerForPCL_cff.py | 78 ++ .../interface/MillePedeAlignmentAlgorithm.h | 1 + .../src/MillePedeAlignmentAlgorithm.cc | 6 +- 8 files changed, 1127 insertions(+), 2 deletions(-) create mode 100644 Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc create mode 100644 Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h create mode 100644 Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py diff --git a/.gitignore b/.gitignore index 82c501e6c418d..49e885a4fbf29 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ __init__.py .#* #*# *~ +.project +.cproject diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index a5a98a14746f4..d937a4b5e28be 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -106,6 +106,7 @@ class AlignmentAlgorithmBase /// Call at end of each loop (must be implemented in derived class) virtual void terminate(const edm::EventSetup& iSetup) = 0; + virtual void terminate() {} /// Run the algorithm (must be implemented in derived class) virtual void run( const edm::EventSetup &setup, const EventInfo &eventInfo) = 0; diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index df2e871fe3c0c..3cef465cc4a55 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -19,6 +19,18 @@ + + + + + + + + + + + + diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc new file mode 100644 index 0000000000000..ac593e3d1752d --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc @@ -0,0 +1,875 @@ +#include "TrackerAlignmentProducerForPCL.h" + +//#include "FWCore/Framework/interface/LooperFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" +#include "Alignment/CommonAlignment/interface/Alignable.h" + +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" + +// System include files +#include +#include + +// Framework +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "FWCore/Utilities/interface/Parse.h" + +// Conditions database +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +// Geometry +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" +#include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h" +#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" +#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" + +// Tracking, LAS and cluster flag map (fwd is enough!) +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" +#include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" +#include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" + +// Alignment +#include "CondFormats/Alignment/interface/SurveyErrors.h" +#include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h" +#include "Alignment/CommonAlignment/interface/SurveyDet.h" +#include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h" +#include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmPluginFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationPluginFactory.h" +#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" + +TrackerAlignmentProducerForPCL::TrackerAlignmentProducerForPCL(const edm::ParameterSet &config) : + theAlignmentAlgo(0), //theAlignmentAlgo(std::nullptr_t), + theAlignmentParameterStore(0), //theAlignmentParameterStore(std::nullptr_t), + theParameterSet(config), + theAlignableExtras(0), + theAlignableTracker(0), + // theTracker + globalPositions(0), + nevent_(0), + doTracker_(true), + + stNFixAlignables_ (config.getParameter("nFixAlignables")), + stRandomShift_ (config.getParameter("randomShift")), + stRandomRotation_ (config.getParameter("randomRotation")), + doMisalignmentScenario_ (config.getParameter("doMisalignmentScenario")), + saveToDB (config.getParameter("saveToDB")), + saveApeToDB (config.getParameter("saveApeToDB")), + saveDeformationsToDB (config.getParameter("saveDeformationsToDB")), + + applyDbAlignment_ (config.getUntrackedParameter("applyDbAlignment")), + checkDbAlignmentValidity_(config.getUntrackedParameter("checkDbAlignmentValidity")), + useExtras_ (config.getUntrackedParameter("useExtras")), + useSurvey_ (config.getParameter("useSurvey")), + + tjTkAssociationMapTag_ (config.getParameter("tjTkAssociationMapTag")), + beamSpotTag_ (config.getParameter("beamSpotTag")), + tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), + clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { + + // ESProducer method ? + //setWhatProduced(this, &AlignmentProducer::produceTracker); + //std::cout << "TrackerAlignmentProducerForPCL::constructor " <("algoConfig"); + edm::VParameterSet iovSelection = config.getParameter("RunRangeSelection"); + algoConfig.addUntrackedParameter("RunRangeSelection", iovSelection); + + std::string algoName = algoConfig.getParameter("algoName"); + theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig); + + if (!theAlignmentAlgo) { + throw cms::Exception("BadConfig") << "Couldn't find the called alignment algorithm" << algoName; + } + + // Finally create integrated calibrations: + edm::VParameterSet calibrations = config.getParameter("calibrations"); + for (auto iCalib = calibrations.begin(); iCalib != calibrations.end(); ++iCalib) { + theCalibrations.push_back(IntegratedCalibrationPluginFactory::get()->create( + iCalib->getParameter("calibrationName"), *iCalib) + ); + } +} + +TrackerAlignmentProducerForPCL::~TrackerAlignmentProducerForPCL() { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + delete theAlignmentAlgo; + + // delete integrated calibration pointed to by (*iCal) + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + delete *iCal; + } + + delete theAlignmentParameterStore; + delete theAlignableExtras; + delete theAlignableTracker; + delete globalPositions; +} + + + +/************************************ + * PUBLIC METHOD IMPLEMENTATION * + ************************************/ + +void TrackerAlignmentProducerForPCL::beginJob() { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called UNUSED \n", __FUNCTION__, __FILE__); + // -> init(); +} + +void TrackerAlignmentProducerForPCL::endJob() { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + finish(); +} + +void TrackerAlignmentProducerForPCL::analyze(const edm::Event& event, + const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze"; + //std::cout << "TrackerAlignmentProducerForPCL::analyze " < merely skip if collection is empty + edm::Handle m_TrajTracksMap; + + // TODO: getByLabel -> getByToken + //if (event.getByToken()) + if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) { + // Form pairs of trajectories and tracks + ConstTrajTrackPairCollection trajTracks; + for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin(); + iPair != m_TrajTracksMap->end(); ++iPair) { + trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) ); + } + + // TODO: This should be in the constructor / beginJob method + edm::Handle theBeamSpot; + event.getByLabel(beamSpotTag_, theBeamSpot); + if (theAlignableExtras) { + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze" + << "initializing AlignableBeamSpot"; + theAlignableExtras->initializeBeamSpot(theBeamSpot->x0(), theBeamSpot->y0(), theBeamSpot->z0(), + theBeamSpot->dxdz(), theBeamSpot->dydz()); + } + + // Run the alignment algorithm with its input + const AliClusterValueMap* clusterValueMapPtr = 0; + //check that the input tag is not empty + if (clusterValueMapTag_.encode().size()) { + edm::Handle clusterValueMap; + event.getByLabel(clusterValueMapTag_, clusterValueMap); + clusterValueMapPtr = &(*clusterValueMap); + } + + const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *theBeamSpot, + clusterValueMapPtr); + theAlignmentAlgo->run(setup, eventInfo); + + } else { + edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze" + << "No track collection found: skipping event"; + } +} + +void TrackerAlignmentProducerForPCL::beginRun(const edm::Run& run, const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + theAlignmentAlgo->beginRun(setup); +} + +void TrackerAlignmentProducerForPCL::endRun(const edm::Run& run, const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + // call with or without las beam info... + typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo; + // if non-empty InputTag + if (tkLasBeamTag_.encode().size()) { + edm::Handle lasBeams; + edm::Handle tsoses; + run.getByLabel(tkLasBeamTag_, lasBeams); + run.getByLabel(tkLasBeamTag_, tsoses); + + theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup); + + } else { + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endRun" + << "No Tk LAS beams to forward to algorithm."; + theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); + } +} + +void TrackerAlignmentProducerForPCL::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, + const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock +} + +void TrackerAlignmentProducerForPCL::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, + const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock +} + + + +/************************************* + * PRIVATE METHOD IMPLEMENTATION * + *************************************/ + +void TrackerAlignmentProducerForPCL::init(const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init"; + + + + /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ + + //Retrieve tracker topology from geometry + edm::ESHandle tTopoHandle; + setup.get().get(tTopoHandle); + const TrackerTopology* const tTopo = tTopoHandle.product(); + + // Create the geometries from the ideal geometries (first time only) + createGeometries(setup); + + // Retrieve and apply alignments, if requested (requires DB setup) + if (applyDbAlignment_) { + // we need GlobalPositionRcd - and have to keep track for later removal + // before writing again to DB... + edm::ESHandle globalPositionRcd; + setup.get().get(globalPositionRcd); + globalPositions = new Alignments(*globalPositionRcd); + + applyDB( + &(*theTracker), + setup, + align::DetectorGlobalPosition(*globalPositions, DetId(DetId::Tracker)) + ); + + applyDB( + &(*theTracker), + setup + ); + } + + // Create alignable tracker + theAlignableTracker = new AlignableTracker(&(*theTracker), tTopo); + + if (useExtras_) { + theAlignableExtras = new AlignableExtras(); + } + + // Create alignment parameter builder + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init" + << "Creating AlignmentParameterBuilder"; + + edm::ParameterSet aliParamBuildCfg = + theParameterSet.getParameter("ParameterBuilder"); + AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker, + theAlignableExtras, + aliParamBuildCfg ); + + // Fix alignables if requested + if (stNFixAlignables_ > 0) { + alignmentParameterBuilder.fixAlignables(stNFixAlignables_); + } + + // Get list of alignables + Alignables theAlignables = alignmentParameterBuilder.alignables(); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" + << "got " << theAlignables.size() << " alignables"; + + // Create AlignmentParameterStore + edm::ParameterSet aliParamStoreCfg = theParameterSet.getParameter("ParameterStore"); + theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" + << "AlignmentParameterStore created!"; + + // Apply misalignment scenario to alignable tracker and muon if requested + // WARNING: this assumes scenarioConfig can be passed to both muon and tracker + if (doMisalignmentScenario_ && doTracker_) { + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" + << "Applying misalignment scenario to " + << (doTracker_ ? "tracker" : ""); + edm::ParameterSet scenarioConfig = theParameterSet.getParameter( "MisalignmentScenario" ); + + TrackerScenarioBuilder scenarioBuilder(theAlignableTracker); + scenarioBuilder.applyScenario(scenarioConfig); + + } else { + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" + << "NOT applying misalignment scenario!"; + } + + // Apply simple misalignment + const std::string sParSel(theParameterSet.getParameter("parameterSelectorSimple")); + simpleMisalignment(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); + + // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm + theAlignmentAlgo->initialize(setup, + theAlignableTracker, + 0, // theAlignableMuon, + theAlignableExtras, + theAlignmentParameterStore); + + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->beginOfJob(theAlignableTracker, 0, theAlignableExtras); + } + + // Not all algorithms support calibrations - so do not pass empty vector + // and throw if non-empty and not supported: + if (!theCalibrations.empty() && !theAlignmentAlgo->addCalibrations(theCalibrations)) { + throw cms::Exception("BadConfig") << "[TrackerAlignmentProducerForPCL::init]\n" + << "Configured " << theCalibrations.size() << " calibration(s) " + << "for algorithm not supporting it."; + } + + + + + /* 1) Former: AlignmentProducer::startingNewLoop(unsigned int iLoop) */ + + nevent_ = 0; + + theAlignmentAlgo->startNewLoop(); + // FIXME: Should this be done in algorithm::startNewLoop()?? + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->startNewLoop(); + } + + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init" + << "Now physically apply alignments to geometry..."; + + // Propagate changes to reconstruction geometry (from initialisation or iteration) + GeometryAligner aligner; + + std::auto_ptr alignments (theAlignableTracker->alignments()); + std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); + std::auto_ptr aliDeforms (theAlignableTracker->surfaceDeformations()); + + aligner.applyAlignments (&(*theTracker), &(*alignments), &(*alignmentErrors), AlignTransform() ); // don't apply global a second time! + aligner.attachSurfaceDeformations(&(*theTracker), &(*aliDeforms)); +} + +void TrackerAlignmentProducerForPCL::finish() { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish"; + + /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ + if (0 == nevent_) { + // beginOfJob is usually called by the framework in the first event of the first loop + // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) + // and the algorithms rely on the initialisations done in beginOfJob. We cannot call + // this->beginOfJob(iSetup); here either since that will access the EventSetup to get + // some geometry information that is not defined either without having seen an event. + edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" + << "Did not process any events, " + << "stop processing without terminating algorithm."; + return; + } + + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" + << "Terminating algorithm."; + + // TODO: Apparently, MP does not use the EventSetup parameter + theAlignmentAlgo->terminate(); + + // FIXME: Should this be done in algorithm::terminate(const edm::EventSetup& iSetup)?? + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->endOfLoop(); + } + + + + + + /* 2) Former: void AlignmentProducer::endOfJob() */ + + if (0 == nevent_) { + edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" << "Did not process any " + << "events in last loop, do not dare to store to DB."; + } else { + // Expand run ranges and make them unique + edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); + RunRanges uniqueRunRanges(makeNonOverlappingRunRanges(runRangeSelectionVPSet)); + + // create dummy IOV + if (uniqueRunRanges.empty()) { + const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue, + cond::timeTypeSpecs[cond::runnumber].endValue); + uniqueRunRanges.push_back(runRange); + } + + std::vector beamSpotParameters; + + for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange) { + + theAlignmentAlgo->setParametersForRunRange(*iRunRange); + + // Save alignments to database + if (saveToDB || saveApeToDB || saveDeformationsToDB) { + writeForRunRange((*iRunRange).first); + } + + // Deal with extra alignables, e.g. beam spot + if (theAlignableExtras) { + Alignables &alis = theAlignableExtras->beamSpot(); + if (!alis.empty()) { + BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast(alis[0]->alignmentParameters()); + beamSpotParameters.push_back(beamSpotAliPars->parameters()); + } + } + } + + if (theAlignableExtras) { + std::ostringstream bsOutput; + + std::vector::const_iterator itPar = beamSpotParameters.begin(); + for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange, ++itPar) { + bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n"; + bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; + bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; + } + + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" + << "Parameters for alignable beamspot:\n" + << bsOutput.str(); + } + + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->endOfJob(); + } + } +} + +void TrackerAlignmentProducerForPCL::createGeometries(const edm::EventSetup& setup) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + //edm::ESTransientHandle cpv; + //iSetup.get().get(cpv); + + edm::ESHandle geometricDet; + setup.get().get(geometricDet); + TrackerGeomBuilderFromGeometricDet trackerBuilder; + + theTracker = boost::shared_ptr(trackerBuilder.build(&(*geometricDet), theParameterSet)); +} + +void TrackerAlignmentProducerForPCL::simpleMisalignment(const Alignables& alivec, const std::string& selection, + float shift, float rot, bool local) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + std::ostringstream output; // collecting output + + if (shift > 0. || rot > 0.) { + output << "Adding random flat shift of max size " << shift + << " and adding random flat rotation of max size " << rot <<" to "; + + std::vector commSel(0); + if (selection != "-1") { + AlignmentParameterSelector aSelector(0,0); // no alignable needed here... + const std::vector cSel(aSelector.convertParamSel(selection)); + + if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) { + throw cms::Exception("BadConfig") + << "[AlignmentProducer::simpleMisalignment_]\n" + << "Expect selection string '" << selection << "' to be at least of length " + << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" + << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; + } + + for (std::vector::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) { + commSel.push_back(*cIter == '0' ? false : true); + } + + output << "parameters defined by (" << selection + << "), representing (x,y,z,alpha,beta,gamma),"; + + } else { + output << "the active parameters of each alignable,"; + } + output << " in " << (local ? "local" : "global") << " frame."; + + for (std::vector::const_iterator it = alivec.begin(); it != alivec.end(); ++it) { + Alignable* ali = (*it); + std::vector mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel); + + if (std::abs(shift) > 0.00001) { + double s0 = 0., s1 = 0., s2 = 0.; + if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.; + + if (local) { + ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) ); + } else { + ali->move( align::GlobalVector(s0,s1,s2) ); + } + } + + if (std::abs(rot)>0.00001) { + align::EulerAngles r(3); + if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dbeta] ) r(2)=rot*double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.; + + const align::RotationType mrot = align::toMatrix(r); + if (local) ali->rotateInLocalFrame(mrot); + else ali->rotateInGlobalFrame(mrot); + } + } // end loop on alignables + + } else { + output << "No simple misalignment added!"; + } + + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::simpleMisalignment" << output.str(); +} + +////////////////////////////////////////////////// +// a templated method - but private, so not accessible from outside +// ==> does not have to be in header file +template +void TrackerAlignmentProducerForPCL::applyDB(G* geometry, const edm::EventSetup& setup, + const AlignTransform& globalCoordinates) const { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + // 'G' is the geometry class for that DB should be applied, + // 'Rcd' is the record class for its Alignments + // 'ErrRcd' is the record class for its AlignmentErrors + // 'globalCoordinates' are global transformation for this geometry + + const Rcd & record = setup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval& validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); + + if (first != edm::IOVSyncValue::beginOfTime() || + last != edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=AlignmentProducer::applyDB" + << "\nTrying to apply " + << record.key().name() + << " with multiple IOVs in tag.\n" + << "Validity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } + + edm::ESHandle alignments; + record.get(alignments); + + edm::ESHandle alignmentErrors; + setup.get().get(alignmentErrors); + + GeometryAligner aligner; + aligner.applyAlignments(geometry, &(*alignments), &(*alignmentErrors), + globalCoordinates); +} + +////////////////////////////////////////////////// +// a templated method - but private, so not accessible from outside +// ==> does not have to be in header file +template +void TrackerAlignmentProducerForPCL::applyDB(G* geometry, const edm::EventSetup& setup) const { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + // 'G' is the geometry class for that DB should be applied, + // 'DeformationRcd' is the record class for its surface deformations + + const DeformationRcd & record = setup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval & validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); + + if (first != edm::IOVSyncValue::beginOfTime() || + last != edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=AlignmentProducer::applyDB" + << "\nTrying to apply " + << record.key().name() + << " with multiple IOVs in tag.\n" + << "Validity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } + + edm::ESHandle surfaceDeformations; + record.get(surfaceDeformations); + + GeometryAligner aligner; + aligner.attachSurfaceDeformations(geometry, &(*surfaceDeformations)); +} + +void TrackerAlignmentProducerForPCL::writeForRunRange(cond::Time_t time) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + // will be 'removed' from constants + const AlignTransform* trackerGlobal = 0; + + // i.e. applied before in applyDB + if (globalPositions) { + trackerGlobal = &align::DetectorGlobalPosition(*globalPositions, + DetId(DetId::Tracker)); + } + + Alignments* alignments = theAlignableTracker->alignments(); + AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors(); + + writeDB(alignments, "TrackerAlignmentRcd", + alignmentErrors, "TrackerAlignmentErrorRcd", + trackerGlobal, time); + + + // Save surface deformations to database + if (saveDeformationsToDB) { + AlignmentSurfaceDeformations* alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations(); + writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time); + } +} + +void TrackerAlignmentProducerForPCL::writeDB(Alignments* alignments, + const std::string& alignRcd, + AlignmentErrors* alignmentErrors, + const std::string& errRcd, + const AlignTransform* globalCoordinates, + cond::Time_t time) const { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + Alignments* tempAlignments = alignments; + AlignmentErrors* tempAlignmentErrors = alignmentErrors; + + // Call service + edm::Service poolDb; + // Die if not available + if (!poolDb.isAvailable()) { + // promised to take over ownership... + delete tempAlignments; + delete tempAlignmentErrors; // dito + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; + } + + if (globalCoordinates && // happens only if (applyDbAlignment_ == true) + globalCoordinates->transform() != AlignTransform::Transform::Identity) { + + tempAlignments = new Alignments(); // temporary storage for + tempAlignmentErrors = new AlignmentErrors(); // final alignments and errors + + GeometryAligner aligner; + aligner.removeGlobalTransform(alignments, alignmentErrors, + *globalCoordinates, + tempAlignments, tempAlignmentErrors); + + delete alignments; // have to delete original alignments + delete alignmentErrors; // same thing for the errors + + edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::writeDB" + << "globalCoordinates removed from alignments (" << alignRcd + << ") and errors (" << alignRcd << ")."; + } + + if (saveToDB) { + edm::LogInfo("Alignment") << "Writing Alignments for run " << time + << " to " << alignRcd << "."; + poolDb->writeOne(tempAlignments, time, alignRcd); + + } else { + // poolDb->writeOne(..) takes over 'alignments' ownership,... + delete tempAlignments; // ...otherwise we have to delete, as promised! + } + + if (saveApeToDB) { + edm::LogInfo("Alignment") << "Writing AlignmentErrors for run " << time + << " to " << errRcd << "."; + poolDb->writeOne(tempAlignmentErrors, time, errRcd); + + } else { + // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,... + delete tempAlignmentErrors; // ...otherwise we have to delete, as promised! + } +} + +void TrackerAlignmentProducerForPCL::writeDB(AlignmentSurfaceDeformations* alignmentSurfaceDeformations, + const std::string& surfaceDeformationRcd, + cond::Time_t time) const { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + // Call service + edm::Service poolDb; + // Die if not available + if (!poolDb.isAvailable()) { + delete alignmentSurfaceDeformations; // promised to take over ownership... + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; + } + + if (saveDeformationsToDB) { + edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time + << " to " << surfaceDeformationRcd << "."; + poolDb->writeOne(alignmentSurfaceDeformations, time, + surfaceDeformationRcd); + } else { + // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,... + delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised! + } +} + +TrackerAlignmentProducerForPCL::RunRanges TrackerAlignmentProducerForPCL::makeNonOverlappingRunRanges( + const edm::VParameterSet& RunRangeSelectionVPSet) { + printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); + + static bool oldRunRangeSelectionWarning = false; + + const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue; + const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue; + + RunRanges uniqueRunRanges; + if (!RunRangeSelectionVPSet.empty()) { + + std::map uniqueFirstRunNumbers; + + for (std::vector::const_iterator ipset = RunRangeSelectionVPSet.begin(); + ipset != RunRangeSelectionVPSet.end(); ++ipset) { + const std::vector RunRangeStrings = (*ipset).getParameter >("RunRanges"); + + for (std::vector::const_iterator irange = RunRangeStrings.begin(); + irange != RunRangeStrings.end(); ++irange) { + + if ((*irange).find(':') == std::string::npos) { + RunNumber first = beginValue; + long int temp = strtol((*irange).c_str(), 0, 0); + if (temp != -1) first = temp; + uniqueFirstRunNumbers[first] = first; + + } else { + if (!oldRunRangeSelectionWarning) { + edm::LogWarning("BadConfig") << "@SUB=AlignmentProducer::makeNonOverlappingRunRanges" + << "Config file contains old format for 'RunRangeSelection'. Only the start run\n" + << "number is used internally. The number of the last run is ignored and can be\n" + << "safely removed from the config file.\n"; + oldRunRangeSelectionWarning = true; + } + + std::vector tokens = edm::tokenize(*irange, ":"); + long int temp; + RunNumber first = beginValue; + temp = strtol(tokens[0].c_str(), 0, 0); + if (temp != -1) first = temp; + uniqueFirstRunNumbers[first] = first; + } + } + } + + for (std::map::iterator iFirst = uniqueFirstRunNumbers.begin(); + iFirst!=uniqueFirstRunNumbers.end(); ++iFirst) { + uniqueRunRanges.push_back(std::pair((*iFirst).first, endValue)); + } + + for (unsigned int i = 0; i < uniqueRunRanges.size()-1; ++i) { + uniqueRunRanges[i].second = uniqueRunRanges[i+1].first - 1; + } + + } else { + uniqueRunRanges.push_back(std::pair(beginValue, endValue)); + } + + return uniqueRunRanges; +} + + + +void TrackerAlignmentProducerForPCL::addSurveyInfo(Alignable* ali) { + const std::vector& comp = ali->components(); + for (unsigned int i = 0; i < comp.size(); ++i) { + addSurveyInfo(comp[i]); + } + + const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; + + if (ali->id() != error.rawId() || + ali->alignableObjectId() != error.structureType()) { + throw cms::Exception("DatabaseError") << "Error reading survey info from DB. " + "Mismatched id!"; + } + + const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); + const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); + + AlignableSurface surf(align::PositionType(pos.x(), pos.y(), pos.z()), + align::RotationType(rot.xx(), rot.xy(), rot.xz(), + rot.yx(), rot.yy(), rot.yz(), + rot.zx(), rot.zy(), rot.zz() ) ); + surf.setWidth (ali->surface().width()); + surf.setLength(ali->surface().length()); + + ali->setSurvey(new SurveyDet(surf, error.matrix())); + + ++theSurveyIndex; +} + +void TrackerAlignmentProducerForPCL::readInSurveyRcds(const edm::EventSetup& setup) { + if (useSurvey_) { + bool tkSurveyBool = watchTkSurveyRcd_.check(setup); + bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(setup); + edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool; + edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool; + + if (tkSurveyBool || tkSurveyErrBool) { + edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION"; + edm::ESHandle surveys; + edm::ESHandle surveyErrors; + + setup.get().get(surveys); + setup.get().get(surveyErrors); + + theSurveyIndex = 0; + theSurveyValues = &*surveys; + theSurveyErrors = &*surveyErrors; + + addSurveyInfo(theAlignableTracker); + } + } +} + +// define this as a plugin +DEFINE_FWK_MODULE(TrackerAlignmentProducerForPCL); diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h new file mode 100644 index 0000000000000..37b421906500f --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h @@ -0,0 +1,154 @@ +#ifndef ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ +#define ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ + +#include + +// Framework +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "DataFormats/Provenance/interface/RunID.h" + +// Geometry +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" + +// Alignment +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" +#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Alignment/CommonAlignment/interface/AlignableExtras.h" +#include "Alignment/TrackerAlignment/interface/AlignableTracker.h" + +#include +#include "CondCore/DBCommon/interface/Time.h" +#include "CondFormats/Alignment/interface/Alignments.h" +#include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" + +// for watcher +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h" + + +class Alignments; +class IntegratedCalibrationBase; +class SurveyErrors; +namespace edm { + class Run; + class LuminosityBlock; +} + +class TrackerAlignmentProducerForPCL : public edm::EDAnalyzer { + public: + + TrackerAlignmentProducerForPCL(const edm::ParameterSet&); + virtual ~TrackerAlignmentProducerForPCL(); + + typedef std::pair ConstTrajTrackPair; + typedef std::vector ConstTrajTrackPairCollection; + typedef std::vector Alignables; + + typedef AlignmentAlgorithmBase::RunNumber RunNumber; + typedef AlignmentAlgorithmBase::RunRange RunRange; + typedef std::vector RunRanges; + + + virtual void beginJob(void) override; + virtual void endJob (void) override; + + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void beginRun(const edm::Run&, const edm::EventSetup&) override; + virtual void endRun (const edm::Run&, const edm::EventSetup&) override; + + virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override; + virtual void endLuminosityBlock (const edm::LuminosityBlock&, const edm::EventSetup&) override; + + private: + + void init(const edm::EventSetup&); + void finish(); + + void createGeometries (const edm::EventSetup&); + void simpleMisalignment(const Alignables&, const std::string&, float, float, bool); + + /// Apply DB constants belonging to (Err)Rcd to geometry, + /// taking into account 'globalPosition' correction. + template + void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const; + /// Apply DB constants for surface deformations + template + void applyDB(G*, const edm::EventSetup&) const; + + // write alignments and alignment errors for all sub detectors and + // the given run number + void writeForRunRange(cond::Time_t); + + /// Write alignment and/or errors to DB for record names + /// (removes *globalCoordinates before writing if non-null...). + /// Takes over ownership of alignments and alignmentErrrors. + void writeDB(Alignments*, const std::string&, AlignmentErrors*, + const std::string&, const AlignTransform*, cond::Time_t) const; + /// Write surface deformations (bows & kinks) to DB for given record name + /// Takes over ownership of alignmentsurfaceDeformations. + void writeDB(AlignmentSurfaceDeformations*, const std::string&, cond::Time_t) const; + + RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet&); + + + /// Add survey info to an alignable + void addSurveyInfo(Alignable*); + /// read in survey records + void readInSurveyRcds(const edm::EventSetup&); + + unsigned int theSurveyIndex; + const Alignments* theSurveyValues; + const SurveyErrors* theSurveyErrors; + + + // std::unique_ptr theAlignmentAlgo; + // std::unique_ptr theAlignmentParameterStore; + //std::vector> theCalibrations; + + AlignmentAlgorithmBase* theAlignmentAlgo; + AlignmentParameterStore* theAlignmentParameterStore; + std::vector theCalibrations; + + edm::ParameterSet theParameterSet; + AlignableExtras* theAlignableExtras; + AlignableTracker* theAlignableTracker; + + //std::shared_ptr theTracker; + boost::shared_ptr theTracker; + + Alignments* globalPositions; + + int nevent_; + const bool doTracker_; + + const int stNFixAlignables_; + const double stRandomShift_; + const double stRandomRotation_; + + const bool doMisalignmentScenario_; + const bool saveToDB; + const bool saveApeToDB; + const bool saveDeformationsToDB; + const bool applyDbAlignment_; + const bool checkDbAlignmentValidity_; + const bool useExtras_; + const bool useSurvey_; + + const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories + const edm::InputTag beamSpotTag_; // beam spot + const edm::InputTag tkLasBeamTag_; // LAS beams in edm::Run (ignore if empty) + const edm::InputTag clusterValueMapTag_; // ValueMap containing associtaion cluster-flag + + + + edm::ESWatcher watchTkSurveyRcd_; + edm::ESWatcher watchTkSurveyErrRcd_; +}; + +#endif /* ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ */ diff --git a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py new file mode 100644 index 0000000000000..923e1998d30a7 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py @@ -0,0 +1,78 @@ +import FWCore.ParameterSet.Config as cms +import Geometry.TrackerGeometryBuilder.trackerGeometryConstants_cfi as trackerGeometryConstants_cfi + +# misalignment scenarios +from Alignment.TrackerAlignment.Scenarios_cff import * + +# algorithms +from Alignment.HIPAlignmentAlgorithm.HIPAlignmentAlgorithm_cfi import * +from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * +from Alignment.KalmanAlignmentAlgorithm.KalmanAlignmentAlgorithm_cfi import * +# parameters +from Alignment.CommonAlignmentAlgorithm.AlignmentParameterStore_cfi import * + +#looper = cms.Looper("AlignmentProducer", +AlignmentProducer = cms.EDAnalyzer("TrackerAlignmentProducerForPCL", + AlignmentParameterStore, # configuration of AlignmentParameterStore + useExtras = cms.untracked.bool(False), + # Read survey info from DB: true requires configuration of PoolDBESSource + # See Alignment/SurveyAnalysis/test/readDB.cfg for an example + useSurvey = cms.bool(False), + + # (Mis-)alignment including surface deformations from database + # true requires configuration of PoolDBESSource + applyDbAlignment = cms.untracked.bool(False), + + # Checks the IOV of the alignment to be applied. Only has an effect + # if applyDbAlignment is True as well. If set to True, the alignment + # record to be applied is expected to have a validity from 1 to INF + checkDbAlignmentValidity = cms.untracked.bool(True), + + # misalignment scenario + MisalignmentScenario = cms.PSet(NoMovementsScenario), # why not by reference? + doMisalignmentScenario = cms.bool(False), + # simple misalignment of selected alignables and selected dof (deprecated!) + randomShift = cms.double(0.0), + randomRotation = cms.double(0.0), + parameterSelectorSimple = cms.string('-1'), + + # selection of alignables and their parameters + # see twiki: SWGuideAlignmentAlgorithms + ParameterBuilder = cms.PSet(parameterTypes = cms.vstring('Selector,RigidBody'), + Selector = cms.PSet(alignParams = cms.vstring('PixelHalfBarrelLayers,111000')) + ), + # number of selected alignables to be kept fixed (deprecated!) + nFixAlignables = cms.int32(0), # i.e. removed from selection above... + + # event input + tjTkAssociationMapTag = cms.InputTag("TrackRefitter"), + beamSpotTag = cms.InputTag("offlineBeamSpot"), + hitPrescaleMapTag = cms.InputTag(""), # not used if empty + # run input + tkLasBeamTag = cms.InputTag(""), # not used if empty + + # Choose one algorithm with configuration, HIP is default + algoConfig = cms.PSet(HIPAlignmentAlgorithm), # why not by reference? + # Some algorithms support integrated calibrations, which to use is defined + # by the string 'calibrationName' in the PSet of each calibration. + calibrations = cms.VPSet(), + # choose monitors (default is none) + monitorConfig = cms.PSet(monitors = cms.untracked.vstring()), + + # VPSet that allows splitting of alignment parameters into various + # run ranges. The default is a run range independent alignment + RunRangeSelection = cms.VPSet( + #cms.PSet(RunRanges = cms.vstring('-1','140401','143488') + # selector = cms.vstring('TrackerTPBHalfBarrel,001000', + # 'TrackerTPEHalfDisk,111000') + #) + ), + + # Tracker constants: different for SLHC pixel topology + trackerGeometryConstants = cms.PSet(trackerGeometryConstants_cfi.trackerGeometryConstants), + + # Save alignment to DB: true requires configuration of PoolDBOutputService + saveToDB = cms.bool(False), # save alignment? + saveApeToDB = cms.bool(False), # save APE? + saveDeformationsToDB = cms.bool(False) # save surface deformations (bows, etc.)? + ) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h index f6ec376c13776..7c080bb969cd1 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h @@ -70,6 +70,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase /// Call at end of job virtual void terminate(const edm::EventSetup& iSetup); + virtual void terminate(); /// Run the algorithm on trajectories and tracks virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index a60bb787efb4a..a31795ab91881 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -274,8 +274,10 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra // Call at end of job --------------------------------------------------------- //____________________________________________________ -void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) -{ +void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) { + terminate(); +} +void MillePedeAlignmentAlgorithm::terminate() { delete theMille;// delete to close binary before running pede below (flush would be enough...) theMille = 0; From dd2f247785ccfed0319212007021b7c3bad5dd49 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Fri, 22 May 2015 11:25:47 +0200 Subject: [PATCH 011/104] added test-config for TrackerAlignmentProducerForPCL in Alignment/CommonAlignmentProducer/test/TrackerAPForPCL/ --- .../test/TrackerAPForPCL/alignment_mille.py | 493 ++++++++++++++++++ 1 file changed, 493 insertions(+) create mode 100644 Alignment/CommonAlignmentProducer/test/TrackerAPForPCL/alignment_mille.py diff --git a/Alignment/CommonAlignmentProducer/test/TrackerAPForPCL/alignment_mille.py b/Alignment/CommonAlignmentProducer/test/TrackerAPForPCL/alignment_mille.py new file mode 100644 index 0000000000000..c3318e107fc46 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/test/TrackerAPForPCL/alignment_mille.py @@ -0,0 +1,493 @@ +#-- Common selection based on CRUZET 2015 Setup mp1553 + +import FWCore.ParameterSet.Config as cms + +process = cms.Process("Alignment") + + + +process.options = cms.untracked.PSet( + Rethrow = cms.untracked.vstring("ProductNotFound"), # do not accept this exception + wantSummary = cms.untracked.bool(True) + ) + + +# initialize MessageLogger +process.load("FWCore.MessageService.MessageLogger_cfi") +process.MessageLogger.destinations = ['alignment'] +process.MessageLogger.statistics = ['alignment'] +process.MessageLogger.categories = ['Alignment'] +process.MessageLogger.alignment = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(10) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + Alignment = cms.untracked.PSet( + limit = cms.untracked.int32(-1), + ) + ) + +process.MessageLogger.cerr.placeholder = cms.untracked.bool(True) +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + + + + +#-- Magnetic field +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +#process.load("Configuration/StandardSequences/MagneticField_38T_cff") ## FOR 3.8T +#process.load("Configuration.StandardSequences.MagneticField_0T_cff") ## FOR 0T + +#-- Load geometry +process.load("Configuration.Geometry.GeometryIdeal_cff") + +#-- Global Tag +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +process.GlobalTag.connect = "frontier://FrontierProd/CMS_COND_31X_GLOBALTAG" +process.GlobalTag.globaltag = "GR_P_V49::All" + +#-- initialize beam spot +process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi") + +#-- AlignmentTrackSelector +process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi") +process.AlignmentTrackSelector.src = 'HitFilteredTracks' # adjust to input file +process.AlignmentTrackSelector.applyBasicCuts = True +process.AlignmentTrackSelector.pMin = 4. +process.AlignmentTrackSelector.ptMin = 0. +process.AlignmentTrackSelector.ptMax = 200. +process.AlignmentTrackSelector.etaMin = -999. +process.AlignmentTrackSelector.etaMax = 999. +process.AlignmentTrackSelector.nHitMin = 8 +process.AlignmentTrackSelector.nHitMin2D = 2 +process.AlignmentTrackSelector.chi2nMax = 9999. +process.AlignmentTrackSelector.applyMultiplicityFilter = True +process.AlignmentTrackSelector.maxMultiplicity = 1 +process.AlignmentTrackSelector.applyNHighestPt = False +process.AlignmentTrackSelector.nHighestPt = 1 +process.AlignmentTrackSelector.seedOnlyFrom = 0 +process.AlignmentTrackSelector.applyIsolationCut = False +process.AlignmentTrackSelector.minHitIsolation = 0.8 +process.AlignmentTrackSelector.applyChargeCheck = False +process.AlignmentTrackSelector.minHitChargeStrip = 50. +#Special option for PCL +process.AlignmentTrackSelector.minHitsPerSubDet.inPIXEL = 2 + + +#-- new track hit filter +# TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1 +process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff") +process.TrackerTrackHitFilter.src = 'TrackRefitter1' +process.TrackerTrackHitFilter.useTrajectories= True # this is needed only if you require some selections; but it will work even if you don't ask for them +process.TrackerTrackHitFilter.minimumHits = 8 +process.TrackerTrackHitFilter.replaceWithInactiveHits = True +process.TrackerTrackHitFilter.rejectBadStoNHits = True +process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC")#,"drop TID stereo","drop TEC stereo") +process.TrackerTrackHitFilter.stripAllInvalidHits = False +process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 12.0") +process.TrackerTrackHitFilter.rejectLowAngleHits = True +process.TrackerTrackHitFilter.TrackAngleCut = 0.087# in rads, starting from the module surface; .35 for cosmcics ok, .17 for collision tracks +process.TrackerTrackHitFilter.usePixelQualityFlag = True #False + +#-- TrackFitter +import RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff +process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff.ctfWithMaterialTracksCosmics.clone( + src = 'TrackerTrackHitFilter', + TrajectoryInEvent = True, + TTRHBuilder = 'WithAngleAndTemplate', #should already be default + NavigationSchool = cms.string('') +) + +#-- Alignment producer +#process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff") +process.load("Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff") +process.AlignmentProducer.ParameterBuilder.Selector = cms.PSet( + alignParams = cms.vstring( + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', + + 'TrackerTIBHalfBarrel,ffffff', + 'TrackerTOBHalfBarrel,ffffff', + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' + ) + ) + +process.AlignmentProducer.doMisalignmentScenario = False #True + +process.AlignmentProducer.MisalignmentScenario = cms.PSet( + setRotations = cms.bool(True), + setTranslations = cms.bool(True), + seed = cms.int32(1234567), + distribution = cms.string('fixed'), # gaussian, uniform (or so...) + setError = cms.bool(True), #GF ??????? + TPBHalfBarrel1 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(-0.0015), + dZlocal = cms.double(0.0100), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-2.e-4), + phiZlocal = cms.double(5.e-4), + + ), + TPBHalfBarrel2 = cms.PSet( + dXlocal = cms.double(-0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.020), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(-2.e-4), + + ), + TPEEndcap1 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(0.0050), + dYlocal = cms.double(0.0020), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-5), + phiYlocal = cms.double(2.e-3), + phiZlocal = cms.double(2.e-5), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.01), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-1.e-4), + phiZlocal = cms.double(2.e-4), + ), + ), + TPEEndcap2 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(-0.0080), + dYlocal = cms.double(0.0050), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(-3.e-4), + phiZlocal = cms.double(2.e-4), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(3.e-4), + ), + ) +) + +process.AlignmentProducer.checkDbAlignmentValidity = False +process.AlignmentProducer.applyDbAlignment = True +process.AlignmentProducer.tjTkAssociationMapTag = 'TrackRefitter2' + +process.AlignmentProducer.algoConfig = process.MillePedeAlignmentAlgorithm +process.AlignmentProducer.algoConfig.mode = 'mille' +process.AlignmentProducer.algoConfig.mergeBinaryFiles = cms.vstring() +process.AlignmentProducer.algoConfig.binaryFile = 'milleBinary0.dat' +process.AlignmentProducer.algoConfig.TrajectoryFactory = process.BrokenLinesTrajectoryFactory +#process.AlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 +process.AlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +process.AlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers + + + +#-- TrackRefitter +process.load("RecoTracker.TrackProducer.TrackRefitters_cff") +process.TrackRefitter1 = RecoTracker.TrackProducer.TrackRefitterP5_cfi.TrackRefitterP5.clone( + src ='ALCARECOTkAlCosmicsCTF0T', + NavigationSchool = cms.string(''), + TrajectoryInEvent = True, + TTRHBuilder = "WithAngleAndTemplate" #default + ) + +process.TrackRefitter2 = process.TrackRefitter1.clone( + src = 'AlignmentTrackSelector', +# TTRHBuilder = 'WithTrackAngle' + ) + +process.source = cms.Source("PoolSource", + skipEvents = cms.untracked.uint32(0), + fileNames = cms.untracked.vstring( + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/00301998-55CE-E411-9266-02163E0126D7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/4C0E09C3-51CE-E411-90E9-02163E012AA3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/5E99D0C2-51CE-E411-92CB-02163E012A6E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/78B74988-53CE-E411-8F2D-02163E012326.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/AA465101-53CE-E411-8229-02163E01292F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/D2B8BC2A-51CE-E411-A8F1-02163E0127A6.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/443/00000/F03416E1-51CE-E411-92E9-02163E012A1C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/30C02E1B-52CE-E411-8E6E-02163E012A6E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/54886D3F-53CE-E411-81D7-02163E01275B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/6465F53D-53CE-E411-AB21-02163E011866.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/6EA89418-55CE-E411-9D40-02163E012050.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/70BF73D8-56CE-E411-A3B5-02163E0120E0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/88A9341A-52CE-E411-AC90-02163E0124EA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/92C3EA23-55CE-E411-B79C-02163E0123B7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/A44DAADA-56CE-E411-8D5F-02163E012770.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/AA34BC43-53CE-E411-9A30-02163E012B50.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/BEC8BF26-51CE-E411-A7F7-02163E01237E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/E4D13627-55CE-E411-8C57-02163E012076.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/EE4BF935-55CE-E411-A44E-02163E011847.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/445/00000/FEE53D38-55CE-E411-8FC2-02163E012A40.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/482B30E0-62CE-E411-8CD9-02163E0127A6.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/6276608D-66CE-E411-8458-02163E012832.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/6ECADD42-65CE-E411-8958-02163E012576.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/70F1658B-6BCE-E411-9B40-02163E011D09.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/76512D33-64CE-E411-B999-02163E0129B8.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/787CDE2E-67CE-E411-9380-02163E012658.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/980CDF2D-67CE-E411-AF91-02163E011D2C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/A2966EDA-6ECE-E411-BB51-02163E01269C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/A6A28F44-65CE-E411-8748-02163E0121C1.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/B26FF310-6BCE-E411-8815-02163E012493.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/C068CDEC-62CE-E411-86A2-02163E01226D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/C25DB915-6BCE-E411-A133-02163E011DED.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/C6E494F8-62CE-E411-8DD6-02163E0121BF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/CE88AB06-6FCE-E411-BD47-02163E011CE0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/D0C7B240-6FCE-E411-A990-02163E011D8A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/DA900B1C-68CE-E411-A3C9-02163E01205D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/DCFA2510-6BCE-E411-AD66-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/E48F770D-70CE-E411-B5A5-02163E01272D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/EEABBA0D-66CE-E411-9D28-02163E01184C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/F253DA42-65CE-E411-9714-02163E012576.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/474/00000/F449E01E-63CE-E411-A5F8-02163E012A6E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/484/00000/5AAF8AB0-6FCE-E411-91C8-02163E01269C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/16BD47B9-71CE-E411-99BD-02163E0121C6.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/16EEAD4B-70CE-E411-8C99-02163E012529.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/50BF56AB-70CE-E411-84FC-02163E012529.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/96F944BE-71CE-E411-BBCE-02163E011D6F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/B80BCBD1-71CE-E411-9BCF-02163E01216F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/E445C51D-70CE-E411-8029-02163E0122AF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/486/00000/EA01D61D-70CE-E411-9535-02163E0127B3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/04662200-73CE-E411-831F-02163E012708.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/12144C37-6FCE-E411-8ABE-02163E0123B7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/2C85DC67-73CE-E411-8E04-02163E011D8A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/B20BCE11-71CE-E411-A943-02163E012B06.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/C85EBB8C-72CE-E411-A050-02163E011804.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/491/00000/CA28A586-72CE-E411-8CC5-02163E0128AC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/2EC8C7AD-75CE-E411-BDCD-02163E011807.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/30CFE7B1-75CE-E411-9C73-02163E012708.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/34371B4B-79CE-E411-9C6C-02163E0126E7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/504750F3-74CE-E411-B8F6-02163E012915.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/5257A0E4-76CE-E411-8523-02163E011D1A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/52E0DF12-71CE-E411-B8E4-02163E0121E4.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/6EA2A43A-74CE-E411-A4A4-02163E0122CE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/B28A15F7-74CE-E411-BE6D-02163E0123B3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/C68A0BB0-75CE-E411-9569-02163E01216F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/D036F404-73CE-E411-A08A-02163E01237E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/D8E51AEE-6FCE-E411-B851-02163E012BE5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/E4A6E2C5-71CE-E411-82EF-02163E012BD7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/E8398AF5-76CE-E411-BFCF-02163E012A6E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/492/00000/F879DB0E-71CE-E411-95BA-02163E012445.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/02514FE6-76CE-E411-B403-02163E0124BD.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/1252AD05-7ACE-E411-9852-02163E011D8A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/3217E771-7BCE-E411-ABEF-02163E011D27.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/3CE4F671-7BCE-E411-914F-02163E011D27.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/86C3E829-7BCE-E411-B35E-02163E0125CE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/8E22C22A-7BCE-E411-8A82-02163E012AFC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/A6C06C07-7ACE-E411-8974-02163E0124D5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/ACCEAF05-7ACE-E411-85F0-02163E0118B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/C48C534A-7ACE-E411-8589-02163E012370.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/CE152053-7BCE-E411-B107-02163E011DDB.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/495/00000/E245DD82-7CCE-E411-A0CC-02163E012B27.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/496/00000/ACC449E0-78CE-E411-8E4C-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/499/00000/767AD767-7ACE-E411-A553-02163E0122F7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/500/00000/D25A7D29-7CCE-E411-BC45-02163E011871.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/501/00000/264548DE-7CCE-E411-B392-02163E012915.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/20ACC02D-8BCE-E411-8796-02163E011CE0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/36A6ED7B-8CCE-E411-BCFB-02163E011D5E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/3E471B7B-8ECE-E411-9573-02163E012BD9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/6AA26380-8CCE-E411-9B12-02163E0122B5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/9A2BA495-8CCE-E411-B361-02163E012B50.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/A888E23C-91CE-E411-B916-02163E0124C6.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/ACB10D76-8CCE-E411-8CDF-02163E012379.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/B8318EA3-8ECE-E411-B720-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/D2B32A61-8ECE-E411-BEEE-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/505/00000/EAAED674-8ECE-E411-AD30-02163E012770.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/507/00000/3AFB863B-8FCE-E411-8742-02163E011847.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/507/00000/CE0D628E-8DCE-E411-AB65-02163E0125DC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/00B65FFA-94CE-E411-AB63-02163E012BD9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/00FA766B-91CE-E411-BD0D-02163E011D6B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/00FD4098-97CE-E411-A157-02163E012B6D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/10047FE1-94CE-E411-8958-02163E01249B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/14FC3639-93CE-E411-BA99-02163E012186.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/22A43255-93CE-E411-865E-02163E011DDB.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/2A0ED06A-96CE-E411-9726-02163E012237.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/38F596C7-96CE-E411-B2F7-02163E012186.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/3A759FAC-90CE-E411-8826-02163E012B16.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/4AEC8C97-95CE-E411-A5AD-02163E011D83.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/4E7C0B1C-95CE-E411-9761-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/5CBF1BFB-9ACE-E411-BEBE-02163E012B27.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/6009D484-97CE-E411-9AC1-02163E01272D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/6206D296-97CE-E411-8A56-02163E011879.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/72B7EA23-95CE-E411-A87A-02163E011CD9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/72BB92B0-9DCE-E411-B3CE-02163E011D1A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/7813F7EF-91CE-E411-969E-02163E011800.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/92D45021-95CE-E411-9BF2-02163E011D51.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/98AC61D9-93CE-E411-836D-02163E0124F5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/BC164D2C-95CE-E411-B628-02163E01206F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/BCF79E32-93CE-E411-AB9B-02163E0129F5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/DACD264A-91CE-E411-B619-02163E0125CC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/DE4B6F52-91CE-E411-A03B-02163E0122F7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/DE83EE99-97CE-E411-801B-02163E01233B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/E2AB583F-93CE-E411-A8E9-02163E0128AA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/E6338331-9ACE-E411-B180-02163E0120C0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/E8980077-8ECE-E411-9B93-02163E0122F7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/F4FCDF9F-98CE-E411-B0F8-02163E012445.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/F8ECD5D9-97CE-E411-9CA6-02163E012063.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/FC98DA2A-92CE-E411-912B-02163E012B7C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/511/00000/FE93EA33-95CE-E411-8AA6-02163E0124FC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/000A8BEC-B4CE-E411-B37E-02163E0125CE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0061B0C6-9FCE-E411-83AE-02163E012217.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/00A3F682-A1CE-E411-8249-02163E0120C5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/02524A9B-BBCE-E411-9C5B-02163E0124EA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/064C2302-ABCE-E411-89A2-02163E0124FE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/08DD8502-ABCE-E411-8955-02163E011805.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0A4CDFE2-B4CE-E411-AC61-02163E012BBF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0AB18B2E-B7CE-E411-BC5F-02163E011A0D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0CF4186B-A3CE-E411-928F-02163E01233B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0E02E2A9-A9CE-E411-895F-02163E0121BF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/0EC1A1AF-B1CE-E411-A63E-02163E01233B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/10841302-ABCE-E411-B8EF-02163E0118EB.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/16CC5048-A2CE-E411-AA31-02163E0118B5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/1A20A3F4-AACE-E411-A3FE-02163E01210B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/1A33254F-98CE-E411-B2D8-02163E01201B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/260CC093-A6CE-E411-851F-02163E01226D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/2881846A-A3CE-E411-97B6-02163E012B6D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/2C983EAD-A9CE-E411-AC81-02163E011DE2.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/2CB25C8C-9CCE-E411-839B-02163E01183D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/302D64B0-B5CE-E411-B8E2-02163E012B16.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/34E1A8C6-B6CE-E411-BAD3-02163E0126EA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/360CD633-AECE-E411-9C98-02163E011D29.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/36565E14-ABCE-E411-890D-02163E0120F2.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/36D52CB4-B8CE-E411-8719-02163E011834.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/385D5186-B5CE-E411-9017-02163E011834.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/3C0AF6AD-B0CE-E411-B34A-02163E0123B3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/4203C354-9DCE-E411-948F-02163E0124F5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/4669B6B8-B8CE-E411-B689-02163E01225A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/4C49D692-A6CE-E411-BFD7-02163E012524.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/4CB247C6-B6CE-E411-8150-02163E012601.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/4CD457CD-9BCE-E411-A238-02163E011847.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/5630C5D2-B8CE-E411-A63C-02163E012AFC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/56AA24B8-A9CE-E411-8693-02163E0120E0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/56BD4AF1-A5CE-E411-9B30-02163E0123B3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/584CA7DD-B2CE-E411-BDE9-02163E012076.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/58A73A81-A3CE-E411-BADF-02163E012A91.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/5C602368-A3CE-E411-AD39-02163E0127CD.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/6029C129-9ACE-E411-BB0E-02163E012029.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/604994D7-B2CE-E411-9C68-02163E0121E4.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/606C46C1-9ECE-E411-9162-02163E011A0D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/647AC2AF-A4CE-E411-933E-02163E01249B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/6488BCF3-B2CE-E411-89D1-02163E012085.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/667B5FEE-B1CE-E411-AF9C-02163E012B7C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/66A1501D-99CE-E411-B3AD-02163E011847.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/6C99F723-98CE-E411-AACF-02163E0129F5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/6CF67882-A1CE-E411-BF60-02163E011D7C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/743CB7A1-B9CE-E411-9F07-02163E012576.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/7462676B-A1CE-E411-8577-02163E012BBF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/74E752C8-B0CE-E411-939F-02163E011834.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/7651C933-AECE-E411-94A9-02163E012326.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/76D3F606-9FCE-E411-8CE1-02163E011866.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/78131AAE-A6CE-E411-8E9D-02163E01271C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/787A2EA5-BBCE-E411-9E22-02163E0122B5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/78C40D77-9DCE-E411-A9C8-02163E011D1A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/8038E5B0-B5CE-E411-9CCF-02163E012ADC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/80A4FCA7-9FCE-E411-9EC8-02163E011D1A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/82FA3CB5-B8CE-E411-AA4D-02163E011DE2.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/84A5D2AD-AACE-E411-AD1A-02163E012237.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/8CCC23F1-AACE-E411-9E52-02163E0128ED.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/8E6256D6-9BCE-E411-BD82-02163E011CE7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/9003D1AA-9FCE-E411-99C8-02163E01183D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/94B4FF75-B9CE-E411-B0C8-02163E0123B9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/94E52BC1-ACCE-E411-9DE0-02163E012AFC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/9A28D0DA-9BCE-E411-8704-02163E011D81.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/9A871153-ABCE-E411-AB97-02163E01205D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/9E1246BE-A4CE-E411-AD6B-02163E0128AA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A0A5BB24-98CE-E411-A4C8-02163E012186.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A0C4F630-AFCE-E411-BC65-02163E0125AD.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A2817DC8-A4CE-E411-B0BA-02163E012029.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A2DB7964-A8CE-E411-A657-02163E0129B4.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A4867BB2-B0CE-E411-88F3-02163E0126EA.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A49E23B1-B5CE-E411-AA75-02163E011CEB.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A83B885E-A8CE-E411-A474-02163E0128ED.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A85A2B7A-9DCE-E411-9ACA-02163E0122AF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/A8F3506A-A3CE-E411-AA9A-02163E012708.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/AA1C3DD9-A4CE-E411-A09B-02163E012075.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/AACBAED1-9ACE-E411-B8C1-02163E012085.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/AAF765A8-A9CE-E411-97A4-02163E012452.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/AE685633-AFCE-E411-9762-02163E012A91.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/B0C0E9B2-B5CE-E411-B175-02163E012652.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/B4DB71E6-9ECE-E411-A356-02163E011DE7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/B69429D6-B4CE-E411-9E6F-02163E0128D1.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/B823C6BE-9ECE-E411-8895-02163E012708.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/B8A248A5-BBCE-E411-99AB-02163E011DB8.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/BC066DD7-B6CE-E411-BAF3-02163E0118B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/BCE2A71E-9ACE-E411-80F5-02163E0123B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/C434D1D0-9BCE-E411-B8F1-02163E011DBE.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/CADF0BD6-9BCE-E411-BE87-02163E0118B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/CEC2B3D3-B9CE-E411-9540-02163E011DE9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/D01F01A4-A6CE-E411-AE29-02163E0128ED.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/D6023175-B7CE-E411-9E48-02163E012732.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/DA9D56AA-A9CE-E411-96F7-02163E0118B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/DE1B3551-ACCE-E411-BB1E-02163E0124FC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/DE297DB8-ADCE-E411-9548-02163E011839.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/DE77DF91-A6CE-E411-B69D-02163E012ABF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/DEDA5492-B9CE-E411-92E7-02163E012ADC.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/E640436F-A3CE-E411-86F2-02163E012B45.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/E8F0109B-BBCE-E411-9B9A-02163E011D7C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/EE8A9044-ACCE-E411-AC2E-02163E012237.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F094596B-A1CE-E411-B6F3-02163E0124D3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F2A829BA-9ECE-E411-B020-02163E011D27.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F4220042-BACE-E411-9E42-02163E011DD9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F4274F34-97CE-E411-94AC-02163E011CD9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F6C5CB6C-A1CE-E411-AC18-02163E012186.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/F8F843D4-9BCE-E411-AB30-02163E01201B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/FAD1C57B-A6CE-E411-A0DE-02163E0121BF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/FC3F5F76-A7CE-E411-B89A-02163E01205D.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/FE43222C-B5CE-E411-8AFD-02163E011834.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/FE924690-A6CE-E411-925E-02163E012293.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/512/00000/FEF385ED-9ECE-E411-88A9-02163E012B7C.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/513/00000/7639474D-BBCE-E411-B8B5-02163E012592.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/513/00000/9488F0AD-BCCE-E411-885A-02163E0123B3.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/513/00000/F8B2EDAE-BCCE-E411-8315-02163E01249B.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/0AA57515-C5CE-E411-85C5-02163E012BBF.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/1A0F0F2D-C2CE-E411-9839-02163E011D8A.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/303E952C-C0CE-E411-967B-02163E0126A1.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/3092B84A-C1CE-E411-B063-02163E012B5F.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/482D0939-C0CE-E411-8619-02163E011847.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/62A77C11-C2CE-E411-9B29-02163E012BE5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/8EBE8595-BFCE-E411-9C69-02163E011D29.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/9254024D-C9CE-E411-8299-02163E0123B7.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/9A0383E9-C2CE-E411-88C6-02163E0123B0.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/AEC68FC1-C5CE-E411-BC7C-02163E011D6E.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/B226D6F5-C3CE-E411-AC22-02163E0127A6.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/B2E763D5-C2CE-E411-8C5F-02163E0126A1.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/C865E84C-BFCE-E411-A810-02163E0121F5.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/CE392847-BFCE-E411-9E09-02163E0123B9.root', + '/store/express/Commissioning2015/StreamExpressCosmics/ALCARECO/TkAlCosmics0T-Express-v1/000/238/514/00000/EA6B6927-BECE-E411-BD9B-02163E012BD9.root', + ), +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(20) +) + +process.p = cms.Path(process.offlineBeamSpot + *process.TrackRefitter1 + *process.TrackerTrackHitFilter + *process.HitFilteredTracks + *process.AlignmentTrackSelector + *process.TrackRefitter2 + *process.AlignmentProducer + ) + + +# MPS needs next line as placeholder for pede _cfg.py: +#MILLEPEDEBLOCK From 34e8b7e6cae184a37b9cb7d279a3675e5e0a118d Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 2 Jun 2015 16:41:13 +0200 Subject: [PATCH 012/104] migrate to AlignmentErrorsExtended --- .../plugins/TrackerAlignmentProducerForPCL.cc | 14 +++++++------- .../plugins/TrackerAlignmentProducerForPCL.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc index ac593e3d1752d..69d6ee9ac929a 100644 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc @@ -381,7 +381,7 @@ void TrackerAlignmentProducerForPCL::init(const edm::EventSetup& setup) { GeometryAligner aligner; std::auto_ptr alignments (theAlignableTracker->alignments()); - std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); + std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); std::auto_ptr aliDeforms (theAlignableTracker->surfaceDeformations()); aligner.applyAlignments (&(*theTracker), &(*alignments), &(*alignmentErrors), AlignTransform() ); // don't apply global a second time! @@ -601,7 +601,7 @@ void TrackerAlignmentProducerForPCL::applyDB(G* geometry, const edm::EventSetup& edm::ESHandle alignments; record.get(alignments); - edm::ESHandle alignmentErrors; + edm::ESHandle alignmentErrors; setup.get().get(alignmentErrors); GeometryAligner aligner; @@ -655,7 +655,7 @@ void TrackerAlignmentProducerForPCL::writeForRunRange(cond::Time_t time) { } Alignments* alignments = theAlignableTracker->alignments(); - AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors(); + AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors(); writeDB(alignments, "TrackerAlignmentRcd", alignmentErrors, "TrackerAlignmentErrorRcd", @@ -671,14 +671,14 @@ void TrackerAlignmentProducerForPCL::writeForRunRange(cond::Time_t time) { void TrackerAlignmentProducerForPCL::writeDB(Alignments* alignments, const std::string& alignRcd, - AlignmentErrors* alignmentErrors, + AlignmentErrorsExtended* alignmentErrors, const std::string& errRcd, const AlignTransform* globalCoordinates, cond::Time_t time) const { printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); Alignments* tempAlignments = alignments; - AlignmentErrors* tempAlignmentErrors = alignmentErrors; + AlignmentErrorsExtended* tempAlignmentErrors = alignmentErrors; // Call service edm::Service poolDb; @@ -694,7 +694,7 @@ void TrackerAlignmentProducerForPCL::writeDB(Alignments* alignments, globalCoordinates->transform() != AlignTransform::Transform::Identity) { tempAlignments = new Alignments(); // temporary storage for - tempAlignmentErrors = new AlignmentErrors(); // final alignments and errors + tempAlignmentErrors = new AlignmentErrorsExtended(); // final alignments and errors GeometryAligner aligner; aligner.removeGlobalTransform(alignments, alignmentErrors, @@ -722,7 +722,7 @@ void TrackerAlignmentProducerForPCL::writeDB(Alignments* alignments, if (saveApeToDB) { edm::LogInfo("Alignment") << "Writing AlignmentErrors for run " << time << " to " << errRcd << "."; - poolDb->writeOne(tempAlignmentErrors, time, errRcd); + poolDb->writeOne(tempAlignmentErrors, time, errRcd); } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,... diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h index 37b421906500f..00b7a7cee3aa6 100644 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h @@ -88,7 +88,7 @@ class TrackerAlignmentProducerForPCL : public edm::EDAnalyzer { /// Write alignment and/or errors to DB for record names /// (removes *globalCoordinates before writing if non-null...). /// Takes over ownership of alignments and alignmentErrrors. - void writeDB(Alignments*, const std::string&, AlignmentErrors*, + void writeDB(Alignments*, const std::string&, AlignmentErrorsExtended*, const std::string&, const AlignTransform*, cond::Time_t) const; /// Write surface deformations (bows & kinks) to DB for given record name /// Takes over ownership of alignmentsurfaceDeformations. From 06ba49329b824b075eeb16b8a175c9325edf70da Mon Sep 17 00:00:00 2001 From: Gianluca Date: Mon, 15 Jun 2015 16:57:52 +0200 Subject: [PATCH 013/104] move to the EDAnalyzer for the alignment producer --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 182 ++++++++---------- 1 file changed, 79 insertions(+), 103 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 00dee7831b0a0..c531d7f669dca 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -43,128 +43,103 @@ NavigationSchool = '', # to avoid filling hit pattern ) -#FIXME: manually exclude the looper so that it doesn't interfere with the test of the Harvesting step for the time being. -if(False): - # Alignment producer (which is a cms.Looper module and hence not added to the sequence) - from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * - #looper.parameterTypes = cms.vstring('Selector,RigidBody') - #looper.ParameterBuilder.parameterTypes = [ - # 'SelectorRigid,RigidBody', - # 'SelectorBowed,BowedSurface' - # ,'Selector2Bowed,TwoBowedSurfaces' - # ] - looper.ParameterBuilder.Selector = cms.PSet( + +#-- Alignment producer +from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * +from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer +SiPixelAliMilleAlignmentProducer = copy.deepcopy(AlignmentProducer) + +SiPixelAliMilleAlignmentProducer.ParameterBuilder.Selector = cms.PSet( alignParams = cms.vstring( - 'TrackerTPBHalfBarrel,111111', - 'TrackerTPEHalfCylinder,111111', - # 'TrackerTPBLayer,111111', - # 'TrackerTPEHalfDisk,111111', - 'TrackerTIBHalfBarrel,ffffff', # or fff fff? - 'TrackerTOBHalfBarrel,ffffff', # dito... - 'TrackerTIDEndcap,ffffff', - 'TrackerTECEndcap,ffffff' - ) + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', + + 'TrackerTIBHalfBarrel,ffffff', + 'TrackerTOBHalfBarrel,ffffff', + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' + ) ) - looper.doMisalignmentScenario = False #True +SiPixelAliMilleAlignmentProducer.doMisalignmentScenario = False #True - # If the above is true, you might want to choose the scenario: - #from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario - #FIXME: is the following really needed given the above parameter? - looper.MisalignmentScenario = cms.PSet( +SiPixelAliMilleAlignmentProducer.MisalignmentScenario = cms.PSet( setRotations = cms.bool(True), setTranslations = cms.bool(True), seed = cms.int32(1234567), distribution = cms.string('fixed'), # gaussian, uniform (or so...) setError = cms.bool(True), #GF ??????? TPBHalfBarrel1 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(-0.0015), - dZlocal = cms.double(0.0100), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-2.e-4), - phiZlocal = cms.double(5.e-4), - ), - TPBHalfBarrel2 = cms.PSet( - dXlocal = cms.double(-0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.020), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(-2.e-4), - ), - TPEEndcap1 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(0.0050), - dYlocal = cms.double(0.0020), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-5), - phiYlocal = cms.double(2.e-3), - phiZlocal = cms.double(2.e-5), - ), - TPEHalfCylinder2 = cms.PSet( dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.01), + dYlocal = cms.double(-0.0015), + dZlocal = cms.double(0.0100), phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-1.e-4), - phiZlocal = cms.double(2.e-4), - ), - ), - TPEEndcap2 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(-0.0080), - dYlocal = cms.double(0.0050), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(-3.e-4), - phiZlocal = cms.double(2.e-4), + phiYlocal = cms.double(-2.e-4), + phiZlocal = cms.double(5.e-4), + ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), + TPBHalfBarrel2 = cms.PSet( + dXlocal = cms.double(-0.0020), dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-3), + dZlocal = cms.double(-0.020), + phiXlocal = cms.double(1.e-3), phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(3.e-4), + phiZlocal = cms.double(-2.e-4), + ), + TPEEndcap1 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(0.0050), + dYlocal = cms.double(0.0020), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-5), + phiYlocal = cms.double(2.e-3), + phiZlocal = cms.double(2.e-5), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.01), + phiXlocal = cms.double(1.e-4), + phiYlocal = cms.double(-1.e-4), + phiZlocal = cms.double(2.e-4), + ), + ), + TPEEndcap2 = cms.PSet( + TPEHalfCylinder1 = cms.PSet( + dXlocal = cms.double(-0.0080), + dYlocal = cms.double(0.0050), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(1.e-3), + phiYlocal = cms.double(-3.e-4), + phiZlocal = cms.double(2.e-4), + ), + TPEHalfCylinder2 = cms.PSet( + dXlocal = cms.double(0.0020), + dYlocal = cms.double(0.0030), + dZlocal = cms.double(-0.005), + phiXlocal = cms.double(-1.e-3), + phiYlocal = cms.double(2.e-4), + phiZlocal = cms.double(3.e-4), + ), ) - ) + ) + +SiPixelAliMilleAlignmentProducer.checkDbAlignmentValidity = False +SiPixelAliMilleAlignmentProducer.applyDbAlignment = True +SiPixelAliMilleAlignmentProducer.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' + +SiPixelAliMilleAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm +SiPixelAliMilleAlignmentProducer.algoConfig.mode = 'mille' +SiPixelAliMilleAlignmentProducer.algoConfig.mergeBinaryFiles = cms.vstring() +SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile = 'milleBinary0.dat' +SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory +#SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 +SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers - looper.checkDbAlignmentValidity = False - looper.applyDbAlignment = True - looper.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' - - # assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): - looper.algoConfig = MillePedeAlignmentAlgorithm - - #from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * - #looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) - looper.algoConfig.mode = 'mille' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' - #looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] - #looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] - looper.algoConfig.binaryFile = 'milleBinaryISN.dat' # BVB: Remove this after it's take care of for the reading - looper.algoConfig.treeFile = 'treeFileISN.root' # BVB: Remove this - - looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory - looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' - #looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' - #FIXME: this needs to come from the release - looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' - #default is sparseMINRES 6 0.8: n(iter) Delta(F) - looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) - looper.algoConfig.pedeSteerer.options = cms.vstring( - #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum - 'entries 500', - 'chisqcut 30.0 4.5', #, - 'threads 1 1' #, - #'outlierdownweighting 3','dwfractioncut 0.1' - #'outlierdownweighting 5','dwfractioncut 0.2' - ) - looper.algoConfig.minNumHits = 8 - looper.saveToDB = False # Ingredient: SiPixelAliTrackerTrackHitFilter import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter @@ -207,5 +182,6 @@ AlignmentTrackSelector* SiPixelAliTrackRefitter0* SiPixelAliTrackerTrackHitFilter* - SiPixelAliTrackFitter) + SiPixelAliTrackFitter* + SiPixelAliMilleAlignmentProducer) ##SiPixelAliMillePedeFileConverter) From 5231dc387edaf1343a89444a79c188b9ceb9e32b Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Fri, 12 Jun 2015 16:46:32 +0200 Subject: [PATCH 014/104] implemented new AlignmentProducer running on PCL * created in CMSSW_7_5_0_pre5 * aligns only tracker * AP is no longer an ESProducer but an EDAnalyzer * runs only with MillePede at the moment Conflicts: Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc --- .../interface/AlignmentAlgorithmBase.h | 3 +- .../plugins/BuildFile.xml | 14 + .../plugins/PCLTrackerAlProducer.cc | 1004 +++++++++++++++++ .../plugins/PCLTrackerAlProducer.h | 193 ++++ .../TrackerAlignmentProducerForPCL_cff.py | 2 +- .../src/MillePedeAlignmentAlgorithm.cc | 6 +- 6 files changed, 1218 insertions(+), 4 deletions(-) create mode 100644 Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc create mode 100644 Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index d937a4b5e28be..5bd345f63c3f6 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -106,7 +106,8 @@ class AlignmentAlgorithmBase /// Call at end of each loop (must be implemented in derived class) virtual void terminate(const edm::EventSetup& iSetup) = 0; - virtual void terminate() {} + virtual void terminate() {}; + /// Run the algorithm (must be implemented in derived class) virtual void run( const edm::EventSetup &setup, const EventInfo &eventInfo) = 0; diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index 3cef465cc4a55..1ca1e71042a15 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -31,6 +31,20 @@ + + + + + + + + + + + + + + diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc new file mode 100644 index 0000000000000..838d6f2b5f4c0 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -0,0 +1,1004 @@ +/// \file PCLTrackerAlProducer.cc +/// +/// \author : Frederic Ronga +/// Revision : $Revision: 1.68 $ +/// last update: $Date: 2012/08/10 09:25:23 $ +/// by : $Author: flucke $ + +#include "PCLTrackerAlProducer.h" +#include "FWCore/Framework/interface/LooperFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" +#include "Alignment/CommonAlignment/interface/Alignable.h" + +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" + +// System include files +#include +#include + +// Framework +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "FWCore/Utilities/interface/Parse.h" + +// Conditions database +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +// Geometry +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromDDD.h" +#include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h" +#include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" +#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h" +#include "Geometry/Records/interface/PTrackerParametersRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTSurveyErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" +#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" + +// Tracking, LAS and cluster flag map (fwd is enough!) +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" +#include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" +#include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" + +// Alignment +#include "CondFormats/Alignment/interface/SurveyErrors.h" +#include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h" +#include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h" +#include "Alignment/CommonAlignment/interface/SurveyDet.h" +#include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h" +#include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmPluginFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationPluginFactory.h" +#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" + +//_____________________________________________________________________________ +PCLTrackerAlProducer::PCLTrackerAlProducer(const edm::ParameterSet& iConfig) : + theAlignmentAlgo(0), theAlignmentParameterStore(0), + theAlignableExtras(0), theAlignableTracker(0), theAlignableMuon(0), + globalPositions_(0), + nevent_(0), theParameterSet(iConfig), + theMaxLoops( iConfig.getUntrackedParameter("maxLoops") ), + stNFixAlignables_(iConfig.getParameter("nFixAlignables") ), + stRandomShift_(iConfig.getParameter("randomShift")), + stRandomRotation_(iConfig.getParameter("randomRotation")), + applyDbAlignment_( iConfig.getUntrackedParameter("applyDbAlignment")), + checkDbAlignmentValidity_( iConfig.getUntrackedParameter("checkDbAlignmentValidity")), + doMisalignmentScenario_(iConfig.getParameter("doMisalignmentScenario")), + saveToDB_(iConfig.getParameter("saveToDB")), + saveApeToDB_(iConfig.getParameter("saveApeToDB")), + saveDeformationsToDB_(iConfig.getParameter("saveDeformationsToDB")), + doTracker_( iConfig.getUntrackedParameter("doTracker") ), + doMuon_( iConfig.getUntrackedParameter("doMuon") ), + useExtras_( iConfig.getUntrackedParameter("useExtras") ), + useSurvey_( iConfig.getParameter("useSurvey") ), + tjTkAssociationMapTag_(iConfig.getParameter("tjTkAssociationMapTag")), + beamSpotTag_(iConfig.getParameter("beamSpotTag")), + tkLasBeamTag_(iConfig.getParameter("tkLasBeamTag")), + clusterValueMapTag_(iConfig.getParameter("hitPrescaleMapTag")) +{ + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::PCLTrackerAlProducer"; + + + + // Create the alignment algorithm + edm::ParameterSet algoConfig = iConfig.getParameter( "algoConfig" ); + edm::VParameterSet iovSelection = iConfig.getParameter( "RunRangeSelection" ); + algoConfig.addUntrackedParameter( "RunRangeSelection", iovSelection ); + std::string algoName = algoConfig.getParameter( "algoName" ); + theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get( )->create( algoName, algoConfig ); + + // Check if found + if ( !theAlignmentAlgo ) + throw cms::Exception("BadConfig") << "Couldn't find algorithm called " << algoName; + + // Now create monitors: + edm::ParameterSet monitorConfig = iConfig.getParameter( "monitorConfig" ); + std::vector monitors = monitorConfig.getUntrackedParameter >( "monitors" ); + for (std::vector::const_iterator miter = monitors.begin(); miter != monitors.end(); ++miter) { + AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, monitorConfig.getUntrackedParameter(*miter)); + + if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter; + + theMonitors.push_back(newMonitor); + } + + // Finally create integrated calibrations: + edm::VParameterSet calibrations = iConfig.getParameter("calibrations"); + for (auto iCalib = calibrations.begin(); iCalib != calibrations.end(); ++iCalib) { + const std::string name(iCalib->getParameter("calibrationName")); + theCalibrations.push_back(IntegratedCalibrationPluginFactory::get()->create(name, *iCalib)); + // exception comes from line before: if (!theCalibrations.back()) throw cms::Exception(..) << ..; + } + +} + + +//_____________________________________________________________________________ +// Delete new objects +PCLTrackerAlProducer::~PCLTrackerAlProducer() +{ + delete theAlignmentAlgo; + + // Delete monitors as well?? + + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + delete *iCal; // delete integrated calibration pointed to by (*iCal) + } + + delete theAlignmentParameterStore; + delete theAlignableExtras; + delete theAlignableTracker; + delete theAlignableMuon; + + delete globalPositions_; +} + + + + +//_____________________________________________________________________________ +// Initialize algorithm +void PCLTrackerAlProducer::beginOfJob() +{ +} + + +void PCLTrackerAlProducer::init(const edm::EventSetup& iSetup) { + printf("(TProdPCL) function %s in %s was called\n", __func__, __FILE__); + + + /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob"; + + //Retrieve tracker topology from geometry + edm::ESHandle tTopoHandle; + iSetup.get().get(tTopoHandle); + const TrackerTopology* const tTopo = tTopoHandle.product(); + + // Create the geometries from the ideal geometries (first time only) + this->createGeometries_( iSetup ); + + // Retrieve and apply alignments, if requested (requires DB setup) + if ( applyDbAlignment_ ) { + // we need GlobalPositionRcd - and have to keep track for later removal + // before writing again to DB... + edm::ESHandle globalPositionRcd; + iSetup.get().get(globalPositionRcd); + globalPositions_ = new Alignments(*globalPositionRcd); + + if ( doTracker_ ) { // apply to tracker + this->applyDB + (&(*theTracker), iSetup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Tracker))); + this->applyDB(&(*theTracker), iSetup); + } + + if ( doMuon_ ) { // apply to tracker + this->applyDB + (&(*theMuonDT), iSetup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); + this->applyDB + (&(*theMuonCSC), iSetup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); + } + } + + // Create alignable tracker and muon + if (doTracker_) { + theAlignableTracker = new AlignableTracker( &(*theTracker), tTopo ); + } + + if (doMuon_) { + theAlignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) ); + } + + if (useExtras_) { + theAlignableExtras = new AlignableExtras(); + } + + // Create alignment parameter builder + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "Creating AlignmentParameterBuilder"; + edm::ParameterSet aliParamBuildCfg = + theParameterSet.getParameter("ParameterBuilder"); + AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker, + theAlignableMuon, + theAlignableExtras, + aliParamBuildCfg ); + // Fix alignables if requested + if (stNFixAlignables_>0) alignmentParameterBuilder.fixAlignables(stNFixAlignables_); + + // Get list of alignables + Alignables theAlignables = alignmentParameterBuilder.alignables(); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "got " << theAlignables.size() << " alignables"; + + // Create AlignmentParameterStore + edm::ParameterSet aliParamStoreCfg = + theParameterSet.getParameter("ParameterStore"); + theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "AlignmentParameterStore created!"; + + // Apply misalignment scenario to alignable tracker and muon if requested + // WARNING: this assumes scenarioConfig can be passed to both muon and tracker + if (doMisalignmentScenario_ && (doTracker_ || doMuon_)) { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "Applying misalignment scenario to " + << (doTracker_ ? "tracker" : "") + << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : "."); + edm::ParameterSet scenarioConfig + = theParameterSet.getParameter( "MisalignmentScenario" ); + if (doTracker_) { + TrackerScenarioBuilder scenarioBuilder( theAlignableTracker ); + scenarioBuilder.applyScenario( scenarioConfig ); + } + if (doMuon_) { + MuonScenarioBuilder muonScenarioBuilder( theAlignableMuon ); + muonScenarioBuilder.applyScenario( scenarioConfig ); + } + } else { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "NOT applying misalignment scenario!"; + } + + // Apply simple misalignment + const std::string sParSel(theParameterSet.getParameter("parameterSelectorSimple")); + this->simpleMisalignment_(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); + + // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm + theAlignmentAlgo->initialize( iSetup, + theAlignableTracker, theAlignableMuon, theAlignableExtras, + theAlignmentParameterStore ); + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignableExtras); + } + // Not all algorithms support calibrations - so do not pass empty vector + // and throw if non-empty and not supported: + if (!theCalibrations.empty() && !theAlignmentAlgo->addCalibrations(theCalibrations)) { + throw cms::Exception("BadConfig") << "[PCLTrackerAlProducer::beginOfJob]\n" + << "Configured " << theCalibrations.size() << " calibration(s) " + << "for algorithm not supporting it."; + } + + for (std::vector::const_iterator monitor = theMonitors.begin(); + monitor != theMonitors.end(); ++monitor) { + (*monitor)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignmentParameterStore); + } + + + + + /* 1) Former: AlignmentProducer::startingNewLoop(unsigned int iLoop) */ + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::startingNewLoop"; + + nevent_ = 0; + + theAlignmentAlgo->startNewLoop(); + // FIXME: Should this be done in algorithm::startNewLoop()?? + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->startNewLoop(); + } + + for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { + (*monitor)->startingNewLoop(); + } + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::startingNewLoop" + << "Now physically apply alignments to geometry..."; + + + // Propagate changes to reconstruction geometry (from initialisation or iteration) + GeometryAligner aligner; + if ( doTracker_ ) { + std::auto_ptr alignments(theAlignableTracker->alignments()); + std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); + aligner.applyAlignments( &(*theTracker),&(*alignments),&(*alignmentErrors), AlignTransform() ); // don't apply global a second time! + std::auto_ptr aliDeforms(theAlignableTracker->surfaceDeformations()); + aligner.attachSurfaceDeformations(&(*theTracker), &(*aliDeforms)); + + } + if ( doMuon_ ) { + std::auto_ptr dtAlignments( theAlignableMuon->dtAlignments()); + std::auto_ptr dtAlignmentErrorsExtended( theAlignableMuon->dtAlignmentErrorsExtended()); + std::auto_ptr cscAlignments( theAlignableMuon->cscAlignments()); + std::auto_ptr cscAlignmentErrorsExtended( theAlignableMuon->cscAlignmentErrorsExtended()); + + aligner.applyAlignments( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrorsExtended), AlignTransform() ); // don't apply global a second time! + aligner.applyAlignments( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrorsExtended), AlignTransform() ); // nope! + } +} + +//_____________________________________________________________________________ +// Terminate algorithm +void PCLTrackerAlProducer::endOfJob() +{ + /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ + if (0 == nevent_) { + // beginOfJob is usually called by the framework in the first event of the first loop + // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) + // and the algorithms rely on the initialisations done in beginOfJob. We cannot call + // this->beginOfJob(iSetup); here either since that will access the EventSetup to get + // some geometry information that is not defined either without having seen an event. + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfLoop" + << "Did not process any events in loop" + << ", stop processing without terminating algorithm."; + return; + } + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfLoop" + << "Terminating algorithm."; + + theAlignmentAlgo->terminate(); + // FIXME: Should this be done in algorithm::terminate(const edm::EventSetup& iSetup)?? + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->endOfLoop(); + } + + /* + for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { + (*monitor)->endOfLoop(iSetup); + } + */ + + + + + + /* 2) Former: void AlignmentProducer::endOfJob() */ + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob"; + + for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { + (*monitor)->endOfJob(); + } + + if (0 == nevent_) { + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" << "Did not process any " + << "events in last loop, do not dare to store to DB."; + } else { + + // Expand run ranges and make them unique + edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); + RunRanges uniqueRunRanges(this->makeNonOverlappingRunRanges(runRangeSelectionVPSet)); + if (uniqueRunRanges.empty()) { // create dummy IOV + const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue, + cond::timeTypeSpecs[cond::runnumber].endValue); + uniqueRunRanges.push_back(runRange); + } + + std::vector beamSpotParameters; + + for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange) { + + theAlignmentAlgo->setParametersForRunRange(*iRunRange); + + // Save alignments to database + if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_) + this->writeForRunRange((*iRunRange).first); + + // Deal with extra alignables, e.g. beam spot + if (theAlignableExtras) { + Alignables &alis = theAlignableExtras->beamSpot(); + if (!alis.empty()) { + BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast(alis[0]->alignmentParameters()); + beamSpotParameters.push_back(beamSpotAliPars->parameters()); + } + } + } + + if (theAlignableExtras) { + std::ostringstream bsOutput; + + std::vector::const_iterator itPar = beamSpotParameters.begin(); + for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange, ++itPar) { + bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n"; + bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; + bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; + } + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" + << "Parameters for alignable beamspot:\n" + << bsOutput.str(); + } + + for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { + (*iCal)->endOfJob(); + } + + } +} + + + +//_____________________________________________________________________________ +// Called at each event +void PCLTrackerAlProducer::analyze(const edm::Event& event, const edm::EventSetup& setup) +{ + ++nevent_; + if (watchTrackerAlRcd.check(setup)) { + printf("(TProdPCL) PCLTrackerAlProducer::analyze | " + "TrackerAlignmentRcd has changed (event nr: %d)\n", nevent_); + init(setup); + } + + + // reading in survey records + this->readInSurveyRcds(setup); + + // Printout event number + for ( int i=10; i<10000000; i*=10 ) + if ( nevent_<10*i && (nevent_%i)==0 ) + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" + << "Events processed: " << nevent_; + + // Retrieve trajectories and tracks from the event + // -> merely skip if collection is empty + edm::Handle m_TrajTracksMap; + if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) { + + // Form pairs of trajectories and tracks + ConstTrajTrackPairCollection trajTracks; + for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin(); + iPair != m_TrajTracksMap->end(); ++iPair) { + trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) ); + } + edm::Handle beamSpot; + event.getByLabel(beamSpotTag_, beamSpot); + + if (nevent_==1 && theAlignableExtras) { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" + << "initializing AlignableBeamSpot" << std::endl; + theAlignableExtras->initializeBeamSpot(beamSpot->x0(), beamSpot->y0(), beamSpot->z0(), + beamSpot->dxdz(), beamSpot->dydz()); + } + + // Run the alignment algorithm with its input + const AliClusterValueMap *clusterValueMapPtr = 0; + if(clusterValueMapTag_.encode().size()){//check that the input tag is not empty + edm::Handle clusterValueMap; + event.getByLabel(clusterValueMapTag_, clusterValueMap); + clusterValueMapPtr = &(*clusterValueMap); + } + + const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *beamSpot, + clusterValueMapPtr); + theAlignmentAlgo->run(setup, eventInfo); + + + for (std::vector::const_iterator monitor = theMonitors.begin(); + monitor != theMonitors.end(); ++monitor) { + (*monitor)->duringLoop(event, setup, trajTracks); // forward eventInfo? + } + } else { + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" + << "No track collection found: skipping event"; + } +} + + + + +// ---------------------------------------------------------------------------- +void PCLTrackerAlProducer::beginRun(const edm::Run &run, const edm::EventSetup &setup) +{ + theAlignmentAlgo->beginRun(setup); // do not forward edm::Run... +} + +// ---------------------------------------------------------------------------- +void PCLTrackerAlProducer::endRun(const edm::Run &run, const edm::EventSetup &setup) +{ + // call with or without las beam info... + typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo; + if (tkLasBeamTag_.encode().size()) { // non-empty InputTag + edm::Handle lasBeams; + edm::Handle tsoses; + run.getByLabel(tkLasBeamTag_, lasBeams); + run.getByLabel(tkLasBeamTag_, tsoses); + + theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup); + } else { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endRun" + << "No Tk LAS beams to forward to algorithm."; + theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); + } +} + +// ---------------------------------------------------------------------------- +void PCLTrackerAlProducer::beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, + const edm::EventSetup &setup) +{ + theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock +} + +// ---------------------------------------------------------------------------- +void PCLTrackerAlProducer::endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, + const edm::EventSetup &setup) +{ + theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock +} + +// ---------------------------------------------------------------------------- + +void PCLTrackerAlProducer::simpleMisalignment_(const Alignables &alivec, const std::string &selection, + float shift, float rot, bool local) +{ + + std::ostringstream output; // collecting output + + if (shift > 0. || rot > 0.) { + output << "Adding random flat shift of max size " << shift + << " and adding random flat rotation of max size " << rot <<" to "; + + std::vector commSel(0); + if (selection != "-1") { + AlignmentParameterSelector aSelector(0,0); // no alignable needed here... + const std::vector cSel(aSelector.convertParamSel(selection)); + if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) { + throw cms::Exception("BadConfig") + << "[PCLTrackerAlProducer::simpleMisalignment_]\n" + << "Expect selection string '" << selection << "' to be at least of length " + << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" + << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; + } + for (std::vector::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) { + commSel.push_back(*cIter == '0' ? false : true); + } + output << "parameters defined by (" << selection + << "), representing (x,y,z,alpha,beta,gamma),"; + } else { + output << "the active parameters of each alignable,"; + } + output << " in " << (local ? "local" : "global") << " frame."; + + for (std::vector::const_iterator it = alivec.begin(); it != alivec.end(); ++it) { + Alignable* ali=(*it); + std::vector mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel); + + if (std::abs(shift)>0.00001) { + double s0 = 0., s1 = 0., s2 = 0.; + if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.; + + if (local) ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) ); + else ali->move( align::GlobalVector(s0,s1,s2) ); + + //AlignmentPositionError ape(dx,dy,dz); + //ali->addAlignmentPositionError(ape); + } + + if (std::abs(rot)>0.00001) { + align::EulerAngles r(3); + if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dbeta]) r(2)=rot*double(random()%1000-500)/500.; + if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.; + + const align::RotationType mrot = align::toMatrix(r); + if (local) ali->rotateInLocalFrame(mrot); + else ali->rotateInGlobalFrame(mrot); + + //ali->addAlignmentPositionErrorFromRotation(mrot); + } + } // end loop on alignables + } else { + output << "No simple misalignment added!"; + } + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::simpleMisalignment_" << output.str(); +} + + +//__________________________________________________________________________________________________ +void PCLTrackerAlProducer::createGeometries_( const edm::EventSetup& iSetup ) +{ + edm::ESTransientHandle cpv; + iSetup.get().get( cpv ); + + if (doTracker_) { + edm::ESHandle geometricDet; + iSetup.get().get( geometricDet ); + edm::ESHandle ptp; + iSetup.get().get( ptp ); + TrackerGeomBuilderFromGeometricDet trackerBuilder; + theTracker = boost::shared_ptr( trackerBuilder.build(&(*geometricDet), *ptp )); + } + + if (doMuon_) { + edm::ESHandle mdc; + iSetup.get().get(mdc); + DTGeometryBuilderFromDDD DTGeometryBuilder; + CSCGeometryBuilderFromDDD CSCGeometryBuilder; + theMuonDT = boost::shared_ptr(new DTGeometry ); + DTGeometryBuilder.build( theMuonDT, &(*cpv), *mdc); + theMuonCSC = boost::shared_ptr( new CSCGeometry ); + CSCGeometryBuilder.build( theMuonCSC, &(*cpv), *mdc ); + } +} + +void PCLTrackerAlProducer::addSurveyInfo_(Alignable* ali) +{ + const std::vector& comp = ali->components(); + + unsigned int nComp = comp.size(); + + for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i]); + + const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; + + if ( ali->id() != error.rawId() || + ali->alignableObjectId() != error.structureType() ) + { + throw cms::Exception("DatabaseError") + << "Error reading survey info from DB. Mismatched id!"; + } + + const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); + const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); + + AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ), + align::RotationType( rot.xx(), rot.xy(), rot.xz(), + rot.yx(), rot.yy(), rot.yz(), + rot.zx(), rot.zy(), rot.zz() ) ); + + surf.setWidth( ali->surface().width() ); + surf.setLength( ali->surface().length() ); + + ali->setSurvey( new SurveyDet( surf, error.matrix() ) ); + + ++theSurveyIndex; +} + +void PCLTrackerAlProducer::readInSurveyRcds( const edm::EventSetup& iSetup ){ + + // Get Survey Rcds and add Survey Info + if ( doTracker_ && useSurvey_ ){ + bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup); + bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); + edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool; + edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool; + if ( tkSurveyBool || tkSurveyErrBool){ + + edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION"; + edm::ESHandle surveys; + edm::ESHandle surveyErrors; + + iSetup.get().get(surveys); + iSetup.get().get(surveyErrors); + + theSurveyIndex = 0; + theSurveyValues = &*surveys; + theSurveyErrors = &*surveyErrors; + addSurveyInfo_(theAlignableTracker); + } + } + + if ( doMuon_ && useSurvey_) { + bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup); + bool DTSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); + bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup); + bool CSCSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); + + if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){ + edm::ESHandle dtSurveys; + edm::ESHandle dtSurveyErrors; + edm::ESHandle cscSurveys; + edm::ESHandle cscSurveyErrors; + + iSetup.get().get(dtSurveys); + iSetup.get().get(dtSurveyErrors); + iSetup.get().get(cscSurveys); + iSetup.get().get(cscSurveyErrors); + + theSurveyIndex = 0; + theSurveyValues = &*dtSurveys; + theSurveyErrors = &*dtSurveyErrors; + std::vector barrels = theAlignableMuon->DTBarrel(); + for (std::vector::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) { + addSurveyInfo_(*iter); + } + + theSurveyIndex = 0; + theSurveyValues = &*cscSurveys; + theSurveyErrors = &*cscSurveyErrors; + std::vector endcaps = theAlignableMuon->CSCEndcaps(); + for (std::vector::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) { + addSurveyInfo_(*iter); + } + } + } + +} + + +////////////////////////////////////////////////// +// a templated method - but private, so not accessible from outside +// ==> does not have to be in header file +template +void PCLTrackerAlProducer::applyDB(G* geometry, const edm::EventSetup &iSetup, + const AlignTransform &globalCoordinates) const +{ + // 'G' is the geometry class for that DB should be applied, + // 'Rcd' is the record class for its Alignments + // 'ErrRcd' is the record class for its AlignmentErrorsExtended + // 'globalCoordinates' are global transformation for this geometry + + const Rcd & record = iSetup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval & validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); + if (first!=edm::IOVSyncValue::beginOfTime() || + last!=edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=PCLTrackerAlProducer::applyDB" + << "\nTrying to apply " + << record.key().name() + << " with multiple IOVs in tag.\n" + << "Validity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } + + edm::ESHandle alignments; + record.get(alignments); + + edm::ESHandle alignmentErrors; + iSetup.get().get(alignmentErrors); + + GeometryAligner aligner; + aligner.applyAlignments(geometry, &(*alignments), &(*alignmentErrors), + globalCoordinates); +} + + +////////////////////////////////////////////////// +// a templated method - but private, so not accessible from outside +// ==> does not have to be in header file +template +void PCLTrackerAlProducer::applyDB(G* geometry, const edm::EventSetup &iSetup) const +{ + // 'G' is the geometry class for that DB should be applied, + // 'DeformationRcd' is the record class for its surface deformations + + const DeformationRcd & record = iSetup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval & validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); + if (first!=edm::IOVSyncValue::beginOfTime() || + last!=edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=PCLTrackerAlProducer::applyDB" + << "\nTrying to apply " + << record.key().name() + << " with multiple IOVs in tag.\n" + << "Validity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } + edm::ESHandle surfaceDeformations; + record.get(surfaceDeformations); + + GeometryAligner aligner; + aligner.attachSurfaceDeformations(geometry, &(*surfaceDeformations)); +} + +////////////////////////////////////////////////// +void PCLTrackerAlProducer::writeForRunRange(cond::Time_t time) +{ + if ( doTracker_ ) { // first tracker + const AlignTransform *trackerGlobal = 0; // will be 'removed' from constants + if (globalPositions_) { // i.e. applied before in applyDB + trackerGlobal = &align::DetectorGlobalPosition(*globalPositions_, + DetId(DetId::Tracker)); + } + + Alignments *alignments = theAlignableTracker->alignments(); + AlignmentErrorsExtended *alignmentErrors = theAlignableTracker->alignmentErrors(); + this->writeDB(alignments, "TrackerAlignmentRcd", + alignmentErrors, "TrackerAlignmentErrorExtendedRcd", trackerGlobal, + time); + } + + if ( doMuon_ ) { // now muon + const AlignTransform *muonGlobal = 0; // will be 'removed' from constants + if (globalPositions_) { // i.e. applied before in applyDB + muonGlobal = &align::DetectorGlobalPosition(*globalPositions_, + DetId(DetId::Muon)); + } + // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete + Alignments *alignments = theAlignableMuon->dtAlignments(); + AlignmentErrorsExtended *alignmentErrors = theAlignableMuon->dtAlignmentErrorsExtended(); + this->writeDB(alignments, "DTAlignmentRcd", + alignmentErrors, "DTAlignmentErrorExtendedRcd", muonGlobal, + time); + + // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete + alignments = theAlignableMuon->cscAlignments(); + alignmentErrors = theAlignableMuon->cscAlignmentErrorsExtended(); + this->writeDB(alignments, "CSCAlignmentRcd", + alignmentErrors, "CSCAlignmentErrorExtendedRcd", muonGlobal, + time); + } + + // Save surface deformations to database + if (saveDeformationsToDB_ && doTracker_) { + AlignmentSurfaceDeformations *alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations(); + this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time); + } +} + +////////////////////////////////////////////////// +void PCLTrackerAlProducer::writeDB(Alignments *alignments, + const std::string &alignRcd, + AlignmentErrorsExtended *alignmentErrors, + const std::string &errRcd, + const AlignTransform *globalCoordinates, + cond::Time_t time) const +{ + Alignments * tempAlignments = alignments; + AlignmentErrorsExtended * tempAlignmentErrorsExtended = alignmentErrors; + + // Call service + edm::Service poolDb; + if (!poolDb.isAvailable()) { // Die if not available + delete tempAlignments; // promised to take over ownership... + delete tempAlignmentErrorsExtended; // dito + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; + } + + if (globalCoordinates // happens only if (applyDbAlignment_ == true) + && globalCoordinates->transform() != AlignTransform::Transform::Identity) { + + tempAlignments = new Alignments(); // temporary storage for + tempAlignmentErrorsExtended = new AlignmentErrorsExtended(); // final alignments and errors + + GeometryAligner aligner; + aligner.removeGlobalTransform(alignments, alignmentErrors, + *globalCoordinates, + tempAlignments, tempAlignmentErrorsExtended); + + delete alignments; // have to delete original alignments + delete alignmentErrors; // same thing for the errors + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::writeDB" + << "globalCoordinates removed from alignments (" << alignRcd + << ") and errors (" << alignRcd << ")."; + } + + if (saveToDB_) { + edm::LogInfo("Alignment") << "Writing Alignments for run " << time + << " to " << alignRcd << "."; + poolDb->writeOne(tempAlignments, time, alignRcd); + } else { // poolDb->writeOne(..) takes over 'alignments' ownership,... + delete tempAlignments; // ...otherwise we have to delete, as promised! + } + + if (saveApeToDB_) { + edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " << time + << " to " << errRcd << "."; + poolDb->writeOne(tempAlignmentErrorsExtended, time, errRcd); + } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,... + delete tempAlignmentErrorsExtended; // ...otherwise we have to delete, as promised! + } +} + + +////////////////////////////////////////////////// +void PCLTrackerAlProducer::writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations, + const std::string &surfaceDeformationRcd, + cond::Time_t time) const +{ + // Call service + edm::Service poolDb; + if (!poolDb.isAvailable()) { // Die if not available + delete alignmentSurfaceDeformations; // promised to take over ownership... + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; + } + + if (saveDeformationsToDB_) { + edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time + << " to " << surfaceDeformationRcd << "."; + poolDb->writeOne(alignmentSurfaceDeformations, time, + surfaceDeformationRcd); + } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,... + delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised! + } +} + +PCLTrackerAlProducer::RunRanges +PCLTrackerAlProducer::makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet) +{ + static bool oldRunRangeSelectionWarning = false; + + const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue; + const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue; + + RunRanges uniqueRunRanges; + if (!RunRangeSelectionVPSet.empty()) { + + std::map uniqueFirstRunNumbers; + + for (std::vector::const_iterator ipset = RunRangeSelectionVPSet.begin(); + ipset != RunRangeSelectionVPSet.end(); + ++ipset) { + const std::vector RunRangeStrings = (*ipset).getParameter >("RunRanges"); + for (std::vector::const_iterator irange = RunRangeStrings.begin(); + irange != RunRangeStrings.end(); + ++irange) { + + if ((*irange).find(':')==std::string::npos) { + + RunNumber first = beginValue; + long int temp = strtol((*irange).c_str(), 0, 0); + if (temp!=-1) first = temp; + uniqueFirstRunNumbers[first] = first; + + } else { + + if (!oldRunRangeSelectionWarning) { + edm::LogWarning("BadConfig") << "@SUB=PCLTrackerAlProducer::makeNonOverlappingRunRanges" + << "Config file contains old format for 'RunRangeSelection'. Only the start run\n" + << "number is used internally. The number of the last run is ignored and can be\n" + << "safely removed from the config file.\n"; + oldRunRangeSelectionWarning = true; + } + + std::vector tokens = edm::tokenize(*irange, ":"); + long int temp; + RunNumber first = beginValue; + temp = strtol(tokens[0].c_str(), 0, 0); + if (temp!=-1) first = temp; + uniqueFirstRunNumbers[first] = first; + } + } + } + + for (std::map::iterator iFirst = uniqueFirstRunNumbers.begin(); + iFirst!=uniqueFirstRunNumbers.end(); + ++iFirst) { + uniqueRunRanges.push_back(std::pair((*iFirst).first, endValue)); + } + for (unsigned int i = 0;i(beginValue, endValue)); + + } + + return uniqueRunRanges; +} + +DEFINE_FWK_MODULE(PCLTrackerAlProducer); diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h new file mode 100644 index 0000000000000..b9227af5619ac --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -0,0 +1,193 @@ +#ifndef Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h +#define Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h + +/// \class AlignmentProducer +/// +/// Package : Alignment/CommonAlignmentProducer +/// Description : calls alignment algorithms +/// +/// \author : Frederic Ronga +/// Revision : $Revision: 1.27 $ +/// last update: $Date: 2012/06/13 16:23:30 $ +/// by : $Author: yana $ + +#include + +// Framework +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "DataFormats/Provenance/interface/RunID.h" + +// Geometry +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" + +// Alignment +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" +#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include "Alignment/CommonAlignment/interface/AlignableExtras.h" +#include "Alignment/TrackerAlignment/interface/AlignableTracker.h" +#include "Alignment/MuonAlignment/interface/AlignableMuon.h" +#include +#include "CondCore/DBCommon/interface/Time.h" +#include "CondFormats/Alignment/interface/Alignments.h" +#include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" + +// for watcher +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTSurveyErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h" + + +class Alignments; +class IntegratedCalibrationBase; +class SurveyErrors; +namespace edm { + class Run; + class LuminosityBlock; +} + +class PCLTrackerAlProducer : public edm::EDAnalyzer +{ + + public: + typedef std::vector Alignables; + typedef std::pair ConstTrajTrackPair; + typedef std::vector ConstTrajTrackPairCollection; + + typedef AlignmentAlgorithmBase::RunNumber RunNumber; + typedef AlignmentAlgorithmBase::RunRange RunRange; + typedef std::vector RunRanges; + + /// Constructor + PCLTrackerAlProducer( const edm::ParameterSet& iConfig ); + + /// Destructor + ~PCLTrackerAlProducer(); + + /// Called at beginning of job + virtual void beginOfJob(); + + /// Called at end of job + virtual void endOfJob(); + + /// Called at run start and calling algorithms beginRun + virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup); + /// Called at run end - currently reading TkFittedLasBeam if an InpuTag is given for that + virtual void endRun(const edm::Run &run, const edm::EventSetup &setup); + + /// Called at lumi block start, calling algorithm's beginLuminosityBlock + virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, + const edm::EventSetup &setup); + /// Called at lumi block end, calling algorithm's endLuminosityBlock + virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, + const edm::EventSetup &setup); + /// Called at each event + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + private: + + // private member functions + void init(const edm::EventSetup&); + + /// Apply random shifts and rotations to selected alignables, according to configuration + void simpleMisalignment_(const Alignables &alivec, const std::string &selection, + float shift, float rot, bool local); + + /// Create tracker and muon geometries + void createGeometries_( const edm::EventSetup& ); + + /// Apply DB constants belonging to (Err)Rcd to geometry, + /// taking into account 'globalPosition' correction. + template + void applyDB(G *geometry, const edm::EventSetup &iSetup, + const AlignTransform &globalPosition) const; + /// Apply DB constants for surface deformations + template + void applyDB(G *geometry, const edm::EventSetup &iSetup) const; + + // write alignments and alignment errors for all sub detectors and + // the given run number + void writeForRunRange(cond::Time_t time); + + /// Write alignment and/or errors to DB for record names + /// (removes *globalCoordinates before writing if non-null...). + /// Takes over ownership of alignments and alignmentErrrors. + void writeDB(Alignments *alignments, const std::string &alignRcd, + AlignmentErrorsExtended *alignmentErrors, const std::string &errRcd, + const AlignTransform *globalCoordinates, + cond::Time_t time) const; + /// Write surface deformations (bows & kinks) to DB for given record name + /// Takes over ownership of alignmentsurfaceDeformations. + void writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations, + const std::string &surfaceDeformationRcd, + cond::Time_t time) const; + + /// Add survey info to an alignable + void addSurveyInfo_(Alignable*); + + /// read in survey records + void readInSurveyRcds( const edm::EventSetup& ); + + RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet); + + // private data members + + unsigned int theSurveyIndex; + const Alignments* theSurveyValues; + const SurveyErrors* theSurveyErrors; + + AlignmentAlgorithmBase* theAlignmentAlgo; + AlignmentParameterStore* theAlignmentParameterStore; + std::vector theMonitors; + std::vector theCalibrations; + + AlignableExtras* theAlignableExtras; + AlignableTracker* theAlignableTracker; + AlignableMuon* theAlignableMuon; + + boost::shared_ptr theTracker; + boost::shared_ptr theMuonDT; + boost::shared_ptr theMuonCSC; + /// GlobalPositions that might be read from DB, NULL otherwise + const Alignments *globalPositions_; + + int nevent_; + edm::ParameterSet theParameterSet; + + // steering parameters + + const unsigned int theMaxLoops; // Number of loops to loop + + const int stNFixAlignables_; + const double stRandomShift_,stRandomRotation_; + const bool applyDbAlignment_,checkDbAlignmentValidity_; + const bool doMisalignmentScenario_; + const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_; + const bool doTracker_,doMuon_,useExtras_; + const bool useSurvey_; // true to read survey info from DB + + // event input tags + const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories + const edm::InputTag beamSpotTag_; // beam spot + const edm::InputTag tkLasBeamTag_; // LAS beams in edm::Run (ignore if empty) + const edm::InputTag clusterValueMapTag_; // ValueMap containing associtaion cluster - flag + + // ESWatcher + edm::ESWatcher watchTkSurveyRcd_; + edm::ESWatcher watchTkSurveyErrRcd_; + edm::ESWatcher watchDTSurveyRcd_; + edm::ESWatcher watchDTSurveyErrRcd_; + edm::ESWatcher watchCSCSurveyRcd_; + edm::ESWatcher watchCSCSurveyErrRcd_; + + edm::ESWatcher watchTrackerAlRcd; +}; + +#endif diff --git a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py index 923e1998d30a7..24c6bb5376c0f 100644 --- a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py +++ b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py @@ -12,7 +12,7 @@ from Alignment.CommonAlignmentAlgorithm.AlignmentParameterStore_cfi import * #looper = cms.Looper("AlignmentProducer", -AlignmentProducer = cms.EDAnalyzer("TrackerAlignmentProducerForPCL", +AlignmentProducer = cms.EDAnalyzer("PCLTrackerAlProducer", AlignmentParameterStore, # configuration of AlignmentParameterStore useExtras = cms.untracked.bool(False), # Read survey info from DB: true requires configuration of PoolDBESSource diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index a31795ab91881..114256b4ee77f 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -274,10 +274,12 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra // Call at end of job --------------------------------------------------------- //____________________________________________________ -void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) { +void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) +{ terminate(); } -void MillePedeAlignmentAlgorithm::terminate() { +void MillePedeAlignmentAlgorithm::terminate() +{ delete theMille;// delete to close binary before running pede below (flush would be enough...) theMille = 0; From afea60977307005c907bbbf18311fa31b8831082 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 11:58:29 +0200 Subject: [PATCH 015/104] in 74X we keep using TrackerAlignmentProducerForPCL --- .../CommonAlignmentProducer/plugins/BuildFile.xml | 14 -------------- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index 1ca1e71042a15..3cef465cc4a55 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -31,20 +31,6 @@ - - - - - - - - - - - - - - diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index c531d7f669dca..dde91f4c2454c 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -7,7 +7,7 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli = copy.deepcopy(hltHighLevel) ALCARECOTkAlMinBiasFilterForSiPixelAli.HLTPaths = ['pathALCARECOTkAlMinBias'] ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names -ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") +ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","reRECO") From bee8b026652532d7e9496ab2749ed034572af0d8 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 11:58:58 +0200 Subject: [PATCH 016/104] hack to use RelVals for tests --- .../python/TrackerAlignmentProducerForPCL_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py index 24c6bb5376c0f..923e1998d30a7 100644 --- a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py +++ b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py @@ -12,7 +12,7 @@ from Alignment.CommonAlignmentAlgorithm.AlignmentParameterStore_cfi import * #looper = cms.Looper("AlignmentProducer", -AlignmentProducer = cms.EDAnalyzer("PCLTrackerAlProducer", +AlignmentProducer = cms.EDAnalyzer("TrackerAlignmentProducerForPCL", AlignmentParameterStore, # configuration of AlignmentParameterStore useExtras = cms.untracked.bool(False), # Read survey info from DB: true requires configuration of PoolDBESSource From 054b6c1bf3d99f87242a2de673efc910d4e8785e Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 11:59:28 +0200 Subject: [PATCH 017/104] from TrackerAlignmentErrorRcd to TrackerAlignmentErrorExtendedRcd --- .../plugins/TrackerAlignmentProducerForPCL.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc index 69d6ee9ac929a..d8ed3efedf8c7 100644 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc @@ -30,10 +30,10 @@ #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" @@ -277,7 +277,7 @@ void TrackerAlignmentProducerForPCL::init(const edm::EventSetup& setup) { setup.get().get(globalPositionRcd); globalPositions = new Alignments(*globalPositionRcd); - applyDB( + applyDB( &(*theTracker), setup, align::DetectorGlobalPosition(*globalPositions, DetId(DetId::Tracker)) @@ -658,7 +658,7 @@ void TrackerAlignmentProducerForPCL::writeForRunRange(cond::Time_t time) { AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors(); writeDB(alignments, "TrackerAlignmentRcd", - alignmentErrors, "TrackerAlignmentErrorRcd", + alignmentErrors, "TrackerAlignmentErrorExtendedRcd", trackerGlobal, time); @@ -860,7 +860,7 @@ void TrackerAlignmentProducerForPCL::readInSurveyRcds(const edm::EventSetup& set edm::ESHandle surveyErrors; setup.get().get(surveys); - setup.get().get(surveyErrors); + setup.get().get(surveyErrors); theSurveyIndex = 0; theSurveyValues = &*surveys; From f56637367933d94c1fcfd94ad2eac71895f2133f Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Tue, 2 Jun 2015 11:10:46 +0200 Subject: [PATCH 018/104] Adding minimal set of necessary files that could make something work --- .../plugins/BuildFile.xml | 6 ++ .../plugins/MillePedeFileConverter.cc | 74 +++++++++++++++ .../plugins/MillePedeFileConverter.h | 38 ++++++++ .../python/MillePedeFileConverter_cfg.py | 33 +++++++ .../plugins/BuildFile.xml | 5 + .../plugins/MillePedeFileExtractor.cc | 91 +++++++++++++++++++ .../plugins/MillePedeFileExtractor.h | 37 ++++++++ .../python/MillePedeFileExtractor_cfg.py | 26 ++++++ CondFormats/Common/src/classes.h | 6 +- CondFormats/Common/src/classes_def.xml | 9 +- 10 files changed, 319 insertions(+), 6 deletions(-) create mode 100644 Alignment/MillePedeFileConverter/plugins/BuildFile.xml create mode 100644 Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc create mode 100644 Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h create mode 100644 Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py create mode 100644 Alignment/MillePedeFileExtractor/plugins/BuildFile.xml create mode 100644 Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc create mode 100644 Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h create mode 100644 Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py diff --git a/Alignment/MillePedeFileConverter/plugins/BuildFile.xml b/Alignment/MillePedeFileConverter/plugins/BuildFile.xml new file mode 100644 index 0000000000000..19cece5899f65 --- /dev/null +++ b/Alignment/MillePedeFileConverter/plugins/BuildFile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc b/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc new file mode 100644 index 0000000000000..27566fd866d4c --- /dev/null +++ b/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc @@ -0,0 +1,74 @@ +// Original Author: Broen van Besien +// Created: Thu, 19 Mar 2015 18:12:35 GMT + +#include "Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "CondFormats/Common/interface/FileBlob.h" + +#include +#include +#include + +MillePedeFileConverter::MillePedeFileConverter(const edm::ParameterSet& iConfig) + : theInputDir(iConfig.getParameter("fileDir")), + theInputFileName(iConfig.getParameter("inputBinaryFile")), + theFileBlobLabel(iConfig.getParameter("fileBlobLabel")) { + // We define what this producer produces: A vector of FileBlobs + produces, edm::InRun>(theFileBlobLabel); +} + +MillePedeFileConverter::~MillePedeFileConverter() {} + +void MillePedeFileConverter::endRunProduce(edm::Run& iRun, + const edm::EventSetup& iSetup) { + edm::LogInfo("MillePedeFileActions") + << "Inserting all data from file " << theInputDir + theInputFileName + << " as a FileBlob to the run, using label \"" << theFileBlobLabel + << "\"."; + // Preparing the vector of FileBlobs: + std::unique_ptr> theVectorOfFileBlobs( + new std::vector()); + FileBlob theFileBlob; + try { + // Creating the FileBlob: + // (The FileBlob will signal problems with the file itself.) + theFileBlob = FileBlob(theInputDir + theInputFileName, true); + } + catch (...) { + // When creation of the FileBlob fails: + edm::LogError("MillePedeFileActions") + << "Error: No FileBlob could be created from the file \"" + << theInputDir + theInputFileName << "\"."; + throw; + } + if (theFileBlob.size() > 0) { + // Adding the FileBlob to the run: + theVectorOfFileBlobs->push_back(theFileBlob); + iRun.put(std::move(theVectorOfFileBlobs), theFileBlobLabel); + } +} + +// Manage the parameters for the module: +// (Note that this will autogenerate the _cfi.py file.) +void MillePedeFileConverter::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("fileDir", "")->setComment( + "Keep the fileDir empty if you want to write to the current " + "directory. If you use it, it should end with a slash."); + + desc.add("inputBinaryFile", "milleBinaryISN.dat")->setComment( + "Filename of the file created by Mille in the AlignmentProducer"); + + desc.add("fileBlobLabel", "milleBinaryISN.dat")->setComment( + "It's probably a good idea to keep the label the same as the " + "original filename(s). See configuration of " + "MillePedeFileExtractor, it should be the same there."); + + descriptions.add("millePedeFileConverter", desc); + descriptions.setComment( + "This is the generic cfi file for the " + "MillePedeFileConverter"); +} diff --git a/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h b/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h new file mode 100644 index 0000000000000..4741a736760bb --- /dev/null +++ b/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h @@ -0,0 +1,38 @@ +#ifndef MillePedeFileConverter_h +#define MillePedeFileConverter_h + +// Original Author: Broen van Besien +// Created: Thu, 19 Mar 2015 18:12:35 GMT + +/* + * This producer... blahblahblha... BVB: TODO + * + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class MillePedeFileConverter + : public edm::one::EDProducer { + public: + explicit MillePedeFileConverter(const edm::ParameterSet&); + ~MillePedeFileConverter(); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + virtual void produce(edm::Event&, const edm::EventSetup&) override {} + virtual void endRunProduce(edm::Run& run, + const edm::EventSetup& iSetup) override final; + + std::string theInputDir; + std::string theInputFileName; + std::string theFileBlobLabel; +}; + +// define this as a plug-in +DEFINE_FWK_MODULE(MillePedeFileConverter); + +#endif diff --git a/Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py b/Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py new file mode 100644 index 0000000000000..4d27aec5d2eef --- /dev/null +++ b/Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py @@ -0,0 +1,33 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("MillePedeFileConverter") + +process.load("FWCore.MessageService.MessageLogger_cfi") + +# Using the normal standard messagelogger, with its standard configuration, +# but setting the category of messages to MillePedeFileActions +process.MessageLogger = process.MessageLogger.clone( + categories = cms.untracked.vstring('MillePedeFileActions'), + ) + +# Limit our test to 5 events (we work on run level anyway) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(5) ) + +process.source = cms.Source("PoolSource", + # replace 'myfile.root' with the source file you want to use + fileNames = cms.untracked.vstring( + "file:step1.root" + ) +) + +# Loading the autogenerated millePedeFileConverter_cfi: +from Alignment.MillePedeFileConverter.millePedeFileConverter_cfi import millePedeFileConverter +process.testMillePedeFileConverter = millePedeFileConverter.clone() + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('myOutputFile.root') +) + +process.p = cms.Path(process.testMillePedeFileConverter) + +process.e = cms.EndPath(process.out) diff --git a/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml b/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml new file mode 100644 index 0000000000000..3b48f173e379a --- /dev/null +++ b/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc b/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc new file mode 100644 index 0000000000000..d9791b2569fbf --- /dev/null +++ b/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc @@ -0,0 +1,91 @@ +// Original Author: Broen van Besien +// Created: Mon, 23 Mar 2015 14:56:15 GMT + +#include +#include + +#include "Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "CondFormats/Common/interface/FileBlob.h" + +MillePedeFileExtractor::MillePedeFileExtractor(const edm::ParameterSet& iConfig) + : theOutputDir(iConfig.getParameter("fileDir")), + theOutputFileName(iConfig.getParameter("outputBinaryFile")), + theFileBlobModule(iConfig.getParameter("fileBlobModule")), + theFileBlobLabel(iConfig.getParameter("fileBlobLabel")) { + // nothing else in the constructor +} + +MillePedeFileExtractor::~MillePedeFileExtractor() {} + +void MillePedeFileExtractor::beginRun(const edm::Run& iRun, + edm::EventSetup const&) { + // Getting our hands on the vector of FileBlobs + edm::Handle> theVectorOfFileBlobs; + iRun.getByLabel(theFileBlobModule, theFileBlobLabel, theVectorOfFileBlobs); + if (theVectorOfFileBlobs.isValid()) { + // Logging the amount of FileBlobs in the vector + int theVectorSize = theVectorOfFileBlobs->size(); + edm::LogInfo("MillePedeFileActions") << "Root file contains " + << theVectorSize << " FileBlob(s)."; + // Loop over the FileBlobs in the vector, and write them to files: + for (std::vector::const_iterator it = + theVectorOfFileBlobs->begin(); + it != theVectorOfFileBlobs->end(); ++it) { + // We format the filename with a number, starting from 0 to the size of + // our vector. + // For this to work, the outputBinaryFile config parameter must contain a + // formatting directive for a number, like %04d. + char theNumberedOutputFileName[200]; + int theNumber = it - theVectorOfFileBlobs->begin(); + sprintf(theNumberedOutputFileName, theOutputFileName.c_str(), theNumber); + // Log the filename to which we will write... + edm::LogInfo("MillePedeFileActions") + << "Writing FileBlob file to file " + << theOutputDir + theNumberedOutputFileName << "."; + // ...and perform the writing operation. + it->write(theOutputDir + theNumberedOutputFileName); + // Carefull, it seems that when writing to an impossible file, this is + // swallowed by the FileBlob->write operation and no error is thrown. + } + } else { + edm::LogError("MillePedeFileActions") + << "Error: The root file does not contain any vector of FileBlob " + "created by module \"" << theFileBlobModule << "\", with label \"" + << theFileBlobLabel << "\"."; + } +} + +// Manage the parameters for the module: +// (Note that this will autogenerate the _cfi.py file.) +void MillePedeFileExtractor::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("fileDir", "")->setComment( + "Keep the fileDir empty if you want to write to the current " + "directory."); + + desc.add("outputBinaryFile", "milleBinaryISN%04d.dat") + ->setComment( + "Base filename of the files that will be created. This must " + "contain " + "a placeholder for an index number in the standard C formatting " + "style, like %04d."); + + desc.add("fileBlobModule", "millePedeFileConverter")->setComment( + "Name of the module that should have generated the blob in the " + "root file. Make sure you overwrite this, if you have changed " + "this is the configuration of the MillePedeFileConverter."); + + desc.add("fileBlobLabel", "milleBinaryISN.dat")->setComment( + "It's probably a good idea to keep the label the same as the " + "original filename(s). See configuration of " + "MillePedeFileConverter, it should be the same there."); + + descriptions.add("millePedeFileExtractor", desc); + descriptions.setComment( + "This is the generic cfi file for the " + "MillePedeFileExtractor"); +} diff --git a/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h b/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h new file mode 100644 index 0000000000000..82ec844be5c16 --- /dev/null +++ b/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h @@ -0,0 +1,37 @@ +#ifndef MillePedeFileConverter_h +#define MillePedeFileConverter_h + +// Original Author: Broen van Besien +// Created: Mon, 23 Mar 2015 14:56:15 GMT + +/* + * This analyzer... blahblahblha... BVB: TODO + * + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class MillePedeFileExtractor : public edm::EDAnalyzer { + public: + explicit MillePedeFileExtractor(const edm::ParameterSet&); + ~MillePedeFileExtractor(); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; + void analyze(const edm::Event&, const edm::EventSetup&) {} + + std::string theOutputDir; + std::string theOutputFileName; + std::string theFileBlobModule; + std::string theFileBlobLabel; +}; + +// define this as a plug-in +DEFINE_FWK_MODULE(MillePedeFileExtractor); + +#endif diff --git a/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py b/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py new file mode 100644 index 0000000000000..ce0d04cdd165b --- /dev/null +++ b/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py @@ -0,0 +1,26 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("MillePedeFileExtractor") + +process.load("FWCore.MessageService.MessageLogger_cfi") + +# Using the normal standard messagelogger, with its standard configuration, +# but setting the category of messages to MillePedeFileActions +process.MessageLogger = process.MessageLogger.clone( + categories = cms.untracked.vstring('MillePedeFileActions'), + ) + +# Limit our test to 5 events (we work on run level anyway) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(5) ) + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:myOutputFile.root' + ) +) + +from Alignment.MillePedeFileExtractor.millePedeFileExtractor_cfi import millePedeFileExtractor +process.testMillePedeFileExtractor = millePedeFileExtractor.clone( + fileBlobModule = cms.string("testMillePedeFileConverter")) + +process.p = cms.Path(process.testMillePedeFileExtractor) diff --git a/CondFormats/Common/src/classes.h b/CondFormats/Common/src/classes.h index ac353519a5ee4..a91625a38c3cb 100644 --- a/CondFormats/Common/src/classes.h +++ b/CondFormats/Common/src/classes.h @@ -1,5 +1,5 @@ #include "CondFormats/Common/src/headers.h" - +#include "DataFormats/Common/interface/Wrapper.h" namespace CondFormats_Common { struct dictionary { @@ -12,6 +12,10 @@ namespace CondFormats_Common { std::map amap1; std::map, DropBoxMetadata::Parameters> amap2; + + std::vector dummyVectorFileBlob; + // The space between the two > > is actually obligatory: + edm::Wrapper > dummyWrapperVectorFileBlob; }; } diff --git a/CondFormats/Common/src/classes_def.xml b/CondFormats/Common/src/classes_def.xml index 4406d6795c58f..2a01926d38190 100644 --- a/CondFormats/Common/src/classes_def.xml +++ b/CondFormats/Common/src/classes_def.xml @@ -14,9 +14,6 @@ - - - @@ -25,6 +22,8 @@ + + @@ -38,7 +37,7 @@ - + @@ -61,4 +60,4 @@ - + From d516faa450c310f401597be64b0e0469634b0fad Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Tue, 2 Jun 2015 11:15:53 +0200 Subject: [PATCH 019/104] Resolving issues in classes_def.xml caused by inbetween updates of others --- CondFormats/Common/src/classes_def.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CondFormats/Common/src/classes_def.xml b/CondFormats/Common/src/classes_def.xml index 2a01926d38190..424cce69424ce 100644 --- a/CondFormats/Common/src/classes_def.xml +++ b/CondFormats/Common/src/classes_def.xml @@ -14,6 +14,9 @@ + + + From c1b8e33b9109d494e48507fbb5ba5b9e9350289a Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 12:57:33 +0200 Subject: [PATCH 020/104] add the file handling module to the sequence and to the output of the alcareco --- .../ALCARECOPromptCalibProdSiPixelAli_Output_cff.py | 3 +-- .../python/ALCARECOPromptCalibProdSiPixelAli_cff.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py index 0b161e11b5c80..152d6bb98f215 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_Output_cff.py @@ -5,8 +5,7 @@ SelectEvents = cms.vstring('pathALCARECOPromptCalibProdSiPixelAli') ), outputCommands = cms.untracked.vstring( - 'keep *_alcaBeamSpotProducer_*_*', - 'keep *_MEtoEDMConvertSiStrip_*_*') + 'keep *_SiPixelAliMillePedeFileConverter_*_*') ) import copy diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index dde91f4c2454c..4617965b7cc90 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -177,11 +177,19 @@ ## binaryFile = looper.algoConfig.binaryFile, ## ) +SiPixelAliMillePedeFileConverter = cms.EDProducer("MillePedeFileConverter", + #FIXME: convert to untracked? + fileDir = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.fileDir.value()), + inputBinaryFile = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile.value()), + fileBlobLabel = cms.string('')) + + + seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* offlineBeamSpot* AlignmentTrackSelector* SiPixelAliTrackRefitter0* SiPixelAliTrackerTrackHitFilter* SiPixelAliTrackFitter* - SiPixelAliMilleAlignmentProducer) - ##SiPixelAliMillePedeFileConverter) + SiPixelAliMilleAlignmentProducer* + SiPixelAliMillePedeFileConverter) From abdf6ae4d6df7f901d0b7189c099ba13ddf41af9 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:15:32 +0200 Subject: [PATCH 021/104] test on files from step2 --- .../python/MillePedeFileExtractor_cfg.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py b/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py index ce0d04cdd165b..220be328f87b0 100644 --- a/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py +++ b/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py @@ -11,16 +11,21 @@ ) # Limit our test to 5 events (we work on run level anyway) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(5) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - 'file:myOutputFile.root' + 'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli.root', + 'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli_2.root' ) ) from Alignment.MillePedeFileExtractor.millePedeFileExtractor_cfi import millePedeFileExtractor process.testMillePedeFileExtractor = millePedeFileExtractor.clone( - fileBlobModule = cms.string("testMillePedeFileConverter")) + #FIXME: handle with an InputLabel instead of + fileBlobModule = cms.string("SiPixelAliMillePedeFileConverter"), + fileBlobLabel = cms.string(''), + outputBinaryFile = cms.string('pippo.dat'), + fileDir = cms.string('/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/')) process.p = cms.Path(process.testMillePedeFileExtractor) From dfa04476ee930da6766bcedc26efdd37ef88d397 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:16:43 +0200 Subject: [PATCH 022/104] move to the new EDAnalyzer for the alignment producer --- .../python/AlcaSiPixelAliHarvester_cff.py | 92 +++++++------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index 6963325b60998..81ddb471049c5 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -1,38 +1,25 @@ import FWCore.ParameterSet.Config as cms +import copy +from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * +from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer +SiPixelAliPedeAlignmentProducer = copy.deepcopy(AlignmentProducer) - - -# Alignment producer -from Alignment.CommonAlignmentProducer.AlignmentProducer_cff import * - -#process.AlignmentProducer.parameterTypes = cms.vstring('Selector,RigidBody') -#process.AlignmentProducer.ParameterBuilder.parameterTypes = [ -# 'SelectorRigid,RigidBody', -# 'SelectorBowed,BowedSurface' -# ,'Selector2Bowed,TwoBowedSurfaces' -# ] -looper.ParameterBuilder.Selector = cms.PSet( +SiPixelAliPedeAlignmentProducer.ParameterBuilder.Selector = cms.PSet( alignParams = cms.vstring( 'TrackerTPBHalfBarrel,111111', 'TrackerTPEHalfCylinder,111111', -# 'TrackerTPBLayer,111111', -# 'TrackerTPEHalfDisk,111111', - 'TrackerTIBHalfBarrel,ffffff', # or fff fff? - 'TrackerTOBHalfBarrel,ffffff', # dito... + 'TrackerTIBHalfBarrel,ffffff', + 'TrackerTOBHalfBarrel,rrrrrr', 'TrackerTIDEndcap,ffffff', 'TrackerTECEndcap,ffffff' ) ) -looper.doMisalignmentScenario = False #True +SiPixelAliPedeAlignmentProducer.doMisalignmentScenario = False #True -# If the above is true, you might want to choose the scenario: -#from Alignment.TrackerAlignment.Scenarios_cff import Tracker10pbScenario as Scenario # TrackerSurveyLASOnlyScenario - -#FIXME: is this needed given the above parameters? -looper.MisalignmentScenario = cms.PSet( +SiPixelAliPedeAlignmentProducer.MisalignmentScenario = cms.PSet( setRotations = cms.bool(True), setTranslations = cms.bool(True), seed = cms.int32(1234567), @@ -45,7 +32,7 @@ phiXlocal = cms.double(1.e-4), phiYlocal = cms.double(-2.e-4), phiZlocal = cms.double(5.e-4), - + ), TPBHalfBarrel2 = cms.PSet( dXlocal = cms.double(-0.0020), @@ -92,38 +79,27 @@ phiZlocal = cms.double(3.e-4), ), ) - - - ) -looper.checkDbAlignmentValidity = False - -looper.applyDbAlignment = True - - -looper.tjTkAssociationMapTag = 'TrackFitter' - -# assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well): -looper.algoConfig = MillePedeAlignmentAlgorithm - -#from Alignment.MillePedeAlignmentAlgorithm.PresigmaScenarios_cff import * -#looper.algoConfig.pedeSteerer.Presigmas.extend(TrackerShortTermPresigmas.Presigmas) -looper.algoConfig.mode = 'pede' #'mille' #'full' # 'pede' # 'full' # 'pedeSteerer' -#looper.algoConfig.mergeBinaryFiles = ['milleBinaryISN.dat'] -#looper.algoConfig.mergeTreeFiles = ['treeFileISN_reg.root'] -looper.algoConfig.binaryFile = 'milleBinaryISN.dat' -looper.algoConfig.treeFile = 'treeFileISN.root' - - - - -looper.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory -looper.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' -#looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/f/flucke/cms/pede/trunk_v69/pede_8GB' -#FIXME: this needs to come from the release -looper.algoConfig.pedeSteerer.pedeCommand = '/afs/cern.ch/user/c/ckleinw/bin/rev125/pede' -#default is sparseMINRES 6 0.8: n(iter) Delta(F) -looper.algoConfig.pedeSteerer.method = 'inversion 5 0.8' ##DNOONAN can be set to inversion instead (faster) -looper.algoConfig.pedeSteerer.options = cms.vstring( +) + +SiPixelAliPedeAlignmentProducer.checkDbAlignmentValidity = False +SiPixelAliPedeAlignmentProducer.applyDbAlignment = True +SiPixelAliPedeAlignmentProducer.tjTkAssociationMapTag = 'TrackRefitter2' + +SiPixelAliPedeAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm +SiPixelAliPedeAlignmentProducer.algoConfig.mode = 'pede' +# FIXME: this needs to be addressed +SiPixelAliPedeAlignmentProducer.algoConfig.mergeBinaryFiles = [ + 'milleBinary0.dat' + ] +SiPixelAliPedeAlignmentProducer.algoConfig.monitorFile = 'millePedeMonitor_pede.root' +SiPixelAliPedeAlignmentProducer.algoConfig.binaryFile = '' +SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesBzeroTrajectoryFactory +SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 +SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' +SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers +SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.pedeCommand = 'pede' +SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' +SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.options = cms.vstring( #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum 'entries 500', 'chisqcut 30.0 4.5', #, @@ -131,10 +107,10 @@ #'outlierdownweighting 3','dwfractioncut 0.1' #'outlierdownweighting 5','dwfractioncut 0.2' ) +SiPixelAliPedeAlignmentProducer.algoConfig.minNumHits = 8 -looper.algoConfig.minNumHits = 8 - from Alignment.FileConverterPlaceHolder.fileconverterplaceholder_cfi import * -ALCAHARVESTSiPixelAli = cms.Sequence(demo) +ALCAHARVESTSiPixelAli = cms.Sequence(SiPixelAliPedeAlignmentProducer* + demo) From 7f1b919230558acf7aeca6d4d6b0af1025b99a03 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:17:18 +0200 Subject: [PATCH 023/104] move DB writing to endRun and initializtion fromn analyze to beginRun --- .../plugins/TrackerAlignmentProducerForPCL.cc | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc index d8ed3efedf8c7..fe221712e0e5e 100644 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc +++ b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc @@ -138,7 +138,7 @@ void TrackerAlignmentProducerForPCL::beginJob() { void TrackerAlignmentProducerForPCL::endJob() { printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - finish(); + } void TrackerAlignmentProducerForPCL::analyze(const edm::Event& event, @@ -148,12 +148,13 @@ void TrackerAlignmentProducerForPCL::analyze(const edm::Event& event, //std::cout << "TrackerAlignmentProducerForPCL::analyze " <beginRun(setup); + init(setup); } void TrackerAlignmentProducerForPCL::endRun(const edm::Run& run, const edm::EventSetup& setup) { @@ -233,6 +235,9 @@ void TrackerAlignmentProducerForPCL::endRun(const edm::Run& run, const edm::Even << "No Tk LAS beams to forward to algorithm."; theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); } + + finish(); + } void TrackerAlignmentProducerForPCL::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, @@ -393,17 +398,17 @@ void TrackerAlignmentProducerForPCL::finish() { edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish"; /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ - if (0 == nevent_) { - // beginOfJob is usually called by the framework in the first event of the first loop - // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) - // and the algorithms rely on the initialisations done in beginOfJob. We cannot call - // this->beginOfJob(iSetup); here either since that will access the EventSetup to get - // some geometry information that is not defined either without having seen an event. - edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" - << "Did not process any events, " - << "stop processing without terminating algorithm."; - return; - } + // if (0 == nevent_) { + // // beginOfJob is usually called by the framework in the first event of the first loop + // // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) + // // and the algorithms rely on the initialisations done in beginOfJob. We cannot call + // // this->beginOfJob(iSetup); here either since that will access the EventSetup to get + // // some geometry information that is not defined either without having seen an event. + // edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" + // << "Did not process any events, " + // << "stop processing without terminating algorithm."; + // return; + // } printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" @@ -423,10 +428,10 @@ void TrackerAlignmentProducerForPCL::finish() { /* 2) Former: void AlignmentProducer::endOfJob() */ - if (0 == nevent_) { - edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" << "Did not process any " - << "events in last loop, do not dare to store to DB."; - } else { + // if (0 == nevent_) { + // edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" << "Did not process any " + // << "events in last loop, do not dare to store to DB."; + // } else { // Expand run ranges and make them unique edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); RunRanges uniqueRunRanges(makeNonOverlappingRunRanges(runRangeSelectionVPSet)); @@ -459,7 +464,7 @@ void TrackerAlignmentProducerForPCL::finish() { beamSpotParameters.push_back(beamSpotAliPars->parameters()); } } - } + // } if (theAlignableExtras) { std::ostringstream bsOutput; From c40d48f941201989d2b66f6453e342634a5dd0cd Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:31:31 +0200 Subject: [PATCH 024/104] move to the new file extractor to handle the binary files --- .../python/AlcaSiPixelAliHarvester_cff.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index 81ddb471049c5..0238527d4e520 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -1,6 +1,16 @@ import FWCore.ParameterSet.Config as cms import copy + + + + +SiPixelAliMilleFileExtractor = cms.EDAnalyzer("MillePedeFileExtractor", + #FIXME: handle with an InputLabel instead of + fileBlobModule = cms.string("SiPixelAliMillePedeFileConverter"), + fileBlobLabel = cms.string(''), + outputBinaryFile = cms.string('pippo2.dat')) + from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer SiPixelAliPedeAlignmentProducer = copy.deepcopy(AlignmentProducer) @@ -89,7 +99,7 @@ SiPixelAliPedeAlignmentProducer.algoConfig.mode = 'pede' # FIXME: this needs to be addressed SiPixelAliPedeAlignmentProducer.algoConfig.mergeBinaryFiles = [ - 'milleBinary0.dat' + SiPixelAliMilleFileExtractor.outputBinaryFile.value() ] SiPixelAliPedeAlignmentProducer.algoConfig.monitorFile = 'millePedeMonitor_pede.root' SiPixelAliPedeAlignmentProducer.algoConfig.binaryFile = '' @@ -110,7 +120,6 @@ SiPixelAliPedeAlignmentProducer.algoConfig.minNumHits = 8 -from Alignment.FileConverterPlaceHolder.fileconverterplaceholder_cfi import * -ALCAHARVESTSiPixelAli = cms.Sequence(SiPixelAliPedeAlignmentProducer* - demo) +ALCAHARVESTSiPixelAli = cms.Sequence(SiPixelAliMilleFileExtractor* + SiPixelAliPedeAlignmentProducer) From f86c91a618c64a34d070c0d47812a45b5fcce6e1 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:36:27 +0200 Subject: [PATCH 025/104] remove the placeholder for the file converter since we now have the actual implementation --- .../FileConverterPlaceHolder/BuildFile.xml | 7 - .../fileconverterplaceholder_cfg.py | 20 --- .../python/fileconverterplaceholder_cfi.py | 4 - .../src/FileConverterPlaceHolder.cc | 156 ------------------ 4 files changed, 187 deletions(-) delete mode 100644 Alignment/FileConverterPlaceHolder/BuildFile.xml delete mode 100644 Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py delete mode 100644 Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py delete mode 100644 Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc diff --git a/Alignment/FileConverterPlaceHolder/BuildFile.xml b/Alignment/FileConverterPlaceHolder/BuildFile.xml deleted file mode 100644 index e18030de98b84..0000000000000 --- a/Alignment/FileConverterPlaceHolder/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py b/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py deleted file mode 100644 index d13348ce6ebab..0000000000000 --- a/Alignment/FileConverterPlaceHolder/fileconverterplaceholder_cfg.py +++ /dev/null @@ -1,20 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("Demo") - -process.load("FWCore.MessageService.MessageLogger_cfi") - -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) - -process.source = cms.Source("PoolSource", - # replace 'myfile.root' with the source file you want to use - fileNames = cms.untracked.vstring( - 'file:myfile.root' - ) -) - -process.demo = cms.EDAnalyzer('FileConverterPlaceHolder' -) - - -process.p = cms.Path(process.demo) diff --git a/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py b/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py deleted file mode 100644 index d86c96d6bec77..0000000000000 --- a/Alignment/FileConverterPlaceHolder/python/fileconverterplaceholder_cfi.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -demo = cms.EDAnalyzer('FileConverterPlaceHolder' -) diff --git a/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc b/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc deleted file mode 100644 index 2730fbe44a7e1..0000000000000 --- a/Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc +++ /dev/null @@ -1,156 +0,0 @@ -// -*- C++ -*- -// -// Package: FileConverterPlaceHolder -// Class: FileConverterPlaceHolder -// -/**\class FileConverterPlaceHolder FileConverterPlaceHolder.cc Alignment/FileConverterPlaceHolder/src/FileConverterPlaceHolder.cc - - Description: [one line class summary] - - Implementation: - [Notes on implementation] -*/ -// -// Original Author: Gianluca Cerminara,40 5-A19,+41227679568, -// Created: Thu May 21 14:37:48 CEST 2015 -// $Id$ -// -// - - -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -// -// class declaration -// - -class FileConverterPlaceHolder : public edm::EDAnalyzer { - public: - explicit FileConverterPlaceHolder(const edm::ParameterSet&); - ~FileConverterPlaceHolder(); - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - - private: - virtual void beginJob() ; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - virtual void beginRun(edm::Run const&, edm::EventSetup const&); - virtual void endRun(edm::Run const&, edm::EventSetup const&); - virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); - virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); - - // ----------member data --------------------------- -}; - -// -// constants, enums and typedefs -// - -// -// static data member definitions -// - -// -// constructors and destructor -// -FileConverterPlaceHolder::FileConverterPlaceHolder(const edm::ParameterSet& iConfig) - -{ - //now do what ever initialization is needed - -} - - -FileConverterPlaceHolder::~FileConverterPlaceHolder() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - -} - - -// -// member functions -// - -// ------------ method called for each event ------------ -void -FileConverterPlaceHolder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - - - -#ifdef THIS_IS_AN_EVENT_EXAMPLE - Handle pIn; - iEvent.getByLabel("example",pIn); -#endif - -#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE - ESHandle pSetup; - iSetup.get().get(pSetup); -#endif -} - - -// ------------ method called once each job just before starting event loop ------------ -void -FileConverterPlaceHolder::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -FileConverterPlaceHolder::endJob() -{ -} - -// ------------ method called when starting to processes a run ------------ -void -FileConverterPlaceHolder::beginRun(edm::Run const&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a run ------------ -void -FileConverterPlaceHolder::endRun(edm::Run const&, edm::EventSetup const&) -{ -} - -// ------------ method called when starting to processes a luminosity block ------------ -void -FileConverterPlaceHolder::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) -{ -} - -// ------------ method called when ending the processing of a luminosity block ------------ -void -FileConverterPlaceHolder::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) -{ -} - -// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void -FileConverterPlaceHolder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - //The following says we do not know what parameters are allowed so do no validation - // Please change this to state exactly what you do use, even if it is no parameters - edm::ParameterSetDescription desc; - desc.setUnknown(); - descriptions.addDefault(desc); -} - -//define this as a plug-in -DEFINE_FWK_MODULE(FileConverterPlaceHolder); From 6c61a3355d6ca4c8bebeb315c627446f24a01762 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 6 Jul 2015 15:34:18 +0200 Subject: [PATCH 026/104] Moved FileConverter and Extractor to MillePedeAlignmentAlgorithm folder --- .../plugins/BuildFile.xml | 0 .../plugins/FileBlobCollection.cc | 14 ++++++++++ .../plugins/FileBlobCollection.h | 28 +++++++++++++++++++ .../plugins/MillePedeFileConverter.cc | 2 +- .../plugins/MillePedeFileConverter.h | 0 .../plugins/MillePedeFileExtractor.cc | 2 +- .../plugins/MillePedeFileExtractor.h | 0 .../python/MillePedeFileConverter_cfg.py | 2 +- .../python/MillePedeFileExtractor_cfg.py | 2 +- .../plugins/BuildFile.xml | 5 ---- 10 files changed, 46 insertions(+), 9 deletions(-) rename Alignment/{MillePedeFileConverter => MillePedeAlignmentAlgorithm}/plugins/BuildFile.xml (100%) create mode 100644 Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc create mode 100644 Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h rename Alignment/{MillePedeFileConverter => MillePedeAlignmentAlgorithm}/plugins/MillePedeFileConverter.cc (97%) rename Alignment/{MillePedeFileConverter => MillePedeAlignmentAlgorithm}/plugins/MillePedeFileConverter.h (100%) rename Alignment/{MillePedeFileExtractor => MillePedeAlignmentAlgorithm}/plugins/MillePedeFileExtractor.cc (98%) rename Alignment/{MillePedeFileExtractor => MillePedeAlignmentAlgorithm}/plugins/MillePedeFileExtractor.h (100%) rename Alignment/{MillePedeFileConverter => MillePedeAlignmentAlgorithm}/python/MillePedeFileConverter_cfg.py (91%) rename Alignment/{MillePedeFileExtractor => MillePedeAlignmentAlgorithm}/python/MillePedeFileExtractor_cfg.py (92%) delete mode 100644 Alignment/MillePedeFileExtractor/plugins/BuildFile.xml diff --git a/Alignment/MillePedeFileConverter/plugins/BuildFile.xml b/Alignment/MillePedeAlignmentAlgorithm/plugins/BuildFile.xml similarity index 100% rename from Alignment/MillePedeFileConverter/plugins/BuildFile.xml rename to Alignment/MillePedeAlignmentAlgorithm/plugins/BuildFile.xml diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc new file mode 100644 index 0000000000000..f9adf3d553f64 --- /dev/null +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc @@ -0,0 +1,14 @@ +#include "Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h" + +FileBlobCollection::FileBlobCollection(){ + std::cout << "Constructor"; + std::cout << "Length of fileBlobs is: " << fileBlobs.size(); +} + +bool FileBlobCollection::mergeProduct(FileBlobCollection const &other) { + std::cout << "Length of fileBlobs is: " << fileBlobs.size(); + fileBlobs.push_back(other.fileBlobs.front()); + std::cout << "Length of fileBlobs is: " << fileBlobs.size(); + // TODO: Should work for more than one + return true; +} diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h new file mode 100644 index 0000000000000..24d5201e6c3f7 --- /dev/null +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h @@ -0,0 +1,28 @@ +#ifndef Alignment_MillePedeAlignmentAlgorithm_FileBlobCollection_h +#define Alignment_MillePedeAlignmentAlgorithm_FileBlobCollection_h + +// Original Author: Broen van Besien +// Created: Mon, 06 Jul 2015 12:18:35 GMT + +/* + * This class... + * BVB: TODO + * + */ + +#include "CondFormats/Common/interface/FileBlob.h" + +#include + +class FileBlobCollection { + public: + FileBlobCollection(); + // TODO: BVB probably nicer to have a more "direct" constructor here + ~FileBlobCollection() {}; + bool mergeProduct(FileBlobCollection const &other); + + private: + std::vector fileBlobs; +}; + +#endif diff --git a/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc similarity index 97% rename from Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc rename to Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc index 27566fd866d4c..1c117c28e6499 100644 --- a/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc @@ -1,7 +1,7 @@ // Original Author: Broen van Besien // Created: Thu, 19 Mar 2015 18:12:35 GMT -#include "Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h" +#include "Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/Common/interface/FileBlob.h" diff --git a/Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h similarity index 100% rename from Alignment/MillePedeFileConverter/plugins/MillePedeFileConverter.h rename to Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h diff --git a/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc similarity index 98% rename from Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc rename to Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc index d9791b2569fbf..ec64d76707803 100644 --- a/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc @@ -4,7 +4,7 @@ #include #include -#include "Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h" +#include "Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/Common/interface/FileBlob.h" diff --git a/Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h similarity index 100% rename from Alignment/MillePedeFileExtractor/plugins/MillePedeFileExtractor.h rename to Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h diff --git a/Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py similarity index 91% rename from Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py rename to Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py index 4d27aec5d2eef..1ef22b23857d9 100644 --- a/Alignment/MillePedeFileConverter/python/MillePedeFileConverter_cfg.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py @@ -21,7 +21,7 @@ ) # Loading the autogenerated millePedeFileConverter_cfi: -from Alignment.MillePedeFileConverter.millePedeFileConverter_cfi import millePedeFileConverter +from Alignment.MillePedeAlignmentAlgorithm.millePedeFileConverter_cfi import millePedeFileConverter process.testMillePedeFileConverter = millePedeFileConverter.clone() process.out = cms.OutputModule("PoolOutputModule", diff --git a/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py similarity index 92% rename from Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py rename to Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py index 220be328f87b0..d02062c62ca6c 100644 --- a/Alignment/MillePedeFileExtractor/python/MillePedeFileExtractor_cfg.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py @@ -20,7 +20,7 @@ ) ) -from Alignment.MillePedeFileExtractor.millePedeFileExtractor_cfi import millePedeFileExtractor +from Alignment.MillePedeAlignmentAlgorithm.millePedeFileExtractor_cfi import millePedeFileExtractor process.testMillePedeFileExtractor = millePedeFileExtractor.clone( #FIXME: handle with an InputLabel instead of fileBlobModule = cms.string("SiPixelAliMillePedeFileConverter"), diff --git a/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml b/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml deleted file mode 100644 index 3b48f173e379a..0000000000000 --- a/Alignment/MillePedeFileExtractor/plugins/BuildFile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - From f37cda41a76c6cb2e7c78c30fbb2d0262f3bc8be Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 6 Jul 2015 16:58:09 +0200 Subject: [PATCH 027/104] Introduced FileBlobCollection, implemented merge Instead of using a std::vector, introduced a new class FileBlobCollection, which is kind of a wrapper around the old vector and which implements the mergeProduct method. This enables the framework to merge different files together. We also update the MillePedeFileConverter to use the new FileBlobCollection. (However MillePedeFileExtracter is not yet updated.) --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 1 + .../plugins/FileBlobCollection.cc | 14 -------------- .../plugins/MillePedeFileConverter.cc | 17 ++++++++--------- .../Common/interface}/FileBlobCollection.h | 4 ++-- CondFormats/Common/src/FileBlobCollection.cc | 18 ++++++++++++++++++ CondFormats/Common/src/classes.h | 6 ++---- CondFormats/Common/src/classes_def.xml | 4 ++-- CondFormats/Common/src/headers.h | 1 + 8 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc rename {Alignment/MillePedeAlignmentAlgorithm/plugins => CondFormats/Common/interface}/FileBlobCollection.h (84%) create mode 100644 CondFormats/Common/src/FileBlobCollection.cc diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 4617965b7cc90..cce503849d2e6 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -181,6 +181,7 @@ #FIXME: convert to untracked? fileDir = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.fileDir.value()), inputBinaryFile = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile.value()), + #FIXME: why was the label removed? Don't we want a label? fileBlobLabel = cms.string('')) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc deleted file mode 100644 index f9adf3d553f64..0000000000000 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include "Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h" - -FileBlobCollection::FileBlobCollection(){ - std::cout << "Constructor"; - std::cout << "Length of fileBlobs is: " << fileBlobs.size(); -} - -bool FileBlobCollection::mergeProduct(FileBlobCollection const &other) { - std::cout << "Length of fileBlobs is: " << fileBlobs.size(); - fileBlobs.push_back(other.fileBlobs.front()); - std::cout << "Length of fileBlobs is: " << fileBlobs.size(); - // TODO: Should work for more than one - return true; -} diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc index 1c117c28e6499..c3011e6d68e7a 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc @@ -4,18 +4,17 @@ #include "Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CondFormats/Common/interface/FileBlob.h" +#include "CondFormats/Common/interface/FileBlobCollection.h" #include #include -#include MillePedeFileConverter::MillePedeFileConverter(const edm::ParameterSet& iConfig) : theInputDir(iConfig.getParameter("fileDir")), theInputFileName(iConfig.getParameter("inputBinaryFile")), theFileBlobLabel(iConfig.getParameter("fileBlobLabel")) { - // We define what this producer produces: A vector of FileBlobs - produces, edm::InRun>(theFileBlobLabel); + // We define what this producer produces: A FileBlobCollection + produces(theFileBlobLabel); } MillePedeFileConverter::~MillePedeFileConverter() {} @@ -26,9 +25,9 @@ void MillePedeFileConverter::endRunProduce(edm::Run& iRun, << "Inserting all data from file " << theInputDir + theInputFileName << " as a FileBlob to the run, using label \"" << theFileBlobLabel << "\"."; - // Preparing the vector of FileBlobs: - std::unique_ptr> theVectorOfFileBlobs( - new std::vector()); + // Preparing the FileBlobCollection: + std::unique_ptr theFileBlobCollection( + new FileBlobCollection()); FileBlob theFileBlob; try { // Creating the FileBlob: @@ -44,8 +43,8 @@ void MillePedeFileConverter::endRunProduce(edm::Run& iRun, } if (theFileBlob.size() > 0) { // Adding the FileBlob to the run: - theVectorOfFileBlobs->push_back(theFileBlob); - iRun.put(std::move(theVectorOfFileBlobs), theFileBlobLabel); + theFileBlobCollection->addFileBlob(theFileBlob); + iRun.put(std::move(theFileBlobCollection), theFileBlobLabel); } } diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h b/CondFormats/Common/interface/FileBlobCollection.h similarity index 84% rename from Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h rename to CondFormats/Common/interface/FileBlobCollection.h index 24d5201e6c3f7..fa7415150f601 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/FileBlobCollection.h +++ b/CondFormats/Common/interface/FileBlobCollection.h @@ -16,9 +16,9 @@ class FileBlobCollection { public: - FileBlobCollection(); - // TODO: BVB probably nicer to have a more "direct" constructor here + FileBlobCollection() {}; ~FileBlobCollection() {}; + void addFileBlob(FileBlob &fileBlob); bool mergeProduct(FileBlobCollection const &other); private: diff --git a/CondFormats/Common/src/FileBlobCollection.cc b/CondFormats/Common/src/FileBlobCollection.cc new file mode 100644 index 0000000000000..5da06cb099dfe --- /dev/null +++ b/CondFormats/Common/src/FileBlobCollection.cc @@ -0,0 +1,18 @@ +#include "CondFormats/Common/interface/FileBlobCollection.h" + +void FileBlobCollection::addFileBlob(FileBlob &fileBlob) { + fileBlobs.push_back(fileBlob); +} + +bool FileBlobCollection::mergeProduct(FileBlobCollection const &other) { + std::cout << "+++++ Length of fileBlobs is: " << fileBlobs.size() + << std::endl; + // fileBlobs.push_back(other.fileBlobs.front()); + std::cout << "+++++ Using multi method!" << std::endl; + fileBlobs.insert(fileBlobs.end(), other.fileBlobs.begin(), + other.fileBlobs.end()); + std::cout << "+++++ Length of fileBlobs is: " << fileBlobs.size() + << std::endl; + // TODO: Should also work for more than one + return true; +} diff --git a/CondFormats/Common/src/classes.h b/CondFormats/Common/src/classes.h index a91625a38c3cb..144e7f95b2584 100644 --- a/CondFormats/Common/src/classes.h +++ b/CondFormats/Common/src/classes.h @@ -13,9 +13,7 @@ namespace CondFormats_Common { std::map amap1; std::map, DropBoxMetadata::Parameters> amap2; - std::vector dummyVectorFileBlob; - // The space between the two > > is actually obligatory: - edm::Wrapper > dummyWrapperVectorFileBlob; + FileBlobCollection dummyFileBlobCollection; + edm::Wrapper dummyWrapperFileBlobCollection; }; } - diff --git a/CondFormats/Common/src/classes_def.xml b/CondFormats/Common/src/classes_def.xml index 424cce69424ce..d10a91c1d6d69 100644 --- a/CondFormats/Common/src/classes_def.xml +++ b/CondFormats/Common/src/classes_def.xml @@ -25,8 +25,8 @@ - - + + diff --git a/CondFormats/Common/src/headers.h b/CondFormats/Common/src/headers.h index 1a59e11de1ace..4bea72af8e83c 100644 --- a/CondFormats/Common/src/headers.h +++ b/CondFormats/Common/src/headers.h @@ -1,6 +1,7 @@ #include "CondFormats/Common/interface/IOVSequence.h" #include "CondFormats/Common/interface/GenericSummary.h" #include "CondFormats/Common/interface/FileBlob.h" +#include "CondFormats/Common/interface/FileBlobCollection.h" #include "CondFormats/Common/interface/MultiFileBlob.h" #include "CondFormats/Common/interface/BaseKeyed.h" From a3ca2436a61b4326994ef457b2702cffba5dc0c4 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 6 Jul 2015 17:07:07 +0200 Subject: [PATCH 028/104] Cleaning FileBlobCollection.cc --- CondFormats/Common/src/FileBlobCollection.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CondFormats/Common/src/FileBlobCollection.cc b/CondFormats/Common/src/FileBlobCollection.cc index 5da06cb099dfe..e619f048efdcd 100644 --- a/CondFormats/Common/src/FileBlobCollection.cc +++ b/CondFormats/Common/src/FileBlobCollection.cc @@ -5,14 +5,7 @@ void FileBlobCollection::addFileBlob(FileBlob &fileBlob) { } bool FileBlobCollection::mergeProduct(FileBlobCollection const &other) { - std::cout << "+++++ Length of fileBlobs is: " << fileBlobs.size() - << std::endl; - // fileBlobs.push_back(other.fileBlobs.front()); - std::cout << "+++++ Using multi method!" << std::endl; fileBlobs.insert(fileBlobs.end(), other.fileBlobs.begin(), other.fileBlobs.end()); - std::cout << "+++++ Length of fileBlobs is: " << fileBlobs.size() - << std::endl; - // TODO: Should also work for more than one return true; } From 52544722df2d4fc78d49ee3ab76e6edeb0dd46d0 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Mon, 6 Jul 2015 17:53:03 +0200 Subject: [PATCH 029/104] Updated MillePedeFileExtracter for FileBlobCollection --- .../plugins/MillePedeFileExtractor.cc | 18 +++++++++--------- .../Common/interface/FileBlobCollection.h | 3 +++ CondFormats/Common/src/FileBlobCollection.cc | 12 ++++++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc index ec64d76707803..d6902ed9aa2b2 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc @@ -2,12 +2,12 @@ // Created: Mon, 23 Mar 2015 14:56:15 GMT #include -#include #include "Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/Common/interface/FileBlob.h" +#include "CondFormats/Common/interface/FileBlobCollection.h" MillePedeFileExtractor::MillePedeFileExtractor(const edm::ParameterSet& iConfig) : theOutputDir(iConfig.getParameter("fileDir")), @@ -22,23 +22,23 @@ MillePedeFileExtractor::~MillePedeFileExtractor() {} void MillePedeFileExtractor::beginRun(const edm::Run& iRun, edm::EventSetup const&) { // Getting our hands on the vector of FileBlobs - edm::Handle> theVectorOfFileBlobs; - iRun.getByLabel(theFileBlobModule, theFileBlobLabel, theVectorOfFileBlobs); - if (theVectorOfFileBlobs.isValid()) { + edm::Handle theFileBlobCollection; + iRun.getByLabel(theFileBlobModule, theFileBlobLabel, theFileBlobCollection); + if (theFileBlobCollection.isValid()) { // Logging the amount of FileBlobs in the vector - int theVectorSize = theVectorOfFileBlobs->size(); + int theVectorSize = theFileBlobCollection->size(); edm::LogInfo("MillePedeFileActions") << "Root file contains " << theVectorSize << " FileBlob(s)."; // Loop over the FileBlobs in the vector, and write them to files: for (std::vector::const_iterator it = - theVectorOfFileBlobs->begin(); - it != theVectorOfFileBlobs->end(); ++it) { + theFileBlobCollection->begin(); + it != theFileBlobCollection->end(); ++it) { // We format the filename with a number, starting from 0 to the size of // our vector. // For this to work, the outputBinaryFile config parameter must contain a // formatting directive for a number, like %04d. char theNumberedOutputFileName[200]; - int theNumber = it - theVectorOfFileBlobs->begin(); + int theNumber = it - theFileBlobCollection->begin(); sprintf(theNumberedOutputFileName, theOutputFileName.c_str(), theNumber); // Log the filename to which we will write... edm::LogInfo("MillePedeFileActions") @@ -46,7 +46,7 @@ void MillePedeFileExtractor::beginRun(const edm::Run& iRun, << theOutputDir + theNumberedOutputFileName << "."; // ...and perform the writing operation. it->write(theOutputDir + theNumberedOutputFileName); - // Carefull, it seems that when writing to an impossible file, this is + // Carefull, it seems that when writing to an impossible file, this is // swallowed by the FileBlob->write operation and no error is thrown. } } else { diff --git a/CondFormats/Common/interface/FileBlobCollection.h b/CondFormats/Common/interface/FileBlobCollection.h index fa7415150f601..5eda54fc46726 100644 --- a/CondFormats/Common/interface/FileBlobCollection.h +++ b/CondFormats/Common/interface/FileBlobCollection.h @@ -19,6 +19,9 @@ class FileBlobCollection { FileBlobCollection() {}; ~FileBlobCollection() {}; void addFileBlob(FileBlob &fileBlob); + int size() const; + std::vector::const_iterator begin() const; + std::vector::const_iterator end() const; bool mergeProduct(FileBlobCollection const &other); private: diff --git a/CondFormats/Common/src/FileBlobCollection.cc b/CondFormats/Common/src/FileBlobCollection.cc index e619f048efdcd..dd552ed4e7b3b 100644 --- a/CondFormats/Common/src/FileBlobCollection.cc +++ b/CondFormats/Common/src/FileBlobCollection.cc @@ -4,6 +4,18 @@ void FileBlobCollection::addFileBlob(FileBlob &fileBlob) { fileBlobs.push_back(fileBlob); } +int FileBlobCollection::size() const { + return fileBlobs.size(); +} + +std::vector::const_iterator FileBlobCollection::begin() const { + return fileBlobs.begin(); +} + +std::vector::const_iterator FileBlobCollection::end() const { + return fileBlobs.end(); +} + bool FileBlobCollection::mergeProduct(FileBlobCollection const &other) { fileBlobs.insert(fileBlobs.end(), other.fileBlobs.begin(), other.fileBlobs.end()); From ca91b0818b68d1e7820c7b524f7a3dd5b0439735 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Sat, 11 Jul 2015 16:47:26 +0200 Subject: [PATCH 030/104] Cleaned and finalized the Converter and Extractor --- .../plugins/MillePedeFileConverter.cc | 4 ++-- .../plugins/MillePedeFileConverter.h | 12 ++++++++++- .../plugins/MillePedeFileExtractor.cc | 17 ++++++++-------- .../plugins/MillePedeFileExtractor.h | 20 +++++++++++++++---- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc index c3011e6d68e7a..c7db44deef9a2 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.cc @@ -58,10 +58,10 @@ void MillePedeFileConverter::fillDescriptions( "Keep the fileDir empty if you want to write to the current " "directory. If you use it, it should end with a slash."); - desc.add("inputBinaryFile", "milleBinaryISN.dat")->setComment( + desc.add("inputBinaryFile", "milleBinary.dat")->setComment( "Filename of the file created by Mille in the AlignmentProducer"); - desc.add("fileBlobLabel", "milleBinaryISN.dat")->setComment( + desc.add("fileBlobLabel", "milleBinary.dat")->setComment( "It's probably a good idea to keep the label the same as the " "original filename(s). See configuration of " "MillePedeFileExtractor, it should be the same there."); diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h index 4741a736760bb..f9e0d074c30f4 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h @@ -5,8 +5,18 @@ // Created: Thu, 19 Mar 2015 18:12:35 GMT /* - * This producer... blahblahblha... BVB: TODO + * This producer will take a given (binary) file and embed it in the output + * edm/root file. * + * The file is added as a fileblob to a vector of fileblobs that exists on the + * level of the run. + * The operation is performed during the endRunProduce phase. + * + * The file can later be extracted again by the corresponding module + * MillePedeFileExtractor. + * + * For more info about the possible parameters, type: + * edmPluginHelp -p MillePedeFileConverter */ #include "FWCore/Framework/interface/Frameworkfwd.h" diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc index d6902ed9aa2b2..e9405ba67b6e8 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.cc @@ -19,8 +19,8 @@ MillePedeFileExtractor::MillePedeFileExtractor(const edm::ParameterSet& iConfig) MillePedeFileExtractor::~MillePedeFileExtractor() {} -void MillePedeFileExtractor::beginRun(const edm::Run& iRun, - edm::EventSetup const&) { +void MillePedeFileExtractor::endRun(const edm::Run& iRun, + edm::EventSetup const&) { // Getting our hands on the vector of FileBlobs edm::Handle theFileBlobCollection; iRun.getByLabel(theFileBlobModule, theFileBlobLabel, theFileBlobCollection); @@ -67,19 +67,18 @@ void MillePedeFileExtractor::fillDescriptions( "Keep the fileDir empty if you want to write to the current " "directory."); - desc.add("outputBinaryFile", "milleBinaryISN%04d.dat") - ->setComment( - "Base filename of the files that will be created. This must " - "contain " - "a placeholder for an index number in the standard C formatting " - "style, like %04d."); + desc.add("outputBinaryFile", "milleBinary%04d.dat")->setComment( + "Base filename of the files that will be created. This must " + "contain " + "a placeholder for an index number in the standard C formatting " + "style, like %04d."); desc.add("fileBlobModule", "millePedeFileConverter")->setComment( "Name of the module that should have generated the blob in the " "root file. Make sure you overwrite this, if you have changed " "this is the configuration of the MillePedeFileConverter."); - desc.add("fileBlobLabel", "milleBinaryISN.dat")->setComment( + desc.add("fileBlobLabel", "milleBinary.dat")->setComment( "It's probably a good idea to keep the label the same as the " "original filename(s). See configuration of " "MillePedeFileConverter, it should be the same there."); diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h index 82ec844be5c16..ef38b90a07e13 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileExtractor.h @@ -1,12 +1,24 @@ -#ifndef MillePedeFileConverter_h -#define MillePedeFileConverter_h +#ifndef MillePedeFileExtractor_h +#define MillePedeFileExtractor_h // Original Author: Broen van Besien // Created: Mon, 23 Mar 2015 14:56:15 GMT /* - * This analyzer... blahblahblha... BVB: TODO + * This analyzer will extract all fileblobs in the input edm/root file and + * write them as files to the file system. * + * It searches for the files in the vector of fileblobs that should exist on + * the level of the run. Unique filenames for each file are generated based + * on a formating directive in the output filename parameter. + * + * The operation is performed during the endRun phase. + * + * The original embedding of the (binary) files in the edm/root files can be + * done with the corresponding module MillePedeFileConverer. + * + * For more info about the possible parameters, type: + * edmPluginHelp -p MillePedeFileExtractor */ #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -22,7 +34,7 @@ class MillePedeFileExtractor : public edm::EDAnalyzer { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; + virtual void endRun(edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) {} std::string theOutputDir; From 48b98aa27dc7f3e77528382a7f8490c7f6195d62 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Sat, 11 Jul 2015 16:48:21 +0200 Subject: [PATCH 031/104] Cleaning the configs of Convertor and Extractor --- .../python/MillePedeFileConverter_cfg.py | 6 +++++ .../python/MillePedeFileExtractor_cfg.py | 22 ++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py index 1ef22b23857d9..d1c362bfb7ba1 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileConverter_cfg.py @@ -4,6 +4,12 @@ process.load("FWCore.MessageService.MessageLogger_cfi") +# This is just a test configuration. It should not be loaded directly in any +# other configuration. +# The filenames below are just suggestions. +# To get all info about this module, type: +# edmPluginHelp -p MillePedeFileConverter + # Using the normal standard messagelogger, with its standard configuration, # but setting the category of messages to MillePedeFileActions process.MessageLogger = process.MessageLogger.clone( diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py index d02062c62ca6c..b9346acc02d6d 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileExtractor_cfg.py @@ -4,6 +4,12 @@ process.load("FWCore.MessageService.MessageLogger_cfi") +# This is just a test configuration. It should not be loaded directly in any +# other configuration. +# The filenames below are just suggestions. +# To get all info about this module, type: +# edmPluginHelp -p MillePedeFileExtractor + # Using the normal standard messagelogger, with its standard configuration, # but setting the category of messages to MillePedeFileActions process.MessageLogger = process.MessageLogger.clone( @@ -11,21 +17,27 @@ ) # Limit our test to 5 events (we work on run level anyway) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(5)) process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - 'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli.root', - 'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli_2.root' + ##'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli.root', + ##'file:/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/PromptCalibProdSiPixelAli_2.root' + ##'file:output.root', + 'file:PromptCalibProdSiPixelAli1.root', + 'file:PromptCalibProdSiPixelAli2.root', ) ) from Alignment.MillePedeAlignmentAlgorithm.millePedeFileExtractor_cfi import millePedeFileExtractor process.testMillePedeFileExtractor = millePedeFileExtractor.clone( #FIXME: handle with an InputLabel instead of + #TODO: Above sentence needs to be finished, otherwise I don't know what to fix. fileBlobModule = cms.string("SiPixelAliMillePedeFileConverter"), fileBlobLabel = cms.string(''), - outputBinaryFile = cms.string('pippo.dat'), - fileDir = cms.string('/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/')) + # You can add formatting directives like "%04d" in the output file name to setup numbering. + outputBinaryFile = cms.string('pippo%04d.dat'), + fileDir = cms.string('/afs/cern.ch/work/b/bvanbesi/private/PCLALI/CMSSW_7_4_4/src/')) + ##fileDir = cms.string('/afs/cern.ch/work/c/cerminar/pcl/ali/frombroen/new/CMSSW_7_4_4/src/')) process.p = cms.Path(process.testMillePedeFileExtractor) From 7d9d54f6f736f099806ca536ef0652cb8c1bc39f Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Sat, 11 Jul 2015 16:49:12 +0200 Subject: [PATCH 032/104] Updating MillePedeAlignmntAlgo to expand filenames When the mergeBinaryFiles contains a formatting directive for a number, like %04d, it will automatically be expanded to the corresponding numbers and added to the list of files to read, if the file actually exists. Multiple files and files without any formatting directive are still accepted and this will continue to work as before. --- .../interface/MillePedeAlignmentAlgorithm.h | 4 ++ .../src/MillePedeAlignmentAlgorithm.cc | 49 ++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h index 7c080bb969cd1..37eae169901d2 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h @@ -193,6 +193,10 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase /// add MillePedeVariables for each AlignmentParameters (exception if no parameters...) void buildUserVariables(const std::vector &alignables) const; + /// Generates list of files to read, given the list and dir from the configuration. + /// This will automatically expand formatting directives, if they appear. + std::vector getExistingFormattedFiles(const std::vector plainFiles, std::string theDir); + void addLaserData(const EventInfo &eventInfo, const TkFittedLasBeamCollection &tkLasBeams, const TsosVectorCollection &tkLasBeamTsoses); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index 114256b4ee77f..e433132d70038 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -60,6 +60,7 @@ #include #include #include +#include #include #include @@ -287,14 +288,16 @@ void MillePedeAlignmentAlgorithm::terminate() if (this->isMode(myMilleBit) || !theConfig.getParameter("binaryFile").empty()) { files.push_back(theDir + theConfig.getParameter("binaryFile")); } else { - const std::vector plainFiles - (theConfig.getParameter >("mergeBinaryFiles")); - for (std::vector::const_iterator i = plainFiles.begin(), iEnd = plainFiles.end(); - i != iEnd; ++i) { - files.push_back(theDir + *i); + const std::vector plainFiles(theConfig.getParameter >("mergeBinaryFiles")); + files = getExistingFormattedFiles(plainFiles, theDir); + // Do some logging: + std::string filesForLogOutput; + for (std::vector::const_iterator i = files.begin(), iEnd = files.end(); i != iEnd; ++i) { + filesForLogOutput += " " + *i; } + edm::LogInfo("Alignment") << "Based on the config parameter mergeBinaryFiles, using the following files as input:" << filesForLogOutput; } - + // cache all positions, rotations and deformations theAlignmentParameterStore->cacheTransformations(); @@ -304,11 +307,43 @@ void MillePedeAlignmentAlgorithm::terminate() } // parameters from pede are not yet applied, - // so we can still write start positions (but with hit statistics in case of mille): + // so we can still write start positions (but with hit statistics in case of mille): this->doIO(0); theLastWrittenIov = 0; } +std::vector MillePedeAlignmentAlgorithm::getExistingFormattedFiles(const std::vector plainFiles, std::string theDir) { + std::vector files; + for (std::vector::const_iterator i = plainFiles.begin(), iEnd = plainFiles.end(); i != iEnd; ++i) { + std::string theInputFileName = *i; + int theNumber = 0; + while (true) { + // Create a formatted version of the filename, with growing numbers + // If the parameter doesn't contain a formatting directive, it just stays unchanged + char theNumberedInputFileName[200]; + sprintf(theNumberedInputFileName, theInputFileName.c_str(), theNumber); + std::string theCompleteInputFileName = theDir + theNumberedInputFileName; + // Check if the file exists + struct stat buffer; + if (stat (theCompleteInputFileName.c_str(), &buffer) == 0) { + // If the file exists, add it to the list + files.push_back(theCompleteInputFileName); + if (theNumberedInputFileName == theInputFileName) { + // If the filename didn't contain a formatting directive, no reason to look any further, break out of the loop + break; + } else { + // Otherwise look for the next number + theNumber++; + } + } else { + // The file doesn't exist, break out of the loop + break; + } + } + } + return files; +} + // Run the algorithm on trajectories and tracks ------------------------------- //____________________________________________________ void MillePedeAlignmentAlgorithm::run(const edm::EventSetup &setup, const EventInfo &eventInfo) From a8f0c5a63000ac35dade432a2146aa24535f958c Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Sat, 11 Jul 2015 16:54:34 +0200 Subject: [PATCH 033/104] Gluing configs for extractor and pede together Also cleaned config for step2 --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 5 +++-- .../python/AlcaSiPixelAliHarvester_cff.py | 20 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index cce503849d2e6..69db81d725820 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -132,7 +132,7 @@ SiPixelAliMilleAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm SiPixelAliMilleAlignmentProducer.algoConfig.mode = 'mille' SiPixelAliMilleAlignmentProducer.algoConfig.mergeBinaryFiles = cms.vstring() -SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile = 'milleBinary0.dat' +SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile = 'milleBinary.dat' SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory #SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' @@ -182,7 +182,8 @@ fileDir = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.fileDir.value()), inputBinaryFile = cms.string(SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile.value()), #FIXME: why was the label removed? Don't we want a label? - fileBlobLabel = cms.string('')) + fileBlobLabel = cms.string(''), + ) diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index 0238527d4e520..004fffdf171a9 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -1,15 +1,14 @@ import FWCore.ParameterSet.Config as cms import copy - - - - SiPixelAliMilleFileExtractor = cms.EDAnalyzer("MillePedeFileExtractor", - #FIXME: handle with an InputLabel instead of fileBlobModule = cms.string("SiPixelAliMillePedeFileConverter"), fileBlobLabel = cms.string(''), - outputBinaryFile = cms.string('pippo2.dat')) + # File names the Extractor will use to write the fileblobs in the root + # file as real binary files to disk, so that the pede step can read them. + # This includes the formatting directive "%04d" which will be expanded to + # 0000, 0001, 0002,... + outputBinaryFile = cms.string('pedeBinary%04d.dat')) from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer @@ -97,10 +96,9 @@ SiPixelAliPedeAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm SiPixelAliPedeAlignmentProducer.algoConfig.mode = 'pede' -# FIXME: this needs to be addressed -SiPixelAliPedeAlignmentProducer.algoConfig.mergeBinaryFiles = [ - SiPixelAliMilleFileExtractor.outputBinaryFile.value() - ] +# Input binary files for the pede step: We use the same value as for the output binary files of the extractor. +# That way the output of the extractor automatically becomes the input for pede. +SiPixelAliPedeAlignmentProducer.algoConfig.mergeBinaryFiles = [SiPixelAliMilleFileExtractor.outputBinaryFile.value()] SiPixelAliPedeAlignmentProducer.algoConfig.monitorFile = 'millePedeMonitor_pede.root' SiPixelAliPedeAlignmentProducer.algoConfig.binaryFile = '' SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesBzeroTrajectoryFactory @@ -108,7 +106,7 @@ SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.pedeCommand = 'pede' -SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' +SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.options = cms.vstring( #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum 'entries 500', From c558d030d840c5618cf56474fd904e9af7f96772 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jun 2015 15:40:19 +0200 Subject: [PATCH 034/104] cleanup --- .../StandardSequences/python/AlCaHarvesting_cff.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py index e1db573d3d080..872be8bb7c676 100644 --- a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py +++ b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py @@ -74,14 +74,6 @@ # ALCAHARVESTSiPixelAli_metadata = cms.PSet(record = cms.untracked.string('TrackerAlignmentRcd'), -# destDB = cms.untracked.string("oracle://cms_orcon_prod/CMS_COND_31X_STRIP"), -# destDBValidation = cms.untracked.string("oracle://cms_orcoff_prep/CMS_COND_STRIP"), -# tag = cms.untracked.string("SiStripBadChannel_PCL_v0_offline"), -# Timetype = cms.untracked.string("runnumber"), -# IOVCheck = cms.untracked.string("All"), -# DuplicateTagHLT = cms.untracked.string("SiStripBadChannel_PCL_v0_hlt"), -# DuplicateTagEXPRESS = cms.untracked.string(""), -# DuplicateTagPROMPT = cms.untracked.string("SiStripBadChannel_PCL_v0_prompt"), ) From ce5b92cccb08b4a83e50c390a5d35d0e521de2d5 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Mon, 13 Jul 2015 15:52:53 +0200 Subject: [PATCH 035/104] ConfiBuilder is now in a different location From a29abc55c40e5f0d08f3906cd9262e14aa54f0bc Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 14 Jul 2015 17:12:47 +0200 Subject: [PATCH 036/104] implement latest sequence for 3.8T provided by Chris Martin --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 171 +++++++----------- 1 file changed, 69 insertions(+), 102 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 69db81d725820..182ce175316cd 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -7,7 +7,7 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli = copy.deepcopy(hltHighLevel) ALCARECOTkAlMinBiasFilterForSiPixelAli.HLTPaths = ['pathALCARECOTkAlMinBias'] ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names -ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","reRECO") +ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") @@ -16,20 +16,43 @@ from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot # Ingredient: AlignmentTrackSelector +# track selector for HighPurity tracks +#-- AlignmentTrackSelector +from Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi import AlignmentTrackSelector +SiPixelAliHighPuritySelector = AlignmentTrackSelector.clone( + applyBasicCuts = True, + #filter = True, + src = 'ALCARECOTkAlMinBias', + trackQualities = ["highPurity"], + pMin = 4., + ) + + + # track selection for alignment from Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi import AlignmentTrackSelector -AlignmentTrackSelector.src = 'ALCARECOTkAlMinBias' #'SiPixelAliTrackFitter' #'ALCARECOTkAlCosmicsCTF0T' #TkAlZMuMu' #MinBias' #'generalTracks' ## ALCARECOTkAlMuonIsolated # adjust to input file -AlignmentTrackSelector.pMin = 4. -AlignmentTrackSelector.ptMin = 0. #HIGHER CUT, LESS TRACKS, MORE EVENTS, LESS TIME THOUGH????? -AlignmentTrackSelector.ptMax = 200. -AlignmentTrackSelector.etaMin = -999. -AlignmentTrackSelector.etaMax = 999. -AlignmentTrackSelector.nHitMin = 10 -AlignmentTrackSelector.nHitMin2D = 3 -AlignmentTrackSelector.chi2nMax = 100. -AlignmentTrackSelector.applyMultiplicityFilter = False# True -AlignmentTrackSelector.maxMultiplicity = 1 -AlignmentTrackSelector.minHitsPerSubDet.inPIXEL = 2 +SiPixelAliTrackSelector = AlignmentTrackSelector.clone( + src = 'SiPixelAliTrackFitter', + applyBasicCuts = True, + pMin = 8., + ptMin = 1.0, + etaMin = -999., + etaMax = 999., + nHitMin = 8, + nHitMin2D = 2, + chi2nMax = 9999., + applyMultiplicityFilter = False, + maxMultiplicity = 1, + applyNHighestPt = False, + nHighestPt = 1, + seedOnlyFrom = 0, + applyIsolationCut = False, + minHitIsolation = 0.8, + applyChargeCheck = False, + minHitChargeStrip = 30., +) +#Special option for PCL +SiPixelAliTrackSelector.minHitsPerSubDet.inPIXEL = 2 # Ingredient: SiPixelAliTrackRefitter0 @@ -39,104 +62,45 @@ # TrackRefitter (normal tracks), TrackRefitterP5 (cosmics) or TrackRefitterBHM (beam halo) SiPixelAliTrackRefitter0 = TrackRefitter.clone( - src = 'AlignmentTrackSelector', #'ALCARECOTkAlMinBias'#'ALCARECOTkAlCosmicsCTF0T' #'ALCARECOTkAlMuonIsolated' + src = 'SiPixelAliHighPuritySelector', #'ALCARECOTkAlMinBias'#'ALCARECOTkAlCosmicsCTF0T' #'ALCARECOTkAlMuonIsolated' NavigationSchool = '', # to avoid filling hit pattern ) +SiPixelAliTrackRefitter1 = SiPixelAliTrackRefitter0.clone( + src = 'SiPixelAliTrackSelector' +) #-- Alignment producer from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer SiPixelAliMilleAlignmentProducer = copy.deepcopy(AlignmentProducer) - SiPixelAliMilleAlignmentProducer.ParameterBuilder.Selector = cms.PSet( - alignParams = cms.vstring( - 'TrackerTPBHalfBarrel,111111', - 'TrackerTPEHalfCylinder,111111', - - 'TrackerTIBHalfBarrel,ffffff', - 'TrackerTOBHalfBarrel,ffffff', - 'TrackerTIDEndcap,ffffff', - 'TrackerTECEndcap,ffffff' - ) + alignParams = cms.vstring( + 'TrackerTPBHalfBarrel,111111', + 'TrackerTPEHalfCylinder,111111', + + 'TrackerTIBHalfBarrel,ffffff', + 'TrackerTOBHalfBarrel,ffffff', + 'TrackerTIDEndcap,ffffff', + 'TrackerTECEndcap,ffffff' ) + ) SiPixelAliMilleAlignmentProducer.doMisalignmentScenario = False #True -SiPixelAliMilleAlignmentProducer.MisalignmentScenario = cms.PSet( - setRotations = cms.bool(True), - setTranslations = cms.bool(True), - seed = cms.int32(1234567), - distribution = cms.string('fixed'), # gaussian, uniform (or so...) - setError = cms.bool(True), #GF ??????? - TPBHalfBarrel1 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(-0.0015), - dZlocal = cms.double(0.0100), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-2.e-4), - phiZlocal = cms.double(5.e-4), - - ), - TPBHalfBarrel2 = cms.PSet( - dXlocal = cms.double(-0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.020), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(-2.e-4), - - ), - TPEEndcap1 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(0.0050), - dYlocal = cms.double(0.0020), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-5), - phiYlocal = cms.double(2.e-3), - phiZlocal = cms.double(2.e-5), - ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.01), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-1.e-4), - phiZlocal = cms.double(2.e-4), - ), - ), - TPEEndcap2 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(-0.0080), - dYlocal = cms.double(0.0050), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(-3.e-4), - phiZlocal = cms.double(2.e-4), - ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(3.e-4), - ), - ) - ) SiPixelAliMilleAlignmentProducer.checkDbAlignmentValidity = False SiPixelAliMilleAlignmentProducer.applyDbAlignment = True -SiPixelAliMilleAlignmentProducer.tjTkAssociationMapTag = 'SiPixelAliTrackFitter' +SiPixelAliMilleAlignmentProducer.tjTkAssociationMapTag = 'SiPixelAliTrackRefitter1' SiPixelAliMilleAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm SiPixelAliMilleAlignmentProducer.algoConfig.mode = 'mille' SiPixelAliMilleAlignmentProducer.algoConfig.mergeBinaryFiles = cms.vstring() -SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile = 'milleBinary.dat' -SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesTrajectoryFactory -#SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 -SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' -SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers +SiPixelAliMilleAlignmentProducer.algoConfig.binaryFile = 'milleBinary_0.dat' +SiPixelAliMilleAlignmentProducer.algoConfig.TrajectoryFactory = cms.PSet( + #process.BrokenLinesBzeroTrajectoryFactory + BrokenLinesTrajectoryFactory + ) @@ -145,18 +109,18 @@ import RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff as HitFilter # Reference config at /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/MP/MPproduction/aliConfigTemplates/Cosmics38T_BL_default_cfg.py SiPixelAliTrackerTrackHitFilter = HitFilter.TrackerTrackHitFilter.clone( - src = 'SiPixelAliTrackRefitter0', #'ALCARECOTkAlCosmicsCTF0T', - useTrajectories= False,#True, # for angle selections + pixel cluster charge + src = 'SiPixelAliTrackRefitter0', #'ALCARECOTkAlCosmicsCTF0T', + # this is needed only if you require some selections; but it will work even if you don't ask for them + useTrajectories= True, minimumHits = 8, - commands = [], # Ref. has equivalent pharse... - detsToIgnore = [], #is default - replaceWithInactiveHits = True, # needed for multiple scattering - stripAllInvalidHits = False, #default + replaceWithInactiveHits = True, rejectBadStoNHits = True, - StoNcommands = ["ALL 18.0"], # 18 for tracker in peak mode, 5 for deconvolution mode -# rejectLowAngleHits = True, - TrackAngleCut = 0.1, # 0.35, # in rads, starting from the module surface; .35 for cosmcics ok, .17 for collision tracks - usePixelQualityFlag = True + commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC"), #,"drop TID stereo","drop TEC stereo") + stripAllInvalidHits = False, + StoNcommands = cms.vstring("ALL 18.0"), + rejectLowAngleHits = True, + TrackAngleCut = 0.17, # in rads, starting from the module surface; .35 for cosmcics ok, .17 for collision tracks + usePixelQualityFlag = True #False ) # Ingredient: SiPixelAliSiPixelAliTrackFitter @@ -189,9 +153,12 @@ seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* offlineBeamSpot* - AlignmentTrackSelector* + SiPixelAliHighPuritySelector* SiPixelAliTrackRefitter0* SiPixelAliTrackerTrackHitFilter* SiPixelAliTrackFitter* + SiPixelAliTrackSelector* + SiPixelAliTrackRefitter1* + SiPixelAliMilleAlignmentProducer* SiPixelAliMillePedeFileConverter) From 2300f745dc9c3d1a9b92d1249a8bebad674b0bb8 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:01:44 +0200 Subject: [PATCH 037/104] new Tracker-AlignmentProducer running on PCL * base: CMSSW_7_4_6 * aligns only tracker * AP is no longer an ESProducer but an EDAnalyzer * runs only with MillePede at the moment --- .../interface/AlignmentAlgorithmBase.h | 243 ++- .../src/AlignmentAlgorithmBase.cc | 9 - .../plugins/BuildFile.xml | 3 +- .../plugins/PCLTrackerAlProducer.cc | 1726 ++++++++++------- .../plugins/PCLTrackerAlProducer.h | 366 ++-- .../TrackerAlignmentProducerForPCL_cff.py | 4 +- .../interface/MillePedeAlignmentAlgorithm.h | 4 +- .../src/MillePedeAlignmentAlgorithm.cc | 22 +- 8 files changed, 1384 insertions(+), 993 deletions(-) delete mode 100644 Alignment/CommonAlignmentAlgorithm/src/AlignmentAlgorithmBase.cc diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index 5bd345f63c3f6..d7e8423ae66e7 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -5,128 +5,161 @@ /// /// Base class for the alignment algorithm /// -/// Any algorithm should derive from this class +/// Each alignment algorithm should derive from this class /// +/*** System includes ***/ #include #include -class AlignableTracker; -class AlignableMuon; -class AlignableExtras; -class AlignmentParameterStore; -class IntegratedCalibrationBase; -class Trajectory; -// These data formats cannot be forward declared since they are typedef's, -// so include the headers that define the typedef's -// (no need to include in dependencies in BuildFile): +/*** Core framework functionality ***/ +#include "CondCore/DBCommon/interface/Time.h" +#include "FWCore/Framework/interface/Event.h" +namespace edm { class EventSetup; class ParameterSet; } +namespace reco { class Track; class BeamSpot; } + +/*** Alignment ***/ +// These data formats cannot be forward declared since they are typedefs, +// hence, include the headers that define the typedef's (no need to include +// in dependencies in BuildFile): // class TsosVectorCollection; // class TkFittedLasBeamCollection; // class AliClusterValueMap; -#include "CondCore/DBCommon/interface/Time.h" #include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" #include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" #include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" -#include "FWCore/Framework/interface/Event.h" -namespace edm { class EventSetup; class ParameterSet; } -namespace reco { class Track; class BeamSpot; } +class AlignableTracker; +class AlignableMuon; +class AlignableExtras; +class AlignmentParameterStore; -class AlignmentAlgorithmBase -{ +/*** Global typedefs part I (see EOF for part II) ***/ +class Trajectory; +typedef std::pair ConstTrajTrackPair; +typedef std::vector< ConstTrajTrackPair > ConstTrajTrackPairs; -public: +class IntegratedCalibrationBase; +typedef std::vector Calibrations; - typedef std::pair ConstTrajTrackPair; - typedef std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection; - typedef cond::RealTimeType::type RunNumber; - typedef std::pair RunRange; +typedef cond::RealTimeType::type RunNumber; +typedef std::pair RunRange; +typedef std::vector RunRanges; - /// define event information passed to algorithms - class EventInfo { - public: - EventInfo(const edm::EventID &theEventId, - const ConstTrajTrackPairCollection &theTrajTrackPairs, - const reco::BeamSpot &theBeamSpot, - const AliClusterValueMap *theClusterValueMap) - : eventId_(theEventId), trajTrackPairs_(theTrajTrackPairs), beamSpot_(theBeamSpot), clusterValueMap_(theClusterValueMap) {} - - const edm::EventID eventId() const { return eventId_; } - const ConstTrajTrackPairCollection& trajTrackPairs() const { return trajTrackPairs_; } - const reco::BeamSpot& beamSpot() const { return beamSpot_; } - const AliClusterValueMap* clusterValueMap() const { return clusterValueMap_; }///might be null! - - - private: - const edm::EventID eventId_; - const ConstTrajTrackPairCollection &trajTrackPairs_; - const reco::BeamSpot &beamSpot_; - const AliClusterValueMap *clusterValueMap_;///might be null! - }; - - /// define run information passed to algorithms (in endRun) - class EndRunInfo { + + +class AlignmentAlgorithmBase { public: - EndRunInfo(const edm::RunID &theRunId, const TkFittedLasBeamCollection *theTkLasBeams, - const TsosVectorCollection *theTkLasBeamTsoses) - : runId_(theRunId), tkLasBeams_(theTkLasBeams), tkLasBeamTsoses_(theTkLasBeamTsoses) {} - - const edm::RunID runId() const { return runId_; } - const TkFittedLasBeamCollection* tkLasBeams() const { return tkLasBeams_; } /// might be null! - const TsosVectorCollection* tkLasBeamTsoses() const { return tkLasBeamTsoses_; } /// might be null! - - - private: - const edm::RunID runId_; - const TkFittedLasBeamCollection *tkLasBeams_; /// might be null! - const TsosVectorCollection *tkLasBeamTsoses_; /// might be null! - }; - - /// Constructor - AlignmentAlgorithmBase(const edm::ParameterSet& cfg); - - /// Destructor - virtual ~AlignmentAlgorithmBase() {}; - - /// Call at beginning of job (must be implemented in derived class) - virtual void initialize( const edm::EventSetup& setup, - AlignableTracker* tracker, - AlignableMuon* muon, - AlignableExtras* extras, - AlignmentParameterStore* store ) = 0; - /// Pass integrated calibrations to algorithm, to be called after initialize(..). - /// (Calibrations' ownership is NOT passed to algorithm.) - /// Return whether feature is supported by algorithm, - /// default implementation returns false. - virtual bool addCalibrations(const std::vector &iCals){return false;} - - /// Call at start of loop - /// Default implementation is dummy for non-iterative algorithms - virtual void startNewLoop() {} - - /// Call at end of each loop (must be implemented in derived class) - virtual void terminate(const edm::EventSetup& iSetup) = 0; - virtual void terminate() {}; - - - /// Run the algorithm (must be implemented in derived class) - virtual void run( const edm::EventSetup &setup, const EventInfo &eventInfo) = 0; - - /// called at begin of run - virtual void beginRun(const edm::EventSetup &setup) {}; - - /// called at end of run - order of arguments like in EDProducer etc. - virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup) {}; - - /// called at begin of luminosity block (no lumi block info passed yet) - virtual void beginLuminosityBlock(const edm::EventSetup &setup) {}; - - /// called at end of luminosity block (no lumi block info passed yet) - virtual void endLuminosityBlock(const edm::EventSetup &setup) {}; - - /// called in order to pass parameters to alignables for a specific run - /// range in case the algorithm supports run range dependent alignment. - virtual bool setParametersForRunRange(const RunRange& rr) { return false; }; + // TODO: DEPRECATED: For not breaking the interface, used in serveral files. + // If possible use the global typedefs above. + typedef std::pair ConstTrajTrackPair; + typedef ConstTrajTrackPairs ConstTrajTrackPairCollection; + typedef cond::RealTimeType::type RunNumber; + typedef std::pair RunRange; + typedef std::vector RunRanges; + + + + /// Define event information passed to algorithms + class EventInfo { + public: + EventInfo(const edm::EventID& theEventId, + const ConstTrajTrackPairs& theTrajTrackPairs, + const reco::BeamSpot& theBeamSpot, + const AliClusterValueMap* theClusterValueMap) : + eventId_ (theEventId), + trajTrackPairs_ (theTrajTrackPairs), + beamSpot_ (theBeamSpot), + clusterValueMap_(theClusterValueMap) {} + + const edm::EventID eventId() const { return eventId_; } + const ConstTrajTrackPairs& trajTrackPairs() const { return trajTrackPairs_; } + const reco::BeamSpot& beamSpot() const { return beamSpot_; } + const AliClusterValueMap* clusterValueMap() const { return clusterValueMap_; } /// might be null! + + private: + const edm::EventID eventId_; + const ConstTrajTrackPairs& trajTrackPairs_; + const reco::BeamSpot& beamSpot_; + const AliClusterValueMap* clusterValueMap_; /// might be null! + }; + + /// Define run information passed to algorithms (in endRun) + class EndRunInfo { + public: + EndRunInfo(const edm::RunID& theRunId, + const TkFittedLasBeamCollection* theTkLasBeams, + const TsosVectorCollection* theTkLasBeamTsoses) : + runId_(theRunId), + tkLasBeams_(theTkLasBeams), + tkLasBeamTsoses_(theTkLasBeamTsoses) {} + + const edm::RunID runId() const { return runId_; } + const TkFittedLasBeamCollection* tkLasBeams() const { return tkLasBeams_; } /// might be null! + const TsosVectorCollection* tkLasBeamTsoses() const { return tkLasBeamTsoses_; } /// might be null! + + private: + const edm::RunID runId_; + const TkFittedLasBeamCollection* tkLasBeams_; /// might be null! + const TsosVectorCollection* tkLasBeamTsoses_; /// might be null! + }; + + + + /// Constructor + AlignmentAlgorithmBase(const edm::ParameterSet&) {} + /// Destructor + virtual ~AlignmentAlgorithmBase() {} + + /// Called at beginning of job (must be implemented in derived class) + virtual void initialize(const edm::EventSetup&, + AlignableTracker*, + AlignableMuon*, + AlignableExtras*, + AlignmentParameterStore*) = 0; + /// Called at end of job (must be implemented in derived class) + virtual void terminate(const edm::EventSetup&) = 0; + /// Called at end of job (must be implemented in derived class) + virtual void terminate() {} + + /// Returns whether calibrations is supported by algorithm, + /// default implementation returns false. + virtual bool supportsCalibrations() { return false; } + /// Pass integrated calibrations to algorithm, to be called after initialize() + /// Calibrations' ownership is NOT passed to algorithm + virtual void addCalibrations(const Calibrations&) {} + + // TODO: DEPRECATED: Actually, there are no iterative algorithms, use + // initialze() and terminate() + /// Called at start of loop, default implementation is dummy for + /// non-iterative algorithms + virtual void startNewLoop() {} + /// Called at end of loop, default implementation is dummy for + /// non-iterative algorithms + virtual void endLoop() {} + + /// Called at begin of run + virtual void beginRun(const edm::EventSetup&) {} + /// Called at end of run - order of arguments like in EDProducer etc. + virtual void endRun (const EndRunInfo&, const edm::EventSetup&) {} + + /// Called at begin of luminosity block (no lumi block info passed yet) + virtual void beginLuminosityBlock(const edm::EventSetup&) {} + /// Called at end of luminosity block (no lumi block info passed yet) + virtual void endLuminosityBlock (const edm::EventSetup&) {} + + /// Returns whether algorithm proccesses events in current configuration + virtual bool processesEvents() { return true; } + /// Run the algorithm (must be implemented in derived class) + virtual void run(const edm::EventSetup&, const EventInfo&) = 0; + + /// Called in order to pass parameters to alignables for a specific run + /// range in case the algorithm supports run range dependent alignment. + virtual bool setParametersForRunRange(const RunRange&) { return false; } }; +/*** Global typedefs part II ***/ +typedef AlignmentAlgorithmBase::EventInfo EventInfo; +typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo; + #endif diff --git a/Alignment/CommonAlignmentAlgorithm/src/AlignmentAlgorithmBase.cc b/Alignment/CommonAlignmentAlgorithm/src/AlignmentAlgorithmBase.cc deleted file mode 100644 index a313dddfcf5e8..0000000000000 --- a/Alignment/CommonAlignmentAlgorithm/src/AlignmentAlgorithmBase.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" - - -//__________________________________________________________________________________________________ -AlignmentAlgorithmBase::AlignmentAlgorithmBase( const edm::ParameterSet& cfg ) -{ - -} - diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index 3cef465cc4a55..8517b4d168ab4 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -19,11 +19,12 @@ - + + diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 838d6f2b5f4c0..252b76b38d1a4 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -5,554 +5,663 @@ /// last update: $Date: 2012/08/10 09:25:23 $ /// by : $Author: flucke $ -#include "PCLTrackerAlProducer.h" -#include "FWCore/Framework/interface/LooperFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" -#include "Alignment/CommonAlignment/interface/Alignable.h" +// TODO: Update Doxygen description -#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +/*** Header file ***/ +#include "PCLTrackerAlProducer.h" -// System include files -#include -#include +/*** Core framework functionality ***/ -// Framework -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Run.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Parse.h" - -// Conditions database #include "FWCore/ServiceRegistry/interface/Service.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" -// Geometry +/*** Alignment ***/ +#include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h" +#include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmPluginFactory.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationPluginFactory.h" +#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h" +#include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h" +#include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" +#include "Alignment/CommonAlignment/interface/SurveyDet.h" +#include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" + +/*** Geometry ***/ +#include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" + #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/Records/interface/MuonNumberingRecord.h" -#include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromDDD.h" #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h" -#include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" -#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h" -#include "Geometry/Records/interface/PTrackerParametersRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTSurveyErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" -#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" - -// Tracking, LAS and cluster flag map (fwd is enough!) -#include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" -#include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" -#include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" + +/*** Logging ***/ +#define PRINT(msg) PRINT_TO_LOGFILE(msg) \ + PRINT_TO_STDOUT(msg) +#define PRINT_TO_LOGFILE(msg) \ +edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::" \ + << __FUNCTION__ << ": " msg; +#define PRINT_TO_STDOUT(msg) \ +printf("(%s) Function %s: %s \n", typeid(*this).name(), __FUNCTION__, msg); + -// Alignment -#include "CondFormats/Alignment/interface/SurveyErrors.h" -#include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h" -#include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h" -#include "Alignment/CommonAlignment/interface/SurveyDet.h" -#include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h" -#include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmPluginFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationPluginFactory.h" -#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" //_____________________________________________________________________________ -PCLTrackerAlProducer::PCLTrackerAlProducer(const edm::ParameterSet& iConfig) : - theAlignmentAlgo(0), theAlignmentParameterStore(0), - theAlignableExtras(0), theAlignableTracker(0), theAlignableMuon(0), +PCLTrackerAlProducer +::PCLTrackerAlProducer(const edm::ParameterSet& config) : + theAlignmentAlgo(0), + theAlignmentParameterStore(0), + theTrackerAlignables(0), + theMuonAlignables(0), + theExtraAlignables(0), globalPositions_(0), - nevent_(0), theParameterSet(iConfig), - theMaxLoops( iConfig.getUntrackedParameter("maxLoops") ), - stNFixAlignables_(iConfig.getParameter("nFixAlignables") ), - stRandomShift_(iConfig.getParameter("randomShift")), - stRandomRotation_(iConfig.getParameter("randomRotation")), - applyDbAlignment_( iConfig.getUntrackedParameter("applyDbAlignment")), - checkDbAlignmentValidity_( iConfig.getUntrackedParameter("checkDbAlignmentValidity")), - doMisalignmentScenario_(iConfig.getParameter("doMisalignmentScenario")), - saveToDB_(iConfig.getParameter("saveToDB")), - saveApeToDB_(iConfig.getParameter("saveApeToDB")), - saveDeformationsToDB_(iConfig.getParameter("saveDeformationsToDB")), - doTracker_( iConfig.getUntrackedParameter("doTracker") ), - doMuon_( iConfig.getUntrackedParameter("doMuon") ), - useExtras_( iConfig.getUntrackedParameter("useExtras") ), - useSurvey_( iConfig.getParameter("useSurvey") ), - tjTkAssociationMapTag_(iConfig.getParameter("tjTkAssociationMapTag")), - beamSpotTag_(iConfig.getParameter("beamSpotTag")), - tkLasBeamTag_(iConfig.getParameter("tkLasBeamTag")), - clusterValueMapTag_(iConfig.getParameter("hitPrescaleMapTag")) -{ - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::PCLTrackerAlProducer"; - - - - // Create the alignment algorithm - edm::ParameterSet algoConfig = iConfig.getParameter( "algoConfig" ); - edm::VParameterSet iovSelection = iConfig.getParameter( "RunRangeSelection" ); - algoConfig.addUntrackedParameter( "RunRangeSelection", iovSelection ); - std::string algoName = algoConfig.getParameter( "algoName" ); - theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get( )->create( algoName, algoConfig ); - - // Check if found - if ( !theAlignmentAlgo ) - throw cms::Exception("BadConfig") << "Couldn't find algorithm called " << algoName; - - // Now create monitors: - edm::ParameterSet monitorConfig = iConfig.getParameter( "monitorConfig" ); - std::vector monitors = monitorConfig.getUntrackedParameter >( "monitors" ); - for (std::vector::const_iterator miter = monitors.begin(); miter != monitors.end(); ++miter) { - AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create(*miter, monitorConfig.getUntrackedParameter(*miter)); - - if (!newMonitor) throw cms::Exception("BadConfig") << "Couldn't find monitor named " << *miter; - theMonitors.push_back(newMonitor); - } - - // Finally create integrated calibrations: - edm::VParameterSet calibrations = iConfig.getParameter("calibrations"); - for (auto iCalib = calibrations.begin(); iCalib != calibrations.end(); ++iCalib) { - const std::string name(iCalib->getParameter("calibrationName")); - theCalibrations.push_back(IntegratedCalibrationPluginFactory::get()->create(name, *iCalib)); - // exception comes from line before: if (!theCalibrations.back()) throw cms::Exception(..) << ..; - } + /* Steering parameters */ + theParameterSet(config), + stNFixAlignables_ (config.getParameter ("nFixAlignables")), + stRandomShift_ (config.getParameter ("randomShift")), + stRandomRotation_ (config.getParameter ("randomRotation")), + applyDbAlignment_ (config.getUntrackedParameter("applyDbAlignment")), + checkDbAlignmentValidity_(config.getUntrackedParameter("checkDbAlignmentValidity")), + doMisalignmentScenario_ (config.getParameter ("doMisalignmentScenario")), + saveToDB_ (config.getParameter ("saveToDB")), + saveApeToDB_ (config.getParameter ("saveApeToDB")), + saveDeformationsToDB_ (config.getParameter ("saveDeformationsToDB")), + doTracker_ (config.getUntrackedParameter("doTracker") ), + doMuon_ (config.getUntrackedParameter("doMuon") ), + useExtras_ (config.getUntrackedParameter("useExtras")), + useSurvey_ (config.getParameter ("useSurvey")), + + /* Event input tags */ + tjTkAssociationMapTag_ (config.getParameter("tjTkAssociationMapTag")), + beamSpotTag_ (config.getParameter("beamSpotTag")), + tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), + clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) +{ + PRINT("called") + createAlignmentAlgorithm(config); + createCalibrations (config); + createMonitors (config); } - //_____________________________________________________________________________ -// Delete new objects -PCLTrackerAlProducer::~PCLTrackerAlProducer() +PCLTrackerAlProducer +::~PCLTrackerAlProducer() { - delete theAlignmentAlgo; + PRINT("called") - // Delete monitors as well?? + delete theAlignmentAlgo; - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - delete *iCal; // delete integrated calibration pointed to by (*iCal) + for (auto iCal = theCalibrations.begin(); + iCal != theCalibrations.end(); + ++iCal) { + delete *iCal; } + // TODO: Delete monitors as well? delete theAlignmentParameterStore; - delete theAlignableExtras; - delete theAlignableTracker; - delete theAlignableMuon; - + delete theTrackerAlignables; + delete theMuonAlignables; + delete theExtraAlignables; delete globalPositions_; } +/****************************************************************************** + *** INTERFACE IMPLEMENTATION *** + ******************************************************************************/ //_____________________________________________________________________________ -// Initialize algorithm -void PCLTrackerAlProducer::beginOfJob() +void PCLTrackerAlProducer +::beginJob() { -} + PRINT("called") + nevent_ = 0; -void PCLTrackerAlProducer::init(const edm::EventSetup& iSetup) { - printf("(TProdPCL) function %s in %s was called\n", __func__, __FILE__); + for (auto iCal = theCalibrations.begin(); + iCal != theCalibrations.end(); + ++iCal) { + (*iCal)->beginOfJob(theTrackerAlignables, + theMuonAlignables, + theExtraAlignables); + } + for (auto monitor = theMonitors.begin(); + monitor != theMonitors.end(); + ++monitor) { + (*monitor)->beginOfJob(theTrackerAlignables, + theMuonAlignables, + theAlignmentParameterStore); + } +} - /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob"; +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::endJob() +{ + PRINT("called") + printf("Events processed: %d", nevent_); - //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); + finish(); - // Create the geometries from the ideal geometries (first time only) - this->createGeometries_( iSetup ); - - // Retrieve and apply alignments, if requested (requires DB setup) - if ( applyDbAlignment_ ) { - // we need GlobalPositionRcd - and have to keep track for later removal - // before writing again to DB... - edm::ESHandle globalPositionRcd; - iSetup.get().get(globalPositionRcd); - globalPositions_ = new Alignments(*globalPositionRcd); + for (auto monitor = theMonitors.begin(); + monitor != theMonitors.end(); + ++monitor) { + (*monitor)->endOfJob(); + } - if ( doTracker_ ) { // apply to tracker - this->applyDB - (&(*theTracker), iSetup, - align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Tracker))); - this->applyDB(&(*theTracker), iSetup); - } - - if ( doMuon_ ) { // apply to tracker - this->applyDB - (&(*theMuonDT), iSetup, - align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); - this->applyDB - (&(*theMuonCSC), iSetup, - align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); - } + for (auto iCal = theCalibrations.begin(); + iCal != theCalibrations.end(); + ++iCal) { + (*iCal)->endOfJob(); } +} - // Create alignable tracker and muon - if (doTracker_) { - theAlignableTracker = new AlignableTracker( &(*theTracker), tTopo ); +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::beginRun(const edm::Run& run, const edm::EventSetup& setup) +{ + PRINT("called") + // Do not forward edm::Run + theAlignmentAlgo->beginRun(setup); +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::endRun(const edm::Run& run, const edm::EventSetup& setup) +{ + PRINT("called") + + // TODO: Either MP nor HIP is implementing the endRun() method... so this + // seems to be useless? + + if (tkLasBeamTag_.encode().size()) { + edm::Handle lasBeams; + edm::Handle tsoses; + run.getByLabel(tkLasBeamTag_, lasBeams); + run.getByLabel(tkLasBeamTag_, tsoses); + + theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), + &(*tsoses)), setup); + } else { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endRun" + << "No Tk LAS beams to forward to algorithm."; + theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); } +} - if (doMuon_) { - theAlignableMuon = new AlignableMuon( &(*theMuonDT), &(*theMuonCSC) ); +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, + const edm::EventSetup & setup) +{ + PRINT("called") + // Do not forward edm::LuminosityBlock + theAlignmentAlgo->beginLuminosityBlock(setup); +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, + const edm::EventSetup& setup) +{ + PRINT("called") + // Do not forward edm::LuminosityBlock + theAlignmentAlgo->endLuminosityBlock(setup); +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::analyze(const edm::Event& event, const edm::EventSetup& setup) +{ + PRINT("called") + ++nevent_; + + if (setupChanged(setup)) { + initAlignmentAlgorithm(setup); + initBeamSpot(event); } - if (useExtras_) { - theAlignableExtras = new AlignableExtras(); + if (!theAlignmentAlgo->processesEvents()) { + edm::LogWarning("BadConfig") << "@SUB=PCLTrackerAlProducer::analyze" + << "Skipping event. The current configuration " + << "of the alignment algorithm does not need " + << "to process any events."; + return; } - // Create alignment parameter builder - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" - << "Creating AlignmentParameterBuilder"; - edm::ParameterSet aliParamBuildCfg = - theParameterSet.getParameter("ParameterBuilder"); - AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker, - theAlignableMuon, - theAlignableExtras, - aliParamBuildCfg ); - // Fix alignables if requested - if (stNFixAlignables_>0) alignmentParameterBuilder.fixAlignables(stNFixAlignables_); + // reading in survey records + this->readInSurveyRcds(setup); - // Get list of alignables - Alignables theAlignables = alignmentParameterBuilder.alignables(); - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" - << "got " << theAlignables.size() << " alignables"; + // Retrieve trajectories and tracks from the event + // -> merely skip if collection is empty + edm::Handle handleTrajTracksCollection; - // Create AlignmentParameterStore - edm::ParameterSet aliParamStoreCfg = - theParameterSet.getParameter("ParameterStore"); - theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg); - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" - << "AlignmentParameterStore created!"; + if (event.getByLabel(tjTkAssociationMapTag_, handleTrajTracksCollection)) { + // Form pairs of trajectories and tracks + ConstTrajTrackPairs trajTracks; + for (auto iter = handleTrajTracksCollection->begin(); + iter != handleTrajTracksCollection->end(); + ++iter) { + trajTracks.push_back(ConstTrajTrackPair(&(*(*iter).key), &(*(*iter).val))); + } - // Apply misalignment scenario to alignable tracker and muon if requested - // WARNING: this assumes scenarioConfig can be passed to both muon and tracker - if (doMisalignmentScenario_ && (doTracker_ || doMuon_)) { - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" - << "Applying misalignment scenario to " - << (doTracker_ ? "tracker" : "") - << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : "."); - edm::ParameterSet scenarioConfig - = theParameterSet.getParameter( "MisalignmentScenario" ); - if (doTracker_) { - TrackerScenarioBuilder scenarioBuilder( theAlignableTracker ); - scenarioBuilder.applyScenario( scenarioConfig ); + //check that the input tag is not empty + const AliClusterValueMap* clusterValueMapPtr = 0; + if (clusterValueMapTag_.encode().size()) { + edm::Handle clusterValueMap; + event.getByLabel(clusterValueMapTag_, clusterValueMap); + clusterValueMapPtr = &(*clusterValueMap); } - if (doMuon_) { - MuonScenarioBuilder muonScenarioBuilder( theAlignableMuon ); - muonScenarioBuilder.applyScenario( scenarioConfig ); + + const EventInfo eventInfo(event.id(), + trajTracks, + *theBeamSpot, + clusterValueMapPtr); + + // Run the alignment algorithm with its input + theAlignmentAlgo->run(setup, eventInfo); + + for (auto monitor = theMonitors.begin(); + monitor != theMonitors.end(); + ++monitor) { + (*monitor)->duringLoop(event, setup, trajTracks); // forward eventInfo? } + } else { - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" - << "NOT applying misalignment scenario!"; + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" + << "No track collection found: skipping event"; } +} - // Apply simple misalignment - const std::string sParSel(theParameterSet.getParameter("parameterSelectorSimple")); - this->simpleMisalignment_(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); - // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm - theAlignmentAlgo->initialize( iSetup, - theAlignableTracker, theAlignableMuon, theAlignableExtras, - theAlignmentParameterStore ); - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignableExtras); - } - // Not all algorithms support calibrations - so do not pass empty vector - // and throw if non-empty and not supported: - if (!theCalibrations.empty() && !theAlignmentAlgo->addCalibrations(theCalibrations)) { - throw cms::Exception("BadConfig") << "[PCLTrackerAlProducer::beginOfJob]\n" - << "Configured " << theCalibrations.size() << " calibration(s) " - << "for algorithm not supporting it."; - } - for (std::vector::const_iterator monitor = theMonitors.begin(); - monitor != theMonitors.end(); ++monitor) { - (*monitor)->beginOfJob(theAlignableTracker, theAlignableMuon, theAlignmentParameterStore); - } +/****************************************************************************** + *** PRIVATE METHOD IMPLEMENTATION *** + ******************************************************************************/ +/*** Code which is independent of Event & Setup + Called from constructor ***/ +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::createAlignmentAlgorithm(const edm::ParameterSet& config) +{ + edm::ParameterSet algoConfig = config.getParameter("algoConfig"); + edm::VParameterSet iovSelection = config.getParameter("RunRangeSelection"); + algoConfig.addUntrackedParameter("RunRangeSelection", iovSelection); + std::string algoName = algoConfig.getParameter("algoName"); + theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig); - /* 1) Former: AlignmentProducer::startingNewLoop(unsigned int iLoop) */ - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::startingNewLoop"; + if (!theAlignmentAlgo) { + throw cms::Exception("BadConfig") + << "Couldn't find the called alignment algorithm: " << algoName; + } +} - nevent_ = 0; +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::createMonitors(const edm::ParameterSet& config) +{ + edm::ParameterSet monitorConfig = config.getParameter("monitorConfig"); + std::vector monitors = monitorConfig.getUntrackedParameter>("monitors"); + + for (auto miter = monitors.begin(); + miter != monitors.end(); + ++miter) { + AlignmentMonitorBase* newMonitor = AlignmentMonitorPluginFactory::get()->create( + *miter, monitorConfig.getUntrackedParameter(*miter) + ); + + if (!newMonitor) { + throw cms::Exception("BadConfig") << "Couldn't find monitor named " + << *miter; + } - theAlignmentAlgo->startNewLoop(); - // FIXME: Should this be done in algorithm::startNewLoop()?? - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->startNewLoop(); + theMonitors.push_back(newMonitor); } +} - for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { - (*monitor)->startingNewLoop(); +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::createCalibrations(const edm::ParameterSet& config) +{ + edm::VParameterSet calibrations = config.getParameter("calibrations"); + + for (auto iCalib = calibrations.begin(); + iCalib != calibrations.end(); + ++iCalib) { + theCalibrations.push_back( + IntegratedCalibrationPluginFactory::get()->create( + iCalib->getParameter("calibrationName"), *iCalib + ) + ); } - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::startingNewLoop" - << "Now physically apply alignments to geometry..."; + // Not all algorithms support calibrations - so do not pass empty vector + // and throw if non-empty and not supported: + if (!theCalibrations.empty()) { + if (theAlignmentAlgo->supportsCalibrations()) { + theAlignmentAlgo->addCalibrations(theCalibrations); + } else { + throw cms::Exception("BadConfig") + << "[TrackerAlignmentProducerForPCL::init]\n" + << "Configured " << theCalibrations.size() << " calibration(s) " + << "for algorithm not supporting it."; + } + } +} - // Propagate changes to reconstruction geometry (from initialisation or iteration) - GeometryAligner aligner; - if ( doTracker_ ) { - std::auto_ptr alignments(theAlignableTracker->alignments()); - std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); - aligner.applyAlignments( &(*theTracker),&(*alignments),&(*alignmentErrors), AlignTransform() ); // don't apply global a second time! - std::auto_ptr aliDeforms(theAlignableTracker->surfaceDeformations()); - aligner.attachSurfaceDeformations(&(*theTracker), &(*aliDeforms)); - } - if ( doMuon_ ) { - std::auto_ptr dtAlignments( theAlignableMuon->dtAlignments()); - std::auto_ptr dtAlignmentErrorsExtended( theAlignableMuon->dtAlignmentErrorsExtended()); - std::auto_ptr cscAlignments( theAlignableMuon->cscAlignments()); - std::auto_ptr cscAlignmentErrorsExtended( theAlignableMuon->cscAlignmentErrorsExtended()); - aligner.applyAlignments( &(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrorsExtended), AlignTransform() ); // don't apply global a second time! - aligner.applyAlignments( &(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrorsExtended), AlignTransform() ); // nope! - } -} +/*** Code which is dependent of Event & Setup + Called and checked for each Event ***/ //_____________________________________________________________________________ -// Terminate algorithm -void PCLTrackerAlProducer::endOfJob() +bool PCLTrackerAlProducer +::setupChanged(const edm::EventSetup& setup) { - /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ - if (0 == nevent_) { - // beginOfJob is usually called by the framework in the first event of the first loop - // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) - // and the algorithms rely on the initialisations done in beginOfJob. We cannot call - // this->beginOfJob(iSetup); here either since that will access the EventSetup to get - // some geometry information that is not defined either without having seen an event. - edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfLoop" - << "Did not process any events in loop" - << ", stop processing without terminating algorithm."; - return; - } + PRINT("Checking EventSetup") + + if (watchTrackerAlRcd.check(setup)) { + PRINT("TrackerAlignmentRcd has changed") + + /* + const auto& rcd = setup.get(); - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfLoop" - << "Terminating algorithm."; + const edm::ValidityInterval& validity = rcd.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); - theAlignmentAlgo->terminate(); - // FIXME: Should this be done in algorithm::terminate(const edm::EventSetup& iSetup)?? - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->endOfLoop(); + auto eID1 = first.eventID(); + printf("(TProdPCL) first runnumber: %u\n", eID1.run()); + printf("(TProdPCL) first event: %llu\n", eID1.event()); + + auto eID2 = last.eventID(); + printf("(TProdPCL) last runnumber: %u\n", eID2.run()); + printf("(TProdPCL) last event: %llu\n", eID2.event()); + */ + + return true; + } + + if (watchTrackerAlErrorExtRcd.check(setup)) { + PRINT("TrackerAlignmentErrorExtendedRcd has changed") + return true; } /* - for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { - (*monitor)->endOfLoop(iSetup); + if (watchTrackerSurDeRcd.check(setup)) { + printf("(TProdPCL) AlignmentProducerForPCL::analyze | " + "TrackerSurfaceDeformationRcd has changed (event nr: %d)\n", nevent_); + return true; + } + if (watchDTAlRcd.check(setup)) { + printf("(TProdPCL) AlignmentProducerForPCL::analyze | " + "DTAlignmentRcd has changed (event nr: %d)\n", nevent_); + return true; + } + if (watchTrackerDigiGeoRcd.check(setup)) { + printf("(TProdPCL) AlignmentProducerForPCL::analyze | " + "TrackerDigiGeometryRcd has changed (event nr: %d)\n", nevent_); + return true; + } + if (watchGlobalPosRcd.check(setup)) { + printf("(TProdPCL) AlignmentProducerForPCL::analyze | " + "GlobalPositionRcd has changed (event nr: %d)\n", nevent_); + return true; + } + if (watchIdealGeoRcd.check(setup)) { + printf("(TProdPCL) AlignmentProducerForPCL::analyze | " + "IdealGeometryRecord has changed (event nr: %d)\n", nevent_); + return true; } */ + return false; +} +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::initAlignmentAlgorithm(const edm::EventSetup& setup) +{ + PRINT("called") + /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob"; + // Retrieve tracker topology from geometry + edm::ESHandle tTopoHandle; + setup.get().get(tTopoHandle); + const TrackerTopology* const tTopo = tTopoHandle.product(); - /* 2) Former: void AlignmentProducer::endOfJob() */ - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob"; - for (std::vector::const_iterator monitor = theMonitors.begin(); monitor != theMonitors.end(); ++monitor) { - (*monitor)->endOfJob(); - } - if (0 == nevent_) { - edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" << "Did not process any " - << "events in last loop, do not dare to store to DB."; - } else { - - // Expand run ranges and make them unique - edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); - RunRanges uniqueRunRanges(this->makeNonOverlappingRunRanges(runRangeSelectionVPSet)); - if (uniqueRunRanges.empty()) { // create dummy IOV - const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue, - cond::timeTypeSpecs[cond::runnumber].endValue); - uniqueRunRanges.push_back(runRange); - } - - std::vector beamSpotParameters; + // Create the geometries from the ideal geometries (first time only) + //std::shared_ptr theTrackerGeometry; + createGeometries(setup); - for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); - iRunRange != uniqueRunRanges.end(); - ++iRunRange) { - theAlignmentAlgo->setParametersForRunRange(*iRunRange); + applyAlignmentsToDB(setup); + createAlignables(tTopo); + buildParameterStore(); + applyMisalignment(); - // Save alignments to database - if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_) - this->writeForRunRange((*iRunRange).first); - - // Deal with extra alignables, e.g. beam spot - if (theAlignableExtras) { - Alignables &alis = theAlignableExtras->beamSpot(); - if (!alis.empty()) { - BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast(alis[0]->alignmentParameters()); - beamSpotParameters.push_back(beamSpotAliPars->parameters()); - } - } - } - - if (theAlignableExtras) { - std::ostringstream bsOutput; - - std::vector::const_iterator itPar = beamSpotParameters.begin(); - for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); - iRunRange != uniqueRunRanges.end(); - ++iRunRange, ++itPar) { - bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n"; - bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; - bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; - } - - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" - << "Parameters for alignable beamspot:\n" - << bsOutput.str(); - } - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->endOfJob(); - } + // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm + theAlignmentAlgo->initialize(setup, + theTrackerAlignables, + theMuonAlignables, + theExtraAlignables, + theAlignmentParameterStore); - } + applyAlignmentsToGeometry(); } +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::initBeamSpot(const edm::Event& event) +{ + event.getByLabel(beamSpotTag_, theBeamSpot); + if (theExtraAlignables) { + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::initBeamSpot" + << "Initializing AlignableBeamSpot"; + + theExtraAlignables->initializeBeamSpot(theBeamSpot->x0(), + theBeamSpot->y0(), + theBeamSpot->z0(), + theBeamSpot->dxdz(), + theBeamSpot->dydz()); + } +} //_____________________________________________________________________________ -// Called at each event -void PCLTrackerAlProducer::analyze(const edm::Event& event, const edm::EventSetup& setup) +void PCLTrackerAlProducer +::createGeometries(const edm::EventSetup& setup) { - ++nevent_; - if (watchTrackerAlRcd.check(setup)) { - printf("(TProdPCL) PCLTrackerAlProducer::analyze | " - "TrackerAlignmentRcd has changed (event nr: %d)\n", nevent_); - init(setup); + if (doTracker_) { + edm::ESHandle geometricDet; + setup.get().get(geometricDet); + + TrackerGeomBuilderFromGeometricDet trackerBuilder; + theTrackerGeometry = boost::shared_ptr( + trackerBuilder.build(&(*geometricDet), theParameterSet) + ); } + if (doMuon_) { + edm::ESTransientHandle cpv; + edm::ESHandle mdc; - // reading in survey records - this->readInSurveyRcds(setup); - - // Printout event number - for ( int i=10; i<10000000; i*=10 ) - if ( nevent_<10*i && (nevent_%i)==0 ) - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" - << "Events processed: " << nevent_; - - // Retrieve trajectories and tracks from the event - // -> merely skip if collection is empty - edm::Handle m_TrajTracksMap; - if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) { - - // Form pairs of trajectories and tracks - ConstTrajTrackPairCollection trajTracks; - for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin(); - iPair != m_TrajTracksMap->end(); ++iPair) { - trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) ); - } - edm::Handle beamSpot; - event.getByLabel(beamSpotTag_, beamSpot); - - if (nevent_==1 && theAlignableExtras) { - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" - << "initializing AlignableBeamSpot" << std::endl; - theAlignableExtras->initializeBeamSpot(beamSpot->x0(), beamSpot->y0(), beamSpot->z0(), - beamSpot->dxdz(), beamSpot->dydz()); + setup.get().get(cpv); + setup.get().get(mdc); + + theMuonDTGeometry = boost::shared_ptr (new DTGeometry); + theMuonCSCGeometry = boost::shared_ptr(new CSCGeometry); + + DTGeometryBuilderFromDDD DTGeometryBuilder; + CSCGeometryBuilderFromDDD CSCGeometryBuilder; + DTGeometryBuilder.build (theMuonDTGeometry, &(*cpv), *mdc); + CSCGeometryBuilder.build(theMuonCSCGeometry, &(*cpv), *mdc); + } +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::applyAlignmentsToDB(const edm::EventSetup& setup) +{ + // Retrieve and apply alignments, if requested (requires z setup) + if (applyDbAlignment_) { + // we need GlobalPositionRcd - and have to keep track for later removal + // before writing again to DB... + edm::ESHandle globalPositionRcd; + setup.get().get(globalPositionRcd); + globalPositions_ = new Alignments(*globalPositionRcd); + + if (doTracker_) { + applyDB( + &(*theTrackerGeometry), + setup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Tracker)) + ); + + applyDB( + &(*theTrackerGeometry), + setup + ); } - // Run the alignment algorithm with its input - const AliClusterValueMap *clusterValueMapPtr = 0; - if(clusterValueMapTag_.encode().size()){//check that the input tag is not empty - edm::Handle clusterValueMap; - event.getByLabel(clusterValueMapTag_, clusterValueMap); - clusterValueMapPtr = &(*clusterValueMap); + if (doMuon_) { + applyDB ( + &(*theMuonDTGeometry), + setup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon)) + ); + + applyDB ( + &(*theMuonCSCGeometry), + setup, + align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon)) + ); } + } +} - const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *beamSpot, - clusterValueMapPtr); - theAlignmentAlgo->run(setup, eventInfo); +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::createAlignables(const TrackerTopology* const tTopo) +{ + if (doTracker_) { + theTrackerAlignables = new AlignableTracker(&(*theTrackerGeometry), tTopo); + } + if (doMuon_) { + theMuonAlignables = new AlignableMuon(&(*theMuonDTGeometry), &(*theMuonCSCGeometry)); + } - for (std::vector::const_iterator monitor = theMonitors.begin(); - monitor != theMonitors.end(); ++monitor) { - (*monitor)->duringLoop(event, setup, trajTracks); // forward eventInfo? - } - } else { - edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" - << "No track collection found: skipping event"; + if (useExtras_) { + theExtraAlignables = new AlignableExtras(); } } +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::buildParameterStore() +{ + // Create alignment parameter builder + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::buildParameterStore" + << "Creating AlignmentParameterBuilder"; + + edm::ParameterSet alParamBuildCfg = theParameterSet.getParameter("ParameterBuilder"); + edm::ParameterSet alParamStoreCfg = theParameterSet.getParameter("ParameterStore"); + AlignmentParameterBuilder alignmentParameterBuilder(theTrackerAlignables, + theMuonAlignables, + theExtraAlignables, + alParamBuildCfg); + + // Fix alignables if requested + if (stNFixAlignables_ > 0) { + alignmentParameterBuilder.fixAlignables(stNFixAlignables_); + } + + // Get list of alignables + Alignables theAlignables = alignmentParameterBuilder.alignables(); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::buildParameterStore" + << "got " << theAlignables.size() << " alignables"; + + // Create AlignmentParameterStore + theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, alParamStoreCfg); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::buildParameterStore" + << "AlignmentParameterStore created!"; +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::applyMisalignment() +{ + // Apply misalignment scenario to alignable tracker and muon if requested + // WARNING: this assumes scenarioConfig can be passed to both muon and tracker + if (doMisalignmentScenario_ && (doTracker_ || doMuon_)) { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob" + << "Applying misalignment scenario to " + << (doTracker_ ? "tracker" : "") + << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : "."); + edm::ParameterSet scenarioConfig = theParameterSet.getParameter("MisalignmentScenario"); -// ---------------------------------------------------------------------------- -void PCLTrackerAlProducer::beginRun(const edm::Run &run, const edm::EventSetup &setup) -{ - theAlignmentAlgo->beginRun(setup); // do not forward edm::Run... -} + if (doTracker_) { + TrackerScenarioBuilder scenarioBuilder(theTrackerAlignables); + scenarioBuilder.applyScenario(scenarioConfig); + } + if (doMuon_) { + MuonScenarioBuilder muonScenarioBuilder(theMuonAlignables); + muonScenarioBuilder.applyScenario(scenarioConfig); + } -// ---------------------------------------------------------------------------- -void PCLTrackerAlProducer::endRun(const edm::Run &run, const edm::EventSetup &setup) -{ - // call with or without las beam info... - typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo; - if (tkLasBeamTag_.encode().size()) { // non-empty InputTag - edm::Handle lasBeams; - edm::Handle tsoses; - run.getByLabel(tkLasBeamTag_, lasBeams); - run.getByLabel(tkLasBeamTag_, tsoses); - - theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup); } else { - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endRun" - << "No Tk LAS beams to forward to algorithm."; - theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); + edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" + << "NOT applying misalignment scenario!"; } -} - -// ---------------------------------------------------------------------------- -void PCLTrackerAlProducer::beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, - const edm::EventSetup &setup) -{ - theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock -} -// ---------------------------------------------------------------------------- -void PCLTrackerAlProducer::endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, - const edm::EventSetup &setup) -{ - theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock + // Apply simple misalignment + const std::string sParSel(theParameterSet.getParameter("parameterSelectorSimple")); + //simpleMisalignment(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); + simpleMisalignment(theAlignmentParameterStore->alignables(), sParSel, stRandomShift_, stRandomRotation_, true); } -// ---------------------------------------------------------------------------- - -void PCLTrackerAlProducer::simpleMisalignment_(const Alignables &alivec, const std::string &selection, - float shift, float rot, bool local) +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::simpleMisalignment(const Alignables& alivec, const std::string& selection, + float shift, float rot, bool local) { - std::ostringstream output; // collecting output if (shift > 0. || rot > 0.) { @@ -563,42 +672,50 @@ void PCLTrackerAlProducer::simpleMisalignment_(const Alignables &alivec, const s if (selection != "-1") { AlignmentParameterSelector aSelector(0,0); // no alignable needed here... const std::vector cSel(aSelector.convertParamSel(selection)); + if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) { - throw cms::Exception("BadConfig") - << "[PCLTrackerAlProducer::simpleMisalignment_]\n" - << "Expect selection string '" << selection << "' to be at least of length " - << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" - << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; + throw cms::Exception("BadConfig") + << "[PCLTrackerAlProducer::simpleMisalignment_]\n" + << "Expect selection string '" << selection << "' to be at least of length " + << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" + << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; } - for (std::vector::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) { + + for (auto cIter = cSel.begin(); + cIter != cSel.end(); + ++cIter) { commSel.push_back(*cIter == '0' ? false : true); } - output << "parameters defined by (" << selection + output << "parameters defined by (" << selection << "), representing (x,y,z,alpha,beta,gamma),"; + } else { output << "the active parameters of each alignable,"; } output << " in " << (local ? "local" : "global") << " frame."; - for (std::vector::const_iterator it = alivec.begin(); it != alivec.end(); ++it) { - Alignable* ali=(*it); + for (auto it = alivec.begin(); + it != alivec.end(); + ++it) { + Alignable* ali = (*it); std::vector mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel); - + if (std::abs(shift)>0.00001) { - double s0 = 0., s1 = 0., s2 = 0.; + double s0 = 0., s1 = 0., s2 = 0.; + if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.; if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.; if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.; - + if (local) ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) ); - else ali->move( align::GlobalVector(s0,s1,s2) ); + else ali->move( align::GlobalVector(s0,s1,s2) ); - //AlignmentPositionError ape(dx,dy,dz); - //ali->addAlignmentPositionError(ape); + //AlignmentPositionError ape(dx,dy,dz); + //ali->addAlignmentPositionError(ape); } if (std::abs(rot)>0.00001) { - align::EulerAngles r(3); + align::EulerAngles r(3); if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.; if (mysel[RigidBodyAlignmentParameters::dbeta]) r(2)=rot*double(random()%1000-500)/500.; if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.; @@ -606,317 +723,546 @@ void PCLTrackerAlProducer::simpleMisalignment_(const Alignables &alivec, const s const align::RotationType mrot = align::toMatrix(r); if (local) ali->rotateInLocalFrame(mrot); else ali->rotateInGlobalFrame(mrot); - - //ali->addAlignmentPositionErrorFromRotation(mrot); + //ali->addAlignmentPositionErrorFromRotation(mrot); } - } // end loop on alignables + } + } else { output << "No simple misalignment added!"; } + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::simpleMisalignment_" << output.str(); } - -//__________________________________________________________________________________________________ -void PCLTrackerAlProducer::createGeometries_( const edm::EventSetup& iSetup ) +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::applyAlignmentsToGeometry() { - edm::ESTransientHandle cpv; - iSetup.get().get( cpv ); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::startingNewLoop" + << "Now physically apply alignments to geometry..."; + + // Propagate changes to reconstruction geometry (from initialisation or iteration) + GeometryAligner aligner; - if (doTracker_) { - edm::ESHandle geometricDet; - iSetup.get().get( geometricDet ); - edm::ESHandle ptp; - iSetup.get().get( ptp ); - TrackerGeomBuilderFromGeometricDet trackerBuilder; - theTracker = boost::shared_ptr( trackerBuilder.build(&(*geometricDet), *ptp )); - } + if (doTracker_) { + std::auto_ptr alignments( theTrackerAlignables->alignments()); + std::auto_ptr alignmentErrExt(theTrackerAlignables->alignmentErrors()); + std::auto_ptr aliDeforms( theTrackerAlignables->surfaceDeformations()); + + aligner.applyAlignments( + &(*theTrackerGeometry), + &(*alignments), + &(*alignmentErrExt), + AlignTransform() + ); // don't apply global a second time! + + aligner.attachSurfaceDeformations( + &(*theTrackerGeometry), + &(*aliDeforms) + ); + } - if (doMuon_) { - edm::ESHandle mdc; - iSetup.get().get(mdc); - DTGeometryBuilderFromDDD DTGeometryBuilder; - CSCGeometryBuilderFromDDD CSCGeometryBuilder; - theMuonDT = boost::shared_ptr(new DTGeometry ); - DTGeometryBuilder.build( theMuonDT, &(*cpv), *mdc); - theMuonCSC = boost::shared_ptr( new CSCGeometry ); - CSCGeometryBuilder.build( theMuonCSC, &(*cpv), *mdc ); - } + if (doMuon_) { + std::auto_ptr dtAlignments( theMuonAlignables->dtAlignments()); + std::auto_ptr cscAlignments(theMuonAlignables->cscAlignments()); + + std::auto_ptr dtAlignmentErrExt( + theMuonAlignables->dtAlignmentErrorsExtended() + ); + std::auto_ptr cscAlignmentErrExt( + theMuonAlignables->cscAlignmentErrorsExtended() + ); + + aligner.applyAlignments( + &(*theMuonDTGeometry), + &(*dtAlignments), + &(*dtAlignmentErrExt), + AlignTransform() + ); // don't apply global a second time! + + aligner.applyAlignments( + &(*theMuonCSCGeometry), + &(*cscAlignments), + &(*cscAlignmentErrExt), + AlignTransform() + ); // nope! + } } -void PCLTrackerAlProducer::addSurveyInfo_(Alignable* ali) +//_____________________________________________________________________________ +template +void PCLTrackerAlProducer +::applyDB(G* geometry, const edm::EventSetup& setup, + const AlignTransform& globalCoordinates) const { - const std::vector& comp = ali->components(); + // 'G' is the geometry class for that DB should be applied, + // 'Rcd' is the record class for its Alignments + // 'ErrRcd' is the record class for its AlignmentErrorsExtended + // 'globalCoordinates' are global transformation for this geometry - unsigned int nComp = comp.size(); + const Rcd& record = setup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval & validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); - for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo_(comp[i]); + if (first != edm::IOVSyncValue::beginOfTime() || + last != edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=PCLTrackerAlProducer::applyDB" + << "\nTrying to apply " << record.key().name() + << " with multiple IOVs in tag.\nValidity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } - const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; + edm::ESHandle alignments; + record.get(alignments); - if ( ali->id() != error.rawId() || - ali->alignableObjectId() != error.structureType() ) - { - throw cms::Exception("DatabaseError") - << "Error reading survey info from DB. Mismatched id!"; - } + edm::ESHandle alignmentErrExt; + setup.get().get(alignmentErrExt); - const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); - const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); + GeometryAligner aligner; + aligner.applyAlignments(geometry, &(*alignments), &(*alignmentErrExt), + globalCoordinates); +} - AlignableSurface surf( align::PositionType( pos.x(), pos.y(), pos.z() ), - align::RotationType( rot.xx(), rot.xy(), rot.xz(), - rot.yx(), rot.yy(), rot.yz(), - rot.zx(), rot.zy(), rot.zz() ) ); +//_____________________________________________________________________________ +template +void PCLTrackerAlProducer +::applyDB(G* geometry, const edm::EventSetup& setup) const +{ + // 'G' is the geometry class for that DB should be applied, + // 'DeformationRcd' is the record class for its surface deformations - surf.setWidth( ali->surface().width() ); - surf.setLength( ali->surface().length() ); + const DeformationRcd & record = setup.get(); + if (checkDbAlignmentValidity_) { + const edm::ValidityInterval & validity = record.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); - ali->setSurvey( new SurveyDet( surf, error.matrix() ) ); + if (first != edm::IOVSyncValue::beginOfTime() || + last != edm::IOVSyncValue::endOfTime()) { + throw cms::Exception("DatabaseError") + << "@SUB=PCLTrackerAlProducer::applyDB" + << "\nTrying to apply " << record.key().name() + << " with multiple IOVs in tag.\nValidity range is " + << first.eventID().run() << " - " << last.eventID().run(); + } + } + edm::ESHandle surfaceDeformations; + record.get(surfaceDeformations); - ++theSurveyIndex; + GeometryAligner aligner; + aligner.attachSurfaceDeformations(geometry, &(*surfaceDeformations)); } -void PCLTrackerAlProducer::readInSurveyRcds( const edm::EventSetup& iSetup ){ - +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::readInSurveyRcds(const edm::EventSetup& setup) +{ // Get Survey Rcds and add Survey Info - if ( doTracker_ && useSurvey_ ){ - bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup); - bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); - edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool; - edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool; - if ( tkSurveyBool || tkSurveyErrBool){ - - edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION"; - edm::ESHandle surveys; + if (doTracker_ && useSurvey_){ + bool tkSurveyBool = watchTkSurveyRcd_.check(setup); + bool tkSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); + + if (tkSurveyBool || tkSurveyErrBool) { + edm::ESHandle surveys; edm::ESHandle surveyErrors; - - iSetup.get().get(surveys); - iSetup.get().get(surveyErrors); - + setup.get(). get(surveys); + setup.get().get(surveyErrors); + theSurveyIndex = 0; - theSurveyValues = &*surveys; - theSurveyErrors = &*surveyErrors; - addSurveyInfo_(theAlignableTracker); + theSurveyValues = &(*surveys); + theSurveyErrors = &(*surveyErrors); + + addSurveyInfo(theTrackerAlignables); } } - - if ( doMuon_ && useSurvey_) { - bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup); - bool DTSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); - bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup); - bool CSCSurveyErrBool = watchTkSurveyErrRcd_.check(iSetup); - - if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){ - edm::ESHandle dtSurveys; - edm::ESHandle dtSurveyErrors; - edm::ESHandle cscSurveys; + + if (doMuon_ && useSurvey_) { + bool DTSurveyBool = watchTkSurveyRcd_.check(setup); + bool DTSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); + bool CSCSurveyBool = watchTkSurveyRcd_.check(setup); + bool CSCSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); + + if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool){ + edm::ESHandle dtSurveys; + edm::ESHandle dtSurveyErrors; + edm::ESHandle cscSurveys; edm::ESHandle cscSurveyErrors; - - iSetup.get().get(dtSurveys); - iSetup.get().get(dtSurveyErrors); - iSetup.get().get(cscSurveys); - iSetup.get().get(cscSurveyErrors); - + setup.get(). get(dtSurveys); + setup.get(). get(dtSurveyErrors); + setup.get(). get(cscSurveys); + setup.get().get(cscSurveyErrors); + theSurveyIndex = 0; - theSurveyValues = &*dtSurveys; - theSurveyErrors = &*dtSurveyErrors; - std::vector barrels = theAlignableMuon->DTBarrel(); - for (std::vector::const_iterator iter = barrels.begin(); iter != barrels.end(); ++iter) { - addSurveyInfo_(*iter); + theSurveyValues = &(*dtSurveys); + theSurveyErrors = &(*dtSurveyErrors); + + Alignables barrels = theMuonAlignables->DTBarrel(); + for (auto iter = barrels.begin(); + iter != barrels.end(); + ++iter) { + addSurveyInfo(*iter); } - + theSurveyIndex = 0; - theSurveyValues = &*cscSurveys; - theSurveyErrors = &*cscSurveyErrors; - std::vector endcaps = theAlignableMuon->CSCEndcaps(); - for (std::vector::const_iterator iter = endcaps.begin(); iter != endcaps.end(); ++iter) { - addSurveyInfo_(*iter); + theSurveyValues = &(*cscSurveys); + theSurveyErrors = &(*cscSurveyErrors); + + Alignables endcaps = theMuonAlignables->CSCEndcaps(); + for (auto iter = endcaps.begin(); + iter != endcaps.end(); + ++iter) { + addSurveyInfo(*iter); } } } - } - -////////////////////////////////////////////////// -// a templated method - but private, so not accessible from outside -// ==> does not have to be in header file -template -void PCLTrackerAlProducer::applyDB(G* geometry, const edm::EventSetup &iSetup, - const AlignTransform &globalCoordinates) const +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::addSurveyInfo(Alignable* alignable) { - // 'G' is the geometry class for that DB should be applied, - // 'Rcd' is the record class for its Alignments - // 'ErrRcd' is the record class for its AlignmentErrorsExtended - // 'globalCoordinates' are global transformation for this geometry + edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION"; - const Rcd & record = iSetup.get(); - if (checkDbAlignmentValidity_) { - const edm::ValidityInterval & validity = record.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); - if (first!=edm::IOVSyncValue::beginOfTime() || - last!=edm::IOVSyncValue::endOfTime()) { - throw cms::Exception("DatabaseError") - << "@SUB=PCLTrackerAlProducer::applyDB" - << "\nTrying to apply " - << record.key().name() - << " with multiple IOVs in tag.\n" - << "Validity range is " - << first.eventID().run() << " - " << last.eventID().run(); - } + const std::vector& comp = alignable->components(); + for (size_t i = 0; i < comp.size(); ++i) { + addSurveyInfo(comp[i]); } - edm::ESHandle alignments; - record.get(alignments); + const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; + + if (alignable->id() != error.rawId() || + alignable->alignableObjectId() != error.structureType()) { + throw cms::Exception("DatabaseError") + << "Error reading survey info from DB. Mismatched id!"; + } + + const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); + const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); - edm::ESHandle alignmentErrors; - iSetup.get().get(alignmentErrors); + AlignableSurface surf(align::PositionType(pos.x(), pos.y(), pos.z()), + align::RotationType(rot.xx(), rot.xy(), rot.xz(), + rot.yx(), rot.yy(), rot.yz(), + rot.zx(), rot.zy(), rot.zz())); + surf.setWidth (alignable->surface().width()); + surf.setLength(alignable->surface().length()); + alignable->setSurvey(new SurveyDet(surf, error.matrix())); + + ++theSurveyIndex; +} + +/* TODO: One method for applying alignments to a given geometry? + * +template +void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, + Alignments* al, + AlignmentErrors* alErrs, + AlignTransform& globalCoordinates) { GeometryAligner aligner; - aligner.applyAlignments(geometry, &(*alignments), &(*alignmentErrors), - globalCoordinates); + + aligner.applyAlignments( + geometry, + al, + alErrs, + globalCoordinates + ); } +*/ -////////////////////////////////////////////////// -// a templated method - but private, so not accessible from outside -// ==> does not have to be in header file -template -void PCLTrackerAlProducer::applyDB(G* geometry, const edm::EventSetup &iSetup) const + +/*** Code for writing results to database + Called from endJob() ***/ + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::finish() { - // 'G' is the geometry class for that DB should be applied, - // 'DeformationRcd' is the record class for its surface deformations + PRINT("called") - const DeformationRcd & record = iSetup.get(); - if (checkDbAlignmentValidity_) { - const edm::ValidityInterval & validity = record.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); - if (first!=edm::IOVSyncValue::beginOfTime() || - last!=edm::IOVSyncValue::endOfTime()) { - throw cms::Exception("DatabaseError") - << "@SUB=PCLTrackerAlProducer::applyDB" - << "\nTrying to apply " - << record.key().name() - << " with multiple IOVs in tag.\n" - << "Validity range is " - << first.eventID().run() << " - " << last.eventID().run(); + /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ + if (theAlignmentAlgo->processesEvents()) { + if (nevent_ == 0) { + // beginOfJob is usually called by the framework in the first event of the first loop + // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) + // and the algorithms rely on the initialisations done in beginOfJob. We cannot call + // this->beginOfJob(iSetup); here either since that will access the EventSetup to get + // some geometry information that is not defined either without having seen an event. + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::finish" + << "Did not process any events, stop " + << "without terminating algorithm."; + return; + } + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" + << "Terminating algorithm."; + theAlignmentAlgo->terminate(); + } + + /* !!! TODO: HACK for MillePede !!! + Because the pede-part of MillePede needs at least 1 Event for initializing + the geometry */ + if (nevent_ == 0) return; + + /* 2) Former: void AlignmentProducer::endOfJob() */ + storeAlignmentsToDB(); +} + +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::storeAlignmentsToDB() +{ + if (theAlignmentAlgo->processesEvents() && nevent_ == 0) { + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" + << "Did not process any events in last loop, " + << "do not dare to store to DB."; + } else { + + // Expand run ranges and make them unique + edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); + RunRanges uniqueRunRanges(makeNonOverlappingRunRanges(runRangeSelectionVPSet)); + + // create dummy IOV + if (uniqueRunRanges.empty()) { + const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue, + cond::timeTypeSpecs[cond::runnumber].endValue); + uniqueRunRanges.push_back(runRange); + } + + std::vector beamSpotParameters; + + for (auto iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange) { + + theAlignmentAlgo->setParametersForRunRange(*iRunRange); + + // Save alignments to database + if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_) { + writeForRunRange((*iRunRange).first); + } + + // Deal with extra alignables, e.g. beam spot + if (theExtraAlignables) { + Alignables &alis = theExtraAlignables->beamSpot(); + if (!alis.empty()) { + BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast(alis[0]->alignmentParameters()); + beamSpotParameters.push_back(beamSpotAliPars->parameters()); + } + } + } + + + + if (theExtraAlignables) { + std::ostringstream bsOutput; + + auto itPar = beamSpotParameters.begin(); + for (auto iRunRange = uniqueRunRanges.begin(); + iRunRange != uniqueRunRanges.end(); + ++iRunRange, ++itPar) { + bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n"; + bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; + bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; + } + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" + << "Parameters for alignable beamspot:\n" + << bsOutput.str(); } } - edm::ESHandle surfaceDeformations; - record.get(surfaceDeformations); +} - GeometryAligner aligner; - aligner.attachSurfaceDeformations(geometry, &(*surfaceDeformations)); +//_____________________________________________________________________________ +RunRanges PCLTrackerAlProducer +::makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet) +{ + static bool oldRunRangeSelectionWarning = false; + + const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue; + const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue; + + RunRanges uniqueRunRanges; + if (!RunRangeSelectionVPSet.empty()) { + + std::map uniqueFirstRunNumbers; + + for (auto ipset = RunRangeSelectionVPSet.begin(); + ipset != RunRangeSelectionVPSet.end(); + ++ipset) { + const std::vector RunRangeStrings = (*ipset).getParameter >("RunRanges"); + + for (auto irange = RunRangeStrings.begin(); + irange != RunRangeStrings.end(); + ++irange) { + + if ((*irange).find(':') == std::string::npos) { + + RunNumber first = beginValue; + long int temp = strtol((*irange).c_str(), 0, 0); + if (temp!=-1) first = temp; + uniqueFirstRunNumbers[first] = first; + + } else { + if (!oldRunRangeSelectionWarning) { + edm::LogWarning("BadConfig") << "@SUB=PCLTrackerAlProducer::makeNonOverlappingRunRanges" + << "Config file contains old format for 'RunRangeSelection'. Only the start run\n" + << "number is used internally. The number of the last run is ignored and can be\n" + << "safely removed from the config file.\n"; + oldRunRangeSelectionWarning = true; + } + + std::vector tokens = edm::tokenize(*irange, ":"); + long int temp; + RunNumber first = beginValue; + temp = strtol(tokens[0].c_str(), 0, 0); + if (temp!=-1) first = temp; + uniqueFirstRunNumbers[first] = first; + } + } + } + + for (auto iFirst = uniqueFirstRunNumbers.begin(); + iFirst != uniqueFirstRunNumbers.end(); + ++iFirst) { + uniqueRunRanges.push_back(std::pair((*iFirst).first, endValue)); + } + + for (size_t i = 0; i < uniqueRunRanges.size()-1; ++i) { + uniqueRunRanges[i].second = uniqueRunRanges[i+1].first - 1; + } + + } else { + uniqueRunRanges.push_back(std::pair(beginValue, endValue)); + } + + return uniqueRunRanges; } -////////////////////////////////////////////////// -void PCLTrackerAlProducer::writeForRunRange(cond::Time_t time) +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::writeForRunRange(cond::Time_t time) { - if ( doTracker_ ) { // first tracker - const AlignTransform *trackerGlobal = 0; // will be 'removed' from constants + // first tracker + if (doTracker_) { + const AlignTransform* trackerGlobal = 0; // will be 'removed' from constants if (globalPositions_) { // i.e. applied before in applyDB trackerGlobal = &align::DetectorGlobalPosition(*globalPositions_, - DetId(DetId::Tracker)); + DetId(DetId::Tracker)); } - - Alignments *alignments = theAlignableTracker->alignments(); - AlignmentErrorsExtended *alignmentErrors = theAlignableTracker->alignmentErrors(); - this->writeDB(alignments, "TrackerAlignmentRcd", - alignmentErrors, "TrackerAlignmentErrorExtendedRcd", trackerGlobal, - time); - } - - if ( doMuon_ ) { // now muon - const AlignTransform *muonGlobal = 0; // will be 'removed' from constants + + // theTrackerAlignables->alignments calls new + Alignments* alignments = theTrackerAlignables->alignments(); + AlignmentErrorsExtended* alignmentErrExt = theTrackerAlignables->alignmentErrors(); + + writeDB(alignments, "TrackerAlignmentRcd", + alignmentErrExt, "TrackerAlignmentErrorExtendedRcd", + trackerGlobal, + time); + } + + // Save surface deformations to database + if (doTracker_ && saveDeformationsToDB_) { + AlignmentSurfaceDeformations* alignmentSurfaceDeformations = theTrackerAlignables->surfaceDeformations(); + writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time); + } + + // now muon + if (doMuon_) { + const AlignTransform* muonGlobal = 0; // will be 'removed' from constants if (globalPositions_) { // i.e. applied before in applyDB muonGlobal = &align::DetectorGlobalPosition(*globalPositions_, - DetId(DetId::Muon)); + DetId(DetId::Muon)); } + // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete - Alignments *alignments = theAlignableMuon->dtAlignments(); - AlignmentErrorsExtended *alignmentErrors = theAlignableMuon->dtAlignmentErrorsExtended(); - this->writeDB(alignments, "DTAlignmentRcd", - alignmentErrors, "DTAlignmentErrorExtendedRcd", muonGlobal, - time); - + Alignments* alignments = theMuonAlignables->dtAlignments(); + AlignmentErrorsExtended* alignmentErrExt = theMuonAlignables->dtAlignmentErrorsExtended(); + + writeDB(alignments, "DTAlignmentRcd", + alignmentErrExt, "DTAlignmentErrorExtendedRcd", + muonGlobal, + time); + // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete - alignments = theAlignableMuon->cscAlignments(); - alignmentErrors = theAlignableMuon->cscAlignmentErrorsExtended(); - this->writeDB(alignments, "CSCAlignmentRcd", - alignmentErrors, "CSCAlignmentErrorExtendedRcd", muonGlobal, - time); - } - - // Save surface deformations to database - if (saveDeformationsToDB_ && doTracker_) { - AlignmentSurfaceDeformations *alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations(); - this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time); + alignments = theMuonAlignables->cscAlignments(); + alignmentErrExt = theMuonAlignables->cscAlignmentErrorsExtended(); + + writeDB(alignments, "CSCAlignmentRcd", + alignmentErrExt, "CSCAlignmentErrorExtendedRcd", + muonGlobal, + time); } } -////////////////////////////////////////////////// -void PCLTrackerAlProducer::writeDB(Alignments *alignments, - const std::string &alignRcd, - AlignmentErrorsExtended *alignmentErrors, - const std::string &errRcd, - const AlignTransform *globalCoordinates, - cond::Time_t time) const +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::writeDB(Alignments* alignments, const std::string &alignRcd, + AlignmentErrorsExtended* alignmentErrExt, const std::string &errRcd, + const AlignTransform *globalCoordinates, + cond::Time_t time) const { - Alignments * tempAlignments = alignments; - AlignmentErrorsExtended * tempAlignmentErrorsExtended = alignmentErrors; + Alignments* tempAlignments = alignments; + AlignmentErrorsExtended* tempAlignmentErrExt = alignmentErrExt; // Call service edm::Service poolDb; - if (!poolDb.isAvailable()) { // Die if not available + if (!poolDb.isAvailable()) { // Die if not available delete tempAlignments; // promised to take over ownership... - delete tempAlignmentErrorsExtended; // dito + delete tempAlignmentErrExt; // dito + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; } - if (globalCoordinates // happens only if (applyDbAlignment_ == true) - && globalCoordinates->transform() != AlignTransform::Transform::Identity) { + if (globalCoordinates && // happens only if (applyDbAlignment_ == true) + globalCoordinates->transform() != AlignTransform::Transform::Identity) { - tempAlignments = new Alignments(); // temporary storage for - tempAlignmentErrorsExtended = new AlignmentErrorsExtended(); // final alignments and errors + tempAlignments = new Alignments(); // temporary storage for + tempAlignmentErrExt = new AlignmentErrorsExtended(); // final alignments and errors GeometryAligner aligner; - aligner.removeGlobalTransform(alignments, alignmentErrors, + aligner.removeGlobalTransform(alignments, alignmentErrExt, *globalCoordinates, - tempAlignments, tempAlignmentErrorsExtended); - - delete alignments; // have to delete original alignments - delete alignmentErrors; // same thing for the errors + tempAlignments, tempAlignmentErrExt); + + delete alignments; // have to delete original alignments + delete alignmentErrExt; // same thing for the errors edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::writeDB" - << "globalCoordinates removed from alignments (" << alignRcd - << ") and errors (" << alignRcd << ")."; + << "globalCoordinates removed from alignments (" + << alignRcd << ") and errors (" << alignRcd << ")."; } - + if (saveToDB_) { edm::LogInfo("Alignment") << "Writing Alignments for run " << time << " to " << alignRcd << "."; poolDb->writeOne(tempAlignments, time, alignRcd); - } else { // poolDb->writeOne(..) takes over 'alignments' ownership,... + + } else { + // poolDb->writeOne(..) takes over 'alignments' ownership, ... delete tempAlignments; // ...otherwise we have to delete, as promised! } if (saveApeToDB_) { - edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " << time - << " to " << errRcd << "."; - poolDb->writeOne(tempAlignmentErrorsExtended, time, errRcd); - } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,... - delete tempAlignmentErrorsExtended; // ...otherwise we have to delete, as promised! + edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " + << time << " to " << errRcd << "."; + poolDb->writeOne(tempAlignmentErrExt, time, errRcd); + + } else { + // poolDb->writeOne(..) takes over 'alignmentErrors' ownership, ... + delete tempAlignmentErrExt; // ...otherwise we have to delete, as promised! } } - -////////////////////////////////////////////////// -void PCLTrackerAlProducer::writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations, - const std::string &surfaceDeformationRcd, - cond::Time_t time) const +//_____________________________________________________________________________ +void PCLTrackerAlProducer +::writeDB(AlignmentSurfaceDeformations* alignmentSurfaceDeformations, + const std::string &surfaceDeformationRcd, + cond::Time_t time) const { // Call service edm::Service poolDb; @@ -924,81 +1270,19 @@ void PCLTrackerAlProducer::writeDB(AlignmentSurfaceDeformations *alignmentSurfac delete alignmentSurfaceDeformations; // promised to take over ownership... throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; } - + if (saveDeformationsToDB_) { - edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time - << " to " << surfaceDeformationRcd << "."; + edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " + << time << " to " << surfaceDeformationRcd << "."; poolDb->writeOne(alignmentSurfaceDeformations, time, - surfaceDeformationRcd); - } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,... + surfaceDeformationRcd); + + } else { + // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,... delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised! } } -PCLTrackerAlProducer::RunRanges -PCLTrackerAlProducer::makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet) -{ - static bool oldRunRangeSelectionWarning = false; - - const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue; - const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue; - - RunRanges uniqueRunRanges; - if (!RunRangeSelectionVPSet.empty()) { - - std::map uniqueFirstRunNumbers; - - for (std::vector::const_iterator ipset = RunRangeSelectionVPSet.begin(); - ipset != RunRangeSelectionVPSet.end(); - ++ipset) { - const std::vector RunRangeStrings = (*ipset).getParameter >("RunRanges"); - for (std::vector::const_iterator irange = RunRangeStrings.begin(); - irange != RunRangeStrings.end(); - ++irange) { - - if ((*irange).find(':')==std::string::npos) { - - RunNumber first = beginValue; - long int temp = strtol((*irange).c_str(), 0, 0); - if (temp!=-1) first = temp; - uniqueFirstRunNumbers[first] = first; - - } else { - - if (!oldRunRangeSelectionWarning) { - edm::LogWarning("BadConfig") << "@SUB=PCLTrackerAlProducer::makeNonOverlappingRunRanges" - << "Config file contains old format for 'RunRangeSelection'. Only the start run\n" - << "number is used internally. The number of the last run is ignored and can be\n" - << "safely removed from the config file.\n"; - oldRunRangeSelectionWarning = true; - } - - std::vector tokens = edm::tokenize(*irange, ":"); - long int temp; - RunNumber first = beginValue; - temp = strtol(tokens[0].c_str(), 0, 0); - if (temp!=-1) first = temp; - uniqueFirstRunNumbers[first] = first; - } - } - } - for (std::map::iterator iFirst = uniqueFirstRunNumbers.begin(); - iFirst!=uniqueFirstRunNumbers.end(); - ++iFirst) { - uniqueRunRanges.push_back(std::pair((*iFirst).first, endValue)); - } - for (unsigned int i = 0;i(beginValue, endValue)); - - } - - return uniqueRunRanges; -} DEFINE_FWK_MODULE(PCLTrackerAlProducer); diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index b9227af5619ac..f16904f2bfed1 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -1,5 +1,5 @@ -#ifndef Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h -#define Alignment_CommonAlignmentAlgorithm_TrackerAlignmentProducer_h +#ifndef Alignment_CommonAlignmentProducer_PCLTrackerAlProducer_h +#define Alignment_CommonAlignmentProducer_PCLTrackerAlProducer_h /// \class AlignmentProducer /// @@ -11,32 +11,48 @@ /// last update: $Date: 2012/06/13 16:23:30 $ /// by : $Author: yana $ +// TODO: Update Doxygen description + + +/*** System includes ***/ #include +#include +#include -// Framework +/*** Core framework functionality ***/ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondCore/DBCommon/interface/Time.h" -#include "DataFormats/Provenance/interface/RunID.h" - -// Geometry -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" - -// Alignment -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" +/*** Alignment ***/ #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" +#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" +#include "Alignment/CommonAlignment/interface/Alignable.h" #include "Alignment/CommonAlignment/interface/AlignableExtras.h" #include "Alignment/TrackerAlignment/interface/AlignableTracker.h" #include "Alignment/MuonAlignment/interface/AlignableMuon.h" -#include -#include "CondCore/DBCommon/interface/Time.h" #include "CondFormats/Alignment/interface/Alignments.h" #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" +#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" +#include "CondFormats/Alignment/interface/SurveyErrors.h" + +#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" + +/*** Records for ESWatcher ***/ +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" + +#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -// for watcher #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h" @@ -44,150 +60,194 @@ #include "CondFormats/AlignmentRecord/interface/CSCSurveyRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCSurveyErrorExtendedRcd.h" +/*** Forward declarations ***/ +#include "FWCore/Framework/interface/Frameworkfwd.h" + +/*** Typedefs ***/ +// TODO: Move this at the end of AlignmentMonitorBase.h +typedef std::vector AlignmentMonitors; + + + +class PCLTrackerAlProducer : public edm::EDAnalyzer { + /**************************** PUBLIC METHODS ********************************/ + public: /********************************************************************/ -class Alignments; -class IntegratedCalibrationBase; -class SurveyErrors; -namespace edm { - class Run; - class LuminosityBlock; -} + /// Constructor + PCLTrackerAlProducer(const edm::ParameterSet&); + /// Destructor + virtual ~PCLTrackerAlProducer(); -class PCLTrackerAlProducer : public edm::EDAnalyzer -{ + /*** Code which implements the interface + Called from outside ***/ - public: - typedef std::vector Alignables; - typedef std::pair ConstTrajTrackPair; - typedef std::vector ConstTrajTrackPairCollection; + virtual void beginJob() override; + virtual void endJob() override; - typedef AlignmentAlgorithmBase::RunNumber RunNumber; - typedef AlignmentAlgorithmBase::RunRange RunRange; - typedef std::vector RunRanges; + virtual void beginRun(const edm::Run&, const edm::EventSetup&) override; + virtual void endRun (const edm::Run&, const edm::EventSetup&) override; - /// Constructor - PCLTrackerAlProducer( const edm::ParameterSet& iConfig ); + virtual void beginLuminosityBlock(const edm::LuminosityBlock&, + const edm::EventSetup&) override; + virtual void endLuminosityBlock (const edm::LuminosityBlock&, + const edm::EventSetup&) override; - /// Destructor - ~PCLTrackerAlProducer(); - - /// Called at beginning of job - virtual void beginOfJob(); - - /// Called at end of job - virtual void endOfJob(); - - /// Called at run start and calling algorithms beginRun - virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup); - /// Called at run end - currently reading TkFittedLasBeam if an InpuTag is given for that - virtual void endRun(const edm::Run &run, const edm::EventSetup &setup); - - /// Called at lumi block start, calling algorithm's beginLuminosityBlock - virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, - const edm::EventSetup &setup); - /// Called at lumi block end, calling algorithm's endLuminosityBlock - virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, - const edm::EventSetup &setup); - /// Called at each event - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; - - private: - - // private member functions - void init(const edm::EventSetup&); - - /// Apply random shifts and rotations to selected alignables, according to configuration - void simpleMisalignment_(const Alignables &alivec, const std::string &selection, - float shift, float rot, bool local); - - /// Create tracker and muon geometries - void createGeometries_( const edm::EventSetup& ); - - /// Apply DB constants belonging to (Err)Rcd to geometry, - /// taking into account 'globalPosition' correction. - template - void applyDB(G *geometry, const edm::EventSetup &iSetup, - const AlignTransform &globalPosition) const; - /// Apply DB constants for surface deformations - template - void applyDB(G *geometry, const edm::EventSetup &iSetup) const; - - // write alignments and alignment errors for all sub detectors and - // the given run number - void writeForRunRange(cond::Time_t time); - - /// Write alignment and/or errors to DB for record names - /// (removes *globalCoordinates before writing if non-null...). - /// Takes over ownership of alignments and alignmentErrrors. - void writeDB(Alignments *alignments, const std::string &alignRcd, - AlignmentErrorsExtended *alignmentErrors, const std::string &errRcd, - const AlignTransform *globalCoordinates, - cond::Time_t time) const; - /// Write surface deformations (bows & kinks) to DB for given record name - /// Takes over ownership of alignmentsurfaceDeformations. - void writeDB(AlignmentSurfaceDeformations *alignmentSurfaceDeformations, - const std::string &surfaceDeformationRcd, - cond::Time_t time) const; - - /// Add survey info to an alignable - void addSurveyInfo_(Alignable*); - - /// read in survey records - void readInSurveyRcds( const edm::EventSetup& ); - - RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet); - - // private data members - - unsigned int theSurveyIndex; - const Alignments* theSurveyValues; - const SurveyErrors* theSurveyErrors; - - AlignmentAlgorithmBase* theAlignmentAlgo; - AlignmentParameterStore* theAlignmentParameterStore; - std::vector theMonitors; - std::vector theCalibrations; - - AlignableExtras* theAlignableExtras; - AlignableTracker* theAlignableTracker; - AlignableMuon* theAlignableMuon; - - boost::shared_ptr theTracker; - boost::shared_ptr theMuonDT; - boost::shared_ptr theMuonCSC; - /// GlobalPositions that might be read from DB, NULL otherwise - const Alignments *globalPositions_; - - int nevent_; - edm::ParameterSet theParameterSet; - - // steering parameters - - const unsigned int theMaxLoops; // Number of loops to loop - - const int stNFixAlignables_; - const double stRandomShift_,stRandomRotation_; - const bool applyDbAlignment_,checkDbAlignmentValidity_; - const bool doMisalignmentScenario_; - const bool saveToDB_, saveApeToDB_,saveDeformationsToDB_; - const bool doTracker_,doMuon_,useExtras_; - const bool useSurvey_; // true to read survey info from DB - - // event input tags - const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories - const edm::InputTag beamSpotTag_; // beam spot - const edm::InputTag tkLasBeamTag_; // LAS beams in edm::Run (ignore if empty) - const edm::InputTag clusterValueMapTag_; // ValueMap containing associtaion cluster - flag - - // ESWatcher - edm::ESWatcher watchTkSurveyRcd_; - edm::ESWatcher watchTkSurveyErrRcd_; - edm::ESWatcher watchDTSurveyRcd_; - edm::ESWatcher watchDTSurveyErrRcd_; - edm::ESWatcher watchCSCSurveyRcd_; - edm::ESWatcher watchCSCSurveyErrRcd_; - - edm::ESWatcher watchTrackerAlRcd; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + + + /************************** PRIVATE METHODS *********************************/ + private: /*******************************************************************/ + + /*** Code which is independent of Event & Setup + Called from constructor ***/ + + // TODO: Add missing method description + + void createAlignmentAlgorithm(const edm::ParameterSet&); + void createMonitors (const edm::ParameterSet&); + void createCalibrations (const edm::ParameterSet&); + + + + /*** Code which is dependent of Event & Setup + Called and checked for each Event ***/ + + // TODO: Add missing method description + + bool setupChanged(const edm::EventSetup&); + void initAlignmentAlgorithm(const edm::EventSetup&); + void initBeamSpot(const edm::Event&); + void createGeometries(const edm::EventSetup&); + void applyAlignmentsToDB(const edm::EventSetup&); + void createAlignables(const TrackerTopology* const); + void buildParameterStore(); + void applyMisalignment(); + void simpleMisalignment(const Alignables&, const std::string&, float, float, bool); + void applyAlignmentsToGeometry(); + + /// Apply DB constants belonging to (Err)Rcd to geometry, + /// taking into account 'globalPosition' correction. + template + void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const; + + /// Apply DB constants for surface deformations + template + void applyDB(G*, const edm::EventSetup&) const; + + /// Add survey info to an alignable + void addSurveyInfo(Alignable*); + + /// read in survey records + void readInSurveyRcds(const edm::EventSetup&); + + + + /*** Code for writing results to database + Called from endJob() ***/ + + // TODO: Add missing method description + + void finish(); + void storeAlignmentsToDB(); + RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet&); + + /// Write alignments and alignment errors for all sub detectors and the + /// given run number + void writeForRunRange(cond::Time_t); + + /// Write alignment and/or errors to DB for record names + /// (removes *globalCoordinates before writing if non-null...). + /// Takes over ownership of alignments and alignmentErrrors. + void writeDB(Alignments*, const std::string&, AlignmentErrorsExtended*, + const std::string&, const AlignTransform*, cond::Time_t) const; + + /// Write surface deformations (bows & kinks) to DB for given record name + /// Takes over ownership of alignmentsurfaceDeformations. + void writeDB(AlignmentSurfaceDeformations*, + const std::string&, cond::Time_t) const; + + + + /*************************** PRIVATE DATA ***********************************/ + /****************************************************************************/ + + /*** Alignment data ***/ + + AlignmentAlgorithmBase* theAlignmentAlgo; + Calibrations theCalibrations; + AlignmentMonitors theMonitors; + + AlignmentParameterStore* theAlignmentParameterStore; + AlignableTracker* theTrackerAlignables; + AlignableMuon* theMuonAlignables; + AlignableExtras* theExtraAlignables; + + edm::Handle theBeamSpot; + /// GlobalPositions that might be read from DB, NULL otherwise + const Alignments* globalPositions_; + + boost::shared_ptr theTrackerGeometry; + boost::shared_ptr theMuonDTGeometry; + boost::shared_ptr theMuonCSCGeometry; + + int nevent_; + + + + /*** Parameters from config-file ***/ + + edm::ParameterSet theParameterSet; + + const int stNFixAlignables_; + const double stRandomShift_, stRandomRotation_; + const bool applyDbAlignment_, checkDbAlignmentValidity_; + const bool doMisalignmentScenario_; + const bool saveToDB_, saveApeToDB_, saveDeformationsToDB_; + const bool doTracker_, doMuon_, useExtras_; + const bool useSurvey_; + + // map with tracks/trajectories + const edm::InputTag tjTkAssociationMapTag_; + // beam spot + const edm::InputTag beamSpotTag_; + // LAS beams in edm::Run (ignore if empty) + const edm::InputTag tkLasBeamTag_; + // ValueMap containing associtaion cluster - flag + const edm::InputTag clusterValueMapTag_; + + + + /*** ESWatcher ***/ + + // TODO: Which Record to watch for changes? (see setupChanged()-method) + + edm::ESWatcher watchTrackerAlRcd; + edm::ESWatcher watchTrackerAlErrorExtRcd; + edm::ESWatcher watchDTAlRcd; + edm::ESWatcher watchDTAlErrExtRcd; + edm::ESWatcher watchCSCAlRcd; + edm::ESWatcher watchCSCAlErrExtRcd; + + edm::ESWatcher watchTrackerSurDeRcd; + edm::ESWatcher watchTrackerDigiGeoRcd; + edm::ESWatcher watchGlobalPosRcd; + edm::ESWatcher watchIdealGeoRcd; + + edm::ESWatcher watchTkSurveyRcd_; + edm::ESWatcher watchTkSurveyErrExtRcd_; + edm::ESWatcher watchDTSurveyRcd_; + edm::ESWatcher watchDTSurveyErrExtRcd_; + edm::ESWatcher watchCSCSurveyRcd_; + edm::ESWatcher watchCSCSurveyErrExtRcd_; + + + + /*** Survey stuff ***/ + + size_t theSurveyIndex; + const Alignments* theSurveyValues; + const SurveyErrors* theSurveyErrors; }; #endif diff --git a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py index 923e1998d30a7..f0d898e92915b 100644 --- a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py +++ b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py @@ -12,8 +12,10 @@ from Alignment.CommonAlignmentAlgorithm.AlignmentParameterStore_cfi import * #looper = cms.Looper("AlignmentProducer", -AlignmentProducer = cms.EDAnalyzer("TrackerAlignmentProducerForPCL", +AlignmentProducer = cms.EDAnalyzer("PCLTrackerAlProducer", AlignmentParameterStore, # configuration of AlignmentParameterStore + doTracker = cms.untracked.bool(True), + doMuon = cms.untracked.bool(False), useExtras = cms.untracked.bool(False), # Read survey info from DB: true requires configuration of PoolDBESSource # See Alignment/SurveyAnalysis/test/readDB.cfg for an example diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h index 37eae169901d2..611de159a4faa 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h @@ -65,13 +65,15 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store); + virtual bool supportsCalibrations() override; /// pass integrated calibrations to Millepede (they are not owned by Millepede!) - virtual bool addCalibrations(const std::vector &iCals); + virtual void addCalibrations(const std::vector &iCals); /// Call at end of job virtual void terminate(const edm::EventSetup& iSetup); virtual void terminate(); + virtual bool processesEvents() override; /// Run the algorithm on trajectories and tracks virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index e433132d70038..eb3a3953cb67d 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -241,12 +241,30 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, } } +//_____________________________________________________________________________ +void MillePedeAlignmentAlgorithm +::addCalibrations(const Calibrations& iCals) +{ + theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end()); + thePedeLabels->addCalibrations(iCals); +} + //____________________________________________________ -bool MillePedeAlignmentAlgorithm::addCalibrations(const std::vector &iCals) +void MillePedeAlignmentAlgorithm::addCalibrations(const std::vector &iCals) { theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end()); thePedeLabels->addCalibrations(iCals); - return true; +} + +//_____________________________________________________________________________ +bool MillePedeAlignmentAlgorithm +::processesEvents() +{ + if (isMode(myMilleBit)) { + return true; + } else { + return false; + } } //____________________________________________________ From 189eecb521bf02996fa8c550f77f0ddc9bdad89d Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:28:00 +0200 Subject: [PATCH 038/104] changed ErrorRcds -> ExtendedErrorRcds --- .../CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc | 4 +++- .../CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 252b76b38d1a4..4a2cbd58e3401 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -861,8 +861,9 @@ ::applyDB(G* geometry, const edm::EventSetup& setup) const void PCLTrackerAlProducer ::readInSurveyRcds(const edm::EventSetup& setup) { +/* // Get Survey Rcds and add Survey Info - if (doTracker_ && useSurvey_){ + if (doTracker_ && useSurvey_) { bool tkSurveyBool = watchTkSurveyRcd_.check(setup); bool tkSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); @@ -919,6 +920,7 @@ ::readInSurveyRcds(const edm::EventSetup& setup) } } } +*/ } //_____________________________________________________________________________ diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index f16904f2bfed1..81c6ef7a2e26f 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -135,11 +135,11 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { template void applyDB(G*, const edm::EventSetup&) const; - /// Add survey info to an alignable - void addSurveyInfo(Alignable*); - /// read in survey records void readInSurveyRcds(const edm::EventSetup&); + + /// Add survey info to an alignable + void addSurveyInfo(Alignable*); From 8d133b43cd802f77584e28705a29b55bef0fe87a Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:29:08 +0200 Subject: [PATCH 039/104] added global typedef for Alignables --- Alignment/CommonAlignment/interface/Alignable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Alignment/CommonAlignment/interface/Alignable.h b/Alignment/CommonAlignment/interface/Alignable.h index 3a2a313fb208d..7c85caba35ea1 100644 --- a/Alignment/CommonAlignment/interface/Alignable.h +++ b/Alignment/CommonAlignment/interface/Alignable.h @@ -243,4 +243,6 @@ class Alignable }; +typedef std::vector Alignables; + #endif From 3679f84b0b001d14346edc2d9159c899c895d486 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:29:45 +0200 Subject: [PATCH 040/104] removed CommonAlignmentAlignmentProcuderPlugin (AlignmentProducer.cc) from BuildFile.xml (interface broken) Conflicts: Alignment/CommonAlignmentProducer/plugins/BuildFile.xml From c0e662d95eb19ceddd6c48360c908f0ead19b7ca Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:40:07 +0200 Subject: [PATCH 041/104] fixed include of AlignmentErrorsExtended --- .../CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index 81c6ef7a2e26f..cc4ca76f7c93a 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -36,12 +36,11 @@ #include "Alignment/TrackerAlignment/interface/AlignableTracker.h" #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "CondFormats/Alignment/interface/Alignments.h" +#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" #include "CondFormats/Alignment/interface/SurveyErrors.h" -#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" - /*** Records for ESWatcher ***/ #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" From cf8bc75c384a6c6c4ba178b738b4a4a87f4c93f4 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 25 Jun 2015 16:40:47 +0200 Subject: [PATCH 042/104] implemented changed AlignmentAlgorithm interface --- .../src/MillePedeAlignmentAlgorithm.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index eb3a3953cb67d..15102b72f8cad 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -241,12 +241,8 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, } } -//_____________________________________________________________________________ -void MillePedeAlignmentAlgorithm -::addCalibrations(const Calibrations& iCals) -{ - theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end()); - thePedeLabels->addCalibrations(iCals); +bool MillePedeAlignmentAlgorithm::supportsCalibrations() { + return true; } //____________________________________________________ @@ -293,7 +289,11 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra // Call at end of job --------------------------------------------------------- //____________________________________________________ -void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) +void MillePedeAlignmentAlgorithm::terminate() +{ + terminate(); +} +void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) { terminate(); } From 5c62294583fd585f06bc19db79cb0ddf0461cf1a Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Tue, 30 Jun 2015 08:49:53 +0200 Subject: [PATCH 043/104] rebuild interface for offline alignment producer Conflicts: Alignment/CommonAlignmentProducer/plugins/BuildFile.xml --- .../interface/AlignmentAlgorithmBase.h | 2 +- .../plugins/BuildFile.xml | 2 +- .../interface/MillePedeAlignmentAlgorithm.h | 19 ++++++++++++------- .../src/MillePedeAlignmentAlgorithm.cc | 8 ++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index d7e8423ae66e7..3e91e03b7ef09 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -127,7 +127,7 @@ class AlignmentAlgorithmBase { virtual bool supportsCalibrations() { return false; } /// Pass integrated calibrations to algorithm, to be called after initialize() /// Calibrations' ownership is NOT passed to algorithm - virtual void addCalibrations(const Calibrations&) {} + virtual bool addCalibrations(const Calibrations&) { return false; } // TODO: DEPRECATED: Actually, there are no iterative algorithms, use // initialze() and terminate() diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index 8517b4d168ab4..b37a9d4cae6c7 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -19,7 +19,7 @@ - + diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h index 611de159a4faa..d291c520cedf6 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeAlignmentAlgorithm.h @@ -60,31 +60,36 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase /// Destructor virtual ~MillePedeAlignmentAlgorithm(); - /// Call at beginning of job + /// Called at beginning of job virtual void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store); + /// Returns whether MP supports calibrations virtual bool supportsCalibrations() override; - /// pass integrated calibrations to Millepede (they are not owned by Millepede!) - virtual void addCalibrations(const std::vector &iCals); + /// Pass integrated calibrations to Millepede (they are not owned by Millepede!) + virtual bool addCalibrations(const std::vector &iCals); - /// Call at end of job + /// Called at end of job virtual void terminate(const edm::EventSetup& iSetup); + /// Called at end of job virtual void terminate(); + /// Returns whether MP should process events in the current configuration virtual bool processesEvents() override; /// Run the algorithm on trajectories and tracks virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo); + // TODO: This method does NOT match endRun() in base class! Nobody is + // calling this? /// Run on run products, e.g. TkLAS - virtual void endRun(const EventInfo &eventInfo, const EndRunInfo &runInfo, - const edm::EventSetup &setup); + virtual void endRun(const EventInfo&, const EndRunInfo&, + const edm::EventSetup&); //override; /* virtual void beginLuminosityBlock(const edm::EventSetup &setup) {} */ /* virtual void endLuminosityBlock(const edm::EventSetup &setup) {} */ - /// called in order to pass parameters to alignables for a specific run + /// Called in order to pass parameters to alignables for a specific run /// range in case the algorithm supports run range dependent alignment. virtual bool setParametersForRunRange(const RunRange &runrange); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index 15102b72f8cad..0ae3629937847 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -241,20 +241,21 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, } } +//____________________________________________________ bool MillePedeAlignmentAlgorithm::supportsCalibrations() { return true; } //____________________________________________________ -void MillePedeAlignmentAlgorithm::addCalibrations(const std::vector &iCals) +bool MillePedeAlignmentAlgorithm::addCalibrations(const std::vector &iCals) { theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end()); thePedeLabels->addCalibrations(iCals); + return true; } //_____________________________________________________________________________ -bool MillePedeAlignmentAlgorithm -::processesEvents() +bool MillePedeAlignmentAlgorithm::processesEvents() { if (isMode(myMilleBit)) { return true; @@ -400,7 +401,6 @@ void MillePedeAlignmentAlgorithm::run(const edm::EventSetup &setup, const EventI } // end of reference trajectory and track loop } - //____________________________________________________ std::pair MillePedeAlignmentAlgorithm::addReferenceTrajectory(const edm::EventSetup &setup, From eb8ff2c3def1ed45c9e6e51bb0a762a2e698ccce Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Tue, 30 Jun 2015 08:58:19 +0200 Subject: [PATCH 044/104] changed logging system --- .../plugins/PCLTrackerAlProducer.cc | 184 ++++++++++-------- .../plugins/PCLTrackerAlProducer.h | 24 +-- 2 files changed, 113 insertions(+), 95 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 4a2cbd58e3401..6fa696ff0abec 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -7,6 +7,8 @@ // TODO: Update Doxygen description + + /*** Header file ***/ #include "PCLTrackerAlProducer.h" @@ -50,13 +52,30 @@ #include "Geometry/Records/interface/MuonNumberingRecord.h" /*** Logging ***/ -#define PRINT(msg) PRINT_TO_LOGFILE(msg) \ - PRINT_TO_STDOUT(msg) -#define PRINT_TO_LOGFILE(msg) \ -edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::" \ - << __FUNCTION__ << ": " msg; -#define PRINT_TO_STDOUT(msg) \ -printf("(%s) Function %s: %s \n", typeid(*this).name(), __FUNCTION__, msg); +template +void buildMessage(std::ostream& oss, T t) +{ + oss << t; +} + +template +void buildMessage(std::ostream& oss, T t, Args... args) +{ + buildMessage(oss, t); + buildMessage(oss, args...); +} + +template +void PRINT_INFO(std::string func, Args... args) +{ + std::ostringstream oss; + buildMessage(oss, args...); + + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::"<< func.c_str() + << ": " << oss.str() << std::endl; + printf("%s::%s: %s\n", "PCLTrackerAlProducer", func.c_str(), + oss.str().c_str()); +} @@ -92,7 +111,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); createAlignmentAlgorithm(config); createCalibrations (config); @@ -103,7 +122,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : PCLTrackerAlProducer ::~PCLTrackerAlProducer() { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); delete theAlignmentAlgo; @@ -131,7 +150,7 @@ PCLTrackerAlProducer void PCLTrackerAlProducer ::beginJob() { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); nevent_ = 0; @@ -156,8 +175,8 @@ ::beginJob() void PCLTrackerAlProducer ::endJob() { - PRINT("called") - printf("Events processed: %d", nevent_); + PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(__FUNCTION__, "Events processed: ", nevent_); finish(); @@ -178,7 +197,7 @@ ::endJob() void PCLTrackerAlProducer ::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); // Do not forward edm::Run theAlignmentAlgo->beginRun(setup); } @@ -187,7 +206,7 @@ ::beginRun(const edm::Run& run, const edm::EventSetup& setup) void PCLTrackerAlProducer ::endRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); // TODO: Either MP nor HIP is implementing the endRun() method... so this // seems to be useless? @@ -210,9 +229,9 @@ ::endRun(const edm::Run& run, const edm::EventSetup& setup) //_____________________________________________________________________________ void PCLTrackerAlProducer ::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, - const edm::EventSetup & setup) + const edm::EventSetup& setup) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->beginLuminosityBlock(setup); } @@ -222,7 +241,7 @@ void PCLTrackerAlProducer ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->endLuminosityBlock(setup); } @@ -231,12 +250,33 @@ ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, void PCLTrackerAlProducer ::analyze(const edm::Event& event, const edm::EventSetup& setup) { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); ++nevent_; + PRINT_INFO(__FUNCTION__, "event number: ", nevent_); if (setupChanged(setup)) { initAlignmentAlgorithm(setup); initBeamSpot(event); + + + const auto& rcd = setup.get(); + edm::ESHandle handle; + rcd.get(handle); + + + + const edm::ValidityInterval& validity = rcd.validityInterval(); + const edm::IOVSyncValue first = validity.first(); + const edm::IOVSyncValue last = validity.last(); + + auto eID1 = first.eventID(); + printf("(TProdPCL) first runnumber: %u\n", eID1.run()); + printf("(TProdPCL) first event: %llu\n", eID1.event()); + + auto eID2 = last.eventID(); + printf("(TProdPCL) last runnumber: %u\n", eID2.run()); + printf("(TProdPCL) last event: %llu\n", eID2.event()); + } if (!theAlignmentAlgo->processesEvents()) { @@ -248,7 +288,7 @@ ::analyze(const edm::Event& event, const edm::EventSetup& setup) } // reading in survey records - this->readInSurveyRcds(setup); + readInSurveyRcds(setup); // Retrieve trajectories and tracks from the event // -> merely skip if collection is empty @@ -380,93 +420,75 @@ ::createCalibrations(const edm::ParameterSet& config) bool PCLTrackerAlProducer ::setupChanged(const edm::EventSetup& setup) { - PRINT("Checking EventSetup") + bool changed = false; - if (watchTrackerAlRcd.check(setup)) { - PRINT("TrackerAlignmentRcd has changed") + if (doTracker_) { + if (watchTrackerAlRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "TrackerAlignmentRcd has changed"); + changed = true; + } - /* - const auto& rcd = setup.get(); + if (watchTrackerAlErrorExtRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "TrackerAlignmentErrorExtendedRcd has changed"); + changed = true; + } - const edm::ValidityInterval& validity = rcd.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); + if (watchTrackerSurDeRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "TrackerSurfaceDeformationRcd has changed"); + changed = true; + } + } - auto eID1 = first.eventID(); - printf("(TProdPCL) first runnumber: %u\n", eID1.run()); - printf("(TProdPCL) first event: %llu\n", eID1.event()); + if (doMuon_) { + if (watchDTAlRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "DTAlignmentRcd has changed"); + changed = true; + } - auto eID2 = last.eventID(); - printf("(TProdPCL) last runnumber: %u\n", eID2.run()); - printf("(TProdPCL) last event: %llu\n", eID2.event()); - */ + if (watchDTAlErrExtRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "DTAlignmentErrorExtendedRcd has changed"); + changed = true; + } - return true; - } + if (watchCSCAlRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "CSCAlignmentRcd has changed"); + changed = true; + } - if (watchTrackerAlErrorExtRcd.check(setup)) { - PRINT("TrackerAlignmentErrorExtendedRcd has changed") - return true; + if (watchCSCAlErrExtRcd.check(setup)) { + PRINT_INFO(__FUNCTION__, "CSCAlignmentErrorExtendedRcd has changed"); + changed = true; + } } - /* - if (watchTrackerSurDeRcd.check(setup)) { - printf("(TProdPCL) AlignmentProducerForPCL::analyze | " - "TrackerSurfaceDeformationRcd has changed (event nr: %d)\n", nevent_); - return true; - } - if (watchDTAlRcd.check(setup)) { - printf("(TProdPCL) AlignmentProducerForPCL::analyze | " - "DTAlignmentRcd has changed (event nr: %d)\n", nevent_); - return true; - } - if (watchTrackerDigiGeoRcd.check(setup)) { - printf("(TProdPCL) AlignmentProducerForPCL::analyze | " - "TrackerDigiGeometryRcd has changed (event nr: %d)\n", nevent_); - return true; - } - if (watchGlobalPosRcd.check(setup)) { - printf("(TProdPCL) AlignmentProducerForPCL::analyze | " - "GlobalPositionRcd has changed (event nr: %d)\n", nevent_); - return true; - } - if (watchIdealGeoRcd.check(setup)) { - printf("(TProdPCL) AlignmentProducerForPCL::analyze | " - "IdealGeometryRecord has changed (event nr: %d)\n", nevent_); - return true; - } + /* TODO: ExtraAlignables: Which record(s) to check? + * + if (useExtras_) {} */ - return false; + return changed; } //_____________________________________________________________________________ void PCLTrackerAlProducer ::initAlignmentAlgorithm(const edm::EventSetup& setup) { - PRINT("called") - - /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginOfJob"; + PRINT_INFO(__FUNCTION__, "called"); // Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; setup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); - - // Create the geometries from the ideal geometries (first time only) //std::shared_ptr theTrackerGeometry; createGeometries(setup); - applyAlignmentsToDB(setup); createAlignables(tTopo); buildParameterStore(); applyMisalignment(); - // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm theAlignmentAlgo->initialize(setup, theTrackerAlignables, @@ -864,8 +886,8 @@ ::readInSurveyRcds(const edm::EventSetup& setup) /* // Get Survey Rcds and add Survey Info if (doTracker_ && useSurvey_) { - bool tkSurveyBool = watchTkSurveyRcd_.check(setup); - bool tkSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); + bool tkSurveyBool = watchTkSurveyRcd.check(setup); + bool tkSurveyErrBool = watchTkSurveyErrExtRcd.check(setup); if (tkSurveyBool || tkSurveyErrBool) { edm::ESHandle surveys; @@ -882,10 +904,10 @@ ::readInSurveyRcds(const edm::EventSetup& setup) } if (doMuon_ && useSurvey_) { - bool DTSurveyBool = watchTkSurveyRcd_.check(setup); - bool DTSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); - bool CSCSurveyBool = watchTkSurveyRcd_.check(setup); - bool CSCSurveyErrBool = watchTkSurveyErrExtRcd_.check(setup); + bool DTSurveyBool = watchTkSurveyRcd.check(setup); + bool DTSurveyErrBool = watchTkSurveyErrExtRcd.check(setup); + bool CSCSurveyBool = watchTkSurveyRcd.check(setup); + bool CSCSurveyErrBool = watchTkSurveyErrExtRcd.check(setup); if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool){ edm::ESHandle dtSurveys; @@ -984,7 +1006,7 @@ void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, void PCLTrackerAlProducer ::finish() { - PRINT("called") + PRINT_INFO(__FUNCTION__, "called"); /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ if (theAlignmentAlgo->processesEvents()) { diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index cc4ca76f7c93a..db3459f3bcee6 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -14,10 +14,12 @@ // TODO: Update Doxygen description + /*** System includes ***/ #include #include #include +#include /*** Core framework functionality ***/ #include "FWCore/Framework/interface/EDAnalyzer.h" @@ -134,7 +136,7 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { template void applyDB(G*, const edm::EventSetup&) const; - /// read in survey records + /// Read in survey records void readInSurveyRcds(const edm::EventSetup&); /// Add survey info to an alignable @@ -219,26 +221,20 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** ESWatcher ***/ - // TODO: Which Record to watch for changes? (see setupChanged()-method) - edm::ESWatcher watchTrackerAlRcd; edm::ESWatcher watchTrackerAlErrorExtRcd; + edm::ESWatcher watchTrackerSurDeRcd; edm::ESWatcher watchDTAlRcd; edm::ESWatcher watchDTAlErrExtRcd; edm::ESWatcher watchCSCAlRcd; edm::ESWatcher watchCSCAlErrExtRcd; - edm::ESWatcher watchTrackerSurDeRcd; - edm::ESWatcher watchTrackerDigiGeoRcd; - edm::ESWatcher watchGlobalPosRcd; - edm::ESWatcher watchIdealGeoRcd; - - edm::ESWatcher watchTkSurveyRcd_; - edm::ESWatcher watchTkSurveyErrExtRcd_; - edm::ESWatcher watchDTSurveyRcd_; - edm::ESWatcher watchDTSurveyErrExtRcd_; - edm::ESWatcher watchCSCSurveyRcd_; - edm::ESWatcher watchCSCSurveyErrExtRcd_; + edm::ESWatcher watchTkSurveyRcd; + edm::ESWatcher watchTkSurveyErrExtRcd; + edm::ESWatcher watchDTSurveyRcd; + edm::ESWatcher watchDTSurveyErrExtRcd; + edm::ESWatcher watchCSCSurveyRcd; + edm::ESWatcher watchCSCSurveyErrExtRcd; From fb2690ebde0bde6e04a946da3cdf87835cef61c5 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Wed, 1 Jul 2015 12:51:15 +0200 Subject: [PATCH 045/104] fixed bug in MillePedeAlignmentAlgorithm (function terminate causes an endless loop) --- .../plugins/PCLTrackerAlProducer.cc | 56 +++++++++++-------- .../src/MillePedeAlignmentAlgorithm.cc | 7 ++- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 6fa696ff0abec..5bd43d5c93c23 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -52,6 +52,9 @@ #include "Geometry/Records/interface/MuonNumberingRecord.h" /*** Logging ***/ +#define CLASS_NAME typeid(*this).name() +#define FUNC_NAME __FUNCTION__ + template void buildMessage(std::ostream& oss, T t) { @@ -66,14 +69,18 @@ void buildMessage(std::ostream& oss, T t, Args... args) } template -void PRINT_INFO(std::string func, Args... args) +void PRINT_INFO(std::string funcName, Args... args) { + std::string className = "PCLTrackerAlProducer"; + std::ostringstream oss; buildMessage(oss, args...); - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::"<< func.c_str() - << ": " << oss.str() << std::endl; - printf("%s::%s: %s\n", "PCLTrackerAlProducer", func.c_str(), + edm::LogInfo("Alignment") << "@SUB=" << className.c_str() << "::" + << funcName.c_str() << ": " + << oss.str() << std::endl; + printf("%s::%s: %s\n", className.c_str(), + funcName.c_str(), oss.str().c_str()); } @@ -111,7 +118,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); createAlignmentAlgorithm(config); createCalibrations (config); @@ -122,7 +129,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : PCLTrackerAlProducer ::~PCLTrackerAlProducer() { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); delete theAlignmentAlgo; @@ -150,7 +157,7 @@ PCLTrackerAlProducer void PCLTrackerAlProducer ::beginJob() { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); nevent_ = 0; @@ -175,8 +182,8 @@ ::beginJob() void PCLTrackerAlProducer ::endJob() { - PRINT_INFO(__FUNCTION__, "called"); - PRINT_INFO(__FUNCTION__, "Events processed: ", nevent_); + PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(FUNC_NAME, "Events processed: ", nevent_); finish(); @@ -197,7 +204,7 @@ ::endJob() void PCLTrackerAlProducer ::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); // Do not forward edm::Run theAlignmentAlgo->beginRun(setup); } @@ -206,7 +213,7 @@ ::beginRun(const edm::Run& run, const edm::EventSetup& setup) void PCLTrackerAlProducer ::endRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); // TODO: Either MP nor HIP is implementing the endRun() method... so this // seems to be useless? @@ -231,7 +238,7 @@ void PCLTrackerAlProducer ::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->beginLuminosityBlock(setup); } @@ -241,7 +248,7 @@ void PCLTrackerAlProducer ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->endLuminosityBlock(setup); } @@ -250,9 +257,9 @@ ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, void PCLTrackerAlProducer ::analyze(const edm::Event& event, const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); ++nevent_; - PRINT_INFO(__FUNCTION__, "event number: ", nevent_); + PRINT_INFO(FUNC_NAME, "event number: ", nevent_); if (setupChanged(setup)) { initAlignmentAlgorithm(setup); @@ -424,39 +431,39 @@ ::setupChanged(const edm::EventSetup& setup) if (doTracker_) { if (watchTrackerAlRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "TrackerAlignmentRcd has changed"); + PRINT_INFO(FUNC_NAME, "TrackerAlignmentRcd has changed"); changed = true; } if (watchTrackerAlErrorExtRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "TrackerAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(FUNC_NAME, "TrackerAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchTrackerSurDeRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "TrackerSurfaceDeformationRcd has changed"); + PRINT_INFO(FUNC_NAME, "TrackerSurfaceDeformationRcd has changed"); changed = true; } } if (doMuon_) { if (watchDTAlRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "DTAlignmentRcd has changed"); + PRINT_INFO(FUNC_NAME, "DTAlignmentRcd has changed"); changed = true; } if (watchDTAlErrExtRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "DTAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(FUNC_NAME, "DTAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchCSCAlRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "CSCAlignmentRcd has changed"); + PRINT_INFO(FUNC_NAME, "CSCAlignmentRcd has changed"); changed = true; } if (watchCSCAlErrExtRcd.check(setup)) { - PRINT_INFO(__FUNCTION__, "CSCAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(FUNC_NAME, "CSCAlignmentErrorExtendedRcd has changed"); changed = true; } } @@ -473,7 +480,7 @@ ::setupChanged(const edm::EventSetup& setup) void PCLTrackerAlProducer ::initAlignmentAlgorithm(const edm::EventSetup& setup) { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); // Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; @@ -1006,7 +1013,7 @@ void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, void PCLTrackerAlProducer ::finish() { - PRINT_INFO(__FUNCTION__, "called"); + PRINT_INFO(FUNC_NAME, "called"); /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ if (theAlignmentAlgo->processesEvents()) { @@ -1022,6 +1029,7 @@ ::finish() return; } + PRINT_INFO(FUNC_NAME, "terminating algorithm"); edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" << "Terminating algorithm."; theAlignmentAlgo->terminate(); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index 0ae3629937847..74660c45bbef5 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -79,6 +79,9 @@ typedef TrajectoryFactoryBase::ReferenceTrajectoryCollection RefTrajColl; #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h" + + + // Constructor ---------------------------------------------------------------- //____________________________________________________ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet &cfg) : @@ -290,11 +293,11 @@ bool MillePedeAlignmentAlgorithm::setParametersForRunRange(const RunRange &runra // Call at end of job --------------------------------------------------------- //____________________________________________________ -void MillePedeAlignmentAlgorithm::terminate() +void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) { terminate(); } -void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) +void MillePedeAlignmentAlgorithm::terminate() { terminate(); } From ee421363a7161e24d5200c57898bb9441522069a Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Fri, 3 Jul 2015 10:42:35 +0200 Subject: [PATCH 046/104] fixed bug: algo->terminate not called in pede mode --- .../plugins/PCLTrackerAlProducer.cc | 104 ++++++++---------- 1 file changed, 44 insertions(+), 60 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 5bd43d5c93c23..22ede27121053 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -69,9 +69,9 @@ void buildMessage(std::ostream& oss, T t, Args... args) } template -void PRINT_INFO(std::string funcName, Args... args) +void PRINT_INFO(std::string className, std::string funcName, Args... args) { - std::string className = "PCLTrackerAlProducer"; + //std::string className = "PCLTrackerAlProducer"; std::ostringstream oss; buildMessage(oss, args...); @@ -84,6 +84,9 @@ void PRINT_INFO(std::string funcName, Args... args) oss.str().c_str()); } +//TODO: void PRINT_WARNING() +//TODO: void PRINT_ERROR() + //_____________________________________________________________________________ @@ -118,7 +121,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); createAlignmentAlgorithm(config); createCalibrations (config); @@ -129,7 +132,7 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : PCLTrackerAlProducer ::~PCLTrackerAlProducer() { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); delete theAlignmentAlgo; @@ -157,7 +160,7 @@ PCLTrackerAlProducer void PCLTrackerAlProducer ::beginJob() { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); nevent_ = 0; @@ -182,8 +185,7 @@ ::beginJob() void PCLTrackerAlProducer ::endJob() { - PRINT_INFO(FUNC_NAME, "called"); - PRINT_INFO(FUNC_NAME, "Events processed: ", nevent_); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called, events processed: ", nevent_); finish(); @@ -204,7 +206,7 @@ ::endJob() void PCLTrackerAlProducer ::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::Run theAlignmentAlgo->beginRun(setup); } @@ -213,7 +215,7 @@ ::beginRun(const edm::Run& run, const edm::EventSetup& setup) void PCLTrackerAlProducer ::endRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // TODO: Either MP nor HIP is implementing the endRun() method... so this // seems to be useless? @@ -238,7 +240,7 @@ void PCLTrackerAlProducer ::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->beginLuminosityBlock(setup); } @@ -248,7 +250,7 @@ void PCLTrackerAlProducer ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->endLuminosityBlock(setup); } @@ -257,33 +259,12 @@ ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, void PCLTrackerAlProducer ::analyze(const edm::Event& event, const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); ++nevent_; - PRINT_INFO(FUNC_NAME, "event number: ", nevent_); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called, event number: ", nevent_); if (setupChanged(setup)) { initAlignmentAlgorithm(setup); initBeamSpot(event); - - - const auto& rcd = setup.get(); - edm::ESHandle handle; - rcd.get(handle); - - - - const edm::ValidityInterval& validity = rcd.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); - - auto eID1 = first.eventID(); - printf("(TProdPCL) first runnumber: %u\n", eID1.run()); - printf("(TProdPCL) first event: %llu\n", eID1.event()); - - auto eID2 = last.eventID(); - printf("(TProdPCL) last runnumber: %u\n", eID2.run()); - printf("(TProdPCL) last event: %llu\n", eID2.event()); - } if (!theAlignmentAlgo->processesEvents()) { @@ -431,39 +412,39 @@ ::setupChanged(const edm::EventSetup& setup) if (doTracker_) { if (watchTrackerAlRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "TrackerAlignmentRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerAlignmentRcd has changed"); changed = true; } if (watchTrackerAlErrorExtRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "TrackerAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchTrackerSurDeRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "TrackerSurfaceDeformationRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerSurfaceDeformationRcd has changed"); changed = true; } } if (doMuon_) { if (watchDTAlRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "DTAlignmentRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "DTAlignmentRcd has changed"); changed = true; } if (watchDTAlErrExtRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "DTAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "DTAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchCSCAlRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "CSCAlignmentRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "CSCAlignmentRcd has changed"); changed = true; } if (watchCSCAlErrExtRcd.check(setup)) { - PRINT_INFO(FUNC_NAME, "CSCAlignmentErrorExtendedRcd has changed"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "CSCAlignmentErrorExtendedRcd has changed"); changed = true; } } @@ -480,7 +461,7 @@ ::setupChanged(const edm::EventSetup& setup) void PCLTrackerAlProducer ::initAlignmentAlgorithm(const edm::EventSetup& setup) { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; @@ -1013,26 +994,19 @@ void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, void PCLTrackerAlProducer ::finish() { - PRINT_INFO(FUNC_NAME, "called"); + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ - if (theAlignmentAlgo->processesEvents()) { - if (nevent_ == 0) { - // beginOfJob is usually called by the framework in the first event of the first loop - // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) - // and the algorithms rely on the initialisations done in beginOfJob. We cannot call - // this->beginOfJob(iSetup); here either since that will access the EventSetup to get - // some geometry information that is not defined either without having seen an event. - edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::finish" - << "Did not process any events, stop " - << "without terminating algorithm."; - return; - } - - PRINT_INFO(FUNC_NAME, "terminating algorithm"); - edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" - << "Terminating algorithm."; - theAlignmentAlgo->terminate(); + if (theAlignmentAlgo->processesEvents() && nevent_ == 0) { + // beginOfJob is usually called by the framework in the first event of the first loop + // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) + // and the algorithms rely on the initialisations done in beginOfJob. We cannot call + // this->beginOfJob(iSetup); here either since that will access the EventSetup to get + // some geometry information that is not defined either without having seen an event. + edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::finish" + << "Did not process any events, stop " + << "without terminating algorithm."; + return; } /* !!! TODO: HACK for MillePede !!! @@ -1040,6 +1014,11 @@ ::finish() the geometry */ if (nevent_ == 0) return; + PRINT_INFO(CLASS_NAME, FUNC_NAME, "terminating algorithm"); + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" + << "Terminating algorithm."; + theAlignmentAlgo->terminate(); + /* 2) Former: void AlignmentProducer::endOfJob() */ storeAlignmentsToDB(); } @@ -1049,11 +1028,11 @@ void PCLTrackerAlProducer ::storeAlignmentsToDB() { if (theAlignmentAlgo->processesEvents() && nevent_ == 0) { + // TODO: If this is the case, it would be already caught in finish() edm::LogError("Alignment") << "@SUB=PCLTrackerAlProducer::endOfJob" << "Did not process any events in last loop, " << "do not dare to store to DB."; } else { - // Expand run ranges and make them unique edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); RunRanges uniqueRunRanges(makeNonOverlappingRunRanges(runRangeSelectionVPSet)); @@ -1075,6 +1054,7 @@ ::storeAlignmentsToDB() // Save alignments to database if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_) { + PRINT_INFO(CLASS_NAME, FUNC_NAME, "Write alignments to db-file"); writeForRunRange((*iRunRange).first); } @@ -1179,6 +1159,8 @@ ::makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet) void PCLTrackerAlProducer ::writeForRunRange(cond::Time_t time) { + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); + // first tracker if (doTracker_) { const AlignTransform* trackerGlobal = 0; // will be 'removed' from constants @@ -1238,6 +1220,8 @@ ::writeDB(Alignments* alignments, const std::string &alignRcd, const AlignTransform *globalCoordinates, cond::Time_t time) const { + PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); + Alignments* tempAlignments = alignments; AlignmentErrorsExtended* tempAlignmentErrExt = alignmentErrExt; From be68faa7e9c1702f2e7c2d927033872e7dd619f9 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 14 Jul 2015 18:56:24 +0200 Subject: [PATCH 047/104] fix an obvious mistake in the merge --- .../src/MillePedeAlignmentAlgorithm.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index 74660c45bbef5..a29664ec7cc3f 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -298,10 +298,6 @@ void MillePedeAlignmentAlgorithm::terminate(const edm::EventSetup& iSetup) terminate(); } void MillePedeAlignmentAlgorithm::terminate() -{ - terminate(); -} -void MillePedeAlignmentAlgorithm::terminate() { delete theMille;// delete to close binary before running pede below (flush would be enough...) theMille = 0; From 540a76ad8d07cafa417d1e317830eaea7327c8e2 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Wed, 15 Jul 2015 18:15:44 +0200 Subject: [PATCH 048/104] Modify to include latest Chris' configuration for 3.8T --- .../python/AlcaSiPixelAliHarvester_cff.py | 87 +++---------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index 004fffdf171a9..d75cdf43fa8ef 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -20,7 +20,7 @@ 'TrackerTPEHalfCylinder,111111', 'TrackerTIBHalfBarrel,ffffff', - 'TrackerTOBHalfBarrel,rrrrrr', + 'TrackerTOBHalfBarrel,ffffff', 'TrackerTIDEndcap,ffffff', 'TrackerTECEndcap,ffffff' ) @@ -28,67 +28,6 @@ SiPixelAliPedeAlignmentProducer.doMisalignmentScenario = False #True -SiPixelAliPedeAlignmentProducer.MisalignmentScenario = cms.PSet( - setRotations = cms.bool(True), - setTranslations = cms.bool(True), - seed = cms.int32(1234567), - distribution = cms.string('fixed'), # gaussian, uniform (or so...) - setError = cms.bool(True), #GF ??????? - TPBHalfBarrel1 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(-0.0015), - dZlocal = cms.double(0.0100), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-2.e-4), - phiZlocal = cms.double(5.e-4), - - ), - TPBHalfBarrel2 = cms.PSet( - dXlocal = cms.double(-0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.020), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(-2.e-4), - - ), - TPEEndcap1 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(0.0050), - dYlocal = cms.double(0.0020), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-5), - phiYlocal = cms.double(2.e-3), - phiZlocal = cms.double(2.e-5), - ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.01), - phiXlocal = cms.double(1.e-4), - phiYlocal = cms.double(-1.e-4), - phiZlocal = cms.double(2.e-4), - ), - ), - TPEEndcap2 = cms.PSet( - TPEHalfCylinder1 = cms.PSet( - dXlocal = cms.double(-0.0080), - dYlocal = cms.double(0.0050), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(1.e-3), - phiYlocal = cms.double(-3.e-4), - phiZlocal = cms.double(2.e-4), - ), - TPEHalfCylinder2 = cms.PSet( - dXlocal = cms.double(0.0020), - dYlocal = cms.double(0.0030), - dZlocal = cms.double(-0.005), - phiXlocal = cms.double(-1.e-3), - phiYlocal = cms.double(2.e-4), - phiZlocal = cms.double(3.e-4), - ), - ) -) SiPixelAliPedeAlignmentProducer.checkDbAlignmentValidity = False SiPixelAliPedeAlignmentProducer.applyDbAlignment = True @@ -96,26 +35,24 @@ SiPixelAliPedeAlignmentProducer.algoConfig = MillePedeAlignmentAlgorithm SiPixelAliPedeAlignmentProducer.algoConfig.mode = 'pede' -# Input binary files for the pede step: We use the same value as for the output binary files of the extractor. -# That way the output of the extractor automatically becomes the input for pede. SiPixelAliPedeAlignmentProducer.algoConfig.mergeBinaryFiles = [SiPixelAliMilleFileExtractor.outputBinaryFile.value()] -SiPixelAliPedeAlignmentProducer.algoConfig.monitorFile = 'millePedeMonitor_pede.root' SiPixelAliPedeAlignmentProducer.algoConfig.binaryFile = '' -SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory = BrokenLinesBzeroTrajectoryFactory -SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.MomentumEstimate = 10 -SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.MaterialEffects = 'BrokenLinesCoarse' #Coarse' #Fine' #'BreakPoints' -SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory.UseInvalidHits = True # to account for multiple scattering in these layers +SiPixelAliPedeAlignmentProducer.algoConfig.TrajectoryFactory = cms.PSet( + #process.BrokenLinesBzeroTrajectoryFactory + BrokenLinesTrajectoryFactory + ) SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.pedeCommand = 'pede' SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.method = 'inversion 5 0.8' SiPixelAliPedeAlignmentProducer.algoConfig.pedeSteerer.options = cms.vstring( #'regularisation 1.0 0.05', # non-stated pre-sigma 50 mrad or 500 mum - 'entries 500', - 'chisqcut 30.0 4.5', #, - 'threads 1 1' #, - #'outlierdownweighting 3','dwfractioncut 0.1' - #'outlierdownweighting 5','dwfractioncut 0.2' + 'entries 500', + 'chisqcut 30.0 4.5', #, + 'threads 1 1' #, + #'outlierdownweighting 3','dwfractioncut 0.1' + #'outlierdownweighting 5','dwfractioncut 0.2' ) -SiPixelAliPedeAlignmentProducer.algoConfig.minNumHits = 8 +SiPixelAliPedeAlignmentProducer.algoConfig.minNumHits = 10 +SiPixelAliPedeAlignmentProducer.saveToDB = True From 3b9b233bb58d8429fdca07964b1fb43f2be8b576 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Wed, 15 Jul 2015 18:16:43 +0200 Subject: [PATCH 049/104] Modify to be able to initialize the algorithm even without processing any event (pede mode) --- .../plugins/PCLTrackerAlProducer.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 22ede27121053..266c8f07da48e 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -209,6 +209,12 @@ ::beginRun(const edm::Run& run, const edm::EventSetup& setup) PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::Run theAlignmentAlgo->beginRun(setup); + + if (setupChanged(setup)) { + initAlignmentAlgorithm(setup); + } + + } //_____________________________________________________________________________ @@ -1012,7 +1018,7 @@ ::finish() /* !!! TODO: HACK for MillePede !!! Because the pede-part of MillePede needs at least 1 Event for initializing the geometry */ - if (nevent_ == 0) return; + //if (nevent_ == 0) return; PRINT_INFO(CLASS_NAME, FUNC_NAME, "terminating algorithm"); edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" From 23cb324e7848810fecfe47973b3a0e4b4fc3dbff Mon Sep 17 00:00:00 2001 From: Gianluca Date: Mon, 27 Jul 2015 11:52:26 +0200 Subject: [PATCH 050/104] add a filter to discard first n LS (default is 20) in the mille step --- .../plugins/BuildFile.xml | 3 + .../plugins/LSNumberFilter.cc | 76 +++++++++++++++++++ .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 4 +- .../python/LSNumberFilter_cfi.py | 5 ++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Alignment/CommonAlignmentProducer/plugins/LSNumberFilter.cc create mode 100644 Alignment/CommonAlignmentProducer/python/LSNumberFilter_cfi.py diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index b37a9d4cae6c7..86ad8fddc4f4f 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -72,3 +72,6 @@ + + + diff --git a/Alignment/CommonAlignmentProducer/plugins/LSNumberFilter.cc b/Alignment/CommonAlignmentProducer/plugins/LSNumberFilter.cc new file mode 100644 index 0000000000000..1c95da1e920c3 --- /dev/null +++ b/Alignment/CommonAlignmentProducer/plugins/LSNumberFilter.cc @@ -0,0 +1,76 @@ +//#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDFilter.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + + + +// +// class declaration +// + + + +class LSNumberFilter : public edm::EDFilter { +public: + explicit LSNumberFilter(const edm::ParameterSet&); + ~LSNumberFilter(); + +private: + + virtual void beginJob() override ; + virtual bool filter(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override ; + + unsigned int minLS; +}; + + + +LSNumberFilter::LSNumberFilter(const edm::ParameterSet& iConfig): + minLS(iConfig.getUntrackedParameter("minLS",21)) +{} + + +LSNumberFilter::~LSNumberFilter() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called on each new Event ------------ +bool LSNumberFilter::filter(edm::Event& iEvent, + const edm::EventSetup& iSetup) { + + if(iEvent.luminosityBlock() < minLS) return false; + + return true; + +} + +// ------------ method called once each job just before starting event loop ------------ +void +LSNumberFilter::beginJob() +{} + +// ------------ method called once each job just after ending the event loop ------------ +void +LSNumberFilter::endJob() { +} + +//define this as a plug-in +DEFINE_FWK_MODULE(LSNumberFilter); diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 182ce175316cd..071c437e2d62a 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -9,7 +9,7 @@ ALCARECOTkAlMinBiasFilterForSiPixelAli.throw = True ## dont throw on unknown path names ALCARECOTkAlMinBiasFilterForSiPixelAli.TriggerResultsTag = cms.InputTag("TriggerResults","","RECO") - +from Alignment.CommonAlignmentProducer.LSNumberFilter_cfi import * # Ingredient: offlineBeamSpot @@ -152,6 +152,7 @@ seqALCARECOPromptCalibProdSiPixelAli = cms.Sequence(ALCARECOTkAlMinBiasFilterForSiPixelAli* + lsNumberFilter* offlineBeamSpot* SiPixelAliHighPuritySelector* SiPixelAliTrackRefitter0* @@ -159,6 +160,5 @@ SiPixelAliTrackFitter* SiPixelAliTrackSelector* SiPixelAliTrackRefitter1* - SiPixelAliMilleAlignmentProducer* SiPixelAliMillePedeFileConverter) diff --git a/Alignment/CommonAlignmentProducer/python/LSNumberFilter_cfi.py b/Alignment/CommonAlignmentProducer/python/LSNumberFilter_cfi.py new file mode 100644 index 0000000000000..5fa6d8c3b08ac --- /dev/null +++ b/Alignment/CommonAlignmentProducer/python/LSNumberFilter_cfi.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +lsNumberFilter = cms.EDFilter("LSNumberFilter", + minLS = cms.untracked.uint32(21) + ) From 3bd99634d2009f9491138e01deeaeda7f0df8ccc Mon Sep 17 00:00:00 2001 From: Gianluca Date: Mon, 27 Jul 2015 15:21:58 +0200 Subject: [PATCH 051/104] add SiPixelAli to PCL workflows tested by relval 1001.0 --- Configuration/PyReleaseValidation/python/relval_steps.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 2adc3fbb485a8..a6676fad6b3e9 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1134,7 +1134,7 @@ def genvalid(fragment,d,suffix='all',fi='',dataSet=''): '--conditions':'auto:run1_data', '--datatier':'ALCARECO', '--eventcontent':'ALCARECO'} -steps['ALCAEXP']={'-s':'ALCA:PromptCalibProd+PromptCalibProdSiStrip+PromptCalibProdSiStripGains', +steps['ALCAEXP']={'-s':'ALCA:PromptCalibProd+PromptCalibProdSiStrip+PromptCalibProdSiStripGains+PromptCalibProdSiPixelAli', '--conditions':'auto:run1_data', '--datatier':'ALCARECO', '--eventcontent':'ALCARECO'} @@ -1190,6 +1190,11 @@ def genvalid(fragment,d,suffix='all',fi='',dataSet=''): '--data':'', '--filein':'file:PromptCalibProdSiStripGains.root'} +steps['ALCAHARVD4']={'-s':'ALCAHARVEST:SiPixelAli', + '--conditions':'auto:run1_data', + '--scenario':'pp', + '--data':'', + '--filein':'file:PromptCalibProdSiStripGains.root'} steps['RECOHISt4']=steps['RECOHI'] steps['RECOHIMIX']=merge([steps['RECOHI'],{'--pileup':'HiMix','--pileup_input':'das:/RelValHydjetQ_MinBias_2760GeV/%s/GEN-SIM'%(baseDataSetRelease[1])}]) From 2aa95470692b124d3aefdbe22fcb83dc7d5eeee5 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 16 Jul 2015 11:32:41 +0200 Subject: [PATCH 052/104] moved algo initialization to beginRun, removed debug-logging, added doxygen Conflicts: Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc --- .../plugins/PCLTrackerAlProducer.cc | 150 ++++-------------- .../plugins/PCLTrackerAlProducer.h | 100 ++++++++---- 2 files changed, 102 insertions(+), 148 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 266c8f07da48e..8274ecd6fa0fe 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -1,11 +1,10 @@ -/// \file PCLTrackerAlProducer.cc -/// -/// \author : Frederic Ronga -/// Revision : $Revision: 1.68 $ -/// last update: $Date: 2012/08/10 09:25:23 $ -/// by : $Author: flucke $ - -// TODO: Update Doxygen description +/** + * @package Alignment/CommonAlignmentProducer + * @file PCLTrackerAlProducer.cc + * + * @author Max Stark (max.stark@cern.ch) + * @date 2015/07/16 + */ @@ -51,42 +50,6 @@ #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/Records/interface/MuonNumberingRecord.h" -/*** Logging ***/ -#define CLASS_NAME typeid(*this).name() -#define FUNC_NAME __FUNCTION__ - -template -void buildMessage(std::ostream& oss, T t) -{ - oss << t; -} - -template -void buildMessage(std::ostream& oss, T t, Args... args) -{ - buildMessage(oss, t); - buildMessage(oss, args...); -} - -template -void PRINT_INFO(std::string className, std::string funcName, Args... args) -{ - //std::string className = "PCLTrackerAlProducer"; - - std::ostringstream oss; - buildMessage(oss, args...); - - edm::LogInfo("Alignment") << "@SUB=" << className.c_str() << "::" - << funcName.c_str() << ": " - << oss.str() << std::endl; - printf("%s::%s: %s\n", className.c_str(), - funcName.c_str(), - oss.str().c_str()); -} - -//TODO: void PRINT_WARNING() -//TODO: void PRINT_ERROR() - //_____________________________________________________________________________ @@ -121,8 +84,6 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - createAlignmentAlgorithm(config); createCalibrations (config); createMonitors (config); @@ -132,8 +93,6 @@ ::PCLTrackerAlProducer(const edm::ParameterSet& config) : PCLTrackerAlProducer ::~PCLTrackerAlProducer() { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - delete theAlignmentAlgo; for (auto iCal = theCalibrations.begin(); @@ -160,8 +119,6 @@ PCLTrackerAlProducer void PCLTrackerAlProducer ::beginJob() { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - nevent_ = 0; for (auto iCal = theCalibrations.begin(); @@ -185,8 +142,6 @@ ::beginJob() void PCLTrackerAlProducer ::endJob() { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called, events processed: ", nevent_); - finish(); for (auto monitor = theMonitors.begin(); @@ -206,7 +161,12 @@ ::endJob() void PCLTrackerAlProducer ::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); + if (setupChanged(setup)) { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::beginRun" + << "EventSetup-Record changed."; + initAlignmentAlgorithm(setup); + } + // Do not forward edm::Run theAlignmentAlgo->beginRun(setup); @@ -221,8 +181,6 @@ ::beginRun(const edm::Run& run, const edm::EventSetup& setup) void PCLTrackerAlProducer ::endRun(const edm::Run& run, const edm::EventSetup& setup) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - // TODO: Either MP nor HIP is implementing the endRun() method... so this // seems to be useless? @@ -246,7 +204,6 @@ void PCLTrackerAlProducer ::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->beginLuminosityBlock(setup); } @@ -256,7 +213,6 @@ void PCLTrackerAlProducer ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& setup) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); // Do not forward edm::LuminosityBlock theAlignmentAlgo->endLuminosityBlock(setup); } @@ -265,14 +221,6 @@ ::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, void PCLTrackerAlProducer ::analyze(const edm::Event& event, const edm::EventSetup& setup) { - ++nevent_; - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called, event number: ", nevent_); - - if (setupChanged(setup)) { - initAlignmentAlgorithm(setup); - initBeamSpot(event); - } - if (!theAlignmentAlgo->processesEvents()) { edm::LogWarning("BadConfig") << "@SUB=PCLTrackerAlProducer::analyze" << "Skipping event. The current configuration " @@ -281,6 +229,18 @@ ::analyze(const edm::Event& event, const edm::EventSetup& setup) return; } + if (setupChanged(setup)) { + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::analyze" + << "EventSetup-Record changed."; + initAlignmentAlgorithm(setup); + } + + if (nevent_== 0 && theExtraAlignables) { + initBeamSpot(event); + } + + ++nevent_; + // reading in survey records readInSurveyRcds(setup); @@ -418,39 +378,32 @@ ::setupChanged(const edm::EventSetup& setup) if (doTracker_) { if (watchTrackerAlRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerAlignmentRcd has changed"); changed = true; } if (watchTrackerAlErrorExtRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchTrackerSurDeRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "TrackerSurfaceDeformationRcd has changed"); changed = true; } } if (doMuon_) { if (watchDTAlRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "DTAlignmentRcd has changed"); changed = true; } if (watchDTAlErrExtRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "DTAlignmentErrorExtendedRcd has changed"); changed = true; } if (watchCSCAlRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "CSCAlignmentRcd has changed"); changed = true; } if (watchCSCAlErrExtRcd.check(setup)) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "CSCAlignmentErrorExtendedRcd has changed"); changed = true; } } @@ -467,8 +420,6 @@ ::setupChanged(const edm::EventSetup& setup) void PCLTrackerAlProducer ::initAlignmentAlgorithm(const edm::EventSetup& setup) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - // Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; setup.get().get(tTopoHandle); @@ -483,7 +434,10 @@ ::initAlignmentAlgorithm(const edm::EventSetup& setup) buildParameterStore(); applyMisalignment(); - // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm + // Initialize alignment algorithm and integrated calibration and pass the + // latter to algorithm + edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::initAlignmentAlgorithm" + << "Initializing alignment algorithm."; theAlignmentAlgo->initialize(setup, theTrackerAlignables, theMuonAlignables, @@ -550,9 +504,10 @@ ::applyAlignmentsToDB(const edm::EventSetup& setup) if (applyDbAlignment_) { // we need GlobalPositionRcd - and have to keep track for later removal // before writing again to DB... - edm::ESHandle globalPositionRcd; - setup.get().get(globalPositionRcd); - globalPositions_ = new Alignments(*globalPositionRcd); + + edm::ESHandle globalAlignments; + setup.get().get(globalAlignments); + globalPositions_ = new Alignments(*globalAlignments); if (doTracker_) { applyDB -void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, - Alignments* al, - AlignmentErrors* alErrs, - AlignTransform& globalCoordinates) { - GeometryAligner aligner; - - aligner.applyAlignments( - geometry, - al, - alErrs, - globalCoordinates - ); -} -*/ - /*** Code for writing results to database @@ -1000,9 +937,6 @@ void PCLTrackerAlProducer::applyAlignmentsToGeometry2(Geometry* geometry, void PCLTrackerAlProducer ::finish() { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - - /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ if (theAlignmentAlgo->processesEvents() && nevent_ == 0) { // beginOfJob is usually called by the framework in the first event of the first loop // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) @@ -1015,17 +949,10 @@ ::finish() return; } - /* !!! TODO: HACK for MillePede !!! - Because the pede-part of MillePede needs at least 1 Event for initializing - the geometry */ - //if (nevent_ == 0) return; - - PRINT_INFO(CLASS_NAME, FUNC_NAME, "terminating algorithm"); edm::LogInfo("Alignment") << "@SUB=PCLTrackerAlProducer::finish" << "Terminating algorithm."; theAlignmentAlgo->terminate(); - /* 2) Former: void AlignmentProducer::endOfJob() */ storeAlignmentsToDB(); } @@ -1060,7 +987,6 @@ ::storeAlignmentsToDB() // Save alignments to database if (saveToDB_ || saveApeToDB_ || saveDeformationsToDB_) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "Write alignments to db-file"); writeForRunRange((*iRunRange).first); } @@ -1074,8 +1000,6 @@ ::storeAlignmentsToDB() } } - - if (theExtraAlignables) { std::ostringstream bsOutput; @@ -1165,8 +1089,6 @@ ::makeNonOverlappingRunRanges(const edm::VParameterSet& RunRangeSelectionVPSet) void PCLTrackerAlProducer ::writeForRunRange(cond::Time_t time) { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - // first tracker if (doTracker_) { const AlignTransform* trackerGlobal = 0; // will be 'removed' from constants @@ -1226,8 +1148,6 @@ ::writeDB(Alignments* alignments, const std::string &alignRcd, const AlignTransform *globalCoordinates, cond::Time_t time) const { - PRINT_INFO(CLASS_NAME, FUNC_NAME, "called"); - Alignments* tempAlignments = alignments; AlignmentErrorsExtended* tempAlignmentErrExt = alignmentErrExt; @@ -1243,8 +1163,8 @@ ::writeDB(Alignments* alignments, const std::string &alignRcd, if (globalCoordinates && // happens only if (applyDbAlignment_ == true) globalCoordinates->transform() != AlignTransform::Transform::Identity) { - tempAlignments = new Alignments(); // temporary storage for - tempAlignmentErrExt = new AlignmentErrorsExtended(); // final alignments and errors + tempAlignments = new Alignments(); // temporary storage for + tempAlignmentErrExt = new AlignmentErrorsExtended(); // final alignments and errors GeometryAligner aligner; aligner.removeGlobalTransform(alignments, alignmentErrExt, diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index db3459f3bcee6..8abc8bd5b5c1e 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -1,17 +1,22 @@ #ifndef Alignment_CommonAlignmentProducer_PCLTrackerAlProducer_h #define Alignment_CommonAlignmentProducer_PCLTrackerAlProducer_h -/// \class AlignmentProducer -/// -/// Package : Alignment/CommonAlignmentProducer -/// Description : calls alignment algorithms -/// -/// \author : Frederic Ronga -/// Revision : $Revision: 1.27 $ -/// last update: $Date: 2012/06/13 16:23:30 $ -/// by : $Author: yana $ - -// TODO: Update Doxygen description +/** + * @package Alignment/CommonAlignmentProducer + * @file PCLTrackerAlProducer.h + * + * @author Max Stark (max.stark@cern.ch) + * @date 2015/07/16 + * + * @brief Tracker-AlignmentProducer for the Prompt Calibration Loop (PCL) + * + * Code is based on standard offline AlignmentProducer (see AlignmentProducer.h) + * Main difference is the base-class exchange from an ESProducerLooper to an + * EDAnalyzer, + * + * @note Only for Tracker-Alignment usage. + * @todo Remove all the muon alignment stuff + */ @@ -45,13 +50,13 @@ /*** Records for ESWatcher ***/ #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" @@ -82,6 +87,7 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** Code which implements the interface Called from outside ***/ + //! virtual void beginJob() override; virtual void endJob() override; @@ -103,10 +109,11 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** Code which is independent of Event & Setup Called from constructor ***/ - // TODO: Add missing method description - + /// Creates the choosen alignment algorithm (specified in config-file) void createAlignmentAlgorithm(const edm::ParameterSet&); + /// Creates the mointors (specified in config-file) void createMonitors (const edm::ParameterSet&); + /// Creates the calibrations (specified in config-file) void createCalibrations (const edm::ParameterSet&); @@ -114,32 +121,54 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** Code which is dependent of Event & Setup Called and checked for each Event ***/ - // TODO: Add missing method description - + /// Checks if one of the EventSetup-Records has changed bool setupChanged(const edm::EventSetup&); + + /// Creates Geometry and Alignables of the Tracker and initializes the + /// AlignmentAlgorithm @theAlignmentAlgo void initAlignmentAlgorithm(const edm::EventSetup&); + + /// Initializes Beamspot @theBeamSpot of Alignables @theExtraAlignables void initBeamSpot(const edm::Event&); + + /// Creates ideal geometry @theTrackerGeometry from IdealGeometryRecord void createGeometries(const edm::EventSetup&); + + /// Applies Alignments from Database (GlobalPositionRcd) to Geometry + /// @theTrackerGeometry void applyAlignmentsToDB(const edm::EventSetup&); + + /// Creates Alignables @theTrackerAlignables from the previously loaded + /// Geometry @theTrackerGeometry void createAlignables(const TrackerTopology* const); + + /// Creates the @theAlignmentParameterStore, which manages all Alignables void buildParameterStore(); + + /// Applies misalignment scenario to @theTrackerAlignables void applyMisalignment(); - void simpleMisalignment(const Alignables&, const std::string&, float, float, bool); + + /// Applies misalignment scenario to @theTrackerAlignables + void simpleMisalignment(const Alignables&, const std::string&, + float, float, bool); + + /// Applies Alignments, AlignmentErrors and SurfaceDeformations to + /// @theTrackerGeometry void applyAlignmentsToGeometry(); - /// Apply DB constants belonging to (Err)Rcd to geometry, - /// taking into account 'globalPosition' correction. + /// Applies DB constants belonging to (Err)Rcd to Geometry, taking into + /// account 'globalPosition' correction. template void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const; - /// Apply DB constants for surface deformations + /// Applies DB constants for SurfaceDeformations template void applyDB(G*, const edm::EventSetup&) const; - /// Read in survey records + /// Reads in survey records void readInSurveyRcds(const edm::EventSetup&); - /// Add survey info to an alignable + /// Adds survey info to an Alignable void addSurveyInfo(Alignable*); @@ -147,24 +176,28 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** Code for writing results to database Called from endJob() ***/ - // TODO: Add missing method description - + /// Steers activities after end of job, terminates the AlignmentAlgorithm + /// @theAlignmentAlgo void finish(); + + /// Writes Alignments (i.e. Records) to database-file void storeAlignmentsToDB(); + + /// Makes unique RunRanges (specified in config-file) RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet&); - /// Write alignments and alignment errors for all sub detectors and the + /// Writes Alignments and AlignmentErrors for all sub detectors and the /// given run number void writeForRunRange(cond::Time_t); - /// Write alignment and/or errors to DB for record names + /// Writes Alignments and/or AlignmentErrors to DB for record names /// (removes *globalCoordinates before writing if non-null...). - /// Takes over ownership of alignments and alignmentErrrors. + /// Takes over ownership of Alignments and AlignmentErrors. void writeDB(Alignments*, const std::string&, AlignmentErrorsExtended*, const std::string&, const AlignTransform*, cond::Time_t) const; - /// Write surface deformations (bows & kinks) to DB for given record name - /// Takes over ownership of alignmentsurfaceDeformations. + /// Writes SurfaceDeformations (bows & kinks) to DB for given record name + /// Takes over ownership of AlignmentSurfaceDeformations. void writeDB(AlignmentSurfaceDeformations*, const std::string&, cond::Time_t) const; @@ -188,6 +221,7 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /// GlobalPositions that might be read from DB, NULL otherwise const Alignments* globalPositions_; + // TODO: Change pointers to std::shared_ptr boost::shared_ptr theTrackerGeometry; boost::shared_ptr theMuonDTGeometry; boost::shared_ptr theMuonCSCGeometry; @@ -208,13 +242,13 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { const bool doTracker_, doMuon_, useExtras_; const bool useSurvey_; - // map with tracks/trajectories + /// Map with tracks/trajectories const edm::InputTag tjTkAssociationMapTag_; - // beam spot + /// BeamSpot const edm::InputTag beamSpotTag_; - // LAS beams in edm::Run (ignore if empty) + /// LAS beams in edm::Run (ignore if empty) const edm::InputTag tkLasBeamTag_; - // ValueMap containing associtaion cluster - flag + /// ValueMap containing associtaion cluster-flag const edm::InputTag clusterValueMapTag_; From e576d5158168509d1e8354d6a9bbf7ef9b2bbe89 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 16 Jul 2015 11:34:10 +0200 Subject: [PATCH 053/104] reorganized includes/typedefs, added doxygen --- .../interface/AlignmentAlgorithmBase.h | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index 3e91e03b7ef09..99e5351f9b10c 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -2,11 +2,21 @@ #ifndef Alignment_CommonAlignmentAlgorithm_AlignmentAlgorithmBase_h #define Alignment_CommonAlignmentAlgorithm_AlignmentAlgorithmBase_h -/// -/// Base class for the alignment algorithm -/// -/// Each alignment algorithm should derive from this class -/// +/** + * @package Alignment/CommonAlignmentAlgorithm + * @file AlignmentAlgorithmBase.h + * + * @author ??? + * + * Last update: + * @author Max Stark (max.stark@cern.ch) + * @date 2015/07/16 + * + * @brief Interface/Base class for alignment algorithms, each alignment + * algorithm has to be derived from this class + */ + + /*** System includes ***/ #include @@ -19,12 +29,6 @@ namespace edm { class EventSetup; class ParameterSet; } namespace reco { class Track; class BeamSpot; } /*** Alignment ***/ -// These data formats cannot be forward declared since they are typedefs, -// hence, include the headers that define the typedef's (no need to include -// in dependencies in BuildFile): -// class TsosVectorCollection; -// class TkFittedLasBeamCollection; -// class AliClusterValueMap; #include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" #include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" #include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" @@ -52,6 +56,9 @@ class AlignmentAlgorithmBase { public: // TODO: DEPRECATED: For not breaking the interface, used in serveral files. // If possible use the global typedefs above. + // With global typedefs one does not have to typedef again like + // typedef AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair; + // in other files. typedef std::pair ConstTrajTrackPair; typedef ConstTrajTrackPairs ConstTrajTrackPairCollection; typedef cond::RealTimeType::type RunNumber; From 6da03892df5c6f0950ab53a959abf8ab3d94f739 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Thu, 16 Jul 2015 17:14:14 +0200 Subject: [PATCH 054/104] fixed typo in readInSurveyRcds() --- .../plugins/PCLTrackerAlProducer.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 8274ecd6fa0fe..4798e54b39586 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -832,7 +832,7 @@ ::applyDB(G* geometry, const edm::EventSetup& setup) const void PCLTrackerAlProducer ::readInSurveyRcds(const edm::EventSetup& setup) { -/* + // Get Survey Rcds and add Survey Info if (doTracker_ && useSurvey_) { bool tkSurveyBool = watchTkSurveyRcd.check(setup); @@ -858,9 +858,9 @@ ::readInSurveyRcds(const edm::EventSetup& setup) bool CSCSurveyBool = watchTkSurveyRcd.check(setup); bool CSCSurveyErrBool = watchTkSurveyErrExtRcd.check(setup); - if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool){ + if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool) { edm::ESHandle dtSurveys; - edm::ESHandle dtSurveyErrors; + edm::ESHandle dtSurveyErrors; edm::ESHandle cscSurveys; edm::ESHandle cscSurveyErrors; setup.get(). get(dtSurveys); @@ -891,7 +891,7 @@ ::readInSurveyRcds(const edm::EventSetup& setup) } } } -*/ + } //_____________________________________________________________________________ From 97eb530ed0866215168cd539ef6fc9439f365c5e Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Mon, 27 Jul 2015 11:35:42 +0200 Subject: [PATCH 055/104] added global typedef 'vector AlignmentMonitors' --- .../CommonAlignmentMonitor/interface/AlignmentMonitorBase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h b/Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h index 3598120a48189..ddb1d3a07f4b4 100644 --- a/Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h +++ b/Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h @@ -110,5 +110,7 @@ class AlignmentMonitorBase std::map, TFileDirectory*> m_baseDirMap, m_iterDirMap; }; +/*** Global typedefs ***/ +typedef std::vector AlignmentMonitors; #endif From eecedc312ff1ba5e227e94fc5d12e60b779c3292 Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Mon, 27 Jul 2015 11:37:34 +0200 Subject: [PATCH 056/104] added ESWatcher for IdealGeometryRecord and GlobalPositionRcd --- .../plugins/PCLTrackerAlProducer.cc | 36 +++++++++----- .../plugins/PCLTrackerAlProducer.h | 49 +++++++++++-------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index 4798e54b39586..f3423373e0d5d 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -18,6 +18,7 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Run.h" + #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Parse.h" #include "FWCore/ServiceRegistry/interface/Service.h" @@ -100,6 +101,7 @@ PCLTrackerAlProducer ++iCal) { delete *iCal; } + // TODO: Delete monitors as well? delete theAlignmentParameterStore; @@ -111,9 +113,9 @@ PCLTrackerAlProducer -/****************************************************************************** - *** INTERFACE IMPLEMENTATION *** - ******************************************************************************/ +//============================================================================= +//=== INTERFACE IMPLEMENTATION === +//============================================================================= //_____________________________________________________________________________ void PCLTrackerAlProducer @@ -287,9 +289,9 @@ ::analyze(const edm::Event& event, const edm::EventSetup& setup) -/****************************************************************************** - *** PRIVATE METHOD IMPLEMENTATION *** - ******************************************************************************/ +//============================================================================= +//=== PRIVATE METHOD IMPLEMENTATION === +//============================================================================= /*** Code which is independent of Event & Setup Called from constructor ***/ @@ -376,18 +378,26 @@ ::setupChanged(const edm::EventSetup& setup) { bool changed = false; + if (watchIdealGeometryRcd.check(setup)) { + changed = true; + } + + if (watchGlobalPositionRcd.check(setup)) { + changed = true; + } + if (doTracker_) { if (watchTrackerAlRcd.check(setup)) { changed = true; - } + } - if (watchTrackerAlErrorExtRcd.check(setup)) { - changed = true; - } + if (watchTrackerAlErrorExtRcd.check(setup)) { + changed = true; + } - if (watchTrackerSurDeRcd.check(setup)) { - changed = true; - } + if (watchTrackerSurDeRcd.check(setup)) { + changed = true; + } } if (doMuon_) { diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h index 8abc8bd5b5c1e..e45cb40674239 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.h @@ -8,11 +8,13 @@ * @author Max Stark (max.stark@cern.ch) * @date 2015/07/16 * - * @brief Tracker-AlignmentProducer for the Prompt Calibration Loop (PCL) + * @brief Tracker-AlignmentProducer for Prompt Calibration Loop (PCL) * * Code is based on standard offline AlignmentProducer (see AlignmentProducer.h) * Main difference is the base-class exchange from an ESProducerLooper to an - * EDAnalyzer, + * EDAnalyzer. For further information regarding aligment workflow on PCL see: + * + * https://indico.cern.ch/event/394130/session/0/contribution/8/attachments/1127471/1610233/2015-07-16_PixelPCL_Ali.pdf * * @note Only for Tracker-Alignment usage. * @todo Remove all the muon alignment stuff @@ -30,18 +32,22 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESWatcher.h" + #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CondCore/DBCommon/interface/Time.h" /*** Alignment ***/ #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h" + #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" + #include "Alignment/CommonAlignment/interface/Alignable.h" #include "Alignment/CommonAlignment/interface/AlignableExtras.h" #include "Alignment/TrackerAlignment/interface/AlignableTracker.h" #include "Alignment/MuonAlignment/interface/AlignableMuon.h" + #include "CondFormats/Alignment/interface/Alignments.h" #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" #include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" @@ -49,16 +55,18 @@ #include "CondFormats/Alignment/interface/SurveyErrors.h" /*** Records for ESWatcher ***/ +#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" + #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" + #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" - #include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" #include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/DTSurveyRcd.h" @@ -69,15 +77,11 @@ /*** Forward declarations ***/ #include "FWCore/Framework/interface/Frameworkfwd.h" -/*** Typedefs ***/ -// TODO: Move this at the end of AlignmentMonitorBase.h -typedef std::vector AlignmentMonitors; - class PCLTrackerAlProducer : public edm::EDAnalyzer { - /**************************** PUBLIC METHODS ********************************/ - public: /********************************************************************/ + //========================== PUBLIC METHODS ================================== + public: //==================================================================== /// Constructor PCLTrackerAlProducer(const edm::ParameterSet&); @@ -102,17 +106,18 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { virtual void analyze(const edm::Event&, const edm::EventSetup&) override; - - /************************** PRIVATE METHODS *********************************/ - private: /*******************************************************************/ + //======================== PRIVATE METHODS ================================= + private: //================================================================= /*** Code which is independent of Event & Setup Called from constructor ***/ /// Creates the choosen alignment algorithm (specified in config-file) void createAlignmentAlgorithm(const edm::ParameterSet&); - /// Creates the mointors (specified in config-file) + + /// Creates the monitors (specified in config-file) void createMonitors (const edm::ParameterSet&); + /// Creates the calibrations (specified in config-file) void createCalibrations (const edm::ParameterSet&); @@ -203,8 +208,8 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { - /*************************** PRIVATE DATA ***********************************/ - /****************************************************************************/ + //========================== PRIVATE DATA ==================================== + //============================================================================ /*** Alignment data ***/ @@ -255,13 +260,17 @@ class PCLTrackerAlProducer : public edm::EDAnalyzer { /*** ESWatcher ***/ + edm::ESWatcher watchIdealGeometryRcd; + edm::ESWatcher watchGlobalPositionRcd; + edm::ESWatcher watchTrackerAlRcd; edm::ESWatcher watchTrackerAlErrorExtRcd; edm::ESWatcher watchTrackerSurDeRcd; - edm::ESWatcher watchDTAlRcd; - edm::ESWatcher watchDTAlErrExtRcd; - edm::ESWatcher watchCSCAlRcd; - edm::ESWatcher watchCSCAlErrExtRcd; + + edm::ESWatcher watchDTAlRcd; + edm::ESWatcher watchDTAlErrExtRcd; + edm::ESWatcher watchCSCAlRcd; + edm::ESWatcher watchCSCAlErrExtRcd; edm::ESWatcher watchTkSurveyRcd; edm::ESWatcher watchTkSurveyErrExtRcd; From 77935122ddf77cd590943f4e2eeebbf2ddf05999 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 28 Jul 2015 11:21:35 +0200 Subject: [PATCH 057/104] revert to official .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 49e885a4fbf29..82c501e6c418d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,3 @@ __init__.py .#* #*# *~ -.project -.cproject From cde8e95f5cf7a59f5024719abffb00b50721b8be Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 28 Jul 2015 11:24:40 +0200 Subject: [PATCH 058/104] remove obsolete class --- .../plugins/TrackerAlignmentProducerForPCL.cc | 880 ------------------ .../plugins/TrackerAlignmentProducerForPCL.h | 154 --- 2 files changed, 1034 deletions(-) delete mode 100644 Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc delete mode 100644 Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc deleted file mode 100644 index fe221712e0e5e..0000000000000 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.cc +++ /dev/null @@ -1,880 +0,0 @@ -#include "TrackerAlignmentProducerForPCL.h" - -//#include "FWCore/Framework/interface/LooperFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterBuilder.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" -#include "Alignment/CommonAlignment/interface/Alignable.h" - -#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" - -// System include files -#include -#include - -// Framework -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/Run.h" - -#include "FWCore/Utilities/interface/Parse.h" - -// Conditions database -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" - -// Geometry -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" -#include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurfaceDeformationRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorExtendedRcd.h" -#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" -#include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" - -// Tracking, LAS and cluster flag map (fwd is enough!) -#include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" -#include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" -#include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" - -// Alignment -#include "CondFormats/Alignment/interface/SurveyErrors.h" -#include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h" -#include "Alignment/CommonAlignment/interface/SurveyDet.h" -#include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h" -#include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmPluginFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/IntegratedCalibrationPluginFactory.h" -#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h" -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterSelector.h" - -TrackerAlignmentProducerForPCL::TrackerAlignmentProducerForPCL(const edm::ParameterSet &config) : - theAlignmentAlgo(0), //theAlignmentAlgo(std::nullptr_t), - theAlignmentParameterStore(0), //theAlignmentParameterStore(std::nullptr_t), - theParameterSet(config), - theAlignableExtras(0), - theAlignableTracker(0), - // theTracker - globalPositions(0), - nevent_(0), - doTracker_(true), - - stNFixAlignables_ (config.getParameter("nFixAlignables")), - stRandomShift_ (config.getParameter("randomShift")), - stRandomRotation_ (config.getParameter("randomRotation")), - doMisalignmentScenario_ (config.getParameter("doMisalignmentScenario")), - saveToDB (config.getParameter("saveToDB")), - saveApeToDB (config.getParameter("saveApeToDB")), - saveDeformationsToDB (config.getParameter("saveDeformationsToDB")), - - applyDbAlignment_ (config.getUntrackedParameter("applyDbAlignment")), - checkDbAlignmentValidity_(config.getUntrackedParameter("checkDbAlignmentValidity")), - useExtras_ (config.getUntrackedParameter("useExtras")), - useSurvey_ (config.getParameter("useSurvey")), - - tjTkAssociationMapTag_ (config.getParameter("tjTkAssociationMapTag")), - beamSpotTag_ (config.getParameter("beamSpotTag")), - tkLasBeamTag_ (config.getParameter("tkLasBeamTag")), - clusterValueMapTag_ (config.getParameter("hitPrescaleMapTag")) { - - // ESProducer method ? - //setWhatProduced(this, &AlignmentProducer::produceTracker); - //std::cout << "TrackerAlignmentProducerForPCL::constructor " <("algoConfig"); - edm::VParameterSet iovSelection = config.getParameter("RunRangeSelection"); - algoConfig.addUntrackedParameter("RunRangeSelection", iovSelection); - - std::string algoName = algoConfig.getParameter("algoName"); - theAlignmentAlgo = AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig); - - if (!theAlignmentAlgo) { - throw cms::Exception("BadConfig") << "Couldn't find the called alignment algorithm" << algoName; - } - - // Finally create integrated calibrations: - edm::VParameterSet calibrations = config.getParameter("calibrations"); - for (auto iCalib = calibrations.begin(); iCalib != calibrations.end(); ++iCalib) { - theCalibrations.push_back(IntegratedCalibrationPluginFactory::get()->create( - iCalib->getParameter("calibrationName"), *iCalib) - ); - } -} - -TrackerAlignmentProducerForPCL::~TrackerAlignmentProducerForPCL() { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - delete theAlignmentAlgo; - - // delete integrated calibration pointed to by (*iCal) - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - delete *iCal; - } - - delete theAlignmentParameterStore; - delete theAlignableExtras; - delete theAlignableTracker; - delete globalPositions; -} - - - -/************************************ - * PUBLIC METHOD IMPLEMENTATION * - ************************************/ - -void TrackerAlignmentProducerForPCL::beginJob() { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called UNUSED \n", __FUNCTION__, __FILE__); - // -> init(); -} - -void TrackerAlignmentProducerForPCL::endJob() { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - -} - -void TrackerAlignmentProducerForPCL::analyze(const edm::Event& event, - const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze"; - //std::cout << "TrackerAlignmentProducerForPCL::analyze " < merely skip if collection is empty - edm::Handle m_TrajTracksMap; - - // TODO: getByLabel -> getByToken - //if (event.getByToken()) - if (event.getByLabel(tjTkAssociationMapTag_, m_TrajTracksMap)) { - // Form pairs of trajectories and tracks - ConstTrajTrackPairCollection trajTracks; - for ( TrajTrackAssociationCollection::const_iterator iPair = m_TrajTracksMap->begin(); - iPair != m_TrajTracksMap->end(); ++iPair) { - trajTracks.push_back( ConstTrajTrackPair( &(*(*iPair).key), &(*(*iPair).val) ) ); - } - - // TODO: This should be in the constructor / beginJob method - edm::Handle theBeamSpot; - event.getByLabel(beamSpotTag_, theBeamSpot); - if (theAlignableExtras) { - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze" - << "initializing AlignableBeamSpot"; - theAlignableExtras->initializeBeamSpot(theBeamSpot->x0(), theBeamSpot->y0(), theBeamSpot->z0(), - theBeamSpot->dxdz(), theBeamSpot->dydz()); - } - - // Run the alignment algorithm with its input - const AliClusterValueMap* clusterValueMapPtr = 0; - //check that the input tag is not empty - if (clusterValueMapTag_.encode().size()) { - edm::Handle clusterValueMap; - event.getByLabel(clusterValueMapTag_, clusterValueMap); - clusterValueMapPtr = &(*clusterValueMap); - } - - const AlignmentAlgorithmBase::EventInfo eventInfo(event.id(), trajTracks, *theBeamSpot, - clusterValueMapPtr); - theAlignmentAlgo->run(setup, eventInfo); - - } else { - edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::analyze" - << "No track collection found: skipping event"; - } -} - -void TrackerAlignmentProducerForPCL::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - theAlignmentAlgo->beginRun(setup); - init(setup); -} - -void TrackerAlignmentProducerForPCL::endRun(const edm::Run& run, const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - // call with or without las beam info... - typedef AlignmentAlgorithmBase::EndRunInfo EndRunInfo; - // if non-empty InputTag - if (tkLasBeamTag_.encode().size()) { - edm::Handle lasBeams; - edm::Handle tsoses; - run.getByLabel(tkLasBeamTag_, lasBeams); - run.getByLabel(tkLasBeamTag_, tsoses); - - theAlignmentAlgo->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup); - - } else { - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endRun" - << "No Tk LAS beams to forward to algorithm."; - theAlignmentAlgo->endRun(EndRunInfo(run.id(), 0, 0), setup); - } - - finish(); - -} - -void TrackerAlignmentProducerForPCL::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, - const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - theAlignmentAlgo->beginLuminosityBlock(setup); // do not forward edm::LuminosityBlock -} - -void TrackerAlignmentProducerForPCL::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, - const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - theAlignmentAlgo->endLuminosityBlock(setup); // do not forward edm::LuminosityBlock -} - - - -/************************************* - * PRIVATE METHOD IMPLEMENTATION * - *************************************/ - -void TrackerAlignmentProducerForPCL::init(const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init"; - - - - /* 1) Former: AlignmentProducer::beginOfJob(const edm::EventSetup& setup) */ - - //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - setup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); - - // Create the geometries from the ideal geometries (first time only) - createGeometries(setup); - - // Retrieve and apply alignments, if requested (requires DB setup) - if (applyDbAlignment_) { - // we need GlobalPositionRcd - and have to keep track for later removal - // before writing again to DB... - edm::ESHandle globalPositionRcd; - setup.get().get(globalPositionRcd); - globalPositions = new Alignments(*globalPositionRcd); - - applyDB( - &(*theTracker), - setup, - align::DetectorGlobalPosition(*globalPositions, DetId(DetId::Tracker)) - ); - - applyDB( - &(*theTracker), - setup - ); - } - - // Create alignable tracker - theAlignableTracker = new AlignableTracker(&(*theTracker), tTopo); - - if (useExtras_) { - theAlignableExtras = new AlignableExtras(); - } - - // Create alignment parameter builder - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init" - << "Creating AlignmentParameterBuilder"; - - edm::ParameterSet aliParamBuildCfg = - theParameterSet.getParameter("ParameterBuilder"); - AlignmentParameterBuilder alignmentParameterBuilder(theAlignableTracker, - theAlignableExtras, - aliParamBuildCfg ); - - // Fix alignables if requested - if (stNFixAlignables_ > 0) { - alignmentParameterBuilder.fixAlignables(stNFixAlignables_); - } - - // Get list of alignables - Alignables theAlignables = alignmentParameterBuilder.alignables(); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" - << "got " << theAlignables.size() << " alignables"; - - // Create AlignmentParameterStore - edm::ParameterSet aliParamStoreCfg = theParameterSet.getParameter("ParameterStore"); - theAlignmentParameterStore = new AlignmentParameterStore(theAlignables, aliParamStoreCfg); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" - << "AlignmentParameterStore created!"; - - // Apply misalignment scenario to alignable tracker and muon if requested - // WARNING: this assumes scenarioConfig can be passed to both muon and tracker - if (doMisalignmentScenario_ && doTracker_) { - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" - << "Applying misalignment scenario to " - << (doTracker_ ? "tracker" : ""); - edm::ParameterSet scenarioConfig = theParameterSet.getParameter( "MisalignmentScenario" ); - - TrackerScenarioBuilder scenarioBuilder(theAlignableTracker); - scenarioBuilder.applyScenario(scenarioConfig); - - } else { - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::beginOfJob" - << "NOT applying misalignment scenario!"; - } - - // Apply simple misalignment - const std::string sParSel(theParameterSet.getParameter("parameterSelectorSimple")); - simpleMisalignment(theAlignables, sParSel, stRandomShift_, stRandomRotation_, true); - - // Initialize alignment algorithm and integrated calibration and pass the latter to algorithm - theAlignmentAlgo->initialize(setup, - theAlignableTracker, - 0, // theAlignableMuon, - theAlignableExtras, - theAlignmentParameterStore); - - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->beginOfJob(theAlignableTracker, 0, theAlignableExtras); - } - - // Not all algorithms support calibrations - so do not pass empty vector - // and throw if non-empty and not supported: - if (!theCalibrations.empty() && !theAlignmentAlgo->addCalibrations(theCalibrations)) { - throw cms::Exception("BadConfig") << "[TrackerAlignmentProducerForPCL::init]\n" - << "Configured " << theCalibrations.size() << " calibration(s) " - << "for algorithm not supporting it."; - } - - - - - /* 1) Former: AlignmentProducer::startingNewLoop(unsigned int iLoop) */ - - nevent_ = 0; - - theAlignmentAlgo->startNewLoop(); - // FIXME: Should this be done in algorithm::startNewLoop()?? - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->startNewLoop(); - } - - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::init" - << "Now physically apply alignments to geometry..."; - - // Propagate changes to reconstruction geometry (from initialisation or iteration) - GeometryAligner aligner; - - std::auto_ptr alignments (theAlignableTracker->alignments()); - std::auto_ptr alignmentErrors(theAlignableTracker->alignmentErrors()); - std::auto_ptr aliDeforms (theAlignableTracker->surfaceDeformations()); - - aligner.applyAlignments (&(*theTracker), &(*alignments), &(*alignmentErrors), AlignTransform() ); // don't apply global a second time! - aligner.attachSurfaceDeformations(&(*theTracker), &(*aliDeforms)); -} - -void TrackerAlignmentProducerForPCL::finish() { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish"; - - /* 1) Former: Status AlignmentProducer::endOfLoop(const edm::EventSetup& iSetup, unsigned int iLoop) */ - // if (0 == nevent_) { - // // beginOfJob is usually called by the framework in the first event of the first loop - // // (a hack: beginOfJob needs the EventSetup that is not well defined without an event) - // // and the algorithms rely on the initialisations done in beginOfJob. We cannot call - // // this->beginOfJob(iSetup); here either since that will access the EventSetup to get - // // some geometry information that is not defined either without having seen an event. - // edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" - // << "Did not process any events, " - // << "stop processing without terminating algorithm."; - // return; - // } - - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::endJob" - << "Terminating algorithm."; - - // TODO: Apparently, MP does not use the EventSetup parameter - theAlignmentAlgo->terminate(); - - // FIXME: Should this be done in algorithm::terminate(const edm::EventSetup& iSetup)?? - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->endOfLoop(); - } - - - - - - /* 2) Former: void AlignmentProducer::endOfJob() */ - - // if (0 == nevent_) { - // edm::LogError("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" << "Did not process any " - // << "events in last loop, do not dare to store to DB."; - // } else { - // Expand run ranges and make them unique - edm::VParameterSet runRangeSelectionVPSet(theParameterSet.getParameter("RunRangeSelection")); - RunRanges uniqueRunRanges(makeNonOverlappingRunRanges(runRangeSelectionVPSet)); - - // create dummy IOV - if (uniqueRunRanges.empty()) { - const RunRange runRange(cond::timeTypeSpecs[cond::runnumber].beginValue, - cond::timeTypeSpecs[cond::runnumber].endValue); - uniqueRunRanges.push_back(runRange); - } - - std::vector beamSpotParameters; - - for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); - iRunRange != uniqueRunRanges.end(); - ++iRunRange) { - - theAlignmentAlgo->setParametersForRunRange(*iRunRange); - - // Save alignments to database - if (saveToDB || saveApeToDB || saveDeformationsToDB) { - writeForRunRange((*iRunRange).first); - } - - // Deal with extra alignables, e.g. beam spot - if (theAlignableExtras) { - Alignables &alis = theAlignableExtras->beamSpot(); - if (!alis.empty()) { - BeamSpotAlignmentParameters *beamSpotAliPars = dynamic_cast(alis[0]->alignmentParameters()); - beamSpotParameters.push_back(beamSpotAliPars->parameters()); - } - } - // } - - if (theAlignableExtras) { - std::ostringstream bsOutput; - - std::vector::const_iterator itPar = beamSpotParameters.begin(); - for (RunRanges::const_iterator iRunRange = uniqueRunRanges.begin(); - iRunRange != uniqueRunRanges.end(); - ++iRunRange, ++itPar) { - bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n"; - bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n"; - bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n"; - } - - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::finish" - << "Parameters for alignable beamspot:\n" - << bsOutput.str(); - } - - for (auto iCal = theCalibrations.begin(); iCal != theCalibrations.end(); ++iCal) { - (*iCal)->endOfJob(); - } - } -} - -void TrackerAlignmentProducerForPCL::createGeometries(const edm::EventSetup& setup) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - //edm::ESTransientHandle cpv; - //iSetup.get().get(cpv); - - edm::ESHandle geometricDet; - setup.get().get(geometricDet); - TrackerGeomBuilderFromGeometricDet trackerBuilder; - - theTracker = boost::shared_ptr(trackerBuilder.build(&(*geometricDet), theParameterSet)); -} - -void TrackerAlignmentProducerForPCL::simpleMisalignment(const Alignables& alivec, const std::string& selection, - float shift, float rot, bool local) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - std::ostringstream output; // collecting output - - if (shift > 0. || rot > 0.) { - output << "Adding random flat shift of max size " << shift - << " and adding random flat rotation of max size " << rot <<" to "; - - std::vector commSel(0); - if (selection != "-1") { - AlignmentParameterSelector aSelector(0,0); // no alignable needed here... - const std::vector cSel(aSelector.convertParamSel(selection)); - - if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) { - throw cms::Exception("BadConfig") - << "[AlignmentProducer::simpleMisalignment_]\n" - << "Expect selection string '" << selection << "' to be at least of length " - << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n" - << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)"; - } - - for (std::vector::const_iterator cIter = cSel.begin(); cIter != cSel.end(); ++cIter) { - commSel.push_back(*cIter == '0' ? false : true); - } - - output << "parameters defined by (" << selection - << "), representing (x,y,z,alpha,beta,gamma),"; - - } else { - output << "the active parameters of each alignable,"; - } - output << " in " << (local ? "local" : "global") << " frame."; - - for (std::vector::const_iterator it = alivec.begin(); it != alivec.end(); ++it) { - Alignable* ali = (*it); - std::vector mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel); - - if (std::abs(shift) > 0.00001) { - double s0 = 0., s1 = 0., s2 = 0.; - if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.; - if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.; - if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.; - - if (local) { - ali->move( ali->surface().toGlobal(align::LocalVector(s0,s1,s2)) ); - } else { - ali->move( align::GlobalVector(s0,s1,s2) ); - } - } - - if (std::abs(rot)>0.00001) { - align::EulerAngles r(3); - if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.; - if (mysel[RigidBodyAlignmentParameters::dbeta] ) r(2)=rot*double(random()%1000-500)/500.; - if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.; - - const align::RotationType mrot = align::toMatrix(r); - if (local) ali->rotateInLocalFrame(mrot); - else ali->rotateInGlobalFrame(mrot); - } - } // end loop on alignables - - } else { - output << "No simple misalignment added!"; - } - - edm::LogInfo("Alignment") << "@SUB=TrackerAlignmentProducerForPCL::simpleMisalignment" << output.str(); -} - -////////////////////////////////////////////////// -// a templated method - but private, so not accessible from outside -// ==> does not have to be in header file -template -void TrackerAlignmentProducerForPCL::applyDB(G* geometry, const edm::EventSetup& setup, - const AlignTransform& globalCoordinates) const { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - // 'G' is the geometry class for that DB should be applied, - // 'Rcd' is the record class for its Alignments - // 'ErrRcd' is the record class for its AlignmentErrors - // 'globalCoordinates' are global transformation for this geometry - - const Rcd & record = setup.get(); - if (checkDbAlignmentValidity_) { - const edm::ValidityInterval& validity = record.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); - - if (first != edm::IOVSyncValue::beginOfTime() || - last != edm::IOVSyncValue::endOfTime()) { - throw cms::Exception("DatabaseError") - << "@SUB=AlignmentProducer::applyDB" - << "\nTrying to apply " - << record.key().name() - << " with multiple IOVs in tag.\n" - << "Validity range is " - << first.eventID().run() << " - " << last.eventID().run(); - } - } - - edm::ESHandle alignments; - record.get(alignments); - - edm::ESHandle alignmentErrors; - setup.get().get(alignmentErrors); - - GeometryAligner aligner; - aligner.applyAlignments(geometry, &(*alignments), &(*alignmentErrors), - globalCoordinates); -} - -////////////////////////////////////////////////// -// a templated method - but private, so not accessible from outside -// ==> does not have to be in header file -template -void TrackerAlignmentProducerForPCL::applyDB(G* geometry, const edm::EventSetup& setup) const { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - // 'G' is the geometry class for that DB should be applied, - // 'DeformationRcd' is the record class for its surface deformations - - const DeformationRcd & record = setup.get(); - if (checkDbAlignmentValidity_) { - const edm::ValidityInterval & validity = record.validityInterval(); - const edm::IOVSyncValue first = validity.first(); - const edm::IOVSyncValue last = validity.last(); - - if (first != edm::IOVSyncValue::beginOfTime() || - last != edm::IOVSyncValue::endOfTime()) { - throw cms::Exception("DatabaseError") - << "@SUB=AlignmentProducer::applyDB" - << "\nTrying to apply " - << record.key().name() - << " with multiple IOVs in tag.\n" - << "Validity range is " - << first.eventID().run() << " - " << last.eventID().run(); - } - } - - edm::ESHandle surfaceDeformations; - record.get(surfaceDeformations); - - GeometryAligner aligner; - aligner.attachSurfaceDeformations(geometry, &(*surfaceDeformations)); -} - -void TrackerAlignmentProducerForPCL::writeForRunRange(cond::Time_t time) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - // will be 'removed' from constants - const AlignTransform* trackerGlobal = 0; - - // i.e. applied before in applyDB - if (globalPositions) { - trackerGlobal = &align::DetectorGlobalPosition(*globalPositions, - DetId(DetId::Tracker)); - } - - Alignments* alignments = theAlignableTracker->alignments(); - AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors(); - - writeDB(alignments, "TrackerAlignmentRcd", - alignmentErrors, "TrackerAlignmentErrorExtendedRcd", - trackerGlobal, time); - - - // Save surface deformations to database - if (saveDeformationsToDB) { - AlignmentSurfaceDeformations* alignmentSurfaceDeformations = theAlignableTracker->surfaceDeformations(); - writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time); - } -} - -void TrackerAlignmentProducerForPCL::writeDB(Alignments* alignments, - const std::string& alignRcd, - AlignmentErrorsExtended* alignmentErrors, - const std::string& errRcd, - const AlignTransform* globalCoordinates, - cond::Time_t time) const { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - Alignments* tempAlignments = alignments; - AlignmentErrorsExtended* tempAlignmentErrors = alignmentErrors; - - // Call service - edm::Service poolDb; - // Die if not available - if (!poolDb.isAvailable()) { - // promised to take over ownership... - delete tempAlignments; - delete tempAlignmentErrors; // dito - throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; - } - - if (globalCoordinates && // happens only if (applyDbAlignment_ == true) - globalCoordinates->transform() != AlignTransform::Transform::Identity) { - - tempAlignments = new Alignments(); // temporary storage for - tempAlignmentErrors = new AlignmentErrorsExtended(); // final alignments and errors - - GeometryAligner aligner; - aligner.removeGlobalTransform(alignments, alignmentErrors, - *globalCoordinates, - tempAlignments, tempAlignmentErrors); - - delete alignments; // have to delete original alignments - delete alignmentErrors; // same thing for the errors - - edm::LogInfo("Alignment") << "@SUB=AlignmentProducer::writeDB" - << "globalCoordinates removed from alignments (" << alignRcd - << ") and errors (" << alignRcd << ")."; - } - - if (saveToDB) { - edm::LogInfo("Alignment") << "Writing Alignments for run " << time - << " to " << alignRcd << "."; - poolDb->writeOne(tempAlignments, time, alignRcd); - - } else { - // poolDb->writeOne(..) takes over 'alignments' ownership,... - delete tempAlignments; // ...otherwise we have to delete, as promised! - } - - if (saveApeToDB) { - edm::LogInfo("Alignment") << "Writing AlignmentErrors for run " << time - << " to " << errRcd << "."; - poolDb->writeOne(tempAlignmentErrors, time, errRcd); - - } else { - // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,... - delete tempAlignmentErrors; // ...otherwise we have to delete, as promised! - } -} - -void TrackerAlignmentProducerForPCL::writeDB(AlignmentSurfaceDeformations* alignmentSurfaceDeformations, - const std::string& surfaceDeformationRcd, - cond::Time_t time) const { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - // Call service - edm::Service poolDb; - // Die if not available - if (!poolDb.isAvailable()) { - delete alignmentSurfaceDeformations; // promised to take over ownership... - throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; - } - - if (saveDeformationsToDB) { - edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time - << " to " << surfaceDeformationRcd << "."; - poolDb->writeOne(alignmentSurfaceDeformations, time, - surfaceDeformationRcd); - } else { - // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,... - delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised! - } -} - -TrackerAlignmentProducerForPCL::RunRanges TrackerAlignmentProducerForPCL::makeNonOverlappingRunRanges( - const edm::VParameterSet& RunRangeSelectionVPSet) { - printf("(TrackerAlignmentProducerForPCL) function %s in %s was called\n", __FUNCTION__, __FILE__); - - static bool oldRunRangeSelectionWarning = false; - - const RunNumber beginValue = cond::timeTypeSpecs[cond::runnumber].beginValue; - const RunNumber endValue = cond::timeTypeSpecs[cond::runnumber].endValue; - - RunRanges uniqueRunRanges; - if (!RunRangeSelectionVPSet.empty()) { - - std::map uniqueFirstRunNumbers; - - for (std::vector::const_iterator ipset = RunRangeSelectionVPSet.begin(); - ipset != RunRangeSelectionVPSet.end(); ++ipset) { - const std::vector RunRangeStrings = (*ipset).getParameter >("RunRanges"); - - for (std::vector::const_iterator irange = RunRangeStrings.begin(); - irange != RunRangeStrings.end(); ++irange) { - - if ((*irange).find(':') == std::string::npos) { - RunNumber first = beginValue; - long int temp = strtol((*irange).c_str(), 0, 0); - if (temp != -1) first = temp; - uniqueFirstRunNumbers[first] = first; - - } else { - if (!oldRunRangeSelectionWarning) { - edm::LogWarning("BadConfig") << "@SUB=AlignmentProducer::makeNonOverlappingRunRanges" - << "Config file contains old format for 'RunRangeSelection'. Only the start run\n" - << "number is used internally. The number of the last run is ignored and can be\n" - << "safely removed from the config file.\n"; - oldRunRangeSelectionWarning = true; - } - - std::vector tokens = edm::tokenize(*irange, ":"); - long int temp; - RunNumber first = beginValue; - temp = strtol(tokens[0].c_str(), 0, 0); - if (temp != -1) first = temp; - uniqueFirstRunNumbers[first] = first; - } - } - } - - for (std::map::iterator iFirst = uniqueFirstRunNumbers.begin(); - iFirst!=uniqueFirstRunNumbers.end(); ++iFirst) { - uniqueRunRanges.push_back(std::pair((*iFirst).first, endValue)); - } - - for (unsigned int i = 0; i < uniqueRunRanges.size()-1; ++i) { - uniqueRunRanges[i].second = uniqueRunRanges[i+1].first - 1; - } - - } else { - uniqueRunRanges.push_back(std::pair(beginValue, endValue)); - } - - return uniqueRunRanges; -} - - - -void TrackerAlignmentProducerForPCL::addSurveyInfo(Alignable* ali) { - const std::vector& comp = ali->components(); - for (unsigned int i = 0; i < comp.size(); ++i) { - addSurveyInfo(comp[i]); - } - - const SurveyError& error = theSurveyErrors->m_surveyErrors[theSurveyIndex]; - - if (ali->id() != error.rawId() || - ali->alignableObjectId() != error.structureType()) { - throw cms::Exception("DatabaseError") << "Error reading survey info from DB. " - "Mismatched id!"; - } - - const CLHEP::Hep3Vector& pos = theSurveyValues->m_align[theSurveyIndex].translation(); - const CLHEP::HepRotation& rot = theSurveyValues->m_align[theSurveyIndex].rotation(); - - AlignableSurface surf(align::PositionType(pos.x(), pos.y(), pos.z()), - align::RotationType(rot.xx(), rot.xy(), rot.xz(), - rot.yx(), rot.yy(), rot.yz(), - rot.zx(), rot.zy(), rot.zz() ) ); - surf.setWidth (ali->surface().width()); - surf.setLength(ali->surface().length()); - - ali->setSurvey(new SurveyDet(surf, error.matrix())); - - ++theSurveyIndex; -} - -void TrackerAlignmentProducerForPCL::readInSurveyRcds(const edm::EventSetup& setup) { - if (useSurvey_) { - bool tkSurveyBool = watchTkSurveyRcd_.check(setup); - bool tkSurveyErrBool = watchTkSurveyErrRcd_.check(setup); - edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool; - edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool; - - if (tkSurveyBool || tkSurveyErrBool) { - edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION"; - edm::ESHandle surveys; - edm::ESHandle surveyErrors; - - setup.get().get(surveys); - setup.get().get(surveyErrors); - - theSurveyIndex = 0; - theSurveyValues = &*surveys; - theSurveyErrors = &*surveyErrors; - - addSurveyInfo(theAlignableTracker); - } - } -} - -// define this as a plugin -DEFINE_FWK_MODULE(TrackerAlignmentProducerForPCL); diff --git a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h b/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h deleted file mode 100644 index 00b7a7cee3aa6..0000000000000 --- a/Alignment/CommonAlignmentProducer/plugins/TrackerAlignmentProducerForPCL.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ -#define ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ - -#include - -// Framework -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "DataFormats/Provenance/interface/RunID.h" - -// Geometry -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" - -// Alignment -#include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h" -#include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "Alignment/CommonAlignment/interface/AlignableExtras.h" -#include "Alignment/TrackerAlignment/interface/AlignableTracker.h" - -#include -#include "CondCore/DBCommon/interface/Time.h" -#include "CondFormats/Alignment/interface/Alignments.h" -#include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h" - -// for watcher -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerSurveyErrorRcd.h" - - -class Alignments; -class IntegratedCalibrationBase; -class SurveyErrors; -namespace edm { - class Run; - class LuminosityBlock; -} - -class TrackerAlignmentProducerForPCL : public edm::EDAnalyzer { - public: - - TrackerAlignmentProducerForPCL(const edm::ParameterSet&); - virtual ~TrackerAlignmentProducerForPCL(); - - typedef std::pair ConstTrajTrackPair; - typedef std::vector ConstTrajTrackPairCollection; - typedef std::vector Alignables; - - typedef AlignmentAlgorithmBase::RunNumber RunNumber; - typedef AlignmentAlgorithmBase::RunRange RunRange; - typedef std::vector RunRanges; - - - virtual void beginJob(void) override; - virtual void endJob (void) override; - - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; - - virtual void beginRun(const edm::Run&, const edm::EventSetup&) override; - virtual void endRun (const edm::Run&, const edm::EventSetup&) override; - - virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override; - virtual void endLuminosityBlock (const edm::LuminosityBlock&, const edm::EventSetup&) override; - - private: - - void init(const edm::EventSetup&); - void finish(); - - void createGeometries (const edm::EventSetup&); - void simpleMisalignment(const Alignables&, const std::string&, float, float, bool); - - /// Apply DB constants belonging to (Err)Rcd to geometry, - /// taking into account 'globalPosition' correction. - template - void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const; - /// Apply DB constants for surface deformations - template - void applyDB(G*, const edm::EventSetup&) const; - - // write alignments and alignment errors for all sub detectors and - // the given run number - void writeForRunRange(cond::Time_t); - - /// Write alignment and/or errors to DB for record names - /// (removes *globalCoordinates before writing if non-null...). - /// Takes over ownership of alignments and alignmentErrrors. - void writeDB(Alignments*, const std::string&, AlignmentErrorsExtended*, - const std::string&, const AlignTransform*, cond::Time_t) const; - /// Write surface deformations (bows & kinks) to DB for given record name - /// Takes over ownership of alignmentsurfaceDeformations. - void writeDB(AlignmentSurfaceDeformations*, const std::string&, cond::Time_t) const; - - RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet&); - - - /// Add survey info to an alignable - void addSurveyInfo(Alignable*); - /// read in survey records - void readInSurveyRcds(const edm::EventSetup&); - - unsigned int theSurveyIndex; - const Alignments* theSurveyValues; - const SurveyErrors* theSurveyErrors; - - - // std::unique_ptr theAlignmentAlgo; - // std::unique_ptr theAlignmentParameterStore; - //std::vector> theCalibrations; - - AlignmentAlgorithmBase* theAlignmentAlgo; - AlignmentParameterStore* theAlignmentParameterStore; - std::vector theCalibrations; - - edm::ParameterSet theParameterSet; - AlignableExtras* theAlignableExtras; - AlignableTracker* theAlignableTracker; - - //std::shared_ptr theTracker; - boost::shared_ptr theTracker; - - Alignments* globalPositions; - - int nevent_; - const bool doTracker_; - - const int stNFixAlignables_; - const double stRandomShift_; - const double stRandomRotation_; - - const bool doMisalignmentScenario_; - const bool saveToDB; - const bool saveApeToDB; - const bool saveDeformationsToDB; - const bool applyDbAlignment_; - const bool checkDbAlignmentValidity_; - const bool useExtras_; - const bool useSurvey_; - - const edm::InputTag tjTkAssociationMapTag_; // map with tracks/trajectories - const edm::InputTag beamSpotTag_; // beam spot - const edm::InputTag tkLasBeamTag_; // LAS beams in edm::Run (ignore if empty) - const edm::InputTag clusterValueMapTag_; // ValueMap containing associtaion cluster-flag - - - - edm::ESWatcher watchTkSurveyRcd_; - edm::ESWatcher watchTkSurveyErrRcd_; -}; - -#endif /* ALIGNMENT_COMMONALIGNMENTPRODUCER_PLUGINS_ALIGNMENTPRODUCERFORPCL_H_ */ From 176ef102b4de5e5a2a0e13db6dc63cd031130b6c Mon Sep 17 00:00:00 2001 From: DirtyDan88 Date: Tue, 28 Jul 2015 13:10:43 +0200 Subject: [PATCH 059/104] added methods for PCLAlignmentProducer and some typedefs --- .../interface/AlignmentAlgorithmBase.h | 243 +++++++++--------- 1 file changed, 120 insertions(+), 123 deletions(-) diff --git a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h index 99e5351f9b10c..32e8e9ee458f6 100644 --- a/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h +++ b/Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h @@ -18,32 +18,34 @@ -/*** System includes ***/ #include #include -/*** Core framework functionality ***/ +class AlignableTracker; +class AlignableMuon; +class AlignableExtras; +class AlignmentParameterStore; +class IntegratedCalibrationBase; +class Trajectory; +// These data formats cannot be forward declared since they are typedef's, +// so include the headers that define the typedef's +// (no need to include in dependencies in BuildFile): +// class TsosVectorCollection; +// class TkFittedLasBeamCollection; +// class AliClusterValueMap; #include "CondCore/DBCommon/interface/Time.h" -#include "FWCore/Framework/interface/Event.h" -namespace edm { class EventSetup; class ParameterSet; } -namespace reco { class Track; class BeamSpot; } - -/*** Alignment ***/ #include "Alignment/LaserAlignment/interface/TsosVectorCollection.h" #include "DataFormats/Alignment/interface/TkFittedLasBeamCollectionFwd.h" #include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" +#include "FWCore/Framework/interface/Event.h" -class AlignableTracker; -class AlignableMuon; -class AlignableExtras; -class AlignmentParameterStore; +namespace edm { class EventSetup; class ParameterSet; } +namespace reco { class Track; class BeamSpot; } /*** Global typedefs part I (see EOF for part II) ***/ -class Trajectory; typedef std::pair ConstTrajTrackPair; typedef std::vector< ConstTrajTrackPair > ConstTrajTrackPairs; -class IntegratedCalibrationBase; typedef std::vector Calibrations; typedef cond::RealTimeType::type RunNumber; @@ -52,117 +54,112 @@ typedef std::vector RunRanges; -class AlignmentAlgorithmBase { +class AlignmentAlgorithmBase +{ + +public: + // TODO: DEPRECATED: For not breaking the interface, used in serveral files. + // If possible use the global typedefs above. + // With global typedefs one does not have to typedef again like + // 'typedef AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair;' + // in other files. + typedef std::pair ConstTrajTrackPair; + typedef std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection; + typedef cond::RealTimeType::type RunNumber; + typedef std::pair RunRange; + + /// define event information passed to algorithms + class EventInfo { + public: + EventInfo(const edm::EventID &theEventId, + const ConstTrajTrackPairCollection &theTrajTrackPairs, + const reco::BeamSpot &theBeamSpot, + const AliClusterValueMap *theClusterValueMap) + : eventId_(theEventId), trajTrackPairs_(theTrajTrackPairs), beamSpot_(theBeamSpot), clusterValueMap_(theClusterValueMap) {} + + const edm::EventID eventId() const { return eventId_; } + const ConstTrajTrackPairCollection& trajTrackPairs() const { return trajTrackPairs_; } + const reco::BeamSpot& beamSpot() const { return beamSpot_; } + const AliClusterValueMap* clusterValueMap() const { return clusterValueMap_; }///might be null! + + + private: + const edm::EventID eventId_; + const ConstTrajTrackPairCollection &trajTrackPairs_; + const reco::BeamSpot &beamSpot_; + const AliClusterValueMap *clusterValueMap_;///might be null! + }; + + /// define run information passed to algorithms (in endRun) + class EndRunInfo { public: - // TODO: DEPRECATED: For not breaking the interface, used in serveral files. - // If possible use the global typedefs above. - // With global typedefs one does not have to typedef again like - // typedef AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair; - // in other files. - typedef std::pair ConstTrajTrackPair; - typedef ConstTrajTrackPairs ConstTrajTrackPairCollection; - typedef cond::RealTimeType::type RunNumber; - typedef std::pair RunRange; - typedef std::vector RunRanges; - - - - /// Define event information passed to algorithms - class EventInfo { - public: - EventInfo(const edm::EventID& theEventId, - const ConstTrajTrackPairs& theTrajTrackPairs, - const reco::BeamSpot& theBeamSpot, - const AliClusterValueMap* theClusterValueMap) : - eventId_ (theEventId), - trajTrackPairs_ (theTrajTrackPairs), - beamSpot_ (theBeamSpot), - clusterValueMap_(theClusterValueMap) {} - - const edm::EventID eventId() const { return eventId_; } - const ConstTrajTrackPairs& trajTrackPairs() const { return trajTrackPairs_; } - const reco::BeamSpot& beamSpot() const { return beamSpot_; } - const AliClusterValueMap* clusterValueMap() const { return clusterValueMap_; } /// might be null! - - private: - const edm::EventID eventId_; - const ConstTrajTrackPairs& trajTrackPairs_; - const reco::BeamSpot& beamSpot_; - const AliClusterValueMap* clusterValueMap_; /// might be null! - }; - - /// Define run information passed to algorithms (in endRun) - class EndRunInfo { - public: - EndRunInfo(const edm::RunID& theRunId, - const TkFittedLasBeamCollection* theTkLasBeams, - const TsosVectorCollection* theTkLasBeamTsoses) : - runId_(theRunId), - tkLasBeams_(theTkLasBeams), - tkLasBeamTsoses_(theTkLasBeamTsoses) {} - - const edm::RunID runId() const { return runId_; } - const TkFittedLasBeamCollection* tkLasBeams() const { return tkLasBeams_; } /// might be null! - const TsosVectorCollection* tkLasBeamTsoses() const { return tkLasBeamTsoses_; } /// might be null! - - private: - const edm::RunID runId_; - const TkFittedLasBeamCollection* tkLasBeams_; /// might be null! - const TsosVectorCollection* tkLasBeamTsoses_; /// might be null! - }; - - - - /// Constructor - AlignmentAlgorithmBase(const edm::ParameterSet&) {} - /// Destructor - virtual ~AlignmentAlgorithmBase() {} - - /// Called at beginning of job (must be implemented in derived class) - virtual void initialize(const edm::EventSetup&, - AlignableTracker*, - AlignableMuon*, - AlignableExtras*, - AlignmentParameterStore*) = 0; - /// Called at end of job (must be implemented in derived class) - virtual void terminate(const edm::EventSetup&) = 0; - /// Called at end of job (must be implemented in derived class) - virtual void terminate() {} - - /// Returns whether calibrations is supported by algorithm, - /// default implementation returns false. - virtual bool supportsCalibrations() { return false; } - /// Pass integrated calibrations to algorithm, to be called after initialize() - /// Calibrations' ownership is NOT passed to algorithm - virtual bool addCalibrations(const Calibrations&) { return false; } - - // TODO: DEPRECATED: Actually, there are no iterative algorithms, use - // initialze() and terminate() - /// Called at start of loop, default implementation is dummy for - /// non-iterative algorithms - virtual void startNewLoop() {} - /// Called at end of loop, default implementation is dummy for - /// non-iterative algorithms - virtual void endLoop() {} - - /// Called at begin of run - virtual void beginRun(const edm::EventSetup&) {} - /// Called at end of run - order of arguments like in EDProducer etc. - virtual void endRun (const EndRunInfo&, const edm::EventSetup&) {} - - /// Called at begin of luminosity block (no lumi block info passed yet) - virtual void beginLuminosityBlock(const edm::EventSetup&) {} - /// Called at end of luminosity block (no lumi block info passed yet) - virtual void endLuminosityBlock (const edm::EventSetup&) {} - - /// Returns whether algorithm proccesses events in current configuration - virtual bool processesEvents() { return true; } - /// Run the algorithm (must be implemented in derived class) - virtual void run(const edm::EventSetup&, const EventInfo&) = 0; - - /// Called in order to pass parameters to alignables for a specific run - /// range in case the algorithm supports run range dependent alignment. - virtual bool setParametersForRunRange(const RunRange&) { return false; } + EndRunInfo(const edm::RunID &theRunId, const TkFittedLasBeamCollection *theTkLasBeams, + const TsosVectorCollection *theTkLasBeamTsoses) + : runId_(theRunId), tkLasBeams_(theTkLasBeams), tkLasBeamTsoses_(theTkLasBeamTsoses) {} + + const edm::RunID runId() const { return runId_; } + const TkFittedLasBeamCollection* tkLasBeams() const { return tkLasBeams_; } /// might be null! + const TsosVectorCollection* tkLasBeamTsoses() const { return tkLasBeamTsoses_; } /// might be null! + + + private: + const edm::RunID runId_; + const TkFittedLasBeamCollection *tkLasBeams_; /// might be null! + const TsosVectorCollection *tkLasBeamTsoses_; /// might be null! + }; + + /// Constructor + AlignmentAlgorithmBase(const edm::ParameterSet&) {}; + + /// Destructor + virtual ~AlignmentAlgorithmBase() {}; + + /// Call at beginning of job (must be implemented in derived class) + virtual void initialize( const edm::EventSetup& setup, + AlignableTracker* tracker, + AlignableMuon* muon, + AlignableExtras* extras, + AlignmentParameterStore* store ) = 0; + + /// Returns whether calibrations is supported by algorithm, + /// default implementation returns false. + virtual bool supportsCalibrations() { return false; } + /// Pass integrated calibrations to algorithm, to be called after initialize() + /// Calibrations' ownership is NOT passed to algorithm + virtual bool addCalibrations(const Calibrations&) { return false; } + + /// Returns whether algorithm proccesses events in current configuration + virtual bool processesEvents() { return true; } + + // TODO: DEPRECATED: Actually, there are no iterative algorithms, use + // initialze() and terminate() + /// Called at start of loop, default implementation is dummy for + /// non-iterative algorithms + virtual void startNewLoop() {} + + /// Call at end of each loop (must be implemented in derived class) + virtual void terminate(const edm::EventSetup& iSetup) = 0; + /// Called at end of job (must be implemented in derived class) + virtual void terminate() {} + + /// Run the algorithm (must be implemented in derived class) + virtual void run( const edm::EventSetup &setup, const EventInfo &eventInfo) = 0; + + /// called at begin of run + virtual void beginRun(const edm::EventSetup &setup) {}; + + /// called at end of run - order of arguments like in EDProducer etc. + virtual void endRun(const EndRunInfo &runInfo, const edm::EventSetup &setup) {}; + + /// called at begin of luminosity block (no lumi block info passed yet) + virtual void beginLuminosityBlock(const edm::EventSetup &setup) {}; + + /// called at end of luminosity block (no lumi block info passed yet) + virtual void endLuminosityBlock(const edm::EventSetup &setup) {}; + + /// called in order to pass parameters to alignables for a specific run + /// range in case the algorithm supports run range dependent alignment. + virtual bool setParametersForRunRange(const RunRange& rr) { return false; }; }; /*** Global typedefs part II ***/ From f213fe4761a96321f36345f06ddead2ba1bf0e95 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 28 Jul 2015 15:53:00 +0200 Subject: [PATCH 060/104] Minor fixes to finalize the check of the new workflow in in the relval 1001 --- Configuration/PyReleaseValidation/python/relval_production.py | 2 +- Configuration/PyReleaseValidation/python/relval_steps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_production.py b/Configuration/PyReleaseValidation/python/relval_production.py index 9fb6157fcbd42..70d5b23784f81 100644 --- a/Configuration/PyReleaseValidation/python/relval_production.py +++ b/Configuration/PyReleaseValidation/python/relval_production.py @@ -11,7 +11,7 @@ ## data production test workflows[1000] = [ '',['RunMinBias2011A','TIER0','SKIMD','HARVESTDfst2','ALCASPLIT']] -workflows[1001] = [ '',['RunMinBias2011A','TIER0EXP','ALCAEXP','ALCAHARVD1','ALCAHARVD2','ALCAHARVD3']] +workflows[1001] = [ '',['RunMinBias2011A','TIER0EXP','ALCAEXP','ALCAHARVD1','ALCAHARVD2','ALCAHARVD3','ALCAHARVD4']] workflows[1002]=['RRD',['RunMinBias2011A','RECOD','COPYPASTE']]#,'RECODFROMRAWRECO']] workflows[1003]=['', ['RunMinBias2012A','RECODDQM','HARVESTDDQM']] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index a6676fad6b3e9..d54291ebb91c5 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1194,7 +1194,7 @@ def genvalid(fragment,d,suffix='all',fi='',dataSet=''): '--conditions':'auto:run1_data', '--scenario':'pp', '--data':'', - '--filein':'file:PromptCalibProdSiStripGains.root'} + '--filein':'file:PromptCalibProdSiPixelAli.root'} steps['RECOHISt4']=steps['RECOHI'] steps['RECOHIMIX']=merge([steps['RECOHI'],{'--pileup':'HiMix','--pileup_input':'das:/RelValHydjetQ_MinBias_2760GeV/%s/GEN-SIM'%(baseDataSetRelease[1])}]) From ba2571937211eb004e34cb054e1f4ee5f5168a6c Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 28 Jul 2015 16:51:55 +0200 Subject: [PATCH 061/104] revert all changes to the AlignmentProducer EDLooper since we now have a dedicated producer --- .../CommonAlignmentProducer/plugins/AlignmentProducer.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc b/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc index 46bd23d1903f0..beca73476f06b 100644 --- a/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/AlignmentProducer.cc @@ -643,6 +643,8 @@ void AlignmentProducer::simpleMisalignment_(const Alignables &alivec, const std: //__________________________________________________________________________________________________ void AlignmentProducer::createGeometries_( const edm::EventSetup& iSetup ) { + edm::ESTransientHandle cpv; + iSetup.get().get( cpv ); if (doTracker_) { edm::ESHandle geometricDet; @@ -654,9 +656,6 @@ void AlignmentProducer::createGeometries_( const edm::EventSetup& iSetup ) } if (doMuon_) { - edm::ESTransientHandle cpv; - iSetup.get().get( cpv ); - edm::ESHandle mdc; iSetup.get().get(mdc); DTGeometryBuilderFromDDD DTGeometryBuilder; From 5a7291f3939a96f85e26a3adf27b400230c63638 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Tue, 28 Jul 2015 18:17:15 +0200 Subject: [PATCH 062/104] Move to the new mechanism for the TrackerTopology --- .../CommonAlignmentProducer/plugins/BuildFile.xml | 1 + .../plugins/PCLTrackerAlProducer.cc | 11 +++++++++-- .../python/TrackerAlignmentProducerForPCL_cff.py | 6 +++--- .../src/MillePedeAlignmentAlgorithm.cc | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml index 86ad8fddc4f4f..8b2e6d2ed3148 100644 --- a/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml +++ b/Alignment/CommonAlignmentProducer/plugins/BuildFile.xml @@ -29,6 +29,7 @@ + diff --git a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc index f3423373e0d5d..2dade05d76c46 100644 --- a/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc +++ b/Alignment/CommonAlignmentProducer/plugins/PCLTrackerAlProducer.cc @@ -41,6 +41,9 @@ /*** Geometry ***/ #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h" +#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h" +#include "Geometry/Records/interface/PTrackerParametersRcd.h" + #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" @@ -432,7 +435,7 @@ ::initAlignmentAlgorithm(const edm::EventSetup& setup) { // Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; - setup.get().get(tTopoHandle); + setup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); // Create the geometries from the ideal geometries (first time only) @@ -484,8 +487,12 @@ ::createGeometries(const edm::EventSetup& setup) setup.get().get(geometricDet); TrackerGeomBuilderFromGeometricDet trackerBuilder; + + edm::ESHandle ptp; + setup.get().get( ptp ); + theTrackerGeometry = boost::shared_ptr( - trackerBuilder.build(&(*geometricDet), theParameterSet) + trackerBuilder.build(&(*geometricDet), *ptp ) ); } diff --git a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py index f0d898e92915b..f3bbb521a9cf1 100644 --- a/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py +++ b/Alignment/CommonAlignmentProducer/python/TrackerAlignmentProducerForPCL_cff.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -import Geometry.TrackerGeometryBuilder.trackerGeometryConstants_cfi as trackerGeometryConstants_cfi +#import Geometry.TrackerGeometryBuilder.trackerGeometryConstants_cfi as trackerGeometryConstants_cfi # misalignment scenarios from Alignment.TrackerAlignment.Scenarios_cff import * @@ -7,7 +7,7 @@ # algorithms from Alignment.HIPAlignmentAlgorithm.HIPAlignmentAlgorithm_cfi import * from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * -from Alignment.KalmanAlignmentAlgorithm.KalmanAlignmentAlgorithm_cfi import * +#from Alignment.KalmanAlignmentAlgorithm.KalmanAlignmentAlgorithm_cfi import * # parameters from Alignment.CommonAlignmentAlgorithm.AlignmentParameterStore_cfi import * @@ -71,7 +71,7 @@ ), # Tracker constants: different for SLHC pixel topology - trackerGeometryConstants = cms.PSet(trackerGeometryConstants_cfi.trackerGeometryConstants), + #trackerGeometryConstants = cms.PSet(trackerGeometryConstants_cfi.trackerGeometryConstants), # Save alignment to DB: true requires configuration of PoolDBOutputService saveToDB = cms.bool(False), # save alignment? diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc index a29664ec7cc3f..de7991df9b334 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeAlignmentAlgorithm.cc @@ -53,6 +53,7 @@ #include #include #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h" @@ -138,7 +139,7 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, //Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; - setup.get().get(tTopoHandle); + setup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); theAlignableNavigator = new AlignableNavigator(extras, tracker, muon); From 3f508c6add467a191c4c7ba92b85e901d3380db1 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Wed, 29 Jul 2015 19:16:56 +0200 Subject: [PATCH 063/104] address conflicts with the trackrefitter cff --- .../python/ALCARECOPromptCalibProdSiPixelAli_cff.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 071c437e2d62a..0bebc4a859edc 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -57,7 +57,9 @@ # Ingredient: SiPixelAliTrackRefitter0 # refitting -from RecoTracker.TrackProducer.TrackRefitters_cff import * +from RecoTracker.IterativeTracking.InitialStep_cff import * +from RecoTracker.Configuration.RecoTrackerP5_cff import * +from RecoTracker.TrackProducer.TrackRefitter_cfi import * # In the following use # TrackRefitter (normal tracks), TrackRefitterP5 (cosmics) or TrackRefitterBHM (beam halo) From db506f5d0d8d4929a2a283d4b2f2b269b184475f Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 11:44:14 +0200 Subject: [PATCH 064/104] - dynamic strip reconstruction for Yuta - added Loose, Medium and Tight tau ID discriminators with pileup weighted isolation - removal of deprecated tau ID discriminators from pat::Taus --- DataFormats/TauReco/interface/PFTau.h | 15 +- DataFormats/TauReco/interface/RecoTauPiZero.h | 64 ++- DataFormats/TauReco/src/PFTau.cc | 28 +- DataFormats/TauReco/src/RecoTauPiZero.cc | 44 +- DataFormats/TauReco/src/classes_def_2.xml | 20 +- .../python/producersLayer1/tauProducer_cfi.py | 111 ++--- .../PatAlgos/python/tools/tauTools.py | 76 ++-- .../Configuration/python/HPSPFTaus_cff.py | 94 +++- .../RecoTau/interface/RecoTauConstructor.h | 13 +- .../PFRecoTauDiscriminationByHPSSelection.cc | 17 +- .../PFRecoTauDiscriminationByIsolation.cc | 197 ++++++--- .../RecoTauBuilderCombinatoricPlugin.cc | 100 +++-- ...uChargedHadronMultiplicityCleanerPlugin.cc | 50 +++ .../plugins/RecoTauPiZeroStripPlugin2.cc | 15 +- .../plugins/RecoTauPiZeroStripPlugin3.cc | 400 ++++++++++++++++++ ...RecoTauDiscriminationByHPSSelection_cfi.py | 1 - .../PFRecoTauDiscriminationByIsolation_cfi.py | 32 +- .../RecoTau/python/RecoTauCleanerPlugins.py | 5 + .../RecoTau/python/RecoTauCleaner_cfi.py | 57 ++- .../python/RecoTauCombinatoricProducer_cfi.py | 7 +- .../python/RecoTauPiZeroBuilderPlugins_cfi.py | 36 +- .../python/RecoTauPiZeroProducer_cfi.py | 6 +- RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 73 +++- 23 files changed, 1110 insertions(+), 351 deletions(-) create mode 100644 RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc create mode 100644 RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h index 16b374e2450c0..e23dac4143d68 100644 --- a/DataFormats/TauReco/interface/PFTau.h +++ b/DataFormats/TauReco/interface/PFTau.h @@ -148,9 +148,16 @@ class PFTau : public BaseTau { /// Retrieve the identified hadronic decay mode according to the number of /// charged and piZero candidates in the signal cone hadronicDecayMode decayMode() const; - hadronicDecayMode calculateDecayMode() const; void setDecayMode(const hadronicDecayMode&); + /// Effect of eta and phi correction of strip on mass of tau candidate + double bendCorrMass() const { return bendCorrMass_; } + void setBendCorrMass(double bendCorrMass) { bendCorrMass_ = bendCorrMass; } + + /// Size of signal cone + double signalConeSize() const { return signalConeSize_; } + void setSignalConeSize(double signalConeSize) { signalConeSize_ = signalConeSize; } + //Electron rejection float emFraction() const; // Ecal/Hcal Cluster Energy float hcalTotOverPLead() const; // total Hcal Cluster E / leadPFChargedHadron P @@ -192,7 +199,7 @@ class PFTau : public BaseTau { CandidatePtr sourceCandidatePtr( size_type i ) const; /// prints information on this PFTau - void dump(std::ostream& out=std::cout) const; + void dump(std::ostream& out = std::cout) const; private: friend class tau::RecoTauConstructor; @@ -226,6 +233,10 @@ class PFTau : public BaseTau { hadronicDecayMode decayMode_; + float bendCorrMass_; + + float signalConeSize_; + reco::PFJetRef jetRef_; PFTauTagInfoRef PFTauTagInfoRef_; reco::PFCandidatePtr leadPFChargedHadrCand_; diff --git a/DataFormats/TauReco/interface/RecoTauPiZero.h b/DataFormats/TauReco/interface/RecoTauPiZero.h index 244f3077c555d..076d7de5e518d 100644 --- a/DataFormats/TauReco/interface/RecoTauPiZero.h +++ b/DataFormats/TauReco/interface/RecoTauPiZero.h @@ -14,32 +14,57 @@ class RecoTauPiZero : public CompositePtrCandidate { kStrips = 3 }; - RecoTauPiZero():CompositePtrCandidate(),algoName_(kUndefined){ - this->setPdgId(111); } - - RecoTauPiZero(PiZeroAlgorithm algoName): - CompositePtrCandidate(), algoName_(algoName) { this->setPdgId(111); } + RecoTauPiZero() + : CompositePtrCandidate(), + algoName_(kUndefined) + { + this->setPdgId(111); + bendCorrEta_ = 0.; + bendCorrPhi_ = 0.; + } + + RecoTauPiZero(PiZeroAlgorithm algoName) + : CompositePtrCandidate(), + algoName_(algoName) + { + this->setPdgId(111); + bendCorrEta_ = 0.; + bendCorrPhi_ = 0.; + } /// constructor from values RecoTauPiZero(Charge q, const LorentzVector& p4, const Point& vtx = Point( 0, 0, 0 ), int pdgId = 111, int status = 0, bool integerCharge = true, - PiZeroAlgorithm algoName=kUndefined): - CompositePtrCandidate( - q, p4, vtx, pdgId, status, integerCharge ),algoName_(algoName) {} + PiZeroAlgorithm algoName = kUndefined) + : CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge ), + algoName_(algoName) + { + bendCorrEta_ = 0.; + bendCorrPhi_ = 0.; + } /// constructor from values RecoTauPiZero(Charge q, const PolarLorentzVector& p4, const Point& vtx = Point( 0, 0, 0 ), int pdgId = 111, int status = 0, bool integerCharge = true, - PiZeroAlgorithm algoName=kUndefined): - CompositePtrCandidate( - q, p4, vtx, pdgId, status, integerCharge ),algoName_(algoName) {} + PiZeroAlgorithm algoName=kUndefined) + : CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge ), + algoName_(algoName) + { + bendCorrEta_ = 0.; + bendCorrPhi_ = 0.; + } /// constructor from a Candidate - explicit RecoTauPiZero( - const Candidate & p, PiZeroAlgorithm algoName=kUndefined): - CompositePtrCandidate(p),algoName_(algoName) { this->setPdgId(111); } + explicit RecoTauPiZero(const Candidate& p, PiZeroAlgorithm algoName = kUndefined) + : CompositePtrCandidate(p), + algoName_(algoName) + { + this->setPdgId(111); + bendCorrEta_ = 0.; + bendCorrPhi_ = 0.; + } /// destructor ~RecoTauPiZero(){}; @@ -62,11 +87,20 @@ class RecoTauPiZero : public CompositePtrCandidate { /// Check whether a given algo produced this pi zero bool algoIs(PiZeroAlgorithm algo) const; - void print(std::ostream& out=std::cout) const; + /// Size of correction to account for spread of photon energy in eta and phi + /// in case charged pions make nuclear interactions or photons convert within the tracking detector + float bendCorrEta() const { return bendCorrEta_; } + float bendCorrPhi() const { return bendCorrPhi_; } + void setBendCorrEta(float bendCorrEta) { bendCorrEta_ = bendCorrEta; } + void setBendCorrPhi(float bendCorrPhi) { bendCorrPhi_ = bendCorrPhi; } + + void print(std::ostream& out = std::cout) const; private: PiZeroAlgorithm algoName_; + float bendCorrEta_; + float bendCorrPhi_; }; std::ostream & operator<<(std::ostream& out, const RecoTauPiZero& c); diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index f67560341df95..bcc8d35364d9f 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -15,14 +15,15 @@ PFTau::PFTau() hcalTotOverPLead_ = NAN; hcalMaxOverPLead_ = NAN; hcal3x3OverPLead_ = NAN; - ecalStripSumEOverPLead_= NAN; + ecalStripSumEOverPLead_ = NAN; bremsRecoveryEOverPLead_ = NAN; electronPreIDOutput_ = NAN; - electronPreIDDecision_= NAN; + electronPreIDDecision_ = NAN; caloComp_ = NAN; segComp_ = NAN; muonDecision_ = NAN; - decayMode_=kNull; + decayMode_ = kNull; + bendCorrMass_ = 0.; } PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx) @@ -40,12 +41,13 @@ PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx) ecalStripSumEOverPLead_= NAN; bremsRecoveryEOverPLead_ = NAN; electronPreIDOutput_ = NAN; - electronPreIDDecision_= NAN; + electronPreIDDecision_ = NAN; caloComp_ = NAN; segComp_ = NAN; muonDecision_ = NAN; - decayMode_=kNull; + decayMode_ = kNull; + bendCorrMass_ = 0.; } PFTau* PFTau::clone() const { return new PFTau(*this); } @@ -177,22 +179,6 @@ void PFTau::setIsolationTauChargedHadronCandidatesRefs(const PFRecoTauChargedHad PFTau::hadronicDecayMode PFTau::decayMode() const { return decayMode_; } -PFTau::hadronicDecayMode PFTau::calculateDecayMode() const { - unsigned int nCharged = signalTauChargedHadronCandidates().size(); - unsigned int nPiZeros = signalPiZeroCandidates().size(); - // If no tracks exist, this is definitely not a tau! - if ( !nCharged ) return kNull; - // Find the maximum number of PiZeros our parameterization can hold - const unsigned int maxPiZeros = kOneProngNPiZero; - // Determine our track index - unsigned int trackIndex = (nCharged - 1)*(maxPiZeros + 1); - // Check if we handle the given number of tracks - if ( trackIndex >= kRareDecayMode ) return kRareDecayMode; - - if(nPiZeros>maxPiZeros) nPiZeros=maxPiZeros; - return static_cast(trackIndex + nPiZeros); -} - void PFTau::setDecayMode(const PFTau::hadronicDecayMode& dm){ decayMode_=dm;} // Setting information about the isolation region diff --git a/DataFormats/TauReco/src/RecoTauPiZero.cc b/DataFormats/TauReco/src/RecoTauPiZero.cc index 7b5fdf78dc7cb..a347175acc738 100644 --- a/DataFormats/TauReco/src/RecoTauPiZero.cc +++ b/DataFormats/TauReco/src/RecoTauPiZero.cc @@ -1,4 +1,5 @@ #include "DataFormats/TauReco/interface/RecoTauPiZero.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/Math/interface/deltaPhi.h" namespace reco { @@ -55,31 +56,30 @@ bool RecoTauPiZero::algoIs(RecoTauPiZero::PiZeroAlgorithm algo) const { return (algoName_ == algo); } -namespace { -std::ostream& operator<<(std::ostream& out, const reco::Candidate::LorentzVector& p4) +namespace { - out << "(mass/pt/eta/phi) (" << std::setiosflags(std::ios::fixed) << std::setprecision(2) - << p4.mass() << "/" << std::setprecision(1) << p4.pt() << "/" << std::setprecision(2) << p4.eta() - << "/" << std::setprecision(2) << p4.phi() << ")"; - return out; -} + std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) + { + if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; + else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; + else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; + else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; + else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; + else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; + else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; + else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; + else assert(0); + } } -void RecoTauPiZero::print(std::ostream& out) const { - if (!out) return; - - out << "RecoTauPiZero: " << this->p4() << - " nDaughters: " << this->numberOfDaughters() << - " (gamma/e) (" << this->numberOfGammas() << "/" << this->numberOfElectrons() << ")" << - " maxDeltaPhi: " << std::setprecision(3) << maxDeltaPhi() << - " maxDeltaEta: " << std::setprecision(3) << maxDeltaEta() << - " algo: " << algo() << - std::endl; - - for(size_t i = 0; i < this->numberOfDaughters(); ++i) - { - out << "--- daughter " << i << ": " << daughterPtr(i)->p4() << - " key: " << daughterPtr(i).key() << std::endl; +void RecoTauPiZero::print(std::ostream& stream) const +{ + std::cout << "Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi() << std::endl; + size_t numDaughters = this->numberOfDaughters(); + for ( size_t iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) { + const reco::PFCandidate* daughter = dynamic_cast(this->daughterPtr(iDaughter).get()); + std::cout << " daughter #" << iDaughter << " (" << getPFCandidateType(daughter->particleId()) << "):" + << " Pt = " << daughter->pt() << ", eta = " << daughter->eta() << ", phi = " << daughter->phi() << std::endl; } } diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 364601d4fe7c2..e64e3f8ff868c 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -1,19 +1,20 @@ - + + - - - - - - + + + + + + - + @@ -265,7 +266,8 @@ isolationTauChargedHadronCandidates_.clear(); - + + diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index 0e660c704fec0..3551bddd1467e 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -50,42 +50,12 @@ embedIsolationPFGammaCands = cms.bool(False), ## embed in AOD externally stored isolation PFGammaCandidates # embed IsoDeposits - isoDeposits = cms.PSet( - pfAllParticles = cms.InputTag("tauIsoDepositPFCandidates"), - pfChargedHadron = cms.InputTag("tauIsoDepositPFChargedHadrons"), - pfNeutralHadron = cms.InputTag("tauIsoDepositPFNeutralHadrons"), - pfGamma = cms.InputTag("tauIsoDepositPFGammas") - ), + isoDeposits = cms.PSet(), # user defined isolation variables the variables defined here will be accessible # via pat::Tau::userIsolation(IsolationKeys key) with the key as defined in # DataFormats/PatCandidates/interface/Isolation.h - # - # (set Pt thresholds for PFChargedHadrons (PFGammas) to 1.0 (1.5) GeV, - # matching the thresholds used when computing the tau iso. discriminators - # in RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py) - userIsolation = cms.PSet( - pfAllParticles = cms.PSet( - src = cms.InputTag("tauIsoDepositPFCandidates"), - deltaR = cms.double(0.5), - threshold = cms.double(0.) - ), - pfChargedHadron = cms.PSet( - src = cms.InputTag("tauIsoDepositPFChargedHadrons"), - deltaR = cms.double(0.5), - threshold = cms.double(0.) - ), - pfNeutralHadron = cms.PSet( - src = cms.InputTag("tauIsoDepositPFNeutralHadrons"), - deltaR = cms.double(0.5), - threshold = cms.double(0.) - ), - pfGamma = cms.PSet( - src = cms.InputTag("tauIsoDepositPFGammas"), - deltaR = cms.double(0.5), - threshold = cms.double(0.) - ) - ), + userIsolation = cms.PSet(), # tau ID (for efficiency studies) addTauID = cms.bool(True), @@ -95,22 +65,18 @@ # disk space decayModeFinding = cms.InputTag("hpsPFTauDiscriminationByDecayModeFinding"), decayModeFindingNewDMs =cms.InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs"), -# decayModeFindingOldDMs = cms.InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs"), - # byCombinedIsolationDeltaBetaCorrRaw = cms.InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr"), - # byVLooseCombinedIsolationDeltaBetaCorr = cms.InputTag("hpsPFTauDiscriminationByVLooseCombinedIsolationDBSumPtCorr"), - # byLooseCombinedIsolationDeltaBetaCorr = cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr"), - # byMediumCombinedIsolationDeltaBetaCorr = cms.InputTag("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr"), - # byTightCombinedIsolationDeltaBetaCorr = cms.InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr"), - chargedIsoPtSum = cms.InputTag("hpsPFTauMVA3IsolationChargedIsoPtSum"), - neutralIsoPtSum = cms.InputTag("hpsPFTauMVA3IsolationNeutralIsoPtSum"), - puCorrPtSum = cms.InputTag("hpsPFTauMVA3IsolationPUcorrPtSum"), - byIsolationMVA3oldDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw'), - byVLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwoLT'), - byLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwoLT'), - byMediumIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3oldDMwoLT'), - byTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3oldDMwoLT'), - byVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3oldDMwoLT'), - byVVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3oldDMwoLT'), + chargedIsoPtSum = cms.InputTag("hpsPFTauChargedIsoPtSum"), + neutralIsoPtSum = cms.InputTag("hpsPFTauNeutralIsoPtSum"), + puCorrPtSum = cms.InputTag("hpsPFTauPUcorrPtSum"), + footprintCorrection = cms.InputTag("hpsPFTauFootprintCorrection"), + photonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauPhotonPtSumOutsideSignalCone"), + ##byIsolationMVA3oldDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw'), + ##byVLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwoLT'), + ##byLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwoLT'), + ##byMediumIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3oldDMwoLT'), + ##byTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3oldDMwoLT'), + ##byVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3oldDMwoLT'), + ##byVVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3oldDMwoLT'), byIsolationMVA3oldDMwLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwLTraw'), byVLooseIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwLT'), byLooseIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwLT'), @@ -118,13 +84,13 @@ byTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3oldDMwLT'), byVTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3oldDMwLT'), byVVTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3oldDMwLT'), - byIsolationMVA3newDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3newDMwoLTraw'), - byVLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwoLT'), - byLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3newDMwoLT'), - byMediumIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3newDMwoLT'), - byTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3newDMwoLT'), - byVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3newDMwoLT'), - byVVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwoLT'), + ##byIsolationMVA3newDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3newDMwoLTraw'), + ##byVLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwoLT'), + ##byLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3newDMwoLT'), + ##byMediumIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3newDMwoLT'), + ##byTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3newDMwoLT'), + ##byVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3newDMwoLT'), + ##byVVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwoLT'), byIsolationMVA3newDMwLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3newDMwLTraw'), byVLooseIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwLT'), byLooseIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3newDMwLT'), @@ -132,25 +98,30 @@ byTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3newDMwLT'), byVTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3newDMwLT'), byVVTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwLT'), - againstElectronLoose = cms.InputTag("hpsPFTauDiscriminationByLooseElectronRejection"), - againstElectronMedium = cms.InputTag("hpsPFTauDiscriminationByMediumElectronRejection"), - againstElectronTight = cms.InputTag("hpsPFTauDiscriminationByTightElectronRejection"), - againstMuonLoose = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection"), - againstMuonMedium = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection"), - againstMuonTight = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection"), - againstMuonLoose2 = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection2"), - againstMuonMedium2 = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection2"), - againstMuonTight2 = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection2"), + ##againstElectronLoose = cms.InputTag("hpsPFTauDiscriminationByLooseElectronRejection"), + ##againstElectronMedium = cms.InputTag("hpsPFTauDiscriminationByMediumElectronRejection"), + ##againstElectronTight = cms.InputTag("hpsPFTauDiscriminationByTightElectronRejection"), + ##againstMuonLoose = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection"), + ##againstMuonMedium = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection"), + ##againstMuonTight = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection"), + ##againstMuonLoose2 = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection2"), + ##againstMuonMedium2 = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection2"), + ##againstMuonTight2 = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection2"), againstMuonLoose3 = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection3"), againstMuonTight3 = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection3"), - againstMuonMVAraw = cms.InputTag('hpsPFTauDiscriminationByMVArawMuonRejection'), - againstMuonLooseMVA = cms.InputTag('hpsPFTauDiscriminationByMVALooseMuonRejection'), - againstMuonMediumMVA = cms.InputTag('hpsPFTauDiscriminationByMVAMediumMuonRejection'), - againstMuonTightMVA = cms.InputTag('hpsPFTauDiscriminationByMVATightMuonRejection'), - byCombinedIsolationDeltaBetaCorrRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), + ##againstMuonMVAraw = cms.InputTag('hpsPFTauDiscriminationByMVArawMuonRejection'), + ##againstMuonLooseMVA = cms.InputTag('hpsPFTauDiscriminationByMVALooseMuonRejection'), + ##againstMuonMediumMVA = cms.InputTag('hpsPFTauDiscriminationByMVAMediumMuonRejection'), + ##againstMuonTightMVA = cms.InputTag('hpsPFTauDiscriminationByMVATightMuonRejection'), byLooseCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"), byMediumCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"), byTightCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"), + byCombinedIsolationDeltaBetaCorrRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), + byLoosePileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByLoosePileupWeightedIsolationDBSum3Hits"), + byMediumPileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits"), + byTightPileupWeightedIsolationHits = cms.InputTag("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"), + byPhotonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone"), + byPileupWeightedIsolationRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits"), againstElectronMVA5raw = cms.InputTag("hpsPFTauDiscriminationByMVA5rawElectronRejection"), againstElectronMVA5category = cms.InputTag("hpsPFTauDiscriminationByMVA5rawElectronRejection:category"), againstElectronVLooseMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5VLooseElectronRejection"), @@ -158,7 +129,7 @@ againstElectronMediumMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5MediumElectronRejection"), againstElectronTightMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5TightElectronRejection"), againstElectronVTightMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5VTightElectronRejection"), -# againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejection"), + ##againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejection"), ), # mc matching configurables diff --git a/PhysicsTools/PatAlgos/python/tools/tauTools.py b/PhysicsTools/PatAlgos/python/tools/tauTools.py index 167dce4cfe9b6..27aa7451c11ae 100644 --- a/PhysicsTools/PatAlgos/python/tools/tauTools.py +++ b/PhysicsTools/PatAlgos/python/tools/tauTools.py @@ -102,28 +102,28 @@ def _switchToPFTau(process, # Hadron-plus-strip(s) (HPS) Tau Discriminators hpsTauIDSources = [ ("decayModeFindingNewDMs", "DiscriminationByDecayModeFindingNewDMs"), - ("decayModeFindingOldDMs", "DiscriminationByDecayModeFindingOldDMs"), ("decayModeFinding", "DiscriminationByDecayModeFinding"), # CV: kept for backwards compatibility - ("byLooseIsolation", "DiscriminationByLooseIsolation"), - ("byVLooseCombinedIsolationDeltaBetaCorr", "DiscriminationByVLooseCombinedIsolationDBSumPtCorr"), - ("byLooseCombinedIsolationDeltaBetaCorr", "DiscriminationByLooseCombinedIsolationDBSumPtCorr"), - ("byMediumCombinedIsolationDeltaBetaCorr", "DiscriminationByMediumCombinedIsolationDBSumPtCorr"), - ("byTightCombinedIsolationDeltaBetaCorr", "DiscriminationByTightCombinedIsolationDBSumPtCorr"), - ("byCombinedIsolationDeltaBetaCorrRaw", "DiscriminationByRawCombinedIsolationDBSumPtCorr"), ("byLooseCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"), ("byMediumCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"), ("byTightCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"), ("byCombinedIsolationDeltaBetaCorrRaw3Hits", "DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), - ("chargedIsoPtSum", "MVA3IsolationChargedIsoPtSum"), - ("neutralIsoPtSum", "MVA3IsolationNeutralIsoPtSum"), - ("puCorrPtSum", "MVA3IsolationPUcorrPtSum"), - ("byIsolationMVA3oldDMwoLTraw", "DiscriminationByIsolationMVA3oldDMwoLTraw"), - ("byVLooseIsolationMVA3oldDMwoLT", "DiscriminationByVLooseIsolationMVA3oldDMwoLT"), - ("byLooseIsolationMVA3oldDMwoLT", "DiscriminationByLooseIsolationMVA3oldDMwoLT"), - ("byMediumIsolationMVA3oldDMwoLT", "DiscriminationByMediumIsolationMVA3oldDMwoLT"), - ("byTightIsolationMVA3oldDMwoLT", "DiscriminationByTightIsolationMVA3oldDMwoLT"), - ("byVTightIsolationMVA3oldDMwoLT", "DiscriminationByVTightIsolationMVA3oldDMwoLT"), - ("byVVTightIsolationMVA3oldDMwoLT", "DiscriminationByVVTightIsolationMVA3oldDMwoLT"), + ("byLoosePileupWeightedIsolation3Hits", "DiscriminationByLoosePileupWeightedIsolationDBSum3Hits"), + ("byMediumPileupWeightedIsolation3Hits", "DiscriminationByMediumPileupWeightedIsolation3Hits"), + ("byTightPileupWeightedIsolationHits", "DiscriminationByTightPileupWeightedIsolation3Hits"), + ("byPhotonPtSumOutsideSignalCone", "DiscriminationByPhotonPtSumOutsideSignalCone"), + ("byPileupWeightedIsolationRaw3Hits", "DiscriminationByRawPileupWeightedIsolation3Hits"), + ("chargedIsoPtSum", "ChargedIsoPtSum"), + ("neutralIsoPtSum", "NeutralIsoPtSum"), + ("puCorrPtSum", "PUcorrPtSum"), + ("footprintCorrection", "FootprintCorrection"), + ("photonPtSumOutsideSignalCone", "PhotonPtSumOutsideSignalCone"), + ##("byIsolationMVA3oldDMwoLTraw", "DiscriminationByIsolationMVA3oldDMwoLTraw"), + ##("byVLooseIsolationMVA3oldDMwoLT", "DiscriminationByVLooseIsolationMVA3oldDMwoLT"), + ##("byLooseIsolationMVA3oldDMwoLT", "DiscriminationByLooseIsolationMVA3oldDMwoLT"), + ##("byMediumIsolationMVA3oldDMwoLT", "DiscriminationByMediumIsolationMVA3oldDMwoLT"), + ##("byTightIsolationMVA3oldDMwoLT", "DiscriminationByTightIsolationMVA3oldDMwoLT"), + ##("byVTightIsolationMVA3oldDMwoLT", "DiscriminationByVTightIsolationMVA3oldDMwoLT"), + ##("byVVTightIsolationMVA3oldDMwoLT", "DiscriminationByVVTightIsolationMVA3oldDMwoLT"), ("byIsolationMVA3oldDMwLTraw", "DiscriminationByIsolationMVA3oldDMwLTraw"), ("byVLooseIsolationMVA3oldDMwLT", "DiscriminationByVLooseIsolationMVA3oldDMwLT"), ("byLooseIsolationMVA3oldDMwLT", "DiscriminationByLooseIsolationMVA3oldDMwLT"), @@ -132,12 +132,12 @@ def _switchToPFTau(process, ("byVTightIsolationMVA3oldDMwLT", "DiscriminationByVTightIsolationMVA3oldDMwLT"), ("byVVTightIsolationMVA3oldDMwLT", "DiscriminationByVVTightIsolationMVA3oldDMwLT"), ("byIsolationMVA3newDMwoLTraw", "DiscriminationByIsolationMVA3newDMwoLTraw"), - ("byVLooseIsolationMVA3newDMwoLT", "DiscriminationByVLooseIsolationMVA3newDMwoLT"), - ("byLooseIsolationMVA3newDMwoLT", "DiscriminationByLooseIsolationMVA3newDMwoLT"), - ("byMediumIsolationMVA3newDMwoLT", "DiscriminationByMediumIsolationMVA3newDMwoLT"), - ("byTightIsolationMVA3newDMwoLT", "DiscriminationByTightIsolationMVA3newDMwoLT"), - ("byVTightIsolationMVA3newDMwoLT", "DiscriminationByVTightIsolationMVA3newDMwoLT"), - ("byVVTightIsolationMVA3newDMwoLT", "DiscriminationByVVTightIsolationMVA3newDMwoLT"), + ##("byVLooseIsolationMVA3newDMwoLT", "DiscriminationByVLooseIsolationMVA3newDMwoLT"), + ##("byLooseIsolationMVA3newDMwoLT", "DiscriminationByLooseIsolationMVA3newDMwoLT"), + ##("byMediumIsolationMVA3newDMwoLT", "DiscriminationByMediumIsolationMVA3newDMwoLT"), + ##("byTightIsolationMVA3newDMwoLT", "DiscriminationByTightIsolationMVA3newDMwoLT"), + ##("byVTightIsolationMVA3newDMwoLT", "DiscriminationByVTightIsolationMVA3newDMwoLT"), + ##("byVVTightIsolationMVA3newDMwoLT", "DiscriminationByVVTightIsolationMVA3newDMwoLT"), ("byIsolationMVA3newDMwLTraw", "DiscriminationByIsolationMVA3newDMwLTraw"), ("byVLooseIsolationMVA3newDMwLT", "DiscriminationByVLooseIsolationMVA3newDMwLT"), ("byLooseIsolationMVA3newDMwLT", "DiscriminationByLooseIsolationMVA3newDMwLT"), @@ -145,9 +145,9 @@ def _switchToPFTau(process, ("byTightIsolationMVA3newDMwLT", "DiscriminationByTightIsolationMVA3newDMwLT"), ("byVTightIsolationMVA3newDMwLT", "DiscriminationByVTightIsolationMVA3newDMwLT"), ("byVVTightIsolationMVA3newDMwLT", "DiscriminationByVVTightIsolationMVA3newDMwLT"), - ("againstElectronLoose", "DiscriminationByLooseElectronRejection"), - ("againstElectronMedium", "DiscriminationByMediumElectronRejection"), - ("againstElectronTight", "DiscriminationByTightElectronRejection"), + ##("againstElectronLoose", "DiscriminationByLooseElectronRejection"), + ##("againstElectronMedium", "DiscriminationByMediumElectronRejection"), + ##("againstElectronTight", "DiscriminationByTightElectronRejection"), ("againstElectronMVA5raw", "DiscriminationByMVA5rawElectronRejection"), ("againstElectronMVA5category", "DiscriminationByMVA5rawElectronRejection:category"), ("againstElectronVLooseMVA5", "DiscriminationByMVA5VLooseElectronRejection"), @@ -155,20 +155,20 @@ def _switchToPFTau(process, ("againstElectronMediumMVA5", "DiscriminationByMVA5MediumElectronRejection"), ("againstElectronTightMVA5", "DiscriminationByMVA5TightElectronRejection"), ("againstElectronVTightMVA5", "DiscriminationByMVA5VTightElectronRejection"), - ("againstElectronDeadECAL", "DiscriminationByDeadECALElectronRejection"), - ("againstMuonLoose", "DiscriminationByLooseMuonRejection"), - ("againstMuonMedium", "DiscriminationByMediumMuonRejection"), - ("againstMuonTight", "DiscriminationByTightMuonRejection"), - ("againstMuonLoose2", "DiscriminationByLooseMuonRejection2"), - ("againstMuonMedium2", "DiscriminationByMediumMuonRejection2"), - ("againstMuonTight2", "DiscriminationByTightMuonRejection2"), + ##("againstElectronDeadECAL", "DiscriminationByDeadECALElectronRejection"), + ##("againstMuonLoose", "DiscriminationByLooseMuonRejection"), + ##("againstMuonMedium", "DiscriminationByMediumMuonRejection"), + ##("againstMuonTight", "DiscriminationByTightMuonRejection"), + ##("againstMuonLoose2", "DiscriminationByLooseMuonRejection2"), + ##("againstMuonMedium2", "DiscriminationByMediumMuonRejection2"), + ##("againstMuonTight2", "DiscriminationByTightMuonRejection2"), ("againstMuonLoose3", "DiscriminationByLooseMuonRejection3"), ("againstMuonTight3", "DiscriminationByTightMuonRejection3"), - ("againstMuonMVAraw", "DiscriminationByMVArawMuonRejection"), - ("againstMuonLooseMVA", "DiscriminationByMVALooseMuonRejection"), - ("againstMuonMediumMVA", "DiscriminationByMVAMediumMuonRejection"), - ("againstMuonTightMVA", "DiscriminationByMVATightMuonRejection") ] - + ##("againstMuonMVAraw", "DiscriminationByMVArawMuonRejection"), + ##("againstMuonLooseMVA", "DiscriminationByMVALooseMuonRejection"), + ##("againstMuonMediumMVA", "DiscriminationByMVAMediumMuonRejection"), + ##("againstMuonTightMVA", "DiscriminationByMVATightMuonRejection") + ] # switch to PFTau collection produced for fixed dR = 0.07 signal cone size def switchToPFTauFixedCone(process, diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index 62c2dce2c1c6e..837522ce831f5 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -108,7 +108,7 @@ applyOccupancyCut = False, applySumPtCut = True, ) -hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr.maximumSumPtCut=hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt +hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr.maximumSumPtCut = hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr = hpsPFTauDiscriminationByLooseIsolation.clone( deltaBetaPUTrackPtCutOverride = cms.double(0.5), @@ -118,7 +118,7 @@ applyOccupancyCut = False, applySumPtCut = True, ) -hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr.maximumSumPtCut=hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt +hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr.maximumSumPtCut = hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr = hpsPFTauDiscriminationByMediumIsolation.clone( deltaBetaPUTrackPtCutOverride = cms.double(0.5), @@ -128,7 +128,7 @@ applyOccupancyCut = False, applySumPtCut = True, ) -hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr.maximumSumPtCut=hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt +hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr.maximumSumPtCut = hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt hpsPFTauDiscriminationByTightIsolationDBSumPtCorr = hpsPFTauDiscriminationByTightIsolation.clone( deltaBetaPUTrackPtCutOverride = cms.double(0.5), @@ -138,7 +138,7 @@ applyOccupancyCut = False, applySumPtCut = True, ) -hpsPFTauDiscriminationByTightIsolationDBSumPtCorr.maximumSumPtCut=hpsPFTauDiscriminationByTightIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt +hpsPFTauDiscriminationByTightIsolationDBSumPtCorr.maximumSumPtCut = hpsPFTauDiscriminationByTightIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minGammaEt hpsPFTauDiscriminationByIsolationSeqDBSumPtCorr = cms.Sequence( hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr* @@ -549,18 +549,58 @@ hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits ) +hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits = hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.clone( + ApplyDiscriminationByECALIsolation = cms.bool(False), + ApplyDiscriminationByWeightedECALIsolation = cms.bool(True), + UseAllPFCandsForWeights = cms.bool(True), + applyFootprintCorrection = cms.bool(True), + applyPhotonPtSumOutsideSignalConeCut = cms.bool(True) +) + +hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits = hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits.clone( + maximumSumPtCut = hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits.maximumSumPtCut +) + +hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits = hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits.clone( + maximumSumPtCut = hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits.maximumSumPtCut +) + +hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone = hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits.clone( + applySumPtCut = cms.bool(False) +) + +hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits = hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits.clone( + Prediscriminants = cms.PSet( + BooleanOperator = cms.string("and"), + decayMode = cms.PSet( + Producer = cms.InputTag('hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone'), + cut = cms.double(0.5) + ) + ), + applySumPtCut = cms.bool(False), + storeRawSumPt = cms.bool(True) +) + +hpsPFTauDiscriminationByPileupWeightedIsolationSeq3Hits = cms.Sequence( + hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone* + hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits +) + # Define the HPS selection discriminator used in cleaning hpsSelectionDiscriminator.PFTauProducer = cms.InputTag("combinatoricRecoTaus") from RecoTauTag.RecoTau.RecoTauCleaner_cfi import RecoTauCleaner -hpsPFTauProducerSansRefs=RecoTauCleaner.clone( - src=cms.InputTag("combinatoricRecoTaus") +hpsPFTauProducerSansRefs = RecoTauCleaner.clone( + src = cms.InputTag("combinatoricRecoTaus") ) from RecoTauTag.RecoTau.RecoTauPiZeroUnembedder_cfi import RecoTauPiZeroUnembedder -hpsPFTauProducer=RecoTauPiZeroUnembedder.clone( - src = cms.InputTag("hpsPFTauProducerSansRefs") +hpsPFTauProducer = RecoTauPiZeroUnembedder.clone( + src = cms.InputTag("hpsPFTauProducerSansRefs") ) @@ -604,7 +644,7 @@ ) from RecoTauTag.RecoTau.PFRecoTauDiscriminationByMVAIsolation2_cff import * -hpsPFTauMVA3IsolationChargedIsoPtSum = hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.clone( +hpsPFTauChargedIsoPtSum = hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.clone( PFTauProducer = cms.InputTag('hpsPFTauProducer'), Prediscriminants = requireDecayMode.clone(), ApplyDiscriminationByECALIsolation = cms.bool(False), @@ -617,12 +657,12 @@ isoConeSizeForDeltaBeta = cms.double(0.8), verbosity = cms.int32(0) ) -hpsPFTauMVA3IsolationNeutralIsoPtSum = hpsPFTauMVA3IsolationChargedIsoPtSum.clone( +hpsPFTauNeutralIsoPtSum = hpsPFTauChargedIsoPtSum.clone( ApplyDiscriminationByECALIsolation = cms.bool(True), ApplyDiscriminationByTrackerIsolation = cms.bool(False), verbosity = cms.int32(0) ) -hpsPFTauMVA3IsolationPUcorrPtSum = hpsPFTauMVA3IsolationChargedIsoPtSum.clone( +hpsPFTauPUcorrPtSum = hpsPFTauChargedIsoPtSum.clone( ApplyDiscriminationByECALIsolation = cms.bool(False), ApplyDiscriminationByTrackerIsolation = cms.bool(False), applyDeltaBetaCorrection = cms.bool(True), @@ -630,12 +670,24 @@ storeRawPUsumPt = cms.bool(True), verbosity = cms.int32(0) ) -hpsPFTauMVA3IsolationNeutralIsoPtSumWeight = hpsPFTauMVA3IsolationChargedIsoPtSum.clone( +hpsPFTauNeutralIsoPtSumWeight = hpsPFTauChargedIsoPtSum.clone( ApplyDiscriminationByWeightedECALIsolation = cms.bool(True), ApplyDiscriminationByTrackerIsolation = cms.bool(False), UseAllPFCandsForWeights = cms.bool(True), verbosity = cms.int32(0) ) +hpsPFTauFootprintCorrection = hpsPFTauChargedIsoPtSum.clone( + ApplyDiscriminationByTrackerIsolation = cms.bool(False), + storeRawSumPt = cms.bool(False), + storeRawFootprintCorrection = cms.bool(True), + verbosity = cms.int32(0) +) +hpsPFTauPhotonPtSumOutsideSignalCone = hpsPFTauChargedIsoPtSum.clone( + ApplyDiscriminationByTrackerIsolation = cms.bool(False), + storeRawSumPt = cms.bool(False), + storeRawPhotonSumPt_outsideSignalCone = cms.bool(True), + verbosity = cms.int32(0) +) hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw = discriminationByIsolationMVA2raw.clone( PFTauProducer = cms.InputTag('hpsPFTauProducer'), @@ -644,9 +696,9 @@ mvaName = cms.string("RecoTauTag_tauIdMVAoldDMwoLTv1"), mvaOpt = cms.string("oldDMwoLT"), srcTauTransverseImpactParameters = cms.InputTag('hpsPFTauTransverseImpactParameters'), - srcChargedIsoPtSum = cms.InputTag('hpsPFTauMVA3IsolationChargedIsoPtSum'), - srcNeutralIsoPtSum = cms.InputTag('hpsPFTauMVA3IsolationNeutralIsoPtSum'), - srcPUcorrPtSum = cms.InputTag('hpsPFTauMVA3IsolationPUcorrPtSum'), + srcChargedIsoPtSum = cms.InputTag('hpsPFTauChargedIsoPtSum'), + srcNeutralIsoPtSum = cms.InputTag('hpsPFTauNeutralIsoPtSum'), + srcPUcorrPtSum = cms.InputTag('hpsPFTauPUcorrPtSum'), verbosity = cms.int32(0) ) hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwoLT = discriminationByIsolationMVA2VLoose.clone( @@ -758,11 +810,12 @@ hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwLT = hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwLT.clone() hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwLT.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAnewDMwLTv1_WPEff40") - hpsPFTauMVAIsolation2Seq = cms.Sequence( - hpsPFTauMVA3IsolationChargedIsoPtSum - + hpsPFTauMVA3IsolationNeutralIsoPtSum - + hpsPFTauMVA3IsolationPUcorrPtSum + hpsPFTauChargedIsoPtSum + + hpsPFTauNeutralIsoPtSum + + hpsPFTauPUcorrPtSum + + hpsPFTauFootprintCorrection + + hpsPFTauPhotonPtSumOutsideSignalCone + hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw + hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwoLT + hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwoLT @@ -813,13 +866,14 @@ #hpsPFTauDiscriminationByIsolationSeqRhoCorr* #hpsPFTauDiscriminationByIsolationSeqCustomRhoCorr* hpsPFTauDiscriminationByIsolationSeqDBSumPtCorr* - + hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr* hpsPFTauDiscriminationByRawChargedIsolationDBSumPtCorr* hpsPFTauDiscriminationByRawGammaIsolationDBSumPtCorr* hpsPFTauDiscriminationByCombinedIsolationSeqDBSumPtCorr* hpsPFTauDiscriminationByCombinedIsolationSeqDBSumPtCorr3Hits* + hpsPFTauDiscriminationByPileupWeightedIsolationSeq3Hits* hpsPFTauDiscriminationByLooseElectronRejection* hpsPFTauDiscriminationByMediumElectronRejection* diff --git a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h index 7fa1345a471a0..1f68ca8a18822 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h +++ b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h @@ -30,6 +30,7 @@ #include "DataFormats/JetReco/interface/PFJetCollection.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" +#include "CommonTools/Utils/interface/StringObjectFunction.h" #include "boost/shared_ptr.hpp" #include @@ -53,7 +54,10 @@ class RecoTauConstructor { /// Constructor with PFCandidate Handle RecoTauConstructor(const PFJetRef& jetRef, const edm::Handle& pfCands, - bool copyGammasFromPiZeros=false); + bool copyGammasFromPiZeros = false, + const StringObjectFunction* signalConeSize = 0, + double minAbsPhotonSumPt_insideSignalCone = 2.5, double minRelPhotonSumPt_insideSignalCone = 0., + double minAbsPhotonSumPt_outsideSignalCone = 1.e+9, double minRelPhotonSumPt_outsideSignalCone = 1.e+9); /* * Code to set leading candidates. These are just wrappers about @@ -133,6 +137,13 @@ class RecoTauConstructor { typedef std::map SortedCollectionMap; bool copyGammas_; + + const StringObjectFunction* signalConeSize_; + double minAbsPhotonSumPt_insideSignalCone_; + double minRelPhotonSumPt_insideSignalCone_; + double minAbsPhotonSumPt_outsideSignalCone_; + double minRelPhotonSumPt_outsideSignalCone_; + // Retrieve collection associated to signal/iso and type std::vector* getCollection(Region region, ParticleType type); SortedListPtr getSortedCollection(Region region, ParticleType type); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index eed957de77242..41f001baf1806 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -47,7 +47,6 @@ class PFRecoTauDiscriminationByHPSSelection : public PFTauDiscriminationProducer typedef std::pair DoublePair; typedef std::map DecayModeCutMap; - TauFunc signalConeFun_; DecayModeCutMap decayModeCuts_; double matchingCone_; double minPt_; @@ -60,8 +59,7 @@ class PFRecoTauDiscriminationByHPSSelection : public PFTauDiscriminationProducer }; PFRecoTauDiscriminationByHPSSelection::PFRecoTauDiscriminationByHPSSelection(const edm::ParameterSet& pset) - : PFTauDiscriminationProducerBase(pset), - signalConeFun_(pset.getParameter("coneSizeFormula")) + : PFTauDiscriminationProducerBase(pset) { // Get the matchign cut matchingCone_ = pset.getParameter("matchingCone"); @@ -217,7 +215,7 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c // Check if tau fails mass cut double maxMass_value = (*massWindow.maxMass_)(*tau); - if ( tauP4.M() > maxMass_value || tauP4.M() < massWindow.minMass_ ) { + if ( !((tauP4.M() - tau->bendCorrMass()) < maxMass_value && (tauP4.M() + tau->bendCorrMass()) > massWindow.minMass_) ) { if ( verbosity_ ) { edm::LogPrint("PFTauByHPSSelect") << " fails tau mass-window cut." ; } @@ -243,7 +241,7 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c } // Check if tau passes cone cut - double cone_size = signalConeFun_(*tau); + double cone_size = tau->signalConeSize(); // Check if any charged objects fail the signal cone cut BOOST_FOREACH(const reco::PFRecoTauChargedHadron& cand, tau->signalTauChargedHadronCandidates()) { if ( verbosity_ ) { @@ -258,10 +256,13 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c } // Now check the pizeros BOOST_FOREACH(const reco::RecoTauPiZero& cand, tau->signalPiZeroCandidates()) { + double dEta = TMath::Max(0., fabs(cand.eta() - tauP4.eta()) - cand.bendCorrEta()); + double dPhi = TMath::Max(0., fabs(cand.phi() - tauP4.phi()) - cand.bendCorrPhi()); + double dR = sqrt(dEta*dEta + dPhi*dPhi); if ( verbosity_ ) { - edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPiZero) = " << deltaR(cand.p4(), tauP4) ; + edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPiZero) = " << dR ; } - if ( deltaR(cand.p4(), tauP4) > cone_size ) { + if ( dR > cone_size ) { if ( verbosity_ ) { edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for strip(s)." ; } @@ -287,7 +288,7 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c } } } - + if ( minPixelHits_ > 0 ) { int numPixelHits = 0; const std::vector& chargedHadrCands = tau->signalPFChargedHadrCands(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 8738f1dbb6cb7..56c43cea2c984 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -4,6 +4,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" #include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" #include "RecoTauTag/RecoTau/interface/ConeTools.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "TMath.h" @@ -56,6 +57,10 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas pset.getParameter("storeRawSumPt") : false; storeRawPUsumPt_ = pset.exists("storeRawPUsumPt") ? pset.getParameter("storeRawPUsumPt") : false; + storeRawFootprintCorrection_ = pset.exists("storeRawFootprintCorrection") ? + pset.getParameter("storeRawFootprintCorrection") : false; + storeRawPhotonSumPt_outsideSignalCone_ = pset.exists("storeRawPhotonSumPt_outsideSignalCone") ? + pset.getParameter("storeRawPhotonSumPt_outsideSignalCone") : false; // Sanity check on requested options. We can't apply cuts and store the // raw output at the same time @@ -77,12 +82,14 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas // Can only store one type int numStoreOptions = 0; - if ( storeRawSumPt_ ) ++numStoreOptions; - if ( storeRawOccupancy_ ) ++numStoreOptions; - if ( storeRawPUsumPt_ ) ++numStoreOptions; + if ( storeRawSumPt_ ) ++numStoreOptions; + if ( storeRawOccupancy_ ) ++numStoreOptions; + if ( storeRawPUsumPt_ ) ++numStoreOptions; + if ( storeRawFootprintCorrection_ ) ++numStoreOptions; + if ( storeRawPhotonSumPt_outsideSignalCone_ ) ++numStoreOptions; if ( numStoreOptions > 1 ) { throw cms::Exception("BadIsoConfig") - << "Both 'store sum pt' and 'store occupancy' options are set." + << "Multiple 'store sum pt' and/or 'store occupancy' options are set." << " These options are mutually exclusive."; } @@ -92,6 +99,22 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas customIsoCone_ = -1; } + applyPhotonPtSumOutsideSignalConeCut_ = pset.getParameter("applyPhotonPtSumOutsideSignalConeCut"); + maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxAbsPhotonSumPt_outsideSignalCone"); + maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxRelPhotonSumPt_outsideSignalCone"); + + applyFootprintCorrection_ = pset.getParameter("applyFootprintCorrection"); + if ( applyFootprintCorrection_ ) { + edm::VParameterSet cfgFootprintCorrections = pset.getParameter("footprintCorrections"); + for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin(); + cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) { + std::string selection = cfgFootprintCorrection->getParameter("selection"); + double offset = cfgFootprintCorrection->getParameter("offset"); + footprintCorrectionType* footprintCorrection = new footprintCorrectionType(selection, offset); + footprintCorrections_.push_back(footprintCorrection); + } + } + // Get the quality cuts specific to the isolation region edm::ParameterSet isolationQCuts = qualityCutsPSet_.getParameterSet( "isolationQualityCuts"); @@ -99,7 +122,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas qcuts_.reset(new tau::RecoTauQualityCuts(isolationQCuts)); vertexAssociator_.reset( - new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); + new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); applyDeltaBeta_ = pset.exists("applyDeltaBetaCorrection") ? pset.getParameter("applyDeltaBetaCorrection") : false; @@ -157,7 +180,13 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas pset.getParameter("verbosity") : 0; } - ~PFRecoTauDiscriminationByIsolation(){} + ~PFRecoTauDiscriminationByIsolation() + { + for ( std::vector::iterator it = footprintCorrections_.begin(); + it != footprintCorrections_.end(); ++it ) { + delete (*it); + } + } void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; double discriminate(const PFTauRef& pfTau) const override; @@ -195,10 +224,29 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas double offsetRelativeSumPt_; double customIsoCone_; + bool applyPhotonPtSumOutsideSignalConeCut_; + double maxAbsPhotonSumPt_outsideSignalCone_; + double maxRelPhotonSumPt_outsideSignalCone_; + + bool applyFootprintCorrection_; + struct footprintCorrectionType + { + footprintCorrectionType(const std::string& selection, double offset) + : selection_(selection), + offset_(offset) + {} + ~footprintCorrectionType() {} + StringCutObjectSelector selection_; + double offset_; + }; + std::vector footprintCorrections_; + // Options to store the raw value in the discriminator instead of boolean pass/fail flag bool storeRawOccupancy_; bool storeRawSumPt_; bool storeRawPUsumPt_; + bool storeRawFootprintCorrection_; + bool storeRawPhotonSumPt_outsideSignalCone_; /* ********************************************************************** **** Pileup Subtraction Parameters *********************************** @@ -360,54 +408,51 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const LogTrace("discriminate") << "After track cuts: " << allPU.size() ; // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc - if(!useAllPFCands_){ - std::vector cleanPU = - pileupQcutsGeneralQCuts_->filterCandRefs(allPU); + if ( !useAllPFCands_ ) { + std::vector cleanPU = + pileupQcutsGeneralQCuts_->filterCandRefs(allPU); std::vector cleanNPU = pileupQcutsGeneralQCuts_->filterCandRefs(allNPU); - LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size() ; - - // Only select PU tracks inside the isolation cone. - DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_); - for(auto const & cand : cleanPU) { - if ( deltaBetaFilter(cand) ) isoPU_.push_back(cand); - } - - for(auto const & cand : cleanNPU) { - if ( deltaBetaFilter(cand) ) chPV_.push_back(cand); + // Only select PU tracks inside the isolation cone. + DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_); + for ( auto const & cand : cleanPU ) { + if ( deltaBetaFilter(cand) ) isoPU_.push_back(cand); + } + + for ( auto const & cand : cleanNPU ) { + if ( deltaBetaFilter(cand) ) chPV_.push_back(cand); } LogTrace("discriminate") << "After cone cuts: " << isoPU_.size() << " " << chPV_.size() ; - }else{ - isoPU_=allPU; - chPV_= allNPU; + } else { + isoPU_ = allPU; + chPV_ = allNPU; } } - if (calculateWeights_) - { - for( auto const & isoObject : isoNeutral_ ) { - if(isoObject->charge() !=0){ - // weight only neutral objects - isoNeutralWeight_.push_back(*isoObject); - continue; - } - - double eta=isoObject->eta(); - double phi=isoObject->phi(); - double sumNPU = 0.5*log(weightedSum(chPV_,eta,phi)); - - double sumPU = 0.5*log(weightedSum(isoPU_,eta,phi)); - PFCandidate neutral = *isoObject; - if (sumNPU+sumPU>0) neutral.setP4(((sumNPU)/(sumNPU+sumPU))*neutral.p4()); - - isoNeutralWeight_.push_back(neutral); - } + if ( calculateWeights_ ) { + for ( auto const & isoObject : isoNeutral_ ) { + if ( isoObject->charge() != 0 ) { + // weight only neutral objects + isoNeutralWeight_.push_back(*isoObject); + continue; } + double eta = isoObject->eta(); + double phi = isoObject->phi(); + double sumNPU = 0.5*log(weightedSum(chPV_, eta, phi)); + + double sumPU = 0.5*log(weightedSum(isoPU_, eta, phi)); + PFCandidate neutral = (*isoObject); + if ( (sumNPU + sumPU) > 0 ) neutral.setP4(((sumNPU)/(sumNPU + sumPU))*neutral.p4()); + + isoNeutralWeight_.push_back(neutral); + } + } + // Check if we want a custom iso cone if ( customIsoCone_ >= 0. ) { DRFilter filter(pfTau->p4(), 0, customIsoCone_); @@ -451,46 +496,59 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const failsOccupancyCut = ( nOccupants > maximumOccupancy_ ); - double totalPt = 0.0; - double puPt = 0.0; + double footprintCorrection_value = 0.; + if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { + for ( std::vector::const_iterator footprintCorrection = footprintCorrections_.begin(); + footprintCorrection != footprintCorrections_.end(); ++footprintCorrection ) { + if ( (*footprintCorrection)->selection_(*pfTau) ) footprintCorrection_value = (*footprintCorrection)->offset_; + } + } + + double totalPt = 0.; + double puPt = 0.; //--- Sum PT requirement if ( applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_ || storeRawPUsumPt_ ) { double chargedPt = 0.0; double neutralPt = 0.0; double weightedNeutralPt = 0.0; - for( auto const & isoObject : isoCharged_ ) { + for ( auto const & isoObject : isoCharged_ ) { chargedPt += isoObject->pt(); } - if(!calculateWeights_){ - for( auto const & isoObject : isoNeutral_ ) { + if ( !calculateWeights_ ) { + for ( auto const & isoObject : isoNeutral_ ) { neutralPt += isoObject->pt(); } - }else{ - for( auto const & isoObject : isoNeutralWeight_){ - weightedNeutralPt+=isoObject.pt(); + } else { + for ( auto const & isoObject : isoNeutralWeight_ ) { + weightedNeutralPt += isoObject.pt(); } } - for( auto const & isoObject : isoPU_ ) { + for ( auto const & isoObject : isoPU_ ) { puPt += isoObject->pt(); } - LogTrace("discriminate") << "chargedPt = " << chargedPt ; - LogTrace("discriminate") << "neutralPt = " << neutralPt ; - LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt ; - LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) << ")" ; - if( calculateWeights_) { + LogTrace("discriminate") << "chargedPt = " << chargedPt ; + LogTrace("discriminate") << "neutralPt = " << neutralPt ; + LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt ; + LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) << ")" ; + + if ( calculateWeights_ ) { neutralPt = weightedNeutralPt; } if ( applyDeltaBeta_ ) { - neutralPt -= deltaBetaFactorThisEvent_*puPt; + neutralPt -= (deltaBetaFactorThisEvent_*puPt); } - + + if ( applyFootprintCorrection_ ) { + neutralPt -= footprintCorrection_value; + } + if ( applyRhoCorrection_ ) { neutralPt -= rhoThisEvent_; } - if ( neutralPt < 0.0 ) { - neutralPt = 0.0; + if ( neutralPt < 0. ) { + neutralPt = 0.; } totalPt = chargedPt + neutralPt; @@ -501,10 +559,25 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const //--- Relative Sum PT requirement failsRelativeSumPtCut = (totalPt > ((pfTau->pt() - offsetRelativeSumPt_)*maximumRelativeSumPt_)); } + + bool failsPhotonPtSumOutsideSignalConeCut = false; + double photonSumPt_outsideSignalCone = 0.; + if ( applyPhotonPtSumOutsideSignalConeCut_ || storeRawPhotonSumPt_outsideSignalCone_ ) { + const std::vector& signalPFGammas = pfTau->signalPFGammaCands(); + for ( std::vector::const_iterator signalPFGamma = signalPFGammas.begin(); + signalPFGamma != signalPFGammas.end(); ++signalPFGamma ) { + double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalPFGamma)->eta(), (*signalPFGamma)->phi()); + if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalPFGamma)->pt(); + } + if ( photonSumPt_outsideSignalCone > maxAbsPhotonSumPt_outsideSignalCone_ || photonSumPt_outsideSignalCone > (maxRelPhotonSumPt_outsideSignalCone_*pfTau->pt()) ) { + failsPhotonPtSumOutsideSignalConeCut = true; + } + } bool fails = (applyOccupancyCut_ && failsOccupancyCut) || (applySumPtCut_ && failsSumPtCut) || - (applyRelativeSumPtCut_ && failsRelativeSumPtCut); + (applyRelativeSumPtCut_ && failsRelativeSumPtCut) || + (applyPhotonPtSumOutsideSignalConeCut_ && failsPhotonPtSumOutsideSignalConeCut); // We did error checking in the constructor, so this is safe. if ( storeRawSumPt_ ) { @@ -515,6 +588,10 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const else return 0.; } else if ( storeRawOccupancy_ ) { return nOccupants; + } else if ( storeRawFootprintCorrection_ ) { + return footprintCorrection_value; + } else if ( storeRawPhotonSumPt_outsideSignalCone_ ) { + return photonSumPt_outsideSignalCone; } else { return (fails ? 0. : 1.); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc index 96edf7b7fc677..5aaaa268b0740 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc @@ -7,6 +7,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h" #include "RecoTauTag/RecoTau/interface/ConeTools.h" +#include "CommonTools/Utils/interface/StringObjectFunction.h" + #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" @@ -14,6 +16,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauConstructor.h" #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" +#include + namespace reco { namespace tau { typedef std::vector ChargedHadronList; @@ -47,13 +51,24 @@ class RecoTauBuilderCombinatoricPlugin : public RecoTauBuilderPlugin }; std::vector decayModesToBuild_; + StringObjectFunction signalConeSize_; + double minAbsPhotonSumPt_insideSignalCone_; + double minRelPhotonSumPt_insideSignalCone_; + double minAbsPhotonSumPt_outsideSignalCone_; + double minRelPhotonSumPt_outsideSignalCone_; + int verbosity_; }; RecoTauBuilderCombinatoricPlugin::RecoTauBuilderCombinatoricPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC) : RecoTauBuilderPlugin(pset, std::move(iC)), qcuts_(pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts")), - isolationConeSize_(pset.getParameter("isolationConeSize")) + isolationConeSize_(pset.getParameter("isolationConeSize")), + signalConeSize_(pset.getParameter("signalConeSize")), + minAbsPhotonSumPt_insideSignalCone_(pset.getParameter("minAbsPhotonSumPt_insideSignalCone")), + minRelPhotonSumPt_insideSignalCone_(pset.getParameter("minRelPhotonSumPt_insideSignalCone")), + minAbsPhotonSumPt_outsideSignalCone_(pset.getParameter("minAbsPhotonSumPt_outsideSignalCone")), + minRelPhotonSumPt_outsideSignalCone_(pset.getParameter("minRelPhotonSumPt_outsideSignalCone")) { typedef std::vector VPSet; const VPSet& decayModes = pset.getParameter("decayModes"); @@ -66,7 +81,7 @@ RecoTauBuilderCombinatoricPlugin::RecoTauBuilderCombinatoricPlugin(const edm::Pa info.maxPiZeros_ = decayMode->getParameter("maxPiZeros"); decayModesToBuild_.push_back(info); } - + verbosity_ = ( pset.exists("verbosity") ) ? pset.getParameter("verbosity") : 0; } @@ -144,17 +159,9 @@ namespace } }; - std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) + double square(double x) { - if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; - else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; - else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; - else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; - else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; - else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; - else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; - else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; - else assert(0); + return x*x; } } @@ -195,20 +202,16 @@ RecoTauBuilderCombinatoricPlugin::operator()( idx = 0; for ( PiZeroList::const_iterator piZero = piZeros.begin(); piZero != piZeros.end(); ++piZero ) { - std::cout << "piZero #" << idx << ": Pt = " << piZero->pt() << ", eta = " << piZero->eta() << ", phi = " << piZero->phi() << std::endl; - size_t numDaughters = piZero->numberOfDaughters(); - for ( size_t iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) { - const reco::PFCandidate* daughter = dynamic_cast(piZero->daughterPtr(iDaughter).get()); - std::cout << " daughter #" << iDaughter << " (" << getPFCandidateType(daughter->particleId()) << "):" - << " Pt = " << daughter->pt() << ", eta = " << daughter->eta() << ", phi = " << daughter->phi() << std::endl; - } + std::cout << "piZero #" << idx << ":" << std::endl; + piZero->print(std::cout); ++idx; } } PFCandPtrs pfchs = qcuts_.filterCandRefs(pfChargedCands(*jet)); PFCandPtrs pfnhs = qcuts_.filterCandRefs(pfCandidates(*jet, reco::PFCandidate::h0)); - + PFCandPtrs pfgammas = qcuts_.filterCandRefs(pfCandidates(*jet, reco::PFCandidate::gamma)); + /// Apply quality cuts to the regional junk around the jet. Note that the /// particle contents of the junk is exclusive to the jet content. PFCandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); @@ -222,8 +225,9 @@ RecoTauBuilderCombinatoricPlugin::operator()( size_t tracksToBuild = decayMode->nCharged_; if ( verbosity_ ) { std::cout << "piZerosToBuild = " << piZerosToBuild << std::endl; + std::cout << "#piZeros = " << piZeros.size() << std::endl; std::cout << "tracksToBuild = " << tracksToBuild << std::endl; - std::cout << "#chargedHadrons = " << chargedHadrons.size() << std::endl; + std::cout << "#chargedHadrons = " << chargedHadrons.size() << std::endl; } // Skip decay mode if jet doesn't have the multiplicity to support it @@ -271,7 +275,10 @@ RecoTauBuilderCombinatoricPlugin::operator()( for ( PiZeroCombo::iterator piZeroCombo = piZeroCombos.begin(); piZeroCombo != piZeroCombos.end(); ++piZeroCombo ) { // Output tau - RecoTauConstructor tau(jet, getPFCands(), true); + RecoTauConstructor tau( + jet, getPFCands(), true, + &signalConeSize_, + minAbsPhotonSumPt_insideSignalCone_, minRelPhotonSumPt_insideSignalCone_, minAbsPhotonSumPt_outsideSignalCone_, minRelPhotonSumPt_outsideSignalCone_); // Reserve space in our collections tau.reserve( RecoTauConstructor::kSignal, @@ -301,6 +308,16 @@ RecoTauBuilderCombinatoricPlugin::operator()( cleanIsolationPiZeros.push_back(precleanedPiZero); } } + if ( verbosity_ ) { + std::cout << "#cleanIsolationPiZeros = " << cleanIsolationPiZeros.size() << std::endl; + int idx = 0; + for ( PiZeroList::const_iterator piZero = cleanIsolationPiZeros.begin(); + piZero != cleanIsolationPiZeros.end(); ++piZero ) { + std::cout << "piZero #" << idx << ":" << std::endl; + piZero->print(std::cout); + ++idx; + } + } // FIXME - are all these reserves okay? will they get propagated to the // dataformat size if they are wrong? @@ -345,7 +362,7 @@ RecoTauBuilderCombinatoricPlugin::operator()( xclean::PredicateAND pfCandFilter_comboChargedHadrons(isolationConeFilter, pfChargedHadronXCleaner_comboChargedHadrons); // 2.) to select neutral PFCandidates within jet xclean::CrossCleanPtrs pfChargedHadronXCleaner_allChargedHadrons(chargedHadrons.begin(), chargedHadrons.end()); - xclean::CrossCleanPtrs piZeroXCleaner(cleanIsolationPiZeros.begin(), cleanIsolationPiZeros.end()); + xclean::CrossCleanPtrs piZeroXCleaner(piZeros.begin(), piZeros.end()); typedef xclean::PredicateAND, xclean::CrossCleanPtrs > pfCandXCleanerType; pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner); // And this cleaning filter predicate with our Iso cone filter @@ -429,6 +446,18 @@ RecoTauBuilderCombinatoricPlugin::operator()( boost::make_filter_iterator( pfChargedJunk, regionalJunk.end(), regionalJunk.end())); + // Add all PFGamma constituents of the jet that are not part of a PiZero + if ( verbosity_ >= 2 ) { + std::cout << "adding isolation PFGammas not considered in PiZeros:" << std::endl; + } + tau.addPFCands( + RecoTauConstructor::kIsolation, RecoTauConstructor::kGamma, + boost::make_filter_iterator( + pfCandFilter_allChargedHadrons, + pfgammas.begin(), pfgammas.end()), + boost::make_filter_iterator( + pfCandFilter_allChargedHadrons, + pfgammas.end(), pfgammas.end())); // Add all gammas that are in the iso cone but weren't in the // orginal PFJet tau.addPFCands( @@ -458,7 +487,30 @@ RecoTauBuilderCombinatoricPlugin::operator()( std::auto_ptr tauPtr = tau.get(true); - if ( primaryVertexRef.isNonnull() ) tauPtr->setVertex(primaryVertexRef->position()); + if ( primaryVertexRef.isNonnull() ) { + tauPtr->setVertex(primaryVertexRef->position()); + } + + double tauEn = tauPtr->energy(); + double tauPz = tauPtr->pz(); + const double chargedPionMass = 0.13957; // GeV + double tauMass = std::max(tauPtr->mass(), chargedPionMass); + double bendCorrMass2 = 0.; + const std::vector& piZeros = tauPtr->signalPiZeroCandidates(); + BOOST_FOREACH( const RecoTauPiZero& piZero, piZeros ) { + double piZeroEn = piZero.energy(); + double piZeroPx = piZero.px(); + double piZeroPy = piZero.py(); + double piZeroPz = piZero.pz(); + double tau_wo_piZeroPx = tauPtr->px() - piZeroPx; + double tau_wo_piZeroPy = tauPtr->py() - piZeroPy; + // CV: Compute effect of varying strip four-vector by eta and phi correction on tau mass + // (derrivative of tau mass by strip eta, phi has been computed using Mathematica) + bendCorrMass2 += square(((piZeroPz*tauEn - piZeroEn*tauPz)/tauMass)*piZero.bendCorrEta()); + bendCorrMass2 += square(((piZeroPy*tau_wo_piZeroPx - piZeroPx*tau_wo_piZeroPy)/tauMass)*piZero.bendCorrPhi()); + } + //edm::LogPrint("RecoTauBuilderCombinatoricPlugin") << "bendCorrMass2 = " << sqrt(bendCorrMass2) << std::endl; + tauPtr->setBendCorrMass(sqrt(bendCorrMass2)); output.push_back(tauPtr); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc new file mode 100644 index 0000000000000..ce8688323ce77 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc @@ -0,0 +1,50 @@ +/* + * RecoTauChargedHadronMultiplicityCleanerPlugin + * + * Author: Christian Veelken, NICPB Tallinn + * + * A reco tau cleaner plugin that ranks the PFTaus by the number of charged hadrons. + */ + +#include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" +#include "DataFormats/TauReco/interface/PFTauDiscriminator.h" + +namespace reco { namespace tau { + +class RecoTauChargedHadronMultiplicityCleanerPlugin : public RecoTauCleanerPlugin +{ + public: + RecoTauChargedHadronMultiplicityCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC); + virtual ~RecoTauChargedHadronMultiplicityCleanerPlugin(){} + + // Get ranking value for a given tau Ref + double operator()(const reco::PFTauRef&) const override; +}; + +RecoTauChargedHadronMultiplicityCleanerPlugin::RecoTauChargedHadronMultiplicityCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC) + : RecoTauCleanerPlugin(pset,std::move(iC)) +{} + +double RecoTauChargedHadronMultiplicityCleanerPlugin::operator()(const reco::PFTauRef& tau) const +{ + // Get the ranking value for this tau. + // N.B. lower value means more "tau like"! + double result = 0.; + const std::vector& chargedHadrons = tau->signalTauChargedHadronCandidates(); + for ( std::vector::const_iterator chargedHadron = chargedHadrons.begin(); + chargedHadron != chargedHadrons.end(); ++chargedHadron ) { + if ( chargedHadron->algo() == PFRecoTauChargedHadron::kChargedPFCandidate ) result -= 8.; + else if ( chargedHadron->algo() == PFRecoTauChargedHadron::kTrack ) result -= 4.; + else if ( chargedHadron->algo() == PFRecoTauChargedHadron::kPFNeutralHadron ) result -= 2.; + else result -= 1.; + } + return result; +} + +}} // end namespace reco::tau + +// Register our plugin +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_EDM_PLUGIN(RecoTauCleanerPluginFactory, + reco::tau::RecoTauChargedHadronMultiplicityCleanerPlugin, + "RecoTauChargedHadronMultiplicityCleanerPlugin"); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index 84bb16d88a94c..df052e5929f9c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -170,15 +170,16 @@ void RecoTauPiZeroStripPlugin2::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs } } -void markCandsInStrip(std::vector& candFlags, const std::set& candIds) +namespace { - for ( std::set::const_iterator candId = candIds.begin(); - candId != candIds.end(); ++candId ) { - candFlags[*candId] = true; + void markCandsInStrip(std::vector& candFlags, const std::set& candIds) + { + for ( std::set::const_iterator candId = candIds.begin(); + candId != candIds.end(); ++candId ) { + candFlags[*candId] = true; + } } -} - -namespace { + inline const reco::TrackBaseRef getTrack(const PFCandidate& cand) { if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc new file mode 100644 index 0000000000000..8616ee0e8c420 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -0,0 +1,400 @@ +/* + * RecoTauPiZeroStripPlugin3 + * + * Merges PFGammas in a PFJet into Candidate piZeros defined as + * strips in eta-phi. + * + * Author: Michail Bachtis (University of Wisconsin) + * + * Code modifications: Evan Friis (UC Davis), + * Christian Veelken (LLR) + * + */ + +#include +#include + +#include "boost/bind.hpp" + +#include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" + +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/TauReco/interface/RecoTauPiZero.h" +#include "DataFormats/JetReco/interface/PFJet.h" +#include "CommonTools/CandUtils/interface/AddFourMomenta.h" +#include "DataFormats/Math/interface/deltaPhi.h" + +#include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" +#include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" +#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" +#include "RecoTauTag/RecoTau/interface/CombinatoricGenerator.h" + +//------------------------------------------------------------------------------- +// CV: the following headers are needed only for debug print-out +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/TrackReco/interface/Track.h" +//------------------------------------------------------------------------------- + +#include "TString.h" +#include "TFormula.h" + +namespace reco { namespace tau { + +namespace { + // Apply a hypothesis on the mass of the strips. + math::XYZTLorentzVector applyMassConstraint( + const math::XYZTLorentzVector& vec,double mass) { + double factor = sqrt(vec.energy()*vec.energy()-mass*mass)/vec.P(); + return math::XYZTLorentzVector( + vec.px()*factor,vec.py()*factor,vec.pz()*factor,vec.energy()); + } +} + +class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin +{ + public: + explicit RecoTauPiZeroStripPlugin3(const edm::ParameterSet&, edm::ConsumesCollector &&iC); + virtual ~RecoTauPiZeroStripPlugin3(); + // Return type is auto_ptr + return_type operator()(const reco::PFJet&) const override; + // Hook to update PV information + virtual void beginEvent() override; + + private: + typedef std::vector PFCandPtrs; + void addCandsToStrip(RecoTauPiZero&, PFCandPtrs&, const std::vector&, std::set&, bool&) const; + + RecoTauVertexAssociator vertexAssociator_; + + RecoTauQualityCuts* qcuts_; + bool applyElecTrackQcuts_; + double minGammaEtStripSeed_; + double minGammaEtStripAdd_; + + double minStripEt_; + + std::vector inputPdgIds_; // type of candidates to clusterize + TFormula* etaAssociationDistance_; // size of strip clustering window in eta direction + TFormula* phiAssociationDistance_; // size of strip clustering window in phi direction + + bool updateStripAfterEachDaughter_; + int maxStripBuildIterations_; + + // Parameters for build strip combinations + bool combineStrips_; + int maxStrips_; + double combinatoricStripMassHypo_; + + AddFourMomenta p4Builder_; + + int verbosity_; +}; + +namespace +{ + TFormula* makeFunction(const std::string& functionName, const edm::ParameterSet& pset) + { + TString formula = pset.getParameter("function"); + formula = formula.ReplaceAll("pT", "x"); + TFormula* function = new TFormula(functionName.data(), formula.Data()); + int numParameter = function->GetNpar(); + for ( int idxParameter = 0; idxParameter < numParameter; ++idxParameter ) { + std::string parameterName = Form("par%i", idxParameter); + double parameter = pset.getParameter(parameterName); + function->SetParameter(idxParameter, parameter); + } + return function; + } +} + +RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC) + : RecoTauPiZeroBuilderPlugin(pset, std::move(iC)), + vertexAssociator_(pset.getParameter("qualityCuts"), std::move(iC)), + qcuts_(0), + etaAssociationDistance_(0), + phiAssociationDistance_(0) +{ + minGammaEtStripSeed_ = pset.getParameter("minGammaEtStripSeed"); + minGammaEtStripAdd_ = pset.getParameter("minGammaEtStripAdd"); + + minStripEt_ = pset.getParameter("minStripEt"); + + edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts"); +//------------------------------------------------------------------------------- +// CV: disable track quality cuts for PFElectronsPFElectron +// (treat PFElectrons like PFGammas for the purpose of building eta-phi strips) + applyElecTrackQcuts_ = pset.getParameter("applyElecTrackQcuts"); + if ( !applyElecTrackQcuts_ ) { + qcuts_pset.addParameter("minTrackPt", std::min(minGammaEtStripSeed_, minGammaEtStripAdd_)); + qcuts_pset.addParameter("maxTrackChi2", 1.e+9); + qcuts_pset.addParameter("maxTransverseImpactParameter", 1.e+9); + qcuts_pset.addParameter("maxDeltaZ", 1.e+9); + qcuts_pset.addParameter("minTrackVertexWeight", -1.); + qcuts_pset.addParameter("minTrackPixelHits", 0); + qcuts_pset.addParameter("minTrackHits", 0); + } +//------------------------------------------------------------------------------- + qcuts_pset.addParameter("minGammaEt", std::min(minGammaEtStripSeed_, minGammaEtStripAdd_)); + qcuts_ = new RecoTauQualityCuts(qcuts_pset); + + inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); + edm::ParameterSet stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistance"); + etaAssociationDistance_ = makeFunction("etaAssociationDistance", stripSize_eta_pset); + edm::ParameterSet stripSize_phi_pset = pset.getParameterSet("stripPhiAssociationDistance"); + phiAssociationDistance_ = makeFunction("phiAssociationDistance", stripSize_phi_pset); + + updateStripAfterEachDaughter_ = pset.getParameter("updateStripAfterEachDaughter"); + maxStripBuildIterations_ = pset.getParameter("maxStripBuildIterations"); + + combineStrips_ = pset.getParameter("makeCombinatoricStrips"); + if ( combineStrips_ ) { + maxStrips_ = pset.getParameter("maxInputStrips"); + combinatoricStripMassHypo_ = pset.getParameter("stripMassWhenCombining"); + } + + verbosity_ = ( pset.exists("verbosity") ) ? + pset.getParameter("verbosity") : 0; +} + +RecoTauPiZeroStripPlugin3::~RecoTauPiZeroStripPlugin3() +{ + delete qcuts_; + delete etaAssociationDistance_; + delete phiAssociationDistance_; +} + +// Update the primary vertex +void RecoTauPiZeroStripPlugin3::beginEvent() +{ + vertexAssociator_.setEvent(*evt()); +} + +void RecoTauPiZeroStripPlugin3::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs& cands, const std::vector& candFlags, + std::set& candIdsCurrentStrip, bool& isCandAdded) const +{ + if ( verbosity_ >= 1 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << ":" ; + } + size_t numCands = cands.size(); + for ( size_t candId = 0; candId < numCands; ++candId ) { + if ( (!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end() ) { // do not include same cand twice + reco::PFCandidatePtr cand = cands[candId]; + double etaAssociationDistance_value = etaAssociationDistance_->Eval(strip.pt()) + etaAssociationDistance_->Eval(cand->pt()); + double phiAssociationDistance_value = phiAssociationDistance_->Eval(strip.pt()) + phiAssociationDistance_->Eval(cand->pt()); + if ( fabs(strip.eta() - cand->eta()) < etaAssociationDistance_value && // check if cand is within eta-phi window centered on strip + fabs(strip.phi() - cand->phi()) < phiAssociationDistance_value ) { + if ( verbosity_ >= 2 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "--> adding PFCand #" << candId << " (" << cand.id() << ":" << cand.key() << "): Et = " << cand->et() << ", eta = " << cand->eta() << ", phi = " << cand->phi() ; + } + strip.addDaughter(cand); + if ( updateStripAfterEachDaughter_ ) p4Builder_.set(strip); + isCandAdded = true; + candIdsCurrentStrip.insert(candId); + } + } + } +} + +namespace +{ + void markCandsInStrip(std::vector& candFlags, const std::set& candIds) + { + for ( std::set::const_iterator candId = candIds.begin(); + candId != candIds.end(); ++candId ) { + candFlags[*candId] = true; + } + } + + inline const reco::TrackBaseRef getTrack(const PFCandidate& cand) + { + if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); + else if ( cand.gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(cand.gsfTrackRef()); + else return reco::TrackBaseRef(); + } +} + +RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(const reco::PFJet& jet) const +{ + if ( verbosity_ >= 1 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << ":" ; + edm::LogPrint("RecoTauPiZeroStripPlugin3") << " minGammaEtStripSeed = " << minGammaEtStripSeed_ ; + edm::LogPrint("RecoTauPiZeroStripPlugin3") << " minGammaEtStripAdd = " << minGammaEtStripAdd_ ; + edm::LogPrint("RecoTauPiZeroStripPlugin3") << " minStripEt = " << minStripEt_ ; + } + + PiZeroVector output; + + // Get the candidates passing our quality cuts + qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); + PFCandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + + // Convert to stl::list to allow fast deletions + PFCandPtrs seedCands; + PFCandPtrs addCands; + int idx = 0; + for ( PFCandPtrs::iterator cand = candsVector.begin(); + cand != candsVector.end(); ++cand ) { + if ( verbosity_ >= 1 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "PFGamma #" << idx << " (" << cand->id() << ":" << cand->key() << "): Et = " << (*cand)->et() << ", eta = " << (*cand)->eta() << ", phi = " << (*cand)->phi() ; + } + if ( (*cand)->et() > minGammaEtStripSeed_ ) { + if ( verbosity_ >= 2 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "--> assigning seedCandId = " << seedCands.size() ; + const reco::TrackBaseRef candTrack = getTrack(*cand); + if ( candTrack.isNonnull() ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "track: Pt = " << candTrack->pt() << " eta = " << candTrack->eta() << ", phi = " << candTrack->phi() << ", charge = " << candTrack->charge() ; + edm::LogPrint("RecoTauPiZeroStripPlugin3") << " (dZ = " << candTrack->dz(vertexAssociator_.associatedVertex(jet)->position()) << ", dXY = " << candTrack->dxy(vertexAssociator_.associatedVertex(jet)->position()) << "," + << " numHits = " << candTrack->hitPattern().numberOfValidTrackerHits() << ", numPxlHits = " << candTrack->hitPattern().numberOfValidPixelHits() << "," + << " chi2 = " << candTrack->normalizedChi2() << ", dPt/Pt = " << (candTrack->ptError()/candTrack->pt()) << ")" ; + } + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," + << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," + << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; + } + seedCands.push_back(*cand); + } else if ( (*cand)->et() > minGammaEtStripAdd_ ) { + if ( verbosity_ >= 2 ) { + edm::LogPrint("RecoTauPiZeroStripPlugin3") << "--> assigning addCandId = " << addCands.size() ; + } + addCands.push_back(*cand); + } + ++idx; + } + + std::vector seedCandFlags(seedCands.size()); // true/false: seedCand is already/not yet included in strip + std::vector addCandFlags(addCands.size()); // true/false: addCand is already/not yet included in strip + + std::set seedCandIdsCurrentStrip; + std::set addCandIdsCurrentStrip; + + size_t idxSeed = 0; + while ( idxSeed < seedCands.size() ) { + if ( verbosity_ >= 2 ) edm::LogPrint("RecoTauPiZeroStripPlugin3") << "processing seed #" << idxSeed ; + + seedCandIdsCurrentStrip.clear(); + addCandIdsCurrentStrip.clear(); + + std::auto_ptr strip(new RecoTauPiZero(*seedCands[idxSeed], RecoTauPiZero::kStrips)); + strip->addDaughter(seedCands[idxSeed]); + seedCandIdsCurrentStrip.insert(idxSeed); + + bool isCandAdded; + int stripBuildIteration = 0; + do { + isCandAdded = false; + + //if ( verbosity_ >= 2 ) edm::LogPrint("RecoTauPiZeroStripPlugin3") << " adding seedCands to strip..." ; + addCandsToStrip(*strip, seedCands, seedCandFlags, seedCandIdsCurrentStrip, isCandAdded); + //if ( verbosity_ >= 2 ) edm::LogPrint("RecoTauPiZeroStripPlugin3") << " adding addCands to strip..." ; + addCandsToStrip(*strip, addCands, addCandFlags, addCandIdsCurrentStrip, isCandAdded); + + if ( !updateStripAfterEachDaughter_ ) p4Builder_.set(*strip); + + ++stripBuildIteration; + } while ( isCandAdded && (stripBuildIteration < maxStripBuildIterations_ || maxStripBuildIterations_ == -1) ); + + if ( strip->et() > minStripEt_ ) { // strip passed Et cuts, add it to the event + if ( verbosity_ >= 2 ) edm::LogPrint("RecoTauPiZeroStripPlugin3") << "Building strip: Et = " << strip->et() << ", eta = " << strip->eta() << ", phi = " << strip->phi() ; + + // Update the vertex + if ( strip->daughterPtr(0).isNonnull() ) strip->setVertex(strip->daughterPtr(0)->vertex()); + output.push_back(strip); + + // Mark daughters as being part of this strip + markCandsInStrip(seedCandFlags, seedCandIdsCurrentStrip); + markCandsInStrip(addCandFlags, addCandIdsCurrentStrip); + } else { // strip failed Et cuts, just skip it + if ( verbosity_ >= 2 ) edm::LogPrint("RecoTauPiZeroStripPlugin3") << "Discarding strip: Et = " << strip->et() << ", eta = " << strip->eta() << ", phi = " << strip->phi() ; + } + + ++idxSeed; + while ( idxSeed < seedCands.size() && seedCandFlags[idxSeed] ) { + ++idxSeed; // fast-forward to next seed cand not yet included in any strip + } + } + + // Check if we want to combine our strips + if ( combineStrips_ && output.size() > 1 ) { + PiZeroVector stripCombinations; + // Sort the output by descending pt + output.sort(output.begin(), output.end(), + boost::bind(&RecoTauPiZero::pt, _1) > + boost::bind(&RecoTauPiZero::pt, _2)); + // Get the end of interesting set of strips to try and combine + PiZeroVector::const_iterator end_iter = takeNElements( + output.begin(), output.end(), maxStrips_); + + // Look at all the combinations + for ( PiZeroVector::const_iterator first = output.begin(); + first != end_iter-1; ++first ) { + for ( PiZeroVector::const_iterator second = first+1; + second != end_iter; ++second ) { + Candidate::LorentzVector firstP4 = first->p4(); + Candidate::LorentzVector secondP4 = second->p4(); + // If we assume a certain mass for each strip apply it here. + firstP4 = applyMassConstraint(firstP4, combinatoricStripMassHypo_); + secondP4 = applyMassConstraint(secondP4, combinatoricStripMassHypo_); + Candidate::LorentzVector totalP4 = firstP4 + secondP4; + // Make our new combined strip + std::auto_ptr combinedStrips( + new RecoTauPiZero(0, totalP4, + Candidate::Point(0, 0, 0), + //111, 10001, true, RecoTauPiZero::kCombinatoricStrips)); + 111, 10001, true, RecoTauPiZero::kUndefined)); + + // Now loop over the strip members + BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, + first->daughterPtrVector()) { + combinedStrips->addDaughter(gamma); + } + BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, + second->daughterPtrVector()) { + combinedStrips->addDaughter(gamma); + } + // Update the vertex + if ( combinedStrips->daughterPtr(0).isNonnull() ) { + combinedStrips->setVertex(combinedStrips->daughterPtr(0)->vertex()); + } + + // Add to our collection of combined strips + stripCombinations.push_back(combinedStrips); + } + } + // When done doing all the combinations, add the combined strips to the + // output. + output.transfer(output.end(), stripCombinations); + } + + // Compute correction to account for spread of photon energy in eta and phi + // in case charged pions make nuclear interactions or photons convert within the tracking detector + for ( PiZeroVector::iterator strip = output.begin(); + strip != output.end(); ++strip ) { + double bendCorrEta = 0.; + double bendCorrPhi = 0.; + double energySum = 0.; + BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, + strip->daughterPtrVector()) { + bendCorrEta += (gamma->energy()*etaAssociationDistance_->Eval(gamma->pt())); + bendCorrPhi += (gamma->energy()*phiAssociationDistance_->Eval(gamma->pt())); + energySum += gamma->energy(); + } + if ( energySum > 1.e-2 ) { + bendCorrEta /= energySum; + bendCorrPhi /= energySum; + } + //std::cout << "stripPt = " << strip->pt() << ": bendCorrEta = " << bendCorrEta << ", bendCorrPhi = " << bendCorrPhi << std::endl; + strip->setBendCorrEta(bendCorrEta); + strip->setBendCorrPhi(bendCorrPhi); + } + + return output.release(); +} +}} // end namespace reco::tau + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_EDM_PLUGIN(RecoTauPiZeroBuilderPluginFactory, + reco::tau::RecoTauPiZeroStripPlugin3, "RecoTauPiZeroStripPlugin3"); diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py index b696df359b875..48f680f011703 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py @@ -66,7 +66,6 @@ Prediscriminants = noPrediscriminants, matchingCone = PFRecoTauPFJetInputs.jetConeSize, minTauPt = cms.double(0.0), - coneSizeFormula = cms.string("max(min(0.1, 3.0/pt()), 0.05)"), decayModes = cms.VPSet( decayMode_1Prong0Pi0, decayMode_1Prong1Pi0, diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py index d395f033c7609..8c9d929732bbf 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py @@ -26,13 +26,16 @@ relativeSumPtCut = cms.double(0.0), relativeSumPtOffset = cms.double(0.0), - qualityCuts = PFTauQualityCuts,# set the standard quality cuts + applyPhotonPtSumOutsideSignalConeCut = cms.bool(False), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.20), + + qualityCuts = PFTauQualityCuts, # set the standard quality cuts # Delta-Beta corrections to remove Pileup applyDeltaBetaCorrection = cms.bool(False), particleFlowSrc = cms.InputTag("particleFlow"), vertexSrc = PFTauQualityCuts.primaryVertexSrc, - # This must correspond to the cone size of the algorithm which built the # tau. (or if customOuterCone option is used, the custom cone size) isoConeSizeForDeltaBeta = cms.double(0.5), @@ -47,6 +50,31 @@ # Uncommenting the parameter below allows this threshold to be overridden. #deltaBetaPUTrackPtCutOverride = cms.double(1.5), + # Tau footprint correction + applyFootprintCorrection = cms.bool(False), + footprintCorrections = cms.VPSet( + cms.PSet( + selection = cms.string("decayMode() = 0"), + offset = cms.double(1.8) + ), + cms.PSet( + selection = cms.string("decayMode() = 1 || decayMode() = 2"), + offset = cms.double(1.5) + ), + cms.PSet( + selection = cms.string("decayMode() = 5"), + offset = cms.double(4.7) + ), + cms.PSet( + selection = cms.string("decayMode() = 6"), + offset = cms.double(1.9) + ), + cms.PSet( + selection = cms.string("decayMode() = 10"), + offset = cms.double(2.0) + ) + ), + # Rho corrections applyRhoCorrection = cms.bool(False), rhoProducer = cms.InputTag("fixedGridRhoFastjetAll"), diff --git a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py index c6bfc1c13f4fa..09687d9dfa2ac 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py @@ -60,6 +60,11 @@ tolerance = cms.double(1.e-2) # CV: consider candidates with almost equal pT to be of the same rank (to avoid sensitivity to rounding errors) ) +chargedHadronMultiplicity = cms.PSet( + name = cms.string("ChargedHadronMultiplicity"), + plugin = cms.string("RecoTauChargedHadronMultiplicityCleanerPlugin") +) + stripMultiplicity = cms.PSet( name = cms.string("StripMultiplicity"), plugin = cms.string("RecoTauStringCleanerPlugin"), diff --git a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py index f990d3c474231..30d65dd479550 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py @@ -2,36 +2,27 @@ import RecoTauTag.RecoTau.RecoTauCleanerPlugins as cleaners -RecoTauCleaner = cms.EDProducer( - "RecoTauCleaner", - src = cms.InputTag("combinatoricRecoTaus"), - cleaners = cms.VPSet( - # Reject taus that have charge == 3 - cleaners.unitCharge, - # Ignore taus reconstructed in pi0 decay modes in which the highest Pt ("leading") pi0 has pt below 2.5 GeV - # (in order to make decay mode reconstruction less sensitive to pile-up) - # NOTE: strips are sorted by decreasing pt - cms.PSet( - name = cms.string("leadStripPtLt2_5"), - plugin = cms.string("RecoTauStringCleanerPlugin"), - selection = cms.string("signalPiZeroCandidates().size() = 0 | signalPiZeroCandidates()[0].pt() > 2.5"), - selectionPassFunction = cms.string("0"), - selectionFailValue = cms.double(1e3) - ), - # Reject taus that are not within DR<0.1 of the jet axis - #cleaners.matchingConeCut, - # Reject taus that fail HPS selections - cms.PSet( - name = cms.string("HPS_Select"), - plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), - src = cms.InputTag("hpsSelectionDiscriminator"), - ), - # CV: Take highes pT tau (use for testing of new high pT tau reconstruction and check if it can become the new default) - cleaners.pt, - # CV: in case two candidates have the same Pt, - # prefer candidates in which PFGammas are part of strips (rather than being merged with PFRecoTauChargedHadrons) - cleaners.stripMultiplicity, - # Take most isolated tau - cleaners.combinedIsolation - ) - ) +RecoTauCleaner = cms.EDProducer("RecoTauCleaner", + src = cms.InputTag("combinatoricRecoTaus"), + cleaners = cms.VPSet( + # Reject taus that have charge == 3 + cleaners.unitCharge, + # Reject taus that are not within DR<0.1 of the jet axis + #cleaners.matchingConeCut, + # Reject taus that fail HPS selections + cms.PSet( + name = cms.string("HPS_Select"), + plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), + src = cms.InputTag("hpsSelectionDiscriminator"), + ), + # CV: prefer 3-prong candidates over 2-prong candidates and 2-prong candidates over 1-prong candidates + cleaners.chargedHadronMultiplicity, + # CV: Take highest pT tau (use for testing of new high pT tau reconstruction and check if it can become the new default) + cleaners.pt, + # CV: in case two candidates have the same Pt, + # prefer candidates in which PFGammas are part of strips (rather than being merged with PFRecoTauChargedHadrons) + cleaners.stripMultiplicity, + # Take most isolated tau + cleaners.combinedIsolation + ) +) diff --git a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py index 8a39046ee66d8..8023b7b429927 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py @@ -83,7 +83,12 @@ combinatoricDecayModeConfigs.config2prong0pi0, combinatoricDecayModeConfigs.config2prong1pi0, combinatoricDecayModeConfigs.config3prong0pi0 - ) + ), + signalConeSize = cms.string("max(min(0.1, 3.0/pt()), 0.05)"), + minAbsPhotonSumPt_insideSignalCone = cms.double(2.5), + minRelPhotonSumPt_insideSignalCone = cms.double(0.10), + minAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), # CV: always require at least some photon energy inside signal cone + minRelPhotonSumPt_outsideSignalCone = cms.double(1.e+9) # for a tau to be reconstructed in a decay mode with pi0s ) combinatoricRecoTaus = cms.EDProducer("RecoTauProducer", diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index fafbeba289195..d8e29335057fd 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -36,9 +36,9 @@ plugin = cms.string("RecoTauPiZeroStripPlugin"), qualityCuts = PFTauQualityCuts, # Clusterize photons and electrons (PF numbering) - stripCandidatesParticleIds = cms.vint32(2, 4), - stripEtaAssociationDistance = cms.double(0.05), - stripPhiAssociationDistance = cms.double(0.2), + stripCandidatesParticleIds = cms.vint32(2, 4), + stripEtaAssociationDistance = cms.double(0.05), + stripPhiAssociationDistance = cms.double(0.2), makeCombinatoricStrips = cms.bool(False) ) @@ -47,9 +47,9 @@ plugin = cms.string("RecoTauPiZeroStripPlugin"), qualityCuts = PFTauQualityCuts, # Clusterize photons and electrons (PF numbering) - stripCandidatesParticleIds = cms.vint32(2, 4), - stripEtaAssociationDistance = cms.double(0.05), - stripPhiAssociationDistance = cms.double(0.2), + stripCandidatesParticleIds = cms.vint32(2, 4), + stripEtaAssociationDistance = cms.double(0.05), + stripPhiAssociationDistance = cms.double(0.2), makeCombinatoricStrips = cms.bool(True), maxInputStrips = cms.int32(5), stripMassWhenCombining = cms.double(0.0), # assume photon like @@ -67,3 +67,27 @@ maxStripBuildIterations = cms.int32(-1) ) +# Produce a "strips" of photons +# with no track quality cuts applied to PFElectrons +# and eta x phi size of strip increasing for low pT photons +modStrips2 = strips.clone( + plugin = cms.string('RecoTauPiZeroStripPlugin3'), + applyElecTrackQcuts = cms.bool(False), + minGammaEtStripSeed = cms.double(0.5), + minGammaEtStripAdd = cms.double(0.), + minStripEt = cms.double(0.5), + # CV: parametrization of strip size in eta and phi determined by Yuta Takahashi, + # chosen to contain 95% of photons from tau decays + stripEtaAssociationDistance = cms.PSet( + function = cms.string("TMath::Max(0.05, [0]*TMath::Power(pT, -[1]))"), + par0 = cms.double(2.15974e-01), + par1 = cms.double(5.14575e-01) + ), + stripPhiAssociationDistance = cms.PSet( + function = cms.string("TMath::Max(0.05, [0]*TMath::Power(pT, -[1]))"), + par0 = cms.double(3.74961e-01), + par1 = cms.double(5.99882e-01) + ), + updateStripAfterEachDaughter = cms.bool(False), + maxStripBuildIterations = cms.int32(-1) +) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py index 3e71ed9f9d487..00b5419b8a260 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py @@ -12,7 +12,8 @@ outputSelection = cms.string('pt > 0'), builders = cms.VPSet( #builders.strips - builders.modStrips + #builders.modStrips + builders.modStrips2 ), ranking = cms.VPSet( ranking.isInStrip @@ -39,7 +40,8 @@ builders = cms.VPSet( builders.combinatoricPhotonPairs, #builders.strips - builders.modStrips + #builders.modStrips + builders.modStrips2 ), ranking = cms.VPSet( ranking.nearPiZeroMassBarrel, # Prefer pi zeros +- 0.05 GeV correct mass diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index 5e724b429ee6f..c5f36486f0765 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -3,6 +3,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" #include "DataFormats/Common/interface/RefToPtr.h" +#include "DataFormats/Math/interface/deltaR.h" + #include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" #include @@ -10,8 +12,17 @@ namespace reco { namespace tau { -RecoTauConstructor::RecoTauConstructor(const PFJetRef& jet, const edm::Handle& pfCands, bool copyGammasFromPiZeros) - : pfCands_(pfCands) +RecoTauConstructor::RecoTauConstructor(const PFJetRef& jet, const edm::Handle& pfCands, + bool copyGammasFromPiZeros, + const StringObjectFunction* signalConeSize, + double minAbsPhotonSumPt_insideSignalCone, double minRelPhotonSumPt_insideSignalCone, + double minAbsPhotonSumPt_outsideSignalCone, double minRelPhotonSumPt_outsideSignalCone) + : signalConeSize_(signalConeSize), + minAbsPhotonSumPt_insideSignalCone_(minAbsPhotonSumPt_insideSignalCone), + minRelPhotonSumPt_insideSignalCone_(minRelPhotonSumPt_insideSignalCone), + minAbsPhotonSumPt_outsideSignalCone_(minAbsPhotonSumPt_outsideSignalCone), + minRelPhotonSumPt_outsideSignalCone_(minRelPhotonSumPt_outsideSignalCone), + pfCands_(pfCands) { // Initialize tau tau_.reset(new PFTau()); @@ -296,6 +307,50 @@ void RecoTauConstructor::sortAndCopyIntoTau() { } } +namespace +{ + PFTau::hadronicDecayMode calculateDecayMode(const reco::PFTau& tau, double dRsignalCone, + double minAbsPhotonSumPt_insideSignalCone, double minRelPhotonSumPt_insideSignalCone, + double minAbsPhotonSumPt_outsideSignalCone, double minRelPhotonSumPt_outsideSignalCone) + { + unsigned int nCharged = tau.signalTauChargedHadronCandidates().size(); + // If no tracks exist, this is definitely not a tau! + if ( !nCharged ) return PFTau::kNull; + + unsigned int nPiZeros = 0; + const std::vector& piZeros = tau.signalPiZeroCandidates(); + for ( std::vector::const_iterator piZero = piZeros.begin(); + piZero != piZeros.end(); ++piZero ) { + double photonSumPt_insideSignalCone = 0.; + double photonSumPt_outsideSignalCone = 0.; + int numPhotons = piZero->numberOfDaughters(); + for ( int idxPhoton = 0; idxPhoton < numPhotons; ++idxPhoton ) { + const reco::Candidate* photon = piZero->daughter(idxPhoton); + double dR = deltaR(photon->p4(), tau.p4()); + if ( dR < dRsignalCone ) { + photonSumPt_insideSignalCone += photon->pt(); + } else { + photonSumPt_outsideSignalCone += photon->pt(); + } + } + if ( photonSumPt_insideSignalCone > minAbsPhotonSumPt_insideSignalCone || photonSumPt_insideSignalCone > (minRelPhotonSumPt_insideSignalCone*tau.pt()) || + photonSumPt_outsideSignalCone > minAbsPhotonSumPt_outsideSignalCone || photonSumPt_outsideSignalCone > (minRelPhotonSumPt_outsideSignalCone*tau.pt()) ) ++nPiZeros; + } + + // Find the maximum number of PiZeros our parameterization can hold + const unsigned int maxPiZeros = PFTau::kOneProngNPiZero; + + // Determine our track index + unsigned int trackIndex = (nCharged - 1)*(maxPiZeros + 1); + + // Check if we handle the given number of tracks + if ( trackIndex >= PFTau::kRareDecayMode ) return PFTau::kRareDecayMode; + + if ( nPiZeros > maxPiZeros ) nPiZeros = maxPiZeros; + return static_cast(trackIndex + nPiZeros); + } +} + std::auto_ptr RecoTauConstructor::get(bool setupLeadingObjects) { LogDebug("TauConstructorGet") << "Start getting" ; @@ -334,14 +389,14 @@ std::auto_ptr RecoTauConstructor::get(bool setupLeadingObjects) // Set P4 tau_->setP4(p4_); -// tau_->setP4( -// sumPFCandP4( -// getCollection(kSignal, kAll)->begin(), -// getCollection(kSignal, kAll)->end() -// ) -// ); + // Set Decay Mode - PFTau::hadronicDecayMode dm = tau_->calculateDecayMode(); + double dRsignalCone = ( signalConeSize_ ) ? (*signalConeSize_)(*tau_) : 0.5; + tau_->setSignalConeSize(dRsignalCone); + PFTau::hadronicDecayMode dm = calculateDecayMode( + *tau_, + dRsignalCone, + minAbsPhotonSumPt_insideSignalCone_, minRelPhotonSumPt_insideSignalCone_, minAbsPhotonSumPt_outsideSignalCone_, minRelPhotonSumPt_outsideSignalCone_); tau_->setDecayMode(dm); LogDebug("TauConstructorGet") << "Pt = " << tau_->pt() << ", eta = " << tau_->eta() << ", phi = " << tau_->phi() << ", mass = " << tau_->mass() << ", dm = " << tau_->decayMode() ; From f36c8f5c9b067a18444da59d29aeaaf765c84547 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 11:58:27 +0200 Subject: [PATCH 065/104] fixed typo in discriminator name --- PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py | 2 +- PhysicsTools/PatAlgos/python/tools/tauTools.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index 3551bddd1467e..bb8119c50d16a 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -117,7 +117,7 @@ byMediumCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"), byTightCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"), byCombinedIsolationDeltaBetaCorrRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), - byLoosePileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByLoosePileupWeightedIsolationDBSum3Hits"), + byLoosePileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits"), byMediumPileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits"), byTightPileupWeightedIsolationHits = cms.InputTag("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"), byPhotonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone"), diff --git a/PhysicsTools/PatAlgos/python/tools/tauTools.py b/PhysicsTools/PatAlgos/python/tools/tauTools.py index 27aa7451c11ae..5282138cc0e4e 100644 --- a/PhysicsTools/PatAlgos/python/tools/tauTools.py +++ b/PhysicsTools/PatAlgos/python/tools/tauTools.py @@ -107,7 +107,7 @@ def _switchToPFTau(process, ("byMediumCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"), ("byTightCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"), ("byCombinedIsolationDeltaBetaCorrRaw3Hits", "DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), - ("byLoosePileupWeightedIsolation3Hits", "DiscriminationByLoosePileupWeightedIsolationDBSum3Hits"), + ("byLoosePileupWeightedIsolation3Hits", "DiscriminationByLoosePileupWeightedIsolation3Hits"), ("byMediumPileupWeightedIsolation3Hits", "DiscriminationByMediumPileupWeightedIsolation3Hits"), ("byTightPileupWeightedIsolationHits", "DiscriminationByTightPileupWeightedIsolation3Hits"), ("byPhotonPtSumOutsideSignalCone", "DiscriminationByPhotonPtSumOutsideSignalCone"), From bbbbd0531e6e570c8ba0b2a8b2fe8f7cfd5fb3ed Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 12:46:26 +0200 Subject: [PATCH 066/104] bug-fix in storing of (raw) footprint correction --- .../PFRecoTauDiscriminationByIsolation.cc | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 56c43cea2c984..0bf1e79732ff3 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -73,12 +73,11 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas } // sanity check2 - can't use weighted and unweighted iso at the same time - if(includeGammas_ && calculateWeights_) - { - throw cms::Exception("BasIsoConfig") - << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' " - << "have been set to true. These options are mutually exclusive."; - } + if ( includeGammas_ && calculateWeights_ ) { + throw cms::Exception("BasIsoConfig") + << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' " + << "have been set to true. These options are mutually exclusive."; + } // Can only store one type int numStoreOptions = 0; @@ -104,7 +103,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxRelPhotonSumPt_outsideSignalCone"); applyFootprintCorrection_ = pset.getParameter("applyFootprintCorrection"); - if ( applyFootprintCorrection_ ) { + if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { edm::VParameterSet cfgFootprintCorrections = pset.getParameter("footprintCorrections"); for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin(); cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) { @@ -153,9 +152,9 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas puFactorizedIsoQCuts.second)); pfCandSrc_ = pset.getParameter("particleFlowSrc"); - pfCand_token=consumes(pfCandSrc_); + pfCand_token = consumes(pfCandSrc_); vertexSrc_ = pset.getParameter("vertexSrc"); - vertex_token=consumes(vertexSrc_); + vertex_token = consumes(vertexSrc_); deltaBetaCollectionCone_ = pset.getParameter( "isoConeSizeForDeltaBeta"); std::string deltaBetaFactorFormula = @@ -508,9 +507,9 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const double puPt = 0.; //--- Sum PT requirement if ( applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_ || storeRawPUsumPt_ ) { - double chargedPt = 0.0; - double neutralPt = 0.0; - double weightedNeutralPt = 0.0; + double chargedPt = 0.; + double neutralPt = 0.; + double weightedNeutralPt = 0.; for ( auto const & isoObject : isoCharged_ ) { chargedPt += isoObject->pt(); } From e48dd87c04c2e1508c8b3d05d2803d0e05422321 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 12:47:19 +0200 Subject: [PATCH 067/104] - store neutral pileup weighted isolation pT sum - bug-fix: disable deltaBeta corrections for pileup weighted isolation discriminators --- RecoTauTag/Configuration/python/HPSPFTaus_cff.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index 837522ce831f5..3711c5fad261f 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -551,6 +551,7 @@ hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits = hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.clone( ApplyDiscriminationByECALIsolation = cms.bool(False), + applyDeltaBetaCorrection = cms.bool(False), ApplyDiscriminationByWeightedECALIsolation = cms.bool(True), UseAllPFCandsForWeights = cms.bool(True), applyFootprintCorrection = cms.bool(True), @@ -814,6 +815,7 @@ hpsPFTauChargedIsoPtSum + hpsPFTauNeutralIsoPtSum + hpsPFTauPUcorrPtSum + + hpsPFTauNeutralIsoPtSumWeight + hpsPFTauFootprintCorrection + hpsPFTauPhotonPtSumOutsideSignalCone + hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw From f3096e7b806c1bf8744ba56d986a22f6ef3ad278 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 12:48:08 +0200 Subject: [PATCH 068/104] added pileup weighted neutral isolation --- PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py | 1 + PhysicsTools/PatAlgos/python/tools/tauTools.py | 1 + 2 files changed, 2 insertions(+) diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index bb8119c50d16a..1fd5fee7f38d2 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -68,6 +68,7 @@ chargedIsoPtSum = cms.InputTag("hpsPFTauChargedIsoPtSum"), neutralIsoPtSum = cms.InputTag("hpsPFTauNeutralIsoPtSum"), puCorrPtSum = cms.InputTag("hpsPFTauPUcorrPtSum"), + neutralIsoPtSumWeight = cms.InputTag("hpsPFTauNeutralIsoPtSumWeight"), footprintCorrection = cms.InputTag("hpsPFTauFootprintCorrection"), photonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauPhotonPtSumOutsideSignalCone"), ##byIsolationMVA3oldDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw'), diff --git a/PhysicsTools/PatAlgos/python/tools/tauTools.py b/PhysicsTools/PatAlgos/python/tools/tauTools.py index 5282138cc0e4e..053e03654bb66 100644 --- a/PhysicsTools/PatAlgos/python/tools/tauTools.py +++ b/PhysicsTools/PatAlgos/python/tools/tauTools.py @@ -115,6 +115,7 @@ def _switchToPFTau(process, ("chargedIsoPtSum", "ChargedIsoPtSum"), ("neutralIsoPtSum", "NeutralIsoPtSum"), ("puCorrPtSum", "PUcorrPtSum"), + ("neutralIsoPtSumWeight", "NeutralIsoPtSumWeight"), ("footprintCorrection", "FootprintCorrection"), ("photonPtSumOutsideSignalCone", "PhotonPtSumOutsideSignalCone"), ##("byIsolationMVA3oldDMwoLTraw", "DiscriminationByIsolationMVA3oldDMwoLTraw"), From 92cf37eaa128fc23022850cc799059aff72b5735 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 May 2015 12:54:16 +0200 Subject: [PATCH 069/104] fixed typo in discriminator name --- PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py | 2 +- PhysicsTools/PatAlgos/python/tools/tauTools.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index 1fd5fee7f38d2..39177b9f29d1a 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -120,7 +120,7 @@ byCombinedIsolationDeltaBetaCorrRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), byLoosePileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits"), byMediumPileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits"), - byTightPileupWeightedIsolationHits = cms.InputTag("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"), + byTightPileupWeightedIsolation3Hits = cms.InputTag("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"), byPhotonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone"), byPileupWeightedIsolationRaw3Hits = cms.InputTag("hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits"), againstElectronMVA5raw = cms.InputTag("hpsPFTauDiscriminationByMVA5rawElectronRejection"), diff --git a/PhysicsTools/PatAlgos/python/tools/tauTools.py b/PhysicsTools/PatAlgos/python/tools/tauTools.py index 053e03654bb66..5680a4e840492 100644 --- a/PhysicsTools/PatAlgos/python/tools/tauTools.py +++ b/PhysicsTools/PatAlgos/python/tools/tauTools.py @@ -109,7 +109,7 @@ def _switchToPFTau(process, ("byCombinedIsolationDeltaBetaCorrRaw3Hits", "DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"), ("byLoosePileupWeightedIsolation3Hits", "DiscriminationByLoosePileupWeightedIsolation3Hits"), ("byMediumPileupWeightedIsolation3Hits", "DiscriminationByMediumPileupWeightedIsolation3Hits"), - ("byTightPileupWeightedIsolationHits", "DiscriminationByTightPileupWeightedIsolation3Hits"), + ("byTightPileupWeightedIsolation3Hits", "DiscriminationByTightPileupWeightedIsolation3Hits"), ("byPhotonPtSumOutsideSignalCone", "DiscriminationByPhotonPtSumOutsideSignalCone"), ("byPileupWeightedIsolationRaw3Hits", "DiscriminationByRawPileupWeightedIsolation3Hits"), ("chargedIsoPtSum", "ChargedIsoPtSum"), From db7a7501e9accae5abcd50d9e6a65c70aad74b76 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 24 May 2015 18:03:57 +0200 Subject: [PATCH 070/104] updated parameters for dynamic strip reconstruction --- .../python/RecoTauPiZeroBuilderPlugins_cfi.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index d8e29335057fd..5a6ed014f35d3 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -70,24 +70,24 @@ # Produce a "strips" of photons # with no track quality cuts applied to PFElectrons # and eta x phi size of strip increasing for low pT photons -modStrips2 = strips.clone( - plugin = cms.string('RecoTauPiZeroStripPlugin3'), - applyElecTrackQcuts = cms.bool(False), - minGammaEtStripSeed = cms.double(0.5), - minGammaEtStripAdd = cms.double(0.), - minStripEt = cms.double(0.5), - # CV: parametrization of strip size in eta and phi determined by Yuta Takahashi, - # chosen to contain 95% of photons from tau decays - stripEtaAssociationDistance = cms.PSet( - function = cms.string("TMath::Max(0.05, [0]*TMath::Power(pT, -[1]))"), - par0 = cms.double(2.15974e-01), - par1 = cms.double(5.14575e-01) - ), - stripPhiAssociationDistance = cms.PSet( - function = cms.string("TMath::Max(0.05, [0]*TMath::Power(pT, -[1]))"), - par0 = cms.double(3.74961e-01), - par1 = cms.double(5.99882e-01) - ), - updateStripAfterEachDaughter = cms.bool(False), - maxStripBuildIterations = cms.int32(-1) +modStrips2 = strips.clone( + plugin = cms.string('RecoTauPiZeroStripPlugin3'), + applyElecTrackQcuts = cms.bool(False), + minGammaEtStripSeed = cms.double(0.5), + minGammaEtStripAdd = cms.double(0.), + minStripEt = cms.double(0.5), + # CV: parametrization of strip size in eta and phi determined by Yuta Takahashi, + # chosen to contain 95% of photons from tau decays + stripEtaAssociationDistance = cms.PSet( + function = cms.string("TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"), + par0 = cms.double(1.97077e-01), + par1 = cms.double(6.58701e-01) + ), + stripPhiAssociationDistance = cms.PSet( + function = cms.string("TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"), + par0 = cms.double(3.52476e-01), + par1 = cms.double(7.07716e-01) + ), + updateStripAfterEachDaughter = cms.bool(False), + maxStripBuildIterations = cms.int32(-1) ) From d3677b75af934d38003142db56d42327d00a879d Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 1 Jun 2015 12:27:34 +0200 Subject: [PATCH 071/104] sutract 2 GeV from k offset values (except for 3prong0pi0), as recommended by Yuta --- .../python/PFRecoTauDiscriminationByIsolation_cfi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py index 8c9d929732bbf..a7533cbcabc9e 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py @@ -55,19 +55,19 @@ footprintCorrections = cms.VPSet( cms.PSet( selection = cms.string("decayMode() = 0"), - offset = cms.double(1.8) + offset = cms.double(0.0) ), cms.PSet( selection = cms.string("decayMode() = 1 || decayMode() = 2"), - offset = cms.double(1.5) + offset = cms.double(0.0) ), cms.PSet( selection = cms.string("decayMode() = 5"), - offset = cms.double(4.7) + offset = cms.double(2.7) ), cms.PSet( selection = cms.string("decayMode() = 6"), - offset = cms.double(1.9) + offset = cms.double(0.0) ), cms.PSet( selection = cms.string("decayMode() = 10"), From b56551f2b42ccdb0bad73d6433d29c27b705d97b Mon Sep 17 00:00:00 2001 From: anehrkor Date: Fri, 29 May 2015 16:25:34 +0200 Subject: [PATCH 072/104] New cleaner module that works also if tau is made up of combination of pf charged hadrons and tracks -> solves rare problem with 3-prongs having charge +/-3. --- .../plugins/RecoTauChargeCleanerPlugin.cc | 59 +++++++++++++++++++ .../RecoTau/python/RecoTauCleanerPlugins.py | 12 ++++ .../RecoTau/python/RecoTauCleaner_cfi.py | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc diff --git a/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc new file mode 100644 index 0000000000000..75a03751191a9 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc @@ -0,0 +1,59 @@ +/* + * Original author: Alexander Nehrkorn (RWTH Aachen) + * + * Description: + * This module rejects tau candidates that do not have unit charge. + * It takes the fact into account that taus do not necessarily need + * to be created from PF charged hadrons only but can be created + * from a combination of PF charged hadrons and tracks. + * + */ + +#include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" +#include "DataFormats/TauReco/interface/PFTau.h" +#include "DataFormats/TauReco/interface/PFTauFwd.h" + +namespace reco { namespace tau { + +class RecoTauChargeCleanerPlugin : public RecoTauCleanerPlugin +{ +public: + explicit RecoTauChargeCleanerPlugin(const edm::ParameterSet&, edm::ConsumesCollector &&iC); + ~RecoTauChargeCleanerPlugin() {} + double operator()(const PFTauRef& tau) const override; + +private: + std::vector nprongs_; + double failResult_; + int charge_; +}; + +RecoTauChargeCleanerPlugin::RecoTauChargeCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC) + : RecoTauCleanerPlugin(pset,std::move(iC)), + nprongs_(pset.getParameter >("nprongs")), + failResult_(pset.getParameter("selectionFailValue")), + charge_(pset.getParameter("passForCharge")) +{} + +double RecoTauChargeCleanerPlugin::operator()(const PFTauRef& cand) const +{ + int charge = 0; + unsigned nChargedPFCandidate(0), nTrack(0); + for(unsigned iSignalCand = 0; iSignalCand < cand->signalTauChargedHadronCandidates().size(); iSignalCand++){ + charge += cand->signalTauChargedHadronCandidates().at(iSignalCand).charge(); + if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate)) nChargedPFCandidate++; + else if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kTrack)) nTrack++; + } + + for(auto nprong : nprongs_){ + if(nChargedPFCandidate+nTrack == nprong) return abs(charge)-charge_; + } + + return failResult_; +} + +}} + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_EDM_PLUGIN(RecoTauCleanerPluginFactory, reco::tau::RecoTauChargeCleanerPlugin, "RecoTauChargeCleanerPlugin"); diff --git a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py index 09687d9dfa2ac..8dcfc7df1ca76 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py @@ -28,6 +28,18 @@ selectionFailValue = cms.double(0), ) +# similar to unitCharge but handles also cases where tau is made up of +# a combination of tracks and pf charged hadrons +charge = cms.PSet( + name = cms.string("Charge"), + plugin = cms.string("RecoTauChargeCleanerPlugin"), + # cleaner is applied to decay modes with the number of prongs given here + nprongs = cms.vuint32(1,3), + # taus with charge != 1 are rejected + passForCharge = cms.int32(1), + selectionFailValue = cms.double(0), +) + # Prefer taus with pt greater 15 ptGt15 = cms.PSet( name = cms.string("PtGt15"), diff --git a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py index 30d65dd479550..d387946755de3 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py @@ -6,7 +6,7 @@ src = cms.InputTag("combinatoricRecoTaus"), cleaners = cms.VPSet( # Reject taus that have charge == 3 - cleaners.unitCharge, + cleaners.charge, # Reject taus that are not within DR<0.1 of the jet axis #cleaners.matchingConeCut, # Reject taus that fail HPS selections From b1b1e4343a5c0cda735adb1d7e1456beccc43a49 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 3 Jun 2015 16:46:21 +0200 Subject: [PATCH 073/104] added functionality to make tau footprint correction dependent on tauPt --- .../plugins/PFRecoTauDiscriminationByIsolation.cc | 11 +++++++---- .../python/PFRecoTauDiscriminationByIsolation_cfi.py | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 0bf1e79732ff3..fa310d5369055 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -5,6 +5,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" #include "RecoTauTag/RecoTau/interface/ConeTools.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "CommonTools/Utils/interface/StringObjectFunction.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "TMath.h" @@ -108,7 +109,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin(); cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) { std::string selection = cfgFootprintCorrection->getParameter("selection"); - double offset = cfgFootprintCorrection->getParameter("offset"); + std::string offset = cfgFootprintCorrection->getParameter("offset"); footprintCorrectionType* footprintCorrection = new footprintCorrectionType(selection, offset); footprintCorrections_.push_back(footprintCorrection); } @@ -230,13 +231,13 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas bool applyFootprintCorrection_; struct footprintCorrectionType { - footprintCorrectionType(const std::string& selection, double offset) + footprintCorrectionType(const std::string& selection, const std::string& offset) : selection_(selection), offset_(offset) {} ~footprintCorrectionType() {} StringCutObjectSelector selection_; - double offset_; + StringObjectFunction offset_; }; std::vector footprintCorrections_; @@ -499,7 +500,9 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { for ( std::vector::const_iterator footprintCorrection = footprintCorrections_.begin(); footprintCorrection != footprintCorrections_.end(); ++footprintCorrection ) { - if ( (*footprintCorrection)->selection_(*pfTau) ) footprintCorrection_value = (*footprintCorrection)->offset_; + if ( (*footprintCorrection)->selection_(*pfTau) ) { + footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau); + } } } diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py index a7533cbcabc9e..37b3758cbc79e 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py @@ -55,23 +55,23 @@ footprintCorrections = cms.VPSet( cms.PSet( selection = cms.string("decayMode() = 0"), - offset = cms.double(0.0) + offset = cms.string("0.0") ), cms.PSet( selection = cms.string("decayMode() = 1 || decayMode() = 2"), - offset = cms.double(0.0) + offset = cms.string("0.0") ), cms.PSet( selection = cms.string("decayMode() = 5"), - offset = cms.double(2.7) + offset = cms.string("2.7") ), cms.PSet( selection = cms.string("decayMode() = 6"), - offset = cms.double(0.0) + offset = cms.string("0.0") ), cms.PSet( selection = cms.string("decayMode() = 10"), - offset = cms.double(2.0) + offset = cms.string("max(2.0, 0.22*pt() - 2.0)") ) ), From d710b81c50d1b522ad19c5baa591697f7b25a221 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 9 Jun 2015 19:38:37 +0200 Subject: [PATCH 074/104] tightened cut on pTouter from 0.20*tauPt to 0.10*tauPt --- .../RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py index 37b3758cbc79e..73c7eac0acad9 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py @@ -28,7 +28,7 @@ applyPhotonPtSumOutsideSignalConeCut = cms.bool(False), maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.20), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), qualityCuts = PFTauQualityCuts, # set the standard quality cuts From f85bf276f39686a93894586e384039790d037852 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 9 Jun 2015 19:42:16 +0200 Subject: [PATCH 075/104] apply cut on ptOuter also in case of HPS combined islation 3-hit discriminators with deltaBeta correction --- RecoTauTag/Configuration/python/HPSPFTaus_cff.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index 3711c5fad261f..f08137d4f9216 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -534,8 +534,11 @@ hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits = hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr.clone() hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.qualityCuts.isolationQualityCuts.minTrackHits = cms.uint32(3) +hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.applyPhotonPtSumOutsideSignalConeCut = cms.bool(True) hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits.qualityCuts.isolationQualityCuts.minTrackHits = cms.uint32(3) +hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits.applyPhotonPtSumOutsideSignalConeCut = cms.bool(True) hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits.qualityCuts.isolationQualityCuts.minTrackHits = cms.uint32(3) +hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits.applyPhotonPtSumOutsideSignalConeCut = cms.bool(True) hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits = hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits.clone( applySumPtCut = False, From fbff2322dbd9ed913b895bfccda3b6ceea456ff3 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 10 Jun 2015 17:37:17 +0200 Subject: [PATCH 076/104] - updated deltaBeta correction factor to 0.2 - updated thresholds for isolation WPs: Loose = 2.5 GeV Medium = 1.5 GeV Tight = 0.8 GeV (no change) --- .../Configuration/python/HPSPFTaus_cff.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index f08137d4f9216..5718fc487c720 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -25,8 +25,8 @@ # Load PFjet input parameters from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs -# deltaBeta correction factor calculated for taus from ak5PFJets (Run I) -ak5dBetaCorrection=0.0772/0.1687 +# deltaBeta correction factor +ak4dBetaCorrection=0.20 # Load MVAs from SQLlite file/prep. DB from RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi import * @@ -134,7 +134,7 @@ deltaBetaPUTrackPtCutOverride = cms.double(0.5), applyDeltaBetaCorrection = True, isoConeSizeForDeltaBeta = 0.8, - deltaBetaFactor = "%0.4f"%(ak5dBetaCorrection), + deltaBetaFactor = "%0.4f"%(ak4dBetaCorrection), applyOccupancyCut = False, applySumPtCut = True, ) @@ -150,10 +150,10 @@ hpsPFTauDiscriminationByVLooseCombinedIsolationDBSumPtCorr = hpsPFTauDiscriminationByVLooseIsolationDBSumPtCorr.clone( ApplyDiscriminationByTrackerIsolation = True, ApplyDiscriminationByECALIsolation = True, - deltaBetaFactor = "%0.4f"%((0.09/0.25)*(ak5dBetaCorrection)), + deltaBetaFactor = "%0.4f"%((0.09/0.25)*(ak4dBetaCorrection)), applyOccupancyCut = False, applySumPtCut = True, - maximumSumPtCut = 3.0, + maximumSumPtCut = 3.5, Prediscriminants = requireDecayMode.clone() ) hpsPFTauDiscriminationByVLooseCombinedIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minTrackPt = 0.5 @@ -162,10 +162,10 @@ hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr = hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr.clone( ApplyDiscriminationByTrackerIsolation = True, ApplyDiscriminationByECALIsolation = True, - deltaBetaFactor = "%0.4f"%(ak5dBetaCorrection), + deltaBetaFactor = "%0.4f"%(ak4dBetaCorrection), applyOccupancyCut = False, applySumPtCut = True, - maximumSumPtCut = 2.0, + maximumSumPtCut = 2.5, Prediscriminants = requireDecayMode.clone() ) hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minTrackPt = 0.5 @@ -191,10 +191,10 @@ hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr = hpsPFTauDiscriminationByMediumIsolationDBSumPtCorr.clone( ApplyDiscriminationByTrackerIsolation = True, ApplyDiscriminationByECALIsolation = True, - deltaBetaFactor = "%0.4f"%(ak5dBetaCorrection), + deltaBetaFactor = "%0.4f"%(ak4dBetaCorrection), applyOccupancyCut = False, applySumPtCut = True, - maximumSumPtCut = 1.0, + maximumSumPtCut = 1.5, Prediscriminants = requireDecayMode.clone() ) hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr.qualityCuts.isolationQualityCuts.minTrackPt = 0.5 @@ -203,7 +203,7 @@ hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr = hpsPFTauDiscriminationByTightIsolationDBSumPtCorr.clone( ApplyDiscriminationByTrackerIsolation = True, ApplyDiscriminationByECALIsolation = True, - deltaBetaFactor = "%0.4f"%(ak5dBetaCorrection), + deltaBetaFactor = "%0.4f"%(ak4dBetaCorrection), applyOccupancyCut = False, applySumPtCut = True, maximumSumPtCut = 0.8, From 6726894fdc2ca66c41ff86f9c3fbf2cc42374211 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 8 Jul 2015 18:10:34 +0200 Subject: [PATCH 077/104] updates to tau vertex producers from Arun --- .../RecoTau/plugins/PFTauPrimaryVertexProducer.cc | 10 ++++++---- .../RecoTau/plugins/PFTauSecondaryVertexProducer.cc | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 156e4ac737f42..f22554a583f32 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -252,11 +252,13 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu // } for(std::vector::const_iterator vtxTrkRef=thePV.tracks_begin();vtxTrkRefbuild(*iter)); } bool FitOk(true); - if ( transTracks.size() >= 3 ) { + if ( transTracks.size() >= 2 ) { AdaptiveVertexFitter avf; avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception try { diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index cab1ab4e29f6d..f458bc2c6b246 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -88,7 +88,7 @@ void PFTauSecondaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSe for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) { reco::PFTauRef RefPFTau(Tau, iPFTau); std::vector SV; - if(RefPFTau->decayMode()==10){ + if(RefPFTau->decayMode()>=5){ /////////////////////////////////////////////////////////////////////////////////////////////// // Get tracks form PFTau daugthers std::vector transTrk; From ecb6a9d87098d35f6dc91025995f2f01cc188fe1 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 22 Jul 2015 10:33:09 +0200 Subject: [PATCH 078/104] updated patTau selection to use new discriminators --- .../PatAlgos/python/cleaningLayer1/tauCleaner_cfi.py | 6 +++--- PhysicsTools/PatAlgos/python/tools/tauTools.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/cleaningLayer1/tauCleaner_cfi.py b/PhysicsTools/PatAlgos/python/cleaningLayer1/tauCleaner_cfi.py index 0a1f241e92fdb..bd961ba20904e 100644 --- a/PhysicsTools/PatAlgos/python/cleaningLayer1/tauCleaner_cfi.py +++ b/PhysicsTools/PatAlgos/python/cleaningLayer1/tauCleaner_cfi.py @@ -7,8 +7,8 @@ preselection = cms.string( 'tauID("decayModeFinding") > 0.5 &' ' tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5 &' - ' tauID("againstMuonTight") > 0.5 &' - ' tauID("againstElectronMedium") > 0.5' + ' tauID("againstMuonTight3") > 0.5 &' + ' tauID("againstElectronVLooseMVA5") > 0.5' ), # overlap checking configurables @@ -34,5 +34,5 @@ ), # finalCut (any string-based cut on pat::Tau) - finalCut = cms.string('pt > 20. & abs(eta) < 2.3'), + finalCut = cms.string('pt > 18. & abs(eta) < 2.3'), ) diff --git a/PhysicsTools/PatAlgos/python/tools/tauTools.py b/PhysicsTools/PatAlgos/python/tools/tauTools.py index 5680a4e840492..6de2055df4d5f 100644 --- a/PhysicsTools/PatAlgos/python/tools/tauTools.py +++ b/PhysicsTools/PatAlgos/python/tools/tauTools.py @@ -209,8 +209,8 @@ def switchToPFTauHPS(process, ## adapt cleanPatTaus if hasattr(process, "cleanPatTaus" + patTauLabel + postfix): getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \ - 'pt > 20 & abs(eta) < 2.3 & tauID("decayModeFindingOldDMs") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5' \ - + ' & tauID("againstMuonTight3") > 0.5 & tauID("againstElectronLoose") > 0.5' + 'pt > 18 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5' \ + + ' & tauID("againstMuonTight3") > 0.5 & tauID("againstElectronVLooseMVA5") > 0.5' # Select switcher by string def switchToPFTauByType(process, From 113058c97fba90fd895ba71982d01c9ee202ada4 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Thu, 16 Jul 2015 15:15:38 +0200 Subject: [PATCH 079/104] Added missing discriminators to updateHPSPFTaus_cff.py - their absence was causing unit tests to fail. --- .../Configuration/python/updateHPSPFTaus_cff.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py index 49c090d733c84..25666b0effe81 100644 --- a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py @@ -11,4 +11,17 @@ ''' -updateHPSPFTaus = cms.Sequence() +updateHPSPFTaus = cms.Sequence( + hpsPFTauChargedIsoPtSum* + hpsPFTauNeutralIsoPtSum* + hpsPFTauPUcorrPtSum* + hpsPFTauNeutralIsoPtSumWeight* + hpsPFTauFootprintCorrection* + hpsPFTauPhotonPtSumOutsideSignalCone* + hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits* + hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits* + hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone* + hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits +) From bd3c836444ff52a165bfe885feea366ac991b3bc Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Sun, 19 Jul 2015 12:32:36 +0200 Subject: [PATCH 080/104] Added import statements whose absence was causing the unit tests to fail --- .../Configuration/python/updateHPSPFTaus_cff.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py index 25666b0effe81..d039daf8bda74 100644 --- a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py @@ -11,6 +11,17 @@ ''' + +from RecoTauTag.RecoTau.PFRecoTauDiscriminationByMVAIsolation2_cff import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationByIsolation_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackFinding_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectron_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronMVA5_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon2_cfi import * +from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonMVA_cfi import * + updateHPSPFTaus = cms.Sequence( hpsPFTauChargedIsoPtSum* hpsPFTauNeutralIsoPtSum* From 7d7893b4436d228135e2b2edef951850f08f59ba Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Thu, 6 Aug 2015 17:44:43 +0200 Subject: [PATCH 081/104] New attempt to add Dynamic Strip Reco to 7_6_X - a new PR was necessary because of a rebase while debugging Previous PR at: https://github.com/cms-sw/cmssw/pull/10215/ --- CommonTools/ParticleFlow/python/pfTaus_cff.py | 44 +++++++++++++++++++ .../python/HLT_25ns14e33_v1_cff.py | 20 +++++++++ .../python/HLT_25ns14e33_v3_cff.py | 20 +++++++++ .../Configuration/python/HLT_50nsGRun_cff.py | 20 +++++++++ .../python/HLT_50ns_5e33_v1_cff.py | 20 +++++++++ .../python/HLT_50ns_5e33_v3_cff.py | 20 +++++++++ .../Configuration/python/HLT_FULL_cff.py | 28 ++++++++++++ .../Configuration/python/HLT_GRun_cff.py | 20 +++++++++ .../python/updateHPSPFTaus_cff.py | 2 + 9 files changed, 194 insertions(+) diff --git a/CommonTools/ParticleFlow/python/pfTaus_cff.py b/CommonTools/ParticleFlow/python/pfTaus_cff.py index 5f1642b279515..e9368bc808463 100644 --- a/CommonTools/ParticleFlow/python/pfTaus_cff.py +++ b/CommonTools/ParticleFlow/python/pfTaus_cff.py @@ -126,6 +126,50 @@ pfTauTagInfoProducer.PFJetTracksAssociatorProducer = 'pfJetTracksAssociatorAtVertex' +# Produce primary vertices + +from RecoTauTag.RecoTau.PFTauPrimaryVertexProducer_cfi import * +from RecoTauTag.RecoTau.PFTauSecondaryVertexProducer_cfi import * +from RecoTauTag.RecoTau.PFTauTransverseImpactParameters_cfi import * +hpsPFTauPrimaryVertexProducer = PFTauPrimaryVertexProducer.clone( + PFTauTag = cms.InputTag("hpsPFTauProducer"), + ElectronTag = cms.InputTag(""), + MuonTag = cms.InputTag(""), + PVTag = cms.InputTag("offlinePrimaryVertices"), + beamSpot = cms.InputTag("offlineBeamSpot"), + TrackCollectionTag = cms.InputTag("generalTracks"), + Algorithm = cms.int32(1), + useBeamSpot = cms.bool(True), + RemoveMuonTracks = cms.bool(False), + RemoveElectronTracks = cms.bool(False), + useSelectedTaus = cms.bool(False), + discriminators = cms.VPSet( + cms.PSet( + discriminator = cms.InputTag('hpsPFTauDiscriminationByDecayModeFindingNewDMs'), + selectionCut = cms.double(0.5) + ) + ), + cut = cms.string("pt > 18.0 & abs(eta) < 2.4") +) + + +hpsPFTauSecondaryVertexProducer = PFTauSecondaryVertexProducer.clone( + PFTauTag = cms.InputTag("hpsPFTauProducer") +) +hpsPFTauTransverseImpactParameters = PFTauTransverseImpactParameters.clone( + PFTauTag = cms.InputTag("hpsPFTauProducer"), + PFTauPVATag = cms.InputTag("hpsPFTauPrimaryVertexProducer"), + PFTauSVATag = cms.InputTag("hpsPFTauSecondaryVertexProducer"), + useFullCalculation = cms.bool(False) +) +hpsPFTauVertexAndImpactParametersSeq = cms.Sequence( + hpsPFTauPrimaryVertexProducer* + hpsPFTauSecondaryVertexProducer* + hpsPFTauTransverseImpactParameters +) + + + pfTausPreSequence = cms.Sequence( pfJetTracksAssociatorAtVertex + pfTauPFJets08Region + diff --git a/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py b/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py index e89340450d63d..df131c07567a1 100644 --- a/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py +++ b/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py @@ -10653,6 +10653,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -10717,6 +10721,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16460,6 +16468,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16524,6 +16536,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19450,6 +19466,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py b/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py index 10f484b05ab6c..5e6463258df39 100644 --- a/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py +++ b/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py @@ -11691,6 +11691,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11755,6 +11759,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17491,6 +17499,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17555,6 +17567,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21588,6 +21604,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py b/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py index a256492fc2508..52b46a4d6ecef 100644 --- a/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py +++ b/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py @@ -11963,6 +11963,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -12027,6 +12031,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17989,6 +17997,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -18053,6 +18065,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21498,6 +21514,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py b/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py index 6e7a13211c4e3..a96c68f0d4623 100644 --- a/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py +++ b/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py @@ -10936,6 +10936,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11000,6 +11004,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16518,6 +16526,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16582,6 +16594,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19605,6 +19621,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py b/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py index 0badd3d5f8fd4..fe15dbd1cb0cc 100644 --- a/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py +++ b/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py @@ -11928,6 +11928,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11992,6 +11996,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17954,6 +17962,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -18018,6 +18030,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21445,6 +21461,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_FULL_cff.py b/HLTrigger/Configuration/python/HLT_FULL_cff.py index 216d9e2673e28..23878a0d31593 100644 --- a/HLTrigger/Configuration/python/HLT_FULL_cff.py +++ b/HLTrigger/Configuration/python/HLT_FULL_cff.py @@ -13124,6 +13124,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13188,6 +13192,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13786,6 +13794,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13850,6 +13862,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19509,6 +19525,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19573,6 +19593,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -23652,6 +23676,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_GRun_cff.py b/HLTrigger/Configuration/python/HLT_GRun_cff.py index 6004be91d5600..22f27400e4e2b 100644 --- a/HLTrigger/Configuration/python/HLT_GRun_cff.py +++ b/HLTrigger/Configuration/python/HLT_GRun_cff.py @@ -11691,6 +11691,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11755,6 +11759,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17491,6 +17499,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17555,6 +17567,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21588,6 +21604,10 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), + maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), + applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py index d039daf8bda74..523413f24c7cc 100644 --- a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py @@ -22,6 +22,8 @@ from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon2_cfi import * from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonMVA_cfi import * +from RecoTauTag.Configuration.HPSPFTaus_cff import * + updateHPSPFTaus = cms.Sequence( hpsPFTauChargedIsoPtSum* hpsPFTauNeutralIsoPtSum* From 629d89cce796e8da610691f1102f3fb164790def Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Sun, 9 Aug 2015 23:24:56 +0200 Subject: [PATCH 082/104] Added fillDescriptions() method, reverted HLT dumps to previous version since they may not be modified. Now failing unit test 1330.0 as well as 135.4. Attempting to diagnose but updating the PR anyway to iterate with the experts. --- .../python/HLT_25ns14e33_v1_cff.py | 20 ------------- .../python/HLT_25ns14e33_v3_cff.py | 20 ------------- .../Configuration/python/HLT_50nsGRun_cff.py | 20 ------------- .../python/HLT_50ns_5e33_v1_cff.py | 20 ------------- .../python/HLT_50ns_5e33_v3_cff.py | 20 ------------- .../Configuration/python/HLT_FULL_cff.py | 28 ------------------- .../Configuration/python/HLT_GRun_cff.py | 20 ------------- .../interface/TauDiscriminationProducerBase.h | 1 + .../PFRecoTauDiscriminationByIsolation.cc | 14 ++++++++++ 9 files changed, 15 insertions(+), 148 deletions(-) diff --git a/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py b/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py index df131c07567a1..e89340450d63d 100644 --- a/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py +++ b/HLTrigger/Configuration/python/HLT_25ns14e33_v1_cff.py @@ -10653,10 +10653,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -10721,10 +10717,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16468,10 +16460,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16536,10 +16524,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19466,10 +19450,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py b/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py index 5e6463258df39..10f484b05ab6c 100644 --- a/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py +++ b/HLTrigger/Configuration/python/HLT_25ns14e33_v3_cff.py @@ -11691,10 +11691,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11759,10 +11755,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17499,10 +17491,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17567,10 +17555,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21604,10 +21588,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py b/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py index 52b46a4d6ecef..a256492fc2508 100644 --- a/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py +++ b/HLTrigger/Configuration/python/HLT_50nsGRun_cff.py @@ -11963,10 +11963,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -12031,10 +12027,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17997,10 +17989,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -18065,10 +18053,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21514,10 +21498,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py b/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py index a96c68f0d4623..6e7a13211c4e3 100644 --- a/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py +++ b/HLTrigger/Configuration/python/HLT_50ns_5e33_v1_cff.py @@ -10936,10 +10936,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11004,10 +11000,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16526,10 +16518,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -16594,10 +16582,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19621,10 +19605,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py b/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py index fe15dbd1cb0cc..0badd3d5f8fd4 100644 --- a/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py +++ b/HLTrigger/Configuration/python/HLT_50ns_5e33_v3_cff.py @@ -11928,10 +11928,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11996,10 +11992,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17962,10 +17954,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -18030,10 +18018,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21461,10 +21445,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_FULL_cff.py b/HLTrigger/Configuration/python/HLT_FULL_cff.py index 23878a0d31593..216d9e2673e28 100644 --- a/HLTrigger/Configuration/python/HLT_FULL_cff.py +++ b/HLTrigger/Configuration/python/HLT_FULL_cff.py @@ -13124,10 +13124,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13192,10 +13188,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13794,10 +13786,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -13862,10 +13850,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19525,10 +19509,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -19593,10 +19573,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -23676,10 +23652,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/HLTrigger/Configuration/python/HLT_GRun_cff.py b/HLTrigger/Configuration/python/HLT_GRun_cff.py index 22f27400e4e2b..6004be91d5600 100644 --- a/HLTrigger/Configuration/python/HLT_GRun_cff.py +++ b/HLTrigger/Configuration/python/HLT_GRun_cff.py @@ -11691,10 +11691,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -11759,10 +11755,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17499,10 +17491,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( False ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -17567,10 +17555,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), @@ -21604,10 +21588,6 @@ applyOccupancyCut = cms.bool( False ), applyDeltaBetaCorrection = cms.bool( False ), applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), - maxRelPhotonSumPt_outsideSignalCone = cms.double(0.10), - applyFootprintCorrection = cms.bool(False), maximumOccupancy = cms.uint32( 0 ), deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), diff --git a/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h b/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h index f5e17c02eba2e..c933264b2b0c2 100644 --- a/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h +++ b/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h @@ -85,6 +85,7 @@ class TauDiscriminationProducerBase : public edm::stream::EDProducer<> { evt.getByToken(disc_token, handle); }; }; + protected: //value given to taus that fail prediscriminants diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index fa310d5369055..f2b501161531b 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -190,6 +190,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); inline double weightedSum(std::vector inColl_, double eta, double phi) const { double out = 1.0; @@ -318,6 +319,19 @@ void PFRecoTauDiscriminationByIsolation::beginEvent(const edm::Event& event, con } } + +void +PFRecoTauDiscriminationByIsolation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription iDesc; + iDesc.add("applyPhotonPtSumOutsideSignalConeCut",false); + iDesc.add("maxAbsPhotonSumPt_outsideSignalCone",1.e+9); + iDesc.add("maxRelPhotonSumPt_outsideSignalCone",0.10); + iDesc.add("applyFootprintCorrection",false); +} + + + double PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const { From 644f8bd89f3f351ff4194d6a4626ac4afab58235 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Tue, 11 Aug 2015 10:29:54 +0200 Subject: [PATCH 083/104] Added Christian's alternate fix to the HLT issues. Now passing all tests except 135.4 (missing module label: combinatoricRecoTaus) --- CommonTools/ParticleFlow/python/pfTaus_cff.py | 45 ------------------- .../PFRecoTauDiscriminationByIsolation.cc | 28 ++++-------- 2 files changed, 9 insertions(+), 64 deletions(-) diff --git a/CommonTools/ParticleFlow/python/pfTaus_cff.py b/CommonTools/ParticleFlow/python/pfTaus_cff.py index e9368bc808463..2395d583c6bad 100644 --- a/CommonTools/ParticleFlow/python/pfTaus_cff.py +++ b/CommonTools/ParticleFlow/python/pfTaus_cff.py @@ -125,51 +125,6 @@ pfTauTagInfoProducer.PFCandidateProducer = jetConfig.ak4PFJets.src pfTauTagInfoProducer.PFJetTracksAssociatorProducer = 'pfJetTracksAssociatorAtVertex' - -# Produce primary vertices - -from RecoTauTag.RecoTau.PFTauPrimaryVertexProducer_cfi import * -from RecoTauTag.RecoTau.PFTauSecondaryVertexProducer_cfi import * -from RecoTauTag.RecoTau.PFTauTransverseImpactParameters_cfi import * -hpsPFTauPrimaryVertexProducer = PFTauPrimaryVertexProducer.clone( - PFTauTag = cms.InputTag("hpsPFTauProducer"), - ElectronTag = cms.InputTag(""), - MuonTag = cms.InputTag(""), - PVTag = cms.InputTag("offlinePrimaryVertices"), - beamSpot = cms.InputTag("offlineBeamSpot"), - TrackCollectionTag = cms.InputTag("generalTracks"), - Algorithm = cms.int32(1), - useBeamSpot = cms.bool(True), - RemoveMuonTracks = cms.bool(False), - RemoveElectronTracks = cms.bool(False), - useSelectedTaus = cms.bool(False), - discriminators = cms.VPSet( - cms.PSet( - discriminator = cms.InputTag('hpsPFTauDiscriminationByDecayModeFindingNewDMs'), - selectionCut = cms.double(0.5) - ) - ), - cut = cms.string("pt > 18.0 & abs(eta) < 2.4") -) - - -hpsPFTauSecondaryVertexProducer = PFTauSecondaryVertexProducer.clone( - PFTauTag = cms.InputTag("hpsPFTauProducer") -) -hpsPFTauTransverseImpactParameters = PFTauTransverseImpactParameters.clone( - PFTauTag = cms.InputTag("hpsPFTauProducer"), - PFTauPVATag = cms.InputTag("hpsPFTauPrimaryVertexProducer"), - PFTauSVATag = cms.InputTag("hpsPFTauSecondaryVertexProducer"), - useFullCalculation = cms.bool(False) -) -hpsPFTauVertexAndImpactParametersSeq = cms.Sequence( - hpsPFTauPrimaryVertexProducer* - hpsPFTauSecondaryVertexProducer* - hpsPFTauTransverseImpactParameters -) - - - pfTausPreSequence = cms.Sequence( pfJetTracksAssociatorAtVertex + pfTauPFJets08Region + diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index f2b501161531b..4c40327597596 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -99,11 +99,15 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas customIsoCone_ = -1; } - applyPhotonPtSumOutsideSignalConeCut_ = pset.getParameter("applyPhotonPtSumOutsideSignalConeCut"); - maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxAbsPhotonSumPt_outsideSignalCone"); - maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxRelPhotonSumPt_outsideSignalCone"); - - applyFootprintCorrection_ = pset.getParameter("applyFootprintCorrection"); + applyPhotonPtSumOutsideSignalConeCut_ = ( pset.exists("applyPhotonPtSumOutsideSignalConeCut") ) ? + pset.getParameter("applyPhotonPtSumOutsideSignalConeCut") : false; + if ( applyPhotonPtSumOutsideSignalConeCut_ ) { + maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxAbsPhotonSumPt_outsideSignalCone"); + maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxRelPhotonSumPt_outsideSignalCone"); + } + + applyFootprintCorrection_ = ( pset.exists("applyFootprintCorrection") ) ? + pset.getParameter("applyFootprintCorrection") : false; if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { edm::VParameterSet cfgFootprintCorrections = pset.getParameter("footprintCorrections"); for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin(); @@ -190,7 +194,6 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; double discriminate(const PFTauRef& pfTau) const override; - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); inline double weightedSum(std::vector inColl_, double eta, double phi) const { double out = 1.0; @@ -319,19 +322,6 @@ void PFRecoTauDiscriminationByIsolation::beginEvent(const edm::Event& event, con } } - -void -PFRecoTauDiscriminationByIsolation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) -{ - edm::ParameterSetDescription iDesc; - iDesc.add("applyPhotonPtSumOutsideSignalConeCut",false); - iDesc.add("maxAbsPhotonSumPt_outsideSignalCone",1.e+9); - iDesc.add("maxRelPhotonSumPt_outsideSignalCone",0.10); - iDesc.add("applyFootprintCorrection",false); -} - - - double PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const { From ccfc093713eb74f654d38446768555caee6fb3d3 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Thu, 13 Aug 2015 11:29:36 +0200 Subject: [PATCH 084/104] Per Slava's suggestion, removed modules from cms.Sequence and added them to import section instead. Now runTheMatrix passes all tests!!! --- .../python/updateHPSPFTaus_cff.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py index 523413f24c7cc..d6c2be075e4df 100644 --- a/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/updateHPSPFTaus_cff.py @@ -22,19 +22,19 @@ from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon2_cfi import * from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonMVA_cfi import * -from RecoTauTag.Configuration.HPSPFTaus_cff import * - -updateHPSPFTaus = cms.Sequence( - hpsPFTauChargedIsoPtSum* - hpsPFTauNeutralIsoPtSum* - hpsPFTauPUcorrPtSum* - hpsPFTauNeutralIsoPtSumWeight* - hpsPFTauFootprintCorrection* - hpsPFTauPhotonPtSumOutsideSignalCone* - hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits* - hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits* - hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits* - hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits* - hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone* - hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits -) +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauChargedIsoPtSum +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauNeutralIsoPtSum +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauPUcorrPtSum +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauNeutralIsoPtSumWeight +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauFootprintCorrection +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauPhotonPtSumOutsideSignalCone +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits + + +updateHPSPFTaus = cms.Sequence() + From 112c7227c098f781f58c23b83967fdf8b25b29e8 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Sat, 15 Aug 2015 18:44:20 +0200 Subject: [PATCH 085/104] Attempting to implement Slava's suggestions after his review of PR 10605. Code compiles but segfaults on several matrix tests - currently attempting to diagnose with GDB but sharing with the experts anyway. --- DataFormats/TauReco/interface/PFTau.h | 4 +-- DataFormats/TauReco/interface/RecoTauPiZero.h | 20 ++++--------- DataFormats/TauReco/src/PFTau.cc | 2 ++ DataFormats/TauReco/src/classes_def_2.xml | 14 ++++----- .../python/producersLayer1/tauProducer_cfi.py | 28 ------------------ .../PFRecoTauDiscriminationByHPSSelection.cc | 12 ++++---- .../PFRecoTauDiscriminationByIsolation.cc | 18 +++++------- .../RecoTauBuilderCombinatoricPlugin.cc | 2 +- .../plugins/RecoTauChargeCleanerPlugin.cc | 8 ++--- ...uChargedHadronMultiplicityCleanerPlugin.cc | 1 - .../plugins/RecoTauPiZeroStripPlugin3.cc | 29 +++++++------------ 11 files changed, 46 insertions(+), 92 deletions(-) diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h index e23dac4143d68..e5c63782bf753 100644 --- a/DataFormats/TauReco/interface/PFTau.h +++ b/DataFormats/TauReco/interface/PFTau.h @@ -151,8 +151,8 @@ class PFTau : public BaseTau { void setDecayMode(const hadronicDecayMode&); /// Effect of eta and phi correction of strip on mass of tau candidate - double bendCorrMass() const { return bendCorrMass_; } - void setBendCorrMass(double bendCorrMass) { bendCorrMass_ = bendCorrMass; } + float bendCorrMass() const { return bendCorrMass_; } + void setBendCorrMass(float bendCorrMass) { bendCorrMass_ = bendCorrMass; } /// Size of signal cone double signalConeSize() const { return signalConeSize_; } diff --git a/DataFormats/TauReco/interface/RecoTauPiZero.h b/DataFormats/TauReco/interface/RecoTauPiZero.h index 076d7de5e518d..cc0a9c8f6a719 100644 --- a/DataFormats/TauReco/interface/RecoTauPiZero.h +++ b/DataFormats/TauReco/interface/RecoTauPiZero.h @@ -16,20 +16,16 @@ class RecoTauPiZero : public CompositePtrCandidate { RecoTauPiZero() : CompositePtrCandidate(), - algoName_(kUndefined) + algoName_(kUndefined), bendCorrEta_ (0.), bendCorrPhi_ (0.) { this->setPdgId(111); - bendCorrEta_ = 0.; - bendCorrPhi_ = 0.; } RecoTauPiZero(PiZeroAlgorithm algoName) : CompositePtrCandidate(), - algoName_(algoName) + algoName_(algoName), bendCorrEta_ (0.), bendCorrPhi_ (0.) { this->setPdgId(111); - bendCorrEta_ = 0.; - bendCorrPhi_ = 0.; } /// constructor from values @@ -38,10 +34,8 @@ class RecoTauPiZero : public CompositePtrCandidate { int pdgId = 111, int status = 0, bool integerCharge = true, PiZeroAlgorithm algoName = kUndefined) : CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge ), - algoName_(algoName) + algoName_(algoName), bendCorrEta_ (0.), bendCorrPhi_ (0.) { - bendCorrEta_ = 0.; - bendCorrPhi_ = 0.; } /// constructor from values @@ -50,20 +44,16 @@ class RecoTauPiZero : public CompositePtrCandidate { int pdgId = 111, int status = 0, bool integerCharge = true, PiZeroAlgorithm algoName=kUndefined) : CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge ), - algoName_(algoName) + algoName_(algoName), bendCorrEta_ (0.), bendCorrPhi_ (0.) { - bendCorrEta_ = 0.; - bendCorrPhi_ = 0.; } /// constructor from a Candidate explicit RecoTauPiZero(const Candidate& p, PiZeroAlgorithm algoName = kUndefined) : CompositePtrCandidate(p), - algoName_(algoName) + algoName_(algoName), bendCorrEta_ (0.), bendCorrPhi_ (0.) { this->setPdgId(111); - bendCorrEta_ = 0.; - bendCorrPhi_ = 0.; } /// destructor diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index bcc8d35364d9f..63f66e0984381 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -24,6 +24,7 @@ PFTau::PFTau() muonDecision_ = NAN; decayMode_ = kNull; bendCorrMass_ = 0.; + signalConeSize_ = 0.; } PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx) @@ -48,6 +49,7 @@ PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx) muonDecision_ = NAN; decayMode_ = kNull; bendCorrMass_ = 0.; + signalConeSize_ = 0.; } PFTau* PFTau::clone() const { return new PFTau(*this); } diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index e64e3f8ff868c..04a7a406f3000 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -4,17 +4,17 @@ - - - - - - + + + + + + - + diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index 39177b9f29d1a..8f5e1854a3286 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -71,13 +71,6 @@ neutralIsoPtSumWeight = cms.InputTag("hpsPFTauNeutralIsoPtSumWeight"), footprintCorrection = cms.InputTag("hpsPFTauFootprintCorrection"), photonPtSumOutsideSignalCone = cms.InputTag("hpsPFTauPhotonPtSumOutsideSignalCone"), - ##byIsolationMVA3oldDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwoLTraw'), - ##byVLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwoLT'), - ##byLooseIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwoLT'), - ##byMediumIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3oldDMwoLT'), - ##byTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3oldDMwoLT'), - ##byVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3oldDMwoLT'), - ##byVVTightIsolationMVA3oldDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3oldDMwoLT'), byIsolationMVA3oldDMwLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3oldDMwLTraw'), byVLooseIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3oldDMwLT'), byLooseIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3oldDMwLT'), @@ -85,13 +78,6 @@ byTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3oldDMwLT'), byVTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3oldDMwLT'), byVVTightIsolationMVA3oldDMwLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3oldDMwLT'), - ##byIsolationMVA3newDMwoLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3newDMwoLTraw'), - ##byVLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwoLT'), - ##byLooseIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3newDMwoLT'), - ##byMediumIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByMediumIsolationMVA3newDMwoLT'), - ##byTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3newDMwoLT'), - ##byVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3newDMwoLT'), - ##byVVTightIsolationMVA3newDMwoLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwoLT'), byIsolationMVA3newDMwLTraw = cms.InputTag('hpsPFTauDiscriminationByIsolationMVA3newDMwLTraw'), byVLooseIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVLooseIsolationMVA3newDMwLT'), byLooseIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByLooseIsolationMVA3newDMwLT'), @@ -99,21 +85,8 @@ byTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByTightIsolationMVA3newDMwLT'), byVTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVTightIsolationMVA3newDMwLT'), byVVTightIsolationMVA3newDMwLT = cms.InputTag('hpsPFTauDiscriminationByVVTightIsolationMVA3newDMwLT'), - ##againstElectronLoose = cms.InputTag("hpsPFTauDiscriminationByLooseElectronRejection"), - ##againstElectronMedium = cms.InputTag("hpsPFTauDiscriminationByMediumElectronRejection"), - ##againstElectronTight = cms.InputTag("hpsPFTauDiscriminationByTightElectronRejection"), - ##againstMuonLoose = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection"), - ##againstMuonMedium = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection"), - ##againstMuonTight = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection"), - ##againstMuonLoose2 = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection2"), - ##againstMuonMedium2 = cms.InputTag("hpsPFTauDiscriminationByMediumMuonRejection2"), - ##againstMuonTight2 = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection2"), againstMuonLoose3 = cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection3"), againstMuonTight3 = cms.InputTag("hpsPFTauDiscriminationByTightMuonRejection3"), - ##againstMuonMVAraw = cms.InputTag('hpsPFTauDiscriminationByMVArawMuonRejection'), - ##againstMuonLooseMVA = cms.InputTag('hpsPFTauDiscriminationByMVALooseMuonRejection'), - ##againstMuonMediumMVA = cms.InputTag('hpsPFTauDiscriminationByMVAMediumMuonRejection'), - ##againstMuonTightMVA = cms.InputTag('hpsPFTauDiscriminationByMVATightMuonRejection'), byLooseCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"), byMediumCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"), byTightCombinedIsolationDeltaBetaCorr3Hits = cms.InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"), @@ -130,7 +103,6 @@ againstElectronMediumMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5MediumElectronRejection"), againstElectronTightMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5TightElectronRejection"), againstElectronVTightMVA5 = cms.InputTag("hpsPFTauDiscriminationByMVA5VTightElectronRejection"), - ##againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejection"), ), # mc matching configurables diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index 41f001baf1806..bb76f2acf8edb 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -106,6 +106,8 @@ PFRecoTauDiscriminationByHPSSelection::PFRecoTauDiscriminationByHPSSelection(con minPixelHits_ = pset.getParameter("minPixelHits"); verbosity_ = pset.exists("verbosity") ? pset.getParameter("verbosity") : 0; + + } PFRecoTauDiscriminationByHPSSelection::~PFRecoTauDiscriminationByHPSSelection() @@ -256,13 +258,13 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c } // Now check the pizeros BOOST_FOREACH(const reco::RecoTauPiZero& cand, tau->signalPiZeroCandidates()) { - double dEta = TMath::Max(0., fabs(cand.eta() - tauP4.eta()) - cand.bendCorrEta()); - double dPhi = TMath::Max(0., fabs(cand.phi() - tauP4.phi()) - cand.bendCorrPhi()); - double dR = sqrt(dEta*dEta + dPhi*dPhi); + double dEta = std::max(0., fabs(cand.eta() - tauP4.eta()) - cand.bendCorrEta()); + double dPhi = std::max(0., reco::deltaPhi(cand.phi(), tauP4.phi()) - cand.bendCorrPhi()); + double dR2 = dEta*dEta + dPhi*dPhi; if ( verbosity_ ) { - edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPiZero) = " << dR ; + edm::LogPrint("PFTauByHPSSelect") << "dR2(tau, signalPiZero) = " << dR2 ; } - if ( dR > cone_size ) { + if ( dR2 > cone_size*cone_size ) { if ( verbosity_ ) { edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for strip(s)." ; } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 4c40327597596..6599f756456af 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -114,8 +114,8 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) { std::string selection = cfgFootprintCorrection->getParameter("selection"); std::string offset = cfgFootprintCorrection->getParameter("offset"); - footprintCorrectionType* footprintCorrection = new footprintCorrectionType(selection, offset); - footprintCorrections_.push_back(footprintCorrection); + std::unique_ptr footprintCorrection(new FootprintCorrection(selection, offset)); + footprintCorrections_.push_back(std::move(footprintCorrection)); } } @@ -186,10 +186,6 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas ~PFRecoTauDiscriminationByIsolation() { - for ( std::vector::iterator it = footprintCorrections_.begin(); - it != footprintCorrections_.end(); ++it ) { - delete (*it); - } } void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; @@ -233,17 +229,17 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas double maxRelPhotonSumPt_outsideSignalCone_; bool applyFootprintCorrection_; - struct footprintCorrectionType + struct FootprintCorrection { - footprintCorrectionType(const std::string& selection, const std::string& offset) + FootprintCorrection(const std::string& selection, const std::string& offset) : selection_(selection), offset_(offset) {} - ~footprintCorrectionType() {} + ~FootprintCorrection() {} StringCutObjectSelector selection_; StringObjectFunction offset_; }; - std::vector footprintCorrections_; + std::vector > footprintCorrections_; // Options to store the raw value in the discriminator instead of boolean pass/fail flag bool storeRawOccupancy_; @@ -502,7 +498,7 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const double footprintCorrection_value = 0.; if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { - for ( std::vector::const_iterator footprintCorrection = footprintCorrections_.begin(); + for ( std::vector >::const_iterator footprintCorrection = footprintCorrections_.begin(); footprintCorrection != footprintCorrections_.end(); ++footprintCorrection ) { if ( (*footprintCorrection)->selection_(*pfTau) ) { footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc index 5aaaa268b0740..521d2e4794481 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc @@ -497,7 +497,7 @@ RecoTauBuilderCombinatoricPlugin::operator()( double tauMass = std::max(tauPtr->mass(), chargedPionMass); double bendCorrMass2 = 0.; const std::vector& piZeros = tauPtr->signalPiZeroCandidates(); - BOOST_FOREACH( const RecoTauPiZero& piZero, piZeros ) { + for (auto const& piZero : piZeros ) { double piZeroEn = piZero.energy(); double piZeroPx = piZero.px(); double piZeroPy = piZero.py(); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc index 75a03751191a9..5125c4c88721c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc @@ -39,10 +39,10 @@ double RecoTauChargeCleanerPlugin::operator()(const PFTauRef& cand) const { int charge = 0; unsigned nChargedPFCandidate(0), nTrack(0); - for(unsigned iSignalCand = 0; iSignalCand < cand->signalTauChargedHadronCandidates().size(); iSignalCand++){ - charge += cand->signalTauChargedHadronCandidates().at(iSignalCand).charge(); - if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate)) nChargedPFCandidate++; - else if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kTrack)) nTrack++; + for(auto const& tauCand : cand->signalTauChargedHadronCandidates()){ + charge += tauCand.charge(); + if(tauCand.algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate)) nChargedPFCandidate++; + else if(tauCand.algoIs(reco::PFRecoTauChargedHadron::kTrack)) nTrack++; } for(auto nprong : nprongs_){ diff --git a/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc index ce8688323ce77..b57cdb9a36202 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauChargedHadronMultiplicityCleanerPlugin.cc @@ -15,7 +15,6 @@ class RecoTauChargedHadronMultiplicityCleanerPlugin : public RecoTauCleanerPlugi { public: RecoTauChargedHadronMultiplicityCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC); - virtual ~RecoTauChargedHadronMultiplicityCleanerPlugin(){} // Get ranking value for a given tau Ref double operator()(const reco::PFTauRef&) const override; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 8616ee0e8c420..23652126ec233 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -69,7 +69,7 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin RecoTauVertexAssociator vertexAssociator_; - RecoTauQualityCuts* qcuts_; + std::unique_ptr qcuts_; bool applyElecTrackQcuts_; double minGammaEtStripSeed_; double minGammaEtStripAdd_; @@ -77,8 +77,8 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin double minStripEt_; std::vector inputPdgIds_; // type of candidates to clusterize - TFormula* etaAssociationDistance_; // size of strip clustering window in eta direction - TFormula* phiAssociationDistance_; // size of strip clustering window in phi direction + std::unique_ptr etaAssociationDistance_; // size of strip clustering window in eta direction + std::unique_ptr phiAssociationDistance_; // size of strip clustering window in phi direction bool updateStripAfterEachDaughter_; int maxStripBuildIterations_; @@ -95,11 +95,11 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin namespace { - TFormula* makeFunction(const std::string& functionName, const edm::ParameterSet& pset) + std::unique_ptr makeFunction(const std::string& functionName, const edm::ParameterSet& pset) { TString formula = pset.getParameter("function"); formula = formula.ReplaceAll("pT", "x"); - TFormula* function = new TFormula(functionName.data(), formula.Data()); + std::unique_ptr function(new TFormula(functionName.data(), formula.Data())); int numParameter = function->GetNpar(); for ( int idxParameter = 0; idxParameter < numParameter; ++idxParameter ) { std::string parameterName = Form("par%i", idxParameter); @@ -112,10 +112,7 @@ namespace RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC) : RecoTauPiZeroBuilderPlugin(pset, std::move(iC)), - vertexAssociator_(pset.getParameter("qualityCuts"), std::move(iC)), - qcuts_(0), - etaAssociationDistance_(0), - phiAssociationDistance_(0) + vertexAssociator_(pset.getParameter("qualityCuts"), std::move(iC)), qcuts_(nullptr), etaAssociationDistance_(nullptr), phiAssociationDistance_(nullptr) { minGammaEtStripSeed_ = pset.getParameter("minGammaEtStripSeed"); minGammaEtStripAdd_ = pset.getParameter("minGammaEtStripAdd"); @@ -138,7 +135,8 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps } //------------------------------------------------------------------------------- qcuts_pset.addParameter("minGammaEt", std::min(minGammaEtStripSeed_, minGammaEtStripAdd_)); - qcuts_ = new RecoTauQualityCuts(qcuts_pset); + //qcuts_ = new RecoTauQualityCuts(qcuts_pset); + std::unique_ptr qcuts_(new RecoTauQualityCuts(qcuts_pset)); inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); edm::ParameterSet stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistance"); @@ -161,9 +159,6 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps RecoTauPiZeroStripPlugin3::~RecoTauPiZeroStripPlugin3() { - delete qcuts_; - delete etaAssociationDistance_; - delete phiAssociationDistance_; } // Update the primary vertex @@ -185,7 +180,7 @@ void RecoTauPiZeroStripPlugin3::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs double etaAssociationDistance_value = etaAssociationDistance_->Eval(strip.pt()) + etaAssociationDistance_->Eval(cand->pt()); double phiAssociationDistance_value = phiAssociationDistance_->Eval(strip.pt()) + phiAssociationDistance_->Eval(cand->pt()); if ( fabs(strip.eta() - cand->eta()) < etaAssociationDistance_value && // check if cand is within eta-phi window centered on strip - fabs(strip.phi() - cand->phi()) < phiAssociationDistance_value ) { + reco::deltaPhi(strip.phi(), cand->phi()) < phiAssociationDistance_value ) { if ( verbosity_ >= 2 ) { edm::LogPrint("RecoTauPiZeroStripPlugin3") << "--> adding PFCand #" << candId << " (" << cand.id() << ":" << cand.key() << "): Et = " << cand->et() << ", eta = " << cand->eta() << ", phi = " << cand->phi() ; } @@ -347,12 +342,10 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con 111, 10001, true, RecoTauPiZero::kUndefined)); // Now loop over the strip members - BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, - first->daughterPtrVector()) { + for ( auto const& gamma : first->daughterPtrVector()) { combinedStrips->addDaughter(gamma); } - BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, - second->daughterPtrVector()) { + for ( auto const& gamma : second->daughterPtrVector()) { combinedStrips->addDaughter(gamma); } // Update the vertex From b95b7a552925606aeaa6769c3cc433ce31d36ef8 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Sun, 16 Aug 2015 15:24:26 +0200 Subject: [PATCH 086/104] Applied Slava's suggestions in PR 10605+10802, now passing all tests! --- .../RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 23652126ec233..759dd3e86634d 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -77,8 +77,8 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin double minStripEt_; std::vector inputPdgIds_; // type of candidates to clusterize - std::unique_ptr etaAssociationDistance_; // size of strip clustering window in eta direction - std::unique_ptr phiAssociationDistance_; // size of strip clustering window in phi direction + std::unique_ptr etaAssociationDistance_; // size of strip clustering window in eta direction + std::unique_ptr phiAssociationDistance_; // size of strip clustering window in phi direction bool updateStripAfterEachDaughter_; int maxStripBuildIterations_; @@ -136,7 +136,9 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps //------------------------------------------------------------------------------- qcuts_pset.addParameter("minGammaEt", std::min(minGammaEtStripSeed_, minGammaEtStripAdd_)); //qcuts_ = new RecoTauQualityCuts(qcuts_pset); - std::unique_ptr qcuts_(new RecoTauQualityCuts(qcuts_pset)); + //std::unique_ptr qcuts_(new RecoTauQualityCuts(qcuts_pset)); + + qcuts_.reset(new RecoTauQualityCuts(qcuts_pset)); inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); edm::ParameterSet stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistance"); @@ -156,10 +158,9 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps verbosity_ = ( pset.exists("verbosity") ) ? pset.getParameter("verbosity") : 0; } - RecoTauPiZeroStripPlugin3::~RecoTauPiZeroStripPlugin3() { -} +} // Update the primary vertex void RecoTauPiZeroStripPlugin3::beginEvent() From 33f99931147abcb767f121eb4b79a3459450b622 Mon Sep 17 00:00:00 2001 From: AJ Johnson Date: Sat, 22 Aug 2015 16:56:02 +0200 Subject: [PATCH 087/104] Bugfix adding absolute value to deltaPhi, changing BOOSTFOREACH loops to auto iterators --- .../plugins/PFRecoTauDiscriminationByHPSSelection.cc | 6 +++--- RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index bb76f2acf8edb..d61204dbee7d0 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -245,7 +245,7 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c // Check if tau passes cone cut double cone_size = tau->signalConeSize(); // Check if any charged objects fail the signal cone cut - BOOST_FOREACH(const reco::PFRecoTauChargedHadron& cand, tau->signalTauChargedHadronCandidates()) { + for (auto const& cand : tau->signalTauChargedHadronCandidates()) { if ( verbosity_ ) { edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPFChargedHadr) = " << deltaR(cand.p4(), tauP4) ; } @@ -257,9 +257,9 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c } } // Now check the pizeros - BOOST_FOREACH(const reco::RecoTauPiZero& cand, tau->signalPiZeroCandidates()) { + for (auto const& cand : tau->signalPiZeroCandidates()) { double dEta = std::max(0., fabs(cand.eta() - tauP4.eta()) - cand.bendCorrEta()); - double dPhi = std::max(0., reco::deltaPhi(cand.phi(), tauP4.phi()) - cand.bendCorrPhi()); + double dPhi = std::max(0., std::abs(reco::deltaPhi(cand.phi(), tauP4.phi())) - cand.bendCorrPhi()); double dR2 = dEta*dEta + dPhi*dPhi; if ( verbosity_ ) { edm::LogPrint("PFTauByHPSSelect") << "dR2(tau, signalPiZero) = " << dR2 ; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 759dd3e86634d..1c72af7a69104 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -370,8 +370,7 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con double bendCorrEta = 0.; double bendCorrPhi = 0.; double energySum = 0.; - BOOST_FOREACH(const RecoTauPiZero::daughters::value_type& gamma, - strip->daughterPtrVector()) { + for (auto const& gamma : strip->daughterPtrVector()) { bendCorrEta += (gamma->energy()*etaAssociationDistance_->Eval(gamma->pt())); bendCorrPhi += (gamma->energy()*phiAssociationDistance_->Eval(gamma->pt())); energySum += gamma->energy(); From fcfdd4f9b314812eeecaa140f33d466ddf0da6e0 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 24 Aug 2015 18:33:02 +0200 Subject: [PATCH 088/104] move CSCObjectMap, CSCStationIndex, DTObjectMap, DTStationIndex to their own files in the process: - rename ObjectMap to DTObjectMap - rename ObjectMapCSC to CSCObjectMap - merge multiple copies --- .../RPCRecHit/interface/CSCSegtoRPC.h | 43 ------- .../RPCRecHit/interface/DTSegtoRPC.h | 43 ------- .../RPCRecHit/interface/TracktoRPC.h | 88 +------------- RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc | 56 +++++++++ RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h | 22 ++++ RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc | 49 +------- RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h | 38 ++++++ RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc | 49 ++++++++ RecoLocalMuon/RPCRecHit/src/DTObjectMap.h | 22 ++++ RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc | 45 +------ RecoLocalMuon/RPCRecHit/src/DTStationIndex.h | 38 ++++++ .../RPCRecHit/src/RPCRecHitProducer.h | 1 - RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc | 114 ++---------------- 13 files changed, 243 insertions(+), 365 deletions(-) create mode 100644 RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc create mode 100644 RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h create mode 100644 RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h create mode 100644 RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc create mode 100644 RecoLocalMuon/RPCRecHit/src/DTObjectMap.h create mode 100644 RecoLocalMuon/RPCRecHit/src/DTStationIndex.h diff --git a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h index 2bda1e06527bf..0f58fc0746055 100644 --- a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h @@ -20,47 +20,4 @@ class CSCSegtoRPC { double MaxD; }; -class CSCStationIndex{ -public: - CSCStationIndex():_region(0),_station(0),_ring(0),_chamber(0){} - CSCStationIndex(int region, int station, int ring, int chamber): - _region(region), - _station(station), - _ring(ring), - _chamber(chamber){} - ~CSCStationIndex(){} - int region() const {return _region;} - int station() const {return _station;} - int ring() const {return _ring;} - int chamber() const {return _chamber;} - bool operator<(const CSCStationIndex& cscind) const{ - if(cscind.region()!=this->region()) - return cscind.region()region(); - else if(cscind.station()!=this->station()) - return cscind.station()station(); - else if(cscind.ring()!=this->ring()) - return cscind.ring()ring(); - else if(cscind.chamber()!=this->chamber()) - return cscind.chamber()chamber(); - return false; - } - -private: - int _region; - int _station; - int _ring; - int _chamber; -}; - -class ObjectMapCSC{ -public: - static ObjectMapCSC* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(CSCStationIndex cscstationindex){return mapInstance->rollstoreCSC[cscstationindex];} -//protected: - std::map > rollstoreCSC; - ObjectMapCSC(const edm::EventSetup& iSetup); -private: - static ObjectMapCSC* mapInstance; -}; - #endif diff --git a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h index 2aeb76b69d2ad..f246769f1a925 100644 --- a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h @@ -25,47 +25,4 @@ class DTSegtoRPC { std::vector extrapolatedRolls; }; -class DTStationIndex{ -public: - DTStationIndex():_region(0),_wheel(0),_sector(0),_station(0){} - DTStationIndex(int region, int wheel, int sector, int station) : - _region(region), - _wheel(wheel), - _sector(sector), - _station(station){} - ~DTStationIndex(){} - int region() const {return _region;} - int wheel() const {return _wheel;} - int sector() const {return _sector;} - int station() const {return _station;} - bool operator<(const DTStationIndex& dtind) const{ - if(dtind.region()!=this->region()) - return dtind.region()region(); - else if(dtind.wheel()!=this->wheel()) - return dtind.wheel()wheel(); - else if(dtind.sector()!=this->sector()) - return dtind.sector()sector(); - else if(dtind.station()!=this->station()) - return dtind.station()station(); - return false; - } - -private: - int _region; - int _wheel; - int _sector; - int _station; -}; - -class ObjectMap{ -public: - static ObjectMap* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(DTStationIndex dtstationindex){return mapInstance->rollstoreDT[dtstationindex];} -//protected: - std::map > rollstoreDT; - ObjectMap(const edm::EventSetup& iSetup); -private: - static ObjectMap* mapInstance; -}; - #endif diff --git a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h index 4b4d9374c84f7..9bc2279126dd8 100644 --- a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h @@ -51,8 +51,7 @@ #include "TrackingTools/TrackRefitter/interface/TrackTransformerForCosmicMuons.h" #include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h" #include "TrackingTools/TrackRefitter/interface/TrackTransformer.h" -//#include "RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h" -//#include "RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h" + using reco::MuonCollection; using reco::TrackCollection; @@ -77,89 +76,4 @@ class TracktoRPC { edm::ESHandle thePropagator; }; -class DTStationIndex2{ -public: - DTStationIndex2():_region(0),_wheel(0),_sector(0),_station(0){} - DTStationIndex2(int region, int wheel, int sector, int station) : - _region(region), - _wheel(wheel), - _sector(sector), - _station(station){} - ~DTStationIndex2(){} - int region() const {return _region;} - int wheel() const {return _wheel;} - int sector() const {return _sector;} - int station() const {return _station;} - bool operator<(const DTStationIndex2& dtind) const{ - if(dtind.region()!=this->region()) - return dtind.region()region(); - else if(dtind.wheel()!=this->wheel()) - return dtind.wheel()wheel(); - else if(dtind.sector()!=this->sector()) - return dtind.sector()sector(); - else if(dtind.station()!=this->station()) - return dtind.station()station(); - return false; - } - -private: - int _region; - int _wheel; - int _sector; - int _station; -}; - -class ObjectMap2{ -public: - static ObjectMap2* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(DTStationIndex2 dtstationindex){return mapInstance->rollstoreDT[dtstationindex];} -//protected: - std::map > rollstoreDT; - ObjectMap2(const edm::EventSetup& iSetup); -private: - static ObjectMap2* mapInstance; -}; -class CSCStationIndex2{ -public: - CSCStationIndex2():_region(0),_station(0),_ring(0),_chamber(0){} - CSCStationIndex2(int region, int station, int ring, int chamber): - _region(region), - _station(station), - _ring(ring), - _chamber(chamber){} - ~CSCStationIndex2(){} - int region() const {return _region;} - int station() const {return _station;} - int ring() const {return _ring;} - int chamber() const {return _chamber;} - bool operator<(const CSCStationIndex2& cscind) const{ - if(cscind.region()!=this->region()) - return cscind.region()region(); - else if(cscind.station()!=this->station()) - return cscind.station()station(); - else if(cscind.ring()!=this->ring()) - return cscind.ring()ring(); - else if(cscind.chamber()!=this->chamber()) - return cscind.chamber()chamber(); - return false; - } - -private: - int _region; - int _station; - int _ring; - int _chamber; -}; - -class ObjectMap2CSC{ -public: - static ObjectMap2CSC* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(CSCStationIndex2 cscstationindex){return mapInstance->rollstoreCSC[cscstationindex];} -//protected: - std::map > rollstoreCSC; - ObjectMap2CSC(const edm::EventSetup& iSetup); -private: - static ObjectMap2CSC* mapInstance; -}; - #endif diff --git a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc new file mode 100644 index 0000000000000..c8f0225579baf --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc @@ -0,0 +1,56 @@ +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +#include "Geometry/RPCGeometry/interface/RPCChamber.h" +#include "Geometry/RPCGeometry/interface/RPCRoll.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" + +CSCObjectMap* CSCObjectMap::mapInstance = NULL; + +CSCObjectMap* CSCObjectMap::GetInstance(const edm::EventSetup& iSetup){ + if (mapInstance == NULL){ + mapInstance = new CSCObjectMap(iSetup); + } + return mapInstance; +} + +CSCObjectMap::CSCObjectMap(const edm::EventSetup& iSetup){ + edm::ESHandle rpcGeo; + edm::ESHandle cscGeo; + + iSetup.get().get(rpcGeo); + iSetup.get().get(cscGeo); + + for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ + if(dynamic_cast< const RPCChamber* >( *it ) != 0 ){ + auto ch = dynamic_cast< const RPCChamber* >( *it ); + std::vector< const RPCRoll*> roles = (ch->rolls()); + for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ + RPCDetId rpcId = (*r)->id(); + int region=rpcId.region(); + if(region!=0){ + int station=rpcId.station(); + int ring=rpcId.ring(); + int cscring=ring; + int cscstation=station; + RPCGeomServ rpcsrv(rpcId); + int rpcsegment = rpcsrv.segment(); + int cscchamber = rpcsegment; //FIX THIS ACCORDING TO RPCGeomServ::segment()Definition + if((station==2||station==3)&&ring==3){//Adding Ring 3 of RPC to the CSC Ring 2 + cscring = 2; + } + CSCStationIndex ind(region,cscstation,cscring,cscchamber); + std::set myrolls; + if (rollstoreCSC.find(ind)!=rollstoreCSC.end()) myrolls=rollstoreCSC[ind]; + myrolls.insert(rpcId); + rollstoreCSC[ind]=myrolls; + } + } + } + } +} diff --git a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h new file mode 100644 index 0000000000000..d28e6e85a1730 --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h @@ -0,0 +1,22 @@ +#ifndef RecoLocalMuon_RPCRecHit_CSCObjectMap_h +#define RecoLocalMuon_RPCRecHit_CSCObjectMap_h + +#include "FWCore/Framework/interface/EventSetup.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" + +#include +#include + +class CSCObjectMap{ +public: + static CSCObjectMap* GetInstance(const edm::EventSetup& iSetup); + std::set GetRolls(CSCStationIndex cscstationindex){return mapInstance->rollstoreCSC[cscstationindex];} + std::map > rollstoreCSC; + CSCObjectMap(const edm::EventSetup& iSetup); + +private: + static CSCObjectMap* mapInstance; +}; + +#endif // RecoLocalMuon_RPCRecHit_CSCObjectMap_h diff --git a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc index d540908501ed3..fbadb7e4813a7 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc @@ -10,52 +10,9 @@ #include #include #include +#include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" -ObjectMapCSC* ObjectMapCSC::mapInstance = NULL; - -ObjectMapCSC* ObjectMapCSC::GetInstance(const edm::EventSetup& iSetup){ - if (mapInstance == NULL){ - mapInstance = new ObjectMapCSC(iSetup); - } - return mapInstance; -} - -ObjectMapCSC::ObjectMapCSC(const edm::EventSetup& iSetup){ - edm::ESHandle rpcGeo; - edm::ESHandle cscGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(cscGeo); - - for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ - if(dynamic_cast< const RPCChamber* >( *it ) != 0 ){ - auto ch = dynamic_cast< const RPCChamber* >( *it ); - std::vector< const RPCRoll*> roles = (ch->rolls()); - for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ - RPCDetId rpcId = (*r)->id(); - int region=rpcId.region(); - if(region!=0){ - int station=rpcId.station(); - int ring=rpcId.ring(); - int cscring=ring; - int cscstation=station; - RPCGeomServ rpcsrv(rpcId); - int rpcsegment = rpcsrv.segment(); - int cscchamber = rpcsegment; //FIX THIS ACCORDING TO RPCGeomServ::segment()Definition - if((station==2||station==3)&&ring==3){//Adding Ring 3 of RPC to the CSC Ring 2 - cscring = 2; - } - CSCStationIndex ind(region,cscstation,cscring,cscchamber); - std::set myrolls; - if (rollstoreCSC.find(ind)!=rollstoreCSC.end()) myrolls=rollstoreCSC[ind]; - myrolls.insert(rpcId); - rollstoreCSC[ind]=myrolls; - } - } - } - } -} - CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const edm::EventSetup& iSetup,const edm::Event& iEvent, bool debug, double eyr){ edm::ESHandle rpcGeo; @@ -128,7 +85,7 @@ CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const float dz=segmentDirection.z(); if(debug) std::cout<<"Calling to Object Map class"<region()) + return cscind.region()region(); + else if(cscind.station()!=this->station()) + return cscind.station()station(); + else if(cscind.ring()!=this->ring()) + return cscind.ring()ring(); + else if(cscind.chamber()!=this->chamber()) + return cscind.chamber()chamber(); + return false; + } + +private: + int _region; + int _station; + int _ring; + int _chamber; +}; + +#endif // RecoLocalMuon_RPCRecHit_CSCStationIndex_h diff --git a/RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc new file mode 100644 index 0000000000000..ea921d472af8e --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc @@ -0,0 +1,49 @@ +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +#include "Geometry/RPCGeometry/interface/RPCChamber.h" +#include "Geometry/RPCGeometry/interface/RPCRoll.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" +#include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" + +DTObjectMap* DTObjectMap::mapInstance = NULL; + +DTObjectMap* DTObjectMap::GetInstance(const edm::EventSetup& iSetup){ + if (mapInstance == NULL){ + mapInstance = new DTObjectMap(iSetup); + } + return mapInstance; +} + +DTObjectMap::DTObjectMap(const edm::EventSetup& iSetup){ + edm::ESHandle rpcGeo; + edm::ESHandle dtGeo; + + iSetup.get().get(rpcGeo); + iSetup.get().get(dtGeo); + + for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ + if(dynamic_cast( *it ) != 0 ){ + auto ch = dynamic_cast( *it ); + std::vector< const RPCRoll*> roles = (ch->rolls()); + for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ + RPCDetId rpcId = (*r)->id(); + int region=rpcId.region(); + if(region==0){ + int wheel=rpcId.ring(); + int sector=rpcId.sector(); + int station=rpcId.station(); + DTStationIndex ind(region,wheel,sector,station); + std::set myrolls; + if (rollstoreDT.find(ind)!=rollstoreDT.end()) myrolls=rollstoreDT[ind]; + myrolls.insert(rpcId); + rollstoreDT[ind]=myrolls; + } + } + } + } +} diff --git a/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h new file mode 100644 index 0000000000000..b5746f42168ab --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h @@ -0,0 +1,22 @@ +#ifndef RecoLocalMuon_RPCRecHit_DTObjectMap_h +#define RecoLocalMuon_RPCRecHit_DTObjectMap_h + +#include "FWCore/Framework/interface/EventSetup.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" + +#include +#include + +class DTObjectMap { +public: + static DTObjectMap* GetInstance(const edm::EventSetup& iSetup); + std::set GetRolls(DTStationIndex dtstationindex){return mapInstance->rollstoreDT[dtstationindex];} + std::map > rollstoreDT; + DTObjectMap(const edm::EventSetup& iSetup); + +private: + static DTObjectMap* mapInstance; +}; + +#endif // RecoLocalMuon_RPCRecHit_DTObjectMap_h diff --git a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc index 8816dc07cde83..7740c58589c07 100644 --- a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc @@ -10,45 +10,10 @@ #include #include #include -#include - -ObjectMap* ObjectMap::mapInstance = NULL; +#include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" +#include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" -ObjectMap* ObjectMap::GetInstance(const edm::EventSetup& iSetup){ - if (mapInstance == NULL){ - mapInstance = new ObjectMap(iSetup); - } - return mapInstance; -} - -ObjectMap::ObjectMap(const edm::EventSetup& iSetup){ - edm::ESHandle rpcGeo; - edm::ESHandle dtGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(dtGeo); - - for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ - if(dynamic_cast( *it ) != 0 ){ - auto ch = dynamic_cast( *it ); - std::vector< const RPCRoll*> roles = (ch->rolls()); - for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ - RPCDetId rpcId = (*r)->id(); - int region=rpcId.region(); - if(region==0){ - int wheel=rpcId.ring(); - int sector=rpcId.sector(); - int station=rpcId.station(); - DTStationIndex ind(region,wheel,sector,station); - std::set myrolls; - if (rollstoreDT.find(ind)!=rollstoreDT.end()) myrolls=rollstoreDT[ind]; - myrolls.insert(rpcId); - rollstoreDT[ind]=myrolls; - } - } - } - } -} +#include int distsector(int sector1,int sector2){ if(sector1==13) sector1=4; @@ -180,7 +145,7 @@ DTSegtoRPC::DTSegtoRPC(edm::Handle all4DSegments, cons float dz=segmentDirection.z(); if(debug) std::cout<<"Calling to Object Map class"< all4DSegments, cons } if(debug) std::cout<<"Calling to Object Map class"<region()) + return dtind.region()region(); + else if(dtind.wheel()!=this->wheel()) + return dtind.wheel()wheel(); + else if(dtind.sector()!=this->sector()) + return dtind.sector()sector(); + else if(dtind.station()!=this->station()) + return dtind.station()station(); + return false; + } + +private: + int _region; + int _wheel; + int _sector; + int _station; +}; + +#endif // RecoLocalMuon_RPCRecHit_DTStationIndex_h diff --git a/RecoLocalMuon/RPCRecHit/src/RPCRecHitProducer.h b/RecoLocalMuon/RPCRecHit/src/RPCRecHitProducer.h index c21a8cb845e6d..898942ba8e852 100644 --- a/RecoLocalMuon/RPCRecHit/src/RPCRecHitProducer.h +++ b/RecoLocalMuon/RPCRecHit/src/RPCRecHitProducer.h @@ -61,7 +61,6 @@ class RPCRecHitProducer : public edm::stream::EDProducer<> { // The reconstruction algorithm RPCRecHitBaseAlgo *theAlgo; -// static std::string theAlgoName; RPCMaskedStrips* RPCMaskedStripsObj; // Object with mask-strips-vector for all the RPC Detectors diff --git a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc index 76db3a7d7ad81..3c91f0eb54a50 100644 --- a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc @@ -9,112 +9,16 @@ #include #include #include -//#include "RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h" -//#include "RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h" #include #include +#include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" +#include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" + #include #include -ObjectMap2* ObjectMap2::mapInstance = NULL; - -ObjectMap2* ObjectMap2::GetInstance(const edm::EventSetup& iSetup){ - if (mapInstance == NULL){ - mapInstance = new ObjectMap2(iSetup); - } - return mapInstance; -} - -ObjectMap2::ObjectMap2(const edm::EventSetup& iSetup){ - edm::ESHandle rpcGeo; - edm::ESHandle dtGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(dtGeo); - - for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ - if(dynamic_cast< RPCChamber const * >( *it ) != 0 ){ - auto ch = dynamic_cast( *it ); - std::vector< const RPCRoll*> roles = (ch->rolls()); - for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ - RPCDetId rpcId = (*r)->id(); - int region=rpcId.region(); - if(region==0){ - int wheel=rpcId.ring(); - int sector=rpcId.sector(); - int station=rpcId.station(); - DTStationIndex2 ind(region,wheel,sector,station); - std::set myrolls; - if (rollstoreDT.find(ind)!=rollstoreDT.end()) myrolls=rollstoreDT[ind]; - myrolls.insert(rpcId); - rollstoreDT[ind]=myrolls; - } - } - } - } -} - -int distsector2(int sector1,int sector2){ - if(sector1==13) sector1=4; - if(sector1==14) sector1=10; - - if(sector2==13) sector2=4; - if(sector2==14) sector2=10; - - int distance = std::abs(sector1 - sector2); - if(distance>6) distance = 12-distance; - return distance; -} - -int distwheel2(int wheel1,int wheel2){ - int distance = std::abs(wheel1 - wheel2); - return distance; -} -ObjectMap2CSC* ObjectMap2CSC::mapInstance = NULL; - -ObjectMap2CSC* ObjectMap2CSC::GetInstance(const edm::EventSetup& iSetup){ - if (mapInstance == NULL){ - mapInstance = new ObjectMap2CSC(iSetup); - } - return mapInstance; -} - -ObjectMap2CSC::ObjectMap2CSC(const edm::EventSetup& iSetup){ - edm::ESHandle rpcGeo; - edm::ESHandle cscGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(cscGeo); - - for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ - if(dynamic_cast< const RPCChamber* >( *it ) != 0 ){ - const RPCChamber* ch = dynamic_cast< const RPCChamber* >( *it ); - std::vector< const RPCRoll*> roles = (ch->rolls()); - for(std::vector::const_iterator r = roles.begin();r != roles.end(); ++r){ - RPCDetId rpcId = (*r)->id(); - int region=rpcId.region(); - if(region!=0){ - int station=rpcId.station(); - int ring=rpcId.ring(); - int cscring=ring; - int cscstation=station; - RPCGeomServ rpcsrv(rpcId); - int rpcsegment = rpcsrv.segment(); - int cscchamber = rpcsegment; //FIX THIS ACCORDING TO RPCGeomServ::segment()Definition - if((station==2||station==3)&&ring==3){//Adding Ring 3 of RPC to the CSC Ring 2 - cscring = 2; - } - CSCStationIndex2 ind(region,cscstation,cscring,cscchamber); - std::set myrolls; - if (rollstoreCSC.find(ind)!=rollstoreCSC.end()) myrolls=rollstoreCSC[ind]; - myrolls.insert(rpcId); - rollstoreCSC[ind]=myrolls; - } - } - } - } -} - bool TracktoRPC::ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup& iSetup) { edm::ESHandle rpcGeo; @@ -217,8 +121,8 @@ for(trackingRecHit_iterator hit=track->recHitsBegin(); hit != track->recHitsEnd( DTChamberId dtid(geomDet->geographicalId().rawId()); int dtW=dtid.wheel(), dtS=dtid.sector(), dtT=dtid.station(); if(dtS==13) dtS=4; if(dtS==14) dtS=10; - ObjectMap2* TheObject = ObjectMap2::GetInstance(iSetup); - DTStationIndex2 theindex(0,dtW,dtS,dtT); + DTObjectMap* TheObject = DTObjectMap::GetInstance(iSetup); + DTStationIndex theindex(0,dtW,dtS,dtT); std::set rollsForThisDT = TheObject->GetInstance(iSetup)->GetRolls(theindex); for(std::set::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++) { @@ -264,12 +168,12 @@ for(trackingRecHit_iterator hit=track->recHitsBegin(); hit != track->recHitsEnd( float dx = trajLP.x()-trackLP.x(), dy=trajLP.y()-trackLP.y();//, dz=trajLP.z()-trackLP.z(); if( dx>10. && dy>10.) continue; - ObjectMap2CSC* TheObjectCSC = ObjectMap2CSC::GetInstance(iSetup); + CSCObjectMap* TheObjectCSC = CSCObjectMap::GetInstance(iSetup); int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring(); int rpcSegment = cscid.chamber(); if(En==2) En= -1; if(Ri==4) Ri =1; - CSCStationIndex2 theindex(En,St,Ri,rpcSegment); + CSCStationIndex theindex(En,St,Ri,rpcSegment); std::set rollsForThisCSC = TheObjectCSC->GetInstance(iSetup)->GetRolls(theindex); for (std::set::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++) { From 51d50fff9d2dbd72a9072df045b88302bcd5dde4 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 24 Aug 2015 20:28:56 +0200 Subject: [PATCH 089/104] move DTObjectMap and CSCObjectMap to the EventSetup --- .../RPCRecHit/python/rpcPointProducer_cff.py | 8 ++++ RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc | 35 ++++++++++-------- RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h | 12 +++--- .../RPCRecHit/src/CSCObjectMapESProducer.cc | 37 +++++++++++++++++++ RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc | 9 ++--- RecoLocalMuon/RPCRecHit/src/DTObjectMap.cc | 35 ++++++++++-------- RecoLocalMuon/RPCRecHit/src/DTObjectMap.h | 10 ++--- .../RPCRecHit/src/DTObjectMapESProducer.cc | 37 +++++++++++++++++++ RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc | 12 ++---- RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc | 10 +++-- 10 files changed, 145 insertions(+), 60 deletions(-) create mode 100644 RecoLocalMuon/RPCRecHit/python/rpcPointProducer_cff.py create mode 100644 RecoLocalMuon/RPCRecHit/src/CSCObjectMapESProducer.cc create mode 100644 RecoLocalMuon/RPCRecHit/src/DTObjectMapESProducer.cc diff --git a/RecoLocalMuon/RPCRecHit/python/rpcPointProducer_cff.py b/RecoLocalMuon/RPCRecHit/python/rpcPointProducer_cff.py new file mode 100644 index 0000000000000..79f00ebe4429f --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/python/rpcPointProducer_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +# EventSetup modules +from RecoLocalMuon.RPCRecHit.cscObjectMapESProducer_cfi import * +from RecoLocalMuon.RPCRecHit.dtObjectMapESProducer_cfi import * + +# EDProducer +from RecoLocalMuon.RPCRecHit.rpcPointProducer_cfi import * diff --git a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc index c8f0225579baf..4cadc4001c8b2 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc +++ b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "Geometry/RPCGeometry/interface/RPCGeomServ.h" @@ -10,21 +9,12 @@ #include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" #include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" -CSCObjectMap* CSCObjectMap::mapInstance = NULL; - -CSCObjectMap* CSCObjectMap::GetInstance(const edm::EventSetup& iSetup){ - if (mapInstance == NULL){ - mapInstance = new CSCObjectMap(iSetup); - } - return mapInstance; -} - -CSCObjectMap::CSCObjectMap(const edm::EventSetup& iSetup){ +CSCObjectMap::CSCObjectMap(MuonGeometryRecord const& record){ edm::ESHandle rpcGeo; + record.get(rpcGeo); + edm::ESHandle cscGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(cscGeo); + record.get(cscGeo); for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ if(dynamic_cast< const RPCChamber* >( *it ) != 0 ){ @@ -46,11 +36,24 @@ CSCObjectMap::CSCObjectMap(const edm::EventSetup& iSetup){ } CSCStationIndex ind(region,cscstation,cscring,cscchamber); std::set myrolls; - if (rollstoreCSC.find(ind)!=rollstoreCSC.end()) myrolls=rollstoreCSC[ind]; + if (rollstore.find(ind)!=rollstore.end()) myrolls=rollstore[ind]; myrolls.insert(rpcId); - rollstoreCSC[ind]=myrolls; + rollstore[ind]=myrolls; } } } } } + +std::set const& CSCObjectMap::getRolls(CSCStationIndex index) const +{ + // FIXME + // the present inplementation allows for NOT finding the given index in the map; + // a muon expert should check that this is the intended behaviour. + static const std::set empty; + return (rollstore.find(index) == rollstore.end()) ? empty : rollstore.at(index); +} + +// register the class with the typelookup system used by the EventSetup +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(CSCObjectMap); diff --git a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h index d28e6e85a1730..3b1e285e72377 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h +++ b/RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h @@ -3,20 +3,20 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" #include #include -class CSCObjectMap{ +class CSCObjectMap { public: - static CSCObjectMap* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(CSCStationIndex cscstationindex){return mapInstance->rollstoreCSC[cscstationindex];} - std::map > rollstoreCSC; - CSCObjectMap(const edm::EventSetup& iSetup); + CSCObjectMap(MuonGeometryRecord const& record); + + std::set const& getRolls(CSCStationIndex index) const; private: - static CSCObjectMap* mapInstance; + std::map> rollstore; }; #endif // RecoLocalMuon_RPCRecHit_CSCObjectMap_h diff --git a/RecoLocalMuon/RPCRecHit/src/CSCObjectMapESProducer.cc b/RecoLocalMuon/RPCRecHit/src/CSCObjectMapESProducer.cc new file mode 100644 index 0000000000000..e10e5e579564d --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/CSCObjectMapESProducer.cc @@ -0,0 +1,37 @@ +// system include files +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" + +class CSCObjectMapESProducer : public edm::ESProducer { +public: + CSCObjectMapESProducer(const edm::ParameterSet&) { + setWhatProduced(this); + } + + ~CSCObjectMapESProducer() { + } + + boost::shared_ptr produce(MuonGeometryRecord const& record) { + return boost::make_shared(record); + } + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + descriptions.add("cscObjectMapESProducer", desc); + } + +}; + +//define this as a plug-in +#include "FWCore/Framework/interface/ModuleFactory.h" +DEFINE_FWK_EVENTSETUP_MODULE(CSCObjectMapESProducer); diff --git a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc index fbadb7e4813a7..c7d3de14bb9cc 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc @@ -17,9 +17,11 @@ CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const edm::ESHandle rpcGeo; edm::ESHandle cscGeo; + edm::ESHandle cscMap; iSetup.get().get(rpcGeo); iSetup.get().get(cscGeo); + iSetup.get().get(cscMap); MaxD=80.; @@ -84,15 +86,10 @@ CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const float dy=segmentDirection.y(); float dz=segmentDirection.z(); - if(debug) std::cout<<"Calling to Object Map class"< rollsForThisCSC = TheObjectCSC->GetInstance(iSetup)->GetRolls(theindex); - - + std::set rollsForThisCSC = cscMap->getRolls(theindex); if(debug) std::cout<<"CSC \t \t Getting chamber from Geometry"<chamber(CSCId); if(debug) std::cout<<"CSC \t \t Getting ID from Chamber"< rpcGeo; + record.get(rpcGeo); + edm::ESHandle dtGeo; - - iSetup.get().get(rpcGeo); - iSetup.get().get(dtGeo); + record.get(dtGeo); for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();itdets().end();it++){ if(dynamic_cast( *it ) != 0 ){ @@ -39,11 +31,24 @@ DTObjectMap::DTObjectMap(const edm::EventSetup& iSetup){ int station=rpcId.station(); DTStationIndex ind(region,wheel,sector,station); std::set myrolls; - if (rollstoreDT.find(ind)!=rollstoreDT.end()) myrolls=rollstoreDT[ind]; + if (rollstore.find(ind)!=rollstore.end()) myrolls=rollstore[ind]; myrolls.insert(rpcId); - rollstoreDT[ind]=myrolls; + rollstore[ind]=myrolls; } } } } } + +std::set const& DTObjectMap::getRolls(DTStationIndex index) const +{ + // FIXME + // the present inplementation allows for NOT finding the given index in the map; + // a muon expert should check that this is the intended behaviour. + static const std::set empty; + return (rollstore.find(index) == rollstore.end()) ? empty : rollstore.at(index); +} + +// register the class with the typelookup system used by the EventSetup +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(DTObjectMap); diff --git a/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h index b5746f42168ab..1335cae2e4e1d 100644 --- a/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h +++ b/RecoLocalMuon/RPCRecHit/src/DTObjectMap.h @@ -3,6 +3,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" #include @@ -10,13 +11,12 @@ class DTObjectMap { public: - static DTObjectMap* GetInstance(const edm::EventSetup& iSetup); - std::set GetRolls(DTStationIndex dtstationindex){return mapInstance->rollstoreDT[dtstationindex];} - std::map > rollstoreDT; - DTObjectMap(const edm::EventSetup& iSetup); + DTObjectMap(MuonGeometryRecord const& record); + + std::set const & getRolls(DTStationIndex index) const; private: - static DTObjectMap* mapInstance; + std::map> rollstore; }; #endif // RecoLocalMuon_RPCRecHit_DTObjectMap_h diff --git a/RecoLocalMuon/RPCRecHit/src/DTObjectMapESProducer.cc b/RecoLocalMuon/RPCRecHit/src/DTObjectMapESProducer.cc new file mode 100644 index 0000000000000..6884d7aff28f1 --- /dev/null +++ b/RecoLocalMuon/RPCRecHit/src/DTObjectMapESProducer.cc @@ -0,0 +1,37 @@ +// system include files +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" + +class DTObjectMapESProducer : public edm::ESProducer { +public: + DTObjectMapESProducer(const edm::ParameterSet&) { + setWhatProduced(this); + } + + ~DTObjectMapESProducer() { + } + + boost::shared_ptr produce(MuonGeometryRecord const& record) { + return boost::make_shared(record); + } + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + descriptions.add("dtObjectMapESProducer", desc); + } + +}; + +//define this as a plug-in +#include "FWCore/Framework/interface/ModuleFactory.h" +DEFINE_FWK_EVENTSETUP_MODULE(DTObjectMapESProducer); diff --git a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc index 7740c58589c07..c2ae657958592 100644 --- a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc @@ -69,9 +69,11 @@ DTSegtoRPC::DTSegtoRPC(edm::Handle all4DSegments, cons }else{ edm::ESHandle rpcGeo; edm::ESHandle dtGeo; + edm::ESHandle dtMap; iSetup.get().get(rpcGeo); iSetup.get().get(dtGeo); + iSetup.get().get(dtMap); /* clock_gettime(CLOCK_REALTIME, &stop_time); @@ -144,13 +146,10 @@ DTSegtoRPC::DTSegtoRPC(edm::Handle all4DSegments, cons float dy=segmentDirection.y(); float dz=segmentDirection.z(); - if(debug) std::cout<<"Calling to Object Map class"< rollsForThisDT = TheObject->GetInstance(iSetup)->GetRolls(theindex); + std::set rollsForThisDT = dtMap->getRolls(theindex); if(debug) std::cout<<"DT \t \t Number of rolls for this DT = "< all4DSegments, cons dtSector=10; } - if(debug) std::cout<<"Calling to Object Map class"< rollsForThisDT = TheObject->GetInstance(iSetup)->GetRolls(theindex); + std::set rollsForThisDT = dtMap->getRolls(theindex); if(debug) std::cout<<"MB4 \t \t Number of rolls for this DT = "< alltracks, const edm:: edm::ESHandle rpcGeo; edm::ESHandle dtGeo; + edm::ESHandle dtMap; edm::ESHandle cscGeo; + edm::ESHandle cscMap; iSetup.get().get("SteppingHelixPropagatorAny",thePropagator); iSetup.get().get(rpcGeo); iSetup.get().get(dtGeo); + iSetup.get().get(dtMap); iSetup.get().get(cscGeo); + iSetup.get().get(cscMap); std::vector rpcput; double MaxD=999.; @@ -121,9 +125,8 @@ for(trackingRecHit_iterator hit=track->recHitsBegin(); hit != track->recHitsEnd( DTChamberId dtid(geomDet->geographicalId().rawId()); int dtW=dtid.wheel(), dtS=dtid.sector(), dtT=dtid.station(); if(dtS==13) dtS=4; if(dtS==14) dtS=10; - DTObjectMap* TheObject = DTObjectMap::GetInstance(iSetup); DTStationIndex theindex(0,dtW,dtS,dtT); - std::set rollsForThisDT = TheObject->GetInstance(iSetup)->GetRolls(theindex); + std::set rollsForThisDT = dtMap->getRolls(theindex); for(std::set::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++) { const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll); @@ -168,13 +171,12 @@ for(trackingRecHit_iterator hit=track->recHitsBegin(); hit != track->recHitsEnd( float dx = trajLP.x()-trackLP.x(), dy=trajLP.y()-trackLP.y();//, dz=trajLP.z()-trackLP.z(); if( dx>10. && dy>10.) continue; - CSCObjectMap* TheObjectCSC = CSCObjectMap::GetInstance(iSetup); int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring(); int rpcSegment = cscid.chamber(); if(En==2) En= -1; if(Ri==4) Ri =1; CSCStationIndex theindex(En,St,Ri,rpcSegment); - std::set rollsForThisCSC = TheObjectCSC->GetInstance(iSetup)->GetRolls(theindex); + std::set rollsForThisCSC = cscMap->getRolls(theindex); for (std::set::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++) { const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll); From 9659695a0b899cfe3c836b97e5c7e3d7007621c9 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Sun, 23 Aug 2015 22:15:39 +0200 Subject: [PATCH 090/104] RPCPointProducer: change into a global::EDProducer - change all configuration parameters into const members - initialise them in the member initializer list - remove unused methods and member variables - change into a global::EDProducer --- .../RPCRecHit/interface/RPCPointProducer.h | 43 ++++++------- .../RPCRecHit/interface/TracktoRPC.h | 2 +- .../RPCRecHit/src/RPCPointProducer.cc | 60 +++++-------------- RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc | 2 +- 4 files changed, 36 insertions(+), 71 deletions(-) diff --git a/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h b/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h index 857b7539041bd..063b9fe5b24a8 100644 --- a/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h +++ b/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h @@ -1,5 +1,5 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -19,31 +19,26 @@ // class decleration // -class RPCPointProducer : public edm::EDProducer { +class RPCPointProducer : public edm::global::EDProducer<> { public: explicit RPCPointProducer(const edm::ParameterSet&); - ~RPCPointProducer(); - // edm::InputTag cscSegments; - edm::EDGetTokenT cscSegments; - edm::EDGetTokenT dt4DSegments; - // edm::InputTag dt4DSegments; - edm::EDGetTokenT tracks; - edm::InputTag tracks_; + private: - virtual void beginJob() ; - virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - bool incldt; - bool inclcsc; - bool incltrack; - bool debug; - double MinCosAng; - double MaxD; - double MaxDrb4; - double MaxDistanceBetweenSegments; - double ExtrapolatedRegion; - edm::ParameterSet trackTransformerParam; - edm::ParameterSet serviceParameters; - // ----------member data --------------------------- + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + + const edm::EDGetTokenT cscSegments; + const edm::EDGetTokenT dt4DSegments; + const edm::EDGetTokenT tracks; + const edm::InputTag tracks_; + + const bool incldt; + const bool inclcsc; + const bool incltrack; + const bool debug; + const double MinCosAng; + const double MaxD; + const double MaxDrb4; + const double ExtrapolatedRegion; + const edm::ParameterSet trackTransformerParam; }; diff --git a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h index 9bc2279126dd8..6bcf5ade1fd11 100644 --- a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h @@ -61,7 +61,7 @@ class TracktoRPC { public: - explicit TracktoRPC(edm::Handle alltracks,const edm::EventSetup& iSetup, const edm::Event& iEvent,bool debug, const edm::ParameterSet& iConfig,edm::InputTag& tracklabel); + explicit TracktoRPC(edm::Handle alltracks,const edm::EventSetup& iSetup, const edm::Event& iEvent,bool debug, const edm::ParameterSet& iConfig, const edm::InputTag & tracklabel); ~TracktoRPC(); RPCRecHitCollection* thePoints(){return _ThePoints;} diff --git a/RecoLocalMuon/RPCRecHit/src/RPCPointProducer.cc b/RecoLocalMuon/RPCRecHit/src/RPCPointProducer.cc index ba6eb52072dca..6459ab853879a 100644 --- a/RecoLocalMuon/RPCRecHit/src/RPCPointProducer.cc +++ b/RecoLocalMuon/RPCRecHit/src/RPCPointProducer.cc @@ -25,44 +25,27 @@ // user include files -RPCPointProducer::RPCPointProducer(const edm::ParameterSet& iConfig) +RPCPointProducer::RPCPointProducer(const edm::ParameterSet& iConfig) : + cscSegments( consumes(iConfig.getParameter("cscSegments")) ), + dt4DSegments( consumes(iConfig.getParameter("dt4DSegments")) ), + tracks( consumes(iConfig.getParameter("tracks")) ), + tracks_( iConfig.getParameter("tracks") ), + incldt( iConfig.getUntrackedParameter("incldt", true) ), + inclcsc( iConfig.getUntrackedParameter("inclcsc", true) ), + incltrack( iConfig.getUntrackedParameter("incltrack", true) ), + debug( iConfig.getUntrackedParameter("debug", false) ), + MinCosAng( iConfig.getUntrackedParameter("MinCosAng", 0.95) ), + MaxD( iConfig.getUntrackedParameter("MaxD", 80.) ), + MaxDrb4( iConfig.getUntrackedParameter("MaxDrb4", 150.) ), + ExtrapolatedRegion( iConfig.getUntrackedParameter("ExtrapolatedRegion", 0.5) ), + trackTransformerParam( iConfig.getParameter("TrackTransformer") ) { - cscSegments = consumes(iConfig.getParameter("cscSegments")); - - dt4DSegments = consumes(iConfig.getParameter("dt4DSegments")); - tracks = consumes(iConfig.getParameter("tracks")); - tracks_ = iConfig.getParameter("tracks"); - - debug=iConfig.getUntrackedParameter("debug",false); - incldt=iConfig.getUntrackedParameter("incldt",true); - inclcsc=iConfig.getUntrackedParameter("inclcsc",true); - incltrack=iConfig.getUntrackedParameter("incltrack",true); - MinCosAng=iConfig.getUntrackedParameter("MinCosAng",0.95); - MaxD=iConfig.getUntrackedParameter("MaxD",80.); - MaxDrb4=iConfig.getUntrackedParameter("MaxDrb4",150.); - ExtrapolatedRegion=iConfig.getUntrackedParameter("ExtrapolatedRegion",0.5); - produces("RPCDTExtrapolatedPoints"); produces("RPCCSCExtrapolatedPoints"); produces("RPCTrackExtrapolatedPoints"); - trackTransformerParam = iConfig.getParameter("TrackTransformer"); } - -RPCPointProducer::~RPCPointProducer(){ - -} - -void RPCPointProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){ - /* - struct timespec start_time, stop_time; - time_t fs; - time_t fn; - time_t ls; - time_t ln; - clock_gettime(CLOCK_REALTIME, &start_time); - */ - +void RPCPointProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { if(incldt){ edm::Handle all4DSegments; iEvent.getByToken(dt4DSegments, all4DSegments); @@ -99,16 +82,3 @@ void RPCPointProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup } } - -// ------------ method called once each job just before starting event loop ------------ -void -RPCPointProducer::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -RPCPointProducer::endJob() { -} - - diff --git a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc index 03308fee1c203..a2200739748af 100644 --- a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc @@ -52,7 +52,7 @@ bool TracktoRPC::ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::E } else return false; } -TracktoRPC::TracktoRPC(edm::Handle alltracks, const edm::EventSetup& iSetup,const edm::Event& iEvent,bool debug,const edm::ParameterSet& iConfig,edm::InputTag& tracklabel){ +TracktoRPC::TracktoRPC(edm::Handle alltracks, const edm::EventSetup& iSetup,const edm::Event& iEvent,bool debug,const edm::ParameterSet& iConfig, const edm::InputTag& tracklabel){ _ThePoints = new RPCRecHitCollection(); // if(alltracks->empty()) return; From a280cca0cc0b6f516edaeaf4b2fa4b3fe5f7f50d Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 25 Aug 2015 02:56:06 +0200 Subject: [PATCH 091/104] fix #include syntax --- .../RPCRecHit/interface/CSCSegtoRPC.h | 6 ++--- .../RPCRecHit/interface/DTSegtoRPC.h | 6 ++--- .../RPCRecHit/interface/RPCPointProducer.h | 6 ++--- .../RPCRecHit/interface/TracktoRPC.h | 2 -- RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc | 21 ++++++++--------- RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc | 21 ++++++++--------- RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc | 23 +++++++++---------- .../RPCRecHit/test/RPCRecHitReader.cc | 14 +++++------ 8 files changed, 47 insertions(+), 52 deletions(-) diff --git a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h index 0f58fc0746055..f161159542dee 100644 --- a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h @@ -1,12 +1,12 @@ #ifndef CSCSEGTORPC_H #define CSCSEGTORPC_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" - class CSCSegtoRPC { public: explicit CSCSegtoRPC(edm::Handle allCSCSegments,const edm::EventSetup& iSetup, const edm::Event& iEvent, bool debug, double eyr); diff --git a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h index f246769f1a925..cc9f59ab4ce90 100644 --- a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h @@ -1,12 +1,12 @@ #ifndef DTSEGTORPC_H #define DTSEGTORPC_H - -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" - class DTSegtoRPC { public: explicit DTSegtoRPC(edm::Handle all4DSegments,const edm::EventSetup& iSetup, const edm::Event& iEvent,bool debug, double eyr); diff --git a/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h b/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h index 063b9fe5b24a8..18f209ca01989 100644 --- a/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h +++ b/RecoLocalMuon/RPCRecHit/interface/RPCPointProducer.h @@ -5,11 +5,11 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include -#include +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" #include "FWCore/Framework/interface/ESHandle.h" -#include +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h" #include "RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h" diff --git a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h index 6bcf5ade1fd11..b90aac0f939d8 100644 --- a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h @@ -3,8 +3,6 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc index c7d3de14bb9cc..59b29c9e0fe11 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc @@ -1,15 +1,14 @@ -#include -#include -#include -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" #include "FWCore/Framework/interface/ESHandle.h" -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h" #include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" #include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" diff --git a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc index c2ae657958592..ca5e253c2257a 100644 --- a/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc @@ -1,15 +1,14 @@ -#include -#include -#include -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonTopologies/interface/RectangularStripTopology.h" #include "FWCore/Framework/interface/ESHandle.h" -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h" #include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" #include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" diff --git a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc index a2200739748af..f9611c109d914 100644 --- a/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc @@ -1,16 +1,15 @@ -#include -#include -#include -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonTopologies/interface/RectangularStripTopology.h" #include "FWCore/Framework/interface/ESHandle.h" -#include -#include -#include -#include -#include +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h" #include "RecoLocalMuon/RPCRecHit/src/DTStationIndex.h" #include "RecoLocalMuon/RPCRecHit/src/DTObjectMap.h" #include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" diff --git a/RecoLocalMuon/RPCRecHit/test/RPCRecHitReader.cc b/RecoLocalMuon/RPCRecHit/test/RPCRecHitReader.cc index 6414f21b44a9c..3c4ac49c82b0c 100644 --- a/RecoLocalMuon/RPCRecHit/test/RPCRecHitReader.cc +++ b/RecoLocalMuon/RPCRecHit/test/RPCRecHitReader.cc @@ -19,17 +19,17 @@ #include #include -#include -#include -#include -#include +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" -#include +#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" -#include -#include +#include "Geometry/RPCGeometry/interface/RPCRoll.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" From 3d87d3d74aa809d16711b0ee34e4e0d7ebe1fe6a Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 25 Aug 2015 02:18:08 +0200 Subject: [PATCH 092/104] add CSCObjectMapESProducer and DTObjectMapESProducer to the HLT configuration --- .../Configuration/python/customizeHLTforCMSSW.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 58a731f1ca871..c39e7f2b7aead 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -104,12 +104,24 @@ def customiseFor10234(process): delattr(process.hltCaloStage1Digis, 'FedId') return process + +# migrate RPCPointProducer to a global::EDProducer (PR #10927) +def customiseFor10927(process): + if any(module.type_() is 'RPCPointProducer' for module in process.producers.itervalues()): + if not hasattr(process, 'CSCObjectMapESProducer'): + process.CSCObjectMapESProducer = cms.ESProducer( 'CSCObjectMapESProducer' ) + if not hasattr(process, 'DTObjectMapESProducer'): + process.DTObjectMapESProducer = cms.ESProducer( 'DTObjectMapESProducer' ) + return process + + # CMSSW version specific customizations -def customiseHLTforCMSSW(process,menuType="GRun",fastSim=False): +def customiseHLTforCMSSW(process, menuType="GRun", fastSim=False): import os cmsswVersion = os.environ['CMSSW_VERSION'] if cmsswVersion >= "CMSSW_7_5": + process = customiseFor10927(process) process = customiseFor9232(process) process = customiseFor8679(process) process = customiseFor8356(process) @@ -118,4 +130,5 @@ def customiseHLTforCMSSW(process,menuType="GRun",fastSim=False): process = customizeHLTforNewJetCorrectors(process) if cmsswVersion >= "CMSSW_7_4": process = customiseFor10234(process) + return process From 648574f11047928524defaaed32f4cc47e0e565a Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 25 Aug 2015 03:00:49 +0200 Subject: [PATCH 093/104] add CSCObjectMapESProducer and DTObjectMapESProducer to test configurations --- HLTrigger/special/test/testHLTRPCFilter.py | 2 +- RecoLocalMuon/RPCRecHit/test/testRPCPointProducer.py | 4 ++-- Validation/RPCRecHits/test/rpcRecHitValidation_cfg.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HLTrigger/special/test/testHLTRPCFilter.py b/HLTrigger/special/test/testHLTRPCFilter.py index 987b7f36cf49e..4bfa8fa9498bf 100644 --- a/HLTrigger/special/test/testHLTRPCFilter.py +++ b/HLTrigger/special/test/testHLTRPCFilter.py @@ -31,7 +31,7 @@ fileName = cms.untracked.string('/tmp/carrillo/afterfilter.root') ) -process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cfi") +process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cff") process.load("HLTrigger.special.hltRPCFilter_cfi") process.selrpc = cms.Path(process.rpcPointProducer*process.hltRPCFilter) diff --git a/RecoLocalMuon/RPCRecHit/test/testRPCPointProducer.py b/RecoLocalMuon/RPCRecHit/test/testRPCPointProducer.py index ddd43ccc7ea8c..764097b55c980 100644 --- a/RecoLocalMuon/RPCRecHit/test/testRPCPointProducer.py +++ b/RecoLocalMuon/RPCRecHit/test/testRPCPointProducer.py @@ -13,7 +13,7 @@ process.GlobalTag.globaltag = "START53_V27::All" process.load("Configuration.StandardSequences.Services_cff") -process.load("Configuration.StandardSequences.Geometry_cff") +process.load("Configuration.StandardSequences.GeometryDB_cff") process.load("Configuration.StandardSequences.Reconstruction_cff") process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") @@ -29,7 +29,7 @@ ) -process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cfi") +process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cff") process.rpcPointProducer.tracks = cms.InputTag("cosmicMuons") # for cosmicMuons process.out = cms.OutputModule("PoolOutputModule", diff --git a/Validation/RPCRecHits/test/rpcRecHitValidation_cfg.py b/Validation/RPCRecHits/test/rpcRecHitValidation_cfg.py index 5ac35eeb72275..b9b84b8f46093 100644 --- a/Validation/RPCRecHits/test/rpcRecHitValidation_cfg.py +++ b/Validation/RPCRecHits/test/rpcRecHitValidation_cfg.py @@ -53,7 +53,7 @@ process.load("Validation.RPCRecHits.rpcRecHitValidation_cfi") #### RPCPorintProducer-Reco validation -process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cfi") +process.load("RecoLocalMuon.RPCRecHit.rpcPointProducer_cff") process.load("Validation.RPCRecHits.rpcPointValidation_cfi") process.rpcPointProducerPlusValidation_step = cms.Sequence( From c4d8f786c755b6d0ff12297c5303350508b799e5 Mon Sep 17 00:00:00 2001 From: Sachiko Toda Date: Fri, 28 Aug 2015 01:54:15 +0200 Subject: [PATCH 094/104] adding scal monitoring --- .../clients/scal_dqm_sourceclient-live_cfg.py | 94 +++++++++++++++++++ DQMServices/Components/src/DQMScalInfo.cc | 45 +++++++++ DQMServices/Components/src/DQMScalInfo.h | 10 ++ 3 files changed, 149 insertions(+) create mode 100755 DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py diff --git a/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py new file mode 100755 index 0000000000000..95a91979e9375 --- /dev/null +++ b/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py @@ -0,0 +1,94 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DQM") + +#---------------------------- +#### Event Source +#---------------------------- +# for live online DQM in P5 +process.load("DQM.Integration.config.inputsource_cfi") + +# for testing in lxplus +#process.load("DQM.Integration.config.fileinputsource_cfi") + +#---------------------------- +#### DQM Environment +#---------------------------- +process.load("DQM.Integration.config.environment_cfi") +process.dqmEnv.subSystemFolder = 'Scal' +process.dqmSaver.tag = 'Scal' +#----------------------------- +process.load("DQMServices.Components.DQMScalInfo_cfi") + +# message logger +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet(threshold = cms.untracked.string('WARNING')) + ) + +# Global tag +# Condition for P5 cluster +process.load("DQM.Integration.config.FrontierCondition_GT_cfi") +process.load("EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi") +process.load("EventFilter.L1GlobalTriggerRawToDigi.l1GtEvmUnpack_cfi") +process.load("EventFilter.L1GlobalTriggerRawToDigi.l1GtRecord_cfi") + +import EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi +gtDigis = EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi.l1GtUnpack.clone() +import EventFilter.L1GlobalTriggerRawToDigi.l1GtEvmUnpack_cfi +gtEvmDigis = EventFilter.L1GlobalTriggerRawToDigi.l1GtEvmUnpack_cfi.l1GtEvmUnpack.clone() + +if (process.runType.getRunType() == process.runType.pp_run): + process.source.SelectEvents = cms.untracked.vstring('HLT_ZeroBias*') + +process.physicsBitSelector = cms.EDFilter("PhysDecl", + applyfilter = cms.untracked.bool(False), + debugOn = cms.untracked.bool(False), + HLTriggerResults = cms.InputTag("TriggerResults","","HLT") + ) + + +process.load("EventFilter.ScalersRawToDigi.ScalersRawToDigi_cfi") + +## Collision Reconstruction +process.load("Configuration.StandardSequences.RawToDigi_Data_cff") +#process.load("Configuration.StandardSequences.Reconstruction_cff") + +#----------------------------- +#### Sub-system configuration follows +process.dump = cms.EDAnalyzer('EventContentAnalyzer') + +# DQM Modules +process.dqmmodules = cms.Sequence(process.dqmEnv + process.dqmSaver) +process.evfDQMmodulesPath = cms.Path( + process.l1GtUnpack* + process.gtDigis* + process.l1GtRecord* + process.physicsBitSelector* + process.scalersRawToDigi* + process.dqmscalInfo* + process.dqmmodules + ) +process.schedule = cms.Schedule(process.evfDQMmodulesPath) + +if (process.runType.getRunType() == process.runType.hi_run): + process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.csctfDigis.producer = cms.InputTag("rawDataRepacker") + process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") + process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") + process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") + process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") + process.gtEvmDigis.EvmGtInputTag = cms.InputTag("rawDataRepacker") + process.hcalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.muonCSCDigis.InputObjects = cms.InputTag("rawDataRepacker") + process.muonDTDigis.inputLabel = cms.InputTag("rawDataRepacker") + process.muonRPCDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.scalersRawToDigi.scalersInputTag = cms.InputTag("rawDataRepacker") + process.siPixelDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.siStripDigis.ProductLabel = cms.InputTag("rawDataRepacker") + + +### process customizations included here +from DQM.Integration.config.online_customizations_cfi import * +process = customise(process) diff --git a/DQMServices/Components/src/DQMScalInfo.cc b/DQMServices/Components/src/DQMScalInfo.cc index 4ed89951a11ca..6f6882e4c4fa9 100755 --- a/DQMServices/Components/src/DQMScalInfo.cc +++ b/DQMServices/Components/src/DQMScalInfo.cc @@ -11,6 +11,12 @@ #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h" #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" +#include "DataFormats/Scalers/interface/Level1TriggerScalers.h" +#include "DataFormats/Scalers/interface/Level1TriggerRates.h" +#include "DataFormats/Scalers/interface/ScalersRaw.h" +#include "DataFormats/Scalers/interface/TimeSpec.h" +#include "DataFormats/Scalers/interface/LumiScalers.h" + using namespace std; @@ -25,6 +31,7 @@ DQMScalInfo::DQMScalInfo(const edm::ParameterSet& ps) gtCollection_ = consumes(parameters_.getUntrackedParameter("gtCollection","gtDigis")); dcsStatusCollection_ = consumes(parameters_.getUntrackedParameter("dcsStatusCollection","scalersRawToDigi")); l1tscollectionToken_ = consumes(parameters_.getUntrackedParameter("l1TSCollection", "scalersRawToDigi")); + lumicollectionToken_ = consumes(parameters_.getUntrackedParameter("lumiCollection", "scalersRawToDigi")); } @@ -35,6 +42,8 @@ void DQMScalInfo::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & /* iRun */, edm::EventSetup const & /* iSetup */) { + const int maxNbins = 2001; + // Fetch GlobalTag information and fill the string/ME. ibooker.cd(); ibooker.setCurrentFolder(scalfolder_ +"/L1TriggerScalers/"); @@ -46,10 +55,18 @@ void DQMScalInfo::bookHistograms(DQMStore::IBooker & ibooker, hlstart_ = ibooker.book1D("lstart","Orbit of last Start",fracLS*maxLS,0,maxLS*262144); hlEC0_ = ibooker.book1D("lEC0","Orbit of last EC0",fracLS*maxLS,0,maxLS*262144); hlHR_ = ibooker.book1D("lHR","Orbit of last HardReset",fracLS*maxLS,0,maxLS*262144); + + hphysTrig_ = ibooker.book1D("Physics_Triggers", "Physics Triggers", maxNbins, -0.5, double(maxNbins)-0.5); + hphysTrig_->setAxisTitle("Lumi Section", 1); + + ibooker.cd(); + ibooker.setCurrentFolder(scalfolder_ +"/LumiScalers/"); + hinstLumi_ = ibooker.book1D("Instant_Lumi", "Instant Lumi", maxNbins, -0.5, double(maxNbins)-0.5); } void DQMScalInfo::analyze(const edm::Event& e, const edm::EventSetup& c){ makeL1Scalars(e); + makeLumiScalars(e); return; } @@ -58,6 +75,11 @@ DQMScalInfo::makeL1Scalars(const edm::Event& e) { edm::Handle l1ts; e.getByToken(l1tscollectionToken_,l1ts); + edm::Handle lumiScalers; + e.getByToken(lumicollectionToken_,lumiScalers); + + Level1TriggerScalersCollection::const_iterator it = l1ts->begin(); + if(l1ts->size()==0) return; hlresync_->Fill((*l1ts)[0].lastResync()); hlOC0_->Fill((*l1ts)[0].lastOrbitCounter0()); @@ -66,5 +88,28 @@ DQMScalInfo::makeL1Scalars(const edm::Event& e) hlEC0_->Fill((*l1ts)[0].lastEventCounter0()); hlHR_->Fill((*l1ts)[0].lastHardReset()); + unsigned int lumisection = it->lumiSegmentNr(); + if(lumisection){ + hphysTrig_->setBinContent(lumisection + 1, it->l1AsPhysics()); + } + return ; } + +void +DQMScalInfo::makeLumiScalars(const edm::Event& e) +{ + edm::Handle lumiScalers; + e.getByToken(lumicollectionToken_,lumiScalers); + + LumiScalersCollection::const_iterator it = lumiScalers->begin(); + + if(lumiScalers->size()){ + unsigned int lumisection = it->sectionNumber(); + if(lumisection){ + hinstLumi_->setBinContent(lumisection + 1, it->instantLumi()); + } + } + + return; +} diff --git a/DQMServices/Components/src/DQMScalInfo.h b/DQMServices/Components/src/DQMScalInfo.h index 74c00f9ae3cba..f5c200422215c 100755 --- a/DQMServices/Components/src/DQMScalInfo.h +++ b/DQMServices/Components/src/DQMScalInfo.h @@ -24,6 +24,12 @@ #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" #include "DataFormats/Scalers/interface/Level1TriggerScalers.h" +#include "DataFormats/Scalers/interface/Level1TriggerScalers.h" +#include "DataFormats/Scalers/interface/Level1TriggerRates.h" +#include "DataFormats/Scalers/interface/ScalersRaw.h" +#include "DataFormats/Scalers/interface/TimeSpec.h" +#include "DataFormats/Scalers/interface/LumiScalers.h" + class DQMScalInfo: public DQMEDAnalyzer{ public: @@ -43,12 +49,14 @@ class DQMScalInfo: public DQMEDAnalyzer{ private: void makeL1Scalars(const edm::Event& e); + void makeLumiScalars(const edm::Event& e); edm::ParameterSet parameters_; std::string scalfolder_; edm::EDGetTokenT gtCollection_; edm::EDGetTokenT dcsStatusCollection_; edm::EDGetTokenT l1tscollectionToken_; + edm::EDGetTokenT lumicollectionToken_; // histograms MonitorElement * hlresync_; MonitorElement * hlOC0_; @@ -56,7 +64,9 @@ class DQMScalInfo: public DQMEDAnalyzer{ MonitorElement * hlstart_; MonitorElement * hlEC0_; MonitorElement * hlHR_; + MonitorElement * hphysTrig_; + MonitorElement * hinstLumi_; }; #endif From 52ab8d1aa864d9c15b03c1a1780d0ceb18a4d30c Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Fri, 28 Aug 2015 09:46:22 +0200 Subject: [PATCH 095/104] more cleanup --- RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h | 8 +++++--- RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h | 8 +++++--- RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h | 13 ++++++------- RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc | 4 ++-- RecoLocalMuon/RPCRecHit/src/DTSegtoRPC.cc | 4 ++-- RecoLocalMuon/RPCRecHit/src/RPCPointProducer.cc | 17 +++++++---------- RecoLocalMuon/RPCRecHit/src/TracktoRPC.cc | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h index f161159542dee..d138c79d5ecd1 100644 --- a/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/CSCSegtoRPC.h @@ -7,14 +7,16 @@ #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include + class CSCSegtoRPC { public: - explicit CSCSegtoRPC(edm::Handle allCSCSegments,const edm::EventSetup& iSetup, const edm::Event& iEvent, bool debug, double eyr); + CSCSegtoRPC(CSCSegmentCollection const* allCSCSegments, edm::EventSetup const& iSetup, bool debug, double eyr); ~CSCSegtoRPC(); - RPCRecHitCollection* thePoints(){return _ThePoints;} + std::unique_ptr && thePoints(){ return std::move(_ThePoints); } private: - RPCRecHitCollection* _ThePoints; + std::unique_ptr _ThePoints; edm::OwnVector RPCPointVector; bool inclcsc; double MaxD; diff --git a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h index cc9f59ab4ce90..b15781ae12bc0 100644 --- a/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/DTSegtoRPC.h @@ -7,14 +7,16 @@ #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include + class DTSegtoRPC { public: - explicit DTSegtoRPC(edm::Handle all4DSegments,const edm::EventSetup& iSetup, const edm::Event& iEvent,bool debug, double eyr); + DTSegtoRPC(DTRecSegment4DCollection const* all4DSegments, edm::EventSetup const& iSetup, bool debug, double eyr); ~DTSegtoRPC(); - RPCRecHitCollection* thePoints(){return _ThePoints;} + std::unique_ptr && thePoints(){ return std::move(_ThePoints); } private: - RPCRecHitCollection* _ThePoints; + std::unique_ptr _ThePoints; edm::OwnVector RPCPointVector; bool incldt; bool incldtMB4; diff --git a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h index b90aac0f939d8..92434eaf6a2a0 100644 --- a/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h +++ b/RecoLocalMuon/RPCRecHit/interface/TracktoRPC.h @@ -50,6 +50,7 @@ #include "TrackingTools/TrackRefitter/interface/TrackTransformerBase.h" #include "TrackingTools/TrackRefitter/interface/TrackTransformer.h" +#include using reco::MuonCollection; using reco::TrackCollection; @@ -57,16 +58,14 @@ typedef std::vector Trajectories; class TracktoRPC { public: - - - explicit TracktoRPC(edm::Handle alltracks,const edm::EventSetup& iSetup, const edm::Event& iEvent,bool debug, const edm::ParameterSet& iConfig, const edm::InputTag & tracklabel); - + TracktoRPC(reco::TrackCollection const* alltracks, edm::EventSetup const& iSetup, bool debug, const edm::ParameterSet& iConfig, const edm::InputTag & tracklabel); ~TracktoRPC(); - RPCRecHitCollection* thePoints(){return _ThePoints;} - bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup& iSetup); + std::unique_ptr && thePoints(){ return std::move(_ThePoints); } private: - RPCRecHitCollection* _ThePoints; + bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup& iSetup); + + std::unique_ptr _ThePoints; edm::OwnVector RPCPointVector; double MaxD; diff --git a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc index 59b29c9e0fe11..952ecf19c52f8 100644 --- a/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc +++ b/RecoLocalMuon/RPCRecHit/src/CSCSegtoRPC.cc @@ -12,7 +12,7 @@ #include "RecoLocalMuon/RPCRecHit/src/CSCStationIndex.h" #include "RecoLocalMuon/RPCRecHit/src/CSCObjectMap.h" -CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const edm::EventSetup& iSetup,const edm::Event& iEvent, bool debug, double eyr){ +CSCSegtoRPC::CSCSegtoRPC(const CSCSegmentCollection * allCSCSegments, const edm::EventSetup& iSetup, bool debug, double eyr){ edm::ESHandle rpcGeo; edm::ESHandle cscGeo; @@ -26,7 +26,7 @@ CSCSegtoRPC::CSCSegtoRPC(edm::Handle allCSCSegments, const if(debug) std::cout<<"CSC \t Number of CSC Segments in this event = "<size()<size()==0){ if(debug) std::cout<<"CSC 0 segments skiping event"< all4DSegments, const edm::EventSetup& iSetup,const edm::Event& iEvent,bool debug,double eyr){ +DTSegtoRPC::DTSegtoRPC(const DTRecSegment4DCollection * all4DSegments, const edm::EventSetup& iSetup, bool debug,double eyr){ /* MinCosAng=iConfig.getUntrackedParameter("MinCosAng",0.95); @@ -61,7 +61,7 @@ DTSegtoRPC::DTSegtoRPC(edm::Handle all4DSegments, cons clock_gettime(CLOCK_REALTIME, &start_time); */ - _ThePoints = new RPCRecHitCollection(); + _ThePoints.reset(new RPCRecHitCollection()); if(all4DSegments->size()>8){ if(debug) std::cout<<"Too many segments in this event we are not doing the extrapolation"< all4DSegments; iEvent.getByToken(dt4DSegments, all4DSegments); if(all4DSegments.isValid()){ - DTSegtoRPC DTClass(all4DSegments,iSetup,iEvent,debug,ExtrapolatedRegion); - std::auto_ptr TheDTPoints(DTClass.thePoints()); - iEvent.put(TheDTPoints,"RPCDTExtrapolatedPoints"); + DTSegtoRPC DTClass(all4DSegments.product(), iSetup, debug, ExtrapolatedRegion); + iEvent.put(DTClass.thePoints(), "RPCDTExtrapolatedPoints"); }else{ if(debug) std::cout<<"RPCHLT Invalid DTSegments collection"< allCSCSegments; iEvent.getByToken(cscSegments, allCSCSegments); if(allCSCSegments.isValid()){ - CSCSegtoRPC CSCClass(allCSCSegments,iSetup,iEvent,debug,ExtrapolatedRegion); - std::auto_ptr TheCSCPoints(CSCClass.thePoints()); - iEvent.put(TheCSCPoints,"RPCCSCExtrapolatedPoints"); + CSCSegtoRPC CSCClass(allCSCSegments.product(), iSetup, debug, ExtrapolatedRegion); + iEvent.put(CSCClass.thePoints(), "RPCCSCExtrapolatedPoints"); }else{ if(debug) std::cout<<"RPCHLT Invalid CSCSegments collection"< alltracks; iEvent.getByToken(tracks,alltracks); if(!(alltracks->empty())){ - TracktoRPC TrackClass(alltracks,iSetup,iEvent,debug,trackTransformerParam,tracks_); - std::auto_ptr TheTrackPoints(TrackClass.thePoints()); - iEvent.put(TheTrackPoints,"RPCTrackExtrapolatedPoints"); + TracktoRPC TrackClass(alltracks.product(), iSetup, debug, trackTransformerParam, tracks_); + iEvent.put(TrackClass.thePoints(), "RPCTrackExtrapolatedPoints"); }else{ - std::cout<<"RPCHLT Invalid Tracks collection"< alltracks, const edm::EventSetup& iSetup,const edm::Event& iEvent,bool debug,const edm::ParameterSet& iConfig, const edm::InputTag& tracklabel){ +TracktoRPC::TracktoRPC(const reco::TrackCollection * alltracks, const edm::EventSetup& iSetup, bool debug,const edm::ParameterSet& iConfig, const edm::InputTag& tracklabel){ - _ThePoints = new RPCRecHitCollection(); + _ThePoints.reset(new RPCRecHitCollection()); // if(alltracks->empty()) return; if(tracklabel.label().find("cosmic")==0) theTrackTransformer = new TrackTransformerForCosmicMuons(iConfig); From a32eb659120e4204c6be5d65fdf2bbe21238b38a Mon Sep 17 00:00:00 2001 From: David Sheffield Date: Wed, 26 Aug 2015 16:09:05 -0500 Subject: [PATCH 096/104] Add index to primary vertex in scouting particle collection --- .../Scouting/interface/ScoutingParticle.h | 8 +++++--- DataFormats/Scouting/src/classes_def.xml | 4 ++-- .../JetMET/plugins/HLTScoutingPFProducer.cc | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/DataFormats/Scouting/interface/ScoutingParticle.h b/DataFormats/Scouting/interface/ScoutingParticle.h index f93555748075f..03484cfb2afdd 100644 --- a/DataFormats/Scouting/interface/ScoutingParticle.h +++ b/DataFormats/Scouting/interface/ScoutingParticle.h @@ -10,10 +10,10 @@ class ScoutingParticle public: //constructor with values for all data fields ScoutingParticle(float pt, float eta, float phi, float m, - int pdgId): - pt_(pt), eta_(eta), phi_(phi), m_(m), pdgId_(pdgId) {} + int pdgId, int vertex): + pt_(pt), eta_(eta), phi_(phi), m_(m), pdgId_(pdgId), vertex_(vertex) {} //default constructor - ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0) {} + ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0), vertex_(0) {} //accessor functions float pt() const { return pt_; } @@ -21,6 +21,7 @@ class ScoutingParticle float phi() const { return phi_; } float m() const { return m_; } int pdgId() const { return pdgId_; } + int vertex() const { return vertex_; } private: float pt_; @@ -28,6 +29,7 @@ class ScoutingParticle float phi_; float m_; int pdgId_; + int vertex_; }; typedef std::vector ScoutingParticleCollection; diff --git a/DataFormats/Scouting/src/classes_def.xml b/DataFormats/Scouting/src/classes_def.xml index 3905e3877ce4c..2640c441a6597 100755 --- a/DataFormats/Scouting/src/classes_def.xml +++ b/DataFormats/Scouting/src/classes_def.xml @@ -5,8 +5,8 @@ - - + + diff --git a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc index 04f0dd1de1fbb..f2a35ecda2fd0 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc @@ -150,13 +150,27 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm: if(doCandidates){ for(auto &cand : *pfCandidateCollection){ if(cand.pt() > pfCandidatePtCut){ + int vertex_index = -1; + int index_counter = 0; + double dr2 = 0.0001; + for (auto &vtx: *outVertices) { + double tmp_dr2 = pow(vtx.x() - cand.vx(), 2) + pow(vtx.y() - cand.vy(), 2) + + pow(vtx.z() - cand.vz(), 2); + if (tmp_dr2 < dr2) { + dr2 = tmp_dr2; + vertex_index = index_counter; + } + if (dr2 == 0.0) + break; + ++index_counter; + } outPFCandidates->emplace_back( - cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId() + cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index ); } } } - + //produce PF jets std::auto_ptr outPFJets(new ScoutingPFJetCollection()); for(auto &jet : *pfJetCollection){ From 61fddad8afa391b4c69d203148d133a52a5d76b6 Mon Sep 17 00:00:00 2001 From: David Sheffield Date: Mon, 31 Aug 2015 12:55:34 -0500 Subject: [PATCH 097/104] Add back checksum for version 2 --- DataFormats/Scouting/src/classes_def.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/DataFormats/Scouting/src/classes_def.xml b/DataFormats/Scouting/src/classes_def.xml index 2640c441a6597..6ff839cd37b9d 100755 --- a/DataFormats/Scouting/src/classes_def.xml +++ b/DataFormats/Scouting/src/classes_def.xml @@ -6,6 +6,7 @@ + From 6a16ed79c1302f9e3d40061aa4dda26e6fb61c43 Mon Sep 17 00:00:00 2001 From: wmtan Date: Wed, 2 Sep 2015 06:14:50 +0200 Subject: [PATCH 098/104] Use anonymous namespace to avoid duplicate symbols --- .../plugins/EGExtraInfoModifierFromDB.cc | 40 +++++++++++-------- .../EGExtraInfoModifierFromFloatValueMaps.cc | 24 ++++++----- .../EGExtraInfoModifierFromIntValueMaps.cc | 24 ++++++----- .../plugins/EGFull5x5ShowerShapeModifier.cc | 24 ++++++----- 4 files changed, 68 insertions(+), 44 deletions(-) diff --git a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromDB.cc b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromDB.cc index 480d62bc6c098..0f491942144ee 100644 --- a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromDB.cc +++ b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromDB.cc @@ -181,11 +181,13 @@ EGExtraInfoModifierFromDB::EGExtraInfoModifierFromDB(const edm::ParameterSet& co } } -template -inline void get_product(const edm::Event& evt, - const edm::EDGetTokenT >& tok, - std::unordered_map > >& map) { - evt.getByToken(tok,map[tok.index()]); +namespace { + template + inline void get_product(const edm::Event& evt, + const edm::EDGetTokenT >& tok, + std::unordered_map > >& map) { + evt.getByToken(tok,map[tok.index()]); + } } void EGExtraInfoModifierFromDB::setEvent(const edm::Event& evt) { @@ -307,16 +309,18 @@ void EGExtraInfoModifierFromDB::setEventContent(const edm::EventSetup& evs) { } } -template -inline void make_consumes(T& tag,U& tok,V& sume) { - if(!(empty_tag == tag)) - tok = sume.template consumes >(tag); -} +namespace { + template + inline void make_consumes(T& tag,U& tok,V& sume) { + if(!(empty_tag == tag)) + tok = sume.template consumes >(tag); + } -template -inline void make_int_consumes(T& tag,U& tok,V& sume) { - if(!(empty_tag == tag)) - tok = sume.template consumes >(tag); + template + inline void make_int_consumes(T& tag,U& tok,V& sume) { + if(!(empty_tag == tag)) + tok = sume.template consumes >(tag); + } } void EGExtraInfoModifierFromDB::setConsumes(edm::ConsumesCollector& sumes) { @@ -360,9 +364,11 @@ void EGExtraInfoModifierFromDB::setConsumes(edm::ConsumesCollector& sumes) { } } -template -inline void assignValue(const T& ptr, const U& tok, const V& map, Z& value) { - if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); +namespace { + template + inline void assignValue(const T& ptr, const U& tok, const V& map, Z& value) { + if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); + } } void EGExtraInfoModifierFromDB::modifyObject(pat::Electron& ele) const { diff --git a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromFloatValueMaps.cc b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromFloatValueMaps.cc index 497f524259a69..b0ae80fc7395f 100644 --- a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromFloatValueMaps.cc +++ b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromFloatValueMaps.cc @@ -87,10 +87,12 @@ EGExtraInfoModifierFromFloatValueMaps(const edm::ParameterSet& conf) : ele_idx = pho_idx = 0; } -inline void get_product(const edm::Event& evt, - const edm::EDGetTokenT >& tok, - std::unordered_map > >& map) { - evt.getByToken(tok,map[tok.index()]); +namespace { + inline void get_product(const edm::Event& evt, + const edm::EDGetTokenT >& tok, + std::unordered_map > >& map) { + evt.getByToken(tok,map[tok.index()]); + } } void EGExtraInfoModifierFromFloatValueMaps:: @@ -135,8 +137,10 @@ void EGExtraInfoModifierFromFloatValueMaps:: setEventContent(const edm::EventSetup& evs) { } -template -inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +namespace { + template + inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +} void EGExtraInfoModifierFromFloatValueMaps:: setConsumes(edm::ConsumesCollector& sumes) { @@ -155,9 +159,11 @@ setConsumes(edm::ConsumesCollector& sumes) { } } -template -inline void assignValue(const T& ptr, const U& tok, const V& map, float& value) { - if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); +namespace { + template + inline void assignValue(const T& ptr, const U& tok, const V& map, float& value) { + if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); + } } void EGExtraInfoModifierFromFloatValueMaps:: diff --git a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromIntValueMaps.cc b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromIntValueMaps.cc index 33f0997162384..4c6ea1544d844 100644 --- a/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromIntValueMaps.cc +++ b/RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromIntValueMaps.cc @@ -87,10 +87,12 @@ EGExtraInfoModifierFromIntValueMaps(const edm::ParameterSet& conf) : ele_idx = pho_idx = 0; } -inline void get_product(const edm::Event& evt, - const edm::EDGetTokenT >& tok, - std::unordered_map > >& map) { - evt.getByToken(tok,map[tok.index()]); +namespace { + inline void get_product(const edm::Event& evt, + const edm::EDGetTokenT >& tok, + std::unordered_map > >& map) { + evt.getByToken(tok,map[tok.index()]); + } } void EGExtraInfoModifierFromIntValueMaps:: @@ -135,8 +137,10 @@ void EGExtraInfoModifierFromIntValueMaps:: setEventContent(const edm::EventSetup& evs) { } -template -inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +namespace { + template + inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +} void EGExtraInfoModifierFromIntValueMaps:: setConsumes(edm::ConsumesCollector& sumes) { @@ -155,9 +159,11 @@ setConsumes(edm::ConsumesCollector& sumes) { } } -template -inline void assignValue(const T& ptr, const U& tok, const V& map, int& value) { - if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); +namespace { + template + inline void assignValue(const T& ptr, const U& tok, const V& map, int& value) { + if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); + } } void EGExtraInfoModifierFromIntValueMaps:: diff --git a/RecoEgamma/EgammaTools/plugins/EGFull5x5ShowerShapeModifier.cc b/RecoEgamma/EgammaTools/plugins/EGFull5x5ShowerShapeModifier.cc index 9728a53977443..cb9283528211b 100644 --- a/RecoEgamma/EgammaTools/plugins/EGFull5x5ShowerShapeModifier.cc +++ b/RecoEgamma/EgammaTools/plugins/EGFull5x5ShowerShapeModifier.cc @@ -130,10 +130,12 @@ EGFull5x5ShowerShapeModifierFromValueMaps(const edm::ParameterSet& conf) : ele_idx = pho_idx = 0; } -inline void get_product(const edm::Event& evt, - const edm::EDGetTokenT >& tok, - std::unordered_map > >& map) { - if( !tok.isUninitialized() ) evt.getByToken(tok,map[tok.index()]); +namespace { + inline void get_product(const edm::Event& evt, + const edm::EDGetTokenT >& tok, + std::unordered_map > >& map) { + if( !tok.isUninitialized() ) evt.getByToken(tok,map[tok.index()]); + } } void EGFull5x5ShowerShapeModifierFromValueMaps:: @@ -195,8 +197,10 @@ void EGFull5x5ShowerShapeModifierFromValueMaps:: setEventContent(const edm::EventSetup& evs) { } -template -inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +namespace { + template + inline void make_consumes(T& tag,U& tok,V& sume) { if( !(empty_tag == tag) ) tok = sume.template consumes >(tag); } +} void EGFull5x5ShowerShapeModifierFromValueMaps:: setConsumes(edm::ConsumesCollector& sumes) { @@ -229,9 +233,11 @@ setConsumes(edm::ConsumesCollector& sumes) { make_consumes(ph_conf.hcalDepth2OverEcalBc,ph_conf.tok_hcalDepth2OverEcalBc,sumes); } -template -inline void assignValue(const T& ptr, const U& tok, const V& map, float& value) { - if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); +namespace { + template + inline void assignValue(const T& ptr, const U& tok, const V& map, float& value) { + if( !tok.isUninitialized() ) value = map.find(tok.index())->second->get(ptr.id(),ptr.key()); + } } void EGFull5x5ShowerShapeModifierFromValueMaps:: From 4840d099ce24ce1685b664fe243ef3213ff417cd Mon Sep 17 00:00:00 2001 From: David Sheffield Date: Tue, 1 Sep 2015 11:54:12 -0500 Subject: [PATCH 099/104] Make default constructor set new variable to invalid value --- DataFormats/Scouting/interface/ScoutingParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/Scouting/interface/ScoutingParticle.h b/DataFormats/Scouting/interface/ScoutingParticle.h index 03484cfb2afdd..545d2f33db591 100644 --- a/DataFormats/Scouting/interface/ScoutingParticle.h +++ b/DataFormats/Scouting/interface/ScoutingParticle.h @@ -13,7 +13,7 @@ class ScoutingParticle int pdgId, int vertex): pt_(pt), eta_(eta), phi_(phi), m_(m), pdgId_(pdgId), vertex_(vertex) {} //default constructor - ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0), vertex_(0) {} + ScoutingParticle():pt_(0), eta_(0), phi_(0), m_(0), pdgId_(0), vertex_(-1) {} //accessor functions float pt() const { return pt_; } From b5886f09532bc849f3cf723814f00a277a4c5d68 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 11 Jul 2015 13:50:17 +0200 Subject: [PATCH 100/104] Removed unused stream::OutputModuleBase::getTriggerResults The method isn't used and the present signature does not allow for consumes. If it becomes necessary to return this functionality, it should be done by adding a stand alone function which is passed an EDGetTokenT. The legacy OutputModule uses a modified version of this to support StreamerOutputModuleBase. --- FWCore/Framework/interface/one/OutputModuleBase.h | 4 ---- FWCore/Framework/src/one/OutputModuleBase.cc | 5 ----- 2 files changed, 9 deletions(-) diff --git a/FWCore/Framework/interface/one/OutputModuleBase.h b/FWCore/Framework/interface/one/OutputModuleBase.h index f1bd4f6a08df1..be11d77030651 100644 --- a/FWCore/Framework/interface/one/OutputModuleBase.h +++ b/FWCore/Framework/interface/one/OutputModuleBase.h @@ -61,8 +61,6 @@ namespace edm { namespace one { - typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - class OutputModuleBase : public EDConsumerBase { public: template friend class edm::maker::ModuleHolderT; @@ -109,8 +107,6 @@ namespace edm { } protected: - Trig getTriggerResults(EventPrincipal const& ep, ModuleCallingContext const*) const; - ModuleDescription const& description() const; ParameterSetID selectorConfig() const { return selector_config_id_; } diff --git a/FWCore/Framework/src/one/OutputModuleBase.cc b/FWCore/Framework/src/one/OutputModuleBase.cc index 5a95abc24c0e5..58da7efd16111 100644 --- a/FWCore/Framework/src/one/OutputModuleBase.cc +++ b/FWCore/Framework/src/one/OutputModuleBase.cc @@ -189,11 +189,6 @@ namespace edm { endJob(); } - - Trig OutputModuleBase::getTriggerResults(EventPrincipal const& ep, - ModuleCallingContext const* mcc) const { - return selectors_.getOneTriggerResults(ep, mcc); } - bool OutputModuleBase::doEvent(EventPrincipal const& ep, EventSetup const&, From 113b50c9246d756c90870c94fd9d01a5e1d8142e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 11 Jul 2015 14:04:13 +0200 Subject: [PATCH 101/104] Made OutputModule::getTriggerResults be compatible with consumes The previous API for getTriggerResults would allow one to retrieve the results without having to first declare consumes. The new interface requires an EDGetTokenT. The implementation of this function also avoids coupling with the event selector code. This allowed those interfaces to be removed from TriggerResultsBasedEventSelector. --- FWCore/Framework/interface/OutputModule.h | 4 ++- .../TriggerResultsBasedEventSelector.h | 6 ---- FWCore/Framework/src/OutputModule.cc | 13 +++++--- .../src/TriggerResultsBasedEventSelector.cc | 31 ------------------- .../Framework/test/stubs/TestOutputModule.cc | 8 +++-- .../interface/StreamerOutputModuleBase.h | 2 ++ .../Streamer/src/StreamerOutputModuleBase.cc | 3 +- 7 files changed, 21 insertions(+), 46 deletions(-) diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index 8ca3097ce2369..403ae3e4be0a3 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -25,6 +25,8 @@ output stream. #include "FWCore/ParameterSet/interface/ParameterSetfwd.h" +#include "FWCore/Utilities/interface/EDGetToken.h" + #include #include #include @@ -94,7 +96,7 @@ namespace edm { // need to clean up the use of Event and EventPrincipal, to avoid // creation of multiple Event objects when handling a single // event. - Trig getTriggerResults(EventPrincipal const& ep, ModuleCallingContext const*) const; + Trig getTriggerResults(EDGetTokenT const& token, EventPrincipal const& ep, ModuleCallingContext const*) const; ModuleDescription const& description() const; ModuleDescription const& moduleDescription() const { return moduleDescription_; diff --git a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h index 38b3c86e7272c..80731da4720b0 100644 --- a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h +++ b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h @@ -75,8 +75,6 @@ namespace edm bool wantEvent(EventPrincipal const& e, ModuleCallingContext const*); - handle_t getOneTriggerResults(EventPrincipal const& e, ModuleCallingContext const*); - // Clear the cache void clear(); @@ -87,10 +85,6 @@ namespace edm // interested in. size_type fill(EventPrincipal const& ev, ModuleCallingContext const*); - // If we have only one handle cached, return it; otherwise throw. - handle_t returnOneHandleOrThrow(); - - bool fillDone_; size_type numberFound_; selectors_t selectors_; diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index 565b40626d525..b799426c8b657 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -16,6 +16,7 @@ #include "FWCore/Framework/interface/OutputModuleDescription.h" #include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/Framework/src/EventSignalsSentry.h" +#include "FWCore/Framework/interface/PrincipalGetAdapter.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -182,10 +183,14 @@ namespace edm { } - Trig OutputModule::getTriggerResults(EventPrincipal const& ep, ModuleCallingContext const* mcc) const { - return selectors_.getOneTriggerResults(ep, mcc); } - - namespace { + Trig OutputModule::getTriggerResults(EDGetTokenT const& token, EventPrincipal const& ep, ModuleCallingContext const* mcc) const { + //This cast is safe since we only call const functions of the EventPrincipal after this point + PrincipalGetAdapter adapter(const_cast(ep), moduleDescription_); + adapter.setConsumer(this); + Trig result; + auto bh = adapter.getByToken_(TypeID(typeid(TriggerResults)),PRODUCT_TYPE, token, mcc); + convert_handle(std::move(bh), result); + return result; } bool diff --git a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc index e304a1342a06b..96701a745d451 100644 --- a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc +++ b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc @@ -187,13 +187,6 @@ namespace edm } } - TriggerResultsBasedEventSelector::handle_t - TriggerResultsBasedEventSelector::getOneTriggerResults(EventPrincipal const& ev, ModuleCallingContext const* mcc) - { - fill(ev, mcc); - return returnOneHandleOrThrow(); - } - bool TriggerResultsBasedEventSelector::wantEvent(EventPrincipal const& ev, ModuleCallingContext const* mcc) { @@ -219,30 +212,6 @@ namespace edm return match_found; } - TriggerResultsBasedEventSelector::handle_t - TriggerResultsBasedEventSelector::returnOneHandleOrThrow() - { - switch (numberFound_) - { - case 0: - throw edm::Exception(edm::errors::ProductNotFound, - "TooFewProducts") - << "TriggerResultsBasedEventSelector::returnOneHandleOrThrow: " - << " too few products found, " - << "exepcted one, got zero\n"; - case 1: - - break; - default: - throw edm::Exception(edm::errors::ProductNotFound, - "TooManyMatches") - << "TriggerResultsBasedEventSelector::returnOneHandleOrThrow: " - << "too many products found, " - << "expected one, got " << numberFound_ << '\n'; - } - return selectors_[0].product(); - } - TriggerResultsBasedEventSelector::size_type TriggerResultsBasedEventSelector::fill(EventPrincipal const& ev, ModuleCallingContext const* mcc) { diff --git a/FWCore/Framework/test/stubs/TestOutputModule.cc b/FWCore/Framework/test/stubs/TestOutputModule.cc index 77f7f7518e185..ebbf64ec66a7d 100644 --- a/FWCore/Framework/test/stubs/TestOutputModule.cc +++ b/FWCore/Framework/test/stubs/TestOutputModule.cc @@ -74,6 +74,7 @@ namespace edmtest int bitMask_; std::vector hltbits_; bool expectTriggerResults_; + edm::EDGetTokenT resultsToken_; }; // ----------------------------------------------------------------- @@ -83,7 +84,8 @@ namespace edmtest name_(ps.getParameter("name")), bitMask_(ps.getParameter("bitMask")), hltbits_(0), - expectTriggerResults_(ps.getUntrackedParameter("expectTriggerResults",true)) + expectTriggerResults_(ps.getUntrackedParameter("expectTriggerResults",true)), + resultsToken_(consumes(edm::InputTag("TriggerResults"))) { } @@ -114,7 +116,7 @@ namespace edmtest if (!expectTriggerResults_) { try { - prod = getTriggerResults(e, mcc); + prod = getTriggerResults(resultsToken_, e, mcc); //throw doesn't happen until we dereference *prod; } @@ -131,7 +133,7 @@ namespace edmtest // Now deal with the other case where we expect the object // to be present. - prod = getTriggerResults(e, mcc); + prod = getTriggerResults(resultsToken_, e, mcc); std::vector vHltState; diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index 4b61108b9d641..b6a18206dfc4e 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -2,6 +2,7 @@ #define IOPool_Streamer_StreamerOutputModuleBase_h #include "FWCore/Framework/interface/OutputModule.h" +#include "FWCore/Utilities/interface/EDGetToken.h" #include "IOPool/Streamer/interface/MsgTools.h" #include "IOPool/Streamer/interface/StreamSerializer.h" #include @@ -61,6 +62,7 @@ namespace edm { uint32 origSize_; char host_name_[255]; + edm::EDGetTokenT trToken_; Strings hltTriggerSelections_; uint32 outputModuleId_; }; //end-of-class-def diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index e6fc155ed16db..a8829acbdd2f8 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -69,6 +69,7 @@ namespace edm { hltbits_(0), origSize_(0), host_name_(), + trToken_(consumes(edm::InputTag("TriggerResults"))), hltTriggerSelections_(), outputModuleId_(0) { // no compression as default value - we need this! @@ -198,7 +199,7 @@ namespace edm { hltbits_.clear(); // If there was something left over from last event - Handle const& prod = getTriggerResults(e, mcc); + Handle const& prod = getTriggerResults(trToken_,e, mcc); //Trig const& prod = getTrigMask(e); std::vector vHltState; From f13d41a266032da9806f4d6d44d9e64ecfa29b14 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 11 Jul 2015 16:58:17 +0200 Subject: [PATCH 102/104] Use an event selector per Stream In order to allow event selection checking to run in parallel, we needed a TriggerResultsBasedEventSelector per stream. --- FWCore/Framework/interface/OutputModule.h | 5 ++- .../interface/one/OutputModuleBase.h | 5 ++- FWCore/Framework/src/OutputModule.cc | 43 ++++++++++++++----- FWCore/Framework/src/one/OutputModuleBase.cc | 40 +++++++++++++---- 4 files changed, 71 insertions(+), 22 deletions(-) diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index 403ae3e4be0a3..c0427d4a8dc12 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -104,7 +104,7 @@ namespace edm { ParameterSetID selectorConfig() const { return selector_config_id_; } - void doPreallocate(PreallocationConfiguration const&) {} + void doPreallocate(PreallocationConfiguration const&); void doBeginJob(); void doEndJob(); @@ -158,9 +158,10 @@ namespace edm { ModuleDescription moduleDescription_; bool wantAllEvents_; - mutable detail::TriggerResultsBasedEventSelector selectors_; + std::vector selectors_; // ID of the ParameterSet that configured the event selector // subsystem. + ParameterSet selectEvents_; ParameterSetID selector_config_id_; // needed because of possible EDAliases. diff --git a/FWCore/Framework/interface/one/OutputModuleBase.h b/FWCore/Framework/interface/one/OutputModuleBase.h index be11d77030651..a3a59692cdbf1 100644 --- a/FWCore/Framework/interface/one/OutputModuleBase.h +++ b/FWCore/Framework/interface/one/OutputModuleBase.h @@ -111,7 +111,7 @@ namespace edm { ParameterSetID selectorConfig() const { return selector_config_id_; } - void doPreallocate(PreallocationConfiguration const&) {} + void doPreallocate(PreallocationConfiguration const&); void doBeginJob(); void doEndJob(); @@ -165,7 +165,8 @@ namespace edm { ModuleDescription moduleDescription_; bool wantAllEvents_; - mutable detail::TriggerResultsBasedEventSelector selectors_; + std::vector selectors_; + ParameterSet selectEvents_; // ID of the ParameterSet that configured the event selector // subsystem. ParameterSetID selector_config_id_; diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index b799426c8b657..56744261f3add 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -17,6 +17,7 @@ #include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/Framework/src/EventSignalsSentry.h" #include "FWCore/Framework/interface/PrincipalGetAdapter.h" +#include "FWCore/Framework/src/PreallocationConfiguration.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -55,16 +56,20 @@ namespace edm { Service tns; process_name_ = tns->getProcessName(); - ParameterSet selectevents = + selectEvents_ = pset.getUntrackedParameterSet("SelectEvents", ParameterSet()); - selectevents.registerIt(); // Just in case this PSet is not registered + selectEvents_.registerIt(); // Just in case this PSet is not registered + + selector_config_id_ = selectEvents_.id(); + selectors_.resize(1); + //need to set wantAllEvents_ in constructor + // we will make the remaining selectors once we know how many streams + wantAllEvents_ = detail::configureEventSelector(selectEvents_, + process_name_, + getAllTriggerNames(), + selectors_[0]); - selector_config_id_ = selectevents.id(); - wantAllEvents_ = detail::configureEventSelector(selectevents, - process_name_, - getAllTriggerNames(), - selectors_); SharedResourcesRegistry::instance()->registerSharedResource( SharedResourcesRegistry::kLegacyModuleResourceName); @@ -171,6 +176,23 @@ namespace edm { OutputModule::~OutputModule() { } + void OutputModule::doPreallocate(PreallocationConfiguration const& iPC) { + auto nstreams = iPC.numberOfStreams(); + selectors_.resize(nstreams); + + bool seenFirst = false; + for(auto& s : selectors_) { + if(seenFirst) { + detail::configureEventSelector(selectEvents_, + process_name_, + getAllTriggerNames(), + s); + } + seenFirst = true; + } + } + + void OutputModule::doBeginJob() { std::vector res = {SharedResourcesRegistry::kLegacyModuleResourceName}; resourceAcquirer_ = SharedResourcesRegistry::instance()->createAcquirer(res); @@ -202,13 +224,14 @@ namespace edm { FDEBUG(2) << "writeEvent called\n"; { - std::lock_guard guard(mutex_); - detail::TRBESSentry products_sentry(selectors_); + auto& s = selectors_[ep.streamID().value()]; + detail::TRBESSentry products_sentry(s); if(!wantAllEvents_) { - if(!selectors_.wantEvent(ep, mcc)) { + if(!s.wantEvent(ep, mcc)) { return true; } } + std::lock_guard guard(mutex_); { std::lock_guard guardAcq(resourceAcquirer_); diff --git a/FWCore/Framework/src/one/OutputModuleBase.cc b/FWCore/Framework/src/one/OutputModuleBase.cc index 58da7efd16111..f186024145bdc 100644 --- a/FWCore/Framework/src/one/OutputModuleBase.cc +++ b/FWCore/Framework/src/one/OutputModuleBase.cc @@ -28,6 +28,7 @@ #include "FWCore/Framework/interface/OutputModuleDescription.h" #include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/Framework/src/EventSignalsSentry.h" +#include "FWCore/Framework/src/PreallocationConfiguration.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -63,16 +64,21 @@ namespace edm { Service tns; process_name_ = tns->getProcessName(); - ParameterSet selectevents = + selectEvents_ = pset.getUntrackedParameterSet("SelectEvents", ParameterSet()); - selectevents.registerIt(); // Just in case this PSet is not registered + selectEvents_.registerIt(); // Just in case this PSet is not registered - selector_config_id_ = selectevents.id(); - wantAllEvents_ = detail::configureEventSelector(selectevents, + selector_config_id_ = selectEvents_.id(); + + //need to set wantAllEvents_ in constructor + // we will make the remaining selectors once we know how many streams + selectors_.resize(1); + wantAllEvents_ = detail::configureEventSelector(selectEvents_, process_name_, getAllTriggerNames(), - selectors_); + selectors_[0]); + } void OutputModuleBase::configure(OutputModuleDescription const& desc) { @@ -180,6 +186,23 @@ namespace edm { return SharedResourcesAcquirer{}; } + void OutputModuleBase::doPreallocate(PreallocationConfiguration const& iPC) { + auto nstreams = iPC.numberOfStreams(); + selectors_.resize(nstreams); + + bool seenFirst = false; + for(auto& s : selectors_) { + if(seenFirst) { + detail::configureEventSelector(selectEvents_, + process_name_, + getAllTriggerNames(), + s); + } else { + seenFirst = true; + } + } + } + void OutputModuleBase::doBeginJob() { resourcesAcquirer_ = createAcquirer(); this->beginJob(); @@ -196,13 +219,14 @@ namespace edm { ModuleCallingContext const* mcc) { { - std::lock_guard guard(mutex_); - detail::TRBESSentry products_sentry(selectors_); + auto& s = selectors_[ep.streamID().value()]; + detail::TRBESSentry products_sentry(s); if(!wantAllEvents_) { - if(!selectors_.wantEvent(ep, mcc)) { + if(!s.wantEvent(ep, mcc)) { return true; } } + std::lock_guard guard(mutex_); { std::lock_guard guard(resourcesAcquirer_); EventSignalsSentry sentry(act,mcc); From 73b8f04f0f1e1c3343eaee0dd2424a259bdaad27 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 14 Jul 2015 15:50:26 -0500 Subject: [PATCH 103/104] Use properly initialized StreamID for test Changes to the implementation of the OutputModule now require a properly initialized StreamID when calling the Event method. --- FWCore/Framework/test/one_outputmodule_t.cppunit.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc index 0e2ca575d33b4..61d117a95e0bf 100644 --- a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc +++ b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc @@ -25,6 +25,7 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" #include "FWCore/Framework/interface/FileBlock.h" +#include "FWCore/Framework/src/PreallocationConfiguration.h" #include "FWCore/Utilities/interface/Exception.h" @@ -78,6 +79,7 @@ class testOneOutputModule: public CppUnit::TestFixture std::map> m_transToFunc; edm::ProcessConfiguration m_procConfig; + edm::PreallocationConfiguration m_preallocConfig; std::shared_ptr m_prodReg; std::shared_ptr m_idHelper; std::shared_ptr m_associationsHelper; @@ -100,6 +102,7 @@ class testOneOutputModule: public CppUnit::TestFixture class BasicOutputModule : public edm::one::OutputModule<> { public: + using edm::one::OutputModuleBase::doPreallocate; BasicOutputModule(edm::ParameterSet const& iPSet): edm::one::OutputModuleBase(iPSet),edm::one::OutputModule<>(iPSet){} unsigned int m_count = 0; @@ -117,6 +120,7 @@ class testOneOutputModule: public CppUnit::TestFixture class RunOutputModule : public edm::one::OutputModule { public: + using edm::one::OutputModuleBase::doPreallocate; RunOutputModule(edm::ParameterSet const& iPSet) : edm::one::OutputModuleBase(iPSet), edm::one::OutputModule(iPSet) {} unsigned int m_count = 0; void write(edm::EventPrincipal const&, edm::ModuleCallingContext const*) override { @@ -141,6 +145,7 @@ class testOneOutputModule: public CppUnit::TestFixture class LumiOutputModule : public edm::one::OutputModule { public: + using edm::one::OutputModuleBase::doPreallocate; LumiOutputModule(edm::ParameterSet const& iPSet) : edm::one::OutputModuleBase(iPSet), edm::one::OutputModule(iPSet) {} unsigned int m_count = 0; void write(edm::EventPrincipal const&, edm::ModuleCallingContext const*) override { @@ -164,6 +169,7 @@ class testOneOutputModule: public CppUnit::TestFixture }; class FileOutputModule : public edm::one::OutputModule { public: + using edm::one::OutputModuleBase::doPreallocate; FileOutputModule(edm::ParameterSet const& iPSet) : edm::one::OutputModuleBase(iPSet), edm::one::OutputModule(iPSet) {} unsigned int m_count = 0; void write(edm::EventPrincipal const&, edm::ModuleCallingContext const*) override { @@ -187,6 +193,7 @@ class testOneOutputModule: public CppUnit::TestFixture class ResourceOutputModule : public edm::one::OutputModule { public: + using edm::one::OutputModuleBase::doPreallocate; ResourceOutputModule(edm::ParameterSet const& iPSet): edm::one::OutputModuleBase(iPSet),edm::one::OutputModule(iPSet){ usesResource(); } @@ -280,7 +287,7 @@ m_ep() edm::StreamContext streamContext(s_streamID0, nullptr); edm::ParentContext parentContext(&streamContext); iBase->setActivityRegistry(m_actReg); - iBase->doWork(*m_ep,*m_es, edm::StreamID::invalidStreamID(), parentContext, nullptr); }; + iBase->doWork(*m_ep,*m_es, s_streamID0, parentContext, nullptr); }; m_transToFunc[Trans::kGlobalEndLuminosityBlock] = [this](edm::Worker* iBase, edm::OutputModuleCommunicator* iComm) { typedef edm::OccurrenceTraits Traits; @@ -347,6 +354,7 @@ namespace { template void testOneOutputModule::testTransitions(std::shared_ptr iMod, Expectations const& iExpect) { + iMod->doPreallocate(m_preallocConfig); edm::WorkerT w{iMod,m_desc,m_params.actions_}; edm::OutputModuleCommunicatorT comm(iMod.get()); for(auto& keyVal: m_transToFunc) { From c38f69607dc923e6e94d617f1a1e42327ffa240c Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 14 Jul 2015 15:52:44 -0500 Subject: [PATCH 104/104] Test for rejection of event from TriggerResults in OutputModule before prefetching data There is no reason to prefetch data and subsequently causing either delayed read or unscheduled execution if the TriggerResults being watched designate that the event should not be stored. --- FWCore/Framework/interface/OutputModule.h | 2 + .../interface/one/OutputModuleBase.h | 1 + FWCore/Framework/src/OutputModule.cc | 15 ++--- FWCore/Framework/src/Worker.h | 63 ++++++++++++++++++- FWCore/Framework/src/WorkerT.cc | 27 ++++++++ FWCore/Framework/src/WorkerT.h | 3 + FWCore/Framework/src/one/OutputModuleBase.cc | 15 ++--- 7 files changed, 110 insertions(+), 16 deletions(-) diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index c0427d4a8dc12..f15625ea27b42 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -209,6 +209,8 @@ namespace edm { virtual void reallyCloseFile(); void registerProductsAndCallbacks(OutputModule const*, ProductRegistry const*) {} + + bool prePrefetchSelection(StreamID id, EventPrincipal const&, ModuleCallingContext const*); /// Ask the OutputModule if we should end the current file. virtual bool shouldWeCloseFile() const {return false;} diff --git a/FWCore/Framework/interface/one/OutputModuleBase.h b/FWCore/Framework/interface/one/OutputModuleBase.h index a3a59692cdbf1..f0e807ac33c70 100644 --- a/FWCore/Framework/interface/one/OutputModuleBase.h +++ b/FWCore/Framework/interface/one/OutputModuleBase.h @@ -215,6 +215,7 @@ namespace edm { void registerProductsAndCallbacks(OutputModuleBase const*, ProductRegistry const*) {} + bool prePrefetchSelection(StreamID id, EventPrincipal const&, ModuleCallingContext const*); // Do the end-of-file tasks; this is only called internally, after // the appropriate tests have been done. diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index 56744261f3add..87d3d0fbff876 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -214,6 +214,14 @@ namespace edm { convert_handle(std::move(bh), result); return result; } + + bool OutputModule::prePrefetchSelection(StreamID id, EventPrincipal const& ep, ModuleCallingContext const* mcc) { + + auto& s = selectors_[id.value()]; + detail::TRBESSentry products_sentry(s); + + return wantAllEvents_ or s.wantEvent(ep,mcc); + } bool OutputModule::doEvent(EventPrincipal const& ep, @@ -224,13 +232,6 @@ namespace edm { FDEBUG(2) << "writeEvent called\n"; { - auto& s = selectors_[ep.streamID().value()]; - detail::TRBESSentry products_sentry(s); - if(!wantAllEvents_) { - if(!s.wantEvent(ep, mcc)) { - return true; - } - } std::lock_guard guard(mutex_); { diff --git a/FWCore/Framework/src/Worker.h b/FWCore/Framework/src/Worker.h index ba84c8345a14f..1c5341ef87209 100644 --- a/FWCore/Framework/src/Worker.h +++ b/FWCore/Framework/src/Worker.h @@ -136,6 +136,9 @@ namespace edm { virtual std::string workerType() const = 0; virtual bool implDo(EventPrincipal&, EventSetup const& c, ModuleCallingContext const* mcc) = 0; + virtual bool implDoPrePrefetchSelection(StreamID id, + EventPrincipal& ep, + ModuleCallingContext const* mcc) = 0; virtual bool implDoBegin(RunPrincipal& rp, EventSetup const& c, ModuleCallingContext const* mcc) = 0; virtual bool implDoStreamBegin(StreamID id, RunPrincipal& rp, EventSetup const& c, @@ -285,6 +288,11 @@ namespace edm { //Signal sentry is handled by the module return iWorker->implDo(ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return iWorker->implDoPrePrefetchSelection(id,ep,mcc); + } }; template<> @@ -299,6 +307,11 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoBegin(ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; template<> class CallImpl>{ @@ -312,6 +325,11 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoStreamBegin(id,ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; template<> class CallImpl>{ @@ -325,6 +343,11 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoEnd(ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; template<> class CallImpl>{ @@ -338,6 +361,11 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoStreamEnd(id,ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; template<> @@ -352,6 +380,12 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoBegin(ep,es, mcc); } + + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; template<> class CallImpl>{ @@ -365,7 +399,13 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoStreamBegin(id,ep,es, mcc); } - }; + + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } +}; template<> class CallImpl>{ @@ -379,6 +419,12 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoEnd(ep,es, mcc); } + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } + }; template<> class CallImpl>{ @@ -392,6 +438,12 @@ namespace edm { ModuleSignalSentry cpp(actReg, context, mcc); return iWorker->implDoStreamEnd(id,ep,es, mcc); } + + static bool prePrefetchSelection(Worker* iWorker,StreamID id, + typename Arg::MyPrincipal & ep, + ModuleCallingContext const* mcc) { + return true; + } }; } @@ -423,7 +475,14 @@ namespace edm { if (T::isEvent_) { ++timesRun_; - + + //if have TriggerResults based selection we want to reject the event before doing prefetching + if( not workerhelper::CallImpl::prePrefetchSelection(this,streamID,ep,&moduleCallingContext_) ) { + state_ = Pass; + ++timesPassed_; + rc = true; + return; + } // Prefetch products the module declares it consumes (not including the products it maybe consumes) std::vector const& items = itemsToGetFromEvent(); for(auto const& item : items) { diff --git a/FWCore/Framework/src/WorkerT.cc b/FWCore/Framework/src/WorkerT.cc index 619054c7f6c3e..8f1382ad85fff 100644 --- a/FWCore/Framework/src/WorkerT.cc +++ b/FWCore/Framework/src/WorkerT.cc @@ -119,6 +119,33 @@ namespace edm{ return module_->doEvent(ep, c, activityRegistry(), mcc); } + template + inline + bool + WorkerT::implDoPrePrefetchSelection(StreamID id, + EventPrincipal& ep, + ModuleCallingContext const* mcc) { + return true; + } + + template<> + inline + bool + WorkerT::implDoPrePrefetchSelection(StreamID id, + EventPrincipal& ep, + ModuleCallingContext const* mcc) { + return module_->prePrefetchSelection(id,ep,mcc); + } + + template<> + inline + bool + WorkerT::implDoPrePrefetchSelection(StreamID id, + EventPrincipal& ep, + ModuleCallingContext const* mcc) { + return module_->prePrefetchSelection(id,ep,mcc); + } + template inline bool diff --git a/FWCore/Framework/src/WorkerT.h b/FWCore/Framework/src/WorkerT.h index 027d7ea91e3e7..d3576cc3e2837 100644 --- a/FWCore/Framework/src/WorkerT.h +++ b/FWCore/Framework/src/WorkerT.h @@ -78,6 +78,9 @@ namespace edm { private: virtual bool implDo(EventPrincipal& ep, EventSetup const& c, ModuleCallingContext const* mcc) override; + virtual bool implDoPrePrefetchSelection(StreamID id, + EventPrincipal& ep, + ModuleCallingContext const* mcc) override; virtual bool implDoBegin(RunPrincipal& rp, EventSetup const& c, ModuleCallingContext const* mcc) override; virtual bool implDoStreamBegin(StreamID id, RunPrincipal& rp, EventSetup const& c, diff --git a/FWCore/Framework/src/one/OutputModuleBase.cc b/FWCore/Framework/src/one/OutputModuleBase.cc index f186024145bdc..1666a4d18c4ce 100644 --- a/FWCore/Framework/src/one/OutputModuleBase.cc +++ b/FWCore/Framework/src/one/OutputModuleBase.cc @@ -212,6 +212,14 @@ namespace edm { endJob(); } + bool OutputModuleBase::prePrefetchSelection(StreamID id, EventPrincipal const& ep, ModuleCallingContext const* mcc) { + + auto& s = selectors_[id.value()]; + detail::TRBESSentry products_sentry(s); + + return wantAllEvents_ or s.wantEvent(ep,mcc); + } + bool OutputModuleBase::doEvent(EventPrincipal const& ep, EventSetup const&, @@ -219,13 +227,6 @@ namespace edm { ModuleCallingContext const* mcc) { { - auto& s = selectors_[ep.streamID().value()]; - detail::TRBESSentry products_sentry(s); - if(!wantAllEvents_) { - if(!s.wantEvent(ep, mcc)) { - return true; - } - } std::lock_guard guard(mutex_); { std::lock_guard guard(resourcesAcquirer_);