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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 60 of file HipPyOptionParser.py.

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

Member Function Documentation

◆ checkOptions()

def HipPyOptionParser.HipPyOptionParser.checkOptions (   self)

Definition at line 261 of file HipPyOptionParser.py.

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

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

◆ doCheckOptions()

def HipPyOptionParser.HipPyOptionParser.doCheckOptions (   self,
  optstocheck 
)

Definition at line 251 of file HipPyOptionParser.py.

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

References HipPyOptionParser.HipPyOptionParser.flag.

Referenced by HipPyOptionParser.HipPyOptionParser.checkOptions().

◆ getTrackDefaults()

def HipPyOptionParser.HipPyOptionParser.getTrackDefaults (   self)

Definition at line 75 of file HipPyOptionParser.py.

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

References HipPyOptionParser.HipPyOptionParser.flag.

◆ interpretOptions()

def HipPyOptionParser.HipPyOptionParser.interpretOptions (   self)

Definition at line 112 of file HipPyOptionParser.py.

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

References mps_monitormerge.items, and HipPyOptionParser.HipPyOptionParser.optdict.

◆ parseOptions()

def HipPyOptionParser.HipPyOptionParser.parseOptions (   self)

Definition at line 98 of file HipPyOptionParser.py.

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

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

Member Data Documentation

◆ applyPVConstraint

HipPyOptionParser.HipPyOptionParser.applyPVConstraint

Definition at line 207 of file HipPyOptionParser.py.

◆ APVmode

HipPyOptionParser.HipPyOptionParser.APVmode

Options for cosmics Get APV mode.

Definition at line 230 of file HipPyOptionParser.py.

◆ Bfield

HipPyOptionParser.HipPyOptionParser.Bfield

Definition at line 78 of file HipPyOptionParser.py.

◆ CPEtype

HipPyOptionParser.HipPyOptionParser.CPEtype

Definition at line 67 of file HipPyOptionParser.py.

◆ datatype

HipPyOptionParser.HipPyOptionParser.datatype

Definition at line 66 of file HipPyOptionParser.py.

◆ flag

HipPyOptionParser.HipPyOptionParser.flag

◆ GlobalTag

HipPyOptionParser.HipPyOptionParser.GlobalTag

Definition at line 120 of file HipPyOptionParser.py.

◆ GTtoGet

HipPyOptionParser.HipPyOptionParser.GTtoGet

Definition at line 246 of file HipPyOptionParser.py.

◆ hitfiltercommands

HipPyOptionParser.HipPyOptionParser.hitfiltercommands

Definition at line 165 of file HipPyOptionParser.py.

◆ LumiJSON

HipPyOptionParser.HipPyOptionParser.LumiJSON

Definition at line 180 of file HipPyOptionParser.py.

◆ optdict

HipPyOptionParser.HipPyOptionParser.optdict

◆ overallweight

HipPyOptionParser.HipPyOptionParser.overallweight

Definition at line 192 of file HipPyOptionParser.py.

◆ PVtype

HipPyOptionParser.HipPyOptionParser.PVtype

Options for mMin.

bias Apply vertex constraint

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

◆ TBDsel

HipPyOptionParser.HipPyOptionParser.TBDsel

Definition at line 214 of file HipPyOptionParser.py.

◆ trkcoll

HipPyOptionParser.HipPyOptionParser.trkcoll

Definition at line 77 of file HipPyOptionParser.py.

◆ uniformetaformula

HipPyOptionParser.HipPyOptionParser.uniformetaformula

Definition at line 197 of file HipPyOptionParser.py.

◆ useTrkSplittingInCosmics

HipPyOptionParser.HipPyOptionParser.useTrkSplittingInCosmics

Definition at line 90 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:12
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
HipPyOptionParser.insertPSetToVPSet
def insertPSetToVPSet(inPSet, outVPSet)
Definition: HipPyOptionParser.py:19
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
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:53
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:213
HipPyOptionParser.parseBoolString
def parseBoolString(theString)
Definition: HipPyOptionParser.py:47
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444