/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Geometry/TrackerCommonData/test/tex2xml.pl
64 строки
1 KB
Andres Vargas
Move to `test` folder instead see: https://github.com/cms-sw/cmssw/pull/26609#issuecomment-490859417
20 май 2019, 18:42
20 май 2019, 18:42
613fb79
Код
Авторство
О чём код?
#!/usr/local/bin/perl ## Usage: ## cat yourtexfile | ./tex2xml > newmaterials.xml while (<>) { if(/ Norm. mixture density \[g\/cm\$\^3\$] &\s* ([\d\.]+)\s*/ ) { $density=$1; print "\n"; print " <CompositeMaterial name=\"$material\" density=\"$density*g/cm3\" symbol=\" \" method=\"mixture by weight\">\n"; $i=0; $tot=0; while (($compsname, $compsperc) = each(%comps)) # while($i<$ncomp) { print " <MaterialFraction fraction=\"".$compsperc."\">\n"; print " <rMaterial name=\"materials:".$compsname."\"/>\n"; print " </MaterialFraction>\n"; $tot+=$compsperc; $i++; } print " </CompositeMaterial>\n"; # print STDERR "Total fraction is: ".$tot."\n"; if(abs($tot-1) > 0.001 ) { die "ERROR: total fraction is ".$tot; } $flushed=1; } if(/Material name:\s*([\w\\]+)/) #new mixture # OLD: if(/Material name: ([\w\\]+)/) #new mixture { $flushed=0; # @compsname = (); %comps = (); $ncomp =0; $material = $1; $material =~ s/\\//g; #print "New material: ".$material."\n"; $inmaterial=1; } if(/^(\s*[0-9]+\s*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)&(.*)/) { $compsname = $3; $compsperc = $7; $compsperc =~ s/\s*//g; $compsperc /= 100; $compsname =~ s/^\s*//; $compsname =~ s/\s*$//; $compsname =~ s/\\//g; $comps{$compsname} += $compsperc; $ncomp++; } if(/\\end{tabular}/) { $inmaterial=0; $density=-1; } }