Skip to content

Commit 83e721b

Browse files
authored
Merge branch 'master' into from-CMSSW_14_1_X_2024-05-22-2300_KBv1
2 parents 948fd54 + ab77a26 commit 83e721b

File tree

53 files changed

+851
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+851
-166
lines changed

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Checks: -*,
2323
,readability-uniqueptr-delete-release
2424
WarningsAsErrors: ''
2525
HeaderFilterRegex: ''
26-
AnalyzeTemporaryDtors: false
2726
CheckOptions:
2827
- key: google-readability-braces-around-statements.ShortStatementLines
2928
value: '1'

Alignment/OfflineValidation/bin/Zmumumerge.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,18 @@ int Zmumumerge(int argc, char* argv[]) {
374374
pt::ptree alignments = main_tree.get_child("alignments");
375375
pt::ptree validation = main_tree.get_child("validation");
376376

377+
//Load defined order
378+
std::vector<std::pair<std::string, pt::ptree>> alignmentsOrdered;
377379
for (const auto& childTree : alignments) {
380+
alignmentsOrdered.push_back(childTree);
381+
}
382+
std::sort(alignmentsOrdered.begin(),
383+
alignmentsOrdered.end(),
384+
[](const std::pair<std::string, pt::ptree>& left, const std::pair<std::string, pt::ptree>& right) {
385+
return left.second.get<int>("index") < right.second.get<int>("index");
386+
});
387+
388+
for (const auto& childTree : alignmentsOrdered) {
378389
// do not consider the nodes with a "file" to merge
379390
if (childTree.second.find("file") == childTree.second.not_found()) {
380391
std::cerr << "Ignoring alignment: " << childTree.second.get<std::string>("title") << ".\nNo file to merged found!"

Alignment/OfflineValidation/python/TkAlAllInOneTool/DMRplotter.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ def __log__(self,log_type="",text=""):
5151
else:
5252
print(text)
5353

54+
def _middleString(self, fullString):
55+
##############################################################
56+
#Auxiliary function to retrieve object name from full string
57+
##############################################################
58+
59+
middleString = "_".join(fullString.split("_")[1:])
60+
if middleString.endswith("_y"): middleString = "_".join(middleString.split("_")[:-1])
61+
middleString = "_".join(middleString.split("_")[:-1])
62+
return middleString
63+
64+
5465
def _replaceMulti(self, mainString, toBeReplaced, newString):
5566
#################################
5667
#Auxiliary function to remove
@@ -339,7 +350,7 @@ def __defineObjects__(self):
339350
if objName in objAreIgnored: continue
340351
objDict[objName] = []
341352
for obj in objList:
342-
if objName in obj.GetName():
353+
if objName == self._middleString(obj.GetName()):
343354
segment = ""
344355
var = ""
345356
if obj.GetName()[-1] == "y":
@@ -834,7 +845,7 @@ def addMC(self,filename):
834845

835846
def plotSingle(self):
836847
##############################################
837-
#Auxiliary plotter for unweighted Data and MC
848+
#Auxiliary plotter for unweighted Data and MC
838849
##############################################
839850

840851
#check for input file and create output dir
@@ -993,7 +1004,7 @@ def plot(self):
9931004
#order plots & prepare y-axis scale factors
9941005
isEmpty = True
9951006
maxY = 0.0
996-
objGroup = []
1007+
objGroup = []
9971008
for objName in self.objNameList: #follow plotting order
9981009
for obj in objects[objName]:
9991010
if obj['var'] == var and obj['segment'] == segment:
@@ -1010,14 +1021,13 @@ def plot(self):
10101021
legStyle = "l"
10111022
if obj['type'] == "DATA":
10121023
drawStyle += "P HIST SAME"
1013-
legStyle = "p"
1024+
legStyle = "p"
10141025
objGroup.append({'hist' : obj['hist'],
10151026
'label' : legendLabel,
10161027
'stat' : self.__getStat__(obj['hist'],var),
10171028
'drawStyle' : drawStyle,
10181029
'legStyle' : legStyle
10191030
})
1020-
10211031
#draw & save
10221032
if not isEmpty:
10231033
legMinY = (1./self.legendOffset)+(1.-1./self.legendOffset)*(self.maxEntriesPerColumn-len(objGroup))/(self.maxEntriesPerColumn*3)

Alignment/OfflineValidation/python/TkAlAllInOneTool/Zmumu.py

Lines changed: 105 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,53 @@
33

44
def Zmumu(config, validationDir):
55
##List with all jobs
6-
jobs = []
6+
jobs, singleJobs = [], []
77
zmumuType = "single"
88

9-
##List with all wished IOVs
10-
IOVs = []
9+
##Dictionary of lists of all IOVs (can be different per each single job)
10+
IOVs = {}
11+
12+
##Auxilliary dictionary of isData flags per each merged job
13+
isDataMerged = {}
1114

1215
##Start with single Zmumu jobs
1316
if not zmumuType in config["validations"]["Zmumu"]:
1417
raise Exception("No 'single' key word in config for Zmumu")
1518

16-
for datasetName in config["validations"]["Zmumu"][zmumuType]:
17-
for IOV in config["validations"]["Zmumu"][zmumuType][datasetName]["IOV"]:
19+
for singleName in config["validations"]["Zmumu"][zmumuType]:
20+
aux_IOV = config["validations"]["Zmumu"][zmumuType][singleName]["IOV"]
21+
if not isinstance(aux_IOV, list) and aux_IOV.endswith(".txt"):
22+
config["validations"]["Zmumu"][zmumuType][singleName]["IOV"] = []
23+
with open(aux_IOV, 'r') as IOVfile:
24+
for line in IOVfile.readlines():
25+
if len(line) != 0: config["validations"]["Zmumu"][zmumuType][singleName]["IOV"].append(int(line))
26+
for IOV in config["validations"]["Zmumu"][zmumuType][singleName]["IOV"]:
1827
##Save IOV to loop later for merge jobs
19-
if not IOV in IOVs:
20-
IOVs.append(IOV)
28+
if singleName not in IOVs.keys():
29+
IOVs[singleName] = []
30+
if IOV not in IOVs[singleName]:
31+
IOVs[singleName].append(IOV)
2132

22-
for alignment in config["validations"]["Zmumu"][zmumuType][datasetName]["alignments"]:
33+
for alignment in config["validations"]["Zmumu"][zmumuType][singleName]["alignments"]:
2334
##Work directory for each IOV
24-
workDir = "{}/Zmumu/{}/{}/{}/{}".format(validationDir, zmumuType, datasetName, alignment, IOV)
35+
workDir = "{}/Zmumu/{}/{}/{}/{}".format(validationDir, zmumuType, singleName, alignment, IOV)
2536

2637
##Write local config
2738
local = {}
28-
local["output"] = "{}/{}/{}/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, alignment, datasetName, IOV)
39+
local["output"] = "{}/{}/Zmumu/{}/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, alignment, singleName, IOV)
2940
local["alignment"] = copy.deepcopy(config["alignments"][alignment])
30-
local["validation"] = copy.deepcopy(config["validations"]["Zmumu"][zmumuType][datasetName])
41+
local["alignment"]["name"] = alignment
42+
local["validation"] = copy.deepcopy(config["validations"]["Zmumu"][zmumuType][singleName])
3143
local["validation"].pop("alignments")
3244
local["validation"]["IOV"] = IOV
45+
if "dataset" in local["validation"]:
46+
local["validation"]["dataset"] = local["validation"]["dataset"].format(IOV)
3347
if "goodlumi" in local["validation"]:
3448
local["validation"]["goodlumi"] = local["validation"]["goodlumi"].format(IOV)
3549

3650
##Write job info
3751
job = {
38-
"name": "Zmumu_{}_{}_{}_{}".format(zmumuType, alignment, datasetName, IOV),
52+
"name": "Zmumu_{}_{}_{}_{}".format(zmumuType, alignment, singleName, IOV),
3953
"dir": workDir,
4054
"exe": "cmsRun",
4155
"cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/Zmumu_cfg.py".format(os.environ["CMSSW_BASE"]),
@@ -44,7 +58,9 @@ def Zmumu(config, validationDir):
4458
"config": local,
4559
}
4660

47-
jobs.append(job)
61+
singleJobs.append(job)
62+
63+
jobs.extend(singleJobs)
4864

4965
##Do merge Zmumu if wished
5066
if "merge" in config["validations"]["Zmumu"]:
@@ -54,40 +70,84 @@ def Zmumu(config, validationDir):
5470

5571
##Loop over all merge jobs/IOVs which are wished
5672
for mergeName in config["validations"]["Zmumu"][zmumuType]:
57-
for IOV in IOVs:
58-
##Work directory for each IOV
59-
workDir = "{}/Zmumu/{}/{}/{}".format(validationDir, zmumuType, mergeName, IOV)
60-
61-
##Write job info
62-
local = {}
63-
64-
job = {
65-
"name": "Zmumu_{}_{}_{}".format(zmumuType, mergeName, IOV),
66-
"dir": workDir,
67-
"exe": "Zmumumerge",
68-
"run-mode": "Condor",
69-
"dependencies": [],
70-
"config": local,
71-
}
72-
73-
for alignment in config["alignments"]:
74-
##Deep copy necessary things from global config
75-
local.setdefault("alignments", {})
76-
local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
73+
##Search for MC single(s)
74+
singlesMC = []
75+
for singleName in config["validations"]["Zmumu"][zmumuType][mergeName]['singles']:
76+
if len(IOVs[singleName]) == 1 and int(IOVs[singleName][0]) == 1: singlesMC.append(singleName)
77+
isMConly = (len(singlesMC) == len(config["validations"]["Zmumu"][zmumuType][mergeName]['singles']))
78+
if isMConly:
79+
isDataMerged[mergeName] = 0
80+
elif len(singlesMC) == 0:
81+
isDataMerged[mergeName] = 1
82+
else:
83+
isDataMerged[mergeName] = -1
84+
85+
##Loop over singles
86+
for iname,singleName in enumerate(config["validations"]["Zmumu"][zmumuType][mergeName]['singles']):
87+
isMC = (singleName in singlesMC)
88+
if isMConly and iname > 0: continue #special case for MC only comparison
89+
elif isMConly: singlesMC.pop(singlesMC.index(singleName))
90+
91+
for IOV in IOVs[singleName]:
92+
##Work directory for each IOV
93+
workDir = "{}/Zmumu/{}/{}/{}".format(validationDir, zmumuType, mergeName, IOV)
94+
95+
##Write job info
96+
local = {}
97+
98+
job = {
99+
"name": "Zmumu_{}_{}_{}".format(zmumuType, mergeName, IOV),
100+
"dir": workDir,
101+
"exe": "Zmumumerge",
102+
"run-mode": "Condor",
103+
"dependencies": [],
104+
"config": local,
105+
}
106+
107+
##Deep copy necessary things from global config + assure plot order
108+
for alignment in config["alignments"]:
109+
idxIncrement = 0
110+
local.setdefault("alignments", {})
111+
if alignment in config["validations"]["Zmumu"]["single"][singleName]["alignments"]: #Cover all DATA validations
112+
local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
113+
local["alignments"][alignment]['index'] = config["validations"]["Zmumu"]["single"][singleName]["alignments"].index(alignment)
114+
local["alignments"][alignment]['isMC'] = False
115+
for singleMCname in singlesMC:
116+
if alignment in config["validations"]["Zmumu"]["single"][singleMCname]["alignments"]: #Add MC objects
117+
local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
118+
local["alignments"][alignment]['index'] = len(config["validations"]["Zmumu"]["single"][singleName]["alignments"])
119+
local["alignments"][alignment]['index'] += idxIncrement + config["validations"]["Zmumu"]["single"][singleMCname]["alignments"].index(alignment)
120+
local["alignments"][alignment]['isMC'] = True
121+
idxIncrement += len(config["validations"]["Zmumu"]["single"][singleMCname]["alignments"])
77122
local["validation"] = copy.deepcopy(config["validations"]["Zmumu"][zmumuType][mergeName])
78-
local["output"] = "{}/{}/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, mergeName, IOV)
79-
80-
##Loop over all single jobs
81-
for singleJob in jobs:
82-
##Get single job info and append to merge job if requirements fullfilled
83-
alignment, datasetName, singleIOV = singleJob["name"].split("_")[2:]
84-
85-
if int(singleIOV) == IOV and datasetName in config["validations"]["Zmumu"][zmumuType][mergeName]["singles"]:
86-
local["alignments"][alignment]["file"] = singleJob["config"]["output"]
87-
job["dependencies"].append(singleJob["name"])
88-
89-
mergeJobs.append(job)
123+
local["validation"]["IOV"] = IOV
124+
if "customrighttitle" in local["validation"].keys():
125+
if "IOV" in local["validation"]["customrighttitle"]:
126+
local["validation"]["customrighttitle"] = local["validation"]["customrighttitle"].replace("IOV",str(IOV))
127+
local["output"] = "{}/{}/Zmumu/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, mergeName, IOV)
128+
129+
##Add global plotting options
130+
if "style" in config.keys():
131+
if "Zmumu" in config['style'].keys():
132+
if zmumuType in config['style']['Zmumu'].keys():
133+
local["style"] = copy.deepcopy(config["style"]["Zmumu"][zmumuType])
134+
if "Rlabel" in local["style"] and "customrighttitle" in local["validation"].keys():
135+
print("WARNING: custom right label is overwritten by global settings")
136+
137+
##Loop over all single jobs
138+
for singleJob in jobs:
139+
##Get single job info and append to merge job if requirements fullfilled
140+
_alignment, _singleName, _singleIOV = singleJob["name"].split("_")[2:]
141+
if _singleName in config["validations"]["Zmumu"][zmumuType][mergeName]["singles"]:
142+
if int(_singleIOV) == IOV or (int(_singleIOV) == 1 and _singleName in singlesMC): #matching DATA job or any MC single job
143+
local["alignments"][_alignment]["file"] = singleJob["config"]["output"]
144+
job["dependencies"].append(singleJob["name"])
145+
146+
mergeJobs.append(job)
90147

91148
jobs.extend(mergeJobs)
92149

150+
if "trends" in config["validations"]["Zmumu"]:
151+
print("[WARNING] Zmumu trends are not implemented yet. Nothing to do here...")
152+
93153
return jobs

Alignment/OfflineValidation/src/PreparePVTrends.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,12 @@ void PreparePVTrends::outputGraphs(const pv::wrappedTrends &allInputs,
558558
g_asym->SetTitle(label);
559559

560560
// scatter or RMS TH1
561-
h_RMS[index] = new TH1F(Form("h_RMS_dz_eta_%s", label.Data()), label, ticks.size() - 1, &(ticks[0]));
561+
std::vector<double> newTicks = ticks;
562+
newTicks.insert(newTicks.end(), ticks.back() + 1.);
563+
h_RMS[index] = new TH1F(Form("h_RMS_dz_eta_%s", label.Data()), label, newTicks.size() - 1, &(newTicks[0]));
562564
h_RMS[index]->SetStats(kFALSE);
563565

564-
for (size_t bincounter = 1; bincounter < ticks.size(); bincounter++) {
566+
for (size_t bincounter = 1; bincounter < ticks.size() + 1; bincounter++) {
565567
h_RMS[index]->SetBinContent(
566568
bincounter, std::abs(allInputs.getHigh()[label][bincounter - 1] - allInputs.getLow()[label][bincounter - 1]));
567569
h_RMS[index]->SetBinError(bincounter, 0.01);

Calibration/HcalCalibAlgos/macros/CalibCorr.C

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
// void CalibCorrScale(infile, oufile, scale)
5252
// Scales all contents of correction factors by "scale" from "infile"
5353
// to "outfile"
54+
// void CalibCorrScale2(infile, oufile, scaleB, scaleT, scaleE)
55+
// Scales all contents of correction factors in the barrel, transition and
56+
// endcap regions by "scaleB", "scaleT", "scaleE" from "infile" and writes
57+
// them to "outfile"
5458
//////////////////////////////////////////////////////////////////////////////
5559
#ifndef CalibrationHcalCalibAlgosCalibCorr_h
5660
#define CalibrationHcalCalibAlgosCalibCorr_h
@@ -144,6 +148,13 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug = false
144148
//Ignore depth index for depth > 1 in HB and HE
145149
if (depth > 1)
146150
depth = 2;
151+
} else if (truncate0 == 6) {
152+
//Ignore depth index for depth > 2 in HB and HE and
153+
// depthe 1, 2 are considered as depth 1
154+
if (depth <= 2)
155+
depth = 1;
156+
else
157+
depth = 2;
147158
}
148159
id = (subdet << 25) | (0x1000000) | ((depth & 0xF) << 20) | ((zside > 0) ? (0x80000 | (ieta << 10)) : (ieta << 10));
149160
if (debug) {
@@ -1353,4 +1364,58 @@ void CalibCorrScale(const char* infile, const char* outfile, double scale) {
13531364
myfile.close();
13541365
}
13551366
}
1367+
1368+
void CalibCorrScale2(const char* infile, const char* outfile, double scaleB, double scaleT, double scaleE) {
1369+
int ietasL[3] = {0, 13, 17};
1370+
int ietasH[3] = {14, 18, 29};
1371+
double scale[3] = {scaleB, scaleT, scaleE};
1372+
std::ofstream myfile;
1373+
myfile.open(outfile);
1374+
if (!myfile.is_open()) {
1375+
std::cout << "** ERROR: Can't open '" << outfile << std::endl;
1376+
} else {
1377+
if (std::string(infile) != "") {
1378+
std::ifstream fInput(infile);
1379+
if (!fInput.good()) {
1380+
std::cout << "Cannot open file " << infile << std::endl;
1381+
} else {
1382+
char buffer[1024];
1383+
unsigned int all(0), good(0), comment(0);
1384+
while (fInput.getline(buffer, 1024)) {
1385+
++all;
1386+
if (buffer[0] == '#') {
1387+
myfile << buffer << std::endl;
1388+
++comment;
1389+
continue; //ignore comment
1390+
}
1391+
std::vector<std::string> items = splitString(std::string(buffer));
1392+
if (items.size() != 5) {
1393+
std::cout << "Ignore line: " << buffer << std::endl;
1394+
} else {
1395+
++good;
1396+
int ieta = std::atoi(items[1].c_str());
1397+
int depth = std::atoi(items[2].c_str());
1398+
int jp(-1);
1399+
for (int j = 0; j < 3; ++j) {
1400+
if (std::abs(ieta) > ietasL[j] && std::abs(ieta) <= ietasH[j]) {
1401+
if (jp < 0)
1402+
jp = j;
1403+
}
1404+
}
1405+
if (jp < 0)
1406+
jp = 2;
1407+
float corrf = scale[jp] * std::atof(items[3].c_str());
1408+
float dcorr = scale[jp] * std::atof(items[4].c_str());
1409+
myfile << std::setw(10) << items[0] << std::setw(10) << std::dec << ieta << std::setw(10) << depth
1410+
<< std::setw(10) << corrf << " " << std::setw(10) << dcorr << std::endl;
1411+
}
1412+
}
1413+
fInput.close();
1414+
std::cout << "Reads total of " << all << ", " << comment << " and " << good << " good records from " << infile
1415+
<< " and copied to " << outfile << std::endl;
1416+
}
1417+
}
1418+
myfile.close();
1419+
}
1420+
}
13561421
#endif

Calibration/HcalCalibAlgos/macros/CalibMonitor.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
// depths in HE with values > 1 as depth 2; (4)
8080
// all depths in HB with values > 1 as depth 2;
8181
// (5) all depths in HB and HE with values > 1
82-
// as depth 2.
82+
// as depth 2; (6) for depth = 1 and 2, depth =
83+
// 1, else depth = 2.
8384
// The digit *d* is used if zside is to be
8485
// ignored (1) or not (0)
8586
// (Default 0)

0 commit comments

Comments
 (0)