Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:13

0001 #!/usr/bin/env ruby
0002 # -----------------------------------------------------------------------------
0003 # 'copy-to-analysis.rb'
0004 # Derek Anderson
0005 # 12.21.2023
0006 #
0007 # Script to automate copying files over to
0008 # a fork of the sPHENIX analysis repo.
0009 # -----------------------------------------------------------------------------
0010 
0011 # modules to use
0012 require 'fileutils'
0013 
0014 # top directory to copy from/to
0015 copy_from = "/sphenix/user/danderson/jets/CaloStatusMapper"
0016 copy_to   = "/sphenix/user/danderson/sphenix/analysis/JS-Jet/CaloStatusMapper"
0017 
0018 # what files to copy
0019 to_copy = [
0020   "README.md",
0021   "Fun4All_TestCaloStatusMapper.C",
0022   "input/dst_calo_run2pp-00047289.list",
0023   "input/run42072.list",
0024   "input/run43273.list",
0025   "scripts/copy-to-analysis.rb",
0026   "scripts/wipe-source.sh",
0027   "src/CaloStatusMapper.cc",
0028   "src/CaloStatusMapper.h",
0029   "src/CaloStatusMapperDefs.h",
0030   "src/CaloStatusMapperLinkDef.h",
0031   "src/autogen.sh",
0032   "src/configure.ac",
0033   "src/Makefile.am",
0034   "src/sphx-build"
0035 ]
0036 
0037 # do copying
0038 to_copy.each do |file|
0039 
0040   # make directory in target if needed
0041   if file.include? "/"
0042 
0043     # grab relative path to file
0044     relative_path = file.clone
0045     relative_path.gsub!(copy_from, "")
0046 
0047     # clean up and isolate path
0048     relative_path.gsub!("//",  "/")
0049     relative_path.gsub!("/./", "/")
0050     relative_path.slice!(relative_path.rindex("/")..-1)
0051 
0052     # make directory
0053     to_make = copy_to + "/" + relative_path
0054     FileUtils.mkdir_p(to_make, :verbose => true) unless File.exists?(to_make)
0055   end
0056 
0057   # make source and target paths
0058   source = copy_from + "/" + file
0059   target = copy_to + "/" + file
0060 
0061   # remove any unwanted patterns
0062   source.gsub!("//",  "/")
0063   target.gsub!("//",  "/")
0064   source.gsub!("/./", "/")
0065   target.gsub!("/./", "/")
0066 
0067   # copy file
0068   FileUtils.cp_r(source, target, :verbose => true)
0069 end
0070 
0071 # end -------------------------------------------------------------------------