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;
512 covmat = covmat + ipcovmat;
516 if (covmat[0][0] != 0.) xpull = (pos[0] - coor[0])/
sqrt(fabs(covmat[0][0]));
525 int npar = derivs2D.num_row();
528 for (
int ipar=0; ipar<npar; ipar++){
529 for (
unsigned int idim=0; idim<hitDim; idim++){
530 derivs[ipar][idim] = derivs2D[ipar][idim];
538 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit1D" <<
"Cov. matrix inversion failed!";
543 bool useThisHit = (maxHitPullThreshold < 0.);
544 useThisHit |= (fabs(xpull) < maxHitPullThreshold);
546 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Hit pull (x) " << xpull <<
" fails the cut " << maxHitPullThreshold;
554 thisjtvj.assign(jtvjtmp);
555 thisjtve=derivs * covmat * (pos-coor);
558 hitresidual[0] = (pos[0] - coor[0]);
561 hitresidualT = hitresidual.T();
563 uservar->
jtvj += hitwt*thisjtvj;
564 uservar->
jtve += hitwt*thisjtve;
569 thischi2 = hitwt*(hitresidualT *covmat *hitresidual)[0];
571 if (
verbose && (thischi2/ static_cast<float>(uservar->
nhit))>10.)
572 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit1D] Added to Chi2 the number " << thischi2 <<
" having " 573 << uservar->
nhit <<
" ndof" 574 <<
", X-resid " << hitresidual[0]
575 <<
", Cov^-1 matr (covmat):" 576 <<
" [0][0] = " << covmat[0][0];
592 static const unsigned int hitDim = 2;
617 covmat = covmat + ipcovmat;
622 if (covmat[0][0] != 0.) xpull = (pos[0] - coor[0])/
sqrt(fabs(covmat[0][0]));
623 if (covmat[1][1] != 0.) ypull = (pos[1] - coor[1])/
sqrt(fabs(covmat[1][1]));
632 int npar = derivs2D.num_row();
635 for (
int ipar=0; ipar<npar; ipar++){
636 for (
unsigned int idim=0; idim<hitDim; idim++){
637 derivs[ipar][idim] = derivs2D[ipar][idim];
645 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Cov. matrix inversion failed!";
650 bool useThisHit = (maxHitPullThreshold < 0.);
651 useThisHit |= (fabs(xpull) < maxHitPullThreshold && fabs(ypull) < maxHitPullThreshold);
653 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::processHit2D" <<
"Hit pull (x,y) " << xpull <<
" , " << ypull <<
" fails the cut " << maxHitPullThreshold;
661 thisjtvj.assign(jtvjtmp);
662 thisjtve=derivs * covmat * (pos-coor);
665 hitresidual[0] = (pos[0] - coor[0]);
666 hitresidual[1] = (pos[1] - coor[1]);
669 hitresidualT = hitresidual.T();
671 uservar->
jtvj += hitwt*thisjtvj;
672 uservar->
jtve += hitwt*thisjtve;
677 thischi2 = hitwt*(hitresidualT *covmat *hitresidual)[0];
679 if (
verbose && (thischi2/ static_cast<float>(uservar->
nhit))>10.)
680 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::processHit2D] Added to Chi2 the number " << thischi2 <<
" having " 681 << uservar->
nhit <<
" ndof" 682 <<
", X-resid " << hitresidual[0]
683 <<
", Y-resid " << hitresidual[1]
684 <<
", Cov^-1 matr (covmat):" 685 <<
" [0][0] = " << covmat[0][0]
686 <<
" [0][1] = " << covmat[0][1]
687 <<
" [1][0] = " << covmat[1][0]
688 <<
" [1][1] = " << covmat[1][1];
712 for (ConstTrajTrackPairCollection::const_iterator it=tracks.begin(); it!=tracks.end(); ++it){
716 float pt = track->
pt();
719 float p = track->
p();
722 float d0 = track->
d0();
723 float dz = track->
dz();
733 <<
"New track pt,eta,phi,chi2n,hits: " 748 double r = gRandom->Rndm();
749 if (trkwt < r)
continue;
751 else if (
trackWt) ihitwt=trkwt;
758 m_Eta.push_back(eta);
759 m_Phi.push_back(phi);
769 m_wt.push_back(ihitwt);
773 std::vector<const TransientTrackingRecHit*> hitvec;
774 std::vector<TrajectoryStateOnSurface> tsosvec;
777 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
778 for (std::vector<TrajectoryMeasurement>::iterator im=measurements.begin(); im!=measurements.end(); ++im){
803 const std::type_info &
type =
typeid(*rechit);
814 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 815 <<
"TypeId of the RecHit: " <<
className(*hit);
826 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Strip RecHit failed! " 827 <<
"TypeId of the TTRH: " <<
className(*hit);
838 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Dynamic cast of Pixel RecHit failed! " 839 <<
"TypeId of the TTRH: " <<
className(*hit);
841 if (!myflag.
isTaken())
continue;
851 hitvec.push_back(hit);
852 tsosvec.push_back(tsos);
864 std::vector<TrajectoryStateOnSurface>::const_iterator itsos=tsosvec.begin();
865 std::vector<const TransientTrackingRecHit*>::const_iterator ihit=hitvec.begin();
868 while (itsos != tsosvec.end()){
870 const GeomDet* det = (*ihit)->det();
872 uint32_t nhitDim = (*ihit)->dimension();
891 double angle = TMath::ASin(sin_theta);
895 else{
if (angle<
cos_cut)ihitwt=0; }
905 if ((*ihit)->hit()!=
nullptr){
907 if (pixhit!=
nullptr){
919 else probXYQgood = (probXYgood && probQgood);
920 if (!probXYQgood) ihitwt=0;
928 bool hitProcessed=
false;
931 hitProcessed=
processHit1D(alidet, ali, alispecifics, tsos, *ihit, ihitwt);
934 hitProcessed=
processHit2D(alidet, ali, alispecifics, tsos, *ihit, ihitwt);
938 <<
"ERROR in <HIPAlignmentAlgorithm::run>: Number of hit dimensions = " 939 << nhitDim <<
" is not supported!" 960 std::ifstream inIterFile(filename.c_str(),
std::ios::in);
962 edm::LogError(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] ERROR! " 963 <<
"Unable to open Iteration file";
968 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::readIterationFile] " 969 <<
"Read last iteration number from file: " <<
result;
978 std::ofstream outIterFile((filename.c_str()),
std::ios::out);
980 <<
"[HIPAlignmentAlgorithm::writeIterationFile] ERROR: Unable to write Iteration file";
983 edm::LogWarning(
"Alignment") <<
"[HIPAlignmentAlgorithm::writeIterationFile] writing iteration number to file: " << iter;
993 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] No APE applied";
997 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::setAlignmentPositionError] Apply APE!";
999 double apeSPar[3], apeRPar[3];
1001 const auto& alignables = alipars.first;
1002 const auto& pars = alipars.second;
1004 apeSPar[0] = pars[0];
1005 apeSPar[1] = pars[1];
1006 apeSPar[2] = pars[2];
1007 apeRPar[0] = pars[3];
1008 apeRPar[1] = pars[4];
1009 apeRPar[2] = pars[5];
1011 int function = pars[6];
1014 printf(
"APE: %u alignables\n", (
unsigned int)alignables.size());
1015 for (
int i=0;
i<21; ++
i) {
1016 double apelinstest=
calcAPE(apeSPar,
i, 0);
1017 double apeexpstest=
calcAPE(apeSPar,
i, 1);
1018 double apestepstest=
calcAPE(apeSPar,
i, 2);
1019 double apelinrtest=
calcAPE(apeRPar,
i, 0);
1020 double apeexprtest=
calcAPE(apeRPar,
i, 1);
1021 double apesteprtest=
calcAPE(apeRPar,
i, 2);
1022 printf(
"APE: iter slin sexp sstep rlin rexp rstep: %5d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f \n",
1023 i, apelinstest, apeexpstest, apestepstest, apelinrtest, apeexprtest, apesteprtest);
1036 double diter=(double)iter;
1037 if (
function == 0)
return std::max(par[1], par[0]+((par[1]-par[0])/par[2])*diter);
1038 else if (
function == 1)
return std::max(0., par[0]*(
exp(-
pow(diter, par[1])/par[2])));
1039 else if (
function == 2){
1040 int ipar2 = (
int)par[2];
1041 int step = iter/ipar2;
1042 double dstep = (double)step;
1043 return std::max(0., par[0] - par[1]*dstep);
1124 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Survey trees booked.";
1126 edm::LogInfo(
"Alignment") <<
"[HIPAlignmentAlgorithm::bookRoot] Root trees booked.";
1162 m2_ObjId = ali->alignableObjectId();
1172 std::vector<std::pair<int, SurfaceDeformation*> > dali_id_pairs;
1175 std::vector<double> dali;
1176 if (1 == ali->surfaceDeformationIdPairs(dali_id_pairs)){
1177 dali_obj = dali_id_pairs[0].second;
1181 for (
auto& dit : dali)
m2_surfDef.push_back((
float)dit);
1189 <<
"------------------------------------------------------------------------\n" 1190 <<
" ALIGNABLE: " << setw(6) << naligned
1192 <<
"hits: " << setw(4) <<
m2_Nhit 1193 <<
" type: " << setw(4) <<
m2_Type 1194 <<
" layer: " << setw(4) <<
m2_Layer 1195 <<
" id: " << setw(4) <<
m2_Id 1196 <<
" objId: " << setw(4) <<
m2_ObjId 1203 <<
"\nDeformations type, nDeformations: " 1208 << setw(12) << pars[0]
1209 << setw(12) << pars[1]
1210 << setw(12) << pars[2]
1211 << setw(12) << pars[3]
1212 << setw(12) << pars[4]
1213 << setw(12) << pars[5];
1224 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Begin: Processing detector " << ali->
id();
1231 int nhit = uservar->
nhit;
1239 if (setDet==0 && nhit<minHitThreshold){
1240 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Skipping detector " << ali->
id() <<
" because number of hits = " << nhit <<
" <= " << minHitThreshold;
1249 int npar = jtve.num_row();
1260 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Matrix inversion failed!";
1263 params = -(jtvjinv * jtve);
1268 for (
int i=0;
i<npar;
i++){
1270 if (fabs(cov[
i][
i])>0.) paramerr[
i] =
sqrt(fabs(cov[i][i]));
1271 else paramerr[
i] = params[
i];
1272 if (params[i]!=0.) relerr = fabs(paramerr[i]/params[i]);
1273 if ((maxRelErrThreshold>=0. && relerr>maxRelErrThreshold) || relerr<minRelErrThreshold){
1275 <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"RelError = " << relerr
1276 <<
" > " << maxRelErrThreshold <<
" or < " << minRelErrThreshold
1277 <<
". Setting param = paramerr = 0 for component " <<
i;
1284 if (params.num_row()!=1){
1285 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"For scanning, please only turn on one parameter! check common_cff_py.txt";
1289 else params[0]=
step;
1290 edm::LogWarning(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"Parameters = " << params;
1295 uservar->
alierr=paramerr;
1301 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::calcParameters" <<
"End: Processing detector " << ali->
id();
1310 std::vector<std::string> monitorFileList;
1314 std::unordered_map<Alignable*, std::unordered_map<int, pawt_t> > ali_datatypecountpair_map;
1316 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.";
1319 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Pre-reading uservar for job " << ijob;
1326 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1327 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1328 <<
". A mismatch might occur!";
1330 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1333 std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();
1340 pawt_t alijobnhits = uvar->
nhit;
1341 if (ali_datatypecountpair_map.find(ali)==ali_datatypecountpair_map.end()){
1342 std::unordered_map<int, pawt_t> newmap;
1343 ali_datatypecountpair_map[ali] = newmap;
1344 ali_datatypecountpair_map[ali][alijobdtype] = alijobnhits;
1347 std::unordered_map<int, pawt_t>& theMap = ali_datatypecountpair_map[ali];
1348 if (theMap.find(alijobdtype)==theMap.end()) theMap[alijobdtype]=alijobnhits;
1349 else theMap[alijobdtype] += alijobnhits;
1359 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Reading uservar for job " << ijob;
1366 <<
"@SUB=HIPAlignmentAlgorithm::collector" 1367 <<
"Number of alignables = " <<
theAlignables.size() <<
" is not the same as number of user variables = " << uvarvec.size()
1368 <<
". A mismatch might occur!";
1371 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" <<
"Could not read user variable files for job " << ijob <<
" in iteration " <<
theIteration;
1376 std::vector<AlignmentUserVariables*> uvarvecadd;
1377 std::vector<AlignmentUserVariables*>::const_iterator iuvarnew=uvarvec.begin();
1387 if (uvarnew!=
nullptr){
1390 int alijobdtype = uvarnew->
datatype;
1392 ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end()
1394 ali_datatypecountpair_map[ali].find(alijobdtype)!=ali_datatypecountpair_map[ali].end()
1396 peraliwgt = ali_datatypecountpair_map[ali][alijobdtype];
1397 unsigned int nNonZeroTypes=0;
1399 for (
auto it=ali_datatypecountpair_map[ali].cbegin(); it!=ali_datatypecountpair_map[ali].cend(); ++it){
1400 sumwgts+=it->second;
1401 if (it->second!=pawt_t(0)) nNonZeroTypes++;
1403 edm::LogInfo(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1404 <<
"Reweighting detector " << ali->id() <<
" / " << ali->alignableObjectId()
1405 <<
" for data type " << alijobdtype <<
" by " << sumwgts <<
"/" << peraliwgt <<
"/" << nNonZeroTypes;
1406 peraliwgt=((nNonZeroTypes==0 || peraliwgt==double(0)) ?
double(1) : double((
double(sumwgts))/peraliwgt/(
double(nNonZeroTypes))));
1408 else if (ali_datatypecountpair_map.find(ali)!=ali_datatypecountpair_map.end())
1409 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1410 <<
"Could not find data type " << alijobdtype <<
" for detector " << ali->id() <<
" / " << ali->alignableObjectId();
1412 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collector" 1413 <<
"Could not find detector " << ali->id() <<
" / " << ali->alignableObjectId()
1414 <<
" in the map ali_datatypecountpair_map";
1418 uvar->
jtvj = (uvarold->
jtvj) + peraliwgt*(uvarnew->
jtvj);
1419 uvar->
jtve = (uvarold->
jtve) + peraliwgt*(uvarnew->
jtve);
1426 uvarvecadd.push_back(uvar);
1435 monitorFileList.push_back(uvfile);
1448 <<
"[HIPAlignmentAlgorithm::collectMonitorTrees] Called in non-collector mode." 1451 TString theTrackMonitorTreeName=Form(
"T1_%i",
theIteration);
1452 TString theHitMonitorTreeName=Form(
"T1_hit_%i",
theIteration);
1454 std::vector<TFile*> finputlist;
1455 TList* eventtrees =
new TList;
1456 TList* hittrees =
new TList;
1458 TFile* finput = TFile::Open(
filename.c_str(),
"read");
1459 if (finput!=
nullptr){
1463 tmptree = (TTree*)finput->Get(theTrackMonitorTreeName);
1464 if (tmptree!=
nullptr) eventtrees->Add(tmptree);
1468 tmptree = (TTree*)finput->Get(theHitMonitorTreeName);
1469 if (tmptree!=
nullptr) hittrees->Add((TTree*)finput->Get(theHitMonitorTreeName));
1471 finputlist.push_back(finput);
1476 edm::LogError(
"Alignment") <<
"@SUB=HIPAlignmentAlgorithm::collectMonitorTrees" 1477 <<
"Monitor file is already open while it is not supposed to be!";
1490 for (TFile*& finput : finputlist) finput->Close();
1501 if (it->matchAlignable(ali))
return &(*it);
1503 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
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
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
std::vector< int > m_nhTEC
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.
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.
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
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.
void clear()
remove all selected Alignables and geometrical restrictions
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)
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
std::string siterationfile
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
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_
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
std::vector< int > m_nhPXF
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< AlignableAbsData > AlignablePositions
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
std::vector< std::pair< align::Alignables, std::vector< double > > > theAPEParameters
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
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