Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "Alignment/CocoaToDDL/interface/CocoaToDDLMgr.h"
00008 #include "Alignment/CocoaToDDL/interface/UnitConverter.h"
00009 #define UC(val,category) UnitConverter(val,category).ucstring()
00010
00011 #include "Alignment/CocoaDDLObjects/interface/CocoaMaterialElementary.h"
00012 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
00013 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h"
00014
00015 #include "Alignment/CocoaModel/interface/Model.h"
00016 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00017 #include "Alignment/CocoaModel/interface/Entry.h"
00018 #include "Alignment/CocoaModel/interface/Measurement.h"
00019
00020
00021
00022 CocoaToDDLMgr* CocoaToDDLMgr::instance = 0;
00023
00024
00025 CocoaToDDLMgr* CocoaToDDLMgr::getInstance()
00026 {
00027 if(!instance) {
00028 instance = new CocoaToDDLMgr;
00029 }
00030 return instance;
00031 }
00032
00033
00034 void CocoaToDDLMgr::writeDDDFile( ALIstring filename)
00035 {
00036
00037 writeHeader( filename );
00038
00039
00040 writeMaterials();
00041
00042
00043 writeSolids();
00044
00045
00046 writeLogicalVolumes();
00047
00048
00049 writePhysicalVolumes();
00050
00051
00052 writeRotations();
00053
00054
00055 writeSpecPars();
00056
00057 newPartPost( filename, "" );
00058
00059
00060 }
00061
00062
00063 void CocoaToDDLMgr::writeHeader( ALIstring filename)
00064 {
00065 newPartPre( filename );
00066 }
00067
00068
00069 void CocoaToDDLMgr::writeMaterials()
00070 {
00071 newSectPre_ma("");
00072 auto &optolist = Model::OptOList();
00073 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00074 if( (*ite)->type() == "system" ) continue;
00075 CocoaMaterialElementary* mat = (*ite)->getMaterial();
00076
00077 if( mat ) {
00078 if( !materialIsRepeated( mat ) ) ma( mat );
00079 }
00080 }
00081
00082 newSectPost_ma("");
00083 }
00084
00085
00086 void CocoaToDDLMgr::writeSolids()
00087 {
00088 newSectPre_so("");
00089
00090 auto &optolist = Model::OptOList();
00091 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00092 bool alreadyWritten = false;
00093 for(auto ite2 = optolist.begin(); ite2 != ite; ite2++ ){
00094 if( (*ite)->shortName() == (*ite2)->shortName() ) {
00095 alreadyWritten = true;
00096 }
00097 }
00098 std::cout << " CocoaToDDLMgr::writeSolids() " << alreadyWritten << *ite;
00099 std::cout << (*ite)->name() << std::endl;
00100 if( !alreadyWritten ) so( *ite );
00101 }
00102
00103 newSectPost_so("");
00104
00105 }
00106
00107
00108 void CocoaToDDLMgr::writeLogicalVolumes()
00109 {
00110 newSectPre_lv("");
00111
00112 auto &optolist = Model::OptOList();
00113 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00114 bool alreadyWritten = false;
00115 for(auto ite2 = optolist.begin(); ite2 != ite; ite2++ ){
00116 if( (*ite)->shortName() == (*ite2)->shortName() ) {
00117 alreadyWritten = true;
00118 }
00119 }
00120 if( !alreadyWritten ) lv( *ite );
00121 }
00122
00123 newSectPost_lv("");
00124
00125 }
00126
00127
00128 void CocoaToDDLMgr::writePhysicalVolumes()
00129 {
00130 newSectPre_pv("");
00131
00132 auto &optolist = Model::OptOList();
00133 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00134 if( (*ite)->type() == "system" ) continue;
00135 pv( *ite );
00136 }
00137
00138 newSectPost_pv("");
00139
00140 }
00141
00142
00143
00144 void CocoaToDDLMgr::writeRotations()
00145 {
00146 newSectPre_ro("");
00147 std::vector<CLHEP::HepRotation>::const_iterator ite;
00148 int nc = 0;
00149 for( ite = theRotationList.begin(); ite != theRotationList.end(); ite++) {
00150
00151 ro( *ite, nc );
00152 nc++;
00153 }
00154 newSectPost_ro("");
00155
00156 }
00157
00158
00159 void CocoaToDDLMgr::writeSpecPars()
00160 {
00161 newSectPre_specPar("");
00162
00163 auto &optolist = Model::OptOList();
00164 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00165 if( (*ite)->type() == "system" ) continue;
00166 specPar( *ite );
00167 }
00168
00169 writeSpecParsCocoa();
00170
00171
00172 measurementsAsSpecPars();
00173
00174
00175 newSectPost_specPar("");
00176
00177
00178 }
00179
00180
00181
00182
00183
00184 void CocoaToDDLMgr::newPartPre(std::string name)
00185 {
00186 filename_=name;
00187 file_.open(filename_.c_str());
00188 file_.precision(8);
00189 file_ << "<?xml version=\"1.0\"?>" << std::endl;
00190
00191
00192 file_ << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\""
00193 << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
00194 << " xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../DDLSchema/DDLSchema.xsd\">"
00195 << std::endl << std::endl;
00196
00197 #ifdef gdebug
00198 cout << "part-pre:" << name << std::endl;
00199 #endif
00200 }
00201
00202
00203 void CocoaToDDLMgr::newPartPost(std::string name, std::string extension)
00204 {
00205 file_ << std::endl << "</DDDefinition>" << std::endl;
00206 file_.close();
00207 }
00208
00209
00210
00211
00212 void CocoaToDDLMgr::newSectPre_ma(std::string name)
00213 {
00214 #ifdef gdebug
00215 std::cout << " sect-mat-pre:" << name << '-' << std::endl;
00216 #endif
00217 newSectPre(filename_,std::string("MaterialSection"));
00218 }
00219
00220
00221 void CocoaToDDLMgr::ma(CocoaMaterialElementary* ma)
00222 {
00223 theMaterialList.push_back( ma );
00224
00225 #ifdef gdebug
00226 cout << " ma:" << ma->getName() << std::endl;
00227 #endif
00228
00229 ALIfloat density = ma->getDensity();
00230
00231
00232 file_ << " <ElementaryMaterial";
00233 ALIstring cSymbol = ma->getSymbol();
00234
00235
00236 file_ << " name=\"" << ma->getName() << "\"";
00237
00238
00239
00240 file_ << " density=\"" << UC(density,"Volumic Mass") << "\"";
00241 file_ << " symbol=\"" << ma->getSymbol() << "\"";
00242
00243
00244
00245 file_ << " atomicWeight=\"" << (ma->getA()) << "*g/mole\""
00246 << " atomicNumber=\"" << ma->getZ() << "\""
00247 << "/>" << std::endl;
00248
00249 }
00250
00251
00252 void CocoaToDDLMgr::newSectPost_ma(std::string name)
00253 {
00254 #ifdef gdebug
00255 cout << " sect-mat-post:" << name << '-' << std::endl;
00256 #endif
00257 newSectPost("MaterialSection");
00258 }
00259
00260
00261
00262
00263 void CocoaToDDLMgr::newSectPre_so(std::string name)
00264 {
00265 #ifdef gdebug
00266 cout << " sect-so-pre:" << name << '-' << std::endl;
00267 #endif
00268 newSectPre(filename_,std::string("SolidSection"));
00269 }
00270
00271
00272 void CocoaToDDLMgr::so(OpticalObject * opto)
00273 {
00274 std::cout << " CocoaToDDLMgr::so( " << opto;
00275 std::cout << " " << opto->shortName() << std::endl;
00276
00277 std::string name = opto->shortName();
00278
00279 if( opto->type() == "system" ){
00280
00281 file_ << " <Box name=\"" << opto->name() << "\"";
00282 file_ << " dx=\"10.*m"
00283 << "\" dy=\"10.*m"
00284 << "\" dz=\"10.*m"
00285 << "\"/>" << std::endl;
00286 return;
00287 }
00288
00289 CocoaSolidShape* so = opto->getSolidShape();
00290
00291 std::cout << " CocoaToDDLMgr::so( so " << so << std::endl;
00292 std::string solidType = so->getType();
00293
00294 if (solidType == "Box")
00295 {
00296 file_ << " <" << solidType << " name=\"" << name << "\"";
00297 CocoaSolidShapeBox * sb = dynamic_cast<CocoaSolidShapeBox*>(so);
00298 file_ << " dx=\"" << UC(sb->getXHalfLength(),"Length")
00299 << "\" dy=\"" << UC(sb->getYHalfLength(),"Length")
00300 << "\" dz=\"" << UC(sb->getZHalfLength(),"Length")
00301 << "\"/>" << std::endl;
00302 }
00303 else if (solidType == "Tubs")
00304 {
00305 CocoaSolidShapeTubs * tu = dynamic_cast < CocoaSolidShapeTubs * > (so);
00306 file_ << " <" << solidType
00307 << " name=\"" << name << "\""
00308 << " rMin=\"" << UC(tu->getInnerRadius(),"Length") << "\""
00309 << " rMax=\"" << UC(tu->getOuterRadius(),"Length") << "\""
00310 << " dz=\"" << UC(tu->getZHalfLength(),"Length") << "\""
00311 << " startPhi=\"" << UC(tu->getStartPhiAngle(),"Angle") << "\""
00312 << " deltaPhi=\"" << UC(tu->getDeltaPhiAngle(),"Angle") << "\""
00313 << "/>" << std::endl;
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 else
00436 {
00437 std::cerr << " <!-- NOT HANDLED: " << solidType << " name=\"" << name<< "\""
00438 << ">" << std::endl
00439 << " </" << solidType << "> -->" << std::endl;
00440 std::exception();
00441 }
00442
00443 }
00444
00445
00446 void CocoaToDDLMgr::newSectPost_so(std::string name)
00447 {
00448 #ifdef gdebug
00449 cout << " sect-so-post:" << name << '-' << std::endl;
00450 #endif
00451 newSectPost("SolidSection");
00452 }
00453
00454
00455
00456
00457 void CocoaToDDLMgr::newSectPre_lv(std::string name)
00458 {
00459 #ifdef gdebug
00460 cout << " sect-lv-pre:" << name << '-' << std::endl;
00461 #endif
00462 newSectPre(filename_,std::string("LogicalPartSection"));
00463 }
00464
00465
00466 void CocoaToDDLMgr::lv(OpticalObject * opto)
00467 {
00468 std::string name = opto->shortName();
00469 std::string rSolid = opto->shortName();
00470 std::string sensitive = "unspecified";
00471
00472 if( opto->type() == "system" ){
00473 file_ << " <LogicalPart name=\""
00474 << name << "\" category=\"" << sensitive << "\">" << std::endl
00475 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
00476 << " <rMaterial name=\"Hydrogen\""
00477 << "/>" << std::endl
00478 << " </LogicalPart>" << std::endl;
00479 return;
00480 }
00481
00482 #ifdef gdebug_v
00483 cout << "xml:lv " << opto->name() << std::endl;
00484 #endif
00485 file_ << " <LogicalPart name=\""
00486 << name << "\" category=\"" << sensitive << "\">" << std::endl
00487 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
00488 << " <rMaterial name=\"" << opto->getMaterial()->getName() << "\""
00489 << "/>" << std::endl
00490 << " </LogicalPart>" << std::endl;
00491 }
00492
00493
00494 void CocoaToDDLMgr::newSectPost_lv(std::string name)
00495 {
00496 #ifdef gdebug
00497 cout << " sect-lv-post:" << name << '-'<< std::endl;
00498 #endif
00499 newSectPost("LogicalPartSection");
00500 }
00501
00502
00503
00504
00505 void CocoaToDDLMgr::newSectPre_pv(std::string name)
00506 {
00507 #ifdef gdebug
00508 cout << " sect-pv-pre:" << name << '-' << std::endl;
00509 #endif
00510 newSectPre(filename_,std::string("PosPartSection"));
00511 }
00512
00513
00514 void CocoaToDDLMgr::pv(OpticalObject * opto)
00515 {
00516 #ifdef gdebug_v
00517 cout << " pv:" << opto->name()
00518 << ':' << opto->parent()->name() << std::endl;
00519 #endif
00520
00521
00522 file_ << " <PosPart copyNumber=\"" << "1" << "\">" << std::endl;
00523 file_ << " <rParent name=\"";
00524
00525
00526
00527 file_ << opto->parent()->shortName() << "\"/>" << std::endl;
00528
00529 file_ << " <rChild name=\"";
00530
00531 file_ << opto->shortName();
00532 file_ << "\"/>" << std::endl;
00533
00534 int rotNumber = buildRotationNumber( opto );
00535
00536
00537 if( rotNumber != -1 ) file_ << " <rRotation name=\"R" << rotNumber << "\"/>" << std::endl;
00538
00539 CLHEP::Hep3Vector t = opto->centreLocal();
00540 if(t != CLHEP::Hep3Vector()) {
00541 const CLHEP::Hep3Vector t = opto->centreLocal();
00542
00543 file_ << " <Translation x=\"" << UC(t[0],"Length") << "\""
00544 << " y=\"" << UC(t[1],"Length") << "\""
00545 << " z=\"" << UC(t[2],"Length")<< "\" />"
00546 << std::endl;
00547 }
00548
00549 file_ << " </PosPart>" << std::endl;
00550
00551 }
00552
00553
00554 void CocoaToDDLMgr::newSectPost_pv(std::string name)
00555 {
00556 #ifdef gdebug
00557 cout << " sect-pv-post:" << name << '-' << std::endl;
00558 #endif
00559 newSectPost("PosPartSection");
00560 }
00561
00562
00563
00564
00565 void CocoaToDDLMgr::newSectPre_ro(std::string name)
00566 {
00567 newSectPre(filename_,std::string("RotationSection"));
00568 }
00569
00570
00571
00572 void CocoaToDDLMgr::ro(const CLHEP::HepRotation& ro, int n)
00573 {
00574
00575 CLHEP::HepRotation roinv = inverseOf(ro);
00576
00577
00578
00579 bool identity = false;
00580 ALIstring tag = " <Rotation name=\"R";
00581 identity=roinv.isIdentity();
00582
00583
00584 if (! identity) {
00585 file_ << tag << n << "\"";
00586 file_ << " phiX=\"" << UC(roinv.phiX(),"Angle") << "\""
00587 << " thetaX=\"" << UC(roinv.thetaX(),"Angle") << "\""
00588 << " phiY=\"" << UC(roinv.phiY(),"Angle") << "\""
00589 << " thetaY=\"" << UC(roinv.thetaY(),"Angle") << "\""
00590 << " phiZ=\"" << UC(roinv.phiZ(),"Angle") << "\""
00591 << " thetaZ=\"" << UC(roinv.thetaZ(),"Angle") << "\""
00592
00593 << " />" << std::endl;
00594 }
00595 }
00596
00597
00598 void CocoaToDDLMgr::newSectPost_ro(std::string name)
00599 {
00600 newSectPost("RotationSection");
00601 }
00602
00603
00604
00605
00606 void CocoaToDDLMgr::newSectPre_specPar(std::string name)
00607 {
00608 #ifdef gdebug
00609 cout << " sect-lv-pre:" << name << '-' << std::endl;
00610 #endif
00611
00612 file_ << "<SpecParSection label=\"" << filename_ << "\" eval=\"true\">" << std::endl;
00613
00614 }
00615
00616
00617
00618 void CocoaToDDLMgr::specPar(OpticalObject * opto)
00619 {
00620 file_ << " <SpecPar name=\"" << opto->name() << "_PARAMS\">" << std::endl;
00621 file_ << " <PartSelector path=\"/" << opto->name() << "\"/> " << std::endl;
00622 file_ << " <Parameter name=\"cocoa_type\"" << " value=\"" << opto->type() << "\" eval=\"false\" /> " << std::endl;
00623 file_ << " <Parameter name=\"cmssw_ID\"" << " value=\"" << opto->getCmsswID() << "\" /> " << std::endl;
00624
00625 const std::vector< Entry* > coord = opto->CoordinateEntryList();
00626 for( int ii=3; ii<6; ii++ ){
00627 Entry* ent = coord[ii];
00628 file_ << " <Parameter name=\"" << ent->name()+std::string("_value") << "\" value=\"";
00629 file_ << UC(ent->value(),"Angle");
00630 file_ << "\" /> " << std::endl;
00631 }
00632 for( int ii=0; ii<6; ii++ ){
00633 Entry* ent = coord[ii];
00634 file_ << " <Parameter name=\"" << ent->name()+std::string("_sigma") << "\" value=\"";
00635 if( ii < 3 ){
00636 file_ << UC(ent->sigma(),"Length");
00637 }else {
00638 file_ << UC(ent->sigma(),"Angle");
00639 }
00640 file_ << "\" /> " << std::endl;
00641 file_ << " <Parameter name=\"" << ent->name()+std::string("_quality") << "\" value=\"" << ent->quality() << "\" /> " << std::endl;
00642 }
00643
00644 const std::vector< Entry* > extraEnt = opto->ExtraEntryList();
00645 for( ALIuint ii=0; ii<extraEnt.size(); ii++ ){
00646 Entry* ent = extraEnt[ii];
00647 file_ << " <Parameter name=\"extra_entry\" value=\"" << ent->name() << "\" eval=\"false\" /> " << std::endl;
00648 file_ << " <Parameter name=\"dimType\" value=\"" << ent->type() << "\" eval=\"false\" /> " << std::endl;
00649 file_ << " <Parameter name=\"value\" value=\"";
00650 if( ent->type() == "nodim" ) {
00651 file_ << ent->value();
00652 }else if( ent->type() == "length" ) {
00653 file_ << UC(ent->value(),"Length");
00654 }else if( ent->type() == "angle" ) {
00655 file_ << UC(ent->value(),"Angle");
00656 }
00657 file_ << "\" eval=\"true\" /> " << std::endl;
00658
00659 file_ << " <Parameter name=\"sigma\" value=\"";
00660 if( ent->type() == "nodim" ) {
00661 file_ << ent->sigma();
00662 }else if( ent->type() == "length" ) {
00663 file_ << UC(ent->sigma(),"Length");
00664 }else if( ent->type() == "angle" ) {
00665 file_ << UC(ent->sigma(),"Angle");
00666 }
00667 file_ << "\" eval=\"true\" /> " << std::endl;
00668
00669 file_ << " <Parameter name=\"quality\" value=\"" << ent->quality() << "\" eval=\"true\" /> " << std::endl;
00670 }
00671
00672 file_ << " </SpecPar>" << std::endl;
00673
00674 }
00675
00676
00677 void CocoaToDDLMgr::measurementsAsSpecPars()
00678 {
00679
00680 std::vector< Measurement* > measlist = Model::MeasurementList();
00681 std::vector< Measurement* >::iterator mite;
00682 std::vector<ALIstring>::iterator site;
00683 std::multimap<OpticalObject*,Measurement*> optoMeasMap;
00684 for( mite = measlist.begin(); mite != measlist.end(); mite++ ) {
00685 auto &optolist = (*mite)->OptOList();
00686 OpticalObject* opto = optolist[optolist.size()-1];
00687 optoMeasMap.insert( std::multimap<OpticalObject*,Measurement*>::value_type(opto, *mite) );
00688 }
00689
00690 typedef std::multimap<OpticalObject*,Measurement*>::const_iterator itemom;
00691 itemom omite;
00692 std::pair<itemom, itemom > omitep;
00693 itemom omite2, omite3;
00694
00695 for( omite = optoMeasMap.begin(); omite != optoMeasMap.end(); omite++ ){
00696 omitep = optoMeasMap.equal_range( (*omite).first );
00697 if( omite != optoMeasMap.begin() && (*omite).first == (*omite3).first ) continue;
00698 omite3 = omite;
00699 for( omite2 = omitep.first; omite2 != omitep.second; omite2++ ){
00700 OpticalObject* opto = (*(omite2)).first;
00701 Measurement* meas = (*(omite2)).second;
00702 std::vector<ALIstring> namelist = meas->OptONameList();
00703 if( omite2 == omitep.first ){
00704 file_ << " <SpecPar name=\"" << meas->name() << "_MEASUREMENT\">" << std::endl;
00705 file_ << " <PartSelector path=\"/" << opto->name() << "\"/> " << std::endl;
00706 }
00707
00708 file_ << " <Parameter name=\"" << std::string("meas_name") << "\" value=\"" << meas->name() << "\" eval=\"false\" /> " << std::endl;
00709 file_ << " <Parameter name=\"" << std::string("meas_type") << "\" value=\"" << meas->type() << "\" eval=\"false\" /> " << std::endl;
00710 for( site = namelist.begin(); site != namelist.end(); site++ ){
00711 file_ << " <Parameter name=\"" << std::string("meas_object_name_")+meas->name() << "\" value=\"" << (*site) << "\" eval=\"false\" /> " << std::endl;
00712 }
00713 for( ALIuint ii = 0; ii < meas->dim(); ii++ ){
00714 file_ << " <Parameter name=\"" << std::string("meas_value_name_")+meas->name() << "\" value=\"" << meas->valueType(ii) << "\" eval=\"false\" /> " << std::endl;
00715 file_ << " <Parameter name=\"" << std::string("meas_value_")+meas->name() << "\" value=\"" << meas->value(ii) << "\" eval=\"true\" /> " << std::endl;
00716 file_ << " <Parameter name=\"" << std::string("meas_sigma_")+meas->name() << "\" value=\"" << meas->sigma(ii) << "\" eval=\"true\" /> " << std::endl;
00717 file_ << " <Parameter name=\"" << std::string("meas_is_simulated_value_")+meas->name() << "\" value=\"" << meas->valueIsSimulated(ii) << "\" eval=\"true\" /> " << std::endl;
00718 }
00719
00720 }
00721 file_ << " </SpecPar>" << std::endl;
00722 }
00723 }
00724
00725
00726
00727 void CocoaToDDLMgr::writeSpecParsCocoa()
00728 {
00729 file_ << "<!-- Define volumes as COCOA objects --> " << std::endl
00730 << " <SpecPar name=\"COCOA\"> " << std::endl;
00731
00732 auto &optolist = Model::OptOList();
00733 for(auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
00734 if( (*ite)->type() == "system" ) continue;
00735 file_ << " <PartSelector path=\"/" << (*ite)->name() << "\"/> " << std::endl;
00736 }
00737
00738 file_ << " <String name=\"COCOA\" value=\"COCOA\"/> " << std::endl
00739 << " </SpecPar> " << std::endl;
00740
00741 }
00742
00743
00744 void CocoaToDDLMgr::newSectPost_specPar(std::string name)
00745 {
00746 newSectPost("SpecParSection");
00747 }
00748
00749
00750
00751
00752
00753 void CocoaToDDLMgr::newSectPre(std::string name, std::string type)
00754 {
00755 file_ << "<" << type << " label=\"" << name << "\">" << std::endl;
00756 }
00757
00758
00759
00760 void CocoaToDDLMgr::newSectPost(std::string name)
00761 {
00762 file_ << "</" << name << ">" << std::endl << std::endl;
00763 }
00764
00765
00766
00767
00768 ALIbool CocoaToDDLMgr::materialIsRepeated( CocoaMaterialElementary* ma )
00769 {
00770 ALIbool isRepeated = false;
00771 std::vector<CocoaMaterialElementary*>::const_iterator ite;
00772
00773 for(ite = theMaterialList.begin(); ite != theMaterialList.end(); ite++ ){
00774 if( *(*ite) == *ma ){
00775 isRepeated = true;
00776 break;
00777 }
00778 }
00779
00780 return isRepeated;
00781 }
00782
00783
00784 std::string CocoaToDDLMgr::scrubString(const std::string& s)
00785 {
00786 std::string::const_iterator ampat;
00787 static const std::string amp = "_";
00788 std::string ret = "";
00789 for (ampat = s.begin(); ampat != s.end(); ampat++)
00790 {
00791 if (*ampat == '&')
00792 ret = ret + amp;
00793 else if (*ampat == '/')
00794 ret = ret + ";";
00795 else if (*ampat == ':')
00796 ret = ret + '_';
00797 else
00798 ret = ret + *ampat;
00799 }
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 return ret;
00811 }
00812
00813
00814
00815 ALIint CocoaToDDLMgr::buildRotationNumber( OpticalObject* opto )
00816 {
00817 ALIint rotnum = -1;
00818
00819 if(opto->rmLocal().isIdentity() ) return rotnum;
00820
00821 std::vector<CLHEP::HepRotation>::const_iterator ite;
00822
00823 int nc = 0;
00824 for( ite = theRotationList.begin(); ite != theRotationList.end(); ite++) {
00825 if( (*ite) == opto->rmLocal() ) {
00826 rotnum = nc;
00827 break;
00828 }
00829 nc++;
00830 }
00831
00832 if( rotnum == -1 ) {
00833 theRotationList.push_back( opto->rmLocal() );
00834 rotnum = theRotationList.size()-1;
00835 }
00836
00837 return rotnum;
00838
00839 }
00840