本文整理汇总了C++中TH1F::GetRandom方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1F::GetRandom方法的具体用法?C++ TH1F::GetRandom怎么用?C++ TH1F::GetRandom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1F
的用法示例。
在下文中一共展示了TH1F::GetRandom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MbPythiaTuneATLAS_Flat
AliGenerator* MbPythiaTuneATLAS_Flat()
{
AliGenPythia* pythia = MbPythiaTuneATLAS();
comment = comment.Append("; flat multiplicity distribution");
// set high multiplicity trigger
// this weight achieves a flat multiplicity distribution
Double_t cont[] =
{0,
0.234836, 0.103484, 0.00984802, 0.0199906, 0.0260018, 0.0208481, 0.0101477, 0.00146998, -0.00681513, -0.0114928,
-0.0113352, -0.0102012, -0.00895238, -0.00534961, -0.00261648, -0.000819048, 0.00130816, 0.00177978, 0.00373838, 0.00566255,
0.00628156, 0.00687458, 0.00668017, 0.00702917, 0.00810848, 0.00876167, 0.00832783, 0.00848518, 0.0107709, 0.0106849,
0.00933702, 0.00912525, 0.0106553, 0.0102785, 0.0101756, 0.010962, 0.00957103, 0.00970448, 0.0117133, 0.012271,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113, 0.0113,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0};
Double_t err[] =
{0,
0.00168216, 0.000743548, 0.00103125, 0.00108605, 0.00117101, 0.00124577, 0.00129119, 0.00128341, 0.00121421, 0.00112431,
0.00100588, 0.000895078, 0.000790314, 0.000711673, 0.000634547, 0.000589133, 0.000542763, 0.000509552, 0.000487375, 0.000468906,
0.000460196, 0.000455806, 0.00044843, 0.000449317, 0.00045007, 0.000458016, 0.000461167, 0.000474742, 0.00050161, 0.00051637,
0.000542336, 0.000558854, 0.000599169, 0.000611982, 0.000663855, 0.000696322, 0.000722825, 0.000771686, 0.000838023, 0.000908317,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003, 0.0003,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0};
TH1F *weight = new TH1F("newweight","newweight",120,-0.5,119.5);
weight->SetContent(cont);
weight->SetError(err);
Int_t limit = weight->GetRandom();
pythia->SetTriggerChargedMultiplicity(limit, 1.4);
comment = comment.Append(Form("; multiplicity threshold set to %d in |eta| < 1.4", limit));
return pythia;
}
示例2: test
void test(int nhit1)
{
TH1F *h = (TH1F*) f->FindObjectAny(Form("dNdEtaHits1_%02d",nhit1));
TH1F *g = new TH1F("toymc","",100,-3,3);
for (int i=0;i<h->GetEntries();i++){
g->Fill(h->GetRandom());
}
g->SetLineColor(2);
h->Draw();
g->Draw("same");
}
示例3: genLayer2
void genLayer2(int nhit2,vector<double> &hits2)
{
TH1F *h = (TH1F*) f->FindObjectAny(Form("dNdEtaHits2_%02d",nhit2));
TH1F *h2 = (TH1F*) f->FindObjectAny(Form("dNdPhiHits2_%02d",nhit2));
hits2.clear();
double eta,phi;
int nGen=0;
for (int i=0;nGen<nhit2;i++){
eta = h->GetRandom();
phi = h2->GetRandom();
if (fabs(eta)<1000) nGen++;
hits2.push_back(eta);
hits2.push_back(phi);
}
}
示例4: DalitzDecay
void DalitzDecay(Particle *PParent, Particle *PLepton1, Particle *PLepton2,
Particle *POther, ParticlePropertyList *PPList, Decay *PDecay)
{
double pmass, lmass, omass, lpmass;
double E1, p1, E3, p3;
double beta_square, lambda;
double costheta, sintheta, cosphi, sinphi, phi;
int new_generation;
pmass=GetMass(PDecay->GetParentID(),PPList);
lmass=0;
omass=0;
int ibody=0;
for( ibody=1; ibody<=3; ibody++)
{
int ID;
ID = PDecay->GetChildID(ibody);
if ( abs(ID)==11 || abs(ID)==13 )
lmass = GetMass(PDecay->GetChildID(ibody), PPList);
else
omass = GetMass(PDecay->GetChildID(ibody), PPList);
}
TH1F * LeptonPairMass = PDecay->GetHistogram();
for ( ibody=1; ibody<=3; ibody++ )
{
switch( PDecay->GetChildID(ibody) )
{
case -11: PLepton1->SetID(-11); break;
case 11: PLepton2->SetID(11); break;
case -13: PLepton1->SetID(-13); break;
case 13: PLepton2->SetID(13); break;
default : POther->SetID(PDecay->GetChildID(ibody));
}
}
for( ;; )
{
lpmass = LeptonPairMass->GetRandom();
if ( pmass-omass>lpmass && lpmass/2.>lmass ) break;
}
E1 = lpmass/2.;
p1 = sqrt((E1+lmass)*(E1-lmass));
beta_square = 1.0 - 4.0*(lmass*lmass)/(lpmass*lpmass);
lambda = beta_square/(2.0-beta_square);
if ( omass<0.01 )
{
do
{
costheta = (2.0*gRandom->Rndm())-1.;
}
while ( (1.0+lambda*costheta*costheta)<(2.0*gRandom->Rndm()) );
}
else
{
costheta = (2.0*gRandom->Rndm())-1.;
}
sintheta = sqrt((1.+costheta)*(1.-costheta));
phi = 2.0*PI*gRandom->Rndm();
sinphi = sin(phi);
cosphi = cos(phi);
new_generation = PParent->GetGeneration()+1;
PLepton1->SetGeneration(new_generation);
PLepton2->SetGeneration(new_generation);
POther->SetGeneration(new_generation);
PLepton1->SetDecaysum(0.0);
PLepton2->SetDecaysum(0.0);
POther->SetDecaysum(0.0);
PLepton1->Set4mom(E1,
p1*sintheta*cosphi,
p1*sintheta*sinphi,
p1*costheta);
PLepton2->Set4mom(E1,invert(PLepton1->Get4mom().Getp()));
E3 = (SQR(pmass)+SQR(omass)-SQR(lpmass))/(2.*pmass);
p3 = sqrt((E3+omass)*(E3-omass));
costheta = (2.0*gRandom->Rndm())-1.;
sintheta = sqrt((1.+costheta)*(1.-costheta));
phi = 2.0*PI*gRandom->Rndm();
sinphi = sin(phi);
cosphi = cos(phi);
POther->Set4mom(E3,
p3*sintheta*cosphi,
p3*sintheta*sinphi,
p3*costheta);
PLepton1->Set4mom(E1,
Rotate(PLepton1->Get4mom().Getp(),costheta,-sintheta,-cosphi,-sinphi));
PLepton2->Set4mom(E1,
Rotate(PLepton2->Get4mom().Getp(),costheta,-sintheta,-cosphi,-sinphi));
Mom4 lp_boost(sqrt(SQR(p3)+SQR(lpmass)),invert(POther->Get4mom().Getp()));
PLepton1->Set4mom(boost(PLepton1->Get4mom(),lp_boost));
//.........这里部分代码省略.........
示例5: FindMCPUWeight
void FindMCPUWeight(){
NCanvas(1,2,"data");
TH1F * Data;
TH1F * DataVtx;
TH1F * PytZ2;
TH1F * PytZ2_Vis;
TFile *fzee = new TFile("ZDiffOutputfile.root");
Data = (TH1F*)fzee->Get("NoCuts_InstLumiPerBx_DATA10");
DataVtx = (TH1F*)fzee->Get("NoCuts_GoodVtx_DATA10");
PytZ2 = (TH1F*)fzee->Get("Gen_PUVtx_Z2PY6");
PytZ2_Vis = (TH1F*)fzee->Get("NoCuts_GoodVtx_Z2PY6");
Float_t DataInt = Data->Integral();
data->cd(1);
NSetTitle(Data,"Single bunch luminosity [10^{30}cm^{-2}s^{-1}]","Entries");
NSetLabelSize(Data);
NSetTitleSize(Data,0.8,0.8,0.06);
NStat(Data,0);
Data->SetTitle("Z Luminosity");
NHSetMarker(Data);
Data->Draw();
Int_t const NRS = 1000;
// Float_t Sigma = 0.0485;
Float_t Sigma = 0.073;
Int_t const MaxVtxInEvent = 25;
Float_t sigma_NSD = Sigma*pow(10,-24);
char hname[100];
sprintf(hname,"Pois_Theory");
gDirectory->Delete(hname);
TH1F * pois_theory = new TH1F(hname,hname,MaxVtxInEvent,-0.5,MaxVtxInEvent-0.5); // Pois hystograms
pois_theory->Sumw2();
for (Int_t NL = 1; NL<=NRS; NL++)
{
Double_t LumiR = Data->GetRandom();
for (Int_t p=0;p<MaxVtxInEvent;p++)
{
Float_t Lum_bunch = (LumiR*pow(10,30)/11346)*sigma_NSD ;
Float_t pois_prob = pow(Lum_bunch,p) * exp(-Lum_bunch)/TMath::Factorial(p) ;
pois_theory->Fill(p+0.01,pois_prob);
}
}
if (pois_theory->GetEntries() !=0)
{
pois_theory->Scale(DataInt/NRS);
data->cd(2);
NSetTitle(pois_theory,"# PU Vertexes in event","Fraction");
NSetLabelSize(pois_theory);
NSetTitleSize(pois_theory,0.8,0.8,0.06);
NStat(pois_theory,0);
pois_theory->SetTitle("MC PU generated vertex distribution");
// pois_theory->SetTitleSize(1.);
NHSetMarker(pois_theory);
DataVtx->Draw();
pois_theory->Draw("SAME HIST");
}
//
// PytZ2->Scale(1./scale);
Float_t scale = PytZ2_Vis->Integral()/PytZ2->Integral();
cout << "MC scale =" << scale << endl;
cout << "Float_t Z2Weight[] = {" ;
for (Int_t j = 1;j<=19; j++)
{
Float_t ra = scale*pois_theory->GetBinContent(j)/PytZ2->GetBinContent(j);
cout << ra << ", " ;
}
cout << " 0 }; " << endl;
return;
}