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 ## ## ## ## ################## ## ## ######################## ## | |
tuple | pileupHist |
type = float, | |
upper = options.maxPileupBin | |
string | VERSION = '1.00' |
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.
00055 : 00056 ''' 00057 lumiinfo:[intlumi per LS, mean interactions ] 00058 00059 intlumi is the deadtime corrected average integraged lumi per lumisection 00060 ''' 00061 00062 LSintLumi = lumiInfo[0] 00063 RMSInt = lumiInfo[1]*minbXsec 00064 AveNumInt = lumiInfo[2]*minbXsec 00065 00066 #coeff = 0 00067 00068 #if RMSInt > 0: 00069 # coeff = 1.0/RMSInt/sqrt(6.283185) 00070 00071 #expon = 2.0*RMSInt*RMSInt 00072 00073 Sqrt2 = sqrt(2) 00074 00075 ##Nbins = hist.GetXaxis().GetNbins() 00076 00077 ProbFromRMS = [] 00078 BinWidth = hist.GetBinWidth(1) 00079 00080 # First, re-constitute lumi distribution for this LS from RMS: 00081 if RMSInt > 0: 00082 00083 AreaLnew = -10. 00084 AreaL = 0 00085 00086 for obs in range (Nbins): 00087 #Old Gaussian normalization; inaccurate for small rms and large bins 00088 #val = hist.GetBinCenter(obs+1) 00089 #prob = coeff*exp(-1.0*(val-AveNumInt)*(val-AveNumInt)/expon) 00090 #ProbFromRMS.append(prob) 00091 00092 left = hist.GetBinLowEdge(obs+1) 00093 right = left+BinWidth 00094 00095 argR = (AveNumInt-right)/Sqrt2/RMSInt 00096 AreaR = MyErf(argR) 00097 00098 if AreaLnew<-5.: 00099 argL = (AveNumInt-left)/Sqrt2/RMSInt 00100 AreaL = MyErf(argL) 00101 else: 00102 AreaL = AreaLnew 00103 AreaLnew = AreaR # save R bin value for L next time 00104 00105 NewProb = (AreaL-AreaR)*0.5 00106 00107 ProbFromRMS.append(NewProb) 00108 00109 #print left, right, argL, argR, AreaL, AreaR, NewProb 00110 00111 else: 00112 obs = hist.FindBin(AveNumInt) 00113 for bin in range (Nbins): 00114 ProbFromRMS.append(0.0) 00115 if obs<Nbins+1: 00116 ProbFromRMS[obs] = 1.0 00117 if AveNumInt < 1.0E-5: 00118 ProbFromRMS[obs] = 0. # just ignore zero values 00119 00120 if calcOption == 'true': # Just put distribution into histogram 00121 if RMSInt > 0: 00122 totalProb = 0 00123 for obs in range (Nbins): 00124 prob = ProbFromRMS[obs] 00125 val = hist.GetBinCenter(obs+1) 00126 #print obs, val, RMSInt,coeff,expon,prob 00127 totalProb += prob 00128 hist.Fill (val, prob * LSintLumi) 00129 00130 if 1.0-totalProb > 0.01: 00131 print "Significant probability density outside of your histogram" 00132 print "Consider using a higher value of --maxPileupBin" 00133 print "Mean %f, RMS %f, Integrated probability %f" % (AveNumInt,RMSInt,totalProb) 00134 # hist.Fill (val, (1 - totalProb) * LSintLumi) 00135 else: 00136 hist.Fill(AveNumInt,LSintLumi) 00137 else: # have to convolute with a poisson distribution to get observed Nint 00138 totalProb = 0 00139 Peak = 0 00140 BinWidth = hist.GetBinWidth(1) 00141 for obs in range (Nbins): 00142 Peak = hist.GetBinCenter(obs+1) 00143 RMSWeight = ProbFromRMS[obs] 00144 for bin in range (Nbins): 00145 val = hist.GetBinCenter(bin+1)-0.5*BinWidth 00146 prob = ROOT.TMath.Poisson (val, Peak) 00147 totalProb += prob 00148 hist.Fill (val, prob * LSintLumi * RMSWeight) 00149 00150 if 1.0-totalProb > 0.01: 00151 print "Significant probability density outside of your histogram" 00152 print "Consider using a higher value of --maxPileupBin" 00153 00154 00155 return hist 00156 00157
def pileupCalc::MyErf | ( | input | ) |
Definition at line 22 of file pileupCalc.py.
00023 : 00024 00025 # Abramowitz and Stegun approximations for Erf (equations 7.1.25-28) 00026 X = abs(input) 00027 00028 p = 0.47047 00029 b1 = 0.3480242 00030 b2 = -0.0958798 00031 b3 = 0.7478556 00032 00033 T = 1.0/(1.0+p*X) 00034 cErf = 1.0 - (b1*T + b2*T*T + b3*T*T*T)*exp(-1.0*X*X) 00035 if input<0: 00036 cErf = -1.0*cErf 00037 00038 # Alternate Erf approximation: 00039 00040 #A1 = 0.278393 00041 #A2 = 0.230389 00042 #A3 = 0.000972 00043 #A4 = 0.078108 00044 00045 #term = 1.0+ A1*X+ A2*X*X+ A3*X*X*X+ A4*X*X*X*X 00046 #denom = term*term*term*term 00047 00048 #dErf = 1.0 - 1.0/denom 00049 #if input<0: 00050 # dErf = -1.0*dErf 00051 00052 return cErf 00053
def pileupCalc::parseInputFile | ( | inputfilename | ) |
output ({run:[ls:[inlumi, meanint]]})
Definition at line 10 of file pileupCalc.py.
00011 : 00012 ''' 00013 output ({run:[ls:[inlumi, meanint]]}) 00014 ''' 00015 selectf=open(inputfilename,'r') 00016 inputfilecontent=selectf.read() 00017 p=pileupParser.pileupParser(inputfilecontent) 00018 00019 # p=inputFilesetParser.inputFilesetParser(inputfilename) 00020 runlsbyfile=p.runsandls() 00021 return runlsbyfile
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.
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 ApvTimingAlgorithm::analyse(), FastFedCablingAlgorithm::analyse(), OptoScanAlgorithm::analyse(), FedTimingAlgorithm::analyse(), DaqScopeModeAlgorithm::analyse(), XmasToDQMSource::analyze(), TopDiLeptonDQM::beginJob(), DQMMessageLogger::beginJob(), L1TDTTF::beginJob(), JetMETHLTOfflineSource::beginRun(), BTagHLTOfflineSource::beginRun(), FedTimingTask::book(), OptoScanTask::book(), PedestalsTask::book(), ecaldqm::MESetEcal::book(), VpspScanTask::book(), FastFedCablingTask::book(), ApvTimingTask::book(), FedCablingTask::book(), L1TGMT::book_(), DTTriggerEfficiencyTest::bookChambHistos(), DTLocalTriggerSynchTask::bookHistos(), TrackerOfflineValidation::bookHists(), TrackerOfflineValidation::bookSummaryHists(), L1TDTTFClient::buildPhiEtaPlotO(), L1TDTTFClient::buildPhiEtaPlotOFC(), CentralityBins::CentralityBins(), L1TauAnalyzer::convertToIntegratedEff(), SamplingAlgorithm::correctProfile(), reco::DiscretizedEnergyFlow::DiscretizedEnergyFlow(), PedsFullNoiseTask::fill(), FineDelayTask::fill(), PedestalsTask::fill(), SiStripSummaryCreator::fillHistos(), ecaldqm::getAverageFromTProfile(), SiPixelActionExecutor::getData(), TrackerOfflineValidation::getMedian(), TrackerOfflineValidationSummary::getMedian(), HiEvtPlaneFlatCalib::HiEvtPlaneFlatCalib(), MuonResidualsFitter::histogramChi2GaussianFit(), MSLayersKeeperX0Averaged::init(), ExpressionHisto< T >::initialize(), PhiScaleHelper::makeBinnedScale(), DTLocalTriggerEfficiencyTest::makeEfficiencyME(), MuIsoValidation::MakeLogBinsForProfile(), AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::MuonSystemMapPlot1D(), DTSegmentAnalysisTest::performClientDiagnostic(), HLTTauDQMSummaryPlotter::plotIntegratedEffHisto(), DistortedMuonProducer::produce(), ISRWeightProducer::produce(), DistortedPFCandProducer::produce(), SamplingAlgorithm::pruneProfile(), CSCCrosstalkGenerator::ratio(), MuScleFitBase::readProbabilityDistributionsFromFile(), RecoTauPlotDiscriminator::RecoTauPlotDiscriminator(), CompareToMedian::runTest(), NoisyChannel::runTest(), Comp2RefEqualH::runTest(), HcalDigiMonitor::setup(), ecaldqm::shiftAxis(), MonitorElement::ShiftFillLast(), smartGausProfile(), smartProfile(), BTagHLTOfflineSource::TriggerPosition(), and JetMETHLTOfflineSource::TriggerPosition().
list pileupCalc::output = args[0] |
Definition at line 219 of file pileupCalc.py.
tuple pileupCalc::parser |
00001 optparse.OptionParser("Usage: %prog [--options] output.root", 00002 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 |
00001 ROOT.TH1D(options.pileupHistName,options.pileupHistName, 00002 options.numPileupBins, 00003 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(), WebInterface::DrawGif(), MagVolumeOutsideValidity::MagVolumeOutsideValidity(), and MFGrid3D::valueInTesla().
string pileupCalc::VERSION = '1.00' |
Definition at line 2 of file pileupCalc.py.