CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Private Attributes
dataset.DatasetBase Class Reference
Inheritance diagram for dataset.DatasetBase:
dataset.Dataset dataset.MultipleDatasets

Public Member Functions

def getfiles
 
def headercomment
 
def writefilelist_hippy
 
def writefilelist_validation
 

Static Private Attributes

 __metaclass__ = abc.ABCMeta
 

Detailed Description

Definition at line 127 of file dataset.py.

Member Function Documentation

def dataset.DatasetBase.getfiles (   self,
  usecache 
)

Definition at line 131 of file dataset.py.

Referenced by dataset.DatasetBase.writefilelist_hippy().

132  def getfiles(self, usecache):
133  pass
def dataset.DatasetBase.headercomment (   self)

Definition at line 135 of file dataset.py.

136  def headercomment(self):
137  pass
def dataset.DatasetBase.writefilelist_hippy (   self,
  firstrun,
  lastrun,
  runs,
  eventsperjob,
  maxevents,
  outputfile,
  usecache = True 
)

Definition at line 167 of file dataset.py.

References python.cmstools.all(), any(), and dataset.DatasetBase.getfiles().

168  def writefilelist_hippy(self, firstrun, lastrun, runs, eventsperjob, maxevents, outputfile, usecache=True):
169  runrange = RunRange(firstrun=firstrun, lastrun=lastrun, runs=runs)
170  if maxevents < 0: maxevents = float("inf")
171  totalevents = sum(datafile.nevents for datafile in self.getfiles(usecache) if all(run in runrange for run in datafile.runs))
172  if totalevents == 0:
173  raise ValueError("No events within the run range!")
174  accepted = rejected = inthisjob = 0. #float so fractions are easier
175 
176  fractiontoaccept = 1.*maxevents / totalevents
177  writecomma = False
178 
179  with open(outputfile, "w") as f:
180  for datafile in self.getfiles(usecache):
181  if all(run in runrange for run in datafile.runs):
182  if accepted == 0 or accepted / (accepted+rejected) <= fractiontoaccept:
183  if writecomma: f.write(",")
184  f.write("'" + datafile.filename + "'")
185  accepted += datafile.nevents
186  inthisjob += datafile.nevents
187  if inthisjob >= eventsperjob:
188  f.write("\n")
189  inthisjob = 0
190  writecomma = False
191  else:
192  writecomma = True
193  else:
194  rejected += datafile.nevents
195  elif any(run in runrange for run in datafile.runs):
196  raise DatasetError("file {} has multiple runs {}, which straddle firstrun or lastrun".format(datafile.filename, datafile.runs))
197  f.write("\n")
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
def dataset.DatasetBase.writefilelist_validation (   self,
  firstrun,
  lastrun,
  runs,
  maxevents,
  outputfile = None,
  usecache = True 
)

Definition at line 138 of file dataset.py.

139  def writefilelist_validation(self, firstrun, lastrun, runs, maxevents, outputfile=None, usecache=True):
140  runrange = RunRange(firstrun=firstrun, lastrun=lastrun, runs=runs)
141 
142  if outputfile is None:
143  outputfile = os.path.join(os.environ["CMSSW_BASE"], "src", "Alignment", "OfflineValidation", "python", self.filenamebase+"_cff.py")
144 
145  if maxevents < 0: maxevents = float("inf")
146  totalevents = sum(datafile.nevents for datafile in self.getfiles(usecache) if all(run in runrange for run in datafile.runs))
147  if totalevents == 0:
148  raise ValueError("No events within the run range!")
149  accepted = rejected = 0. #float so fractions are easier
150 
151  fractiontoaccept = 1.*maxevents / totalevents
152 
153  with open(outputfile, "w") as f:
154  f.write("#"+self.headercomment+"\n")
155  f.write(validationheader)
156  for datafile in self.getfiles(usecache):
157  if all(run in runrange for run in datafile.runs):
158  if accepted == 0 or accepted / (accepted+rejected) <= fractiontoaccept:
159  f.write('"' + datafile.filename + '",\n')
160  accepted += datafile.nevents
161  else:
162  rejected += datafile.nevents
163  elif any(run in runrange for run in datafile.runs):
164  raise DatasetError("file {} has multiple runs {}, which straddle firstrun or lastrun".format(datafile.filename, datafile.runs))
165  f.write("#total events in these files: {}".format(accepted))
166  f.write(validationfooter)
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
def writefilelist_validation
Definition: dataset.py:138

Member Data Documentation

dataset.DatasetBase.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 128 of file dataset.py.