CMS 3D CMS Logo

Functions | Variables

PDRates Namespace Reference

Functions

def PrimaryDatasets
def RateInPD

Variables

int average = 0
list Datasets = []
int lsMax = 999999
int lsMin = 1
int nLS_within_range = 0
tuple parser = OptionParser(usage="Example: ./PDRates.py --runNumber 146644 --PD Mu --perLS")
 PrimaryDataset = options.PrimaryDataset
dictionary RatePerLS = {}
tuple RatesTmp = open("rates_tmp.txt","w")
 Run = options.RunNumber
string st_title = " \"Rates in PrimaryDataset "
tuple TempFile = open("tmp.gnuplot.txt","w")

Function Documentation

def PDRates::PrimaryDatasets (   Run)

Definition at line 29 of file PDRates.py.

00030                         :
00031         # -- List of Primary Datasets:
00032 
00033         dbs_cmd = """ dbs search --query='find primds.name 
00034                 where run=%d and dataset like */RAW' """ % (Run)
00035         rows = commands.getoutput(dbs_cmd)
00036         lines = rows.split("\n")
00037         j=0
00038         print "\nThe primary datasets for this run are: \n"
00039         for Line in lines:
00040                 j=j+1
00041                 if j <=4:
00042                         continue
00043                 print Line
00044                 line=Line.split()
00045                 Datasets.append(line[0])
00046         print " "
00047 
00048 

def PDRates::RateInPD (   Run,
  PrimaryDataset,
  lsMin,
  lsMax,
  printLS = False 
)

Definition at line 49 of file PDRates.py.

00050                                                           :
00051         dbs_cmd = """ dbs search --query='find file,lumi,file.numevents, file.size
00052                 where run=%d and dataset like /%s/*/RAW 
00053                 and lumi >= %d and lumi <= %d
00054                 and file.status=VALID '""" % (Run, PrimaryDataset,lsMin, lsMax)
00055         rows = commands.getoutput(dbs_cmd)
00056         lines = rows.split("\n")
00057         j=0
00058         LumiSections = []
00059         Files = []
00060         Evts = 0
00061         Size = 0
00062         LSinFile = {}
00063         NumberOfLSInFile = {}
00064         for Line in lines:
00065                 j=j+1
00066                 if j <=4:
00067                         continue
00068                 line=Line.split()
00069                 LS = line[1]
00070                 file = line[0]
00071                 Nevts = int(line[2])
00072                 size = int(line[3])
00073                 LSinFile[LS] = file
00074                 if LumiSections.count(LS) == 0:
00075                         LumiSections.append(LS)
00076                 if Files.count(file) == 0:
00077                         Files.append(file)
00078                         Evts += Nevts
00079                         Size += size
00080                         NumberOfLSInFile[file] =1
00081                 else:
00082                         NumberOfLSInFile[file] = NumberOfLSInFile[file]+1
00083                 RatePerLS[LS] = Nevts
00084                         
00085         Number_of_LS = len(LumiSections)
00086         LS_Length = 23.3
00087         if Run < 125100:
00088                 LS_Length = 93.3
00089         rate = Evts / (Number_of_LS * LS_Length)
00090         if Evts > 0:
00091                 size_per_event = (Size / Evts) / 1000.
00092         else:
00093                 size_per_event=-1
00094         print "Rate in \t",PrimaryDataset,"\t is : \t",rate," Hz", " \t size is : \t",size_per_event, "kB / event "
00095 
00096         lsmin=9999999
00097         lsmax=-1
00098         for (LS,file) in LSinFile.iteritems():
00099                 nls = NumberOfLSInFile[file]
00100                 RatePerLS[LS] = RatePerLS[LS] / nls
00101                 RatePerLS[LS] = RatePerLS[LS] / LS_Length
00102                 if int(LS) > lsmax:
00103                         lsmax=int(LS)
00104                 if int(LS) < lsmin:
00105                         lsmin=int(LS)
00106         if printLS:
00107                 print "lsmin lsmax",lsmin,lsmax
00108                 for ls in range(lsmin,lsmax):
00109                         if not `ls` in RatePerLS.keys():
00110                                 RatePerLS[LS] = 0
00111                                 print "Missing LS ",ls
00112 


Variable Documentation

list PDRates::Datasets = []

Definition at line 177 of file PDRates.py.

int PDRates::lsMax = 999999

Definition at line 120 of file PDRates.py.

int PDRates::lsMin = 1

Definition at line 119 of file PDRates.py.

Definition at line 138 of file PDRates.py.

tuple PDRates::parser = OptionParser(usage="Example: ./PDRates.py --runNumber 146644 --PD Mu --perLS")

Definition at line 20 of file PDRates.py.

PDRates::PrimaryDataset = options.PrimaryDataset

Definition at line 132 of file PDRates.py.

dictionary PDRates::RatePerLS = {}

Definition at line 133 of file PDRates.py.

tuple PDRates::RatesTmp = open("rates_tmp.txt","w")

Definition at line 140 of file PDRates.py.

PDRates::Run = options.RunNumber

Definition at line 131 of file PDRates.py.

Referenced by fwlite::RunFactory::makeRun().

string PDRates::st_title = " \"Rates in PrimaryDataset "

Definition at line 159 of file PDRates.py.

tuple PDRates::TempFile = open("tmp.gnuplot.txt","w")

Definition at line 153 of file PDRates.py.