Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Configuration/PyReleaseValidation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Configuration/PyReleaseValidation/python/MatrixUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,62 +133,72 @@
# 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)] = {}
if not self.allowReuse: stepDict[self.getStepName(step,preventReuseKeyword)] = {}
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):
Expand All @@ -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',
Expand Down Expand Up @@ -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 = [
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Configuration/StandardSequences/python/VtxSmeared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 12 additions & 8 deletions IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

namespace CLHEP {
class HepRandomEngine;
Expand All @@ -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
10 changes: 10 additions & 0 deletions IOMC/EventVertexGenerators/python/VtxDisplacedFlat_cfi.py
Original file line number Diff line number Diff line change
@@ -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"),
)



4 changes: 2 additions & 2 deletions IOMC/EventVertexGenerators/python/VtxSmearedFlat_cfi.py
Original file line number Diff line number Diff line change
@@ -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"),
)


Expand Down
12 changes: 12 additions & 0 deletions IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
#
Expand Down
69 changes: 49 additions & 20 deletions IOMC/EventVertexGenerators/src/FlatEvtVtxGenerator.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h"
#include "FWCore/Utilities/interface/Exception.h"

Expand All @@ -12,14 +10,23 @@

using CLHEP::cm;
using CLHEP::ns;
using CLHEP::radian;

FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
fMinX = p.getParameter<double>("MinX") * cm;
fMinY = p.getParameter<double>("MinY") * cm;
fMinZ = p.getParameter<double>("MinZ") * cm;
fMaxX = p.getParameter<double>("MaxX") * cm;
fMaxY = p.getParameter<double>("MaxY") * cm;
fFixedR = p.getParameter<bool>("FixedR");
Comment thread
bfonta marked this conversation as resolved.
if (fFixedR) {
fMaxR = p.getParameter<double>("MaxR") * cm;
fMinR = p.getParameter<double>("MinR") * cm;
fMaxPhi = p.getParameter<double>("MaxPhi") * radian;
fMinPhi = p.getParameter<double>("MinPhi") * radian;
} else {
fMinX = p.getParameter<double>("MinX") * cm;
fMaxX = p.getParameter<double>("MaxX") * cm;
fMinY = p.getParameter<double>("MinY") * cm;
fMaxY = p.getParameter<double>("MaxY") * cm;
}
fMaxZ = p.getParameter<double>("MaxZ") * cm;
fMinZ = p.getParameter<double>("MinZ") * cm;
fMinT = p.getParameter<double>("MinT") * ns * c_light;
fMaxT = p.getParameter<double>("MaxT") * ns * c_light;

Expand All @@ -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 << "]";
Expand All @@ -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);
Comment thread
bfonta marked this conversation as resolved.
} 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);

Expand All @@ -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<double>("MinX", 0.0)->setComment("in cm");
desc.add<double>("MaxX", 0.001)->setComment("in cm");
desc.add<double>("MinY", 0.0)->setComment("in cm");
desc.add<double>("MaxY", 0.001)->setComment("in cm");
desc.add<double>("MinZ", 0.0)->setComment("in cm");
desc.add<double>("MaxZ", 0.001)->setComment("in cm");
desc.add<double>("MinT", 0.0)->setComment("in ns");
desc.add<double>("MaxT", 0.001)->setComment("in ns");
desc.add<bool>("FixedR", false);
desc.add<double>("MinR", 0.0)->setComment("in cm");
desc.add<double>("MaxR", 0.001)->setComment("in cm");
desc.add<double>("MinPhi", -3.14159265359)->setComment("in radians");
desc.add<double>("MaxPhi", 3.14159265359)->setComment("in radians");
desc.add<edm::InputTag>("src");
descriptions.add("FlatEvtVtxGenerator", desc);
}