2 #include <unordered_map> 48 theMonitorConfig(cfg),
49 doTrackHitMonitoring(theMonitorConfig.fillTrackMonitoring || theMonitorConfig.fillTrackHitMonitoring),
51 surveyResiduals_(cfg.getUntrackedParameter<
std::vector<
std::
string>>(
"surveyResiduals")),
52 theTrackHitMonitorIORootFile(
nullptr),
55 theAlignablesMonitorIORootFile(
nullptr),
56 theAlignablesMonitorTree(
nullptr),
101 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" 110 if (uniEtaFormula.empty()) {
111 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" 112 <<
"Uniform eta formula is empty! Resetting to 1.";
115 theEtaFormula = std::make_unique<TFormula>(uniEtaFormula.c_str());
122 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" 132 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" 133 <<
"Initializing...";
147 bool findMatchIOV =
false;
148 for (
unsigned int iovl = 0; iovl <
theIOVrangeSet.size(); iovl++) {
151 iovapp.append(
".root");
152 iovapp.insert(0,
"_");
162 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" 163 <<
"Found the IOV file matching IOV first run " <<
firstrun;
169 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" 170 <<
"Didn't find the IOV file matching IOV first run " << firstrun
171 <<
" from the validity interval";
174 iovapp.append(
".root");
175 iovapp.insert(0,
"_");
183 if (extras !=
nullptr)
184 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" 185 <<
"AlignableNavigator initialized with AlignableExtras";
200 for (std::vector<edm::ParameterSet>::const_iterator setiter =
theAPEParameterSet.begin();
208 if (alignParams.size() == 1 && alignParams[0] ==
std::string(
"selected"))
215 std::vector<double> apeSPar = setiter->getParameter<std::vector<double>>(
"apeSPar");
216 std::vector<double> apeRPar = setiter->getParameter<std::vector<double>>(
"apeRPar");
217 std::string function = setiter->getParameter<std::string>(
"function");
219 if (apeSPar.size() != 3 || apeRPar.size() != 3)
220 throw cms::Exception(
"BadConfig") <<
"apeSPar and apeRPar must have 3 values each" << std::endl;
222 for (std::vector<double>::const_iterator
i = apeRPar.begin();
i != apeRPar.end(); ++
i)
223 apeSPar.push_back(*
i);
225 if (
function == std::string(
"linear"))
226 apeSPar.push_back(0);
227 else if (
function == std::string(
"exponential"))
228 apeSPar.push_back(1);
229 else if (
function == std::string(
"step"))
230 apeSPar.push_back(2);
233 <<
"APE function must be \"linear\", \"exponential\", or \"step\"." << std::endl;
250 if (alignParams.size() == 1 && alignParams[0] ==
std::string(
"selected"))
257 double minRelParError = setiter->getParameter<
double>(
"minRelParError");
258 double maxRelParError = setiter->getParameter<
double>(
"maxRelParError");
259 int minNHits = setiter->getParameter<
int>(
"minNHits");
260 double maxHitPull = setiter->getParameter<
double>(
"maxHitPull");
261 bool applyPixelProbCut = setiter->getParameter<
bool>(
"applyPixelProbCut");
262 bool usePixelProbXYOrProbQ = setiter->getParameter<
bool>(
"usePixelProbXYOrProbQ");
263 double minPixelProbXY = setiter->getParameter<
double>(
"minPixelProbXY");
264 double maxPixelProbXY = setiter->getParameter<
double>(
"maxPixelProbXY");
265 double minPixelProbQ = setiter->getParameter<
double>(
"minPixelProbQ");
266 double maxPixelProbQ = setiter->getParameter<
double>(
"maxPixelProbQ");
267 for (
auto& ali : alignables) {
282 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" 283 <<
"Alignment specifics acquired for detector " << alispecs.
id() <<
" / " 284 << alispecs.
objId() <<
":\n" 287 <<
" - minNHits = " << alispecs.
minNHits <<
"\n" 288 <<
" - maxHitPull = " << alispecs.
maxHitPull <<
"\n" 303 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 317 int numAlignablesFromFile = theAlignablePositionsFromFile.size();
318 if (numAlignablesFromFile == 0) {
324 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 325 <<
"IO alignables file not found for iteration " <<
theIteration;
327 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 328 <<
"Alignables Read " << numAlignablesFromFile;
338 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 339 <<
"Iteration increased by one and is now " <<
theIteration;
343 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 344 <<
"Apply positions from file ...";
348 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 361 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" 371 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm] Using survey constraint";
377 for (
unsigned int i = 0;
i < nAlignable; ++
i) {
381 int nhit = uservar->
nhit;
385 int tmp_Type = tl.first;
386 int tmp_Layer = tl.second;
388 float tmpz = pos.
z();
390 (tmp_Type == 5 && tmp_Layer == 4 && fabs(tmpz) > 90)) {
408 uservar->
jtvj += invCov;
409 uservar->
jtve += invCov * sensResid;
434 <<
", step=" <<
SetScanDet.at(2) <<
", currentDet = " << ali->id();
442 if (dynamic_cast<AlignableDetUnit*>(ali) !=
nullptr) {
443 std::vector<std::pair<int, SurfaceDeformation*>> pairs;
444 ali->surfaceDeformationIdPairs(pairs);
445 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" 446 <<
"The alignable contains " << pairs.size() <<
" surface deformations";
448 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" 449 <<
"The alignable cannot contain surface deformations";
453 ali->alignmentParameters()->setValid(
true);
461 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::terminate] Aligned units: " << ialigned;
466 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm] Writing aligned parameters to file: " << theAlignables.size()
525 static const unsigned int hitDim = 1;
546 covmat = covmat + ipcovmat;
550 if (covmat[0][0] != 0.)
551 xpull = (pos[0] - coor[0]) /
sqrt(fabs(covmat[0][0]));
560 int npar = derivs2D.num_row();
563 for (
int ipar = 0; ipar < npar; ipar++) {
564 for (
unsigned int idim = 0; idim < hitDim; idim++) {
565 derivs[ipar][idim] = derivs2D[ipar][idim];
573 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit1D" 574 <<
"Cov. matrix inversion failed!";
578 double maxHitPullThreshold =
580 bool useThisHit = (maxHitPullThreshold < 0.);
581 useThisHit |= (fabs(xpull) < maxHitPullThreshold);
583 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" 584 <<
"Hit pull (x) " << xpull <<
" fails the cut " << maxHitPullThreshold;
592 thisjtvj.assign(jtvjtmp);
593 thisjtve = derivs * covmat * (pos - coor);
596 hitresidual[0] = (pos[0] - coor[0]);
599 hitresidualT = hitresidual.T();
601 uservar->
jtvj += hitwt * thisjtvj;
602 uservar->
jtve += hitwt * thisjtve;
607 thischi2 = hitwt * (hitresidualT * covmat * hitresidual)[0];
609 if (
verbose && (thischi2 / static_cast<float>(uservar->
nhit)) > 10.)
610 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit1D] Added to Chi2 the number " << thischi2
611 <<
" having " << uservar->
nhit <<
" ndof" 612 <<
", X-resid " << hitresidual[0] <<
", Cov^-1 matr (covmat):" 613 <<
" [0][0] = " << covmat[0][0];
627 static const unsigned int hitDim = 2;
654 covmat = covmat + ipcovmat;
659 if (covmat[0][0] != 0.)
660 xpull = (pos[0] - coor[0]) /
sqrt(fabs(covmat[0][0]));
661 if (covmat[1][1] != 0.)
662 ypull = (pos[1] - coor[1]) /
sqrt(fabs(covmat[1][1]));
671 int npar = derivs2D.num_row();
674 for (
int ipar = 0; ipar < npar; ipar++) {
675 for (
unsigned int idim = 0; idim < hitDim; idim++) {
676 derivs[ipar][idim] = derivs2D[ipar][idim];
684 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" 685 <<
"Cov. matrix inversion failed!";
689 double maxHitPullThreshold =
691 bool useThisHit = (maxHitPullThreshold < 0.);
692 useThisHit |= (fabs(xpull) < maxHitPullThreshold && fabs(ypull) < maxHitPullThreshold);
694 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" 695 <<
"Hit pull (x,y) " << xpull <<
" , " << ypull <<
" fails the cut " 696 << maxHitPullThreshold;
704 thisjtvj.assign(jtvjtmp);
705 thisjtve = derivs * covmat * (pos - coor);
708 hitresidual[0] = (pos[0] - coor[0]);
709 hitresidual[1] = (pos[1] - coor[1]);
712 hitresidualT = hitresidual.T();
714 uservar->
jtvj += hitwt * thisjtvj;
715 uservar->
jtve += hitwt * thisjtve;
720 thischi2 = hitwt * (hitresidualT * covmat * hitresidual)[0];
722 if (
verbose && (thischi2 / static_cast<float>(uservar->
nhit)) > 10.)
723 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit2D] Added to Chi2 the number " << thischi2
724 <<
" having " << uservar->
nhit <<
" ndof" 725 <<
", X-resid " << hitresidual[0] <<
", Y-resid " << hitresidual[1]
726 <<
", Cov^-1 matr (covmat):" 727 <<
" [0][0] = " << covmat[0][0] <<
" [0][1] = " << covmat[0][1]
728 <<
" [1][0] = " << covmat[1][0] <<
" [1][1] = " << covmat[1][1];
747 for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
751 float pt = track->
pt();
754 float p = track->
p();
757 float d0 = track->
d0();
758 float dz = track->
dz();
768 edm::LogInfo(
"Alignment") <<
"New track pt,eta,phi,chi2n,hits: " << pt <<
"," << eta <<
"," << phi <<
"," << chi2n
780 double r = gRandom->Rndm();
805 std::vector<const TransientTrackingRecHit*> hitvec;
806 std::vector<TrajectoryStateOnSurface> tsosvec;
809 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
810 for (std::vector<TrajectoryMeasurement>::iterator im = measurements.begin(); im != measurements.end(); ++im) {
834 const std::type_info&
type =
typeid(*rechit);
844 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 845 <<
"TypeId of the RecHit: " <<
className(*hit);
855 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 856 <<
"TypeId of the TTRH: " <<
className(*hit);
867 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! " 868 <<
"TypeId of the TTRH: " <<
className(*hit);
878 hitvec.push_back(hit);
879 tsosvec.push_back(tsos);
891 std::vector<TrajectoryStateOnSurface>::const_iterator itsos = tsosvec.begin();
892 std::vector<const TransientTrackingRecHit*>::const_iterator ihit = hitvec.begin();
895 while (itsos != tsosvec.end()) {
897 const GeomDet* det = (*ihit)->det();
899 uint32_t nhitDim = (*ihit)->dimension();
906 if (ali !=
nullptr) {
918 double angle = TMath::ASin(sin_theta);
919 double alihitwt = ihitwt;
936 if ((*ihit)->hit() !=
nullptr) {
938 if (pixhit !=
nullptr) {
952 probXYQgood = (probXYgood || probQgood);
954 probXYQgood = (probXYgood && probQgood);
963 bool hitProcessed =
false;
966 hitProcessed =
processHit1D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
969 hitProcessed =
processHit2D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
973 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Number of hit dimensions = " << nhitDim
974 <<
" is not supported!" << std::endl;
995 std::ifstream inIterFile(filename.c_str(),
std::ios::in);
997 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] ERROR! " 998 <<
"Unable to open Iteration file";
1002 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] " 1003 <<
"Read last iteration number from file: " <<
result;
1012 std::ofstream outIterFile((filename.c_str()),
std::ios::out);
1014 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] ERROR: Unable to write Iteration file";
1016 outIterFile << iter;
1017 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] writing iteration number to file: " 1020 outIterFile.close();
1028 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] No APE applied";
1032 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] Apply APE!";
1034 double apeSPar[3], apeRPar[3];
1036 const auto& alignables = alipars.first;
1037 const auto& pars = alipars.second;
1039 apeSPar[0] = pars[0];
1040 apeSPar[1] = pars[1];
1041 apeSPar[2] = pars[2];
1042 apeRPar[0] = pars[3];
1043 apeRPar[1] = pars[4];
1044 apeRPar[2] = pars[5];
1046 int function = pars[6];
1049 printf(
"APE: %u alignables\n", (
unsigned int)alignables.size());
1050 for (
int i = 0;
i < 21; ++
i) {
1051 double apelinstest =
calcAPE(apeSPar,
i, 0);
1052 double apeexpstest =
calcAPE(apeSPar,
i, 1);
1053 double apestepstest =
calcAPE(apeSPar,
i, 2);
1054 double apelinrtest =
calcAPE(apeRPar,
i, 0);
1055 double apeexprtest =
calcAPE(apeRPar,
i, 1);
1056 double apesteprtest =
calcAPE(apeRPar,
i, 2);
1057 printf(
"APE: iter slin sexp sstep rlin rexp rstep: %5d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f \n",
1077 double diter = (double)iter;
1079 return std::max(par[1], par[0] + ((par[1] - par[0]) / par[2]) * diter);
1080 else if (
function == 1)
1081 return std::max(0., par[0] * (
exp(-
pow(diter, par[1]) / par[2])));
1082 else if (
function == 2) {
1083 int ipar2 = (
int)par[2];
1084 int step = iter / ipar2;
1085 double dstep = (double)step;
1086 return std::max(0., par[0] - par[1] * dstep);
1147 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Survey trees booked.";
1149 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Root trees booked.";
1186 m2_ObjId = ali->alignableObjectId();
1196 std::vector<std::pair<int, SurfaceDeformation*>> dali_id_pairs;
1199 std::vector<double> dali;
1200 if (1 == ali->surfaceDeformationIdPairs(dali_id_pairs)) {
1201 dali_obj = dali_id_pairs[0].second;
1205 for (
auto& dit : dali)
1213 edm::LogVerbatim(
"Alignment") <<
"------------------------------------------------------------------------\n" 1214 <<
" ALIGNABLE: " << setw(6) << naligned <<
'\n' 1215 <<
"hits: " << setw(4) <<
m2_Nhit <<
" type: " << setw(4) <<
m2_Type 1216 <<
" layer: " << setw(4) <<
m2_Layer <<
" id: " << setw(4) <<
m2_Id 1217 <<
" objId: " << setw(4) <<
m2_ObjId <<
'\n' 1220 <<
"\nDeformations type, nDeformations: " << setw(12) <<
m2_dtype << setw(12)
1222 <<
"params: " << setw(12) << pars[0] << setw(12) << pars[1] << setw(12) << pars[2]
1223 << setw(12) << pars[3] << setw(12) << pars[4] << setw(12) << pars[5];
1235 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1236 <<
"Begin: Processing detector " << ali->
id();
1243 int nhit = uservar->
nhit;
1251 minHitThreshold = 1;
1252 if (setDet == 0 && nhit < minHitThreshold) {
1253 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1254 <<
"Skipping detector " << ali->
id() <<
" because number of hits = " << nhit
1255 <<
" <= " << minHitThreshold;
1264 int npar = jtve.num_row();
1275 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1276 <<
"Matrix inversion failed!";
1279 params = -(jtvjinv * jtve);
1282 double minRelErrThreshold =
1284 double maxRelErrThreshold =
1286 for (
int i = 0;
i < npar;
i++) {
1288 if (fabs(cov[
i][
i]) > 0.)
1289 paramerr[
i] =
sqrt(fabs(cov[i][i]));
1291 paramerr[
i] = params[
i];
1292 if (params[i] != 0.)
1293 relerr = fabs(paramerr[i] / params[i]);
1294 if ((maxRelErrThreshold >= 0. && relerr > maxRelErrThreshold) || relerr < minRelErrThreshold) {
1295 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1296 <<
"RelError = " << relerr <<
" > " << maxRelErrThreshold <<
" or < " 1297 << minRelErrThreshold <<
". Setting param = paramerr = 0 for component " <<
i;
1303 if (params.num_row() != 1) {
1304 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1305 <<
"For scanning, please only turn on one parameter! check common_cff_py.txt";
1312 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1313 <<
"Parameters = " <<
params;
1318 uservar->
alierr = paramerr;
1324 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" 1325 <<
"End: Processing detector " << ali->
id();
1332 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1335 std::vector<std::string> monitorFileList;
1339 std::unordered_map<Alignable*, std::unordered_map<int, pawt_t>> ali_datatypecountpair_map;
1341 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1342 <<
"Per-alignable reweighting is turned on. Iterating over the parallel jobs to sum " 1343 "number of hits per alignable for each data type.";
1346 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1347 <<
"Pre-reading uservar for job " << ijob;
1352 std::vector<AlignmentUserVariables*> uvarvec =
1355 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1357 <<
" is not the same as number of user variables = " << uvarvec.size()
1358 <<
". A mismatch might occur!";
1360 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1361 <<
"Could not read user variable files for job " << ijob <<
" in iteration " 1365 std::vector<AlignmentUserVariables*>::const_iterator iuvar =
1371 if (uvar !=
nullptr) {
1373 pawt_t alijobnhits = uvar->
nhit;
1374 if (ali_datatypecountpair_map.find(ali) == ali_datatypecountpair_map.end()) {
1375 std::unordered_map<int, pawt_t> newmap;
1376 ali_datatypecountpair_map[ali] = newmap;
1377 ali_datatypecountpair_map[ali][alijobdtype] = alijobnhits;
1379 std::unordered_map<int, pawt_t>& theMap = ali_datatypecountpair_map[ali];
1380 if (theMap.find(alijobdtype) == theMap.end())
1381 theMap[alijobdtype] = alijobnhits;
1383 theMap[alijobdtype] += alijobnhits;
1393 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1394 <<
"Reading uservar for job " << ijob;
1399 std::vector<AlignmentUserVariables*> uvarvec =
1402 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1404 <<
" is not the same as number of user variables = " << uvarvec.size()
1405 <<
". A mismatch might occur!";
1408 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1409 <<
"Could not read user variable files for job " << ijob <<
" in iteration " 1415 std::vector<AlignmentUserVariables*> uvarvecadd;
1416 std::vector<AlignmentUserVariables*>::const_iterator iuvarnew = uvarvec.begin();
1427 if (uvarnew !=
nullptr) {
1428 double peraliwgt = 1;
1430 int alijobdtype = uvarnew->
datatype;
1431 if (ali_datatypecountpair_map.find(ali) != ali_datatypecountpair_map.end() &&
1432 ali_datatypecountpair_map[ali].find(alijobdtype) != ali_datatypecountpair_map[ali].end()) {
1433 peraliwgt = ali_datatypecountpair_map[ali][alijobdtype];
1434 unsigned int nNonZeroTypes = 0;
1436 for (
auto it = ali_datatypecountpair_map[ali].cbegin(); it != ali_datatypecountpair_map[ali].cend(); ++it) {
1437 sumwgts += it->second;
1438 if (it->second != pawt_t(0))
1441 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1442 <<
"Reweighting detector " << ali->id() <<
" / " << ali->alignableObjectId()
1443 <<
" for data type " << alijobdtype <<
" by " << sumwgts <<
"/" << peraliwgt
1444 <<
"/" << nNonZeroTypes;
1445 peraliwgt = ((nNonZeroTypes == 0 || peraliwgt == double(0))
1447 : double((
double(sumwgts)) / peraliwgt / (
double(nNonZeroTypes))));
1448 }
else if (ali_datatypecountpair_map.find(ali) != ali_datatypecountpair_map.end())
1449 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1450 <<
"Could not find data type " << alijobdtype <<
" for detector " << ali->id()
1451 <<
" / " << ali->alignableObjectId();
1453 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1454 <<
"Could not find detector " << ali->id() <<
" / " << ali->alignableObjectId()
1455 <<
" in the map ali_datatypecountpair_map";
1459 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt * (uvarnew->
jtvj);
1460 uvar->
jtve = (uvarold->
jtve) + peraliwgt * (uvarnew->
jtve);
1467 uvarvecadd.push_back(uvar);
1476 monitorFileList.push_back(uvfile);
1490 throw cms::Exception(
"LogicError") <<
"[HIPAlignmentAlgorithm::collectMonitorTrees] Called in non-collector mode." 1493 TString theTrackMonitorTreeName = Form(
"T1_%i",
theIteration);
1494 TString theHitMonitorTreeName = Form(
"T1_hit_%i",
theIteration);
1496 std::vector<TFile*> finputlist;
1497 TList* eventtrees =
new TList;
1498 TList* hittrees =
new TList;
1500 TFile* finput = TFile::Open(
filename.c_str(),
"read");
1501 if (finput !=
nullptr) {
1505 tmptree = (TTree*)finput->Get(theTrackMonitorTreeName);
1506 if (tmptree !=
nullptr)
1507 eventtrees->Add(tmptree);
1511 tmptree = (TTree*)finput->Get(theHitMonitorTreeName);
1512 if (tmptree !=
nullptr)
1513 hittrees->Add((TTree*)finput->Get(theHitMonitorTreeName));
1515 finputlist.push_back(finput);
1520 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collectMonitorTrees" 1521 <<
"Monitor file is already open while it is not supposed to be!";
1530 if (eventtrees->GetSize() > 0)
1532 if (hittrees->GetSize() > 0)
1538 for (TFile*& finput : finputlist)
1550 if (ali !=
nullptr) {
1554 if (it->matchAlignable(ali))
1557 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::findAlignableSpecs] Alignment object with id " << ali->
id()
1558 <<
" / " << ali->
alignableObjectId() <<
" could not be found. Returning default.";
ClusterRef cluster() const
void attachUserVariables(const align::Alignables &alivec, const std::vector< AlignmentUserVariables * > &uvarvec, int &ierr)
Attach User Variables to given alignables.
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
TTree * theTrackMonitorTree
std::string uniEtaFormula
bool hasFilledProb() const
std::vector< int > m_nhTIB
std::vector< HIPAlignableSpecificParameters > theAlignableSpecifics
HIPAlignableSpecificParameters defaultAlignableSpecs
ConstRecHitPointer const & recHit() const
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
AlignmentParameterStore * theAlignmentParameterStore
std::vector< float > m_Eta
std::pair< int, int > typeAndLayer(const Alignable *ali, const TrackerTopology *tTopo) const
Obtain type and layer from Alignable.
const EventID & eventID() const
std::vector< float > m_d0
bool usePixelProbXYOrProbQ
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
static AlignableObjectId commonObjectIdProvider(const AlignableObjectId &, const AlignableObjectId &)
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
TFile * theAlignablesMonitorIORootFile
HIPUserVariables * clone(void) const override
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
LocalVector localDirection() const
LocalPoint localPosition() const
HIPAlignableSpecificParameters * findAlignableSpecs(const Alignable *ali)
void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override
Run the algorithm.
static char const * tname
void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
Call at beginning of job.
align::StructureType m2_ObjId
double phi() const
azimuthal angle of momentum vector
void writeIterationFile(std::string filename, int iter)
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
TFile * theTrackHitMonitorIORootFile
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &adet) const
Get relevant Alignable from AlignableDet.
void applyAlignableAbsolutePositions(const align::Alignables &alis, const AlignablePositions &newpos, int &ierr)
apply absolute positions to alignables
std::vector< int > m_Nhits
LocalError positionError() const
int numberOfValidStripTOBHits() const
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
std::unique_ptr< AlignableNavigator > theAlignableDetAccessor
const ConstTrajTrackPairCollection & trajTrackPairs() const
define event information passed to algorithms
std::vector< unsigned > theIOVrangeSet
void writeHIPUserVariables(const Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
bool calcParameters(Alignable *ali, int setDet, double start, double step)
const bool fillTrackHitMonitoring
std::vector< float > m_Pt
const AlgebraicVector & parameters(void) const
Get alignment parameters.
void bookBranches() override
DataContainer const & measurements() const
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
std::vector< int > m_nhPXB
void clear()
remove all selected Alignables and geometrical restrictions
std::vector< float > m_wt
double eta() const
pseudorapidity of momentum vector
int numberOfValidPixelBarrelHits() const
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
std::vector< AlignmentUserVariables * > readHIPUserVariables(const Alignables &alivec, const char *filename, int iter, int &ierr)
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
CLHEP::HepMatrix AlgebraicMatrix
HIPAlignmentAlgorithm(const edm::ParameterSet &cfg)
Constructor.
std::vector< edm::ParameterSet > theCutsPerComponent
void setValid(bool v)
Set validity flag.
std::vector< int > m_nhTID
TTree * theHitMonitorTree
double pt() const
track transverse momentum
std::vector< float > m_Phi
HIPHitMonitorVariables hitmonitorvars
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string siterationfile
std::vector< int > m_nhTEC
AlignablePositions readAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, int &ierr) override
read Alignable current absolute positions
int numberOfValidStripTIDHits() const
ClusterRef cluster() const
int readIterationFile(std::string filename)
unsigned short numberOfValidHits() const
number of valid hits found
int numberOfValidStripTECHits() const
std::vector< double > SetScanDet
const LocalTrajectoryError & localError() const
void setAlignmentPositionError(void)
virtual LocalPoint localPosition() const =0
TFile * theSurveyIORootFile
const bool fillTrackMonitoring
unsigned int m_rawQualityWord
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
void collectMonitorTrees(const std::vector< std::string > &filenames)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double calcAPE(double *par, int iter, int function)
const align::Alignables & selectedAlignables() const
vector of alignables selected so far
std::string suvarfilecore
int numSelected(void) const
Get number of selected parameters.
virtual TrackingRecHit const * hit() const
CLHEP::HepVector AlgebraicVector
void setTree(TTree *tree_)
std::vector< int > m_nhTOB
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
HIPTrackMonitorVariables trackmonitorvars
const std::string outfilecore
align::StructureType objId() const
ClusterRef cluster() const
CompositeAlignmentParameters selectParameters(const std::vector< AlignableDet * > &alignabledets) const
AlgebraicSymMatrix inverseCovariance() const
Get inverse of survey covariance wrt given structure type in constructor.
bool theApplyCutsPerComponent
std::unique_ptr< AlignableObjectId > alignableObjectId_
void writeAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr) override
write Alignable current absolute positions
void bookBranches() override
std::string smisalignedfile
int numberOfValidStripTIBHits() const
std::vector< edm::ParameterSet > theAPEParameterSet
align::StructureType m3_ObjId
std::unique_ptr< TFormula > theEtaFormula
std::vector< Alignable * > Alignables
int numberOfValidPixelEndcapHits() const
align::Alignables theAlignables
virtual void terminate()
Called at end of job (must be implemented in derived class)
AlgebraicVector sensorResidual() const
std::vector< float > m2_surfDef
const AliClusterValueMap * clusterValueMap() const
HIPMonitorConfig theMonitorConfig
float probabilityXY() const
void fillAlignablesMonitor(const edm::EventSetup &setup)
bool isValid(void) const
Get validity flag.
CLHEP::HepSymMatrix AlgebraicSymMatrix
void startNewLoop(void) override
Called at start of new loop.
unsigned int addSelections(const edm::ParameterSet &pSet)
const std::vector< std::string > surveyResiduals_
std::vector< int > m_nhPXF
std::vector< AlignableAbsData > AlignablePositions
bool processHit2D(const AlignableDetOrUnitPtr &alidet, const Alignable *ali, const HIPAlignableSpecificParameters *alispecifics, const TrajectoryStateOnSurface &tsos, const TrackingRecHit *hit, double hitwt)
std::vector< float > m_dz
DetId geographicalId() const
bool processHit1D(const AlignableDetOrUnitPtr &alidet, const Alignable *ali, const HIPAlignableSpecificParameters *alispecifics, const TrajectoryStateOnSurface &tsos, const TrackingRecHit *hit, double hitwt)
const IOVSyncValue & first() const
std::vector< std::pair< align::Alignables, std::vector< double > > > theAPEParameters
virtual LocalError localPositionError() const =0
TTree * theAlignablesMonitorTree
Constructor of the full muon geometry.
const PositionType & position() const
T const * product() const
std::vector< align::StructureType > theLevels
SiPixelRecHitQuality::QualWordType rawQualityWord() const
std::vector< float > m_Chi2n
float probabilityQ() const
Power< A, B >::type pow(const A &a, const B &b)
const align::Alignables & alignables(void) const
get all alignables
std::string className(const T &t)
const bool doTrackHitMonitoring
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
std::string theCollectorPath
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
SurfaceDeformationFactory::Type m2_dtype
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
std::string sparameterfile