CMS 3D CMS Logo

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

Functions

def fillPileupHistogram
 
def MyErf
 
def parseInputFile
 

Variables

list CalculationModeChoices = ['truth', 'observed']
 
string default = 'PileupCalc.root'
 
string help = 'output root file'
 
tuple histFile = ROOT.TFile.Open(output, 'recreate')
 
tuple inpf = open(options.inputfile, 'r')
 
tuple inputfilecontent = inpf.read()
 
tuple inputPileupRange = parseInputFile(options.inputLumiJSON)
 
tuple inputRange = selectionParser.selectionParser(inputfilecontent)
 
list LSPUlist = inputPileupRange[run]
 
list lumiInfo = LSPUlist[LSnumber]
 
 nbins = options.numPileupBins
 
list output = args[0]
 
tuple parser
 

## Main Program

More...
 
tuple pileupHist
 
 type = float,
 
 upper = options.maxPileupBin
 
string VERSION = '1.00'
 

Function Documentation

def pileupCalc.fillPileupHistogram (   lumiInfo,
  calcOption,
  hist,
  minbXsec,
  Nbins 
)
lumiinfo:[intlumi per LS, mean interactions ]

intlumi is the deadtime corrected average integraged lumi per lumisection

Definition at line 54 of file pileupCalc.py.

References MyErf(), and mathSSE.sqrt().

54 
55 def fillPileupHistogram (lumiInfo, calcOption, hist, minbXsec, Nbins):
56  '''
57  lumiinfo:[intlumi per LS, mean interactions ]
58 
59  intlumi is the deadtime corrected average integraged lumi per lumisection
60  '''
61 
62  LSintLumi = lumiInfo[0]
63  RMSInt = lumiInfo[1]*minbXsec
64  AveNumInt = lumiInfo[2]*minbXsec
65 
66  #coeff = 0
67 
68  #if RMSInt > 0:
69  # coeff = 1.0/RMSInt/sqrt(6.283185)
70 
71  #expon = 2.0*RMSInt*RMSInt
72 
73  Sqrt2 = sqrt(2)
74 
75  ##Nbins = hist.GetXaxis().GetNbins()
76 
77  ProbFromRMS = []
78  BinWidth = hist.GetBinWidth(1)
79 
80  # First, re-constitute lumi distribution for this LS from RMS:
81  if RMSInt > 0:
82 
83  AreaLnew = -10.
84  AreaL = 0
85 
86  for obs in range (Nbins):
87  #Old Gaussian normalization; inaccurate for small rms and large bins
88  #val = hist.GetBinCenter(obs+1)
89  #prob = coeff*exp(-1.0*(val-AveNumInt)*(val-AveNumInt)/expon)
90  #ProbFromRMS.append(prob)
91 
92  left = hist.GetBinLowEdge(obs+1)
93  right = left+BinWidth
94 
95  argR = (AveNumInt-right)/Sqrt2/RMSInt
96  AreaR = MyErf(argR)
97 
98  if AreaLnew<-5.:
99  argL = (AveNumInt-left)/Sqrt2/RMSInt
100  AreaL = MyErf(argL)
101  else:
102  AreaL = AreaLnew
103  AreaLnew = AreaR # save R bin value for L next time
104 
105  NewProb = (AreaL-AreaR)*0.5
106 
107  ProbFromRMS.append(NewProb)
108 
109  #print left, right, argL, argR, AreaL, AreaR, NewProb
110 
111  else:
112  obs = hist.FindBin(AveNumInt)
113  for bin in range (Nbins):
114  ProbFromRMS.append(0.0)
115  if obs<Nbins+1:
116  ProbFromRMS[obs] = 1.0
117  if AveNumInt < 1.0E-5:
118  ProbFromRMS[obs] = 0. # just ignore zero values
119 
120  if calcOption == 'true': # Just put distribution into histogram
121  if RMSInt > 0:
122  totalProb = 0
123  for obs in range (Nbins):
124  prob = ProbFromRMS[obs]
125  val = hist.GetBinCenter(obs+1)
126  #print obs, val, RMSInt,coeff,expon,prob
127  totalProb += prob
128  hist.Fill (val, prob * LSintLumi)
129 
130  if 1.0-totalProb > 0.01:
131  print "Significant probability density outside of your histogram"
132  print "Consider using a higher value of --maxPileupBin"
133  print "Mean %f, RMS %f, Integrated probability %f" % (AveNumInt,RMSInt,totalProb)
134  # hist.Fill (val, (1 - totalProb) * LSintLumi)
135  else:
136  hist.Fill(AveNumInt,LSintLumi)
137  else: # have to convolute with a poisson distribution to get observed Nint
138  totalProb = 0
139  Peak = 0
140  BinWidth = hist.GetBinWidth(1)
141  for obs in range (Nbins):
142  Peak = hist.GetBinCenter(obs+1)
143  RMSWeight = ProbFromRMS[obs]
144  for bin in range (Nbins):
145  val = hist.GetBinCenter(bin+1)-0.5*BinWidth
146  prob = ROOT.TMath.Poisson (val, Peak)
147  totalProb += prob
148  hist.Fill (val, prob * LSintLumi * RMSWeight)
149 
150  if 1.0-totalProb > 0.01:
151  print "Significant probability density outside of your histogram"
152  print "Consider using a higher value of --maxPileupBin"
153 
154 
155  return hist
156 
157 
T sqrt(T t)
Definition: SSEVec.h:48
def fillPileupHistogram
Definition: pileupCalc.py:54
def pileupCalc.MyErf (   input)

Definition at line 22 of file pileupCalc.py.

References funct.abs(), and create_public_lumi_plots.exp.

Referenced by fillPileupHistogram().

22 
23 def MyErf(input):
24 
25  # Abramowitz and Stegun approximations for Erf (equations 7.1.25-28)
26  X = abs(input)
27 
28  p = 0.47047
29  b1 = 0.3480242
30  b2 = -0.0958798
31  b3 = 0.7478556
32 
33  T = 1.0/(1.0+p*X)
34  cErf = 1.0 - (b1*T + b2*T*T + b3*T*T*T)*exp(-1.0*X*X)
35  if input<0:
36  cErf = -1.0*cErf
37 
38  # Alternate Erf approximation:
39 
40  #A1 = 0.278393
41  #A2 = 0.230389
42  #A3 = 0.000972
43  #A4 = 0.078108
44 
45  #term = 1.0+ A1*X+ A2*X*X+ A3*X*X*X+ A4*X*X*X*X
46  #denom = term*term*term*term
47 
48  #dErf = 1.0 - 1.0/denom
49  #if input<0:
50  # dErf = -1.0*dErf
51 
52  return cErf
53 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def pileupCalc.parseInputFile (   inputfilename)
output ({run:[ls:[inlumi, meanint]]})

Definition at line 10 of file pileupCalc.py.

10 
11 def parseInputFile(inputfilename):
12  '''
13  output ({run:[ls:[inlumi, meanint]]})
14  '''
15  selectf=open(inputfilename,'r')
16  inputfilecontent=selectf.read()
17  p=pileupParser.pileupParser(inputfilecontent)
18 
19 # p=inputFilesetParser.inputFilesetParser(inputfilename)
20  runlsbyfile=p.runsandls()
21  return runlsbyfile
def parseInputFile
Definition: pileupCalc.py:10

Variable Documentation

list pileupCalc.CalculationModeChoices = ['truth', 'observed']

Definition at line 172 of file pileupCalc.py.

string pileupCalc.default = 'PileupCalc.root'

Definition at line 183 of file pileupCalc.py.

string pileupCalc.help = 'output root file'

Definition at line 184 of file pileupCalc.py.

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

Definition at line 278 of file pileupCalc.py.

tuple pileupCalc.inpf = open(options.inputfile, 'r')

Definition at line 240 of file pileupCalc.py.

tuple pileupCalc.inputfilecontent = inpf.read()

Definition at line 241 of file pileupCalc.py.

tuple pileupCalc.inputPileupRange = parseInputFile(options.inputLumiJSON)

Definition at line 247 of file pileupCalc.py.

tuple pileupCalc.inputRange = selectionParser.selectionParser(inputfilecontent)

Definition at line 242 of file pileupCalc.py.

list pileupCalc.LSPUlist = inputPileupRange[run]

Definition at line 257 of file pileupCalc.py.

list pileupCalc.lumiInfo = LSPUlist[LSnumber]

Definition at line 262 of file pileupCalc.py.

Referenced by edm.BranchTypeToInfoTreeName().

pileupCalc.nbins = options.numPileupBins

Definition at line 237 of file pileupCalc.py.

Referenced by npstat::HistoND< Numeric, Axis >.accumulateBinsLoop(), FedTimingAlgorithm.analyse(), ApvTimingAlgorithm.analyse(), FastFedCablingAlgorithm.analyse(), OptoScanAlgorithm.analyse(), DaqScopeModeAlgorithm.analyse(), BigEventsDebugger< T >.analyze(), DQMMessageLogger.beginJob(), BigEventsDebugger< T >.BigEventsDebugger(), FastFedCablingTask.book(), ApvTimingTask.book(), FedTimingTask.book(), VpspScanTask.book(), OptoScanTask.book(), PedestalsTask.book(), FedCablingTask.book(), ecaldqm::MESetEcal.book(), DTTriggerEfficiencyTask.bookChamberHistos(), DTLocalTriggerEfficiencyTest.bookChambHistos(), DTLocalTriggerSynchTest.bookChambHistos(), DTTriggerEfficiencyTest.bookChambHistos(), TopDiLeptonDQM.bookHistograms(), L1TDTTF.bookHistograms(), L1TGMT.bookHistograms(), JetMETHLTOfflineSource.bookHistograms(), DTLocalTriggerTask.bookHistos(), DTLocalTriggerSynchTask.bookHistos(), TrackerOfflineValidation.bookHists(), TrackerOfflineValidation.bookSummaryHists(), BTagEntry.BTagEntry(), L1TDTTFClient.buildPhiEtaPlotO(), L1TDTTFClient.buildPhiEtaPlotOFC(), PixelLumiDQM.calculateBunchMask(), CentralityBins.CentralityBins(), SamplingAlgorithm.correctProfile(), reco::DiscretizedEnergyFlow.DiscretizedEnergyFlow(), FitterFuncs::PulseShapeFunctor.EvalPulse(), PedestalsTask.fill(), FineDelayTask.fill(), PedsFullNoiseTask.fill(), SiStripSummaryCreator.fillHistos(), ThroughputServiceClient.fillSummaryPlots(), ecaldqm::binning.getBinningMEM_(), PrimaryVertexValidation.getMAD(), PrimaryVertexValidation.getMedian(), TrackerOfflineValidationSummary.getMedian(), TrackerOfflineValidation.getMedian(), heppy::BTagSF.getSFb(), heppy::BTagSF.getSFc(), MuonResidualsFitter.histogramChi2GaussianFit(), MSLayersKeeperX0Averaged.init(), ExpressionHisto< T >.initialize(), PhiScaleHelper.makeBinnedScale(), DTLocalTriggerEfficiencyTest.makeEfficiencyME(), MuIsoValidation.MakeLogBinsForProfile(), AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D.MuonSystemMapPlot1D(), DTSegmentAnalysisTest.performClientDiagnostic(), DistortedPFCandProducer.produce(), DistortedMuonProducer.produce(), ISRWeightProducer.produce(), SamplingAlgorithm.pruneProfile(), CSCCrosstalkGenerator.ratio(), HcalTDCReco.reconstruct(), RecoTauPlotDiscriminator.RecoTauPlotDiscriminator(), Comp2RefEqualH.runTest(), NoisyChannel.runTest(), CompareToMedian.runTest(), HcalQIEShape.setLowEdges(), HcalDigiMonitor.setup(), MonitorElement.ShiftFillLast(), smartGausProfile(), smartProfile(), th1ToFormulaLin(), and JetMETHLTOfflineSource.TriggerPosition().

list pileupCalc.output = args[0]

Definition at line 219 of file pileupCalc.py.

tuple pileupCalc.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")

## Main Program

Definition at line 168 of file pileupCalc.py.

tuple pileupCalc.pileupHist
Initial value:
1 = ROOT.TH1D(options.pileupHistName,options.pileupHistName,
2  options.numPileupBins,
3  0., options.maxPileupBin)

Definition at line 233 of file pileupCalc.py.

pileupCalc.type = float,

Definition at line 192 of file pileupCalc.py.

pileupCalc.upper = options.maxPileupBin

Definition at line 238 of file pileupCalc.py.

Referenced by LHEAnalyzer.analyze(), MomentumDependentPedeLabeler.buildMomentumDependencyMap(), ConstrainedTreeBuilder.covarianceMatrix(), ConstrainedTreeBuilderT.covarianceMatrix(), InterpolatedPulse< 1500U >.derivative(), Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.dumpPython(), cmsPerfSuiteHarvest.exportIgProfReport(), TableParser.extractPages(), FileNamesHelper.getJobID_fromIgProfLogName(), MagVolumeOutsideValidity.MagVolumeOutsideValidity(), InterpolatedPulse< 1500U >.secondDerivative(), jetTools.AddJetCollection.toolCode(), and MFGrid3D.valueInTesla().

string pileupCalc.VERSION = '1.00'

Definition at line 2 of file pileupCalc.py.