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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 61 of file HipPyOptionParser.py.

61  def __init__(self, strflag, stropt):
62  # input file
63  self.flag=strflag.lower().strip()
64  self.rawopt = stropt.strip()
65  self.optdict=dict()
66 
67  self.datatype=-1
68  self.CPEtype="template"
69  self.getTrackDefaults()
70 
71  if self.rawopt.lower()!="noopts":
72  self.parseOptions()
73  self.interpretOptions()
74 
75 

Member Function Documentation

◆ checkOptions()

def HipPyOptionParser.HipPyOptionParser.checkOptions (   self)

Definition at line 262 of file HipPyOptionParser.py.

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 

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

◆ doCheckOptions()

def HipPyOptionParser.HipPyOptionParser.doCheckOptions (   self,
  optstocheck 
)

Definition at line 252 of file HipPyOptionParser.py.

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 
261 

References HipPyOptionParser.HipPyOptionParser.flag.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions().

◆ getTrackDefaults()

def HipPyOptionParser.HipPyOptionParser.getTrackDefaults (   self)

Definition at line 76 of file HipPyOptionParser.py.

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 
98 

References HipPyOptionParser.HipPyOptionParser.flag.

◆ interpretOptions()

def HipPyOptionParser.HipPyOptionParser.interpretOptions (   self)

Definition at line 113 of file HipPyOptionParser.py.

113  def interpretOptions(self):
114  gttogetpsets=[]
115  for key,val in six.iteritems(self.optdict):
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 
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"):
208  self.applyPVConstraint=parseBoolString(val)
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 
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 
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":
242  self.useTrkSplittingInCosmics=parseBoolString(val)
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 
251 

References HipPyOptionParser.HipPyOptionParser.optdict.

◆ parseOptions()

def HipPyOptionParser.HipPyOptionParser.parseOptions (   self)

Definition at line 99 of file HipPyOptionParser.py.

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 
112 

References HipPyOptionParser.HipPyOptionParser.optdict, HipPyOptionParser.HipPyOptionParser.rawopt, and submitPVValidationJobs.split().

Member Data Documentation

◆ applyPVConstraint

HipPyOptionParser.HipPyOptionParser.applyPVConstraint

Definition at line 208 of file HipPyOptionParser.py.

◆ APVmode

HipPyOptionParser.HipPyOptionParser.APVmode

Options for cosmics Get APV mode.

Definition at line 231 of file HipPyOptionParser.py.

◆ Bfield

HipPyOptionParser.HipPyOptionParser.Bfield

Definition at line 79 of file HipPyOptionParser.py.

◆ CPEtype

HipPyOptionParser.HipPyOptionParser.CPEtype

Definition at line 68 of file HipPyOptionParser.py.

◆ datatype

HipPyOptionParser.HipPyOptionParser.datatype

Definition at line 67 of file HipPyOptionParser.py.

◆ flag

HipPyOptionParser.HipPyOptionParser.flag

◆ GlobalTag

HipPyOptionParser.HipPyOptionParser.GlobalTag

Definition at line 121 of file HipPyOptionParser.py.

◆ GTtoGet

HipPyOptionParser.HipPyOptionParser.GTtoGet

Definition at line 247 of file HipPyOptionParser.py.

◆ hitfiltercommands

HipPyOptionParser.HipPyOptionParser.hitfiltercommands

Definition at line 166 of file HipPyOptionParser.py.

◆ LumiJSON

HipPyOptionParser.HipPyOptionParser.LumiJSON

Definition at line 181 of file HipPyOptionParser.py.

◆ optdict

HipPyOptionParser.HipPyOptionParser.optdict

◆ overallweight

HipPyOptionParser.HipPyOptionParser.overallweight

Definition at line 193 of file HipPyOptionParser.py.

◆ PVtype

HipPyOptionParser.HipPyOptionParser.PVtype

Options for mMin.

bias Apply vertex constraint

Definition at line 204 of file HipPyOptionParser.py.

◆ rawopt

HipPyOptionParser.HipPyOptionParser.rawopt

◆ TBDconstraint

HipPyOptionParser.HipPyOptionParser.TBDconstraint

Get options common in min.

bias, Zmumu and Ymumu Get TBD constraint type

Definition at line 223 of file HipPyOptionParser.py.

◆ TBDsel

HipPyOptionParser.HipPyOptionParser.TBDsel

Definition at line 215 of file HipPyOptionParser.py.

◆ trkcoll

HipPyOptionParser.HipPyOptionParser.trkcoll

Definition at line 78 of file HipPyOptionParser.py.

◆ uniformetaformula

HipPyOptionParser.HipPyOptionParser.uniformetaformula

Definition at line 198 of file HipPyOptionParser.py.

◆ useTrkSplittingInCosmics

HipPyOptionParser.HipPyOptionParser.useTrkSplittingInCosmics

Definition at line 91 of file HipPyOptionParser.py.

LumiList.LumiList
Definition: LumiList.py:22
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
HipPyOptionParser.insertValToPSet
def insertValToPSet(name, val, thePSet)
Definition: HipPyOptionParser.py:13
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
HipPyOptionParser.insertPSetToVPSet
def insertPSetToVPSet(inPSet, outVPSet)
Definition: HipPyOptionParser.py:20
plotBaryCentre_VS_BeamSpot.parseOptions
def parseOptions()
Definition: plotBaryCentre_VS_BeamSpot.py:44
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
str
#define str(s)
Definition: TestProcessor.cc:52
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
mps_setup.append
append
Definition: mps_setup.py:85
createfilelist.int
int
Definition: createfilelist.py:10
cmsDriverOptions.checkOptions
def checkOptions()
Definition: cmsDriverOptions.py:19
format
pileupCalc.upper
upper
Definition: pileupCalc.py:214
HipPyOptionParser.parseBoolString
def parseBoolString(theString)
Definition: HipPyOptionParser.py:48
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444