CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
AlCaHLTBitMon_QueryRunRegistry Namespace Reference

Functions

def DBSquery
 file dbs More...
 
def defineOptions
 
def extractData
 
def filesize1
 
def getData
 
def getElement
 
def getRegExp
 
def getText
 
def makecff
 file cff data More...
 
def printLumi
 lumiCalc More...
 
def printObj
 
def serverQuery
 

Variables

tuple data = extractData(options.workspaceName,options.regexp,options.dataset,options.site,options)
 
int DEBUG = 0
 DEBUG. More...
 
tuple options = defineOptions()
 

Function Documentation

def AlCaHLTBitMon_QueryRunRegistry.DBSquery (   dataset,
  site,
  run 
)

file dbs

Definition at line 52 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by getData().

52 
53 def DBSquery(dataset,site,run):
54 
55  url = "http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"
56  args = {}
57  args['url'] = url
58  args['level'] = 'CRITICAL'
59  api = DBSAPI.dbsApi.DbsApi(args)
60  files = api.listFiles(path=dataset,tier_list =site,runNumber=run)
61  return files
def AlCaHLTBitMon_QueryRunRegistry.defineOptions ( )

Definition at line 103 of file AlCaHLTBitMon_QueryRunRegistry.py.

References reco.print().

104 def defineOptions():
105  parser = OptionParser()
106  parser.add_option("-w", "--workspace",
107  dest="workspaceName",
108  default="GLOBAL",
109  help="define workspace: GLOBAL TRACKER ")
110 
111  parser.add_option("-r", "--regexp",
112  dest="regexp",
113  type="string",
114  default='groupName : LIKE %Collisions10% , runNumber : = 136088',
115  help=" \"{runNumber} >= 148127 and {runNumber} < 148128 \" ")
116 
117  parser.add_option("-d", "--datasetPath",
118  dest="dataset", \
119  default="/MinimumBias/Run2010A-TkAlMinBias-Dec22ReReco_v1/ALCARECO",
120  help="For example : --datasetPath /MinimumBias/Run2010A-TkAlMinBias-Dec22ReReco_v1/ALCARECO")
121 
122  parser.add_option("-s", "--site",
123  dest="site",
124  default="T2_CH_CAF",
125  help="For example : site T2_CH_CAF")
126 
127  parser.add_option("-i", "--info",
128  action="store_true",
129  dest="info",
130  default=False,
131  help="printout the column names on which it's possible to cut")
132 
133  (options, args) = parser.parse_args()
134  if len(sys.argv) == 1:
135  print("\nUsage: %s --help"%sys.argv[0])
136  sys.exit(0)
137 
138  return options
139 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
def AlCaHLTBitMon_QueryRunRegistry.extractData (   mode,
  reg,
  dataset,
  site,
  options 
)

Definition at line 247 of file AlCaHLTBitMon_QueryRunRegistry.py.

References getData(), and serverQuery().

248 def extractData(mode,reg,dataset,site,options):
249  doc = minidom.parseString(serverQuery(mode,reg))
250  return getData(doc,options,dataset,site)
def AlCaHLTBitMon_QueryRunRegistry.filesize1 (   n)

Definition at line 34 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by printLumi().

34 
35 def filesize1(n):
36  info = os.stat(n)
37  sz = info[stat.ST_SIZE]
38  return sz
def AlCaHLTBitMon_QueryRunRegistry.getData (   doc,
  options,
  dataset,
  site 
)

Definition at line 165 of file AlCaHLTBitMon_QueryRunRegistry.py.

References DBSquery(), getElement(), makecff(), printLumi(), and printObj().

Referenced by extractData(), HcalTBWriter.extractEventInfo(), PixelPopConDCSSourceHandler< Type >.getNewObjects(), and HcalTBSource.produce().

166 def getData(doc,options,dataset,site):
167  server = xmlrpclib.ServerProxy('http://cms-service-runregistry-api.web.cern.ch/cms-service-runregistry-api/xmlrpc')
168  runs = getElement(doc,'RUN')
169  txtLongData=""
170  txtkey=""
171  lista=[]
172 
173  sep="\t"
174 
175  for run in runs:
176  txtrun=printObj(run,'NUMBER') + sep + printObj(run,'HLTKEY')
177  txtLongData+= txtrun + sep + "\n"
178 
179  for run in runs:
180  test=printObj(run,'HLTKEY')
181  if not (test in lista):
182  lista.append(test)
183 
184  file2=open("lista_key.txt",'w')
185  for pkey in range(len(lista)):
186  pwkey = lista[pkey] +"\n"
187  file2.write(pwkey)
188 
189  file2.close()
190 
191  for i in range(len(lista)):
192  if DEBUG:
193  print lista[i]
194  nameDBS=""
195  nameDBS=str(i)+".data"
196  name=""
197  name=str(i)+".json"
198  nameLumi=""
199  nameLumi=str(i)+".lumi"
200  file1 = open( name ,'w')
201  listaDBS = []
202  if DEBUG:
203  print nameDBS
204  for run in runs:
205  key=printObj(run,'HLTKEY')
206  if (key == lista[i]):
207  print "running......"
208  if DEBUG:
209  print printObj(run,'NUMBER')
210  txtruns = "{runNumber} >= " + printObj(run,'NUMBER') + " and {runNumber} < " + str(int(printObj(run,'NUMBER'))+1)
211  txtriv = txtruns + " and {cmpPix} in ('GOOD') and {cmpStrip} in ('GOOD') and {cmpTrack} in ('GOOD')"
212  riv = server.RunDatasetTable.export('GLOBAL', 'csv_run_numbers',txtriv)
213  if riv:
214  lumirun = server.RunLumiSectionRangeTable.export('GLOBAL', 'json',txtruns)
215  ###dbs file
216  file = DBSquery(dataset,site,str(printObj(run,'NUMBER')))
217  for uno in file:
218  stringDBS = {}
219  stringDBS = uno['LogicalFileName']
220  listaDBS += [stringDBS]
221  ###
222  if DEBUG:
223  print lumirun
224  comp="{}"
225  if (lumirun == comp):
226  print "LUMI ZERO"
227  else:
228  file1.write(lumirun)
229 
230  file1.close()
231  string=""
232  string="sed -i 's/}{/, /g'"
233  string2=""
234  string2= string + " " + name
235  os.system(string2)
236  printLumi(name,nameLumi)
237  os.system("sed -i 's/\//_/g' lista_key.txt")
238  listaDBS2 =[]
239  for rootLSF in listaDBS:
240  if not (rootLSF in listaDBS2):
241  listaDBS2.append(rootLSF)
242  makecff(listaDBS2,nameDBS)
243 
244  return txtLongData
245 
246 #---------------------------------------------
def AlCaHLTBitMon_QueryRunRegistry.getElement (   obj,
  name 
)

Definition at line 158 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by getData(), printObj(), and CSCBaseElectronicsSim.simulate().

159 def getElement(obj,name):
160  return obj.getElementsByTagName(name)
def AlCaHLTBitMon_QueryRunRegistry.getRegExp (   regexp)

Definition at line 251 of file AlCaHLTBitMon_QueryRunRegistry.py.

252 def getRegExp(regexp):
253  items = regexp.split(',')
254  dd = {}
255  for item in items:
256  key,value = item.split(':')
257  dd[key.replace(' ','')] = value
258  return dd
259 
260 
261 #---------------------------------------------MAIN
def AlCaHLTBitMon_QueryRunRegistry.getText (   nodelist)

Definition at line 151 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by printObj().

152 def getText(nodelist):
153  rc = ""
154  for node in nodelist:
155  if node.nodeType == node.TEXT_NODE:
156  rc = rc + node.data
157  return rc
def AlCaHLTBitMon_QueryRunRegistry.makecff (   file_list,
  namefile 
)

file cff data

Definition at line 63 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by getData().

63 
64 def makecff(file_list,namefile):
65  file1 = open(namefile ,'w')
66  stringS = "process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )\n"
67  stringS = stringS + "readFiles = cms.untracked.vstring()\n"
68  stringS = stringS + "secFiles = cms.untracked.vstring()\n"
69  stringS = stringS + "\n"
70  file1.write(stringS)
71 
72  filecount = 0
73  extendOpen = 0
74  for filename in file_list:
75 
76  if extendOpen == 0:
77  stringS = "readFiles.extend([\n"
78  file1.write(stringS)
79  extendOpen = 1
80 
81  stringS = " '"
82  stringS = stringS + str(filename)
83  stringS = stringS + "',\n"
84  file1.write(stringS)
85  filecount = filecount + 1
86  if filecount == 50:
87  stringS = "])\n\n"
88  file1.write(stringS)
89  filecount = 0
90  extendOpen = 0
91 
92  if extendOpen == 1:
93  stringS = "])\n\n"
94  file1.write(stringS)
95 
96  stringS = "process.source = cms.Source(\"PoolSource\",\n"
97  stringS = stringS + " fileNames = readFiles,\n"
98  stringS = stringS + " secondaryFileNames = secFiles\n"
99  stringS = stringS + ")\n"
100  file1.write(stringS)
101  file1.close()
102 
def AlCaHLTBitMon_QueryRunRegistry.printLumi (   file,
  namefile 
)

lumiCalc

Definition at line 40 of file AlCaHLTBitMon_QueryRunRegistry.py.

References filesize1(), and if().

Referenced by getData().

40 
41 def printLumi(file,namefile):
42  if(filesize1(file) != 0):
43  string= "lumiCalc.py -c frontier://LumiCalc/CMS_LUMI_PROD -i "
44  string1= " --nowarning overview >"
45  string2= string + file + string1 + namefile
46  data = os.system(string2)
47  else:
48  data = ""
49  print "0 lumi are not avaible"
50  return data
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def AlCaHLTBitMon_QueryRunRegistry.printObj (   obj,
  name 
)

Definition at line 161 of file AlCaHLTBitMon_QueryRunRegistry.py.

References getElement(), and getText().

Referenced by getData().

162 def printObj(obj,name):
163  return getText(getElement(obj,name)[0].childNodes)
164 
def AlCaHLTBitMon_QueryRunRegistry.serverQuery (   workspaceName,
  regexp 
)

Definition at line 140 of file AlCaHLTBitMon_QueryRunRegistry.py.

Referenced by extractData().

141 def serverQuery(workspaceName,regexp):
142 
143  # get handler to RR XML-RPC server
144  server = xmlrpclib.ServerProxy('http://cms-service-runregistry-api.web.cern.ch/cms-service-runregistry-api/xmlrpc')
145  if DEBUG:
146  print regexp
147  data = server.RunDatasetTable.export(workspaceName,'xml_all' ,regexp)
148  return data
149 
150 #----------------------------------------------------

Variable Documentation

tuple AlCaHLTBitMon_QueryRunRegistry.data = extractData(options.workspaceName,options.regexp,options.dataset,options.site,options)

Definition at line 263 of file AlCaHLTBitMon_QueryRunRegistry.py.

int AlCaHLTBitMon_QueryRunRegistry.DEBUG = 0

DEBUG.

Definition at line 31 of file AlCaHLTBitMon_QueryRunRegistry.py.

tuple AlCaHLTBitMon_QueryRunRegistry.options = defineOptions()

Definition at line 262 of file AlCaHLTBitMon_QueryRunRegistry.py.