CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
personalPlayback.Playback Class Reference
Inheritance diagram for personalPlayback.Playback:
personalPlayback.Applet

Public Member Functions

def discover_files (self)
 
def do_create_lumi (self)
 
def do_exec (self)
 
def do_init (self)
 
- Public Member Functions inherited from personalPlayback.Applet
def __init__ (self, name, opts, kwargs)
 
def do_exec (self)
 
def do_init (self)
 
def log (self)
 
def write (self, fp)
 

Public Attributes

 global_file
 
 input
 
 lumi_backlog
 
 lumi_backlog_size
 
 lumi_found
 
 lumi_order
 
 next_lumi_index
 
 output
 
 ramdisk
 
 run
 
- Public Attributes inherited from personalPlayback.Applet
 control_fp
 
 kwargs
 
 name
 
 opts
 

Additional Inherited Members

- Static Public Member Functions inherited from personalPlayback.Applet
def read (fp)
 

Detailed Description

Definition at line 63 of file personalPlayback.py.

Member Function Documentation

def personalPlayback.Playback.discover_files (   self)

Definition at line 66 of file personalPlayback.py.

66  def discover_files(self):
67  self.lumi_found = {}
68 
69  files_found = set()
70  streams_found = set()
71  run_found = None
72  for f in os.listdir(self.input):
73  r = self.re_pattern.match(f)
74  if r:
75  run, lumi, stream, stream_source = r.groups()
76  run, lumi = int(run), int(lumi)
77 
78  if run_found is None:
79  run_found = run
80  elif run_found != run:
81  raise Exception("Files from multiple runs are not (yet) supported for as playback input.")
82 
83  lumi_dct = self.lumi_found.setdefault(lumi, { 'streams': {} })
84  lumi_dct["streams"][stream] = (f, stream_source)
85  files_found.add(f)
86  streams_found.add(stream)
87 
88  if run_found is None:
89  raise Exception("Playback files not found.")
90 
91  if self.run < 0:
92  self.run = run_found
93 
94  self.log.info("Found run %s, will map output to run %s", run_found, self.run)
95  self.log.info("Found %d lumisections with %d files", len(self.lumi_found), len(files_found))
96  self.log.info("Found %d streams: %s", len(streams_found), list(streams_found))
97 
98  self.lumi_order = list(self.lumi_found.keys())
99  self.lumi_order.sort()
100  self.log.info("Lumi order: %s", str(self.lumi_order))
101 
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def personalPlayback.Playback.do_create_lumi (   self)

Definition at line 125 of file personalPlayback.py.

References WorkFlow.WorkFlow.input, personalPlayback.Playback.input, personalPlayback.Playback.lumi_backlog, personalPlayback.Playback.lumi_backlog_size, personalPlayback.Playback.lumi_found, personalPlayback.Playback.lumi_order, personalPlayback.Playback.next_lumi_index, GeometryComparisonPlotter.output, CastorLedAnalysis.output, HcalLedAnalysis.output, personalPlayback.Playback.output, PhysicsTools::Calibration::MVAComputer.output, RPCRunIOV::RunIOV_Item.run, TB06Reco.run, TB06RecoH2.run, RPCDQMObject.run, EfficiencyPlotter.run, WZInterestingEventSelector::event.run, MuonRecoTest.run, DTResolutionAnalysisTest.run, BeamSpotRcdReader::theBSfromDB.run, DTBlockedROChannelsTest.run, DTDataIntegrityTest.run, DTChamberEfficiencyTest.run, DTResolutionTest.run, ME::Header.run, DTEfficiencyTest.run, personalPlayback.Playback.run, HitEff.run, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, cond::RunInfo_t.run, and SiPixelErrorEstimation.run.

Referenced by personalPlayback.Playback.do_exec().

125  def do_create_lumi(self):
126  orig_lumi = self.lumi_order[(self.next_lumi_index - 1) % len(self.lumi_order)]
127  play_lumi = self.next_lumi_index;
128  self.next_lumi_index += 1
129 
130  self.log.info("Start copying lumi (original) %06d -> %06d (playback)", orig_lumi, play_lumi)
131 
132  lumi_dct = self.lumi_found[orig_lumi]
133  streams = lumi_dct["streams"]
134 
135  def ijoin(f):
136  return os.path.join(self.input, f)
137 
138  def ojoin(f):
139  return os.path.join(self.output, f)
140 
141  written_files = set()
142  for stream, v in streams.items():
143  jsn_orig_fn, stream_source = v
144  jsn_play_fn = "run%06d_ls%04d_stream%s_%s.jsn" % (self.run, play_lumi, stream, stream_source)
145 
146  # define dat filename
147  ext = "dat"
148  if stream.startswith("streamDQMHistograms"):
149  ext = "pb"
150  dat_play_fn = "run%06d_ls%04d_stream%s_%s.%s" % (self.run, play_lumi, stream, stream_source, ext)
151 
152  # read the original file name, for copying
153  with open(ijoin(jsn_orig_fn), 'r') as f:
154  jsn_data = json.load(f)
155  dat_orig_fn = jsn_data["data"][3]
156 
157  # copy the data file
158  if os.path.exists(ijoin(dat_orig_fn)):
159  self.log.info("C: %s -> %s", dat_orig_fn, dat_play_fn)
160  shutil.copyfile(ijoin(dat_orig_fn), ojoin(dat_play_fn))
161 
162  written_files.add(dat_play_fn)
163  else:
164  log.warning("Dat file is missing: %s", dat_orig_fn)
165 
166  # write a new json file point to a different data file
167  # this has to be atomic!
168  jsn_data["data"][3] = dat_play_fn
169 
170  f = tempfile.NamedTemporaryFile(prefix=jsn_play_fn+ ".", suffix=".tmp", dir = self.output, delete=False)
171  tmp_fp = f.name
172  json.dump(jsn_data, f)
173  f.close()
174 
175  os.rename(tmp_fp, ojoin(jsn_play_fn))
176  written_files.add(jsn_play_fn)
177 
178  self.log.info("Copied %d files for lumi %06d", len(written_files), play_lumi)
179 
180  self.lumi_backlog.append((play_lumi, written_files))
181  while len(self.lumi_backlog) > self.lumi_backlog_size:
182  old_lumi, files_to_delete = self.lumi_backlog.popleft()
183 
184  self.log.info("Deleting %d files for old lumi %06d", len(files_to_delete), old_lumi)
185  for f in files_to_delete:
186  os.unlink(ojoin(f))
187 
def personalPlayback.Playback.do_exec (   self)

Definition at line 188 of file personalPlayback.py.

References personalPlayback.Playback.do_create_lumi(), GeometryComparisonPlotter.output, CastorLedAnalysis.output, HcalLedAnalysis.output, personalPlayback.Playback.output, PhysicsTools::Calibration::MVAComputer.output, RPCRunIOV::RunIOV_Item.run, TB06RecoH2.run, TB06Reco.run, RPCDQMObject.run, EfficiencyPlotter.run, WZInterestingEventSelector::event.run, MuonRecoTest.run, DTResolutionAnalysisTest.run, BeamSpotRcdReader::theBSfromDB.run, DTBlockedROChannelsTest.run, DTDataIntegrityTest.run, DTChamberEfficiencyTest.run, DTResolutionTest.run, ME::Header.run, DTEfficiencyTest.run, personalPlayback.Playback.run, HitEff.run, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, cond::RunInfo_t.run, and SiPixelErrorEstimation.run.

188  def do_exec(self):
189  last_write = 0
190  lumi_produced = 0
191 
192  while True:
193  time.sleep(1)
194 
195  now = time.time()
196  if (now - last_write) > self.opts.playback_time_lumi:
197  last_write = now
198 
199  if self.opts.playback_nlumi > -1 and lumi_produced >= self.opts.playback_nlumi:
200  break
201 
202  self.do_create_lumi()
203  lumi_produced += 1
204 
205  # write eor
206  eor_fn = "run%06d_ls0000_EoR.jsn" % (self.run, )
207  eor_fp = os.path.join(self.output, eor_fn)
208  with open(eor_fp, "w"):
209  pass
210 
211  self.log.info("Wrote EoR: %s", eor_fp)
212 
def personalPlayback.Playback.do_init (   self)

Definition at line 102 of file personalPlayback.py.

102  def do_init(self):
103  # check if our input directory is okay
104  self.input = self.opts.playback
105  self.ramdisk = self.opts.work_ramdisk
106  self.run = self.opts.run
107  self.log.info("Using input directory: %s", self.input)
108 
109  self.discover_files()
110 
111  self.output = os.path.join(self.ramdisk, "run%06d" % self.run)
112  if not os.path.isdir(self.output):
113  os.makedirs(self.output)
114  self.log.info("Using output directory: %s", self.output)
115 
116  self.global_file = os.path.join(self.ramdisk, ".run%06d.global" % self.run)
117  self.log.info("Writing: %s", self.global_file)
118  with open(self.global_file, "w") as f:
119  f.write("run_key = pp_run")
120 
121  self.lumi_backlog = collections.deque()
124 

Member Data Documentation

personalPlayback.Playback.global_file

Definition at line 116 of file personalPlayback.py.

personalPlayback.Playback.input

Definition at line 104 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.lumi_backlog

Definition at line 121 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.lumi_backlog_size

Definition at line 122 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.lumi_found

Definition at line 67 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.lumi_order

Definition at line 98 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.next_lumi_index

Definition at line 123 of file personalPlayback.py.

Referenced by personalPlayback.Playback.do_create_lumi().

personalPlayback.Playback.output
personalPlayback.Playback.ramdisk

Definition at line 105 of file personalPlayback.py.

Referenced by personalPlayback.FrameworkJob.discover_latest().

personalPlayback.Playback.run