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 static std::vector< OpticalObject* > optolist = Model::OptOList();
00073 static std::vector< OpticalObject* >::const_iterator ite;
00074 for(ite = optolist.begin(); ite != optolist.end(); ite++ ){
00075 if( (*ite)->type() == "system" ) continue;
00076 CocoaMaterialElementary* mat = (*ite)->getMaterial();
00077
00078 if( mat ) {
00079 if( !materialIsRepeated( mat ) ) ma( mat );
00080 }
00081 }
00082
00083 newSectPost_ma("");
00084 }
00085
00086
00087 void CocoaToDDLMgr::writeSolids()
00088 {
00089 newSectPre_so("");
00090
00091 static std::vector< OpticalObject* > optolist = Model::OptOList();
00092 static std::vector< OpticalObject* >::const_iterator ite,ite2;
00093 for(ite = optolist.begin(); ite != optolist.end(); ite++ ){
00094 bool alreadyWritten = false;
00095 for(ite2 = optolist.begin(); ite2 != ite; ite2++ ){
00096 if( (*ite)->shortName() == (*ite2)->shortName() ) {
00097 alreadyWritten = true;
00098 }
00099 }
00100 std::cout << " CocoaToDDLMgr::writeSolids() " << alreadyWritten << *ite;
00101 std::cout << (*ite)->name() << std::endl;
00102 if( !alreadyWritten ) so( *ite );
00103 }
00104
00105 newSectPost_so("");
00106
00107 }
00108
00109
00110 void CocoaToDDLMgr::writeLogicalVolumes()
00111 {
00112 newSectPre_lv("");
00113
00114 static std::vector< OpticalObject* > optolist = Model::OptOList();
00115 static std::vector< OpticalObject* >::const_iterator ite,ite2;
00116 for(ite = optolist.begin(); ite != optolist.end(); ite++ ){
00117 bool alreadyWritten = false;
00118 for(ite2 = optolist.begin(); ite2 != ite; ite2++ ){
00119 if( (*ite)->shortName() == (*ite2)->shortName() ) {
00120 alreadyWritten = true;
00121 }
00122 }
00123 if( !alreadyWritten ) lv( *ite );
00124 }
00125
00126 newSectPost_lv("");
00127
00128 }
00129
00130
00131 void CocoaToDDLMgr::writePhysicalVolumes()
00132 {
00133 newSectPre_pv("");
00134
00135 static std::vector< OpticalObject* > optolist = Model::OptOList();
00136 static std::vector< OpticalObject* >::const_iterator ite;
00137 for(ite = optolist.begin(); ite != optolist.end(); ite++ ){
00138 if( (*ite)->type() == "system" ) continue;
00139 pv( *ite );
00140 }
00141
00142 newSectPost_pv("");
00143
00144 }
00145
00146
00147
00148 void CocoaToDDLMgr::writeRotations()
00149 {
00150 newSectPre_ro("");
00151 std::vector<CLHEP::HepRotation>::const_iterator ite;
00152 int nc = 0;
00153 for( ite = theRotationList.begin(); ite != theRotationList.end(); ite++) {
00154
00155 ro( *ite, nc );
00156 nc++;
00157 }
00158 newSectPost_ro("");
00159
00160 }
00161
00162
00163 void CocoaToDDLMgr::writeSpecPars()
00164 {
00165 newSectPre_specPar("");
00166
00167 static std::vector< OpticalObject* > optolist = Model::OptOList();
00168 static std::vector< OpticalObject* >::const_iterator ite;
00169 for(ite = optolist.begin(); ite != optolist.end(); ite++ ){
00170 if( (*ite)->type() == "system" ) continue;
00171 specPar( *ite );
00172 }
00173
00174 writeSpecParsCocoa();
00175
00176
00177 measurementsAsSpecPars();
00178
00179
00180 newSectPost_specPar("");
00181
00182
00183 }
00184
00185
00186
00187
00188
00189 void CocoaToDDLMgr::newPartPre(std::string name)
00190 {
00191 filename_=name;
00192 file_.open(filename_.c_str());
00193 file_.precision(8);
00194 file_ << "<?xml version=\"1.0\"?>" << std::endl;
00195
00196
00197 file_ << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\""
00198 << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
00199 << " xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../DDLSchema/DDLSchema.xsd\">"
00200 << std::endl << std::endl;
00201
00202 #ifdef gdebug
00203 cout << "part-pre:" << name << std::endl;
00204 #endif
00205 }
00206
00207
00208 void CocoaToDDLMgr::newPartPost(std::string name, std::string extension)
00209 {
00210 file_ << std::endl << "</DDDefinition>" << std::endl;
00211 file_.close();
00212 }
00213
00214
00215
00216
00217 void CocoaToDDLMgr::newSectPre_ma(std::string name)
00218 {
00219 #ifdef gdebug
00220 std::cout << " sect-mat-pre:" << name << '-' << std::endl;
00221 #endif
00222 newSectPre(filename_,std::string("MaterialSection"));
00223 }
00224
00225
00226 void CocoaToDDLMgr::ma(CocoaMaterialElementary* ma)
00227 {
00228 theMaterialList.push_back( ma );
00229
00230 #ifdef gdebug
00231 cout << " ma:" << ma->getName() << std::endl;
00232 #endif
00233
00234 ALIfloat density = ma->getDensity();
00235
00236
00237 file_ << " <ElementaryMaterial";
00238 ALIstring cSymbol = ma->getSymbol();
00239
00240
00241 file_ << " name=\"" << ma->getName() << "\"";
00242
00243
00244
00245 file_ << " density=\"" << UC(density,"Volumic Mass") << "\"";
00246 file_ << " symbol=\"" << ma->getSymbol() << "\"";
00247
00248
00249
00250 file_ << " atomicWeight=\"" << (ma->getA()) << "*g/mole\""
00251 << " atomicNumber=\"" << ma->getZ() << "\""
00252 << "/>" << std::endl;
00253
00254 }
00255
00256
00257 void CocoaToDDLMgr::newSectPost_ma(std::string name)
00258 {
00259 #ifdef gdebug
00260 cout << " sect-mat-post:" << name << '-' << std::endl;
00261 #endif
00262 newSectPost("MaterialSection");
00263 }
00264
00265
00266
00267
00268 void CocoaToDDLMgr::newSectPre_so(std::string name)
00269 {
00270 #ifdef gdebug
00271 cout << " sect-so-pre:" << name << '-' << std::endl;
00272 #endif
00273 newSectPre(filename_,std::string("SolidSection"));
00274 }
00275
00276
00277 void CocoaToDDLMgr::so(OpticalObject * opto)
00278 {
00279 std::cout << " CocoaToDDLMgr::so( " << opto;
00280 std::cout << " " << opto->shortName() << std::endl;
00281
00282 std::string name = opto->shortName();
00283
00284 if( opto->type() == "system" ){
00285
00286 file_ << " <Box name=\"" << opto->name() << "\"";
00287 file_ << " dx=\"10.*m"
00288 << "\" dy=\"10.*m"
00289 << "\" dz=\"10.*m"
00290 << "\"/>" << std::endl;
00291 return;
00292 }
00293
00294 CocoaSolidShape* so = opto->getSolidShape();
00295
00296 std::cout << " CocoaToDDLMgr::so( so " << so << std::endl;
00297 std::string solidType = so->getType();
00298
00299 if (solidType == "Box")
00300 {
00301 file_ << " <" << solidType << " name=\"" << name << "\"";
00302 CocoaSolidShapeBox * sb = dynamic_cast<CocoaSolidShapeBox*>(so);
00303 file_ << " dx=\"" << UC(sb->getXHalfLength(),"Length")
00304 << "\" dy=\"" << UC(sb->getYHalfLength(),"Length")
00305 << "\" dz=\"" << UC(sb->getZHalfLength(),"Length")
00306 << "\"/>" << std::endl;
00307 }
00308 else if (solidType == "Tubs")
00309 {
00310 CocoaSolidShapeTubs * tu = dynamic_cast < CocoaSolidShapeTubs * > (so);
00311 file_ << " <" << solidType
00312 << " name=\"" << name << "\""
00313 << " rMin=\"" << UC(tu->getInnerRadius(),"Length") << "\""
00314 << " rMax=\"" << UC(tu->getOuterRadius(),"Length") << "\""
00315 << " dz=\"" << UC(tu->getZHalfLength(),"Length") << "\""
00316 << " startPhi=\"" << UC(tu->getStartPhiAngle(),"Angle") << "\""
00317 << " deltaPhi=\"" << UC(tu->getDeltaPhiAngle(),"Angle") << "\""
00318 << "/>" << std::endl;
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
00436
00437
00438
00439
00440 else
00441 {
00442 std::cerr << " <!-- NOT HANDLED: " << solidType << " name=\"" << name<< "\""
00443 << ">" << std::endl
00444 << " </" << solidType << "> -->" << std::endl;
00445 std::exception();
00446 }
00447
00448 }
00449
00450
00451 void CocoaToDDLMgr::newSectPost_so(std::string name)
00452 {
00453 #ifdef gdebug
00454 cout << " sect-so-post:" << name << '-' << std::endl;
00455 #endif
00456 newSectPost("SolidSection");
00457 }
00458
00459
00460
00461
00462 void CocoaToDDLMgr::newSectPre_lv(std::string name)
00463 {
00464 #ifdef gdebug
00465 cout << " sect-lv-pre:" << name << '-' << std::endl;
00466 #endif
00467 newSectPre(filename_,std::string("LogicalPartSection"));
00468 }
00469
00470
00471 void CocoaToDDLMgr::lv(OpticalObject * opto)
00472 {
00473 std::string name = opto->shortName();
00474 std::string rSolid = opto->shortName();
00475 std::string sensitive = "unspecified";
00476
00477 if( opto->type() == "system" ){
00478 file_ << " <LogicalPart name=\""
00479 << name << "\" category=\"" << sensitive << "\">" << std::endl
00480 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
00481 << " <rMaterial name=\"Hydrogen\""
00482 << "/>" << std::endl
00483 << " </LogicalPart>" << std::endl;
00484 return;
00485 }
00486
00487 #ifdef gdebug_v
00488 cout << "xml:lv " << opto->name() << std::endl;
00489 #endif
00490 file_ << " <LogicalPart name=\""
00491 << name << "\" category=\"" << sensitive << "\">" << std::endl
00492 << " <rSolid name=\"" << rSolid << "\"/>" << std::endl
00493 << " <rMaterial name=\"" << opto->getMaterial()->getName() << "\""
00494 << "/>" << std::endl
00495 << " </LogicalPart>" << std::endl;
00496 }
00497
00498
00499 void CocoaToDDLMgr::newSectPost_lv(std::string name)
00500 {
00501 #ifdef gdebug
00502 cout << " sect-lv-post:" << name << '-'<< std::endl;
00503 #endif
00504 newSectPost("LogicalPartSection");
00505 }
00506
00507
00508
00509
00510 void CocoaToDDLMgr::newSectPre_pv(std::string name)
00511 {
00512 #ifdef gdebug
00513 cout << " sect-pv-pre:" << name << '-' << std::endl;
00514 #endif
00515 newSectPre(filename_,std::string("PosPartSection"));
00516 }
00517
00518
00519 void CocoaToDDLMgr::pv(OpticalObject * opto)
00520 {
00521 #ifdef gdebug_v
00522 cout << " pv:" << opto->name()
00523 << ':' << opto->parent()->name() << std::endl;
00524 #endif
00525
00526
00527 file_ << " <PosPart copyNumber=\"" << "1" << "\">" << std::endl;
00528 file_ << " <rParent name=\"";
00529
00530
00531
00532 file_ << opto->parent()->shortName() << "\"/>" << std::endl;
00533
00534 file_ << " <rChild name=\"";
00535
00536 file_ << opto->shortName();
00537 file_ << "\"/>" << std::endl;
00538
00539 int rotNumber = buildRotationNumber( opto );
00540
00541
00542 if( rotNumber != -1 ) file_ << " <rRotation name=\"R" << rotNumber << "\"/>" << std::endl;
00543
00544 CLHEP::Hep3Vector t = opto->centreLocal();
00545 if(t != CLHEP::Hep3Vector()) {
00546 const CLHEP::Hep3Vector t = opto->centreLocal();
00547
00548 file_ << " <Translation x=\"" << UC(t[0],"Length") << "\""
00549 << " y=\"" << UC(t[1],"Length") << "\""
00550 << " z=\"" << UC(t[2],"Length")<< "\" />"
00551 << std::endl;
00552 }
00553
00554 file_ << " </PosPart>" << std::endl;
00555
00556 }
00557
00558
00559 void CocoaToDDLMgr::newSectPost_pv(std::string name)
00560 {
00561 #ifdef gdebug
00562 cout << " sect-pv-post:" << name << '-' << std::endl;
00563 #endif
00564 newSectPost("PosPartSection");
00565 }
00566
00567
00568
00569
00570 void CocoaToDDLMgr::newSectPre_ro(std::string name)
00571 {
00572 newSectPre(filename_,std::string("RotationSection"));
00573 }
00574
00575
00576
00577 void CocoaToDDLMgr::ro(const CLHEP::HepRotation& ro, int n)
00578 {
00579
00580 CLHEP::HepRotation roinv = inverseOf(ro);
00581
00582
00583
00584 bool identity = false;
00585 ALIstring tag = " <Rotation name=\"R";
00586 identity=roinv.isIdentity();
00587
00588
00589 if (! identity) {
00590 file_ << tag << n << "\"";
00591 file_ << " phiX=\"" << UC(roinv.phiX(),"Angle") << "\""
00592 << " thetaX=\"" << UC(roinv.thetaX(),"Angle") << "\""
00593 << " phiY=\"" << UC(roinv.phiY(),"Angle") << "\""
00594 << " thetaY=\"" << UC(roinv.thetaY(),"Angle") << "\""
00595 << " phiZ=\"" << UC(roinv.phiZ(),"Angle") << "\""
00596 << " thetaZ=\"" << UC(roinv.thetaZ(),"Angle") << "\""
00597
00598 << " />" << std::endl;
00599 }
00600 }
00601
00602
00603 void CocoaToDDLMgr::newSectPost_ro(std::string name)
00604 {
00605 newSectPost("RotationSection");
00606 }
00607
00608
00609
00610
00611 void CocoaToDDLMgr::newSectPre_specPar(std::string name)
00612 {
00613 #ifdef gdebug
00614 cout << " sect-lv-pre:" << name << '-' << std::endl;
00615 #endif
00616
00617 file_ << "<SpecParSection label=\"" << filename_ << "\" eval=\"true\">" << std::endl;
00618
00619 }
00620
00621
00622
00623 void CocoaToDDLMgr::specPar(OpticalObject * opto)
00624 {
00625 file_ << " <SpecPar name=\"" << opto->name() << "_PARAMS\">" << std::endl;
00626 file_ << " <PartSelector path=\"/" << opto->name() << "\"/> " << std::endl;
00627 file_ << " <Parameter name=\"cocoa_type\"" << " value=\"" << opto->type() << "\" eval=\"false\" /> " << std::endl;
00628 file_ << " <Parameter name=\"cmssw_ID\"" << " value=\"" << opto->getCmsswID() << "\" /> " << 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( ALIuint 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( ALIuint 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<CLHEP::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