本文整理汇总了C++中TPad::SetGrid方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::SetGrid方法的具体用法?C++ TPad::SetGrid怎么用?C++ TPad::SetGrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::SetGrid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: first
void first() {
TCanvas *nut = new TCanvas("nut", "FirstSession",100,10,700,900);
nut->Range(0,0,20,24);
nut->SetFillColor(10);
nut->SetBorderSize(2);
TPaveLabel *pl = new TPaveLabel(3,22,17,23.7,
"My first ROOT interactive session","br");
pl->SetFillColor(18);
pl->Draw();
TText t(0,0,"a");
t.SetTextFont(62);
t.SetTextSize(0.025);
t.SetTextAlign(12);
t.DrawText(2,20.3,"ROOT is based on CINT, a powerful C/C++ interpreter.");
t.DrawText(2,19.3,"Blocks of lines can be entered within {...}.");
t.DrawText(2,18.3,"Previous typed lines can be recalled.");
t.SetTextFont(72);
t.SetTextSize(0.026);
t.DrawText(3,17,"Root > float x=5; float y=7;");
t.DrawText(3,16,"Root > x*sqrt(y)");
t.DrawText(3,14,
"Root > for (int i=2;i<7;i++) printf(\"sqrt(%d) = %f\\n\",i,sqrt(i));");
t.DrawText(3,10,"Root > TF1 f1(\"f1\",\"sin(x)/x\",0,10)");
t.DrawText(3, 9,"Root > f1.Draw()");
t.SetTextFont(81);
t.SetTextSize(0.018);
t.DrawText(4,15,"(float) 13.2288f");
t.DrawText(4,13.3,"sqrt(2) = 1.414214");
t.DrawText(4,12.7,"sqrt(3) = 1.732051");
t.DrawText(4,12.1,"sqrt(4) = 2.000000");
t.DrawText(4,11.5,"sqrt(5) = 2.236068");
t.DrawText(4,10.9,"sqrt(6) = 2.449490");
TPad *pad = new TPad("pad","pad",.2,.05,.8,.35);
pad->Draw();
pad->cd();
pad->SetGrid();
TF1 *f1 = new TF1("f1","sin(x)/x",0,10);
f1->Draw();
}
示例2: DrawGrid
void DrawGrid()
{
Int_t ncol = 100;
Int_t nrow = 200;
TPad *grid = new TPad("grid","",0,0,1,1);
grid->Draw();
grid->cd();
grid->SetGrid();
grid->SetFillStyle(4000);
grid->SetFrameFillStyle(0);
TH2 *hgrid = new TH2C("hgrid","", ncol+1, -5, ncol+5, nrow, -5, nrow-1+5);
hgrid->Draw();
hgrid->GetXaxis()->SetNdivisions(6,100);
hgrid->GetYaxis()->SetNdivisions(200);
hgrid->GetYaxis()->SetLabelOffset(999.);
hgrid->GetXaxis()->SetLabelOffset(999.);
}
示例3: GE11sEfficiencyPlots_3Sector_DividerCurrent
//.........这里部分代码省略.........
File3 >> current >> eff >> efferr;
cout<<"3==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
if (!File3.good()) break;
NT_Detector3_HV.push_back(current);
NT_Detector3_Eff.push_back(eff);
NT_Detector3_EffErr.push_back(efferr);
NT_Detector3->Fill(current,eff,efferr);
nlines++;
}
while (1)
{
File4 >> current >> eff >> efferr;
cout<<"4==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
if (!File4.good()) break;
NT_Detector4_HV.push_back(current);
NT_Detector4_Eff.push_back(eff);
NT_Detector4_EffErr.push_back(efferr);
NT_Detector4->Fill(current,eff,efferr);
nlines++;
}
File1.close();
File2.close();
File3.close();
File4.close();
TCanvas* c1 = new TCanvas("c1","",1);
c1->Range(0,0,1,1);
TPad *pad = new TPad("pad","",0,0,1,1);
pad->SetGrid();
pad->Draw();
pad->cd();
TF1 *f1 = new TF1("f1","[0]+(0.989)/([1]+exp(-[2]*(x-697.3)))",650,815);
TF1 *f2 = new TF1("f2","(0.968)/([1]+exp(-[2]*(x-713)))",650,815);
TF1 *f3 = new TF1("f3","(0.973)/([1]+exp(-[2]*(x-725)))",650,820);
TF1 *f4 = new TF1("f4","(0.985)/([1]+exp(-[2]*(x-614)))",565,720);
// f3->SetParameters(1.,1.,1.);
// create first graph
TGraphErrors *gr1 = new TGraphErrors(NT_Detector1_HV.size());
for(unsigned int i=0;i<NT_Detector1_HV.size();i++)
{
gr1->SetPoint(i,NT_Detector1_HV[i],NT_Detector1_Eff[i]);
gr1->SetPointError(i,0,4*NT_Detector1_EffErr[i]);
}
gr1->SetMarkerColor(kGreen+3);
gr1->SetLineColor(kGreen+3);
gr1->SetMarkerStyle(21);
gr1->GetXaxis()->SetTitle("Current Supplied To HV Divider (#mu A)");
gr1->GetYaxis()->SetTitle("Efficiency");
gr1->SetTitle(GraphTitle);
f1->SetLineColor(kGreen+3);
gr1->Fit("f1","R");
// create first graph
TGraphErrors *gr5 = new TGraphErrors(NT_Detector2_HV.size());
for(unsigned int i=0;i<NT_Detector2_HV.size();i++)
{
gr5->SetPoint(i,NT_Detector2_HV[i],NT_Detector2_Eff[i]);
示例4: test
// -----------------------------------------------------------------------------
//
void test() {
time_t start = TTimeStamp().GetSec();
set_plot_style();
bool draw = true;
//bool debug = true;
// Define analysis configuration
PSet ps;
defaultPSet(ps);
// Response plots
if (false) {
//xSectDistr(ps);
responseProfile();
return;
}
// Print configuration
std::stringstream ss;
printPSet(ps,ss);
std::cout << ss.str() << std::endl;
// Params to store
DoubleVV ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err;
IntV length;
clear( ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length );
init( ps, ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length );
// Loop through Meff bins
int loop = 0;
int nloops = ps.nmeff;
for ( int imeff = 0; imeff < ps.nmeff; ++imeff ) {
// Generate numbers in (x1,x2) plane
DoubleVV dalitz;
generateTruth( ps, imeff, dalitz, true );
// Integrate across dalitz plane
integrate( ps, imeff, dalitz, ratio, ratio_errh, ratio_errl,
pass, pass_err, fail, fail_err, length );
// Labeling
std::stringstream ss;
ss << "Meff" << int( ps.meff_bins[imeff] );
// New canvas for plots
TCanvas* c1 = 0;
if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" );
// Pad for cross-section plot
TPad* pad = 0;
if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.);
if (pad) {
pad->SetGrid();
pad->Draw();
pad->cd();
pad->SetLogz();
}
TH1F* hr = 0;
if (draw) hr = pad->DrawFrame(ps.min,ps.min,ps.max,ps.max);
// Histo title
if (hr) {
std::stringstream sss;
sss << "M_{eff}=" << ps.meff_bins[imeff] << " GeV"
<< ", p_{T1}=" << dr(ps.pt1_bins[imeff],1) << " GeV"
<< ", p_{T2}=" << dr(ps.pt2_bins[imeff],1) << " GeV"
<< ", p_{T3}=" << dr(ps.pt3_bins[imeff],1) << " GeV";
hr->SetTitle( sss.str().c_str() );
hr->GetXaxis()->SetTitle( "x_{2}" );
hr->GetYaxis()->SetTitle( "x_{1}" );
}
// Create 2D cross-section plot
TH2D* his = 0;
if (draw) his = new TH2D(TString("Histo"+ss.str()),"",
ps.nbins,ps.min,ps.max,
ps.nbins,ps.min,ps.max);
//double x3 = ( 2. * ps.pt3_bins[imeff] ) / ( ps.meff_bins[imeff] + ps.pt3_bins[imeff] );
// Fill 2D cross-section plot
for ( int x2_bin = 0; x2_bin < ps.nbins; ++x2_bin ) {
for ( int x1_bin = 0; x1_bin < ps.nbins; ++x1_bin ) {
// std::cout << " Fill:"
// << " x2_bin: " << x2_bin
// << " x2: " << val(x2_bin,nbins)
// << " x1_bin: " << x1_bin
// << " x1: " << val(x1_bin,nbins)
// << " val: " << dalitz[x2_bin][x1_bin]
// << std::endl;
if (his) his->Fill( val(x2_bin,ps)+ps.width/2.,
val(x1_bin,ps)+ps.width/2.,
dalitz[x2_bin][x1_bin] );
}
//.........这里部分代码省略.........
示例5: probabilityDirection
//.........这里部分代码省略.........
for (int j = 0; j < _vertex; j++)
{
if (_pdg[j] == 5)
{
bs.push_back(j);
}
else//if (_pdg[j] == -5)
{
bbars.push_back(j);
}
}
for (int k = 0; k < bbars.size(); k++)
{
/*if (
_bbarIPdistance < 0.50
|| _bbartotalnumber > 5
|| _bbartotalnumber < 3
|| _bbarnumber < 2
|| _bbartotalnumber - _bbarnumber < 2
)
{
continue;
}*/
if (bbars.size() > 1)
{
std::cout << "Nb: " << i << '\n';
probhist->Fill(_probability[bbars[k]]);
chihist->Fill(_chi2[bbars[k]]);
}
else
{
probhist_non->Fill(_probability[bbars[0]]);
chihist_non->Fill(_chi2[bbars[0]]);
}
}
for (int m = 0; m < bs.size(); m++)
{
/*if (
_bIPdistance < 0.50
|| _btotalnumber > 5
//|| _btotalnumber < 3
|| _bnumber < 2
|| _btotalnumber - _bnumber < 2
)
{
continue;
}*/
if (bs.size() > 1)
{
probhist->Fill(_probability[bs[m]]);
chihist->Fill(_chi2[bs[m]]);
}
else
{
probhist_non->Fill(_probability[bs[0]]);
chihist_non->Fill(_chi2[bs[0]]);
}
}
if ( bbars.size() > 0)
{
totalcounter++;
}
if ( bs.size() > 0)
{
totalcounter++;
}
}
boxPad->cd();
probhist_non->SetMarkerStyle(20);
chihist_non->SetMarkerStyle(20);
chihist_non->SetMarkerColor(kBlack);
chihist_non->SetMarkerSize(0.7);
chihist_non->GetXaxis()->SetTitle("#chi^2");
chihist->SetFillColor(kYellow);
chihist->GetXaxis()->SetTitle("#chi^{2}");
probhist_non->SetMarkerColor(kBlack);
probhist_non->SetMarkerSize(0.7);
probhist_non->GetXaxis()->SetTitle("P(V)");
//probhist->GetYaxis()->SetRange(0,0.1);
//probhist_non->GetYaxis()->SetRange(0,0.1);
probhist->SetMaximum(2000);
probhist_non->SetMaximum(2000);
probhist_non->SetMinimum(0);
probhist->SetMinimum(0);
probhist->SetFillColor(kYellow);
probhist->GetXaxis()->SetTitle("P(V)");
probhist->DrawNormalized("same");
probhist_non->DrawNormalized("ex0psame");
boxPad->SetGrid();
box1Pad->cd();
box1Pad->SetLogy();
chihist->DrawNormalized("");
chihist_non->DrawNormalized("ex0psame",1);
box1Pad->SetGrid();
box1Pad->Modified();
boxPad->Modified();
std::cout << "Statistics: " << probhist->GetEntries() << " with ternary; " << probhist_non->GetEntries() << " without ternary; " << totalcounter << " total; " << counter << " discarded\n";
std::cout << "Mean: " << probhist->GetMean() << " with ternary; " << probhist_non->GetMean() << " without ternary;\n";
}
示例6: talk
// -----------------------------------------------------------------------------
//
void talk() {
time_t start = TTimeStamp().GetSec();
bool draw = true;
bool debug = true;
// Binning
int xbins = 100;
int ybins = 100;
double xmin = 0.0;
double xmax = 1.0;
double ymin = 0.0;
double ymax = 1.0;
double xbin_centre = ( ( xmax - xmin ) / xbins ) / 2.;
double ybin_centre = ( ( ymax - ymin ) / ybins ) / 2.;
// AlphaT values
const int nat = 1;
double at[nat];
for ( int ii = 0; ii < nat; ++ii ) { at[ii] = 0.55 + ii * 0.001; }
// HT regions
const int nht = 3;
double ht_min[nht] = { 250., 300., 350. };
// Jet pT thresholds
double pt1_min[nht] = { 71.4, 85.7, 100. };
double pt2_min[nht] = { 71.4, 85.7, 100. };
double pt3_min[nht] = { 35.7, 42.9., 50. };
// x fractions
double x1_min[nht];
double x2_min[nht];
double x3_max[nht];
for ( int ii = 0; ii < nht; ++ii ) { x1_min[ii] = ( 2. * pt1_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); }
for ( int ii = 0; ii < nht; ++ii ) { x2_min[ii] = ( 2. * pt2_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); }
for ( int ii = 0; ii < nht; ++ii ) { x3_max[ii] = ( 2. * pt3_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); }
// Loop through bins
int loop = 0;
int nloops = nht;
for ( int iht = 0; iht < nht; ++iht ) {
std::cout << "Completed "
<< 100.*float(loop)/float(nloops)
<< "%..."
<< std::endl;
loop++;
// Labeling
std::stringstream ss;
ss << "HT" << int(ht_min[iht]);
// New canvas for plots
TCanvas* c1 = 0;
if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" );
// Pad for cross-section plot
TPad* pad = 0;
if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.);
if (pad) {
pad->SetGrid();
pad->Draw();
pad->cd();
pad->SetLogz();
}
TH1F* hr = 0;
if (draw) hr = pad->DrawFrame(0.,0.,1.,1.);
// Histo title
if (hr) {
std::stringstream sss;
sss << "H_{T}=" << ht_min[iht]
<< "(p_{T1},p_{T2},p_{T3})="
<< pt1_min[iht] << ","
<< pt2_min[iht] << ","
<< pt3_min[iht] << ")"
<< ", (x_{1},x_{2},x_{3})="
<< x1_min[iht] << ","
<< x2_min[iht] << ","
<< x3_max[iht] << ")";
hr->SetTitle( sss.str().c_str() );
hr->GetXaxis()->SetTitle( "x_{2}" );
hr->GetYaxis()->SetTitle( "x_{1}" );
}
// Create 2D cross-section plot
TH2D* his = 0;
if (draw) his = new TH2D(TString("Histo"+ss.str()),"",
xbins,xmin,xmax,
ybins,ymin,ymax);
// Fill 2D cross-section plot
for ( int xbin = 0; xbin < xbins; ++xbin ) {
for ( int ybin = 0; ybin < ybins; ++ybin ) {
double x2 = ( ( xmax - xmin ) / xbins ) * xbin + xmin;
double x1 = ( ( ymax - ymin ) / ybins ) * ybin + ymin;
double val = ( x1*x1 + x2*x2 ) / ( ( 1 - x1 ) * ( 1 - x2 ) );
//.........这里部分代码省略.........
示例7: plotFinal
void plotFinal() {
double yPos, xPos, theta, energy = 0.; // NOTE: theta comes in degrees
int numHit, pID = 0;
TFile* file = new TFile("complete.root");
TTree* Hits_Info = (TTree *)file->Get("Signal");
Hits_Info->SetBranchAddress("numHits", &numHit);
Hits_Info->SetBranchAddress("energyTot", &energy);
Hits_Info->SetBranchAddress("XPosition", &xPos);
Hits_Info->SetBranchAddress("YPosition", &yPos);
Hits_Info->SetBranchAddress("Particle_ID", &pID);
Hits_Info->SetBranchAddress("Theta", &theta);
// Initialize histograms
double nEnergyMin = 10; // MeV
double nEnergyMax = 510; // MeV
int nEnergyBins = 50;
double dEnergyBinSize = (double)(nEnergyMax - nEnergyMin) / (double)nEnergyBins;
double nThetaMin = 52; // mrad
double nThetaMax = 70; // mrad
int nThetaBins = 50;
double dThetaBinSize = (nThetaMax - nThetaMin) / nThetaBins;
double nM2Min = -1000; // MeV
double nM2Max = 1000; // MeV
int nM2Bins = 100;
double dM2BinSize = (nM2Max - nM2Min)/nM2Bins;
TH1D* hgammaEnergy = new TH1D("Energy" , // plot label
"Gamma Energy Distribution", // title
nEnergyBins, // x number of bins
nEnergyMin, // x lower bound
nEnergyMax); // x upper bound
TH1D* hgammaTheta = new TH1D("#theta" , // plot label
"Gamma #theta Distribution", // title
nThetaBins, // x number of bins
nThetaMin, // x lower bound
nThetaMax); // x upper bound
TH1D* hm2 = new TH1D("M_{A'}^{2}" , // plot label
"Missing Mass Squared", // title
nM2Bins, // x number of bins
nM2Min, // x lower bound
nM2Max); // x upper bound
TH2F* henergytheta = new TH2F("scatter", // plot label
"#theta vs Energy", // title
nThetaBins, // x num of bins
nThetaMin, // x min
nThetaMax, // x max
nEnergyBins, // y num of bins
nEnergyMin, // y min
nEnergyMax); // y max
// go through all entries and fill the histograms
int nentries = Hits_Info->GetEntries();
for (int i=0; i<nentries; i++) {
Hits_Info->GetEntry(i);
if (pID == 22) { // gammas only
theta*= TMath::Pi()/180; //radians
hgammaEnergy->Fill(energy,BINNING_WEIGHT / dEnergyBinSize);
hgammaTheta->Fill(theta*1000, BINNING_WEIGHT / dThetaBinSize);
henergytheta->Fill(theta*1000, energy);
hm2->Fill(mSquared(energy, theta), BINNING_WEIGHT / dM2BinSize);
}
}
// create canvas and draw histogram
TCanvas* canvas = new TCanvas("canvas", "canvas", 700, 700);
canvas->Divide(3,2);
TPad* p;
p = (TPad*)canvas->cd(2);
p->SetLogy();
p->SetGrid();
hgammaEnergy->SetFillColor(kBlue);
hgammaEnergy->SetFillStyle(3001);
hgammaEnergy->Draw();
hgammaEnergy->GetXaxis()->SetTitle("Energy (MeV)");
hgammaEnergy->GetYaxis()->SetTitle("Photons per MeV per Second (MeV^{-1} s^{-1})");
hgammaEnergy->GetXaxis()->CenterTitle();
hgammaEnergy->GetYaxis()->CenterTitle();
p = (TPad*)canvas->cd(5);
p->SetLogy();
p->SetGrid();
//.........这里部分代码省略.........
示例8: second
void second() {
TCanvas *nut = new TCanvas("nut", "Second Session",100,10,750,1000);
nut->Range(0,0,20,24);
nut->SetFillColor(18);
TPaveLabel *pl = new TPaveLabel(3,22,17,23.7,"My second ROOT interactive session","br");
pl->SetFillColor(18);
pl->Draw();
TText t(0,0,"a");
t.SetTextFont(62);
t.SetTextSize(0.025);
t.SetTextAlign(12);
t.DrawText(2,21,"Very large C/C++ files can be interpreted (50,000 lines+).");
t.DrawText(2,20,"Functions in macros can reference other functions, etc.");
t.DrawText(2,19,"Let's make a file \"graph.C\" with the following statements:");
TPaveText *macro = new TPaveText(2,11,18,18);
macro->SetFillColor(10);
macro->SetTextColor(kBlue);
macro->SetBorderSize(6);
macro->SetTextAlign(12);
macro->SetTextFont(61);
macro->AddText("{");
macro->AddText(" TCanvas *c1 = new TCanvas(\"c1\",\"A Simple Graph Example\",200,10,700,500);");
macro->AddText(" c1->Range(-0.5,-2,2.5,12);");
macro->AddText(" const Int_t n = 20");
macro->AddText(" Float_t x[n], y[n];");
macro->AddText(" for (Int_t i=0;i<n;i++) {");
macro->AddText(" x[i] = i*0.1;");
macro->AddText(" y[i] = 10*sin(x[i]+0.2);");
macro->AddText(" }");
macro->AddText(" gr = new TGraph(n,x,y);");
macro->AddText(" gr->Draw(\"AC*\");");
macro->AddText("}");
macro->AddText(" ");
macro->Draw();
t.SetTextFont(72);
t.SetTextColor(kRed);
t.SetTextSize(0.026);
t.DrawText(3,10,"Root > .x graph.C");
TPad *pad = new TPad("pad","pad",.15,.05,.85,.40);
pad->SetFillColor(41);
pad->SetFrameFillColor(33);
pad->Draw();
pad->cd();
pad->SetGrid();
pad->Range(-0.5,-2,2.5,12);
const Int_t n = 20;
Float_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i*0.1;
y[i] = 10*sin(x[i]+0.2);
}
gr = new TGraph(n,x,y);
gr->Draw("AC*");
nut->cd();
}
示例9: GE11sEfficiencyScan
void GE11sEfficiencyScan(int RunNumber, string RunName, string path)
{
ifstream InGE11_IV_GIF, InGE11_IV, InGE11_V;
//string path = "/home/ramkrishna/TEMP/LogFiles_TB/LogFiles306To407";
string gif = path+"/Efficiency_LC1_"+std::to_string(RunNumber)+".log";
string IV = path+"/Efficiency_LC2_"+std::to_string(RunNumber)+".log";
string V = path+"/Efficiency_LC3_"+std::to_string(RunNumber)+".log";
cout<<"gif = "<<gif<<endl;
InGE11_IV_GIF.open(gif);
InGE11_IV.open(IV);
InGE11_V.open(V);
string rootFile = "Efficiency_Run"+std::to_string(RunNumber)+".root";
const char *CharrootFile = rootFile.c_str();
TFile *f = new TFile(CharrootFile,"RECREATE");
//TTree *tree = new TTree("Run306", "Detector info for Run 306");
TNtuple *GE11_IV_GIF = new TNtuple("GE11_IV_GIF","data from text file LC1","MeanPosOfSector:Efficiency:EfficiencyError:Nevents");
TNtuple *GE11_IV = new TNtuple("GE11_IV","data from text file LC2","MeanPosOfSector:Efficiency:EfficiencyError:Nevents");
TNtuple *GE11_V = new TNtuple("GE11_V","data from text file LC3","MeanPosOfSector:Efficiency:EfficiencyError:Nevents");
Int_t nlines = 0;
vector<double> GIF_MeanPosOfSector, GIF_Efficiency, GIF_EfficiencyError;
vector<unsigned int> GIF_Nevents;
unsigned int temp_Nevents;
double temp_MeanPosOfSector, temp_Efficiency, temp_EfficiencyError;
vector<double> IV_MeanPosOfSector, IV_Efficiency, IV_EfficiencyError;
vector<unsigned int> IV_Nevents;
vector<double> V_MeanPosOfSector, V_Efficiency, V_EfficiencyError;
vector<unsigned int> V_Nevents;
string NameOfDet, xRange;
while (1)
{
InGE11_IV_GIF >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents;
if (!InGE11_IV_GIF.good()) break;
GIF_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5));
GIF_Efficiency.push_back(temp_Efficiency);
GIF_EfficiencyError.push_back(temp_EfficiencyError);
GIF_Nevents.push_back(temp_Nevents);
GE11_IV_GIF->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents);
nlines++;
if (nlines > 20)
{
cout<<"Check the input text file for run number "<< RunNumber << endl;
exit(EXIT_SUCCESS);
}
}
InGE11_IV_GIF.close();
nlines=0;
while (1)
{
InGE11_IV >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents;
if (!InGE11_IV.good()) break;
IV_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5));
IV_Efficiency.push_back(temp_Efficiency);
IV_EfficiencyError.push_back(temp_EfficiencyError);
IV_Nevents.push_back(temp_Nevents);
GE11_IV->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents);
nlines++;
}
InGE11_IV.close();
nlines=0;
while (1)
{
InGE11_V >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents;
if (!InGE11_V.good()) break;
V_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5));
V_Efficiency.push_back(temp_Efficiency);
V_EfficiencyError.push_back(temp_EfficiencyError);
V_Nevents.push_back(temp_Nevents);
GE11_V->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents);
nlines++;
}
InGE11_V.close();
string CanvasName = "RunNumber"+std::to_string(RunNumber);
const char * CharCanvasName = CanvasName.c_str();
TCanvas* c1 = new TCanvas(CharCanvasName,"Efficiency Scan Plot",200,10,700,500);
TPad *pad = new TPad("pad","",0,0,1,1);
//pad->SetFillColor(42);
pad->SetGrid();
pad->Draw();
pad->cd();
// draw a frame to define the range
TH1F *hr = pad->DrawFrame(0,-0.5,100,1.1);
hr->SetXTitle("Detector Position (mm)");
//.........这里部分代码省略.........
示例10: rob
// -----------------------------------------------------------------------------
//
void rob() {
// Binning
int xbins = 100;
int ybins = 100;
double xmax = 1.0;
double xmin = 0.0;
// double xrange = xmax - xmin;
// xmax += xrange / xbins / 2;
// xmin -= xrange / xbins / 2;
// //xbins++;
double ymax = 1.0;
double ymin = 0.0;
// double yrange = ymax - ymin;
// ymax += yrange / ybins / 2;
// ymin -= yrange / ybins / 2;
// //ybins++;
std::cout << " Binning: "
<< " xbins: " << xbins
<< " ybins: " << xbins
<< " xmin: " << xmin
<< " xmax: " << xmax
<< " ymin: " << ymin
<< " ymax: " << ymax
<< std::endl;
// Examples values of pt1, pt2, mht, x1, x2, x3, sigma and alpha_t
// double pt1 = 50.;
// double pt2 = 50.;
// double mht = 50.;
// double x1 = ( 2. * pt1 ) / ( pt1 + pt2 + mht );
// double x2 = ( 2. * pt2 ) / ( pt1 + pt2 + mht );
// double x3 = 2 - x1 - x2;
// double sigma = ( x1*x1 + x2*x2 ) / ( (1-x1) * (1-x2) );
// double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) );
// std::cout << " pt1: " << pt1
// << " pt2: " << pt2
// << " mht: " << mht
// << " x1: " << x1
// << " x2: " << x2
// << " x3: " << x3
// << " sigma: " << sigma
// << " alpha_t: " << alpha_t
// << std::endl;
// Cross section
TCanvas* c1 = new TCanvas( "Contours", "" );
//c1->SetGridx(1);
//c1->SetGridy(1);
TPad* pad = new TPad("pad","",0.,0.,1.,1.);
pad->SetGrid();
pad->Draw();
pad->cd();
pad->SetLogz(1);
TH1F* hr = pad->DrawFrame(0.,0.,1.,1.);
const int nx = 3;
const int ny = 10;
double pt[nx] = { 30., 50., 100. };
double ht[ny];
for ( int ii = 0; ii < ny; ++ii ) { ht[ii] = 150. + ii * 50.; }
double ratio[nx][ny];
double xbin_centre = ( ( xmax - xmin ) / xbins ) / 2.;
double ybin_centre = ( ( ymax - ymin ) / ybins ) / 2.;
TH2D* his = new TH2D("Contours","",xbins,xmin,xmax,ybins,ymin,ymax);
for ( int ii = 0; ii < nx; ++ii ) {
for ( int jj = 0; jj < ny; ++jj ) {
double x3 = ( 2. * pt[ii] ) / ( ht[jj] + pt[ii] );
double n = 0.;
double d = 0.;
for ( int xbin = 0; xbin < xbins; ++xbin ) {
for ( int ybin = 0; ybin < ybins; ++ybin ) {
double x2 = ( ( xmax - xmin ) / xbins ) * xbin + xmin;
double x1 = ( ( ymax - ymin ) / ybins ) * ybin + ymin;
double val = ( x1*x1 + x2*x2 ) / ( ( 1 - x1 ) * ( 1 - x2 ) );
if ( x1 < x2 || // jet ordering by Pt
x1 + x2 > 2. || // from relation "x1 + x2 + x3 = 2"
x1 > 1.0 || // from "lost jet" and relation "xmiss = -x1 -x2"
x1 + x2 < 1. // from "lost jet" and relation "xmiss = -x1 -x2"
) { continue; }
if ( ( x1 + x2 ) < ( 2 - x3 ) ) { continue; }
d += val;
double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) );
if ( alpha_t > 0.5 ) n+= val;
if ( ii == 2 && jj == 9 ) { his->Fill( x2+xbin_centre, x1+ybin_centre, val ); }
}
}
double r = 0.;
if ( d > 0. ) { r = n/d; }
ratio[ii][jj] = r;
std::cout << " Pt: " << pt[ii]
//.........这里部分代码省略.........