CMS 3D CMS Logo

Functions | Variables
create_public_peakpu_plots Namespace Reference

Functions

def CacheFilePath (cache_file_dir, day=None)
 
def GetXLocator (ax)
 
def PlotPeakPUAllYears (lumi_data_by_fill_per_year)
 
def processdata (years)
 
def TweakPlot (fig, ax, time_range, add_extra_head_room=False)
 

Variables

 accel_mode
 
 action
 
 amodetag_bug_workaround
 
 arg_parser
 
 args
 
 beam_energy
 
 beam_energy_defaults
 
 beam_energy_from_cfg
 
 beam_energy_tmp
 
 beam_fluctuation
 
 beam_fluctuation_defaults
 
 beam_fluctuation_from_cfg
 
 beam_fluctuation_tmp
 
 cache_file_dir
 
 cfg_defaults
 
 cfg_parser
 
 color_scheme_names
 
 color_scheme_names_tmp
 
 config_file_name
 
 date_begin
 
 date_end
 
 DATE_FMT_STR_AXES
 
 DATE_FMT_STR_CFG
 
 DATE_FMT_STR_LUMICALC
 
 DATE_FMT_STR_LUMICALC_DAY
 
 DATE_FMT_STR_OUT
 
 desc_str
 
 description
 
 help
 
 hist
 
 ignore_cache
 
 KNOWN_ACCEL_MODES
 
 LEAD_SCALE_FACTOR
 
 lumi_data_by_fill_per_year
 
 lumicalc_flags_from_cfg
 
 lumicalc_script
 
 NUM_SEC_IN_LS
 
 options
 
 oracle_connection_string
 
 particle_type_str
 
 particle_type_strings
 
 path_name
 
 tmp
 
 today
 
 use_oracle
 
 verbose
 
 year_begin
 
 year_end
 
 years
 

Function Documentation

def create_public_peakpu_plots.CacheFilePath (   cache_file_dir,
  day = None 
)

Definition at line 110 of file create_public_peakpu_plots.py.

110 def CacheFilePath(cache_file_dir, day=None):
111  cache_file_path = os.path.abspath(cache_file_dir)
112  if day:
113  cache_file_name = "lumicalc_cache_%s.csv" % day.isoformat()
114  cache_file_path = os.path.join(cache_file_path, cache_file_name)
115  return cache_file_path
116 
117 
def CacheFilePath(cache_file_dir, day=None)
def create_public_peakpu_plots.GetXLocator (   ax)
Pick a DateLocator based on the range of the x-axis.

Definition at line 118 of file create_public_peakpu_plots.py.

References min(), and TweakPlot().

Referenced by TweakPlot().

118 def GetXLocator(ax):
119  """Pick a DateLocator based on the range of the x-axis."""
120  (x_lo, x_hi) = ax.get_xlim()
121  num_days = x_hi - x_lo
122  min_num_ticks = min(num_days, 5)
123  locator = matplotlib.dates.AutoDateLocator(minticks=min_num_ticks,
124  maxticks=None)
125  # End of GetLocator().
126  return locator
127 
T min(T a, T b)
Definition: MathUtil.h:58
def create_public_peakpu_plots.PlotPeakPUAllYears (   lumi_data_by_fill_per_year)
Mode 1: years side-by-side

Definition at line 410 of file create_public_peakpu_plots.py.

References public_plots_tools.AddLogo(), indexGen.date, public_plots_tools.SavePlot(), and TweakPlot().

410  def PlotPeakPUAllYears(lumi_data_by_fill_per_year):
411  """Mode 1: years side-by-side"""
412 
413  # Loop over all color schemes and plot.
414  for color_scheme_name in color_scheme_names:
415  print " color scheme '%s'" % color_scheme_name
416  color_scheme = ColorScheme(color_scheme_name)
417  color_by_year = color_scheme.color_by_year
418  logo_name = color_scheme.logo_name
419  file_suffix = color_scheme.file_suffix
420 
421  for type in ["lin", "log"]:
422  is_log = (type == "log")
423  aspect_ratio = matplotlib.figure.figaspect(1. / 2.5)
424  fig = plt.figure(figsize=aspect_ratio)
425  ax = fig.add_subplot(111)
426 
427  time_begin_ultimate = datetime.datetime.strptime(lumi_data_by_fill_per_year[years[0]][0][0],DATE_FMT_STR_LUMICALC).date()
428  str_begin_ultimate = time_begin_ultimate.strftime(DATE_FMT_STR_OUT)
429  for (year_index, year) in enumerate(years):
430 
431  lumi_data = lumi_data_by_fill_per_year[year]
432  times_tmp = [datetime.datetime.strptime(tmp,DATE_FMT_STR_LUMICALC).date() for tmp in lumi_data[0]]
433  times = [matplotlib.dates.date2num(i) for i in times_tmp] #x_axis
434  maxpus = lumi_data[1] # y_axis
435 
436  # NOTE: Special case for 2010.
437  label = None
438  if year == 2010 or year == 2011 :
439  label = r"%d, %s" % \
440  (year,r'7TeV $\sigma$=71.5mb')
441  else:
442  label = r"%d, %s" % \
443  (year,r'8TeV $\sigma$=73mb')
444  ax.plot(times,maxpus,
445  color=color_by_year[year],
446 # marker="none", linestyle="solid",
447  marker="o", linestyle='none',
448  linewidth=4,
449  label=label)
450  if is_log:
451  ax.set_yscale("log")
452 
453  time_begin = datetime.datetime(years[0], 1, 1, 0, 0, 0)
454  time_end = datetime.datetime(years[-1], 12, 16, 20, 50,9)
455  str_begin = time_begin.strftime(DATE_FMT_STR_OUT)
456  str_end = time_end.strftime(DATE_FMT_STR_OUT)
457 
458  num_cols = None
459  num_cols = len(years)
460  tmp_x = 0.095
461  tmp_y = .95
462 
463  leg = ax.legend(loc="upper left", bbox_to_anchor=(tmp_x, 0., 1., tmp_y),
464  frameon=False, ncol=num_cols)
465  for t in leg.get_texts():
466  t.set_font_properties(FONT_PROPS_TICK_LABEL)
467 
468  # Set titles and labels.
469  fig.suptitle(r"CMS peak interactions per crossing, %s" % particle_type_str,
470  fontproperties=FONT_PROPS_SUPTITLE)
471  ax.set_title("Data included from %s to %s UTC \n" % \
472  (str_begin_ultimate, str_end),
473  fontproperties=FONT_PROPS_TITLE)
474  ax.set_xlabel(r"Date (UTC)", fontproperties=FONT_PROPS_AX_TITLE)
475  ax.set_ylabel(r"Peak interactions per crossing",\
476  fontproperties=FONT_PROPS_AX_TITLE)
477 
478  # Add the logo.
479  #zoom = 1.7
480  zoom = .95
481  AddLogo(logo_name, ax, zoom=zoom)
482  extra_head_room = 0
483  if is_log:
484  #if mode == 1:
485  extra_head_room = 1
486  #elif mode == 2:
487  # extra_head_room = 2
488  TweakPlot(fig, ax, (time_begin, time_end),
489 # TweakPlot(fig, ax, (time_begin_ultimate, time_end),
490  add_extra_head_room=True)
491 
492  log_suffix = ""
493  if is_log:
494  log_suffix = "_log"
495  SavePlot(fig, "peak_pu_%s_%s%s" % \
496  (particle_type_str.lower(),
497  log_suffix, file_suffix))
def TweakPlot(fig, ax, time_range, add_extra_head_room=False)
def AddLogo(logo_name, ax, zoom=1.2)
def PlotPeakPUAllYears(lumi_data_by_fill_per_year)
def SavePlot(fig, file_name_base)
def create_public_peakpu_plots.processdata (   years)

Definition at line 69 of file create_public_peakpu_plots.py.

References mps_setup.append, spr.find(), objects.autophobj.float, createfilelist.int, genParticles_cff.map, split, and str.

69 def processdata(years):
70  results={}#{year:[[str,str],[pu,pu]]}
71  for y in years:
72  fills=[]#[fillnum]
73  maxputimelist=[]
74  maxpulist=[]
75  results[y]=[maxputimelist,maxpulist]
76  f=None
77  try:
78  lumifilename=str(y)+'lumibyls.csv'
79  f=open(lumifilename,'rb')
80  except IOError:
81  print 'failed to open file ',lumifilename
82  return result
83  freader=csv.reader(f,delimiter=',')
84  idx=0
85  for row in freader:
86  if idx==0:
87  idx=1
88  continue
89  if row[0].find('#')==1:
90  continue
91  [runnum,fillnum]=map(lambda i:int(i),row[0].split(':'))
92  avgpu=float(row[7])
93  if avgpu>50: continue
94  putime=row[2]
95  max_avgpu=avgpu
96  max_putime=putime
97  if fillnum not in fills:#new fill
98  fills.append(fillnum)
99  results[y][0].append(max_putime)
100  results[y][1].append(max_avgpu)
101  if avgpu>max_avgpu:
102  results[y][0][-1]=max_putime
103  results[y][1][-1]=max_avgpu
104  print results
105  return results
106 
107 
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
#define str(s)
double split
Definition: MVATrainer.cc:139
def create_public_peakpu_plots.TweakPlot (   fig,
  ax,
  time_range,
  add_extra_head_room = False 
)

Definition at line 131 of file create_public_peakpu_plots.py.

References GetXLocator().

Referenced by GetXLocator(), and PlotPeakPUAllYears().

131  add_extra_head_room=False):
132 
133  # Fiddle with axes ranges etc.
134  (time_begin, time_end) = time_range
135  ax.relim()
136  ax.autoscale_view(False, True, True)
137  for label in ax.get_xticklabels():
138  label.set_ha("right")
139  label.set_rotation(30.)
140 
141  # Bit of magic here: increase vertical scale by one tick to make
142  # room for the legend.
143  if add_extra_head_room:
144  y_ticks = ax.get_yticks()
145  (y_min, y_max) = ax.get_ylim()
146  is_log = (ax.get_yscale() == "log")
147  y_max_new = y_max
148  if is_log:
149  tmp = y_ticks[-1] / y_ticks[-2]
150  y_max_new = y_max * math.pow(tmp, add_extra_head_room)
151  else:
152  tmp = y_ticks[-1] - y_ticks[-2]
153  y_max_new = y_max + add_extra_head_room * tmp
154  ax.set_ylim(y_min, y_max_new)
155 
156  # Add a second vertical axis on the right-hand side.
157  ax_sec = ax.twinx()
158  ax_sec.set_ylim(ax.get_ylim())
159  ax_sec.set_yscale(ax.get_yscale())
160 
161  for ax_tmp in fig.axes:
162  for sub_ax in [ax_tmp.xaxis, ax_tmp.yaxis]:
163  for label in sub_ax.get_ticklabels():
164  label.set_font_properties(FONT_PROPS_TICK_LABEL)
165 
166  ax.set_xlim(time_begin, time_end)
167 
168  locator = GetXLocator(ax)
169  minorXlocator=matplotlib.ticker.AutoMinorLocator()
170  #ax.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(5))
171  #ax.yaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(5))
172  ax.xaxis.set_major_locator(locator)
173  ax.xaxis.set_minor_locator(minorXlocator)
174 
175  formatter = matplotlib.dates.DateFormatter(DATE_FMT_STR_AXES)
176  ax.xaxis.set_major_formatter(formatter)
177 
178  fig.subplots_adjust(top=.85, bottom=.14, left=.13, right=.91)
179  # End of TweakPlot().
180 

Variable Documentation

create_public_peakpu_plots.accel_mode

Definition at line 227 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.action

Definition at line 188 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.amodetag_bug_workaround

Definition at line 235 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.arg_parser

Definition at line 187 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.args

Definition at line 192 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy

Definition at line 244 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_defaults

Definition at line 307 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_from_cfg

Definition at line 245 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_tmp

Definition at line 241 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation

Definition at line 257 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_defaults

Definition at line 316 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_from_cfg

Definition at line 258 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_tmp

Definition at line 254 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cache_file_dir

Definition at line 220 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cfg_defaults

Definition at line 200 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.cfg_parser

Definition at line 209 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.color_scheme_names

Definition at line 218 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.color_scheme_names_tmp

Definition at line 217 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.config_file_name

Definition at line 197 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.date_begin

Definition at line 269 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.date_end

Definition at line 271 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_AXES

Definition at line 61 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_CFG

Definition at line 62 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC

Definition at line 58 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_LUMICALC_DAY

Definition at line 59 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.DATE_FMT_STR_OUT

Definition at line 60 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.desc_str

Definition at line 185 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.description

Definition at line 187 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.help

Definition at line 189 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.hist

Definition at line 35 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.ignore_cache

Definition at line 198 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.KNOWN_ACCEL_MODES

Definition at line 65 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.LEAD_SCALE_FACTOR

Definition at line 67 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumi_data_by_fill_per_year

Definition at line 383 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_flags_from_cfg

Definition at line 226 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.lumicalc_script

Definition at line 225 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.NUM_SEC_IN_LS

Definition at line 63 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.options

Definition at line 192 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.oracle_connection_string

Definition at line 293 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_str

Definition at line 305 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.particle_type_strings

Definition at line 300 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.path_name

Definition at line 367 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.tmp

Definition at line 268 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.today

Definition at line 275 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.use_oracle

Definition at line 294 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.verbose

Definition at line 222 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_begin

Definition at line 395 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.year_end

Definition at line 396 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.years

Definition at line 381 of file create_public_peakpu_plots.py.