diff --git a/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.cc b/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.cc index d74f7da4ec950..59cddf564e779 100644 --- a/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.cc +++ b/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.cc @@ -27,13 +27,15 @@ using namespace std; DTFakeT0ESProducer::DTFakeT0ESProducer(const edm::ParameterSet& pset) { //framework - setWhatProduced(this, &DTFakeT0ESProducer::produce); + auto cc = setWhatProduced(this, &DTFakeT0ESProducer::produce); // setWhatProduced(this,dependsOn(& DTGeometryESModule::parseDDD())); findingRecord(); //read constant value for t0 from cfg t0Mean = pset.getParameter("t0Mean"); t0Sigma = pset.getParameter("t0Sigma"); + cpvTokenDDD_ = cc.consumesFrom(edm::ESInputTag()); + mdcToken_ = cc.consumes(); } DTFakeT0ESProducer::~DTFakeT0ESProducer() {} @@ -59,13 +61,10 @@ std::unique_ptr DTFakeT0ESProducer::produce(const DTT0Rcd& iRecord) { } void DTFakeT0ESProducer::parseDDD(const DTT0Rcd& iRecord) { - edm::ESTransientHandle cpv; - edm::ESHandle mdc; + edm::ESTransientHandle cpv = iRecord.getTransientHandle(cpvTokenDDD_); + const auto& mdc = iRecord.get(mdcToken_); - iRecord.getRecord().get(cpv); - iRecord.getRecord().get(mdc); - - DTGeometryParserFromDDD parser(&(*cpv), *mdc, theLayerIdWiresMap); + DTGeometryParserFromDDD parser(&(*cpv), mdc, theLayerIdWiresMap); } void DTFakeT0ESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, diff --git a/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.h b/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.h index 7b69578bc49e6..3ca80375ce1e7 100644 --- a/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.h +++ b/CalibMuon/DTCalibration/plugins/DTFakeT0ESProducer.h @@ -21,6 +21,12 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DetectorDescription/Core/interface/DDCompactView.h" +#include "DetectorDescription/DDCMS/interface/DDCompactView.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h" + //#include #include @@ -48,5 +54,8 @@ class DTFakeT0ESProducer : public edm::ESProducer, public edm::EventSetupRecordI //t0 mean and sigma values read from cfg double t0Mean; double t0Sigma; + + edm::ESGetToken cpvTokenDDD_; + edm::ESGetToken mdcToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.cc b/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.cc index 5aca6ce1837fb..7291adf7f2543 100644 --- a/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.cc @@ -51,7 +51,9 @@ DTNoiseCalibration::DTNoiseCalibration(const edm::ParameterSet& pset) dbLabel_(pset.getUntrackedParameter("dbLabel", "")), //fastAnalysis_( pset.getParameter("fastAnalysis", true) ), wireIdWithHisto_(std::vector()), - lumiMax_(3000) { + lumiMax_(3000), + dtGeomToken_(esConsumes()), + ttrigToken_(esConsumes(edm::ESInputTag("", pset.getParameter("dbLabel")))) { // Get the debug parameter for verbose output //debug = ps.getUntrackedParameter("debug"); /*// The analysis type @@ -96,12 +98,10 @@ void DTNoiseCalibration::beginJob() { void DTNoiseCalibration::beginRun(const edm::Run& run, const edm::EventSetup& setup) { // Get the DT Geometry - setup.get().get(dtGeom_); - + dtGeom_ = setup.getHandle(dtGeomToken_); // tTrig if (readDB_) - setup.get().get(dbLabel_, tTrigMap_); - + tTrigMap_ = &setup.getData(ttrigToken_); runBeginTime_ = time_t(run.beginTime().value() >> 32); runEndTime_ = time_t(run.endTime().value() >> 32); /* diff --git a/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.h b/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.h index ef846f0c6c23c..5c5f236f15d49 100644 --- a/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTNoiseCalibration.h @@ -12,6 +12,8 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/DataRecord/interface/DTTtrigRcd.h" #include #include @@ -74,8 +76,11 @@ class DTNoiseCalibration : public edm::EDAnalyzer { // Get the DT Geometry edm::ESHandle dtGeom_; + const edm::ESGetToken dtGeomToken_; + // tTrig map edm::ESHandle tTrigMap_; + const edm::ESGetToken ttrigToken_; TFile* rootFile_; // TDC digi distribution diff --git a/CalibMuon/DTCalibration/plugins/DTNoiseComputation.cc b/CalibMuon/DTCalibration/plugins/DTNoiseComputation.cc index b41cf3e8d59bc..e9be264db4b63 100644 --- a/CalibMuon/DTCalibration/plugins/DTNoiseComputation.cc +++ b/CalibMuon/DTCalibration/plugins/DTNoiseComputation.cc @@ -38,7 +38,7 @@ using namespace edm; using namespace std; -DTNoiseComputation::DTNoiseComputation(const edm::ParameterSet &ps) { +DTNoiseComputation::DTNoiseComputation(const edm::ParameterSet &ps) : dtGeomToken_(esConsumes()) { cout << "[DTNoiseComputation]: Constructor" << endl; // Get the debug parameter for verbose output @@ -61,7 +61,7 @@ DTNoiseComputation::DTNoiseComputation(const edm::ParameterSet &ps) { void DTNoiseComputation::beginRun(const edm::Run &, const EventSetup &setup) { // Get the DT Geometry - setup.get().get(dtGeom); + dtGeom = setup.getHandle(dtGeomToken_); static int count = 0; diff --git a/CalibMuon/DTCalibration/plugins/DTNoiseComputation.h b/CalibMuon/DTCalibration/plugins/DTNoiseComputation.h index 1e74be9b61297..de24a0853f9aa 100644 --- a/CalibMuon/DTCalibration/plugins/DTNoiseComputation.h +++ b/CalibMuon/DTCalibration/plugins/DTNoiseComputation.h @@ -14,6 +14,7 @@ #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "DataFormats/MuonDetId/interface/DTChamberId.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include #include @@ -57,6 +58,7 @@ class DTNoiseComputation : public edm::EDAnalyzer { // Get the DT Geometry edm::ESHandle dtGeom; + const edm::ESGetToken dtGeomToken_; // The file which contain the occupancy plot and the digi event plot TFile* theFile; diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc index af764e74b77ae..1635d11f4c2d0 100644 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc @@ -35,7 +35,8 @@ DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset) : histRange_(pset.getParameter("histogramRange")), segment4DLabel_(pset.getParameter("segment4DLabel")), rootBaseDir_(pset.getUntrackedParameter("rootBaseDir", "DT/Residuals")), - detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis", false)) { + detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis", false)), + dtGeomToken_(esConsumes()) { edm::ConsumesCollector collector(consumesCollector()); select_ = new DTSegmentSelector(pset, collector); @@ -63,7 +64,7 @@ void DTResidualCalibration::beginJob() { TH1::SetDefaultSumw2(true); } void DTResidualCalibration::beginRun(const edm::Run& run, const edm::EventSetup& setup) { // get the geometry edm::ESHandle dtGeomH; - setup.get().get(dtGeomH); + dtGeomH = setup.getHandle(dtGeomToken_); dtGeom_ = dtGeomH.product(); // Loop over all the chambers diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h index 1b6c5f328d0cd..cce4721877c0a 100644 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h @@ -13,6 +13,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include #include @@ -59,6 +60,8 @@ class DTResidualCalibration : public edm::EDAnalyzer { TFile* rootFile_; // Geometry const DTGeometry* dtGeom_; + const edm::ESGetToken dtGeomToken_; + // Histograms per super-layer std::map histoMapTH1F_; std::map histoMapTH2F_; diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc index 4ac67cd7cbbce..ee9d5055e90b9 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc @@ -42,9 +42,8 @@ DTT0Calibration::DTT0Calibration(const edm::ParameterSet& pset) tpPeakWidthPerLayer(pset.getParameter("tpPeakWidthPerLayer")), rejectDigiFromPeak(pset.getParameter("rejectDigiFromPeak")), hLayerPeaks("hLayerPeaks", "", 3000, 0, 3000), - spectrum(20) - -{ + spectrum(20), + dtGeomToken_(esConsumes()) { // Get the debug parameter for verbose output if (debug) cout << "[DTT0Calibration]Constructor called!" << endl; @@ -99,7 +98,7 @@ void DTT0Calibration::analyze(const edm::Event& event, const edm::EventSetup& ev // Get the DT Geometry if (nevents == 1) - eventSetup.get().get(dtGeom); + dtGeom = eventSetup.getHandle(dtGeomToken_); // Iterate through all digi collections ordered by LayerId for (const auto& digis_per_layer : *digis) { diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h index a0d0ac56f994d..459cafe9908b0 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h @@ -17,6 +17,7 @@ #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "DataFormats/DTDigi/interface/DTDigiCollection.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include #include @@ -122,5 +123,6 @@ class DTT0Calibration : public edm::one::EDAnalyzer<> { //DTGeometry used to loop on the SL in the endJob edm::ESHandle dtGeom; + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.cc b/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.cc index 9e82947100e13..395e74d8197f1 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.cc @@ -24,7 +24,7 @@ using namespace edm; // using namespace cond; // Constructor -DTT0CalibrationRMS::DTT0CalibrationRMS(const edm::ParameterSet& pset) { +DTT0CalibrationRMS::DTT0CalibrationRMS(const edm::ParameterSet& pset) : dtGeomToken_(esConsumes()) { // Get the debug parameter for verbose output debug = pset.getUntrackedParameter("debug"); if (debug) @@ -102,7 +102,7 @@ void DTT0CalibrationRMS::analyze(const edm::Event& event, const edm::EventSetup& event.getByLabel(digiLabel, digis); // Get the DT Geometry - eventSetup.get().get(dtGeom); + dtGeom = eventSetup.getHandle(dtGeomToken_); // Iterate through all digi collections ordered by LayerId DTDigiCollection::DigiRangeIterator dtLayerIt; diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h b/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h index f0145820c40c9..ee97801d2774d 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h @@ -13,6 +13,7 @@ #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include #include @@ -105,5 +106,6 @@ class DTT0CalibrationRMS : public edm::EDAnalyzer { //DTGeometry used to loop on the SL in the endJob edm::ESHandle dtGeom; + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.cc b/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.cc index f5455d038d8e4..bc9eae7e83648 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.cc @@ -8,6 +8,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "CondFormats/DTObjects/interface/DTT0.h" @@ -21,8 +22,8 @@ using namespace edm; namespace dtCalibration { - DTT0ChamberReferenceCorrection::DTT0ChamberReferenceCorrection(const ParameterSet& pset) - : calibChamber_(pset.getParameter("calibChamber")) { + DTT0ChamberReferenceCorrection::DTT0ChamberReferenceCorrection(const ParameterSet& pset, edm::ConsumesCollector cc) + : calibChamber_(pset.getParameter("calibChamber")), t0Token_(cc.esConsumes()) { //DTChamberId chosenChamberId; if (!calibChamber_.empty() && calibChamber_ != "None" && calibChamber_ != "All") { stringstream linestr; @@ -40,8 +41,8 @@ namespace dtCalibration { void DTT0ChamberReferenceCorrection::setES(const EventSetup& setup) { // Get t0 record from DB ESHandle t0H; - setup.get().get(t0H); - t0Map_ = &*t0H; + t0H = setup.getHandle(t0Token_); + t0Map_ = &setup.getData(t0Token_); LogVerbatim("Calibration") << "[DTT0ChamberReferenceCorrection] T0 version: " << t0H->version(); } diff --git a/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.h b/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.h index 3fa4e5bb715c5..723a3b4d9ad20 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.h +++ b/CalibMuon/DTCalibration/plugins/DTT0ChamberReferenceCorrection.h @@ -11,6 +11,10 @@ #include "CalibMuon/DTCalibration/interface/DTT0BaseCorrection.h" #include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "CondFormats/DataRecord/interface/DTT0Rcd.h" +#include "CondFormats/DTObjects/interface/DTT0.h" #include @@ -25,7 +29,7 @@ namespace dtCalibration { class DTT0ChamberReferenceCorrection : public DTT0BaseCorrection { public: // Constructor - DTT0ChamberReferenceCorrection(const edm::ParameterSet&); + DTT0ChamberReferenceCorrection(const edm::ParameterSet&, edm::ConsumesCollector); // Destructor ~DTT0ChamberReferenceCorrection() override; @@ -40,6 +44,7 @@ namespace dtCalibration { DTChamberId chosenChamberId_; const DTT0* t0Map_; + edm::ESGetToken t0Token_; }; } // namespace dtCalibration diff --git a/CalibMuon/DTCalibration/plugins/DTT0Correction.cc b/CalibMuon/DTCalibration/plugins/DTT0Correction.cc index dcbda683426ef..7a55a301679ba 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Correction.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0Correction.cc @@ -29,7 +29,9 @@ using namespace std; DTT0Correction::DTT0Correction(const ParameterSet& pset) : correctionAlgo_{DTT0CorrectionFactory::get()->create(pset.getParameter("correctionAlgo"), - pset.getParameter("correctionAlgoConfig"))} { + pset.getParameter("correctionAlgoConfig"))}, + dtGeomToken_(esConsumes()), + t0Token_(esConsumes()) { LogVerbatim("Calibration") << "[DTT0Correction] Constructor called" << endl; } @@ -38,12 +40,12 @@ DTT0Correction::~DTT0Correction() { LogVerbatim("Calibration") << "[DTT0Correcti void DTT0Correction::beginRun(const edm::Run& run, const edm::EventSetup& setup) { // Get t0 record from DB ESHandle t0H; - setup.get().get(t0H); - t0Map_ = &*t0H; + t0H = setup.getHandle(t0Token_); + t0Map_ = &setup.getData(t0Token_); LogVerbatim("Calibration") << "[DTT0Correction]: T0 version: " << t0H->version() << endl; // Get geometry from Event Setup - setup.get().get(muonGeom_); + muonGeom_ = setup.getHandle(dtGeomToken_); // Pass EventSetup to correction Algo correctionAlgo_->setES(setup); diff --git a/CalibMuon/DTCalibration/plugins/DTT0Correction.h b/CalibMuon/DTCalibration/plugins/DTT0Correction.h index 703243093bffd..dda53305e403d 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Correction.h +++ b/CalibMuon/DTCalibration/plugins/DTT0Correction.h @@ -8,6 +8,9 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/DTObjects/interface/DTT0.h" +#include "CondFormats/DataRecord/interface/DTT0Rcd.h" #include @@ -34,9 +37,12 @@ class DTT0Correction : public edm::EDAnalyzer { protected: private: - const DTT0* t0Map_; + std::unique_ptr correctionAlgo_; + edm::ESHandle muonGeom_; + const edm::ESGetToken dtGeomToken_; - std::unique_ptr correctionAlgo_; + const DTT0* t0Map_; + edm::ESGetToken t0Token_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.cc b/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.cc index 7eea1c9701777..89b6f9407f513 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.cc @@ -15,6 +15,7 @@ #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "CondFormats/DTObjects/interface/DTT0.h" #include "CondFormats/DataRecord/interface/DTT0Rcd.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include #include @@ -24,8 +25,8 @@ using namespace edm; namespace dtCalibration { - DTT0FEBPathCorrection::DTT0FEBPathCorrection(const ParameterSet& pset) - : calibChamber_(pset.getParameter("calibChamber")) { + DTT0FEBPathCorrection::DTT0FEBPathCorrection(const ParameterSet& pset, edm::ConsumesCollector cc) + : calibChamber_(pset.getParameter("calibChamber")), t0Token_(cc.esConsumes()) { //DTChamberId chosenChamberId; if (!calibChamber_.empty() && calibChamber_ != "None" && calibChamber_ != "All") { stringstream linestr; @@ -43,8 +44,8 @@ namespace dtCalibration { void DTT0FEBPathCorrection::setES(const EventSetup& setup) { // Get t0 record from DB ESHandle t0H; - setup.get().get(t0H); - t0Map_ = &*t0H; + t0H = setup.getHandle(t0Token_); + t0Map_ = &setup.getData(t0Token_); LogVerbatim("Calibration") << "[DTT0FEBPathCorrection] T0 version: " << t0H->version(); } diff --git a/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.h b/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.h index 39c1234766657..8a3204a61b1ae 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.h +++ b/CalibMuon/DTCalibration/plugins/DTT0FEBPathCorrection.h @@ -11,6 +11,10 @@ #include "CalibMuon/DTCalibration/interface/DTT0BaseCorrection.h" #include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "CondFormats/DataRecord/interface/DTT0Rcd.h" +#include "CondFormats/DTObjects/interface/DTT0.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include @@ -25,7 +29,7 @@ namespace dtCalibration { class DTT0FEBPathCorrection : public DTT0BaseCorrection { public: // Constructor - DTT0FEBPathCorrection(const edm::ParameterSet&); + DTT0FEBPathCorrection(const edm::ParameterSet&, edm::ConsumesCollector); // Destructor ~DTT0FEBPathCorrection() override; @@ -42,6 +46,7 @@ namespace dtCalibration { DTChamberId chosenChamberId_; const DTT0* t0Map_; + edm::ESGetToken t0Token_; }; } // namespace dtCalibration diff --git a/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.cc b/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.cc index 867ae6336bb88..d3d88c3c073eb 100644 --- a/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.cc +++ b/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.cc @@ -33,9 +33,10 @@ using namespace std; using namespace edm; // Constructor -DTTPDeadWriter::DTTPDeadWriter(const ParameterSet& pset) { +DTTPDeadWriter::DTTPDeadWriter(const ParameterSet& pset) : dtGeomToken_(esConsumes()) { // get selected debug option debug = pset.getUntrackedParameter("debug", false); + t0Token_ = esConsumes(edm::ESInputTag("", pset.getParameter("debug"))); // Create the object to be written to DB tpDeadList = new DTDeadFlag(); @@ -52,12 +53,10 @@ DTTPDeadWriter::~DTTPDeadWriter() { void DTTPDeadWriter::beginRun(const edm::Run&, const EventSetup& setup) { // Get the t0 map - ESHandle t0; - setup.get().get(t0); - tZeroMap = &*t0; + tZeroMap = &setup.getData(t0Token_); // Get the muon Geometry - setup.get().get(muonGeom); + muonGeom = setup.getHandle(dtGeomToken_); } // Do the job diff --git a/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h b/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h index 0a005ae97fe04..0288bcb8a932c 100644 --- a/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h +++ b/CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h @@ -10,6 +10,9 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/DTObjects/interface/DTT0.h" +#include "CondFormats/DataRecord/interface/DTT0Rcd.h" #include @@ -48,11 +51,13 @@ class DTTPDeadWriter : public edm::EDAnalyzer { //The map of t0 to be read from event const DTT0* tZeroMap; + edm::ESGetToken t0Token_; // The object to be written to DB DTDeadFlag* tpDeadList; //The DTGeometry edm::ESHandle muonGeom; + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.cc b/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.cc index 44b0203583001..946c74ee204ee 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.cc +++ b/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.cc @@ -25,7 +25,8 @@ using namespace edm; using namespace std; -DTTTrigCorrectionFirst::DTTTrigCorrectionFirst(const ParameterSet& pset) { +DTTTrigCorrectionFirst::DTTTrigCorrectionFirst(const ParameterSet& pset) + : dtGeomToken_(esConsumes()), ttrigToken_(esConsumes(edm::ESInputTag("", pset.getParameter("dbLabel")))) { debug = pset.getUntrackedParameter("debug", false); ttrigMin = pset.getUntrackedParameter("ttrigMin", 0); ttrigMax = pset.getUntrackedParameter("ttrigMax", 5000); @@ -38,11 +39,10 @@ DTTTrigCorrectionFirst::~DTTTrigCorrectionFirst() {} void DTTTrigCorrectionFirst::beginRun(const edm::Run& run, const edm::EventSetup& setup) { ESHandle tTrig; - setup.get().get(dbLabel, tTrig); - tTrigMap = &*tTrig; + tTrig = setup.getHandle(ttrigToken_); + tTrigMap = &setup.getData(ttrigToken_); cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl; - - setup.get().get(muonGeom); + muonGeom = setup.getHandle(dtGeomToken_); } void DTTTrigCorrectionFirst::endJob() { diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h b/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h index 5b0c496e3398a..70803fa64b4e8 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h +++ b/CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h @@ -11,6 +11,8 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/DataRecord/interface/DTTtrigRcd.h" #include @@ -35,8 +37,11 @@ class DTTTrigCorrectionFirst : public edm::EDAnalyzer { protected: private: - const DTTtrig* tTrigMap; edm::ESHandle muonGeom; + const edm::ESGetToken dtGeomToken_; + + const DTTtrig* tTrigMap; + const edm::ESGetToken ttrigToken_; std::string dbLabel; diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc index 4ea933cd41001..7faccb654a4ab 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc @@ -38,7 +38,9 @@ DTTTrigOffsetCalibration::DTTTrigOffsetCalibration(const ParameterSet& pset) : theRecHits4DLabel_(pset.getParameter("recHits4DLabel")), doTTrigCorrection_(pset.getUntrackedParameter("doT0SegCorrection", false)), theCalibChamber_(pset.getUntrackedParameter("calibChamber", "All")), - dbLabel_(pset.getUntrackedParameter("dbLabel", "")) { + dbLabel_(pset.getUntrackedParameter("dbLabel", "")), + ttrigToken_(esConsumes(edm::ESInputTag("", pset.getParameter("dbLabel")))), + dtGeomToken_(esConsumes()) { LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Constructor called!"; edm::ConsumesCollector collector(consumesCollector()); @@ -53,8 +55,8 @@ DTTTrigOffsetCalibration::DTTTrigOffsetCalibration(const ParameterSet& pset) void DTTTrigOffsetCalibration::beginRun(const edm::Run& run, const edm::EventSetup& setup) { if (doTTrigCorrection_) { ESHandle tTrig; - setup.get().get(dbLabel_, tTrig); - tTrigMap_ = &*tTrig; + tTrig = setup.getHandle(ttrigToken_); + tTrigMap_ = &setup.getData(ttrigToken_); LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration]: TTrig version: " << tTrig->version() << endl; } } @@ -79,7 +81,7 @@ void DTTTrigOffsetCalibration::analyze(const Event& event, const EventSetup& eve // Get the DT Geometry ESHandle dtGeom; - eventSetup.get().get(dtGeom); + dtGeom = eventSetup.getHandle(dtGeomToken_); // Get the rechit collection from the event Handle all4DSegments; diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h index d6a0825bfe17b..60c448faad1e4 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h @@ -10,6 +10,9 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/DataRecord/interface/DTTtrigRcd.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" #include @@ -49,5 +52,8 @@ class DTTTrigOffsetCalibration : public edm::EDAnalyzer { TFile* rootFile_; const DTTtrig* tTrigMap_; ChamberHistosMap theT0SegHistoMap_; + + const edm::ESGetToken ttrigToken_; + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigWriter.cc b/CalibMuon/DTCalibration/plugins/DTTTrigWriter.cc index fa85f6a6f69a3..d790e8dcad5f5 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigWriter.cc +++ b/CalibMuon/DTCalibration/plugins/DTTTrigWriter.cc @@ -33,7 +33,7 @@ using namespace std; using namespace edm; // Constructor -DTTTrigWriter::DTTTrigWriter(const ParameterSet& pset) { +DTTTrigWriter::DTTTrigWriter(const ParameterSet& pset) : dtGeomToken_(esConsumes()) { // get selected debug option debug = pset.getUntrackedParameter("debug", false); @@ -72,8 +72,7 @@ void DTTTrigWriter::analyze(const Event& event, const EventSetup& eventSetup) { cout << "[DTTTrigWriter]Analyzer called!" << endl; // Get the DT Geometry - ESHandle dtGeom; - eventSetup.get().get(dtGeom); + dtGeom = eventSetup.getHandle(dtGeomToken_); // Get all the sls from the setup const vector superLayers = dtGeom->superLayers(); diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigWriter.h b/CalibMuon/DTCalibration/plugins/DTTTrigWriter.h index 47cf1a4518179..f008f0d4ea0c8 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigWriter.h +++ b/CalibMuon/DTCalibration/plugins/DTTTrigWriter.h @@ -8,7 +8,10 @@ */ #include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" // #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" #include @@ -60,5 +63,9 @@ class DTTTrigWriter : public edm::EDAnalyzer { // The object to be written to DB DTTtrig* tTrig; + + //geom + edm::ESHandle dtGeom; + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc index 17297347a421a..d851f5735ad64 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc @@ -33,7 +33,8 @@ using namespace edm; DTVDriftSegmentCalibration::DTVDriftSegmentCalibration(const ParameterSet& pset) : theRecHits4DLabel_(pset.getParameter("recHits4DLabel")), //writeVDriftDB_(pset.getUntrackedParameter("writeVDriftDB", false)), - theCalibChamber_(pset.getUntrackedParameter("calibChamber", "All")) { + theCalibChamber_(pset.getUntrackedParameter("calibChamber", "All")), + dtGeomToken_(esConsumes()) { LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Constructor called!"; edm::ConsumesCollector collector(consumesCollector()); @@ -59,7 +60,7 @@ void DTVDriftSegmentCalibration::analyze(const Event& event, const EventSetup& e // Get the DT Geometry ESHandle dtGeom; - eventSetup.get().get(dtGeom); + dtGeom = eventSetup.getHandle(dtGeomToken_); // Get the rechit collection from the event Handle all4DSegments; diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h index 398535a960acf..6361953a6552f 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h @@ -11,6 +11,8 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" #include @@ -45,5 +47,7 @@ class DTVDriftSegmentCalibration : public edm::EDAnalyzer { TFile* rootFile_; ChamberHistosMapTH1F theVDriftHistoMapTH1F_; ChamberHistosMapTH2F theVDriftHistoMapTH2F_; + + const edm::ESGetToken dtGeomToken_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftWriter.cc b/CalibMuon/DTCalibration/plugins/DTVDriftWriter.cc index 363cab5cf2cf3..5a2ba83a87222 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftWriter.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftWriter.cc @@ -33,7 +33,10 @@ using namespace std; using namespace edm; DTVDriftWriter::DTVDriftWriter(const ParameterSet& pset) - : granularity_(pset.getUntrackedParameter("calibGranularity", "bySL")), + : mTimeMapToken_(esConsumes()), + vDriftMapToken_(esConsumes()), + dtGeomToken_(esConsumes()), + granularity_(pset.getUntrackedParameter("calibGranularity", "bySL")), mTimeMap_(nullptr), vDriftMap_(nullptr), vDriftAlgo_{DTVDriftPluginFactory::get()->create(pset.getParameter("vDriftAlgo"), @@ -53,13 +56,9 @@ DTVDriftWriter::~DTVDriftWriter() { LogVerbatim("Calibration") << "[DTVDriftWrit void DTVDriftWriter::beginRun(const edm::Run& run, const edm::EventSetup& setup) { // Get the map of vdrift from the Setup if (readLegacyVDriftDB) { - ESHandle mTime; - setup.get().get(mTime); - mTimeMap_ = &*mTime; + mTimeMap_ = &setup.getData(mTimeMapToken_); } else { - ESHandle hVdrift; - setup.get().get(hVdrift); - vDriftMap_ = &*hVdrift; + vDriftMap_ = &setup.getData(vDriftMapToken_); // Consistency check: no parametrization is implemented for the time being int version = vDriftMap_->version(); if (version != 1) { @@ -68,7 +67,8 @@ void DTVDriftWriter::beginRun(const edm::Run& run, const edm::EventSetup& setup) } // Get geometry from Event Setup - setup.get().get(dtGeom_); + dtGeom_ = setup.getHandle(dtGeomToken_); + // Pass EventSetup to concrete implementation vDriftAlgo_->setES(setup); } diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftWriter.h b/CalibMuon/DTCalibration/plugins/DTVDriftWriter.h index a95c30059fcc9..ccd7a8bdf80b8 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftWriter.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftWriter.h @@ -12,6 +12,9 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "CondFormats/DataRecord/interface/DTMtimeRcd.h" +#include "CondFormats/DataRecord/interface/DTRecoConditionsVdriftRcd.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include @@ -33,8 +36,10 @@ class DTVDriftWriter : public edm::EDAnalyzer { void endJob() override; private: - std::string granularity_; // enforced by SL - + const edm::ESGetToken mTimeMapToken_; + const edm::ESGetToken vDriftMapToken_; + const edm::ESGetToken dtGeomToken_; + std::string granularity_; // enforced by SL const DTMtime* mTimeMap_; // legacy DB object const DTRecoConditions* vDriftMap_; // DB object in new format bool readLegacyVDriftDB; // which format to use to read old values diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkFilter.cc new file mode 100644 index 0000000000000..9d7cc3d4557b5 --- /dev/null +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkFilter.cc @@ -0,0 +1,164 @@ +// system include files +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDFilter.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h" + +//#define EDM_ML_DEBUG +// +// class declaration +// + +namespace alcaHcalIsoTrk { + struct Counters { + Counters() : nAll_(0), nGood_(0), nLow_(0), nHigh_(0) {} + mutable std::atomic nAll_, nGood_, nLow_, nHigh_; + }; +} // namespace alcaHcalIsoTrk + +class AlCaHcalIsotrkFilter : public edm::global::EDFilter > { +public: + AlCaHcalIsotrkFilter(edm::ParameterSet const&); + + std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; + + bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; + void globalEndRun(edm::Run const& iRun, edm::EventSetup const&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + // ----------member data --------------------------- + double pTrackLow_, pTrackHigh_; + int prescaleLow_, prescaleHigh_; + edm::InputTag labelIsoTkVar_; + edm::EDGetTokenT tokIsoTrkVar_; +}; + +// +// constructors and destructor +// +AlCaHcalIsotrkFilter::AlCaHcalIsotrkFilter(edm::ParameterSet const& iConfig) + : pTrackLow_(iConfig.getParameter("momentumLow")), + pTrackHigh_(iConfig.getParameter("momentumHigh")), + prescaleLow_(iConfig.getParameter("prescaleLow")), + prescaleHigh_(iConfig.getParameter("prescaleHigh")), + labelIsoTkVar_(iConfig.getParameter("isoTrackLabel")), + tokIsoTrkVar_(consumes(labelIsoTkVar_)) { + edm::LogVerbatim("HcalIsoTrack") << "Parameters read from config file \n\t momentumLow_ " << pTrackLow_ + << "\t prescaleLow_ " << prescaleLow_ << "\t momentumHigh_ " << pTrackHigh_ + << "\t prescaleHigh_ " << prescaleHigh_ << "\n\t Labels " << labelIsoTkVar_; +} // AlCaHcalIsotrkFilter::AlCaHcalIsotrkFilter constructor + +// +// member functions +// + +// ------------ method called on each new Event ------------ +bool AlCaHcalIsotrkFilter::filter(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const { + bool accept(false); + ++(runCache(iEvent.getRun().index())->nAll_); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "AlCaHcalIsotrkFilter::Run " << iEvent.id().run() << " Event " + << iEvent.id().event() << " Luminosity " << iEvent.luminosityBlock() << " Bunch " + << iEvent.bunchCrossing(); +#endif + + auto const& isotrkCalibColl = iEvent.getHandle(tokIsoTrkVar_); + if (isotrkCalibColl.isValid()) { + auto isotrkCalib = isotrkCalibColl.product(); + bool low(false), high(false), inRange(false); + for (auto itr = isotrkCalib->begin(); itr != isotrkCalib->end(); ++itr) { + if (itr->p_ < pTrackLow_) { + low = true; + } else if (itr->p_ > pTrackHigh_) { + high = true; + } else { + inRange = true; + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "AlCaHcalIsotrkFilter::Finds " << isotrkCalib->size() + << " entries in HcalIsoTrkCalibVariables collection with inRange " << inRange + << " low " << low << " high " << high; +#endif + if (low) + ++(runCache(iEvent.getRun().index())->nLow_); + if (high) + ++(runCache(iEvent.getRun().index())->nHigh_); + if (inRange) { + accept = true; + } else { + if (low) { + if (prescaleLow_ <= 1) + accept = true; + else if (runCache(iEvent.getRun().index())->nLow_ % prescaleLow_ == 1) + accept = true; + } + if (high) { + if (prescaleHigh_ <= 1) + accept = true; + else if (runCache(iEvent.getRun().index())->nHigh_ % prescaleHigh_ == 1) + accept = true; + } + } + } else { + edm::LogVerbatim("HcalIsoTrack") << "AlCaHcalIsotrkFilter::Cannot find the collection for HcalIsoTrkCalibVariables"; + } + + // Return the acceptance flag + if (accept) + ++(runCache(iEvent.getRun().index())->nGood_); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "AlCaHcalIsotrkFilter::Accept flag " << accept << " All " + << runCache(iEvent.getRun().index())->nAll_ << " Good " + << runCache(iEvent.getRun().index())->nGood_ << " Low " + << runCache(iEvent.getRun().index())->nLow_ << " High " + << runCache(iEvent.getRun().index())->nHigh_; +#endif + return accept; + +} // AlCaHcalIsotrkFilter::filter + +// ------------ method called when starting to processes a run ------------ +std::shared_ptr AlCaHcalIsotrkFilter::globalBeginRun(edm::Run const& iRun, + edm::EventSetup const&) const { + edm::LogVerbatim("HcalIsoTrack") << "Start the Run " << iRun.run(); + return std::make_shared(); +} + +// ------------ method called when ending the processing of a run ------------ +void AlCaHcalIsotrkFilter::globalEndRun(edm::Run const& iRun, edm::EventSetup const&) const { + edm::LogVerbatim("HcalIsoTrack") << "Select " << runCache(iRun.index())->nGood_ << " good events out of " + << runCache(iRun.index())->nAll_ << " total # of events with " + << runCache(iRun.index())->nLow_ << ":" << runCache(iRun.index())->nHigh_ + << " events below and above the required range"; +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void AlCaHcalIsotrkFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("momentumLow", 40.0); + desc.add("momentumHigh", 60.0); + desc.add("prescaleLow", 1); + desc.add("prescaleHigh", 1); + desc.add("isoTrackLabel", edm::InputTag("alcaHcalIsotrkProducer", "HcalIsoTrack")); + descriptions.add("alcaHcalIsotrkFilter", desc); +} + +//define this as a plug-in +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(AlCaHcalIsotrkFilter); diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkProducer.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkProducer.cc new file mode 100644 index 0000000000000..67cd96c4c1d9b --- /dev/null +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkProducer.cc @@ -0,0 +1,1405 @@ +// -*- C++ -*- + +// system include files +#include +#include +#include +#include +#include +#include +#include +#include + +// user include files +#include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h" +#include "Calibration/IsolatedParticles/interface/ChargeIsolation.h" +#include "Calibration/IsolatedParticles/interface/eCone.h" +#include "Calibration/IsolatedParticles/interface/eECALMatrix.h" +#include "Calibration/IsolatedParticles/interface/eHCALMatrix.h" +#include "Calibration/IsolatedParticles/interface/TrackSelection.h" + +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" +#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h" +#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h" + +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h" +#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkEventVariables.h" +#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" +#include "DataFormats/Math/interface/LorentzVector.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/MuonReco/interface/MuonSelectors.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackReco/interface/HitPattern.h" +#include "DataFormats/TrackReco/interface/TrackBase.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/Common/interface/TriggerResults.h" +#include "DataFormats/HLTReco/interface/TriggerEvent.h" +#include "DataFormats/HLTReco/interface/TriggerObject.h" +#include "DataFormats/Luminosity/interface/LumiDetails.h" +#include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h" +#include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h" +#include "DataFormats/L1Trigger/interface/BXVector.h" +#include "L1Trigger/L1TGlobal/interface/L1TGlobalUtil.h" +#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" + +#include "FWCore/Common/interface/TriggerNames.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/Records/interface/CaloTopologyRecord.h" +#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" +#include "Geometry/CaloTopology/interface/HcalTopology.h" +#include "Geometry/CaloTopology/interface/CaloTopology.h" +#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h" +#include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h" + +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" + +//#define EDM_ML_DEBUG +// +// class declaration +// + +namespace alcaHcalIsoTracks { + struct Counters { + Counters() : nAll_(0), nGood_(0), nRange_(0) {} + mutable std::atomic nAll_, nGood_, nRange_; + }; +} // namespace alcaHcalIsoTracks + +class AlCaHcalIsotrkProducer : public edm::stream::EDProducer > { +public: + explicit AlCaHcalIsotrkProducer(edm::ParameterSet const&, const alcaHcalIsoTracks::Counters*); + ~AlCaHcalIsotrkProducer() override = default; + + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { + return std::make_unique(); + } + + void produce(edm::Event&, edm::EventSetup const&) override; + void endStream() override; + static void globalEndJob(const alcaHcalIsoTracks::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void beginRun(edm::Run const&, edm::EventSetup const&) override; + void endRun(edm::Run const&, edm::EventSetup const&) override; + std::array getProducts(int goodPV, + double eventWeight, + std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* topo, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& towerHandle, + const edm::Handle& genParticles, + const HcalRespCorrs* respCorrs, + const edm::Handle& muonh, + std::vector& hocalib, + HcalIsoTrkEventVariables& hocalibEvent); + double dR(math::XYZTLorentzVector&, math::XYZTLorentzVector&); + double trackP(const reco::Track*, const edm::Handle&); + double rhoh(const edm::Handle&); + double eThreshold(const DetId& id, const CaloGeometry* geo) const; + DetId newId(const DetId&); + void storeEnergy(const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector& detIds, + std::vector& hitEnergies); + std::pair storeEnergy(const HcalRespCorrs* respCorrs, + edm::Handle& hbhe, + const std::vector& ids, + std::vector& hitEnergy1, + std::vector& hitEnergy2); + bool notaMuon(const reco::Track* pTrack0, const edm::Handle& muonh); + + // ----------member data --------------------------- + l1t::L1TGlobalUtil* l1GtUtils_; + HLTConfigProvider hltConfig_; + unsigned int nRun_, nAll_, nGood_, nRange_; + const std::vector trigNames_; + spr::trackSelectionParameters selectionParameter_; + const std::string theTrackQuality_; + const std::string processName_, l1Filter_; + const std::string l2Filter_, l3Filter_; + const double a_coneR_, a_mipR_, a_mipR2_, a_mipR3_; + const double a_mipR4_, a_mipR5_, pTrackMin_, eEcalMax_; + const double maxRestrictionP_, slopeRestrictionP_; + const double hcalScale_, eIsolate1_, eIsolate2_; + const double pTrackLow_, pTrackHigh_; + const bool ignoreTrigger_, useL1Trigger_; + const bool unCorrect_, collapseDepth_; + const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; + const double hitEthrEE2_, hitEthrEE3_; + const double hitEthrEELo_, hitEthrEEHi_; + const edm::InputTag triggerEvent_, theTriggerResultsLabel_; + const std::string labelGenTrack_, labelRecVtx_, labelEB_; + const std::string labelEE_, labelHBHE_, labelTower_, l1TrigName_; + const std::vector oldID_, newDepth_; + const bool hep17_; + const std::string labelIsoTkVar_, labelIsoTkEvtVar_; + + double a_charIsoR_, a_coneR1_, a_coneR2_; + const HcalDDDRecConstants* hdc_; + std::vector etabins_, phibins_; + std::vector oldDet_, oldEta_, oldDepth_; + double etadist_, phidist_, etahalfdist_, phihalfdist_; + + edm::EDGetTokenT tok_trigEvt_; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_parts_; + edm::EDGetTokenT tok_genTrack_; + edm::EDGetTokenT tok_recVtx_; + edm::EDGetTokenT tok_bs_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_hbhe_; + edm::EDGetTokenT tok_cala_; + edm::EDGetTokenT tok_ew_; + edm::EDGetTokenT > tok_alg_; + edm::EDGetTokenT tok_Muon_; + + edm::ESGetToken tok_ddrec_; + edm::ESGetToken tok_bFieldH_; + edm::ESGetToken tok_ecalChStatus_; + edm::ESGetToken tok_sevlv_; + edm::ESGetToken tok_geom_; + edm::ESGetToken tok_caloTopology_; + edm::ESGetToken tok_htopo_; + edm::ESGetToken tok_resp_; +}; + +AlCaHcalIsotrkProducer::AlCaHcalIsotrkProducer(edm::ParameterSet const& iConfig, + const alcaHcalIsoTracks::Counters* counters) + : nRun_(0), + nAll_(0), + nGood_(0), + nRange_(0), + trigNames_(iConfig.getParameter >("triggers")), + theTrackQuality_(iConfig.getParameter("trackQuality")), + processName_(iConfig.getParameter("processName")), + l1Filter_(iConfig.getParameter("l1Filter")), + l2Filter_(iConfig.getParameter("l2Filter")), + l3Filter_(iConfig.getParameter("l3Filter")), + a_coneR_(iConfig.getParameter("coneRadius")), + a_mipR_(iConfig.getParameter("coneRadiusMIP")), + a_mipR2_(iConfig.getParameter("coneRadiusMIP2")), + a_mipR3_(iConfig.getParameter("coneRadiusMIP3")), + a_mipR4_(iConfig.getParameter("coneRadiusMIP4")), + a_mipR5_(iConfig.getParameter("coneRadiusMIP5")), + pTrackMin_(iConfig.getParameter("minimumTrackP")), + eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), + maxRestrictionP_(iConfig.getParameter("maxTrackP")), + slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), + hcalScale_(iConfig.getUntrackedParameter("hHcalScale", 1.0)), + eIsolate1_(iConfig.getParameter("isolationEnergyTight")), + eIsolate2_(iConfig.getParameter("isolationEnergyLoose")), + pTrackLow_(iConfig.getParameter("momentumLow")), + pTrackHigh_(iConfig.getParameter("momentumHigh")), + ignoreTrigger_(iConfig.getUntrackedParameter("ignoreTriggers", false)), + useL1Trigger_(iConfig.getUntrackedParameter("useL1Trigger", false)), + unCorrect_(iConfig.getUntrackedParameter("unCorrect", false)), + collapseDepth_(iConfig.getUntrackedParameter("collapseDepth", false)), + hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold")), + hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0")), + hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1")), + hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2")), + hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3")), + hitEthrEELo_(iConfig.getParameter("EEHitEnergyThresholdLow")), + hitEthrEEHi_(iConfig.getParameter("EEHitEnergyThresholdHigh")), + triggerEvent_(iConfig.getParameter("labelTriggerEvent")), + theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), + labelGenTrack_(iConfig.getParameter("labelTrack")), + labelRecVtx_(iConfig.getParameter("labelVertex")), + labelEB_(iConfig.getParameter("labelEBRecHit")), + labelEE_(iConfig.getParameter("labelEERecHit")), + labelHBHE_(iConfig.getParameter("labelHBHERecHit")), + labelTower_(iConfig.getParameter("labelCaloTower")), + l1TrigName_(iConfig.getUntrackedParameter("l1TrigName", "L1_SingleJet60")), + oldID_(iConfig.getUntrackedParameter >("oldID")), + newDepth_(iConfig.getUntrackedParameter >("newDepth")), + hep17_(iConfig.getUntrackedParameter("hep17")), + labelIsoTkVar_(iConfig.getParameter("isoTrackLabel")), + labelIsoTkEvtVar_(iConfig.getParameter("isoTrackEventLabel")) { + // Get the run parameters + const double isolationRadius(28.9), innerR(10.0), outerR(30.0); + reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality_); + selectionParameter_.minPt = iConfig.getParameter("minTrackPt"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.minQuality = trackQuality_; + selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); + selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); + a_charIsoR_ = a_coneR_ + isolationRadius; + a_coneR1_ = a_coneR_ + innerR; + a_coneR2_ = a_coneR_ + outerR; + // Different isolation cuts are described in DN-2016/029 + // Tight cut uses 2 GeV; Loose cut uses 10 GeV + // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18)) + // with the factor for exponential slopeRestrictionP_ = log(2.5)/18 + // maxRestrictionP_ = 8 GeV as came from a study + std::string labelBS = iConfig.getParameter("labelBeamSpot"); + edm::InputTag algTag = iConfig.getParameter("algInputTag"); + edm::InputTag extTag = iConfig.getParameter("extInputTag"); + std::string labelMuon = iConfig.getParameter("labelMuon"); + + for (unsigned int k = 0; k < oldID_.size(); ++k) { + oldDet_.emplace_back((oldID_[k] / 10000) % 10); + oldEta_.emplace_back((oldID_[k] / 100) % 100); + oldDepth_.emplace_back(oldID_[k] % 100); + } + l1GtUtils_ = new l1t::L1TGlobalUtil(iConfig, consumesCollector(), *this, algTag, extTag, l1t::UseEventSetupIn::Event); + // define tokens for access + tok_trigEvt_ = consumes(triggerEvent_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_bs_ = consumes(labelBS); + tok_genTrack_ = consumes(labelGenTrack_); + tok_ew_ = consumes(edm::InputTag("generator")); + tok_parts_ = consumes(edm::InputTag("genParticles")); + tok_cala_ = consumes(labelTower_); + tok_alg_ = consumes >(algTag); + tok_Muon_ = consumes(labelMuon); + tok_recVtx_ = consumes(labelRecVtx_); + tok_EB_ = consumes(edm::InputTag("ecalRecHit", labelEB_)); + tok_EE_ = consumes(edm::InputTag("ecalRecHit", labelEE_)); + tok_hbhe_ = consumes(labelHBHE_); + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " " + << labelBS << " " << labelRecVtx_ << " " << labelGenTrack_ << " " + << edm::InputTag("ecalRecHit", labelEB_) << " " + << edm::InputTag("ecalRecHit", labelEE_) << " " << labelHBHE_ << " " << labelTower_ + << " " << labelMuon; + + tok_ddrec_ = esConsumes(); + tok_bFieldH_ = esConsumes(); + tok_ecalChStatus_ = esConsumes(); + tok_sevlv_ = esConsumes(); + tok_geom_ = esConsumes(); + tok_caloTopology_ = esConsumes(); + tok_htopo_ = esConsumes(); + tok_resp_ = esConsumes(); + + edm::LogVerbatim("HcalIsoTrack") << "Parameters read from config file \n" + << "\t minPt " << selectionParameter_.minPt << "\t theTrackQuality " + << theTrackQuality_ << "\t minQuality " << selectionParameter_.minQuality + << "\t maxDxyPV " << selectionParameter_.maxDxyPV << "\t maxDzPV " + << selectionParameter_.maxDzPV << "\t maxChi2 " << selectionParameter_.maxChi2 + << "\t maxDpOverP " << selectionParameter_.maxDpOverP << "\t minOuterHit " + << selectionParameter_.minOuterHit << "\t minLayerCrossed " + << selectionParameter_.minLayerCrossed << "\t maxInMiss " + << selectionParameter_.maxInMiss << "\t maxOutMiss " + << selectionParameter_.maxOutMiss << "\t a_coneR " << a_coneR_ << ":" << a_coneR1_ + << ":" << a_coneR2_ << "\t a_charIsoR " << a_charIsoR_ << "\t a_mipR " << a_mipR_ + << "\t a_mipR2 " << a_mipR2_ << "\t a_mipR3 " << a_mipR3_ << "\t a_mipR4 " + << a_mipR4_ << "\t a_mipR5 " << a_mipR5_ << "\n pTrackMin_ " << pTrackMin_ + << "\t eEcalMax_ " << eEcalMax_ << "\t maxRestrictionP_ " << maxRestrictionP_ + << "\t slopeRestrictionP_ " << slopeRestrictionP_ << "\t eIsolateStrong_ " + << eIsolate1_ << "\t eIsolateSoft_ " << eIsolate2_ << "\t hcalScale_ " << hcalScale_ + << "\n\t momentumLow_ " << pTrackLow_ << "\t momentumHigh_ " << pTrackHigh_ + << "\n\t ignoreTrigger_ " << ignoreTrigger_ << "\n\t useL1Trigger_ " << useL1Trigger_ + << "\t unCorrect_ " << unCorrect_ << "\t collapseDepth_ " << collapseDepth_ + << "\t L1TrigName_ " << l1TrigName_ << "\nThreshold for EB " << hitEthrEB_ + << " EE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":" << hitEthrEE2_ << ":" + << hitEthrEE3_ << ":" << hitEthrEELo_ << ":" << hitEthrEEHi_; + edm::LogVerbatim("HcalIsoTrack") << "Process " << processName_ << " L1Filter:" << l1Filter_ + << " L2Filter:" << l2Filter_ << " L3Filter:" << l3Filter_; + for (unsigned int k = 0; k < trigNames_.size(); ++k) { + edm::LogVerbatim("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k]; + } + edm::LogVerbatim("HcalIsoTrack") << oldID_.size() << " DetIDs to be corrected with HEP17 flag:" << hep17_; + for (unsigned int k = 0; k < oldID_.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "[" << k << "] Det " << oldDet_[k] << " EtaAbs " << oldEta_[k] << " Depth " + << oldDepth_[k] << ":" << newDepth_[k]; + + for (int i = 0; i < 10; i++) + phibins_.push_back(-M_PI + 0.1 * (2 * i + 1) * M_PI); + for (int i = 0; i < 8; ++i) + etabins_.push_back(-2.1 + 0.6 * i); + etadist_ = etabins_[1] - etabins_[0]; + phidist_ = phibins_[1] - phibins_[0]; + etahalfdist_ = 0.5 * etadist_; + phihalfdist_ = 0.5 * phidist_; + edm::LogVerbatim("HcalIsoTrack") << "EtaDist " << etadist_ << " " << etahalfdist_ << " PhiDist " << phidist_ << " " + << phihalfdist_; + //create also IsolatedPixelTrackCandidateCollection which contains isolation info and reference to primary track + produces(labelIsoTkVar_); + produces(labelIsoTkEvtVar_); + edm::LogVerbatim("HcalIsoTrack") << " Expected to produce the collections:\n" + << "HcalIsoTrkCalibVariablesCollection with label " << labelIsoTkVar_ + << "\nand HcalIsoTrkEventVariablesCollection with label " << labelIsoTkEvtVar_; +} + +void AlCaHcalIsotrkProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("processName", "HLT"); + std::vector trig; + desc.add >("triggers", trig); + desc.add("l1Filter", ""); + desc.add("l2Filter", "L2Filter"); + desc.add("l3Filter", "Filter"); + // following 10 parameters are parameters to select good tracks + desc.add("trackQuality", "highPurity"); + desc.add("minTrackPt", 1.0); + desc.add("maxDxyPV", 0.02); + desc.add("maxDzPV", 0.02); + desc.add("maxChi2", 5.0); + desc.add("maxDpOverP", 0.1); + desc.add("minOuterHit", 4); + desc.add("minLayerCrossed", 8); + desc.add("maxInMiss", 0); + desc.add("maxOutMiss", 0); + // Minimum momentum of selected isolated track and signal zone + desc.add("minimumTrackP", 10.0); + desc.add("coneRadius", 34.98); + // signal zone in ECAL and MIP energy cutoff + desc.add("coneRadiusMIP", 14.0); + desc.add("coneRadiusMIP2", 18.0); + desc.add("coneRadiusMIP3", 20.0); + desc.add("coneRadiusMIP4", 22.0); + desc.add("coneRadiusMIP5", 24.0); + desc.add("maximumEcalEnergy", 2.0); + // following 4 parameters are for isolation cuts and described in the code + desc.add("maxTrackP", 8.0); + desc.add("slopeTrackP", 0.05090504066); + desc.add("isolationEnergyTight", 2.0); + desc.add("isolationEnergyLoose", 10.0); + // energy thershold for ECAL (from Egamma group) + desc.add("EBHitEnergyThreshold", 0.08); + desc.add("EEHitEnergyThreshold0", 0.30); + desc.add("EEHitEnergyThreshold1", 0.00); + desc.add("EEHitEnergyThreshold2", 0.00); + desc.add("EEHitEnergyThreshold3", 0.00); + desc.add("EEHitEnergyThresholdLow", 0.30); + desc.add("EEHitEnergyThresholdHigh", 0.30); + // prescale factors + desc.add("momentumLow", 40.0); + desc.add("momentumHigh", 60.0); + desc.add("prescaleLow", 1); + desc.add("prescaleHigh", 1); + // various labels for collections used in the code + desc.add("labelTriggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT")); + desc.add("labelTriggerResult", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("labelTrack", "generalTracks"); + desc.add("labelVertex", "offlinePrimaryVertices"); + desc.add("labelEBRecHit", "EcalRecHitsEB"); + desc.add("labelEERecHit", "EcalRecHitsEE"); + desc.add("labelHBHERecHit", "hbhereco"); + desc.add("labelBeamSpot", "offlineBeamSpot"); + desc.add("labelCaloTower", "towerMaker"); + desc.add("labelMuon", "muons"); + desc.add("algInputTag", edm::InputTag("gtStage2Digis")); + desc.add("extInputTag", edm::InputTag("gtStage2Digis")); + desc.add("isoTrackLabel", "HcalIsoTrack"); + desc.add("isoTrackEventLabel", "HcalIsoTrackEvent"); + // Various flags used for selecting tracks, choice of energy Method2/0 + // Data type 0/1 for single jet trigger or others + desc.addUntracked("ignoreTriggers", false); + desc.addUntracked("useL1Trigger", false); + desc.addUntracked("hcalScale", 1.0); + desc.addUntracked("unCorrect", false); + desc.addUntracked("collapseDepth", false); + desc.addUntracked("l1TrigName", "L1_SingleJet60"); + std::vector dummy; + desc.addUntracked >("oldID", dummy); + desc.addUntracked >("newDepth", dummy); + desc.addUntracked("hep17", false); + descriptions.add("alcaHcalIsotrkProducer", desc); +} + +void AlCaHcalIsotrkProducer::produce(edm::Event& iEvent, edm::EventSetup const& iSetup) { + nAll_++; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); +#endif + + HcalIsoTrkEventVariables isoTrkEvent; + //Step1: Get all the relevant containers + const MagneticField* bField = &iSetup.getData(tok_bFieldH_); + const EcalChannelStatus* theEcalChStatus = &iSetup.getData(tok_ecalChStatus_); + const EcalSeverityLevelAlgo* theEcalSevlv = &iSetup.getData(tok_sevlv_); + + // get handles to calogeometry and calotopology + const CaloGeometry* geo = &iSetup.getData(tok_geom_); + const CaloTopology* caloTopology = &iSetup.getData(tok_caloTopology_); + const HcalTopology* theHBHETopology = &iSetup.getData(tok_htopo_); + const HcalRespCorrs* respCorrs = &iSetup.getData(tok_resp_); + bool okC(true); + //Get track collection + auto trkCollection = iEvent.getHandle(tok_genTrack_); + if (!trkCollection.isValid()) { + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_; + okC = false; + } + + //Get muon collection + auto const& muonh = iEvent.getHandle(tok_Muon_); + + //Define the best vertex and the beamspot + auto const& recVtxs = iEvent.getHandle(tok_recVtx_); + auto const& beamSpotH = iEvent.getHandle(tok_bs_); + math::XYZPoint leadPV(0, 0, 0); + int goodPV(0); + if (recVtxs.isValid() && !(recVtxs->empty())) { + isoTrkEvent.allvertex_ = recVtxs->size(); + for (unsigned int k = 0; k < recVtxs->size(); ++k) { + if (!((*recVtxs)[k].isFake()) && ((*recVtxs)[k].ndof() > 4)) { + if (goodPV == 0) + leadPV = math::XYZPoint((*recVtxs)[k].x(), (*recVtxs)[k].y(), (*recVtxs)[k].z()); + goodPV++; + } + } + } + if (goodPV == 0 && beamSpotH.isValid()) { + leadPV = beamSpotH->position(); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " << goodPV << " vertex"; + if (beamSpotH.isValid()) { + edm::LogVerbatim("HcalIsoTrack") << " Beam Spot " << beamSpotH->position(); + } +#endif + + // RecHits + auto barrelRecHitsHandle = iEvent.getHandle(tok_EB_); + if (!barrelRecHitsHandle.isValid()) { + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_; + okC = false; + } + auto endcapRecHitsHandle = iEvent.getHandle(tok_EE_); + if (!endcapRecHitsHandle.isValid()) { + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_; + okC = false; + } + auto hbhe = iEvent.getHandle(tok_hbhe_); + if (!hbhe.isValid()) { + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_; + okC = false; + } + auto caloTower = iEvent.getHandle(tok_cala_); + + //=== genParticle information + auto const& genParticles = iEvent.getHandle(tok_parts_); + auto const& genEventInfo = iEvent.getHandle(tok_ew_); + double eventWeight = (genEventInfo.isValid()) ? genEventInfo->weight() : 1.0; + + //Propagate tracks to calorimeter surface) + std::vector trkCaloDirections; + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false); + std::vector trkCaloDets; + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDets, false); + std::vector vecL1, vecL3; + isoTrkEvent.tracks_ = trkCollection->size(); + isoTrkEvent.tracksProp_ = trkCaloDirections.size(); + isoTrkEvent.hltbits_.assign(trigNames_.size(), false); + + if (!ignoreTrigger_) { + //L1 + l1GtUtils_->retrieveL1(iEvent, iSetup, tok_alg_); + const std::vector >& finalDecisions = l1GtUtils_->decisionsFinal(); + for (const auto& decision : finalDecisions) { + if (decision.first.find(l1TrigName_) != std::string::npos) { + isoTrkEvent.l1Bit_ = decision.second; + break; + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ << " is " << isoTrkEvent.l1Bit_ + << " from a list of " << finalDecisions.size() << " decisions"; +#endif + + //HLT + auto const& triggerResults = iEvent.getHandle(tok_trigRes_); + if (triggerResults.isValid()) { + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); + if (!trigNames_.empty()) { + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (names[iHLT].find(trigNames_[i]) != std::string::npos) { + isoTrkEvent.hltbits_[i] = (hlt > 0); + if (hlt > 0) + isoTrkEvent.trigPass_ = true; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") + << "This trigger " << names[iHLT] << " Flag " << hlt << ":" << isoTrkEvent.hltbits_[i]; +#endif + } + } + } + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << isoTrkEvent.trigPass_ << ":" << trigNames_.empty() + << ":" << okC; +#endif + } + + auto outputHcalIsoTrackColl = std::make_unique(); + std::array ntksave{{0, 0, 0}}; + if (ignoreTrigger_ || useL1Trigger_) { + if (ignoreTrigger_ || isoTrkEvent.l1Bit_) + ntksave = getProducts(goodPV, + eventWeight, + vecL1, + vecL3, + leadPV, + trkCaloDirections, + trkCaloDets, + geo, + caloTopology, + theHBHETopology, + theEcalChStatus, + theEcalSevlv, + barrelRecHitsHandle, + endcapRecHitsHandle, + hbhe, + caloTower, + genParticles, + respCorrs, + muonh, + *outputHcalIsoTrackColl, + isoTrkEvent); + isoTrkEvent.tracksSaved_ = ntksave[0]; + isoTrkEvent.tracksLoose_ = ntksave[1]; + isoTrkEvent.tracksTight_ = ntksave[2]; + } else { + trigger::TriggerEvent triggerEvent; + auto const& triggerEventHandle = iEvent.getHandle(tok_trigEvt_); + if (!triggerEventHandle.isValid()) { + edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " << triggerEvent_.label(); + } else if (okC) { + triggerEvent = *(triggerEventHandle.product()); + const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects()); + bool done(false); + auto const& triggerResults = iEvent.getHandle(tok_trigRes_); + if (triggerResults.isValid()) { + std::vector modules; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + bool ok = (isoTrkEvent.trigPass_) || (trigNames_.empty()); + if (ok) { + unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]); + const std::vector& moduleLabels(hltConfig_.moduleLabels(triggerindx)); + std::vector vecL2; + vecL1.clear(); + vecL3.clear(); + //loop over all trigger filters in event (i.e. filters passed) + for (unsigned int ifilter = 0; ifilter < triggerEvent.sizeFilters(); ++ifilter) { + std::vector Keys; + std::string label = triggerEvent.filterTag(ifilter).label(); + //loop over keys to objects passing this filter + for (unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) { + if (label.find(moduleLabels[imodule]) != std::string::npos) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label; +#endif + for (unsigned int ifiltrKey = 0; ifiltrKey < triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) { + Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]); + const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]); + math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy()); + if (label.find(l2Filter_) != std::string::npos) { + vecL2.push_back(v4); + } else if (label.find(l3Filter_) != std::string::npos) { + vecL3.push_back(v4); + } else if ((label.find(l1Filter_) != std::string::npos) || (l1Filter_.empty())) { + vecL1.push_back(v4); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") + << "key " << ifiltrKey << " : pt " << TO.pt() << " eta " << TO.eta() << " phi " << TO.phi() + << " mass " << TO.mass() << " Id " << TO.id(); +#endif + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") + << "sizes " << vecL1.size() << ":" << vecL2.size() << ":" << vecL3.size(); +#endif + } + } + } + + // Now Make the products for all selected tracks + if (!done) { + ntksave = getProducts(goodPV, + eventWeight, + vecL1, + vecL3, + leadPV, + trkCaloDirections, + trkCaloDets, + geo, + caloTopology, + theHBHETopology, + theEcalChStatus, + theEcalSevlv, + barrelRecHitsHandle, + endcapRecHitsHandle, + hbhe, + caloTower, + genParticles, + respCorrs, + muonh, + *outputHcalIsoTrackColl, + isoTrkEvent); + isoTrkEvent.tracksSaved_ += ntksave[0]; + isoTrkEvent.tracksLoose_ += ntksave[1]; + isoTrkEvent.tracksTight_ += ntksave[2]; + done = true; + } + } + } + } + } + } + isoTrkEvent.trigPassSel_ = (isoTrkEvent.tracksSaved_ > 0); + if (isoTrkEvent.trigPassSel_) { + ++nGood_; + for (auto itr = outputHcalIsoTrackColl->begin(); itr != outputHcalIsoTrackColl->end(); ++itr) { + if (itr->p_ > pTrackLow_ && itr->p_ < pTrackHigh_) + ++nRange_; + } + } + + auto outputEventcol = std::make_unique(); + outputEventcol->emplace_back(isoTrkEvent); + iEvent.put(std::move(outputEventcol), labelIsoTkEvtVar_); + iEvent.put(std::move(outputHcalIsoTrackColl), labelIsoTkVar_); +} + +void AlCaHcalIsotrkProducer::endStream() { + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; + globalCache()->nRange_ += nRange_; +} + +void AlCaHcalIsotrkProducer::globalEndJob(const alcaHcalIsoTracks::Counters* count) { + edm::LogVerbatim("HcalIsoTrack") << "Finds " << count->nGood_ << " good tracks in " << count->nAll_ << " events and " + << count->nRange_ << " events in the momentum range"; +} + +void AlCaHcalIsotrkProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { + hdc_ = &iSetup.getData(tok_ddrec_); + if (!ignoreTrigger_) { + bool changed(false); + edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " + << hltConfig_.init(iRun, iSetup, processName_, changed); + } +} + +void AlCaHcalIsotrkProducer::endRun(edm::Run const& iRun, edm::EventSetup const&) { + edm::LogVerbatim("HcalIsoTrack") << "endRun [" << nRun_ << "] " << iRun.run(); + ++nRun_; +} + +std::array AlCaHcalIsotrkProducer::getProducts(int goodPV, + double eventWeight, + std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* caloTopology, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& tower, + const edm::Handle& genParticles, + const HcalRespCorrs* respCorrs, + const edm::Handle& muonh, + std::vector& hocalib, + HcalIsoTrkEventVariables& hocalibEvent) { + int nSave(0), nLoose(0), nTight(0); + unsigned int nTracks(0), nselTracks(0); + double rhohEV = (tower.isValid()) ? rhoh(tower) : 0; + + //Loop over tracks + std::vector::const_iterator trkDetItr; + for (trkDetItr = trkCaloDirections.begin(), nTracks = 0; trkDetItr != trkCaloDirections.end(); + trkDetItr++, nTracks++) { + const reco::Track* pTrack = &(*(trkDetItr->trkItr)); + math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p()); + bool accept(false); + HcalIsoTrkCalibVariables isoTk; + isoTk.eventWeight_ = eventWeight; + isoTk.goodPV_ = goodPV; + isoTk.nVtx_ = hocalibEvent.allvertex_; + isoTk.nTrk_ = trkCaloDirections.size(); + isoTk.rhoh_ = rhohEV; + for (const auto& trig : hocalibEvent.hltbits_) + isoTk.trgbits_.emplace_back(trig); + if (!vecL1.empty()) { + isoTk.l1pt_ = vecL1[0].pt(); + isoTk.l1eta_ = vecL1[0].eta(); + isoTk.l1phi_ = vecL1[0].phi(); + } + if (!vecL3.empty()) { + isoTk.l3pt_ = vecL3[0].pt(); + isoTk.l3eta_ = vecL3[0].eta(); + isoTk.l3phi_ = vecL3[0].phi(); + } + + isoTk.p_ = pTrack->p(); + isoTk.pt_ = pTrack->pt(); + isoTk.phi_ = pTrack->phi(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << isoTk.pt_ << "|" + << pTrack->eta() << "|" << isoTk.phi_ << "|" << isoTk.p_; + int flag(0); +#endif + isoTk.mindR2_ = 999; + for (unsigned int k = 0; k < vecL3.size(); ++k) { + double dr = dR(vecL3[k], v4); + if (dr < isoTk.mindR2_) { + isoTk.mindR2_ = dr; + } + } + isoTk.mindR1_ = (!vecL1.empty()) ? dR(vecL1[0], v4) : 999; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Closest L3 object at dr :" << isoTk.mindR2_ << " and from L1 " + << isoTk.mindR1_; +#endif + isoTk.ieta_ = isoTk.iphi_ = 0; + if (trkDetItr->okHCAL) { + HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); + isoTk.ieta_ = detId.ieta(); + isoTk.iphi_ = detId.iphi(); + if (isoTk.p_ > 40.0 && isoTk.p_ <= 60.0) + hocalibEvent.ietaAll_.emplace_back(isoTk.ieta_); + } + //Selection of good track + isoTk.selectTk_ = spr::goodTrack(pTrack, leadPV, selectionParameter_, false); + spr::trackSelectionParameters oneCutParameters = selectionParameter_; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; + oneCutParameters.maxInMiss = 2; + oneCutParameters.maxOutMiss = 2; + bool qltyFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; + isoTk.qltyMissFlag_ = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; + oneCutParameters.maxInMiss = 2; + oneCutParameters.maxOutMiss = 2; + isoTk.qltyPVFlag_ = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + double eIsolation = maxRestrictionP_ * exp(slopeRestrictionP_ * std::abs((double)isoTk.ieta_)); + if (eIsolation < eIsolate1_) + eIsolation = eIsolate1_; + if (eIsolation < eIsolate2_) + eIsolation = eIsolate2_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr->okECAL << "|" + << trkDetItr->okHCAL << " eIsolation " << eIsolation; + if (qltyFlag) + flag += 1; + if (trkDetItr->okECAL) + flag += 2; + if (trkDetItr->okHCAL) + flag += 4; +#endif + isoTk.qltyFlag_ = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL); + bool notMuon = (muonh.isValid()) ? notaMuon(pTrack, muonh) : true; +#ifdef EDM_ML_DEBUG + if (notMuon) + flag += 8; +#endif + if (isoTk.qltyFlag_ && notMuon) { + nselTracks++; + int nNearTRKs(0); + ////////////////////////////////-MIP STUFF-////////////////////////////// + std::vector eIds; + std::vector eHit; +#ifdef EDM_ML_DEBUG + double eMipDR = +#endif + spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR_, + trkDetItr->directionECAL, + eIds, + eHit); + double eEcal(0); + for (unsigned int k = 0; k < eIds.size(); ++k) { + if (eHit[k] > eThreshold(eIds[k], geo)) + eEcal += eHit[k]; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << eMipDR << ":" << eEcal; +#endif + isoTk.eMipDR_.emplace_back(eEcal); + ////////////////////////////////-MIP STUFF-/////////////////////////////// + ////////////////////////////////-MIP STUFF-2////////////////////////////// + std::vector eIds2; + std::vector eHit2; +#ifdef EDM_ML_DEBUG + double eMipDR2 = +#endif + spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR2_, + trkDetItr->directionECAL, + eIds2, + eHit2); + double eEcal2(0); + for (unsigned int k = 0; k < eIds2.size(); ++k) { + if (eHit2[k] > eThreshold(eIds2[k], geo)) + eEcal2 += eHit2[k]; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << eMipDR2 << ":" << eEcal2; +#endif + isoTk.eMipDR_.emplace_back(eEcal2); + ////////////////////////////////-MIP STUFF-2///////////////////////////// + ////////////////////////////////-MIP STUFF-3///////////////////////////// + std::vector eIds3; + std::vector eHit3; +#ifdef EDM_ML_DEBUG + double eMipDR3 = +#endif + spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR3_, + trkDetItr->directionECAL, + eIds3, + eHit3); + double eEcal3(0); + for (unsigned int k = 0; k < eIds3.size(); ++k) { + if (eHit3[k] > eThreshold(eIds3[k], geo)) + eEcal3 += eHit3[k]; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << eMipDR3 << ":" << eEcal3; +#endif + isoTk.eMipDR_.emplace_back(eEcal3); + ////////////////////////////////-MIP STUFF-3///////////////////////////// + ////////////////////////////////-MIP STUFF-4///////////////////////////// + std::vector eIds4; + std::vector eHit4; +#ifdef EDM_ML_DEBUG + double eMipDR4 = +#endif + spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR4_, + trkDetItr->directionECAL, + eIds4, + eHit4); + double eEcal4(0); + for (unsigned int k = 0; k < eIds4.size(); ++k) { + if (eHit4[k] > eThreshold(eIds4[k], geo)) + eEcal4 += eHit4[k]; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << eMipDR4 << ":" << eEcal4; +#endif + isoTk.eMipDR_.emplace_back(eEcal4); + ////////////////////////////////-MIP STUFF-4///////////////////////////// + ////////////////////////////////-MIP STUFF-5///////////////////////////// + std::vector eIds5; + std::vector eHit5; +#ifdef EDM_ML_DEBUG + double eMipDR5 = +#endif + spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR5_, + trkDetItr->directionECAL, + eIds5, + eHit5); + double eEcal5(0); + for (unsigned int k = 0; k < eIds5.size(); ++k) { + if (eHit5[k] > eThreshold(eIds5[k], geo)) + eEcal5 += eHit5[k]; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << eMipDR5 << ":" << eEcal5; +#endif + isoTk.eMipDR_.emplace_back(eEcal5); + ////////////////////////////////-MIP STUFF-5///////////////////////////// + + isoTk.emaxNearP_ = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 15, 15); + const DetId cellE(trkDetItr->detIdECAL); + std::pair e11x11P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 5, + 5, + -100.0, + -100.0, + -100.0, + 100.0); + std::pair e15x15P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 7, + 7, + -100.0, + -100.0, + -100.0, + 100.0); + if (e11x11P.second && e15x15P.second) { + isoTk.eAnnular_ = (e15x15P.first - e11x11P.first); + } else { + isoTk.eAnnular_ = -(e15x15P.first - e11x11P.first); + } + isoTk.hmaxNearP_ = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false); + const DetId cellH(trkDetItr->detIdHCAL); + double h5x5 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); + double h7x7 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); + isoTk.hAnnular_ = h7x7 - h5x5; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << isoTk.emaxNearP_ << " (Hcal) " << isoTk.hmaxNearP_ + << " Annular E (Ecal) " << e11x11P.first << ":" << e15x15P.first << ":" + << isoTk.eAnnular_ << " (Hcal) " << h5x5 << ":" << h7x7 << ":" + << isoTk.hAnnular_; + if (isoTk.eMipDR_[0] < eEcalMax_) + flag += 16; + if (isoTk.hmaxNearP_ < eIsolation) + flag += 32; +#endif + isoTk.gentrackP_ = trackP(pTrack, genParticles); + if (isoTk.eMipDR_[0] < eEcalMax_ && isoTk.hmaxNearP_ < eIsolation) { + int nRecHits(-999), nRecHits1(-999), nRecHits3(-999); + std::vector ids, ids1, ids3; + std::vector edet0, edet1, edet3; + isoTk.eHcal_ = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR_, + trkDetItr->directionHCAL, + nRecHits, + ids, + edet0, + 0); + if (!oldID_.empty()) { + for (unsigned k = 0; k < ids.size(); ++k) + ids[k] = newId(ids[k]); + } + storeEnergy(respCorrs, ids, edet0, isoTk.eHcal_, isoTk.detIds_, isoTk.hitEnergies_); + std::pair ehcal0 = + storeEnergy(respCorrs, hbhe, ids, isoTk.hitEnergiesRaw_, isoTk.hitEnergiesAux_); + isoTk.eHcalRaw_ = ehcal0.first; + isoTk.eHcalAux_ = ehcal0.second; + + //----- hcal energy in the extended cone 1 (a_coneR+10) -------------- + isoTk.eHcal10_ = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR1_, + trkDetItr->directionHCAL, + nRecHits1, + ids1, + edet1, + 0); + if (!oldID_.empty()) { + for (unsigned k = 0; k < ids1.size(); ++k) + ids1[k] = newId(ids1[k]); + } + storeEnergy(respCorrs, ids1, edet1, isoTk.eHcal10_, isoTk.detIds1_, isoTk.hitEnergies1_); + std::pair ehcal1 = + storeEnergy(respCorrs, hbhe, ids1, isoTk.hitEnergies1Raw_, isoTk.hitEnergies1Aux_); + isoTk.eHcal10Raw_ = ehcal1.first; + isoTk.eHcal10Aux_ = ehcal1.second; + + //----- hcal energy in the extended cone 3 (a_coneR+30) -------------- + isoTk.eHcal30_ = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR2_, + trkDetItr->directionHCAL, + nRecHits3, + ids3, + edet3, + 0); + if (!oldID_.empty()) { + for (unsigned k = 0; k < ids3.size(); ++k) + ids3[k] = newId(ids3[k]); + } + storeEnergy(respCorrs, ids3, edet3, isoTk.eHcal30_, isoTk.detIds3_, isoTk.hitEnergies3_); + std::pair ehcal3 = + storeEnergy(respCorrs, hbhe, ids3, isoTk.hitEnergies3Raw_, isoTk.hitEnergies3Aux_); + isoTk.eHcal30Raw_ = ehcal3.first; + isoTk.eHcal30Aux_ = ehcal3.second; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << isoTk.pt_ << "|" + << pTrack->eta() << "|" << isoTk.phi_ << "|" << isoTk.p_ + << " Generator Level p " << isoTk.gentrackP_; + edm::LogVerbatim("HcalIsoTrack") << "e_MIP " << isoTk.eMipDR_[0] << " Chg Isolation " << isoTk.hmaxNearP_ + << " eHcal" << isoTk.eHcal_ << ":" << isoTk.eHcalRaw_ << ":" << isoTk.eHcalAux_ + << " ieta " << isoTk.ieta_ << " Quality " << isoTk.qltyMissFlag_ << ":" + << isoTk.qltyPVFlag_ << ":" << isoTk.selectTk_; + for (unsigned int ll = 0; ll < isoTk.detIds_.size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << HcalDetId(isoTk.detIds_[ll]) << " hit enery is = " << isoTk.hitEnergies_[ll] + << " : " << isoTk.hitEnergiesRaw_[ll] << " : " << isoTk.hitEnergiesAux_[ll]; + } + for (unsigned int ll = 0; ll < isoTk.detIds1_.size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << HcalDetId(isoTk.detIds1_[ll]) << " hit enery is = " << isoTk.hitEnergies1_[ll] + << " : " << isoTk.hitEnergies1Raw_[ll] << " : " << isoTk.hitEnergies1Aux_[ll]; + ; + } + for (unsigned int ll = 0; ll < isoTk.detIds3_.size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << HcalDetId(isoTk.detIds3_[ll]) << " hit enery is = " << isoTk.hitEnergies3_[ll] + << " : " << isoTk.hitEnergies3Raw_[ll] << " : " << isoTk.hitEnergies3Aux_[ll]; + ; + } + if (isoTk.p_ > pTrackMin_) + flag += 64; +#endif + if (isoTk.p_ > pTrackMin_) + accept = true; + if (accept) { + hocalib.emplace_back(isoTk); + nSave++; + int type(0); + if (isoTk.eMipDR_[0] < 1.0) { + if (isoTk.hmaxNearP_ < eIsolate2_) { + ++nLoose; + type = 1; + } + if (isoTk.hmaxNearP_ < eIsolate1_) { + ++nTight; + type = 2; + } + } + if (isoTk.p_ > 40.0 && isoTk.p_ <= 60.0 && isoTk.selectTk_) { + hocalibEvent.ietaGood_.emplace_back(isoTk.ieta_); + hocalibEvent.trackType_.emplace_back(type); + } +#ifdef EDM_ML_DEBUG + for (unsigned int k = 0; k < isoTk.trgbits_.size(); k++) { + edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " << isoTk.trgbits_[k]; + } +#endif + } + } + } +#ifdef EDM_ML_DEBUG + if (isoTk.eMipDR_.empty()) + edm::LogVerbatim("HcalIsoTrack") << "Track " << nTracks << " Selection Flag " << std::hex << flag << std::dec + << " Accept " << accept << " Momentum " << isoTk.p_ << ":" << pTrackMin_; + else + edm::LogVerbatim("HcalIsoTrack") << "Track " << nTracks << " Selection Flag " << std::hex << flag << std::dec + << " Accept " << accept << " Momentum " << isoTk.p_ << ":" << pTrackMin_ + << " Ecal Energy " << isoTk.eMipDR_[0] << ":" << eEcalMax_ + << " Charge Isolation " << isoTk.hmaxNearP_ << ":" << eIsolation; +#endif + } + std::array i3{{nSave, nLoose, nTight}}; + return i3; +} + +double AlCaHcalIsotrkProducer::dR(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) { + return reco::deltaR(vec1.eta(), vec1.phi(), vec2.eta(), vec2.phi()); +} + +double AlCaHcalIsotrkProducer::trackP(const reco::Track* pTrack, + const edm::Handle& genParticles) { + double pmom = -1.0; + if (genParticles.isValid()) { + double mindR(999.9); + for (const auto& p : (*genParticles)) { + double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), p.momentum().Eta(), p.momentum().Phi()); + if (dR < mindR) { + mindR = dR; + pmom = p.momentum().R(); + } + } + } + return pmom; +} + +double AlCaHcalIsotrkProducer::rhoh(const edm::Handle& tower) { + std::vector sumPFNallSMDQH2; + sumPFNallSMDQH2.reserve(phibins_.size() * etabins_.size()); + for (auto eta : etabins_) { + for (auto phi : phibins_) { + double hadder = 0; + for (const auto& pf_it : (*tower)) { + if (fabs(eta - pf_it.eta()) > etahalfdist_) + continue; + if (fabs(reco::deltaPhi(phi, pf_it.phi())) > phihalfdist_) + continue; + hadder += pf_it.hadEt(); + } + sumPFNallSMDQH2.emplace_back(hadder); + } + } + + double evt_smdq(0); + std::sort(sumPFNallSMDQH2.begin(), sumPFNallSMDQH2.end()); + if (sumPFNallSMDQH2.size() % 2) + evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 1) / 2]; + else + evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size() / 2] + sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 2) / 2]) / 2.; + double rhoh = evt_smdq / (etadist_ * phidist_); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Rho " << evt_smdq << ":" << rhoh; +#endif + return rhoh; +} + +double AlCaHcalIsotrkProducer::eThreshold(const DetId& id, const CaloGeometry* geo) const { + const GlobalPoint& pos = geo->getPosition(id); + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (id.subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + return eThr; +} + +DetId AlCaHcalIsotrkProducer::newId(const DetId& id) { + HcalDetId hid(id); + if (hep17_ && ((hid.iphi() < 63) || (hid.iphi() > 66) || (hid.zside() < 0))) + return id; + for (unsigned int k = 0; k < oldID_.size(); ++k) { + if ((hid.subdetId() == oldDet_[k]) && (hid.ietaAbs() == oldEta_[k]) && (hid.depth() == oldDepth_[k])) { + return static_cast(HcalDetId(hid.subdet(), hid.ieta(), hid.iphi(), newDepth_[k])); + } + } + return id; +} + +void AlCaHcalIsotrkProducer::storeEnergy(const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector& detIds, + std::vector& hitEnergies) { + double ehcal(0); + if (unCorrect_) { + for (unsigned int k = 0; k < ids.size(); ++k) { + double corr = (respCorrs->getValues(ids[k]))->getValue(); + if (corr != 0) + edet[k] /= corr; + ehcal += edet[k]; + } + } else { + for (const auto& en : edet) + ehcal += en; + } + if ((std::abs(ehcal - eHcal) > 0.001) && (!unCorrect_)) + edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << eHcal << ":" << ehcal << " from " + << ids.size() << " cells"; + eHcal = hcalScale_ * ehcal; + + if (collapseDepth_) { + std::map hitMap; + for (unsigned int k = 0; k < ids.size(); ++k) { + HcalDetId id = hdc_->mergedDepthDetId(HcalDetId(ids[k])); + auto itr = hitMap.find(id); + if (itr == hitMap.end()) { + hitMap[id] = edet[k]; + } else { + (itr->second) += edet[k]; + } + } + detIds.reserve(hitMap.size()); + hitEnergies.reserve(hitMap.size()); + for (const auto& hit : hitMap) { + detIds.emplace_back(hit.first.rawId()); + hitEnergies.emplace_back(hit.second); + } + } else { + detIds.reserve(ids.size()); + hitEnergies.reserve(ids.size()); + for (unsigned int k = 0; k < ids.size(); ++k) { + detIds.emplace_back(ids[k].rawId()); + hitEnergies.emplace_back(edet[k]); + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "StoreEnergy1::Input to storeEnergy with " << ids.size() << " cells"; + for (unsigned int k = 0; k < ids.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId(ids[k]) << " E " << edet[k]; + edm::LogVerbatim("HcalIsoTrack") << "StoreEnergy1::Output of storeEnergy with " << detIds.size() << " cells and Etot " + << eHcal; + for (unsigned int k = 0; k < detIds.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId(detIds[k]) << " E " << hitEnergies[k]; +#endif +} + +std::pair AlCaHcalIsotrkProducer::storeEnergy(const HcalRespCorrs* respCorrs, + edm::Handle& hbhe, + const std::vector& ids, + std::vector& hitEnergy1, + std::vector& hitEnergy2) { + double ehcal1(0), ehcal2(0); + std::vector edet1, edet2; + for (unsigned int k = 0; k < ids.size(); ++k) { + double e1(0), e2(0); + for (auto itr = hbhe->begin(); itr != hbhe->end(); ++itr) { + if (itr->id() == ids[k]) { + e1 = itr->eraw(); + e2 = itr->eaux(); + break; + } + } + if (e1 < 1.e-10) + e1 = 0; + if (e2 < 1.e-10) + e2 = 0; + edet1.emplace_back(e1); + edet2.emplace_back(e2); + } + if (unCorrect_) { + for (unsigned int k = 0; k < ids.size(); ++k) { + double corr = (respCorrs->getValues(ids[k]))->getValue(); + if (corr != 0) { + edet1[k] /= corr; + edet2[k] /= corr; + } + } + } + for (unsigned int k = 0; k < ids.size(); ++k) { + ehcal1 += edet1[k]; + ehcal2 += edet2[k]; + } + ehcal1 *= hcalScale_; + ehcal2 *= hcalScale_; + + if (collapseDepth_) { + std::map > hitMap; + for (unsigned int k = 0; k < ids.size(); ++k) { + HcalDetId id = hdc_->mergedDepthDetId(HcalDetId(ids[k])); + auto itr = hitMap.find(id); + if (itr == hitMap.end()) { + hitMap[id] = std::make_pair(edet1[k], edet2[k]); + } else { + (itr->second).first += edet1[k]; + (itr->second).second += edet2[k]; + } + } + hitEnergy1.reserve(hitMap.size()); + hitEnergy2.reserve(hitMap.size()); + for (const auto& hit : hitMap) { + hitEnergy1.emplace_back(hit.second.first); + hitEnergy2.emplace_back(hit.second.second); + } + } else { + hitEnergy1.reserve(ids.size()); + hitEnergy2.reserve(ids.size()); + for (unsigned int k = 0; k < ids.size(); ++k) { + hitEnergy1.emplace_back(edet1[k]); + hitEnergy2.emplace_back(edet2[k]); + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "StoreEnergy2::Input to storeEnergy with " << ids.size() << " cells"; + edm::LogVerbatim("HcalIsoTrack") << "StoreEnergy2::Output of storeEnergy with " << hitEnergy1.size() + << " cells and Etot " << ehcal1 << ":" << ehcal2; + for (unsigned int k = 0; k < hitEnergy1.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << hitEnergy1[k] << " : " << hitEnergy2[k]; +#endif + return std::make_pair(ehcal1, ehcal2); +} + +bool AlCaHcalIsotrkProducer::notaMuon(const reco::Track* pTrack0, const edm::Handle& muonh) { + bool flag(true); + for (reco::MuonCollection::const_iterator recMuon = muonh->begin(); recMuon != muonh->end(); ++recMuon) { + if (recMuon->innerTrack().isNonnull()) { + const reco::Track* pTrack = (recMuon->innerTrack()).get(); + bool mediumMuon = (((recMuon->isPFMuon()) && (recMuon->isGlobalMuon() || recMuon->isTrackerMuon())) && + (recMuon->innerTrack()->validFraction() > 0.49)); + if (mediumMuon) { + double chiGlobal = ((recMuon->globalTrack().isNonnull()) ? recMuon->globalTrack()->normalizedChi2() : 999); + bool goodGlob = (recMuon->isGlobalMuon() && chiGlobal < 3 && + recMuon->combinedQuality().chi2LocalPosition < 12 && recMuon->combinedQuality().trkKink < 20); + mediumMuon = muon::segmentCompatibility(*recMuon) > (goodGlob ? 0.303 : 0.451); + } + if (mediumMuon) { + double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), pTrack0->eta(), pTrack0->phi()); + if (dR < 0.1) { + flag = false; + break; + } + } + } + } + return flag; +} + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(AlCaHcalIsotrkProducer); diff --git a/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_Output_cff.py b/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_Output_cff.py new file mode 100644 index 0000000000000..010f3b54e9593 --- /dev/null +++ b/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_Output_cff.py @@ -0,0 +1,20 @@ +import FWCore.ParameterSet.Config as cms + +# output block for alcastream HCAL Isotrk +# output module +# module alcastreamHcalIsotrkOutput = PoolOutputModule +OutALCARECOHcalCalIsoTrkProducerFilter_noDrop = cms.PSet( + # use this in case of filter available + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOHcalCalIsoTrkProducerFilter') + ), + outputCommands = cms.untracked.vstring( + 'keep *_HcalIsoTrack_*_*', + 'keep *_HcalIsoTrackEvent_*_*', + ) +) + + +import copy +OutALCARECOHcalCalIsoTrkProducerFilter=copy.deepcopy(OutALCARECOHcalCalIsoTrkProducerFilter_noDrop) +OutALCARECOHcalCalIsoTrkProducerFilter.outputCommands.insert(0, "drop *") diff --git a/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_cff.py b/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_cff.py new file mode 100644 index 0000000000000..061621a1e4bae --- /dev/null +++ b/Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalIsoTrkProducerFilter_cff.py @@ -0,0 +1,14 @@ +import FWCore.ParameterSet.Config as cms + +#------------------------------------------------ +#AlCaReco filtering for HCAL isotrk: +#------------------------------------------------ + +from Calibration.HcalAlCaRecoProducers.alcaHcalIsotrkProducer_cfi import * +from Calibration.HcalAlCaRecoProducers.alcaHcalIsotrkFilter_cfi import * + +seqALCARECOHcalCalIsoTrkProducerFilter = cms.Sequence(alcaHcalIsotrkProducer * alcaHcalIsotrkFilter) + + + + diff --git a/Calibration/HcalAlCaRecoProducers/test/AlCaHcalIsoTrk_cfg.py b/Calibration/HcalAlCaRecoProducers/test/AlCaHcalIsoTrk_cfg.py new file mode 100644 index 0000000000000..d686d68c0ed12 --- /dev/null +++ b/Calibration/HcalAlCaRecoProducers/test/AlCaHcalIsoTrk_cfg.py @@ -0,0 +1,65 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 +process = cms.Process("ALCAISOTRACK",Run2_2018) + +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load("Configuration.StandardSequences.GeometryRecoDB_cff") +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load('Configuration.StandardSequences.AlCaRecoStreams_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.autoCond import autoCond +process.GlobalTag.globaltag=autoCond['run2_mc'] +process.load("RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi") + +if hasattr(process,'MessageLogger'): + process.MessageLogger.HcalIsoTrack=dict() + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100) +) + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:/afs/cern.ch/user/h/huwang/work/public/for_Sunanda/RECO_data.root', + ) +) + +process.load('RecoLocalCalo.CaloTowersCreator.calotowermaker_cfi') +process.towerMakerAll = process.calotowermaker.clone() +process.towerMakerAll.hbheInput = cms.InputTag("hbhereco") +process.towerMakerAll.hoInput = cms.InputTag("none") +process.towerMakerAll.hfInput = cms.InputTag("none") +process.towerMakerAll.ecalInputs = cms.VInputTag(cms.InputTag("ecalRecHit","EcalRecHitsEB"), cms.InputTag("ecalRecHit","EcalRecHitsEE")) +process.towerMakerAll.AllowMissingInputs = True + +process.ALCARECOStreamHcalCalIsoTrkProducerFilter = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOHcalCalIsoTrkProducerFilter') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('ALCARECO'), + filterName = cms.untracked.string('ALCARECOHcalCalIsoTrkProducerFilter') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + # outputCommands = process.OutALCARECOHcalCalIsoTrkProducerFilter.outputCommands, + outputCommands = cms.untracked.vstring( + 'keep *', + ), + fileName = cms.untracked.string('PoolOutput.root'), + ) + +process.alcaHcalIsotrkProducer.ignoreTriggers = True + +# Path and EndPath definitions +process.endjob_step = cms.EndPath(process.endOfProcess) +process.ALCARECOStreamHcalCalIsoTrkProducerFilterOutPath = cms.EndPath(process.ALCARECOStreamHcalCalIsoTrkProducerFilter) + +# Schedule definition +process.schedule = cms.Schedule(process.pathALCARECOHcalCalIsoTrkProducerFilter,process.endjob_step,process.ALCARECOStreamHcalCalIsoTrkProducerFilterOutPath) diff --git a/Calibration/HcalCalibAlgos/plugins/HcalIsoTrackAnalyzer.cc b/Calibration/HcalCalibAlgos/plugins/HcalIsoTrackAnalyzer.cc new file mode 100644 index 0000000000000..3a8256c648cd3 --- /dev/null +++ b/Calibration/HcalCalibAlgos/plugins/HcalIsoTrackAnalyzer.cc @@ -0,0 +1,297 @@ +// system include files +#include +#include +#include +#include +#include + +// Root objects +#include "TROOT.h" +#include "TSystem.h" +#include "TFile.h" +#include "TProfile.h" +#include "TDirectory.h" +#include "TTree.h" +#include "TLorentzVector.h" +#include "TInterpreter.h" + +#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h" +#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkEventVariables.h" + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +//#define EDM_ML_DEBUG + +class HcalIsoTrackAnalyzer : public edm::one::EDAnalyzer { +public: + explicit HcalIsoTrackAnalyzer(edm::ParameterSet const&); + ~HcalIsoTrackAnalyzer() override {} + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void analyze(edm::Event const&, edm::EventSetup const&) override; + void beginJob() override; + void beginRun(edm::Run const&, edm::EventSetup const&) override {} + void endRun(edm::Run const&, edm::EventSetup const&) override; + + edm::Service fs; + const double pTrackLow_, pTrackHigh_; + const int useRaw_, dataType_; + const edm::InputTag labelIsoTkVar_, labelIsoTkEvt_; + edm::EDGetTokenT tokIsoTrkVar_; + edm::EDGetTokenT tokIsoTrkEvt_; + unsigned int nRun_, nRange_, nLow_, nHigh_; + + TTree *tree, *tree2; + int t_Run, t_Event, t_DataType, t_ieta, t_iphi; + int t_goodPV, t_nVtx, t_nTrk; + double t_EventWeight, t_p, t_pt, t_phi; + double t_l1pt, t_l1eta, t_l1phi; + double t_l3pt, t_l3eta, t_l3phi; + double t_mindR1, t_mindR2; + double t_eMipDR, t_eMipDR2, t_eMipDR3, t_eMipDR4; + double t_eMipDR5, t_hmaxNearP, t_gentrackP; + double t_emaxNearP, t_eAnnular, t_hAnnular; + double t_eHcal, t_eHcal10, t_eHcal30, t_rhoh; + bool t_selectTk, t_qltyFlag, t_qltyMissFlag, t_qltyPVFlag; + std::vector t_DetIds, t_DetIds1, t_DetIds3; + std::vector t_HitEnergies, t_HitEnergies1, t_HitEnergies3; + std::vector t_trgbits; + + unsigned int t_RunNo, t_EventNo; + bool t_TrigPass, t_TrigPassSel, t_L1Bit; + int t_Tracks, t_TracksProp, t_TracksSaved; + int t_TracksLoose, t_TracksTight, t_allvertex; + std::vector t_ietaAll, t_ietaGood, t_trackType; + std::vector t_hltbits; +}; + +HcalIsoTrackAnalyzer::HcalIsoTrackAnalyzer(const edm::ParameterSet& iConfig) + : pTrackLow_(iConfig.getParameter("momentumLow")), + pTrackHigh_(iConfig.getParameter("momentumHigh")), + useRaw_(iConfig.getUntrackedParameter("useRaw", 0)), + dataType_(iConfig.getUntrackedParameter("dataType", 0)), + labelIsoTkVar_(iConfig.getParameter("isoTrackVarLabel")), + labelIsoTkEvt_(iConfig.getParameter("isoTrackEvtLabel")), + tokIsoTrkVar_(consumes(labelIsoTkVar_)), + tokIsoTrkEvt_(consumes(labelIsoTkEvt_)), + nRun_(0), + nRange_(0), + nLow_(0), + nHigh_(0) { + usesResource(TFileService::kSharedResource); + + //now do whatever initialization is needed + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << labelIsoTkVar_ << " " << labelIsoTkEvt_; + + edm::LogVerbatim("HcalIsoTrack") << "Parameters read from config file \n\t momentumLow_ " << pTrackLow_ + << "\t momentumHigh_ " << pTrackHigh_ << "\t useRaw_ " << useRaw_ + << "\t dataType_ " << dataType_; +} + +void HcalIsoTrackAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) { + t_Run = iEvent.id().run(); + t_Event = iEvent.id().event(); + t_DataType = dataType_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Run " << t_Run << " Event " << t_Event << " type " << t_DataType + << " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); +#endif + + // Fill from IsoTrkCalibVariables collection + auto const& isotrkCalibColl = iEvent.getHandle(tokIsoTrkVar_); + if (isotrkCalibColl.isValid()) { + auto isotrkCalib = isotrkCalibColl.product(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Finds HcalIsoTrkCalibVariablesCollection with " << isotrkCalib->size() + << " entries"; +#endif + for (auto itr = isotrkCalib->begin(); itr != isotrkCalib->end(); ++itr) { + t_ieta = itr->ieta_; + t_iphi = itr->iphi_; + t_goodPV = itr->goodPV_; + t_nVtx = itr->nVtx_; + t_nTrk = itr->nTrk_; + t_EventWeight = itr->eventWeight_; + t_p = itr->p_; + t_pt = itr->pt_; + t_phi = itr->phi_; + t_l1pt = itr->l1pt_; + t_l1eta = itr->l1eta_; + t_l1phi = itr->l1phi_; + t_l3pt = itr->l3pt_; + t_l3eta = itr->l3eta_; + t_l3phi = itr->l3phi_; + t_mindR1 = itr->mindR1_; + t_mindR2 = itr->mindR2_; + t_eMipDR = itr->eMipDR_[0]; + t_eMipDR2 = itr->eMipDR_[1]; + t_eMipDR3 = itr->eMipDR_[2]; + t_eMipDR4 = itr->eMipDR_[3]; + t_eMipDR5 = itr->eMipDR_[4]; + t_hmaxNearP = itr->hmaxNearP_; + t_gentrackP = itr->gentrackP_; + t_emaxNearP = itr->emaxNearP_; + t_eAnnular = itr->eAnnular_; + t_hAnnular = itr->hAnnular_; + t_rhoh = itr->rhoh_; + t_selectTk = itr->selectTk_; + t_qltyFlag = itr->qltyFlag_; + t_qltyMissFlag = itr->qltyMissFlag_; + t_qltyPVFlag = itr->qltyPVFlag_; + t_trgbits = itr->trgbits_; + t_eHcal = itr->eHcal_; + t_eHcal10 = itr->eHcal10_; + t_eHcal30 = itr->eHcal30_; + t_DetIds = itr->detIds_; + t_DetIds1 = itr->detIds1_; + t_DetIds3 = itr->detIds3_; + t_HitEnergies = itr->hitEnergies_; + t_HitEnergies1 = itr->hitEnergies1_; + t_HitEnergies3 = itr->hitEnergies3_; + tree->Fill(); + + if (t_p < pTrackLow_) { + ++nLow_; + } else if (t_p < pTrackHigh_) { + ++nHigh_; + } else { + ++nRange_; + } + } + } else { + edm::LogVerbatim("HcalIsoTrack") << "Cannot find HcalIsoTrkCalibVariablesCollection"; + } + + // Fill from IsoTrkEventVariables collection + auto const& isotrkEventColl = iEvent.getHandle(tokIsoTrkEvt_); + if (isotrkEventColl.isValid()) { + auto isotrkEvent = isotrkEventColl.product(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalIsoTrack") << "Finds HcalIsoTrkEventVariablesCollection with " << isotrkEvent->size() + << " entries"; +#endif + auto itr = isotrkEvent->begin(); + if (itr != isotrkEvent->end()) { + t_RunNo = iEvent.id().run(); + t_EventNo = iEvent.id().event(); + t_TrigPass = itr->trigPass_; + t_TrigPassSel = itr->trigPassSel_; + t_L1Bit = itr->l1Bit_; + t_Tracks = itr->tracks_; + t_TracksProp = itr->tracksProp_; + t_TracksSaved = itr->tracksSaved_; + t_TracksLoose = itr->tracksLoose_; + t_TracksTight = itr->tracksTight_; + t_allvertex = itr->allvertex_; + t_ietaAll = itr->ietaAll_; + t_ietaGood = itr->ietaGood_; + t_trackType = itr->trackType_; + t_hltbits = itr->hltbits_; + tree2->Fill(); + } + } else { + edm::LogVerbatim("HcalIsoTrack") << "Cannot find HcalIsoTrkEventVariablesCollections"; + } +} + +void HcalIsoTrackAnalyzer::beginJob() { + tree = fs->make("CalibTree", "CalibTree"); + + tree->Branch("t_Run", &t_Run, "t_Run/I"); + tree->Branch("t_Event", &t_Event, "t_Event/I"); + tree->Branch("t_DataType", &t_DataType, "t_DataType/I"); + tree->Branch("t_ieta", &t_ieta, "t_ieta/I"); + tree->Branch("t_iphi", &t_iphi, "t_iphi/I"); + tree->Branch("t_EventWeight", &t_EventWeight, "t_EventWeight/D"); + tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I"); + tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I"); + tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I"); + tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D"); + tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D"); + tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D"); + tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D"); + tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D"); + tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D"); + tree->Branch("t_p", &t_p, "t_p/D"); + tree->Branch("t_pt", &t_pt, "t_pt/D"); + tree->Branch("t_phi", &t_phi, "t_phi/D"); + tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D"); + tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D"); + tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D"); + tree->Branch("t_eMipDR2", &t_eMipDR2, "t_eMipDR2/D"); + tree->Branch("t_eMipDR3", &t_eMipDR3, "t_eMipDR3/D"); + tree->Branch("t_eMipDR4", &t_eMipDR4, "t_eMipDR4/D"); + tree->Branch("t_eMipDR5", &t_eMipDR5, "t_eMipDR5/D"); + tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D"); + tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D"); + tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D"); + tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D"); + tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D"); + tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D"); + tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D"); + tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D"); + tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O"); + tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O"); + tree->Branch("t_qltyMissFlag", &t_qltyMissFlag, "t_qltyMissFlag/O"); + tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O"); + tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D"); + + tree->Branch("t_DetIds", &t_DetIds); + tree->Branch("t_HitEnergies", &t_HitEnergies); + tree->Branch("t_trgbits", &t_trgbits); + tree->Branch("t_DetIds1", &t_DetIds1); + tree->Branch("t_DetIds3", &t_DetIds3); + tree->Branch("t_HitEnergies1", &t_HitEnergies1); + tree->Branch("t_HitEnergies3", &t_HitEnergies3); + + tree2 = fs->make("EventInfo", "Event Information"); + + tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i"); + tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i"); + tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I"); + tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I"); + tree2->Branch("t_TracksSaved", &t_TracksSaved, "t_TracksSaved/I"); + tree2->Branch("t_TracksLoose", &t_TracksLoose, "t_TracksLoose/I"); + tree2->Branch("t_TracksTight", &t_TracksTight, "t_TracksTight/I"); + tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O"); + tree2->Branch("t_TrigPassSel", &t_TrigPassSel, "t_TrigPassSel/O"); + tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O"); + tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I"); + tree2->Branch("t_ietaAll", &t_ietaAll); + tree2->Branch("t_ietaGood", &t_ietaGood); + tree2->Branch("t_trackType", &t_trackType); + tree2->Branch("t_hltbits", &t_hltbits); +} + +// ------------ method called when starting to processes a run ------------ + +// ------------ method called when ending the processing of a run ------------ +void HcalIsoTrackAnalyzer::endRun(edm::Run const& iRun, edm::EventSetup const&) { + nRun_++; + edm::LogVerbatim("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run() << " with " << nLow_ + << " events with p < " << pTrackLow_ << ", " << nHigh_ << " events with p > " + << pTrackHigh_ << ", and " << nRange_ << " events in the right momentum range"; +} + +void HcalIsoTrackAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("momentumLow", 40.0); + desc.add("momentumHigh", 60.0); + desc.addUntracked("useRaw", 0); + desc.addUntracked("dataType", 0); + desc.add("isoTrackVarLabel", edm::InputTag("alcaHcalIsotrkProducer", "HcalIsoTrack")); + desc.add("isoTrackEvtLabel", edm::InputTag("alcaHcalIsotrkProducer", "HcalIsoTrackEvent")); + descriptions.add("hcalIsoTrackAnalyzer", desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(HcalIsoTrackAnalyzer); diff --git a/Calibration/HcalCalibAlgos/test/python/isoTrackAnalysis_cfg.py b/Calibration/HcalCalibAlgos/test/python/isoTrackAnalysis_cfg.py new file mode 100644 index 0000000000000..19f36ac3d41da --- /dev/null +++ b/Calibration/HcalCalibAlgos/test/python/isoTrackAnalysis_cfg.py @@ -0,0 +1,36 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 +process = cms.Process("ANALYSIS",Run2_2018) + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load('Configuration.StandardSequences.Services_cff') +process.load("Configuration.StandardSequences.GeometryRecoDB_cff") +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag,'auto:run2_data','') + +if 'MessageLogger' in process.__dict__: + process.MessageLogger.HcalIsoTrack=dict() +process.MessageLogger.cerr.FwkReport.reportEvery = 1 +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + +process.load('Calibration.HcalCalibAlgos.hcalIsoTrackAnalyzer_cfi') +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:PoolOutput.root', + ) +) + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +process.TFileService = cms.Service("TFileService", + fileName = cms.string('output.root') +) + +process.hcalIsoTrackAnalyzer.useRaw = 0 # 2 for Raw + +process.p = cms.Path(process.hcalIsoTrackAnalyzer) + diff --git a/CondFormats/SiPixelObjects/src/SiPixelVCal.cc b/CondFormats/SiPixelObjects/src/SiPixelVCal.cc index a40fa5f4985af..da083bd629a84 100644 --- a/CondFormats/SiPixelObjects/src/SiPixelVCal.cc +++ b/CondFormats/SiPixelObjects/src/SiPixelVCal.cc @@ -1,6 +1,8 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelVCal.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include + bool SiPixelVCal::putSlopeAndOffset(const uint32_t& pixid, float& slopeValue, float& offsetValue) { std::map::const_iterator id = m_vcal.find(pixid); if (id != m_vcal.end()) { diff --git a/Configuration/EventContent/python/AlCaRecoOutput_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_cff.py index ce7e83798e11e..35647601956fb 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_cff.py @@ -92,6 +92,7 @@ from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrk_Output_cff import * from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkFilter_Output_cff import * from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkNoHLT_Output_cff import * +from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkProducerFilter_Output_cff import * # HCAL calibration with iterative phi sym from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIterativePhiSym_Output_cff import * # HCAL calibration with min.bias diff --git a/Configuration/Geometry/python/dict2021Geometry.py b/Configuration/Geometry/python/dict2021Geometry.py index 0ea1374d7e778..8ddd9095f0f10 100644 --- a/Configuration/Geometry/python/dict2021Geometry.py +++ b/Configuration/Geometry/python/dict2021Geometry.py @@ -2584,6 +2584,105 @@ ], "reco" :[ + ], + }, + "P7" : { + 2 : [ + 'Geometry/VeryForwardData/data/RP_Box.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_000.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_001.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_002.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_003.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_004.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_005.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_020.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_021.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_022.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_023.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_024.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_025.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_100.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_101.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_102.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_103.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_104.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_105.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_120.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_121.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_122.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_123.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_124.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_125.xml', + 'Geometry/VeryForwardData/data/RP_Hybrid/v2/RP_Hybrid.xml', + 'Geometry/VeryForwardData/data/RP_Materials/v4/RP_Materials.xml', + 'Geometry/VeryForwardData/data/RP_Transformations.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_000.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_001.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_002.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_004.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_005.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_020.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_021.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_024.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_025.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_100.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_101.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_102.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_104.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_105.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_120.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_121.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_124.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_125.xml', + 'Geometry/VeryForwardData/data/RP_Device/v1/RP_Device.xml', + 'Geometry/VeryForwardData/data/RP_Vertical_Device/2021/Simu/v2/RP_Vertical_Device.xml', + 'Geometry/VeryForwardData/data/RP_Horizontal_Device/2021/Simu/v2/RP_Horizontal_Device.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Simu/v3/CTPPS_220_Right_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Simu/v3/CTPPS_220_Left_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Simu/v3/CTPPS_210_Right_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Simu/v3/CTPPS_210_Left_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Simu/v3/CTPPS_Stations_Assembly.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Cuts_Per_Region/Simu/v1/CTPPS_Cuts_Per_Region.xml', + 'Geometry/VeryForwardData/data/RP_Sensitive_Dets.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Transformations.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Parameters.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Station_Parameters.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Horizontal_Pot/v2/CTPPS_Timing_Horizontal_Pot.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern1_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern2_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern2_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment5.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Detector_Assembly/v1/CTPPS_Diamond_Detector_Assembly.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/Simu/v1/CTPPS_Detectors_Assembly_022.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/Simu/v1/CTPPS_Detectors_Assembly_122.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Sensitive_Dets_TimingHits.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/ppstrackerMaterials.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/PPS_Pixel_Sens.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/RP_Dist_Beam_Cent/Simu/v1/RP_Dist_Beam_Cent.xml', + ], + "sim" : [ + + ], + "reco" :[ + ], }, } diff --git a/Configuration/PyReleaseValidation/python/MatrixInjector.py b/Configuration/PyReleaseValidation/python/MatrixInjector.py index 6d8a1223ef32e..0561195d28926 100644 --- a/Configuration/PyReleaseValidation/python/MatrixInjector.py +++ b/Configuration/PyReleaseValidation/python/MatrixInjector.py @@ -65,6 +65,19 @@ def __init__(self,opt,mode='init',options=''): if(opt.batchName): self.batchName = '__'+opt.batchName+'-'+self.batchTime + #################################### + # Checking and setting up GPU attributes + #################################### + # Mendatory + self.RequiresGPU = opt.gpu + self.GPUMemoryMB = opt.GPUMemoryMB + self.CUDACapabilities = opt.CUDACapabilities + self.CUDARuntime = opt.CUDARuntime + # optional + self.GPUName = opt.GPUName + self.CUDADriverVersion = opt.CUDADriverVersion + self.CUDARuntimeVersion = opt.CUDARuntimeVersion + # WMagent url if not self.wmagent: # Overwrite with env variable @@ -180,8 +193,18 @@ def __init__(self,opt,mode='init',options=''): "nowmIO": {}, "Multicore" : opt.nThreads, # this is the per-taskchain Multicore; it's the default assigned to a task if it has no value specified "EventStreams": self.numberOfStreams, - "KeepOutput" : False + "KeepOutput" : False, + "RequiresGPU" : None, + "GPUParams": None + } + self.defaultGPUParams={ + "GPUMemoryMB": self.GPUMemoryMB, + "CUDACapabilities": self.CUDACapabilities, + "CUDARuntime": self.CUDARuntime } + if self.GPUName: self.defaultGPUParams.update({"GPUName": self.GPUName}) + if self.CUDADriverVersion: self.defaultGPUParams.update({"CUDADriverVersion": self.CUDADriverVersion}) + if self.CUDARuntimeVersion: self.defaultGPUParams.update({"CUDARuntimeVersion": self.CUDARuntimeVersion}) self.chainDicts={} @@ -408,6 +431,9 @@ def prepare(self, mReader, directories, mode='init'): if setPrimaryDs: chainDict['nowmTasklist'][-1]['PrimaryDataset']=setPrimaryDs nextHasDSInput=None + if 'GPU' in step and self.RequiresGPU != 'forbidden': + chainDict['nowmTasklist'][-1]['RequiresGPU'] = self.RequiresGPU + chainDict['nowmTasklist'][-1]['GPUParams']=json.dumps(self.defaultGPUParams) else: #not first step and no inputDS chainDict['nowmTasklist'].append(copy.deepcopy(self.defaultTask)) @@ -420,6 +446,9 @@ def prepare(self, mReader, directories, mode='init'): chainDict['nowmTasklist'][-1]['LumisPerJob']=splitForThisWf if step in wmsplit: chainDict['nowmTasklist'][-1]['LumisPerJob']=wmsplit[step] + if 'GPU' in step and self.RequiresGPU != 'forbidden': + chainDict['nowmTasklist'][-1]['RequiresGPU'] = self.RequiresGPU + chainDict['nowmTasklist'][-1]['GPUParams']=json.dumps(self.defaultGPUParams) # change LumisPerJob for Hadronizer steps. if 'Hadronizer' in step: diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index bd2a20d5e2471..961b74b82f4bf 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -415,10 +415,12 @@ def condition(self, fragment, stepList, key, hasHarvest): # - 2021 conditions, TTbar # - 2021 conditions, Z->mumu, class PatatrackWorkflow(UpgradeWorkflow): - def __init__(self, reco, harvest, **kwargs): + def __init__(self, digi = {}, reco = {}, harvest = {}, **kwargs): # adapt the parameters for the UpgradeWorkflow init method super(PatatrackWorkflow, self).__init__( steps = [ + 'Digi', + 'DigiTrigger', 'Reco', 'HARVEST', 'RecoFakeHLT', @@ -428,6 +430,7 @@ def __init__(self, reco, harvest, **kwargs): ], PU = [], **kwargs) + self.__digi = digi self.__reco = reco self.__reco.update({ '--datatier': 'GEN-SIM-RECO,DQMIO', @@ -452,13 +455,18 @@ def condition(self, fragment, stepList, key, hasHarvest): return result def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: + if 'Digi' in step: + stepDict[stepName][k] = merge([self.__digi, stepDict[step][k]]) + elif 'Reco' in step: stepDict[stepName][k] = merge([self.__reco, stepDict[step][k]]) elif 'HARVEST' in step: stepDict[stepName][k] = merge([self.__harvest, stepDict[step][k]]) upgradeWFs['PatatrackPixelOnlyCPU'] = PatatrackWorkflow( + digi = { + # there is no customisation for enabling the Patatrack pixel quadruplets running only on the CPU + }, reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', '--procModifiers': 'pixelNtupletFit' @@ -471,6 +479,9 @@ def setup_(self, step, stepName, stepDict, k, properties): ) upgradeWFs['PatatrackPixelOnlyGPU'] = PatatrackWorkflow( + digi = { + '--procModifiers': 'gpu' + }, reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', '--procModifiers': 'pixelNtupletFit,gpu' @@ -483,6 +494,9 @@ def setup_(self, step, stepName, stepDict, k, properties): ) upgradeWFs['PatatrackPixelOnlyTripletsCPU'] = PatatrackWorkflow( + digi = { + # there is no customisation for enabling the Patatrack pixel triplets running only on the CPU + }, reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', '--procModifiers': 'pixelNtupletFit', @@ -496,6 +510,10 @@ def setup_(self, step, stepName, stepDict, k, properties): ) upgradeWFs['PatatrackPixelOnlyTripletsGPU'] = PatatrackWorkflow( + digi = { + '--procModifiers': 'gpu', + '--customise': 'HLTrigger/Configuration/customizeHLTforPatatrack.enablePatatrackPixelTriplets' + }, reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', '--procModifiers': 'pixelNtupletFit,gpu', @@ -520,6 +538,9 @@ def setup_(self, step, stepName, stepDict, k, properties): ) upgradeWFs['PatatrackECALOnlyGPU'] = PatatrackWorkflow( + digi = { + '--procModifiers': 'gpu' + }, reco = { '-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,VALIDATION:@ecalOnlyValidation,DQM:@ecalOnly', '--procModifiers': 'gpu' @@ -543,6 +564,9 @@ def setup_(self, step, stepName, stepDict, k, properties): ) upgradeWFs['PatatrackHCALOnlyGPU'] = PatatrackWorkflow( + digi = { + '--procModifiers': 'gpu' + }, reco = { '-s': 'RAW2DIGI:RawToDigi_hcalOnly,RECO:reconstruction_hcalOnly,VALIDATION:@hcalOnlyValidation,DQM:@hcalOnly+@hcal2Only', '--procModifiers': 'gpu' diff --git a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py index c3d0723c5e829..bdadf6e63259b 100755 --- a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py +++ b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py @@ -105,208 +105,268 @@ def runSelected(opt): } - import optparse + import argparse usage = 'usage: runTheMatrix.py --show -s ' - parser = optparse.OptionParser(usage) - - parser.add_option('-b','--batchName', - help='relval batch: suffix to be appended to Campaign name', - dest='batchName', - default='' - ) - - parser.add_option('-m','--memoryOffset', - help='memory of the wf for single core', - dest='memoryOffset', - default=3000 - ) - parser.add_option('--addMemPerCore', - help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore', - dest='memPerCore', - default=1500 - ) - parser.add_option('-j','--nproc', - help='number of processes. 0 Will use 4 processes, not execute anything but create the wfs', - dest='nProcs', - default=4 - ) - parser.add_option('-t','--nThreads', - help='number of threads per process to use in cmsRun.', - dest='nThreads', - default=1 - ) - parser.add_option('--nStreams', - help='number of streams to use in cmsRun.', - dest='nStreams', - default=0 - ) - parser.add_option('--numberEventsInLuminosityBlock', - help='number of events in a luminosity block', - dest='numberEventsInLuminosityBlock', - default=-1 - ) - - parser.add_option('-n','--showMatrix', - help='Only show the worflows. Use --ext to show more', - dest='show', - default=False, - action='store_true' - ) - parser.add_option('-e','--extended', - help='Show details of workflows, used with --show', - dest='extended', - default=False, - action='store_true' - ) - parser.add_option('-s','--selected', - help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited', - dest='restricted', - default=False, - action='store_true' - ) - parser.add_option('-l','--list', - help='Coma separated list of workflow to be shown or ran. Possible keys are also '+str(predefinedSet.keys())+'. and wild card like muon, or mc', - dest='testList', - default=None - ) - parser.add_option('-r','--raw', - help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)', - dest='raw' - ) - parser.add_option('-i','--useInput', - help='Use recyling where available. Either all, or a coma separated list of wf number.', - dest='useInput', - default=None - ) - parser.add_option('-w','--what', - help='Specify the set to be used. Argument must be the name of a set (standard, pileup,...) or multiple sets separated by commas (--what standard,pileup )', - dest='what', - default='all' - ) - parser.add_option('--step1', - help='Used with --raw. Limit the production to step1', - dest='step1Only', - default=False - ) - parser.add_option('--maxSteps', - help='Only run maximum on maxSteps. Used when we are only interested in first n steps.', - dest='maxSteps', - default=9999, - type="int" - ) - parser.add_option('--fromScratch', - help='Coma separated list of wf to be run without recycling. all is not supported as default.', - dest='fromScratch', - default=None - ) - parser.add_option('--refRelease', - help='Allow to modify the recycling dataset version', - dest='refRel', - default=None - ) - parser.add_option('--wmcontrol', - help='Create the workflows for injection to WMAgent. In the WORKING. -wmcontrol init will create the the workflows, -wmcontrol test will dryRun a test, -wmcontrol submit will submit to wmagent', - choices=['init','test','submit','force'], - dest='wmcontrol', - default=None, - ) - parser.add_option('--revertDqmio', - help='When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO', - choices=['yes','no'], - dest='revertDqmio', - default='no', - ) - parser.add_option('--optionswm', - help='Specify a few things for wm injection', - default='', - dest='wmoptions') - parser.add_option('--keep', - help='allow to specify for which coma separated steps the output is needed', - default=None) - parser.add_option('--label', - help='allow to give a special label to the output dataset name', - default='') - parser.add_option('--command', - help='provide a way to add additional command to all of the cmsDriver commands in the matrix', - dest='command', - action='append', - default=None - ) - parser.add_option('--apply', - help='allow to use the --command only for 1 coma separeated', - dest='apply', - default=None) - parser.add_option('--workflow', - help='define a workflow to be created or altered from the matrix', - action='append', - dest='workflow', - default=None - ) - parser.add_option('--dryRun', - help='do not run the wf at all', - action='store_true', - dest='dryRun', - default=False - ) - parser.add_option('--testbed', - help='workflow injection to cmswebtest (you need dedicated rqmgr account)', - dest='testbed', - default=False, - action='store_true' - ) - parser.add_option('--noCafVeto', - help='Run from any source, ignoring the CAF label', - dest='cafVeto', - default=True, - action='store_false' - ) - parser.add_option('--overWrite', - help='Change the content of a step for another. List of pairs.', - dest='overWrite', - default=None - ) - parser.add_option('--noRun', - help='Remove all run list selection from wfs', - dest='noRun', - default=False, - action='store_true') - - parser.add_option('--das-options', - help='Options to be passed to dasgoclient.', - dest='dasOptions', - default="--limit 0", - action='store') - - parser.add_option('--job-reports', - help='Dump framework job reports', - dest='jobReports', - default=False, - action='store_true') - - parser.add_option('--ibeos', - help='Use IB EOS site configuration', - dest='IBEos', - default=False, - action='store_true') - - parser.add_option('--sites', - help='Run DAS query to get data from a specific site (default is T2_CH_CERN). Set it to empty string to search all sites.', - dest='dasSites', - default='T2_CH_CERN', - action='store') - parser.add_option('--interactive', - help="Open the Matrix interactive shell", - action='store_true', - default=False) - - parser.add_option('--dbs-url', - help='Overwrite DbsUrl value in JSON submitted to ReqMgr2', - dest='dbsUrl', - default=None, - action='store') - - opt,args = parser.parse_args() + parser = argparse.ArgumentParser(usage,formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + parser.add_argument('-b','--batchName', + help='relval batch: suffix to be appended to Campaign name', + dest='batchName', + default='') + + parser.add_argument('-m','--memoryOffset', + help='memory of the wf for single core', + dest='memoryOffset', + type=int, + default=3000) + + parser.add_argument('--addMemPerCore', + help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore', + dest='memPerCore', + type=int, + default=1500) + + parser.add_argument('-j','--nproc', + help='number of processes. 0 Will use 4 processes, not execute anything but create the wfs', + dest='nProcs', + type=int, + default=4) + + parser.add_argument('-t','--nThreads', + help='number of threads per process to use in cmsRun.', + dest='nThreads', + type=int, + default=1) + + parser.add_argument('--nStreams', + help='number of streams to use in cmsRun.', + dest='nStreams', + type=int, + default=0) + + parser.add_argument('--numberEventsInLuminosityBlock', + help='number of events in a luminosity block', + dest='numberEventsInLuminosityBlock', + type=int, + default=-1) + + parser.add_argument('-n','--showMatrix', + help='Only show the worflows. Use --ext to show more', + dest='show', + default=False, + action='store_true') + + parser.add_argument('-e','--extended', + help='Show details of workflows, used with --show', + dest='extended', + default=False, + action='store_true') + + parser.add_argument('-s','--selected', + help='Run a pre-defined selected matrix of wf. Deprecated, please use -l limited', + dest='restricted', + default=False, + action='store_true') + + parser.add_argument('-l','--list', + help='Comma separated list of workflow to be shown or ran. Possible keys are also '+str(predefinedSet.keys())+'. and wild card like muon, or mc', + dest='testList', + default=None) + + parser.add_argument('-r','--raw', + help='Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)', + dest='raw') + + parser.add_argument('-i','--useInput', + help='Use recyling where available. Either all, or a comma separated list of wf number.', + dest='useInput', + type=lambda x: x.split(','), + default=None) + + parser.add_argument('-w','--what', + help='Specify the set to be used. Argument must be the name of a set (standard, pileup,...) or multiple sets separated by commas (--what standard,pileup )', + dest='what', + default='all') + + parser.add_argument('--step1', + help='Used with --raw. Limit the production to step1', + dest='step1Only', + default=False) + + parser.add_argument('--maxSteps', + help='Only run maximum on maxSteps. Used when we are only interested in first n steps.', + dest='maxSteps', + default=9999, + type=int) + + parser.add_argument('--fromScratch', + help='Comma separated list of wf to be run without recycling. all is not supported as default.', + dest='fromScratch', + type=lambda x: x.split(','), + default=None) + + parser.add_argument('--refRelease', + help='Allow to modify the recycling dataset version', + dest='refRel', + default=None) + + parser.add_argument('--wmcontrol', + help='Create the workflows for injection to WMAgent. In the WORKING. -wmcontrol init will create the the workflows, -wmcontrol test will dryRun a test, -wmcontrol submit will submit to wmagent', + choices=['init','test','submit','force'], + dest='wmcontrol', + default=None) + + parser.add_argument('--revertDqmio', + help='When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO', + choices=['yes','no'], + dest='revertDqmio', + default='no') + + parser.add_argument('--optionswm', + help='Specify a few things for wm injection', + default='', + dest='wmoptions') + + parser.add_argument('--keep', + help='allow to specify for which comma separated steps the output is needed', + default=None) + + parser.add_argument('--label', + help='allow to give a special label to the output dataset name', + default='') + + parser.add_argument('--command', + help='provide a way to add additional command to all of the cmsDriver commands in the matrix', + dest='command', + action='append', + default=None) + + parser.add_argument('--apply', + help='allow to use the --command only for 1 comma separeated', + dest='apply', + default=None) + + parser.add_argument('--workflow', + help='define a workflow to be created or altered from the matrix', + action='append', + dest='workflow', + default=None) + + parser.add_argument('--dryRun', + help='do not run the wf at all', + action='store_true', + dest='dryRun', + default=False) + + parser.add_argument('--testbed', + help='workflow injection to cmswebtest (you need dedicated rqmgr account)', + dest='testbed', + default=False, + action='store_true') + + parser.add_argument('--noCafVeto', + help='Run from any source, ignoring the CAF label', + dest='cafVeto', + default=True, + action='store_false') + + parser.add_argument('--overWrite', + help='Change the content of a step for another. List of pairs.', + dest='overWrite', + default=None) + + parser.add_argument('--noRun', + help='Remove all run list selection from wfs', + dest='noRun', + default=False, + action='store_true') + + parser.add_argument('--das-options', + help='Options to be passed to dasgoclient.', + dest='dasOptions', + default="--limit 0", + action='store') + + parser.add_argument('--job-reports', + help='Dump framework job reports', + dest='jobReports', + default=False, + action='store_true') + + parser.add_argument('--ibeos', + help='Use IB EOS site configuration', + dest='IBEos', + default=False, + action='store_true') + + parser.add_argument('--sites', + help='Run DAS query to get data from a specific site. Set it to empty string to search all sites.', + dest='dasSites', + default='T2_CH_CERN', + action='store') + + parser.add_argument('--interactive', + help="Open the Matrix interactive shell", + action='store_true', + default=False) + + parser.add_argument('--dbs-url', + help='Overwrite DbsUrl value in JSON submitted to ReqMgr2', + dest='dbsUrl', + default=None, + action='store') + + gpugroup = parser.add_argument_group('GPU-related options','These options are only meaningful when --gpu is used, and is not set to forbidden.') + + gpugroup.add_argument('--gpu','--requires-gpu', + help='Enable GPU workflows. Possible options are "forbidden" (default), "required" (implied if no argument is given), or "optional".', + dest='gpu', + choices=['forbidden', 'optional', 'required'], + nargs='?', + const='required', + default='forbidden', + action='store') + + gpugroup.add_argument('--gpu-memory', + help='Specify the minimum amount of GPU memory required by the job, in MB.', + dest='GPUMemoryMB', + type=int, + default=8000) + + gpugroup.add_argument('--cuda-capabilities', + help='Specify a comma-separated list of CUDA "compute capabilities", or GPU hardware architectures, that the job can use.', + dest='CUDACapabilities', + type=lambda x: x.split(','), + default='6.0,6.1,6.2,7.0,7.2,7.5,8.0,8.6') + + # read the CUDA runtime version included in CMSSW + cudart_version = None + libcudart = os.path.realpath(os.path.expandvars('$CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/lib/libcudart.so')) + if os.path.isfile(libcudart): + cudart_basename = os.path.basename(libcudart) + cudart_version = '.'.join(cudart_basename.split('.')[2:4]) + gpugroup.add_argument('--cuda-runtime', + help='Specify major and minor version of the CUDA runtime used to build the application.', + dest='CUDARuntime', + default=cudart_version) + + gpugroup.add_argument('--force-gpu-name', + help='Request a specific GPU model, e.g. "Tesla T4" or "NVIDIA GeForce RTX 2080". The default behaviour is to accept any supported GPU.', + dest='GPUName', + default='') + + gpugroup.add_argument('--force-cuda-driver-version', + help='Request a specific CUDA driver version, e.g. 470.57.02. The default behaviour is to accept any supported CUDA driver version.', + dest='CUDADriverVersion', + default='') + + gpugroup.add_argument('--force-cuda-runtime-version', + help='Request a specific CUDA runtime version, e.g. 11.4. The default behaviour is to accept any supported CUDA runtime version.', + dest='CUDARuntimeVersion', + default='') + + opt = parser.parse_args() if opt.command: opt.command = ' '.join(opt.command) os.environ["CMSSW_DAS_QUERY_SITES"]=opt.dasSites if opt.IBEos: @@ -347,8 +407,6 @@ def stepOrIndex(s): if opt.keep: opt.keep=map(stepOrIndex,opt.keep.split(',')) - - if opt.testList: testList=[] for entry in opt.testList.split(','): @@ -366,17 +424,7 @@ def stepOrIndex(s): print(entry,'is not a possible selected entry') opt.testList = list(set(testList)) - - - if opt.useInput: opt.useInput = opt.useInput.split(',') - if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(',') - if opt.nProcs: opt.nProcs=int(opt.nProcs) - if opt.nThreads: opt.nThreads=int(opt.nThreads) - if opt.nStreams: opt.nStreams=int(opt.nStreams) - if (opt.numberEventsInLuminosityBlock): opt.numberEventsInLuminosityBlock=int(opt.numberEventsInLuminosityBlock) - if (opt.memoryOffset): opt.memoryOffset=int(opt.memoryOffset) - if (opt.memPerCore): opt.memPerCore=int(opt.memPerCore) - + if opt.wmcontrol: performInjectionOptionTest(opt) if opt.overWrite: diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index 84ebf7ff9a000..27c56df274158 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -92,6 +92,7 @@ from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrk_cff import * from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkFilter_cff import * from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkFilterNoHLT_cff import * +from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalIsoTrkProducerFilter_cff import * # HCAL noise from Calibration.HcalAlCaRecoProducers.ALCARECOHcalCalNoise_cff import * #HCAL calibration iterative PhiSym @@ -219,6 +220,7 @@ pathALCARECOHcalCalIsoTrk = cms.Path(seqALCARECOHcalCalIsoTrk*ALCARECOHcalCalIsoTrackDQM) pathALCARECOHcalCalIsoTrkFilter = cms.Path(seqALCARECOHcalCalIsoTrkFilter) pathALCARECOHcalCalIsoTrkFilterNoHLT = cms.Path(seqALCARECOHcalCalIsoTrkFilterNoHLT) +pathALCARECOHcalCalIsoTrkProducerFilter = cms.Path(seqALCARECOHcalCalIsoTrkProducerFilter) pathALCARECOHcalCalNoise = cms.Path(seqALCARECOHcalCalNoise) pathALCARECOHcalCalIterativePhiSym = cms.Path(seqALCARECOHcalCalIterativePhiSym*ALCARECOHcalCalIterativePhisymDQM) pathALCARECOHcalCalIsolatedBunchFilter = cms.Path(seqALCARECOHcalCalIsolatedBunchFilter) @@ -651,6 +653,15 @@ dataTier = cms.untracked.string('ALCARECO') ) +ALCARECOStreamHcalCalIsoTrkProducerFilter = cms.FilteredStream( + responsible = 'Sunanda Banerjee', + name = 'HcalCalIsoTrkProducerFilter', + paths = (pathALCARECOHcalCalIsoTrkProducerFilter), + content = OutALCARECOHcalCalIsoTrkProducerFilter.outputCommands, + selectEvents = OutALCARECOHcalCalIsoTrkProducerFilter.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + ALCARECOStreamHcalCalNoise = cms.FilteredStream( responsible = 'Grigory Safronov', name = 'HcalCalNoise', diff --git a/DQM/TrackingMonitorSource/src/TrackToTrackComparisonHists.cc b/DQM/TrackingMonitorSource/src/TrackToTrackComparisonHists.cc index 983fa54270163..a30b0a94d92ee 100644 --- a/DQM/TrackingMonitorSource/src/TrackToTrackComparisonHists.cc +++ b/DQM/TrackingMonitorSource/src/TrackToTrackComparisonHists.cc @@ -120,7 +120,7 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E edm::Handle monitoredPVHandle; iEvent.getByToken(monitoredPVToken_, monitoredPVHandle); - if (!monitoredTracksHandle.isValid()) { + if (!monitoredPVHandle.isValid()) { edm::LogError("TrackToTrackComparisonHists") << "monitoredPVHandle not found, skipping event"; return; } diff --git a/DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h b/DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h index 86f55909273d4..166ad2c17490e 100644 --- a/DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h +++ b/DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h @@ -17,14 +17,22 @@ class HcalIsoTrkCalibVariables { ieta_ = iphi_ = 0; eMipDR_.clear(); eHcal_ = eHcal10_ = eHcal30_ = 0; + eHcalRaw_ = eHcal10Raw_ = eHcal30Raw_ = 0; + eHcalAux_ = eHcal10Aux_ = eHcal30Aux_ = 0; emaxNearP_ = eAnnular_ = hmaxNearP_ = hAnnular_ = 0; selectTk_ = qltyFlag_ = qltyMissFlag_ = qltyPVFlag_ = false; detIds_.clear(); hitEnergies_.clear(); + hitEnergiesRaw_.clear(); + hitEnergiesAux_.clear(); detIds1_.clear(); hitEnergies1_.clear(); + hitEnergies1Raw_.clear(); + hitEnergies1Aux_.clear(); detIds3_.clear(); hitEnergies3_.clear(); + hitEnergies3Raw_.clear(); + hitEnergies3Aux_.clear(); }; double eventWeight_, rhoh_; @@ -36,10 +44,14 @@ class HcalIsoTrkCalibVariables { int ieta_, iphi_; std::vector eMipDR_; double eHcal_, eHcal10_, eHcal30_; + double eHcalRaw_, eHcal10Raw_, eHcal30Raw_; + double eHcalAux_, eHcal10Aux_, eHcal30Aux_; double emaxNearP_, eAnnular_, hmaxNearP_, hAnnular_; bool selectTk_, qltyFlag_, qltyMissFlag_, qltyPVFlag_; std::vector detIds_, detIds1_, detIds3_; std::vector hitEnergies_, hitEnergies1_, hitEnergies3_; + std::vector hitEnergiesRaw_, hitEnergies1Raw_, hitEnergies3Raw_; + std::vector hitEnergiesAux_, hitEnergies1Aux_, hitEnergies3Aux_; }; typedef std::vector HcalIsoTrkCalibVariablesCollection; diff --git a/DataFormats/HcalCalibObjects/src/classes_def.xml b/DataFormats/HcalCalibObjects/src/classes_def.xml index 1b24c79775e89..bdf98f9cc7549 100644 --- a/DataFormats/HcalCalibObjects/src/classes_def.xml +++ b/DataFormats/HcalCalibObjects/src/classes_def.xml @@ -9,8 +9,9 @@ - - + + + diff --git a/FWCore/MessageLogger/python/MessageLogger_cfi.py b/FWCore/MessageLogger/python/MessageLogger_cfi.py index 03fbc08480b71..3047fb252bcb7 100644 --- a/FWCore/MessageLogger/python/MessageLogger_cfi.py +++ b/FWCore/MessageLogger/python/MessageLogger_cfi.py @@ -1,4 +1,2 @@ -import FWCore.ParameterSet.Config as cms - -from FWCore.MessageService.MessageLogger_cfi import * +from FWCore.ParameterSet.MessageLogger import * diff --git a/FWCore/MessageService/python/MessageLogger_cfi.py b/FWCore/MessageService/python/MessageLogger_cfi.py index 88fa79fac2eb5..28523953bf054 100644 --- a/FWCore/MessageService/python/MessageLogger_cfi.py +++ b/FWCore/MessageService/python/MessageLogger_cfi.py @@ -1,91 +1 @@ -import FWCore.ParameterSet.Config as cms - -_category = cms.optional.untracked.PSetTemplate( - reportEvery = cms.untracked.int32(1), - limit = cms.optional.untracked.int32, - timespan = cms.optional.untracked.int32 -) - -_destination_base = cms.untracked.PSet( - noLineBreaks = cms.optional.untracked.bool, - noTimeStamps = cms.optional.untracked.bool, - lineLength = cms.optional.untracked.int32, - threshold = cms.optional.untracked.string, - statisticsThreshold = cms.optional.untracked.string, - allowAnyLabel_ = _category -) -_destination_no_stat = _destination_base.clone( - enableStatistics = cms.untracked.bool(False), - resetStatistics = cms.untracked.bool(False) -) - -_file_destination = cms.optional.untracked.PSetTemplate( - noLineBreaks = cms.optional.untracked.bool, - noTimeStamps = cms.optional.untracked.bool, - lineLength = cms.optional.untracked.int32, - threshold = cms.optional.untracked.string, - statisticsThreshold = cms.optional.untracked.string, - enableStatistics = cms.untracked.bool(False), - resetStatistics = cms.untracked.bool(False), - filename = cms.optional.untracked.string, - extension = cms.optional.untracked.string, - output = cms.optional.untracked.string, - allowAnyLabel_ = _category -) - -_default_pset = cms.untracked.PSet( - reportEvery = cms.untracked.int32(1), - limit = cms.optional.untracked.int32, - timespan = cms.optional.untracked.int32, - - noLineBreaks = cms.untracked.bool(False), - noTimeStamps = cms.untracked.bool(False), - lineLength = cms.untracked.int32(80), - threshold = cms.untracked.string("INFO"), - statisticsThreshold = cms.untracked.string("INFO"), - allowAnyLabel_ = _category -) - - -MessageLogger = cms.Service("MessageLogger", - suppressWarning = cms.untracked.vstring(), - suppressFwkInfo = cms.untracked.vstring(), - suppressInfo = cms.untracked.vstring(), - suppressDebug = cms.untracked.vstring(), - debugModules = cms.untracked.vstring(), - cout = _destination_no_stat.clone( - enable = cms.untracked.bool(False) - ), - default = _default_pset.clone(), - cerr = _destination_base.clone( - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - resetStatistics = cms.untracked.bool(False), - statisticsThreshold = cms.untracked.string('WARNING'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noTimeStamps = cms.untracked.bool(False), - FwkReport = cms.untracked.PSet( - reportEvery = cms.untracked.int32(1), - limit = cms.untracked.int32(10000000) - ), - default = cms.untracked.PSet( - limit = cms.untracked.int32(10000000) - ), - Root_NoDictionary = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FwkSummary = cms.untracked.PSet( - reportEvery = cms.untracked.int32(1), - limit = cms.untracked.int32(10000000) - ), - threshold = cms.untracked.string('INFO') - ), - files = cms.untracked.PSet( - allowAnyLabel_ = _file_destination - ), - allowAnyLabel_ = _category -) - - +from FWCore.ParameterSet.MessageLogger import MessageLogger diff --git a/FWCore/ParameterSet/python/Config.py b/FWCore/ParameterSet/python/Config.py index e4fdcb0367e82..c6d198ba04ed6 100644 --- a/FWCore/ParameterSet/python/Config.py +++ b/FWCore/ParameterSet/python/Config.py @@ -18,6 +18,7 @@ from .SequenceTypes import * from .SequenceTypes import _ModuleSequenceType, _Sequenceable #extend needs it from .SequenceVisitors import PathValidator, EndPathValidator, ScheduleTaskValidator, NodeVisitor, CompositeVisitor, ModuleNamesFromGlobalsVisitor +from .MessageLogger import MessageLogger from . import DictTypes from .ExceptionHandling import * @@ -137,6 +138,11 @@ def __init__(self,name,*Mods): self.options = Process.defaultOptions_() self.maxEvents = Process.defaultMaxEvents_() self.maxLuminosityBlocks = Process.defaultMaxLuminosityBlocks_() + # intentionally not cloned to ensure that everyone taking + # MessageLogger still via + # FWCore.Message(Logger|Service).MessageLogger_cfi + # use the very same MessageLogger object. + self.MessageLogger = MessageLogger for m in self.__modifiers: m._setChosen() @@ -1479,6 +1485,14 @@ def __init__(self,process, SelectEvents = untracked.PSet(), outputCommands = unt self.__process = process self.__SelectEvents = SelectEvents self.__outputCommands = outputCommands + # Need to remove MessageLogger from the subprocess now that MessageLogger is always present + if self.__process.MessageLogger is not MessageLogger: + print("""Warning: You have reconfigured service +'edm::MessageLogger' in a subprocess. +This service has already been configured. +This particular service may not be reconfigured in a subprocess. +The reconfiguration will be ignored.""") + del self.__process.MessageLogger def dumpPython(self, options=PrintOptions()): out = "parentProcess"+str(hash(self))+" = process\n" out += self.__process.dumpPython() @@ -1885,9 +1899,9 @@ def testProcessInsertion(self): p.a = EDAnalyzer("MyAnalyzer") self.assertTrue( 'a' in p.analyzers_() ) self.assertTrue( 'a' in p.analyzers) - p.add_(Service("MessageLogger")) - self.assertTrue('MessageLogger' in p.services_()) - self.assertEqual(p.MessageLogger.type_(), "MessageLogger") + p.add_(Service("SomeService")) + self.assertTrue('SomeService' in p.services_()) + self.assertEqual(p.SomeService.type_(), "SomeService") p.Tracer = Service("Tracer") self.assertTrue('Tracer' in p.services_()) self.assertRaises(TypeError, setattr, *(p,'b',"this should fail")) @@ -2036,6 +2050,101 @@ def testProcessDumpPython(self): wantSummary = cms.untracked.bool(False) ) +process.MessageLogger = cms.Service("MessageLogger", + cerr = cms.untracked.PSet( + FwkReport = cms.untracked.PSet( + limit = cms.untracked.int32(10000000), + reportEvery = cms.untracked.int32(1) + ), + FwkSummary = cms.untracked.PSet( + limit = cms.untracked.int32(10000000), + reportEvery = cms.untracked.int32(1) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + Root_NoDictionary = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + default = cms.untracked.PSet( + limit = cms.untracked.int32(10000000) + ), + enable = cms.untracked.bool(True), + enableStatistics = cms.untracked.bool(True), + lineLength = cms.optional.untracked.int32, + noLineBreaks = cms.optional.untracked.bool, + noTimeStamps = cms.untracked.bool(False), + resetStatistics = cms.untracked.bool(False), + statisticsThreshold = cms.untracked.string('WARNING'), + threshold = cms.untracked.string('INFO'), + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + limit = cms.optional.untracked.int32, + reportEvery = cms.untracked.int32(1), + timespan = cms.optional.untracked.int32 + ) + ), + cout = cms.untracked.PSet( + enable = cms.untracked.bool(False), + enableStatistics = cms.untracked.bool(False), + lineLength = cms.optional.untracked.int32, + noLineBreaks = cms.optional.untracked.bool, + noTimeStamps = cms.optional.untracked.bool, + resetStatistics = cms.untracked.bool(False), + statisticsThreshold = cms.optional.untracked.string, + threshold = cms.optional.untracked.string, + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + limit = cms.optional.untracked.int32, + reportEvery = cms.untracked.int32(1), + timespan = cms.optional.untracked.int32 + ) + ), + debugModules = cms.untracked.vstring(), + default = cms.untracked.PSet( + limit = cms.optional.untracked.int32, + lineLength = cms.untracked.int32(80), + noLineBreaks = cms.untracked.bool(False), + noTimeStamps = cms.untracked.bool(False), + reportEvery = cms.untracked.int32(1), + statisticsThreshold = cms.untracked.string('INFO'), + threshold = cms.untracked.string('INFO'), + timespan = cms.optional.untracked.int32, + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + limit = cms.optional.untracked.int32, + reportEvery = cms.untracked.int32(1), + timespan = cms.optional.untracked.int32 + ) + ), + files = cms.untracked.PSet( + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + enableStatistics = cms.untracked.bool(False), + extension = cms.optional.untracked.string, + filename = cms.optional.untracked.string, + lineLength = cms.optional.untracked.int32, + noLineBreaks = cms.optional.untracked.bool, + noTimeStamps = cms.optional.untracked.bool, + output = cms.optional.untracked.string, + resetStatistics = cms.untracked.bool(False), + statisticsThreshold = cms.optional.untracked.string, + threshold = cms.optional.untracked.string, + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + limit = cms.optional.untracked.int32, + reportEvery = cms.untracked.int32(1), + timespan = cms.optional.untracked.int32 + ) + ) + ), + suppressDebug = cms.untracked.vstring(), + suppressFwkInfo = cms.untracked.vstring(), + suppressInfo = cms.untracked.vstring(), + suppressWarning = cms.untracked.vstring(), + allowAnyLabel_=cms.optional.untracked.PSetTemplate( + limit = cms.optional.untracked.int32, + reportEvery = cms.untracked.int32(1), + timespan = cms.optional.untracked.int32 + ) +) + + """) p = Process("test") p.a = EDAnalyzer("MyAnalyzer") @@ -2842,7 +2951,19 @@ def testSubProcess(self): process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet( ), outputCommands = cms.untracked.vstring()))""" equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0]))) - self.assertEqual(_lineDiff(d,Process('Parent').dumpPython()+Process('Child').dumpPython()),equalD) + # SubProcesses are dumped before Services, so in order to + # craft the dump of the Parent and Child manually the dump + # of the Parent needs to be split at the MessageLogger + # boundary (now when it is part of Process by default), + # and insert the dump of the Child between the top part of + # the Parent (before MessageLogger) and the bottom part of + # the Parent (after and including MessageLogger) + messageLoggerSplit = 'process.MessageLogger = cms.Service' + parentDumpSplit = Process('Parent').dumpPython().split(messageLoggerSplit) + childProcess = Process('Child') + del childProcess.MessageLogger + combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1] + self.assertEqual(_lineDiff(d, combinedDump), equalD) p = TestMakePSet() process.fillProcessDesc(p) self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules']) diff --git a/FWCore/ParameterSet/python/MessageLogger.py b/FWCore/ParameterSet/python/MessageLogger.py new file mode 100644 index 0000000000000..9f7f25796c971 --- /dev/null +++ b/FWCore/ParameterSet/python/MessageLogger.py @@ -0,0 +1,93 @@ +#import FWCore.ParameterSet.Config as cms +from .Types import * +from .Modules import Service + +_category = optional.untracked.PSetTemplate( + reportEvery = untracked.int32(1), + limit = optional.untracked.int32, + timespan = optional.untracked.int32 +) + +_destination_base = untracked.PSet( + noLineBreaks = optional.untracked.bool, + noTimeStamps = optional.untracked.bool, + lineLength = optional.untracked.int32, + threshold = optional.untracked.string, + statisticsThreshold = optional.untracked.string, + allowAnyLabel_ = _category +) +_destination_no_stat = _destination_base.clone( + enableStatistics = untracked.bool(False), + resetStatistics = untracked.bool(False) +) + +_file_destination = optional.untracked.PSetTemplate( + noLineBreaks = optional.untracked.bool, + noTimeStamps = optional.untracked.bool, + lineLength = optional.untracked.int32, + threshold = optional.untracked.string, + statisticsThreshold = optional.untracked.string, + enableStatistics = untracked.bool(False), + resetStatistics = untracked.bool(False), + filename = optional.untracked.string, + extension = optional.untracked.string, + output = optional.untracked.string, + allowAnyLabel_ = _category +) + +_default_pset = untracked.PSet( + reportEvery = untracked.int32(1), + limit = optional.untracked.int32, + timespan = optional.untracked.int32, + + noLineBreaks = untracked.bool(False), + noTimeStamps = untracked.bool(False), + lineLength = untracked.int32(80), + threshold = untracked.string("INFO"), + statisticsThreshold = untracked.string("INFO"), + allowAnyLabel_ = _category +) + + +MessageLogger = Service("MessageLogger", + suppressWarning = untracked.vstring(), + suppressFwkInfo = untracked.vstring(), + suppressInfo = untracked.vstring(), + suppressDebug = untracked.vstring(), + debugModules = untracked.vstring(), + cout = _destination_no_stat.clone( + enable = untracked.bool(False) + ), + default = _default_pset.clone(), + cerr = _destination_base.clone( + enable = untracked.bool(True), + enableStatistics = untracked.bool(True), + resetStatistics = untracked.bool(False), + statisticsThreshold = untracked.string('WARNING'), + INFO = untracked.PSet( + limit = untracked.int32(0) + ), + noTimeStamps = untracked.bool(False), + FwkReport = untracked.PSet( + reportEvery = untracked.int32(1), + limit = untracked.int32(10000000) + ), + default = untracked.PSet( + limit = untracked.int32(10000000) + ), + Root_NoDictionary = untracked.PSet( + limit = untracked.int32(0) + ), + FwkSummary = untracked.PSet( + reportEvery = untracked.int32(1), + limit = untracked.int32(10000000) + ), + threshold = untracked.string('INFO') + ), + files = untracked.PSet( + allowAnyLabel_ = _file_destination + ), + allowAnyLabel_ = _category +) + + diff --git a/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc b/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc index eb807819edd5c..45a1b188c8ce9 100644 --- a/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc +++ b/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc @@ -288,27 +288,10 @@ void testmakeprocess::taskTest() { for (auto const& pset : vpsetServices) { serviceNames.insert(pset.getParameter("@service_type")); } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv11"); - expectedServiceNames.emplace_back("serv12"); - expectedServiceNames.emplace_back("serv13"); - expectedServiceNames.emplace_back("serv14"); - expectedServiceNames.emplace_back("serv15"); - expectedServiceNames.emplace_back("serv16"); - expectedServiceNames.emplace_back("serv17"); - expectedServiceNames.emplace_back("serv18"); - expectedServiceNames.emplace_back("serv19"); - expectedServiceNames.emplace_back("serv20"); - expectedServiceNames.emplace_back("serv21"); - expectedServiceNames.emplace_back("serv22"); - expectedServiceNames.emplace_back("serv23"); - expectedServiceNames.emplace_back("serv24"); - expectedServiceNames.emplace_back("serv25"); - expectedServiceNames.emplace_back("serv26"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); + std::vector expectedServiceNames{"MessageLogger", "serv1", "serv2", "serv11", "serv12", "serv13", + "serv14", "serv15", "serv16", "serv17", "serv18", "serv19", + "serv20", "serv21", "serv22", "serv23", "serv24", "serv25", + "serv26", "serv27", "serv28"}; bool result = true; for (auto const& name : expectedServiceNames) { if (serviceNames.find(name) == serviceNames.end()) { @@ -407,11 +390,7 @@ void testmakeprocess::taskTestWithEmptySchedule() { for (auto const& pset : vpsetServices) { serviceNames.insert(pset.getParameter("@service_type")); } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); + std::vector expectedServiceNames{"MessageLogger", "serv1", "serv2", "serv27", "serv28"}; bool result = true; for (auto const& name : expectedServiceNames) { if (serviceNames.find(name) == serviceNames.end()) { @@ -516,29 +495,10 @@ void testmakeprocess::taskTestWithSchedule() { for (auto const& pset : vpsetServices) { serviceNames.insert(pset.getParameter("@service_type")); } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv3"); - expectedServiceNames.emplace_back("serv4"); - expectedServiceNames.emplace_back("serv11"); - expectedServiceNames.emplace_back("serv12"); - expectedServiceNames.emplace_back("serv13"); - expectedServiceNames.emplace_back("serv14"); - expectedServiceNames.emplace_back("serv15"); - expectedServiceNames.emplace_back("serv16"); - expectedServiceNames.emplace_back("serv17"); - expectedServiceNames.emplace_back("serv18"); - expectedServiceNames.emplace_back("serv19"); - expectedServiceNames.emplace_back("serv20"); - expectedServiceNames.emplace_back("serv21"); - expectedServiceNames.emplace_back("serv22"); - expectedServiceNames.emplace_back("serv23"); - expectedServiceNames.emplace_back("serv24"); - expectedServiceNames.emplace_back("serv25"); - expectedServiceNames.emplace_back("serv26"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); + std::vector expectedServiceNames{"MessageLogger", "serv1", "serv2", "serv3", "serv4", "serv11", + "serv12", "serv13", "serv14", "serv15", "serv16", "serv17", + "serv18", "serv19", "serv20", "serv21", "serv22", "serv23", + "serv24", "serv25", "serv26", "serv27", "serv28"}; bool result = true; for (auto const& name : expectedServiceNames) { if (serviceNames.find(name) == serviceNames.end()) { diff --git a/FastSimulation/EventProducer/BuildFile.xml b/FastSimulation/EventProducer/BuildFile.xml deleted file mode 100644 index 8e1402c1ef46f..0000000000000 --- a/FastSimulation/EventProducer/BuildFile.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/FastSimulation/EventProducer/interface/FamosManager.h b/FastSimulation/EventProducer/interface/FamosManager.h deleted file mode 100644 index bd27b1107c2b7..0000000000000 --- a/FastSimulation/EventProducer/interface/FamosManager.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef FastSimulation_EventProducer_FamosManager_H -#define FastSimulation_EventProducer_FamosManager_H - -#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" -#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h" -#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" -#include - -namespace HepMC { - class GenEvent; -} - -namespace edm { - class HepMCProduct; -} // namespace edm - -class FSimEvent; -class TrajectoryManager; -class PileUpSimulator; -class MagneticField; -class CalorimetryManager; -class RandomEngineAndDistribution; -class TrackerTopology; - -// using trailing _ for private data members, m_p prefix for PSet variables (MSt) - -class FamosManager { -public: - /// Constructor - FamosManager(edm::ParameterSet const& p, edm::ConsumesCollector&&); - - /// Destructor - ~FamosManager(); - - /// Get information from the Event Setup - void setupGeometryAndField(edm::Run const& run, const edm::EventSetup& es); - - /// The simulated event - FSimEvent* simEvent() const { return mySimEvent; } - - /// The real thing is done here - void reconstruct(const HepMC::GenEvent* evt, const TrackerTopology* tTopo, RandomEngineAndDistribution const*); - - /// The tracker - TrajectoryManager* trackerManager() const { return myTrajectoryManager; } - - /// The calorimeter - CalorimetryManager* calorimetryManager() const { return myCalorimetry; } - -private: - int iEvent; - // const HepMC::GenEvent* myGenEvent; - FSimEvent* mySimEvent; - TrajectoryManager* myTrajectoryManager; - CalorimetryManager* myCalorimetry; - -private: - bool m_pUseMagneticField; - bool m_Tracking; - bool m_Calorimetry; - bool m_Alignment; - double weight_; - int m_pRunNumber; - int m_pVerbose; -}; -#endif diff --git a/FastSimulation/EventProducer/interface/FamosProducer.h b/FastSimulation/EventProducer/interface/FamosProducer.h deleted file mode 100644 index a46b5cd869587..0000000000000 --- a/FastSimulation/EventProducer/interface/FamosProducer.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef FastSimulation_EventProducer_FamosProducer_H -#define FastSimulation_EventProducer_FamosProducer_H - -#include "FWCore/Framework/interface/stream/EDProducer.h" - -#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" - -class FamosManager; -class ParameterSet; -class Event; -class EventSetup; - -namespace HepMC { - class GenEvent; -} - -class FamosProducer : public edm::stream::EDProducer<> { -public: - explicit FamosProducer(edm::ParameterSet const& p); - ~FamosProducer() override; - void beginRun(edm::Run const& run, const edm::EventSetup& es) override; - void produce(edm::Event& e, const edm::EventSetup& c) override; - -private: - FamosManager* famosManager_; - HepMC::GenEvent* evt_; - bool simulateMuons; - - // token for hepmc from signal event - edm::EDGetTokenT sourceToken; -}; - -#endif diff --git a/FastSimulation/EventProducer/python/FamosSimHits_cff.py b/FastSimulation/EventProducer/python/FamosSimHits_cff.py deleted file mode 100644 index 66f3bb0015080..0000000000000 --- a/FastSimulation/EventProducer/python/FamosSimHits_cff.py +++ /dev/null @@ -1,51 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from FastSimulation.Event.ParticleFilter_cfi import * -from FastSimulation.MaterialEffects.MaterialEffects_cfi import * -from FastSimulation.TrajectoryManager.ActivateDecays_cfi import * -from FastSimulation.TrajectoryManager.TrackerSimHits_cfi import * -from FastSimulation.Calorimetry.Calorimetry_cff import * - -MaterialEffectsForMuonsBlock.MaterialEffectsForMuons.use_hardcoded_geometry = True -MaterialEffectsBlock.MaterialEffects.use_hardcoded_geometry = True - - -famosSimHits = cms.EDProducer("FamosProducer", - # FastCalorimetry - FamosCalorimetryBlock, - # Conditions to save Tracker SimHits - TrackerSimHitsBlock, - # Material effects to be simulated in the tracker material and associated cuts - MaterialEffectsBlock, - # Material effects for muons in ECAL - MaterialEffectsForMuonsInECALBlock, - # Material effects for muons in HCAL - MaterialEffectsForMuonsInHCALBlock, - # (De)activate decays of unstable particles (K0S, etc...) - ActivateDecaysBlock, - # Kinematic cuts for the particle filter in the SimEvent - ParticleFilterBlock, - # The HepMCProduct source - SourceLabel = cms.InputTag("generatorSmeared"), - # The genParticle source (in case there is no HepMCProduct) - GenParticleLabel = cms.InputTag("genParticles"), - # If false, no SimTrack collection for Muons is stored - SimulateMuons = cms.bool(True), - # The beam spot source - BeamSpotLabel = cms.InputTag("offlineBeamSpot"), - # Run Number - RunNumber = cms.untracked.int32(1001), - Verbosity = cms.untracked.int32(0), - # If false, no misalignment can be applied in the tracker - ApplyAlignment = cms.bool(True), - # If false, no SimHits are simulated in the tracker - # (but the tracker material is still here) - SimulateTracking = cms.bool(True), - # If false, no PCaloHits are produced - SimulateCalorimetry = cms.bool(True), - # If the following is false, no B field map is used, - # and B is set to 4 T altogether - UseMagneticField = cms.bool(True), -) - - diff --git a/FastSimulation/EventProducer/src/FamosManager.cc b/FastSimulation/EventProducer/src/FamosManager.cc deleted file mode 100644 index b071b09660be5..0000000000000 --- a/FastSimulation/EventProducer/src/FamosManager.cc +++ /dev/null @@ -1,160 +0,0 @@ -// CMSSW Header -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Run.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/Provenance/interface/EventID.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" - -#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" - -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" - -//#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -//#include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" -#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometryRecord.h" -#include "FastSimulation/ParticlePropagator/interface/MagneticFieldMapRecord.h" - -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" -#include "Geometry/Records/interface/CaloTopologyRecord.h" -//#include "Geometry/CaloTopology/interface/CaloTopology.h" - -// HepMC headers -//#include "HepMC/GenEvent.h" - -// FAMOS Header -#include "FastSimulation/EventProducer/interface/FamosManager.h" -#include "FastSimulation/TrajectoryManager/interface/TrajectoryManager.h" -#include "FastSimulation/Event/interface/FSimEvent.h" -#include "FastSimulation/ParticlePropagator/interface/MagneticFieldMap.h" -#include "FastSimulation/Calorimetry/interface/CalorimetryManager.h" -#include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h" -#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" -#include "FastSimulation/ShowerDevelopment/interface/FastHFShowerLibrary.h" -#include -#include -#include - -using namespace HepMC; - -FamosManager::FamosManager(edm::ParameterSet const& p, edm::ConsumesCollector&& iC) - : iEvent(0), - myCalorimetry(nullptr), - m_pUseMagneticField(p.getParameter("UseMagneticField")), - m_Tracking(p.getParameter("SimulateTracking")), - m_Calorimetry(p.getParameter("SimulateCalorimetry")), - m_Alignment(p.getParameter("ApplyAlignment")), - m_pRunNumber(p.getUntrackedParameter("RunNumber", 1)), - m_pVerbose(p.getUntrackedParameter("Verbosity", 1)) { - // Initialize the FSimEvent - mySimEvent = new FSimEvent(p.getParameter("ParticleFilter")); - - /// Initialize the TrajectoryManager - myTrajectoryManager = new TrajectoryManager(mySimEvent, - p.getParameter("MaterialEffects"), - p.getParameter("TrackerSimHits"), - p.getParameter("ActivateDecays")); - - // Initialize Calorimetry Fast Simulation (if requested) - if (m_Calorimetry) - myCalorimetry = new CalorimetryManager(mySimEvent, - p.getParameter("Calorimetry"), - p.getParameter("MaterialEffectsForMuonsInECAL"), - p.getParameter("MaterialEffectsForMuonsInHCAL"), - p.getParameter("GFlash"), - std::move(iC)); -} - -FamosManager::~FamosManager() { - if (mySimEvent) - delete mySimEvent; - if (myTrajectoryManager) - delete myTrajectoryManager; - if (myCalorimetry) - delete myCalorimetry; -} - -void FamosManager::setupGeometryAndField(edm::Run const& run, const edm::EventSetup& es) { - // Particle data table (from Pythia) - edm::ESHandle pdt; - es.getData(pdt); - mySimEvent->initializePdt(&(*pdt)); - - // Initialize the full (misaligned) tracker geometry - // (only if tracking is requested) - std::string misAligned = m_Alignment ? "MisAligned" : ""; - // 1) By default, the aligned geometry is chosen (m_Alignment = false) - // 2) By default, the misaligned geometry is aligned - edm::ESHandle tracker; - es.get().get(misAligned, tracker); - if (m_Tracking) - myTrajectoryManager->initializeTrackerGeometry(&(*tracker)); - - // Initialize the tracker misaligned reco geometry (always needed) - // By default, the misaligned geometry is aligned - edm::ESHandle theGeomSearchTracker; - es.get().get(misAligned, theGeomSearchTracker); - - // Initialize the misaligned tracker interaction geometry - edm::ESHandle theTrackerInteractionGeometry; - es.get().get(misAligned, theTrackerInteractionGeometry); - - // Initialize the magnetic field - double bField000 = 0.; - if (m_pUseMagneticField) { - edm::ESHandle theMagneticFieldMap; - es.get().get(misAligned, theMagneticFieldMap); - const GlobalPoint g(0., 0., 0.); - bField000 = theMagneticFieldMap->inTeslaZ(g); - myTrajectoryManager->initializeRecoGeometry( - &(*theGeomSearchTracker), &(*theTrackerInteractionGeometry), &(*theMagneticFieldMap)); - } else { - myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker), &(*theTrackerInteractionGeometry), nullptr); - bField000 = 4.0; - } - // The following should be on LogInfo - //std::cout << "B-field(T) at (0,0,0)(cm): " << bField000 << std::endl; - - // Initialize the calorimeter geometry - if (myCalorimetry) { - edm::ESHandle pG; - es.get().get(pG); - myCalorimetry->getCalorimeter()->setupGeometry(*pG); - - edm::ESHandle theCaloTopology; - es.get().get(theCaloTopology); - myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology); - myCalorimetry->getCalorimeter()->initialize(bField000); - - myCalorimetry->getHFShowerLibrary()->initHFShowerLibrary(es); - } - - m_pRunNumber = run.run(); -} - -void FamosManager::reconstruct(const HepMC::GenEvent* evt, - const TrackerTopology* tTopo, - RandomEngineAndDistribution const* random) { - // myGenEvent = evt; - - iEvent++; - edm::EventID id(m_pRunNumber, 1U, iEvent); - - // Fill the event from the original generated event - mySimEvent->fill(*evt, id); - - // And propagate the particles through the detector - myTrajectoryManager->reconstruct(tTopo, random); - - if (myCalorimetry) - myCalorimetry->reconstruct(random); - - edm::LogInfo("FamosManager") << " saved : Event " << iEvent << " of weight " << mySimEvent->weight() << " with " - << mySimEvent->nTracks() << " tracks and " << mySimEvent->nVertices() - << " vertices, generated by " << mySimEvent->nGenParts() << " particles " << std::endl; -} diff --git a/FastSimulation/EventProducer/src/FamosProducer.cc b/FastSimulation/EventProducer/src/FamosProducer.cc deleted file mode 100644 index 155b0ec337611..0000000000000 --- a/FastSimulation/EventProducer/src/FamosProducer.cc +++ /dev/null @@ -1,119 +0,0 @@ -#include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" -#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" - -#include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexTypeFwd.h" - -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/Candidate/interface/CandidateFwd.h" -#include "DataFormats/Provenance/interface/EventID.h" - -#include "FastSimulation/EventProducer/interface/FamosProducer.h" -#include "FastSimulation/EventProducer/interface/FamosManager.h" -#include "FastSimulation/Event/interface/FSimEvent.h" -#include "FastSimulation/Event/interface/KineParticleFilter.h" -#include "FastSimulation/Calorimetry/interface/CalorimetryManager.h" -#include "FastSimulation/TrajectoryManager/interface/TrajectoryManager.h" -#include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" -#include "Geometry/Records/interface/TrackerTopologyRcd.h" - -#include "HepMC/GenVertex.h" -#include "HepMC/GenEvent.h" - -#include -#include -#include - -FamosProducer::FamosProducer(edm::ParameterSet const& p) { - produces(); - produces(); - produces("VertexTypes"); - produces("TrackerHits"); - produces("EcalHitsEB"); - produces("EcalHitsEE"); - produces("EcalHitsES"); - produces("HcalHits"); - // Temporary facility to allow for the crossing frame to work... - simulateMuons = p.getParameter("SimulateMuons"); - if (simulateMuons) - produces("MuonSimTracks"); - - // hepmc event from signal event - edm::InputTag sourceLabel = p.getParameter("SourceLabel"); - sourceToken = consumes(sourceLabel); - - // famos manager - famosManager_ = new FamosManager(p, consumesCollector()); -} - -FamosProducer::~FamosProducer() { delete famosManager_; } - -void FamosProducer::beginRun(edm::Run const& run, const edm::EventSetup& es) { - famosManager_->setupGeometryAndField(run, es); -} - -void FamosProducer::produce(edm::Event& iEvent, const edm::EventSetup& es) { - using namespace edm; - - RandomEngineAndDistribution random(iEvent.streamID()); - - //Retrieve tracker topology from geometry - edm::ESHandle tTopoHand; - es.get().get(tTopoHand); - const TrackerTopology* tTopo = tTopoHand.product(); - - // get the signal event - Handle theHepMCProduct; - iEvent.getByToken(sourceToken, theHepMCProduct); - const HepMC::GenEvent* myGenEvent = theHepMCProduct->GetEvent(); - - // do the simulation - famosManager_->reconstruct(myGenEvent, tTopo, &random); - - // get the hits, simtracks and simvertices and put in the event - CalorimetryManager* calo = famosManager_->calorimetryManager(); - TrajectoryManager* tracker = famosManager_->trackerManager(); - - std::unique_ptr p1(new edm::SimTrackContainer); - std::unique_ptr m1(new edm::SimTrackContainer); - std::unique_ptr p2(new edm::SimVertexContainer); - std::unique_ptr v1(new FSimVertexTypeCollection); - std::unique_ptr p3(new edm::PSimHitContainer); - std::unique_ptr p4(new edm::PCaloHitContainer); - std::unique_ptr p5(new edm::PCaloHitContainer); - std::unique_ptr p6(new edm::PCaloHitContainer); - std::unique_ptr p7(new edm::PCaloHitContainer); - - FSimEvent* fevt = famosManager_->simEvent(); - fevt->load(*p1, *m1); - fevt->load(*p2); - fevt->load(*v1); - tracker->loadSimHits(*p3); - - if (calo) { - calo->loadFromEcalBarrel(*p4); - calo->loadFromEcalEndcap(*p5); - calo->loadFromPreshower(*p6); - calo->loadFromHcal(*p7); - calo->loadMuonSimTracks(*m1); - } - - if (simulateMuons) - iEvent.put(std::move(m1), "MuonSimTracks"); - iEvent.put(std::move(p1)); - iEvent.put(std::move(p2)); - iEvent.put(std::move(p3), "TrackerHits"); - iEvent.put(std::move(v1), "VertexTypes"); - iEvent.put(std::move(p4), "EcalHitsEB"); - iEvent.put(std::move(p5), "EcalHitsEE"); - iEvent.put(std::move(p6), "EcalHitsES"); - iEvent.put(std::move(p7), "HcalHits"); -} - -DEFINE_FWK_MODULE(FamosProducer); diff --git a/FastSimulation/ForwardDetectors/test/CastorTowerProducerTest_cfg.py b/FastSimulation/ForwardDetectors/test/CastorTowerProducerTest_cfg.py deleted file mode 100644 index c55d4a4bf1157..0000000000000 --- a/FastSimulation/ForwardDetectors/test/CastorTowerProducerTest_cfg.py +++ /dev/null @@ -1,80 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("PROD") - -# The number of events to be processed. -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) ) - -# For valgrind studies -# process.ProfilerService = cms.Service("ProfilerService", -# lastEvent = cms.untracked.int32(13), -# firstEvent = cms.untracked.int32(3), -# paths = cms.untracked.vstring('p1') -#) - -# Include the RandomNumberGeneratorService definition -process.load("IOMC.RandomEngine.IOMC_cff") - -# Generate H -> ZZ -> l+l- l'+l'- (l,l'=e or mu), with mH=200GeV/c2 -#process.load("Configuration.Generator.H200ZZ4L_cfi") -# Generate ttbar events -# process.load("FastSimulation/Configuration/ttbar_cfi") -# Generate multijet events with different ptHAT bins -# process.load("FastSimulation/Configuration/QCDpt80-120_cfi") -# process.load("FastSimulation/Configuration/QCDpt600-800_cfi") -# Generate Minimum Bias Events -process.load("FastSimulation/Configuration/MinBiasEvents_cfi") -# Generate muons with a flat pT particle gun, and with pT=10. -# process.load("FastSimulation/Configuration/FlatPtMuonGun_cfi") -# replace FlatRandomPtGunProducer.PGunParameters.PartID={130} -# Generate di-electrons with pT=35 GeV -#process.load("FastSimulation/Configuration/DiElectrons_cfi") - -# Famos sequences (Frontier conditions) -process.load("FastSimulation/Configuration/CommonInputs_cff") -process.GlobalTag.globaltag = "IDEAL_30X::All" -process.load("FastSimulation/Configuration/FamosSequences_cff") - -# Parametrized magnetic field (new mapping, 4.0 and 3.8T) -#process.load("Configuration.StandardSequences.MagneticField_40T_cff") -process.load("Configuration.StandardSequences.MagneticField_38T_cff") -process.VolumeBasedMagneticFieldESProducer.useParametrizedTrackerField = True - -# If you want to turn on/off pile-up -#process.famosPileUp.PileUpSimulator.averageNumber = 5.0 -# You may not want to simulate everything for your study -process.fastSimProducer.SimulateCalorimetry = True -for layer in process.fastSimProducer.detectorDefinition.BarrelLayers: - layer.interactionModels = cms.untracked.vstring("pairProduction", "nuclearInteraction", "bremsstrahlung", "energyLoss", "multipleScattering", "trackerSimHits") -for layer in process.fastSimProducer.detectorDefinition.ForwardLayers: - layer.interactionModels = cms.untracked.vstring("pairProduction", "nuclearInteraction", "bremsstrahlung", "energyLoss", "multipleScattering", "trackerSimHits") -# process.fastSimProducer.SimulateMuons = False - -# include Castor fast sim -process.load("FastSimulation.ForwardDetectors.CastorFastReco_cff") - -# Produce Tracks and Clusters -process.p1 = cms.Path(process.ProductionFilterSequence*process.famosWithEverything*process.CastorFastReco) - -# To write out events (not need: FastSimulation _is_ fast!) -process.o1 = cms.OutputModule( - "PoolOutputModule", - fileName = cms.untracked.string("MyFirstFamosFile.root"), - outputCommands = cms.untracked.vstring("keep *_Castor*Reco_*_*", - "drop *_mix_*_*") - ) - -process.outpath = cms.EndPath(process.o1) - -# Keep the logging output to a nice level # - -#process.Timing = cms.Service("Timing") -#process.load("FWCore/MessageService/MessageLogger_cfi") -#process.MessageLogger.destinations = cms.untracked.vstring("pyDetailedInfo.txt","cout") -# -#process.MessageLogger.cout = cms.untracked.PSet(threshold=cms.untracked.string("INFO"), -# default=cms.untracked.PSet(limit=cms.untracked.int32(0)), -# FamosManager=cms.untracked.PSet(limit=cms.untracked.int32(100000))) - -# Make the job crash in case of missing product -process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring('ProductNotFound') ) diff --git a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc index 23256f54071f1..624d09739ea33 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc @@ -17,7 +17,7 @@ #include -FastTSGFromL2Muon::FastTSGFromL2Muon(const edm::ParameterSet& cfg) : theConfig(cfg) { +FastTSGFromL2Muon::FastTSGFromL2Muon(const edm::ParameterSet& cfg) { produces(); edm::ParameterSet serviceParameters = cfg.getParameter("ServiceParameters"); @@ -28,15 +28,14 @@ FastTSGFromL2Muon::FastTSGFromL2Muon(const edm::ParameterSet& cfg) : theConfig(c theSeedCollectionLabels = cfg.getParameter >("SeedCollectionLabels"); theSimTrackCollectionLabel = cfg.getParameter("SimTrackCollectionLabel"); // useTFileService_ = cfg.getUntrackedParameter("UseTFileService",false); + edm::ParameterSet regionBuilderPSet = cfg.getParameter("MuonTrackingRegionBuilder"); + theRegionBuilder = std::make_unique(regionBuilderPSet, consumesCollector()); } FastTSGFromL2Muon::~FastTSGFromL2Muon() {} void FastTSGFromL2Muon::beginRun(edm::Run const& run, edm::EventSetup const& es) { //region builder - edm::ParameterSet regionBuilderPSet = theConfig.getParameter("MuonTrackingRegionBuilder"); - edm::ConsumesCollector iC = consumesCollector(); - theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC); /* if(useTFileService_) { diff --git a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h index 26a618c3a8e72..ffb56f5b4c11c 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h +++ b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h @@ -37,7 +37,6 @@ class FastTSGFromL2Muon : public edm::stream::EDProducer<> { const SimTrack& theSimTrack); private: - edm::ParameterSet theConfig; edm::InputTag theSimTrackCollectionLabel; edm::InputTag theL2CollectionLabel; std::vector theSeedCollectionLabels; @@ -46,7 +45,7 @@ class FastTSGFromL2Muon : public edm::stream::EDProducer<> { MuonServiceProxy* theService; double thePtCut; - MuonTrackingRegionBuilder* theRegionBuilder; + std::unique_ptr theRegionBuilder; // TH1F* h_nSeedPerTrack; // TH1F* h_nGoodSeedPerTrack; diff --git a/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc b/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc index 4b336ea86d502..2b9f331f48ebd 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc @@ -52,7 +52,6 @@ FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig, const MuonServiceProxy* service, edm::ConsumesCollector& iC) : theCategory("FastSimulation|Muons|FastTSGFromPropagation"), - theTracker(), theNavigation(), theService(service), theUpdator(), @@ -65,7 +64,10 @@ FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig, iC.consumes(theConfig.getParameter("HitProducer"))), beamSpot_(iC.consumes(iConfig.getParameter("beamSpot"))), theMeasurementTrackerEventToken_( - iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))) {} + iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))), + theGeometryToken(iC.esConsumes()), + theTTRHBuilderToken(iC.esConsumes(edm::ESInputTag("", "WithTrackAngle"))), + theTrackerToken(iC.esConsumes()) {} FastTSGFromPropagation::~FastTSGFromPropagation() { LogTrace(theCategory) << " FastTSGFromPropagation dtor called "; } @@ -320,8 +322,6 @@ void FastTSGFromPropagation::init(const MuonServiceProxy* service) { theEstimator = std::make_unique(theMaxChi2); - theCacheId_MT = 0; - theCacheId_TG = 0; thePropagatorName = theConfig.getParameter("Propagator"); @@ -347,14 +347,9 @@ void FastTSGFromPropagation::init(const MuonServiceProxy* service) { theErrorMatrixAdjuster.reset(); } - theService->eventSetup().get().get(theTracker); - theNavigation = std::make_unique(theTracker); - - edm::ESHandle geometry; - theService->eventSetup().get().get(geometry); - theGeometry = &(*geometry); + theGeometry = &theService->eventSetup().getData(theGeometryToken); - theService->eventSetup().get().get("WithTrackAngle", theTTRHBuilder); + theTTRHBuilder = theService->eventSetup().getHandle(theTTRHBuilderToken); } void FastTSGFromPropagation::setEvent(const edm::Event& iEvent) { @@ -364,30 +359,16 @@ void FastTSGFromPropagation::setEvent(const edm::Event& iEvent) { iEvent.getByToken(theSimTrackCollectionToken_, theSimTracks); iEvent.getByToken(recHitCombinationsToken_, recHitCombinations); - unsigned long long newCacheId_MT = theService->eventSetup().get().cacheIdentifier(); - - if (theUpdateStateFlag && newCacheId_MT != theCacheId_MT) { - LogTrace(theCategory) << "Measurment Tracker Geometry changed!"; - theCacheId_MT = newCacheId_MT; - theService->eventSetup().get().get(theMeasTracker); - } - if (theUpdateStateFlag) { iEvent.getByToken(theMeasurementTrackerEventToken_, theMeasTrackerEvent); } - bool trackerGeomChanged = false; - unsigned long long newCacheId_TG = theService->eventSetup().get().cacheIdentifier(); if (newCacheId_TG != theCacheId_TG) { LogTrace(theCategory) << "Tracker Reco Geometry changed!"; theCacheId_TG = newCacheId_TG; - theService->eventSetup().get().get(theTracker); - trackerGeomChanged = true; - } - - if (trackerGeomChanged && theTracker.product()) { + auto theTracker = theService->eventSetup().getHandle(theTrackerToken); theNavigation = std::make_unique(theTracker); } } diff --git a/FastSimulation/Muons/plugins/FastTSGFromPropagation.h b/FastSimulation/Muons/plugins/FastTSGFromPropagation.h index 0ebc8ba23216e..5f812d6ff5830 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromPropagation.h +++ b/FastSimulation/Muons/plugins/FastTSGFromPropagation.h @@ -44,6 +44,9 @@ struct TrajectoryStateTransform; class SimTrack; class TrackerGeometry; class TrackerTopology; +class TransientRecHitRecord; +class CkfComponentsRecord; +class TrackerRecoGeometryRecord; class FastTSGFromPropagation : public TrackerSeedGenerator { public: @@ -123,15 +126,10 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { } }; - unsigned long long theCacheId_MT; unsigned long long theCacheId_TG; std::string theCategory; - edm::ESHandle theTracker; - - edm::ESHandle theMeasTracker; - std::unique_ptr theNavigation; const TrackerGeometry* theGeometry; @@ -175,6 +173,13 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { edm::Handle recHitCombinations; edm::Handle theMeasTrackerEvent; edm::ESHandle theTTRHBuilder; + + //from init + edm::ESGetToken theGeometryToken; + edm::ESGetToken theTTRHBuilderToken; + + //from setEvent + edm::ESGetToken theTrackerToken; }; #endif diff --git a/Geometry/HcalCommonData/python/hcalDDDSimConstants_cff.py b/Geometry/HcalCommonData/python/hcalDDDSimConstants_cff.py index ed450728bbf4e..50663626e0dfd 100644 --- a/Geometry/HcalCommonData/python/hcalDDDSimConstants_cff.py +++ b/Geometry/HcalCommonData/python/hcalDDDSimConstants_cff.py @@ -4,4 +4,4 @@ from Geometry.HcalCommonData.hcalSimulationParameters_cff import * from Geometry.HcalCommonData.hcalSimulationConstants_cfi import * from Geometry.HcalCommonData.caloSimulationParameters_cff import * -from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import * +from Geometry.HcalCommonData.hcalDBConstants_cff import * diff --git a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc index 5f3abf37f5ea1..aacc352ce8d51 100644 --- a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc +++ b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc @@ -5,6 +5,7 @@ #include "DataFormats/Math/interface/GeantUnits.h" #include "CLHEP/Units/GlobalPhysicalConstants.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" +#include #include //#define EDM_ML_DEBUG diff --git a/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Left_Station.xml b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Left_Station.xml new file mode 100644 index 0000000000000..20e129354fcd1 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Left_Station.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Right_Station.xml b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Right_Station.xml new file mode 100644 index 0000000000000..d9583634c2071 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Right_Station.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Left_Station.xml b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Left_Station.xml new file mode 100644 index 0000000000000..c3da30f67e6f9 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Left_Station.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Right_Station.xml b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Right_Station.xml new file mode 100644 index 0000000000000..1d88fa39dd542 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Right_Station.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml new file mode 100644 index 0000000000000..3b7b5b744a527 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml new file mode 100644 index 0000000000000..378d4155c893e --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml new file mode 100644 index 0000000000000..aa2bec0580c4e --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml new file mode 100644 index 0000000000000..081ad41552b3d --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml new file mode 100644 index 0000000000000..03e56824cec6e --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml @@ -0,0 +1,248 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Timing_Negative_Station/v1/CTPPS_Timing_Negative_Station.xml b/Geometry/VeryForwardData/data/CTPPS_Timing_Negative_Station/v1/CTPPS_Timing_Negative_Station.xml new file mode 100644 index 0000000000000..0e55d08b462df --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Timing_Negative_Station/v1/CTPPS_Timing_Negative_Station.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/CTPPS_Timing_Positive_Station/v1/CTPPS_Timing_Positive_Station.xml b/Geometry/VeryForwardData/data/CTPPS_Timing_Positive_Station/v1/CTPPS_Timing_Positive_Station.xml new file mode 100644 index 0000000000000..bf8811f766135 --- /dev/null +++ b/Geometry/VeryForwardData/data/CTPPS_Timing_Positive_Station/v1/CTPPS_Timing_Positive_Station.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/RP_Horizontal_Device/2021/Reco/v2/RP_Horizontal_Device.xml b/Geometry/VeryForwardData/data/RP_Horizontal_Device/2021/Reco/v2/RP_Horizontal_Device.xml new file mode 100644 index 0000000000000..1231568849c5a --- /dev/null +++ b/Geometry/VeryForwardData/data/RP_Horizontal_Device/2021/Reco/v2/RP_Horizontal_Device.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/RP_Vertical_Device/2021/Reco/v2/RP_Vertical_Device.xml b/Geometry/VeryForwardData/data/RP_Vertical_Device/2021/Reco/v2/RP_Vertical_Device.xml new file mode 100644 index 0000000000000..a4c5ce118faa0 --- /dev/null +++ b/Geometry/VeryForwardData/data/RP_Vertical_Device/2021/Reco/v2/RP_Vertical_Device.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardData/data/dd4hep/cmsExtendedGeometry2021.xml b/Geometry/VeryForwardData/data/dd4hep/cmsExtendedGeometry2021.xml index 7e43b537e9595..e4ac6d75f7536 100644 --- a/Geometry/VeryForwardData/data/dd4hep/cmsExtendedGeometry2021.xml +++ b/Geometry/VeryForwardData/data/dd4hep/cmsExtendedGeometry2021.xml @@ -343,12 +343,12 @@ - + - - - - + + + + diff --git a/Geometry/VeryForwardData/python/cmsExtendedGeometry2021XML_cfi.py b/Geometry/VeryForwardData/python/cmsExtendedGeometry2021XML_cfi.py index 09e627234f5d7..deab27a6f6941 100644 --- a/Geometry/VeryForwardData/python/cmsExtendedGeometry2021XML_cfi.py +++ b/Geometry/VeryForwardData/python/cmsExtendedGeometry2021XML_cfi.py @@ -346,12 +346,12 @@ 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/Simu/v1/CTPPS_Detectors_Assembly_122.xml', 'Geometry/VeryForwardData/data/CTPPS_Diamond_Sensitive_Dets_TimingHits.xml', 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/ppstrackerMaterials.xml', - 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/PPS_Pixel_Module_2x2_Run3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml', 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/PPS_Pixel_Sens.xml', - 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v1/CTPPS_Pixel_Assembly_Box_Real_003.xml', - 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v1/CTPPS_Pixel_Assembly_Box_Real_023.xml', - 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v1/CTPPS_Pixel_Assembly_Box_Real_103.xml', - 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v1/CTPPS_Pixel_Assembly_Box_Real_123.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml', 'Geometry/VeryForwardData/data/CTPPS_2021/RP_Dist_Beam_Cent/Simu/v1/RP_Dist_Beam_Cent.xml', 'Geometry/EcalSimData/data/ecalsens.xml', 'Geometry/HcalCommonData/data/hcalsens/2021/v1/hcalsenspmf.xml', diff --git a/Geometry/VeryForwardGeometry/data/dd4hep/v3/geometryRPFromDD_2021.xml b/Geometry/VeryForwardGeometry/data/dd4hep/v3/geometryRPFromDD_2021.xml new file mode 100644 index 0000000000000..85ecb9391b0f4 --- /dev/null +++ b/Geometry/VeryForwardGeometry/data/dd4hep/v3/geometryRPFromDD_2021.xml @@ -0,0 +1,127 @@ + + + + + + + # common and strip files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # diamond files + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Totem Timing files + + + + + + + # pixel files + + + + + + + + + # RP distance + + + + diff --git a/Geometry/VeryForwardGeometry/python/dd4hep/v3/geometryRPFromDD_2021_cfi.py b/Geometry/VeryForwardGeometry/python/dd4hep/v3/geometryRPFromDD_2021_cfi.py new file mode 100644 index 0000000000000..bc2f4549850d9 --- /dev/null +++ b/Geometry/VeryForwardGeometry/python/dd4hep/v3/geometryRPFromDD_2021_cfi.py @@ -0,0 +1,18 @@ +import FWCore.ParameterSet.Config as cms + +DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('Geometry/VeryForwardGeometry/data/dd4hep/v3/geometryRPFromDD_2021.xml'), + appendToDataLabel = cms.string('XMLIdealGeometryESSource_CTPPS') +) + +DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer", + appendToDataLabel = cms.string('XMLIdealGeometryESSource_CTPPS') +) + +ctppsGeometryESModule = cms.ESProducer("CTPPSGeometryESModule", + fromDD4hep = cms.untracked.bool(True), + isRun2 = cms.bool(False), + verbosity = cms.untracked.uint32(1), + compactViewTag = cms.string('XMLIdealGeometryESSource_CTPPS') +) + diff --git a/Geometry/VeryForwardGeometry/python/v1/geometryRPFromDD_2021_cfi.py b/Geometry/VeryForwardGeometry/python/v1/geometryRPFromDD_2021_cfi.py new file mode 100644 index 0000000000000..e283ad5c78756 --- /dev/null +++ b/Geometry/VeryForwardGeometry/python/v1/geometryRPFromDD_2021_cfi.py @@ -0,0 +1,142 @@ +import FWCore.ParameterSet.Config as cms + +# common and strip files +totemGeomXMLFiles = cms.vstring( + 'Geometry/CMSCommonData/data/materials.xml', + 'Geometry/CMSCommonData/data/rotations.xml', + 'Geometry/CMSCommonData/data/extend/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms/2017/v1/cms.xml', + 'Geometry/CMSCommonData/data/beampipe/2017/v1/beampipe.xml', + 'Geometry/CMSCommonData/data/cmsBeam.xml', + 'Geometry/CMSCommonData/data/cmsMother.xml', + 'Geometry/CMSCommonData/data/mgnt.xml', + 'Geometry/TrackerCommonData/data/trackermaterial/2021/v1/trackermaterial.xml', + 'Geometry/TrackerCommonData/data/pixfwdMaterials/2021/v2/pixfwdMaterials.xml', + 'Geometry/ForwardCommonData/data/forward.xml', + 'Geometry/ForwardCommonData/data/totemRotations.xml', + 'Geometry/ForwardCommonData/data/totemMaterials.xml', + 'Geometry/VeryForwardData/data/RP_Box.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_000.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_001.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_002.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_003.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_004.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_005.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_020.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_021.xml', +# 'Geometry/VeryForwardData/data/RP_Boxv3//RP_Box_022.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_023.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_024.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_025.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_100.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_101.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_102.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_103.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_104.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_105.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_120.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_121.xml', +# 'Geometry/VeryForwardData/data/RP_Boxv3//RP_Box_122.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_123.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_124.xml', + 'Geometry/VeryForwardData/data/RP_Box/v3/RP_Box_125.xml', + 'Geometry/VeryForwardData/data/RP_Hybrid/v2/RP_Hybrid.xml', + 'Geometry/VeryForwardData/data/RP_Materials/v4/RP_Materials.xml', + 'Geometry/VeryForwardData/data/RP_Transformations.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_000.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_001.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_002.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_004.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_005.xml', +# 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_022.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_024.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_025.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_100.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_101.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_102.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_104.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_105.xml', +# 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_122.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_124.xml', + 'Geometry/VeryForwardData/data/RP_Detectors_Assembly/RP_Detectors_Assembly_125.xml', + 'Geometry/VeryForwardData/data/RP_Device.xml', + 'Geometry/VeryForwardData/data/RP_Vertical_Device/2021/Reco/v2/RP_Vertical_Device.xml', + 'Geometry/VeryForwardData/data/RP_Horizontal_Device/2021/Reco/v2/RP_Horizontal_Device.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Right_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Right_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_220_Left_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v2/RP_210_Left_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Stations/Reco/v1/RP_Stations_Assembly.xml', + + 'Geometry/VeryForwardData/data/RP_Sensitive_Dets.xml', + 'Geometry/VeryForwardData/data/CTPPS_2021/Cuts_Per_Region/Reco/v1/RP_Cuts_Per_Region.xml', + + 'Geometry/VeryForwardData/data/CTPPS_2021/RP_Param_Beam_Region/v1/RP_Param_Beam_Region.xml' + ) + +# diamond files +ctppsDiamondGeomXMLFiles = cms.vstring( + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Materials.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Transformations.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_X_Distance.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Parameters.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Station_Parameters.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Horizontal_Pot/v2/CTPPS_Timing_Horizontal_Pot.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Positive_Station/v1/CTPPS_Timing_Positive_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_Timing_Negative_Station/v1/CTPPS_Timing_Negative_Station.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/Reco/v1/CTPPS_Timing_Stations_Assembly.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern1_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern2_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern2_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern3_Segment4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_Segments/CTPPS_Diamond_Pattern4_Segment5.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane1.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane2.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml', + 'Geometry/VeryForwardData/data/CTPPS_Diamond_2021/CTPPS_Diamond_Detector_Assembly/v1/CTPPS_Diamond_Detector_Assembly.xml' + ) + + +# Totem Timing files +totemTimingGeomXMLFiles = cms.vstring( + # UFSDetectors + 'Geometry/VeryForwardData/data/TotemTiming/TotemTiming_Dist_Beam_Cent.xml', + 'Geometry/VeryForwardData/data/TotemTiming/TotemTiming_DetectorAssembly.xml', + 'Geometry/VeryForwardData/data/TotemTiming/TotemTiming_Parameters.xml', + 'Geometry/VeryForwardData/data/TotemTiming/TotemTiming_Plane.xml', + 'Geometry/VeryForwardData/data/TotemTiming/TotemTiming_Station.xml', + ) + +# pixel files +ctppsPixelGeomXMLFiles = cms.vstring( + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/ppstrackerMaterials.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v3/PPS_Pixel_Module_2x2_Run3.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Modules/v2/PPS_Pixel_Sens.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_003.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_023.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_103.xml', + 'Geometry/VeryForwardData/data/CTPPS_Pixel_2021/Assembly/v2/CTPPS_Pixel_Assembly_Box_Real_123.xml' + ) + +XMLIdealGeometryESSource_CTPPS = cms.ESSource("XMLIdealGeometryESSource", + geomXMLFiles = totemGeomXMLFiles + ctppsDiamondGeomXMLFiles + totemTimingGeomXMLFiles + ctppsPixelGeomXMLFiles, + rootNodeName = cms.string('cms:CMSE') + ) + +# position of RPs +XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Geometry/VeryForwardData/data/CTPPS_2021/RP_Dist_Beam_Cent/Reco/v1/RP_Dist_Beam_Cent.xml") + +ctppsGeometryESModule = cms.ESProducer("CTPPSGeometryESModule", + verbosity = cms.untracked.uint32(1), + isRun2 = cms.bool(False), + compactViewTag = cms.string('XMLIdealGeometryESSource_CTPPS') +) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 01b08a9b7a69c..9dcd91c5bfbf5 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -1,5 +1,8 @@ import FWCore.ParameterSet.Config as cms +# modifiers +from Configuration.ProcessModifiers.gpu_cff import gpu + # helper fuctions from HLTrigger.Configuration.common import * @@ -140,6 +143,10 @@ def customiseFor35315(process): # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): + # if the gpu modifier is enabled, make the Pixel, ECAL and HCAL reconstruction offloadable to a GPU + from HLTrigger.Configuration.customizeHLTforPatatrack import customizeHLTforPatatrack + gpu.makeProcessModifier(customizeHLTforPatatrack).apply(process) + # add call to action function in proper order: newest last! # process = customiseFor12718(process) diff --git a/HLTrigger/Configuration/python/customizeHLTforPatatrack.py b/HLTrigger/Configuration/python/customizeHLTforPatatrack.py index d133b2978f46b..b119a7742f1bb 100644 --- a/HLTrigger/Configuration/python/customizeHLTforPatatrack.py +++ b/HLTrigger/Configuration/python/customizeHLTforPatatrack.py @@ -133,51 +133,50 @@ def customisePixelLocalReconstruction(process): src = "hltSiPixelClustersCUDA" ) - # convert the pixel digis errors to the legacy format - from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA - process.hltSiPixelDigiErrors = _siPixelDigiErrorsFromSoA.clone( - digiErrorSoASrc = "hltSiPixelDigiErrorsSoA", - UsePhase1 = True - ) - # copy the pixel digis (except errors) and clusters to the host from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA process.hltSiPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone( src = "hltSiPixelClustersCUDA" ) - # convert the pixel digis (except errors) and clusters to the legacy format - from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA - process.hltSiPixelDigisClusters = _siPixelDigisClustersFromSoA.clone( - src = "hltSiPixelDigisSoA" - ) + # reconstruct the pixel digis on the cpu + process.hltSiPixelDigisLegacy = process.hltSiPixelDigis.clone() - # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA + # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors to the legacy format + from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA process.hltSiPixelDigis = SwitchProducerCUDA( # legacy producer - cpu = process.hltSiPixelDigis, - # alias used to access products from multiple conversion modules - cuda = cms.EDAlias( - hltSiPixelDigisClusters = cms.VPSet( - cms.PSet(type = cms.string("PixelDigiedmDetSetVector")) - ), - hltSiPixelDigiErrors = cms.VPSet( + cpu = cms.EDAlias( + hltSiPixelDigisLegacy = cms.VPSet( cms.PSet(type = cms.string("DetIdedmEDCollection")), cms.PSet(type = cms.string("SiPixelRawDataErroredmDetSetVector")), cms.PSet(type = cms.string("PixelFEDChanneledmNewDetSetVector")) ) + ), + # conversion from SoA to legacy format + cuda = _siPixelDigiErrorsFromSoA.clone( + digiErrorSoASrc = "hltSiPixelDigiErrorsSoA", + UsePhase1 = True ) ) - # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA + # reconstruct the pixel clusters on the cpu + process.hltSiPixelClustersLegacy = process.hltSiPixelClusters.clone() + + # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters to the legacy format + from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA process.hltSiPixelClusters = SwitchProducerCUDA( # legacy producer - cpu = process.hltSiPixelClusters, - # alias used to access products from multiple conversion modules - cuda = cms.EDAlias( - hltSiPixelDigisClusters = cms.VPSet( + cpu = cms.EDAlias( + hltSiPixelClustersLegacy = cms.VPSet( cms.PSet(type = cms.string("SiPixelClusteredmNewDetSetVector")) ) + ), + # conversion from SoA to legacy format + cuda = _siPixelDigisClustersFromSoA.clone( + src = "hltSiPixelDigisSoA", + produceDigis = False, + storeDigis = False, ) ) @@ -193,7 +192,7 @@ def customisePixelLocalReconstruction(process): process.hltSiPixelRecHits = SwitchProducerCUDA( # legacy producer cpu = process.hltSiPixelRecHits, - # converter to legacy format + # conversion from SoA to legacy format cuda = _siPixelRecHitFromCUDA.clone( pixelRecHitSrc = "hltSiPixelRecHitsCUDA", src = "hltSiPixelClusters" @@ -208,11 +207,11 @@ def customisePixelLocalReconstruction(process): process.hltSiPixelClustersCUDA, # reconstruct the pixel digis and clusters on the gpu process.hltSiPixelRecHitsCUDA, # reconstruct the pixel rechits on the gpu process.hltSiPixelDigisSoA, # copy the pixel digis (except errors) and clusters to the host - process.hltSiPixelDigisClusters, # convert the pixel digis (except errors) and clusters to the legacy format process.hltSiPixelDigiErrorsSoA, # copy the pixel digis errors to the host - process.hltSiPixelDigiErrors, # convert the pixel digis errors to the legacy format - process.hltSiPixelDigis, # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA - process.hltSiPixelClusters, # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA + process.hltSiPixelDigisLegacy, # legacy pixel digis producer + process.hltSiPixelDigis, # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors from SoA + process.hltSiPixelClustersLegacy, # legacy pixel cluster producer + process.hltSiPixelClusters, # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters from SoA process.hltSiPixelClustersCache, # legacy module, used by the legacy pixel quadruplet producer process.hltSiPixelRecHits) # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA diff --git a/IOMC/ParticleGuns/interface/BaseFlatGunProducer.h b/IOMC/ParticleGuns/interface/BaseFlatGunProducer.h index 4c8d015f1ea15..65010ddc30012 100644 --- a/IOMC/ParticleGuns/interface/BaseFlatGunProducer.h +++ b/IOMC/ParticleGuns/interface/BaseFlatGunProducer.h @@ -32,6 +32,8 @@ namespace edm { void endRunProduce(edm::Run& r, const edm::EventSetup&) override; private: + const ESGetToken fPDGTableToken; + protected: // non-virtuals ! this and only way ! // diff --git a/IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h b/IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h index 1054d63134bad..1804c253bac62 100644 --- a/IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h +++ b/IOMC/ParticleGuns/interface/BaseRandomtXiGunProducer.h @@ -32,6 +32,8 @@ namespace edm { void endRunProduce(edm::Run& r, const edm::EventSetup&) override; private: + const ESGetToken fPDGTableToken; + protected: // non-virtuals ! this and only way ! // diff --git a/IOMC/ParticleGuns/interface/FlatBaseThetaGunProducer.h b/IOMC/ParticleGuns/interface/FlatBaseThetaGunProducer.h index f3fdd9843c408..409702f65cf7d 100644 --- a/IOMC/ParticleGuns/interface/FlatBaseThetaGunProducer.h +++ b/IOMC/ParticleGuns/interface/FlatBaseThetaGunProducer.h @@ -27,6 +27,8 @@ namespace edm { void endRunProduce(edm::Run& r, const edm::EventSetup&) override; private: + const ESGetToken fPDGTableToken; + protected: // non-virtuals ! this and only way ! // diff --git a/IOMC/ParticleGuns/src/BaseFlatGunProducer.cc b/IOMC/ParticleGuns/src/BaseFlatGunProducer.cc index a8af2b9cc32cb..fdcc95fd1b6de 100644 --- a/IOMC/ParticleGuns/src/BaseFlatGunProducer.cc +++ b/IOMC/ParticleGuns/src/BaseFlatGunProducer.cc @@ -27,7 +27,8 @@ using namespace std; using namespace CLHEP; BaseFlatGunProducer::BaseFlatGunProducer(const ParameterSet& pset) - : fEvt(nullptr) + : fPDGTableToken(esConsumes()), + fEvt(nullptr) // fPDGTable( new DefaultConfig::ParticleDataTable("PDG Table") ) { Service rng; @@ -84,7 +85,7 @@ BaseFlatGunProducer::~BaseFlatGunProducer() { } void BaseFlatGunProducer::beginRun(const edm::Run& r, const EventSetup& es) { - es.getData(fPDGTable); + fPDGTable = es.getHandle(fPDGTableToken); return; } void BaseFlatGunProducer::endRun(const Run& run, const EventSetup& es) {} diff --git a/IOMC/ParticleGuns/src/BaseRandomtXiGunProducer.cc b/IOMC/ParticleGuns/src/BaseRandomtXiGunProducer.cc index 0fa6e9c1b1e82..07cffa59df250 100644 --- a/IOMC/ParticleGuns/src/BaseRandomtXiGunProducer.cc +++ b/IOMC/ParticleGuns/src/BaseRandomtXiGunProducer.cc @@ -28,7 +28,8 @@ using namespace edm; using namespace std; using namespace CLHEP; -BaseRandomtXiGunProducer::BaseRandomtXiGunProducer(const edm::ParameterSet& pset) : fEvt(nullptr) { +BaseRandomtXiGunProducer::BaseRandomtXiGunProducer(const edm::ParameterSet& pset) + : fPDGTableToken(esConsumes()), fEvt(nullptr) { Service rng; if (!rng.isAvailable()) { throw cms::Exception("Configuration") @@ -60,7 +61,7 @@ BaseRandomtXiGunProducer::BaseRandomtXiGunProducer(const edm::ParameterSet& pset BaseRandomtXiGunProducer::~BaseRandomtXiGunProducer() {} void BaseRandomtXiGunProducer::beginRun(const edm::Run& r, const EventSetup& es) { - es.getData(fPDGTable); + fPDGTable = es.getHandle(fPDGTableToken); return; } diff --git a/IOMC/ParticleGuns/src/FlatBaseThetaGunProducer.cc b/IOMC/ParticleGuns/src/FlatBaseThetaGunProducer.cc index 2ad0291ab3de2..8c01613cb8175 100644 --- a/IOMC/ParticleGuns/src/FlatBaseThetaGunProducer.cc +++ b/IOMC/ParticleGuns/src/FlatBaseThetaGunProducer.cc @@ -16,7 +16,8 @@ using namespace edm; -FlatBaseThetaGunProducer::FlatBaseThetaGunProducer(const edm::ParameterSet& pset) : fEvt(nullptr) { +FlatBaseThetaGunProducer::FlatBaseThetaGunProducer(const edm::ParameterSet& pset) + : fPDGTableToken(esConsumes()), fEvt(nullptr) { edm::ParameterSet pgun_params = pset.getParameter("PGunParameters"); fPartIDs = pgun_params.getParameter >("PartID"); @@ -41,7 +42,9 @@ FlatBaseThetaGunProducer::FlatBaseThetaGunProducer(const edm::ParameterSet& pset FlatBaseThetaGunProducer::~FlatBaseThetaGunProducer() {} -void FlatBaseThetaGunProducer::beginRun(const edm::Run& r, const edm::EventSetup& es) { es.getData(fPDGTable); } +void FlatBaseThetaGunProducer::beginRun(const edm::Run& r, const edm::EventSetup& es) { + fPDGTable = es.getHandle(fPDGTableToken); +} void FlatBaseThetaGunProducer::endRun(const Run& run, const EventSetup& es) {} void FlatBaseThetaGunProducer::endRunProduce(Run& run, const EventSetup& es) { diff --git a/IORawData/CSCCommissioning/src/CSCFileDumper.cc b/IORawData/CSCCommissioning/src/CSCFileDumper.cc index ea1a418e4839f..a97d224ae3bb2 100644 --- a/IORawData/CSCCommissioning/src/CSCFileDumper.cc +++ b/IORawData/CSCCommissioning/src/CSCFileDumper.cc @@ -20,7 +20,7 @@ #include #include -CSCFileDumper::CSCFileDumper(const edm::ParameterSet &pset) { +CSCFileDumper::CSCFileDumper(edm::ParameterSet const &pset) { i_token = consumes(pset.getParameter("source")); // source_ = pset.getUntrackedParameter("source","rawDataCollector"); output = pset.getUntrackedParameter("output"); diff --git a/IORawData/CSCCommissioning/src/CSCFileDumper.h b/IORawData/CSCCommissioning/src/CSCFileDumper.h index 5a700a60772aa..44ad010fdfbec 100644 --- a/IORawData/CSCCommissioning/src/CSCFileDumper.h +++ b/IORawData/CSCCommissioning/src/CSCFileDumper.h @@ -1,7 +1,7 @@ -#ifndef CSCFileDumper_h -#define CSCFileDumper_h +#ifndef IORawData_CSCCommissioning_CSCFileDumper_h +#define IORawData_CSCCommissioning_CSCFileDumper_h -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -11,7 +11,7 @@ #include -class CSCFileDumper : public edm::EDAnalyzer { +class CSCFileDumper : public edm::one::EDAnalyzer<> { public: std::map dump_files; std::set eventsToDump; @@ -20,10 +20,12 @@ class CSCFileDumper : public edm::EDAnalyzer { std::string output, events; // int fedID_first, fedID_last; - CSCFileDumper(const edm::ParameterSet& pset); + CSCFileDumper(edm::ParameterSet const& pset); ~CSCFileDumper(void) override; + void beginJob() override{}; void analyze(const edm::Event& e, const edm::EventSetup& c) override; + void endJob() override{}; private: std::vector cscFEDids; diff --git a/IORawData/CSCCommissioning/test/dumpTest.py b/IORawData/CSCCommissioning/test/dumpTest.py index 144b76391e66e..2071f9a73c91b 100644 --- a/IORawData/CSCCommissioning/test/dumpTest.py +++ b/IORawData/CSCCommissioning/test/dumpTest.py @@ -3,7 +3,7 @@ process = cms.Process("TEST") process.load("FWCore.MessageLogger.MessageLogger_cfi") -process.MessageLogger.cout.placeholder = cms.untracked.bool(False) +#process.MessageLogger.cout.placeholder = cms.untracked.bool(False) process.MessageLogger.cout.threshold = cms.untracked.string('INFO') process.MessageLogger.debugModules = cms.untracked.vstring('*') diff --git a/L1Trigger/L1TMuonOverlap/src/GhostBuster.cc b/L1Trigger/L1TMuonOverlap/src/GhostBuster.cc index 3558a6790bdfa..a1d1946c37569 100644 --- a/L1Trigger/L1TMuonOverlap/src/GhostBuster.cc +++ b/L1Trigger/L1TMuonOverlap/src/GhostBuster.cc @@ -1,5 +1,6 @@ #include "L1Trigger/L1TMuonOverlap/interface/GhostBuster.h" +#include #include #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc b/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc index 177aaa58a49ee..c1ccba0558c0a 100644 --- a/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc +++ b/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc @@ -1,5 +1,6 @@ #include "L1Trigger/L1TMuonOverlap/interface/GhostBusterPreferRefDt.h" +#include #include #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h b/RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h index 748beb80134ff..55824812654f5 100644 --- a/RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h +++ b/RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h @@ -16,6 +16,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h" +#include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "RecoMuon/TrackerSeedGenerator/interface/RedundantSeedCleaner.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" @@ -47,6 +48,7 @@ class TrackerSeedCleaner { usePt_Cleaner = pset.getParameter("ptCleaner"); cleanBySharedHits = pset.getParameter("cleanerFromSharedHits"); beamspotToken_ = iC.consumes(theBeamSpotTag); + theTTRHBuilderToken = iC.esConsumes(edm::ESInputTag("", builderName_)); } ///intizialization @@ -70,6 +72,7 @@ class TrackerSeedCleaner { std::string builderName_; edm::ESHandle theTTRHBuilder; + edm::ESGetToken theTTRHBuilderToken; bool useDirection_Cleaner, usePt_Cleaner, cleanBySharedHits; }; diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.cc b/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.cc index 611c97465479b..f48d10b07839c 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.cc +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.cc @@ -23,7 +23,8 @@ #include #include "TrackingTools/GeomPropagators/interface/StateOnTrackerBound.h" -TSGForRoadSearch::TSGForRoadSearch(const edm::ParameterSet &par, edm::ConsumesCollector &iC) { +TSGForRoadSearch::TSGForRoadSearch(const edm::ParameterSet &par, edm::ConsumesCollector &iC) + : theGeometricSearchTrackerToken(iC.esConsumes()) { theOption = par.getParameter("option"); theCopyMuonRecHit = par.getParameter("copyMuonRecHit"); @@ -69,13 +70,7 @@ void TSGForRoadSearch::init(const MuonServiceProxy *service) { theProxyService = void TSGForRoadSearch::setEvent(const edm::Event &event) { //get the measurementtracker - if (theManySeeds) { - theProxyService->eventSetup().get().get(theMeasurementTracker); - if (!theMeasurementTracker.isValid()) /*abort*/ { - edm::LogError(theCategory) << "measurement tracker geometry not found "; - } - } - theProxyService->eventSetup().get().get(theGeometricSearchTracker); + theGeometricSearchTracker = theProxyService->eventSetup().getHandle(theGeometricSearchTrackerToken); edm::Handle data; event.getByToken(theMeasurementTrackerEventToken, data); diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.h b/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.h index eef9a85b6ba54..b9bb2f3a5b52a 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.h +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGForRoadSearch.h @@ -41,6 +41,7 @@ class TrackingRegion; class MuonServiceProxy; class TrajectoryStateUpdator; class TrackerTopology; +class TrackerRecoGeometryRecord; class TSGForRoadSearch : public TrackerSeedGenerator { public: @@ -88,8 +89,8 @@ class TSGForRoadSearch : public TrackerSeedGenerator { std::vector &result) const; edm::ParameterSet theConfig; - edm::ESHandle theMeasurementTracker; edm::ESHandle theGeometricSearchTracker; + edm::ESGetToken theGeometricSearchTrackerToken; edm::InputTag theMeasurementTrackerEventTag; edm::EDGetTokenT theMeasurementTrackerEventToken; @@ -102,9 +103,7 @@ class TSGForRoadSearch : public TrackerSeedGenerator { bool theCopyMuonRecHit; bool theManySeeds; std::string thePropagatorName; - edm::ESHandle theProp; std::string thePropagatorCompatibleName; - edm::ESHandle thePropCompatible; Chi2MeasurementEstimator *theChi2Estimator; std::string theCategory; diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc index 684de272ea147..2fd0c81c68ed5 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc @@ -42,6 +42,8 @@ TSGFromL2Muon::TSGFromL2Muon(const edm::ParameterSet& cfg) { //L2 collection theL2CollectionLabel = cfg.getParameter("MuonCollectionLabel"); l2muonToken = consumes(theL2CollectionLabel); + + theTTopoToken = esConsumes(); } TSGFromL2Muon::~TSGFromL2Muon() = default; @@ -59,9 +61,7 @@ void TSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) { auto result = std::make_unique(); //Retrieve tracker topology from geometry - edm::ESHandle tTopoHand; - es.get().get(tTopoHand); - const TrackerTopology* tTopo = tTopoHand.product(); + const TrackerTopology* tTopo = &es.getData(theTTopoToken); //intialize tools theService->update(es); diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.h b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.h index 6544b32737cea..a701fbe33ceb9 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.h +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.h @@ -17,6 +17,7 @@ class MuonServiceProxy; class TrackerSeedGenerator; class MuonTrackingRegionBuilder; class TrackerSeedCleaner; +class TrackerTopologyRcd; // // Generate tracker seeds from L2 muons @@ -37,5 +38,6 @@ class TSGFromL2Muon : public edm::stream::EDProducer<> { std::unique_ptr theTkSeedGenerator; std::unique_ptr theSeedCleaner; edm::EDGetTokenT l2muonToken; + edm::ESGetToken theTTopoToken; }; #endif diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.cc b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.cc index 28b03405f1051..eb1d3622bcd66 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.cc +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.cc @@ -33,7 +33,6 @@ TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC, const MuonServiceProxy* service) : theCategory("Muon|RecoMuon|TSGFromPropagation"), - theMeasTrackerName(iConfig.getParameter("MeasurementTrackerName")), theService(service), theMaxChi2(iConfig.getParameter("MaxChi2")), theFixedErrorRescaling(iConfig.getParameter("ErrorRescaling")), @@ -61,7 +60,8 @@ TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet& iConfig, theErrorMatrixPset(iConfig.getParameter("errorMatrixPset")), theBeamSpotToken(iC.consumes(iConfig.getParameter("beamSpot"))), theMeasurementTrackerEventToken( - iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))) {} + iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))), + theTrackerToken(iC.esConsumes()) {} TSGFromPropagation::~TSGFromPropagation() { LogTrace(theCategory) << " TSGFromPropagation dtor called "; } @@ -157,8 +157,6 @@ void TSGFromPropagation::init(const MuonServiceProxy* service) { theEstimator = std::make_unique(theMaxChi2); - theCacheId_MT = 0; - theCacheId_TG = 0; theService = service; @@ -168,38 +166,21 @@ void TSGFromPropagation::init(const MuonServiceProxy* service) { if (theResetMethod == ResetMethod::matrix && !theErrorMatrixPset.empty()) { theErrorMatrixAdjuster = std::make_unique(theErrorMatrixPset); } - - theService->eventSetup().get().get(theTracker); - theNavigation = std::make_unique(theTracker); } void TSGFromPropagation::setEvent(const edm::Event& iEvent) { iEvent.getByToken(theBeamSpotToken, beamSpot); - unsigned long long newCacheId_MT = theService->eventSetup().get().cacheIdentifier(); - - if (theUpdateStateFlag && newCacheId_MT != theCacheId_MT) { - LogTrace(theCategory) << "Measurment Tracker Geometry changed!"; - theCacheId_MT = newCacheId_MT; - theService->eventSetup().get().get(theMeasTrackerName, theMeasTracker); - } - if (theUpdateStateFlag) { iEvent.getByToken(theMeasurementTrackerEventToken, theMeasTrackerEvent); } - bool trackerGeomChanged = false; - unsigned long long newCacheId_TG = theService->eventSetup().get().cacheIdentifier(); if (newCacheId_TG != theCacheId_TG) { LogTrace(theCategory) << "Tracker Reco Geometry changed!"; theCacheId_TG = newCacheId_TG; - theService->eventSetup().get().get(theTracker); - trackerGeomChanged = true; - } - - if (trackerGeomChanged && (theTracker.product() != nullptr)) { + edm::ESHandle theTracker = theService->eventSetup().getHandle(theTrackerToken); theNavigation = std::make_unique(theTracker); } } diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h index 584806bd8a8e8..d4c35c52f7f52 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h @@ -29,6 +29,7 @@ class GeometricSearchTracker; class DirectTrackerNavigation; struct TrajectoryStateTransform; class TrackerTopology; +class TrackerRecoGeometryRecord; class TSGFromPropagation : public TrackerSeedGenerator { public: @@ -105,15 +106,10 @@ class TSGFromPropagation : public TrackerSeedGenerator { } }; - unsigned long long theCacheId_MT; unsigned long long theCacheId_TG; const std::string theCategory; - edm::ESHandle theTracker; - - const std::string theMeasTrackerName; - edm::ESHandle theMeasTracker; edm::Handle theMeasTrackerEvent; std::unique_ptr theNavigation; @@ -150,6 +146,7 @@ class TSGFromPropagation : public TrackerSeedGenerator { edm::Handle beamSpot; const edm::EDGetTokenT theBeamSpotToken; const edm::EDGetTokenT theMeasurementTrackerEventToken; + const edm::ESGetToken theTrackerToken; }; #endif diff --git a/RecoMuon/TrackerSeedGenerator/src/TrackerSeedCleaner.cc b/RecoMuon/TrackerSeedGenerator/src/TrackerSeedCleaner.cc index 038494b706d04..bc747b9875e3e 100644 --- a/RecoMuon/TrackerSeedGenerator/src/TrackerSeedCleaner.cc +++ b/RecoMuon/TrackerSeedGenerator/src/TrackerSeedCleaner.cc @@ -24,15 +24,12 @@ #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h" -#include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "RecoTracker/TkTrackingRegions/interface/TkTrackingRegionsMargin.h" #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h" #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h" -#include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGeneratorFactory.h" using namespace std; using namespace edm; @@ -61,7 +58,7 @@ void TrackerSeedCleaner::clean(const reco::TrackRef& muR, if (cleanBySharedHits) theRedundantCleaner->define(seeds); - theProxyService->eventSetup().get().get(builderName_, theTTRHBuilder); + theTTRHBuilder = theProxyService->eventSetup().getHandle(theTTRHBuilderToken); LogDebug("TrackerSeedCleaner") << seeds.size() << " trajectory seeds to the events before cleaning" << endl; diff --git a/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h b/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h index 327e0f30e9e59..53271501fed23 100644 --- a/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h +++ b/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h @@ -5,7 +5,6 @@ #include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h" #include "RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h" #include "DataFormats/Common/interface/RangeMap.h" -#include "FWCore/Framework/interface/EventSetup.h" class LayerWithHits; class DetLayer; @@ -20,7 +19,7 @@ class CosmicHitTripletGenerator { typedef std::vector > Container; public: - CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const edm::EventSetup& iSetup); + CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const TrackerGeometry& trackGeom); CosmicHitTripletGenerator(CosmicLayerTriplets& layers); ~CosmicHitTripletGenerator(); @@ -30,9 +29,9 @@ class CosmicHitTripletGenerator { void add(const LayerWithHits* inner, const LayerWithHits* middle, const LayerWithHits* outer, - const edm::EventSetup& iSetup); + const TrackerGeometry& trackGeom); - void hitTriplets(const TrackingRegion& reg, OrderedHitTriplets& prs, const edm::EventSetup& iSetup); + void hitTriplets(const TrackingRegion& reg, OrderedHitTriplets& prs); private: Container theGenerators; diff --git a/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h b/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h index ec0af890622b1..264589063be11 100644 --- a/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h +++ b/RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h @@ -18,17 +18,16 @@ class CosmicHitTripletGeneratorFromLayerTriplet { CosmicHitTripletGeneratorFromLayerTriplet(const LayerWithHits* inner, const LayerWithHits* middle, const LayerWithHits* outer, - const edm::EventSetup& iSetup); + const TrackerGeometry& trackGeom); ~CosmicHitTripletGeneratorFromLayerTriplet() {} - void hitTriplets(const TrackingRegion& ar, OrderedHitTriplets& ap, const edm::EventSetup& iSetup); + void hitTriplets(const TrackingRegion& ar, OrderedHitTriplets& ap); const LayerWithHits* innerLayer() const { return theInnerLayer; } const LayerWithHits* middleLayer() const { return theMiddleLayer; } const LayerWithHits* outerLayer() const { return theOuterLayer; } private: - const TransientTrackingRecHitBuilder* TTRHbuilder; const TrackerGeometry* trackerGeometry; const LayerWithHits* theOuterLayer; const LayerWithHits* theMiddleLayer; diff --git a/RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h b/RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h index 23e64e50fd206..62c072dd09a0c 100644 --- a/RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h +++ b/RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h @@ -6,8 +6,6 @@ */ #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" #include "DataFormats/Common/interface/RangeMap.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESWatcher.h" #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h" #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h" #include "RecoTracker/TkHitPairs/interface/LayerWithHits.h" @@ -18,12 +16,18 @@ #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" -#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" +class GeometricSearchTracker; +class TrackerTopology; #include class CosmicLayerTriplets { public: - CosmicLayerTriplets(){}; + CosmicLayerTriplets(std::string geometry, + const SiStripRecHit2DCollection &collrphi, + const GeometricSearchTracker &track, + const TrackerTopology &ttopo) { + init(collrphi, std::move(geometry), track, ttopo); + }; ~CosmicLayerTriplets(); // explicit PixelSeedLayerPairs(const edm::EventSetup& iSetup); typedef std::pair > LayerPairAndLayers; @@ -40,18 +44,14 @@ class CosmicLayerTriplets { LayerWithHits *lh3; LayerWithHits *lh4; - edm::ESWatcher watchTrackerGeometry_; - std::vector bl; //MP std::vector allLayersWithHits; -public: - void init(const SiStripRecHit2DCollection &collstereo, - const SiStripRecHit2DCollection &collrphi, - const SiStripMatchedRecHit2DCollection &collmatched, + void init(const SiStripRecHit2DCollection &collrphi, std::string geometry, - const edm::EventSetup &iSetup); + const GeometricSearchTracker &track, + const TrackerTopology &ttopo); private: std::string _geometry; diff --git a/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGenerator.cc b/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGenerator.cc index 1eca20a664826..b9689d04956e2 100644 --- a/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGenerator.cc +++ b/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGenerator.cc @@ -6,7 +6,7 @@ using namespace std; -CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const edm::EventSetup& iSetup) { +CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const TrackerGeometry& trackGeom) { // vector layerTriplets = layers(); vector layerTriplets = layers.layers(); vector::const_iterator it; @@ -17,7 +17,7 @@ CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers // const LayerWithHits* second=(*it).first.second; // const LayerWithHits* third=(*ilwh); // add( (*it).first.first, (*it).first.second, (*it).second,iSetup); - add((*it).first.first, (*it).first.second, (*ilwh), iSetup); + add((*it).first.first, (*it).first.second, (*ilwh), trackGeom); } } } @@ -27,15 +27,13 @@ CosmicHitTripletGenerator::~CosmicHitTripletGenerator() {} void CosmicHitTripletGenerator::add(const LayerWithHits* inner, const LayerWithHits* middle, const LayerWithHits* outer, - const edm::EventSetup& iSetup) { - theGenerators.push_back(std::make_unique(inner, middle, outer, iSetup)); + const TrackerGeometry& trackGeom) { + theGenerators.push_back(std::make_unique(inner, middle, outer, trackGeom)); } -void CosmicHitTripletGenerator::hitTriplets(const TrackingRegion& region, - OrderedHitTriplets& pairs, - const edm::EventSetup& iSetup) { +void CosmicHitTripletGenerator::hitTriplets(const TrackingRegion& region, OrderedHitTriplets& pairs) { Container::const_iterator i; for (i = theGenerators.begin(); i != theGenerators.end(); i++) { - (**i).hitTriplets(region, pairs, iSetup); + (**i).hitTriplets(region, pairs); } } diff --git a/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGeneratorFromLayerTriplet.cc b/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGeneratorFromLayerTriplet.cc index 8cafa3803701f..e6de0ecfb7dc4 100644 --- a/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGeneratorFromLayerTriplet.cc +++ b/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGeneratorFromLayerTriplet.cc @@ -2,12 +2,8 @@ #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h" #include "TrackingTools/DetLayers/interface/DetLayer.h" #include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h" -#include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include @@ -16,20 +12,13 @@ typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit; CosmicHitTripletGeneratorFromLayerTriplet::CosmicHitTripletGeneratorFromLayerTriplet(const LayerWithHits *inner, const LayerWithHits *middle, const LayerWithHits *outer, - const edm::EventSetup &iSetup) - : TTRHbuilder(nullptr), - trackerGeometry(nullptr), + const TrackerGeometry &trackGeom) + : trackerGeometry(&trackGeom), //theLayerCache(*layerCache), theOuterLayer(outer), theMiddleLayer(middle), - theInnerLayer(inner) { - edm::ESHandle tracker; - iSetup.get().get(tracker); - trackerGeometry = tracker.product(); -} -void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion ®ion, - OrderedHitTriplets &result, - const edm::EventSetup &iSetup) { + theInnerLayer(inner) {} +void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &result) { if (theInnerLayer->recHits().empty()) return; if (theMiddleLayer->recHits().empty()) @@ -44,10 +33,6 @@ void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion std::vector::const_iterator mhh; std::vector::const_iterator ihh; - std::string builderName = "WithTrackAngle"; - edm::ESHandle builder; - iSetup.get().get(builderName, builder); - if (!seedfromoverlaps) { for (ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) { auto oh = (BaseTrackerRecHit const *)(&*ohh); diff --git a/RecoPixelVertexing/PixelTriplets/src/CosmicLayerTriplets.cc b/RecoPixelVertexing/PixelTriplets/src/CosmicLayerTriplets.cc index 0efa73ded159c..2799a9fb26d2f 100644 --- a/RecoPixelVertexing/PixelTriplets/src/CosmicLayerTriplets.cc +++ b/RecoPixelVertexing/PixelTriplets/src/CosmicLayerTriplets.cc @@ -53,21 +53,12 @@ CosmicLayerTriplets::~CosmicLayerTriplets() { } } -void CosmicLayerTriplets::init(const SiStripRecHit2DCollection& collstereo, - const SiStripRecHit2DCollection& collrphi, - const SiStripMatchedRecHit2DCollection& collmatched, +void CosmicLayerTriplets::init(const SiStripRecHit2DCollection& collrphi, std::string geometry, - const edm::EventSetup& iSetup) { - _geometry = geometry; - if (watchTrackerGeometry_.check(iSetup)) { - edm::ESHandle track; - iSetup.get().get(track); - bl = track->barrelLayers(); - } - edm::ESHandle httopo; - iSetup.get().get(httopo); - const TrackerTopology& ttopo = *httopo; - + const GeometricSearchTracker& track, + const TrackerTopology& ttopo) { + _geometry = std::move(geometry); + bl = track.barrelLayers(); for (vector::const_iterator it = allLayersWithHits.begin(); it != allLayersWithHits.end(); it++) { delete *it; } diff --git a/RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCosmics.h b/RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCosmics.h index 98a64d1fc9303..b9d5ddcd994bc 100644 --- a/RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCosmics.h +++ b/RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCosmics.h @@ -9,6 +9,7 @@ #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" //#include "RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorFromLayerPairs.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" @@ -22,21 +23,28 @@ #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" #include "RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h" class PixelSeedLayerPairs; +class GeometricSearchTracker; +class TrackerRecoGeometryRecord; class SeedGeneratorForCosmics { public: typedef TrajectoryStateOnSurface TSOS; - SeedGeneratorForCosmics(const edm::ParameterSet &conf); - virtual ~SeedGeneratorForCosmics(){}; + SeedGeneratorForCosmics(const edm::ParameterSet &conf, edm::ConsumesCollector); + + void run(const SiStripRecHit2DCollection &collstereo, + const SiStripRecHit2DCollection &collrphi, + const SiStripMatchedRecHit2DCollection &collmatched, + const edm::EventSetup &c, + TrajectorySeedCollection &); + +private: void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const edm::EventSetup &c); - void run(TrajectorySeedCollection &, const edm::EventSetup &c); - bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &c, const TrackingRegion ®ion); + bool seeds(TrajectorySeedCollection &output, const TrackingRegion ®ion); -private: int32_t maxSeeds_; GlobalTrackingRegion region; CosmicHitPairGenerator *thePairGenerator; @@ -44,11 +52,14 @@ class SeedGeneratorForCosmics { edm::ESHandle magfield; edm::ESHandle tracker; + const edm::ESGetToken theMagfieldToken; + const edm::ESGetToken theTrackerToken; + const edm::ESGetToken theSearchTrackerToken; + const edm::ESGetToken theTTopoToken; + KFUpdator *theUpdator; PropagatorWithMaterial *thePropagatorAl; PropagatorWithMaterial *thePropagatorOp; - const TransientTrackingRecHitBuilder *TTTRHBuilder; - std::string builderName; std::string geometry; std::string hitsforseeds; float seedpt; diff --git a/RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc b/RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc index ed557a17f8989..c84b74fcfec16 100644 --- a/RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc +++ b/RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc @@ -15,7 +15,7 @@ using namespace std; CosmicSeedGenerator::CosmicSeedGenerator(edm::ParameterSet const& conf) - : cosmic_seed(conf), + : cosmic_seed(conf, consumesCollector()), check(conf, consumesCollector()) { @@ -45,10 +45,8 @@ void CosmicSeedGenerator::produce(edm::Event& ev, const edm::EventSetup& es) { //check on the number of clusters size_t clustsOrZero = check.tooManyClusters(ev); if (!clustsOrZero) { - cosmic_seed.init(*stereorecHits, *rphirecHits, *matchedrecHits, es); - // invoke the seed finding algorithm - cosmic_seed.run(*output, es); + cosmic_seed.run(*stereorecHits, *rphirecHits, *matchedrecHits, es, *output); } else edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n"; diff --git a/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc b/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc index 5ea1475c38907..4b76244f4abdc 100644 --- a/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc +++ b/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc @@ -2,6 +2,7 @@ #include "RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TrackingTools/Records/interface/TransientRecHitRecord.h" +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" void SeedGeneratorForCRack::init(const SiStripRecHit2DCollection& collstereo, const SiStripRecHit2DCollection& collrphi, const SiStripMatchedRecHit2DCollection& collmatched, @@ -18,11 +19,14 @@ void SeedGeneratorForCRack::init(const SiStripRecHit2DCollection& collstereo, iSetup.get().get(builderName, theBuilder); TTTRHBuilder = theBuilder.product(); - CosmicLayerPairs cosmiclayers(geometry); - cosmiclayers.init(collstereo, collrphi, collmatched, iSetup); - thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, iSetup); + edm::ESHandle track; + iSetup.get().get(track); + edm::ESHandle httopo; + iSetup.get().get(httopo); + CosmicLayerPairs cosmiclayers(geometry, collrphi, collmatched, *track, *httopo); + thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, *tracker); HitPairs.clear(); - thePairGenerator->hitPairs(region, HitPairs, iSetup); + thePairGenerator->hitPairs(region, HitPairs); LogDebug("CosmicSeedFinder") << "Initialized with " << HitPairs.size() << " hit pairs" << std::endl; } diff --git a/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCosmics.cc b/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCosmics.cc index fde24fb999b24..f22625e1cef7b 100644 --- a/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCosmics.cc +++ b/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCosmics.cc @@ -5,52 +5,50 @@ #include "FWCore/Utilities/interface/isFinite.h" #include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "RecoTracker/TkSeedGenerator/interface/FastHelix.h" +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" void SeedGeneratorForCosmics::init(const SiStripRecHit2DCollection& collstereo, const SiStripRecHit2DCollection& collrphi, const SiStripMatchedRecHit2DCollection& collmatched, const edm::EventSetup& iSetup) { - iSetup.get().get(magfield); - iSetup.get().get(tracker); + magfield = iSetup.getHandle(theMagfieldToken); + tracker = iSetup.getHandle(theTrackerToken); thePropagatorAl = new PropagatorWithMaterial(alongMomentum, 0.1057, &(*magfield)); thePropagatorOp = new PropagatorWithMaterial(oppositeToMomentum, 0.1057, &(*magfield)); theUpdator = new KFUpdator(); - // get the transient builder - // - - edm::ESHandle theBuilder; - - iSetup.get().get(builderName, theBuilder); - TTTRHBuilder = theBuilder.product(); LogDebug("CosmicSeedFinder") << " Hits built with " << hitsforseeds << " hits"; - CosmicLayerPairs cosmiclayers(geometry); + GeometricSearchTracker const& track = iSetup.getData(theSearchTrackerToken); + TrackerTopology const& ttopo = iSetup.getData(theTTopoToken); - cosmiclayers.init(collstereo, collrphi, collmatched, iSetup); - thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, iSetup); + CosmicLayerPairs cosmiclayers(geometry, collrphi, collmatched, track, ttopo); + + thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, *tracker); HitPairs.clear(); if ((hitsforseeds == "pairs") || (hitsforseeds == "pairsandtriplets")) { - thePairGenerator->hitPairs(region, HitPairs, iSetup); + thePairGenerator->hitPairs(region, HitPairs); } - CosmicLayerTriplets cosmiclayers2; - cosmiclayers2.init(collstereo, collrphi, collmatched, geometry, iSetup); - theTripletGenerator = new CosmicHitTripletGenerator(cosmiclayers2, iSetup); + CosmicLayerTriplets cosmiclayers2(geometry, collrphi, track, ttopo); + theTripletGenerator = new CosmicHitTripletGenerator(cosmiclayers2, *tracker); HitTriplets.clear(); if ((hitsforseeds == "triplets") || (hitsforseeds == "pairsandtriplets")) { - theTripletGenerator->hitTriplets(region, HitTriplets, iSetup); + theTripletGenerator->hitTriplets(region, HitTriplets); } } -SeedGeneratorForCosmics::SeedGeneratorForCosmics(edm::ParameterSet const& conf) - : maxSeeds_(conf.getParameter("maxSeeds")) { +SeedGeneratorForCosmics::SeedGeneratorForCosmics(edm::ParameterSet const& conf, edm::ConsumesCollector iCC) + : maxSeeds_(conf.getParameter("maxSeeds")), + theMagfieldToken(iCC.esConsumes()), + theTrackerToken(iCC.esConsumes()), + theSearchTrackerToken(iCC.esConsumes()), + theTTopoToken(iCC.esConsumes()) { float ptmin = conf.getParameter("ptMin"); float originradius = conf.getParameter("originRadius"); float halflength = conf.getParameter("originHalfLength"); float originz = conf.getParameter("originZPosition"); seedpt = conf.getParameter("SeedPt"); - builderName = conf.getParameter("TTRHBuilder"); geometry = conf.getUntrackedParameter("GeometricStructure", "STANDARD"); region = GlobalTrackingRegion(ptmin, originradius, halflength, originz); hitsforseeds = conf.getUntrackedParameter("HitsForSeeds", "pairs"); @@ -64,17 +62,20 @@ SeedGeneratorForCosmics::SeedGeneratorForCosmics(edm::ParameterSet const& conf) //*** } -void SeedGeneratorForCosmics::run(TrajectorySeedCollection& output, const edm::EventSetup& iSetup) { - seeds(output, iSetup, region); +void SeedGeneratorForCosmics::run(const SiStripRecHit2DCollection& collstereo, + const SiStripRecHit2DCollection& collrphi, + const SiStripMatchedRecHit2DCollection& collmatched, + const edm::EventSetup& c, + TrajectorySeedCollection& output) { + init(collstereo, collrphi, collmatched, c); + seeds(output, region); delete thePairGenerator; delete theTripletGenerator; delete thePropagatorAl; delete thePropagatorOp; delete theUpdator; } -bool SeedGeneratorForCosmics::seeds(TrajectorySeedCollection& output, - const edm::EventSetup& iSetup, - const TrackingRegion& region) { +bool SeedGeneratorForCosmics::seeds(TrajectorySeedCollection& output, const TrackingRegion& region) { LogDebug("CosmicSeedFinder") << "Number of triplets " << HitTriplets.size(); LogDebug("CosmicSeedFinder") << "Number of pairs " << HitPairs.size(); @@ -100,8 +101,6 @@ bool SeedGeneratorForCosmics::seeds(TrajectorySeedCollection& output, ->surface() .toGlobal((*(HitTriplets[it].outer())).localPosition()); - // SeedingHitSet::ConstRecHitPointer outrhit=TTTRHBuilder->build(HitPairs[is].outer()) - SeedingHitSet::ConstRecHitPointer outrhit = HitTriplets[it].outer(); //***top-bottom SeedingHitSet::ConstRecHitPointer innrhit = HitTriplets[it].inner(); @@ -183,7 +182,6 @@ bool SeedGeneratorForCosmics::seeds(TrajectorySeedCollection& output, .toGlobal((*(HitPairs[is].outer())).localPosition()); LogDebug("CosmicSeedFinder") << "inner point of the seed " << inner << " outer point of the seed " << outer; - //RC const TransientTrackingRecHit* outrhit=TTTRHBuilder->build(HitPairs[is].outer().RecHit()); SeedingHitSet::ConstRecHitPointer outrhit = HitPairs[is].outer(); //***top-bottom SeedingHitSet::ConstRecHitPointer innrhit = HitPairs[is].inner(); diff --git a/RecoTracker/TkHitPairs/interface/CosmicHitPairGenerator.h b/RecoTracker/TkHitPairs/interface/CosmicHitPairGenerator.h index d715723cc824c..c35a5f4a45210 100644 --- a/RecoTracker/TkHitPairs/interface/CosmicHitPairGenerator.h +++ b/RecoTracker/TkHitPairs/interface/CosmicHitPairGenerator.h @@ -18,16 +18,16 @@ class CosmicHitPairGenerator { typedef std::vector > Container; public: - CosmicHitPairGenerator(SeedLayerPairs& layers, const edm::EventSetup& iSetup); + CosmicHitPairGenerator(SeedLayerPairs& layers, const TrackerGeometry&); CosmicHitPairGenerator(SeedLayerPairs& layers); ~CosmicHitPairGenerator(); /// add generators based on layers // void add(const DetLayer* inner, const DetLayer* outer); - void add(const LayerWithHits* inner, const LayerWithHits* outer, const edm::EventSetup& iSetup); + void add(const LayerWithHits* inner, const LayerWithHits* outer, const TrackerGeometry& trackGeom); /// form base class - void hitPairs(const TrackingRegion& reg, OrderedHitPairs& prs, const edm::EventSetup& iSetup); + void hitPairs(const TrackingRegion& reg, OrderedHitPairs& pr); private: Container theGenerators; diff --git a/RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h b/RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h index 58e9e921c0904..b7d9eb16d861d 100644 --- a/RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h +++ b/RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h @@ -11,47 +11,21 @@ class DetLayer; class TrackingRegion; class LayerWithHits; -class CompareHitPairsY { -public: - CompareHitPairsY(const edm::EventSetup& iSetup) { iSetup.get().get(tracker); }; - bool operator()(const OrderedHitPair& h1, const OrderedHitPair& h2) { - const TrackingRecHit* trh1i = h1.inner()->hit(); - const TrackingRecHit* trh2i = h2.inner()->hit(); - const TrackingRecHit* trh1o = h1.outer()->hit(); - const TrackingRecHit* trh2o = h2.outer()->hit(); - GlobalPoint in1p = tracker->idToDet(trh1i->geographicalId())->surface().toGlobal(trh1i->localPosition()); - GlobalPoint in2p = tracker->idToDet(trh2i->geographicalId())->surface().toGlobal(trh2i->localPosition()); - GlobalPoint ou1p = tracker->idToDet(trh1o->geographicalId())->surface().toGlobal(trh1o->localPosition()); - GlobalPoint ou2p = tracker->idToDet(trh2o->geographicalId())->surface().toGlobal(trh2o->localPosition()); - if (ou1p.y() * ou2p.y() < 0) - return ou1p.y() > ou2p.y(); - else { - float dist1 = 100 * std::abs(ou1p.z() - in1p.z()) - std::abs(ou1p.y()) - 0.1 * std::abs(in1p.y()); - float dist2 = 100 * std::abs(ou2p.z() - in2p.z()) - std::abs(ou2p.y()) - 0.1 * std::abs(in2p.y()); - return dist1 < dist2; - } - } -private: - edm::ESHandle tracker; -}; class CosmicHitPairGeneratorFromLayerPair { public: - CosmicHitPairGeneratorFromLayerPair(const LayerWithHits* inner, - const LayerWithHits* outer, - const edm::EventSetup& iSetup); + CosmicHitPairGeneratorFromLayerPair(const LayerWithHits* inner, const LayerWithHits* outer, const TrackerGeometry&); ~CosmicHitPairGeneratorFromLayerPair(); // virtual OrderedHitPairs hitPairs( const TrackingRegion& region,const edm::EventSetup& iSetup ) { // return HitPairGenerator::hitPairs(region, iSetup); // } - void hitPairs(const TrackingRegion& ar, OrderedHitPairs& ap, const edm::EventSetup& iSetup); + void hitPairs(const TrackingRegion& ar, OrderedHitPairs& ap); const LayerWithHits* innerLayer() const { return theInnerLayer; } const LayerWithHits* outerLayer() const { return theOuterLayer; } private: - const TransientTrackingRecHitBuilder* TTRHbuilder; const TrackerGeometry* trackerGeometry; const LayerWithHits* theOuterLayer; const LayerWithHits* theInnerLayer; diff --git a/RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h b/RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h index 5434320d62b93..d816cbe7a9978 100644 --- a/RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h +++ b/RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h @@ -15,23 +15,28 @@ #include class TrackerTopology; +class GeometricSearchTracker; class CosmicLayerPairs : public SeedLayerPairs { public: - CosmicLayerPairs(std::string geometry) : _geometry(geometry){}; //:isFirstCall(true){}; + CosmicLayerPairs(std::string geometry, + const SiStripRecHit2DCollection &collrphi, + const SiStripMatchedRecHit2DCollection &collmatched, + const GeometricSearchTracker &track, + const TrackerTopology &ttopo) + : _geometry(geometry) { + init(collrphi, collmatched, track, ttopo); + }; ~CosmicLayerPairs() override; - // explicit PixelSeedLayerPairs(const edm::EventSetup& iSetup); - // virtual vector operator()() const; std::vector operator()() override; - void init(const SiStripRecHit2DCollection &collstereo, - const SiStripRecHit2DCollection &collrphi, - const SiStripMatchedRecHit2DCollection &collmatched, - //std::string geometry, - const edm::EventSetup &iSetup); private: - //bool isFirstCall; + void init(const SiStripRecHit2DCollection &collrphi, + const SiStripMatchedRecHit2DCollection &collmatched, + const GeometricSearchTracker &, + const TrackerTopology &); + std::string _geometry; std::vector bl; diff --git a/RecoTracker/TkHitPairs/src/CosmicHitPairGenerator.cc b/RecoTracker/TkHitPairs/src/CosmicHitPairGenerator.cc index 84beb496a331f..186b9b277a3d4 100644 --- a/RecoTracker/TkHitPairs/src/CosmicHitPairGenerator.cc +++ b/RecoTracker/TkHitPairs/src/CosmicHitPairGenerator.cc @@ -6,11 +6,11 @@ using namespace std; -CosmicHitPairGenerator::CosmicHitPairGenerator(SeedLayerPairs& layers, const edm::EventSetup& iSetup) { +CosmicHitPairGenerator::CosmicHitPairGenerator(SeedLayerPairs& layers, const TrackerGeometry& trackGeom) { vector layerPairs = layers(); vector::const_iterator it; for (it = layerPairs.begin(); it != layerPairs.end(); it++) { - add((*it).first, (*it).second, iSetup); + add((*it).first, (*it).second, trackGeom); } } @@ -18,15 +18,13 @@ CosmicHitPairGenerator::~CosmicHitPairGenerator() {} void CosmicHitPairGenerator::add(const LayerWithHits* inner, const LayerWithHits* outer, - const edm::EventSetup& iSetup) { - theGenerators.push_back(std::make_unique(inner, outer, iSetup)); + const TrackerGeometry& trackGeom) { + theGenerators.push_back(std::make_unique(inner, outer, trackGeom)); } -void CosmicHitPairGenerator::hitPairs(const TrackingRegion& region, - OrderedHitPairs& pairs, - const edm::EventSetup& iSetup) { +void CosmicHitPairGenerator::hitPairs(const TrackingRegion& region, OrderedHitPairs& pairs) { Container::const_iterator i; for (i = theGenerators.begin(); i != theGenerators.end(); i++) { - (**i).hitPairs(region, pairs, iSetup); + (**i).hitPairs(region, pairs); } } diff --git a/RecoTracker/TkHitPairs/src/CosmicHitPairGeneratorFromLayerPair.cc b/RecoTracker/TkHitPairs/src/CosmicHitPairGeneratorFromLayerPair.cc index d928ae7f48a76..cbe3726ca0ae2 100644 --- a/RecoTracker/TkHitPairs/src/CosmicHitPairGeneratorFromLayerPair.cc +++ b/RecoTracker/TkHitPairs/src/CosmicHitPairGeneratorFromLayerPair.cc @@ -12,24 +12,13 @@ using namespace std; // typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit; -CosmicHitPairGeneratorFromLayerPair::CosmicHitPairGeneratorFromLayerPair( - const LayerWithHits* inner, - const LayerWithHits* outer, - // LayerCacheType* layerCache, - const edm::EventSetup& iSetup) - : TTRHbuilder(nullptr), - trackerGeometry(nullptr), - //theLayerCache(*layerCache), - theOuterLayer(outer), - theInnerLayer(inner) { - edm::ESHandle tracker; - iSetup.get().get(tracker); - trackerGeometry = tracker.product(); -} +CosmicHitPairGeneratorFromLayerPair::CosmicHitPairGeneratorFromLayerPair(const LayerWithHits* inner, + const LayerWithHits* outer, + const TrackerGeometry& geom) + : trackerGeometry(&geom), theOuterLayer(outer), theInnerLayer(inner) {} CosmicHitPairGeneratorFromLayerPair::~CosmicHitPairGeneratorFromLayerPair() {} -void CosmicHitPairGeneratorFromLayerPair::hitPairs(const TrackingRegion& region, - OrderedHitPairs& result, - const edm::EventSetup& iSetup) { + +void CosmicHitPairGeneratorFromLayerPair::hitPairs(const TrackingRegion& region, OrderedHitPairs& result) { // static int NSee = 0; static int Ntry = 0; static int Nacc = 0; typedef OrderedHitPair::InnerRecHit InnerHit; @@ -65,9 +54,6 @@ void CosmicHitPairGeneratorFromLayerPair::hitPairs(const TrackingRegion& region, } vector allthepairs; - std::string builderName = "WithTrackAngle"; - edm::ESHandle builder; - iSetup.get().get(builderName, builder); for (auto ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) { for (auto ihh = theInnerLayer->recHits().begin(); ihh != theInnerLayer->recHits().end(); ihh++) { @@ -107,14 +93,41 @@ void CosmicHitPairGeneratorFromLayerPair::hitPairs(const TrackingRegion& region, } } - // stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(iSetup)); - // //Seed from overlaps are saved only if - // //no others have been saved + /* + // uncomment if the sort operation below needs to be called + class CompareHitPairsY { + public: + CompareHitPairsY(const TrackerGeometry& t): tracker{&t} {} + bool operator()(const OrderedHitPair& h1, const OrderedHitPair& h2) { + const TrackingRecHit* trh1i = h1.inner()->hit(); + const TrackingRecHit* trh2i = h2.inner()->hit(); + const TrackingRecHit* trh1o = h1.outer()->hit(); + const TrackingRecHit* trh2o = h2.outer()->hit(); + GlobalPoint in1p = tracker->idToDet(trh1i->geographicalId())->surface().toGlobal(trh1i->localPosition()); + GlobalPoint in2p = tracker->idToDet(trh2i->geographicalId())->surface().toGlobal(trh2i->localPosition()); + GlobalPoint ou1p = tracker->idToDet(trh1o->geographicalId())->surface().toGlobal(trh1o->localPosition()); + GlobalPoint ou2p = tracker->idToDet(trh2o->geographicalId())->surface().toGlobal(trh2o->localPosition()); + if (ou1p.y() * ou2p.y() < 0) + return ou1p.y() > ou2p.y(); + else { + float dist1 = 100 * std::abs(ou1p.z() - in1p.z()) - std::abs(ou1p.y()) - 0.1 * std::abs(in1p.y()); + float dist2 = 100 * std::abs(ou2p.z() - in2p.z()) - std::abs(ou2p.y()) - 0.1 * std::abs(in2p.y()); + return dist1 < dist2; + } + } + + private: + const TrackerGeometry* tracker; + }; + stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(*trackerGeometry)); + //Seed from overlaps are saved only if + //no others have been saved - // if (allthepairs.size()>0) { - // if (seedfromoverlaps) { - // if (result.size()==0) result.push_back(allthepairs[0]); - // } - // else result.push_back(allthepairs[0]); - // } + if (allthepairs.size()>0) { + if (seedfromoverlaps) { + if (result.size()==0) result.push_back(allthepairs[0]); + } + else result.push_back(allthepairs[0]); + } +*/ } diff --git a/RecoTracker/TkHitPairs/src/CosmicLayerPairs.cc b/RecoTracker/TkHitPairs/src/CosmicLayerPairs.cc index 10c0084343c29..466bf179f6e69 100644 --- a/RecoTracker/TkHitPairs/src/CosmicLayerPairs.cc +++ b/RecoTracker/TkHitPairs/src/CosmicLayerPairs.cc @@ -11,7 +11,6 @@ #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" - std::vector CosmicLayerPairs::operator()() { std::vector result; @@ -236,30 +235,20 @@ std::vector CosmicLayerPairs::operator()() { } CosmicLayerPairs::~CosmicLayerPairs() {} -void CosmicLayerPairs::init(const SiStripRecHit2DCollection &collstereo, - const SiStripRecHit2DCollection &collrphi, +void CosmicLayerPairs::init(const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, - //std::string geometry, - const edm::EventSetup &iSetup) { + const GeometricSearchTracker &track, + const TrackerTopology &ttopo) { ////std::cout << "initializing geometry " << geometry << std::endl; - //_geometry=geometry; - //if(isFirstCall){ - //std::cout << "in isFirtsCall" << std::endl; - edm::ESHandle track; - iSetup.get().get(track); //std::cout << "about to take barrel" << std::endl; - bl = track->barrelLayers(); + bl = track.barrelLayers(); //std::cout << "barrel taken" << std::endl; - fpos = track->posTecLayers(); + fpos = track.posTecLayers(); //std::cout << "pos forw taken" << std::endl; - fneg = track->negTecLayers(); + fneg = track.negTecLayers(); //std::cout << "neg forw taken" << std::endl; //isFirstCall=false; - edm::ESHandle httopo; - iSetup.get().get(httopo); - const TrackerTopology &ttopo = *httopo; - if (_geometry == "MTCC") { //we have to distinguish the MTCC and CRACK case because they have special geometries with different neumbering of layers MTCCLayerWithHits.push_back(new LayerWithHits(bl[0], selectTIBHit(collrphi, ttopo, 1))); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelChargeReweightingAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelChargeReweightingAlgorithm.cc index a2b894ba5d29d..b4b53ed3c57fe 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelChargeReweightingAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelChargeReweightingAlgorithm.cc @@ -227,8 +227,15 @@ bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& hit, ydouble[col] = topol->isItBigPixelInY(hitPixel.second + col - THY); } - for (int row = 0; row < TXSIZE; ++row) { - for (int col = 0; col < TYSIZE; ++col) { + // define loop boundaries that will prevent the row and col loops + // from going out of physical bounds of the pixel module + int rowmin = std::max(0, THX - hitPixel.first); + int rowmax = std::min(TXSIZE, topol->nrows() + THX - hitPixel.first); + int colmin = std::max(0, THY - hitPixel.second); + int colmax = std::min(TYSIZE, topol->ncolumns() + THY - hitPixel.second); + + for (int row = rowmin; row < rowmax; ++row) { + for (int col = colmin; col < colmax; ++col) { //Fill charges into 21x13 Pixel Array with hitPixel in centre pixrewgt[row][col] = hitSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)]; @@ -266,12 +273,10 @@ bool SiPixelChargeReweightingAlgorithm::hitSignalReweight(const PSimHit& hit, printCluster(pixrewgt); } - for (int row = 0; row < TXSIZE; ++row) { - for (int col = 0; col < TYSIZE; ++col) { - float charge = 0; - charge = pixrewgt[row][col]; - if ((hitPixel.first + row - THX) >= 0 && (hitPixel.first + row - THX) < topol->nrows() && - (hitPixel.second + col - THY) >= 0 && (hitPixel.second + col - THY) < topol->ncolumns() && charge > 0) { + for (int row = rowmin; row < rowmax; ++row) { + for (int col = colmin; col < colmax; ++col) { + float charge = pixrewgt[row][col]; + if (charge > 0) { chargeAfter += charge; theSignal[PixelDigi::pixelToChannel(hitPixel.first + row - THX, hitPixel.second + col - THY)] += (boolmakeDigiSimLinks ? SiPixelDigitizerAlgorithm::Amplitude(charge, &hit, hitIndex, tofBin, charge) diff --git a/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules b/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules index 293e5392c0b79..d5bdfed3e70a3 100644 --- a/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules +++ b/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules @@ -29,7 +29,6 @@ IOMC/RandomEngine/bin/.* : geant4core #geant4 (indirect) FastSimulation/Calorimetry/.* : geant4.* -FastSimulation/EventProducer/.* : geant4.* FastSimulation/MaterialEffects/.* : geant4.* VisSimulation/VisSimBase/.* : geant4.* Validation/TrackerHits/.* : geant4.* diff --git a/Utilities/ReleaseScripts/scripts/addOnTests.py b/Utilities/ReleaseScripts/scripts/addOnTests.py index b7203ddcd29f2..83372de8a95a2 100755 --- a/Utilities/ReleaseScripts/scripts/addOnTests.py +++ b/Utilities/ReleaseScripts/scripts/addOnTests.py @@ -145,12 +145,10 @@ def runTests(self, testList = None): print('Running in %s thread(s)' % self.maxThreads) + if testList: + self.commands = {d:c for d,c in self.commands.items() if d in testList} for dirName, command in self.commands.items(): - if testList and not dirName in testList: - del self.commands[dirName] - continue - # make sure we don't run more than the allowed number of threads: while self.activeThreads() >= self.maxThreads: time.sleep(10) diff --git a/Validation/RecoTrack/python/plotting/plotting.py b/Validation/RecoTrack/python/plotting/plotting.py index bc31f4ae57a1e..0a1c886e5270a 100644 --- a/Validation/RecoTrack/python/plotting/plotting.py +++ b/Validation/RecoTrack/python/plotting/plotting.py @@ -49,8 +49,7 @@ def _setStyle(): def _getObject(tdirectory, name): obj = tdirectory.Get(name) if not obj: - if verbose: - print("Did not find {obj} from {dir}".format(obj=name, dir=tdirectory.GetPath())) + print("Did not find {obj} from {dir}".format(obj=name, dir=tdirectory.GetPath())) return None return obj @@ -1073,7 +1072,7 @@ def create(self, tdirectory): return result class AggregateHistos: - """Class to create a histogram by aggregaging integrals of another histoggrams.""" + """Class to create a histogram by aggregating integrals of another histogram.""" def __init__(self, name, mapping, normalizeTo=None): """Constructor. @@ -1935,7 +1934,7 @@ def _modifyHisto(th1, profileX): if self._fallback is not None: self._histograms = list(map(_modifyHisto, self._histograms, profileX)) else: - self._histograms =list(map(lambda h: _modifyHisto(h, self._profileX), self._histograms)) + self._histograms = list(map(lambda h: _modifyHisto(h, self._profileX), self._histograms)) if requireAllHistograms and None in self._histograms: self._histograms = [None]*len(self._histograms) @@ -2497,7 +2496,7 @@ def _save(self, canvas, saveFormat, prefix=None, postfix=None, single=False, dir # Save the canvas to file and clear name = self._name if not os.path.exists(directory+'/'+name): - os.makedirs(directory+'/'+name) + os.makedirs(directory+'/'+name, exist_ok=True) if prefix is not None: name = prefix+name if postfix is not None: diff --git a/Validation/RecoTrack/python/plotting/validation.py b/Validation/RecoTrack/python/plotting/validation.py index 147764dfa8011..73f98013209f0 100644 --- a/Validation/RecoTrack/python/plotting/validation.py +++ b/Validation/RecoTrack/python/plotting/validation.py @@ -978,6 +978,7 @@ def _doPlots(self, sample, harvestedFile, plotterFolder, dqmSubFolder, htmlRepor refValFile.Close() if len(fileList) == 0: + print("No object found in %s" % plotterFolder.getName()) return [] dups = _findDuplicates(fileList) @@ -1044,6 +1045,7 @@ def _doPlotsFastFull(self, fastSample, fullSample, plotterFolder, dqmSubFolder, fastValFile.Close() if len(fileList) == 0: + print("No object found in %s" % plotterFolder.getName()) return [] dups = _findDuplicates(fileList) @@ -1111,6 +1113,7 @@ def _doPlotsPileup(self, pu140Sample, pu200Sample, plotterFolder, dqmSubFolder, pu140ValFile.Close() if len(fileList) == 0: + print("No object found in %s" % plotterFolder.getName()) return [] dups = _findDuplicates(fileList) @@ -1294,13 +1297,12 @@ def _doPlots(self, plotterFolder, dqmSubFolder, newsubdir, newdir, iProc, return plotterFolder.create(self._openFiles, self._labels, dqmSubFolder) fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs) + if len(fileList) == 0: + print("No object found in %s" % plotterFolder.getName()) + for tableCreator in plotterFolder.getTableCreators(): self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder)) - - if len(fileList) == 0: - return fileList - dups = _findDuplicates(fileList) if len(dups) > 0: print("Plotter produced multiple files with names", ", ".join(dups)) @@ -1365,7 +1367,7 @@ def _doPlots(self, plotterFolder, dqmSubFolder, newsubdir, newdir, iProc, return # check if plots are produced if len(fileList) == 0: - return fileList + print("No object found in %s" % plotterFolder.getName()) # check if there are duplicated plot dups = _findDuplicates(fileList)