#!/usr/local/bin/perl ############################################ # # run_hdfast_lite: perl script for running # the stdhep translaters and HDFast # # Paul M Eugenio # Carnegie Mellon University # # created: some time in Nov 199 # last modified by: PME 11-Nov-99 ########################################## select((select(STDOUT),$|=1)[$[]); $GeoFile= $ENV{"HALLD_HOME"}."/src/HDFast/HDFast.db"; if(! -e $GeoFile){ print "GEO FILE:".$GeoFile." DOES NOT EXITS!\n\n"; exit; } if(! -e "db/"){ $syscmd="ln -s ".$ENV{"HDFAST_DIR"}."/db ."; print $syscmd."\n"; system($syscmd); } &printusage($0) if($#ARGV == -1); $label= "none"; $tail = ".ascii"; $stdhep_it="ascii2stdhep"; $unstdhep_it="stdhep2ascii"; $REMOVE=1; $dbFile=0; $SaveBadEvents = 0; $DEBUG =0; $ManyMode = 0; # # Used in ManyMode #@Beams=(5,6,8,10,12); @Beams=(5,8,12); @Xmasses=(1.4,1.7,2.0); #@Xmasses=(1.4); @Xwidths=(0.25); $nskip=0; for (@ARGV) { if(/^-G(.+)/) { $dbFile = $1;} if(/^-S(.+)/) { $nskip = $1;} if(/^-d/) { $REMOVE = 0;} if(/^-g(.+)/) { $gamp_flag = " -g"; $gamp_kludge=$1; } if(/^-D(.+)/) { $DEBUG = $1;} if(/^-n(.+)/) { $nparts = $1;} if(/^-t(.+)/) { $tag0 = $1;} if(/^-M/) { $ManyMode = 1;} if(/^-N(.+)/) { $nevents = $1;} if(/^-I(.+)/) { $tail = ".itape";$stdhep_it="itape2stdhep";$unstdhep_it="stdhep2itape"} if(/^-A(.+)/) { $tail = ".ascii";} if(/^-v/) { $SaveOldFormat = 1;} if(/^-u/) { $SaveBadEvents = 1;} if(/^-B(.+)/) { $beamp = $1;} } if($ManyMode==0){ @Beams=(-1); @Xmasses=(1); @Xwidths=(1); } if($#ARGV > 0){ $dcmd="\$HDFAST_DIR/HALLD.cmd"; foreach $beamZ (@Beams){ foreach $Xmass (@Xmasses){ foreach $Xwidth (@Xwidths){ # # Create name tag which is used to make I/O file names # if($beamZ == -1){ $key=""; }else{ $key=":B".$beamZ."M".$Xmass."W".$Xwidth; } $tag = $tag0.$key; print "Using nametag of ".$tag."\n"; # Run ascii2stdhep $syscomm = "ascii2stdhep -i".$tag.".ascii -S$nskip -o" .$tag.".evt -n".$nparts." -N".$nevents.$gamp_flag ; print $syscomm."\n"; system($syscomm); # create sym link # if(-f "db") # {system("rm db");} # $syscomm = "ln -s \$MCFAST_DIR/db ."; # print $syscomm."\n"; # system($syscomm); ############ # Run HDFast_lite ############ # # make the command file # print "Making mcfast command file:\n"; $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/Geo.db/$dbFile/g\" tmp > tmp2" ; print $syscomm."\n"; system($syscomm); }else { system("cp $GeoFile Geo.db"); system("cp tmp tmp2"); } $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); # # create HDFast command # $RdtFile = $tag.".rdt "; $syscomm = "HDFast_lite -f ".$tag.".cmd -l ".$tag.".log -hb ".$tag.".hbook"; if($SaveBadEvents){ $syscomm = $syscomm." -u -"; } if($SaveOldFormat){ $syscomm = $syscomm." -v -"; } if($DEBUG){ $syscomm = $syscomm." -d ".$DEBUG." "; } print $syscomm."\n"; system($syscomm); # # Remove stdhep input file and the created 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." ".$gamp_flag.$gamp_kludge ; print $syscomm."\n"; system($syscomm); # # clean up loose files # if( $REMOVE==1){ system("rm Geo.db"); $syscomm = "rm ".$tag.".mcfasted.evt"; print $syscomm."\n"; system($syscomm); } } } } } sub printusage { print " usage: @_[0] [-options] -N# numbers of data events -S# Skip the first # events -t tag used to create files like .ascii -n# number of particles in an event -D# debug level (default: 0) -M many mode -- loop over masses and widths (must edit me) -g use gamp input file format -u save broken events (*.evt file do not use w/ -v ) -G use a nonstardard geo file(mostly used for debugging) -d don't remove files(used for debuging) typical usage: @_[0] -N100 -texample -n6\n"; }