From a0c415d55569cc12b33024003d87ec41a4838d29 Mon Sep 17 00:00:00 2001 From: Broen van Besien Date: Fri, 23 Jan 2015 17:18:53 +0100 Subject: [PATCH 01/63] 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 02/63] 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 03/63] 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 04/63] 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 05/63] 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 06/63] 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 07/63] 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 08/63] 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 09/63] 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 10/63] 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 11/63] 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 12/63] 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 13/63] 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 14/63] 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 15/63] 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 16/63] 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 17/63] 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 18/63] 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 19/63] 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 20/63] 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 21/63] 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 22/63] 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 23/63] 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 24/63] 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 25/63] 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 26/63] 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 27/63] 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 28/63] 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 29/63] 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 30/63] 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 31/63] 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 32/63] 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 33/63] 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 34/63] 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 35/63] 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 36/63] 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 37/63] 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 38/63] 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 39/63] 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 40/63] 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 41/63] 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 42/63] 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 43/63] 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 44/63] 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 45/63] 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 46/63] 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 47/63] 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 48/63] 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 49/63] 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 50/63] 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 51/63] 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 52/63] 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 53/63] 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 54/63] 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 55/63] 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 56/63] 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 57/63] 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 58/63] 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 59/63] 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 60/63] 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 61/63] 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 62/63] 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 63/63] 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)