本文整理汇总了C++中TH1I::GetXaxis方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1I::GetXaxis方法的具体用法?C++ TH1I::GetXaxis怎么用?C++ TH1I::GetXaxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1I
的用法示例。
在下文中一共展示了TH1I::GetXaxis方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MPulseLengths_init
/** This method initializes histograms.
*/
INT MPulseLengths_init()
{
// This histogram has the pulse lengths on the X-axis and the number of pulses on the Y-axis
// One histogram is created for each detector
std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin();
mapIter != bank_to_detector_map.end(); mapIter++) {
std::string bankname = mapIter->first;
std::string detname = gSetup->GetDetectorName(bankname);
std::string histname = "h" + detname + "_Lengths";
std::string histtitle = "Plot of the pulse lengths for the " + detname + " detector";
TH1I* hDetLengths = new TH1I(histname.c_str(), histtitle.c_str(), 100,0,100);
hDetLengths->GetXaxis()->SetTitle("Pulse Lengths [N Samples]");
hDetLengths->GetYaxis()->SetTitle("Arbitrary Unit");
hDetLengths->SetBit(TH1::kCanRebin);
length_histograms_map[bankname] = hDetLengths;
}
std::string histname = "hAvgPulseLengthsPerChannel";
std::string histtitle = "Plot of the average pulse lengths per event for the each channel";
average_length_histogram = new TH2I(histname.c_str(), histtitle.c_str(), 1,0,1, 5000,0,5000);
average_length_histogram->GetXaxis()->SetTitle("Bank Name");
average_length_histogram->GetYaxis()->SetTitle("MIDAS Event Number");
average_length_histogram->SetBit(TH1::kCanRebin);
return SUCCESS;
}
示例2: RFMacro_BeamBunchPeriod
int RFMacro_BeamBunchPeriod(void)
{
gDirectory->cd("/"); //return to file base directory
//Goto Beam Path
TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("RF");
if(!locDirectory)
return 0;
locDirectory->cd();
//Get RF Bunch Period Histograms
gDirectory->cd("RF_BeamBunchPeriod");
TH1I* locHist_RFBeamBunchPeriod = (TH1I*)gDirectory->Get("RFBeamBunchPeriod");
//Get/Make Canvas
TCanvas *locCanvas = NULL;
if(TVirtualPad::Pad() == NULL)
locCanvas = new TCanvas("RF_BeamBunchPeriod", "RF_BeamBunchPeriod", 1200, 800); //for testing
else
locCanvas = gPad->GetCanvas();
//Draw
gPad->SetTicks();
gPad->SetGrid();
if(locHist_RFBeamBunchPeriod != NULL)
{
TH1I* locHist = locHist_RFBeamBunchPeriod;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
return 1;
}
示例3: RFMacro_TDCConversion
int RFMacro_TDCConversion(void)
{
gDirectory->cd("/"); //return to file base directory
//Goto Beam Path
TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("RF");
if(!locDirectory)
return 0;
locDirectory->cd();
//Get RF DeltaT Histograms
gDirectory->cd("DeltaT_RF_FirstTime");
TH1I* locHist_FDCRF_FirstTimeDeltaT = (TH1I*)gDirectory->Get("FDCRF_FirstTimeDeltaT");
TH1I* locHist_TOFRF_FirstTimeDeltaT = (TH1I*)gDirectory->Get("TOFRF_FirstTimeDeltaT");
TH1I* locHist_TAGHRF_FirstTimeDeltaT = (TH1I*)gDirectory->Get("TAGHRF_FirstTimeDeltaT");
TH1I* locHist_PSCRF_FirstTimeDeltaT = (TH1I*)gDirectory->Get("PSCRF_FirstTimeDeltaT");
//Get/Make Canvas
TCanvas *locCanvas = NULL;
if(TVirtualPad::Pad() == NULL)
locCanvas = new TCanvas("RF_TDCConversion", "RF_TDCConversion", 1200, 800); //for testing
else
locCanvas = gPad->GetCanvas();
locCanvas->Divide(2, 2);
//Draw
locCanvas->cd(1);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TOFRF_FirstTimeDeltaT != NULL)
{
TH1I* locHist = locHist_TOFRF_FirstTimeDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(2);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TAGHRF_FirstTimeDeltaT != NULL)
{
TH1I* locHist = locHist_TAGHRF_FirstTimeDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(3);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_PSCRF_FirstTimeDeltaT != NULL)
{
TH1I* locHist = locHist_PSCRF_FirstTimeDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(4);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_FDCRF_FirstTimeDeltaT != NULL)
{
TH1I* locHist = locHist_FDCRF_FirstTimeDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
return 1;
}
示例4: main
int main()
{
float const conS =.3/2.35;
ofstream fout("cal/backN.cal");
ofstream fwhm("cal/fwhmback.dat");
TFile f("sort.root");
TCanvas* canvas[14];
int Ntele = 14;
int Nstrip = 32;
ostringstream outstring;
TH2I frame("frame","",10,4.5,9.5,10,0,130);
frame.SetStats(kFALSE);
double xx[14*32];
double yy[14*32];
TF1 *func = new TF1("fit",ThPeaks,3,9,4);
double para[5];
ifstream file("cal/back.cal");
float intercept, slope;
int i1,i2;
string name;
TH1F con("con","",500,0,10);
for (int itele=0;itele<Ntele;itele++)
{
outstring.str("");
outstring << "B"<<itele;
name = outstring.str();
canvas[itele] = new TCanvas(name.c_str());
canvas[itele]->Divide(6,6);
for (int istrip =0;istrip<Nstrip;istrip++)
{
canvas[itele]->cd(istrip+1);
file >> i1 >> i2 >> slope >> intercept;
outstring.str("");
outstring << "back/cal/EBC"<<itele<<"_"<<istrip;
string name = outstring.str();
cout << name << endl;
TH1I * hist = (TH1I*) f.Get(name.c_str());
frame.Draw();
hist->SetStats(kFALSE);
hist->GetXaxis()->SetRangeUser(4.5,9.5);
con.GetXaxis()->SetRangeUser(4.5,9.5);
for (int i=1;i<=500;i++)
for (int j=1;j<500;j++)
{
float deltax = hist->GetBinCenter(i)-con.GetBinCenter(j);
if (fabs(deltax) > 10.*conS)continue;
float fact = gauss(deltax,0.,conS);
float y = fact*hist->GetBinContent(i)*hist->GetBinWidth(i);
con.SetBinContent(j,y+con.GetBinContent(j));
}
for (int i=1;i<=500;i++)
{
hist->SetBinContent(i,con.GetBinContent(i));
con.SetBinContent(i,0.);
}
hist->Draw("same");
func->SetParameter(0,0);
func->SetParameter(1,1.);
func->FixParameter(2,conS);
//func->SetParameter(2,0.1);
func->SetParameter(3,8.);
func->SetLineColor(2);
//func->Draw("same");
hist->Fit(func);
func->GetParameters(para);
cout << "chisq=" << func->GetChisquare() << endl;
if (fabs(para[1]-1.) < .2)
{
slope *= para[1];
intercept = intercept*para[1] + para[0];
}
fout << itele << " " << istrip << " "
<< slope << " " << intercept << endl;
fwhm << itele << " " << istrip << " "
<< para[2]*2.35 << endl;
int ii = itele*32+istrip;
xx[ii] = (float)ii;
yy[ii] = para[2]*2.35;
cout << para[0] << " " << para[1] << " " << para[2] << endl;
//.........这里部分代码省略.........
示例5: RFMacro_SelfResolution
int RFMacro_SelfResolution(void)
{
gStyle->SetOptStat(1111);
gDirectory->cd("/"); //return to file base directory
//Goto Beam Path
TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("RF");
if(!locDirectory)
return 0;
locDirectory->cd();
//Get RF DeltaT Histograms
gDirectory->cd("DeltaT_RF_Itself");
TH1I* locHist_FDCRF_SelfDeltaT = (TH1I*)gDirectory->Get("FDCRF_SelfDeltaT");
TH1I* locHist_TOFRF_SelfDeltaT = (TH1I*)gDirectory->Get("TOFRF_SelfDeltaT");
TH1I* locHist_TAGHRF_SelfDeltaT = (TH1I*)gDirectory->Get("TAGHRF_SelfDeltaT");
TH1I* locHist_PSCRF_SelfDeltaT = (TH1I*)gDirectory->Get("PSCRF_SelfDeltaT");
//Time resolutions
double locTimeResolutionSq_TOF = locHist_TOFRF_SelfDeltaT->GetStdDev() / sqrt(2.0);
locTimeResolutionSq_TOF *= locTimeResolutionSq_TOF;
double locTimeResolutionSq_FDC = locHist_FDCRF_SelfDeltaT->GetStdDev() / sqrt(2.0);
locTimeResolutionSq_FDC *= locTimeResolutionSq_FDC;
double locTimeResolutionSq_PSC = locHist_PSCRF_SelfDeltaT->GetStdDev() / sqrt(2.0);
locTimeResolutionSq_PSC *= locTimeResolutionSq_PSC;
double locTimeResolutionSq_TAGH = locHist_TAGHRF_SelfDeltaT->GetStdDev() / sqrt(2.0);
locTimeResolutionSq_TAGH *= locTimeResolutionSq_TAGH;
//Print Coarse offsets to screen:
cout << "Time-resolution-squared for TOF/TAGH/PSC/FDC are: " << locTimeResolutionSq_TOF << ", " << locTimeResolutionSq_TAGH << ", " << locTimeResolutionSq_PSC << ", " << locTimeResolutionSq_FDC << endl;
//Print Coarse offsets to file:
ofstream locOutputFileStream;
locOutputFileStream.open("rf_time_resolution_sq.txt");
locOutputFileStream << std::setprecision(6) << locTimeResolutionSq_TOF << " " << locTimeResolutionSq_TAGH << " " << locTimeResolutionSq_PSC << " " << locTimeResolutionSq_FDC << endl;
locOutputFileStream.close();
//Get/Make Canvas
TCanvas *locCanvas = NULL;
if(TVirtualPad::Pad() == NULL)
locCanvas = new TCanvas("RF_SelfResolution", "RF_SelfResolution", 1200, 800); //for testing
else
locCanvas = gPad->GetCanvas();
locCanvas->Divide(2, 2);
//Draw
locCanvas->cd(1);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TOFRF_SelfDeltaT != NULL)
{
TH1I* locHist = locHist_TOFRF_SelfDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(2);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TAGHRF_SelfDeltaT != NULL)
{
TH1I* locHist = locHist_TAGHRF_SelfDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(3);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_PSCRF_SelfDeltaT != NULL)
{
TH1I* locHist = locHist_PSCRF_SelfDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(4);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_FDCRF_SelfDeltaT != NULL)
{
TH1I* locHist = locHist_FDCRF_SelfDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
}
示例6: processWaveforms
//.........这里部分代码省略.........
waveformWrap->Write();
for(Plots p : targetPlots)
{
p.getTOFHisto()->Write();
p.getEnergyHisto()->Write();
}
fittedTimeHisto->Write();
deltaTVsPulseIntegral0->Write();
deltaTVsPulseIntegral1->Write();
deltaTVsPulseIntegral2->Write();
deltaTVsPulseIntegral3->Write();
deltaTVsPulseIntegral4->Write();
deltaTVsPulseIntegral5->Write();
deltaTVsPulseHeight->Write();
relativeTriggerTimeHisto->Write();
triggerAmplitudeHisto->Write();
relativeTriggerTimeVsAmplitude->Write();
gammaToGammaTimeH->Write();
}
else if(mode=="waveform")
{
setBranchesHistosW(treeToSort);
triggerWalk = new TH2I("triggerWalk","trigger time vs. waveform chunk #",200,0,200,1000,0,1000);
TH1I* monitorHisto = new TH1I("targetPosH", "targetPos", 7, 0, 7);
monitorHisto->GetXaxis()->SetTitle("target position of each waveform");
long triggersWithGamma = 0;
vector<int> fullWaveform(MACRO_LENGTH/2, BASELINE);
vector<double> triggerList;
int prevTargetPos = 0;
double firstTimetagInSeries = 0;
int totalEntries = treeToSort->GetEntries();
cout << "Total waveforms = " << totalEntries << endl;
/*TCanvas *mycan = (TCanvas*)gROOT->FindObject("mycan");
if(!mycan)
{
mycan = new TCanvas("mycan","mycan");
}*/
// EVENT LOOP for sorting through channel-specific waveforms
for(int j=1; j<totalEntries; j++)
{
cout << "Processing triggers on waveform " << j << "\r";
fflush(stdout);
if(j>30)
{
break;
}
triggerList.clear();
triggerValues.clear();
示例7: main
int main(void)
{
gStyle->SetOptStat(1111);
TDirectory *locTopDirectory = gDirectory;
//Goto Beam Path
TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("RF");
if(!locDirectory)
return 0;
locDirectory->cd();
//Get RF DeltaT Histograms
gDirectory->cd("DeltaT_RF_TAGH");
TH1I* locHist_FDCRF_TaggerDeltaT = (TH1I*)gDirectory->Get("FDCRF_TaggerDeltaT");
TH1I* locHist_TOFRF_TaggerDeltaT = (TH1I*)gDirectory->Get("TOFRF_TaggerDeltaT");
TH1I* locHist_TAGHRF_TaggerDeltaT = (TH1I*)gDirectory->Get("TAGHRF_TaggerDeltaT");
TH1I* locHist_PSCRF_TaggerDeltaT = (TH1I*)gDirectory->Get("PSCRF_TaggerDeltaT");
//Get/Make Canvas
TCanvas *locCanvas = NULL;
if(TVirtualPad::Pad() == NULL)
locCanvas = new TCanvas("RF_TaggerDeltaT", "RF_TaggerDeltaT", 1200, 800); //for testing
else
locCanvas = gPad->GetCanvas();
locCanvas->Divide(2, 2);
//Draw
locCanvas->cd(1);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TOFRF_TaggerDeltaT != NULL)
{
TH1I* locHist = locHist_TOFRF_TaggerDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(2);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_TAGHRF_TaggerDeltaT != NULL)
{
TH1I* locHist = locHist_TAGHRF_TaggerDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(3);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_PSCRF_TaggerDeltaT != NULL)
{
TH1I* locHist = locHist_PSCRF_TaggerDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
locCanvas->cd(4);
gPad->SetTicks();
gPad->SetGrid();
if(locHist_FDCRF_TaggerDeltaT != NULL)
{
TH1I* locHist = locHist_FDCRF_TaggerDeltaT;
locHist->GetXaxis()->SetTitleSize(0.05);
locHist->GetYaxis()->SetTitleSize(0.05);
locHist->GetXaxis()->SetLabelSize(0.05);
locHist->GetYaxis()->SetLabelSize(0.05);
locHist->Draw();
}
}
示例8: CsIProj
void CsIProj()
{
TFile *file = new TFile("../root/NZ_55_New.root");
TFile *gates = new TFile("../gates/zlines.root");
TFile *gates2 = new TFile("../gates/zlines_new.root");
ofstream ofile("CsI_55A_New.dat");
TCanvas *mycan = (TCanvas*)gROOT->FindObjectAny("mycan");
if(!mycan)
{
mycan = new TCanvas("mycan","mycan");
mycan->Divide(1,2);
}
ostringstream outstring;
string name;
int p1= 30, p2=50; //+- fit limits up to 2 peaks. May be different.
int const num_par = 5; //number of peaks times 2(pol1)+3(gaus).
for(int ic =0;ic<56;ic++)
{
outstring.str("");
outstring << "dEE/dEE_" << ic;
name = outstring.str();
mycan->cd(1);
TH2I *hist = (TH2I*)file->Get(name.c_str());
hist->Draw("col");
hist->GetXaxis()->SetRangeUser(200.,1800.);
hist->GetYaxis()->SetRangeUser(5.,50.);
if(ic <16 || ic > 31)
TCutG *mycut = (TCutG*)gates->Get(Form("Zline_%i_2_4",ic));
else
TCutG *mycut = (TCutG*)gates2->Get(Form("Zline_%i_2_4",ic));
mycut->Draw();
file->cd();
outstring.str("");
outstring << "CsI/CsIGate/ECsI_" << ic << "_Gate";
name = outstring.str();
gPad->SetLogz();
mycan->cd(2);
TH1I * proj = (TH1I*)file->Get(name.c_str());
proj->Draw();
proj->Rebin(4);
proj->GetXaxis()->SetRangeUser(700.,1800.);
mycan->Modified();
mycan->Update();
TMarker * mark;
mark=(TMarker*)mycan->WaitPrimitive("TMarker"); //Get the Background limits
int bkg_lo = mark->GetX();
delete mark;
mark=(TMarker*)mycan->WaitPrimitive("TMarker");
int bkg_hi = mark->GetX();
delete mark;
mark=(TMarker*)mycan->WaitPrimitive("TMarker"); // Get the 1st peak initial guess
int peak1 = mark->GetX();
delete mark;
double par[num_par] = {0.};
double out[num_par] = {0.};
int peak1_lo = peak1 - p1, peak1_hi = peak1 + p1; // Peak center and limits
TF1 *l1 = new TF1("l1", "pol1", bkg_lo, bkg_hi);
TF1 *g1 = new TF1("g1", "gaus", peak1_lo,peak1_hi);
TF1 *total = new TF1("total", "pol1(0)+gaus(2)", bkg_lo,bkg_hi);
proj->Fit(l1,"R");
proj->Fit(g1,"R+");
l1->GetParameters(&par[0]);
g1->GetParameters(&par[2]);
total->SetParameters(par);
proj->Fit(total,"R");
total->GetParameters(out);
ofile << ic << " " << out[3] << endl;
outstring.str("");
outstring << "55A_" << ic;
name = outstring.str();
total->SetName(name.c_str());
total->Draw("same");
mycan->Modified();
mycan->Update();
bool IsGood = 0;
//.........这里部分代码省略.........