CMS 3D CMS Logo

Functions
TkMap_script_phase1 Namespace Reference

Functions

def downloadnlineDQMhisto (run, Run_type)
 
def downloadOfflineDQMhisto (run, Run_type)
 
def getGT (DQMfile, RunNumber, globalTagVar)
 
def setRunDirectory (runNumber)
 

Function Documentation

def TkMap_script_phase1.downloadnlineDQMhisto (   run,
  Run_type 
)

Definition at line 61 of file TkMap_script_phase1.py.

References any(), edm.print(), setRunDirectory(), split, and str.

Referenced by getGT().

61 def downloadnlineDQMhisto(run, Run_type):
62  runDirval=setRunDirectory(run)
63  DataLocalDir=runDirval[0]
64  DataOfflineDir=runDirval[1]
65  nnn=run/100
66  nnnOnline = run/10000
67  File_Name_online=''
68  deadRocMap = False
69  ##################online file########
70  url1 = 'https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+str(nnnOnline)+'xxxx/000'+str(nnn)+'xx/'
71  os.popen("curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url1+" > index_online.html")
72 
73  url2 = 'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OnlineData/original/000'+str(nnnOnline)+'xxxx/000'+str(nnn)+'xx/'
74  os.popen("curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url2+" > index_online_backup.html")
75  f_online_backup=codecs.open("index_online_backup.html", 'r')
76  index_online_backup = f_online_backup.readlines()
77 
78  f_online=codecs.open("index_online.html", 'r')
79  index_online = f_online.readlines()
80  if any(str(run) in x for x in index_online):
81  for x in index_online:
82  if (str(run) in x) and ("_PixelPhase1_" in x):
83  File_Name_online=str(str(x).split(".root'>")[1].split("</a></td><td>")[0])
84  deadRocMap = True
85  else:
86  print("Can't find any file in offline server, trying the online server")
87  if any(str(run) in y for y in index_online_backup):
88  for y in index_online:
89  if (str(run) in y) and ("_PixelPhase1_" in y):
90  File_Name_online=str(str(y).split(".root'>")[1].split("</a></td><td>")[0])
91  deadRocMap = True
92  else:
93  print('No Online DQM file available. Skip dead roc map')
94  deadRocMap = False
95 
96  print('Downloading DQM file:'+File_Name_online)
97 
98 
99  os.system('curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+str(nnnOnline)+'xxxx/000'+str(nnn)+'xx/'+File_Name_online+' > /tmp/'+File_Name_online)
100 
101  os.remove('index_online.html')
102  os.remove('index_online_backup.html')
103  return deadRocMap, File_Name_online;
104 
105 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def downloadnlineDQMhisto(run, Run_type)
def setRunDirectory(runNumber)
#define str(s)
double split
Definition: MVATrainer.cc:139
def TkMap_script_phase1.downloadOfflineDQMhisto (   run,
  Run_type 
)

Definition at line 36 of file TkMap_script_phase1.py.

References any(), edm.print(), setRunDirectory(), split, and str.

Referenced by getGT().

36 def downloadOfflineDQMhisto(run, Run_type):
37  runDirval=setRunDirectory(run)
38  DataLocalDir=runDirval[0]
39  DataOfflineDir=runDirval[1]
40  nnn=run/100
41  print('Processing '+ Run_type + ' in '+DataOfflineDir+"...")
42  File_Name = ''
43  print('Directory to fetch the DQM file from: https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+'/'+Run_type+'/000'+str(nnn)+'xx/')
44  url = 'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+'/'+Run_type+'/000'+str(nnn)+'xx/'
45  os.popen("curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url+" > index.html")
46  f=codecs.open("index.html", 'r')
47  index = f.readlines()
48  if any(str(Run_Number[i]) in s for s in index):
49  for s in index:
50  if (str(Run_Number[i]) in s) and ("__DQMIO.root" in s):
51  File_Name = str(str(s).split("xx/")[1].split("'>DQM")[0])
52  else:
53  print('No DQM file available. Please check the Offline server')
54  sys.exit(0)
55 
56  print('Downloading DQM file:'+File_Name)
57  os.system('curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+'/'+Run_type+'/000'+str(nnn)+'xx/'+File_Name+' > /tmp/'+File_Name)
58 
59  return File_Name
60 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def setRunDirectory(runNumber)
#define str(s)
double split
Definition: MVATrainer.cc:139
def downloadOfflineDQMhisto(run, Run_type)
def TkMap_script_phase1.getGT (   DQMfile,
  RunNumber,
  globalTagVar 
)

Definition at line 106 of file TkMap_script_phase1.py.

References downloadnlineDQMhisto(), downloadOfflineDQMhisto(), createfilelist.int, edm.print(), setRunDirectory(), str, and digitizers_cfi.strip.

106 def getGT(DQMfile, RunNumber, globalTagVar):
107  globalTag_v0 = getGTfromDQMFile(DQMfile, RunNumber, globalTagVar)
108  print("Global Tag: " + globalTag_v0)
109  globalTag = globalTag_v0
110 
111  for z in range(len(globalTag_v0)-2):#clean up the garbage string in the GT
112  if (globalTag_v0[z].isdigit()) and (globalTag_v0[z+1].isdigit()) and (globalTag_v0[z+2].isdigit()) and(globalTag_v0[z+3].isupper()):
113  globalTag = globalTag_v0[z:]
114  if globalTag == "":
115  print(" No GlobalTag found: trying from DAS.... ");
116  globalTag = str(os.popen('getGTscript.sh '+filepath+ File_Name+' ' +str(Run_Number[i])));
117  if globalTag == "":
118  print(" No GlobalTag found for run: "+str(Run_Number[i]));
119  return globalTag
120 
121 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def getGT(DQMfile, RunNumber, globalTagVar)
#define str(s)
def TkMap_script_phase1.setRunDirectory (   runNumber)

Definition at line 16 of file TkMap_script_phase1.py.

Referenced by downloadnlineDQMhisto(), downloadOfflineDQMhisto(), and getGT().

16 def setRunDirectory(runNumber):
17  # Don't forget to add an entry when there is a new era
18  dirDict = { 315252:['Data2018', 'Run2018'],\
19  308336:['Data2018', 'Commissioning2018'],\
20  294644:['Data2017', 'Run2017'],\
21  290123:['Data2017', 'Commissioning2017'],\
22  284500:['Data2016', 'PARun2016'],\
23  271024:['Data2016', 'Run2016'],\
24  264200:['Data2016', 'Commissioning2016'],\
25  246907:['Data2015', 'Run2015'],\
26  232881:['Data2015', 'Commissioning2015'],\
27  211658:['Data2013', 'Run2013'],\
28  209634:['Data2013', 'HIRun2013'],\
29  190450:['Data2012', 'Run2012']}
30  runKey=0
31  for key in sorted(dirDict):
32  if runNumber > key:
33  runKey=key
34  return dirDict[runKey]
35 
def setRunDirectory(runNumber)