#!/usr/local/bin/perl ############################################ # # run_mcfast: perl script for running # the stdhep translaters and mcfast # # Paul M Eugenio # Carnegie Mellon University # # created: some time in Sept 1998 # last modified by: PME 19-Nov-98 ########################################## select((select(STDOUT),$|=1)[$[]); if(! -e "HDMS.db"){ print "GEO FILE \"HDMS.db\" DOES NOT EXITS!\n\n"; print "Make a link from your geo file to HDMS.db\n\n"; exit; } &printusage($0) if($#ARGV == -1); $label= "none"; $tail = ".ascii"; $stdhep_it="ascii2stdhep"; $unstdhep_it="stdhep2ascii"; $REMOVE=1; $dbFile=0; for (@ARGV) { if(/^-G(.+)/) { $dbFile = $1;} if(/^-d/) { $REMOVE = 0;} if(/^-n(.+)/) { $nparts = $1;} if(/^-t(.+)/) { $tag = $1;} if(/^-N(.+)/) { $nevents = $1;} if(/^-I(.+)/) { $tail = ".itape";$stdhep_it="itape2stdhep";$unstdhep_it="stdhep2itape"} if(/^-A(.+)/) { $tail = ".ascii";} if(/^-B(.+)/) { $beamp = $1;} } #print "dbFile: ".$dbFile,"\n"; if($#ARGV > 0){ $dcmd="\$HDMS_MCFAST_DIR/HDMS.cmd"; # Run ascii2stdhep $syscomm = "ascii2stdhep -i".$tag.".ascii -o".$tag.".evt -n".$nparts." -N".$nevents ; print $syscomm."\n"; system($syscomm); # create sym link if(-f "db") {system("rm db");} $syscomm = "ln -s \$MCFAST_DIR/mcfast/db ."; print $syscomm."\n"; system($syscomm); # Run MCFast $syscomm = "sed \"s/input.evt/".$tag.".evt/g\" " ; $syscomm = $syscomm." ".$dcmd." >".$tag.".cmd"; print $syscomm."\n"; system($syscomm); $syscomm = "sed \"s/output.evt/".$tag.".mcfasted.evt/g\" " ; $syscomm = $syscomm." ".$tag.".cmd > tmp"; print $syscomm."\n"; system($syscomm); print "cp tmp tmp2\n"; system("cp tmp tmp2"); if($dbFile ){ $syscomm = "sed \"s/\\/home\\/halld\\/source\\/HDMS_mcfast\\/HDMS.db/"; $syscomm = $syscomm.$dbFile."/g\" tmp > tmp2"; print $syscomm."\n"; system($syscomm); } $syscomm = "sed \"s/25000/".$nevents."/g\" " ; $syscomm = $syscomm." tmp2 >".$tag.".cmd"; print $syscomm."\n"; system($syscomm); $syscomm = "rm tmp tmp2"; print $syscomm."\n"; system($syscomm); $syscomm = "mcfast -f ".$tag.".cmd -l ".$tag.".log -hb ".$tag.".hbook"; print $syscomm."\n"; system($syscomm); # Remove stdhep input file and cmd file if($REMOVE==1){ $syscomm = "rm ".$tag.".evt"; print $syscomm."\n"; system($syscomm); $syscomm = "rm ".$tag.".cmd"; print $syscomm."\n"; system($syscomm); } # Run stdhep2ascii $syscomm = "stdhep2ascii -i".$tag.".mcfasted.evt -o".$tag.".mcfasted.ascii -n".$nparts." -N".$nevents ; print $syscomm."\n"; system($syscomm); #remove stdhep output file if($REMOVE==1){ $syscomm = "rm ".$tag.".mcfasted.evt"; print $syscomm."\n"; system($syscomm); } } sub printusage { print " usage: @_[0] [-options] -N# numbers of data events -t tag used to create files like .ascii -n number of particles in an event -G use a nonstardard geo file(mostly used for debugging) -d don't remove files(used for debuging)\n"; }