File indexing completed on 2024-04-06 11:56:23
0001
0002 use File::Basename;
0003
0004 print "Configuring the python executables and run scripts...\n";
0005
0006
0007
0008 $iter = $ARGV[0];
0009 $dir = $ARGV[1];
0010 $odir = $ARGV[2];
0011
0012
0013
0014
0015 $createDBs = 1;
0016 $intoNtuples = 1;
0017 $geomComparison = 1;
0018 $plotFigs = 1;
0019
0020
0021
0022 print "Set path and configuration... \n";
0023
0024
0025
0026
0027
0028
0029
0030 print "Opening common... \n";
0031 $COMMON = "python/common_cff_py.txt";
0032 open (COMMON) or die "Can't open the file!";
0033 @commonFileInput = <COMMON>;
0034
0035
0036
0037
0038 print "Starting loop... \n";
0039 for ($j = 1; $j <= $iter; $j++){
0040 print "Loop $j \n";
0041
0042 if ($createDBs == 1){
0043
0044 system("
0045 cp python/upload_serial_tpl_py.txt $dir/upload_serial_cfg.py
0046 ");
0047 replace( "$dir/upload_serial_cfg.py", "<PATH>", "$dir" );
0048 replace( "$dir/upload_serial_cfg.py", "<OUTPATH>", "$odir" );
0049 replace( "$dir/upload_serial_cfg.py", "<N>", "$j" );
0050 insertBlock( "$dir/upload_serial_cfg.py", "<COMMON>", @commonFileInput );
0051
0052 print "Create IOIteration.root ... \n";
0053
0054 system("
0055 cp data/IOIteration_serial.root $dir/.
0056 ");
0057 replace( "$dir/IOIteration_serial.root", "<ITER>", "$j" );
0058
0059
0060 print "Run upload_serial... \n";
0061 system("
0062 cmsRun $dir/upload_serial_cfg.py
0063 ");
0064 }
0065
0066 if ($intoNtuples == 1){
0067
0068 system("
0069 cp test/serialIntoNtuples_tpl.py $odir/serialIntoNtuples_cfg.py
0070 ");
0071 replace( "$odir/serialIntoNtuples_cfg.py", "<PATH>", "$odir" );
0072 replace( "$odir/serialIntoNtuples_cfg.py", "<N>", "$j" );
0073 system("
0074 cmsRun $odir/serialIntoNtuples_cfg.py
0075 rm $odir/alignments_$j.db
0076 ");
0077 }
0078
0079 if ($geomComparison == 1){
0080
0081 system("
0082 cp test/serialGeomCompare_tpl.py $odir/serialGeomCompare_cfg.py
0083 ");
0084 replace( "$odir/serialGeomCompare_cfg.py", "<PATH>", "$odir" );
0085 replace( "$odir/serialGeomCompare_cfg.py", "<N>", "$j" );
0086 system("
0087 cmsRun $odir/serialGeomCompare_cfg.py
0088 ");
0089 }
0090
0091 if ($plotFigs == 1){
0092
0093 system("
0094 cp scripts/compareGeomSerial_tpl.C scripts/compareGeomSerial.C
0095 ");
0096 replace( "scripts/compareGeomSerial.C", "<PATH>", "$odir" );
0097 replace( "scripts/compareGeomSerial.C", "<N>", "$j" );
0098 system("
0099 cd scripts
0100 root -l -q -b 'compareGeomSerial.C()'
0101 cd ../
0102 ");
0103 }
0104
0105 }
0106
0107
0108
0109
0110
0111
0112
0113 sub replace {
0114
0115 $infile = @_[0];
0116 $torepl = @_[1];
0117 $repl = @_[2];
0118
0119
0120 open(INFILE,"$infile") or die "cannot open $infile";;
0121 @log=<INFILE>;
0122 close(INFILE);
0123
0124 system("rm -f tmp");
0125 open(OUTFILE,">tmp");
0126
0127 foreach $line (@log) {
0128 $linecopy = $line =~ s/$torepl/$repl/;
0129 if ($line =~ /$torepl/) { print OUTFILE $linecopy; }
0130 else { print OUTFILE $line; }
0131 }
0132
0133 close(OUTFILE);
0134 system("mv tmp $infile");
0135
0136 }
0137
0138 sub insertBlock {
0139
0140 ($infile, $torepl, @repl) = @_;
0141
0142 open(INFILE,"$infile") or die "cannot open $infile";;
0143 @log=<INFILE>;
0144 close(INFILE);
0145
0146 system("rm -f tmp");
0147 open(OUTFILE,">tmp");
0148
0149 foreach $line (@log) {
0150 if ($line =~ /$torepl/) { print OUTFILE @repl; }
0151 else { print OUTFILE $line; }
0152 }
0153
0154 close(OUTFILE);
0155 system("mv tmp $infile");
0156
0157 }