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