Functions | Variables
raw2rootAnalyser Namespace Reference

Functions

def analyse (detector, stream, query=False, partition=False, write=False)
 functions More...
 

Variables

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

Function Documentation

def raw2rootAnalyser.analyse (   detector,
  stream,
  query = False,
  partition = False,
  write = False 
)

functions

Definition at line 23 of file raw2rootAnalyser.py.

References open(), and type.

23 def analyse(detector, stream, query=False, partition=False, write=False):
24  to_return = []
25  releases = []
26  runs = []
27  run_subrun_to_list_map = {}
28  raw_query = "data_tier raw and file_type importedDetector and online.detector %s"%detector
29  if type(stream) == int: raw_query +=" and online.stream %i"%stream
30  if type(partition) == int: raw_query += " and online.partition %i"%partition
31  if query: raw_query += " and %s"%query
32  print "run : using query: %s"%raw_query
33  raw_files = sam.listFiles(dimensions=raw_query)
34  raw_files.sort()
35  n_kids = 0
36  print "run : found %i raw files"%len(raw_files)
37  for i,raw_file in enumerate(raw_files):
38  if i%100 == 0: print "run : file: [%i/%i]"%(i,len(raw_files))
39  # if i > 20: break
40  run = tools.findRun(raw_file)
41  subrun = tools.findSubRun(raw_file)
42  if run not in runs: runs.append(run)
43  this_json = {"file_name":raw_file,"children":[],"run":run,"subrun":subrun}
44 
45  if not options.assume:
46  # explicitly check all the children of this file
47  kids = sam.getFileLineage("children",raw_file)
48  for kid in kids:
49  try:
50  metadata = sam.getMetadata(kid["file_name"])
51  except:
52  print "run : - exception with %s, %s"%(raw_file,kid["file_name"])
53  metadata = {}
54  # print metadata
55  if "DAQ2RawDigit.base_release" in metadata.keys():
56  release = metadata["DAQ2RawDigit.base_release"]
57  if release not in releases:
58  print "run : - new release found: %s"%release
59  releases.append(release)
60  this_json["children"].append({"file_name":kid["file_name"],"release":release})
61  n_kids +=1
62 
63  to_return.append(this_json)
64  run_subrun_to_list_map[(run,subrun)] = i
65  #### if we haven't explicitly found the children of a file, instead we assume a match based on run and subrun
66  if options.assume:
67  root_query = "data_tier artdaq and file_type importedDetector and online.detector %s"%detector
68  if type(stream) == int: root_query +=" and online.stream %i"%stream
69  if type(partition) == int: root_query += " and online.partition %i"%partition
70  if query: root_query += " and %s"%query
71  print "run : using query: %s"%root_query
72  root_files = sam.listFiles(dimensions=root_query)
73  root_files.sort()
74  print "run : found %i root files"%len(root_files)
75  for i,root_file in enumerate(root_files):
76  if i%100 == 0: print "run : file: [%i/%i]"%(i,len(root_files))
77  # if i > 20: break
78  try:
79  run = tools.findRun(root_file)
80  except:
81  print "run : - exception finding run for file: %s"%root_file
82  continue
83  subrun = tools.findSubRun(root_file)
84  if run not in runs:
85  print "run : - artdaq run found which doesn't match any raw run: %i"%run
86  continue
87  try:
88  release = tools.findRelease(root_file)
89  except:
90  print "run : - exception finding release for file: %s"%root_file
91  continue
92  if release not in releases:
93  print "run : - new release found: %s"%release
94  releases.append(release)
95  if (run,subrun) not in run_subrun_to_list_map.keys():
96  print "run : - artdaq run, subrun found which doesn't match any raw run: r%i s%i"%(run,subrun)
97  continue
98  this_json = to_return[run_subrun_to_list_map[(run,subrun)]]
99  this_json["children"].append({"file_name":root_file,"release":release})
100  n_kids +=1
101 
102  print "run : found %i kids, over %i runs, in %i releases"%(n_kids,len(runs),len(releases))
103  if write:
104  print "run : writing results as %s"%write
105  to_write = {}
106  to_write["raw_files"] = to_return
107  to_write["releases"] = releases
108  to_write["runs"] = runs
109  cPickle.dump(to_write,open(write,"wb"))
110  # return to_return, releases
procfile open("FD_BRL_v0.txt")
def analyse(detector, stream, query=False, partition=False, write=False)
functions

Variable Documentation

raw2rootAnalyser.action

Definition at line 13 of file raw2rootAnalyser.py.

list raw2rootAnalyser.all_samples = ["neardet_cosmics", "fardet_cosmics", "neardet_numi", "fardet_numi","neardet_ddactivity"]

Definition at line 20 of file raw2rootAnalyser.py.

raw2rootAnalyser.args

Definition at line 15 of file raw2rootAnalyser.py.

raw2rootAnalyser.default

Definition at line 13 of file raw2rootAnalyser.py.

raw2rootAnalyser.dest

Definition at line 13 of file raw2rootAnalyser.py.

raw2rootAnalyser.help

Definition at line 13 of file raw2rootAnalyser.py.

raw2rootAnalyser.options

Definition at line 15 of file raw2rootAnalyser.py.

raw2rootAnalyser.parser = OptionParser()

Definition at line 12 of file raw2rootAnalyser.py.

raw2rootAnalyser.partition

FD cosmics.

FD numi.

Definition at line 127 of file raw2rootAnalyser.py.

raw2rootAnalyser.query

ND dd-activity.

Definition at line 119 of file raw2rootAnalyser.py.

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

Definition at line 4 of file raw2rootAnalyser.py.

raw2rootAnalyser.str

Definition at line 13 of file raw2rootAnalyser.py.

raw2rootAnalyser.type

Definition at line 13 of file raw2rootAnalyser.py.

Referenced by analyse().

raw2rootAnalyser.write

Run ND cosmics.

ND numi.

Definition at line 115 of file raw2rootAnalyser.py.