Classes | |
class | ParsingError |
Functions | |
def | appendSqliteFile |
def | checkLock |
def | cmp_list_lumi |
def | cmp_list_run |
def | cp |
def | createWeightedPayloads |
CREATE FILE FOR PAYLOADS. | |
def | createWeightedPayloadsNew |
def | delta |
def | deltaSig |
def | dirExists |
def | dump |
def | dumpValues |
def | exit |
def | isnan |
def | lock |
def | ls |
def | nonzero |
def | pack |
lumi tools CondCore/Utilities/python/timeUnitHelper.py | |
def | parse |
def | readBeamSpotFile |
def | readSqliteFile |
def | rmLock |
def | sendEmail |
General utilities. | |
def | setLockName |
def | sortAndCleanBeamList |
Sort and clean list of data for consecutive duplicates and bad fits. | |
def | timeoutManager |
def | unpack |
def | unpackLumiid |
def | uploadSqliteFile |
def | weight |
def | writeSqliteFile |
Variables | |
string | lockFile = ".lock" |
tuple | USAGE = re.compile(r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)') |
OPTIONS. |
def CommonMethods::appendSqliteFile | ( | combinedSqliteFileName, | |
sqliteFileName, | |||
tagName, | |||
IOVSince, | |||
IOVTill, | |||
tmpDir = "/tmp/" |
|||
) |
Definition at line 928 of file CommonMethods.py.
00929 : 00930 aCommand = "cmscond_export_iov -d sqlite_file:" + tmpDir + combinedSqliteFileName + " -s sqlite_file:" + sqliteFileName + " -i " + tagName + " -t " + tagName + " -l sqlite_file:" + tmpDir + "log.db" + " -b " + IOVSince + " -e " + IOVTill 00931 print aCommand 00932 std = commands.getstatusoutput(aCommand) 00933 print std[1] 00934 return not std[0]
def CommonMethods::checkLock | ( | ) |
Definition at line 71 of file CommonMethods.py.
def CommonMethods::cmp_list_lumi | ( | a, | |
b | |||
) |
Definition at line 259 of file CommonMethods.py.
def CommonMethods::cmp_list_run | ( | a, | |
b | |||
) |
Definition at line 253 of file CommonMethods.py.
def CommonMethods::cp | ( | fromDir, | |
toDir, | |||
listOfFiles, | |||
overwrite = False , |
|||
smallList = False |
|||
) |
Definition at line 189 of file CommonMethods.py.
Referenced by CustomPhysicsList::addCustomPhysics(), EBSummaryClient::analyze(), PixelTrackBuilder::build(), HtrXmlPattern::do_hand_fill(), DTUserKeyedConfigHandler::DTUserKeyedConfigHandler(), pftools::Exercises3::evaluateCalibrator(), HtrXmlPatternTool::Fill(), edm::RootOutputFile::fillBranches(), L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu(), L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu(), PreshowerClusterAlgo::makeOneCluster(), InclusiveVertexFinder::nearTracks(), DDStreamer::pos_read(), Strip1DMeasurementTransformator::projectionMatrix(), BarrelDetLayer::setSurface(), ForwardDetLayer::setSurface(), CustomPhysicsList::setupRHadronPhycis(), and L1GtVmeWriterCore::writeVME().
00190 : 00191 cpCommand = '' 00192 copiedFiles = [] 00193 if fromDir.find('castor') != -1 or toDir.find('castor') != -1 : 00194 cpCommand = 'rf' 00195 elif fromDir.find('resilient') != -1: 00196 cpCommand = 'dc' 00197 if fromDir[len(fromDir)-1] != '/': 00198 fromDir += '/' 00199 00200 if toDir[len(toDir)-1] != '/': 00201 toDir += '/' 00202 00203 for file in listOfFiles: 00204 if os.path.isfile(toDir+file): 00205 if overwrite: 00206 print "File " + file + " already exists in destination directory. We will overwrite it." 00207 else: 00208 print "File " + file + " already exists in destination directory. We will Keep original file." 00209 if not smallList: 00210 copiedFiles.append(file) 00211 continue 00212 # copy to local disk 00213 aCommand = cpCommand + 'cp '+ fromDir + file + " " + toDir 00214 print " >> " + aCommand 00215 tmpStatus = commands.getstatusoutput( aCommand ) 00216 if tmpStatus[0] == 0: 00217 copiedFiles.append(file) 00218 else: 00219 print "[cp()]\tERROR: Can't copy file " + file 00220 return copiedFiles
def CommonMethods::createWeightedPayloads | ( | fileName, | |
listbeam = [] , |
|||
weighted = True |
|||
) |
CREATE FILE FOR PAYLOADS.
Definition at line 622 of file CommonMethods.py.
00623 : 00624 newlistbeam = [] 00625 tmpbeam = BeamSpot() 00626 docreate = True 00627 countlumi = 0 00628 tmprun = "" 00629 maxNlumis = 60 00630 if weighted: 00631 maxNlumis = 999999999 00632 for ii in range(0,len(listbeam)): 00633 ibeam = listbeam[ii] 00634 inextbeam = BeamSpot() 00635 iNNbeam = BeamSpot() 00636 if docreate: 00637 tmpbeam.IOVfirst = ibeam.IOVfirst 00638 tmpbeam.IOVBeginTime = ibeam.IOVBeginTime 00639 tmpbeam.Run = ibeam.Run 00640 tmpbeam.Type = 2 00641 docheck = False 00642 docreate = False 00643 #print "Currently testing ii="+str(ii)+" Lumi1: "+str(ibeam.IOVfirst) 00644 00645 # check last iov 00646 if ii < len(listbeam) - 1: 00647 inextbeam = listbeam[ii+1] 00648 docheck = True 00649 if ii < len(listbeam) -2: 00650 iNNbeam = listbeam[ii+2] 00651 else: 00652 print "close payload because end of data has been reached. Run "+ibeam.Run 00653 docreate = True 00654 # check we run over the same run 00655 if ibeam.Run != inextbeam.Run: 00656 print "close payload because end of run "+ibeam.Run 00657 docreate = True 00658 # check maximum lumi counts 00659 if countlumi == maxNlumis -1: 00660 print "close payload because maximum lumi sections accumulated within run "+ibeam.Run 00661 docreate = True 00662 countlumi = 0 00663 # weighted average position 00664 (tmpbeam.X, tmpbeam.Xerr) = weight(tmpbeam.X, tmpbeam.Xerr, ibeam.X, ibeam.Xerr) 00665 (tmpbeam.Y, tmpbeam.Yerr) = weight(tmpbeam.Y, tmpbeam.Yerr, ibeam.Y, ibeam.Yerr) 00666 (tmpbeam.Z, tmpbeam.Zerr) = weight(tmpbeam.Z, tmpbeam.Zerr, ibeam.Z, ibeam.Zerr) 00667 (tmpbeam.sigmaZ, tmpbeam.sigmaZerr) = weight(tmpbeam.sigmaZ, tmpbeam.sigmaZerr, ibeam.sigmaZ, ibeam.sigmaZerr) 00668 (tmpbeam.dxdz, tmpbeam.dxdzerr) = weight(tmpbeam.dxdz, tmpbeam.dxdzerr, ibeam.dxdz, ibeam.dxdzerr) 00669 (tmpbeam.dydz, tmpbeam.dydzerr) = weight(tmpbeam.dydz, tmpbeam.dydzerr, ibeam.dydz, ibeam.dydzerr) 00670 #print "wx = " + ibeam.beamWidthX + " err= "+ ibeam.beamWidthXerr 00671 (tmpbeam.beamWidthX, tmpbeam.beamWidthXerr) = weight(tmpbeam.beamWidthX, tmpbeam.beamWidthXerr, ibeam.beamWidthX, ibeam.beamWidthXerr) 00672 (tmpbeam.beamWidthY, tmpbeam.beamWidthYerr) = weight(tmpbeam.beamWidthY, tmpbeam.beamWidthYerr, ibeam.beamWidthY, ibeam.beamWidthYerr) 00673 00674 if weighted: 00675 docheck = False 00676 # check offsets 00677 #if False: 00678 if docheck: 00679 00680 # define minimum limit 00681 min_limit = 0.0025 00682 00683 # limit for x and y 00684 limit = float(ibeam.beamWidthX)/2. 00685 if limit < min_limit: limit = min_limit 00686 00687 # check movements in X 00688 adelta1 = delta(ibeam.X, ibeam.Xerr, inextbeam.X, inextbeam.Xerr) 00689 adelta2 = (0.,1.e9) 00690 adelta1dxdz = delta(ibeam.dxdz, ibeam.dxdzerr, inextbeam.dxdz, inextbeam.dxdzerr) 00691 adelta2dxdz = (0.,1.e9) 00692 adelta1dydz = delta(ibeam.dydz, ibeam.dydzerr, inextbeam.dydz, inextbeam.dydzerr) 00693 adelta2dydz = (0.,1.e9) 00694 adelta1widthx = delta(ibeam.beamWidthX, ibeam.beamWidthXerr, inextbeam.beamWidthX, inextbeam.beamWidthXerr) 00695 adelta2widthx = (0.,1.e9) 00696 adelta1widthy = delta(ibeam.beamWidthY, ibeam.beamWidthYerr, inextbeam.beamWidthY, inextbeam.beamWidthYerr) 00697 adelta2widthy = (0.,1.e9) 00698 adelta1z0 = delta(ibeam.Z, ibeam.Zerr, inextbeam.Z, inextbeam.Zerr) 00699 adelta1sigmaZ = delta(ibeam.sigmaZ, ibeam.sigmaZerr, inextbeam.sigmaZ, inextbeam.sigmaZerr) 00700 00701 if iNNbeam.Type != -1: 00702 adelta2 = delta(inextbeam.X, inextbeam.Xerr, iNNbeam.X, iNNbeam.Xerr) 00703 adelta2dxdz = delta(inextbeam.dxdz, inextbeam.dxdzerr, iNNbeam.dxdz, iNNbeam.dxdzerr) 00704 adelta2dydz = delta(inextbeam.dydz, inextbeam.dydzerr, iNNbeam.dydz, iNNbeam.dydzerr) 00705 adelta2widthx = delta(inextbeam.beamWidthX, inextbeam.beamWidthXerr, iNNbeam.beamWidthX, iNNbeam.beamWidthXerr) 00706 adelta2widthy = delta(inextbeam.beamWidthY, inextbeam.beamWidthYerr, iNNbeam.beamWidthY, iNNbeam.beamWidthYerr) 00707 00708 deltaX = deltaSig(adelta1) > 3.5 and adelta1[0] >= limit 00709 if ii < len(listbeam) -2: 00710 if deltaX==False and adelta1[0]*adelta2[0] > 0. and math.fabs(adelta1[0]+adelta2[0]) >= limit: 00711 #print " positive, "+str(adelta1[0]+adelta2[0])+ " limit="+str(limit) 00712 deltaX = True 00713 elif deltaX==True and adelta1[0]*adelta2[0]<=0 and adelta2[0] != 0 and math.fabs(adelta1[0]/adelta2[0]) > 0.33 and math.fabs(adelta1[0]/adelta2[0]) < 3: 00714 deltaX = False 00715 #print " negative, "+str(adelta1[0]/adelta2[0]) 00716 #else: 00717 # print str(adelta1[0]/adelta2[0]) 00718 00719 # check movemnts in Y 00720 adelta1 = delta(ibeam.Y, ibeam.Yerr, inextbeam.Y, inextbeam.Yerr) 00721 adelta2 = (0.,1.e9) 00722 if iNNbeam.Type != -1: 00723 adelta2 = delta(inextbeam.Y, inextbeam.Yerr, iNNbeam.Y, iNNbeam.Yerr) 00724 00725 deltaY = deltaSig(adelta1) > 3.5 and adelta1[0] >= limit 00726 if ii < len(listbeam) -2: 00727 if deltaY==False and adelta1[0]*adelta2[0] > 0. and math.fabs(adelta1[0]+adelta2[0]) >= limit: 00728 deltaY = True 00729 elif deltaY==True and adelta1[0]*adelta2[0]<=0 and adelta2[0] != 0 and math.fabs(adelta1[0]/adelta2[0]) > 0.33 and math.fabs(adelta1[0]/adelta2[0]) < 3: 00730 deltaY = False 00731 # check movements in Z 00732 00733 limit = float(ibeam.sigmaZ)/2. 00734 deltaZ = deltaSig(adelta1z0) > 3.5 and math.fabs(adelta1z0[0]) >= limit 00735 00736 deltasigmaZ = deltaSig(adelta1sigmaZ) > 5.0 00737 00738 # check dxdz 00739 adelta = delta(ibeam.dxdz, ibeam.dxdzerr, inextbeam.dxdz, inextbeam.dxdzerr) 00740 deltadxdz = deltaSig(adelta) > 5.0 00741 if deltadxdz and adelta1dxdz[0]*adelta2dxdz[0]<=0 and adelta2dxdz[0] != 0 and math.fabs(adelta1dxdz[0]/adelta2dxdz[0]) > 0.33 and math.fabs(adelta1dxdz[0]/adelta2dxdz[0]) < 3: 00742 deltadxdz = False 00743 # check dydz 00744 adelta = delta(ibeam.dydz, ibeam.dydzerr, inextbeam.dydz, inextbeam.dydzerr) 00745 deltadydz = deltaSig(adelta) > 5.0 00746 if deltadydz and adelta1dydz[0]*adelta2dydz[0]<=0 and adelta2dydz[0] != 0 and math.fabs(adelta1dydz[0]/adelta2dydz[0]) > 0.33 and math.fabs(adelta1dydz[0]/adelta2dydz[0]) < 3: 00747 deltadydz = False 00748 00749 adelta = delta(ibeam.beamWidthX, ibeam.beamWidthXerr, inextbeam.beamWidthX, inextbeam.beamWidthXerr) 00750 deltawidthX = deltaSig(adelta) > 5 00751 if deltawidthX and adelta1widthx[0]*adelta2widthx[0]<=0 and adelta2widthx[0] != 0 and math.fabs(adelta1widthx[0]/adelta2widthx[0]) > 0.33 and math.fabs(adelta1widthx[0]/adelta2widthx[0]) < 3: 00752 deltawidthX = False 00753 00754 adelta = delta(ibeam.beamWidthY, ibeam.beamWidthYerr, inextbeam.beamWidthY, inextbeam.beamWidthYerr) 00755 deltawidthY = deltaSig(adelta) > 5 00756 if deltawidthY and adelta1widthy[0]*adelta2widthy[0]<=0 and adelta2widthy[0] != 0 and math.fabs(adelta1widthy[0]/adelta2widthy[0]) > 0.33 and math.fabs(adelta1widthy[0]/adelta2widthy[0]) < 3: 00757 deltawidthY = False 00758 #if iNNbeam.Type != -1: 00759 # deltaX = deltaX and delta(ibeam.X, ibeam.Xerr, iNNbeam.X, iNNbeam.Xerr) > 1.5 00760 # deltaY = deltaY and delta(ibeam.Y, ibeam.Yerr, iNNbeam.Y, iNNbeam.Yerr) > 1.5 00761 # deltaZ = deltaZ and delta(ibeam.Z, ibeam.Zerr, iNNbeam.Z, iNNbeam.Zerr) > 1.5 00762 # 00763 # deltasigmaZ = deltasigmaZ and delta(ibeam.sigmaZ, ibeam.sigmaZerr, iNNbeam.sigmaZ, iNNbeam.sigmaZerr) > 2.5 00764 # deltadxdz = deltadxdz and delta(ibeam.dxdz, ibeam.dxdzerr, iNNbeam.dxdz, iNNbeam.dxdzerr) > 2.5 00765 # deltadydz = deltadydz and delta(ibeam.dydz, ibeam.dydzerr, iNNbeam.dydz, iNNbeam.dydzerr) > 2.5 00766 # 00767 # deltawidthX = deltawidthX and delta(ibeam.beamWidthX, ibeam.beamWidthXerr, iNNbeam.beamWidthX, iNNbeam.beamWidthXerr) > 3 00768 # deltawidthY = deltawidthY and delta(ibeam.beamWidthY, ibeam.beamWidthYerr, iNNbeam.beamWidthY, iNNbeam.beamWidthYerr) > 3 00769 00770 if deltaX or deltaY or deltaZ or deltasigmaZ or deltadxdz or deltadydz or deltawidthX or deltawidthY: 00771 docreate = True 00772 #print "shift here: x="+str(deltaX)+" y="+str(deltaY) 00773 #print "x1 = "+ibeam.X + " x1err = "+ibeam.Xerr 00774 #print "x2 = "+inextbeam.X + " x2err = "+inextbeam.Xerr 00775 #print "Lumi1: "+str(ibeam.IOVfirst) + " Lumi2: "+str(inextbeam.IOVfirst) 00776 #print " x= "+ibeam.X+" +/- "+ibeam.Xerr 00777 #print "weighted average x = "+tmpbeam.X +" +//- "+tmpbeam.Xerr 00778 print "close payload because of movement in X= "+str(deltaX)+", Y= "+str(deltaY) + ", Z= "+str(deltaZ)+", sigmaZ= "+str(deltasigmaZ)+", dxdz= "+str(deltadxdz)+", dydz= "+str(deltadydz)+", widthX= "+str(deltawidthX)+", widthY= "+str(deltawidthY) 00779 if docreate: 00780 #if ii == len(listbeam)-1: 00781 tmpbeam.IOVlast = ibeam.IOVlast 00782 tmpbeam.IOVEndTime = ibeam.IOVEndTime 00783 print " Run: "+tmpbeam.Run +" Lumi1: "+str(tmpbeam.IOVfirst) + " Lumi2: "+str(tmpbeam.IOVlast) 00784 newlistbeam.append(tmpbeam) 00785 tmpbeam = BeamSpot() 00786 countlumi = 0 00787 tmprun = ibeam.Run 00788 countlumi += 1 00789 00790 payloadfile = open(fileName,"w") 00791 for iload in newlistbeam: 00792 dump( iload, payloadfile ) 00793 payloadfile.close() return newlistbeam
def CommonMethods::createWeightedPayloadsNew | ( | fileName, | |
listbeam = [] , |
|||
weighted = True |
|||
) |
Definition at line 795 of file CommonMethods.py.
00796 : 00797 newlistbeam = [] 00798 docreate = False 00799 docheck = False 00800 lastPayload = listbeam[0] 00801 00802 firstToUse = 0 00803 lastToUse = 0 00804 for ii in range(0,len(listbeam)): 00805 docreate = False 00806 if docheck: 00807 deltaX = delta(ibeam.X, ibeam.Xerr, inextbeam.X, inextbeam.Xerr) > 1.5 00808 deltaY = delta(ibeam.Y, ibeam.Yerr, inextbeam.Y, inextbeam.Yerr) > 1.5 00809 deltaZ = delta(ibeam.Z, ibeam.Zerr, inextbeam.Z, inextbeam.Zerr) > 2.5 00810 00811 deltasigmaZ = delta(ibeam.sigmaZ, ibeam.sigmaZerr, inextbeam.sigmaZ, inextbeam.sigmaZerr) > 2.5 00812 deltadxdz = delta(ibeam.dxdz, ibeam.dxdzerr, inextbeam.dxdz, inextbeam.dxdzerr) > 2.5 00813 deltadydz = delta(ibeam.dydz, ibeam.dydzerr, inextbeam.dydz, inextbeam.dydzerr) > 2.5 00814 00815 deltawidthX = delta(ibeam.beamWidthX, ibeam.beamWidthXerr, inextbeam.beamWidthX, inextbeam.beamWidthXerr) > 3 00816 deltawidthY = delta(ibeam.beamWidthY, ibeam.beamWidthYerr, inextbeam.beamWidthY, inextbeam.beamWidthYerr) > 3 00817 00818 #if iNNbeam.Type != -1: 00819 # deltaX = deltaX and delta(ibeam.X, ibeam.Xerr, iNNbeam.X, iNNbeam.Xerr) > 1.5 00820 # deltaY = deltaY and delta(ibeam.Y, ibeam.Yerr, iNNbeam.Y, iNNbeam.Yerr) > 1.5 00821 # deltaZ = deltaZ and delta(ibeam.Z, ibeam.Zerr, iNNbeam.Z, iNNbeam.Zerr) > 1.5 00822 # 00823 # deltasigmaZ = deltasigmaZ and delta(ibeam.sigmaZ, ibeam.sigmaZerr, iNNbeam.sigmaZ, iNNbeam.sigmaZerr) > 2.5 00824 # deltadxdz = deltadxdz and delta(ibeam.dxdz, ibeam.dxdzerr, iNNbeam.dxdz, iNNbeam.dxdzerr) > 2.5 00825 # deltadydz = deltadydz and delta(ibeam.dydz, ibeam.dydzerr, iNNbeam.dydz, iNNbeam.dydzerr) > 2.5 00826 # 00827 # deltawidthX = deltawidthX and delta(ibeam.beamWidthX, ibeam.beamWidthXerr, iNNbeam.beamWidthX, iNNbeam.beamWidthXerr) > 3 00828 # deltawidthY = deltawidthY and delta(ibeam.beamWidthY, ibeam.beamWidthYerr, iNNbeam.beamWidthY, iNNbeam.beamWidthYerr) > 3 00829 00830 if deltaX or deltaY or deltaZ or deltasigmaZ or deltadxdz or deltadydz or deltawidthX or deltawidthY: 00831 if ii != 0: 00832 docreate = True 00833 lastToUse = ii-1 00834 #print "shift here: x="+str(deltaX)+" y="+str(deltaY) 00835 #print "x1 = "+ibeam.X + " x1err = "+ibeam.Xerr 00836 #print "x2 = "+inextbeam.X + " x2err = "+inextbeam.Xerr 00837 #print "Lumi1: "+str(ibeam.IOVfirst) + " Lumi2: "+str(inextbeam.IOVfirst) 00838 #print " x= "+ibeam.X+" +/- "+ibeam.Xerr 00839 #print "weighted average x = "+tmpbeam.X +" +//- "+tmpbeam.Xerr 00840 print "close payload because of movement in X= "+str(deltaX)+", Y= "+str(deltaY) + ", Z= "+str(deltaZ)+", sigmaZ= "+str(deltasigmaZ)+", dxdz= "+str(deltadxdz)+", dydz= "+str(deltadydz)+", widthX= "+str(deltawidthX)+", widthY= "+str(deltawidthY) 00841 00842 #WARNING this will only be fine for Run based IOVs 00843 if ii >= len(listbeam) - 1 or listbeam[ii].Run != listbeam[ii+1].Run : 00844 print "close payload because end of run has been reached. Run " + listbeam[ii].Run 00845 docreate = True 00846 lastToUse = ii 00847 00848 00849 # check maximum lumi counts 00850 #? if countlumi == maxNlumis: 00851 #? print "close payload because maximum lumi sections accumulated within run "+ibeam.Run 00852 #? docreate = True 00853 #? countlumi = 0 00854 if docreate: 00855 tmpbeam = BeamSpot() 00856 for ibeam in listbeam[firstToUse:lastToUse]: 00857 (tmpbeam.X, tmpbeam.Xerr) = weight(tmpbeam.X, tmpbeam.Xerr, ibeam.X, ibeam.Xerr) 00858 (tmpbeam.Y, tmpbeam.Yerr) = weight(tmpbeam.Y, tmpbeam.Yerr, ibeam.Y, ibeam.Yerr) 00859 (tmpbeam.Z, tmpbeam.Zerr) = weight(tmpbeam.Z, tmpbeam.Zerr, ibeam.Z, ibeam.Zerr) 00860 (tmpbeam.sigmaZ, tmpbeam.sigmaZerr) = weight(tmpbeam.sigmaZ, tmpbeam.sigmaZerr, ibeam.sigmaZ, ibeam.sigmaZerr) 00861 (tmpbeam.dxdz, tmpbeam.dxdzerr) = weight(tmpbeam.dxdz, tmpbeam.dxdzerr, ibeam.dxdz, ibeam.dxdzerr) 00862 (tmpbeam.dydz, tmpbeam.dydzerr) = weight(tmpbeam.dydz, tmpbeam.dydzerr, ibeam.dydz, ibeam.dydzerr) 00863 #print "wx = " + ibeam.beamWidthX + " err= "+ ibeam.beamWidthXerr 00864 (tmpbeam.beamWidthX, tmpbeam.beamWidthXerr) = weight(tmpbeam.beamWidthX, tmpbeam.beamWidthXerr, ibeam.beamWidthX, ibeam.beamWidthXerr) 00865 (tmpbeam.beamWidthY, tmpbeam.beamWidthYerr) = weight(tmpbeam.beamWidthY, tmpbeam.beamWidthYerr, ibeam.beamWidthY, ibeam.beamWidthYerr) 00866 tmpbeam.IOVfirst = listbeam[firstToUse].IOVfirst 00867 tmpbeam.IOVBeginTime = listbeam[firstToUse].IOVBeginTime 00868 tmpbeam.Run = listbeam[firstToUse].Run 00869 tmpbeam.Type = 2 00870 tmpbeam.IOVlast = listbeam[lastToUse].IOVlast 00871 tmpbeam.IOVEndTime = listbeam[lastToUse].IOVEndTime 00872 newlistbeam.append(tmpbeam) 00873 firstToUse = lastToUse+1 00874 print "Run: " + tmpbeam.Run + " Lumi1: " + str(tmpbeam.IOVfirst) + " Lumi2: " + str(tmpbeam.IOVlast) 00875 00876 payloadfile = open(fileName,"w") 00877 for iload in newlistbeam: 00878 dump( iload, payloadfile ) 00879 payloadfile.close()
def CommonMethods::delta | ( | x, | |
xerr, | |||
nextx, | |||
nextxerr | |||
) |
Definition at line 321 of file CommonMethods.py.
def CommonMethods::deltaSig | ( | x | ) |
Definition at line 325 of file CommonMethods.py.
def CommonMethods::dirExists | ( | dir | ) |
Definition at line 157 of file CommonMethods.py.
Referenced by SiStripCommissioningSource::remove().
def CommonMethods::dump | ( | beam, | |
file | |||
) |
Definition at line 289 of file CommonMethods.py.
def CommonMethods::dumpValues | ( | beam, | |
file | |||
) |
Definition at line 298 of file CommonMethods.py.
00299 : 00300 end = "\n" 00301 file.write("Type "+str(beam.Type)+end) 00302 file.write("X0 "+str(beam.X)+end) 00303 file.write("Y0 "+str(beam.Y)+end) 00304 file.write("Z0 "+str(beam.Z)+end) 00305 file.write("sigmaZ0 "+str(beam.sigmaZ)+end) 00306 file.write("dxdz "+str(beam.dxdz)+end) 00307 file.write("dydz "+str(beam.dydz)+end) 00308 file.write("BeamWidthX "+beam.beamWidthX+end) 00309 file.write("BeamWidthY "+beam.beamWidthY+end) 00310 file.write("Cov(0,j) "+str(math.pow(float(beam.Xerr),2))+" 0 0 0 0 0 0" +end) 00311 file.write("Cov(1,j) 0 "+str(math.pow(float(beam.Yerr),2))+" 0 0 0 0 0" +end) 00312 file.write("Cov(2,j) 0 0 "+str(math.pow(float(beam.Zerr),2))+" 0 0 0 0" +end) 00313 file.write("Cov(3,j) 0 0 0 "+str(math.pow(float(beam.sigmaZerr),2))+" 0 0 0" +end) 00314 file.write("Cov(4,j) 0 0 0 0 "+str(math.pow(float(beam.dxdzerr),2))+" 0 0" +end) 00315 file.write("Cov(5,j) 0 0 0 0 0 "+str(math.pow(float(beam.dydzerr),2))+" 0" +end) 00316 file.write("Cov(6,j) 0 0 0 0 0 0 "+str(math.pow(float(beam.beamWidthXerr),2)) +end) 00317 file.write("EmittanceX 0"+end) 00318 file.write("EmittanceY 0"+end) 00319 file.write("BetaStar 0"+end)
def CommonMethods::exit | ( | msg = "" | ) |
Definition at line 90 of file CommonMethods.py.
def CommonMethods::isnan | ( | num | ) |
Definition at line 95 of file CommonMethods.py.
def CommonMethods::lock | ( | ) |
Definition at line 79 of file CommonMethods.py.
Referenced by stor::ConcurrentQueue< T, EnqPolicy >::addExternallyDroppedEvents(), evf::FUResourceTable::allocateResource(), stor::QueueCollection< T >::allQueuesStale(), cscdqm::Collection::book(), evf::FUResourceTable::buildResource(), cscdqm::EventProcessor::calcEMUFractionHisto(), stor::ConcurrentQueue< T, EnqPolicy >::clear(), stor::QueueCollection< T >::clearQueue(), stor::QueueCollection< T >::clearQueues(), stor::QueueCollection< T >::clearStaleQueues(), StorageAccount::counter(), cond::XMLAuthenticationService::XMLAuthenticationService::credentials(), evf::FUResourceBroker::customWebPage(), stor::ConcurrentQueue< T, EnqPolicy >::deqNowait(), stor::ConcurrentQueue< T, EnqPolicy >::deqTimedWait(), stor::ConcurrentQueue< T, EnqPolicy >::deqWait(), evf::FUResourceTable::discard(), evf::FUResourceTable::discardDataEvent(), stor::QueueCollection< T >::empty(), stor::ConcurrentQueue< T, EnqPolicy >::enqNowait(), stor::ConcurrentQueue< T, EnqPolicy >::enqTimedWait(), stor::ConcurrentQueue< T, EnqPolicy >::enqWait(), CSCMonitorObject::Fill(), stor::ConcurrentQueue< T, EnqPolicy >::full(), stor::QueueCollection< T >::full(), CSCMonitorObject::GetBinContent(), CSCMonitorObject::GetBinError(), CSCMonitorObject::GetEntries(), stor::QueueCollection< T >::getExpirationInterval(), CSCMonitorObject::GetMaximumBin(), stor::QueueCollection< T >::getQueue(), DQMNet::onPeerConnect(), DQMNet::onPeerData(), stor::QueueCollection< T >::popEvent(), cscdqm::Dispatcher::processStandby(), evf::FUResourceTable::sendData(), CSCMonitorObject::SetAxisRange(), CSCMonitorObject::setAxisTitle(), CSCMonitorObject::SetBinContent(), CSCMonitorObject::SetBinError(), stor::ConcurrentQueue< T, EnqPolicy >::setCapacity(), CSCMonitorObject::SetEntries(), stor::QueueCollection< T >::setExpirationInterval(), CSCMonitorObject::SetMaximum(), stor::ConcurrentQueue< T, EnqPolicy >::setMemory(), CSCMonitorObject::SetNormFactor(), stor::QueueCollection< T >::size(), stor::QueueCollection< T >::stale(), StorageAccount::Stamp::Stamp(), cscdqm::EventProcessor::standbyEfficiencyHistos(), StorageAccount::Stamp::tick(), cscdqm::EventProcessor::updateEfficiencyHistos(), cscdqm::EventProcessorMutex::updateFractionAndEfficiencyHistos(), cscdqm::Dispatcher::updateFractionAndEfficiencyHistos(), cscdqm::EventProcessor::updateFractionHistos(), cscdqm::EventProcessor::writeShifterHistograms(), and stor::ConcurrentQueue< T, EnqPolicy >::~ConcurrentQueue().
def CommonMethods::ls | ( | dir, | |
filter = "" |
|||
) |
Definition at line 166 of file CommonMethods.py.
00167 : 00168 lsCommand = '' 00169 listOfFiles = [] 00170 if dir.find('castor') != -1: 00171 lsCommand = 'ns' 00172 elif not os.path.exists(dir): 00173 print "ERROR: File or directory " + dir + " doesn't exist" 00174 return listOfFiles 00175 00176 aCommand = lsCommand + 'ls '+ dir 00177 #aCommand = lsCommand + 'ls '+ dir + " | grep .txt" 00178 if filter != "": 00179 aCommand += " | grep " + filter 00180 00181 tmpStatus = commands.getstatusoutput( aCommand ) 00182 listOfFiles = tmpStatus[1].split('\n') 00183 if len(listOfFiles) == 1: 00184 if listOfFiles[0].find('No such file or directory') != -1: 00185 exit("ERROR: File or directory " + dir + " doesn't exist") 00186 00187 return listOfFiles
def CommonMethods::nonzero | ( | self | ) |
Definition at line 129 of file CommonMethods.py.
00129 : # will become the nonzero method of optparse.Values 00130 "True if options were given" 00131 for v in self.__dict__.itervalues(): 00132 if v is not None: return True 00133 return False 00134
def CommonMethods::pack | ( | high, | |
low | |||
) |
lumi tools CondCore/Utilities/python/timeUnitHelper.py
pack high,low 32bit unsigned int to one unsigned 64bit long long Note:the print value of result number may appear signed, if the sign bit is used.
Definition at line 227 of file CommonMethods.py.
def CommonMethods::parse | ( | docstring, | |
arglist = None |
|||
) |
Definition at line 105 of file CommonMethods.py.
00106 : 00107 global optionstring 00108 global tagType 00109 optionstring = docstring 00110 match = USAGE.search(optionstring) 00111 if not match: raise ParsingError("Cannot find the option string") 00112 optlines = match.group(1).splitlines() 00113 try: 00114 p = optparse.OptionParser(optlines[0]) 00115 for line in optlines[1:]: 00116 opt, help=line.split(':')[:2] 00117 short,long=opt.split(',')[:2] 00118 if '=' in opt: 00119 action='store' 00120 long=long.split('=')[0] 00121 else: 00122 action='store_true' 00123 p.add_option(short.strip(),long.strip(), 00124 action = action, help = help.strip()) 00125 except (IndexError,ValueError): 00126 raise ParsingError("Cannot parse the option string correctly") 00127 return p.parse_args(arglist)
def CommonMethods::readBeamSpotFile | ( | fileName, | |
listbeam = [] , |
|||
IOVbase = "runbase" , |
|||
firstRun = '1' , |
|||
lastRun = '4999999999' |
|||
) |
Definition at line 329 of file CommonMethods.py.
00330 : 00331 tmpbeam = BeamSpot() 00332 tmpbeamsize = 0 00333 00334 #firstRun = "1" 00335 #lastRun = "4999999999" 00336 if IOVbase == "lumibase" and firstRun=='1' and lastRun=='4999999999' : 00337 firstRun = "1:1" 00338 lastRun = "4999999999:4999999999" 00339 00340 inputfiletype = 0 00341 #print "first = " +firstRun 00342 #print "last = " +lastRun 00343 00344 # for bx 00345 maplist = {} 00346 hasBX = False 00347 00348 tmpfile = open(fileName) 00349 atmpline = tmpfile.readline() 00350 if atmpline.find('Runnumber') != -1: 00351 inputfiletype = 1 00352 if len(atmpline.split()) > 2: 00353 hasBX = True 00354 print " Input data has been calculated as function of BUNCH CROSSINGS." 00355 tmpfile.seek(0) 00356 00357 00358 if inputfiletype ==1: 00359 00360 tmpBX = 0 00361 for line in tmpfile: 00362 00363 if line.find('Type') != -1: 00364 tmpbeam.Type = int(line.split()[1]) 00365 tmpbeamsize += 1 00366 if line.find('X0') != -1: 00367 tmpbeam.X = line.split()[1] 00368 #tmpbeam.Xerr = line.split()[4] 00369 tmpbeamsize += 1 00370 #print " x = " + str(tmpbeam.X) 00371 if line.find('Y0') != -1: 00372 tmpbeam.Y = line.split()[1] 00373 #tmpbeam.Yerr = line.split()[4] 00374 tmpbeamsize += 1 00375 #print " y =" + str(tmpbeam.Y) 00376 if line.find('Z0') != -1 and line.find('sigmaZ0') == -1: 00377 tmpbeam.Z = line.split()[1] 00378 #tmpbeam.Zerr = line.split()[4] 00379 tmpbeamsize += 1 00380 if line.find('sigmaZ0') !=-1: 00381 tmpbeam.sigmaZ = line.split()[1] 00382 #tmpbeam.sigmaZerr = line.split()[5] 00383 tmpbeamsize += 1 00384 if line.find('dxdz') != -1: 00385 tmpbeam.dxdz = line.split()[1] 00386 #tmpbeam.dxdzerr = line.split()[4] 00387 tmpbeamsize += 1 00388 if line.find('dydz') != -1: 00389 tmpbeam.dydz = line.split()[1] 00390 #tmpbeam.dydzerr = line.split()[4] 00391 tmpbeamsize += 1 00392 if line.find('BeamWidthX') != -1: 00393 tmpbeam.beamWidthX = line.split()[1] 00394 #tmpbeam.beamWidthXerr = line.split()[6] 00395 tmpbeamsize += 1 00396 if line.find('BeamWidthY') != -1: 00397 tmpbeam.beamWidthY = line.split()[1] 00398 #tmpbeam.beamWidthYerr = line.split()[6] 00399 tmpbeamsize += 1 00400 if line.find('Cov(0,j)') != -1: 00401 tmpbeam.Xerr = str(math.sqrt( float( line.split()[1] ) ) ) 00402 tmpbeamsize += 1 00403 if line.find('Cov(1,j)') != -1: 00404 tmpbeam.Yerr = str(math.sqrt( float( line.split()[2] ) ) ) 00405 tmpbeamsize += 1 00406 if line.find('Cov(2,j)') != -1: 00407 tmpbeam.Zerr = str(math.sqrt( float( line.split()[3] ) ) ) 00408 tmpbeamsize += 1 00409 if line.find('Cov(3,j)') != -1: 00410 tmpbeam.sigmaZerr = str(math.sqrt( float( line.split()[4] ) ) ) 00411 tmpbeamsize += 1 00412 if line.find('Cov(4,j)') != -1: 00413 tmpbeam.dxdzerr = str(math.sqrt( float( line.split()[5] ) ) ) 00414 tmpbeamsize += 1 00415 if line.find('Cov(5,j)') != -1: 00416 tmpbeam.dydzerr = str(math.sqrt( float( line.split()[6] ) ) ) 00417 tmpbeamsize += 1 00418 if line.find('Cov(6,j)') != -1: 00419 tmpbeam.beamWidthXerr = str(math.sqrt( float( line.split()[7] ) ) ) 00420 tmpbeam.beamWidthYerr = tmpbeam.beamWidthXerr 00421 tmpbeamsize += 1 00422 if line.find('LumiRange') != -1: 00423 if IOVbase=="lumibase": 00424 tmpbeam.IOVfirst = line.split()[1] 00425 tmpbeam.IOVlast = line.split()[3] 00426 tmpbeamsize += 1 00427 if line.find('Runnumber') != -1: 00428 tmpbeam.Run = line.split()[1] 00429 if IOVbase == "runbase": 00430 tmpbeam.IOVfirst = line.split()[1] 00431 tmpbeam.IOVlast = line.split()[1] 00432 if hasBX: 00433 tmpBX = line.split()[3] 00434 tmpbeamsize += 1 00435 if line.find('BeginTimeOfFit') != -1: 00436 tmpbeam.IOVBeginTime = line.split()[1] +" "+line.split()[2] +" "+line.split()[3] 00437 if IOVbase =="timebase": 00438 tmpbeam.IOVfirst = time.mktime( time.strptime(line.split()[1] + " " + line.split()[2] + " " + line.split()[3],"%Y.%m.%d %H:%M:%S %Z") ) 00439 tmpbeamsize += 1 00440 if line.find('EndTimeOfFit') != -1: 00441 tmpbeam.IOVEndTime = line.split()[1] +" "+line.split()[2] +" "+line.split()[3] 00442 if IOVbase =="timebase": 00443 tmpbeam.IOVlast = time.mktime( time.strptime(line.split()[1] + " " + line.split()[2] + " " + line.split()[3],"%Y.%m.%d %H:%M:%S %Z") ) 00444 tmpbeamsize += 1 00445 if tmpbeamsize == 20: 00446 if IOVbase=="lumibase": 00447 tmprunfirst = int(firstRun.split(":")[0]) 00448 tmprunlast = int(lastRun.split(":")[0]) 00449 tmplumifirst = int(firstRun.split(":")[1]) 00450 tmplumilast = int(lastRun.split(":")[1]) 00451 acceptiov1 = acceptiov2 = False 00452 # check lumis in the same run 00453 if tmprunfirst == tmprunlast and int(tmpbeam.Run)==tmprunfirst: 00454 if int(tmpbeam.IOVfirst) >= tmplumifirst and int(tmpbeam.IOVlast)<=tmplumilast: 00455 acceptiov1 = acceptiov2 = True 00456 # if different runs make sure you select the correct range of lumis 00457 elif int(tmpbeam.Run) == tmprunfirst: 00458 if int(tmpbeam.IOVfirst) >= tmplumifirst: acceptiov1 = True 00459 elif int(tmpbeam.Run) == tmprunlast: 00460 if int(tmpbeam.IOVlast) <= tmplumilast: acceptiov2 = True 00461 elif tmprunfirst <= int(tmpbeam.Run) and tmprunlast >= int(tmpbeam.Run): 00462 acceptiov1 = acceptiov2 = True 00463 00464 if acceptiov1 and acceptiov2: 00465 if tmpbeam.Type != 2: 00466 print "invalid fit, skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00467 elif isnan(tmpbeam.Z) or isnan(tmpbeam.Zerr) or isnan(tmpbeam.sigmaZerr) or isnan(tmpbeam.beamWidthXerr) or isnan(tmpbeam.beamWidthYerr): 00468 print "invalid fit, NaN values!! skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00469 elif hasBX: 00470 if maplist.has_key(tmpBX) == False: 00471 maplist[tmpBX] = [tmpbeam] 00472 else: 00473 maplist[tmpBX].append(tmpbeam) 00474 else: 00475 listbeam.append(tmpbeam) 00476 00477 elif int(tmpbeam.IOVfirst) >= int(firstRun) and int(tmpbeam.IOVlast) <= int(lastRun): 00478 if tmpbeam.Type != 2: 00479 print "invalid fit, skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00480 elif isnan(tmpbeam.Z) or isnan(tmpbeam.Zerr) or isnan(tmpbeam.sigmaZerr) or isnan(tmpbeam.beamWidthXerr) or isnan(tmpbeam.beamWidthYerr): 00481 print "invalid fit, NaN values!! skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00482 else: 00483 listbeam.append(tmpbeam) 00484 00485 tmpbeamsize = 0 00486 tmpbeam = BeamSpot() 00487 tmpBX = 0 00488 else: 00489 00490 for line in tmpfile: 00491 00492 if line.find('X0') != -1: 00493 tmpbeam.X = line.split()[2] 00494 tmpbeam.Xerr = line.split()[4] 00495 tmpbeamsize += 1 00496 #print " x = " + str(tmpbeam.X) 00497 if line.find('Y0') != -1: 00498 tmpbeam.Y = line.split()[2] 00499 tmpbeam.Yerr = line.split()[4] 00500 tmpbeamsize += 1 00501 #print " y =" + str(tmpbeam.Y) 00502 if line.find('Z0') != -1 and line.find('Sigma Z0') == -1: 00503 tmpbeam.Z = line.split()[2] 00504 tmpbeam.Zerr = line.split()[4] 00505 tmpbeamsize += 1 00506 #print " z =" + str(tmpbeam.Z) 00507 if line.find('Sigma Z0') !=-1: 00508 tmpbeam.sigmaZ = line.split()[3] 00509 tmpbeam.sigmaZerr = line.split()[5] 00510 tmpbeamsize += 1 00511 if line.find('dxdz') != -1: 00512 tmpbeam.dxdz = line.split()[2] 00513 tmpbeam.dxdzerr = line.split()[4] 00514 tmpbeamsize += 1 00515 if line.find('dydz') != -1: 00516 tmpbeam.dydz = line.split()[2] 00517 tmpbeam.dydzerr = line.split()[4] 00518 tmpbeamsize += 1 00519 if line.find('Beam Width X') != -1: 00520 tmpbeam.beamWidthX = line.split()[4] 00521 tmpbeam.beamWidthXerr = line.split()[6] 00522 tmpbeamsize += 1 00523 if line.find('Beam Width Y') != -1: 00524 tmpbeam.beamWidthY = line.split()[4] 00525 tmpbeam.beamWidthYerr = line.split()[6] 00526 tmpbeamsize += 1 00527 #if line.find('Run ') != -1: 00528 if line.find('for runs') != -1: 00529 #tmpbeam.IOVfirst = line.split()[6].strip(',') 00530 tmpbeam.Run = line.split()[2] 00531 if IOVbase == "runbase": 00532 tmpbeam.IOVfirst = line.split()[2] 00533 tmpbeam.IOVlast = line.split()[4] 00534 tmpbeamsize += 1 00535 if line.find('LumiSection') != -1: 00536 if IOVbase=="lumibase": 00537 tmpbeam.IOVfirst = line.split()[10] 00538 tmpbeam.IOVlast = line.split()[10] 00539 tmpbeamsize += 1 00540 if tmpbeamsize == 10: 00541 00542 if IOVbase=="lumibase": 00543 tmprunfirst = int(firstRun.split(":")[0]) 00544 tmprunlast = int(lastRun.split(":")[0]) 00545 tmplumifirst = int(firstRun.split(":")[1]) 00546 tmplumilast = int(lastRun.split(":")[1]) 00547 acceptiov1 = acceptiov2 = False 00548 # check lumis in the same run 00549 if tmprunfirst == tmprunlast and int(tmpbeam.Run)==tmprunfirst: 00550 if int(tmpbeam.IOVfirst) >= tmplumifirst and int(tmpbeam.IOVlast)<=tmplumilast: 00551 acceptiov1 = acceptiov2 = True 00552 # if different runs make sure you select the correct range of lumis 00553 elif int(tmpbeam.Run) == tmprunfirst: 00554 if int(tmpbeam.IOVfirst) >= tmplumifirst: acceptiov1 = True 00555 elif int(tmpbeam.Run) == tmprunlast: 00556 if int(tmpbeam.IOVlast) <= tmplumilast: acceptiov2 = True 00557 elif tmprunfirst <= int(tmpbeam.Run) and tmprunlast >= int(tmpbeam.Run): 00558 acceptiov1 = acceptiov2 = True 00559 00560 if acceptiov1 and acceptiov2: 00561 if isnan(tmpbeam.Z) or isnan(tmpbeam.Zerr) or isnan(tmpbeam.sigmaZerr) or isnan(tmpbeam.beamWidthXerr) or isnan(tmpbeam.beamWidthYerr): 00562 print "invalid fit, NaN values!! skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00563 elif hasBX: 00564 if maplist.has_key(tmpBX) == False: 00565 maplist[tmpBX] = [tmpbeam] 00566 else: 00567 maplist[tmpBX].append(tmpbeam) 00568 else: 00569 listbeam.append(tmpbeam) 00570 00571 elif int(tmpbeam.IOVfirst) >= int(firstRun) and int(tmpbeam.IOVlast) <= int(lastRun): 00572 if isnan(tmpbeam.Z) or isnan(tmpbeam.Zerr) or isnan(tmpbeam.sigmaZerr) or isnan(tmpbeam.beamWidthXerr) or isnan(tmpbeam.beamWidthYerr): 00573 print "invalid fit, NaN values!! skip Run "+str(tmpbeam.Run)+" IOV: "+str(tmpbeam.IOVfirst) + " to "+ str(tmpbeam.IOVlast) 00574 else: 00575 listbeam.append(tmpbeam) 00576 00577 tmpbeamsize = 0 00578 tmpbeam = BeamSpot() 00579 tmpBX = 0 00580 00581 tmpfile.close() 00582 print " got total number of IOVs = " + str(len(listbeam)) + " from file " + fileName 00583 #print " run " + str(listbeam[3].IOVfirst ) + " " + str( listbeam[3].X ) 00584 if hasBX: 00585 return maplist 00586 else: 00587 return listbeam
def CommonMethods::readSqliteFile | ( | sqliteFileName, | |
tagName, | |||
sqliteTemplateFile, | |||
tmpDir = "/tmp/" |
|||
) |
Definition at line 905 of file CommonMethods.py.
00906 : 00907 readDBOut = tmpDir + "readDB_" + tagName + ".py" 00908 00909 rFile = open(sqliteTemplateFile) 00910 rNewFile = open(readDBOut,'w') 00911 00912 readDBTags = [('SQLITEFILE','sqlite_file:' + sqliteFileName), 00913 ('TAGNAME',tagName)] 00914 00915 for line in rFile: 00916 for itag in readDBTags: 00917 line = line.replace(itag[0],itag[1]) 00918 rNewFile.write(line) 00919 00920 rNewFile.close() 00921 status_rDB = commands.getstatusoutput('cmsRun '+ readDBOut) 00922 00923 outtext = status_rDB[1] 00924 print outtext 00925 os.system("rm -f " + readDBOut) 00926 return not status_rDB[0]
def CommonMethods::rmLock | ( | ) |
Definition at line 84 of file CommonMethods.py.
def CommonMethods::sendEmail | ( | mailList, | |
error | |||
) |
General utilities.
Definition at line 148 of file CommonMethods.py.
def CommonMethods::setLockName | ( | name | ) |
Definition at line 66 of file CommonMethods.py.
def CommonMethods::sortAndCleanBeamList | ( | listbeam = [] , |
|
IOVbase = "lumibase" |
|||
) |
Sort and clean list of data for consecutive duplicates and bad fits.
Definition at line 590 of file CommonMethods.py.
00591 : 00592 # sort the list 00593 if IOVbase == "lumibase": 00594 listbeam.sort( cmp = cmp_list_lumi ) 00595 else: 00596 listbeam.sort( cmp = cmp_list_run ) 00597 00598 # first clean list of data for consecutive duplicates and bad fits 00599 tmpremovelist = [] 00600 for ii in range(0,len(listbeam)): 00601 ibeam = listbeam[ii] 00602 datax = ibeam.IOVfirst 00603 #print str(ii) + " " +datax 00604 if datax == '0' and IOVbase =="runbase": 00605 print " iov = 0? skip this IOV = "+ str(ibeam.IOVfirst) + " to " + str(ibeam.IOVlast) 00606 tmpremovelist.append(ibeam) 00607 00608 if ii < len(listbeam) -1: 00609 #print listbeam[ii+1].IOVfirst 00610 if IOVbase =="lumibase": 00611 if ibeam.Run == listbeam[ii+1].Run and ibeam.IOVfirst == listbeam[ii+1].IOVfirst: 00612 print " duplicate IOV = "+datax+", keep only last duplicate entry" 00613 tmpremovelist.append(ibeam) 00614 elif datax == listbeam[ii+1].IOVfirst: 00615 print " duplicate IOV = "+datax+", keep only last duplicate entry" 00616 tmpremovelist.append(ibeam) 00617 00618 for itmp in tmpremovelist: 00619 listbeam.remove(itmp)
def CommonMethods::timeoutManager | ( | type, | |
timeout = -1 , |
|||
fileName = ".timeout" |
|||
) |
Definition at line 8 of file CommonMethods.py.
00009 : 00010 if timeout == 0: 00011 return 1 00012 timeFormat = "%a,%Y/%m/%d,%H:%M:%S" 00013 currentTime = time.gmtime() 00014 timeoutLine = type + ' ' + time.strftime(timeFormat, currentTime) + '\n' 00015 isTimeout = False 00016 alreadyThere = False 00017 timeoutType = -1; 00018 fileExist = os.path.isfile(fileName) 00019 text = '' 00020 fields = [] 00021 reset = False 00022 if timeout == -1: 00023 reset = True 00024 if fileExist: 00025 file = open(fileName) 00026 for line in file: 00027 text += line 00028 fields = line.strip('\n').split(' ') 00029 if fields[0] == type: 00030 alreadyThere = True 00031 if reset: 00032 text = text.replace(line,'') 00033 continue 00034 00035 fileTime = time.strptime(fields[1],timeFormat) 00036 myTime = time.mktime(fileTime) 00037 referenceTime = time.mktime(time.gmtime()) 00038 daylight = 0 00039 if currentTime.tm_isdst == 0: 00040 daylight = 3600 00041 elapsedTime = referenceTime-myTime-daylight 00042 if elapsedTime > timeout: 00043 isTimeout = True 00044 timeoutType = 1 00045 print "Timeout! " + str(elapsedTime) + " seconds passed since the " + type + " timeout was set and you can't tolerate more than " + str(timeout) + " seconds!" 00046 else: 00047 timeoutType = 0 00048 print "Timeout of type " + type + " already exist and was generated " + str(elapsedTime) + " seconds ago at " + fields[1] 00049 00050 file.close() 00051 00052 if not fileExist or not alreadyThere and not reset: 00053 timeoutType = -1 00054 text += timeoutLine 00055 00056 if not fileExist or not alreadyThere or isTimeout or (reset and alreadyThere): 00057 if fileExist: 00058 commands.getstatusoutput("rm -rf " + fileName) 00059 file = open(fileName,'w') 00060 file.write(text) 00061 file.close() 00062 00063 return timeoutType 00064
def CommonMethods::unpack | ( | i | ) |
unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
Definition at line 235 of file CommonMethods.py.
def CommonMethods::unpackLumiid | ( | i | ) |
unpack 64bit lumiid to dictionary {'run','lumisection'}
Definition at line 243 of file CommonMethods.py.
def CommonMethods::uploadSqliteFile | ( | sqliteFileDirName, | |
sqliteFileName, | |||
dropbox = "/DropBox" |
|||
) |
Definition at line 936 of file CommonMethods.py.
00937 : 00938 # Changing permissions to metadata 00939 acmd = "chmod a+w " + sqliteFileDirName + sqliteFileName + ".txt" 00940 outcmd = commands.getstatusoutput(acmd) 00941 print acmd 00942 # print outcmd[1] 00943 if outcmd[0]: 00944 print "Can't change permission to file: " + sqliteFileDirName + sqliteFileName + ".txt" 00945 return False 00946 00947 acmd = "cp " + sqliteFileDirName + sqliteFileName + ".db " + sqliteFileDirName + sqliteFileName + ".txt ." 00948 print acmd 00949 outcmd = commands.getstatusoutput(acmd) 00950 print outcmd[1] 00951 if outcmd[0]: 00952 print "Couldn't cd to " + sqliteFileDirName 00953 return False 00954 00955 acmd = "tar -cvjf " + sqliteFileName + ".tar.bz2 " + sqliteFileName + ".db " + sqliteFileName + ".txt" 00956 print acmd 00957 outcmd = commands.getstatusoutput(acmd) 00958 print outcmd[1] 00959 if outcmd[0]: 00960 print "Couldn't zip the files!" 00961 return False 00962 00963 acmd = "chmod a+w " + sqliteFileName + ".tar.bz2" 00964 outcmd = commands.getstatusoutput(acmd) 00965 print acmd 00966 # print outcmd[1] 00967 if outcmd[0]: 00968 print "Can't change permission to file: " + sqliteFileDirName + sqliteFileName + ".tar.bz2" 00969 return False 00970 00971 acmd = "scp -p " + sqliteFileName + ".tar.bz2" + " webcondvm.cern.ch:" + dropbox 00972 print acmd 00973 outcmd = commands.getstatusoutput(acmd) 00974 print outcmd[1] 00975 if outcmd[0]: 00976 print "Couldn't scp the files to DropBox!" 00977 return False 00978 00979 00980 acmd = "mv " + sqliteFileName + ".tar.bz2 " + sqliteFileDirName 00981 print acmd 00982 outcmd = commands.getstatusoutput(acmd) 00983 print outcmd[1] 00984 if outcmd[0]: 00985 print "Couldn't mv the file to " + sqliteFileDirName 00986 return False 00987 00988 acmd = "rm " + sqliteFileName + ".db " + sqliteFileName + ".txt" 00989 print acmd 00990 outcmd = commands.getstatusoutput(acmd) 00991 print outcmd[1] 00992 if outcmd[0]: 00993 print "Couldn't rm the db and txt files" 00994 return False 00995 00996 # acmd = "scp -p " + sqliteFileDirName + sqliteFileName + ".txt webcondvm.cern.ch:/tmp" 00997 # outcmd = commands.getstatusoutput(acmd) 00998 # print acmd 00999 # print outcmd[1] 01000 # if outcmd[0]: 01001 # print "Can't change permission to file: " + sqliteFileName + ".txt" 01002 # return False 01003 01004 # acmd = "ssh webcondvm.cern.ch \"mv /tmp/" + sqliteFileName + ".db /tmp/" + sqliteFileName + ".txt " + dropbox +"\"" 01005 # print acmd 01006 # outcmd = commands.getstatusoutput(acmd) 01007 # print outcmd[1] 01008 # if outcmd[0]: 01009 # print "Can't move files from tmp to dropbox!" 01010 return False 01011 01012 # acmd = "ssh webcondvm.cern.ch \"mv /tmp/" + final_sqlite_file_name + ".txt "+dropbox +"\"" 01013 # outcmd = commands.getstatusoutput(acmd) 01014 # print acmd 01015 # print outcmd[1] 01016 # if outcmd[0]: 01017 # print "Can't change permission to file: " + sqliteFileName + ".txt" 01018 # return False 01019 01020 return True 01021
def CommonMethods::weight | ( | x1, | |
x1err, | |||
x2, | |||
x2err | |||
) |
Definition at line 268 of file CommonMethods.py.
Referenced by lhef::LHERunInfo::Counter::add(), KalmanVertexUpdator< N >::add(), reco::TrackKinematics::add(), PhysicsTools::LeastSquares::add(), MuonTruth::addChannel(), RPCRawDataCounts::addDccRecord(), CaloValidationStatistics::addEntry(), Accumulator::addEntry(), MultiTrajectoryStateAssembler::addInvalidState(), TtFullLepKinSolver::addKinSolInfo(), addMeas(), MuonCSCChamberResidual::addResidual(), MuonDT13ChamberResidual::addResidual(), MuonDT2ChamberResidual::addResidual(), CSCPairResidualsConstraint::addTrack(), FedCablingAlgorithm::analyse(), TtSemiLepSignalSelMVATrainer::analyze(), Rivet::CMS_EWK_10_012::analyze(), MuonTruth::analyze(), HistoAnalyzer< C >::analyze(), Rivet::CMS_FWD_10_006::analyze(), EBBeamHodoTask::analyze(), JetAnaPythia< Jet >::analyze(), Rivet::CMS_2011_S8884919::analyze(), Rivet::CMS_2010_S8656010::analyze(), Rivet::MC_LES_HOUCHES_SYSTEMATICS_CMS::analyze(), Rivet::CMS_2010_S8547297::analyze(), EEBeamHodoTask::analyze(), zPdfUnc::analyze(), JetTagMVATreeTrainer::analyze(), ZLONLOHistogrammer::analyze(), EWKSystUnc::analyze(), Rivet::CMS_2011_S8978280::analyze(), Rivet::CMS_2011_S8968497::analyze(), Rivet::CMS_QCD_10_010::analyze(), Rivet::CMS_FWD_10_011::analyze(), IsolatedTracksNxN::analyze(), ZMCHistogrammer::analyze(), EgHLTOfflineSource::analyze(), GsfVertexUpdator::assembleVertexComponents(), CaloTowersCreationAlgo::assignHit(), reco::tau::RecoTauVertexAssociator::associatedVertex(), JetAnaPythia< Jet >::beginJob(), BremsstrahlungSimulator::brem(), GsfVertexWeightCalculator::calculate(), ClusterShapeAlgo::Calculate_EnergyDepTopology(), PositionCalc::Calculate_Location(), TBPositionCalc::CalculateCMSPos(), XHistogram::check_weight(), MultiGaussianStateCombiner1D::combine(), MultiTrajectoryStateCombiner::combine(), CandIsolatorFromDeposits::SingleDeposit::compute(), PairProductionSimulator::compute(), MuScleFitUtils::computeWeight(), MassWindow::count(), BackgroundHandler::countEventsInAllWindows(), HcalTB02SD::curve_LY(), ECalSD::curve_LY(), DreamSD::curve_LY(), SignedImpactParameter3D::distanceWithJetAxis(), CSCOfflineMonitor::doEfficiencies(), CSCValidation::doEfficiencies(), PhysicsTools::TrainProcessor::doTrainData(), MuScleFit::duringFastLoop(), CalorimetryManager::EMShowerSimulation(), CaloTowersCreationAlgo::emShwrLogWeightPos(), DTResolutionAnalysisTest::endRun(), DTCertificationSummary::endRun(), edm::RefVector< TrackingRecHitCollection >::erase(), reco::Jet::etaetaMoment(), reco::Jet::etaphiMoment(), reco::Jet::etaPhiStatistics(), evaluateTtFullHadSignalSel(), evaluateTtSemiLepSignalSel(), HParticle::Fill(), HMassVSPartProfile::Fill(), HMassVSPart::Fill(), ConfigurableHisto::fill(), HPartVSEta::Fill(), HPartVSPt::Fill(), HPartVSPhi::Fill(), MuonSystemMapPlot1D::fill_dxdz(), MuonSystemMapPlot1D::fill_dydz(), MuonSystemMapPlot1D::fill_x(), MuonSystemMapPlot1D::fill_y(), SiPixelDataQuality::fillGlobalQualityPlot(), HLXMonitor::FillHistograms(), recoBSVTagInfoValidationAnalyzer::fillRecoToSim(), SVTagInfoValidationAnalyzer::fillRecoToSim(), SVTagInfoValidationAnalyzer::fillSimToReco(), recoBSVTagInfoValidationAnalyzer::fillSimToReco(), reco::PositiveSideGhostTrackFitter::fit(), MuonResiduals1DOFFitter::fit(), PFDisplacedVertexFinder::fitVertexFromSeed(), SherpaHadronizer::generatePartonsAndHadronize(), CaloSD::getAttenuation(), ECalSD::getBirkL3(), HCalSD::getEnergyDeposit(), ECalSD::getEnergyDeposit(), EcalTBH4BeamSD::getEnergyDeposit(), HcalTB02SD::getEnergyDeposit(), HcalTB06BeamSD::getEnergyDeposit(), EcalClusterTools::getEnergyDepTopology(), GsfBetheHeitlerUpdator::getMixtureParameters(), TtFullLepKinSolver::getNuSolution(), DreamSD::getStepInfo(), AdaptiveVertexFitter::getWeight(), CaloMeanResponse::getWeight(), tnp::BaseTreeFiller::init(), reco::GhostTrack::initStates(), CSCPairResidualsConstraint::isFiducial(), IPTools::jetTrackDistance(), likelihood(), EnergyLossPlain::logTruncate(), reco::PFDisplacedVertexSeed::mergeWith(), reco::tau::qcuts::minTrackVertexWeight(), MuonResiduals1DOFFitter_FCN(), MuonResiduals5DOFFitter_FCN(), MuonResiduals6DOFFitter_FCN(), MuonResiduals6DOFrphiFitter_FCN(), MtvClusterizer1D< T >::operator()(), SmsModeFinder3d::operator()(), FsmwModeFinder3d::operator()(), FsmwClusterizer1D< T >::operator()(), EnergyLossPlain::optimal(), DTSegmentAnalysisTest::performClientDiagnostic(), reco::Jet::phiphiMoment(), MuonResiduals6DOFrphiFitter::plot(), MuonResiduals6DOFFitter::plot(), MuonResiduals5DOFFitter::plot(), MuonResiduals1DOFFitter::plot(), MuonResidualsFitter::plotweighted(), PrescaleWeightProvider::prescaleWeight(), PrintMaterialBudgetInfo::printInfo(), edm::BeamHaloProducer::produce(), WeakEffectsWeightProducer::produce(), AlCaElectronsProducer::produce(), ISRWeightProducer::produce(), ISRGammaWeightProducer::produce(), FSRWeightProducer::produce(), edm::BeamHaloSource::produce(), EcalTBWeightsXMLTranslator::readWeightSet(), KalmanVertexUpdator< N >::remove(), CaloTowersCreationAlgo::rescale(), CaloTowersCreationAlgo::rescaleTowers(), EcalClusterTools::roundnessSelectedBarrelRecHits(), UpdateTProfile::setBinContent(), FWGUIManager::setFrom(), Histograms::SetWeight(), CandIsolatorFromDeposits::SingleDeposit::SingleDeposit(), sistrip::MeasureLA::summarize_module_muH_byLayer(), TBposition(), hcalCalib::Terminate(), SiTrivialDigitalConverter::truncate(), EcalTPGParamBuilder::uncodeWeight(), KalmanVertexUpdator< N >::update(), CommissioningTask::updateHistoSet(), reco::PFDisplacedVertexSeed::updateSeedPoint(), GsfMaterialEffectsUpdator::updateState(), MultiVertexFitter::updateWeights(), PrimaryVertexMonitor::vertexPlots(), VertexTrackFactory< 6 >::vertexTrack(), vtxMean(), TtFullLepKinSolver::WeightSolfromMC(), and MuonResidualsTwoBin::wmean().
00269 : 00270 #print "x1 = "+str(x1)+" +/- "+str(x1err)+" x2 = "+str(x2)+" +/- "+str(x2err) 00271 x1 = float(x1) 00272 x1err = float(x1err) 00273 x2 = float(x2) 00274 x2err = float(x2err) 00275 tmperr = 0. 00276 if x2err < 1e-6 : 00277 x2err = 1e-6 00278 if x1err < 1e-6: 00279 x1 = x2/(x2err * x2err) 00280 tmperr = 1/(x2err*x2err) 00281 else: 00282 x1 = x1/(x1err*x1err) + x2/(x2err * x2err) 00283 tmperr = 1/(x1err*x1err) + 1/(x2err*x2err) 00284 x1 = x1/tmperr 00285 x1err = 1/tmperr 00286 x1err = math.sqrt(x1err) 00287 return (str(x1), str(x1err))
def CommonMethods::writeSqliteFile | ( | sqliteFileName, | |
tagName, | |||
timeType, | |||
beamSpotFile, | |||
sqliteTemplateFile, | |||
tmpDir = "/tmp/" |
|||
) |
Definition at line 881 of file CommonMethods.py.
00882 : 00883 writeDBOut = tmpDir + "write2DB_" + tagName + ".py" 00884 wFile = open(sqliteTemplateFile) 00885 wNewFile = open(writeDBOut,'w') 00886 00887 writeDBTags = [('SQLITEFILE','sqlite_file:' + sqliteFileName), 00888 ('TAGNAME',tagName), 00889 ('TIMETYPE',timeType), 00890 ('BEAMSPOTFILE',beamSpotFile)] 00891 00892 for line in wFile: 00893 for itag in writeDBTags: 00894 line = line.replace(itag[0],itag[1]) 00895 wNewFile.write(line) 00896 00897 wNewFile.close() 00898 print "writing sqlite file ..." 00899 status_wDB = commands.getstatusoutput('cmsRun '+ writeDBOut) 00900 print status_wDB[1] 00901 00902 os.system("rm -f " + writeDBOut) 00903 return not status_wDB[0]
string CommonMethods::lockFile = ".lock" |
Definition at line 5 of file CommonMethods.py.
tuple CommonMethods::USAGE = re.compile(r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)') |
OPTIONS.
Definition at line 102 of file CommonMethods.py.