2 #include <unordered_map> 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";
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;
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;
411 if (dynamic_cast<AlignableDetUnit*>(ali)!=
nullptr){
412 std::vector<std::pair<int, SurfaceDeformation*>> pairs;
413 ali->surfaceDeformationIdPairs(pairs);
414 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" <<
"The alignable contains " << pairs.size() <<
" surface deformations";
416 else edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::terminate" <<
"The alignable cannot contain surface deformations";
420 ali->alignmentParameters()->setValid(
true);
428 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::terminate] Aligned units: " << ialigned;
434 <<
"[HIPAlignmentAlgorithm] Writing aligned parameters to file: " << theAlignables.size()
493 static const unsigned int hitDim = 1;
494 if (hitwt==0.)
return false;
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;
594 if (hitwt==0.)
return false;
619 covmat = covmat + ipcovmat;
624 if (covmat[0][0] != 0.) xpull = (pos[0] - coor[0])/
sqrt(fabs(covmat[0][0]));
625 if (covmat[1][1] != 0.) ypull = (pos[1] - coor[1])/
sqrt(fabs(covmat[1][1]));
634 int npar = derivs2D.num_row();
637 for (
int ipar=0; ipar<npar; ipar++){
638 for (
unsigned int idim=0; idim<hitDim; idim++){
639 derivs[ipar][idim] = derivs2D[ipar][idim];
647 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Cov. matrix inversion failed!";
652 bool useThisHit = (maxHitPullThreshold < 0.);
653 useThisHit |= (fabs(xpull) < maxHitPullThreshold && fabs(ypull) < maxHitPullThreshold);
655 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Hit pull (x,y) " << xpull <<
" , " << ypull <<
" fails the cut " << maxHitPullThreshold;
663 thisjtvj.assign(jtvjtmp);
664 thisjtve=derivs * covmat * (pos-coor);
667 hitresidual[0] = (pos[0] - coor[0]);
668 hitresidual[1] = (pos[1] - coor[1]);
671 hitresidualT = hitresidual.T();
673 uservar->
jtvj += hitwt*thisjtvj;
674 uservar->
jtve += hitwt*thisjtve;
679 thischi2 = hitwt*(hitresidualT *covmat *hitresidual)[0];
681 if (
verbose && (thischi2/ static_cast<float>(uservar->
nhit))>10.)
682 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit2D] Added to Chi2 the number " << thischi2 <<
" having " 683 << uservar->
nhit <<
" ndof" 684 <<
", X-resid " << hitresidual[0]
685 <<
", Y-resid " << hitresidual[1]
686 <<
", Cov^-1 matr (covmat):" 687 <<
" [0][0] = " << covmat[0][0]
688 <<
" [0][1] = " << covmat[0][1]
689 <<
" [1][0] = " << covmat[1][0]
690 <<
" [1][1] = " << covmat[1][1];
708 for (ConstTrajTrackPairCollection::const_iterator it=tracks.begin(); it!=tracks.end(); ++it){
712 float pt = track->
pt();
715 float p = track->
p();
718 float d0 = track->
d0();
719 float dz = track->
dz();
729 <<
"New track pt,eta,phi,chi2n,hits: " 744 double r = gRandom->Rndm();
745 if (trkwt < r)
continue;
747 else if (
trackWt) ihitwt=trkwt;
768 std::vector<const TransientTrackingRecHit*> hitvec;
769 std::vector<TrajectoryStateOnSurface> tsosvec;
772 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
773 for (std::vector<TrajectoryMeasurement>::iterator im=measurements.begin(); im!=measurements.end(); ++im){
798 const std::type_info &
type =
typeid(*rechit);
809 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 810 <<
"TypeId of the RecHit: " <<
className(*hit);
821 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 822 <<
"TypeId of the TTRH: " <<
className(*hit);
833 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! " 834 <<
"TypeId of the TTRH: " <<
className(*hit);
836 if (!myflag.
isTaken())
continue;
846 hitvec.push_back(hit);
847 tsosvec.push_back(tsos);
859 std::vector<TrajectoryStateOnSurface>::const_iterator itsos=tsosvec.begin();
860 std::vector<const TransientTrackingRecHit*>::const_iterator ihit=hitvec.begin();
863 while (itsos != tsosvec.end()){
865 const GeomDet* det = (*ihit)->det();
867 uint32_t nhitDim = (*ihit)->dimension();
886 double angle = TMath::ASin(sin_theta);
887 double alihitwt=ihitwt;
891 else{
if (angle<
cos_cut)alihitwt=0; }
899 if ((*ihit)->hit()!=
nullptr){
901 if (pixhit!=
nullptr){
913 else probXYQgood = (probXYgood && probQgood);
914 if (!probXYQgood) alihitwt=0;
921 bool hitProcessed=
false;
924 hitProcessed=
processHit1D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
927 hitProcessed=
processHit2D(alidet, ali, alispecifics, tsos, *ihit, alihitwt);
931 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Number of hit dimensions = " 932 << nhitDim <<
" is not supported!" 952 std::ifstream inIterFile(filename.c_str(),
std::ios::in);
954 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] ERROR! " 955 <<
"Unable to open Iteration file";
960 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] " 961 <<
"Read last iteration number from file: " <<
result;
970 std::ofstream outIterFile((filename.c_str()),
std::ios::out);
972 <<
"[HIPAlignmentAlgorithm::writeIterationFile] ERROR: Unable to write Iteration file";
975 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] writing iteration number to file: " << iter;
985 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] No APE applied";
989 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] Apply APE!";
991 double apeSPar[3], apeRPar[3];
993 const auto& alignables = alipars.first;
994 const auto& pars = alipars.second;
996 apeSPar[0] = pars[0];
997 apeSPar[1] = pars[1];
998 apeSPar[2] = pars[2];
999 apeRPar[0] = pars[3];
1000 apeRPar[1] = pars[4];
1001 apeRPar[2] = pars[5];
1003 int function = pars[6];
1006 printf(
"APE: %u alignables\n", (
unsigned int)alignables.size());
1007 for (
int i=0;
i<21; ++
i) {
1008 double apelinstest=
calcAPE(apeSPar,
i, 0);
1009 double apeexpstest=
calcAPE(apeSPar,
i, 1);
1010 double apestepstest=
calcAPE(apeSPar,
i, 2);
1011 double apelinrtest=
calcAPE(apeRPar,
i, 0);
1012 double apeexprtest=
calcAPE(apeRPar,
i, 1);
1013 double apesteprtest=
calcAPE(apeRPar,
i, 2);
1014 printf(
"APE: iter slin sexp sstep rlin rexp rstep: %5d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f \n",
1015 i, apelinstest, apeexpstest, apestepstest, apelinrtest, apeexprtest, apesteprtest);
1028 double diter=(double)iter;
1029 if (
function == 0)
return std::max(par[1], par[0]+((par[1]-par[0])/par[2])*diter);
1030 else if (
function == 1)
return std::max(0., par[0]*(
exp(-
pow(diter, par[1])/par[2])));
1031 else if (
function == 2){
1032 int ipar2 = (
int)par[2];
1033 int step = iter/ipar2;
1034 double dstep = (double)step;
1035 return std::max(0., par[0] - par[1]*dstep);
1096 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Survey trees booked.";
1098 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Root trees booked.";
1134 m2_ObjId = ali->alignableObjectId();
1144 std::vector<std::pair<int, SurfaceDeformation*> > dali_id_pairs;
1147 std::vector<double> dali;
1148 if (1 == ali->surfaceDeformationIdPairs(dali_id_pairs)){
1149 dali_obj = dali_id_pairs[0].second;
1153 for (
auto& dit : dali)
m2_surfDef.push_back((
float)dit);
1161 <<
"------------------------------------------------------------------------\n" 1162 <<
" ALIGNABLE: " << setw(6) << naligned
1164 <<
"hits: " << setw(4) <<
m2_Nhit 1165 <<
" type: " << setw(4) <<
m2_Type 1166 <<
" layer: " << setw(4) <<
m2_Layer 1167 <<
" id: " << setw(4) <<
m2_Id 1168 <<
" objId: " << setw(4) <<
m2_ObjId 1175 <<
"\nDeformations type, nDeformations: " 1180 << setw(12) << pars[0]
1181 << setw(12) << pars[1]
1182 << setw(12) << pars[2]
1183 << setw(12) << pars[3]
1184 << setw(12) << pars[4]
1185 << setw(12) << pars[5];
1196 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Begin: Processing detector " << ali->
id();
1203 int nhit = uservar->
nhit;
1211 if (setDet==0 && nhit<minHitThreshold){
1212 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Skipping detector " << ali->
id() <<
" because number of hits = " << nhit <<
" <= " << minHitThreshold;
1221 int npar = jtve.num_row();
1232 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Matrix inversion failed!";
1235 params = -(jtvjinv * jtve);
1240 for (
int i=0;
i<npar;
i++){
1242 if (fabs(cov[
i][
i])>0.) paramerr[
i] =
sqrt(fabs(cov[i][i]));
1243 else paramerr[
i] = params[
i];
1244 if (params[i]!=0.) relerr = fabs(paramerr[i]/params[i]);
1245 if ((maxRelErrThreshold>=0. && relerr>maxRelErrThreshold) || relerr<minRelErrThreshold){
1247 <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"RelError = " << relerr
1248 <<
" > " << maxRelErrThreshold <<
" or < " << minRelErrThreshold
1249 <<
". Setting param = paramerr = 0 for component " <<
i;
1256 if (params.num_row()!=1){
1257 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"For scanning, please only turn on one parameter! check common_cff_py.txt";
1261 else params[0]=
step;
1262 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Parameters = " << params;
1267 uservar->
alierr=paramerr;
1273 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"End: Processing detector " << ali->
id();
1282 std::vector<std::string> monitorFileList;
1286 std::unordered_map<Alignable*, std::unordered_map<int, pawt_t> > ali_datatypecountpair_map;
1288 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.";
1291 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Pre-reading uservar for job " << ijob;
1298 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1299 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1300 <<
". A mismatch might occur!";
1302 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1305 std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
1312 pawt_t alijobnhits = uvar->
nhit;
1313 if (ali_datatypecountpair_map.find(ali)==ali_datatypecountpair_map.end()){
1314 std::unordered_map<int, pawt_t> newmap;
1315 ali_datatypecountpair_map[ali] = newmap;
1316 ali_datatypecountpair_map[ali][alijobdtype] = alijobnhits;
1319 std::unordered_map<int, pawt_t>& theMap = ali_datatypecountpair_map[ali];
1320 if (theMap.find(alijobdtype)==theMap.end()) theMap[alijobdtype]=alijobnhits;
1321 else theMap[alijobdtype] += alijobnhits;
1331 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Reading uservar for job " << ijob;
1338 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1339 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1340 <<
". A mismatch might occur!";
1343 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1348 std::vector<AlignmentUserVariables*> uvarvecadd;
1349 std::vector<AlignmentUserVariables*>::const_iterator iuvarnew=uvarvec.begin();
1359 if (uvarnew!=
nullptr){
1362 int alijobdtype = uvarnew->
datatype;
1364 ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end()
1366 ali_datatypecountpair_map[ali].find(alijobdtype)!=ali_datatypecountpair_map[ali].end()
1368 peraliwgt = ali_datatypecountpair_map[ali][alijobdtype];
1369 unsigned int nNonZeroTypes=0;
1371 for (
auto it=ali_datatypecountpair_map[ali].cbegin(); it!=ali_datatypecountpair_map[ali].cend(); ++it){
1372 sumwgts+=it->second;
1373 if (it->second!=pawt_t(0)) nNonZeroTypes++;
1375 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1376 <<
"Reweighting detector " << ali->id() <<
" / " << ali->alignableObjectId()
1377 <<
" for data type " << alijobdtype <<
" by " << sumwgts <<
"/" << peraliwgt <<
"/" << nNonZeroTypes;
1378 peraliwgt=((nNonZeroTypes==0 || peraliwgt==double(0)) ?
double(1) : double((
double(sumwgts))/peraliwgt/(
double(nNonZeroTypes))));
1380 else if (ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end())
1381 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1382 <<
"Could not find data type " << alijobdtype <<
" for detector " << ali->id() <<
" / " << ali->alignableObjectId();
1384 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1385 <<
"Could not find detector " << ali->id() <<
" / " << ali->alignableObjectId()
1386 <<
" in the map ali_datatypecountpair_map";
1390 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt*(uvarnew->
jtvj);
1391 uvar->
jtve = (uvarold->
jtve) + peraliwgt*(uvarnew->
jtve);
1398 uvarvecadd.push_back(uvar);
1407 monitorFileList.push_back(uvfile);
1420 <<
"[HIPAlignmentAlgorithm::collectMonitorTrees] Called in non-collector mode." 1423 TString theTrackMonitorTreeName=Form(
"T1_%i",
theIteration);
1424 TString theHitMonitorTreeName=Form(
"T1_hit_%i",
theIteration);
1426 std::vector<TFile*> finputlist;
1427 TList* eventtrees =
new TList;
1428 TList* hittrees =
new TList;
1430 TFile* finput = TFile::Open(
filename.c_str(),
"read");
1431 if (finput!=
nullptr){
1435 tmptree = (TTree*)finput->Get(theTrackMonitorTreeName);
1436 if (tmptree!=
nullptr) eventtrees->Add(tmptree);
1440 tmptree = (TTree*)finput->Get(theHitMonitorTreeName);
1441 if (tmptree!=
nullptr) hittrees->Add((TTree*)finput->Get(theHitMonitorTreeName));
1443 finputlist.push_back(finput);
1448 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collectMonitorTrees" 1449 <<
"Monitor file is already open while it is not supposed to be!";
1462 for (TFile*& finput : finputlist) finput->Close();
1473 if (it->matchAlignable(ali))
return &(*it);
1475 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
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
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.
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.
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
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
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
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::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
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