CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
validateAlignments.ValidationJob Class Reference

— Classes —############################ More...

Public Member Functions

def __init__
 
def createJob
 
def getValidation
 
def runJob
 

Public Attributes

 validation
 

Private Member Functions

def __createJob
 
def __getValidation
 

Private Attributes

 __commandLineOptions
 
 __config
 
 __scripts
 
 __valName
 
 __valType
 

Detailed Description

— Classes —############################

Definition at line 38 of file validateAlignments.py.

Constructor & Destructor Documentation

def validateAlignments.ValidationJob.__init__ (   self,
  validation,
  config,
  options 
)

Definition at line 39 of file validateAlignments.py.

References split.

39 
40  def __init__( self, validation, config, options ):
41  if validation[1] == "":
42  # intermediate syntax
43  valString = validation[0].split( "->" )[0]
44  alignments = validation[0].split( "->" )[1]
45  # force user to use the normal syntax
46  if "->" in validation[0]:
47  msg = ("Instead of using the intermediate syntax\n'"
48  +valString.strip()+"-> "+alignments.strip()
49  +":'\nyou have to use the now fully supported syntax \n'"
50  +valString.strip()+": "
51  +alignments.strip()+"'.")
52  raise AllInOneError(msg)
53  else:
54  valString = validation[0]
55  alignments = validation[1]
56  valString = valString.split()
57  self.__valType = valString[0]
58  self.__valName = valString[1]
59  self.__commandLineOptions = options
60  self.__config = config
61  # workaround for intermediate parallel version
62  if self.__valType == "offlineParallel":
63  section = "offline" + ":" + self.__valName
64  else:
65  section = self.__valType + ":" + self.__valName
66  if not self.__config.has_section( section ):
67  raise AllInOneError, ("Validation '%s' of type '%s' is requested in"
68  " '[validation]' section, but is not defined."
69  "\nYou have to add a '[%s]' section."
70  %( self.__valName, self.__valType, section ))
71  self.validation = self.__getValidation( self.__valType, self.__valName,
72  alignments, self.__config,
73  options )
double split
Definition: MVATrainer.cc:139

Member Function Documentation

def validateAlignments.ValidationJob.__createJob (   self,
  jobMode,
  outpath 
)
private
This private method creates the needed files for the validation job.

Definition at line 137 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.createJob().

138  def __createJob( self, jobMode, outpath ):
139  """This private method creates the needed files for the validation job.
140  """
141  self.validation.createConfiguration( outpath )
142  self.__scripts = self.validation.createScript( outpath )
143  if jobMode.split( ',' )[0] == "crab":
144  self.validation.createCrabCfg( outpath )
145  return None
def validateAlignments.ValidationJob.__getValidation (   self,
  valType,
  name,
  alignments,
  config,
  options 
)
private

Definition at line 74 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, and split.

74 
75  def __getValidation( self, valType, name, alignments, config, options ):
76  if valType == "compare":
77  alignmentsList = alignments.split( "," )
78  firstAlignList = alignmentsList[0].split()
79  firstAlignName = firstAlignList[0].strip()
80  if firstAlignName == "IDEAL":
81  raise AllInOneError, ("'IDEAL' has to be the second (reference)"
82  " alignment in 'compare <val_name>: "
83  "<alignment> <reference>'.")
84  if len( firstAlignList ) > 1:
85  firstRun = firstAlignList[1]
86  else:
87  firstRun = "1"
88  firstAlign = Alignment( firstAlignName, self.__config, firstRun )
89  secondAlignList = alignmentsList[1].split()
90  secondAlignName = secondAlignList[0].strip()
91  if len( secondAlignList ) > 1:
92  secondRun = secondAlignList[1]
93  else:
94  secondRun = "1"
95  if secondAlignName == "IDEAL":
96  secondAlign = secondAlignName
97  else:
98  secondAlign = Alignment( secondAlignName, self.__config,
99  secondRun )
100  # check if alignment was already compared previously
101  try:
102  randomWorkdirPart = \
103  globalDictionaries.alignRandDict[firstAlignName]
104  except KeyError:
105  randomWorkdirPart = None
106 
107  validation = GeometryComparison( name, firstAlign, secondAlign,
108  self.__config,
109  self.__commandLineOptions.getImages,
110  randomWorkdirPart )
111  globalDictionaries.alignRandDict[firstAlignName] = \
112  validation.randomWorkdirPart
113  if not secondAlignName == "IDEAL":
114  globalDictionaries.alignRandDict[secondAlignName] = \
115  validation.randomWorkdirPart
116  elif valType == "offline":
117  validation = OfflineValidation( name,
118  Alignment( alignments.strip(), self.__config ), self.__config )
119  elif valType == "offlineDQM":
120  validation = OfflineValidationDQM( name,
121  Alignment( alignments.strip(), self.__config ), self.__config )
122  elif valType == "offlineParallel":
123  validation = OfflineValidationParallel( name,
124  Alignment( alignments.strip(), self.__config ), self.__config )
125  elif valType == "mcValidate":
126  validation = MonteCarloValidation( name,
127  Alignment( alignments.strip(), self.__config ), self.__config )
128  elif valType == "split":
129  validation = TrackSplittingValidation( name,
130  Alignment( alignments.strip(), self.__config ), self.__config )
131  elif valType == "zmumu":
132  validation = ZMuMuValidation( name,
133  Alignment( alignments.strip(), self.__config ), self.__config )
134  else:
135  raise AllInOneError, "Unknown validation mode '%s'"%valType
136  return validation
double split
Definition: MVATrainer.cc:139
def validateAlignments.ValidationJob.createJob (   self)
This is the method called to create the job files.

Definition at line 146 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

147  def createJob(self):
148  """This is the method called to create the job files."""
149  self.__createJob( self.validation.jobmode,
150  os.path.abspath( self.__commandLineOptions.Name) )
def validateAlignments.ValidationJob.getValidation (   self)

Definition at line 198 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

199  def getValidation( self ):
200  return self.validation
201 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 151 of file validateAlignments.py.

References validateAlignments.ValidationJob.__scripts, validateAlignments.ValidationJob.__valName, validateAlignments.ValidationJob.__valType, cmsRelvalreport.exit, helperFunctions.getCommandOutput2(), and split.

152  def runJob( self ):
153  general = self.__config.getGeneral()
154  log = ""
155  for script in self.__scripts:
156  name = os.path.splitext( os.path.basename( script) )[0]
157  if self.__commandLineOptions.dryRun:
158  print "%s would run: %s"%( name, os.path.basename( script) )
159  continue
160  log = "> Validating "+name
161  print "> Validating "+name
162  if self.validation.jobmode == "interactive":
163  log += getCommandOutput2( script )
164  elif self.validation.jobmode.split(",")[0] == "lxBatch":
165  repMap = {
166  "commands": self.validation.jobmode.split(",")[1],
167  "logDir": general["logdir"],
168  "jobName": name,
169  "script": script,
170  "bsub": "/afs/cern.ch/cms/caf/scripts/cmsbsub"
171  }
172  log+=getCommandOutput2("%(bsub)s %(commands)s -J %(jobName)s "
173  "-o %(logDir)s/%(jobName)s.stdout -e "
174  "%(logDir)s/%(jobName)s.stderr "
175  "%(script)s"%repMap)
176  elif self.validation.jobmode.split( "," )[0] == "crab":
177  os.chdir( general["logdir"] )
178  crabName = "crab." + os.path.basename( script )[:-3]
179  theCrab = crabWrapper.CrabWrapper()
180  options = { "-create": "",
181  "-cfg": crabName + ".cfg",
182  "-submit": "" }
183  try:
184  theCrab.run( options )
185  except AllInOneError, e:
186  print "crab:", str(e).split("\n")[0]
187  exit(1)
188  else:
189  raise AllInOneError, ("Unknown 'jobmode'!\n"
190  "Please change this parameter either in "
191  "the [general] or in the ["
192  + self.__valType + ":" + self.__valName
193  + "] section to one of the following "
194  "values:\n"
195  "\tinteractive\n\tlxBatch, -q <queue>\n"
196  "\tcrab, -q <queue>")
197  return log
double split
Definition: MVATrainer.cc:139

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 58 of file validateAlignments.py.

validateAlignments.ValidationJob.__config
private

Definition at line 59 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__getValidation().

validateAlignments.ValidationJob.__scripts
private

Definition at line 141 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 57 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 56 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.validation

Definition at line 70 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.getValidation().