test
CMS 3D CMS Logo

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

Functions

def fillPileupHistogram
 

Variables

string action = 'store_true'
 
list beamModeChoices = ["","stable", "quiet", "either"]
 
dictionary csvDict = {}
 
tuple dbGroup = optparse.OptionGroup(parser, "Database Options")
 
list deadTable = runDTarray[2]
 
 debug = options.debugLumi,
 
tuple events = open(options.csvInput, 'r')
 
tuple f = open(options.inputfile, 'r')
 
tuple fileparsingResult = csvSelectionParser.csvSelectionParser(options.inputfile)
 
string help = 'connect string to lumiDB (optional, default to frontier://LumiCalc/CMS_LUMI_PROD)'
 
tuple hist
 
tuple histFile = ROOT.TFile.Open(output, 'recreate')
 
list histList = []
 
tuple inputfilecontent = f.read()
 
tuple inputGroup = optparse.OptionGroup(parser, "Input Options")
 
 inputRange = options.runnumber
 Get input source. More...
 
string mode = 'csv'
 
list output = args[0]
 
tuple parameters = LumiQueryAPI.ParametersObject()
 

## Main Program

More...
 
tuple parser
 
tuple pieces = sepRE.split(line.strip())
 
tuple pileupGroup = optparse.OptionGroup(parser, "Pileup Options")
 
tuple pileupHist
 Save what we need in the parameters object. More...
 
tuple recordedData = LumiQueryAPI.recordedLumiForRange(session, parameters, inputRange)
 
dictionary runLumiDict = {}
 
list runNumber = runDTarray[0]
 pprint (recordedData) More...
 
tuple sepRE = re.compile(r'[\s,;:]+')
 
list xingInstLumiArray
 

Function Documentation

def estimatePileup.fillPileupHistogram (   deadTable,
  parameters,
  runNumber = 0,
  hist = None,
  debug = False,
  mode = 'deadtable' 
)
Given a deadtable and run number, will (create if necessary
and) fill histogram with expected pileup distribution.  If a
histogram is created, it is owned by the user and is his/her
responsibility to clean up the memory.

Definition at line 14 of file estimatePileup.py.

14 
15  mode='deadtable'):
16  '''Given a deadtable and run number, will (create if necessary
17  and) fill histogram with expected pileup distribution. If a
18  histogram is created, it is owned by the user and is his/her
19  responsibility to clean up the memory.'''
20  if hist:
21  maxBin = hist.GetNbinsX()
22  upper = int( hist.GetBinLowEdge(maxBin) + \
23  hist.GetBinWidth(maxBin) + 0.25 )
24  else:
25  histname = '%s_%s' % (parameters.pileupHistName, runNumber)
26  hist = ROOT.TH1D (histname, histname, parameters.maxPileupBin + 1,
27  -0.5, parameters.maxPileupBin + 0.5)
28  upper = parameters.maxPileupBin
29  for lumiSection, deadArray in sorted (deadTable.iteritems()):
30  if mode == 'csv':
31  numerator = float (deadArray[1])
32  denominator = float (deadArray[0])
33  instLumiArray = deadArray[2]
34  livetime = 1
35  if numerator < 0:
36  numerator = 0
37  if denominator:
38  livetime = numerator / denominator
39  else:
40  # we got everything from lumiDB
41  if len(deadArray) <= parameters.xingIndex:
42  # for some reason the xing instantaneous luminosity
43  # information isn't there. Print a warning and then skip
44  # it:
45  if parameters.noWarnings:
46  continue
47  if runNumber:
48  print "No Xing Instantaneous luminosity information for run %d, lumi section %d" \
49  % (runNumber, lumiSection)
50  else:
51  print "No Xing Instantaneous luminosity information for lumi section %d" \
52  % lumiSection
53  continue
54  numerator = float (deadArray[0])
55  denominator = float (deadArray[2] * deadArray[4])
56  xingInstLumiArray = deadArray[parameters.xingIndex]
57  # here we only want the instantaneous luminosities and don't
58  # care which crosings they fall in. So we only want the odd
59  instLumiArray = [(xingInstLumiArray[index], xingInstLumiArray[index + 1]) \
60  for index in xrange( 0, len (xingInstLumiArray), 2 ) ]
61  livetime = 1
62  if numerator < 0:
63  numerator = 0
64  if denominator:
65  livetime = 1 - numerator / denominator
66  # totalInstLumi = reduce(lambda x, y: x+y, instLumiArray) # not needed
67  for xing, xingInstLumi in instLumiArray:
68  xingIntLumi = xingInstLumi * parameters.lumiSectionLen * livetime
69  mean = xingInstLumi * parameters.minBiasXsec * \
70  parameters.rotationTime
71  if mean > 100:
72  if runNumber:
73  print "mean number of pileup events > 100 for run %d, lum %d : m %f l %f" % \
74  (runNumber, lumiSection, mean, xingInstLumi)
75  else:
76  print "mean number of pileup events > 100 for lum %d: m %f l %f" % \
77  (lumiSection, mean, xingInstLumi)
78 
79  for obs in range (upper):
80  prob = ROOT.TMath.Poisson (obs, mean)
81  totalProb += prob
82  hist.Fill (obs, prob * xingIntLumi)
83  if debug:
84  print "ls", lumiSection, "xing", xing, "inst", xingInstLumi, \
85  "mean", mean, "totalProb", totalProb, 1 - totalProb
86  print " hist mean", hist.GetMean()
87  if totalProb < 1:
88  hist.Fill (obs, (1 - totalProb) * xingIntLumi)
89  return hist
90 
91 

Variable Documentation

string estimatePileup.action = 'store_true'

Definition at line 140 of file estimatePileup.py.

list estimatePileup.beamModeChoices = ["","stable", "quiet", "either"]

Definition at line 102 of file estimatePileup.py.

dictionary estimatePileup.csvDict = {}

Definition at line 194 of file estimatePileup.py.

tuple estimatePileup.dbGroup = optparse.OptionGroup(parser, "Database Options")

Definition at line 105 of file estimatePileup.py.

list estimatePileup.deadTable = runDTarray[2]

Definition at line 259 of file estimatePileup.py.

estimatePileup.debug = options.debugLumi,

Definition at line 224 of file estimatePileup.py.

tuple estimatePileup.events = open(options.csvInput, 'r')

Definition at line 193 of file estimatePileup.py.

tuple estimatePileup.f = open(options.inputfile, 'r')

Definition at line 248 of file estimatePileup.py.

tuple estimatePileup.fileparsingResult = csvSelectionParser.csvSelectionParser(options.inputfile)

Definition at line 246 of file estimatePileup.py.

string estimatePileup.help = 'connect string to lumiDB (optional, default to frontier://LumiCalc/CMS_LUMI_PROD)'

Definition at line 109 of file estimatePileup.py.

tuple estimatePileup.hist
Initial value:
1 = fillPileupHistogram(lumiDict, parameters,
2  runNumber = runNumber,
3  debug = options.debugLumi,
4  mode='csv')

Definition at line 215 of file estimatePileup.py.

Referenced by APVCyclePhaseMonitor.beginRun(), Book.book(), TouchableToHistory.buildAll(), ClusMultInvestPlots(), Combined2DHisto(), CombinedHisto(), examples::TrackAnalysisAlgorithm.draw(), fwlite::Scanner< Collection >.draw(), fwlite::Scanner< Collection >.draw2D(), fwlite::Scanner< Collection >.drawProf(), L1TEventInfoClient.dumpContentMonitorElements(), EcalPedHists.endJob(), EcalURecHitHists.endJob(), EcalCosmicsHists.endJob(), DQMHistNormalizer.endRun(), ExpressionHisto< T >.fill(), edm::Principal.fillPrincipal(), EgHLTOfflineSummaryClient.getEgHLTSumHist_(), TouchableToHistory.getNavStory(), fwlite::Scanner< Collection >.getSameH1(), fwlite::Scanner< Collection >.getSameH2(), fwlite::Scanner< Collection >.getSameProf(), SiStripSummaryCreator.getSummaryME(), FWEveViewManager.highlightAdded(), HistoAnalyzer< C >.HistoAnalyzer(), MuonResidualsFitter.histogramChi2GaussianFit(), EcalDisplaysByEvent.init2DEcalHist(), EcalDisplaysByEvent.init3DEcalHist(), EcalURecHitHists.initHists(), EcalCosmicsHists.initHists(), ExpressionHisto< T >.initialize(), main(), LA_Filler_Fitter.make_and_fit_symmchi2(), SiStripSpyDisplayModule.MakeDigiHist_(), ValidateGeometry.makeHistogram(), SiStripSpyDisplayModule.MakeProcessedRawDigiHist_(), SiStripSpyDisplayModule.MakeRawDigiHist_(), DDExpandedView.mergedSpecificsV(), DQMGenericClient.normalizeToEntries(), DQMRivetClient.normalizeToIntegral(), DQMRivetClient.normalizeToLumi(), CSCAlignmentCorrections.plot(), MuonResidualsFitter.plotsimple(), MuonResidualsFitter.plotweighted(), EcalPedHists.readEBdigis(), EcalPedHists.readEEdigis(), DQMRivetClient.scaleByFactor(), DDExpandedView.specificsV(), tfwliteselectortest::ThingsTSelector.terminate(), tfwliteselectortest::ThingsTSelector2.terminate(), __class__< T >.terminate(), sistrip::EnsembleCalibrationLA.write_ensembles_plots(), sistrip::MeasureLA.write_report_plots(), and sistrip::EnsembleCalibrationLA.write_samples_plots().

tuple estimatePileup.histFile = ROOT.TFile.Open(output, 'recreate')

Definition at line 227 of file estimatePileup.py.

list estimatePileup.histList = []

Definition at line 186 of file estimatePileup.py.

tuple estimatePileup.inputfilecontent = f.read()

Definition at line 249 of file estimatePileup.py.

tuple estimatePileup.inputGroup = optparse.OptionGroup(parser, "Input Options")

Definition at line 106 of file estimatePileup.py.

tuple estimatePileup.inputRange = options.runnumber

Get input source.

Definition at line 241 of file estimatePileup.py.

Referenced by SiStripNoiseNormalizedWithApvGainBuilder.analyze(), SiStripApvGainBuilderFromTag.analyze(), SiStripGain.fillNewGain(), cms::ReconstructerFP420.produce(), cms::TrackerizerFP420.produce(), cms::ClusterizerFP420.produce(), cms::DigitizerFP420.produce(), PixelDigiCollection.put(), DigiCollectionFP420.put(), TrackCollectionFP420.put(), ClusterCollectionFP420.put(), RecoCollectionFP420.put(), ClusterCollectionFP420.putclear(), TrackCollectionFP420.putclear(), RecoCollectionFP420.putclear(), DigiCollectionFP420.putclear(), FP420TrackMain.run(), and FP420ClusterMain.run().

string estimatePileup.mode = 'csv'

Definition at line 225 of file estimatePileup.py.

list estimatePileup.output = args[0]

Definition at line 157 of file estimatePileup.py.

tuple estimatePileup.parameters = LumiQueryAPI.ParametersObject()

## Main Program

Definition at line 101 of file estimatePileup.py.

tuple estimatePileup.parser
Initial value:
1 = optparse.OptionParser("Usage: %prog [--options] output.root",
2  description = "Script to estimate pileup distribution using xing instantaneous luminosity information and minimum bias cross section. Output is TH1D stored in root file")

Definition at line 103 of file estimatePileup.py.

tuple estimatePileup.pieces = sepRE.split(line.strip())

Definition at line 196 of file estimatePileup.py.

tuple estimatePileup.pileupGroup = optparse.OptionGroup(parser, "Pileup Options")

Definition at line 107 of file estimatePileup.py.

tuple estimatePileup.pileupHist
Initial value:
1 = ROOT.TH1D(parameters.pileupHistName, parameters.pileupHistName,
2  1001,
3  0.0, 25.)

Save what we need in the parameters object.

Let's start the fun

Definition at line 183 of file estimatePileup.py.

tuple estimatePileup.recordedData = LumiQueryAPI.recordedLumiForRange(session, parameters, inputRange)

Definition at line 255 of file estimatePileup.py.

dictionary estimatePileup.runLumiDict = {}

Definition at line 192 of file estimatePileup.py.

list estimatePileup.runNumber = runDTarray[0]

pprint (recordedData)

Definition at line 258 of file estimatePileup.py.

tuple estimatePileup.sepRE = re.compile(r'[\s,;:]+')

Definition at line 191 of file estimatePileup.py.

list estimatePileup.xingInstLumiArray
Initial value:
1 = [( int(orbit), float(lum) ) \
2  for orbit, lum in zip( pieces[9::2],
3  pieces[10::2] ) ]

Definition at line 205 of file estimatePileup.py.