Skip to content

Commit

Permalink
Close by gun generator (cms-sw#58)
Browse files Browse the repository at this point in the history
* new close by gun with moving vertex
* pointing option default is True, so if used particles will be produced parallel to the beamline
* update documentation
  • Loading branch information
apsallid authored and clelange committed May 2, 2019
1 parent f7fd426 commit e0c28d8
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For details on the pileup scenario, please see https://github.com/cms-sw/cmssw/b

Whenever you would like to change configuration, change to the `reco_prodtools/templates/python` directory and execute the corresponding script. Then make sure to run `scram b`.

## details
## Details

To produce `NEVENTS` GEN-SIM-DIGI events with `NPART` sets of particles (per event) of type `PART_PDGID` and in the p_T range from `PTMIN` to `PTMAX`, one should run:
```
Expand Down Expand Up @@ -84,6 +84,43 @@ Rule of thumb for GEN-SIM-DIGI: 4 events per `1nh`:
* 20 events should be possible to finish in queue `8nh`.
* Ditto, 100 events in `1nd`.

### Close-by gun

Another gun that could be used is `--gunMode closeby`, which is capable of creating several vertices. Mind that it is only available in `CMSSW_10_6_0_pre4` or later.
With this choice particles can be produced with random energy, R and Z in a specified range. When more than
one particle are asked to be produced, then each particle will be created at a different vertex,
equally spaced by Delta, the arc-distance between two consecutive vertices
over the circle of radius R. Also, there is the `--pointing` option which if used particles will be produced parallel to the beamline, otherwise they will be pointing to (0,0,0). Furthermore, there is the `--overlapping` option that if used then
particles will be generated in a window [phiMin,phiMax], [rMin,rMax], otherwise with a DeltaPhi=Delta/R.
Apart from producing multiple particles, this gun could also produce a single particle wherever the user wishes, having always the
nice feature of assigning to the vertex the time required to travel from (0,0,0) to the desired location. This could be
useful e.g. when someone wants to shoot straight to the scintillator part. Keep in mind that there is no sense of
adding the antiparticle.
As an example, the command below will produce `NEVENTS` GEN-SIM-DIGI events with `NPART` sets of particles (per event) of type `PART_PDGID`
in the energy range from `EMIN` to `EMAX` (Pt option not available), radius range from `RMIN` to `RMAX`, z position from `ZMIN` to `ZMAX`, parallel to the beamline, with a distance between the particles vertices of deltaPhi = DELTA/R.

```
python SubmitHGCalPGun.py
--datTier GSD
--nevts NEVENTS
--evtsperjob NPERJOB
--queue QUEUENAME
--partID PART_PDGID
--nPart NPART
--thresholdMin EMIN
--thresholdMax EMAX
--rMin RMIN
--rMax RMAX
--zMin ZMIN
--zMax ZMAX
--Delta DELTA
--pointing
--etaMin ETAMIN
--etaMax ETAMAX
--gunType E
--gunMode closeby
--tag MYTAG
```

## RECO step

Expand Down Expand Up @@ -147,7 +184,7 @@ python SubmitHGCalPGun.py \

Starting from `CMSSW_10_4_0_pre3` (cms-sw/cmssw#25208), the handling of the calibration weights has been rewritten to be more generic and play nicely with eras. PR #54 took care of these changes.

# to contribute
# Contributing

We use the _fork and pull_ model:

Expand Down
23 changes: 21 additions & 2 deletions SubmitHGCalPGun.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ def parseOptions():
parser.add_option('', '--thresholdMax', dest='thresholdMax', type=float, default=35.0, help='max. threshold value')
parser.add_option('', '--etaMin', dest='etaMin', type=float, default=1.479, help='min. eta value')
parser.add_option('', '--etaMax', dest='etaMax', type=float, default=3.0, help='max. eta value')
parser.add_option('', '--gunMode', dest='gunMode', type='string', default='default', help='default or pythia8')
parser.add_option('', '--zMin', dest='zMin', type=float, default=321.6, help='min. z value start of EE at V10')
parser.add_option('', '--zMax', dest='zMax', type=float, default=650.0, help='max. z value')
parser.add_option('', '--rMin', dest='rMin', type=float, default=0.0, help='min. r value')
parser.add_option('', '--rMax', dest='rMax', type=float, default=300.0, help='max. r value')
parser.add_option('', '--pointing', action='store_false', dest='pointing', default=True, help='pointing to (0,0,0) in case of closeby gun')
parser.add_option('', '--overlapping', action='store_true', dest='overlapping', default=False, help='particles will be generated in window [phiMin,phiMax], [rMin,rMax] (true) or with a DeltaPhi=Delta/R (default false) in case of closeby gun')
parser.add_option('', '--gunMode', dest='gunMode', type='string', default='default', help='default or pythia8 or closeby')
parser.add_option('', '--gunType', dest='gunType', type='string', default='Pt', help='Pt or E gun')
parser.add_option('', '--InConeID', dest='InConeID', type='string', default='', help='PDG ID for single particle to be generated in the cone (supported as PARTID), default is empty string (none)')
parser.add_option('', '--MinDeltaR', dest='MinDeltaR', type=float, default=0.3, help='min. DR value')
parser.add_option('', '--MaxDeltaR', dest='MaxDeltaR', type=float, default=0.4, help='max. DR value')
parser.add_option('', '--Delta', dest='Delta', type=float, default=0.25, help=' arc-distance between two consecutive vertices over the circle of radius R')
parser.add_option('', '--MinMomRatio', dest='MinMomRatio', type=float, default=0.5, help='min. momentum ratio for particle inside of the cone and particle that defines the cone')
parser.add_option('', '--MaxMomRatio', dest='MaxMomRatio', type=float, default=2.0, help='max. momentum ratio for particle inside of the cone and particle that defines the cone')
parser.add_option('-l', '--local', action='store_true', dest='LOCAL', default=False, help='store output dir locally instead of at EOS CMG area, default is False.')
Expand Down Expand Up @@ -65,7 +72,7 @@ def parseOptions():
print 'ERROR: CMSSW does not seem to be set up. Exiting...'
sys.exit()

partGunModes = ['default', 'pythia8']
partGunModes = ['default', 'pythia8', 'closeby']
if opt.gunMode not in partGunModes:
parser.error('Particle gun mode ' + opt.gunMode + ' is not supported. Exiting...')
sys.exit()
Expand Down Expand Up @@ -141,6 +148,8 @@ def printSetup(CMSSW_BASE, CMSSW_VERSION, SCRAM_ARCH, currentDir, outDir):
print 'INPUTS: ', [curr_input, 'Particle gun mode: ' + opt.gunMode + ', type: ' + opt.gunType + ', PDG ID '+str(opt.PARTID)+', '+str(opt.NPART)+' times per event, ' + opt.gunType + ' threshold in ['+str(opt.thresholdMin)+','+str(opt.thresholdMax)+'], eta threshold in ['+str(opt.etaMin)+','+str(opt.etaMax)+']',opt.RELVAL][int(opt.DTIER=='GSD')]
if (opt.InConeID!='' and opt.DTIER=='GSD'):
print ' IN-CONE: PDG ID '+str(opt.InConeID)+', deltaR in ['+str(opt.MinDeltaR)+ ','+str(opt.MaxDeltaR)+']'+', momentum ratio in ['+str(opt.MinMomRatio)+ ','+str(opt.MaxMomRatio)+']'
if (opt.gunMode == 'closeby' and opt.DTIER=='GSD'):
print ' z threshold in ['+str(opt.zMin)+','+str(opt.zMax)+'], r threshold in ['+str(opt.rMin)+','+str(opt.rMax)+'], pointing to (0,0,0) '+str(opt.pointing) + ', overlapping '+str(opt.overlapping)
print 'STORE AREA: ', [opt.eosArea, currentDir][int(opt.LOCAL)]
print 'OUTPUT DIR: ', outDir
print 'QUEUE: ', opt.QUEUE
Expand Down Expand Up @@ -188,6 +197,8 @@ def submitHGCalProduction():
partGunType = 'Pythia8%sGun' % opt.gunType
if opt.InConeID != '':
partGunType = 'MultiParticleInConeGunProducer' # change part gun type if needed, keep opt.gunType unchanged (E or Pt) for the "primary particle"
if opt.gunMode == 'closeby':
partGunType = 'CloseByParticleGunProducer'

# RELVAL
DASquery=False
Expand Down Expand Up @@ -340,6 +351,14 @@ def submitHGCalProduction():
s_template=s_template.replace('MAXTHRESHSTRING',"Max"+str(opt.gunType))
s_template=s_template.replace('MINTHRESHSTRING',"Min"+str(opt.gunType))
s_template=s_template.replace('GUNMODE',str(opt.gunMode))
if opt.gunMode == 'closeby':
s_template=s_template.replace('DUMMYZMIN',str(opt.zMin))
s_template=s_template.replace('DUMMYZMAX',str(opt.zMax))
s_template=s_template.replace('DUMMYDELTA',str(opt.Delta))
s_template=s_template.replace('DUMMYRMIN',str(opt.rMin))
s_template=s_template.replace('DUMMYRMAX',str(opt.rMax))
s_template=s_template.replace('DUMMYPOINTING',str(opt.pointing))
s_template=s_template.replace('DUMMYOVERLAPPING',str(opt.overlapping))


elif (opt.DTIER == 'RECO' or opt.DTIER == 'NTUP'):
Expand Down
23 changes: 23 additions & 0 deletions templates/partGun_GSD_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,26 @@
),
PythiaParameters = cms.PSet(parameterSets = cms.vstring())
)
elif gunmode == 'closeby':
process.generator = cms.EDProducer("GUNPRODUCERTYPE",
AddAntiParticle = cms.bool(False),
PGunParameters = cms.PSet(
PartID = cms.vint32(DUMMYIDs),
EnMin = cms.double(DUMMYTHRESHMIN),
EnMax = cms.double(DUMMYTHRESHMAX),
RMin = cms.double(DUMMYRMIN),
RMax = cms.double(DUMMYRMAX),
ZMin = cms.double(DUMMYZMIN),
ZMax = cms.double(DUMMYZMAX),
Delta = cms.double(DUMMYDELTA),
Pointing = cms.bool(DUMMYPOINTING),
Overlapping = cms.bool(DUMMYOVERLAPPING),
MaxEta = cms.double(DUMMYETAMAX),
MinEta = cms.double(DUMMYETAMIN),
MaxPhi = cms.double(3.14159265359/6.),
MinPhi = cms.double(-3.14159265359/6.)
),
Verbosity = cms.untracked.int32(10),
psethack = cms.string('single or multiple particles predefined E moving vertex'),
firstRun = cms.untracked.uint32(1)
)

0 comments on commit e0c28d8

Please sign in to comment.