2 #include <unordered_map> 50 verbose(cfg.getParameter<bool>(
"verbosity")),
51 theMonitorConfig(cfg),
52 doTrackHitMonitoring(theMonitorConfig.fillTrackMonitoring || theMonitorConfig.fillTrackHitMonitoring),
54 surveyResiduals_(cfg.getUntrackedParameter<
std::vector<
std::
string> >(
"surveyResiduals")),
55 theTrackHitMonitorIORootFile(
nullptr),
58 theAlignablesMonitorIORootFile(
nullptr),
59 theAlignablesMonitorTree(
nullptr),
102 if (isCollector)
edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" <<
"Collector mode";
110 if (uniEtaFormula.empty()){
111 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" <<
"Uniform eta formula is empty! Resetting to 1.";
114 theEtaFormula = std::make_unique<TFormula>(uniEtaFormula.c_str());
121 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::HIPAlignmentAlgorithm" <<
"Constructed";
130 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" <<
"Initializing...";
142 unsigned int firstrun = first1.
eventID().
run();
145 bool findMatchIOV=
false;
146 for (
unsigned int iovl = 0; iovl <
theIOVrangeSet.size(); iovl++){
149 iovapp.append(
".root");
150 iovapp.insert(0,
"_");
160 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" <<
"Found the IOV file matching IOV first run " << firstrun;
165 if (!findMatchIOV)
edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" <<
"Didn't find the IOV file matching IOV first run " << firstrun <<
" from the validity interval";
169 iovapp.append(
".root");
170 iovapp.insert(0,
"_");
178 if (extras!=
nullptr)
edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::initialize" <<
"AlignableNavigator initialized with AlignableExtras";
194 std::vector<Alignable*> alignables;
205 std::vector<double> apeSPar = setiter->getParameter<std::vector<double> >(
"apeSPar");
206 std::vector<double> apeRPar = setiter->getParameter<std::vector<double> >(
"apeRPar");
207 std::string function = setiter->getParameter<std::string>(
"function");
209 if (apeSPar.size()!=3 || apeRPar.size()!=3)
211 <<
"apeSPar and apeRPar must have 3 values each" 214 for (std::vector<double>::const_iterator
i = apeRPar.begin();
i != apeRPar.end(); ++
i) apeSPar.push_back(*
i);
216 if (
function == std::string(
"linear")) apeSPar.push_back(0);
217 else if (
function == std::string(
"exponential")) apeSPar.push_back(1);
218 else if (
function == std::string(
"step")) apeSPar.push_back(2);
219 else throw cms::Exception(
"BadConfig") <<
"APE function must be \"linear\", \"exponential\", or \"step\"." << std::endl;
221 theAPEParameters.push_back(std::pair<std::vector<Alignable*>, std::vector<double> >(alignables, apeSPar));
229 std::vector<Alignable*> alignables;
240 double minRelParError = setiter->getParameter<
double>(
"minRelParError");
241 double maxRelParError = setiter->getParameter<
double>(
"maxRelParError");
242 int minNHits = setiter->getParameter<
int>(
"minNHits");
243 double maxHitPull = setiter->getParameter<
double>(
"maxHitPull");
244 bool applyPixelProbCut = setiter->getParameter<
bool>(
"applyPixelProbCut");
245 bool usePixelProbXYOrProbQ = setiter->getParameter<
bool>(
"usePixelProbXYOrProbQ");
246 double minPixelProbXY = setiter->getParameter<
double>(
"minPixelProbXY");
247 double maxPixelProbXY = setiter->getParameter<
double>(
"maxPixelProbXY");
248 double minPixelProbQ = setiter->getParameter<
double>(
"minPixelProbQ");
249 double maxPixelProbQ = setiter->getParameter<
double>(
"maxPixelProbQ");
250 for (
auto& ali : alignables){
266 <<
"@SUB=HIPAlignmentAlgorithm::initialize" 267 <<
"Alignment specifics acquired for detector " << alispecs.
id() <<
" / " << alispecs.
objId()
271 <<
" - minNHits = " << alispecs.
minNHits <<
"\n" 272 <<
" - maxHitPull = " << alispecs.
maxHitPull <<
"\n" 290 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"Begin";
302 int numAlignablesFromFile = theAlignablePositionsFromFile.size();
303 if (numAlignablesFromFile==0){
307 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"IO alignables file not found for iteration " <<
theIteration;
310 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"Alignables Read " << numAlignablesFromFile;
320 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"Iteration increased by one and is now " <<
theIteration;
324 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"Apply positions from file ...";
340 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::startNewLoop" <<
"End";
349 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm] Using survey constraint";
355 for (
unsigned int i = 0;
i < nAlignable; ++
i){
359 int nhit = uservar->
nhit;
363 int tmp_Type = tl.first;
364 int tmp_Layer = tl.second;
366 float tmpz = pos.
z();
367 if (nhit< 1500 || (tmp_Type==5 && tmp_Layer==4 && fabs(tmpz)>90)){
381 uservar->
jtvj += invCov;
382 uservar->
jtve += invCov * sensResid;
412 if (dynamic_cast<AlignableDetUnit*>(ali)!=
nullptr){
413 std::vector<std::pair<int, SurfaceDeformation*>> pairs;
415 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" <<
"The alignable contains " << pairs.size() <<
" surface deformations";
417 else edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" <<
"The alignable cannot contain surface deformations";
429 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::terminate] Aligned units: " << ialigned;
435 <<
"[HIPAlignmentAlgorithm] Writing aligned parameters to file: " <<
theAlignables.size()
494 static const unsigned int hitDim = 1;
513 covmat = covmat + ipcovmat;
517 if (covmat[0][0] != 0.) xpull = (pos[0] - coor[0])/
sqrt(fabs(covmat[0][0]));
526 int npar = derivs2D.num_row();
529 for (
int ipar=0; ipar<npar; ipar++){
530 for (
unsigned int idim=0; idim<hitDim; idim++){
531 derivs[ipar][idim] = derivs2D[ipar][idim];
539 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit1D" <<
"Cov. matrix inversion failed!";
544 bool useThisHit = (maxHitPullThreshold < 0.);
545 useThisHit |= (fabs(xpull) < maxHitPullThreshold);
547 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Hit pull (x) " << xpull <<
" fails the cut " << maxHitPullThreshold;
555 thisjtvj.assign(jtvjtmp);
556 thisjtve=derivs * covmat * (pos-coor);
559 hitresidual[0] = (pos[0] - coor[0]);
562 hitresidualT = hitresidual.T();
564 uservar->
jtvj += hitwt*thisjtvj;
565 uservar->
jtve += hitwt*thisjtve;
570 thischi2 = hitwt*(hitresidualT *covmat *hitresidual)[0];
572 if (
verbose && (thischi2/ static_cast<float>(uservar->
nhit))>10.)
573 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit1D] Added to Chi2 the number " << thischi2 <<
" having " 574 << uservar->
nhit <<
" ndof" 575 <<
", X-resid " << hitresidual[0]
576 <<
", Cov^-1 matr (covmat):" 577 <<
" [0][0] = " << covmat[0][0];
593 static const unsigned int hitDim = 2;
618 covmat = covmat + ipcovmat;
623 if (covmat[0][0] != 0.) xpull = (pos[0] - coor[0])/
sqrt(fabs(covmat[0][0]));
624 if (covmat[1][1] != 0.) ypull = (pos[1] - coor[1])/
sqrt(fabs(covmat[1][1]));
633 int npar = derivs2D.num_row();
636 for (
int ipar=0; ipar<npar; ipar++){
637 for (
unsigned int idim=0; idim<hitDim; idim++){
638 derivs[ipar][idim] = derivs2D[ipar][idim];
646 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Cov. matrix inversion failed!";
651 bool useThisHit = (maxHitPullThreshold < 0.);
652 useThisHit |= (fabs(xpull) < maxHitPullThreshold && fabs(ypull) < maxHitPullThreshold);
654 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Hit pull (x,y) " << xpull <<
" , " << ypull <<
" fails the cut " << maxHitPullThreshold;
662 thisjtvj.assign(jtvjtmp);
663 thisjtve=derivs * covmat * (pos-coor);
666 hitresidual[0] = (pos[0] - coor[0]);
667 hitresidual[1] = (pos[1] - coor[1]);
670 hitresidualT = hitresidual.T();
672 uservar->
jtvj += hitwt*thisjtvj;
673 uservar->
jtve += hitwt*thisjtve;
678 thischi2 = hitwt*(hitresidualT *covmat *hitresidual)[0];
680 if (
verbose && (thischi2/ static_cast<float>(uservar->
nhit))>10.)
681 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit2D] Added to Chi2 the number " << thischi2 <<
" having " 682 << uservar->
nhit <<
" ndof" 683 <<
", X-resid " << hitresidual[0]
684 <<
", Y-resid " << hitresidual[1]
685 <<
", Cov^-1 matr (covmat):" 686 <<
" [0][0] = " << covmat[0][0]
687 <<
" [0][1] = " << covmat[0][1]
688 <<
" [1][0] = " << covmat[1][0]
689 <<
" [1][1] = " << covmat[1][1];
713 for (ConstTrajTrackPairCollection::const_iterator it=tracks.begin(); it!=tracks.end(); ++it){
717 float pt = track->
pt();
720 float p = track->
p();
723 float d0 = track->
d0();
724 float dz = track->
dz();
734 <<
"New track pt,eta,phi,chi2n,hits: " 749 double r = gRandom->Rndm();
750 if (trkwt < r)
continue;
752 else if (
trackWt) ihitwt=trkwt;
759 m_Eta.push_back(eta);
760 m_Phi.push_back(phi);
770 m_wt.push_back(ihitwt);
774 std::vector<const TransientTrackingRecHit*> hitvec;
775 std::vector<TrajectoryStateOnSurface> tsosvec;
778 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
779 for (std::vector<TrajectoryMeasurement>::iterator im=measurements.begin(); im!=measurements.end(); ++im){
804 const std::type_info &
type =
typeid(*rechit);
815 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 816 <<
"TypeId of the RecHit: " <<
className(*hit);
827 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 828 <<
"TypeId of the TTRH: " <<
className(*hit);
839 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! " 840 <<
"TypeId of the TTRH: " <<
className(*hit);
842 if (!myflag.
isTaken())
continue;
852 hitvec.push_back(hit);
853 tsosvec.push_back(tsos);
865 std::vector<TrajectoryStateOnSurface>::const_iterator itsos=tsosvec.begin();
866 std::vector<const TransientTrackingRecHit*>::const_iterator ihit=hitvec.begin();
869 while (itsos != tsosvec.end()){
871 const GeomDet* det = (*ihit)->det();
873 uint32_t nhitDim = (*ihit)->dimension();
892 double angle = TMath::ASin(sin_theta);
896 else{
if (angle<
cos_cut)ihitwt=0; }
906 if ((*ihit)->hit()!=
nullptr){
908 if (pixhit!=
nullptr){
920 else probXYQgood = (probXYgood && probQgood);
921 if (!probXYQgood) ihitwt=0;
929 bool hitProcessed=
false;
932 hitProcessed=
processHit1D(alidet, ali, alispecifics, tsos, *ihit, ihitwt);
935 hitProcessed=
processHit2D(alidet, ali, alispecifics, tsos, *ihit, ihitwt);
939 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Number of hit dimensions = " 940 << nhitDim <<
" is not supported!" 961 std::ifstream inIterFile(filename.c_str(),
std::ios::in);
963 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] ERROR! " 964 <<
"Unable to open Iteration file";
969 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] " 970 <<
"Read last iteration number from file: " <<
result;
979 std::ofstream outIterFile((filename.c_str()),
std::ios::out);
981 <<
"[HIPAlignmentAlgorithm::writeIterationFile] ERROR: Unable to write Iteration file";
984 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] writing iteration number to file: " << iter;
994 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] No APE applied";
998 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] Apply APE!";
1000 double apeSPar[3], apeRPar[3];
1001 for (std::vector<std::pair<std::vector<Alignable*>, std::vector<double> > >::const_iterator alipars =
theAPEParameters.begin(); alipars !=
theAPEParameters.end(); ++alipars) {
1002 const std::vector<Alignable*> &alignables = alipars->first;
1003 const std::vector<double> &pars = alipars->second;
1005 apeSPar[0] = pars[0];
1006 apeSPar[1] = pars[1];
1007 apeSPar[2] = pars[2];
1008 apeRPar[0] = pars[3];
1009 apeRPar[1] = pars[4];
1010 apeRPar[2] = pars[5];
1012 int function = pars[6];
1015 printf(
"APE: %u alignables\n", (
unsigned int)alignables.size());
1016 for (
int i=0;
i<21; ++
i) {
1017 double apelinstest=
calcAPE(apeSPar,
i, 0);
1018 double apeexpstest=
calcAPE(apeSPar,
i, 1);
1019 double apestepstest=
calcAPE(apeSPar,
i, 2);
1020 double apelinrtest=
calcAPE(apeRPar,
i, 0);
1021 double apeexprtest=
calcAPE(apeRPar,
i, 1);
1022 double apesteprtest=
calcAPE(apeRPar,
i, 2);
1023 printf(
"APE: iter slin sexp sstep rlin rexp rstep: %5d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f \n",
1024 i, apelinstest, apeexpstest, apestepstest, apelinrtest, apeexprtest, apesteprtest);
1037 double diter=(double)iter;
1038 if (
function == 0)
return std::max(par[1], par[0]+((par[1]-par[0])/par[2])*diter);
1039 else if (
function == 1)
return std::max(0., par[0]*(
exp(-
pow(diter, par[1])/par[2])));
1040 else if (
function == 2){
1041 int ipar2 = (
int)par[2];
1042 int step = iter/ipar2;
1043 double dstep = (double)step;
1044 return std::max(0., par[0] - par[1]*dstep);
1125 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Survey trees booked.";
1127 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Root trees booked.";
1174 std::vector<std::pair<int, SurfaceDeformation*> > dali_id_pairs;
1177 std::vector<double> dali;
1179 dali_obj = dali_id_pairs[0].second;
1183 for (
auto& dit : dali)
m2_surfDef.push_back((
float)dit);
1191 <<
"------------------------------------------------------------------------\n" 1192 <<
" ALIGNABLE: " << setw(6) << naligned
1194 <<
"hits: " << setw(4) <<
m2_Nhit 1195 <<
" type: " << setw(4) <<
m2_Type 1196 <<
" layer: " << setw(4) <<
m2_Layer 1197 <<
" id: " << setw(4) <<
m2_Id 1198 <<
" objId: " << setw(4) <<
m2_ObjId 1205 <<
"\nDeformations type, nDeformations: " 1210 << setw(12) << pars[0]
1211 << setw(12) << pars[1]
1212 << setw(12) << pars[2]
1213 << setw(12) << pars[3]
1214 << setw(12) << pars[4]
1215 << setw(12) << pars[5];
1226 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Begin: Processing detector " << ali->
id();
1233 int nhit = uservar->
nhit;
1241 if (setDet==0 && nhit<minHitThreshold){
1242 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Skipping detector " << ali->
id() <<
" because number of hits = " << nhit <<
" <= " << minHitThreshold;
1251 int npar = jtve.num_row();
1262 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Matrix inversion failed!";
1265 params = -(jtvjinv * jtve);
1270 for (
int i=0;
i<npar;
i++){
1272 if (fabs(cov[
i][
i])>0.) paramerr[
i] =
sqrt(fabs(cov[i][i]));
1273 else paramerr[
i] = params[
i];
1274 if (params[i]!=0.) relerr = fabs(paramerr[i]/params[i]);
1275 if ((maxRelErrThreshold>=0. && relerr>maxRelErrThreshold) || relerr<minRelErrThreshold){
1277 <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"RelError = " << relerr
1278 <<
" > " << maxRelErrThreshold <<
" or < " << minRelErrThreshold
1279 <<
". Setting param = paramerr = 0 for component " <<
i;
1286 if (params.num_row()!=1){
1287 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"For scanning, please only turn on one parameter! check common_cff_py.txt";
1291 else params[0]=
step;
1292 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Parameters = " << params;
1297 uservar->
alierr=paramerr;
1303 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"End: Processing detector " << ali->
id();
1312 std::vector<std::string> monitorFileList;
1316 std::unordered_map<Alignable*, std::unordered_map<int, pawt_t> > ali_datatypecountpair_map;
1318 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Per-alignable reweighting is turned on. Iterating over the parallel jobs to sum number of hits per alignable for each data type.";
1321 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Pre-reading uservar for job " << ijob;
1328 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1329 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1330 <<
". A mismatch might occur!";
1332 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1335 std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
1343 pawt_t alijobnhits = uvar->
nhit;
1344 if (ali_datatypecountpair_map.find(ali)==ali_datatypecountpair_map.end()){
1345 std::unordered_map<int, pawt_t> newmap;
1346 ali_datatypecountpair_map[ali] = newmap;
1347 ali_datatypecountpair_map[ali][alijobdtype] = alijobnhits;
1350 std::unordered_map<int, pawt_t>& theMap = ali_datatypecountpair_map[ali];
1351 if (theMap.find(alijobdtype)==theMap.end()) theMap[alijobdtype]=alijobnhits;
1352 else theMap[alijobdtype] += alijobnhits;
1362 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Reading uservar for job " << ijob;
1369 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1370 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1371 <<
". A mismatch might occur!";
1374 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1379 std::vector<AlignmentUserVariables*> uvarvecadd;
1380 std::vector<AlignmentUserVariables*>::const_iterator iuvarnew=uvarvec.begin();
1391 if (uvarnew!=
nullptr){
1394 int alijobdtype = uvarnew->
datatype;
1396 ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end()
1398 ali_datatypecountpair_map[ali].find(alijobdtype)!=ali_datatypecountpair_map[ali].end()
1400 peraliwgt = ali_datatypecountpair_map[ali][alijobdtype];
1401 unsigned int nNonZeroTypes=0;
1403 for (
auto it=ali_datatypecountpair_map[ali].cbegin(); it!=ali_datatypecountpair_map[ali].cend(); ++it){
1404 sumwgts+=it->second;
1405 if (it->second!=pawt_t(0)) nNonZeroTypes++;
1407 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1409 <<
" for data type " << alijobdtype <<
" by " << sumwgts <<
"/" << peraliwgt <<
"/" << nNonZeroTypes;
1410 peraliwgt=((nNonZeroTypes==0 || peraliwgt==double(0)) ?
double(1) : double((
double(sumwgts))/peraliwgt/(
double(nNonZeroTypes))));
1412 else if (ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end())
1413 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1414 <<
"Could not find data type " << alijobdtype <<
" for detector " << ali->
id() <<
" / " << ali->
alignableObjectId();
1416 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1418 <<
" in the map ali_datatypecountpair_map";
1422 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt*(uvarnew->
jtvj);
1423 uvar->
jtve = (uvarold->
jtve) + peraliwgt*(uvarnew->
jtve);
1430 uvarvecadd.push_back(uvar);
1439 monitorFileList.push_back(uvfile);
1452 <<
"[HIPAlignmentAlgorithm::collectMonitorTrees] Called in non-collector mode." 1455 TString theTrackMonitorTreeName=Form(
"T1_%i",
theIteration);
1456 TString theHitMonitorTreeName=Form(
"T1_hit_%i",
theIteration);
1458 std::vector<TFile*> finputlist;
1459 TList* eventtrees =
new TList;
1460 TList* hittrees =
new TList;
1462 TFile* finput = TFile::Open(
filename.c_str(),
"read");
1463 if (finput!=
nullptr){
1467 tmptree = (TTree*)finput->Get(theTrackMonitorTreeName);
1468 if (tmptree!=
nullptr) eventtrees->Add(tmptree);
1472 tmptree = (TTree*)finput->Get(theHitMonitorTreeName);
1473 if (tmptree!=
nullptr) hittrees->Add((TTree*)finput->Get(theHitMonitorTreeName));
1475 finputlist.push_back(finput);
1480 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collectMonitorTrees" 1481 <<
"Monitor file is already open while it is not supposed to be!";
1494 for (TFile*& finput : finputlist) finput->Close();
1505 if (it->matchAlignable(ali))
return &(*it);
1507 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::findAlignableSpecs] Alignment object with id " << ali->
id() <<
" / " << 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
std::vector< float > m_Phi
bool hasFilledProb() const
std::vector< HIPAlignableSpecificParameters > theAlignableSpecifics
HIPAlignableSpecificParameters defaultAlignableSpecs
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const =0
ConstRecHitPointer const & recHit() const
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
AlignmentParameterStore * theAlignmentParameterStore
std::pair< int, int > typeAndLayer(const Alignable *ali, const TrackerTopology *tTopo) const
Obtain type and layer from Alignable.
const EventID & eventID() const
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
void setAlignmentPositionError(const align::Alignables &alivec, double valshift, double valrot)
Set Alignment position error.
LocalVector localDirection() const
LocalPoint localPosition() const
std::vector< int > m_nhTEC
HIPAlignableSpecificParameters * findAlignableSpecs(const Alignable *ali)
static char const * tname
std::vector< int > m_nhTIB
align::StructureType m2_ObjId
std::vector< float > m_wt
def setup(process, global_tag, zero_tesla=False)
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.
HIPUserVariables * clone(void) const
void applyAlignableAbsolutePositions(const align::Alignables &alis, const AlignablePositions &newpos, int &ierr)
apply absolute positions to alignables
std::vector< float > m_Eta
LocalError positionError() const
int numberOfValidStripTOBHits() const
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
std::unique_ptr< AlignableNavigator > theAlignableDetAccessor
const ConstTrajTrackPairCollection & trajTrackPairs() const
unsigned int m_rawQualityWord
define event information passed to algorithms
std::vector< unsigned > theIOVrangeSet
void writeHIPUserVariables(const Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
std::vector< float > m_d0
bool calcParameters(Alignable *ali, int setDet, double start, double step)
std::vector< float > m_Pt
const bool fillTrackHitMonitoring
std::vector< std::pair< std::vector< Alignable * >, std::vector< double > > > theAPEParameters
const AlgebraicVector & parameters(void) const
Get alignment parameters.
std::vector< int > m_Nhits
DataContainer const & measurements() const
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
AlignablePositions readAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, int &ierr)
read Alignable current absolute positions
void clear()
remove all selected Alignables and geometrical restrictions
double eta() const
pseudorapidity of momentum vector
void startNewLoop(void)
Called at start of new loop.
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)
std::vector< float > m_Chi2n
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.
TTree * theHitMonitorTree
double pt() const
track transverse momentum
std::vector< float > m_dz
std::vector< int > m_nhTID
void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store)
Call at beginning of job.
std::string siterationfile
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const bool fillTrackMonitoring
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 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.
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_
std::string smisalignedfile
int numberOfValidStripTIBHits() const
std::vector< edm::ParameterSet > theAPEParameterSet
align::StructureType m3_ObjId
std::unique_ptr< TFormula > theEtaFormula
int numberOfValidPixelEndcapHits() const
std::vector< int > m_nhPXF
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
unsigned int addSelections(const edm::ParameterSet &pSet)
const std::vector< std::string > surveyResiduals_
std::vector< AlignableAbsData > AlignablePositions
void writeAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write Alignable current absolute positions
bool processHit2D(const AlignableDetOrUnitPtr &alidet, const Alignable *ali, const HIPAlignableSpecificParameters *alispecifics, const TrajectoryStateOnSurface &tsos, const TrackingRecHit *hit, double hitwt)
eventInfo
add run, event number and lumi section
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
virtual LocalError localPositionError() const =0
std::vector< int > m_nhTOB
TTree * theAlignablesMonitorTree
Constructor of the full muon geometry.
std::vector< int > m_nhPXB
const PositionType & position() const
T const * product() const
std::vector< align::StructureType > theLevels
SiPixelRecHitQuality::QualWordType rawQualityWord() const
float probabilityQ() const
std::vector< Alignable * > theAlignables
Power< A, B >::type pow(const A &a, const B &b)
const align::Alignables & alignables(void) const
get all alignables
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
std::string className(const T &t)
const bool doTrackHitMonitoring
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
std::string theCollectorPath
void run(const edm::EventSetup &setup, const EventInfo &eventInfo)
Run the algorithm.
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::string sparameterfile