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

 applyPVConstraint
 
 APVmode
 Options for cosmics Get APV mode. More...
 
 Bfield
 
 CPEtype
 
 datatype
 
 flag
 
 GlobalTag
 
 GTtoGet
 
 hitfiltercommands
 
 LumiJSON
 
 optdict
 
 overallweight
 
 PVtype
 Options for mMin. More...
 
 rawopt
 
 TBDconstraint
 Get options common in min. More...
 
 TBDsel
 
 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 260 of file HipPyOptionParser.py.

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

260  def checkOptions(self):
261  optstocheck=[]
262  checkcosmics=(self.flag=="cosmics" or self.flag=="cdcs")
263  checkymumuconstr=(self.flag=="ymumu" and hasattr(self, "TBDconstraint"))
264  if checkcosmics:
265  optstocheck=[
266  "Bfield",
267  "APVmode",
268  "useTrkSplittingInCosmics"
269  ]
270  if checkymumuconstr:
271  optstocheck=[
272  "TBDsel"
273  ]
274  self.doCheckOptions(optstocheck)
275 
def HipPyOptionParser.HipPyOptionParser.doCheckOptions (   self,
  optstocheck 
)

Definition at line 250 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.flag.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions().

250  def doCheckOptions(self,optstocheck):
251  # First check option consistencies overall
252  if (hasattr(self,"TBDconstraint") and hasattr(self,"applyPVConstraint")):
253  raise RuntimeError("Options TBDconstraint and applyPVConstraint cannot coexist.")
254  # Force presence of the options passed
255  for oc in optstocheck:
256  if not hasattr(self,oc):
257  raise RuntimeError("Option {} needs to specified in {}.".format(oc, self.flag))
258 
259 
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 hits to drop or keep
151  elif key=="hitfiltercommands":
152  vallist=val.split(';')
153  for iv in range(0,len(vallist)):
154  keepdrop_det_pair=vallist[iv].split('=')
155  if len(keepdrop_det_pair)==2:
156  if (keepdrop_det_pair[0]=="keep" or keepdrop_det_pair[0]=="drop"):
157  strcmd = keepdrop_det_pair[0]
158 
159  keepdrop_det_pair[1]=keepdrop_det_pair[1].replace('/',' ') # e.g. 'PIX/2' instead of 'PIX 2'
160  keepdrop_det_pair[1]=keepdrop_det_pair[1].upper()
161 
162  strcmd = strcmd + " " + keepdrop_det_pair[1]
163  if not hasattr(self,"hitfiltercommands"):
165  self.hitfiltercommands.append(strcmd)
166  else:
167  raise RuntimeError("Keep/drop command {} is not keep or drop.".format(keepdrop_det_pair[0]))
168  else:
169  raise RuntimeError("Keep/drop-det. pair {} does not have size==2 or has a command other than keep or drop.".format(vallist[iv]))
170  # Get data type
171  elif (key=="type" or key=="datatype" or key=="datagroup"):
172  try:
173  dtype=int(val)
174  self.datatype=dtype
175  except ValueError:
176  print "Data type is not an integer"
177  # Get lumi json file
178  elif key=="lumilist":
179  self.LumiJSON = LumiList.LumiList(filename = val).getVLuminosityBlockRange()
180  # Get CPE type
181  elif key=="cpe" or key=="cpetype":
182  val=val.lower()
183  self.CPEtype=val
184  # Get non-standard track collection name
185  elif key=="trackcollection":
186  self.trkcoll=val
187  # Get overall weight. Turns reweighting on
188  elif key=="overallweight":
189  try:
190  fval=float(val)
191  self.overallweight=fval
192  except ValueError:
193  print "Overall weight is not a float"
194  # Get uniform eta formula. Turns reweighting on
195  elif key=="uniformetaformula":
197  ## Options for mMin. bias
198  # Apply vertex constraint
199  elif (key=="primaryvertextpye" or key=="pvtype"):
200  val=val.lower()
201  if (val=="nobs" or val=="withbs"):
202  self.PVtype=val
203  else:
204  raise ValueError("PV type can only receive NoBS or WithBS.")
205  elif (key=="primaryvertexconstraint" or key=="pvconstraint"):
207  if not hasattr(self,"PVtype"):
208  self.PVtype="nobs"
209  # Get custom track selection for TBD
210  elif (key=="twobodytrackselection" or key=="twobodydecayselection" or key=="tbdselection"):
211  val=val.lower()
212  if (val=="zsel" or val=="y1ssel"):
213  self.TBDsel=val
214  else:
215  raise ValueError("TBD selection can only be Zsel or Y1Ssel at this time.")
216  ## Get options common in min. bias, Zmumu and Ymumu
217  # Get TBD constraint type
218  elif (key=="twobodytrackconstraint" or key=="twobodydecayconstraint" or key=="tbdconstraint"):
219  val=val.lower()
220  if ("momconstr" in val or "fullconstr" in val):
221  self.TBDconstraint=val
222  else:
223  raise ValueError("TBD constraint can only be momconstr... or fullconstr...")
224  ## Options for cosmics
225  # Get APV mode
226  elif key=="apvmode":
227  val=val.lower()
228  if (val=="peak" or val=="deco"):
229  self.APVmode=val
230  else:
231  raise ValueError("APV mode can only be peak or deco in cosmics")
232  # Get magnetic field value
233  elif key=="bfield":
234  val=val.lower()
235  if (val=="0t" or val=="zerotesla" or val=="3.8t"):
236  self.Bfield=val
237  else:
238  raise ValueError("B field can only be 0T, ZEROTESLA or 3.8T")
239  elif key=="usetracksplitting":
241  else:
242  raise RuntimeError("Option {} is not implemented.".format(key))
243 
244  if len(gttogetpsets)>0:
245  self.GTtoGet = cms.VPSet()
246  for ps in gttogetpsets:
247  insertPSetToVPSet(ps,self.GTtoGet)
248 
249 
def replace(string, replacements)
TBDconstraint
Get options common in min.
def insertPSetToVPSet(inPSet, outVPSet)
def insertValToPSet(name, val, thePSet)
def parseBoolString(theString)
double split
Definition: MVATrainer.cc:139
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.applyPVConstraint

Definition at line 206 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.APVmode

Options for cosmics Get APV mode.

Definition at line 229 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 245 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.hitfiltercommands

Definition at line 164 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.LumiJSON

Definition at line 179 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.optdict
HipPyOptionParser.HipPyOptionParser.overallweight

Definition at line 191 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.PVtype

Options for mMin.

bias Apply vertex constraint

Definition at line 202 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 221 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.TBDsel

Definition at line 213 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.trkcoll

Definition at line 76 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.uniformetaformula

Definition at line 196 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.useTrkSplittingInCosmics

Definition at line 89 of file HipPyOptionParser.py.