Skip to content

Commit

Permalink
Merge pull request #16 from cms-sw/master
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
kskovpen authored Dec 3, 2021
2 parents f69783f + 6d449f5 commit 43ac400
Show file tree
Hide file tree
Showing 521 changed files with 17,726 additions and 4,999 deletions.
6 changes: 3 additions & 3 deletions Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod {
const Alignments* dtAlignments,
const Alignments* cscAlignments,
const Alignments* gemAlignments,
const Alignments* globalPositionRcd,
const AlignmentErrorsExtended* dtAlignmentErrorsExtended,
const AlignmentErrorsExtended* cscAlignmentErrorsExtended,
const AlignmentErrorsExtended* gemAlignmentErrorsExtended);
const AlignmentErrorsExtended* gemAlignmentErrorsExtended,
const Alignments* globalPositionRcd);
~MuonAlignmentInputDB() override;

// ---------- const member functions ---------------------
Expand All @@ -67,10 +67,10 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod {
const Alignments* dtAlignments_;
const Alignments* cscAlignments_;
const Alignments* gemAlignments_;
const Alignments* globalPositionRcd_;
const AlignmentErrorsExtended* dtAlignmentErrorsExtended_;
const AlignmentErrorsExtended* cscAlignmentErrorsExtended_;
const AlignmentErrorsExtended* gemAlignmentErrorsExtended_;
const Alignments* globalPositionRcd_;

const bool m_getAPEs;
};
Expand Down
20 changes: 19 additions & 1 deletion Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> {
bool m_done;
std::string m_input, m_output;

std::string m_dtLabel, m_cscLabel, m_gemLabel;
std::string m_dtLabel, m_cscLabel, m_gemLabel, m_dtAPELabel, m_cscAPELabel, m_gemAPELabel;
double m_shiftErr, m_angleErr;
std::string m_fileName;
bool m_getAPEs;
Expand All @@ -76,6 +76,11 @@ class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> {
edm::ESGetToken<Alignments, DTAlignmentRcd> dtAliToken_;
edm::ESGetToken<Alignments, CSCAlignmentRcd> cscAliToken_;
edm::ESGetToken<Alignments, GEMAlignmentRcd> gemAliToken_;

edm::ESGetToken<AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd> dtAPEToken_;
edm::ESGetToken<AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd> cscAPEToken_;
edm::ESGetToken<AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd> gemAPEToken_;

const edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
};

Expand Down Expand Up @@ -116,6 +121,9 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi
m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
m_gemLabel = iConfig.getParameter<std::string>("gemLabel");
m_dtAPELabel = iConfig.getParameter<std::string>("dtAPELabel");
m_cscAPELabel = iConfig.getParameter<std::string>("cscAPELabel");
m_gemAPELabel = iConfig.getParameter<std::string>("gemAPELabel");
m_shiftErr = iConfig.getParameter<double>("shiftErr");
m_angleErr = iConfig.getParameter<double>("angleErr");
m_getAPEs = iConfig.getParameter<bool>("getAPEs");
Expand All @@ -125,6 +133,10 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi
cscAliToken_ = esConsumes(edm::ESInputTag("", m_cscLabel));
gemAliToken_ = esConsumes(edm::ESInputTag("", m_gemLabel));

dtAPEToken_ = esConsumes(edm::ESInputTag("", m_dtAPELabel));
cscAPEToken_ = esConsumes(edm::ESInputTag("", m_cscAPELabel));
gemAPEToken_ = esConsumes(edm::ESInputTag("", m_gemAPELabel));

dtGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML));
cscGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML));
gemGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML));
Expand Down Expand Up @@ -173,6 +185,9 @@ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::Event
&iSetup.getData(dtAliToken_),
&iSetup.getData(cscAliToken_),
&iSetup.getData(gemAliToken_),
&iSetup.getData(dtAPEToken_),
&iSetup.getData(cscAPEToken_),
&iSetup.getData(gemAPEToken_),
&iSetup.getData(gprToken_));
MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod);
if (m_getAPEs) {
Expand Down Expand Up @@ -216,6 +231,9 @@ void MuonGeometryDBConverter::fillDescriptions(edm::ConfigurationDescriptions &d
desc.add<std::string>("dtLabel", "");
desc.add<std::string>("cscLabel", "");
desc.add<std::string>("gemLabel", "");
desc.add<std::string>("dtAPELabel", "");
desc.add<std::string>("cscAPELabel", "");
desc.add<std::string>("gemAPELabel", "");
desc.add<double>("shiftErr", 1000.0);
desc.add<double>("angleErr", 6.28);
desc.add<bool>("getAPEs", true);
Expand Down
6 changes: 3 additions & 3 deletions Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ MuonAlignmentInputDB::MuonAlignmentInputDB(const DTGeometry* dtGeometry,
const Alignments* dtAlignments,
const Alignments* cscAlignments,
const Alignments* gemAlignments,
const Alignments* globalPositionRcd,
const AlignmentErrorsExtended* dtAlignmentErrorsExtended,
const AlignmentErrorsExtended* cscAlignmentErrorsExtended,
const AlignmentErrorsExtended* gemAlignmentErrorsExtended)
const AlignmentErrorsExtended* gemAlignmentErrorsExtended,
const Alignments* globalPositionRcd)
: dtGeometry_(dtGeometry),
cscGeometry_(cscGeometry),
gemGeometry_(gemGeometry),
dtAlignments_(dtAlignments),
cscAlignments_(cscAlignments),
gemAlignments_(gemAlignments),
globalPositionRcd_(globalPositionRcd),
dtAlignmentErrorsExtended_(dtAlignmentErrorsExtended),
cscAlignmentErrorsExtended_(cscAlignmentErrorsExtended),
gemAlignmentErrorsExtended_(gemAlignmentErrorsExtended),
globalPositionRcd_(globalPositionRcd),
m_getAPEs(true) {}

// MuonAlignmentInputDB::MuonAlignmentInputDB(const MuonAlignmentInputDB& rhs)
Expand Down
32 changes: 24 additions & 8 deletions Alignment/OfflineValidation/macros/FitPVResiduals.C
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ void arrangeFitCanvas(TCanvas *canv, TH1F *meanplots[100], Int_t nFiles, TString
hnewUp->Draw("same");
makeNewXAxis(hnewUp);
}
fright[j]->Draw("sames");
fright[j]->Draw("same");
fleft[j]->Draw("same");
fall[j]->Draw("same");
}
Expand Down Expand Up @@ -4054,13 +4054,29 @@ void makeNewXAxis(TH1F *h)
void makeNewPairOfAxes(TH2F *h)
/*--------------------------------------------------------------------*/
{
int ndivx = 505;
float axmin = -etaRange;
float axmax = etaRange;

int ndivy = 510;
float aymin = -TMath::Pi();
float aymax = TMath::Pi();
TString myTitle = h->GetName();
// fake defaults
float axmin = -999;
float axmax = 999.;
float aymin = -999;
float aymax = 999.;
int ndivx = h->GetXaxis()->GetNdivisions();
int ndivy = h->GetYaxis()->GetNdivisions();

if (!myTitle.Contains("L1Map")) {
ndivx = 505;
ndivy = 510;
axmin = -etaRange;
axmax = etaRange;
aymin = -TMath::Pi();
aymax = TMath::Pi();
} else {
// this is a L1 map
axmin = 0.5;
axmax = nModZ_ + 0.5;
aymin = 0.5;
aymax = nLadders_ + 0.5;
}

// Remove the current axis
h->GetXaxis()->SetLabelOffset(999);
Expand Down
19 changes: 10 additions & 9 deletions Alignment/OfflineValidation/macros/FitPVResolution.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

float SUMPTMIN = 1.;
float SUMPTMAX = 1e3;
int TRACKBINS = 60;
int VTXBINS = 40;
int TRACKBINS = 120;
int VTXBINS = 60;

/*
This is an auxilliary class to store the list of files
Expand Down Expand Up @@ -257,9 +257,9 @@ void FitPVResolution(TString namesandlabels, TString theDate = "", bool isStrict
std::cout << "File n. " << i << " getting the default minimum sum pT range: " << theSumPtMin_[i] << std::endl;
theSumPtMax_[i] = 1e3;
std::cout << "File n. " << i << " getting the default maxmum sum pT range: " << theSumPtMax_[i] << std::endl;
theTrackBINS_[i] = 60.;
theTrackBINS_[i] = 120.;
std::cout << "File n. " << i << " getting the default number of tracks bins: " << theTrackBINS_[i] << std::endl;
theTrackBINS_[i] = 40.;
theTrackBINS_[i] = 60.;
std::cout << "File n. " << i << " getting the default number of vertices bins: " << theVtxBINS_[i] << std::endl;
}
}
Expand Down Expand Up @@ -335,17 +335,17 @@ void FitPVResolution(TString namesandlabels, TString theDate = "", bool isStrict
}

// max vertices
const int max_n_vertices = std::min(40, VTXBINS); // take the minimum to avoid overflow
const int max_n_vertices = std::min(60, VTXBINS); // take the minimum to avoid overflow
std::vector<float> myNVtx_bins_;
for (float i = 0; i <= max_n_vertices; i++) {
myNVtx_bins_.push_back(1. + i);
myNVtx_bins_.push_back(i - 0.5f);
}

// max track
const int max_n_tracks = std::min(60, TRACKBINS); // take the minimum to avoid overflow
const int max_n_tracks = std::min(120, TRACKBINS); // take the minimum to avoid overflow
std::vector<float> myNTrack_bins_;
for (float i = 0; i <= max_n_tracks; i++) {
myNTrack_bins_.push_back(1 + i * 2);
myNTrack_bins_.push_back(i - 0.5f);
}

// max sumPt
Expand Down Expand Up @@ -988,7 +988,7 @@ void fillTrendPlotByIndex(TH1F* trendPlot,
std::smatch match;
if (std::regex_search(iterator.first, match, toMatch) && match.size() > 1) {
result = match.str(1);
bin = std::stoi(result);
bin = std::stoi(result) + 1;
} else {
result = std::string("");
continue;
Expand Down Expand Up @@ -1131,6 +1131,7 @@ void setPVResolStyle() {

writeExtraText = true; // if extra text
lumi_13TeV = "p-p collisions";
lumi_0p9TeV = "p-p collisions";
extraText = "Internal";

TH1::StatOverflows(kTRUE);
Expand Down
78 changes: 60 additions & 18 deletions Alignment/OfflineValidation/plugins/SplitVertexResolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <chrono>
#include <iostream>
#include <random>
#include <fmt/printf.h>
#include <boost/range/adaptor/indexed.hpp>

// ROOT include files
Expand Down Expand Up @@ -255,11 +256,11 @@ class SplitVertexResolution : public edm::one::EDAnalyzer<edm::one::WatchRuns, e
static const int nPtBins_ = 30;
std::array<float, nPtBins_ + 1> mypT_bins_;

static const int nTrackBins_ = 60;
static const int nTrackBins_ = 120;
const double nVisTrackBins_; // will be configured
std::array<float, nTrackBins_ + 1> myNTrack_bins_;

static const int nVtxBins_ = 40;
static const int nVtxBins_ = 60;
const double nVisVtxBins_; // will be configured
std::array<float, nVtxBins_ + 1> myNVtx_bins_;

Expand All @@ -285,8 +286,8 @@ SplitVertexResolution::SplitVertexResolution(const edm::ParameterSet& iConfig)
// binning
sumpTStartScale_(iConfig.getUntrackedParameter<double>("sumpTStartScale", 1.)),
sumpTEndScale_(iConfig.getUntrackedParameter<double>("sumpTEndScale", 1e3)),
nVisTrackBins_(iConfig.getUntrackedParameter<double>("nTrackBins", 60.)),
nVisVtxBins_(iConfig.getUntrackedParameter<double>("nVtxBins", 40.)) {
nVisTrackBins_(iConfig.getUntrackedParameter<double>("nTrackBins", 120.)),
nVisVtxBins_(iConfig.getUntrackedParameter<double>("nVtxBins", 60.)) {
usesResource(TFileService::kSharedResource);

std::vector<unsigned int> defaultRuns;
Expand All @@ -295,12 +296,55 @@ SplitVertexResolution::SplitVertexResolution(const edm::ParameterSet& iConfig)

mypT_bins_ = PVValHelper::makeLogBins<float, nPtBins_>(sumpTStartScale_, sumpTEndScale_);

std::vector<float> vect = PVValHelper::generateBins(nTrackBins_ + 1, 1., 120.);
// IMPORTANT
// first argument is start, second argument is the range so it's [-0.5;nTracksBins_-0.5]
std::vector<float> vect = PVValHelper::generateBins(nTrackBins_ + 1, -0.5, nTrackBins_);
std::copy(vect.begin(), vect.begin() + nTrackBins_ + 1, myNTrack_bins_.begin());

vect.clear();
vect = PVValHelper::generateBins(nVtxBins_ + 1, 1., 40.);

// IMPORTANT
// first argument is start, second argument is the range so it's [-0.5;nVtxBins_-0.5]
vect = PVValHelper::generateBins(nVtxBins_ + 1, -0.5, nVtxBins_);
std::copy(vect.begin(), vect.begin() + nVtxBins_ + 1, myNVtx_bins_.begin());

if (debug_) {
std::string toOutput = "";
for (const auto& pTbin : mypT_bins_ | boost::adaptors::indexed(1)) {
if (pTbin.index() != 1) {
toOutput += " ";
}
toOutput += fmt::sprintf("%.2f", pTbin.value());
if (pTbin.index() != nPtBins_ + 1) {
toOutput += ",";
}
}
edm::LogVerbatim("SplitVertexResolution") << "sum(pT) bins = [" << toOutput << "] \n";

toOutput.clear();
for (const auto& tkbin : myNTrack_bins_ | boost::adaptors::indexed(1)) {
if (tkbin.index() != 1) {
toOutput += " ";
}
toOutput += fmt::sprintf("%.1f", tkbin.value());
if (tkbin.index() != nTrackBins_ + 1) {
toOutput += ",";
}
}
edm::LogVerbatim("SplitVertexResolution") << "n. track bins = [" << toOutput << "] \n";

toOutput.clear();
for (const auto& vtxbin : myNVtx_bins_ | boost::adaptors::indexed(1)) {
if (vtxbin.index() != 1) {
toOutput += " ";
}
toOutput += fmt::sprintf("%.1f", vtxbin.value());
if (vtxbin.index() != nVtxBins_ + 1) {
toOutput += ",";
}
}
edm::LogVerbatim("SplitVertexResolution") << "n. vertices bins = [" << toOutput << "] \n";
}
}

SplitVertexResolution::~SplitVertexResolution() = default;
Expand Down Expand Up @@ -539,8 +583,8 @@ void SplitVertexResolution::analyze(const edm::Event& iEvent, const edm::EventSe
for (int inTrackBin = 0; inTrackBin < nTrackBins_; inTrackBin++) {
float nTrackF = myNTrack_bins_[inTrackBin];
float nTrackL = myNTrack_bins_[inTrackBin + 1];

if (ntrks >= nTrackF && ntrks < nTrackL) {
//if (ntrks == inTrackBin) {
PVValHelper::fillByIndex(h_resolX_Ntracks_, inTrackBin, resX * cmToUm, "7");
PVValHelper::fillByIndex(h_resolY_Ntracks_, inTrackBin, resY * cmToUm, "8");
PVValHelper::fillByIndex(h_resolZ_Ntracks_, inTrackBin, resZ * cmToUm, "9");
Expand All @@ -554,13 +598,10 @@ void SplitVertexResolution::analyze(const edm::Event& iEvent, const edm::EventSe
// filling the vertex multeplicity binned distributions

for (int inVtxBin = 0; inVtxBin < nVtxBins_; inVtxBin++) {
/*
float nVtxF = myNVtx_bins_[inVtxBin];
float nVtxL = myNVtx_bins_[inVtxBin+1];
if(nOfflineVtx >= nVtxF && nOfflineVtx < nVtxL){
*/

if (nOfflineVtx == inVtxBin) {
float nVtxF = myNVtx_bins_[inVtxBin];
float nVtxL = myNVtx_bins_[inVtxBin + 1];
if (nOfflineVtx >= nVtxF && nOfflineVtx < nVtxL) {
//if (nOfflineVtx == inVtxBin) {
PVValHelper::fillByIndex(h_resolX_Nvtx_, inVtxBin, deltaX * cmToUm, "7");
PVValHelper::fillByIndex(h_resolY_Nvtx_, inVtxBin, deltaY * cmToUm, "8");
PVValHelper::fillByIndex(h_resolZ_Nvtx_, inVtxBin, deltaZ * cmToUm, "9");
Expand Down Expand Up @@ -1064,8 +1105,8 @@ void SplitVertexResolution::fillDescriptions(edm::ConfigurationDescriptions& des
desc.addUntracked<std::vector<unsigned int>>("runControlNumber", {});
desc.addUntracked<double>("sumpTStartScale", 1.);
desc.addUntracked<double>("sumpTEndScale", 1e3);
desc.addUntracked<double>("nTrackBins", 60.);
desc.addUntracked<double>("nVtxBins", 40.);
desc.addUntracked<double>("nTrackBins", 120.);
desc.addUntracked<double>("nVtxBins", 60.);
descriptions.addWithDefaultLabel(desc);
}

Expand All @@ -1075,7 +1116,8 @@ std::pair<long long, long long> SplitVertexResolution::getRunTime(const edm::Eve
{
const auto& runInfo = iSetup.getData(runInfoToken_);
if (debug_) {
edm::LogInfo("SplitVertexResolution") << runInfo.m_start_time_str << " " << runInfo.m_stop_time_str << std::endl;
edm::LogInfo("SplitVertexResolution")
<< "start time: " << runInfo.m_start_time_str << " - stop time: " << runInfo.m_stop_time_str << std::endl;
}
return std::make_pair(runInfo.m_start_time_ll, runInfo.m_stop_time_ll);
}
Expand All @@ -1085,7 +1127,7 @@ void SplitVertexResolution::fillTrendPlotByIndex(TH1F* trendPlot, std::vector<TH
//*************************************************************
{
for (auto iterator = h.begin(); iterator != h.end(); iterator++) {
unsigned int bin = std::distance(h.begin(), iterator);
unsigned int bin = std::distance(h.begin(), iterator) + 1;
statmode::fitParams myFit = fitResiduals((*iterator));

switch (fitPar_) {
Expand Down
8 changes: 5 additions & 3 deletions Alignment/OfflineValidation/src/PVValidationHelpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ std::vector<float> PVValHelper::generateBins(int n, float start, float range)
float interval = range / (n - 1);
std::iota(v.begin(), v.end(), 1.);

//std::cout<<" interval:"<<interval<<std::endl;
//for(float &a : v) { std::cout<< a << " "; }
//std::cout<< "\n";
/*
std::cout<<" interval:"<<interval<<std::endl;
for(float &a : v) { std::cout<< a << " "; }
std::cout<< "\n";
*/

std::for_each(begin(v), end(v), [&](float& a) { a = start + ((a - 1) * interval); });

Expand Down
Loading

0 comments on commit 43ac400

Please sign in to comment.