Skip to content

Commit fb38c87

Browse files
author
Sunanda
committed
Code check
1 parent afa8681 commit fb38c87

File tree

4 files changed

+110
-104
lines changed

4 files changed

+110
-104
lines changed

Calibration/HcalCalibAlgos/macros/CalibCorr.C

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
// factor from phi symmetry studies
4141
// *infile* is the name of the input file
4242
// *flag* can have a value between 0:5 specifying the type of correction
43-
// 5 for run-dependent correctons using results from several phi
44-
// symmetry studies; 4 for using results from one phi-symmetry
43+
// 5 for run-dependent correctons using results from several phi
44+
// symmetry studies; 4 for using results from one phi-symmetry
4545
// study; 3 for pileup correction using machine learning method;
46-
// 2 for overall response corrections; 1 for depth dependence
46+
// 2 for overall response corrections; 1 for depth dependence
4747
// corrections; 0 for raddam corrections)
4848
// CalibSelectRBX(rbxFile, debug)
4949
// A class for selecting a given set of Read Out Box's and provides
@@ -877,13 +877,15 @@ double CalibCorr::getPhiCorrs(int run, unsigned int idx) {
877877
if (good_ == 0)
878878
return cfac;
879879
unsigned int runid = runId(run);
880-
std::map<std::pair<unsigned int, unsigned int>, double>::iterator itr = corrPhiSyms_.find(std::pair<unsigned int, unsigned int>(runid, idx));
880+
std::map<std::pair<unsigned int, unsigned int>, double>::iterator itr =
881+
corrPhiSyms_.find(std::pair<unsigned int, unsigned int>(runid, idx));
881882
if (itr != corrPhiSyms_.end())
882883
cfac = itr->second;
883884
if (debug_) {
884885
int subdet, zside, ieta, iphi, depth;
885886
unpackDetId(idx, subdet, zside, ieta, iphi, depth);
886-
std::cout << "Run " << run << " ID " << runid << ":" << std::hex << idx << std::dec << " (Sub " << subdet << " eta " << zside * ieta << " phi " << iphi << " depth " << depth << ") Factor " << cfac << std::endl;
887+
std::cout << "Run " << run << " ID " << runid << ":" << std::hex << idx << std::dec << " (Sub " << subdet << " eta "
888+
<< zside * ieta << " phi " << iphi << " depth " << depth << ") Factor " << cfac << std::endl;
887889
}
888890
return cfac;
889891
}
@@ -1117,50 +1119,53 @@ unsigned int CalibCorr::readCorrPhis(const char* infile0) {
11171119
continue; //ignore other comments
11181120
} else {
11191121
std::vector<std::string> item = splitString(bufferString0);
1120-
if (item.size() > 2) {
1121-
int run1 = std::atoi(item[0].c_str());
1122-
int run2 = std::atoi(item[1].c_str());
1123-
std::string infile(item[2]);
1124-
unsigned int runid = runs_.size();
1125-
runs_.push_back(std::pair<int, int>(run1, run2));
1126-
std::ifstream fInput(infile.c_str());
1127-
if (!fInput.good()) {
1128-
std::cout << "Cannot open file " << infile << std::endl;
1129-
} else {
1130-
char buffer[1024];
1131-
while (fInput.getline(buffer, 1024)) {
1132-
++all;
1133-
std::string bufferString(buffer);
1134-
if (bufferString.substr(0, 1) == "#") {
1135-
continue; //ignore other comments
1136-
} else {
1137-
std::vector<std::string> items = splitString(bufferString);
1138-
if (items.size() < 5) {
1139-
std::cout << "Ignore line: " << buffer << " Size " << items.size();
1140-
for (unsigned int k = 0; k < items.size(); ++k)
1141-
std::cout << " [" << k << "] : " << items[k];
1142-
std::cout << std::endl;
1143-
} else {
1144-
++good;
1145-
int subdet = std::atoi(items[0].c_str());
1146-
int ieta = std::atoi(items[1].c_str());
1147-
int iphi = std::atoi(items[2].c_str());
1148-
int depth = std::atoi(items[3].c_str());
1149-
double corrf = std::atof(items[4].c_str());
1150-
unsigned int id = packDetId(subdet, ieta, iphi, depth);
1151-
corrPhiSyms_[std::pair<int, int>(runid, id)] = corrf;
1152-
if (debug_)
1153-
std::cout << "ID " << runid << ":" << std::hex << id << std::dec << ":" << id << " (subdet " << subdet << " eta " << ieta << " phi " << iphi << " depth " << depth << ") " << corrPhiSym_[id] << std::endl;
1154-
}
1155-
}
1156-
}
1157-
fInput.close();
1158-
}
1159-
}
1122+
if (item.size() > 2) {
1123+
int run1 = std::atoi(item[0].c_str());
1124+
int run2 = std::atoi(item[1].c_str());
1125+
std::string infile(item[2]);
1126+
unsigned int runid = runs_.size();
1127+
runs_.push_back(std::pair<int, int>(run1, run2));
1128+
std::ifstream fInput(infile.c_str());
1129+
if (!fInput.good()) {
1130+
std::cout << "Cannot open file " << infile << std::endl;
1131+
} else {
1132+
char buffer[1024];
1133+
while (fInput.getline(buffer, 1024)) {
1134+
++all;
1135+
std::string bufferString(buffer);
1136+
if (bufferString.substr(0, 1) == "#") {
1137+
continue; //ignore other comments
1138+
} else {
1139+
std::vector<std::string> items = splitString(bufferString);
1140+
if (items.size() < 5) {
1141+
std::cout << "Ignore line: " << buffer << " Size " << items.size();
1142+
for (unsigned int k = 0; k < items.size(); ++k)
1143+
std::cout << " [" << k << "] : " << items[k];
1144+
std::cout << std::endl;
1145+
} else {
1146+
++good;
1147+
int subdet = std::atoi(items[0].c_str());
1148+
int ieta = std::atoi(items[1].c_str());
1149+
int iphi = std::atoi(items[2].c_str());
1150+
int depth = std::atoi(items[3].c_str());
1151+
double corrf = std::atof(items[4].c_str());
1152+
unsigned int id = packDetId(subdet, ieta, iphi, depth);
1153+
corrPhiSyms_[std::pair<int, int>(runid, id)] = corrf;
1154+
if (debug_)
1155+
std::cout << "ID " << runid << ":" << std::hex << id << std::dec << ":" << id << " (subdet "
1156+
<< subdet << " eta " << ieta << " phi " << iphi << " depth " << depth << ") "
1157+
<< corrPhiSym_[id] << std::endl;
1158+
}
1159+
}
1160+
}
1161+
fInput.close();
1162+
}
1163+
}
11601164
}
11611165
}
11621166
fIn.close();
1163-
std::cout << "Reads total of " << all << " and " << good << " good records of phi-symmetry factors from " << runs_.size() << " files as given in " << infile0 << std::endl;
1167+
std::cout << "Reads total of " << all << " and " << good << " good records of phi-symmetry factors from "
1168+
<< runs_.size() << " files as given in " << infile0 << std::endl;
11641169
}
11651170
return good;
11661171
}
@@ -1452,7 +1457,8 @@ bool CalibDuplicate::select(int ieta, int iphi) {
14521457
}
14531458

14541459
double CalibDuplicate::getCorr(int run, int ieta, int depth) {
1455-
std::map<std::pair<int, int>, std::vector<double> >::const_iterator itr = corrs_.find(std::pair<int, int>(ieta, depth));
1460+
std::map<std::pair<int, int>, std::vector<double> >::const_iterator itr =
1461+
corrs_.find(std::pair<int, int>(ieta, depth));
14561462
double corr(1.0);
14571463
if (itr != corrs_.end()) {
14581464
unsigned int irun = runId(run);
@@ -1480,23 +1486,24 @@ bool CalibDuplicate::readCorrFactor(const char* infile) {
14801486
fInput >> eta >> depth;
14811487
std::vector<double> corrs;
14821488
for (int i = 0; i < nrun; ++i) {
1483-
fInput >> corr;
1484-
corrs.push_back(corr);
1489+
fInput >> corr;
1490+
corrs.push_back(corr);
14851491
}
14861492
corrs_[std::pair<int, int>(eta, depth)] = corrs;
14871493
}
14881494
fInput.close();
1489-
std::cout << "CalibDuplicate::readCorrFactor:Reads information of " << runs_.size() << " runs and " << corrs_.size() << " channels from " << infile << std::endl;
1495+
std::cout << "CalibDuplicate::readCorrFactor:Reads information of " << runs_.size() << " runs and " << corrs_.size()
1496+
<< " channels from " << infile << std::endl;
14901497
flag = true;
14911498
if (debug_) {
14921499
for (unsigned int k = 0; k < runs_.size(); ++k)
1493-
std::cout << "Run range[" << k << "] " << runs_[k].first << ":" << runs_[k].second << std::endl;
1500+
std::cout << "Run range[" << k << "] " << runs_[k].first << ":" << runs_[k].second << std::endl;
14941501
std::map<std::pair<int, int>, std::vector<double> >::const_iterator itr;
14951502
for (itr = corrs_.begin(); itr != corrs_.end(); ++itr) {
1496-
std::cout << "eta:depth [" << (itr->first).first << ":" << (itr->first).second << "]";
1497-
for (unsigned int i = 0; i < (itr->second).size(); ++i)
1498-
std::cout << " " << (itr->second)[i];
1499-
std::cout << std::endl;
1503+
std::cout << "eta:depth [" << (itr->first).first << ":" << (itr->first).second << "]";
1504+
for (unsigned int i = 0; i < (itr->second).size(); ++i)
1505+
std::cout << " " << (itr->second)[i];
1506+
std::cout << std::endl;
15001507
}
15011508
}
15021509
}
@@ -1531,7 +1538,6 @@ void CalibCorrTest(const char* infile, int flag) {
15311538
CalibDuplicate* c1 = new CalibDuplicate(infile, -flag, true);
15321539
delete c1;
15331540
}
1534-
15351541
}
15361542

15371543
unsigned int stringTest(const std::string& str) {

Calibration/HcalCalibAlgos/macros/CalibMonitor.C

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
// information (x=3/2/1/0 for having 1000/500/50/
5151
// 100 bins for response distribution in (0:5);
5252
// y=3/2/1/0 containing list of run ranges and
53-
// ieta, depth for gain changes (3): list of
54-
// ieta, iphi of channels to be selected (2);
55-
// list containing depth dependent weights for
53+
// ieta, depth for gain changes (3): list of
54+
// ieta, iphi of channels to be selected (2);
55+
// list containing depth dependent weights for
5656
// each ieta (1); list of duplicate entries (0)
5757
// in the dupFileName;
5858
// m=1/0 for (not) making plots for each RBX;
@@ -1164,10 +1164,10 @@ void CalibMonitor::Loop(Long64_t nmax, bool debug) {
11641164
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
11651165
cfac *= cDuplicate_->getWeight((*t_DetIds)[k]);
11661166
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1167-
int subdet, zside, ieta, iphi, depth;
1168-
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
1167+
int subdet, zside, ieta, iphi, depth;
1168+
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
11691169
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1170-
}
1170+
}
11711171
eHcal += (cfac * ((*t_HitEnergies)[k]));
11721172
if (debug) {
11731173
int subdet, zside, ieta, iphi, depth;
@@ -1770,10 +1770,10 @@ void CalibMonitor::correctEnergy(double &eHcal, const Long64_t &entry) {
17701770
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
17711771
cfac *= cDuplicate_->getWeight((*t_DetIds1)[idet]);
17721772
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1773-
int subdet, zside, ieta, iphi, depth;
1774-
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
1773+
int subdet, zside, ieta, iphi, depth;
1774+
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
17751775
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1776-
}
1776+
}
17771777
double hitEn = cfac * (*t_HitEnergies1)[idet];
17781778
Etot1 += hitEn;
17791779
}
@@ -1789,10 +1789,10 @@ void CalibMonitor::correctEnergy(double &eHcal, const Long64_t &entry) {
17891789
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
17901790
cfac *= cDuplicate_->getWeight((*t_DetIds3)[idet]);
17911791
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1792-
int subdet, zside, ieta, iphi, depth;
1793-
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
1792+
int subdet, zside, ieta, iphi, depth;
1793+
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
17941794
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1795-
}
1795+
}
17961796
double hitEn = cfac * (*t_HitEnergies3)[idet];
17971797
Etot3 += hitEn;
17981798
}

Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
// correction; < 0 use eDelta; > 0 rho dependent
5353
// correction (-8)
5454
// flag (int) = 7 digit integer (ymlthdo) with control
55-
// information (y=3/2/1/0 containing list of
56-
// run ranges and ieta, depth for gain changes
55+
// information (y=3/2/1/0 containing list of
56+
// run ranges and ieta, depth for gain changes
5757
// (3): list of ieta, iphi of channels to be
5858
// selected (2); list containing depth dependent
59-
// weights for each ieta (1); list of duplicate
59+
// weights for each ieta (1); list of duplicate
6060
// entries (0) in the dupFileName;
6161
// m=0/1 for controlling creation of depth
6262
// depedendent histograms;
@@ -930,10 +930,10 @@ void CalibPlotProperties::Loop(Long64_t nentries) {
930930
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
931931
cfac *= cDuplicate_->getWeight((*t_DetIds)[k]);
932932
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
933-
int subdet, zside, ieta, iphi, depth;
934-
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
933+
int subdet, zside, ieta, iphi, depth;
934+
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
935935
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
936-
}
936+
}
937937
eHcal += (cfac * ((*t_HitEnergies)[k]));
938938
if (debug) {
939939
int subdet, zside, ieta, iphi, depth;
@@ -1029,11 +1029,11 @@ void CalibPlotProperties::Loop(Long64_t nentries) {
10291029
cfac *= cFactor_->getCorr(t_Run, (*t_DetIds)[k]);
10301030
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
10311031
cfac *= cDuplicate_->getWeight((*t_DetIds)[k]);
1032-
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1033-
int subdet, zside, ieta, iphi, depth;
1034-
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
1035-
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1036-
}
1032+
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1033+
int subdet, zside, ieta, iphi, depth;
1034+
unpackDetId((*t_DetIds)[k], subdet, zside, ieta, iphi, depth);
1035+
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1036+
}
10371037
double ener = cfac * (*t_HitEnergies)[k];
10381038
if (corrPU_)
10391039
correctEnergy(ener);
@@ -1264,10 +1264,10 @@ void CalibPlotProperties::correctEnergy(double &eHcal) {
12641264
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
12651265
cfac *= cDuplicate_->getWeight((*t_DetIds1)[idet]);
12661266
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1267-
int subdet, zside, ieta, iphi, depth;
1268-
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
1267+
int subdet, zside, ieta, iphi, depth;
1268+
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
12691269
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1270-
}
1270+
}
12711271
double hitEn = cfac * (*t_HitEnergies1)[idet];
12721272
Etot1 += hitEn;
12731273
}
@@ -1283,10 +1283,10 @@ void CalibPlotProperties::correctEnergy(double &eHcal) {
12831283
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
12841284
cfac *= cDuplicate_->getWeight((*t_DetIds)[idet]);
12851285
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1286-
int subdet, zside, ieta, iphi, depth;
1287-
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
1286+
int subdet, zside, ieta, iphi, depth;
1287+
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
12881288
cfac *= cDuplicate_->getCorr(t_Run, ieta, depth);
1289-
}
1289+
}
12901290
double hitEn = cfac * (*t_HitEnergies3)[idet];
12911291
Etot3 += hitEn;
12921292
}

Calibration/HcalCalibAlgos/macros/CalibTree.C

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,10 @@ Double_t CalibTree::Loop(int loop,
863863
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
864864
hitEn *= cDuplicate_->getWeight(id);
865865
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
866-
int subdet, zside, ieta, iphi, depth;
867-
unpackDetId((*t_DetIds)[idet], subdet, zside, ieta, iphi, depth);
868-
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
869-
}
866+
int subdet, zside, ieta, iphi, depth;
867+
unpackDetId((*t_DetIds)[idet], subdet, zside, ieta, iphi, depth);
868+
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
869+
}
870870
double Wi = evWt * hitEn / en.Etot;
871871
double Fac = (inverse) ? (en.ehcal / (pmom - t_eMipDR)) : ((pmom - t_eMipDR) / en.ehcal);
872872
double Fac2 = Wi * Fac * Fac;
@@ -1489,11 +1489,11 @@ CalibTree::energyCalor CalibTree::energyHcal(double pmom, const Long64_t &entry,
14891489
hitEn *= cFactor_->getCorr(t_Run, id);
14901490
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
14911491
hitEn *= cDuplicate_->getWeight(id);
1492-
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1493-
int subdet, zside, ieta, iphi, depth;
1494-
unpackDetId((*t_DetIds)[idet], subdet, zside, ieta, iphi, depth);
1495-
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1496-
}
1492+
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1493+
int subdet, zside, ieta, iphi, depth;
1494+
unpackDetId((*t_DetIds)[idet], subdet, zside, ieta, iphi, depth);
1495+
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1496+
}
14971497
etot += hitEn;
14981498
etot2 += ((*t_HitEnergies)[idet]);
14991499
}
@@ -1516,11 +1516,11 @@ CalibTree::energyCalor CalibTree::energyHcal(double pmom, const Long64_t &entry,
15161516
hitEn *= cFactor_->getCorr(t_Run, id);
15171517
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(1)))
15181518
hitEn *= cDuplicate_->getWeight(id);
1519-
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1520-
int subdet, zside, ieta, iphi, depth;
1521-
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
1522-
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1523-
}
1519+
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1520+
int subdet, zside, ieta, iphi, depth;
1521+
unpackDetId((*t_DetIds1)[idet], subdet, zside, ieta, iphi, depth);
1522+
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1523+
}
15241524
etot1 += hitEn;
15251525
}
15261526
}
@@ -1539,11 +1539,11 @@ CalibTree::energyCalor CalibTree::energyHcal(double pmom, const Long64_t &entry,
15391539
hitEn *= cFactor_->getCorr(t_Run, id);
15401540
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3)))
15411541
hitEn *= cDuplicate_->getWeight(id);
1542-
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1543-
int subdet, zside, ieta, iphi, depth;
1544-
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
1545-
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1546-
}
1542+
if ((cDuplicate_ != nullptr) && (cDuplicate_->doCorr(3))) {
1543+
int subdet, zside, ieta, iphi, depth;
1544+
unpackDetId((*t_DetIds3)[idet], subdet, zside, ieta, iphi, depth);
1545+
hitEn *= cDuplicate_->getCorr(t_Run, ieta, depth);
1546+
}
15471547
etot3 += hitEn;
15481548
}
15491549
}

0 commit comments

Comments
 (0)