test
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
alignment.Alignment Class Reference

Public Member Functions

def __init__
 
def getConditions
 
def getRepMap
 
def restrictTo
 

Public Attributes

 color
 
 conditions
 
 condShorts
 
 globaltag
 
 mode
 
 name
 
 runGeomComp
 
 style
 
 title
 

Private Member Functions

def __getConditions
 
def __shorthandExists
 
def __testDbExist
 

Detailed Description

Definition at line 7 of file alignment.py.

Constructor & Destructor Documentation

def alignment.Alignment.__init__ (   self,
  name,
  config,
  runGeomComp = "1" 
)

Definition at line 8 of file alignment.py.

8 
9  def __init__(self, name, config, runGeomComp = "1"):
10  self.condShorts = {
11  "TrackerAlignmentErrorExtendedRcd": {
12  "zeroAPE": {
13  "connectString":("frontier://FrontierProd"
14  "/CMS_CONDITIONS"),
15  "tagName": "TrackerIdealGeometryErrorsExtended210_mc",
16  "labelName": ""
17  }
18  },
19  "TrackerSurfaceDeformationRcd": {
20  "zeroDeformations": {
21  "connectString":("frontier://FrontierProd"
22  "/CMS_CONDITIONS"),
23  "tagName": "TrackerSurfaceDeformations_zero",
24  "labelName": ""
25  }
26  },
27  }
28  section = "alignment:%s"%name
29  if not config.has_section( section ):
30  raise AllInOneError, ("section %s not found. Please define the "
31  "alignment!"%section)
32  config.checkInput(section,
33  knownSimpleOptions = ['globaltag', 'style', 'color', 'title'],
34  knownKeywords = ['condition'])
35  self.name = name
36  if config.exists(section,"title"):
37  self.title = config.get(section,"title")
38  else:
39  self.title = self.name
40  if (int(runGeomComp) != 1):
41  self.name += "_run" + runGeomComp
42  self.title += " run " + runGeomComp
43  if "|" in self.title or "," in self.title or '"' in self.title:
44  msg = "The characters '|', '\"', and ',' cannot be used in the alignment title!"
45  raise AllInOneError(msg)
46  self.runGeomComp = runGeomComp
47  self.globaltag = config.get( section, "globaltag" )
48  self.conditions = self.__getConditions( config, section )
49 
50  self.color = config.get(section,"color")
51  self.style = config.get(section,"style")
52  try: #make sure color is an int
53  int(self.color)
54  except ValueError:
55  try: #kRed, kBlue, ...
56  self.color = str(getattr(ROOT, self.color))
57  int(self.color)
58  except (AttributeError, ValueError):
59  raise ValueError("color has to be an integer or a ROOT constant (kRed, kBlue, ...)!")
60  try: #make sure style is an int
61  int(self.style)
62  except ValueError:
63  raise ValueError("style has to be an integer!")

Member Function Documentation

def alignment.Alignment.__getConditions (   self,
  theConfig,
  theSection 
)
private

Definition at line 80 of file alignment.py.

References alignment.Alignment.__shorthandExists(), alignment.Alignment.condShorts, join(), and split.

80 
81  def __getConditions( self, theConfig, theSection ):
82  conditions = []
83  for option in theConfig.options( theSection ):
84  if option.startswith( "condition " ):
85  rcdName = option.split( "condition " )[1]
86  condPars = theConfig.get( theSection, option ).split( "," )
87  if len(condPars) == 1:
88  if len(condPars[0])==0:
89  msg = ("In section [%s]: '%s' is used with too few "
90  "arguments. A connect_string and a tag are "
91  "required!"%(theSection, option))
92  raise AllInOneError(msg)
93  elif self.__shorthandExists(rcdName, condPars[0]):
94  shorthand = condPars[0]
95  condPars = [
96  self.condShorts[rcdName][shorthand]["connectString"],
97  self.condShorts[rcdName][shorthand]["tagName"],
98  self.condShorts[rcdName][shorthand]["labelName"]]
99  else:
100  msg = ("In section [%s]: '%s' is used with '%s', "
101  "which is an unknown shorthand for '%s'. Either "
102  "provide at least a connect_string and a tag or "
103  "use a known shorthand.\n"
104  %(theSection, option, condPars[0], rcdName))
105  if rcdName in self.condShorts:
106  msg += "Known shorthands for '%s':\n"%(rcdName)
107  theShorts = self.condShorts[rcdName]
108  knownShorts = [("\t"+key+": "
109  +theShorts[key]["connectString"]+","
110  +theShorts[key]["tagName"]+","
111  +theShorts[key]["labelName"]) \
112  for key in theShorts]
113  msg+="\n".join(knownShorts)
114  else:
115  msg += ("There are no known shorthands for '%s'."
116  %(rcdName))
117  raise AllInOneError(msg)
118  if len( condPars ) == 2:
119  condPars.append( "" )
120  if len(condPars) > 3:
121  msg = ("In section [%s]: '%s' is used with too many "
122  "arguments. A maximum of 3 arguments is allowed."
123  %(theSection, option))
124  raise AllInOneError(msg)
125  conditions.append({"rcdName": rcdName.strip(),
126  "connectString": condPars[0].strip(),
127  "tagName": condPars[1].strip(),
128  "labelName": condPars[2].strip()})
129  return conditions
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
double split
Definition: MVATrainer.cc:139
def alignment.Alignment.__shorthandExists (   self,
  theRcdName,
  theShorthand 
)
private
Method which checks, if `theShorthand` is a valid shorthand for the
given `theRcdName`.

Arguments:
- `theRcdName`: String which specifies the database record.
- `theShorthand`: String which specifies the shorthand to check.

Definition at line 64 of file alignment.py.

References alignment.Alignment.condShorts.

Referenced by alignment.Alignment.__getConditions().

64 
65  def __shorthandExists(self, theRcdName, theShorthand):
66  """Method which checks, if `theShorthand` is a valid shorthand for the
67  given `theRcdName`.
68 
69  Arguments:
70  - `theRcdName`: String which specifies the database record.
71  - `theShorthand`: String which specifies the shorthand to check.
72  """
73 
74  if (theRcdName in self.condShorts) and \
75  (theShorthand in self.condShorts[theRcdName]):
76  return True
77  else:
78  return False
79 
def alignment.Alignment.__testDbExist (   self,
  dbpath 
)
private

Definition at line 130 of file alignment.py.

131  def __testDbExist(self, dbpath):
132  #FIXME delete return to end train debuging
133  return
134  if not dbpath.startswith("sqlite_file:"):
135  print "WARNING: could not check existence for",dbpath
136  else:
137  if not os.path.exists( dbpath.split("sqlite_file:")[1] ):
138  raise "could not find file: '%s'"%dbpath.split("sqlite_file:")[1]
def alignment.Alignment.getConditions (   self)
This function creates the configuration snippet to override
   global tag conditions.

Definition at line 158 of file alignment.py.

References alignment.Alignment.conditions, and helperFunctions.replaceByMap().

159  def getConditions(self):
160  """This function creates the configuration snippet to override
161  global tag conditions.
162  """
163  if len( self.conditions ):
164  loadCond = ("\nimport CalibTracker.Configuration."
165  "Common.PoolDBESSource_cfi\n")
166  for cond in self.conditions:
167  if not cond["labelName"] == "":
168  temp = configTemplates.conditionsTemplate.replace(
169  "tag = cms.string('.oO[tagName]Oo.')",
170  ("tag = cms.string('.oO[tagName]Oo.'),"
171  "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
172  else:
173  temp = configTemplates.conditionsTemplate
174  loadCond += replaceByMap( temp, cond )
175  else:
176  loadCond = ""
177  return loadCond
def replaceByMap
— Helpers —############################
def alignment.Alignment.getRepMap (   self)

Definition at line 147 of file alignment.py.

References alignment.Alignment.color, alignment.Alignment.globaltag, entry.name, alignment.Alignment.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, plotscripts.SawTeethFunction.name, alignment.Alignment.runGeomComp, alignment.Alignment.style, and alignment.Alignment.title.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToExtendedValidation(), offlineValidation.OfflineValidation.appendToExtendedValidation(), preexistingValidation.PreexistingOfflineValidation.appendToExtendedValidation(), preexistingValidation.PreexistingTrackSplittingValidation.appendToExtendedValidation(), trackSplittingValidation.TrackSplittingValidation.appendToMerge(), offlineValidation.OfflineValidation.appendToMerge(), trackSplittingValidation.TrackSplittingValidation.createConfiguration(), monteCarloValidation.MonteCarloValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), geometryComparison.GeometryComparison.createConfiguration(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), and preexistingValidation.PreexistingValidation.getCompareStrings().

148  def getRepMap( self ):
149  result = {
150  "name": self.name,
151  "title": self.title,
152  "color": self.color,
153  "style": self.style,
154  "runGeomComp": self.runGeomComp,
155  "GlobalTag": self.globaltag
156  }
157  return result
def alignment.Alignment.restrictTo (   self,
  restriction 
)

Definition at line 139 of file alignment.py.

References alignment.Alignment.mode, and svgfig.Poly.mode.

140  def restrictTo( self, restriction ):
141  result = []
142  if not restriction == None:
143  for mode in self.mode:
144  if mode in restriction:
145  result.append( mode )
146  self.mode = result

Member Data Documentation

alignment.Alignment.color

Definition at line 49 of file alignment.py.

Referenced by cuy.plotElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), and alignment.Alignment.getRepMap().

alignment.Alignment.conditions

Definition at line 47 of file alignment.py.

Referenced by alignment.Alignment.getConditions().

alignment.Alignment.condShorts

Definition at line 9 of file alignment.py.

Referenced by alignment.Alignment.__getConditions(), and alignment.Alignment.__shorthandExists().

alignment.Alignment.globaltag

Definition at line 46 of file alignment.py.

Referenced by alignment.Alignment.getRepMap(), and cmsHarvester.CMSHarvester.option_handler_globaltag().

alignment.Alignment.mode

Definition at line 145 of file alignment.py.

Referenced by alignment.Alignment.restrictTo().

alignment.Alignment.name

Definition at line 34 of file alignment.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), dirstructure.Directory.__create_pie_image(), dqm_interfaces.DirID.__eq__(), BeautifulSoup.Tag.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), dirstructure.Comparison.__make_image(), core.autovars.NTupleVariable.__repr__(), core.autovars.NTupleObjectType.__repr__(), core.autovars.NTupleObject.__repr__(), core.autovars.NTupleCollection.__repr__(), dirstructure.Directory.__repr__(), dqm_interfaces.DirID.__repr__(), dirstructure.Comparison.__repr__(), config.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), BeautifulSoup.Tag.__str__(), BeautifulSoup.SoupStrainer.__str__(), core.autovars.NTupleObjectType.addSubObjects(), core.autovars.NTupleObjectType.addVariables(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), monteCarloValidation.MonteCarloValidation.createConfiguration(), trackSplittingValidation.TrackSplittingValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), validation.Sample.digest(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), TreeCrawler.Package.dump(), core.autovars.NTupleVariable.fillBranch(), core.autovars.NTupleObject.fillBranches(), core.autovars.NTupleCollection.fillBranchesScalar(), core.autovars.NTupleCollection.fillBranchesVector(), core.autovars.NTupleCollection.get_cpp_declaration(), core.autovars.NTupleCollection.get_cpp_wrapper_class(), core.autovars.NTupleCollection.get_py_wrapper_class(), utils.StatisticalTest.get_status(), production_tasks.Task.getname(), dataset.CMSDataset.getPrimaryDatasetEntries(), dataset.PrivateDataset.getPrimaryDatasetEntries(), zMuMuValidation.ZMuMuValidation.getRepMap(), alignment.Alignment.getRepMap(), genericValidation.GenericValidationData.getRepMap(), VIDSelectorBase.VIDSelectorBase.initialize(), personalPlayback.Applet.log(), core.autovars.NTupleVariable.makeBranch(), core.autovars.NTupleObject.makeBranches(), core.autovars.NTupleCollection.makeBranchesScalar(), core.autovars.NTupleCollection.makeBranchesVector(), dirstructure.Directory.print_report(), dataset.BaseDataset.printInfo(), dataset.Dataset.printInfo(), production_tasks.MonitorJobs.run(), BeautifulSoup.SoupStrainer.searchTag(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), Vispa.Views.PropertyView.Property.valueChanged(), counter.Counter.write(), and average.Average.write().

alignment.Alignment.runGeomComp

Definition at line 45 of file alignment.py.

Referenced by alignment.Alignment.getRepMap().

alignment.Alignment.style

Definition at line 50 of file alignment.py.

Referenced by alignment.Alignment.getRepMap(), and Formatter.SimpleHTMLFormatter.headers().

alignment.Alignment.title

Definition at line 36 of file alignment.py.

Referenced by cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), Vispa.Views.LineDecayView.LineDecayContainer.autolayout(), Vispa.Views.LineDecayView.LineDecayContainer.autolayoutThreadFinished(), python.rootplot.root2matplotlib.HistStack.bar(), python.rootplot.root2matplotlib.HistStack.bar3d(), python.rootplot.root2matplotlib.HistStack.barcluster(), python.rootplot.root2matplotlib.HistStack.barh(), python.rootplot.root2matplotlib.HistStack.barstack(), Vispa.Views.LineDecayView.LineDecayContainer.childFinishedAutolayouting(), python.rootplot.root2matplotlib.HistStack.errorbar(), python.rootplot.root2matplotlib.HistStack.errorbarh(), alignment.Alignment.getRepMap(), Formatter.SimpleHTMLFormatter.headers(), python.rootplot.root2matplotlib.HistStack.histstack(), Vispa.Gui.PortWidget.PortWidget.name(), python.rootplot.root2matplotlib.Hist.show_titles(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), python.rootplot.utilities.Hist2D.TH2F(), and python.rootplot.root2matplotlib.Hist2D.TH2F().