Functions | Variables
pclistAnalyser Namespace Reference

Functions

def add_to_children (release, run, subrun, json)
 functions More...
 
def analyse (detector, stream, query=False, partition=False, write=False)
 

Variables

 sam = samweb_client.SAMWebClient(experiment="nova")
 
 parser = OptionParser()
 
 help
 
 action
 
 type
 
 str
 
 dest
 
 default
 
 options
 
 args
 
list all_samples = ["neardet_cosmics", "neardet_ddactivity", "fardet_cosmics"]
 
 write
 Run ND cosmics. More...
 
 query
 ND activity. More...
 
 partition
 FD cosmics. More...
 

Function Documentation

def pclistAnalyser.add_to_children (   release,
  run,
  subrun,
  json 
)

functions

Definition at line 22 of file pclistAnalyser.py.

Referenced by analyse().

22 def add_to_children(release,run,subrun,json):
23  for this_run in json:
24  if this_run["run"] != run: continue
25  for child in this_run["children"]:
26  if child["release"] != release: continue
27  child["subruns"] += 1
28  return
29  this_run["children"].append({"release":release,"subruns":1})
30  return
31 
def add_to_children(release, run, subrun, json)
functions
def pclistAnalyser.analyse (   detector,
  stream,
  query = False,
  partition = False,
  write = False 
)

Definition at line 32 of file pclistAnalyser.py.

References add_to_children(), open(), and type.

32 def analyse(detector, stream, query=False, partition=False, write=False):
33  artdaq_releases = []
34  files = []
35  release_to_files_map = {}
36 
37  artdaq_query = "data_tier artdaq and file_type importedDetector and online.detector %s"%detector
38  if type(stream) == int: artdaq_query += " and online.stream %i"%stream
39  if type(partition) == int: artdaq_query += " and online.partition %i"%partition
40  if query: artdaq_query += " and %s"%query
41  print "run : using query: %s"%artdaq_query
42  artdaq_files = sam.listFiles(dimensions=artdaq_query)
43  artdaq_files.sort()
44  n_kids = 0
45  print "run : found %i artdaq files"%len(artdaq_files)
46  for i,artdaq_file in enumerate(artdaq_files):
47  if i%100 == 0: print "run : file: [%i/%i]"%(i,len(artdaq_files))
48  # if i>200: break
49  artdaq_release = tools.findRelease(artdaq_file)
50  if artdaq_release not in artdaq_releases:
51  artdaq_releases.append(artdaq_release)
52  files.append({"artdaq_release":artdaq_release,"releases":["artdaq"],"runs":[],"files":[]})
53  release_to_files_map[artdaq_release] = len(artdaq_releases)-1
54 
55  this_json = files[release_to_files_map[artdaq_release]]
56 
57  run = tools.findRun(artdaq_file)
58  subrun = tools.findSubRun(artdaq_file)
59  if run not in this_json["runs"]:
60  this_json["runs"].append(run)
61  this_json["files"].append( {"run":run,
62  "children": [{"release":"artdaq","subruns":0}]} )
63 
64  # add artdaq file to children
65  add_to_children("artdaq",run,subrun,this_json["files"])
66 
67  # explicitly check all the children of this file
68  kids = sam.getFileLineage("children",artdaq_file)
69  # print "run : has %i children"%len(kids)
70  for kid in kids:
71  if ".pclist." not in kid["file_name"]: continue
72  # print "run : pclist child:",kid["file_name"]
73  n_kids +=1
74  try:
75  release = tools.findRelease(kid["file_name"])
76  except:
77  print "run : - cannot deterimine release for file: ",file_name
78  continue
79  if release not in this_json["releases"]:
80  print "run : - new pclist release found: %s"%release
81  this_json["releases"].append(release)
82  add_to_children(release,run,subrun,this_json["files"])
83 
84  files[release_to_files_map[artdaq_release]] = this_json
85  # run_subrun_to_list_map[(run,subrun)] = i
86  # print artdaq_releases
87  # for i,f in enumerate(files):
88  # print "file[%i]"%i
89  # for key in f.keys():
90  # print " %s: %s"%(key,repr(f[key]))
91 
92  # print "run : found %i kids, over %i runs, in %i releases"%(n_kids,len(runs),len(releases))
93  if write:
94  print "run : writing results as %s"%write
95  to_write = {}
96  to_write["artdaq_releases"] = artdaq_releases
97  to_write["files"] = files
98  cPickle.dump(to_write,open(write,"wb"))
99  with open(write, 'w') as outfile:
100  JSON.dump(to_write, outfile)
101  # return to_return, releases
def add_to_children(release, run, subrun, json)
functions
def analyse(detector, stream, query=False, partition=False, write=False)
procfile open("FD_BRL_v0.txt")

Variable Documentation

pclistAnalyser.action

Definition at line 14 of file pclistAnalyser.py.

list pclistAnalyser.all_samples = ["neardet_cosmics", "neardet_ddactivity", "fardet_cosmics"]

Definition at line 19 of file pclistAnalyser.py.

pclistAnalyser.args

Definition at line 15 of file pclistAnalyser.py.

pclistAnalyser.default

Definition at line 14 of file pclistAnalyser.py.

pclistAnalyser.dest

Definition at line 14 of file pclistAnalyser.py.

pclistAnalyser.help

Definition at line 14 of file pclistAnalyser.py.

pclistAnalyser.options

Definition at line 15 of file pclistAnalyser.py.

pclistAnalyser.parser = OptionParser()

Definition at line 13 of file pclistAnalyser.py.

pclistAnalyser.partition

FD cosmics.

Definition at line 114 of file pclistAnalyser.py.

pclistAnalyser.query

ND activity.

Definition at line 110 of file pclistAnalyser.py.

pclistAnalyser.sam = samweb_client.SAMWebClient(experiment="nova")

Definition at line 4 of file pclistAnalyser.py.

pclistAnalyser.str

Definition at line 14 of file pclistAnalyser.py.

pclistAnalyser.type

Definition at line 14 of file pclistAnalyser.py.

Referenced by analyse().

pclistAnalyser.write