test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Namespaces | Functions
PileUp.cc File Reference
#include "Mixing/Base/interface/PileUp.h"
#include "DataFormats/Provenance/interface/BranchIDListHelper.h"
#include "DataFormats/Provenance/interface/ModuleDescription.h"
#include "DataFormats/Provenance/interface/ThinnedAssociationsHelper.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
#include "FWCore/Framework/src/SignallingProductRegistry.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
#include "FWCore/ServiceRegistry/interface/ProcessContext.h"
#include "FWCore/Sources/interface/VectorInputSourceDescription.h"
#include "FWCore/Sources/interface/VectorInputSourceFactory.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/GetPassID.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Version/interface/GetReleaseVersion.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "Mixing/Base/src/SecondaryEventProvider.h"
#include "CondFormats/DataRecord/interface/MixingRcd.h"
#include "CondFormats/RunInfo/interface/MixingModuleConfig.h"
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandPoisson.h"
#include <algorithm>
#include <memory>
#include "TMath.h"

Go to the source code of this file.

Namespaces

 edm
 HLT enums.
 

Functions

static Double_t GetRandom (TH1 *th1, CLHEP::HepRandomEngine *rng)
 

Function Documentation

static Double_t GetRandom ( TH1 *  th1,
CLHEP::HepRandomEngine *  rng 
)
static

return a random number distributed according the histogram bin contents.

This routine is derived from root/hist/hist/src/TH1.cxx

Definition at line 46 of file PileUp.cc.

References funct::integral(), diffTwoXMLs::r1, and x().

Referenced by edm::PileUp::CalculatePileup().

47 {
48  Int_t nbinsx = th1->GetNbinsX();
49  Double_t* fIntegral = th1->GetIntegral();
50  Double_t integral = fIntegral[nbinsx];
51 
52  if (integral == 0) return 0;
53 
54  Double_t r1 = rng->flat();
55  Int_t ibin = TMath::BinarySearch(nbinsx,fIntegral,r1);
56  Double_t x = th1->GetBinLowEdge(ibin+1);
57  if (r1 > fIntegral[ibin])
58  x += th1->GetBinWidth(ibin+1)*(r1-fIntegral[ibin])/(fIntegral[ibin+1] - fIntegral[ibin]);
59  return x;
60 }
T x() const
Cartesian x coordinate.
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69