2 #include <unordered_map>
46 theMonitorConfig(
cfg),
47 doTrackHitMonitoring(theMonitorConfig.fillTrackMonitoring || theMonitorConfig.fillTrackHitMonitoring),
48 defaultAlignableSpecs((
Alignable*)nullptr),
50 theTrackHitMonitorIORootFile(nullptr),
51 theTrackMonitorTree(nullptr),
52 theHitMonitorTree(nullptr),
53 theAlignablesMonitorIORootFile(nullptr),
54 theAlignablesMonitorTree(nullptr),
55 theSurveyIORootFile(nullptr),
56 theSurveyTree(nullptr) {
99 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm"
102 trackPs =
cfg.getParameter<
bool>(
"UsePreSelection");
104 trackWt =
cfg.getParameter<
bool>(
"UseReweighting");
105 Scale =
cfg.getParameter<
double>(
"Weight");
109 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm"
110 <<
"Uniform eta formula is empty! Resetting to 1.";
116 SetScanDet =
cfg.getParameter<std::vector<double>>(
"setScanDet");
117 col_cut =
cfg.getParameter<
double>(
"CLAngleCut");
118 cos_cut =
cfg.getParameter<
double>(
"CSAngleCut");
120 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm"
130 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize"
131 <<
"Initializing...";
143 bool findMatchIOV =
false;
144 for (
unsigned int iovl = 0; iovl <
theIOVrangeSet.size(); iovl++) {
147 iovapp.append(
".root");
148 iovapp.insert(0,
"_");
158 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize"
159 <<
"Found the IOV file matching IOV first run " <<
firstrun;
165 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize"
166 <<
"Didn't find the IOV file matching IOV first run " <<
firstrun
167 <<
" from the validity interval";
170 iovapp.append(
".root");
171 iovapp.insert(0,
"_");
179 if (extras !=
nullptr)
180 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize"
181 <<
"AlignableNavigator initialized with AlignableExtras";
196 for (std::vector<edm::ParameterSet>::const_iterator setiter =
theAPEParameterSet.begin();
211 std::vector<double> apeSPar = setiter->getParameter<std::vector<double>>(
"apeSPar");
212 std::vector<double> apeRPar = setiter->getParameter<std::vector<double>>(
"apeRPar");
215 if (apeSPar.size() != 3 || apeRPar.size() != 3)
216 throw cms::Exception(
"BadConfig") <<
"apeSPar and apeRPar must have 3 values each" << std::endl;
218 for (std::vector<double>::const_iterator
i = apeRPar.begin();
i != apeRPar.end(); ++
i)
219 apeSPar.push_back(*
i);
222 apeSPar.push_back(0);
224 apeSPar.push_back(1);
226 apeSPar.push_back(2);
229 <<
"APE function must be \"linear\", \"exponential\", or \"step\"." << std::endl;
253 double minRelParError = setiter->getParameter<
double>(
"minRelParError");
254 double maxRelParError = setiter->getParameter<
double>(
"maxRelParError");
255 int minNHits = setiter->getParameter<
int>(
"minNHits");
256 double maxHitPull = setiter->getParameter<
double>(
"maxHitPull");
257 bool applyPixelProbCut = setiter->getParameter<
bool>(
"applyPixelProbCut");
258 bool usePixelProbXYOrProbQ = setiter->getParameter<
bool>(
"usePixelProbXYOrProbQ");
259 double minPixelProbXY = setiter->getParameter<
double>(
"minPixelProbXY");
260 double maxPixelProbXY = setiter->getParameter<
double>(
"maxPixelProbXY");
261 double minPixelProbQ = setiter->getParameter<
double>(
"minPixelProbQ");
262 double maxPixelProbQ = setiter->getParameter<
double>(
"maxPixelProbQ");
263 for (
auto& ali : alignables) {
278 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize"
279 <<
"Alignment specifics acquired for detector " << alispecs.
id() <<
" / "
280 << alispecs.
objId() <<
":\n"
283 <<
" - minNHits = " << alispecs.
minNHits <<
"\n"
284 <<
" - maxHitPull = " << alispecs.
maxHitPull <<
"\n"
299 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
313 int numAlignablesFromFile = theAlignablePositionsFromFile.size();
314 if (numAlignablesFromFile == 0) {
320 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
321 <<
"IO alignables file not found for iteration " <<
theIteration;
323 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
324 <<
"Alignables Read " << numAlignablesFromFile;
334 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
335 <<
"Iteration increased by one and is now " <<
theIteration;
339 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
340 <<
"Apply positions from file ...";
344 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
357 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop"
367 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm] Using survey constraint";
371 for (
unsigned int i = 0;
i < nAlignable; ++
i) {
375 int nhit = uservar->
nhit;
379 int tmp_Type = tl.first;
380 int tmp_Layer = tl.second;
382 float tmpz =
pos.z();
384 (tmp_Type == 5 && tmp_Layer == 4 && fabs(tmpz) > 90)) {
402 uservar->
jtvj += invCov;
403 uservar->
jtve += invCov * sensResid;
428 <<
", step=" <<
SetScanDet.at(2) <<
", currentDet = " << ali->id();
436 if (dynamic_cast<AlignableDetUnit*>(ali) !=
nullptr) {
437 std::vector<std::pair<int, SurfaceDeformation*>> pairs;
438 ali->surfaceDeformationIdPairs(pairs);
439 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate"
440 <<
"The alignable contains " << pairs.size() <<
" surface deformations";
442 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate"
443 <<
"The alignable cannot contain surface deformations";
447 ali->alignmentParameters()->setValid(
true);
455 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::terminate] Aligned units: " << ialigned;
519 static const unsigned int hitDim = 1;
534 coor[0] =
hit->localPosition().
x();
537 covmat[0][0] =
hit->localPositionError().xx();
540 covmat = covmat + ipcovmat;
544 if (covmat[0][0] != 0.)
545 xpull = (
pos[0] - coor[0]) /
sqrt(fabs(covmat[0][0]));
554 int npar = derivs2D.num_row();
557 for (
int ipar = 0; ipar < npar; ipar++) {
558 for (
unsigned int idim = 0; idim < hitDim; idim++) {
559 derivs[ipar][idim] = derivs2D[ipar][idim];
567 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit1D"
568 <<
"Cov. matrix inversion failed!";
572 double maxHitPullThreshold =
574 bool useThisHit = (maxHitPullThreshold < 0.);
575 useThisHit |= (fabs(xpull) < maxHitPullThreshold);
577 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D"
578 <<
"Hit pull (x) " << xpull <<
" fails the cut " << maxHitPullThreshold;
586 thisjtvj.assign(jtvjtmp);
587 thisjtve = derivs * covmat * (
pos - coor);
590 hitresidual[0] = (
pos[0] - coor[0]);
593 hitresidualT = hitresidual.T();
595 uservar->
jtvj += hitwt * thisjtvj;
596 uservar->
jtve += hitwt * thisjtve;
601 thischi2 = hitwt * (hitresidualT * covmat * hitresidual)[0];
603 if (
verbose && (thischi2 / static_cast<float>(uservar->
nhit)) > 10.)
604 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit1D] Added to Chi2 the number " << thischi2
605 <<
" having " << uservar->
nhit <<
" ndof"
606 <<
", X-resid " << hitresidual[0] <<
", Cov^-1 matr (covmat):"
607 <<
" [0][0] = " << covmat[0][0];
621 static const unsigned int hitDim = 2;
639 coor[0] =
hit->localPosition().
x();
640 coor[1] =
hit->localPosition().
y();
643 covmat[0][0] =
hit->localPositionError().xx();
644 covmat[1][1] =
hit->localPositionError().yy();
645 covmat[0][1] =
hit->localPositionError().xy();
648 covmat = covmat + ipcovmat;
653 if (covmat[0][0] != 0.)
654 xpull = (
pos[0] - coor[0]) /
sqrt(fabs(covmat[0][0]));
655 if (covmat[1][1] != 0.)
656 ypull = (
pos[1] - coor[1]) /
sqrt(fabs(covmat[1][1]));
665 int npar = derivs2D.num_row();
668 for (
int ipar = 0; ipar < npar; ipar++) {
669 for (
unsigned int idim = 0; idim < hitDim; idim++) {
670 derivs[ipar][idim] = derivs2D[ipar][idim];
678 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D"
679 <<
"Cov. matrix inversion failed!";
683 double maxHitPullThreshold =
685 bool useThisHit = (maxHitPullThreshold < 0.);
686 useThisHit |= (fabs(xpull) < maxHitPullThreshold && fabs(ypull) < maxHitPullThreshold);
688 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D"
689 <<
"Hit pull (x,y) " << xpull <<
" , " << ypull <<
" fails the cut "
690 << maxHitPullThreshold;
698 thisjtvj.assign(jtvjtmp);
699 thisjtve = derivs * covmat * (
pos - coor);
702 hitresidual[0] = (
pos[0] - coor[0]);
703 hitresidual[1] = (
pos[1] - coor[1]);
706 hitresidualT = hitresidual.T();
708 uservar->
jtvj += hitwt * thisjtvj;
709 uservar->
jtve += hitwt * thisjtve;
714 thischi2 = hitwt * (hitresidualT * covmat * hitresidual)[0];
716 if (
verbose && (thischi2 / static_cast<float>(uservar->
nhit)) > 10.)
717 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit2D] Added to Chi2 the number " << thischi2
718 <<
" having " << uservar->
nhit <<
" ndof"
719 <<
", X-resid " << hitresidual[0] <<
", Y-resid " << hitresidual[1]
720 <<
", Cov^-1 matr (covmat):"
721 <<
" [0][0] = " << covmat[0][0] <<
" [0][1] = " << covmat[0][1]
722 <<
" [1][0] = " << covmat[1][0] <<
" [1][1] = " << covmat[1][1];
741 for (ConstTrajTrackPairCollection::const_iterator it =
tracks.begin(); it !=
tracks.end(); ++it) {
750 int nhit =
track->numberOfValidHits();
754 int nhpxb =
track->hitPattern().numberOfValidPixelBarrelHits();
755 int nhpxf =
track->hitPattern().numberOfValidPixelEndcapHits();
756 int nhtib =
track->hitPattern().numberOfValidStripTIBHits();
757 int nhtob =
track->hitPattern().numberOfValidStripTOBHits();
758 int nhtid =
track->hitPattern().numberOfValidStripTIDHits();
759 int nhtec =
track->hitPattern().numberOfValidStripTECHits();
774 double r = gRandom->Rndm();
799 std::vector<const TransientTrackingRecHit*> hitvec;
800 std::vector<TrajectoryStateOnSurface> tsosvec;
803 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
804 for (std::vector<TrajectoryMeasurement>::iterator im = measurements.begin(); im != measurements.end(); ++im) {
824 int subDet =
hit->geographicalId().subdetId();
828 const std::type_info&
type =
typeid(*rechit);
831 const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(rechit);
835 myflag = (*
eventInfo.clusterValueMap())[stripclust];
838 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! "
842 const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(rechit);
846 myflag = (*
eventInfo.clusterValueMap())[stripclust];
849 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! "
858 myflag = (*
eventInfo.clusterValueMap())[pixelclust];
861 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! "
872 hitvec.push_back(
hit);
873 tsosvec.push_back(tsos);
885 std::vector<TrajectoryStateOnSurface>::const_iterator itsos = tsosvec.begin();
886 std::vector<const TransientTrackingRecHit*>::const_iterator ihit = hitvec.begin();
889 while (itsos != tsosvec.end()) {
891 const GeomDet* det = (*ihit)->det();
893 uint32_t nhitDim = (*ihit)->dimension();
900 if (ali !=
nullptr) {
912 double angle = TMath::ASin(sin_theta);
913 double alihitwt = ihitwt;
930 if ((*ihit)->hit() !=
nullptr) {
931 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>((*ihit)->hit());
932 if (pixhit !=
nullptr) {
946 probXYQgood = (probXYgood || probQgood);
948 probXYQgood = (probXYgood && probQgood);
957 bool hitProcessed =
false;
960 hitProcessed =
processHit1D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
963 hitProcessed =
processHit2D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
967 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Number of hit dimensions = " << nhitDim
968 <<
" is not supported!" << std::endl;
991 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] ERROR! "
992 <<
"Unable to open Iteration file";
996 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] "
997 <<
"Read last iteration number from file: " <<
result;
1008 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] ERROR: Unable to write Iteration file";
1010 outIterFile << iter;
1011 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] writing iteration number to file: "
1014 outIterFile.close();
1022 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] No APE applied";
1026 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] Apply APE!";
1028 double apeSPar[3], apeRPar[3];
1030 const auto& alignables = alipars.first;
1031 const auto& pars = alipars.second;
1033 apeSPar[0] = pars[0];
1034 apeSPar[1] = pars[1];
1035 apeSPar[2] = pars[2];
1036 apeRPar[0] = pars[3];
1037 apeRPar[1] = pars[4];
1038 apeRPar[2] = pars[5];
1040 int function = pars[6];
1043 printf(
"APE: %u alignables\n", (
unsigned int)alignables.size());
1044 for (
int i = 0;
i < 21; ++
i) {
1045 double apelinstest =
calcAPE(apeSPar,
i, 0);
1046 double apeexpstest =
calcAPE(apeSPar,
i, 1);
1047 double apestepstest =
calcAPE(apeSPar,
i, 2);
1048 double apelinrtest =
calcAPE(apeRPar,
i, 0);
1049 double apeexprtest =
calcAPE(apeRPar,
i, 1);
1050 double apesteprtest =
calcAPE(apeRPar,
i, 2);
1051 printf(
"APE: iter slin sexp sstep rlin rexp rstep: %5d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f \n",
1071 double diter = (double)iter;
1073 return std::max(par[1], par[0] + ((par[1] - par[0]) / par[2]) * diter);
1074 else if (
function == 1)
1075 return std::max(0., par[0] * (
exp(-
pow(diter, par[1]) / par[2])));
1076 else if (
function == 2) {
1077 int ipar2 = (
int)par[2];
1078 int step = iter / ipar2;
1079 double dstep = (double)
step;
1080 return std::max(0., par[0] - par[1] * dstep);
1141 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Survey trees booked.";
1143 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Root trees booked.";
1176 m2_ObjId = ali->alignableObjectId();
1186 std::vector<std::pair<int, SurfaceDeformation*>> dali_id_pairs;
1189 std::vector<double> dali;
1190 if (1 == ali->surfaceDeformationIdPairs(dali_id_pairs)) {
1191 dali_obj = dali_id_pairs[0].second;
1195 for (
auto& dit : dali)
1203 edm::LogVerbatim(
"Alignment") <<
"------------------------------------------------------------------------\n"
1204 <<
" ALIGNABLE: " << setw(6) << naligned <<
'\n'
1205 <<
"hits: " << setw(4) <<
m2_Nhit <<
" type: " << setw(4) <<
m2_Type
1206 <<
" layer: " << setw(4) <<
m2_Layer <<
" id: " << setw(4) <<
m2_Id
1207 <<
" objId: " << setw(4) <<
m2_ObjId <<
'\n'
1210 <<
"\nDeformations type, nDeformations: " << setw(12) <<
m2_dtype << setw(12)
1212 <<
"params: " << setw(12) << pars[0] << setw(12) << pars[1] << setw(12) << pars[2]
1213 << setw(12) << pars[3] << setw(12) << pars[4] << setw(12) << pars[5];
1225 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1226 <<
"Begin: Processing detector " << ali->
id();
1233 int nhit = uservar->
nhit;
1241 minHitThreshold = 1;
1242 if (setDet == 0 && nhit < minHitThreshold) {
1243 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1244 <<
"Skipping detector " << ali->
id() <<
" because number of hits = " << nhit
1245 <<
" <= " << minHitThreshold;
1254 int npar = jtve.num_row();
1265 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1266 <<
"Matrix inversion failed!";
1269 params = -(jtvjinv * jtve);
1272 double minRelErrThreshold =
1274 double maxRelErrThreshold =
1276 for (
int i = 0;
i < npar;
i++) {
1278 if (fabs(cov[
i][
i]) > 0.)
1279 paramerr[
i] =
sqrt(fabs(cov[
i][
i]));
1283 relerr = fabs(paramerr[
i] /
params[
i]);
1284 if ((maxRelErrThreshold >= 0. && relerr > maxRelErrThreshold) || relerr < minRelErrThreshold) {
1285 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1286 <<
"RelError = " << relerr <<
" > " << maxRelErrThreshold <<
" or < "
1287 << minRelErrThreshold <<
". Setting param = paramerr = 0 for component " <<
i;
1293 if (
params.num_row() != 1) {
1294 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1295 <<
"For scanning, please only turn on one parameter! check common_cff_py.txt";
1302 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1303 <<
"Parameters = " <<
params;
1308 uservar->
alierr = paramerr;
1314 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters"
1315 <<
"End: Processing detector " << ali->
id();
1322 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1325 std::vector<std::string> monitorFileList;
1329 std::unordered_map<Alignable*, std::unordered_map<int, pawt_t>> ali_datatypecountpair_map;
1331 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1332 <<
"Per-alignable reweighting is turned on. Iterating over the parallel jobs to sum "
1333 "number of hits per alignable for each data type.";
1336 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1337 <<
"Pre-reading uservar for job " << ijob;
1342 std::vector<AlignmentUserVariables*> uvarvec =
1345 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1347 <<
" is not the same as number of user variables = " << uvarvec.size()
1348 <<
". A mismatch might occur!";
1350 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1351 <<
"Could not read user variable files for job " << ijob <<
" in iteration "
1355 std::vector<AlignmentUserVariables*>::const_iterator iuvar =
1361 if (uvar !=
nullptr) {
1363 pawt_t alijobnhits = uvar->
nhit;
1364 if (ali_datatypecountpair_map.find(ali) == ali_datatypecountpair_map.end()) {
1365 std::unordered_map<int, pawt_t> newmap;
1366 ali_datatypecountpair_map[ali] = newmap;
1367 ali_datatypecountpair_map[ali][alijobdtype] = alijobnhits;
1369 std::unordered_map<int, pawt_t>& theMap = ali_datatypecountpair_map[ali];
1370 if (theMap.find(alijobdtype) == theMap.end())
1371 theMap[alijobdtype] = alijobnhits;
1373 theMap[alijobdtype] += alijobnhits;
1383 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1384 <<
"Reading uservar for job " << ijob;
1389 std::vector<AlignmentUserVariables*> uvarvec =
1392 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1394 <<
" is not the same as number of user variables = " << uvarvec.size()
1395 <<
". A mismatch might occur!";
1398 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1399 <<
"Could not read user variable files for job " << ijob <<
" in iteration "
1405 std::vector<AlignmentUserVariables*> uvarvecadd;
1406 std::vector<AlignmentUserVariables*>::const_iterator iuvarnew = uvarvec.begin();
1417 if (uvarnew !=
nullptr) {
1418 double peraliwgt = 1;
1420 int alijobdtype = uvarnew->datatype;
1421 if (ali_datatypecountpair_map.find(ali) != ali_datatypecountpair_map.end() &&
1422 ali_datatypecountpair_map[ali].find(alijobdtype) != ali_datatypecountpair_map[ali].end()) {
1423 peraliwgt = ali_datatypecountpair_map[ali][alijobdtype];
1424 unsigned int nNonZeroTypes = 0;
1426 for (
auto it = ali_datatypecountpair_map[ali].cbegin(); it != ali_datatypecountpair_map[ali].cend(); ++it) {
1427 sumwgts += it->second;
1428 if (it->second != pawt_t(0))
1431 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1432 <<
"Reweighting detector " << ali->id() <<
" / " << ali->alignableObjectId()
1433 <<
" for data type " << alijobdtype <<
" by " << sumwgts <<
"/" << peraliwgt
1434 <<
"/" << nNonZeroTypes;
1435 peraliwgt = ((nNonZeroTypes == 0 || peraliwgt == double(0))
1437 : double((
double(sumwgts)) / peraliwgt / (
double(nNonZeroTypes))));
1438 }
else if (ali_datatypecountpair_map.find(ali) != ali_datatypecountpair_map.end())
1439 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1440 <<
"Could not find data type " << alijobdtype <<
" for detector " << ali->id()
1441 <<
" / " << ali->alignableObjectId();
1443 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector"
1444 <<
"Could not find detector " << ali->id() <<
" / " << ali->alignableObjectId()
1445 <<
" in the map ali_datatypecountpair_map";
1448 uvar->
nhit = (uvarold->
nhit) + (uvarnew->nhit);
1449 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt * (uvarnew->jtvj);
1450 uvar->
jtve = (uvarold->
jtve) + peraliwgt * (uvarnew->jtve);
1451 uvar->
alichi2 = (uvarold->
alichi2) + peraliwgt * (uvarnew->alichi2);
1457 uvarvecadd.push_back(uvar);
1466 monitorFileList.push_back(uvfile);
1480 throw cms::Exception(
"LogicError") <<
"[HIPAlignmentAlgorithm::collectMonitorTrees] Called in non-collector mode."
1483 TString theTrackMonitorTreeName = Form(
"T1_%i",
theIteration);
1484 TString theHitMonitorTreeName = Form(
"T1_hit_%i",
theIteration);
1486 std::vector<TFile*> finputlist;
1487 TList* eventtrees =
new TList;
1488 TList* hittrees =
new TList;
1490 TFile* finput = TFile::Open(
filename.c_str(),
"read");
1491 if (finput !=
nullptr) {
1495 tmptree = (TTree*)finput->Get(theTrackMonitorTreeName);
1496 if (tmptree !=
nullptr)
1497 eventtrees->Add(tmptree);
1501 tmptree = (TTree*)finput->Get(theHitMonitorTreeName);
1502 if (tmptree !=
nullptr)
1503 hittrees->Add((TTree*)finput->Get(theHitMonitorTreeName));
1505 finputlist.push_back(finput);
1510 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collectMonitorTrees"
1511 <<
"Monitor file is already open while it is not supposed to be!";
1520 if (eventtrees->GetSize() > 0)
1522 if (hittrees->GetSize() > 0)
1528 for (TFile*& finput : finputlist)
1540 if (ali !=
nullptr) {
1544 if (it->matchAlignable(ali))
1547 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::findAlignableSpecs] Alignment object with id " << ali->
id()
1548 <<
" / " << ali->
alignableObjectId() <<
" could not be found. Returning default.";