2 #include <unordered_map>
48 theMonitorConfig(
cfg),
49 doTrackHitMonitoring(theMonitorConfig.fillTrackMonitoring || theMonitorConfig.fillTrackHitMonitoring),
50 defaultAlignableSpecs((
Alignable*)nullptr),
52 theTrackHitMonitorIORootFile(nullptr),
53 theTrackMonitorTree(nullptr),
54 theHitMonitorTree(nullptr),
55 theAlignablesMonitorIORootFile(nullptr),
56 theAlignablesMonitorTree(nullptr),
57 theSurveyIORootFile(nullptr),
58 theSurveyTree(nullptr) {
101 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm"
104 trackPs =
cfg.getParameter<
bool>(
"UsePreSelection");
106 trackWt =
cfg.getParameter<
bool>(
"UseReweighting");
107 Scale =
cfg.getParameter<
double>(
"Weight");
111 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm"
112 <<
"Uniform eta formula is empty! Resetting to 1.";
118 SetScanDet =
cfg.getParameter<std::vector<double>>(
"setScanDet");
119 col_cut =
cfg.getParameter<
double>(
"CLAngleCut");
120 cos_cut =
cfg.getParameter<
double>(
"CSAngleCut");
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();
215 std::vector<double> apeSPar = setiter->getParameter<std::vector<double>>(
"apeSPar");
216 std::vector<double> apeRPar = setiter->getParameter<std::vector<double>>(
"apeRPar");
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);
226 apeSPar.push_back(0);
228 apeSPar.push_back(1);
230 apeSPar.push_back(2);
233 <<
"APE function must be \"linear\", \"exponential\", or \"step\"." << std::endl;
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;
525 static const unsigned int hitDim = 1;
540 coor[0] =
hit->localPosition().
x();
543 covmat[0][0] =
hit->localPositionError().xx();
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;
645 coor[0] =
hit->localPosition().
x();
646 coor[1] =
hit->localPosition().
y();
649 covmat[0][0] =
hit->localPositionError().xx();
650 covmat[1][1] =
hit->localPositionError().yy();
651 covmat[0][1] =
hit->localPositionError().xy();
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) {
756 int nhit =
track->numberOfValidHits();
760 int nhpxb =
track->hitPattern().numberOfValidPixelBarrelHits();
761 int nhpxf =
track->hitPattern().numberOfValidPixelEndcapHits();
762 int nhtib =
track->hitPattern().numberOfValidStripTIBHits();
763 int nhtob =
track->hitPattern().numberOfValidStripTOBHits();
764 int nhtid =
track->hitPattern().numberOfValidStripTIDHits();
765 int nhtec =
track->hitPattern().numberOfValidStripTECHits();
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) {
830 int subDet =
hit->geographicalId().subdetId();
834 const std::type_info&
type =
typeid(*rechit);
837 const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(rechit);
841 myflag = (*
eventInfo.clusterValueMap())[stripclust];
844 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! "
848 const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(rechit);
852 myflag = (*
eventInfo.clusterValueMap())[stripclust];
855 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! "
864 myflag = (*
eventInfo.clusterValueMap())[pixelclust];
867 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! "
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) {
937 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>((*ihit)->hit());
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;
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;
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]));
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";
1458 uvar->
nhit = (uvarold->
nhit) + (uvarnew->nhit);
1459 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt * (uvarnew->jtvj);
1460 uvar->
jtve = (uvarold->
jtve) + peraliwgt * (uvarnew->jtve);
1461 uvar->
alichi2 = (uvarold->
alichi2) + peraliwgt * (uvarnew->alichi2);
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.";