62 #include "TStopwatch.h"
96 std::vector<Alignable*> &all_DT_chambers,
97 std::vector<Alignable*> &all_CSC_chambers);
185 , m_muonCollectionTag(cfg.getParameter<edm::
InputTag>(
"muonCollectionTag"))
186 , m_reference(cfg.getParameter<std::vector<std::
string> >(
"reference"))
187 , m_minTrackPt(cfg.getParameter<double>(
"minTrackPt"))
188 , m_maxTrackPt(cfg.getParameter<double>(
"maxTrackPt"))
189 , m_minTrackP(cfg.getParameter<double>(
"minTrackP"))
190 , m_maxTrackP(cfg.getParameter<double>(
"maxTrackP"))
191 , m_maxDxy(cfg.getParameter<double>(
"maxDxy"))
192 , m_minTrackerHits(cfg.getParameter<int>(
"minTrackerHits"))
193 , m_maxTrackerRedChi2(cfg.getParameter<double>(
"maxTrackerRedChi2"))
194 , m_allowTIDTEC(cfg.getParameter<bool>(
"allowTIDTEC"))
195 , m_minNCrossedChambers(cfg.getParameter<int>(
"minNCrossedChambers"))
196 , m_minDT13Hits(cfg.getParameter<int>(
"minDT13Hits"))
197 , m_minDT2Hits(cfg.getParameter<int>(
"minDT2Hits"))
198 , m_minCSCHits(cfg.getParameter<int>(
"minCSCHits"))
199 , m_writeTemporaryFile(cfg.getParameter<std::
string>(
"writeTemporaryFile"))
200 , m_readTemporaryFiles(cfg.getParameter<std::vector<std::
string> >(
"readTemporaryFiles"))
201 , m_doAlignment(cfg.getParameter<bool>(
"doAlignment"))
202 , m_strategy(cfg.getParameter<int>(
"strategy"))
203 , m_residualsModel(cfg.getParameter<std::
string>(
"residualsModel"))
204 , m_minAlignmentHits(cfg.getParameter<int>(
"minAlignmentHits"))
205 , m_twoBin(cfg.getParameter<bool>(
"twoBin"))
206 , m_combineME11(cfg.getParameter<bool>(
"combineME11"))
207 , m_weightAlignment(cfg.getParameter<bool>(
"weightAlignment"))
208 , m_reportFileName(cfg.getParameter<std::
string>(
"reportFileName"))
209 , m_maxResSlopeY(cfg.getParameter<double>(
"maxResSlopeY"))
210 , m_createNtuple(cfg.getParameter<bool>(
"createNtuple"))
211 , m_peakNSigma(cfg.getParameter<double>(
"peakNSigma"))
212 , m_BFieldCorrection(cfg.getParameter<int>(
"bFieldCorrection"))
213 , m_doDT(cfg.getParameter<bool>(
"doDT"))
214 , m_doCSC(cfg.getParameter<bool>(
"doCSC"))
215 , m_useResiduals(cfg.getParameter<std::
string>(
"useResiduals"))
222 TFile &tfile = fs->
file();
264 m_ttree = fs->
make<TTree>(
"mual_ttree",
"mual_ttree");
289 return s.length()==1 && std::isdigit(s[0]);
296 return atoi(s.c_str());
306 if (alignableMuon ==
NULL)
307 throw cms::Exception(
"MuonAlignmentFromReference") <<
"doMuon must be set to True" << std::endl;
340 bool made_fitter =
false;
367 CSCDetId id( (*ali)->geomDetId().rawId() );
395 throw cms::Exception(
"MuonAlignmentFromReference") <<
"only DTChambers and CSCChambers can be aligned with this module" << std::endl;
401 int index = (*ali)->geomDetId().rawId();
411 std::vector<Alignable*> all_DT_chambers = alignableMuon->
DTChambers();
412 std::vector<Alignable*> all_CSC_chambers = alignableMuon->
CSCChambers();
424 std::vector<Alignable*> &all_DT_chambers,
425 std::vector<Alignable*> &all_CSC_chambers)
427 std::map<Alignable*,bool> already_seen;
431 bool parsing_error =
false;
435 if (!barrel && !endcap) parsing_error =
true;
437 if (!parsing_error && barrel)
454 else parsing_error =
true;
457 bool wheel_digit =
false;
458 while (!parsing_error &&
numeric(
name->substr(index, 1)))
465 if (!plus) wheel *= -1;
466 if (!wheel_digit) parsing_error =
true;
472 bool station_digit =
false;
473 while (!parsing_error &&
numeric(
name->substr(index, 1)))
477 station_digit =
true;
480 if (!station_digit) parsing_error =
true;
486 bool sector_digit =
false;
487 while (!parsing_error &&
numeric(
name->substr(index, 1)))
494 if (!sector_digit) parsing_error =
true;
498 bool no_such_chamber =
false;
500 if (wheel < -2 || wheel > 2) no_such_chamber =
true;
501 if (station < 1 || station > 4) no_such_chamber =
true;
502 if (station == 4 && (sector < 1 || sector > 14)) no_such_chamber =
true;
503 if (station < 4 && (sector < 1 || sector > 12)) no_such_chamber =
true;
506 throw cms::Exception(
"MuonAlignmentFromReference") <<
"reference chamber doesn't exist: " << (*name) << std::endl;
509 for (std::vector<Alignable*>::const_iterator ali = all_DT_chambers.begin(); ali != all_DT_chambers.end(); ++ali)
511 if ((*ali)->geomDetId().rawId() ==
id.rawId())
513 std::map<Alignable*,bool>::const_iterator trial = already_seen.find(*ali);
514 if (trial == already_seen.end())
516 reference.push_back(*ali);
517 already_seen[*ali] =
true;
524 if (!parsing_error && endcap)
541 else parsing_error =
true;
544 bool station_digit =
false;
545 while (!parsing_error &&
numeric(
name->substr(index, 1)))
549 station_digit =
true;
552 if (!plus) station *= -1;
553 if (!station_digit) parsing_error =
true;
559 bool ring_digit =
false;
560 while (!parsing_error &&
numeric(
name->substr(index, 1)))
567 if (!ring_digit) parsing_error =
true;
573 bool chamber_digit =
false;
574 while (!parsing_error &&
numeric(
name->substr(index, 1)))
578 chamber_digit =
true;
581 if (!chamber_digit) parsing_error =
true;
585 bool no_such_chamber =
false;
587 int endcap = (station > 0 ? 1 : 2);
588 station =
abs(station);
589 if (station < 1 || station > 4) no_such_chamber =
true;
590 if (station == 1 && (ring < 1 || ring > 4)) no_such_chamber =
true;
591 if (station > 1 && (ring < 1 || ring > 2)) no_such_chamber =
true;
592 if (station == 1 && (chamber < 1 || chamber > 36)) no_such_chamber =
true;
593 if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18)) no_such_chamber =
true;
594 if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36)) no_such_chamber =
true;
597 throw cms::Exception(
"MuonAlignmentFromReference") <<
"reference chamber doesn't exist: " << (*name) << std::endl;
599 CSCDetId id(endcap, station, ring, chamber);
600 for (std::vector<Alignable*>::const_iterator ali = all_CSC_chambers.begin(); ali != all_CSC_chambers.end(); ++ali)
602 if ((*ali)->geomDetId().rawId() ==
id.rawId())
604 std::map<Alignable*,bool>::const_iterator trial = already_seen.find(*ali);
605 if (trial == already_seen.end())
607 reference.push_back(*ali);
608 already_seen[*ali] =
true;
616 throw cms::Exception(
"MuonAlignmentFromReference") <<
"reference chamber name is malformed: " << (*name) << std::endl;
631 for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin(); trajtrack != trajtracks.end(); ++trajtrack)
698 std::vector<DetId> chamberIds = mrft.
chamberIds();
706 for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end(); ++chamberId)
749 fitter->second->fill(charge, residdata);
789 fitter->second->fill(charge, residdata);
813 std::map<Alignable*,MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(ali);
828 fitter->second->fill(charge, residdata);
872 <<
"That's all!" << std::endl;
874 TStopwatch stop_watch;
881 std::cout <<
"readTmpFiles took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
890 std::cout <<
"selectResidualsPeaks took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
898 std::cout <<
"correctBField took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
907 std::cout <<
"fillNtuple took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
915 std::cout <<
"eraseNotSelectedResiduals took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
924 std::cout <<
"fitAndAlign took "<< stop_watch.CpuTime() <<
" sec" << std::endl;
943 report <<
"nan = None; NAN = None" << std::endl;
944 report <<
"reports = []" << std::endl;
945 report <<
"class ValErr:" << std::endl
946 <<
" def __init__(self, value, error, antisym):" << std::endl
947 <<
" self.value, self.error, self.antisym = value, error, antisym" << std::endl
949 <<
" def __repr__(self):" << std::endl
950 <<
" if self.antisym == 0.:" << std::endl
951 <<
" return \"%g +- %g\" % (self.value, self.error)" << std::endl
952 <<
" else:" << std::endl
953 <<
" return \"%g +- %g ~ %g\" % (self.value, self.error, self.antisym)" << std::endl
955 <<
"class Report:" << std::endl
956 <<
" def __init__(self, chamberId, postal_address, name):" << std::endl
957 <<
" self.chamberId, self.postal_address, self.name = chamberId, postal_address, name" << std::endl
958 <<
" self.status = \"NOFIT\"" << std::endl
959 <<
" self.fittype = None" << std::endl
961 <<
" def add_parameters(self, deltax, deltay, deltaz, deltaphix, deltaphiy, deltaphiz, loglikelihood, numsegments, sumofweights, redchi2):" << std::endl
962 <<
" self.status = \"PASS\"" << std::endl
963 <<
" self.deltax, self.deltay, self.deltaz, self.deltaphix, self.deltaphiy, self.deltaphiz = deltax, deltay, deltaz, deltaphix, deltaphiy, deltaphiz" << std::endl
964 <<
" self.loglikelihood, self.numsegments, self.sumofweights, self.redchi2 = loglikelihood, numsegments, sumofweights, redchi2" << std::endl
966 <<
" 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
967 <<
" 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
969 <<
" def __repr__(self):" << std::endl
970 <<
" return \"<Report %s %s %s>\" % (self.postal_address[0], \" \".join(map(str, self.postal_address[1:])), self.status)"<< std::endl
976 std::vector<bool> selector = (*ali)->alignmentParameters()->selector();
977 bool align_x = selector[0];
978 bool align_y = selector[1];
979 bool align_z = selector[2];
980 bool align_phix = selector[3];
981 bool align_phiy = selector[4];
982 bool align_phiz = selector[5];
983 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));
986 std::vector<int> paramIndex;
987 int paramIndex_counter = -1;
988 if (align_x) paramIndex_counter++;
989 paramIndex.push_back(paramIndex_counter);
990 if (align_y) paramIndex_counter++;
991 paramIndex.push_back(paramIndex_counter);
992 if (align_z) paramIndex_counter++;
993 paramIndex.push_back(paramIndex_counter);
994 if (align_phix) paramIndex_counter++;
995 paramIndex.push_back(paramIndex_counter);
996 if (align_phiy) paramIndex_counter++;
997 paramIndex.push_back(paramIndex_counter);
998 if (align_phiz) paramIndex_counter++;
999 paramIndex.push_back(paramIndex_counter);
1001 DetId id = (*ali)->geomDetId();
1011 char wheel_label[][2]={
"A",
"B",
"C",
"D",
"E"};
1019 sprintf(cname,
"MBwh%sst%dsec%02d", wheel_label[chamberId.
wheel()+2], chamberId.
station(), chamberId.
sector());
1022 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"DT\", "
1023 << chamberId.
wheel() <<
", " << chamberId.
station() <<
", " << chamberId.
sector() <<
"), \"" << cname <<
"\"))" << std::endl;
1029 sprintf(cname,
"ME%s%d%d_%02d", (chamberId.
endcap() == 1 ?
"p" :
"m"), chamberId.
station(), chamberId.
ring(), chamberId.
chamber());
1035 report <<
"reports.append(Report(" <<
id.rawId() <<
", (\"CSC\", "
1037 <<
"), \"" << cname <<
"\"))" << std::endl;
1043 std::map<Alignable*, MuonResidualsTwoBin*>::const_iterator fitter =
m_fitters.find(thisali);
1049 TStopwatch stop_watch;
1053 std::cout <<
"=============================================================================================" << std::endl;
1054 std::cout <<
"Fitting " << cname << std::endl;
1058 report <<
"reports[-1].posNum = " << fitter->second->numResidualsPos() << std::endl;
1059 report <<
"reports[-1].negNum = " << fitter->second->numResidualsNeg() << std::endl;
1095 bool successful_fit = fitter->second->fit(thisali);
1097 double loglikelihood = fitter->second->loglikelihood();
1098 double numsegments = fitter->second->numsegments();
1099 double sumofweights = fitter->second->sumofweights();
1100 double redchi2 = fitter->second->plot(cname, &rootDirectory, thisali);
1132 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error, gammaresslope_antisym;
1133 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error = gammaresslope_antisym = 0.;
1150 report <<
"reports[-1].fittype = \"5DOF\"" << std::endl;
1151 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1152 <<
" None, \\" << std::endl
1153 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1154 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1155 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1156 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1157 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1158 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " << sigmaresid_antisym <<
")" << std::endl;
1159 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1164 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " << gammaresid_antisym <<
")" << std::endl;
1165 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error <<
", " << gammaresslope_antisym <<
")" << std::endl;
1183 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1184 namesimple_x << cname <<
"_simple_x";
1185 namesimple_dxdz << cname <<
"_simple_dxdz";
1186 nameweighted_x << cname <<
"_weighted_x";
1187 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1198 if (align_x) params[paramIndex[0]] = deltax_value;
1199 if (align_z) params[paramIndex[2]] = deltaz_value;
1200 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1201 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1202 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1248 double gammax_value, gammax_error, gammax_antisym, gammay_value, gammay_error, gammay_antisym,
1249 gammadxdz_value, gammadxdz_error, gammadxdz_antisym, gammadydz_value, gammadydz_error, gammadydz_antisym;
1250 gammax_value = gammax_error = gammax_antisym = gammay_value = gammay_error = gammay_antisym = gammadxdz_value
1251 = gammadxdz_error = gammadxdz_antisym = gammadydz_value = gammadydz_error = gammadydz_antisym = 0.;
1275 report <<
"reports[-1].fittype = \"6DOF\"" << std::endl;
1276 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1277 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " << deltay_antisym <<
"), \\" << std::endl
1278 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1279 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1280 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1281 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1282 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1283 report <<
"reports[-1].sigmax = ValErr(" << sigmax_value <<
", " << sigmax_error <<
", " << sigmax_antisym<<
")" << std::endl;
1284 report <<
"reports[-1].sigmay = ValErr(" << sigmay_value <<
", " << sigmay_error <<
", " << sigmay_antisym<<
")" << std::endl;
1285 report <<
"reports[-1].sigmadxdz = ValErr(" << sigmadxdz_value <<
", " << sigmadxdz_error <<
", "<< sigmadxdz_antisym <<
")" << std::endl;
1286 report <<
"reports[-1].sigmadydz = ValErr(" << sigmadydz_value <<
", " << sigmadydz_error <<
", "<< sigmadydz_antisym <<
")" << std::endl;
1291 report <<
"reports[-1].gammax = ValErr(" << gammax_value <<
", " << gammax_error <<
", " << gammax_antisym <<
")" << std::endl;
1292 report <<
"reports[-1].gammay = ValErr(" << gammay_value <<
", " << gammay_error <<
", " << gammay_antisym <<
")" << std::endl;
1293 report <<
"reports[-1].gammadxdz = ValErr(" << gammadxdz_value <<
", " << gammadxdz_error <<
", " << gammadxdz_antisym <<
")" << std::endl;
1294 report <<
"reports[-1].gammadydz = ValErr(" << gammadydz_value <<
", " << gammadydz_error <<
", " << gammadydz_antisym <<
")" << std::endl;
1297 report <<
"reports[-1].add_stats("
1327 std::stringstream namesimple_x, namesimple_y, namesimple_dxdz, namesimple_dydz, nameweighted_x,
1328 nameweighted_y, nameweighted_dxdz, nameweighted_dydz;
1329 namesimple_x << cname <<
"_simple_x";
1330 namesimple_y << cname <<
"_simple_y";
1331 namesimple_dxdz << cname <<
"_simple_dxdz";
1332 namesimple_dydz << cname <<
"_simple_dydz";
1333 nameweighted_x << cname <<
"_weighted_x";
1334 nameweighted_y << cname <<
"_weighted_y";
1335 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1336 nameweighted_dydz << cname <<
"_weighted_dydz";
1351 if (align_x) params[paramIndex[0]] = deltax_value;
1352 if (align_y) params[paramIndex[1]] = deltay_value;
1353 if (align_z) params[paramIndex[2]] = deltaz_value;
1354 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1355 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1356 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1394 double gammaresid_value, gammaresid_error, gammaresid_antisym, gammaresslope_value, gammaresslope_error, gammaresslope_antisym;
1395 gammaresid_value = gammaresid_error = gammaresid_antisym = gammaresslope_value = gammaresslope_error = gammaresslope_antisym = 0.;
1411 report <<
"reports[-1].fittype = \"6DOFrphi\"" << std::endl;
1412 report <<
"reports[-1].add_parameters(ValErr(" << deltax_value <<
", " << deltax_error <<
", " << deltax_antisym <<
"), \\" << std::endl
1413 <<
" ValErr(" << deltay_value <<
", " << deltay_error <<
", " << deltay_antisym <<
"), \\" << std::endl
1414 <<
" ValErr(" << deltaz_value <<
", " << deltaz_error <<
", " << deltaz_antisym <<
"), \\" << std::endl
1415 <<
" ValErr(" << deltaphix_value <<
", " << deltaphix_error <<
", " << deltaphix_antisym <<
"), \\" << std::endl
1416 <<
" ValErr(" << deltaphiy_value <<
", " << deltaphiy_error <<
", " << deltaphiy_antisym <<
"), \\" << std::endl
1417 <<
" ValErr(" << deltaphiz_value <<
", " << deltaphiz_error <<
", " << deltaphiz_antisym <<
"), \\" << std::endl
1418 <<
" " << loglikelihood <<
", " << numsegments <<
", " << sumofweights <<
", " << redchi2 <<
")" << std::endl;
1419 report <<
"reports[-1].sigmaresid = ValErr(" << sigmaresid_value <<
", " << sigmaresid_error <<
", " << sigmaresid_antisym <<
")" << std::endl;
1420 report <<
"reports[-1].sigmaresslope = ValErr(" << sigmaresslope_value <<
", " << sigmaresslope_error <<
", " << sigmaresslope_antisym <<
")" << std::endl;
1425 report <<
"reports[-1].gammaresid = ValErr(" << gammaresid_value <<
", " << gammaresid_error <<
", " << gammaresid_antisym <<
")" << std::endl;
1426 report <<
"reports[-1].gammaresslope = ValErr(" << gammaresslope_value <<
", " << gammaresslope_error <<
", " << gammaresslope_antisym <<
")" << std::endl;
1444 std::stringstream namesimple_x, namesimple_dxdz, nameweighted_x, nameweighted_dxdz;
1445 namesimple_x << cname <<
"_simple_x";
1446 namesimple_dxdz << cname <<
"_simple_dxdz";
1447 nameweighted_x << cname <<
"_weighted_x";
1448 nameweighted_dxdz << cname <<
"_weighted_dxdz";
1459 if (align_x) params[paramIndex[0]] = deltax_value;
1460 if (align_y) params[paramIndex[1]] = deltay_value;
1461 if (align_z) params[paramIndex[2]] = deltaz_value;
1462 if (align_phix) params[paramIndex[3]] = deltaphix_value;
1463 if (align_phiy) params[paramIndex[4]] = deltaphiy_value;
1464 if (align_phiz) params[paramIndex[5]] = deltaphiz_value;
1470 std::vector<Alignable*> oneortwo;
1471 oneortwo.push_back(*ali);
1472 if (thisali != *ali) oneortwo.push_back(thisali);
1477 std::cout <<
"MINUIT fit failed!" << std::endl;
1480 report <<
"reports[-1].status = \"MINUITFAIL\"" << std::endl;
1483 for (
int i = 0;
i < numParams;
i++) cov[
i][
i] = 1000.;
1485 std::vector<Alignable*> oneortwo;
1486 oneortwo.push_back(*ali);
1487 if (thisali != *ali) oneortwo.push_back(thisali);
1493 std::cout <<
"Too few hits!" << std::endl;
1496 report <<
"reports[-1].status = \"TOOFEWHITS\"" << std::endl;
1499 for (
int i = 0;
i < numParams;
i++) cov[
i][
i] = 1000.;
1501 std::vector<Alignable*> oneortwo;
1502 oneortwo.push_back(*ali);
1503 if (thisali != *ali) oneortwo.push_back(thisali);
1508 (*ali)->setAlignmentParameters(parnew);
1510 (*ali)->alignmentParameters()->setValid(
true);
1512 std::cout << cname<<
" fittime= "<< stop_watch.CpuTime() <<
" sec" << std::endl;
1515 if (writeReport) report << std::endl;
1519 if (writeReport) report.close();
1529 file = fopen(
fileName->c_str(),
"r");
1531 throw cms::Exception(
"MuonAlignmentFromReference") <<
"file \"" << *
fileName <<
" can't be opened (doesn't exist?)" << std::endl;
1533 fread(&size,
sizeof(
int), 1, file);
1536 <<
" fitters, but this job has " <<
m_indexes.size() <<
" fitters (probably corresponds to the wrong alignment job)" << std::endl;
1542 unsigned int index_toread;
1543 fread(&index_toread,
sizeof(
unsigned int), 1, file);
1544 if (*
index != index_toread)
1545 throw cms::Exception(
"MuonAlignmentFromReference") <<
"file \"" << *
fileName <<
"\" has index " << index_toread
1546 <<
" at position " << i <<
", but this job is expecting " << *
index <<
" (probably corresponds to the wrong alignment job)" << std::endl;
1547 fitter->
read(file, i);
1560 fwrite(&size,
sizeof(
int), 1, file);
1566 unsigned int index_towrite = *
index;
1567 fwrite(&index_towrite,
sizeof(
unsigned int), 1, file);
1568 fitter->
write(file, i);
1606 int vars_index[10] = {0,1};
1685 sprintf(cname,
"MB%+d/%d/%02d", chamberId.
wheel(), chamberId.
station(), chamberId.
sector());
1690 sprintf(cname,
"ME%s%d/%d/%02d", (chamberId.
endcap() == 1 ?
"+" :
"-"), chamberId.
station(), chamberId.
ring(), chamberId.
chamber());
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()
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
long m_counter_station123aligning
int m_minNCrossedChambers
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
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
uint32_t rawId() const
get the raw id
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
long m_counter_cscaligning
void eraseNotSelectedResiduals()
Abs< T >::type abs(const T &t)
void write(FILE *file, int which=0)
void parseReference(std::vector< Alignable * > &reference, std::vector< Alignable * > &all_DT_chambers, std::vector< Alignable * > &all_CSC_chambers)
virtual ~MuonAlignmentFromReference()
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
void read(FILE *file, int which=0)
std::string m_writeTemporaryFile
std::string m_useResiduals
long m_counter_station4aligning
long m_counter_station4valid
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
std::vector< double * >::const_iterator residualsPos_begin() const
int station() const
Return the station number.
void selectPeakResiduals(double nsigma, int nvar, int *vars)
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Detector det() const
get the detector field from this detid
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
tuple size
Write out results.
long m_counter_minchambers
const align::Alignables & alignables(void) const
get all alignables
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
std::map< unsigned int, MuonResidualsTwoBin * > m_fitterOrder
std::vector< Alignable * > m_alignables
bool contains_TIDTEC() const
std::map< Alignable *, MuonResidualsTwoBin * > m_fitters
MuonChamberResidual * chamberResidual(DetId chamberId, int type)