File indexing completed on 2024-04-06 11:57:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 use strict;
0023
0024
0025 $|=1;
0026
0027
0028
0029
0030
0031
0032 my $baseUrl = "http://hep.fi.infn.it/CMS/software/CMS_Geometry/Programs/";
0033 my $nTibLayers = 4;
0034 my $nTidDisks = 3;
0035 my $nTidRings = 3;
0036
0037
0038 my $outputFile = "NewSurvey.dat";
0039
0040
0041 require LWP::UserAgent;
0042 my $ua = LWP::UserAgent->new;
0043
0044
0045 my @strSides = ( "int", "ext" );
0046 my @zSides = ( "-", "+" );
0047
0048
0049 my $TIBoutput = "TIB".$outputFile;
0050 open( OUTPUT,">$TIBoutput" ) or die "Couldn't open $TIBoutput: $!";
0051
0052 print "Writing output to $TIBoutput\n";
0053
0054 for ( my $iLayer = 1; $iLayer <= $nTibLayers; $iLayer++ ) {
0055 foreach my $zSide ( @zSides ) {
0056 foreach my $strSide ( @strSides ) {
0057
0058 my $name = "TIB".$zSide."_Layer".$iLayer."_".$strSide;
0059
0060 print " Processing $name...";
0061
0062
0063 my $geomUrl = $baseUrl."/".$name."/datafiles/".$name."_geometry.dat";
0064 my $gResponse = $ua->get($geomUrl);
0065 die $gResponse->status_line if ( !$gResponse->is_success );
0066 my $geometry = $gResponse->content();
0067
0068
0069 my $surveyUrl = $baseUrl."/".$name."/datafiles/".$name."_survey.dat";
0070 my $sResponse = $ua->get($surveyUrl);
0071 die $sResponse->status_line if ( !$sResponse->is_success );
0072 my $survey = $sResponse->content();
0073
0074 my @geomData = &extractData( $geometry );
0075 my @surveyData = &extractData( $survey );
0076 my @id = ( $iLayer, ($zSide=~/-/?1:2), ($strSide=~/int/?1:2) );
0077
0078 &printOut( \@id, \@geomData, \@surveyData );
0079
0080 print " done\n";
0081 }
0082 }
0083 }
0084
0085 close(OUTPUT) or die "Couldn't close $TIBoutput: $!";
0086 print $TIBoutput." all done\n";
0087
0088
0089
0090 my @dSides = ( "back", "front" );
0091
0092 my $TIDoutput = "TID".$outputFile;
0093 open ( OUTPUT,">$TIDoutput" ) or die "Couldn't open $TIDoutput: $!";
0094
0095
0096 for ( my $iRing = 1; $iRing<=$nTidRings; $iRing++ ) {
0097 for ( my $iDisk = 1; $iDisk<=$nTidDisks; $iDisk++ ) {
0098 foreach my $zSide ( @zSides ) {
0099 foreach my $dSide ( @dSides ) {
0100
0101
0102 my $name = "TID".$zSide."_Ring".$iRing."_Disk".$iDisk."_".$dSide;
0103
0104
0105
0106
0107
0108
0109
0110 print " Processing $name...";
0111
0112
0113 my $geomUrl = $baseUrl."/".$name."/datafiles/".$name."_geometry.dat";
0114 my $gResponse = $ua->get($geomUrl);
0115 die $gResponse->status_line if ( !$gResponse->is_success );
0116 my $geometry = $gResponse->content();
0117
0118
0119 my $surveyUrl = $baseUrl."/".$name."/datafiles/".$name."_survey.dat";
0120 my $sResponse = $ua->get($surveyUrl);
0121 die $sResponse->status_line if ( !$sResponse->is_success );
0122 my $survey = $sResponse->content();
0123
0124 my @geomData = &extractData( $geometry );
0125 my @surveyData = &extractData( $survey );
0126 my @id = ( ($zSide=~/-/?1:2), $iDisk, $iRing, ($dSide=~/back/?1:2) );
0127
0128 &printOut( \@id, \@geomData, \@surveyData );
0129
0130 print " done\n";
0131 }
0132 }
0133 }
0134 }
0135
0136
0137
0138
0139 sub extractData {
0140
0141 my $data = shift;
0142
0143 my @lines = split( "\n", $data );
0144
0145 shift @lines;
0146
0147 return sort byStringMod @lines;
0148
0149 }
0150
0151
0152
0153
0154 sub byStringMod {
0155
0156 my @afields = split( /\s+/, $a );
0157 my @bfields = split( /\s+/, $b );
0158
0159 if ( $afields[0] != $bfields[0] ) {
0160 return $afields[0] <=> $bfields[0];
0161 } else {
0162 return $afields[1] <=> $bfields[1];
0163 }
0164
0165 }
0166
0167
0168
0169
0170 sub printOut {
0171
0172 my $id = shift;
0173 my $geometry = shift;
0174 my $survey = shift;
0175
0176
0177 if ( @$geometry != @$survey )
0178 {
0179 print " *** Warning: missing data in this file. Skipping.";
0180 return;
0181 }
0182
0183 my $count = 0;
0184 foreach my $gLine ( @$geometry )
0185 {
0186
0187 my @gFields = split( /\s+/, $gLine );
0188 printf OUTPUT "%9d", shift @gFields;
0189 print OUTPUT " ";
0190
0191 foreach my $field ( @$id ) {
0192 printf OUTPUT "%2d ", $field;
0193 }
0194
0195 printf OUTPUT "%3d %2d ", shift @gFields, shift @gFields;
0196 print OUTPUT join( " ", @gFields);
0197 print OUTPUT " ";
0198
0199 my @sFields = split( /\s+/, $$survey[$count] );
0200 shift @sFields; shift @sFields; shift @sFields;
0201 print OUTPUT join( " ", @sFields);
0202 print OUTPUT "\n";
0203
0204 ++$count;
0205 }
0206
0207 }