def fieldtotal(self,fieldname,fieldtype): ''' given the input result field name and type, return the total ''' fieldidx=None result=0 try: fieldidx=self.__inputResultHeader.index(fieldname) except: print('field ',fieldname,' not found') raise for r in self.__inputResult: stringvalue=r[fieldidx] if fieldtype in ['int','unsigned int']: if not CommonUtil.is_intstr(stringvalue): print('field ',fieldname,' is not integer type') raise else: result=int(result)+int(stringvalue) continue elif fieldtype in ['float'] : if not CommonUtil.is_floatstr(stringvalue): print('field ',fieldname,' is not float type') raise else: result=float(result)+float(stringvalue) continue else: raise RunTimeError('cannot sum types other than int ,float') return result
def fieldvalues(self,fieldname,fieldtype): ''' given the input result field name and typem return the list of values ''' fieldidx=None result=[] try: fieldidx=self.__inputResultHeader.index(fieldname) except: print('field ',fieldname,' not found') raise RuntimeError('field') for r in self.__inputResult: stringvalue=r[fieldidx] if fieldtype in ['int','unsigned int']: if not CommonUtil.is_intstr(stringvalue): print('field ',fieldname,' is not integer type') raise RuntimeError('field') else: result.append(int(stringvalue)) continue elif fieldtype in ['float']: if not CommonUtil.is_floatstr(stringvalue): print('field ',fieldname,' is not float type') raise RuntimeError('field') else: result.append(float(stringvalue)) contine elif fieldtype in ['string','str']: result.append(stringvalue) else: raise RuntimeError('unsupported type '+fieldtype) return result
def fieldtotal(self, fieldname, fieldtype): ''' given the input result field name and type, return the total ''' fieldidx = None result = 0 try: fieldidx = self.__inputResultHeader.index(fieldname) except: print 'field ', fieldname, ' not found' raise for r in self.__inputResult: stringvalue = r[fieldidx] if fieldtype in ['int', 'unsigned int']: if not CommonUtil.is_intstr(stringvalue): print 'field ', fieldname, ' is not integer type' raise else: result = int(result) + int(stringvalue) continue elif fieldtype in ['float']: if not CommonUtil.is_floatstr(stringvalue): print 'field ', fieldname, ' is not float type' raise else: result = float(result) + float(stringvalue) continue else: raise 'cannot sum types other than int ,float' return result
def fieldvalues(self, fieldname, fieldtype): ''' given the input result field name and typem return the list of values ''' fieldidx = None result = [] try: fieldidx = self.__inputResultHeader.index(fieldname) except: print 'field ', fieldname, ' not found' raise for r in self.__inputResult: stringvalue = r[fieldidx] if fieldtype in ['int', 'unsigned int']: if not CommonUtil.is_intstr(stringvalue): print 'field ', fieldname, ' is not integer type' raise else: result.append(int(stringvalue)) continue elif fieldtype in ['float']: if not CommonUtil.is_floatstr(stringvalue): print 'field ', fieldname, ' is not float type' raise else: result.append(float(stringvalue)) contine elif fieldtype in ['string', 'str']: result.append(stringvalue) else: raise 'unsupported type ', fieldtype return result
def _getnorm(schema,norm): if isinstance(norm,int) or isinstance(norm,float) or CommonUtil.is_floatstr(norm) or CommonUtil.is_intstr(norm): return float(norm) if not isinstance(norm,str): raise ValueError('wrong parameter type') normdataid=dataDML.guessnormIdByName(schema,norm) normresult=dataDML.luminormById(schema,normdataid) return normresult[2]
if options.beammode=='stable': pbeammode = 'STABLE BEAMS' if options.verbose: print 'General configuration' print '\tconnect: ',options.connect print '\tauthpath: ',options.authpath print '\tlumi data version: ',options.lumiversion print '\tsiteconfpath: ',options.siteconfpath print '\toutputfile: ',options.outputfile print '\tscalefactor: ',options.scalefactor if options.action=='recorded' and options.hltpath: print 'Action: effective luminosity in hltpath: ',options.hltpath else: print 'Action: ',options.action if options.normfactor: if CommonUtil.is_floatstr(normfactor): print '\tuse norm factor value ',normfactor else: print '\tuse specific norm factor name ',normfactor else: print '\tuse norm factor in context (amodetag,beamenergy)' if options.runnumber: # if runnumber specified, do not go through other run selection criteria print '\tselect specific run== ',options.runnumber else: print '\trun selections == ' print '\tinput selection file: ',options.inputfile print '\tbeam mode: ',options.beammode print '\tfill: ',options.fillnum print '\tamodetag: ',options.amodetag print '\tbegin: ',options.begin print '\tend: ',options.end