diff --git a/SimG4CMS/Calo/macros/MakeHitStudyPlots.C b/SimG4CMS/Calo/macros/MakeHitStudyPlots.C index 89f16d34b3527..8c07b1f595fe5 100644 --- a/SimG4CMS/Calo/macros/MakeHitStudyPlots.C +++ b/SimG4CMS/Calo/macros/MakeHitStudyPlots.C @@ -9,18 +9,31 @@ // makeHitStudyPlots(file1, tag1, file2, tag2, todomin, todomax, gtitle, // ratio, save, dirnm) // -// where -// file1 std::string Name of the first ROOT file [old/analRun3.root] -// file2 std::string Name of the second ROOT file [new/analRun3.root] -// tag1 std::string Tag for the first file [Bug] -// tag2 std::string Tag for the second file [Fix] -// gtitle std::string Overall Titile [""] -// todomin int Minimum type # of histograms to be plotted [0] -// todomax int Maximum type # of histograms to be plotted [0] -// ratio bool if the ratio to be plotted [true] -// (works when both files are active) -// save bool If the canvas is to be saved as jpg file [false] -// dirnm std::string Name of the directory [CaloSimHitStudy] +// To make plots of ratios of hits produced with identical geometry and +// generator level files created by HGCalHitCheck +// +// makeDDDvsDD4hepPlots(dirnm, inType, geometry, layer, ratio, save) +// +// where (for makeHitStudyPlots) +// file1 std::string Name of the first ROOT file [old/analRun3.root] +// file2 std::string Name of the second ROOT file [new/analRun3.root] +// tag1 std::string Tag for the first file [Bug] +// tag2 std::string Tag for the second file [Fix] +// gtitle std::string Overall Titile [""] +// todomin int Minimum type # of histograms to be plotted [0] +// todomax int Maximum type # of histograms to be plotted [0] +// dirnm std::string Name of the directory [CaloSimHitStudy] +// +// where (for makeHitStudyPlots) +// dirnm std::string Directory name (EE/HEF/HEB) +// inType std::string Name of the input data (Muon/MinBias) +// geometry std::string Tag for the geometry (D98/D99) +// layer int Layer number (if 0; all layers combined) +// +// where (common to both macros) +// ratio bool if the ratio to be plotted [true] +// (works when both files are active) +// save bool If the canvas is to be saved as jpg file [false] // ////////////////////////////////////////////////////////////////////////////// @@ -237,3 +250,191 @@ void makeHitStudyPlots(std::string file1 = "uncorr/analRun3.root", } } } + +void makeDDDvsDD4hepPlots(std::string dirnm = "EE", + std::string inType = "Muon", + std::string geometry = "D98", + int layer = 0, + bool ratio = true, + bool save = false) { + const int plots = 3; + std::string types[2] = {"DDD", "DD4hep"}; + std::string plotf[plots] = {"L", "F", "P"}; + std::string plotp[plots] = {"All", "Full|SiPM 2mm", "Partial|SiPM 4mm"}; + int rebins[2] = {4, 20}; + double xmaxs[2] = {1000, 5000}; + bool debug(false); + + gStyle->SetCanvasBorderMode(0); + gStyle->SetCanvasColor(kWhite); + gStyle->SetPadColor(kWhite); + gStyle->SetFillColor(kWhite); + if (ratio) + gStyle->SetOptStat(0); + else + gStyle->SetOptStat(1110); + TFile* file[2]; + int nfile(0); + std::string tag(""), tags[2], filex[2]; + for (int i = 0; i < 2; ++i) { + filex[i] = types[i] + geometry + inType + ".root"; + file[nfile] = new TFile(filex[i].c_str()); + if (file[nfile]) { + tags[nfile] = types[i]; + ++nfile; + tag += tags[nfile]; + } + } + char name[80], nameD[80], title[80]; + int rebin = (inType == "Muon") ? rebins[0] : rebins[1]; + double xmax = (inType == "Muon") ? xmaxs[0] : xmaxs[1]; + sprintf(nameD, "hgcalHitCheck%s", dirnm.c_str()); + sprintf(title, "%s vs %s for %s", types[0].c_str(), types[1].c_str(), inType.c_str()); + std::cout << "Use " << nfile << " files from " << filex[0] << " and " << filex[1] << " and look for " << plots + << " plots in " << nameD << " with rebin " << rebin << " Max " << xmax; + for (int i = 0; i < plots; ++i) { + if (layer == 0) + sprintf(name, "Hits%s", plotf[i].c_str()); + else + sprintf(name, "Hits%s%d", plotf[i].c_str(), layer); + double y1(0.90), dy(0.12); + double y2 = y1 - dy * nfile - 0.01; + TLegend* leg = (ratio) ? (new TLegend(0.40, 0.86, 0.90, 0.90)) : (new TLegend(0.65, y2 - nfile * 0.04, 0.90, y2)); + leg->SetBorderSize(1); + leg->SetFillColor(10); + TH1D* hist0[nfile]; + for (int ifile = 0; ifile < nfile; ++ifile) { + TDirectory* dir = (TDirectory*)file[ifile]->FindObjectAny(nameD); + hist0[ifile] = static_cast(dir->FindObjectAny(name)); + if (debug) + std::cout << name << " read out at " << hist0[ifile] << " for " << tags[ifile] << std::endl; + } + char namec[160]; + if (!ratio) { + sprintf(namec, "c_%s%s%s%s", geometry.c_str(), inType.c_str(), dirnm.c_str(), name); + TCanvas* pad; + int first(0); + for (int ifile = 0; ifile < nfile; ++ifile) { + TH1D* hist(hist0[ifile]); + if (hist != nullptr) { + if (rebin > 1) + hist->Rebin(rebin); + hist->SetTitle(title); + hist->SetLineColor(first + 1); + hist->SetLineStyle(first + 1); + hist->GetYaxis()->SetTitleOffset(1.4); + hist->GetXaxis()->SetRangeUser(0, xmax); + hist->GetXaxis()->SetTitleSize(0.025); + hist->GetXaxis()->SetTitleOffset(1.2); + hist->SetMarkerStyle(first + 20); + hist->SetMarkerColor(first + 1); + hist->SetMarkerSize(0.7); + if (first == 0) { + pad = new TCanvas(namec, namec, 500, 500); + pad->SetRightMargin(0.10); + pad->SetTopMargin(0.10); + pad->SetLogy(); + hist->Draw(); + } else { + hist->Draw("sames"); + } + leg->AddEntry(hist, tags[ifile].c_str(), "lp"); + pad->Update(); + ++first; + TPaveStats* st = ((TPaveStats*)hist->GetListOfFunctions()->FindObject("stats")); + if (st != NULL) { + st->SetLineColor(first); + st->SetTextColor(first); + st->SetY1NDC(y1 - dy); + st->SetY2NDC(y1); + st->SetX1NDC(0.65); + st->SetX2NDC(0.90); + y1 -= dy; + } + pad->Modified(); + pad->Update(); + leg->Draw("same"); + pad->Update(); + } + if (save) { + sprintf(name, "%s.pdf", pad->GetName()); + pad->Print(name); + } + } + } else if (nfile == 2) { + sprintf(namec, "cR_%s%s%s%s", geometry.c_str(), inType.c_str(), dirnm.c_str(), name); + TCanvas* pad = new TCanvas(namec, namec, 500, 500); + int nbin = hist0[0]->GetNbinsX(); + int nbinR = nbin / rebin; + double xlow = hist0[0]->GetXaxis()->GetBinLowEdge(1); + double xhigh = xmax; + TH1D* histr = new TH1D(name, hist0[0]->GetTitle(), nbinR, xlow, xhigh); + histr->SetTitle(title); + if (layer == 0) + sprintf(name, "Number of hits (%s)", plotp[i].c_str()); + else + sprintf(name, "Number of hits in Layer %d (%s)", layer, plotp[i].c_str()); + histr->GetXaxis()->SetTitle(name); + sprintf(name, "Ratio (%s/%s)", tags[0].c_str(), tags[1].c_str()); + histr->GetYaxis()->SetTitle(name); + histr->GetXaxis()->SetLabelOffset(0.005); + histr->GetXaxis()->SetTitleOffset(1.30); + histr->GetXaxis()->SetTitleSize(0.036); + histr->GetYaxis()->SetLabelOffset(0.005); + histr->GetYaxis()->SetTitleOffset(1.20); + histr->GetYaxis()->SetTitleSize(0.036); + histr->GetYaxis()->SetRangeUser(0.0, 5.0); + histr->SetMarkerStyle(20); + histr->SetMarkerColor(1); + histr->SetMarkerSize(0.7); + double sumNum(0), sumDen(0), maxDev(0); + for (int j = 0; j < nbinR; ++j) { + double tnum(0), tden(0), rnum(0), rden(0); + for (int i = 0; i < rebin; ++i) { + int ib = j * rebin + i + 1; + tnum += hist0[0]->GetBinContent(ib); + tden += hist0[1]->GetBinContent(ib); + rnum += ((hist0[0]->GetBinError(ib)) * (hist0[0]->GetBinError(ib))); + rden += ((hist0[1]->GetBinError(ib)) * (hist0[1]->GetBinError(ib))); + } + if (tden > 0 && tnum > 0) { + double rat = tnum / tden; + double err = rat * sqrt((rnum / (tnum * tnum)) + (rden / (tden * tden))); + histr->SetBinContent(j + 1, rat); + histr->SetBinError(j + 1, err); + double temp1 = (rat > 1.0) ? 1.0 / rat : rat; + double temp2 = (rat > 1.0) ? err / (rat * rat) : err; + sumNum += (fabs(1 - temp1) / (temp2 * temp2)); + sumDen += (1.0 / (temp2 * temp2)); + if (fabs(1 - temp1) > maxDev) + maxDev = fabs(1 - temp1); + } + } + histr->Draw(); + if (layer == 0) + sprintf(name, "%s %s", dirnm.c_str(), plotp[i].c_str()); + else + sprintf(name, "%s (Layer %d) %s", dirnm.c_str(), layer, plotp[i].c_str()); + leg->AddEntry(histr, name, "lp"); + leg->Draw("same"); + pad->Update(); + TLine* line = new TLine(xlow, 1.0, xhigh, 1.0); + line->SetLineColor(2); + line->SetLineWidth(2); + line->SetLineStyle(2); + line->Draw("same"); + pad->Modified(); + pad->Update(); + sumNum = (sumDen > 0) ? (sumNum / sumDen) : 0; + sumDen = (sumDen > 0) ? 1.0 / sqrt(sumDen) : 0; + if (sumNum == 0) + sumDen = 0; + std::cout << tags[0] << " vs " << tags[1] << " " << hist0[0]->GetXaxis()->GetTitle() << " Mean deviation " + << sumNum << " +- " << sumDen << " maximum " << maxDev << std::endl; + if (save) { + sprintf(name, "%s.pdf", pad->GetName()); + pad->Print(name); + } + } + } +} diff --git a/SimG4CMS/Calo/plugins/HGCalHitCheck.cc b/SimG4CMS/Calo/plugins/HGCalHitCheck.cc new file mode 100644 index 0000000000000..d3245d5e736f6 --- /dev/null +++ b/SimG4CMS/Calo/plugins/HGCalHitCheck.cc @@ -0,0 +1,195 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" +#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" + +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" + +#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" +#include "Geometry/CaloTopology/interface/HGCalTopology.h" +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" + +#include +#include +#include +#include + +class HGcalHitCheck : public edm::one::EDAnalyzer<> { +public: + HGcalHitCheck(const edm::ParameterSet& ps); + ~HGcalHitCheck() override {} + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +protected: + void analyze(edm::Event const&, edm::EventSetup const&) override; + void beginJob() override; + void endJob() override {} + +private: + const std::string g4Label_, caloHitSource_, nameSense_, nameDetector_, tag_; + const int layers_, verbosity_; + const edm::EDGetTokenT tok_calo_; + const edm::ESGetToken geomToken_; + bool histos_; + TH1D *h_hits_, *h_hit1_, *h_hit2_; + std::vector h_hitL_, h_hitF_, h_hitP_; +}; + +HGcalHitCheck::HGcalHitCheck(const edm::ParameterSet& ps) + : g4Label_(ps.getParameter("moduleLabel")), + caloHitSource_(ps.getParameter("caloHitSource")), + nameSense_(ps.getParameter("nameSense")), + nameDetector_(ps.getParameter("tag")), + tag_(ps.getParameter("nameDevice")), + layers_(ps.getParameter("layers")), + verbosity_(ps.getParameter("verbosity")), + tok_calo_(consumes(edm::InputTag(g4Label_, caloHitSource_))), + geomToken_(esConsumes(edm::ESInputTag{"", nameSense_})), + histos_(false) { + edm::LogVerbatim("HitStudy") << "Test Hit ID for " << nameDetector_ << " using SimHits for " << nameSense_ + << " with module Label: " << g4Label_ << " Hits: " << caloHitSource_; +} + +void HGcalHitCheck::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("moduleLabel", "g4SimHits"); + desc.add("caloHitSource", "HGCHitsEE"); + desc.add("nameSense", "HGCalEESensitive"); + desc.add("nameDevice", "HGCal EE"); + desc.add("tag", "DDD"); + desc.add("layers", 26); + desc.add("verbosity", 0); + descriptions.add("hgcalHitCheckEE", desc); +} + +void HGcalHitCheck::beginJob() { + edm::Service fs; + if (!fs.isAvailable()) { + edm::LogVerbatim("HitStudy") << "TFileService unavailable: no histograms"; + } else { + histos_ = true; + char name[100], title[200]; + sprintf(name, "HitsL"); + sprintf(title, "Number of hits in %s for %s", nameSense_.c_str(), tag_.c_str()); + h_hits_ = fs->make(name, title, 1000, 0, 5000.); + h_hits_->GetXaxis()->SetTitle(title); + h_hits_->GetYaxis()->SetTitle("Hits"); + h_hits_->Sumw2(); + sprintf(name, "HitsF"); + sprintf(title, "Number of hits in %s for %s in Full Wafers or SiPM 2", nameSense_.c_str(), tag_.c_str()); + h_hit1_ = fs->make(name, title, 1000, 0, 5000.); + h_hit1_->GetXaxis()->SetTitle(title); + h_hit1_->GetYaxis()->SetTitle("Hits"); + h_hit1_->Sumw2(); + sprintf(name, "HitsP"); + sprintf(title, "Number of hits in %s for %s in Partial Wafers or SiPM 4", nameSense_.c_str(), tag_.c_str()); + h_hit2_ = fs->make(name, title, 1000, 0, 5000.); + h_hit2_->GetXaxis()->SetTitle(title); + h_hit2_->GetYaxis()->SetTitle("Hits"); + h_hit2_->Sumw2(); + for (int k = 0; k < layers_; ++k) { + sprintf(name, "HitsL%d", k + 1); + sprintf(title, "Number of hits in %s for %s in Layer %d", nameSense_.c_str(), tag_.c_str(), k + 1); + h_hitL_.emplace_back(fs->make(name, title, 1000, 0, 5000.)); + h_hitL_.back()->GetXaxis()->SetTitle(title); + h_hitL_.back()->GetYaxis()->SetTitle("Hits"); + h_hitL_.back()->Sumw2(); + sprintf(name, "HitsF%d", k + 1); + sprintf(title, + "Number of hits in %s for %s in Full Wafers or SiPM 2 of Layer %d", + nameSense_.c_str(), + tag_.c_str(), + k + 1); + h_hitF_.emplace_back(fs->make(name, title, 1000, 0, 5000.)); + h_hitF_.back()->GetXaxis()->SetTitle(title); + h_hitF_.back()->GetYaxis()->SetTitle("Hits"); + h_hitF_.back()->Sumw2(); + sprintf(name, "HitsP%d", k + 1); + sprintf(title, + "Number of hits in %s for %s in Partial Wafers or SiPM 4 of Layer %d", + nameSense_.c_str(), + tag_.c_str(), + k + 1); + h_hitP_.emplace_back(fs->make(name, title, 1000, 0, 5000.)); + h_hitP_.back()->GetXaxis()->SetTitle(title); + h_hitP_.back()->GetYaxis()->SetTitle("Hits"); + h_hitP_.back()->Sumw2(); + } + } +} + +void HGcalHitCheck::analyze(const edm::Event& e, const edm::EventSetup& iS) { + if (verbosity_ > 0) + edm::LogVerbatim("HitStudy") << "Run = " << e.id().run() << " Event = " << e.id().event(); + + // get hcalGeometry + const HGCalGeometry* geom = &iS.getData(geomToken_); + const HGCalDDDConstants& hgc = geom->topology().dddConstants(); + const std::vector& validIds = geom->getValidDetIds(); + edm::LogVerbatim("HitStudy") << "Detector " << nameSense_ << " with " << validIds.size() << " valid cells"; + + const edm::Handle& hitsCalo = e.getHandle(tok_calo_); + bool getHits = (hitsCalo.isValid()); + uint32_t nhits = (getHits) ? hitsCalo->size() : 0; + uint32_t wafer(0), tiles(0); + if (verbosity_ > 1) + edm::LogVerbatim("HitStudy") << "HGcalHitCheck: Input flags Hits " << getHits << " with " << nhits << " hits"; + if (histos_) + h_hits_->Fill(nhits); + + if (getHits) { + std::vector hits; + hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end()); + if (!hits.empty()) { + for (auto hit : hits) { + if (histos_) { + if ((nameSense_ == "HGCalEESensitive") || (nameSense_ == "HGCalHESiliconSensitive")) { + ++wafer; + HGCSiliconDetId id(hit.id()); + int lay = id.layer(); + h_hitL_[lay - 1]->Fill(nhits); + HGCalParameters::waferInfo info = hgc.waferInfo(lay, id.waferU(), id.waferV()); + if (info.part == HGCalTypes::WaferFull) { + h_hit1_->Fill(nhits); + h_hitF_[lay - 1]->Fill(nhits); + } else { + h_hit2_->Fill(nhits); + h_hitP_[lay - 1]->Fill(nhits); + } + } else { + ++tiles; + HGCScintillatorDetId id(hit.id()); + int lay = id.layer(); + h_hitL_[lay - 1]->Fill(nhits); + int sipm = id.sipm(); + if (sipm == 1) { + h_hit2_->Fill(nhits); + h_hitP_[lay - 1]->Fill(nhits); + } else { + h_hit1_->Fill(nhits); + h_hitF_[lay - 1]->Fill(nhits); + } + } + } + } + } + } + edm::LogVerbatim("HitStudy") << "Total hits = " << nhits << " Wafer DetIds = " << wafer << " Tile DetIds = " << tiles; +} + +//define this as a plug-in +DEFINE_FWK_MODULE(HGcalHitCheck); diff --git a/SimG4CMS/Calo/python/hgcalHitCheck_cff.py b/SimG4CMS/Calo/python/hgcalHitCheck_cff.py new file mode 100644 index 0000000000000..0b8cc65111a2f --- /dev/null +++ b/SimG4CMS/Calo/python/hgcalHitCheck_cff.py @@ -0,0 +1,18 @@ +import FWCore.ParameterSet.Config as cms + +from SimG4CMS.Calo.hgcalHitCheckEE_cfi import * +from Configuration.ProcessModifiers.dd4hep_cff import dd4hep + +dd4hep.toModify( hgcalHitCheckEE, tag = "DD4hep" ) + +hgcalHitCheckHEF = hgcalHitCheckEE.clone( + nameDevice = "HGCal HE Silicon", + nameSense = "HGCalHESiliconSensitive", + caloHitSource = "HGCHitsHEfront", + layers = 21) + +hgcalHitCheckHEB = hgcalHitCheckEE.clone( + nameDevice = "HGCal HE Scinitillator", + nameSense = "HGCalHEScintillatorSensitive", + caloHitSource = "HGCHitsHEback", + layers = 21) diff --git a/SimG4CMS/Calo/test/python/Gen_MinBias.py b/SimG4CMS/Calo/test/python/Gen_MinBias.py new file mode 100644 index 0000000000000..e43ed773beccf --- /dev/null +++ b/SimG4CMS/Calo/test/python/Gen_MinBias.py @@ -0,0 +1,161 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: MinBias_13TeV_pythia8_TuneCUETP8M1_cfi.py -s GEN -n 1000 --conditions auto:phase2_realistic_T25 --beamspot HLLHC --datatier GEN-SIM --eventcontent FEVTDEBUG --geometry Extended2026D98 --era Phase2C17I13M9 --python Gen_MinBias.py --no_exec --fileout file:step0MinBias.root --nThreads 8 +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 + +process = cms.Process('GEN',Phase2C17I13M9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D98Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + holdsReferencesToDeleteEarly = cms.untracked.VPSet(), + makeTriggerResults = cms.obsolete.untracked.bool, + modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('MinBias_13TeV_pythia8_TuneCUETP8M1_cfi.py nevts:100'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:step0MinBias.root'), + outputCommands = process.FEVTDEBUGEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T25', '') + +process.generator = cms.EDFilter("Pythia8ConcurrentGeneratorFilter", + PythiaParameters = cms.PSet( + parameterSets = cms.vstring( + 'pythia8CommonSettings', + 'pythia8CUEP8M1Settings', + 'processParameters' + ), + processParameters = cms.vstring( + 'SoftQCD:nonDiffractive = on', + 'SoftQCD:singleDiffractive = on', + 'SoftQCD:doubleDiffractive = on' + ), + pythia8CUEP8M1Settings = cms.vstring( + 'Tune:pp 14', + 'Tune:ee 7', + 'MultipartonInteractions:pT0Ref=2.4024', + 'MultipartonInteractions:ecmPow=0.25208', + 'MultipartonInteractions:expPow=1.6' + ), + pythia8CommonSettings = cms.vstring( + 'Tune:preferLHAPDF = 2', + 'Main:timesAllowErrors = 10000', + 'Check:epTolErr = 0.01', + 'Beams:setProductionScalesFromLHEF = off', + 'SLHA:minMassSM = 1000.', + 'ParticleDecays:limitTau0 = on', + 'ParticleDecays:tau0Max = 10', + 'ParticleDecays:allowPhotonRadiation = on' + ) + ), + comEnergy = cms.double(13000.0), + crossSection = cms.untracked.double(71390000000.0), + filterEfficiency = cms.untracked.double(1.0), + maxEventsToPrint = cms.untracked.int32(0), + pythiaHepMCVerbosity = cms.untracked.bool(False), + pythiaPylistVerbosity = cms.untracked.int32(1) +) + + +process.ProductionFilterSequence = cms.Sequence(process.generator) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.endjob_step,process.FEVTDEBUGoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 8 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.ProductionFilterSequence) + + + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/SimG4CMS/Calo/test/python/Gen_SingleMuon.py b/SimG4CMS/Calo/test/python/Gen_SingleMuon.py new file mode 100644 index 0000000000000..2317d553ab1ed --- /dev/null +++ b/SimG4CMS/Calo/test/python/Gen_SingleMuon.py @@ -0,0 +1,134 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 + +process = cms.Process('GEN',Phase2C17I13M9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D98Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + holdsReferencesToDeleteEarly = cms.untracked.VPSet(), + makeTriggerResults = cms.obsolete.untracked.bool, + modulesToIgnoreForDeleteEarly = cms.untracked.vstring(), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('SingleMuPt100_pythia8_cfi.py nevts:100'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:step0Muon.root'), + outputCommands = process.FEVTDEBUGEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T25', '') + +process.generator = cms.EDProducer("FlatRandomEGunProducer", + PGunParameters = cms.PSet( + MinEta = cms.double(1.50), + MaxEta = cms.double(3.1), + MinPhi = cms.double(-3.14159265359), + MaxPhi = cms.double(3.14159265359), + MinE = cms.double(100.00), + MaxE = cms.double(100.00), + PartID = cms.vint32(-13) + ), + Verbosity = cms.untracked.int32(0), + AddAntiParticle = cms.bool(True), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single mu E 100') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.endjob_step,process.FEVTDEBUGoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 8 +process.options.numberOfStreams = 0 +process.options.numberOfConcurrentLuminosityBlocks = 1 +process.options.eventSetup.numberOfConcurrentIOVs = 1 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + + + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/SimG4CMS/Calo/test/python/Sim2026_cfg.py b/SimG4CMS/Calo/test/python/Sim2026_cfg.py new file mode 100644 index 0000000000000..0d900f095482a --- /dev/null +++ b/SimG4CMS/Calo/test/python/Sim2026_cfg.py @@ -0,0 +1,120 @@ +############################################################################### +# Way to use this: +# cmsRun Sim2026_cfg.py geometry=D98 type=DDD data=Muon +# +# Options for geometry: D98, D99 +# type: DDD, DD4hep +# data: Muon, MinBias +# +############################################################################### +import FWCore.ParameterSet.Config as cms +import os, sys, imp, re, random +import FWCore.ParameterSet.VarParsing as VarParsing + +#################################################################### +### SETUP OPTIONS +options = VarParsing.VarParsing('standard') +options.register('geometry', + "D98", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "geometry of operations: D98, D99") +options.register('type', + "DDD", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "type of operations: DDD, DD4hep") +options.register('data', + "Muon", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "data of operations: Muon, MinBias") + +### get and parse the command line arguments +options.parseArguments() + +print(options) + +#################################################################### +# Use the options + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 +if (options.type == "DD4hep"): + from Configuration.ProcessModifiers.dd4hep_cff import dd4hep + process = cms.Process('Sim2026',Phase2C17I13M9,dd4hep) + geomFile = "Configuration.Geometry.Geometry" + options.type +"Extended2026" + options.geometry + "Reco_cff" +else: + process = cms.Process('Sim2026',Phase2C17I13M9) + geomFile = "Configuration.Geometry.GeometryExtended2026" + options.geometry + "Reco_cff" + +globalTag = "auto:phase2_realistic_T25" +inFile = "file:step0" + options.data + ".root" +outFile = "file:step1" + options.type + options.geometry + options.data + ".root" +tFile = "file:" + options.type + options.geometry + options.data + ".root" + +print("Geometry file: ", geomFile) +print("Global Tag: ", globalTag) +print("Input file: ", inFile) +print("Output file: ", outFile) +print("Histogram file:", tFile) + +process.load(geomFile) +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load("Configuration.EventContent.EventContent_cff") +process.load("Configuration.StandardSequences.SimIdeal_cff") +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, globalTag, '') + +process.source = cms.Source("PoolSource", + dropDescendantsOfDroppedBranches = cms.untracked.bool(False), + fileNames = cms.untracked.vstring(inFile), + secondaryFileNames = cms.untracked.vstring() +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +if 'MessageLogger' in process.__dict__: + process.MessageLogger.G4cerr=dict() + process.MessageLogger.HitStudy=dict() + +process.Timing = cms.Service("Timing") + +process.load("IOMC.RandomEngine.IOMC_cff") +process.RandomNumberGeneratorService.generator.initialSeed = 456789 +process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 +process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 +process.rndmStore = cms.EDProducer("RandomEngineStateProducer") + +# Event output +process.output = cms.OutputModule("PoolOutputModule", + process.FEVTSIMEventContent, + fileName = cms.untracked.string(outFile) +) + +process.load("SimG4CMS.Calo.hgcalHitCheck_cff") +process.TFileService = cms.Service("TFileService", + fileName = cms.string(tFile) +) + +process.simulation_step = cms.Path(process.psim) +process.out_step = cms.EndPath(process.output) +process.analysis_step1 = cms.EndPath(process.hgcalHitCheckEE) +process.analysis_step2 = cms.EndPath(process.hgcalHitCheckHEF) +process.analysis_step3 = cms.EndPath(process.hgcalHitCheckHEB) + +process.g4SimHits.Physics.type = 'SimG4Core/Physics/FTFP_BERT_EMM' + +# Schedule definition +process.schedule = cms.Schedule(process.simulation_step, + process.out_step, + process.analysis_step1, + process.analysis_step2, + process.analysis_step3, + )