CMS 3D CMS Logo

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 (self, usecache)
 
def headercomment (self)
 
def writefilelist_hippy (self, firstrun, lastrun, runs, eventsperjob, maxevents, outputfile, usecache=True)
 
def writefilelist_validation (self, firstrun, lastrun, runs, maxevents, outputfile=None, usecache=True)
 

Static Private Attributes

 __metaclass__ = abc.ABCMeta
 

Detailed Description

Definition at line 127 of file dataset.py.

Member Function Documentation

◆ getfiles()

def dataset.DatasetBase.getfiles (   self,
  usecache 
)

Reimplemented in dataset.MultipleDatasets, and dataset.Dataset.

Definition at line 131 of file dataset.py.

131  def getfiles(self, usecache):
132  pass
133 

Referenced by dataset.DatasetBase.writefilelist_hippy().

◆ headercomment()

def dataset.DatasetBase.headercomment (   self)

Reimplemented in dataset.MultipleDatasets, and dataset.Dataset.

Definition at line 135 of file dataset.py.

135  def headercomment(self):
136  pass
137 

◆ writefilelist_hippy()

def dataset.DatasetBase.writefilelist_hippy (   self,
  firstrun,
  lastrun,
  runs,
  eventsperjob,
  maxevents,
  outputfile,
  usecache = True 
)

Definition at line 167 of file dataset.py.

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

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

◆ writefilelist_validation()

def dataset.DatasetBase.writefilelist_validation (   self,
  firstrun,
  lastrun,
  runs,
  maxevents,
  outputfile = None,
  usecache = True 
)

Definition at line 138 of file dataset.py.

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

Member Data Documentation

◆ __metaclass__

dataset.DatasetBase.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 128 of file dataset.py.

dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
align::RunRange
std::pair< RunNumber, RunNumber > RunRange
Definition: Utilities.h:38
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:26
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
format