68 #include "TStopwatch.h" 194 m_minTrackP(cfg.getParameter<double>(
"minTrackP")),
195 m_maxTrackP(cfg.getParameter<double>(
"maxTrackP")),
196 m_maxDxy(cfg.getParameter<double>(
"maxDxy")),
265 m_ttree = fs->
make<TTree>(
"mual_ttree",
"mual_ttree");
291 return atoi(s.c_str());
299 if (alignableMuon ==
nullptr)
300 throw cms::Exception(
"MuonAlignmentFromReference") <<
"doMuon must be set to True" << std::endl;
319 <<
"unrecognized residualsModel: \"" <<
m_residualsModel <<
"\"" << std::endl;
336 <<
"unrecognized useResiduals: \"" <<
m_useResiduals <<
"\"" << std::endl;
348 bool made_fitter =
false;
378 for (
const auto& ali2 : m_alignables) {
401 <<
"only DTChambers and CSCChambers can be aligned with this module" << std::endl;
407 int index = ali->geomDetId().rawId();
417 const auto& all_DT_chambers = alignableMuon->
DTChambers();
418 const auto& all_CSC_chambers = alignableMuon->
CSCChambers();
430 std::cout <<
"****** EVENT START *******" << std::endl;
448 std::cout <<
"JUST BEFORE LOOP OVER trajTrackPairs" << std::endl;
452 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end();
466 std::cout <<
"JUST BEFORE muonResidualsFromTrack" << std::endl;
470 muonDetIdAssociator_,
477 std::cout <<
"JUST AFTER muonResidualsFromTrack" << std::endl;
480 std::cout <<
"JUST BEFORE PROCESS" << std::endl;
483 std::cout <<
"JUST AFTER PROCESS" << std::endl;
488 std::cout <<
"JUST AFTER LOOP OVER trajTrackPairs" << std::endl;
533 std::vector<DetId> chamberIds = mrft.
chamberIds();
540 for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end();
552 if (dt13 !=
nullptr && dt2 !=
nullptr) {
558 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
585 std::cout <<
"processMuonResidualsFromTrack 6DOF dt13->residual() " << dt13->
residual()
603 fitter->second->fill(charge, residdata);
618 if (dt13 !=
nullptr) {
623 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
646 std::cout <<
"processMuonResidualsFromTrack 5DOF dt13->residual() " << dt13->
residual()
660 fitter->second->fill(charge, residdata);
671 if (csc !=
nullptr) {
681 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(ali);
697 std::cout <<
"processMuonResidualsFromTrack 6DOFrphi csc->residual() " << csc->
residual()
711 fitter->second->fill(charge, residdata);
756 <<
"That's all!" << std::endl;
758 TStopwatch stop_watch;
765 std::cout <<
"readTmpFiles took " << stop_watch.CpuTime() <<
" sec" << std::endl;
774 std::cout <<
"selectResidualsPeaks took " << stop_watch.CpuTime() <<
" sec" << std::endl;
782 std::cout <<
"correctBField took " << stop_watch.CpuTime() <<
" sec" << std::endl;
791 std::cout <<
"fiducialCuts took " << stop_watch.CpuTime() <<
" sec" << std::endl;
800 std::cout <<
"fillNtuple took " << stop_watch.CpuTime() <<
" sec" << std::endl;
808 std::cout <<
"eraseNotSelectedResiduals took " << stop_watch.CpuTime() <<
" sec" << std::endl;
817 std::cout <<
"fitAndAlign took " << stop_watch.CpuTime() <<
" sec" << std::endl;
825 std::cout <<
"end: MuonAlignmentFromReference::terminate()" << std::endl;
838 report <<
"nan = None; NAN = None" << std::endl;
839 report <<
"nan = 0" << std::endl;
840 report <<
"reports = []" << std::endl;
841 report <<
"class ValErr:" << std::endl
842 <<
" def __init__(self, value, error, antisym):" << std::endl
843 <<
" self.value, self.error, self.antisym = value, error, antisym" << std::endl
845 <<
" def __repr__(self):" << std::endl
846 <<
" if self.antisym == 0.:" << std::endl
847 <<
" return \"%g +- %g\" % (self.value, self.error)" << std::endl
848 <<
" else:" << std::endl
849 <<
" return \"%g +- %g ~ %g\" % (self.value, self.error, self.antisym)" << std::endl
851 <<
"class Report:" << std::endl
852 <<
" def __init__(self, chamberId, postal_address, name):" << std::endl
853 <<
" self.chamberId, self.postal_address, self.name = chamberId, postal_address, name" << std::endl
854 <<
" self.status = \"NOFIT\"" << std::endl
855 <<
" self.fittype = None" << std::endl
857 <<
" def add_parameters(self, deltax, deltay, deltaz, deltaphix, deltaphiy, deltaphiz, loglikelihood, " 858 "numsegments, sumofweights, redchi2):" 860 <<
" self.status = \"PASS\"" << std::endl
861 <<
" self.deltax, self.deltay, self.deltaz, self.deltaphix, self.deltaphiy, self.deltaphiz = deltax, " 862 "deltay, deltaz, deltaphix, deltaphiy, deltaphiz" 864 <<
" self.loglikelihood, self.numsegments, self.sumofweights, self.redchi2 = loglikelihood, " 865 "numsegments, sumofweights, redchi2" 868 <<
" def add_stats(self, median_x, median_y, median_dxdz, median_dydz, mean30_x, mean30_y, mean20_dxdz, " 869 "mean50_dydz, mean15_x, mean15_y, mean10_dxdz, mean25_dydz, wmean30_x, wmean30_y, wmean20_dxdz, " 870 "wmean50_dydz, wmean15_x, wmean15_y, wmean10_dxdz, wmean25_dydz, stdev30_x, stdev30_y, stdev20_dxdz, " 871 "stdev50_dydz, stdev15_x, stdev15_y, stdev10_dxdz, stdev25_dydz):" 873 <<
" self.median_x, self.median_y, self.median_dxdz, self.median_dydz, self.mean30_x, self.mean30_y, " 874 "self.mean20_dxdz, self.mean50_dydz, self.mean15_x, self.mean15_y, self.mean10_dxdz, self.mean25_dydz, " 875 "self.wmean30_x, self.wmean30_y, self.wmean20_dxdz, self.wmean50_dydz, self.wmean15_x, self.wmean15_y, " 876 "self.wmean10_dxdz, self.wmean25_dydz, self.stdev30_x, self.stdev30_y, self.stdev20_dxdz, " 877 "self.stdev50_dydz, self.stdev15_x, self.stdev15_y, self.stdev10_dxdz, self.stdev25_dydz = median_x, " 878 "median_y, median_dxdz, median_dydz, mean30_x, mean30_y, mean20_dxdz, mean50_dydz, mean15_x, mean15_y, " 879 "mean10_dxdz, mean25_dydz, wmean30_x, wmean30_y, wmean20_dxdz, wmean50_dydz, wmean15_x, wmean15_y, " 880 "wmean10_dxdz, wmean25_dydz, stdev30_x, stdev30_y, stdev20_dxdz, stdev50_dydz, stdev15_x, stdev15_y, " 881 "stdev10_dxdz, stdev25_dydz" 884 <<
" def __repr__(self):" << std::endl
885 <<
" return \"<Report %s %s %s>\" % (self.postal_address[0], \" \".join(map(str, " 886 "self.postal_address[1:])), self.status)" 892 std::cout <<
"***** just after report.open" << std::endl;
896 std::cout <<
"***** Start loop over alignables" << std::endl;
898 std::vector<bool> selector = ali->alignmentParameters()->selector();
899 bool align_x = selector[0];
900 bool align_y = selector[1];
901 bool align_z = selector[2];
902 bool align_phix = selector[3];
903 bool align_phiy = selector[4];
904 bool align_phiz = selector[5];
905 int numParams = ((align_x ? 1 : 0) + (align_y ? 1 : 0) + (align_z ? 1 : 0) + (align_phix ? 1 : 0) +
906 (align_phiy ? 1 : 0) + (align_phiz ? 1 : 0));
909 std::vector<int> paramIndex;
910 int paramIndex_counter = -1;
912 paramIndex_counter++;
913 paramIndex.push_back(paramIndex_counter);
915 paramIndex_counter++;
916 paramIndex.push_back(paramIndex_counter);
918 paramIndex_counter++;
919 paramIndex.push_back(paramIndex_counter);
921 paramIndex_counter++;
922 paramIndex.push_back(paramIndex_counter);
924 paramIndex_counter++;
925 paramIndex.push_back(paramIndex_counter);
927 paramIndex_counter++;
928 paramIndex.push_back(paramIndex_counter);
930 DetId id = ali->geomDetId();
940 std::cout <<
"***** loop over alignables 1" << std::endl;
943 char wheel_label[][2] = {
"A",
"B",
"C",
"D",
"E"};
950 sprintf(cname,
"MBwh%sst%dsec%02d", wheel_label[chamberId.
wheel() + 2], chamberId.
station(), chamberId.
sector());
952 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"DT\", " << chamberId.
wheel() <<
", " 953 << chamberId.
station() <<
", " << chamberId.
sector() <<
"), \"" << cname <<
"\"))" << std::endl;
959 (chamberId.
endcap() == 1 ?
"p" :
"m"),
967 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"CSC\", " << chamberId.
endcap() <<
", " 968 << chamberId.
station() <<
", " << chamberId.
ring() <<
", " << chamberId.
chamber() <<
"), \"" << cname
969 <<
"\"))" << std::endl;
974 std::cout <<
"***** loop over alignables 2" << std::endl;
978 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(thisali);
981 std::cout <<
"***** loop over alignables 3" << std::endl;
986 TStopwatch stop_watch;
991 std::cout <<
"=============================================================================================" 994 std::cout <<
"Fitting " << cname << std::endl;
997 report <<
"reports[-1].posNum = " << fitter->second->numResidualsPos() << std::endl;
998 report <<
"reports[-1].negNum = " << fitter->second->numResidualsNeg() << std::endl;
1042 std::cout <<
"***** loop over alignables 4" << std::endl;
1049 std::cout <<
"***** loop over alignables 5" << std::endl;
1051 bool successful_fit = fitter->second->fit(thisali);
1054 std::cout <<
"***** loop over alignables 6 " << fitter->second->type() << std::endl;
1056 double loglikelihood = fitter->second->loglikelihood();
1057 double numsegments = fitter->second->numsegments();
1058 double sumofweights = fitter->second->sumofweights();
1059 double redchi2 = fitter->second->plot(cname, &rootDirectory, thisali);
1063 std::cout <<
"***** loop over alignables k5DOF" << std::endl;
1093 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error,
1094 gammaresslope_antisym;
1095 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error =
1096 gammaresslope_antisym = 0.;
1111 report <<
"reports[-1].fittype = \"5DOF\"" << std::endl;
1112 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " 1113 << deltax_antisym <<
"), \\" << std::endl
1114 <<
" None, \\" << std::endl
1115 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " 1116 << deltaz_antisym <<
"), \\" << std::endl
1117 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " 1118 << deltaphix_antisym <<
"), \\" << std::endl
1119 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " 1120 << deltaphiy_antisym <<
"), \\" << std::endl
1121 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " 1122 << deltaphiz_antisym <<
"), \\" << std::endl
1123 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights
1124 <<
", " << redchi2 <<
")" << std::endl;
1125 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " 1126 << sigmaresid_antisym <<
")" << std::endl;
1127 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error
1128 <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1132 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " 1133 << gammaresid_antisym <<
")" << std::endl;
1134 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error
1135 <<
", " << gammaresslope_antisym <<
")" << std::endl;
1160 <<
"None)" << std::endl;
1162 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1163 namesimple_x << cname <<
"_simple_x";
1164 namesimple_dxdz << cname <<
"_simple_dxdz";
1165 nameweighted_x << cname <<
"_weighted_x";
1166 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1169 fitter->second->plotsimple(
1172 fitter->second->plotweighted(nameweighted_x.str(),
1177 fitter->second->plotweighted(nameweighted_dxdz.str(),
1184 if (successful_fit) {
1186 params[paramIndex[0]] = deltax_value;
1188 params[paramIndex[2]] = deltaz_value;
1190 params[paramIndex[3]] = deltaphix_value;
1192 params[paramIndex[4]] = deltaphiy_value;
1194 params[paramIndex[5]] = deltaphiz_value;
1200 std::cout <<
"***** loop over alignables k6DOF" << std::endl;
1242 double gammax_value, gammax_error, gammax_antisym, gammay_value, gammay_error, gammay_antisym,
1243 gammadxdz_value, gammadxdz_error, gammadxdz_antisym, gammadydz_value, gammadydz_error, gammadydz_antisym;
1244 gammax_value = gammax_error = gammax_antisym = gammay_value = gammay_error = gammay_antisym =
1245 gammadxdz_value = gammadxdz_error = gammadxdz_antisym = gammadydz_value = gammadydz_error =
1246 gammadydz_antisym = 0.;
1268 report <<
"reports[-1].fittype = \"6DOF\"" << std::endl;
1269 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " 1270 << deltax_antisym <<
"), \\" << std::endl
1271 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " 1272 << deltay_antisym <<
"), \\" << std::endl
1273 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " 1274 << deltaz_antisym <<
"), \\" << std::endl
1275 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " 1276 << deltaphix_antisym <<
"), \\" << std::endl
1277 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " 1278 << deltaphiy_antisym <<
"), \\" << std::endl
1279 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " 1280 << deltaphiz_antisym <<
"), \\" << std::endl
1281 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights
1282 <<
", " << redchi2 <<
")" << std::endl;
1283 report <<
"reports[-1].sigmax = ValErr(" << sigmax_value <<
", " << sigmax_error <<
", " << sigmax_antisym
1284 <<
")" << std::endl;
1285 report <<
"reports[-1].sigmay = ValErr(" << sigmay_value <<
", " << sigmay_error <<
", " << sigmay_antisym
1286 <<
")" << std::endl;
1287 report <<
"reports[-1].sigmadxdz = ValErr(" << sigmadxdz_value <<
", " << sigmadxdz_error <<
", " 1288 << sigmadxdz_antisym <<
")" << std::endl;
1289 report <<
"reports[-1].sigmadydz = ValErr(" << sigmadydz_value <<
", " << sigmadydz_error <<
", " 1290 << sigmadydz_antisym <<
")" << std::endl;
1294 report <<
"reports[-1].gammax = ValErr(" << gammax_value <<
", " << gammax_error <<
", " << gammax_antisym
1295 <<
")" << std::endl;
1296 report <<
"reports[-1].gammay = ValErr(" << gammay_value <<
", " << gammay_error <<
", " << gammay_antisym
1297 <<
")" << std::endl;
1298 report <<
"reports[-1].gammadxdz = ValErr(" << gammadxdz_value <<
", " << gammadxdz_error <<
", " 1299 << gammadxdz_antisym <<
")" << std::endl;
1300 report <<
"reports[-1].gammadydz = ValErr(" << gammadydz_value <<
", " << gammadydz_error <<
", " 1301 << gammadydz_antisym <<
")" << std::endl;
1340 std::stringstream namesimple_x, namesimple_y, namesimple_dxdz, namesimple_dydz, nameweighted_x,
1341 nameweighted_y, nameweighted_dxdz, nameweighted_dydz;
1342 namesimple_x << cname <<
"_simple_x";
1343 namesimple_y << cname <<
"_simple_y";
1344 namesimple_dxdz << cname <<
"_simple_dxdz";
1345 namesimple_dydz << cname <<
"_simple_dydz";
1346 nameweighted_x << cname <<
"_weighted_x";
1347 nameweighted_y << cname <<
"_weighted_y";
1348 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1349 nameweighted_dydz << cname <<
"_weighted_dydz";
1353 fitter->second->plotsimple(
1355 fitter->second->plotsimple(
1358 fitter->second->plotweighted(nameweighted_x.str(),
1363 fitter->second->plotweighted(nameweighted_y.str(),
1368 fitter->second->plotweighted(nameweighted_dxdz.str(),
1373 fitter->second->plotweighted(nameweighted_dydz.str(),
1380 if (successful_fit) {
1382 params[paramIndex[0]] = deltax_value;
1384 params[paramIndex[1]] = deltay_value;
1386 params[paramIndex[2]] = deltaz_value;
1388 params[paramIndex[3]] = deltaphix_value;
1390 params[paramIndex[4]] = deltaphiy_value;
1392 params[paramIndex[5]] = deltaphiz_value;
1398 std::cout <<
"***** loop over alignables k6DOFrphi" << std::endl;
1432 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error,
1433 gammaresslope_antisym;
1434 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error =
1435 gammaresslope_antisym = 0.;
1449 report <<
"reports[-1].fittype = \"6DOFrphi\"" << std::endl;
1450 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " 1451 << deltax_antisym <<
"), \\" << std::endl
1452 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " 1453 << deltay_antisym <<
"), \\" << std::endl
1454 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " 1455 << deltaz_antisym <<
"), \\" << std::endl
1456 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " 1457 << deltaphix_antisym <<
"), \\" << std::endl
1458 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " 1459 << deltaphiy_antisym <<
"), \\" << std::endl
1460 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " 1461 << deltaphiz_antisym <<
"), \\" << std::endl
1462 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights
1463 <<
", " << redchi2 <<
")" << std::endl;
1464 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " 1465 << sigmaresid_antisym <<
")" << std::endl;
1466 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error
1467 <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1471 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " 1472 << gammaresid_antisym <<
")" << std::endl;
1473 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error
1474 <<
", " << gammaresslope_antisym <<
")" << std::endl;
1484 << fitter->second->wmean(
1488 << fitter->second->wmean(
1492 << fitter->second->wmean(
1496 << fitter->second->wmean(
1503 <<
"None)" << std::endl;
1505 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1506 namesimple_x << cname <<
"_simple_x";
1507 namesimple_dxdz << cname <<
"_simple_dxdz";
1508 nameweighted_x << cname <<
"_weighted_x";
1509 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1512 fitter->second->plotsimple(
1515 fitter->second->plotweighted(nameweighted_x.str(),
1520 fitter->second->plotweighted(nameweighted_dxdz.str(),
1527 if (successful_fit) {
1529 params[paramIndex[0]] = deltax_value;
1531 params[paramIndex[1]] = deltay_value;
1533 params[paramIndex[2]] = deltaz_value;
1535 params[paramIndex[3]] = deltaphix_value;
1537 params[paramIndex[4]] = deltaphiy_value;
1539 params[paramIndex[5]] = deltaphiz_value;
1543 if (successful_fit) {
1545 oneortwo.push_back(ali);
1547 oneortwo.push_back(thisali);
1551 std::cout <<
"MINUIT fit failed!" << std::endl;
1553 report <<
"reports[-1].status = \"MINUITFAIL\"" << std::endl;
1556 for (
int i = 0;
i < numParams;
i++)
1560 oneortwo.push_back(ali);
1562 oneortwo.push_back(thisali);
1567 std::cout <<
"Too few hits!" << std::endl;
1569 report <<
"reports[-1].status = \"TOOFEWHITS\"" << std::endl;
1572 for (
int i = 0;
i < numParams;
i++)
1576 oneortwo.push_back(ali);
1578 oneortwo.push_back(thisali);
1583 ali->setAlignmentParameters(parnew);
1585 ali->alignmentParameters()->setValid(
true);
1588 std::cout << cname <<
" fittime= " << stop_watch.CpuTime() <<
" sec" << std::endl;
1592 report << std::endl;
1606 file = fopen((*fileName).c_str(),
"r");
1607 if (file ==
nullptr)
1609 <<
"file \"" << *
fileName <<
"\" can't be opened (doesn't exist?)" << std::endl;
1611 fread(&size,
sizeof(
int), 1, file);
1614 <<
"file \"" << *
fileName <<
"\" has " << size <<
" fitters, but this job has " <<
m_indexes.size()
1615 <<
" fitters (probably corresponds to the wrong alignment job)" << std::endl;
1620 unsigned int index_toread;
1621 fread(&index_toread,
sizeof(
unsigned int), 1, file);
1622 if (*
index != index_toread)
1624 <<
"file \"" << *
fileName <<
"\" has index " << index_toread <<
" at position " << i
1625 <<
", but this job is expecting " << *
index <<
" (probably corresponds to the wrong alignment job)" 1627 fitter->
read(file, i);
1638 fwrite(&size,
sizeof(
int), 1, file);
1643 unsigned int index_towrite = *
index;
1644 fwrite(&index_towrite,
sizeof(
unsigned int), 1, file);
1645 fitter->
write(file, i);
1688 int vars_index[10] = {0, 1};
1754 sprintf(cname,
"MB%+d/%d/%02d", chamberId.
wheel(), chamberId.
station(), chamberId.
sector());
1759 (chamberId.
endcap() == 1 ?
"+" :
"-"),
1795 for (; residual != fitter->
residualsPos_end(); ++residual, ++residual_ok) {
1833 std::map<Alignable*, bool> already_seen;
1836 bool parsing_error =
false;
1840 if (!barrel && !endcap)
1841 parsing_error =
true;
1843 if (!parsing_error && barrel) {
1857 parsing_error =
true;
1860 bool wheel_digit =
false;
1861 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1870 parsing_error =
true;
1873 parsing_error =
true;
1877 bool station_digit =
false;
1878 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1881 station_digit =
true;
1885 parsing_error =
true;
1888 parsing_error =
true;
1892 bool sector_digit =
false;
1893 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1896 sector_digit =
true;
1900 parsing_error =
true;
1902 if (!parsing_error) {
1903 bool no_such_chamber =
false;
1905 if (wheel < -2 || wheel > 2)
1906 no_such_chamber =
true;
1907 if (station < 1 || station > 4)
1908 no_such_chamber =
true;
1909 if (station == 4 && (sector < 1 || sector > 14))
1910 no_such_chamber =
true;
1911 if (station < 4 && (sector < 1 || sector > 12))
1912 no_such_chamber =
true;
1914 if (no_such_chamber)
1916 <<
"reference chamber doesn't exist: " << (*name) << std::endl;
1919 for (
const auto& ali : all_DT_chambers) {
1920 if (ali->geomDetId().rawId() ==
id.rawId()) {
1921 std::map<Alignable*, bool>::const_iterator
trial = already_seen.find(ali);
1922 if (trial == already_seen.end()) {
1923 reference.push_back(ali);
1924 already_seen[ali] =
true;
1931 if (!parsing_error && endcap) {
1945 parsing_error =
true;
1948 bool station_digit =
false;
1949 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1952 station_digit =
true;
1958 parsing_error =
true;
1961 parsing_error =
true;
1965 bool ring_digit =
false;
1966 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1973 parsing_error =
true;
1976 parsing_error =
true;
1980 bool chamber_digit =
false;
1981 while (!parsing_error &&
numeric(
name->substr(index, 1))) {
1984 chamber_digit =
true;
1988 parsing_error =
true;
1990 if (!parsing_error) {
1991 bool no_such_chamber =
false;
1993 int endcap = (station > 0 ? 1 : 2);
1994 station =
abs(station);
1995 if (station < 1 || station > 4)
1996 no_such_chamber =
true;
1997 if (station == 1 && (ring < 1 || ring > 4))
1998 no_such_chamber =
true;
1999 if (station > 1 && (ring < 1 || ring > 2))
2000 no_such_chamber =
true;
2001 if (station == 1 && (chamber < 1 || chamber > 36))
2002 no_such_chamber =
true;
2003 if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18))
2004 no_such_chamber =
true;
2005 if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36))
2006 no_such_chamber =
true;
2008 if (no_such_chamber)
2010 <<
"reference chamber doesn't exist: " << (*name) << std::endl;
2013 for (
const auto& ali : all_CSC_chambers) {
2014 if (ali->geomDetId().rawId() ==
id.rawId()) {
2015 std::map<Alignable*, bool>::const_iterator
trial = already_seen.find(ali);
2016 if (trial == already_seen.end()) {
2017 reference.push_back(ali);
2018 already_seen[ali] =
true;
2027 <<
"reference chamber name is malformed: " << (*name) << std::endl;
void initialize(const edm::EventSetup &iSetup, AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *extras, AlignmentParameterStore *alignmentParameterStore) override
Call at beginning of job (must be implemented in derived class)
double p() const
momentum vector magnitude
edm::InputTag m_muonCollectionTag
double m_maxTrackerRedChi2
long m_counter_trackerchi2
std::vector< double * >::const_iterator residualsPos_end() const
std::vector< double * >::const_iterator residualsPos_begin() const
long m_counter_trackertidtec
align::Alignables CSCChambers()
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
align::Alignables m_alignables
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
long m_counter_station123aligning
int m_minNCrossedChambers
constexpr uint32_t rawId() const
get the raw id
int trackerNumHits() const
void selectResidualsPeaks()
long m_counter_station123dt13hits
std::vector< bool >::const_iterator residualsPos_ok_begin() const
T * make(const Args &...args) const
make new ROOT object
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
std::string m_reportFileName
~MuonAlignmentFromReference() override
Interface/Base class for alignment algorithms, each alignment algorithm has to be derived from this c...
long m_counter_trackmomentum
const ConstTrajTrackPairCollection & trajTrackPairs() const
define event information passed to algorithms
std::string m_residualsModel
AlignmentParameterStore * m_alignmentParameterStore
const std::vector< DetId > chamberIds() const
void processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft)
int number(std::string s)
MuonResidualsFitter::MuonAlignmentTreeRow m_tree_row
std::vector< unsigned int > m_indexes
std::string chamberPrettyNameFromId(unsigned int idx)
align::Alignables DTChambers()
double pt() const
track transverse momentum
const reco::Track * getTrack()
AlignableDetOrUnitPtr chamberAlignable() const
void startNewLoop() override
AlignableNavigator * m_alignableNavigator
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
long m_counter_cscaligning
void eraseNotSelectedResiduals()
Abs< T >::type abs(const T &t)
void parseReference(align::Alignables &reference, const align::Alignables &all_DT_chambers, const align::Alignables &all_CSC_chambers)
void write(FILE *file, int which=0)
std::map< unsigned int, MuonResidualsTwoBin * > m_fitterOrder
long m_counter_station123valid
std::vector< std::string > m_reference
std::map< Alignable *, MuonResidualsTwoBin * > m_fitters
double pz() const
z coordinate of momentum vector
double normalizedChi2() const
long m_counter_station4hits
TFile & file() const
return opened TFile
void run(const edm::EventSetup &iSetup, const EventInfo &eventInfo) override
Run the algorithm (must be implemented in derived class)
CLHEP::HepVector AlgebraicVector
long m_counter_station123
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void eraseNotSelectedResiduals()
long m_counter_station123dt2hits
long m_counter_totchambers
void read(FILE *file, int which=0)
std::string m_writeTemporaryFile
std::string m_useResiduals
long m_counter_station4aligning
long m_counter_station4valid
std::vector< Alignable * > Alignables
std::map< Alignable *, Alignable * > m_me11map
virtual void terminate()
Called at end of job (must be implemented in derived class)
const reco::BeamSpot & beamSpot() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< std::string > m_readTemporaryFiles
bool numeric(std::string s)
MuonAlignmentFromReference(const edm::ParameterSet &cfg)
int charge() const
track electric charge
#define DEFINE_EDM_PLUGIN(factory, type, name)
const Point & position() const
position
long m_counter_trackerhits
int station() const
Return the station number.
void selectPeakResiduals(double nsigma, int nvar, int *vars)
int wheel() const
Return the wheel number.
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Constructor of the full muon geometry.
const DetId & geomDetId() const
long m_counter_minchambers
const align::Alignables & alignables(void) const
get all alignables
constexpr Detector det() const
get the detector field from this detid
bool contains_TIDTEC() const
MuonChamberResidual * chamberResidual(DetId chamberId, int type)
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection