test
CMS 3D CMS Logo

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

Functions

def CacheFilePath
 
def GetXLocator
 
def PlotPeakPUAllYears
 
def processdata
 
def TweakPlot
 

Variables

tuple accel_mode = cfg_parser.get("general", "accel_mode")
 
 amodetag_bug_workaround = False
 
tuple arg_parser = optparse.OptionParser(description=desc_str)
 
 beam_energy = None
 
dictionary beam_energy_defaults
 
 beam_energy_from_cfg = None
 
tuple beam_energy_tmp = cfg_parser.get("general", "beam_energy")
 
 beam_fluctuation = None
 
dictionary beam_fluctuation_defaults
 
 beam_fluctuation_from_cfg = None
 
tuple beam_fluctuation_tmp = cfg_parser.get("general", "beam_fluctuation")
 
tuple cache_file_dir = cfg_parser.get("general", "cache_dir")
 
dictionary cfg_defaults
 
tuple cfg_parser = ConfigParser.SafeConfigParser(cfg_defaults)
 
list color_scheme_names = [i.strip() for i in color_scheme_names_tmp.split(",")]
 
tuple color_scheme_names_tmp = cfg_parser.get("general", "color_schemes")
 
list config_file_name = args[0]
 
tuple date_begin = datetime.datetime.strptime(tmp, DATE_FMT_STR_CFG)
 
 date_end = None
 
string DATE_FMT_STR_AXES = "%-d %b"
 
string DATE_FMT_STR_CFG = "%Y-%m-%d"
 
string DATE_FMT_STR_LUMICALC = "%m/%d/%y %H:%M:%S"
 
string DATE_FMT_STR_LUMICALC_DAY = "%m/%d/%y"
 
string DATE_FMT_STR_OUT = "%Y-%m-%d %H:%M"
 
string desc_str = "test pu"
 
string help = "Ignore all cached lumiCalc results "
 
 ignore_cache = options.ignore_cache
 
list KNOWN_ACCEL_MODES
 
int LEAD_SCALE_FACTOR = 82
 
dictionary lumi_data_by_fill_per_year = {}
 
tuple lumicalc_flags_from_cfg = cfg_parser.get("general", "lumicalc_flags")
 
tuple lumicalc_script = cfg_parser.get("general", "lumicalc_script")
 
int NUM_SEC_IN_LS = 2
 
tuple oracle_connection_string = cfg_parser.get("general", "oracle_connection")
 
list particle_type_str = particle_type_strings[accel_mode]
 
dictionary particle_type_strings
 
tuple path_name = CacheFilePath(cache_file_dir)
 
tuple tmp = cfg_parser.get("general", "date_begin")
 
tuple today = datetime.datetime.utcnow()
 
tuple use_oracle = (len(oracle_connection_string) != 0)
 
tuple verbose = cfg_parser.getboolean("general", "verbose")
 
tuple year_begin = date_begin.isocalendar()
 
tuple year_end = date_end.isocalendar()
 
list years = [2010,2011,2012]
 

Function Documentation

def create_public_peakpu_plots.CacheFilePath (   cache_file_dir,
  day = None 
)

Definition at line 109 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 
def create_public_peakpu_plots.GetXLocator (   ax)
Pick a DateLocator based on the range of the x-axis.

Definition at line 117 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
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 409 of file create_public_peakpu_plots.py.

References public_plots_tools.AddLogo(), 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(),
log_suffix, file_suffix))
def create_public_peakpu_plots.processdata (   years)

Definition at line 68 of file create_public_peakpu_plots.py.

References bitset_utilities.append(), spr.find(), and split.

68 
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 
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double split
Definition: MVATrainer.cc:139
def create_public_peakpu_plots.TweakPlot (   fig,
  ax,
  time_range,
  add_extra_head_room = False 
)

Definition at line 130 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().

Variable Documentation

string create_public_peakpu_plots.accel_mode = cfg_parser.get("general", "accel_mode")

Definition at line 226 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.amodetag_bug_workaround = False

Definition at line 234 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.arg_parser = optparse.OptionParser(description=desc_str)

Definition at line 186 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.beam_energy = None

Definition at line 243 of file create_public_peakpu_plots.py.

dictionary create_public_peakpu_plots.beam_energy_defaults
Initial value:
1 = {
2  "PROTPHYS" : {2010 : 3500.,
3  2011 : 3500.,
4  2012 : 4000.,
5  2013 : 1380.1},
6  "IONPHYS" : {2010 : 3500.,
7  2011 : 3500.},
8  "PAPHYS" : {2013 : 4000.}
9  }

Definition at line 306 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_energy_from_cfg = None

Definition at line 244 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.beam_energy_tmp = cfg_parser.get("general", "beam_energy")

Definition at line 240 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.beam_fluctuation = None

Definition at line 256 of file create_public_peakpu_plots.py.

dictionary create_public_peakpu_plots.beam_fluctuation_defaults
Initial value:
1 = {
2  "PROTPHYS" : {2010 : .15,
3  2011 : .15,
4  2012 : .15,
5  2013 : .15},
6  "IONPHYS" : {2010 : .15,
7  2011 : .15},
8  "PAPHYS" : {2013 : .15}
9  }

Definition at line 315 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.beam_fluctuation_from_cfg = None

Definition at line 257 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.beam_fluctuation_tmp = cfg_parser.get("general", "beam_fluctuation")

Definition at line 253 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.cache_file_dir = cfg_parser.get("general", "cache_dir")

Definition at line 219 of file create_public_peakpu_plots.py.

dictionary create_public_peakpu_plots.cfg_defaults
Initial value:
1 = {
2  "lumicalc_flags" : "",
3  "date_end" : None,
4  "color_schemes" : "Joe, Greg",
5  "beam_energy" : None,
6  "beam_fluctuation" : None,
7  "verbose" : False,
8  "oracle_connection" : None
9  }

Definition at line 199 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.cfg_parser = ConfigParser.SafeConfigParser(cfg_defaults)

Definition at line 208 of file create_public_peakpu_plots.py.

list create_public_peakpu_plots.color_scheme_names = [i.strip() for i in color_scheme_names_tmp.split(",")]

Definition at line 217 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.color_scheme_names_tmp = cfg_parser.get("general", "color_schemes")

Definition at line 216 of file create_public_peakpu_plots.py.

list create_public_peakpu_plots.config_file_name = args[0]

Definition at line 196 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.date_begin = datetime.datetime.strptime(tmp, DATE_FMT_STR_CFG)

Definition at line 268 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.date_end = None

Definition at line 270 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.DATE_FMT_STR_AXES = "%-d %b"

Definition at line 60 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.DATE_FMT_STR_CFG = "%Y-%m-%d"

Definition at line 61 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.DATE_FMT_STR_LUMICALC = "%m/%d/%y %H:%M:%S"

Definition at line 57 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.DATE_FMT_STR_LUMICALC_DAY = "%m/%d/%y"

Definition at line 58 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.DATE_FMT_STR_OUT = "%Y-%m-%d %H:%M"

Definition at line 59 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.desc_str = "test pu"

Definition at line 184 of file create_public_peakpu_plots.py.

string create_public_peakpu_plots.help = "Ignore all cached lumiCalc results "

Definition at line 188 of file create_public_peakpu_plots.py.

create_public_peakpu_plots.ignore_cache = options.ignore_cache

Definition at line 197 of file create_public_peakpu_plots.py.

list create_public_peakpu_plots.KNOWN_ACCEL_MODES
Initial value:
1 = ["PROTPHYS", "IONPHYS", "PAPHYS",
2  "2013_amode_bug_workaround"]

Definition at line 64 of file create_public_peakpu_plots.py.

int create_public_peakpu_plots.LEAD_SCALE_FACTOR = 82

Definition at line 66 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.lumi_data_by_fill_per_year = {}

Definition at line 382 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.lumicalc_flags_from_cfg = cfg_parser.get("general", "lumicalc_flags")

Definition at line 225 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.lumicalc_script = cfg_parser.get("general", "lumicalc_script")

Definition at line 224 of file create_public_peakpu_plots.py.

int create_public_peakpu_plots.NUM_SEC_IN_LS = 2

Definition at line 62 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.oracle_connection_string = cfg_parser.get("general", "oracle_connection")

Definition at line 292 of file create_public_peakpu_plots.py.

list create_public_peakpu_plots.particle_type_str = particle_type_strings[accel_mode]

Definition at line 304 of file create_public_peakpu_plots.py.

dictionary create_public_peakpu_plots.particle_type_strings
Initial value:
1 = {
2  "PROTPHYS" : "pp",
3  "IONPHYS" : "PbPb",
4  "PAPHYS" : "pPb"
5  }

Definition at line 299 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.path_name = CacheFilePath(cache_file_dir)

Definition at line 366 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.tmp = cfg_parser.get("general", "date_begin")

Definition at line 267 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.today = datetime.datetime.utcnow()

Definition at line 274 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.use_oracle = (len(oracle_connection_string) != 0)

Definition at line 293 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.verbose = cfg_parser.getboolean("general", "verbose")

Definition at line 221 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.year_begin = date_begin.isocalendar()

Definition at line 394 of file create_public_peakpu_plots.py.

tuple create_public_peakpu_plots.year_end = date_end.isocalendar()

Definition at line 395 of file create_public_peakpu_plots.py.

list create_public_peakpu_plots.years = [2010,2011,2012]

Definition at line 380 of file create_public_peakpu_plots.py.