diff --git a/CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleCalibrationStruct.h b/CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleCalibrationStruct.h index e8b7bdc2baa21..a55ae6dc585c8 100644 --- a/CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleCalibrationStruct.h +++ b/CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleCalibrationStruct.h @@ -91,6 +91,25 @@ struct SiPixelLorentzAngleCalibrationHistograms { // ouput LA maps std::vector h2_byLayerLA_; std::vector h2_byLayerDiff_; + + // FPix Minimal Cluster Size + static constexpr int nRings_ = 2; + static constexpr int nPanels_ = 2; + static constexpr int nSides_ = 2; + static constexpr int betaStartIdx_ = nRings_ * nPanels_ * nSides_; + static constexpr int nAngles_ = 2; + + MonitorMap h_fpixAngleSize_; + MonitorMap h_fpixMean_; + MonitorMap h_fpixMagField_[3]; + + dqm::reco::MonitorElement* h_fpixMeanHistoFitStatus_; + dqm::reco::MonitorElement* h_fpixMinClusterSizeCotAngle_; + dqm::reco::MonitorElement* h_fpixNhitsClusterSizeCotAngle_; + dqm::reco::MonitorElement* h_fpixFitStatusMuH_; + dqm::reco::MonitorElement* h_fpixMuH_; + dqm::reco::MonitorElement* h_fpixDeltaMuH_; + dqm::reco::MonitorElement* h_fpixRelDeltaMuH_; }; #endif diff --git a/CalibTracker/SiPixelLorentzAngle/python/SiPixelLorentzAnglePCLHarvesterMCS_cfi.py b/CalibTracker/SiPixelLorentzAngle/python/SiPixelLorentzAnglePCLHarvesterMCS_cfi.py new file mode 100644 index 0000000000000..fe66a322a7d68 --- /dev/null +++ b/CalibTracker/SiPixelLorentzAngle/python/SiPixelLorentzAnglePCLHarvesterMCS_cfi.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms +from CalibTracker.SiPixelLorentzAngle.SiPixelLorentzAnglePCLWorker_cfi import SiPixelLorentzAnglePCLWorker as worker +from CalibTracker.SiPixelLorentzAngle.siPixelLorentzAnglePCLHarvesterMCS_cfi import siPixelLorentzAnglePCLHarvesterMCS as _defaultHarvester + +SiPixelLorentzAnglePCLHarvesterMCS = _defaultHarvester.clone( + newmodulelist = worker.newmodulelist.value(), # taken from worker configuration, need to stay in synch + dqmDir = worker.folder.value(), # taken from worker configuration, need to stay in synch +) diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvesterMCS.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvesterMCS.cc new file mode 100644 index 0000000000000..0c11795ec573c --- /dev/null +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvesterMCS.cc @@ -0,0 +1,642 @@ +// -*- C++ -*- +// +// Package: CalibTracker/SiPixelLorentzAnglePCLHarvesterMCS +// Class: SiPixelLorentzAnglePCLHarvesterMCS +// +/**\class SiPixelLorentzAnglePCLHarvesterMCS SiPixelLorentzAnglePCLHarvesterMCS.cc CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvesterMCS.cc + Description: reads the intermediate ALCAPROMPT DQMIO-like dataset and performs the fitting of the SiPixel Lorentz Angle in the Prompt Calibration Loop + Implementation: + Reads the 16 2D histograms of the cluster size x/y vs cot(alpha/beta) and 16*3 histograms of the magnetic field components created by SiPixelLorentzAnglePCLWorker module. The cluster size x/y vs cot(alpha/beta) histograms are used to generate 1D profiles (average cluster size x/y vs cot(alpha/beta)) which are then fit and the values of the cot (alpha/beta) for which the cluster sizes are minimal are determined. The obtained cot(alpha/beta)_min value for z- and z+ side are used to perform fit and the muH for different rings and panels of the Pixel Forward Phase 1 detector using the formulas: + cot(alpha)_min = vx/vz = (muHBy + muH^2*Bz*Bx)/(1+muH^2*Bz^2) + cot(beta)_min = vy/vz = -(muHBx - muH^2*Bz*Bx)/(1+muH^2*Bz^2) + +The extracted value of the muH are stored in an output sqlite file which is then uploaded to the conditions database. +*/ +// +// Original Author: tsusa +// Created: Sat, 14 Jan 2021 10:12:21 GMT +// +// + +// system includes + +#include +#include +#include + +// user includes +#include "CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngleCalibrationStruct.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" +#include "CondFormats/DataRecord/interface/SiPixelLorentzAngleRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h" +#include "DQMServices/Core/interface/DQMEDHarvester.h" +#include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" +#include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/PixelTopologyMap.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" + +// for ROOT fits +#include "TFitResult.h" +#include "TVirtualFitter.h" +#include "TH1D.h" + +namespace SiPixelLAHarvestMCS { + + enum fitStatus { kFitNotPerformed = -2, kNoFitResult = -1, kFitConverged = 0, kFitFailed = 1 }; + + Double_t MCSFitFunction(Double_t* x, Double_t* par) { + Double_t arg; + + if (x[0] < par[3]) { + arg = par[1] * par[1] + par[2] * par[2] * (x[0] - par[3]) * (x[0] - par[3]); + } else { + arg = par[1] * par[1] + par[4] * par[4] * (x[0] - par[3]) * (x[0] - par[3]); + } + Double_t fitval = par[0] + sqrt(arg); + return fitval; + } + + struct FPixMuH { + double bfield[3]; + double shiftx; // Shift in x direction + double shifty; // Shift in y direction + double shiftx_err; + double shifty_err; + }; + + void fcn_func(Int_t& npar, Double_t* deriv, Double_t& f, Double_t* par, Int_t flag); + + class FitFPixMuH : public TObject { + public: + FitFPixMuH() : muH(0), muHErr(0) {} + + //----------------------------------------------------------- + ~FitFPixMuH() override = default; + + friend void fcn_func(Int_t& npar, Double_t* deriv, Double_t& f, Double_t* par, Int_t flag); + + void add(const FPixMuH& fmh) { cmvar.push_back(fmh); } + int fit(double initVal) { + minuit = TVirtualFitter::Fitter(this, 1); + minuit->SetFCN(fcn_func); + double tanlorpertesla = initVal; + minuit->SetParameter(0, "muH", tanlorpertesla, 0.1, 0., 0.); + + double arglist[100]; + arglist[0] = 3.; + minuit->ExecuteCommand("SET PRINT", arglist, 0); + double up = 1.0; + minuit->SetErrorDef(up); + arglist[0] = 100000.; + int status = minuit->ExecuteCommand("MIGRAD", arglist, 0); + muH = minuit->GetParameter(0); + muHErr = minuit->GetParError(0); + + return status; + } + + double getMuH() { return muH; } + double getMuHErr() { return muHErr; } + unsigned int size() { return cmvar.size(); } + + private: + TVirtualFitter* minuit; + std::vector cmvar; + double muH; + double muHErr; + + double calcChi2(double par_0) { + double tanlorpertesla = par_0; + double tlpt2 = tanlorpertesla * tanlorpertesla; + double v[3], xshift, yshift; + + int n = cmvar.size(); + + double chi2 = 0.0; + for (int i = 0; i < n; i++) { + v[0] = -(tanlorpertesla * cmvar[i].bfield[1] + tlpt2 * cmvar[i].bfield[0] * cmvar[i].bfield[2]); + v[1] = tanlorpertesla * cmvar[i].bfield[0] - tlpt2 * cmvar[i].bfield[1] * cmvar[i].bfield[2]; + v[2] = -(1. + tlpt2 * cmvar[i].bfield[2] * cmvar[i].bfield[2]); + + xshift = v[0] / v[2]; + yshift = v[1] / v[2]; + + chi2 += (xshift - cmvar[i].shiftx) * (xshift - cmvar[i].shiftx) / cmvar[i].shiftx_err / cmvar[i].shiftx_err + + (yshift - cmvar[i].shifty) * (yshift - cmvar[i].shifty) / cmvar[i].shifty_err / cmvar[i].shifty_err; + } + return chi2; + } + }; + + void fcn_func(Int_t& npar, Double_t* deriv, Double_t& f, Double_t* par, Int_t flag) { + f = ((dynamic_cast((TVirtualFitter::GetFitter())->GetObjectFit()))->calcChi2(par[0])); + } +} // namespace SiPixelLAHarvestMCS + +//------------------------------------------------------------------------------ +class SiPixelLorentzAnglePCLHarvesterMCS : public DQMEDHarvester { +public: + SiPixelLorentzAnglePCLHarvesterMCS(const edm::ParameterSet&); + ~SiPixelLorentzAnglePCLHarvesterMCS() override = default; + using FPixCotAngleFitResults = std::unordered_map>; + using FpixMuHResults = std::unordered_map>; + using FitParametersInitValuesMuHFitMap = std::unordered_map; + + void beginRun(const edm::Run&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override; + void findMean(dqm::reco::MonitorElement* h_2D, dqm::reco::MonitorElement* h_mean, TH1D* h_slice); + int getIndex(bool isBetaAngle, int r, int p, int s); + + // es tokens + const edm::ESGetToken geomEsToken_; + const edm::ESGetToken topoEsTokenBR_, topoEsTokenER_; + const edm::ESGetToken siPixelLAEsToken_; + const edm::ESGetToken magneticFieldToken_; + + const std::string dqmDir_; + std::vector newmodulelist_; + const std::vector fitRange_; + const std::vector fitParametersInitValues_; + const std::vector fitParametersInitValuesMuHFit_; + FitParametersInitValuesMuHFitMap fitParametersInitValuesMuHFitMap_; + + const int minHitsCut_; + const std::string recordName_; + SiPixelLorentzAngleCalibrationHistograms hists_; + SiPixelLAHarvestMCS::fitStatus fitMCSHistogram(dqm::reco::MonitorElement* h_mean); + std::pair theFitRange_{-1.5, 1.5}; + + std::unique_ptr f1_; + FpixMuHResults fpixMuHResults; + + const SiPixelLorentzAngle* currentLorentzAngle_; + const TrackerTopology* tTopo; +}; + +//------------------------------------------------------------------------------ +SiPixelLorentzAnglePCLHarvesterMCS::SiPixelLorentzAnglePCLHarvesterMCS(const edm::ParameterSet& iConfig) + : geomEsToken_(esConsumes()), + topoEsTokenBR_(esConsumes()), + topoEsTokenER_(esConsumes()), + siPixelLAEsToken_(esConsumes()), + dqmDir_(iConfig.getParameter("dqmDir")), + newmodulelist_(iConfig.getParameter>("newmodulelist")), + fitRange_(iConfig.getParameter>("fitRange")), + fitParametersInitValues_(iConfig.getParameter>("fitParameters")), + fitParametersInitValuesMuHFit_(iConfig.getParameter>("fitParametersMuHFit")), + minHitsCut_(iConfig.getParameter("minHitsCut")), + recordName_(iConfig.getParameter("record")) { + // initialize the fit range + + if (fitRange_.size() == 2) { + theFitRange_.first = fitRange_[0]; + theFitRange_.second = fitRange_[1]; + } else { + throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") << "Wrong number of fit range parameters specified"; + } + + if (fitParametersInitValues_.size() != 5) { + throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") + << "Wrong number of initial values for fit parameters specified"; + } + + if (fitParametersInitValuesMuHFit_.size() != 4) { + throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") + << "Wrong number of initial values for fit parameters specified"; + } + + fitParametersInitValuesMuHFitMap_["R1_P1"] = fitParametersInitValuesMuHFit_[0]; + fitParametersInitValuesMuHFitMap_["R1_P2"] = fitParametersInitValuesMuHFit_[1]; + fitParametersInitValuesMuHFitMap_["R2_P1"] = fitParametersInitValuesMuHFit_[2]; + fitParametersInitValuesMuHFitMap_["R2_P2"] = fitParametersInitValuesMuHFit_[3]; + + // first ensure DB output service is available + edm::Service poolDbService; + if (!poolDbService.isAvailable()) + throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") << "PoolDBService required"; +} + +//------------------------------------------------------------------------------ +void SiPixelLorentzAnglePCLHarvesterMCS::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { + // geometry + + const TrackerGeometry* geom = &iSetup.getData(geomEsToken_); + tTopo = &iSetup.getData(topoEsTokenBR_); + currentLorentzAngle_ = &iSetup.getData(siPixelLAEsToken_); + PixelTopologyMap map = PixelTopologyMap(geom, tTopo); + hists_.nlay = geom->numberOfLayers(PixelSubdetector::PixelBarrel); + hists_.nModules_.resize(hists_.nlay); + hists_.nLadders_.resize(hists_.nlay); + for (int i = 0; i < hists_.nlay; i++) { + hists_.nModules_[i] = map.getPXBModules(i + 1); + hists_.nLadders_[i] = map.getPXBLadders(i + 1); + } + + // list of modules already filled, then return (we already entered here) + if (!hists_.BPixnewDetIds_.empty() || !hists_.FPixnewDetIds_.empty()) + return; + + if (!newmodulelist_.empty()) { + for (auto const& modulename : newmodulelist_) { + if (modulename.find("BPix_") != std::string::npos) { + PixelBarrelName bn(modulename, true); + const auto& detId = bn.getDetId(tTopo); + hists_.BPixnewmodulename_.push_back(modulename); + hists_.BPixnewDetIds_.push_back(detId.rawId()); + hists_.BPixnewModule_.push_back(bn.moduleName()); + hists_.BPixnewLayer_.push_back(bn.layerName()); + } else if (modulename.find("FPix_") != std::string::npos) { + PixelEndcapName en(modulename, true); + const auto& detId = en.getDetId(tTopo); + hists_.FPixnewmodulename_.push_back(modulename); + hists_.FPixnewDetIds_.push_back(detId.rawId()); + hists_.FPixnewDisk_.push_back(en.diskName()); + hists_.FPixnewBlade_.push_back(en.bladeName()); + } + } + } + + uint count = 0; + for (const auto& id : hists_.BPixnewDetIds_) { + LogDebug("SiPixelLorentzAnglePCLHarvesterMCS") << id; + count++; + } + LogDebug("SiPixelLorentzAnglePCLHarvesterMCS") << "Stored a total of " << count << " new detIds."; + + // list of modules already filled, return (we already entered here) + if (!hists_.detIdsList.empty()) + return; + + std::vector treatedIndices; + + for (const auto& det : geom->detsPXB()) { + const PixelGeomDetUnit* pixelDet = dynamic_cast(det); + const auto& layer = tTopo->pxbLayer(pixelDet->geographicalId()); + const auto& module = tTopo->pxbModule(pixelDet->geographicalId()); + int i_index = module + (layer - 1) * hists_.nModules_[layer - 1]; + + uint32_t rawId = pixelDet->geographicalId().rawId(); + + // if the detId is already accounted for in the special class, do not attach it + if (std::find(hists_.BPixnewDetIds_.begin(), hists_.BPixnewDetIds_.end(), rawId) != hists_.BPixnewDetIds_.end()) + continue; + if (std::find(treatedIndices.begin(), treatedIndices.end(), i_index) != treatedIndices.end()) { + hists_.detIdsList[i_index].push_back(rawId); + } else { + hists_.detIdsList.insert(std::pair>(i_index, {rawId})); + treatedIndices.push_back(i_index); + } + } + + count = 0; + for (const auto& i : treatedIndices) { + for (const auto& id : hists_.detIdsList[i]) { + LogDebug("SiPixelLorentzAnglePCLHarvesterMCS") << id; + count++; + }; + } + LogDebug("SiPixelLorentzAnglePCLHarvesterMCS") << "Stored a total of " << count << " detIds."; +} +//------------------------------------------------------------------------------ +void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) { + iGetter.cd(); + iGetter.setCurrentFolder(dqmDir_); + + // get mean and size-angle hists, book summary hists + std::string hname; + int nBins = hists_.nAngles_ * hists_.nRings_ * hists_.nPanels_ * hists_.nSides_; + hists_.h_fpixMeanHistoFitStatus_ = + iBooker.book1D("fpixMeanHistoFitStatus", + "fit status by angles/rings/panels/sides; angle/ring/panel/side; fit status", + nBins, + -0.5, + nBins - 0.5); + hists_.h_fpixMinClusterSizeCotAngle_ = + iBooker.book1D("fpixMinClusterSizeCotAngle", + "cot angle of minimal cluster size by angles/rings/panels/sides; angle/ring/panel/side; ", + nBins, + -0.5, + nBins - 0.5); + hists_.h_fpixNhitsClusterSizeCotAngle_ = + iBooker.book1D("fpixNhitsClusterSizeCotAngle", + "number of hits by angles/rings/panels/sides; angle/ring/panel/side; ", + nBins, + -0.5, + nBins - 0.5); + + std::string binNameAlpha; + std::string binNameBeta; + + const auto& prefix_ = fmt::sprintf("%s/FPix", dqmDir_); + int histsCounter = 0; + int nHistoExpected = 0; + for (int r = 0; r < hists_.nRings_; ++r) { + for (int p = 0; p < hists_.nPanels_; ++p) { + for (int s = 0; s < hists_.nSides_; ++s) { + int idx = getIndex(false, r, p, s); + int idxBeta = getIndex(true, r, p, s); + nHistoExpected++; + hname = fmt::format("{}/R{}_P{}_z{}_alphaMean", dqmDir_, r + 1, p + 1, s + 1); + if ((hists_.h_fpixMean_[idx] = iGetter.get(hname)) == nullptr) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve " << hname << " histogram"; + } else + histsCounter++; + + nHistoExpected++; + hname = fmt::format("{}/R{}_P{}_z{}_betaMean", dqmDir_, r + 1, p + 1, s + 1); + if ((hists_.h_fpixMean_[idxBeta] = iGetter.get(hname)) == nullptr) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve " << hname << " histogram"; + } else + histsCounter++; + + nHistoExpected++; + hname = fmt::format("{}/R{}_P{}_z{}_alpha", prefix_, r + 1, p + 1, s + 1); + if ((hists_.h_fpixAngleSize_[idx] = iGetter.get(hname)) == nullptr) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve " << hname << " histogram"; + } else + histsCounter++; + + nHistoExpected++; + hname = fmt::format("{}/R{}_P{}_z{}_beta", prefix_, r + 1, p + 1, s + 1); + if ((hists_.h_fpixAngleSize_[idxBeta] = iGetter.get(hname)) == nullptr) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve " << hname << " histogram"; + } else + histsCounter++; + + for (int m = 0; m < 3; ++m) { + nHistoExpected++; + hname = fmt::format("{}/R{}_P{}_z{}_B{}", prefix_, r + 1, p + 1, s + 1, m); + if ((hists_.h_fpixMagField_[m][idx] = iGetter.get(hname)) == nullptr) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve " << hname << " histogram"; + } else + histsCounter++; + } + + // set labels & init summary histos + int binAlpha = idx + 1; + int binBeta = idxBeta + 1; + char sign = s == 0 ? '-' : '+'; + binNameAlpha = fmt::sprintf("#alpha: R%d_P%d_z%c", r + 1, p + 1, sign); + binNameBeta = fmt::sprintf("#beta:R%d_P%d_z%c", r + 1, p + 1, sign); + hists_.h_fpixMeanHistoFitStatus_->setBinLabel(binAlpha, binNameAlpha); + hists_.h_fpixMeanHistoFitStatus_->setBinLabel(binBeta, binNameBeta); + hists_.h_fpixMeanHistoFitStatus_->setBinContent(binAlpha, SiPixelLAHarvestMCS::kFitNotPerformed); + hists_.h_fpixMeanHistoFitStatus_->setBinContent(binBeta, SiPixelLAHarvestMCS::kFitNotPerformed); + + hists_.h_fpixMinClusterSizeCotAngle_->setBinLabel(binAlpha, binNameAlpha); + hists_.h_fpixMinClusterSizeCotAngle_->setBinLabel(binBeta, binNameBeta); + hists_.h_fpixNhitsClusterSizeCotAngle_->setBinLabel(binAlpha, binNameAlpha); + hists_.h_fpixNhitsClusterSizeCotAngle_->setBinLabel(binBeta, binNameBeta); + } + } + } + + if (histsCounter != nHistoExpected) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob") + << "Failed to retrieve all histograms, expected 56 got " << histsCounter; + return; + } + + // book hervesting hists + iBooker.setCurrentFolder(fmt::format("{}Harvesting", dqmDir_)); + int nBinsMuH = hists_.nRings_ * hists_.nPanels_; + hists_.h_fpixFitStatusMuH_ = iBooker.book1D( + "fpixFitStatusMuH", "muH fit status by rings/panels; ring/panel; fitStatus", nBinsMuH, -0.5, nBinsMuH - 0.5); + hists_.h_fpixMuH_ = + iBooker.book1D("fpixMuH", "muH by rings/panels; ring/panel; #muH [1/T]", nBinsMuH, -0.5, nBinsMuH - 0.5); + hists_.h_fpixDeltaMuH_ = iBooker.book1D( + "fpixDeltaMuH", "#Delta muH by rings/panels; ring/panel; #Delta #muH [1/T]", nBinsMuH, -0.5, nBinsMuH - 0.5); + hists_.h_fpixRelDeltaMuH_ = iBooker.book1D("fpixRelDeltaMuH", + "#Delta #muH/#muH by rings/panels; ring/panel; #Delta #muH/#MuH", + nBinsMuH, + -0.5, + nBinsMuH - 0.5); + std::string binName; + for (int r = 0; r < hists_.nRings_; ++r) { + for (int p = 0; p < hists_.nPanels_; ++p) { + int idx = r * hists_.nPanels_ + p + 1; + binName = fmt::sprintf("R%d_P%d", r + 1, p + 1); + hists_.h_fpixFitStatusMuH_->setBinLabel(idx, binName); + hists_.h_fpixFitStatusMuH_->setBinContent(idx, SiPixelLAHarvestMCS::kFitNotPerformed); + hists_.h_fpixMuH_->setBinLabel(idx, binName); + hists_.h_fpixDeltaMuH_->setBinLabel(idx, binName); + hists_.h_fpixRelDeltaMuH_->setBinLabel(idx, binName); + } + } + + // make and fit profile hists, fit muH + int nSizeBins = hists_.h_fpixAngleSize_[0]->getNbinsY(); + double minSize = hists_.h_fpixAngleSize_[0]->getAxisMin(2); + double maxSize = hists_.h_fpixAngleSize_[0]->getAxisMax(2); + TH1D* h_slice = new TH1D("h_slice", "slice of cot_angle histogram", nSizeBins, minSize, maxSize); + f1_ = std::make_unique("f1", SiPixelLAHarvestMCS::MCSFitFunction, -3., 3., 5); + f1_->SetParNames("Offset", "RMS Constant", "SlopeL", "cot(angle)_min", "SlopeR"); + + for (int r = 0; r < hists_.nRings_; ++r) { + for (int p = 0; p < hists_.nPanels_; ++p) { + SiPixelLAHarvestMCS::FitFPixMuH fitMuH; + SiPixelLAHarvestMCS::FPixMuH fmh; + for (int s = 0; s < hists_.nSides_; ++s) { + int idx = getIndex(false, r, p, s); + int idxBeta = getIndex(true, r, p, s); + int binAlpha = idx + 1; + int binBeta = idxBeta + 1; + + int entriesAlpha = hists_.h_fpixAngleSize_[idx]->getEntries(); + int entriesBeta = hists_.h_fpixAngleSize_[idxBeta]->getEntries(); + hists_.h_fpixNhitsClusterSizeCotAngle_->setBinContent(binAlpha, entriesAlpha); + hists_.h_fpixNhitsClusterSizeCotAngle_->setBinContent(binBeta, entriesBeta); + findMean(hists_.h_fpixAngleSize_[idx], hists_.h_fpixMean_[idx], h_slice); + findMean(hists_.h_fpixAngleSize_[idxBeta], hists_.h_fpixMean_[idxBeta], h_slice); + + SiPixelLAHarvestMCS::fitStatus statusAlphaFit = entriesAlpha < minHitsCut_ + ? SiPixelLAHarvestMCS::kFitNotPerformed + : fitMCSHistogram(hists_.h_fpixMean_[idx]); + SiPixelLAHarvestMCS::fitStatus statusBetaFit = entriesBeta < minHitsCut_ + ? SiPixelLAHarvestMCS::kFitNotPerformed + : fitMCSHistogram(hists_.h_fpixMean_[idxBeta]); + + hists_.h_fpixMeanHistoFitStatus_->setBinContent(binAlpha, statusAlphaFit); + hists_.h_fpixMeanHistoFitStatus_->setBinContent(binBeta, statusBetaFit); + + if (entriesAlpha < minHitsCut_ || entriesBeta < minHitsCut_) + continue; + + assert(strcmp(f1_->GetName(), "f1") == 0); + + if (statusAlphaFit == SiPixelLAHarvestMCS::kFitConverged && + statusBetaFit == SiPixelLAHarvestMCS::kFitConverged) { + double shiftX = hists_.h_fpixMean_[idx]->getTH1()->GetFunction("f1")->GetParameter(3); + double errShiftX = hists_.h_fpixMean_[idx]->getTH1()->GetFunction("f1")->GetParError(3); + double shiftY = hists_.h_fpixMean_[idxBeta]->getTH1()->GetFunction("f1")->GetParameter(3); + double errShiftY = hists_.h_fpixMean_[idxBeta]->getTH1()->GetFunction("f1")->GetParError(3); + + hists_.h_fpixMinClusterSizeCotAngle_->setBinContent(binAlpha, shiftX); + hists_.h_fpixMinClusterSizeCotAngle_->setBinError(binAlpha, errShiftX); + hists_.h_fpixMinClusterSizeCotAngle_->setBinContent(binBeta, shiftY); + hists_.h_fpixMinClusterSizeCotAngle_->setBinError(binBeta, errShiftY); + + fmh.shiftx = shiftX; + fmh.shiftx_err = errShiftX; + fmh.shifty = shiftY; + fmh.shifty_err = errShiftY; + fmh.bfield[0] = hists_.h_fpixMagField_[0][idx]->getMean(); + fmh.bfield[1] = hists_.h_fpixMagField_[1][idx]->getMean(); + fmh.bfield[2] = hists_.h_fpixMagField_[2][idx]->getMean(); + fitMuH.add(fmh); + } // if fut converged + } // loop over z sides + + if (fitMuH.size() == hists_.nSides_) { + std::string fpixPartNames = "R" + std::to_string(r + 1) + "_P" + std::to_string(p + 1); + double initMuH = fitParametersInitValuesMuHFitMap_[fpixPartNames]; + int status = fitMuH.fit(initMuH); + int idxMuH = r * hists_.nPanels_ + p + 1; + double muH = fitMuH.getMuH(); + double muHErr = fitMuH.getMuHErr(); + hists_.h_fpixFitStatusMuH_->setBinContent(idxMuH, status); + hists_.h_fpixMuH_->setBinContent(idxMuH, muH); + hists_.h_fpixMuH_->setBinError(idxMuH, muHErr); + fpixMuHResults.insert(std::make_pair(fpixPartNames, std::make_pair(muH, muH))); + } + } + } + + std::shared_ptr LorentzAngle = std::make_shared(); + + bool isPayloadChanged{false}; + + for (const auto& [id, value] : currentLorentzAngle_->getLorentzAngles()) { + DetId ID = DetId(id); + float muHForDB = value; + if (ID.subdetId() == PixelSubdetector::PixelEndcap) { + PixelEndcapName pen(ID, tTopo, true); // use det-id phaseq + int panel = pen.pannelName(); + int ring = pen.ringName(); + std::string fpixPartNames = "R" + std::to_string(ring) + "_P" + std::to_string(panel); + if (fpixMuHResults.find(fpixPartNames) != fpixMuHResults.end()) { + double measuredMuH = fpixMuHResults[fpixPartNames].first; + double deltaMuH = value - measuredMuH; + double deltaMuHoverMuH = deltaMuH / value; + int idxMuH = (ring - 1) * hists_.nPanels_ + panel; + hists_.h_fpixDeltaMuH_->setBinContent(idxMuH, deltaMuH); + hists_.h_fpixRelDeltaMuH_->setBinContent(idxMuH, deltaMuHoverMuH); + muHForDB = measuredMuH; + if (!isPayloadChanged && (deltaMuHoverMuH != 0.f)) + isPayloadChanged = true; + } + } // if endcap + if (!LorentzAngle->putLorentzAngle(id, muHForDB)) { + edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS") + << "[SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob]: detid (" << id << ") already exists"; + } + } + + if (isPayloadChanged) { + // fill the DB object record + edm::Service mydbservice; + if (mydbservice.isAvailable()) { + try { + mydbservice->writeOneIOV(*LorentzAngle, mydbservice->currentTime(), recordName_); + } catch (const cond::Exception& er) { + edm::LogError("SiPixelLorentzAngleDB") << er.what(); + } catch (const std::exception& er) { + edm::LogError("SiPixelLorentzAngleDB") << "caught std::exception " << er.what(); + } + } else { + edm::LogError("SiPixelLorentzAngleDB") << "Service is unavailable"; + } + } else { + edm::LogPrint("SiPixelLorentzAngleDB") << __PRETTY_FUNCTION__ << " there is no new valid measurement to append! "; + } +} + +//------------------------------------------------------------------------------ +void SiPixelLorentzAnglePCLHarvesterMCS::findMean(dqm::reco::MonitorElement* h_2D, + dqm::reco::MonitorElement* h_mean, + TH1D* h_slice) { + int n_x = h_2D->getNbinsX(); + int n_y = h_2D->getNbinsY(); + + for (int i = 1; i <= n_x; i++) { + h_slice->Reset("ICE"); + + //loop over bins in size + + for (int j = 1; j <= n_y; j++) { + h_slice->SetBinContent(j, h_2D->getBinContent(i, j)); + } + double mean = h_slice->GetMean(); + double error = h_slice->GetMeanError(); + h_mean->setBinContent(i, mean); + h_mean->setBinError(i, error); + } // end loop over bins in depth +} + +//------------------------------------------------------------------------------ +SiPixelLAHarvestMCS::fitStatus SiPixelLorentzAnglePCLHarvesterMCS::fitMCSHistogram(dqm::reco::MonitorElement* h_mean) { + SiPixelLAHarvestMCS::fitStatus retVal; + + f1_->SetParameters(fitParametersInitValues_[0], + fitParametersInitValues_[1], + fitParametersInitValues_[2], + fitParametersInitValues_[3], + fitParametersInitValues_[4]); + + int nFits = 0; + while (nFits < 5) { + nFits++; + double fitMin = f1_->GetParameter(3) + theFitRange_.first; + double fitMax = f1_->GetParameter(3) + theFitRange_.second; + + if (fitMin < -3) + fitMin = -3; + if (fitMax > 3) + fitMax = 3; + + TFitResultPtr r = h_mean->getTH1()->Fit(f1_.get(), "ERSM", "", fitMin, fitMax); + retVal = r == -1 ? SiPixelLAHarvestMCS::kNoFitResult + : r->IsValid() ? SiPixelLAHarvestMCS::kFitConverged + : SiPixelLAHarvestMCS::kFitFailed; + } + return retVal; +} + +//------------------------------------------------------------------------------ +void SiPixelLorentzAnglePCLHarvesterMCS::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Harvester module of the SiPixel Lorentz Angle PCL monitoring workflow for MinimalClusterSizeMethod"); + desc.add("dqmDir", "AlCaReco/SiPixelLorentzAngle")->setComment("the directory of PCL Worker output"); + desc.add>("newmodulelist", {})->setComment("the list of DetIds for new sensors"); + desc.add>("fitRange", {-1.5, 1.5})->setComment("range to perform the fit"); + desc.add>("fitParameters", {1., 0.1, -1.6, 0., 1.6}) + ->setComment("initial values for fit parameters"); + desc.add>("fitParametersMuHFit", {0.08, 0.08, 0.08, 0.08}) + ->setComment("initial values for fit parameters (muH fit)"); + desc.add("minHitsCut", 1000)->setComment("cut on minimum number of on-track hits to accept measurement"); + desc.add("record", "SiPixelLorentzAngleRcdMCS")->setComment("target DB record"); + descriptions.addWithDefaultLabel(desc); +} + +int SiPixelLorentzAnglePCLHarvesterMCS::getIndex(bool isBetaAngle, int r, int p, int s) { + int idx = hists_.nSides_ * hists_.nPanels_ * r + hists_.nSides_ * p + s; + return (isBetaAngle ? idx + hists_.betaStartIdx_ : idx); +} +DEFINE_FWK_MODULE(SiPixelLorentzAnglePCLHarvesterMCS); diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc index 071dcfe0cc613..a6d5bc0329e39 100644 --- a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc @@ -54,6 +54,8 @@ #include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" // ROOT includes #include @@ -97,6 +99,8 @@ struct Rechit { float y; }; +enum LorentzAngleAnalysisTypeEnum { eGrazingAngle, eMinimumClusterSize }; + class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { public: explicit SiPixelLorentzAnglePCLWorker(const edm::ParameterSet&); @@ -117,6 +121,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { const std::pair surface_deformation(const PixelTopology* topol, TrajectoryStateOnSurface& tsos, const SiPixelRecHit* recHitPix) const; + LorentzAngleAnalysisTypeEnum convertStringToLorentzAngleAnalysisTypeEnum(std::string type); // ------------ member data ------------ SiPixelLorentzAngleCalibrationHistograms iHists; @@ -125,6 +130,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { const SiPixelTemplateDBObject* templateDBobject_; std::vector thePixelTemp_; + LorentzAngleAnalysisTypeEnum analysisType_; std::string folder_; bool notInPCL_; std::string filename_; @@ -191,6 +197,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { edm::ESGetToken siPixelTemplateEsToken_; edm::ESGetToken topoPerEventEsToken_; edm::ESGetToken geomPerEventEsToken_; + edm::ESGetToken magneticFieldToken_; // event consumes edm::EDGetTokenT t_trajTrack; @@ -200,7 +207,8 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { // constructors and destructor // SiPixelLorentzAnglePCLWorker::SiPixelLorentzAnglePCLWorker(const edm::ParameterSet& iConfig) - : folder_(iConfig.getParameter("folder")), + : analysisType_(convertStringToLorentzAngleAnalysisTypeEnum(iConfig.getParameter("analysisType"))), + folder_(iConfig.getParameter("folder")), notInPCL_(iConfig.getParameter("notInPCL")), filename_(iConfig.getParameter("fileName")), newmodulelist_(iConfig.getParameter>("newmodulelist")), @@ -216,12 +224,12 @@ SiPixelLorentzAnglePCLWorker::SiPixelLorentzAnglePCLWorker(const edm::ParameterS topoEsToken_(esConsumes()), siPixelTemplateEsToken_(esConsumes()), topoPerEventEsToken_(esConsumes()), - geomPerEventEsToken_(esConsumes()) { + geomPerEventEsToken_(esConsumes()), + magneticFieldToken_(esConsumes()) { t_trajTrack = consumes(iConfig.getParameter("src")); // now do what ever initialization is needed int bufsize = 64000; - // create tree structure // Barrel pixel if (notInPCL_) { @@ -315,6 +323,9 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS // Retrieve track geometry const TrackerGeometry* tracker = &iSetup.getData(geomPerEventEsToken_); + // Retrieve magnetic field + const MagneticField* magField = &iSetup.getData(magneticFieldToken_); + // get the association map between tracks and trajectories edm::Handle trajTrackCollectionHandle; iEvent.getByToken(t_trajTrack, trajTrackCollectionHandle); @@ -440,7 +451,7 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS float cotalpha = trackdirection.x() / trackdirection.z(); float cotbeta = trackdirection.y() / trackdirection.z(); float cotbeta_min = clustSizeYMin_[layer_ - 1] * ypitch_ / width_; - if (fabs(cotbeta) <= cotbeta_min) + if (std::abs(cotbeta) <= cotbeta_min) continue; double drdz = sqrt(1. + cotalpha * cotalpha + cotbeta * cotbeta); double clusterCharge_cut = clustChargeMaxPerLength_ * drdz; @@ -482,6 +493,8 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS SiPixelLorentzAngleTreeBarrel_->Fill(); } + if (analysisType_ != eGrazingAngle) + continue; // is one pixel in cluster a large pixel ? (hit will be excluded) bool large_pix = false; for (int j = 0; j < pixinfo_.npix; j++) { @@ -650,6 +663,58 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS if (notInPCL_) { SiPixelLorentzAngleTreeForward_->Fill(); } + + if (analysisType_ != eMinimumClusterSize) + continue; + + int theMagField = magField->nominalValue(); + if (theMagField < 37 || theMagField > 39) + continue; + + double chi2_ndof = chi2_ / ndof_; + if (chi2_ndof >= normChi2Max_) + continue; + + //--- large pixel cut + bool large_pix = false; + for (int j = 0; j < pixinfoF_.npix; j++) { + int colpos = static_cast(pixinfoF_.col[j]); + if (pixinfoF_.row[j] == 0 || pixinfoF_.row[j] == 79 || pixinfoF_.row[j] == 80 || pixinfoF_.row[j] == 159 || + colpos % 52 == 0 || colpos % 52 == 51) { + large_pix = true; + } + } + + if (large_pix) + continue; + + //--- residual cut + double residual = sqrt(pow(trackhitCorrXF_ - rechitCorrF_.x, 2) + pow(trackhitCorrYF_ - rechitCorrF_.y, 2)); + + if (residual > residualMax_) + continue; + + int ringIdx = bladeF_ <= 22 ? 0 : 1; + int panelIdx = panelF_ - 1; + int sideIdx = sideF_ - 1; + int idx = iHists.nSides_ * iHists.nPanels_ * ringIdx + iHists.nSides_ * panelIdx + sideIdx; + int idxBeta = iHists.betaStartIdx_ + idx; + + double cotanAlpha = std::tan(M_PI / 2. - trackhitF_.alpha); + double cotanBeta = std::tan(M_PI / 2. - trackhitF_.beta); + + LocalVector Bfield = theGeomDet->surface().toLocal(magField->inTesla(theGeomDet->surface().position())); + iHists.h_fpixMagField_[0][idx]->Fill(Bfield.x()); + iHists.h_fpixMagField_[1][idx]->Fill(Bfield.y()); + iHists.h_fpixMagField_[2][idx]->Fill(Bfield.z()); + + if (clustF_.size_y >= 2) { + iHists.h_fpixAngleSize_[idx]->Fill(cotanAlpha, clustF_.size_x); + } + + if (clust_.size_x >= 0) { + iHists.h_fpixAngleSize_[idxBeta]->Fill(cotanBeta, clustF_.size_y); + } } } //end iteration over trajectory measurements } //end iteration over trajectories @@ -708,112 +773,169 @@ void SiPixelLorentzAnglePCLWorker::dqmBeginRun(edm::Run const& run, edm::EventSe void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const& iSetup) { - // book the by partition monitoring - const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size(); - - iBooker.setCurrentFolder(fmt::sprintf("%s/SectorMonitoring", folder_.data())); - iHists.h_bySectOccupancy_ = iBooker.book1D( - "h_bySectorOccupancy", "hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect - 0.5); - - iBooker.setCurrentFolder(folder_); - static constexpr double min_depth_ = -100.; - static constexpr double max_depth_ = 400.; - static constexpr double min_drift_ = -500.; - static constexpr double max_drift_ = 500.; - - // book the mean values projections and set the bin names of the by sector monitoring - char name[128]; - char title[256]; - for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) { - for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) { - unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1]; - std::string binName = fmt::sprintf("BPix Lay%i Mod%i", i_layer, i_module); - LogDebug("SiPixelLorentzAnglePCLWorker") << " i_index: " << i_index << " bin name: " << binName - << " (i_layer: " << i_layer << " i_module:" << i_module << ")"; - - iHists.h_bySectOccupancy_->setBinLabel(i_index, binName); - - sprintf(name, "h_mean_layer%i_module%i", i_layer, i_module); - sprintf(title, - "average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]", - i_layer, - i_module); - iHists.h_mean_[i_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_); + std::string name; + std::string title; + if (analysisType_ == eGrazingAngle) { + // book the by partition monitoring + const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size(); + + iBooker.setCurrentFolder(fmt::sprintf("%s/SectorMonitoring", folder_.data())); + iHists.h_bySectOccupancy_ = iBooker.book1D( + "h_bySectorOccupancy", "hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect - 0.5); + + iBooker.setCurrentFolder(folder_); + static constexpr double min_depth_ = -100.; + static constexpr double max_depth_ = 400.; + static constexpr double min_drift_ = -500.; + static constexpr double max_drift_ = 500.; + + // book the mean values projections and set the bin names of the by sector monitoring + for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) { + for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) { + unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1]; + std::string binName = fmt::sprintf("BPix Lay%i Mod%i", i_layer, i_module); + LogDebug("SiPixelLorentzAnglePCLWorker") << " i_index: " << i_index << " bin name: " << binName + << " (i_layer: " << i_layer << " i_module:" << i_module << ")"; + + iHists.h_bySectOccupancy_->setBinLabel(i_index, binName); + + name = fmt::sprintf("h_mean_layer%i_module%i", i_layer, i_module); + title = fmt::sprintf( + "average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]", i_layer, i_module); + iHists.h_mean_[i_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_); + } } - } - for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) { - sprintf(name, "h_BPixnew_mean_%s", iHists.BPixnewmodulename_[i].c_str()); - sprintf(title, - "average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]", - iHists.BPixnewmodulename_[i].c_str()); - int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i; - iHists.h_mean_[new_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_); + for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) { + name = fmt::sprintf("h_BPixnew_mean_%s", iHists.BPixnewmodulename_[i].c_str()); + title = fmt::sprintf("average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]", + iHists.BPixnewmodulename_[i].c_str()); + int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i; + iHists.h_mean_[new_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_); - LogDebug("SiPixelLorentzAnglePCLWorker") << "i_index" << new_index << " bin name: " << iHists.BPixnewmodulename_[i]; + LogDebug("SiPixelLorentzAnglePCLWorker") + << "i_index" << new_index << " bin name: " << iHists.BPixnewmodulename_[i]; - iHists.h_bySectOccupancy_->setBinLabel(new_index, iHists.BPixnewmodulename_[i]); - } + iHists.h_bySectOccupancy_->setBinLabel(new_index, iHists.BPixnewmodulename_[i]); + } + + //book the 2D histograms + for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) { + iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/BPixLayer%i", folder_.data(), i_layer)); + for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) { + unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1]; + + name = fmt::sprintf("h_drift_depth_adc_layer%i_module%i", i_layer, i_module); + title = fmt::sprintf( + "depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); + iHists.h_drift_depth_adc_[i_index] = + iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); + + name = fmt::sprintf("h_drift_depth_adc2_layer%i_module%i", i_layer, i_module); + title = fmt::sprintf( + "depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); + iHists.h_drift_depth_adc2_[i_index] = + iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); + + name = fmt::sprintf("h_drift_depth_noadc_layer%i_module%i", i_layer, i_module); + title = fmt::sprintf( + "depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); + iHists.h_drift_depth_noadc_[i_index] = + iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); + + name = fmt::sprintf("h_drift_depth_layer%i_module%i", i_layer, i_module); + title = + fmt::sprintf("depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); + iHists.h_drift_depth_[i_index] = + iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); + } + } - //book the 2D histograms - for (int i_layer = 1; i_layer <= iHists.nlay; i_layer++) { - iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/BPixLayer%i", folder_.data(), i_layer)); - for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) { - unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1]; + // book the "new" modules + iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/NewModules", folder_.data())); + for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) { + int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i; - sprintf(name, "h_drift_depth_adc_layer%i_module%i", i_layer, i_module); - sprintf(title, "depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); - iHists.h_drift_depth_adc_[i_index] = + name = fmt::sprintf("h_BPixnew_drift_depth_adc_%s", iHists.BPixnewmodulename_[i].c_str()); + title = fmt::sprintf("depth vs drift (ADC) %s; drift [#mum]; production depth [#mum]", + iHists.BPixnewmodulename_[i].c_str()); + iHists.h_drift_depth_adc_[new_index] = iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - sprintf(name, "h_drift_depth_adc2_layer%i_module%i", i_layer, i_module); - sprintf( - title, "depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); - iHists.h_drift_depth_adc2_[i_index] = + name = fmt::sprintf("h_BPixnew_drift_depth_adc2_%s", iHists.BPixnewmodulename_[i].c_str()); + title = fmt::sprintf("depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]", + iHists.BPixnewmodulename_[i].c_str()); + iHists.h_drift_depth_adc2_[new_index] = iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - sprintf(name, "h_drift_depth_noadc_layer%i_module%i", i_layer, i_module); - sprintf( - title, "depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); - iHists.h_drift_depth_noadc_[i_index] = + name = fmt::sprintf("h_BPixnew_drift_depth_noadc_%s", iHists.BPixnewmodulename_[i].c_str()); + title = fmt::sprintf("depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]", + iHists.BPixnewmodulename_[i].c_str()); + iHists.h_drift_depth_noadc_[new_index] = iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - sprintf(name, "h_drift_depth_layer%i_module%i", i_layer, i_module); - sprintf(title, "depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module); - iHists.h_drift_depth_[i_index] = + name = fmt::sprintf("h_BPixnew_drift_depth_%s", iHists.BPixnewmodulename_[i].c_str()); + title = fmt::sprintf("depth vs drift %s; drift [#mum]; production depth [#mum]", + iHists.BPixnewmodulename_[i].c_str()); + iHists.h_drift_depth_[new_index] = iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); } - } - - // book the "new" modules - iBooker.setCurrentFolder(fmt::sprintf("%s/BPix/NewModules", folder_.data())); - for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) { - int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i; - - sprintf(name, "h_BPixnew_drift_depth_adc_%s", iHists.BPixnewmodulename_[i].c_str()); - sprintf( - title, "depth vs drift (ADC) %s; drift [#mum]; production depth [#mum]", iHists.BPixnewmodulename_[i].c_str()); - iHists.h_drift_depth_adc_[new_index] = - iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - - sprintf(name, "h_BPixnew_drift_depth_adc2_%s", iHists.BPixnewmodulename_[i].c_str()); - sprintf(title, - "depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]", - iHists.BPixnewmodulename_[i].c_str()); - iHists.h_drift_depth_adc2_[new_index] = - iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - - sprintf(name, "h_BPixnew_drift_depth_noadc_%s", iHists.BPixnewmodulename_[i].c_str()); - sprintf(title, - "depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]", - iHists.BPixnewmodulename_[i].c_str()); - iHists.h_drift_depth_noadc_[new_index] = - iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - - sprintf(name, "h_BPixnew_drift_depth_%s", iHists.BPixnewmodulename_[i].c_str()); - sprintf(title, "depth vs drift %s; drift [#mum]; production depth [#mum]", iHists.BPixnewmodulename_[i].c_str()); - iHists.h_drift_depth_[new_index] = - iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_); - } + } // end if GrazinAngleAnalysis + else { + iBooker.setCurrentFolder(folder_); + std::string baseName; + std::string baseTitle; + + for (int r = 0; r < iHists.nRings_; ++r) { + for (int p = 0; p < iHists.nPanels_; ++p) { + for (int s = 0; s < iHists.nSides_; ++s) { + baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1); + if (s == 0) + baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1); + else + baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1); + + int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s; + int idxBeta = iHists.betaStartIdx_ + idx; + + name = fmt::sprintf("%s_alphaMean", baseName); + title = fmt::sprintf("%s_alphaMean;cot(#alpha); Average cluster size x (pixel)", baseTitle); + iHists.h_fpixMean_[idx] = iBooker.book1D(name, title, 60, -3., 3.); + name = fmt::sprintf("%s_betaMean", baseName); + title = fmt::sprintf("%s_betaMean;cot(#beta); Average cluster size y (pixel)", baseTitle); + iHists.h_fpixMean_[idxBeta] = iBooker.book1D(name, title, 60, -3., 3.); + + } // loop over sides + } // loop over panels + } // loop over rings + iBooker.setCurrentFolder(fmt::sprintf("%s/FPix", folder_.data())); + for (int r = 0; r < iHists.nRings_; ++r) { + for (int p = 0; p < iHists.nPanels_; ++p) { + for (int s = 0; s < iHists.nSides_; ++s) { + baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1); + if (s == 0) + baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1); + else + baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1); + + int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s; + int idxBeta = iHists.betaStartIdx_ + idx; + + name = fmt::sprintf("%s_alpha", baseName); + title = fmt::sprintf("%s_alpha;cot(#alpha); Cluster size x (pixel)", baseTitle); + iHists.h_fpixAngleSize_[idx] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5); + name = fmt::sprintf("%s_beta", baseName); + title = fmt::sprintf("%s_beta;cot(#beta); Cluster size y (pixel) ", baseTitle); + iHists.h_fpixAngleSize_[idxBeta] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5); + for (int m = 0; m < 3; ++m) { + name = fmt::sprintf("%s_B%d", baseName, m); + char bComp = m == 0 ? 'x' : (m == 1 ? 'y' : 'z'); + title = fmt::sprintf("%s_magField%d;B_{%c} [T];Entries", baseTitle, m, bComp); + iHists.h_fpixMagField_[m][idx] = iBooker.book1D(name, title, 10000, -5., 5.); + } // mag. field comps + } // loop over sides + } // loop over panels + } // loop over rings + } // if MinimalClusterSize // book the track monitoring plots iBooker.setCurrentFolder(fmt::sprintf("%s/TrackMonitoring", folder_.data())); @@ -870,10 +992,17 @@ const std::pair SiPixelLorentzAnglePCLWorker::surface_de return lps; } +LorentzAngleAnalysisTypeEnum SiPixelLorentzAnglePCLWorker::convertStringToLorentzAngleAnalysisTypeEnum( + std::string type) { + return (type == "GrazingAngle") ? eGrazingAngle : eMinimumClusterSize; +} + // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void SiPixelLorentzAnglePCLWorker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.setComment("Worker module of the SiPixel Lorentz Angle PCL monitoring workflow"); + desc.add("analysisType", "GrazingAngle") + ->setComment("analysis type - GrazingAngle (default) or MinimumClusterSize"); desc.add("folder", "AlCaReco/SiPixelLorentzAngle")->setComment("directory of PCL Worker output"); desc.add("notInPCL", false)->setComment("create TTree (true) or not (false)"); desc.add("fileName", "testrun.root")->setComment("name of the TTree file if notInPCL = true"); diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_Output_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_Output_cff.py new file mode 100644 index 0000000000000..142d8d11e7e33 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_Output_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +OutALCARECOPromptCalibProdSiPixelLAMCS_noDrop = cms.PSet( + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOPromptCalibProdSiPixelLorentzAngleMCS') + ), + outputCommands = cms.untracked.vstring( + 'keep *_alcaBeamSpotProducer_*_*', + 'keep *_MEtoEDMConvertSiPixelLorentzAngleMCS_*_*', + ) +) +OutALCARECOPromptCalibProdSiPixelLAMCS=OutALCARECOPromptCalibProdSiPixelLAMCS_noDrop.clone() +OutALCARECOPromptCalibProdSiPixelLAMCS.outputCommands.insert(0, "drop *") diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py new file mode 100644 index 0000000000000..a03ef70f2e36d --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py @@ -0,0 +1,69 @@ +import FWCore.ParameterSet.Config as cms + +# ------------------------------------------------------------------------------ +# configure a filter to run only on the events selected by SiPixelCalCosmics AlcaReco +from HLTrigger.HLTfilters.hltHighLevel_cfi import * +ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS = hltHighLevel.clone( + HLTPaths = ['pathALCARECOSiPixelCalCosmics'], + throw = True, ## dont throw on unknown path names + TriggerResultsTag = ("TriggerResults","","RECO") +) +# ------------------------------------------------------------------------------ +# This is the sequence for track refitting of the track saved by SiPixelCalSingleMuonLoose +# to have access to transient objects produced during RECO step and not saved + +from Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi import * +ALCARECOPixelLACalibrationTracksMCS = AlignmentTrackSelector.clone( + src = 'ALCARECOSiPixelCalCosmics', + filter = True, + applyBasicCuts = True, + ptMin = 3. +) + +# FIXME: the beam-spot should be kept in the AlCaReco (if not already there) and dropped from here +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * +from RecoTracker.IterativeTracking.InitialStep_cff import * +from RecoTracker.Configuration.RecoTrackerP5_cff import * +from RecoTracker.TrackProducer.TrackRefitter_cfi import * +from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * + +ALCARECOPixelLACalibrationTracksRefitMCS = TrackRefitter.clone(src = "ALCARECOPixelLACalibrationTracksMCS", + TrajectoryInEvent = True, + NavigationSchool = "" + ) + +# refit and BS can be dropped if done together with RECO. +# track filter can be moved in acalreco if no otehr users +ALCARECOPixelLATrackFilterRefitMCS = cms.Sequence(ALCARECOPixelLACalibrationTracksMCS + + offlineBeamSpot + + ALCARECOPixelLACalibrationTracksRefitMCS) + +# ------------------------------------------------------------------------------ +# This is the module actually doing the calibration +from CalibTracker.SiPixelLorentzAngle.SiPixelLorentzAnglePCLWorker_cfi import SiPixelLorentzAnglePCLWorker +ALCARECOSiPixelLACalibMCS = SiPixelLorentzAnglePCLWorker.clone( + folder = 'AlCaReco/SiPixelLorentzAngle', + src = 'ALCARECOPixelLACalibrationTracksRefitMCS', + analysisType = 'MinimalClusterSize' +) +# ---------------------------------------------------------------------------- + +# **************************************************************************** +# ** Conversion for the SiPixelLorentzAngle DQM dir ** +# **************************************************************************** +MEtoEDMConvertSiPixelLorentzAngleMCS = cms.EDProducer("MEtoEDMConverter", + Name = cms.untracked.string('MEtoEDMConverter'), + Verbosity = cms.untracked.int32(0), # 0 provides no output + # 1 provides basic output + # 2 provide more detailed output + Frequency = cms.untracked.int32(50), + MEPathToSave = cms.untracked.string('AlCaReco/SiPixelLorentzAngle'), + ) + +# The actual sequence +seqALCARECOPromptCalibProdSiPixelLorentzAngleMCS = cms.Sequence( + ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS * + ALCARECOPixelLATrackFilterRefitMCS * + ALCARECOSiPixelLACalibMCS * + MEtoEDMConvertSiPixelLorentzAngleMCS + ) diff --git a/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cff.py b/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cff.py new file mode 100644 index 0000000000000..5a778e3a667d6 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cff.py @@ -0,0 +1,18 @@ +import FWCore.ParameterSet.Config as cms + +from Calibration.TkAlCaRecoProducers.AlcaSiPixelLorentzAngleHarvesterMCS_cfi import * +from DQMServices.Components.EDMtoMEConverter_cfi import * + +EDMtoMEConvertSiPixelLorentzAngleMCS = EDMtoMEConverter.clone( + lumiInputTag = ("MEtoEDMConvertSiPixelLorentzAngleMCS","MEtoEDMConverterLumi"), + runInputTag = ("MEtoEDMConvertSiPixelLorentzAngleMCS","MEtoEDMConverterRun") +) + +DQMStore = cms.Service("DQMStore") + +from DQMServices.Core.DQMEDHarvester import DQMEDHarvester +dqmEnvSiPixelLorentzAngleMCS = DQMEDHarvester('DQMHarvestingMetadata', + subSystemFolder = cms.untracked.string('AlCaReco'), + ) + +ALCAHARVESTSiPixelLorentzAngleMCS = cms.Sequence( EDMtoMEConvertSiPixelLorentzAngleMCS + alcaSiPixelLorentzAngleHarvesterMCS + dqmEnvSiPixelLorentzAngleMCS ) diff --git a/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cfi.py b/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cfi.py new file mode 100644 index 0000000000000..030d90f542ce3 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/AlcaSiPixelLorentzAngleHarvesterMCS_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +from CalibTracker.SiPixelLorentzAngle.SiPixelLorentzAnglePCLHarvesterMCS_cfi import SiPixelLorentzAnglePCLHarvesterMCS +alcaSiPixelLorentzAngleHarvesterMCS = SiPixelLorentzAnglePCLHarvesterMCS.clone() diff --git a/Calibration/TkAlCaRecoProducers/test/parseFwkJobReport.py b/Calibration/TkAlCaRecoProducers/test/parseFwkJobReport.py index 0e00433c55046..7a791bd69d3b9 100644 --- a/Calibration/TkAlCaRecoProducers/test/parseFwkJobReport.py +++ b/Calibration/TkAlCaRecoProducers/test/parseFwkJobReport.py @@ -8,6 +8,7 @@ 'BeamSpotObjectHP_ByLumi', 'BeamSpotObjectHP_ByRun', 'SiPixelLA_pcl', # SiPixel + 'SiPixelLAMCS_pcl', # SiPixel 'SiPixelQualityFromDbRcd_other', 'SiPixelQualityFromDbRcd_prompt', 'SiPixelQualityFromDbRcd_stuckTBM', diff --git a/Calibration/TkAlCaRecoProducers/test/testPCLAlCaHarvesting.py b/Calibration/TkAlCaRecoProducers/test/testPCLAlCaHarvesting.py index 514ad224358d3..46dd670f9ba67 100644 --- a/Calibration/TkAlCaRecoProducers/test/testPCLAlCaHarvesting.py +++ b/Calibration/TkAlCaRecoProducers/test/testPCLAlCaHarvesting.py @@ -84,6 +84,7 @@ def findRunStopTime(run_number): process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiPixelAli_dbOutput) process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiPixelAliHG_dbOutput) process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiPixelLA_dbOutput) +process.PoolDBOutputService.toPut.append(process.ALCAHARVESTSiPixelLAMCS_dbOutput) process.PoolDBOutputService.toPut.extend(process.ALCAHARVESTSiPixelQuality_dbOutput) process.PoolDBOutputService.toPut.append(process.ALCAHARVESTBeamSpotByRun_dbOutput) process.PoolDBOutputService.toPut.append(process.ALCAHARVESTBeamSpotByLumi_dbOutput) @@ -105,6 +106,7 @@ def findRunStopTime(run_number): process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiPixelAli_metadata) process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiPixelAliHG_metadata) process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiPixelLA_metadata) +process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTSiPixelLAMCS_metadata) process.pclMetadataWriter.recordsToMap.extend(process.ALCAHARVESTSiPixelQuality_metadata) process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTBeamSpotByRun_metadata) process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVESTBeamSpotByLumi_metadata) @@ -142,7 +144,7 @@ def findRunStopTime(run_number): process.SiPixelAliPedeAlignmentProducerHG.algoConfig.mergeBinaryFiles=[] process.SiPixelLA = cms.Path(process.ALCAHARVESTSiPixelLorentzAngle) - +process.SiPixelLAMCS = cms.Path(process.ALCAHARVESTSiPixelLorentzAngleMCS) process.SiPixelQuality = cms.Path(process.ALCAHARVESTSiPixelQuality) process.ALCAHARVESTDQMSaveAndMetadataWriter = cms.Path(process.dqmSaver+process.pclMetadataWriter) @@ -159,6 +161,7 @@ def findRunStopTime(run_number): process.SiPixelAli, process.SiPixelAliHG, process.SiPixelLA, + process.SiPixelLAMCS, process.SiPixelQuality, process.BeamSpotByRun, process.BeamSpotByLumi, diff --git a/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prep.json b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prep.json new file mode 100644 index 0000000000000..28fbe0f23aa1f --- /dev/null +++ b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prep.json @@ -0,0 +1,9 @@ +{ + "destinationDatabase": "oracle://cms_orcoff_prep/CMS_CONDITIONS", + "destinationTags": { + "SiPixelLorentzAngleMCS_byPCL_multirun_v0_prompt": {} + }, + "inputTag": "SiPixelLAMCS_pcl", + "since": null, + "userText": "Multirun Upload for SiPixelLA Minimal Cluster Size Method (prep)" +} diff --git a/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prod.json b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prod.json new file mode 100644 index 0000000000000..8158e63a4b34a --- /dev/null +++ b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_multirun_prod.json @@ -0,0 +1,9 @@ +{ + "destinationDatabase": "oracle://cms_orcon_prod/CMS_CONDITIONS", + "destinationTags": { + "SiPixelLorentzAngleMCS_byPCL_multirun_v0_prompt": {} + }, + "inputTag": "SiPixelLAMCS_pcl", + "since": null, + "userText": "Multirun Upload for SiPixelLorentzAngle Minimal Cluster Size Method" +} diff --git a/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prep.json b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prep.json new file mode 100644 index 0000000000000..18c1646564226 --- /dev/null +++ b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prep.json @@ -0,0 +1,9 @@ +{ + "destinationDatabase": "oracle://cms_orcoff_prep/CMS_CONDITIONS", + "destinationTags": { + "SiPixelLorentzAngleMCS_byPCL_v0_prompt": {} + }, + "inputTag": "SiPixelLAMCS_pcl", + "since": null, + "userText": "Tier0 PCL Upload for SiPixelLA Minimal Cluster Size (prep)" +} diff --git a/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prod.json b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prod.json new file mode 100644 index 0000000000000..67b2ce21a28fa --- /dev/null +++ b/CondFormats/Common/data/SiPixelLorentzAngleRcd_MCS_prod.json @@ -0,0 +1,9 @@ +{ + "destinationDatabase": "oracle://cms_orcon_prod/CMS_CONDITIONS", + "destinationTags": { + "SiPixelLorentzAngleMCS_byPCL_v0_prompt": {} + }, + "inputTag": "SiPixelLAMCS_pcl", + "since": null, + "userText": "Tier0 PCL Upload for SiPixelLorentzAngle Minimal Cluster Size Method" +} diff --git a/CondFormats/Common/test/DropBoxMetadataReader.py b/CondFormats/Common/test/DropBoxMetadataReader.py index 2d48c5754648f..4cfcf6e7a2a16 100644 --- a/CondFormats/Common/test/DropBoxMetadataReader.py +++ b/CondFormats/Common/test/DropBoxMetadataReader.py @@ -45,6 +45,7 @@ "SiPixelQualityFromDbRcd_stuckTBM", "SiPixelQualityFromDbRcd_other", "SiPixelLorentzAngleRcd", + "SiPixelLorentzAngleRcdMCS", "CTPPSRPAlignmentCorrectionsDataRcd", "PPSTimingCalibrationRcd_HPTDC", "PPSTimingCalibrationRcd_SAMPIC" diff --git a/CondFormats/Common/test/ProduceDropBoxMetadata.py b/CondFormats/Common/test/ProduceDropBoxMetadata.py index d102b7ca826d0..33fd33bf3d30b 100644 --- a/CondFormats/Common/test/ProduceDropBoxMetadata.py +++ b/CondFormats/Common/test/ProduceDropBoxMetadata.py @@ -91,6 +91,12 @@ def encodeJsonInString(filename): SiPixelLorentzAngleRcd_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_prep.json") SiPixelLorentzAngleRcd_multirun_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_multirun_prep.json") +#SiPixelLorenzAngle, FPix +SiPixelLorentzAngleRcd_MCS_prod_str = encodeJsonInString("SiPixelLorentzAngleRcd_MCS_prod.json") +SiPixelLorentzAngleRcd_MCS_multirun_prod_str = encodeJsonInString("SiPixelLorentzAngleRcd_MCS_multirun_prod.json") +SiPixelLorentzAngleRcd_MCS_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_MCS_prep.json") +SiPixelLorentzAngleRcd_MCS_multirun_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_MCS_multirun_prep.json") + #CT-PPS alignment and timing CTPPSRPAlignmentCorrectionsDataRcd_prod_str = encodeJsonInString("CTPPSRPAlignmentCorrectionsDataRcd_prod.json") CTPPSRPAlignmentCorrectionsDataRcd_prep_str = encodeJsonInString("CTPPSRPAlignmentCorrectionsDataRcd_prep.json") @@ -208,7 +214,15 @@ def encodeJsonInString(filename): prodMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_multirun_prod_str), prepMetaData = cms.untracked.string(SiPixelLorentzAngleRcd_prep_str), prepMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_multirun_prep_str), - ), + ), + cms.PSet(record = cms.untracked.string('SiPixelLorentzAngleRcdMCS'), + Source = cms.untracked.string("AlcaHarvesting"), + FileClass = cms.untracked.string("ALCA"), + prodMetaData = cms.untracked.string(SiPixelLorentzAngleRcd_MCS_prod_str), + prodMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_MCS_multirun_prod_str), + prepMetaData = cms.untracked.string(SiPixelLorentzAngleRcd_MCS_prep_str), + prepMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_MCS_multirun_prep_str), + ), cms.PSet(record = cms.untracked.string('CTPPSRPAlignmentCorrectionsDataRcd'), Source = cms.untracked.string("AlcaHarvesting"), FileClass = cms.untracked.string("ALCA"), diff --git a/Configuration/AlCa/python/autoAlca.py b/Configuration/AlCa/python/autoAlca.py index 4011e6923f988..e676eb9ddf498 100644 --- a/Configuration/AlCa/python/autoAlca.py +++ b/Configuration/AlCa/python/autoAlca.py @@ -13,7 +13,7 @@ "EGamma" : "EcalESAlign+EcalUncalWElectron+EcalUncalZElectron+HcalCalIsoTrkProducerFilter+HcalCalIterativePhiSym", "Express" : "SiStripCalZeroBias+TkAlMinBias+SiStripPCLHistos+SiStripCalMinBias+SiStripCalMinBiasAAG+Hotline+SiPixelCalZeroBias", "ExpressAlignment" : "TkAlMinBias", - "ExpressCosmics" : "SiStripPCLHistos+SiStripCalZeroBias+TkAlCosmics0T+SiPixelCalZeroBias", + "ExpressCosmics" : "SiStripPCLHistos+SiStripCalZeroBias+TkAlCosmics0T+SiPixelCalZeroBias+SiPixelCalCosmics", "HcalNZS" : "HcalCalMinBias", "HLTPhysics" : "TkAlMinBias", "JetHT" : "HcalCalIsoTrkProducerFilter+TkAlJetHT", diff --git a/Configuration/AlCa/python/autoPCL.py b/Configuration/AlCa/python/autoPCL.py index 4f67f9815da83..6e6fd9e8ece27 100644 --- a/Configuration/AlCa/python/autoPCL.py +++ b/Configuration/AlCa/python/autoPCL.py @@ -13,6 +13,7 @@ 'PromptCalibProdSiPixelAliHG' : 'SiPixelAliHG', 'PromptCalibProdSiPixel' : 'SiPixelQuality', 'PromptCalibProdSiPixelLA' : 'SiPixelLA', + 'PromptCalibProdSiPixelLAMCS' : 'SiPixelLAMCS', 'PromptCalibProdEcalPedestals': 'EcalPedestals', 'PromptCalibProdLumiPCC': 'LumiPCC', 'PromptCalibProdPPSTimingCalib' : 'PPSTimingCalibration', diff --git a/Configuration/EventContent/python/AlCaRecoOutput_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_cff.py index c4fb1dff232ec..12d7357e3e417 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_cff.py @@ -166,6 +166,7 @@ from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiStripGainsAAG_Output_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiStripHitEfficiency_Output_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiPixelLorentzAngle_Output_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_Output_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripPCLHistos_Output_cff import * from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAli_Output_cff import * from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAliHG_Output_cff import * diff --git a/Configuration/PyReleaseValidation/python/relval_production.py b/Configuration/PyReleaseValidation/python/relval_production.py index 07c4428688712..633f8d28b462b 100644 --- a/Configuration/PyReleaseValidation/python/relval_production.py +++ b/Configuration/PyReleaseValidation/python/relval_production.py @@ -34,6 +34,8 @@ workflows[1044] = ['',['RunRawPPS2022B','TIER0EXPPPSCALRUN3','ALCASPLITPPSCALRUN3','ALCAHARVDPPSCALRUN3']] workflows[1045] = ['',['RunRawPPS2022B','TIER0EXPPPSCALRUN3','ALCASPLITPPSALIGRUN3','ALCAHARVDPPSALIGRUN3']] +workflows[1052] = ['',['RunCosmics2022F','TIER0EXPCOSMICSRUN3','ALCAEXPCOSMICSRUN3','ALCAHARVDSIPIXELLAMCS']] +workflows[1052.1] = ['',['RunSiPixelCalCosmics2022F','ALCASPLITSIPIXELLAMCS','ALCAHARVDSIPIXELLAMCS']] ## MC production test #workflows[1100] = [ '',[]] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index e5bea0a9cef80..cd007f8c334ce 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -542,6 +542,11 @@ steps['RunTau2022D']={'INPUT':InputInfo(dataSet='/Tau/Run2022D-v1/RAW',label='2022D',events=100000,location='STD', ls=Run2022D)} steps['RunMuonEG2022D']={'INPUT':InputInfo(dataSet='/MuonEG/Run2022D-v1/RAW',label='2022D',events=100000,location='STD', ls=Run2022D)} +Run2022FCosmics_LS24={360336: [[24, 24]]} +Run2022FCosmics={360333: [[1,105]]} +steps['RunCosmics2022F']={'INPUT':InputInfo(dataSet='/Cosmics/Run2022F-v1/RAW',label='2022F',events=100000,location='STD', ls=Run2022FCosmics_LS24)} +steps['RunSiPixelCalCosmics2022F']={'INPUT':InputInfo(dataSet='/Cosmics/Run2022F-SiPixelCalCosmics-PromptReco-v1/ALCARECO',label='2022F',events=100000,location='STD', ls=Run2022FCosmics)} + # Highstat HLTPhysics Run2015DHS=selectedLS([258712,258713,258714,258741,258742,258745,258749,258750,259626,259637,259683,259685,259686,259721,259809,259810,259818,259820,259821,259822,259862,259890,259891]) steps['RunHLTPhy2015DHS']={'INPUT':InputInfo(dataSet='/HLTPhysics/Run2015D-v1/RAW',label='2015DHS',events=100000,location='STD', ls=Run2015DHS)} @@ -2158,6 +2163,17 @@ def lhegensim2018ml(fragment,howMuch): '--conditions':'auto:run3_data_express' },steps['TIER0']]) +steps['TIER0EXPCOSMICSRUN3']=merge([{'--scenario':'cosmics', + '-s':'RAW2DIGI,L1Reco,RECO,ALCAPRODUCER:@allForExpressCosmics,ENDJOB', + '-n':1000, + '--data':'', + '--process':'RECO', + '--era':'Run3', + '--conditions':'auto:run3_data_express', + '--datatier':'ALCARECO', + '--eventcontent':'ALCARECO', + '--customise_commands':'"process.source.eventsToProcess = cms.untracked.VEventRange(\'360336:24:422152-360336:24:422152\')"'},steps['TIER0EXP']]) + steps['TIER0PROMPTRUN3']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,ALCAPRODUCER:@allForPrompt+@allForExpress,DQM:@allForPrompt,ENDJOB', '--process':'RECO', '--datatier':'ALCARECO,DQMIO', @@ -2368,6 +2384,15 @@ def lhegensim2018ml(fragment,howMuch): '--triggerResultsProcess':'ALCARECO', } +steps['ALCASPLITSIPIXELLAMCS']={'-s':'ALCA:PromptCalibProdSiPixelLAMCS', + '-n':1000, + '--scenario':'cosmics', + '--era':'Run3', + '--datatier':'ALCARECO', + '--eventcontent':'ALCARECO', + '--conditions':'auto:run3_data_express', + '--customise_commands':'"process.ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS.HLTPaths = [\'*\']; process.ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS.TriggerResultsTag = cms.InputTag(\'TriggerResults\',\'\',\'HLT\')"'} + steps['ALCAHARVDHPBS']={'-s':'ALCAHARVEST:%s'%(autoPCL['PromptCalibProdBeamSpotHP']), #'--conditions':'auto:run2_data_promptlike', '--conditions':'auto:run3_data_express', # to replaced with line above once run2_data_promptlike will contain DropBoxMetadata @@ -2449,6 +2474,13 @@ def lhegensim2018ml(fragment,howMuch): '--era':'Run3', '--filein':'file:PromptCalibProdPPSAlignment.root'} +steps['ALCAHARVDSIPIXELLAMCS']={'-s':'ALCAHARVEST:%s'%(autoPCL['PromptCalibProdSiPixelLAMCS']), + '--conditions':'auto:run3_data_express', + '--scenario':'cosmics', + '--data':'', + '--era':'Run3', + '--filein':'file:PromptCalibProdSiPixelLAMCS.root'} + steps['RECOCOSD']=merge([{'--scenario':'cosmics', '-s':'RAW2DIGI,L1Reco,RECO,DQM', '--datatier':'RECO,DQMIO', # no miniAOD for cosmics @@ -2995,6 +3027,16 @@ def gen2021HiMix(fragment,howMuch): '--eventcontent':'ALCARECO', '--triggerResultsProcess': 'RECO'} +steps['ALCAEXPCOSMICSRUN3']={'-s':'ALCAOUTPUT:@allForExpressCosmics,ALCA:PromptCalibProdSiStrip+PromptCalibProdSiPixelLAMCS', + '-n':1000, + '--scenario':'cosmics', + '--era':'Run3', + '--datatier':'ALCARECO', + '--eventcontent':'ALCARECO', + '--conditions':'auto:run3_data_express', + '--triggerResultsProcess': 'RECO'} + + steps['ALCAEXPHI']=merge([{'-s':'ALCA:PromptCalibProd+PromptCalibProdSiStrip+PromptCalibProdSiStripGains+PromptCalibProdSiStripGainsAAG', '--scenario':'HeavyIons'},steps['ALCAEXP']]) steps['ALCAEXPTE']={'-s':'ALCA:PromptCalibProdEcalPedestals', diff --git a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py index 3e9888c46305f..ae0b5f80c6951 100644 --- a/Configuration/StandardSequences/python/AlCaHarvesting_cff.py +++ b/Configuration/StandardSequences/python/AlCaHarvesting_cff.py @@ -7,6 +7,7 @@ from Calibration.TkAlCaRecoProducers.AlcaSiStripGainsAAGHarvester_cff import * from Calibration.TkAlCaRecoProducers.AlcaSiStripHitEfficiencyHarvester_cff import * from Calibration.TkAlCaRecoProducers.AlcaSiPixelLorentzAngleHarvester_cff import * +from Calibration.TkAlCaRecoProducers.AlcaSiPixelLorentzAngleHarvesterMCS_cff import * from Alignment.CommonAlignmentProducer.AlcaSiPixelAliHarvester_cff import * from Alignment.CommonAlignmentProducer.AlcaSiPixelAliHarvesterHG_cff import * from Calibration.EcalCalibAlgos.AlcaEcalPedestalsHarvester_cff import * @@ -187,6 +188,14 @@ ) # -------------------------------------------------------------------------------------- +# SiPixel Lorentz Angle Minimal Cluster Size +ALCAHARVESTSiPixelLAMCS_metadata = cms.PSet(record = cms.untracked.string('SiPixelLorentzAngleRcdMCS')) + +ALCAHARVESTSiPixelLAMCS_dbOutput = cms.PSet(record = cms.string('SiPixelLorentzAngleRcdMCS'), + tag = cms.string('SiPixelLAMCS_pcl'), + timetype = cms.untracked.string('runnumber') + ) +# -------------------------------------------------------------------------------------- # ECAL Pedestals ALCAHARVESTEcalPedestals_metadata = cms.PSet(record = cms.untracked.string('EcalPedestalsRcd')) @@ -278,6 +287,7 @@ SiPixelAli = cms.Path(ALCAHARVESTSiPixelAli) SiPixelAliHG = cms.Path(ALCAHARVESTSiPixelAliHG) SiPixelLA = cms.Path(ALCAHARVESTSiPixelLorentzAngle) +SiPixelLAMCS = cms.Path(ALCAHARVESTSiPixelLorentzAngleMCS) EcalPedestals = cms.Path(ALCAHARVESTEcalPedestals) LumiPCC = cms.Path(ALCAHARVESTLumiPCC) SiPixelQuality = cms.Path(dqmEnvSiPixelQuality+ALCAHARVESTSiPixelQuality)#+siPixelPhase1DQMHarvester) diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index 110bcfa48124f..d87510eb078fa 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -161,6 +161,7 @@ from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiStripHitEfficiency_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiPixelLorentzAngle_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripPCLHistos_cff import * from Alignment.CommonAlignmentProducer.ALCARECOPromptCalibProdSiPixelAli_cff import * @@ -286,6 +287,7 @@ pathALCARECOPromptCalibProdSiStripGainsAAG = cms.Path(seqALCARECOPromptCalibProdSiStripGainsAAG) pathALCARECOPromptCalibProdSiStripHitEfficiency = cms.Path(seqALCARECOPromptCalibProdSiStripHitEfficiency) pathALCARECOPromptCalibProdSiPixelLorentzAngle = cms.Path(seqALCARECOPromptCalibProdSiPixelLorentzAngle) +pathALCARECOPromptCalibProdSiPixelLorentzAngleMCS = cms.Path(seqALCARECOPromptCalibProdSiPixelLorentzAngleMCS) pathALCARECOPromptCalibProdSiPixelAli = cms.Path(seqALCARECOPromptCalibProdSiPixelAli) pathALCARECOPromptCalibProdSiPixelAliHG = cms.Path(seqALCARECOPromptCalibProdSiPixelAliHG) pathALCARECOPromptCalibProdSiPixel = cms.Path(seqALCARECOPromptCalibProdSiPixel) @@ -1038,6 +1040,15 @@ dataTier = cms.untracked.string('ALCARECO') ) +ALCARECOStreamPromptCalibProdSiPixelLAMCS = cms.FilteredStream( + responsible = 'Tanja Susa', + name = 'PromptCalibProdSiPixelLAMCS', + paths = (pathALCARECOPromptCalibProdSiPixelLorentzAngleMCS), + content = OutALCARECOPromptCalibProdSiPixelLAMCS.outputCommands, + selectEvents = OutALCARECOPromptCalibProdSiPixelLAMCS.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + ALCARECOStreamPromptCalibProdSiPixelAli = cms.FilteredStream( responsible = 'Gianluca Cerminara', name = 'PromptCalibProdSiPixelAli',