Exemplo n.º 1
0
    'pvNTracks': {'stats': 101111},
    'pvTrackPt': {'stats': 101111},
}


# Argument parsing
from optparse import OptionParser
parser = OptionParser(usage=__usage__, version=__version__)
parser.add_option('-i', '--interactive', dest='interactive', action='store_true', default=False, help='interactive')
parser.add_option('-b', '--batch', dest='batch', action='store_true', default=False, help='run in batch mode')
parser.add_option('-o', '--output', dest='output', default='.gif', help='comma-separated list of output files or formats (default: .gif')
(options,args) = parser.parse_args()
if len(args) != 1:
    parser.error('wrong number of command line arguments')
filename = args[0]
run = getRunFromName(filename)
if run:
    basename = run+'-'
else:
    run = 'UNKNOWN'
    basename = ''


# Setup ROOT
if options.batch:
    os.unsetenv('DISPLAY')
import ROOT
from InDetBeamSpotExample import ROOTUtils
ROOTUtils.setStyle()
ROOT.gStyle.SetPalette(1)
c = ROOT.TCanvas('BeamSpotMonitoring','Beam Spot Monitoring',750,1000)
Exemplo n.º 2
0
    def addTask(self,
                dsName,
                taskName,
                template,
                release,
                njobs,
                taskpostprocsteps='',
                status=StatusCodes['SUBMITTED'],
                onDisk=OnDiskCodes['ALLONDISK'],
                createdTime=None,
                createdUser=None,
                createdHost=None,
                comment=''):
        """Add an entry for a new task if the task doesn't exist already. If the task exists,
           its UPDATED, NJOBS, STATUS and ONDISK fields will be updated."""
        tstamp = time.time()
        nDefined = self.getNTasks([
            'where DSNAME =',
            DbParam(dsName), 'and TASKNAME=',
            DbParam(taskName)
        ])
        updateStatus = self.getNTasks([
            'where DSNAME = ',
            DbParam(dsName), 'and TASKNAME=',
            DbParam(taskName),
            'and STATUS < %i' % TaskManager.StatusCodes['POSTPROCRUNNING']
        ])

        if nDefined:
            # Task entry exists already; only update UPDATED, NJOBS, STATUS, ONDISK and possibly ATLREL
            task = self.getTaskDict(dsName, taskName)
            if task['TEMPLATE'] != template:
                print 'ERROR: Must not update task with different template: DSNAME = %s, TASKNAME = %s, templates = %s vs %s' % (
                    dsName, taskName, task['TEMPLATE'], template)
            else:
                updateStr = [
                    'update TASKS set UPDATED =',
                    DbParam(tstamp), ', NJOBS = ',
                    DbParam(task['NJOBS'] + njobs), ', ONDISK = ',
                    DbParam(onDisk)
                ]

                if not release in task['ATLREL']:
                    print 'WARNING: Updating task using different release: DSNAME = %s, TASKNAME = %s, release = = %s vs %s' % (
                        dsName, taskName, task['ATLREL'], release)
                    release = '; '.join([task['ATLREL'], release])
                    updateStr += [', ATLREL = ', DbParam(release)]

                if updateStatus:
                    updateStr += [', STATUS = ', DbParam(status)]

                updateStr += [
                    'where DSNAME = ',
                    DbParam(dsName), 'and TASKNAME = ',
                    DbParam(taskName)
                ]

                self.execute(updateStr)

        else:
            # New task entry
            if not createdTime:
                createdTime = tstamp
            if not createdUser:
                createdUser = getUserName()
            if not createdHost:
                createdHost = os.uname()[1]
            runnr = getRunFromName(dsName, None, True)
            self.execute([
                'insert into TASKS (DSNAME,RUNNR,TASKNAME,TEMPLATE,TASKPOSTPROCSTEPS,ATLREL,CREATED,CREATED_USER,CREATED_HOST,UPDATED,STATUS,ONDISK,NJOBS,TASKCOMMENT) values (',
                DbParam(dsName), ',',
                DbParam(runnr), ',',
                DbParam(taskName), ',',
                DbParam(template), ',',
                DbParam(taskpostprocsteps), ',',
                DbParam(release), ',',
                DbParam(createdTime), ',',
                DbParam(createdUser), ',',
                DbParam(createdHost), ',',
                DbParam(tstamp), ',',
                DbParam(status), ',',
                DbParam(onDisk), ',',
                DbParam(njobs), ',',
                DbParam(comment), ')'
            ], True)
    def yx(self):
        ROOT.gStyle.SetOptStat(0)
        c = ROOTUtils.protect(ROOTUtils.MyCanvas('yx',options.canvas))
        c.SetRightMargin(0.14)
        h = ROOTUtils.protect(ROOT.TH2F('pvYX','Primary vertex: y vs x;Primary vertex x [mm];Primary vertex y [mm]',nbins,xmin,xmax,nbins,ymin,ymax))
        nt.Draw('y:x >> pvYX',cuts)
        h.Draw('COLZ')
        h.GetYaxis().SetTitleOffset(1.0)
        drawLabels()
        drawInfo(c,h,options.more)
        ROOT.gPad.Update()
        c.save()


# Start processing
run = getRunFromName(ntFile)
if options.public:
    runFillInfo = 'Fill %s' % (lhcFillData.get(run,'') if lhcFillData.get(run,'') else '')
else:
    runFillInfo = 'Run %s (LHC Fill %s)' % (run,lhcFillData.get(run,'') if lhcFillData.get(run,'') else '')

if options.energy:
    lhcEnergyInfo = '#sqrt{s} = %s;' % lhcEnergyData.get(run,'') if  lhcEnergyData.get(run,'') else ''
else:
    lhcEnergyInfo = ''

f = ROOT.TFile(ntFile)
if f.Get('Vertices'):
    nt = f.Get('Vertices')
elif f.Get('Beamspot/Vertices'):
    nt = f.Get('Beamspot/Vertices')
Exemplo n.º 4
0
    except ValueError as e:
        sys.exit('ERROR: Bad database connection string {}'.format(e))
    print()
    print('Import from: {}:{}'.format(fromDbtype, fromDbname))
    print('Import into: {}:{}'.format(destDbtype, destDbname))
    print()

    with getTaskManager() as taskman:
        with getTaskManager(fromDbconn) as fromman:
            nImported = 0
            qual.append('order by RUNNR desc')
            for t in fromman.taskIterDict(qual=qual):
                print('Importing ', t['DSNAME'], '/', t['TASKNAME'], '...')
                if not 'RUNNR' in t.keys():
                    # Fill run number from DSNAME
                    t['RUNNR'] = getRunFromName(t['DSNAME'], None, True)
                if not t.get('RESULTLINKS'):
                    # Rebuild old result files and links
                    links = ''
                    files = t.get('RESULTFILES', '')
                    if files == None:
                        files = ''
                    dsname = t['DSNAME']
                    taskname = t['TASKNAME']
                    summaryFiles = glob.glob('%s/%s/*beamspot.gif' %
                                             (dsname, taskname))
                    if len(summaryFiles) > 0:
                        for r in summaryFiles:
                            f = r.split('/')[-1]
                            pdf = f[:-3] + 'pdf'
                            if not f in files.split():
Exemplo n.º 5
0
    if len(args) != 1:
        parser.error('wrong number of command line arguments')
    tag1 = args[0]
    tag2 = args[0]

else:
    if len(args) < 2:
        parser.error('wrong number of command line arguments')
    tag1 = args[0]
    tag2 = args[1]

if options.runNumber:
    runNumber = int(options.runNumber)
    print('Doing comparison for run %i' % runNumber)
elif options.config == 'OnlineOffline':
    runNumber = getRunFromName(tag1, '0', True)
    print('Doing comparison for run %i' % runNumber)
elif options.config == 'Reproc':
    runNumber = getRunFromName(tag2, '0', True)
    print('Doing comparison for run %i' % runNumber)
else:
    runNumber = 0
    #print ('Doing comparison for all runs in %s' % tag1)

# Precision
ndp = 5
ndptilt = 8

# Setup ROOT
if options.batch:
    ROOT.gROOT.SetBatch(1)
Exemplo n.º 6
0
for a in options.statlist.split(','):
    statList.append(int(a))
    try:
        fitIDInt = int(format(int(a), '08b')[:4], 2)
        fitIdList.append(fitIDInt)
    except:
        print('ERROR: Status word value of %i has no known fitId entry' %
              int(a))
        sys.exit(1)

# First loop over all input files to determine if an everage is available
# (i.e. nEntires with correct fit status > 0)

# Set initial min and max run numbers from file names
#try:
runs = [int(getRunFromName(f)) for f in args]
minRun = min(runs)
maxRun = max(runs)
#except:
#    minRun = 1E10
#    maxRun = -1
nEntries = 0

print('\nDetermining if average beamspot parameters available')
for filename in args:
    print('\nExtracting from file ', filename, ':')

    f = ROOT.TFile(filename)
    if f.Get('BeamSpotNt'):
        bsNt = BeamSpotNt(filename)
    elif f.Get('Beamspot/Beamspots'):