Skip to content

Commit

Permalink
Merge pull request #44377 from mmusich/mm_fromkello-EL9patches
Browse files Browse the repository at this point in the history
[14.0.X] EL9-migration related patches to All-in-one
  • Loading branch information
cmsbuild authored Mar 13, 2024
2 parents 0fbdafe + d2bb401 commit 19f4a22
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 44 deletions.
18 changes: 9 additions & 9 deletions Alignment/OfflineValidation/bin/DMRtrends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ int trends(int argc, char *argv[]) {

for (auto const &Variable : validation.get_child("Variables")) {
vector<tuple<TString, TString, float, float>> DMRs{{"mu", "#mu [#mum]", -6, 6},
{"sigma", "#sigma_{#mu} [#mum]", -15, 15},
{"sigma", "#sigma_{#mu} [#mum]", -5, 5},
{"muplus", "#mu outward [#mum]", -6, 6},
{"sigmaplus", "#sigma_{#mu outward} [#mum]", -15, 15},
{"sigmaplus", "#sigma_{#mu outward} [#mum]", -5, 5},
{"muminus", "#mu inward [#mum]", -6, 6},
{"sigmaminus", "#sigma_{#mu inward} [#mum]", -15, 15},
{"deltamu", "#Delta#mu [#mum]", -15, 15},
{"sigmadeltamu", "#sigma_{#Delta#mu} [#mum]", -15, 15},
{"musigma", "#mu [#mum]", -6, 6},
{"muplussigmaplus", "#mu outward [#mum]", -15, 15},
{"muminussigmaminus", "#mu inward [#mum]", -15, 15},
{"deltamusigmadeltamu", "#Delta#mu [#mum]", -15, 15}};
{"sigmaminus", "#sigma_{#mu inward} [#mum]", -5, 5},
{"deltamu", "#Delta#mu [#mum]", -5, 5},
{"sigmadeltamu", "#sigma_{#Delta#mu} [#mum]", -5, 5},
{"musigma", "#mu [#mum]", -2, 4},
{"muplussigmaplus", "#mu outward [#mum]", -5, 5},
{"muminussigmaminus", "#mu inward [#mum]", -5, 5},
{"deltamusigmadeltamu", "#Delta#mu [#mum]", -5, 10}};

if (Variable.second.get_value<string>() == "DrmsNR") {
DMRs = {{"mu", "RMS(x'_{pred}-x'_{hit} /#sigma)", -1.2, 1.2},
Expand Down
9 changes: 6 additions & 3 deletions Alignment/OfflineValidation/bin/PVtrends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ int trends(int argc, char *argv[]) {
outputdir.data(),
Form("mean %s", titles[i].data()),
Form("mean %s", ytitles[i].data()),
-7.,
10.,
-4.,
8.,
style,
GetLumi,
lumiAxisType.data());
Expand All @@ -150,7 +150,7 @@ int trends(int argc, char *argv[]) {
Form("RMS %s", titles[i].data()),
Form("RMS %s", ytitles[i].data()),
0.,
35.,
25.,
style,
GetLumi,
lumiAxisType.data());
Expand Down Expand Up @@ -181,12 +181,15 @@ int trends(int argc, char *argv[]) {
int color = alignment.second.get<int>("color");
int style = floor(alignment.second.get<double>("style") / 100.);
gMean->SetMarkerColor(color);
gMean->SetLineColor(color); // no need to be set but looks better IMHO
gMean->SetMarkerStyle(style);
gMean->SetMarkerSize(1.6);

hRMS->SetTitle(gtitle); // for the legend
//hRMS ->SetTitle(""); // for the legend
hRMS->SetMarkerSize(0.6);
hRMS->SetMarkerColor(color);
hRMS->SetLineColor(color); // needs to be set, otherwise color is NOT picked up
hRMS->SetMarkerStyle(style);

mean(gMean, "PZ", "p", fullRange);
Expand Down
54 changes: 42 additions & 12 deletions Alignment/OfflineValidation/plugins/TrackerGeometryCompare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
#include "CalibTracker/Records/interface/SiStripQualityRcd.h"
#include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h"

#include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
#include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
Expand Down Expand Up @@ -228,11 +229,11 @@ void TrackerGeometryCompare::endJob() {
int iname(0);
for (std::vector<TrackerMap>::iterator it = m_vtkmap_.begin(); it != m_vtkmap_.end(); ++it) {
std::stringstream mapname;
mapname << surfdir_ << "/TkMap_SurfDeform" << iname << ".png";
mapname << surfdir_ << "/TkMap_SurfDeform_0" << iname << ".png";
it->save(true, 0, 0, mapname.str());
mapname.str(std::string());
mapname.clear();
mapname << surfdir_ << "/TkMap_SurfDeform" << iname << ".pdf";
mapname << surfdir_ << "/TkMap_SurfDeform_1" << iname << ".pdf";
it->save(true, 0, 0, mapname.str());
++iname;
}
Expand Down Expand Up @@ -403,6 +404,15 @@ void TrackerGeometryCompare::createROOTGeometry(const edm::EventSetup& iSetup) {
referenceTracker = new AlignableTracker(&(*theRefTracker), tTopo);
//referenceTracker->setSurfaceDeformation(surfDef1, true) ;

//set tracker pixel Phase, assume current tracker is the same Phase
if (theRefTracker->isThere(GeomDetEnumerators::P2PXB) || theRefTracker->isThere(GeomDetEnumerators::P2PXEC)) {
phase_ = SiPixelPI::phase::two;
} else if (theRefTracker->isThere(GeomDetEnumerators::P1PXB) || theRefTracker->isThere(GeomDetEnumerators::P1PXEC)) {
phase_ = SiPixelPI::phase::one;
} else {
phase_ = SiPixelPI::phase::zero;
}

int inputRawid1;
int inputRawid2;
int inputDtype1, inputDtype2;
Expand Down Expand Up @@ -526,7 +536,16 @@ void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* c
if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
}
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
if (phase_ < SiPixelPI::phase::two) {
if (phase_ == SiPixelPI::phase::zero) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
} else {
// old-style tracker map does not support Phase1 Pixel
if (!(inputSubdetid1 == 1 && inputSubdetid2 == 1) && !(inputSubdetid1 == 2 && inputSubdetid2 == 2)) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
}
}
}
}
}
}
Expand All @@ -545,7 +564,6 @@ void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* c
curTree->SetBranchAddress("dpar", &p_inputDpar2);

unsigned int nEntries12 = curTree->GetEntries();

for (unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
curTree->GetEntry(iEntry);
for (int ii = 0; ii < 12; ++ii) {
Expand All @@ -569,7 +587,16 @@ void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* c
if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
}
(m_vtkmap_.at(npar)).fill_current_val(inputRawid2, surfDeform_[npar]);
if (phase_ < SiPixelPI::phase::two) {
if (phase_ == SiPixelPI::phase::zero) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid2, surfDeform_[npar]);
} else {
// old-style tracker map does not support Phase1 Pixel
if (inputSubdetid2 != 1 && inputSubdetid2 != 2) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid2, surfDeform_[npar]);
}
}
}
}
}

Expand All @@ -585,7 +612,6 @@ void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* c
refTree->SetBranchAddress("subdetid", &inputSubdetid1);
refTree->SetBranchAddress("dtype", &inputDtype1);
refTree->SetBranchAddress("dpar", &p_inputDpar1);

unsigned int nEntries11 = refTree->GetEntries();

for (unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
Expand All @@ -611,14 +637,22 @@ void TrackerGeometryCompare::compareSurfaceDeformations(TTree* refTree, TTree* c
if (TMath::Abs(surfDeform_[npar]) > (m_rangeHigh_ - m_rangeLow_) / (10. * m_nBins_))
m_h1_[histname2.str()]->Fill(surfDeform_[npar]);
}
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
if (phase_ < SiPixelPI::phase::two) {
if (phase_ == SiPixelPI::phase::zero) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
} else {
// old-style tracker map does not support Phase1 Pixel
if (inputSubdetid1 != 1 && inputSubdetid1 != 2) {
(m_vtkmap_.at(npar)).fill_current_val(inputRawid1, surfDeform_[npar]);
}
}
}
}
}

} else if (inputFilename1_ == "IDEAL" && inputFilename2_ == "IDEAL") {
edm::LogInfo("TrackerGeometryCompare") << ">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
}

return;
}

Expand Down Expand Up @@ -709,7 +743,6 @@ void TrackerGeometryCompare::compareGeometries(Alignable* refAli,
<< ", rawId: " << refAli->geomDetId().rawId() << ", subdetId: " << detid.subdetId() << "): " << diff << check;
throw cms::Exception("Tolerance in TrackerGeometryCompare exceeded");
}

AlgebraicVector TRtot(12);
// global
TRtot(1) = Rtotal.x();
Expand Down Expand Up @@ -774,14 +807,12 @@ void TrackerGeometryCompare::setCommonTrackerSystem() {
TrackerCommonTR(6) = TrackerCommonR_.z();

edm::LogInfo("TrackerGeometryCompare") << "and after the transformation: " << TrackerCommonTR;

align::moveAlignable(currentTracker, TrackerCommonTR);
}

void TrackerGeometryCompare::diffCommonTrackerSystem(Alignable* refAli, Alignable* curAli) {
const auto& refComp = refAli->components();
const auto& curComp = curAli->components();

unsigned int nComp = refComp.size();
//only perform for designate levels
bool useLevel = false;
Expand Down Expand Up @@ -888,7 +919,6 @@ void TrackerGeometryCompare::fillTree(Alignable* refAli,
daVal_ = diff[9];
dbVal_ = diff[10];
dgVal_ = diff[11];

//detIdFlag
if (refAli->alignableObjectId() == align::AlignableDetUnit) {
if (detIdFlag_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class TrackerGeometryCompare : public edm::one::EDAnalyzer<> {
bool weightById_;
std::string weightByIdFile_;
std::vector<unsigned int> weightByIdVector_;
SiPixelPI::phase phase_;

std::vector<uint32_t> detIdFlagVector_;
align::StructureType commonTrackerLevel_;
Expand Down
1 change: 1 addition & 0 deletions Alignment/OfflineValidation/python/TkAlAllInOneTool/MTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def MTS(config, validationDir):
local = {}
local["output"] = "{}/{}/MTS/{}/{}/{}/{}".format(config["LFS"], config["name"], mtsType, alignment, singleName, IOV)
local["alignment"] = copy.deepcopy(config["alignments"][alignment])
local["alignment"]["name"] = alignment
local["validation"] = copy.deepcopy(config["validations"]["MTS"][mtsType][singleName])
local["validation"].pop("alignments")
local["validation"]["IOV"] = IOV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@
process,
"conditionsIn{}".format(condition),
poolDBESSource.clone(
# FIXME%START
connect = cms.string("sqlite_file:" + str(config["alignment"]["conditions"][condition]["connect"]) if "alignments_MP.db" in str(config["alignment"]["conditions"][condition]["connect"]) else str(config["alignment"]["conditions"][condition]["connect"])),
#FIXME%END
connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
toGet = cms.VPSet(
cms.PSet(
record = cms.string(str(condition)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_all_keys(var):
Generate all keys for nested dictionary
- reserved keywords are not picked up
"""
reserved_keys = ["customrighttitle","title"]
reserved_keys = ["customrighttitle","title","Rlabel"]
if hasattr(var,'items'):
for k, v in var.items():
if k in reserved_keys: continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ executable = run.sh
output = condor/condor.out
error = condor/condor.err
log = condor/condor.log
requirements = (OpSysAndVer =?= "CentOS7")
requirements = (OpSysAndVer =?= "AlmaLinux9")
+JobFlavour = "espresso"
+AccountingGroup = "group_u_CMS.CAF.ALCA"
queue
33 changes: 18 additions & 15 deletions Alignment/OfflineValidation/python/TkAlMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
'name' : 'r #Delta#phi',
'units': '#mum rad',
'scale': 10000.,
'range': [-200., 200.],
'range': [-100., 100.],
},
'dphi': {
'name' : '#Delta#phi',
Expand Down Expand Up @@ -222,7 +222,7 @@ def prepare_map_colors(self):
self.colors = []
#self.palette = array('i', [])
col_idx = self.start_color_idx + self.n_color_color_bar + 10
self.col_dic = {}
self.col_dic = {} #Never used explicitly but needs to keep TColor values in the global memory
self.rgb_map = {}
#pal_idx = 0
#self.pal_map = {}
Expand All @@ -236,16 +236,17 @@ def prepare_map_colors(self):
self.colors.append(idx)
col_idx +=1
self.rgb_map[idx] = col_idx
#print( idx, (r+0.)/255., (g+0.)/255., (b+0.)/255.)
#color = ROOT.TColor(col_idx, (r+0.)/255., (g+0.)/255., (b+0.)/255.)

#self.col_dic[idx] = ROOT.TColor(col_idx, (r+0.)/255., (g+0.)/255., (b+0.)/255.)
try:
col = ROOT.gROOT.GetColor(col_idx)
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.)
self.col_dic[idx] = col
col = ROOT.gROOT.GetColor(col_idx) #Here still OK
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.) #Here segmentation if color index does not exist
self.col_dic[idx] = col #Here the new color is saved in in the global variable
except:
self.col_dic[idx] = ROOT.TColor(col_idx, (r+0.)/255., (g+0.)/255., (b+0.)/255.)
#Here the 6 argument TColor init with dummy rgb must be used, 4 argument one does not work (ROOT bug?)
#New color index is defined and SetRGB must also be called to overwrite dummy rgb
col = ROOT.TColor(col_idx, 0., 0., 0., "", 1)
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.)
self.col_dic[idx] = col #Here the new color is saved in in the global variable
#self.palette.append(col_idx)
print('TkAlMap: map contains '+str(len(self.colors))+' colors')

Expand Down Expand Up @@ -273,7 +274,6 @@ def get_color_rgb(self, val):
value_range = self.max_val - self.min_val
if value_range == 0.: value_frac = 0.5
else: value_frac = (val - self.min_val + 0.)/(value_range + 0.)

if self.palette == 1:
r = 255
g = 255
Expand Down Expand Up @@ -323,7 +323,6 @@ def fill_colors(self):
col = self.rgb_map[rgb]
#col = self.pal_map[rgb]
#col = self.col_dic[rgb]
#print(val, rgb, col)
self.TkAlMap_TPL_dict[module].SetFillColor(col)
#self.TkAlMap_TPL_dict[module].SetFillColor(TEST_COLOR_IDX)
####else: print('Warning: Unknown module '+str(module))
Expand Down Expand Up @@ -373,11 +372,15 @@ def set_colorbar_colors(self):
col_idx += 1
r, g, b = self.get_color_rgb(val)
try:
col = ROOT.gROOT.GetColor(col_idx)
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.)
self.color_bar_colors[col_idx] = col
col = ROOT.gROOT.GetColor(col_idx) #Here still OK
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.) #Here segmentation if color index does not exist
self.color_bar_colors[col_idx] = col #Here the new color is saved in in the global variable
except:
self.color_bar_colors[col_idx] = ROOT.TColor(col_idx, (r+0.)/255., (g+0.)/255., (b+0.)/255.)
#Here the 6 argument TColor init with dummy rgb must be used, 4 argument one does not work (ROOT bug?)
#New color index is defined and SetRGB must also be called to overwrite dummy rgb
col = ROOT.TColor(col_idx, 0., 0., 0., "", 1)
col.SetRGB((r+0.)/255., (g+0.)/255., (b+0.)/255.)
self.color_bar_colors[col_idx] = col #Here the new color is saved in in the global variable
x2 = x1 + b_dx
y2 = y1 + b_dy + b_width
x = array('d', [x1, x1, x2, x2])
Expand Down
3 changes: 3 additions & 0 deletions Alignment/OfflineValidation/scripts/validateAlignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ def main():
## Customize the condor submit file for this specific job
condorSubmitCustomization = {"overwrite": [], "addBefore": []}

## Hack to solve condor dagman issue with passing environmental variables
condorSubmitCustomization["addBefore"].append('+JobFlavour|+environment = "CMSSW_BASE={}"'.format(fnc.digest_path("$CMSSW_BASE")))

# Take given flavour for the job, except if overwritten in job config
condorSubmitCustomization["overwrite"].append('+JobFlavour = "{}"'.format(args.job_flavour if not 'flavour' in job else job['flavour']))

Expand Down
2 changes: 2 additions & 0 deletions Alignment/OfflineValidation/src/Trend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ float Run2Lumi::operator()() const { return operator()(firstRun, lastRun); }
template <typename T>
void CopyStyle(T* objIn, T* objOut) {
objOut->SetLineColor(objIn->GetLineColor());
objOut->SetLineColor(objIn->GetMarkerColor());
objOut->SetMarkerColor(objIn->GetMarkerColor());
objOut->SetFillColorAlpha(objIn->GetFillColor(), 0.2); // TODO??

Expand Down Expand Up @@ -292,4 +293,5 @@ Trend::~Trend() {

c.RedrawAxis();
c.SaveAs(Form("%s/%s.pdf", outputDir, c.GetName()), Form("Title:%s", c.GetTitle()));
c.SaveAs(Form("%s/%s.png", outputDir, c.GetName()), Form("Title:%s", c.GetTitle()));
}

0 comments on commit 19f4a22

Please sign in to comment.