46 #ifdef OS_OSPACE_STD_NAMESPACE
47 using namespace os_std;
84 theInstance =
new Model;
108 std::vector<ALIstring> SectionTitle;
109 SectionTitle.push_back(
ALIstring(
"GLOBAL_OPTIONS"));
110 SectionTitle.push_back(
ALIstring(
"PARAMETERS"));
111 SectionTitle.push_back(
ALIstring(
"SYSTEM_TREE_DESCRIPTION"));
112 SectionTitle.push_back(
ALIstring(
"SYSTEM_TREE_DATA"));
113 SectionTitle.push_back(
ALIstring(
"MEASUREMENTS"));
114 SectionTitle.push_back(
ALIstring(
"REPORT.OUT"));
115 std::vector<ALIstring>::iterator SectionTitleIterator;
118 std::vector<ALIstring> wordlist;
120 ALIint currentSectionNo = -1;
121 while (!filein.
eof()) {
124 assert(!wordlist.empty());
134 SectionTitleIterator =
find(SectionTitle.begin(), SectionTitle.end(), *wordlist.begin());
135 if (SectionTitleIterator != SectionTitle.end()) {
137 currentSectionNo = SectionTitleIterator - SectionTitle.begin();
138 if (currentSectionNo != InSectionNo + 1) {
141 std::cerr <<
"BAD ORDER OF SECTIONS, reading section " << *SectionTitleIterator << std::endl
142 <<
" currentSectionNo = " << currentSectionNo <<
" InSectionNo = " << InSectionNo << std::endl
143 <<
" --------- Please see documentation ---------- " << std::endl;
152 SetValueDisplacementsFromReportOut();
156 std::cout << std::endl <<
"START OF SECTION: " << currentSectionNo <<
" " << *SectionTitleIterator << std::endl;
164 if (wordlist.size() == 2) {
167 if (!isnumber && wordlist[0] !=
ALIstring(
"external_meas")) {
169 std::cerr <<
": EXPECTING A NUMBER, FOUND: " << wordlist[1] << std::endl;
185 std::cerr <<
": IN GLOBAL_OPTIONS section TWO-WORD LINES ARE EXPECTED " << std::endl;
203 if (wordlist.size() == 2) {
218 }
else if (wordlist.size() == 3) {
219 if (wordlist[1] !=
"seed") {
221 std::cerr <<
": For a three-word parameter line, second has to be 'seed', it is " << wordlist[1]
226 if (wordlist[0] ==
"gauss" || wordlist[0] ==
"flat") {
230 std::cerr <<
": For a three-word parameter line, first has to be 'gauss' or 'flat', it is " << wordlist[0]
234 }
else if (wordlist.size() == 4) {
235 if (wordlist[0] ==
"gauss") {
237 }
else if (wordlist[0] ==
"flat") {
241 std::cerr <<
": For a four-word parameter line, first has to be 'gauss' or 'flat', it is " << wordlist[0]
247 std::cerr <<
": IN PARAMETERS section TWO-WORD-LINES ARE EXPECTED " << std::endl;
262 std::vector<ALIstring> wordlist2 = wordlist;
263 std::vector<ALIstring>::iterator vsite;
264 ALIint wsiz = wordlist.size();
269 for (vsite = wordlist2.begin(); vsite != wordlist2.end(); ++vsite) {
271 int nOpticalObjects = atoi((*vsite).c_str());
273 if (nOpticalObjects == 1) {
276 <<
" number of repeated OpticalObjects = 1. Please avoid the numbering " << std::endl;
282 std::cerr <<
"NUMBER SHOULD BE FOLLOWED BY an OpticalObject type" << std::endl;
291 wordlist.push_back(*(vsite + 1));
296 wordlist.push_back(*vsite);
307 if (wordlist[0] ==
ALIstring(
"object")) {
309 std::vector<std::vector<ALIstring> >::iterator vvsite;
310 for (vvsite = theOptODictionary.begin(); vvsite != theOptODictionary.end(); ++vvsite) {
313 if (*((*vvsite).begin()) == wordlist[1]) {
315 std::cerr <<
"SYSTEM_TREE_DESCRIPTION: REPEATED object " << *((*vvsite).begin())
316 <<
" ( NOT ALLOWED NEITHER WITH EQUAL NOR WITH DIFFERENT COMPONENTS)" << std::endl;
321 std::vector<ALIstring> vstemp;
322 copy(wordlist.begin() + 1, wordlist.end(), back_inserter(vstemp));
326 if (OptODictionary().
empty()) {
328 std::cerr <<
"SYSTEM_TREE_DESCRIPTION section: FIRST LINE SHOULD START WITH 'object'" << std::endl;
331 copy(wordlist.begin(), wordlist.end(), back_inserter(*(OptODictionary().
end() - 1)));
341 std::vector<std::vector<ALIstring> > OptODictionary2;
342 reorderOptODictionary(
"system", OptODictionary2);
343 if (OptODictionary2.empty()) {
344 std::cerr <<
"SYSTEM_TREE_DESCRIPTION section: no object 'system' found " << std::endl;
349 std::vector<std::vector<ALIstring> >::const_iterator vvscite, vvscite2;
351 for (vvscite = theOptODictionary.begin(); vvscite != theOptODictionary.end(); ++vvscite) {
353 for (vvscite2 = OptODictionary2.begin(); vvscite2 != OptODictionary2.end(); ++vvscite2) {
354 if (*((*vvscite).begin()) == *((*vvscite2).begin())) {
360 std::cerr <<
"!!!SYSTEM_TREE_DESCRIPTION section: object " << *((*vvscite).begin())
361 <<
" is not hanging from object 'system' " << std::endl;
362 for (vvscite = OptODictionary().begin(); vvscite != OptODictionary().end(); ++vvscite) {
363 std::vector<ALIstring> ptemp = *vvscite;
369 theOptODictionary = OptODictionary2;
375 std::vector<std::vector<ALIstring> >::iterator itevs;
376 for (itevs = OptODictionary().
begin(); itevs != OptODictionary().end(); ++itevs) {
377 std::vector<ALIstring> ptemp = *itevs;
384 if (wordlist[0] !=
"system") {
385 std::cerr <<
"SYSTEM_TREE_DATA section: object 'system' is not the first one " << std::endl;
393 theOptOList.push_back(OptOsystem);
398 std::cerr <<
" STILL SOME LINES AFTER ALL SYSTEM TREE IS READ!!!" << std::endl;
409 if (wordlist.size() == 2) {
410 measName = wordlist[1];
419 }
else if (measType ==
ALIstring(
"DISTANCEMETER3DIM")) {
423 }
else if (measType ==
ALIstring(
"DISTANCEMETER") || measType ==
ALIstring(
"DISTANCEMETER1DIM")) {
427 }
else if (measType ==
ALIstring(
"TILTMETER")) {
431 }
else if (measType ==
ALIstring(
"COPS")) {
435 }
else if (measType ==
ALIstring(
"DIFFCENTRE")) {
438 }
else if (measType ==
ALIstring(
"DIFFANGLE")) {
441 }
else if (measType ==
ALIstring(
"DIFFENTRY")) {
444 }
else if (measType ==
ALIstring(
"measurements_from_file") || measType ==
ALIstring(
"@measurements_from_file")) {
448 if (wordlist.size() == 4) {
454 }
else if (measType ==
ALIstring(
"measurements_from_file_ROOT") ||
455 measType ==
ALIstring(
"@measurements_from_file")) {
457 }
else if (wordlist[0] ==
ALIstring(
"correlations_from_file") ||
458 wordlist[0] ==
ALIstring(
"@correlations_from_file")) {
460 }
else if (wordlist[0] ==
ALIstring(
"copy_measurements") || wordlist[0] ==
ALIstring(
"@copy_measurements")) {
461 copyMeasurements(wordlist);
464 }
else if (wordlist[0] ==
ALIstring(
"fittedEntries_from_file")) {
467 std::cout <<
" setting fittedEntries_from_file " << wordlist[0] <<
" == " << wordlist[1] << std::endl;
469 std::cerr <<
"Measurement:" << std::endl;
471 std::cerr <<
"!!! type of measurement not allowed: " << wordlist[0] << std::endl;
472 std::cerr <<
" Allowed types: SENSOR2D, DISTANCEMETER, DISTANCEMETER1DIM, TILTMETER, COPS, DIFFENTRY "
483 std::cerr <<
"BAD ORDER OF SECTIONS, reading section " << *SectionTitleIterator << std::endl
484 <<
" currentSectionNo = " << currentSectionNo <<
" InSectionNo = " << InSectionNo << std::endl
485 <<
" --------- Please see documentation ---------- " << std::endl;
497 std::cout << std::endl <<
"@@@@ Building Measurements links to OptOs" << std::endl;
501 std::cout <<
"---------- SYSTEM SUCCESFULLY READ ----------" << std::endl << std::endl;
514 std::vector<std::vector<ALIstring> >::iterator vvsite;
515 std::vector<ALIstring>::iterator vsite;
518 for (vvsite = OptODictionary().
begin(); vvsite != OptODictionary().end(); ++vvsite) {
519 if (*((*vvsite).begin()) == ssearch) {
521 OptODictionary2.push_back(*vvsite);
528 for (vsite = (*vvsite).begin() + 1; vsite != (*vvsite).end(); ++vsite) {
529 reorderOptODictionary(*vsite, OptODictionary2);
547 std::vector<Measurement*>::const_iterator vmcite;
548 for (vmcite = MeasurementList().
begin(); vmcite != MeasurementList().end(); ++vmcite) {
572 std::vector<OpticalObject*>::const_iterator vocite;
573 for (vocite = OptOList().
begin(); vocite != OptOList().end(); ++vocite) {
574 if ((*vocite)->name() == opto_name)
578 if (vocite == OptOList().end()) {
580 std::cerr <<
" LIST OF OpticalObjects " << std::endl;
581 for (vocite = OptOList().begin(); vocite != OptOList().end(); ++vocite) {
582 std::cerr << (*vocite)->name() << std::endl;
584 std::cerr <<
"!!EXITING at getOptOByName: Optical Object " << opto_name <<
" doesn't exist!!" << std::endl;
590 std::cout << opto_name.c_str() <<
"SSOptOitem" << (*vocite) << (*vocite)->name() <<
"len" << OptOList().size()
603 std::vector<OpticalObject*>::const_iterator vocite;
604 for (vocite = OptOList().
begin(); vocite != OptOList().end(); ++vocite) {
606 if ((*vocite)->type() == opto_type)
610 if (vocite == OptOList().end()) {
612 std::cerr <<
"!!EXITING at getOptOByType: Optical Object " << opto_type <<
" doesn't exist!!" << std::endl;
625 std::vector<Entry*>::const_iterator vecite;
626 for (vecite = EntryList().
begin(); vecite != EntryList().end(); ++vecite) {
628 std::cout <<
"getEntryByName: " << (*vecite)->OptOCurrent()->name() <<
" E " << (*vecite)->name()
629 <<
" Searching: " << opto_name <<
" E " << entry_name << std::endl;
631 if ((*vecite)->OptOCurrent()->name() == opto_name && (*vecite)->name() == entry_name) {
636 std::cerr <<
"!!!EXITING at getEntryByName: Entry name not found:" << opto_name <<
" " << entry_name << std::endl;
643 std::vector<Measurement*>::const_iterator vmcite;
644 for (vmcite = theMeasurementVector.begin(); vmcite != theMeasurementVector.end(); ++vmcite) {
645 if ((*vmcite)->name() == meas_name)
649 if (vmcite != theMeasurementVector.end()) {
655 std::cerr <<
" LIST OF Measurements " << std::endl;
656 for (vmcite = theMeasurementVector.begin(); vmcite != theMeasurementVector.end(); ++vmcite) {
657 std::cerr << (*vmcite)->name() << std::endl;
659 std::cerr <<
"!!EXITING at getMeasurementByName: Measurement " << meas_name <<
" doesn't exist!!" << std::endl;
676 std::vector<ALIstring>::iterator vsite;
677 for (vsite = vcomponents.begin(); vsite != vcomponents.end(); ++vsite) {
678 vcomponents.pop_back();
682 ALIint ALIstring_found = 0;
683 std::vector<std::vector<ALIstring> >::iterator vvsite;
684 for (vvsite = OptODictionary().
begin(); vvsite != OptODictionary().end(); ++vvsite) {
685 if (*((*vvsite).begin()) == opto_type) {
688 vcomponents = *vvsite;
689 vcomponents.erase(vcomponents.begin());
694 if (ALIstring_found) {
707 std::vector<OpticalObject*>::iterator voite;
708 for (voite = vcomponents.begin(); voite != vcomponents.end(); ++voite) {
709 vcomponents.pop_back();
716 std::cout << opto_name <<
"getComponentOptOs: opto " << opto << opto->
name() << std::endl;
717 std::vector<OpticalObject*>::const_iterator vocite;
720 std::cout <<
"optolist size " << OptOList().size() << std::endl;
722 for (vocite = OptOList().
begin(); vocite != OptOList().end(); ++vocite) {
723 if ((*vocite)->parent() !=
nullptr) {
725 if ((*vocite)->parent()->name() == opto_name) {
727 vcomponents.push_back((*vocite));
753 std::cout <<
"createCopyComponentList " << typ << std::endl;
757 theOptOsToCopyList.erase(theOptOsToCopyList.begin(), theOptOsToCopyList.end());
760 fillCopyComponentList(start_opto);
763 theOptOsToCopyListIterator = theOptOsToCopyList.begin();
772 std::cout <<
"entering fillCopyComponentList(): OptO" << opto->
name() << std::endl;
774 std::vector<OpticalObject*> vopto;
775 ALIbool opto_found = getComponentOptOs(opto->
name(), vopto);
778 std::cout <<
"fillCopyComponentList: NO COMPONENTS TO COPY IN THIS OptO" << opto->
name() << std::endl;
782 std::vector<OpticalObject*>::const_iterator vocite;
783 for (vocite = vopto.begin(); vocite != vopto.end(); ++vocite) {
784 theOptOsToCopyList.push_back(*vocite);
786 std::cout <<
"fillCopyOptOList " << (*vocite)->type() <<
" " << (*vocite)->name() << std::endl;
788 fillCopyComponentList(*vocite);
798 std::cout <<
"entering nextOptOToCopy() " << std::endl;
799 ++theOptOsToCopyListIterator;
801 return *(theOptOsToCopyListIterator - 1);
867 ALIuint odsize = theOptODictionary.size();
869 theOptODictionary.pop_back();
885 std::cout <<
"CMSLinkDeleteOptOs: cms_link_halfplanes " << cmslink_halfplanes << cmslink_iter << std::endl;
887 if (cmslink_iter == 1) {
891 deleteOptO(
"s/mabsL");
893 if (cmslink_method == 1) {
894 deleteOptO(
"s/tracker/det_trkDL");
895 deleteOptO(
"s/tracker/det_trkDR");
898 if (cmslink_halfplanes == 2) {
900 deleteOptO(
"s/mabsR");
903 }
else if (cmslink_iter == 2) {
906 deleteOptO(
"s/mabsL");
907 deleteOptO(
"s/tracker/CST/wheel_trkL/peri/mirror");
908 deleteOptO(
"s/tracker/CST/wheel_trkL/det_trkU");
912 if (cmslink_halfplanes <= 1) {
913 deleteOptO(
"s/tracker/CST/wheel_trkR");
914 }
else if (cmslink_halfplanes == 2) {
916 deleteOptO(
"s/mabsR");
917 deleteOptO(
"s/tracker/CST/wheel_trkR/peri/mirror");
918 deleteOptO(
"s/tracker/CST/wheel_trkR/det_trkU");
921 }
else if (cmslink_iter == 3) {
924 deleteOptO(
"s/tracker");
926 if (cmslink_halfplanes == 2) {
1123 std::vector<Entry*>::const_iterator vecite;
1124 std::vector<Entry*>::iterator veite2;
1126 std::cout <<
"SIZE" << theEntryVector.size() << std::endl;
1129 veite2 =
find(theEntryVector.begin(), theEntryVector.end(), (*vecite));
1132 theEntryVector.erase(veite2);
1137 veite2 =
find(theEntryVector.begin(), theEntryVector.end(), (*vecite));
1140 theEntryVector.erase(veite2);
1143 for (vecite = theEntryVector.begin(); vecite != theEntryVector.end(); ++vecite) {
1148 std::vector<Measurement*> MeasToBeDeleted;
1149 std::vector<Measurement*>::const_iterator vmite;
1150 std::vector<OpticalObject*>::const_iterator vocite;
1151 for (vmite = MeasurementList().begin(); vmite != MeasurementList().end(); ++vmite) {
1153 std::cout <<
"Deleting Measurement" << (*vmite)->name() << std::endl;
1155 for (vocite = (*vmite)->OptOList().begin(); vocite != (*vmite)->OptOList().end(); ++vocite) {
1156 if ((*vocite) == opto) {
1158 MeasToBeDeleted.push_back(*vmite);
1166 std::vector<Measurement*>::const_iterator vmcite;
1167 std::vector<Measurement*>::iterator vmite2;
1169 std::cout <<
"SIZEMEAS" << MeasToBeDeleted.size() << std::endl;
1170 for (vmcite = MeasToBeDeleted.begin(); vmcite != MeasToBeDeleted.end(); ++vmcite) {
1171 vmite2 =
find(theMeasurementVector.begin(), theMeasurementVector.end(), (*vmcite));
1174 theMeasurementVector.erase(vmite2);
1179 std::vector<OpticalObject*> vopto;
1181 for (vocite = vopto.begin(); vocite != vopto.end(); ++vocite) {
1182 deleteOptO(*vocite);
1190 std::vector<OpticalObject*>::iterator dvoite =
1193 theOptOList.erase(dvoite);
1276 if (
position >= theParamFittedSigmaVector.size()) {
1278 <<
" bigger than dimension of theParamFittedSigmaVector " << theParamFittedSigmaVector.size()
1282 std::vector<ALIdouble>::const_iterator vdcite = theParamFittedSigmaVector.begin() +
position;
1296 std::vector<ALIstring> wordlist;
1303 std::cout <<
"@@@@ No more measurements left" << std::endl;
1326 if (wordlist[0] ==
"DATE:") {
1334 <<
" DATE: " << wordlist[1] <<
" " << wordlist[1] << std::endl;
1337 for (
ii = 0;
ii < nMeas;
ii++) {
1340 wordlist[0] ==
ALIstring(
"DISTANCEMETER") || wordlist[0] ==
ALIstring(
"DISTANCEMETER1DIM") ||
1342 if (wordlist.size() != 2) {
1343 std::cerr <<
"!!!EXITING Model::readMeasurementsFromFile. number of words should be 2 instead of "
1344 << wordlist.size() << std::endl;
1348 std::vector<Measurement*>::const_iterator vmcite;
1349 for (vmcite = MeasurementList().
begin(); vmcite != MeasurementList().end(); ++vmcite) {
1357 ALIint fcolon = (*vmcite)->name().find(
':');
1361 if (
oname == wordlist[1]) {
1363 if ((*vmcite)->type() != wordlist[0]) {
1364 std::cerr <<
"!!! Reading measurement from file: type in file is " << wordlist[0] <<
" and should be "
1365 << (*vmcite)->type() << std::endl;
1384 std::cerr <<
"!!!FATAL ERROR: Measurement value type is " << wordlist[0]
1385 <<
" while in setup definition was " << meastemp->
valueType(
ii) << std::endl;
1397 if (vmcite == MeasurementList().
end()) {
1398 for (vmcite = MeasurementList().
begin(); vmcite != MeasurementList().end(); ++vmcite) {
1399 std::cerr <<
"MEAS: " << (*vmcite)->name() <<
" " << (*vmcite)->type() << std::endl;
1401 std::cerr <<
"!!! Reading measurement from file: measurement not found in list: type in file is " << wordlist[1]
1406 std::cerr <<
" wrong type of measurement: " << wordlist[0] << std::endl
1407 <<
" Available types are SENSOR2D, TILTMETER, DISTANCEMETER, DISTANCEMETER1DIM, COPS" << std::endl;
1428 std::cout <<
" Model::copyMeasurements "
1429 <<
" subsstr1 " << subsstr1 <<
" subsstr2 " << subsstr2 <<
" querystr " << querystr << std::endl;
1431 std::vector<Measurement*> measToCopy;
1432 std::vector<Measurement*>::iterator mite;
1433 for (mite = theMeasurementVector.begin(); mite != theMeasurementVector.end(); ++mite) {
1436 if (meas->
name().find(querystr) != std::string::npos) {
1437 measToCopy.push_back(meas);
1443 for (mite = measToCopy.begin(); mite != measToCopy.end(); ++mite) {
1445 std::vector<ALIstring> wlt;
1446 wlt.push_back(meas->
type());
1455 if (wlt.size() == 2) {
1477 throw cms::Exception(
"LogicError") <<
"@SUB=Model::copyMeasurements\n"
1478 <<
"unknown measurement type: " << meas->
type();
1482 meastemp->
copyMeas(meas, subsstr1, subsstr2);
1491 std::cout <<
" Model::SetValueDisplacementsFromReportOut() " << std::endl;
1498 std::vector<Entry*>::const_iterator vecite;
1501 entryData = entryMgr->
findEntryByLongName((*vecite)->OptOCurrent()->longName(), (*vecite)->name());
1503 std::cout <<
"SetValueDisplacementsFromReportOut " << (*vecite)->OptOCurrent()->longName() <<
" "
1515 str =
"COCOA_Init ";
1517 str =
"COCOA_ReadingModel";
1519 str =
"COCOA_InitFit";
1521 str =
"COCOA_FitOK";
1523 str =
"COCOA_FitImproving";
1525 str =
"COCOA_FitCannotImprove";
1527 str =
"COCOA_FitChi2Worsened";
1529 str =
"COCOA_FitMatrixNonInversable";
1547 theOptOList.push_back(OptOsystem);
1555 std::vector<OpticalAlignInfo>::iterator ite;
1556 for (ite = theOpticalAlignments.begin(); ite != theOpticalAlignments.end(); ++ite) {
1558 if ((*ite).type_ ==
type) {
1563 std::cerr <<
"!! WARNING: Model::FindOptAlignInfoByType more than one objects of type " <<
type << std::endl;
1564 std::cerr <<
" returning object " << oai.
name_ << std::endl <<
" skipping object " << (*ite).name_ << std::endl;
1569 std::cerr <<
"!! ERROR: Model::FindOptAlignInfoByType object not found, of type " <<
type << std::endl;
1578 std::vector<OpticalAlignMeasurementInfo>::iterator mite;
1581 std::cout <<
" BuildMeasurementsFromOA " << std::endl;
1582 std::vector<OpticalAlignMeasurementInfo> measInfos = measList.
oaMeasurements_;
1583 for (mite = measInfos.begin(); mite != measInfos.end(); ++mite) {
1587 std::cout <<
" BuildMeasurementsFromOA measType " << measType <<
" measName " << measName << std::endl;
1590 if (measType ==
ALIstring(
"SENSOR2D")) {
1592 }
else if (measType ==
ALIstring(
"DISTANCEMETER3DIM")) {
1594 }
else if (measType ==
ALIstring(
"DISTANCEMETER") || measType ==
ALIstring(
"DISTANCEMETER1DIM")) {
1596 }
else if (measType ==
ALIstring(
"TILTMETER")) {
1598 }
else if (measType ==
ALIstring(
"COPS")) {
1604 }
else if (measType ==
ALIstring(
"DIFFENTRY")) {
1607 std::cerr <<
" !!! Model::BuildMeasurementsFromOA : measType not found " << measType << std::endl;