CMS 3D CMS Logo

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

Public Member Functions

def __init__
 
def checkOptions
 
def doCheckOptions
 
def getTrackDefaults
 
def interpretOptions
 
def parseOptions
 

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 59 of file HipPyOptionParser.py.

Constructor & Destructor Documentation

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

Member Function Documentation

def HipPyOptionParser.HipPyOptionParser.checkOptions (   self)

Definition at line 261 of file HipPyOptionParser.py.

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

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

Definition at line 251 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.flag.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions().

252  def doCheckOptions(self,optstocheck):
253  # First check option consistencies overall
254  if (hasattr(self,"TBDconstraint") and hasattr(self,"applyPVConstraint")):
255  raise RuntimeError("Options TBDconstraint and applyPVConstraint cannot coexist.")
256  # Force presence of the options passed
257  for oc in optstocheck:
258  if not hasattr(self,oc):
259  raise RuntimeError("Option {} needs to specified in {}.".format(oc, self.flag))
260 
def HipPyOptionParser.HipPyOptionParser.getTrackDefaults (   self)

Definition at line 75 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.flag.

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

Definition at line 112 of file HipPyOptionParser.py.

113  def interpretOptions(self):
114  gttogetpsets=[]
115  for key,val in self.optdict.items():
116  # Get GT name
117  if key=="gt":
118  autofind=val.find("auto")
119  if autofind>-1:
120  val=val[0:autofind+4]+":"+val[autofind+4:]
121  self.GlobalTag = val
122  # Get GT toGet PSets
123  elif key=="gtspecs":
124  vallist=val.split(';')
125  for varset in vallist:
126  apset = cms.PSet()
127  specs = varset.split('|')
128  for spec in specs:
129  namespec=spec.split('=')
130  if len(namespec)==2:
131  tmpspec=namespec[1]
132  frontierfind=tmpspec.find("frontier")
133  sqlitefind=tmpspec.find("sqlite_file")
134  if frontierfind>-1 and sqlitefind>-1:
135  raise RuntimeError("Inconsistent setting: Cannot specify frontier and sqlite_file at the same time!")
136  elif frontierfind>-1:
137  tmpspec=tmpspec[0:frontierfind+8]+":"+tmpspec[frontierfind+8:]
138  elif sqlitefind>-1:
139  tmpspec=tmpspec[0:sqlitefind+11]+":"+tmpspec[sqlitefind+11:]
140  elif namespec[0]=="connect":
141  if tmpspec.endswith(".db"):
142  tmpspec = str("sqlite_file:")+tmpspec
143  elif tmpspec.find("//")>-1:
144  tmpspec = str("frontier:")+tmpspec
145  else:
146  tmpspec = str("frontier://")+tmpspec
147  cmsstrspec = cms.string(tmpspec)
148  insertValToPSet(namespec[0],cmsstrspec,apset)
149  else:
150  raise RuntimeError("GT specification {} does not have size==2".format(namespec))
151  gttogetpsets.append(apset)
152  # Get hits to drop or keep
153  elif key=="hitfiltercommands":
154  vallist=val.split(';')
155  for iv in range(0,len(vallist)):
156  keepdrop_det_pair=vallist[iv].split('=')
157  if len(keepdrop_det_pair)==2:
158  if (keepdrop_det_pair[0]=="keep" or keepdrop_det_pair[0]=="drop"):
159  strcmd = keepdrop_det_pair[0]
160 
161  keepdrop_det_pair[1]=keepdrop_det_pair[1].replace('/',' ') # e.g. 'PIX/2' instead of 'PIX 2'
162  keepdrop_det_pair[1]=keepdrop_det_pair[1].upper()
163 
164  strcmd = strcmd + " " + keepdrop_det_pair[1]
165  if not hasattr(self,"hitfiltercommands"):
166  self.hitfiltercommands=[]
167  self.hitfiltercommands.append(strcmd)
168  else:
169  raise RuntimeError("Keep/drop command {} is not keep or drop.".format(keepdrop_det_pair[0]))
170  else:
171  raise RuntimeError("Keep/drop-det. pair {} does not have size==2 or has a command other than keep or drop.".format(vallist[iv]))
172  # Get data type
173  elif (key=="type" or key=="datatype" or key=="datagroup"):
174  try:
175  dtype=int(val)
176  self.datatype=dtype
177  except ValueError:
178  print("Data type is not an integer")
179  # Get lumi json file
180  elif key=="lumilist":
181  self.LumiJSON = LumiList.LumiList(filename = val).getVLuminosityBlockRange()
182  # Get CPE type
183  elif key=="cpe" or key=="cpetype":
184  val=val.lower()
185  self.CPEtype=val
186  # Get non-standard track collection name
187  elif key=="trackcollection":
188  self.trkcoll=val
189  # Get overall weight. Turns reweighting on
190  elif key=="overallweight":
191  try:
192  fval=float(val)
193  self.overallweight=fval
194  except ValueError:
195  print("Overall weight is not a float")
196  # Get uniform eta formula. Turns reweighting on
197  elif key=="uniformetaformula":
198  self.uniformetaformula=val
199  ## Options for mMin. bias
200  # Apply vertex constraint
201  elif (key=="primaryvertextype" or key=="pvtype"):
202  val=val.lower()
203  if (val=="nobs" or val=="withbs"):
204  self.PVtype=val
205  else:
206  raise ValueError("PV type can only receive NoBS or WithBS.")
207  elif (key=="primaryvertexconstraint" or key=="pvconstraint"):
209  if not hasattr(self,"PVtype"):
210  self.PVtype="nobs"
211  # Get custom track selection for TBD
212  elif (key=="twobodytrackselection" or key=="twobodydecayselection" or key=="tbdselection"):
213  val=val.lower()
214  if (val=="zsel" or val=="y1ssel"):
215  self.TBDsel=val
216  else:
217  raise ValueError("TBD selection can only be Zsel or Y1Ssel at this time.")
218  ## Get options common in min. bias, Zmumu and Ymumu
219  # Get TBD constraint type
220  elif (key=="twobodytrackconstraint" or key=="twobodydecayconstraint" or key=="tbdconstraint"):
221  val=val.lower()
222  if ("momconstr" in val or "fullconstr" in val):
223  self.TBDconstraint=val
224  else:
225  raise ValueError("TBD constraint can only be momconstr... or fullconstr...")
226  ## Options for cosmics
227  # Get APV mode
228  elif key=="apvmode":
229  val=val.lower()
230  if (val=="peak" or val=="deco"):
231  self.APVmode=val
232  else:
233  raise ValueError("APV mode can only be peak or deco in cosmics")
234  # Get magnetic field value
235  elif key=="bfield":
236  val=val.lower()
237  if (val=="0t" or val=="zerotesla" or val=="3.8t"):
238  self.Bfield=val
239  else:
240  raise ValueError("B field can only be 0T, ZEROTESLA or 3.8T")
241  elif key=="usetracksplitting":
243  else:
244  raise RuntimeError("Option {} is not implemented.".format(key))
245 
246  if len(gttogetpsets)>0:
247  self.GTtoGet = cms.VPSet()
248  for ps in gttogetpsets:
249  insertPSetToVPSet(ps,self.GTtoGet)
250 
TBDconstraint
Get options common in min.
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
APVmode
Options for cosmics Get APV mode.
def HipPyOptionParser.HipPyOptionParser.parseOptions (   self)

Definition at line 98 of file HipPyOptionParser.py.

References HipPyOptionParser.HipPyOptionParser.optdict.

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

Member Data Documentation

HipPyOptionParser.HipPyOptionParser.applyPVConstraint

Definition at line 207 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.APVmode

Options for cosmics Get APV mode.

Definition at line 230 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.Bfield

Definition at line 78 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.CPEtype

Definition at line 67 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.datatype

Definition at line 66 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.flag

Definition at line 62 of file HipPyOptionParser.py.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions(), HipPyOptionParser.HipPyOptionParser.doCheckOptions(), and HipPyOptionParser.HipPyOptionParser.getTrackDefaults().

HipPyOptionParser.HipPyOptionParser.GlobalTag

Definition at line 120 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.GTtoGet

Definition at line 246 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.hitfiltercommands

Definition at line 165 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.LumiJSON

Definition at line 180 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.optdict

Definition at line 64 of file HipPyOptionParser.py.

Referenced by HipPyOptionParser.HipPyOptionParser.parseOptions().

HipPyOptionParser.HipPyOptionParser.overallweight

Definition at line 192 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.PVtype

Options for mMin.

bias Apply vertex constraint

Definition at line 203 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.rawopt

Definition at line 63 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.TBDconstraint

Get options common in min.

bias, Zmumu and Ymumu Get TBD constraint type

Definition at line 222 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.TBDsel

Definition at line 214 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.trkcoll

Definition at line 77 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.uniformetaformula

Definition at line 197 of file HipPyOptionParser.py.

HipPyOptionParser.HipPyOptionParser.useTrkSplittingInCosmics

Definition at line 90 of file HipPyOptionParser.py.