Example #1
0
    def CreateMCCF(self):
        sys.stdout.flush()
        if not self.cfgtype == 'MC':
            print 'ERROR attempting to make a MC config when specified type is ' + self.cfgtype
            return ''
        if not self.CheckOptions():
            print 'ERROR please make sure all options stated above are entered'
            return ''
        self.ListOptions()
        try:
            configfile = open(self.config_filename, "w")
            print "Open config file for writing "
            configfile.write(
                "# Automatically generated config file, from ND280Configs.CreateMCCF\n\n"
            )

            ### Seed MC using sub+subrun - override defaults here
            f = ND280File(self.options['inputfile'])
            run = f.GetRunNumber()
            subrun = f.GetSubRunNumber()

            self.options['nd280mc_random_seed'] = str(
                GetRandomSeed(run, subrun, 'g4mc'))  # uint32
            self.options['elmc_random_seed'] = str(
                GetRandomSeed(run, subrun, 'elmc', hexbits=7))  # int32

            ### Software Setup
            configfile.write("[software]\n")
            configfile.write("cmtpath = " + self.options['cmtpath'] + "\n")
            configfile.write("cmtroot = " + self.options['cmtroot'] + "\n")
            configfile.write("nd280ver = " + self.options['nd280ver'] + "\n\n")

            ### Configuration
            configfile.write('[configuration]\n')
            configfile.write("module_list = " + self.options['module_list'] +
                             '\n')
            configfile.write("inputfile = " + self.options['inputfile'] +
                             '\n\n')

            ### File naming
            configfile.write("[filenaming]\n")
            configfile.write("comment = " + self.options['comment'] + "\n\n")

            ### Geometry
            configfile.write("[geometry]\n")
            configfile.write("baseline = " + self.options['baseline'] + "\n")
            configfile.write("p0d_water_fill = " +
                             self.options['p0d_water_fill'] + "\n\n")

            ### nd280mc
            configfile.write('[nd280mc]\n')
            configfile.write(
                'physicslist = ' + 'NeutG4CascadeInterface_QGSP_BERT' +
                '\n')  # p6S   # soph does it go here or the other one?
            configfile.write('num_events = ' + self.options['num_events'] +
                             '\n')
            configfile.write('mc_type = ' + self.options['mc_type'] + '\n')
            configfile.write('random_seed = ' +
                             self.options['nd280mc_random_seed'] + '\n')
            configfile.write('nbunches = ' + self.options['nbunches'] + '\n')
            configfile.write('interactions_per_spill = ' +
                             self.options['interactions_per_spill'] + '\n')
            configfile.write('pot_per_spill = ' +
                             self.options['pot_per_spill'] + '\n')
            configfile.write('bunch_duration = ' +
                             self.options['bunch_duration'] + '\n')
            configfile.write('mc_full_spill = ' +
                             self.options['mc_full_spill'] + '\n')
            configfile.write('time_offset = ' + self.options['time_offset'] +
                             '\n')
            configfile.write('count_type = ' + self.options['count_type'] +
                             '\n')
            configfile.write('mc_position = ' + self.options['mc_position'] +
                             '\n\n')

            ### elecSim
            configfile.write('[electronics]\n')
            configfile.write('random_seed = ' +
                             self.options['elmc_random_seed'] + '\n\n')

            ### production
            configfile.write('[analysis]\n')  # new for P6
            configfile.write('production = ' + self.options['production'] +
                             '\n')
            configfile.write('save_geometry = 1\n')

            ### dead channels
            if 'tpc_periods_to_activate' in self.options or 'ecal_periods_to_activate' in self.options:
                configfile.write('\n[dead_channels]\n')
            if 'tpc_periods_to_activate' in self.options:
                configfile.write('tpc_periods_to_activate = ' +
                                 self.options['tpc_periods_to_activate'] +
                                 '\n')
            if 'ecal_periods_to_activate' in self.options:
                configfile.write('ecal_periods_to_activate = ' +
                                 self.options['ecal_periods_to_activate'] +
                                 '\n')

            configfile.close()
            return self.config_filename
        except:
            configfile.close()
            print "Could not write the config file " + self.config_filename
            print open(self.config_filename, "r").readlines()
            sys.exit(1)
        return ''
Example #2
0
                  default='',
                  help="Version of nd280Highland2 to process with")
(options, args) = parser.parse_args()

###############################################################################

# Main Program
if not options.version:
    sys.exit('Please enter a version of the ND280 Software to use')
if not options.input and not 'lfn:' in options.input:
    sys.exit('Please enter an lfn: input file')
if not options.highlandVersion:
    sys.exit('Please specify a version of nd280Highland2 to process with')

print 'INPUT FILE: ' + options.input
inputFile = ND280File(options.input)

## Create Job object
print 'Job object'
j = ND280Process(options.version, inputFile, 'MiniTree')

## Run the Job
print 'Running job'
j.SetHighlandVersion(options.highlandVersion)
j.RunCreateMiniTree()

## Build up the file path progenitor and end
path_prot = os.path.dirname(options.input).rstrip(
    'anal')  # naturally assume we're processing an oaAnalysis file
path_end = ''
Example #3
0
    sys.exit('Please enter a version of the ND280 Software to use')

## example input is 'lfn:/grid/t2k.org/nd280/raw/ND280/ND280/00005000_00005999/nd280_00005216_0000.daq.mid.gz'
input = options.input
if not input and not 'lfn:' in input:
    sys.exit('Please enter an lfn: input file')

evtype = options.evtype
if not evtype:
    sys.exit(
        'Please enter the event type you wish to process using the -e or --evtype flag'
    )

os.system('env')

input_file = ND280File(input)

## Create Job object
j = ND280Raw(nd280ver,
             '/data/wilson/T2K/T2KComputingRep/CERNBeamProcessing/Testing/',
             input_file, evtype)

## Run the Job
j.SetQuick()
j.Run()

## Build up the path srm://srm-t2k.gridpp.rl.ac.uk/castor/ads.rl.ac.uk/prod/t2k.org/nd280/v7r19p1/logf/ND280/ND280/00003000_00003999/
path_prot = destination + '/t2k.org/nd280/' + nd280ver + '/'
reg_path_prot = 'lfn:/grid/t2k.org/nd280/' + nd280ver + '/'
path_end = 'CERNTestBeam/' + input_file.GetRunRange() + '/'
Example #4
0
    print 'Setting the trigger option to default: ' + trigger

rundir = ND280GRID.RunRange(run)

lfcdir = 'lfn:/grid/t2k.org/nd280/mcp1/' + neutrino + '/' + geo_baseline + '/' + area + '/' + trigger + '/' + level + '/'

try:
    source_dir = ND280Dir(lfcdir)
except:
    sys.exit('Could not see ' + lfcdir + ' please double check it exists.')

try:
    dest_dir = ND280Dir(destination)
except:
    sys.exit('Could not see ' + destination +
             ' please double check it exists.')

for file_name, size in source_dir.dir_dic.iteritems():
    if not run in file_name:
        continue
    f = ND280File(source_dir.dir + '/' + file_name)
    if run == f.GetRunNumber():
        if not subrun:
            f.Copy(dest_dir)
        elif subrun == f.GetSubRunNumber():
            f.Copy(dest_dir)
        else:
            continue
    else:
        continue
Example #5
0
def main(argv):

    # Parser Options
    ########################################################################
    parser = optparse.OptionParser()
    # example input is
    # 'lfn:/t2k.org/nd280/raw/ND280/ND280/00005000_00005999/nd280_00005216_0000.daq.mid.gz'
    parser.add_option("-i",
                      "--input",
                      dest="input",
                      type="string",
                      help="Input to process, must be an lfn")
    # example version is v12r15 or v11r31
    parser.add_option("-v",
                      "--version",
                      dest="version",
                      type="string",
                      help="Version of nd280 software to use")
    # example ???
    parser.add_option("--useTestDB",
                      action='store_true',
                      default=False,
                      help="Prepend the DB cascade with the test DB")

    (options, args) = parser.parse_args()

    nd280ver = options.version
    if not nd280ver:
        print 'Please enter a version of the ND280 Software to use'
        parser.print_help()
        return

    usr_input = options.input
    if not (type(usr_input) is str and len(usr_input) > 0):
        print 'Please enter an input file'
        parser.print_help()
        return
    usr_input = usr_input.strip()

    if 'lfn:' not in usr_input:
        usr_input = 'lfn:' + usr_input

    default_SE = SE.GetDefaultSE()
    #########################################################################
    # Parser Options

    # Main Program
    ########################################################################

    # print environment variables
    lotsOfPounds = str()
    for index in range(0, 80):
        lotsOfPounds += '#'

    print 'Environment variables'
    print lotsOfPounds
    os.system('env')
    print lotsOfPounds

    # Delay processing by random time to avoid database blocking
    # rt = 200. * random.random()
    rt = StatusWait.kJobSubmit
    print lotsOfPounds
    print 'Sleeping ' + str(rt) + ' seconds'
    print lotsOfPounds
    sleep(rt)

    print lotsOfPounds
    print 'INPUT FILE: ' + usr_input
    print lotsOfPounds
    input_file = ND280File(usr_input)

    # directory suffix added to each stage name
    dirsuff = '_p0dmod'

    print lotsOfPounds
    # Create Job object
    mem_unit = SE.units(1).kGibibyte
    mem_unit_str = 'GiB'
    time_unit = StatusWait.kHour
    time_unit_str = 'hr'
    print 'Job object'
    # max file size
    fmem = 20 * mem_unit  # 20 GiB
    # max memory
    vmem = 4 * mem_unit  # 4 GiB
    # job time limit
    tlim = 24 * time_unit  # 24 hr
    dbtime = '2038-01-01'

    print 'Max file size = ', str(fmem / mem_unit), mem_unit_str
    print 'Max memory = ', str(vmem / mem_unit), mem_unit_str
    print 'Max walltime = ', str(tlim / time_unit), time_unit_str
    print 'DB time = ' + dbtime
    print lotsOfPounds

    # define the processing
    evtype = 'spill'
    modules = "oaCalib"
    modulelist = list()
    if modules:
        modulelist = modules.split(",")
        print lotsOfPounds
        print 'module list'
        print modulelist
        print lotsOfPounds
    config = '[calibrate],par_override = P0DMOD.PARAMETERS.DAT'
    nd280_proc = ND280Process(nd280ver, input_file, "Raw", evtype, modulelist,
                              config, dbtime, fmem, vmem, tlim)
    # use the test DataBase?
    if options.useTestDB:
        nd280_proc.useTestDB = True

    # Build up the path
    # lfn:/t2k.org/nd280/calib/v*r*p*/ND280/ND280/0000*000_0000*999/[filetype]
    path_prot = join('lfn:/t2k.org/nd280/calib', nd280ver, 'ND280/ND280',
                     input_file.GetRunRange())
    path_prot += '/'
    path_end = str()

    # Copy across the root files, register some
    # Remove files from list if respin
    # cata, logf, cnfg always copied
    copyfiles = ['psmu', 'anal']
    dirlist = copyfiles

    # Test that we are able to copy a test file
    print lotsOfPounds
    print 'Testing copy'
    nd280_proc.TestCopy(path_prot, path_end, dirsuff, default_SE)
    print lotsOfPounds

    # Run the Job
    # print 'Running quick job'
    # nd280_proc.SetQuick()

    # calibration
    print lotsOfPounds
    print 'ND280Process.RunRaw()'
    nd280_proc.RunRaw()
    print lotsOfPounds

    # reconstruction
    print lotsOfPounds
    print 'ND280Process.RunP0DRecon()'
    nd280_proc.RunP0DRecon()
    print lotsOfPounds

    # sand muon selection
    print lotsOfPounds
    print 'ND280Process.RunP0DControlSample()'
    nd280_proc.RunP0DControlSample()
    print lotsOfPounds

    # oaAanalysis
    print lotsOfPounds
    print 'ND280Process.RunOAAnalysis()'
    nd280_proc.RunOAAnalysis()
    print lotsOfPounds

    print lotsOfPounds
    print 'Copy ROOT files'
    nd280_proc.CopyLogFile(path_prot, path_end, dirsuff, default_SE)
    print lotsOfPounds

    print lotsOfPounds
    print 'Copy Log files'
    nd280_proc.CopyRootFiles(path_prot, path_end, dirlist, dirsuff, default_SE)
    print lotsOfPounds

    print lotsOfPounds
    print 'Finished OK'
    print lotsOfPounds
Example #6
0
 def  __init__(self,nd280ver,input_file):
     super(P0DBarEndCalib,self).__init__(nd280ver)
     #Hard code intermidiate file name for simplicity.
     self.hitsOutput = "hits.root"
     self.inputToGenCalib = "file.txt"
     self.nd280file = ND280File(input_file)