diff --git a/Configuration/PyReleaseValidation/README.md b/Configuration/PyReleaseValidation/README.md index ef50a51ea34d4..e6833e77a3e0b 100644 --- a/Configuration/PyReleaseValidation/README.md +++ b/Configuration/PyReleaseValidation/README.md @@ -81,6 +81,7 @@ The offsets currently in use are: * 0.782: Complete L1 workflow, producing only NANO output L1/P2GT objects * 0.8: BPH Parking (Run-2) * 0.81: Running also HeavyFlavor DQM +* 0.82: Displaced vertex * 0.85: Phase-2 Heavy Ion * 0.9: Vector hits * 0.12: Neutron background diff --git a/Configuration/PyReleaseValidation/python/MatrixUtil.py b/Configuration/PyReleaseValidation/python/MatrixUtil.py index a1d6010414fc7..8c3757cbe23fb 100644 --- a/Configuration/PyReleaseValidation/python/MatrixUtil.py +++ b/Configuration/PyReleaseValidation/python/MatrixUtil.py @@ -208,7 +208,7 @@ def __str__(self): return "input from: {0} with run {1}".format(self.dataSet, self.run) -# merge dictionaries, with prioty on the [0] index +# merge dictionaries, with priority on the [0] index def merge(dictlist,TELL=False): import copy last=len(dictlist)-1 diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 1887169482d37..c8fb9d8892be6 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -133,27 +133,28 @@ # every special workflow gets its own derived class, which must then be added to the global dict upgradeWFs preventReuseKeyword = 'NOREUSE' class UpgradeWorkflow(object): - def __init__(self,steps,PU,suffix,offset): + def __init__(self, steps, PU, suffix, offset): self.steps = steps self.PU = PU self.allowReuse = True # ensure all PU steps are in normal step list - for step in self.PU: - if not step in self.steps: - self.steps.append(step) + self.steps.extend(step for step in self.PU if step not in self.steps) self.suffix = suffix - if len(self.suffix)>0 and self.suffix[0]!='_': self.suffix = '_'+self.suffix + if len(self.suffix)>0 and self.suffix[0]!='_': + self.suffix = '_'+self.suffix + self.offset = offset if self.offset < 0.0 or self.offset > 1.0: - raise ValueError("Special workflow offset must be between 0.0 and 1.0") + raise ValueError("Special workflow offset must be between 0.0 and 1.0.") + def getStepName(self, step, extra=""): - stepName = step + self.suffix + extra - return stepName + return step + self.suffix + extra + def getStepNamePU(self, step, extra=""): - stepNamePU = step + 'PU' + self.suffix + extra - return stepNamePU + return step + 'PU' + self.suffix + extra + def init(self, stepDict): for step in self.steps: stepDict[self.getStepName(step)] = {} @@ -161,34 +162,43 @@ def init(self, stepDict): for step in self.PU: stepDict[self.getStepNamePU(step)] = {} if not self.allowReuse: stepDict[self.getStepNamePU(step,preventReuseKeyword)] = {} + def setup(self, stepDict, k, properties): for step in self.steps: self.setup_(step, self.getStepName(step), stepDict, k, properties) if not self.allowReuse: self.preventReuse(self.getStepName(step,preventReuseKeyword), stepDict, k) + def setupPU(self, stepDict, k, properties): for step in self.PU: self.setupPU_(step, self.getStepNamePU(step), stepDict, k, properties) if not self.allowReuse: self.preventReuse(self.getStepNamePU(step,preventReuseKeyword), stepDict, k) + def setup_(self, step, stepName, stepDict, k, properties): pass + def setupPU_(self, step, stepName, stepDict, k, properties): pass + def workflow(self, workflows, num, fragment, stepList, key, hasHarvest): if self.condition(fragment, stepList, key, hasHarvest): self.workflow_(workflows, num, fragment, stepList, key) + def workflow_(self, workflows, num, fragment, stepList, key): fragmentTmp = [fragment, key] if len(self.suffix)>0: fragmentTmp.append(self.suffix) # avoid spurious workflows (no steps modified) if self.offset==0 or workflows[num][1]!=stepList: workflows[num+self.offset] = [ fragmentTmp, stepList ] + def condition(self, fragment, stepList, key, hasHarvest): return False + def preventReuse(self, stepName, stepDict, k): if "Sim" in stepName and stepName != "Sim": stepDict[stepName][k] = None if "Gen" in stepName: stepDict[stepName][k] = None + upgradeWFs = OrderedDict() class UpgradeWorkflow_baseline(UpgradeWorkflow): @@ -202,8 +212,10 @@ def setup_(self, step, stepName, stepDict, k, properties): if era is not None: stepDict[stepName][k]['--era']=era if modifier is not None: stepDict[stepName][k]['--procModifier']=modifier + def condition(self, fragment, stepList, key, hasHarvest): return True + upgradeWFs['baseline'] = UpgradeWorkflow_baseline( steps = [ 'Gen', @@ -1222,8 +1234,9 @@ class UpgradeWorkflow_photonDRN(UpgradeWorkflow): def setup_(self, step, stepName, stepDict, k, properties): if 'Reco' in step: stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) + def condition(self, fragment, stepList, key, hasHarvest): - return '2018' in key and "SingleGamma" in fragment + return '2018' in key and 'SingleGamma' in fragment upgradeWFs['photonDRN'] = UpgradeWorkflow_photonDRN( steps = [ @@ -1241,6 +1254,27 @@ def condition(self, fragment, stepList, key, hasHarvest): '--procModifiers': 'enableSonicTriton,photonDRN' } +# workflows with a displaced vertex +class UpgradeWorkflow_displacedVertex(UpgradeWorkflow): + def setup_(self, step, stepName, stepDict, k, properties): + if 'Gen' in step: + stepDict[stepName][k] = merge([{'--beamspot': 'Displaced'}, stepDict[step][k]]) + + def condition(self, fragment, stepList, key, hasHarvest): + return any(x in fragment for x in ('SingleElectron', 'SingleGamma')) + +upgradeWFs['displacedVertex'] = UpgradeWorkflow_displacedVertex( + steps = [ + 'GenSim', + 'GenSimHLBeamSpot', + ], + PU = [ + 'GenSim', + 'GenSimHLBeamSpot', + ], + suffix = '_displacedVertex', + offset = 0.82 +) # Patatrack workflows (NoPU and PU): # - TTbar_14, ZMM_14", ZEE_14, ZTT_14, NuGun, SingleMu, QCD_Pt15To7000_Flat for diff --git a/Configuration/StandardSequences/python/VtxSmeared.py b/Configuration/StandardSequences/python/VtxSmeared.py index 03acc5a207810..17ef97632e8af 100644 --- a/Configuration/StandardSequences/python/VtxSmeared.py +++ b/Configuration/StandardSequences/python/VtxSmeared.py @@ -17,7 +17,8 @@ 'Early2p2TeVCollision': 'IOMC.EventVertexGenerators.VtxSmearedEarly2p2TeVCollision_cfi', 'Early7TeVCollision': 'IOMC.EventVertexGenerators.VtxSmearedEarly7TeVCollision_cfi', 'Early900GeVCollision': 'IOMC.EventVertexGenerators.VtxSmearedEarly900GeVCollision_cfi', - 'Flat': 'IOMC.EventVertexGenerators.VtxSmearedFlat_cfi', + 'Flat': 'IOMC.EventVertexGenerators.VtxSmearedFlat_cfi', + 'Displaced': 'IOMC.EventVertexGenerators.VtxDisplacedFlat_cfi', 'Gauss': 'IOMC.EventVertexGenerators.VtxSmearedGauss_cfi', 'GaussSigmaZ4cm': 'IOMC.EventVertexGenerators.VtxSmearedGaussSigmaZ4cm_cfi', 'Realistic7TeVCollision': 'IOMC.EventVertexGenerators.VtxSmearedRealistic7TeVCollision_cfi', diff --git a/IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h b/IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h index 9c58a4cae90e1..83ecf8f607366 100644 --- a/IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h +++ b/IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h @@ -14,6 +14,7 @@ */ #include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" namespace CLHEP { class HepRandomEngine; @@ -28,28 +29,31 @@ class FlatEvtVtxGenerator : public BaseEvtVtxGenerator { FlatEvtVtxGenerator& operator=(const FlatEvtVtxGenerator& rhs) = delete; ~FlatEvtVtxGenerator() override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + /// return a new event vertex ROOT::Math::XYZTVector vertexShift(CLHEP::HepRandomEngine*) const override; const TMatrixD* GetInvLorentzBoost() const override { return nullptr; } /// set min in X in cm - void minX(double m = 0.0); + inline void minX(double m = 0.0) { fMinX = m; } /// set min in Y in cm - void minY(double m = 0.0); + inline void minY(double m = 0.0) { fMinY = m; } /// set min in Z in cm - void minZ(double m = 0.0); + inline void minZ(double m = 0.0) { fMinZ = m; } /// set max in X in cm - void maxX(double m = 0); + inline void maxX(double m = 0) { fMaxX = m; } /// set max in Y in cm - void maxY(double m = 0); + inline void maxY(double m = 0) { fMaxY = m; } /// set max in Z in cm - void maxZ(double m = 0); + inline void maxZ(double m = 0) { fMaxZ = m; } private: - double fMinX, fMinY, fMinZ, fMinT; - double fMaxX, fMaxY, fMaxZ, fMaxT; + double fMinX, fMinY, fMinZ, fMinT, fMinR, fMinPhi; + double fMaxX, fMaxY, fMaxZ, fMaxT, fMaxR, fMaxPhi; + bool fFixedR; }; #endif diff --git a/IOMC/EventVertexGenerators/python/VtxDisplacedFlat_cfi.py b/IOMC/EventVertexGenerators/python/VtxDisplacedFlat_cfi.py new file mode 100644 index 0000000000000..40f1e5c1bdaa3 --- /dev/null +++ b/IOMC/EventVertexGenerators/python/VtxDisplacedFlat_cfi.py @@ -0,0 +1,10 @@ +import FWCore.ParameterSet.Config as cms + +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import FlatVtxDisplacedParameters +VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator", + FlatVtxDisplacedParameters, + src = cms.InputTag("generator", "unsmeared"), +) + + + diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedFlat_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedFlat_cfi.py index 578f16dec09d2..fab1fe44f2729 100644 --- a/IOMC/EventVertexGenerators/python/VtxSmearedFlat_cfi.py +++ b/IOMC/EventVertexGenerators/python/VtxSmearedFlat_cfi.py @@ -1,9 +1,9 @@ import FWCore.ParameterSet.Config as cms -from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import FlatVtxSmearingParameters,VtxSmearedCommon +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import FlatVtxSmearingParameters VtxSmeared = cms.EDProducer("FlatEvtVtxGenerator", FlatVtxSmearingParameters, - VtxSmearedCommon + src = cms.InputTag("generator", "unsmeared"), ) diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py index 83dfbe7974e2a..1f3daa8782a82 100644 --- a/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py +++ b/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py @@ -85,6 +85,7 @@ # Can restore correlation via MinT += (MinZ - MaxZ)/2 and MaxT += (MaxZ - MinZ)/2 # in [ns] units (recall c_light = 29.98cm/ns) FlatVtxSmearingParameters = cms.PSet( + FixedR = cms.bool(False), MaxZ = cms.double(5.3), MaxX = cms.double(0.0015), MaxY = cms.double(0.0015), @@ -94,6 +95,17 @@ MaxT = cms.double(0.177), MinT = cms.double(-0.177) ) + +FlatVtxDisplacedParameters = cms.PSet( + FixedR = cms.bool(True), + MaxR = cms.double(10.1), + MinR = cms.double(10.0), + MaxZ = cms.double(0.001), + MinZ = cms.double(0.000), + MaxT = cms.double(0.001), + MinT = cms.double(0.000), +) + ############################################# # Beta functions smearing (pp 7+7 TeV) # diff --git a/IOMC/EventVertexGenerators/src/FlatEvtVtxGenerator.cc b/IOMC/EventVertexGenerators/src/FlatEvtVtxGenerator.cc index bb7a6d2939a87..1cb39e485d7b8 100644 --- a/IOMC/EventVertexGenerators/src/FlatEvtVtxGenerator.cc +++ b/IOMC/EventVertexGenerators/src/FlatEvtVtxGenerator.cc @@ -1,5 +1,3 @@ - - #include "IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h" #include "FWCore/Utilities/interface/Exception.h" @@ -12,14 +10,23 @@ using CLHEP::cm; using CLHEP::ns; +using CLHEP::radian; FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) { - fMinX = p.getParameter("MinX") * cm; - fMinY = p.getParameter("MinY") * cm; - fMinZ = p.getParameter("MinZ") * cm; - fMaxX = p.getParameter("MaxX") * cm; - fMaxY = p.getParameter("MaxY") * cm; + fFixedR = p.getParameter("FixedR"); + if (fFixedR) { + fMaxR = p.getParameter("MaxR") * cm; + fMinR = p.getParameter("MinR") * cm; + fMaxPhi = p.getParameter("MaxPhi") * radian; + fMinPhi = p.getParameter("MinPhi") * radian; + } else { + fMinX = p.getParameter("MinX") * cm; + fMaxX = p.getParameter("MaxX") * cm; + fMinY = p.getParameter("MinY") * cm; + fMaxY = p.getParameter("MaxY") * cm; + } fMaxZ = p.getParameter("MaxZ") * cm; + fMinZ = p.getParameter("MinZ") * cm; fMinT = p.getParameter("MinT") * ns * c_light; fMaxT = p.getParameter("MaxT") * ns * c_light; @@ -39,6 +46,14 @@ FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVt throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: " << "MinT is greater than MaxT"; } + if (fMinR > fMaxR) { + throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: " + << "MinR is greater than MaxR"; + } + if (fMinPhi > fMaxPhi) { + throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: " + << "MinPhi is greater than MaxPhi"; + } edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Initialized with x[" << fMinX << ":" << fMaxX << "] cm; y[" << fMinY << ":" << fMaxY << "] cm; z[" << fMinZ << ":" << fMaxZ << "] cm; t[" << fMinT << ":" << fMaxT << "]"; @@ -48,8 +63,15 @@ FlatEvtVtxGenerator::~FlatEvtVtxGenerator() {} ROOT::Math::XYZTVector FlatEvtVtxGenerator::vertexShift(CLHEP::HepRandomEngine* engine) const { double aX, aY, aZ, aT; - aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX); - aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY); + if (fFixedR) { + double aR = CLHEP::RandFlat::shoot(engine, fMinR, fMaxR); + double aPhi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi); + aX = aR * std::cos(aPhi); + aY = aR * std::sin(aPhi); + } else { + aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX); + aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY); + } aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ); aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT); @@ -59,14 +81,21 @@ ROOT::Math::XYZTVector FlatEvtVtxGenerator::vertexShift(CLHEP::HepRandomEngine* return ROOT::Math::XYZTVector(aX, aY, aZ, aT); } -void FlatEvtVtxGenerator::minX(double min) { fMinX = min; } - -void FlatEvtVtxGenerator::minY(double min) { fMinY = min; } - -void FlatEvtVtxGenerator::minZ(double min) { fMinZ = min; } - -void FlatEvtVtxGenerator::maxX(double max) { fMaxX = max; } - -void FlatEvtVtxGenerator::maxY(double max) { fMaxY = max; } - -void FlatEvtVtxGenerator::maxZ(double max) { fMaxZ = max; } +void FlatEvtVtxGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("MinX", 0.0)->setComment("in cm"); + desc.add("MaxX", 0.001)->setComment("in cm"); + desc.add("MinY", 0.0)->setComment("in cm"); + desc.add("MaxY", 0.001)->setComment("in cm"); + desc.add("MinZ", 0.0)->setComment("in cm"); + desc.add("MaxZ", 0.001)->setComment("in cm"); + desc.add("MinT", 0.0)->setComment("in ns"); + desc.add("MaxT", 0.001)->setComment("in ns"); + desc.add("FixedR", false); + desc.add("MinR", 0.0)->setComment("in cm"); + desc.add("MaxR", 0.001)->setComment("in cm"); + desc.add("MinPhi", -3.14159265359)->setComment("in radians"); + desc.add("MaxPhi", 3.14159265359)->setComment("in radians"); + desc.add("src"); + descriptions.add("FlatEvtVtxGenerator", desc); +}