File indexing completed on 2024-04-06 11:56:04
0001
0002
0003
0004
0005
0006
0007 #include "Alignment/CocoaToDDL/interface/CocoaToDDLMgr.h"
0008 #include "Alignment/CocoaToDDL/interface/UnitConverter.h"
0009 #define UC(val, category) UnitConverter(val, category).ucstring()
0010
0011 #include "Alignment/CocoaDDLObjects/interface/CocoaMaterialElementary.h"
0012 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
0013 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h"
0014
0015 #include "Alignment/CocoaModel/interface/Model.h"
0016 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0017 #include "Alignment/CocoaModel/interface/Entry.h"
0018 #include "Alignment/CocoaModel/interface/Measurement.h"
0019
0020 CocoaToDDLMgr* CocoaToDDLMgr::instance = nullptr;
0021
0022
0023 CocoaToDDLMgr* CocoaToDDLMgr::getInstance() {
0024 if (!instance) {
0025 instance = new CocoaToDDLMgr;
0026 }
0027 return instance;
0028 }
0029
0030
0031 void CocoaToDDLMgr::writeDDDFile(ALIstring filename) {
0032
0033 writeHeader(filename);
0034
0035
0036 writeMaterials();
0037
0038
0039 writeSolids();
0040
0041
0042 writeLogicalVolumes();
0043
0044
0045 writePhysicalVolumes();
0046
0047
0048 writeRotations();
0049
0050
0051 writeSpecPars();
0052
0053 newPartPost(filename, "");
0054 }
0055
0056
0057 void CocoaToDDLMgr::writeHeader(ALIstring filename) { newPartPre(filename); }
0058
0059
0060 void CocoaToDDLMgr::writeMaterials() {
0061 newSectPre_ma("");
0062 auto& optolist = Model::OptOList();
0063 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0064 if ((*ite)->type() == "system")
0065 continue;
0066 CocoaMaterialElementary* mat = (*ite)->getMaterial();
0067
0068 if (mat) {
0069 if (!materialIsRepeated(mat))
0070 ma(mat);
0071 }
0072 }
0073
0074 newSectPost_ma("");
0075 }
0076
0077
0078 void CocoaToDDLMgr::writeSolids() {
0079 newSectPre_so("");
0080
0081 auto& optolist = Model::OptOList();
0082 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0083 bool alreadyWritten = false;
0084 for (auto ite2 = optolist.begin(); ite2 != ite; ite2++) {
0085 if ((*ite)->shortName() == (*ite2)->shortName()) {
0086 alreadyWritten = true;
0087 }
0088 }
0089 std::cout << " CocoaToDDLMgr::writeSolids() " << alreadyWritten << *ite;
0090 std::cout << (*ite)->name() << std::endl;
0091 if (!alreadyWritten)
0092 so(*ite);
0093 }
0094
0095 newSectPost_so("");
0096 }
0097
0098
0099 void CocoaToDDLMgr::writeLogicalVolumes() {
0100 newSectPre_lv("");
0101
0102 auto& optolist = Model::OptOList();
0103 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0104 bool alreadyWritten = false;
0105 for (auto ite2 = optolist.begin(); ite2 != ite; ite2++) {
0106 if ((*ite)->shortName() == (*ite2)->shortName()) {
0107 alreadyWritten = true;
0108 }
0109 }
0110 if (!alreadyWritten)
0111 lv(*ite);
0112 }
0113
0114 newSectPost_lv("");
0115 }
0116
0117
0118 void CocoaToDDLMgr::writePhysicalVolumes() {
0119 newSectPre_pv("");
0120
0121 auto& optolist = Model::OptOList();
0122 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0123 if ((*ite)->type() == "system")
0124 continue;
0125 pv(*ite);
0126 }
0127
0128 newSectPost_pv("");
0129 }
0130
0131
0132 void CocoaToDDLMgr::writeRotations() {
0133 newSectPre_ro("");
0134 std::vector<CLHEP::HepRotation>::const_iterator ite;
0135 int nc = 0;
0136 for (ite = theRotationList.begin(); ite != theRotationList.end(); ++ite) {
0137
0138 ro(*ite, nc);
0139 nc++;
0140 }
0141 newSectPost_ro("");
0142 }
0143
0144
0145 void CocoaToDDLMgr::writeSpecPars() {
0146 newSectPre_specPar("");
0147
0148 auto& optolist = Model::OptOList();
0149 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0150 if ((*ite)->type() == "system")
0151 continue;
0152 specPar(*ite);
0153 }
0154
0155 writeSpecParsCocoa();
0156
0157
0158 measurementsAsSpecPars();
0159
0160 newSectPost_specPar("");
0161 }
0162
0163
0164
0165 void CocoaToDDLMgr::newPartPre(std::string name) {
0166 filename_ = name;
0167 file_.open(filename_.c_str());
0168 file_.precision(8);
0169 file_ << "<?xml version=\"1.0\"?>" << std::endl;
0170
0171
0172 file_ << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\""
0173 << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
0174 << " xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../DDLSchema/DDLSchema.xsd\">" << std::endl
0175 << std::endl;
0176
0177 #ifdef gdebug
0178 cout << "part-pre:" << name << std::endl;
0179 #endif
0180 }
0181
0182
0183 void CocoaToDDLMgr::newPartPost(std::string name, std::string extension) {
0184 file_ << std::endl << "</DDDefinition>" << std::endl;
0185 file_.close();
0186 }
0187
0188
0189
0190 void CocoaToDDLMgr::newSectPre_ma(std::string name) {
0191 #ifdef gdebug
0192 std::cout << " sect-mat-pre:" << name << '-' << std::endl;
0193 #endif
0194 newSectPre(filename_, std::string("MaterialSection"));
0195 }
0196
0197
0198 void CocoaToDDLMgr::ma(CocoaMaterialElementary* ma) {
0199 theMaterialList.push_back(ma);
0200
0201 #ifdef gdebug
0202 cout << " ma:" << ma->getName() << std::endl;
0203 #endif
0204
0205 ALIfloat density = ma->getDensity();
0206
0207
0208 file_ << " <ElementaryMaterial";
0209 ALIstring cSymbol = ma->getSymbol();
0210
0211
0212 file_ << " name=\"" << ma->getName() << "\"";
0213
0214
0215
0216 file_ << " density=\"" << UC(density, "Volumic Mass") << "\"";
0217 file_ << " symbol=\"" << ma->getSymbol() << "\"";
0218
0219
0220 file_ << " atomicWeight=\"" << (ma->getA()) << "*g/mole\""
0221 << " atomicNumber=\"" << ma->getZ() << "\""
0222 << "/>" << std::endl;
0223 }
0224
0225
0226 void CocoaToDDLMgr::newSectPost_ma(std::string name) {
0227 #ifdef gdebug
0228 cout << " sect-mat-post:" << name << '-' << std::endl;
0229 #endif
0230 newSectPost("MaterialSection");
0231 }
0232
0233
0234
0235 void CocoaToDDLMgr::newSectPre_so(std::string name) {
0236 #ifdef gdebug
0237 cout << " sect-so-pre:" << name << '-' << std::endl;
0238 #endif
0239 newSectPre(filename_, std::string("SolidSection"));
0240 }
0241
0242
0243 void CocoaToDDLMgr::so(OpticalObject* opto) {
0244 std::cout << " CocoaToDDLMgr::so( " << opto;
0245 std::cout << " " << opto->shortName() << std::endl;
0246
0247 std::string name = opto->shortName();
0248
0249 if (opto->type() == "system") {
0250
0251 file_ << " <Box name=\"" << opto->name() << "\"";
0252 file_ << " dx=\"10.*m"
0253 << "\" dy=\"10.*m"
0254 << "\" dz=\"10.*m"
0255 << "\"/>" << std::endl;
0256 return;
0257 }
0258
0259 CocoaSolidShape* so = opto->getSolidShape();
0260
0261 std::cout << " CocoaToDDLMgr::so( so " << so << std::endl;
0262 std::string solidType = so->getType();
0263
0264 if (solidType == "Box") {
0265 file_ << " <" << solidType << " name=\"" << name << "\"";
0266 CocoaSolidShapeBox* sb = dynamic_cast<CocoaSolidShapeBox*>(so);
0267 file_ << " dx=\"" << UC(sb->getXHalfLength(), "Length") << "\" dy=\"" << UC(sb->getYHalfLength(), "Length")
0268 << "\" dz=\"" << UC(sb->getZHalfLength(), "Length") << "\"/>" << std::endl;
0269 } else if (solidType == "Tubs") {
0270 CocoaSolidShapeTubs* tu = dynamic_cast<CocoaSolidShapeTubs*>(so);
0271 file_ << " <" << solidType << " name=\"" << name << "\""
0272 << " rMin=\"" << UC(tu->getInnerRadius(), "Length") << "\""
0273 << " rMax=\"" << UC(tu->getOuterRadius(), "Length") << "\""
0274 << " dz=\"" << UC(tu->getZHalfLength(), "Length") << "\""
0275 << " startPhi=\"" << UC(tu->getStartPhiAngle(), "Angle") << "\""
0276 << " deltaPhi=\"" << UC(tu->getDeltaPhiAngle(), "Angle") << "\""
0277 << "/>" << std::endl;
0278 }
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399 else {
0400 std::cerr << " <!-- NOT HANDLED: " << solidType << " name=\"" << name << "\""
0401 << ">" << std::endl
0402 << " </" << solidType << "> -->" << std::endl;
0403 std::exception();
0404 }
0405 }
0406
0407
0408 void CocoaToDDLMgr::newSectPost_so(std::string name) {
0409 #ifdef gdebug
0410 cout << " sect-so-post:" << name << '-' << std::endl;
0411 #endif
0412 newSectPost("SolidSection");
0413 }
0414
0415
0416
0417 void CocoaToDDLMgr::newSectPre_lv(std::string name) {
0418 #ifdef gdebug
0419 cout << " sect-lv-pre:" << name << '-' << std::endl;
0420 #endif
0421 newSectPre(filename_, std::string("LogicalPartSection"));
0422 }
0423
0424
0425 void CocoaToDDLMgr::lv(OpticalObject* opto) {
0426 std::string name = opto->shortName();
0427 std::string rSolid = opto->shortName();
0428 std::string sensitive = "unspecified";
0429
0430 if (opto->type() == "system") {
0431 file_ << " <LogicalPart name=\"" << name << "\" category=\"" << sensitive << "\">" << std::endl
0432 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
0433 << " <rMaterial name=\"Hydrogen\""
0434 << "/>" << std::endl
0435 << " </LogicalPart>" << std::endl;
0436 return;
0437 }
0438
0439 #ifdef gdebug_v
0440 cout << "xml:lv " << opto->name() << std::endl;
0441 #endif
0442 file_ << " <LogicalPart name=\"" << name << "\" category=\"" << sensitive << "\">" << std::endl
0443 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
0444 << " <rMaterial name=\"" << opto->getMaterial()->getName() << "\""
0445 << "/>" << std::endl
0446 << " </LogicalPart>" << std::endl;
0447 }
0448
0449
0450 void CocoaToDDLMgr::newSectPost_lv(std::string name) {
0451 #ifdef gdebug
0452 cout << " sect-lv-post:" << name << '-' << std::endl;
0453 #endif
0454 newSectPost("LogicalPartSection");
0455 }
0456
0457
0458
0459 void CocoaToDDLMgr::newSectPre_pv(std::string name) {
0460 #ifdef gdebug
0461 cout << " sect-pv-pre:" << name << '-' << std::endl;
0462 #endif
0463 newSectPre(filename_, std::string("PosPartSection"));
0464 }
0465
0466
0467 void CocoaToDDLMgr::pv(OpticalObject* opto) {
0468 #ifdef gdebug_v
0469 cout << " pv:" << opto->name() << ':' << opto->parent()->name() << std::endl;
0470 #endif
0471
0472
0473 file_ << " <PosPart copyNumber=\""
0474 << "1"
0475 << "\">" << std::endl;
0476 file_ << " <rParent name=\"";
0477
0478
0479
0480 file_ << opto->parent()->shortName() << "\"/>" << std::endl;
0481
0482 file_ << " <rChild name=\"";
0483
0484 file_ << opto->shortName();
0485 file_ << "\"/>" << std::endl;
0486
0487 int rotNumber = buildRotationNumber(opto);
0488
0489
0490 if (rotNumber != -1)
0491 file_ << " <rRotation name=\"R" << rotNumber << "\"/>" << std::endl;
0492
0493 CLHEP::Hep3Vector t = opto->centreLocal();
0494 if (t != CLHEP::Hep3Vector()) {
0495 const CLHEP::Hep3Vector t = opto->centreLocal();
0496
0497 file_ << " <Translation x=\"" << UC(t[0], "Length") << "\""
0498 << " y=\"" << UC(t[1], "Length") << "\""
0499 << " z=\"" << UC(t[2], "Length") << "\" />" << std::endl;
0500 }
0501
0502 file_ << " </PosPart>" << std::endl;
0503 }
0504
0505
0506 void CocoaToDDLMgr::newSectPost_pv(std::string name) {
0507 #ifdef gdebug
0508 cout << " sect-pv-post:" << name << '-' << std::endl;
0509 #endif
0510 newSectPost("PosPartSection");
0511 }
0512
0513
0514
0515 void CocoaToDDLMgr::newSectPre_ro(std::string name) { newSectPre(filename_, std::string("RotationSection")); }
0516
0517
0518
0519 void CocoaToDDLMgr::ro(const CLHEP::HepRotation& ro, int n) {
0520 CLHEP::HepRotation roinv = inverseOf(ro);
0521
0522
0523
0524 bool identity = false;
0525 ALIstring tag = " <Rotation name=\"R";
0526 identity = roinv.isIdentity();
0527
0528
0529 if (!identity) {
0530 file_ << tag << n << "\"";
0531 file_ << " phiX=\"" << UC(roinv.phiX(), "Angle") << "\""
0532 << " thetaX=\"" << UC(roinv.thetaX(), "Angle") << "\""
0533 << " phiY=\"" << UC(roinv.phiY(), "Angle") << "\""
0534 << " thetaY=\"" << UC(roinv.thetaY(), "Angle") << "\""
0535 << " phiZ=\"" << UC(roinv.phiZ(), "Angle") << "\""
0536 << " thetaZ=\"" << UC(roinv.thetaZ(), "Angle")
0537 << "\""
0538
0539 << " />" << std::endl;
0540 }
0541 }
0542
0543
0544 void CocoaToDDLMgr::newSectPost_ro(std::string name) { newSectPost("RotationSection"); }
0545
0546
0547
0548 void CocoaToDDLMgr::newSectPre_specPar(std::string name) {
0549 #ifdef gdebug
0550 cout << " sect-lv-pre:" << name << '-' << std::endl;
0551 #endif
0552
0553 file_ << "<SpecParSection label=\"" << filename_ << "\" eval=\"true\">" << std::endl;
0554 }
0555
0556
0557 void CocoaToDDLMgr::specPar(OpticalObject* opto) {
0558 file_ << " <SpecPar name=\"" << opto->name() << "_PARAMS\">" << std::endl;
0559 file_ << " <PartSelector path=\"/" << opto->name() << "\"/> " << std::endl;
0560 file_ << " <Parameter name=\"cocoa_type\""
0561 << " value=\"" << opto->type() << "\" eval=\"false\" /> " << std::endl;
0562 file_ << " <Parameter name=\"cmssw_ID\""
0563 << " value=\"" << opto->getCmsswID() << "\" /> " << std::endl;
0564
0565 const std::vector<Entry*>& coord = opto->CoordinateEntryList();
0566 for (int ii = 3; ii < 6; ii++) {
0567 Entry* ent = coord[ii];
0568 file_ << " <Parameter name=\"" << ent->name() + std::string("_value") << "\" value=\"";
0569 file_ << UC(ent->value(), "Angle");
0570 file_ << "\" /> " << std::endl;
0571 }
0572 for (int ii = 0; ii < 6; ii++) {
0573 Entry* ent = coord[ii];
0574 file_ << " <Parameter name=\"" << ent->name() + std::string("_sigma") << "\" value=\"";
0575 if (ii < 3) {
0576 file_ << UC(ent->sigma(), "Length");
0577 } else {
0578 file_ << UC(ent->sigma(), "Angle");
0579 }
0580 file_ << "\" /> " << std::endl;
0581 file_ << " <Parameter name=\"" << ent->name() + std::string("_quality") << "\" value=\"" << ent->quality()
0582 << "\" /> " << std::endl;
0583 }
0584
0585 const std::vector<Entry*>& extraEnt = opto->ExtraEntryList();
0586 for (ALIuint ii = 0; ii < extraEnt.size(); ii++) {
0587 Entry* ent = extraEnt[ii];
0588 file_ << " <Parameter name=\"extra_entry\" value=\"" << ent->name() << "\" eval=\"false\" /> " << std::endl;
0589 file_ << " <Parameter name=\"dimType\" value=\"" << ent->type() << "\" eval=\"false\" /> " << std::endl;
0590 file_ << " <Parameter name=\"value\" value=\"";
0591 if (ent->type() == "nodim") {
0592 file_ << ent->value();
0593 } else if (ent->type() == "length") {
0594 file_ << UC(ent->value(), "Length");
0595 } else if (ent->type() == "angle") {
0596 file_ << UC(ent->value(), "Angle");
0597 }
0598 file_ << "\" eval=\"true\" /> " << std::endl;
0599
0600 file_ << " <Parameter name=\"sigma\" value=\"";
0601 if (ent->type() == "nodim") {
0602 file_ << ent->sigma();
0603 } else if (ent->type() == "length") {
0604 file_ << UC(ent->sigma(), "Length");
0605 } else if (ent->type() == "angle") {
0606 file_ << UC(ent->sigma(), "Angle");
0607 }
0608 file_ << "\" eval=\"true\" /> " << std::endl;
0609
0610 file_ << " <Parameter name=\"quality\" value=\"" << ent->quality() << "\" eval=\"true\" /> " << std::endl;
0611 }
0612
0613 file_ << " </SpecPar>" << std::endl;
0614 }
0615
0616
0617 void CocoaToDDLMgr::measurementsAsSpecPars() {
0618 std::vector<Measurement*> measlist = Model::MeasurementList();
0619 std::vector<Measurement*>::iterator mite;
0620 std::vector<ALIstring>::iterator site;
0621 std::multimap<OpticalObject*, Measurement*> optoMeasMap;
0622 for (mite = measlist.begin(); mite != measlist.end(); ++mite) {
0623 auto& optolist = (*mite)->OptOList();
0624 OpticalObject* opto = optolist[optolist.size() - 1];
0625 optoMeasMap.insert(std::multimap<OpticalObject*, Measurement*>::value_type(opto, *mite));
0626 }
0627
0628 typedef std::multimap<OpticalObject*, Measurement*>::const_iterator itemom;
0629 itemom omite;
0630 std::pair<itemom, itemom> omitep;
0631 itemom omite2, omite3;
0632
0633 for (omite = optoMeasMap.begin(); omite != optoMeasMap.end(); ++omite) {
0634 omitep = optoMeasMap.equal_range((*omite).first);
0635 if (omite != optoMeasMap.begin() && (*omite).first == (*omite3).first)
0636 continue;
0637 omite3 = omite;
0638 for (omite2 = omitep.first; omite2 != omitep.second; ++omite2) {
0639 OpticalObject* opto = (*(omite2)).first;
0640 Measurement* meas = (*(omite2)).second;
0641 std::vector<ALIstring> namelist = meas->OptONameList();
0642 if (omite2 == omitep.first) {
0643 file_ << " <SpecPar name=\"" << meas->name() << "_MEASUREMENT\">" << std::endl;
0644 file_ << " <PartSelector path=\"/" << opto->name() << "\"/> " << std::endl;
0645 }
0646
0647 file_ << " <Parameter name=\"" << std::string("meas_name") << "\" value=\"" << meas->name()
0648 << "\" eval=\"false\" /> " << std::endl;
0649 file_ << " <Parameter name=\"" << std::string("meas_type") << "\" value=\"" << meas->type()
0650 << "\" eval=\"false\" /> " << std::endl;
0651 for (site = namelist.begin(); site != namelist.end(); ++site) {
0652 file_ << " <Parameter name=\"" << std::string("meas_object_name_") + meas->name() << "\" value=\"" << (*site)
0653 << "\" eval=\"false\" /> " << std::endl;
0654 }
0655 for (ALIuint ii = 0; ii < meas->dim(); ii++) {
0656 file_ << " <Parameter name=\"" << std::string("meas_value_name_") + meas->name() << "\" value=\""
0657 << meas->valueType(ii) << "\" eval=\"false\" /> " << std::endl;
0658 file_ << " <Parameter name=\"" << std::string("meas_value_") + meas->name() << "\" value=\""
0659 << meas->value(ii) << "\" eval=\"true\" /> " << std::endl;
0660 file_ << " <Parameter name=\"" << std::string("meas_sigma_") + meas->name() << "\" value=\""
0661 << meas->sigma(ii) << "\" eval=\"true\" /> " << std::endl;
0662 file_ << " <Parameter name=\"" << std::string("meas_is_simulated_value_") + meas->name() << "\" value=\""
0663 << meas->valueIsSimulated(ii) << "\" eval=\"true\" /> " << std::endl;
0664 }
0665 }
0666 file_ << " </SpecPar>" << std::endl;
0667 }
0668 }
0669
0670
0671 void CocoaToDDLMgr::writeSpecParsCocoa() {
0672 file_ << "<!-- Define volumes as COCOA objects --> " << std::endl << " <SpecPar name=\"COCOA\"> " << std::endl;
0673
0674 auto& optolist = Model::OptOList();
0675 for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
0676 if ((*ite)->type() == "system")
0677 continue;
0678 file_ << " <PartSelector path=\"/" << (*ite)->name() << "\"/> " << std::endl;
0679 }
0680
0681 file_ << " <String name=\"COCOA\" value=\"COCOA\"/> " << std::endl << " </SpecPar> " << std::endl;
0682 }
0683
0684
0685 void CocoaToDDLMgr::newSectPost_specPar(std::string name) { newSectPost("SpecParSection"); }
0686
0687
0688
0689
0690 void CocoaToDDLMgr::newSectPre(std::string name, std::string type) {
0691 file_ << "<" << type << " label=\"" << name << "\">" << std::endl;
0692 }
0693
0694
0695 void CocoaToDDLMgr::newSectPost(std::string name) { file_ << "</" << name << ">" << std::endl << std::endl; }
0696
0697
0698 ALIbool CocoaToDDLMgr::materialIsRepeated(CocoaMaterialElementary* ma) {
0699 ALIbool isRepeated = false;
0700 std::vector<CocoaMaterialElementary*>::const_iterator ite;
0701
0702 for (ite = theMaterialList.begin(); ite != theMaterialList.end(); ++ite) {
0703 if (*(*ite) == *ma) {
0704 isRepeated = true;
0705 break;
0706 }
0707 }
0708
0709 return isRepeated;
0710 }
0711
0712
0713 std::string CocoaToDDLMgr::scrubString(const std::string& s) {
0714 std::string::const_iterator ampat;
0715 static const std::string amp = "_";
0716 std::string ret = "";
0717 for (ampat = s.begin(); ampat != s.end(); ++ampat) {
0718 if (*ampat == '&')
0719 ret = ret + amp;
0720 else if (*ampat == '/')
0721 ret = ret + ";";
0722 else if (*ampat == ':')
0723 ret = ret + '_';
0724 else
0725 ret = ret + *ampat;
0726 }
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737 return ret;
0738 }
0739
0740
0741 ALIint CocoaToDDLMgr::buildRotationNumber(OpticalObject* opto) {
0742 ALIint rotnum = -1;
0743
0744 if (opto->rmLocal().isIdentity())
0745 return rotnum;
0746
0747 std::vector<CLHEP::HepRotation>::const_iterator ite;
0748
0749 int nc = 0;
0750 for (ite = theRotationList.begin(); ite != theRotationList.end(); ++ite) {
0751 if ((*ite) == opto->rmLocal()) {
0752 rotnum = nc;
0753 break;
0754 }
0755 nc++;
0756 }
0757
0758 if (rotnum == -1) {
0759 theRotationList.push_back(opto->rmLocal());
0760 rotnum = theRotationList.size() - 1;
0761 }
0762
0763 return rotnum;
0764 }