CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
HipPyOptionParser.HipPyOptionParser Class Reference

Public Member Functions

def __init__ (self, strflag, stropt)
 
def checkOptions (self)
 
def doCheckOptions (self, optstocheck)
 
def getTrackDefaults (self)
 
def interpretOptions (self)
 
def parseOptions (self)
 

Public Attributes

 APVmode
 Options for cosmics Get APV mode. More...
 
 Bfield
 
 CPEtype
 
 datatype
 
 flag
 
 GlobalTag
 
 GTtoGet
 
 LumiJSON
 
 optdict
 
 overallweight
 
 rawopt
 
 TBDconstraint
 Get options common in min. More...
 
 TBDsel
 Options for mMin. More...
 
 trkcoll
 
 uniformetaformula
 
 useTrkSplittingInCosmics
 

Detailed Description

Definition at line 58 of file HipPyOptionParser.py.

Constructor & Destructor Documentation

def HipPyOptionParser.HipPyOptionParser.__init__ (   self,
  strflag,
  stropt 
)

Definition at line 59 of file HipPyOptionParser.py.

Member Function Documentation

def HipPyOptionParser.HipPyOptionParser.checkOptions (   self)

Definition at line 225 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.doCheckOptions(), and HipPyOptionParser.HipPyOptionParser.flag.

225  def checkOptions(self):
226  optstocheck=[]
227  checkcosmics=(self.flag=="cosmics" or self.flag=="cdcs")
228  checkymumuconstr=(self.flag=="ymumu" and hasattr(self, "TBDconstraint"))
229  if checkcosmics:
230  optstocheck=[
231  "Bfield",
232  "APVmode",
233  "useTrkSplittingInCosmics"
234  ]
235  if checkymumuconstr:
236  optstocheck=[
237  "TBDsel"
238  ]
239  self.doCheckOptions(optstocheck)
240 
def HipPyOptionParser.HipPyOptionParser.doCheckOptions (   self,
  optstocheck 
)

Definition at line 219 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.flag.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions().

219  def doCheckOptions(self,optstocheck):
220  for oc in optstocheck:
221  if not hasattr(self,oc):
222  raise RuntimeError("Option {} needs to specified in {}.".format(oc, self.flag))
223 
224 
def HipPyOptionParser.HipPyOptionParser.getTrackDefaults (   self)

Definition at line 74 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.flag.

74  def getTrackDefaults(self):
75  if self.flag=="mbvertex":
76  self.trkcoll="ALCARECOTkAlMinBias"
77  self.Bfield="3.8t"
78  elif self.flag=="zmumu":
79  self.trkcoll="ALCARECOTkAlZMuMu"
80  self.Bfield="3.8t"
81  elif self.flag=="ymumu":
82  self.trkcoll="ALCARECOTkAlUpsilonMuMu"
83  self.Bfield="3.8t"
84  elif self.flag=="jpsimumu":
85  self.trkcoll="ALCARECOTkAlJpsiMuMu"
86  self.Bfield="3.8t"
87  elif self.flag=="cosmics":
88  self.trkcoll="ALCARECOTkAlCosmicsCTF0T"
90  elif self.flag=="cdcs":
91  self.trkcoll="ALCARECOTkAlCosmicsInCollisions"
92  self.useTrkSplittingInCosmics=False
93  else:
94  raise RuntimeError("Flag {} is unimplemented.".format(self.flag))
95 
96 
def HipPyOptionParser.HipPyOptionParser.interpretOptions (   self)

Definition at line 111 of file HipPyOptionParser.py.

111  def interpretOptions(self):
112  gttogetpsets=[]
113  for key,val in self.optdict.iteritems():
114  # Get GT name
115  if key=="gt":
116  autofind=val.find("auto")
117  if autofind>-1:
118  val=val[0:autofind+4]+":"+val[autofind+4:]
119  self.GlobalTag = val
120  # Get GT toGet PSets
121  elif key=="gtspecs":
122  vallist=val.split(';')
123  for varset in vallist:
124  apset = cms.PSet()
125  specs = varset.split('|')
126  for spec in specs:
127  namespec=spec.split('=')
128  if len(namespec)==2:
129  tmpspec=namespec[1]
130  frontierfind=tmpspec.find("frontier")
131  sqlitefind=tmpspec.find("sqlite_file")
132  if frontierfind>-1 and sqlitefind>-1:
133  raise RuntimeError("Inconsistent setting: Cannot specify frontier and sqlite_file at the same time!")
134  elif frontierfind>-1:
135  tmpspec=tmpspec[0:frontierfind+8]+":"+tmpspec[frontierfind+8:]
136  elif sqlitefind>-1:
137  tmpspec=tmpspec[0:sqlitefind+11]+":"+tmpspec[sqlitefind+11:]
138  elif namespec[0]=="connect":
139  if tmpspec.endswith(".db"):
140  tmpspec = str("sqlite_file:")+tmpspec
141  elif tmpspec.find("//")>-1:
142  tmpspec = str("frontier:")+tmpspec
143  else:
144  tmpspec = str("frontier://")+tmpspec
145  cmsstrspec = cms.string(tmpspec)
146  insertValToPSet(namespec[0],cmsstrspec,apset)
147  else:
148  raise RuntimeError("GT specification {} does not have size==2".format(namespec))
149  gttogetpsets.append(apset)
150  # Get data type
151  elif (key=="type" or key=="datatype" or key=="datagroup"):
152  try:
153  dtype=int(val)
154  self.datatype=dtype
155  except ValueError:
156  print "Data type is not an integer"
157  # Get lumi json file
158  elif key=="lumilist":
159  self.LumiJSON = LumiList.LumiList(filename = val).getVLuminosityBlockRange()
160  # Get CPE type
161  elif key=="cpe" or key=="cpetype":
162  val=val.lower()
163  self.CPEtype=val
164  # Get non-standard track collection name
165  elif key=="trackcollection":
166  self.trkcoll=val
167  # Get overall weight. Turns reweighting on
168  elif key=="overallweight":
169  try:
170  fval=float(val)
171  self.overallweight=fval
172  except ValueError:
173  print "Overall weight is not a float"
174  # Get uniform eta formula. Turns reweighting on
175  elif key=="uniformetaformula":
177  ## Options for mMin. bias
178  # Get custom track selection for TBD
179  elif (key=="twobodytrackselection" or key=="twobodydecayselection" or key=="tbdselection"):
180  val=val.lower()
181  if (val=="zsel" or val=="y1sel"):
182  self.TBDsel=val
183  else:
184  raise ValueError("TBD selection can only be Zsel or Y1sel at this time.")
185  ## Get options common in min. bias, Zmumu and Ymumu
186  # Get TBD constraint type
187  elif (key=="twobodytrackconstraint" or key=="twobodydecayconstraint" or key=="tbdconstraint"):
188  val=val.lower()
189  if ("momconstr" in val or "fullconstr" in val):
190  self.TBDconstraint=val
191  else:
192  raise ValueError("TBD constraint can only be momconstr... or fullconstr...")
193  ## Options for cosmics
194  # Get APV mode
195  elif key=="apvmode":
196  val=val.lower()
197  if (val=="peak" or val=="deco"):
198  self.APVmode=val
199  else:
200  raise ValueError("APV mode can only be peak or deco in cosmics")
201  # Get magnetic field value
202  elif key=="bfield":
203  val=val.lower()
204  if (val=="0t" or val=="zerotesla" or val=="3.8t"):
205  self.Bfield=val
206  else:
207  raise ValueError("B field can only be 0T, ZEROTESLA or 3.8T")
208  elif key=="usetracksplitting":
210  else:
211  raise RuntimeError("Option {} is not implemented.".format(key))
212 
213  if len(gttogetpsets)>0:
214  self.GTtoGet = cms.VPSet()
215  for ps in gttogetpsets:
216  insertPSetToVPSet(ps,self.GTtoGet)
217 
218 
TBDconstraint
Get options common in min.
def insertPSetToVPSet(inPSet, outVPSet)
def insertValToPSet(name, val, thePSet)
def parseBoolString(theString)
APVmode
Options for cosmics Get APV mode.
def HipPyOptionParser.HipPyOptionParser.parseOptions (   self)

Definition at line 97 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.optdict.

97  def parseOptions(self):
98  delimiter=' '
99  optdelimiter=':'
100  optlist=self.rawopt.split(delimiter)
101  for sopt in optlist:
102  olist=sopt.split(optdelimiter)
103  if len(olist)==2:
104  theKey=olist[0].lower()
105  theVal=olist[1]
106  self.optdict[theKey]=theVal
107  else:
108  raise RuntimeError("Option {} has an invalid number of delimiters {}".format(sopt,optdelimiter))
109 
110 

Member Data Documentation

HipPyOptionParser.HipPyOptionParser.APVmode

Options for cosmics Get APV mode.

Definition at line 198 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.Bfield

Definition at line 77 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.CPEtype

Definition at line 66 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.datatype

Definition at line 65 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.GlobalTag

Definition at line 119 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.GTtoGet

Definition at line 214 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.LumiJSON

Definition at line 159 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.optdict
HipPyOptionParser.HipPyOptionParser.overallweight

Definition at line 171 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.rawopt

Definition at line 62 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.TBDconstraint

Get options common in min.

bias, Zmumu and Ymumu Get TBD constraint type

Definition at line 190 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.TBDsel

Options for mMin.

bias Get custom track selection for TBD

Definition at line 182 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.trkcoll

Definition at line 76 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.uniformetaformula

Definition at line 176 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.useTrkSplittingInCosmics

Definition at line 89 of file HipPyOptionParser.py.