Skip to content

Commit

Permalink
Merge branch 'CMSSW_10_6_X' into jmenano-particle-net-ak4-106x
Browse files Browse the repository at this point in the history
  • Loading branch information
silviodonato committed Nov 9, 2020
2 parents 1b7fc06 + 53f19cb commit 11f44a1
Show file tree
Hide file tree
Showing 34 changed files with 909 additions and 334 deletions.
6 changes: 3 additions & 3 deletions Configuration/AlCa/python/autoCond.py
Expand Up @@ -26,11 +26,11 @@
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2
'run2_mc_pa' : '106X_mcRun2_pA_v5',
# GlobalTag for Run1 data reprocessing
'run1_data' : '106X_dataRun2_v28',
'run1_data' : '106X_dataRun2_v29',
# GlobalTag for Run2 data reprocessing
'run2_data' : '106X_dataRun2_v28',
'run2_data' : '106X_dataRun2_v29',
# GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu
'run2_data_relval' : '106X_dataRun2_relval_v26',
'run2_data_relval' : '106X_dataRun2_relval_v27',
# GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail
'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v13',
# GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed)
Expand Down
14 changes: 14 additions & 0 deletions Configuration/Applications/python/ConfigBuilder.py
Expand Up @@ -937,6 +937,7 @@ def define_Configs(self):
self.RECOSIMDefaultCFF="Configuration/StandardSequences/RecoSim_cff"
self.PATDefaultCFF="Configuration/StandardSequences/PAT_cff"
self.NANODefaultCFF="PhysicsTools/NanoAOD/nano_cff"
self.NANOGENDefaultCFF="PhysicsTools/NanoAOD/nanogen_cff"
self.EIDefaultCFF=None
self.SKIMDefaultCFF="Configuration/StandardSequences/Skims_cff"
self.POSTRECODefaultCFF="Configuration/StandardSequences/PostRecoGenerator_cff"
Expand Down Expand Up @@ -986,6 +987,8 @@ def define_Configs(self):
self.REPACKDefaultSeq='DigiToRawRepack'
self.PATDefaultSeq='miniAOD'
self.PATGENDefaultSeq='miniGEN'
#TODO: Check based of file input
self.NANOGENDefaultSeq='nanogenSequence'
self.NANODefaultSeq='nanoSequence'

self.EVTCONTDefaultCFF="Configuration/EventContent/EventContent_cff"
Expand Down Expand Up @@ -1689,6 +1692,17 @@ def prepare_NANO(self, sequence = "nanoAOD"):
self._options.customise_commands = self._options.customise_commands + " \n"
self._options.customise_commands = self._options.customise_commands + "process.unpackedPatTrigger.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n"

def prepare_NANOGEN(self, sequence = "nanoAOD"):
''' Enrich the schedule with NANOGEN '''
# TODO: Need to modify this based on the input file type
fromGen = any([x in self.stepMap for x in ['LHE', 'GEN', 'AOD']])
self.loadDefaultOrSpecifiedCFF(sequence,self.NANOGENDefaultCFF)
self.scheduleSequence(sequence.split('.')[-1],'nanoAOD_step')
custom = "customizeNanoGEN" if fromGen else "customizeNanoGENFromMini"
if self._options.runUnscheduled:
self._options.customisation_file_unsch.insert(0, '.'.join([self.NANOGENDefaultCFF, custom]))
else:
self._options.customisation_file.insert(0, '.'.join([self.NANOGENDefaultCFF, custom]))

def prepare_EI(self, sequence = None):
''' Enrich the schedule with event interpretation '''
Expand Down
Expand Up @@ -3,6 +3,7 @@

from Configuration.Generator.Pythia8CommonSettings_cfi import *
from Configuration.Generator.MCTunes2017.PythiaCP5Settings_cfi import *
from Configuration.Generator.PSweightsPythia.PythiaPSweightsSettings_cfi import *

generator = cms.EDFilter("Pythia8HadronizerFilter",
maxEventsToPrint = cms.untracked.int32(1),
Expand All @@ -13,6 +14,7 @@
PythiaParameters = cms.PSet(
pythia8CommonSettingsBlock,
pythia8CP5SettingsBlock,
pythia8PSweightsSettingsBlock,
JetMatchingParameters = cms.vstring(
'JetMatching:setMad = off',
'JetMatching:scheme = 1',
Expand All @@ -28,6 +30,7 @@
),
parameterSets = cms.vstring('pythia8CommonSettings',
'pythia8CP5Settings',
'pythia8PSweightsSettings',
'JetMatchingParameters'
)

Expand Down
Expand Up @@ -2,6 +2,7 @@
from Configuration.Generator.Pythia8CommonSettings_cfi import *
from Configuration.Generator.MCTunes2017.PythiaCP5Settings_cfi import *
from Configuration.Generator.Pythia8PowhegEmissionVetoSettings_cfi import *
from Configuration.Generator.PSweightsPythia.PythiaPSweightsSettings_cfi import *

generator = cms.EDFilter("Pythia8HadronizerFilter",
maxEventsToPrint = cms.untracked.int32(1),
Expand All @@ -12,6 +13,7 @@
PythiaParameters = cms.PSet(
pythia8CommonSettingsBlock,
pythia8CP5SettingsBlock,
pythia8PSweightsSettingsBlock,
pythia8PowhegEmissionVetoSettingsBlock,
processParameters = cms.vstring(
'POWHEG:nFinal = 2', ## Number of final state particles
Expand All @@ -21,6 +23,7 @@
),
parameterSets = cms.vstring('pythia8CommonSettings',
'pythia8CP5Settings',
'pythia8PSweightsSettings',
'pythia8PowhegEmissionVetoSettings',
'processParameters'
)
Expand Down
3 changes: 3 additions & 0 deletions Configuration/PyReleaseValidation/python/relval_generator.py
Expand Up @@ -40,3 +40,6 @@
workflows[545]=['',['BsToMuMu_forSTEAM_13TeV_TuneCUETP8M1','HARVESTGEN']]

# Miscellaneous
workflows[546]=['',['DYToLL_M-50_13TeV_pythia8','NANOGENFromGen']]
workflows[547]=['',['DYToll01234Jets_5f_LO_MLM_Madgraph_LHE_13TeV','Hadronizer_TuneCP5_13TeV_MLM_5f_max4j_LHE_pythia8','NANOGENFromGen']]
workflows[548]=['',['TTbar_Pow_LHE_13TeV','Hadronizer_TuneCP5_13TeV_powhegEmissionVeto2p_pythia8','NANOGENFromGen']]
5 changes: 5 additions & 0 deletions Configuration/PyReleaseValidation/python/relval_steps.py
Expand Up @@ -2905,11 +2905,16 @@ def gen2018HiMix(fragment,howMuch):
steps['MINIAODMCUP18FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018_FastSim'},stepMiniAODMC])

stepNanoAODDefaults = { '-s': 'NANO,DQM:@nanoAODDQM', '-n': 1000 }
stepNanoGenDefaults = { '-s': 'NANOGEN,DQM:@nanogenDQM', '-n': 1000 }
stepNanoAODData = merge([{ '--data':'', '--eventcontent' : 'NANOAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ])
stepNanoAODMC = merge([{ '--mc':'' , '--eventcontent' : 'NANOAODSIM,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMData = merge([{ '--data':'', '--eventcontent' : 'NANOEDMAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMMC = merge([{ '--mc':'' , '--eventcontent' : 'NANOEDMAODSIM,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoAODDefaults ])
stepNanoEDMMCProd = merge([{ '--mc':'', '-s': 'NANO', '--eventcontent' : 'NANOEDMAODSIM','--datatier': 'NANOAODSIM' }, stepNanoAODDefaults ])
stepNanoGen = merge([{ '--mc':'' , '--eventcontent' : 'NANOAODGEN,DQM','--datatier': 'NANOAODSIM,DQMIO' }, stepNanoGenDefaults ])

steps['NANOGENFromGen'] = merge([{'--conditions': 'auto:run2_mc', '--customise' : 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGEN'}, stepNanoGen ])
steps['NANOGENFromMini'] = merge([{'--conditions': 'auto:run2_mc'}, stepNanoGen ])

steps['NANOAOD2016'] = merge([{'--conditions': 'auto:run2_data_relval', '--era': 'Run2_2016'}, stepNanoAODData ])
steps['NANOAOD2017'] = merge([{'--conditions': 'auto:run2_data_relval', '--era': 'Run2_2017'}, stepNanoAODData ])
Expand Down
3 changes: 3 additions & 0 deletions DQMOffline/Configuration/python/DQMOffline_cff.py
Expand Up @@ -191,6 +191,9 @@
DQMOfflineNanoAOD = cms.Sequence(nanoDQM)
#PostDQMOfflineNanoAOD = cms.Sequence(nanoDQM)

from PhysicsTools.NanoAOD.nanogenDQM_cff import nanogenDQM
DQMOfflineNanoGen = cms.Sequence(nanogenDQM)

# L1 trigger sequences
DQMOfflineL1TMonitoring = cms.Sequence( l1TriggerDqmOffline ) # L1 emulator is run within this sequence for real data

Expand Down
4 changes: 4 additions & 0 deletions DQMOffline/Configuration/python/autoDQM.py
Expand Up @@ -100,6 +100,10 @@
'PostDQMOffline',
'DQMHarvestNanoAOD'],

'nanogenDQM': ['DQMOfflineNanoGen',
'PostDQMOffline',
'DQMHarvestNanoAOD'],

'standardDQM': ['DQMOffline',
'PostDQMOffline',
'dqmHarvesting'],
Expand Down
1 change: 1 addition & 0 deletions GeneratorInterface/Pythia8Interface/BuildFile.xml
Expand Up @@ -11,6 +11,7 @@
<use name="dire"/>
<use name="hepmc"/>
<use name="clhep"/>
<use name="root"/>
<export>
<lib name="1"/>
</export>
Expand Up @@ -32,6 +32,7 @@ namespace gen {
virtual bool generatePartonsAndHadronize() = 0;
bool decay() { return true; } // NOT used - let's call it "design imperfection"
bool readSettings( int ); // common func
void makeTmpSLHA(const std::string&); //helper for above
virtual bool initializeForInternalPartons() = 0;
bool declareStableParticles( const std::vector<int>& ); // common func
bool declareSpecialSettings( const std::vector<std::string>& ); // common func
Expand Down
32 changes: 32 additions & 0 deletions GeneratorInterface/Pythia8Interface/interface/SLHAReaderBase.h
@@ -0,0 +1,32 @@
#ifndef GeneratorInterface_Pythia8Interface_SLHAReaderBase
#define GeneratorInterface_Pythia8Interface_SLHAReaderBase

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <string>
#include <vector>

class TFile;
class TTree;

class SLHAReaderBase {
public:
SLHAReaderBase(const edm::ParameterSet& conf);
virtual ~SLHAReaderBase();

//this function should parse the config description (e.g. with splitline() below)
//then use the information to get the SLHA info out of the tree and return it
virtual std::string getSLHA(const std::string& configDesc) = 0;

static std::vector<std::string> splitline(const std::string& line, char delim);

protected:
//members
TFile* file_;
TTree* tree_;
};

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory<SLHAReaderBase*(const edm::ParameterSet&)> SLHAReaderFactory;

#endif
5 changes: 5 additions & 0 deletions GeneratorInterface/Pythia8Interface/plugins/BuildFile.xml
Expand Up @@ -8,3 +8,8 @@
<use name="GeneratorInterface/ExternalDecays"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="SLHA*.cc" name="GeneratorInterfacePythia8SLHAReader">
<use name="GeneratorInterface/Pythia8Interface"/>
<use name="root"/>
</library>
29 changes: 29 additions & 0 deletions GeneratorInterface/Pythia8Interface/plugins/SLHAReaderpMSSM.cc
@@ -0,0 +1,29 @@
#include "GeneratorInterface/Pythia8Interface/interface/SLHAReaderBase.h"

#include "TTree.h"
#include "TString.h"

#include <memory>

class SLHAReaderpMSSM : public SLHAReaderBase {
public:
SLHAReaderpMSSM(const edm::ParameterSet& conf) : SLHAReaderBase(conf) {}
~SLHAReaderpMSSM() override {}

std::string getSLHA(const std::string& configDesc) override;
};

DEFINE_EDM_PLUGIN(SLHAReaderFactory, SLHAReaderpMSSM, "SLHAReaderpMSSM");

std::string SLHAReaderpMSSM::getSLHA(const std::string& configDesc) {
const auto& config_fields = splitline(configDesc, '_');
int chain = std::stoi(config_fields.at(2));
int iteration = std::stoi(config_fields.at(3));

auto slhabranch = std::make_unique<TString>();
auto slhabranch_ptr = slhabranch.get();
tree_->SetBranchAddress("slhacontent", &slhabranch_ptr);
tree_->GetEntryWithIndex(chain, iteration);

return std::string(*slhabranch);
}
30 changes: 21 additions & 9 deletions GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc
@@ -1,4 +1,8 @@
#include <memory>
#include <string>

#include "GeneratorInterface/Pythia8Interface/interface/Py8InterfaceBase.h"
#include "GeneratorInterface/Pythia8Interface/interface/SLHAReaderBase.h"

#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand Down Expand Up @@ -164,20 +168,28 @@ namespace gen {
} else if (currentParameters.exists("SLHATableForPythia8")) {
std::string slhatable = currentParameters.getParameter<std::string>("SLHATableForPythia8");

char tempslhaname[] = "pythia8SLHAtableXXXXXX";
int fd = mkstemp(tempslhaname);
write(fd, slhatable.c_str(), slhatable.size());
close(fd);

slhafile_ = tempslhaname;

fMasterGen->settings.mode("SLHA:readFrom", 2);
fMasterGen->settings.word("SLHA:file", slhafile_);
makeTmpSLHA(slhatable);
} else if (currentParameters.exists("SLHATreeForPythia8")) {
auto slhaReaderParams = currentParameters.getParameter<edm::ParameterSet>("SLHATreeForPythia8");
std::unique_ptr<SLHAReaderBase> reader(SLHAReaderFactory::get()->create(slhaReaderParams.getParameter<std::string>("name"), slhaReaderParams));
makeTmpSLHA(reader->getSLHA(currentParameters.getParameter<std::string>("ConfigDescription")));
}

return true;
}

void Py8InterfaceBase::makeTmpSLHA(const std::string& slhatable) {
char tempslhaname[] = "pythia8SLHAtableXXXXXX";
int fd = mkstemp(tempslhaname);
write(fd, slhatable.c_str(), slhatable.size());
close(fd);

slhafile_ = tempslhaname;

fMasterGen->settings.mode("SLHA:readFrom", 2);
fMasterGen->settings.word("SLHA:file", slhafile_);
}

bool Py8InterfaceBase::declareStableParticles(const std::vector<int>& pdgIds) {
for (size_t i = 0; i < pdgIds.size(); i++) {
// FIXME: need to double check if PID's are the same in Py6 & Py8,
Expand Down
33 changes: 33 additions & 0 deletions GeneratorInterface/Pythia8Interface/src/SLHAReaderBase.cc
@@ -0,0 +1,33 @@
#include "GeneratorInterface/Pythia8Interface/interface/SLHAReaderBase.h"
#include "FWCore/Utilities/interface/Exception.h"

#include <sstream>

#include "TFile.h"
#include "TTree.h"

SLHAReaderBase::SLHAReaderBase(const edm::ParameterSet& conf) {
auto filename = conf.getParameter<std::string>("file");
file_ = TFile::Open(filename.c_str());
if (!file_)
throw cms::Exception("MissingFile") << "Could not open file " << filename;

auto treename = conf.getParameter<std::string>("tree");
tree_ = (TTree*)file_->Get(treename.c_str());
if (!tree_)
throw cms::Exception("MissingTree") << "Could not get tree " << treename << " from file " << filename;
}

SLHAReaderBase::~SLHAReaderBase() { file_->Close(); }

std::vector<std::string> SLHAReaderBase::splitline(const std::string& line, char delim) {
std::stringstream ss(line);
std::string field;
std::vector<std::string> fields;
while (getline(ss, field, delim)) {
fields.push_back(field);
}
return fields;
}

EDM_REGISTER_PLUGINFACTORY(SLHAReaderFactory, "SLHAReaderFactory");

0 comments on commit 11f44a1

Please sign in to comment.