9 #define UC(val,category) UnitConverter(val,category).ucstring() 73 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
74 if( (*ite)->type() ==
"system" )
continue;
91 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
92 bool alreadyWritten =
false;
93 for(
auto ite2 = optolist.begin(); ite2 != ite; ite2++ ){
94 if( (*ite)->shortName() == (*ite2)->shortName() ) {
95 alreadyWritten =
true;
98 std::cout <<
" CocoaToDDLMgr::writeSolids() " << alreadyWritten << *ite;
100 if( !alreadyWritten )
so( *ite );
113 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
114 bool alreadyWritten =
false;
115 for(
auto ite2 = optolist.begin(); ite2 != ite; ite2++ ){
116 if( (*ite)->shortName() == (*ite2)->shortName() ) {
117 alreadyWritten =
true;
120 if( !alreadyWritten )
lv( *ite );
133 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
134 if( (*ite)->type() ==
"system" )
continue;
147 std::vector<CLHEP::HepRotation>::const_iterator ite;
164 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
165 if( (*ite)->type() ==
"system" )
continue;
189 file_ <<
"<?xml version=\"1.0\"?>" << std::endl;
192 file_ <<
"<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"" 193 <<
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" 194 <<
" xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../DDLSchema/DDLSchema.xsd\">" 195 << std::endl << std::endl;
198 cout <<
"part-pre:" << name << std::endl;
205 file_ << std::endl <<
"</DDDefinition>" << std::endl;
215 std::cout <<
" sect-mat-pre:" << name <<
'-' << std::endl;
232 file_ <<
" <ElementaryMaterial";
240 file_ <<
" density=\"" <<
UC(density,
"Volumic Mass") <<
"\"";
245 file_ <<
" atomicWeight=\"" << (ma->
getA()) <<
"*g/mole\"" 246 <<
" atomicNumber=\"" << ma->
getZ() <<
"\"" 247 <<
"/>" << std::endl;
255 cout <<
" sect-mat-post:" << name <<
'-' << std::endl;
266 cout <<
" sect-so-pre:" << name <<
'-' << std::endl;
274 std::cout <<
" CocoaToDDLMgr::so( " << opto;
275 std::cout <<
" " << opto->shortName() << std::endl;
279 if( opto->type() ==
"system" ){
281 file_ <<
" <Box name=\"" << opto->
name() <<
"\"";
282 file_ <<
" dx=\"10.*m" 285 <<
"\"/>" << std::endl;
291 std::cout <<
" CocoaToDDLMgr::so( so " << so << std::endl;
294 if (solidType ==
"Box")
296 file_ <<
" <" << solidType <<
" name=\"" << name <<
"\"";
301 <<
"\"/>" << std::endl;
303 else if (solidType ==
"Tubs")
306 file_ <<
" <" << solidType
307 <<
" name=\"" << name <<
"\"" 313 <<
"/>" << std::endl;
437 std::cerr <<
" <!-- NOT HANDLED: " << solidType <<
" name=\"" << name<<
"\"" 439 <<
" </" << solidType <<
"> -->" << std::endl;
449 cout <<
" sect-so-post:" << name <<
'-' << std::endl;
460 cout <<
" sect-lv-pre:" << name <<
'-' << std::endl;
472 if( opto->
type() ==
"system" ){
473 file_ <<
" <LogicalPart name=\"" 474 << name <<
"\" category=\"" << sensitive <<
"\">" << std::endl
475 <<
" <rSolid name=\"" << rSolid <<
"\"/>" << std::endl
476 <<
" <rMaterial name=\"Hydrogen\"" 478 <<
" </LogicalPart>" << std::endl;
483 cout <<
"xml:lv " << opto->
name() << std::endl;
485 file_ <<
" <LogicalPart name=\"" 486 << name <<
"\" category=\"" << sensitive <<
"\">" << std::endl
487 <<
" <rSolid name=\"" << rSolid <<
"\"/>" << std::endl
490 <<
" </LogicalPart>" << std::endl;
497 cout <<
" sect-lv-post:" << name <<
'-'<< std::endl;
508 cout <<
" sect-pv-pre:" << name <<
'-' << std::endl;
518 <<
':' << opto->
parent()->
name() << std::endl;
522 file_ <<
" <PosPart copyNumber=\"" <<
"1" <<
"\">" << std::endl;
523 file_ <<
" <rParent name=\"";
529 file_ <<
" <rChild name=\"";
532 file_ <<
"\"/>" << std::endl;
537 if( rotNumber != -1 )
file_ <<
" <rRotation name=\"R" << rotNumber <<
"\"/>" << std::endl;
540 if(t != CLHEP::Hep3Vector()) {
543 file_ <<
" <Translation x=\"" <<
UC(t[0],
"Length") <<
"\"" 544 <<
" y=\"" <<
UC(t[1],
"Length") <<
"\"" 545 <<
" z=\"" <<
UC(t[2],
"Length")<<
"\" />" 549 file_ <<
" </PosPart>" << std::endl;
557 cout <<
" sect-pv-post:" << name <<
'-' << std::endl;
575 CLHEP::HepRotation roinv = inverseOf(ro);
579 bool identity =
false;
581 identity=roinv.isIdentity();
585 file_ << tag << n <<
"\"";
586 file_ <<
" phiX=\"" <<
UC(roinv.phiX(),
"Angle") <<
"\"" 587 <<
" thetaX=\"" <<
UC(roinv.thetaX(),
"Angle") <<
"\"" 588 <<
" phiY=\"" <<
UC(roinv.phiY(),
"Angle") <<
"\"" 589 <<
" thetaY=\"" <<
UC(roinv.thetaY(),
"Angle") <<
"\"" 590 <<
" phiZ=\"" <<
UC(roinv.phiZ(),
"Angle") <<
"\"" 591 <<
" thetaZ=\"" <<
UC(roinv.thetaZ(),
"Angle") <<
"\"" 593 <<
" />" << std::endl;
609 cout <<
" sect-lv-pre:" << name <<
'-' << std::endl;
612 file_ <<
"<SpecParSection label=\"" <<
filename_ <<
"\" eval=\"true\">" << std::endl;
620 file_ <<
" <SpecPar name=\"" << opto->
name() <<
"_PARAMS\">" << std::endl;
621 file_ <<
" <PartSelector path=\"/" << opto->
name() <<
"\"/> " << std::endl;
622 file_ <<
" <Parameter name=\"cocoa_type\"" <<
" value=\"" << opto->
type() <<
"\" eval=\"false\" /> " << std::endl;
623 file_ <<
" <Parameter name=\"cmssw_ID\"" <<
" value=\"" << opto->
getCmsswID() <<
"\" /> " << std::endl;
626 for(
int ii=3;
ii<6;
ii++ ){
630 file_ <<
"\" /> " << std::endl;
632 for(
int ii=0;
ii<6;
ii++ ){
640 file_ <<
"\" /> " << std::endl;
647 file_ <<
" <Parameter name=\"extra_entry\" value=\"" << ent->
name() <<
"\" eval=\"false\" /> " << std::endl;
648 file_ <<
" <Parameter name=\"dimType\" value=\"" << ent->
type() <<
"\" eval=\"false\" /> " << std::endl;
649 file_ <<
" <Parameter name=\"value\" value=\"";
650 if( ent->
type() ==
"nodim" ) {
652 }
else if( ent->
type() ==
"length" ) {
654 }
else if( ent->
type() ==
"angle" ) {
657 file_ <<
"\" eval=\"true\" /> " << std::endl;
659 file_ <<
" <Parameter name=\"sigma\" value=\"";
660 if( ent->
type() ==
"nodim" ) {
662 }
else if( ent->
type() ==
"length" ) {
664 }
else if( ent->
type() ==
"angle" ) {
667 file_ <<
"\" eval=\"true\" /> " << std::endl;
669 file_ <<
" <Parameter name=\"quality\" value=\"" << ent->
quality() <<
"\" eval=\"true\" /> " << std::endl;
672 file_ <<
" </SpecPar>" << std::endl;
681 std::vector< Measurement* >::iterator mite;
682 std::vector<ALIstring>::iterator site;
683 std::multimap<OpticalObject*,Measurement*> optoMeasMap;
684 for( mite = measlist.begin(); mite != measlist.end(); ++mite ) {
685 auto &optolist = (*mite)->OptOList();
690 typedef std::multimap<OpticalObject*,Measurement*>::const_iterator itemom;
692 std::pair<itemom, itemom > omitep;
693 itemom omite2, omite3;
695 for( omite = optoMeasMap.begin(); omite != optoMeasMap.end(); ++omite ){
696 omitep = optoMeasMap.equal_range( (*omite).first );
697 if( omite != optoMeasMap.begin() && (*omite).first == (*omite3).first )
continue;
699 for( omite2 = omitep.first; omite2 != omitep.second; ++omite2 ){
703 if( omite2 == omitep.first ){
704 file_ <<
" <SpecPar name=\"" << meas->
name() <<
"_MEASUREMENT\">" << std::endl;
705 file_ <<
" <PartSelector path=\"/" << opto->
name() <<
"\"/> " << std::endl;
708 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_name") <<
"\" value=\"" << meas->
name() <<
"\" eval=\"false\" /> " << std::endl;
709 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_type") <<
"\" value=\"" << meas->
type() <<
"\" eval=\"false\" /> " << std::endl;
710 for( site = namelist.begin(); site != namelist.end(); ++site ){
711 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_object_name_")+meas->
name() <<
"\" value=\"" << (*site) <<
"\" eval=\"false\" /> " << std::endl;
714 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_value_name_")+meas->
name() <<
"\" value=\"" << meas->
valueType(
ii) <<
"\" eval=\"false\" /> " << std::endl;
715 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_value_")+meas->
name() <<
"\" value=\"" << meas->
value(
ii) <<
"\" eval=\"true\" /> " << std::endl;
716 file_ <<
" <Parameter name=\"" <<
std::string(
"meas_sigma_")+meas->
name() <<
"\" value=\"" << meas->
sigma(
ii) <<
"\" eval=\"true\" /> " << std::endl;
721 file_ <<
" </SpecPar>" << std::endl;
729 file_ <<
"<!-- Define volumes as COCOA objects --> " << std::endl
730 <<
" <SpecPar name=\"COCOA\"> " << std::endl;
733 for(
auto ite = optolist.begin(); ite != optolist.end(); ite++ ){
734 if( (*ite)->type() ==
"system" )
continue;
735 file_ <<
" <PartSelector path=\"/" << (*ite)->
name() <<
"\"/> " << std::endl;
738 file_ <<
" <String name=\"COCOA\" value=\"COCOA\"/> " << std::endl
739 <<
" </SpecPar> " << std::endl;
755 file_ <<
"<" << type <<
" label=\"" << name <<
"\">" << std::endl;
762 file_ <<
"</" << name <<
">" << std::endl << std::endl;
771 std::vector<CocoaMaterialElementary*>::const_iterator ite;
774 if( *(*ite) == *
ma ){
786 std::string::const_iterator ampat;
789 for (ampat = s.begin(); ampat != s.end(); ++ampat)
793 else if (*ampat ==
'/')
795 else if (*ampat ==
':')
819 if(opto->
rmLocal().isIdentity() )
return rotnum;
821 std::vector<CLHEP::HepRotation>::const_iterator ite;
825 if( (*ite) == opto->
rmLocal() ) {
ALIfloat getOuterRadius() const
void specPar(OpticalObject *opto)
const ALIuint getCmsswID() const
void newSectPost_pv(std::string name)
void newSectPre_so(std::string name)
void pv(OpticalObject *opto)
void newSectPost_ro(std::string name)
CocoaMaterialElementary * getMaterial() const
const ALIstring & type() const
void newSectPost_so(std::string name)
void newSectPre_lv(std::string name)
void writeLogicalVolumes()
bool valueIsSimulated(ALIint coor)
const ALIuint dim() const
const std::vector< Entry * > & ExtraEntryList() const
const ALIstring valueType(ALIuint ii) const
const CLHEP::HepRotation rmLocal() const
ALIbool materialIsRepeated(CocoaMaterialElementary *ma)
void writeHeader(ALIstring filename)
ALIstring getSymbol() const
const std::vector< Entry * > & CoordinateEntryList() const
void newSectPre(std::string name, std::string type)
void newPartPost(std::string name, std::string extension)
void newPartPre(std::string name)
ALIfloat getStartPhiAngle() const
void writeSpecParsCocoa()
ALIstring getType() const
ALIstring getName() const
void newSectPre_ma(std::string name)
ALIfloat getZHalfLength() const
void writeDDDFile(ALIstring filename)
void lv(OpticalObject *opto)
void writePhysicalVolumes()
static CocoaToDDLMgr * instance
void measurementsAsSpecPars()
Container::value_type value_type
const CLHEP::Hep3Vector centreLocal() const
ALIfloat getDeltaPhiAngle() const
const ALIdouble * sigma() const
#define UC(val, category)
const OpticalObject * parent() const
const std::vector< ALIstring > & OptONameList() const
std::vector< CocoaMaterialElementary * > theMaterialList
ALIfloat getYHalfLength() const
void newSectPre_pv(std::string name)
ALIfloat getInnerRadius() const
static CocoaToDDLMgr * getInstance()
std::string scrubString(const std::string &s)
std::vector< CLHEP::HepRotation > theRotationList
ALIfloat getXHalfLength() const
static std::vector< OpticalObject * > & OptOList()
void newSectPost_specPar(std::string name)
const ALIstring & name() const
void ma(CocoaMaterialElementary *ma)
void ro(const CLHEP::HepRotation &ro, int n)
void so(OpticalObject *opto)
const ALIdouble * value() const
const ALIstring shortName() const
const ALIstring & type() const
ALIint buildRotationNumber(OpticalObject *opto)
void newSectPre_specPar(std::string name)
const ALIstring & name() const
const ALIstring & name() const
void newSectPost_ma(std::string name)
void newSectPost(std::string name)
void newSectPre_ro(std::string name)
static std::vector< Measurement * > & MeasurementList()
ALIfloat getZHalfLength() const
void newSectPost_lv(std::string name)
const ALIstring & type() const