67 #include "TStopwatch.h" 197 ,
m_minTrackP(cfg.getParameter<double>(
"minTrackP"))
198 ,
m_maxTrackP(cfg.getParameter<double>(
"maxTrackP"))
199 ,
m_maxDxy(cfg.getParameter<double>(
"maxDxy"))
274 m_ttree = fs->
make<TTree>(
"mual_ttree",
"mual_ttree");
299 return s.length()==1 && std::isdigit(s[0]);
305 if (!
numeric(s)) assert(
false);
306 return atoi(s.c_str());
316 if (alignableMuon ==
nullptr)
317 throw cms::Exception(
"MuonAlignmentFromReference") <<
"doMuon must be set to True" << std::endl;
351 bool made_fitter =
false;
385 for (
const auto& ali2: m_alignables)
406 throw cms::Exception(
"MuonAlignmentFromReference") <<
"only DTChambers and CSCChambers can be aligned with this module" << std::endl;
412 int index = ali->geomDetId().rawId();
422 const auto& all_DT_chambers = alignableMuon->
DTChambers();
423 const auto& all_CSC_chambers = alignableMuon->
CSCChambers();
452 if (
m_debug)
std::cout <<
"JUST BEFORE LOOP OVER trajTrackPairs" << std::endl;
456 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end(); ++trajtrack)
470 if (
m_debug)
std::cout <<
"JUST BEFORE muonResidualsFromTrack" << std::endl;
480 if (
m_debug)
std::cout <<
"JUST AFTER LOOP OVER trajTrackPairs" << std::endl;
531 std::vector<DetId> chamberIds = mrft.
chamberIds();
539 for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end(); ++chamberId)
553 if (dt13 !=
nullptr && dt2 !=
nullptr)
589 std::cout <<
"processMuonResidualsFromTrack 6DOF dt13->residual() " << dt13->
residual() << std::endl;
599 fitter->second->fill(charge, residdata);
646 std::cout <<
"processMuonResidualsFromTrack 5DOF dt13->residual() " << dt13->
residual() << std::endl;
654 fitter->second->fill(charge, residdata);
678 std::map<Alignable*,MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(ali);
695 std::cout <<
"processMuonResidualsFromTrack 6DOFrphi csc->residual() " << csc->
residual() << std::endl;
703 fitter->second->fill(charge, residdata);
749 <<
"That's all!" << std::endl;
751 TStopwatch stop_watch;
758 if (m_debug)
std::cout <<
"readTmpFiles took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
767 if (m_debug)
std::cout <<
"selectResidualsPeaks took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
775 if (m_debug)
std::cout <<
"correctBField took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
783 if (m_debug)
std::cout <<
"fiducialCuts took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
792 if (m_debug)
std::cout <<
"fillNtuple took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
800 if (m_debug)
std::cout <<
"eraseNotSelectedResiduals took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
809 if (m_debug)
std::cout <<
"fitAndAlign took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
815 if (m_debug)
std::cout <<
"end: MuonAlignmentFromReference::terminate()" << std::endl;
831 report <<
"nan = None; NAN = None" << std::endl;
832 report <<
"nan = 0" << std::endl;
833 report <<
"reports = []" << std::endl;
834 report <<
"class ValErr:" << std::endl
835 <<
" def __init__(self, value, error, antisym):" << std::endl
836 <<
" self.value, self.error, self.antisym = value, error, antisym" << std::endl
838 <<
" def __repr__(self):" << std::endl
839 <<
" if self.antisym == 0.:" << std::endl
840 <<
" return \"%g +- %g\" % (self.value, self.error)" << std::endl
841 <<
" else:" << std::endl
842 <<
" return \"%g +- %g ~ %g\" % (self.value, self.error, self.antisym)" << std::endl
844 <<
"class Report:" << std::endl
845 <<
" def __init__(self, chamberId, postal_address, name):" << std::endl
846 <<
" self.chamberId, self.postal_address, self.name = chamberId, postal_address, name" << std::endl
847 <<
" self.status = \"NOFIT\"" << std::endl
848 <<
" self.fittype = None" << std::endl
850 <<
" def add_parameters(self, deltax, deltay, deltaz, deltaphix, deltaphiy, deltaphiz, loglikelihood, numsegments, sumofweights, redchi2):" << std::endl
851 <<
" self.status = \"PASS\"" << std::endl
852 <<
" self.deltax, self.deltay, self.deltaz, self.deltaphix, self.deltaphiy, self.deltaphiz = deltax, deltay, deltaz, deltaphix, deltaphiy, deltaphiz" << std::endl
853 <<
" self.loglikelihood, self.numsegments, self.sumofweights, self.redchi2 = loglikelihood, numsegments, sumofweights, redchi2" << std::endl
855 <<
" def add_stats(self, median_x, median_y, median_dxdz, median_dydz, mean30_x, mean30_y, mean20_dxdz, mean50_dydz, mean15_x, mean15_y, mean10_dxdz, mean25_dydz, wmean30_x, wmean30_y, wmean20_dxdz, wmean50_dydz, wmean15_x, wmean15_y, wmean10_dxdz, wmean25_dydz, stdev30_x, stdev30_y, stdev20_dxdz, stdev50_dydz, stdev15_x, stdev15_y, stdev10_dxdz, stdev25_dydz):" << std::endl
856 <<
" self.median_x, self.median_y, self.median_dxdz, self.median_dydz, self.mean30_x, self.mean30_y, self.mean20_dxdz, self.mean50_dydz, self.mean15_x, self.mean15_y, self.mean10_dxdz, self.mean25_dydz, self.wmean30_x, self.wmean30_y, self.wmean20_dxdz, self.wmean50_dydz, self.wmean15_x, self.wmean15_y, self.wmean10_dxdz, self.wmean25_dydz, self.stdev30_x, self.stdev30_y, self.stdev20_dxdz, self.stdev50_dydz, self.stdev15_x, self.stdev15_y, self.stdev10_dxdz, self.stdev25_dydz = median_x, median_y, median_dxdz, median_dydz, mean30_x, mean30_y, mean20_dxdz, mean50_dydz, mean15_x, mean15_y, mean10_dxdz, mean25_dydz, wmean30_x, wmean30_y, wmean20_dxdz, wmean50_dydz, wmean15_x, wmean15_y, wmean10_dxdz, wmean25_dydz, stdev30_x, stdev30_y, stdev20_dxdz, stdev50_dydz, stdev15_x, stdev15_y, stdev10_dxdz, stdev25_dydz" << std::endl
858 <<
" def __repr__(self):" << std::endl
859 <<
" return \"<Report %s %s %s>\" % (self.postal_address[0], \" \".join(map(str, self.postal_address[1:])), self.status)"<< std::endl
863 if (m_debug)
std::cout <<
"***** just after report.open" << std::endl;
867 if (m_debug)
std::cout <<
"***** Start loop over alignables" << std::endl;
869 std::vector<bool> selector = ali->alignmentParameters()->selector();
870 bool align_x = selector[0];
871 bool align_y = selector[1];
872 bool align_z = selector[2];
873 bool align_phix = selector[3];
874 bool align_phiy = selector[4];
875 bool align_phiz = selector[5];
876 int numParams = ((align_x ? 1 : 0) + (align_y ? 1 : 0) + (align_z ? 1 : 0) + (align_phix ? 1 : 0) + (align_phiy ? 1 : 0) + (align_phiz ? 1 : 0));
879 std::vector<int> paramIndex;
880 int paramIndex_counter = -1;
881 if (align_x) paramIndex_counter++;
882 paramIndex.push_back(paramIndex_counter);
883 if (align_y) paramIndex_counter++;
884 paramIndex.push_back(paramIndex_counter);
885 if (align_z) paramIndex_counter++;
886 paramIndex.push_back(paramIndex_counter);
887 if (align_phix) paramIndex_counter++;
888 paramIndex.push_back(paramIndex_counter);
889 if (align_phiy) paramIndex_counter++;
890 paramIndex.push_back(paramIndex_counter);
891 if (align_phiz) paramIndex_counter++;
892 paramIndex.push_back(paramIndex_counter);
894 DetId id = ali->geomDetId();
903 if (m_debug)
std::cout <<
"***** loop over alignables 1" << std::endl;
906 char wheel_label[][2]={
"A",
"B",
"C",
"D",
"E"};
914 sprintf(cname,
"MBwh%sst%dsec%02d", wheel_label[chamberId.
wheel()+2], chamberId.
station(), chamberId.
sector());
917 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"DT\", " 918 << chamberId.
wheel() <<
", " << chamberId.
station() <<
", " << chamberId.
sector() <<
"), \"" << cname <<
"\"))" << std::endl;
924 sprintf(cname,
"ME%s%d%d_%02d", (chamberId.
endcap() == 1 ?
"p" :
"m"), chamberId.
station(), chamberId.
ring(), chamberId.
chamber());
930 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"CSC\", " 932 <<
"), \"" << cname <<
"\"))" << std::endl;
936 if (m_debug)
std::cout <<
"***** loop over alignables 2" << std::endl;
940 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(thisali);
942 if (m_debug)
std::cout <<
"***** loop over alignables 3" << std::endl;
948 TStopwatch stop_watch;
952 if (m_debug)
std::cout <<
"=============================================================================================" << std::endl;
953 if (m_debug)
std::cout <<
"Fitting " << cname << std::endl;
957 report <<
"reports[-1].posNum = " << fitter->second->numResidualsPos() << std::endl;
958 report <<
"reports[-1].negNum = " << fitter->second->numResidualsNeg() << std::endl;
989 if (m_debug)
std::cout <<
"***** loop over alignables 4" << std::endl;
997 if (m_debug)
std::cout <<
"***** loop over alignables 5" << std::endl;
999 bool successful_fit = fitter->second->fit(thisali);
1001 if (m_debug)
std::cout <<
"***** loop over alignables 6 " << fitter->second->type() << std::endl;
1003 double loglikelihood = fitter->second->loglikelihood();
1004 double numsegments = fitter->second->numsegments();
1005 double sumofweights = fitter->second->sumofweights();
1006 double redchi2 = fitter->second->plot(cname, &rootDirectory, thisali);
1010 if (m_debug)
std::cout <<
"***** loop over alignables k5DOF" << std::endl;
1040 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error, gammaresslope_antisym;
1041 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error = gammaresslope_antisym = 0.;
1058 report <<
"reports[-1].fittype = \"5DOF\"" << std::endl;
1059 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1060 <<
" None, \\" << std::endl
1061 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1062 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1063 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1064 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1065 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1066 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " << sigmaresid_antisym <<
")" << std::endl;
1067 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1072 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " << gammaresid_antisym <<
")" << std::endl;
1073 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error <<
", " << gammaresslope_antisym <<
")" << std::endl;
1091 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1092 namesimple_x << cname <<
"_simple_x";
1093 namesimple_dxdz << cname <<
"_simple_dxdz";
1094 nameweighted_x << cname <<
"_weighted_x";
1095 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1106 if (align_x) params[paramIndex[0]] = deltax_value;
1107 if (align_z) params[paramIndex[2]] = deltaz_value;
1108 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1109 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1110 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1116 if (m_debug)
std::cout <<
"***** loop over alignables k6DOF" << std::endl;
1158 double gammax_value, gammax_error, gammax_antisym, gammay_value, gammay_error, gammay_antisym,
1159 gammadxdz_value, gammadxdz_error, gammadxdz_antisym, gammadydz_value, gammadydz_error, gammadydz_antisym;
1160 gammax_value = gammax_error = gammax_antisym = gammay_value = gammay_error = gammay_antisym = gammadxdz_value
1161 = gammadxdz_error = gammadxdz_antisym = gammadydz_value = gammadydz_error = gammadydz_antisym = 0.;
1185 report <<
"reports[-1].fittype = \"6DOF\"" << std::endl;
1186 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1187 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " << deltay_antisym <<
"), \\" << std::endl
1188 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1189 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1190 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1191 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1192 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1193 report <<
"reports[-1].sigmax = ValErr(" << sigmax_value <<
", " << sigmax_error <<
", " << sigmax_antisym<<
")" << std::endl;
1194 report <<
"reports[-1].sigmay = ValErr(" << sigmay_value <<
", " << sigmay_error <<
", " << sigmay_antisym<<
")" << std::endl;
1195 report <<
"reports[-1].sigmadxdz = ValErr(" << sigmadxdz_value <<
", " << sigmadxdz_error <<
", "<< sigmadxdz_antisym <<
")" << std::endl;
1196 report <<
"reports[-1].sigmadydz = ValErr(" << sigmadydz_value <<
", " << sigmadydz_error <<
", "<< sigmadydz_antisym <<
")" << std::endl;
1201 report <<
"reports[-1].gammax = ValErr(" << gammax_value <<
", " << gammax_error <<
", " << gammax_antisym <<
")" << std::endl;
1202 report <<
"reports[-1].gammay = ValErr(" << gammay_value <<
", " << gammay_error <<
", " << gammay_antisym <<
")" << std::endl;
1203 report <<
"reports[-1].gammadxdz = ValErr(" << gammadxdz_value <<
", " << gammadxdz_error <<
", " << gammadxdz_antisym <<
")" << std::endl;
1204 report <<
"reports[-1].gammadydz = ValErr(" << gammadydz_value <<
", " << gammadydz_error <<
", " << gammadydz_antisym <<
")" << std::endl;
1207 report <<
"reports[-1].add_stats(" 1237 std::stringstream namesimple_x, namesimple_y, namesimple_dxdz, namesimple_dydz, nameweighted_x,
1238 nameweighted_y, nameweighted_dxdz, nameweighted_dydz;
1239 namesimple_x << cname <<
"_simple_x";
1240 namesimple_y << cname <<
"_simple_y";
1241 namesimple_dxdz << cname <<
"_simple_dxdz";
1242 namesimple_dydz << cname <<
"_simple_dydz";
1243 nameweighted_x << cname <<
"_weighted_x";
1244 nameweighted_y << cname <<
"_weighted_y";
1245 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1246 nameweighted_dydz << cname <<
"_weighted_dydz";
1261 if (align_x) params[paramIndex[0]] = deltax_value;
1262 if (align_y) params[paramIndex[1]] = deltay_value;
1263 if (align_z) params[paramIndex[2]] = deltaz_value;
1264 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1265 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1266 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1272 if (m_debug)
std::cout <<
"***** loop over alignables k6DOFrphi" << std::endl;
1306 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error, gammaresslope_antisym;
1307 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error = gammaresslope_antisym = 0.;
1323 report <<
"reports[-1].fittype = \"6DOFrphi\"" << std::endl;
1324 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1325 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " << deltay_antisym <<
"), \\" << std::endl
1326 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1327 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1328 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1329 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1330 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1331 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " << sigmaresid_antisym <<
")" << std::endl;
1332 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1337 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " << gammaresid_antisym <<
")" << std::endl;
1338 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error <<
", " << gammaresslope_antisym <<
")" << std::endl;
1356 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1357 namesimple_x << cname <<
"_simple_x";
1358 namesimple_dxdz << cname <<
"_simple_dxdz";
1359 nameweighted_x << cname <<
"_weighted_x";
1360 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1371 if (align_x) params[paramIndex[0]] = deltax_value;
1372 if (align_y) params[paramIndex[1]] = deltay_value;
1373 if (align_z) params[paramIndex[2]] = deltaz_value;
1374 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1375 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1376 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1383 oneortwo.push_back(ali);
1384 if (thisali != ali) oneortwo.push_back(thisali);
1389 if (m_debug)
std::cout <<
"MINUIT fit failed!" << std::endl;
1392 report <<
"reports[-1].status = \"MINUITFAIL\"" << std::endl;
1395 for (
int i = 0;
i < numParams;
i++) cov[
i][
i] = 1000.;
1398 oneortwo.push_back(ali);
1399 if (thisali != ali) oneortwo.push_back(thisali);
1405 if (m_debug)
std::cout <<
"Too few hits!" << std::endl;
1408 report <<
"reports[-1].status = \"TOOFEWHITS\"" << std::endl;
1411 for (
int i = 0;
i < numParams;
i++) cov[
i][
i] = 1000.;
1414 oneortwo.push_back(ali);
1415 if (thisali != ali) oneortwo.push_back(thisali);
1420 ali->setAlignmentParameters(parnew);
1422 ali->alignmentParameters()->setValid(
true);
1424 if (m_debug)
std::cout << cname<<
" fittime= "<< stop_watch.CpuTime() <<
" sec" << std::endl;
1427 if (writeReport) report << std::endl;
1431 if (writeReport) report.close();
1441 file = fopen( (*fileName).c_str(),
"r");
1442 if (file ==
nullptr)
1443 throw cms::Exception(
"MuonAlignmentFromReference") <<
"file \"" << *
fileName <<
"\" can't be opened (doesn't exist?)" << std::endl;
1445 fread(&size,
sizeof(
int), 1, file);
1448 <<
" fitters, but this job has " <<
m_indexes.size() <<
" fitters (probably corresponds to the wrong alignment job)" << std::endl;
1454 unsigned int index_toread;
1455 fread(&index_toread,
sizeof(
unsigned int), 1, file);
1456 if (*
index != index_toread)
1457 throw cms::Exception(
"MuonAlignmentFromReference") <<
"file \"" << *
fileName <<
"\" has index " << index_toread
1458 <<
" at position " << i <<
", but this job is expecting " << *
index <<
" (probably corresponds to the wrong alignment job)" << std::endl;
1459 fitter->
read(file, i);
1472 fwrite(&size,
sizeof(
int), 1, file);
1478 unsigned int index_towrite = *
index;
1479 fwrite(&index_towrite,
sizeof(
unsigned int), 1, file);
1480 fitter->
write(file, i);
1529 int vars_index[10] = {0,1};
1608 sprintf(cname,
"MB%+d/%d/%02d", chamberId.
wheel(), chamberId.
station(), chamberId.
sector());
1613 sprintf(cname,
"ME%s%d/%d/%02d", (chamberId.
endcap() == 1 ?
"+" :
"-"), chamberId.
station(), chamberId.
ring(), chamberId.
chamber());
1694 std::map<Alignable*,bool> already_seen;
1698 bool parsing_error =
false;
1702 if (!barrel && !endcap) parsing_error =
true;
1704 if (!parsing_error && barrel)
1721 else parsing_error =
true;
1724 bool wheel_digit =
false;
1725 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1732 if (!plus) wheel *= -1;
1733 if (!wheel_digit) parsing_error =
true;
1739 bool station_digit =
false;
1740 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1744 station_digit =
true;
1747 if (!station_digit) parsing_error =
true;
1753 bool sector_digit =
false;
1754 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1758 sector_digit =
true;
1761 if (!sector_digit) parsing_error =
true;
1765 bool no_such_chamber =
false;
1767 if (wheel < -2 || wheel > 2) no_such_chamber =
true;
1768 if (station < 1 || station > 4) no_such_chamber =
true;
1769 if (station == 4 && (sector < 1 || sector > 14)) no_such_chamber =
true;
1770 if (station < 4 && (sector < 1 || sector > 12)) no_such_chamber =
true;
1772 if (no_such_chamber)
1773 throw cms::Exception(
"MuonAlignmentFromReference") <<
"reference chamber doesn't exist: " << (*name) << std::endl;
1776 for (
const auto& ali: all_DT_chambers)
1778 if (ali->geomDetId().rawId() ==
id.rawId())
1780 std::map<Alignable*,bool>::const_iterator trial = already_seen.find(ali);
1781 if (trial == already_seen.end())
1783 reference.push_back(ali);
1784 already_seen[ali] =
true;
1791 if (!parsing_error && endcap)
1808 else parsing_error =
true;
1811 bool station_digit =
false;
1812 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1816 station_digit =
true;
1819 if (!plus) station *= -1;
1820 if (!station_digit) parsing_error =
true;
1826 bool ring_digit =
false;
1827 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1834 if (!ring_digit) parsing_error =
true;
1840 bool chamber_digit =
false;
1841 while (!parsing_error &&
numeric(
name->substr(index, 1)))
1845 chamber_digit =
true;
1848 if (!chamber_digit) parsing_error =
true;
1852 bool no_such_chamber =
false;
1854 int endcap = (station > 0 ? 1 : 2);
1855 station =
abs(station);
1856 if (station < 1 || station > 4) no_such_chamber =
true;
1857 if (station == 1 && (ring < 1 || ring > 4)) no_such_chamber =
true;
1858 if (station > 1 && (ring < 1 || ring > 2)) no_such_chamber =
true;
1859 if (station == 1 && (chamber < 1 || chamber > 36)) no_such_chamber =
true;
1860 if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18)) no_such_chamber =
true;
1861 if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36)) no_such_chamber =
true;
1863 if (no_such_chamber)
1864 throw cms::Exception(
"MuonAlignmentFromReference") <<
"reference chamber doesn't exist: " << (*name) << std::endl;
1867 for (
const auto& ali: all_CSC_chambers)
1869 if (ali->geomDetId().rawId() ==
id.rawId())
1871 std::map<Alignable*,bool>::const_iterator trial = already_seen.find(ali);
1872 if (trial == already_seen.end())
1874 reference.push_back(ali);
1875 already_seen[ali] =
true;
1883 throw cms::Exception(
"MuonAlignmentFromReference") <<
"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
long m_counter_trackertidtec
std::vector< double * >::const_iterator residualsPos_end() const
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)
long m_counter_station123valid
std::vector< std::string > m_reference
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
eventInfo
add run, event number and lumi section
long m_counter_trackerhits
std::vector< double * >::const_iterator residualsPos_begin() const
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
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
std::map< unsigned int, MuonResidualsTwoBin * > m_fitterOrder
constexpr Detector det() const
get the detector field from this detid
bool contains_TIDTEC() const
std::map< Alignable *, MuonResidualsTwoBin * > m_fitters
MuonChamberResidual * chamberResidual(DetId chamberId, int type)