本文整理汇总了C++中TAxis::SetRange方法的典型用法代码示例。如果您正苦于以下问题:C++ TAxis::SetRange方法的具体用法?C++ TAxis::SetRange怎么用?C++ TAxis::SetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAxis
的用法示例。
在下文中一共展示了TAxis::SetRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlotRatevsDAC
bool TMRCScanner::PlotRatevsDAC(int xmin,int xmax,int ymax)
{
int channel = 0;
// Read channel range from configuration
ffile = new TFile(foutfile);
if (ffile->IsOpen()){
ftree = (TTree*) ffile->Get("T");
//ftree->SetMarkerStyle(23);
//ftree->SetLineColor(kRed);
ftree->Draw("(HITEntries[0]/Duration):DAC>>hDAC(1024,0,1023,2001,0,2000)","HITEntries!=0","L");
TH2F *h = (TH2F*)gPad->GetPrimitive("hDAC");
TAxis *xaxis = h->GetXaxis();
xaxis->SetTitle("Threshold [DAC unit]");
xaxis->SetRange(xmin,xmax);
TAxis *yaxis = h->GetYaxis();
yaxis->SetTitle("Rate [Hz]");
yaxis->SetRange(0,ymax);
h->SetTitle("Pulse Amplitude Integral Distribution");
for (int i = 2048; i<(2048+128); i++) {
ftree->Draw(Form("(HITEntries[%d]/Duration):DAC",channel+i),"HITEntries!=0","SAME,L");
printf("%d\n",i);
}
ftree->SetLineColor(kRed);
ftree->Draw("Rate:DAC","","SAME,L");
}else {
printf("File %s not opened \n",foutfile);
return false;
}
delete ffile;
return true;
}
示例2: if
//________________________________________________________________
void KVCanvas::DynamicZoomTH1(Int_t Sign, Int_t px, Int_t)
{
// Zoom in or out of histogram with mouse wheel
if (!fSelected) return;
TH1* TheHisto = (TH1*) FindHisto();//fSelected;
Double_t percent = 0.15 - Sign * 0.05;
Int_t dX = 0;
px = AbsPixeltoX(px);
TAxis* ax = TheHisto->GetXaxis();
Int_t NbinsXtmp = ax->GetNbins();
Int_t X0tmp = ax->GetFirst();
Int_t X1tmp = ax->GetLast();
Int_t step = TMath::Min(TMath::Max(1, (Int_t)(percent * (X1tmp - X0tmp))), NbinsXtmp / 2);
step *= Sign;
X0tmp = TMath::Min(TMath::Max(X0tmp + step, 1), X1tmp - step);
X1tmp = TMath::Max(TMath::Min(X1tmp - step, NbinsXtmp), X0tmp);
if (X0tmp >= X1tmp) X0tmp = X1tmp - 1;
if (Sign > 0) dX = (Int_t)(X0tmp + (X1tmp - X0tmp) * 0.5 - ax->FindBin(px));
if ((X0tmp - dX) < 0) ax->SetRange(0, X1tmp - X0tmp);
else if ((X1tmp - dX) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (X1tmp - X0tmp), ax->GetNbins());
else ax->SetRange(X0tmp - dX, X1tmp - dX);
Modified();
Update();
return;
}
示例3: GetSlices
void GetSlices(Double_t start, Double_t end, TH3D *source, TH2D **target)
{
TAxis *zAxis = source->GetZaxis();
Int_t startBin = zAxis->FindBin(start);
Int_t endBin = zAxis->FindBin(end);
Int_t it = 0;
for(Int_t iBin = startBin; iBin < endBin; iBin += 10){
zAxis->SetRange(iBin, iBin + 9);
//cout << iBin << endl;
TString name = Form("yx%d", it);
target[it++] = (TH2D*)source->Project3D(name);
}
source->GetZaxis()->UnZoom();
//zAxis->UnZoom();
}
示例4:
TH1 *PullHisto(const TList *list, const char *name, Int_t min, Int_t max,
Double_t &mean)
{
THnSparse *hs = list->FindObject(name);
if (!hs) return 0;
TAxis *atmp = hs->GetAxis(1);
atmp->SetRange(min, max);
// !!!!!!!!!!!!!!!!!!!!
hs->GetAxis(2)->SetRangeUser(-0.5, 0.5);
TH1 *hfin = hs->Projection(0);
hfin->SetTitle(Form("p_{t} #in (%4.2f, %4.2f) GeV/c",
atmp->GetBinLowEdge(min),
atmp->GetBinLowEdge(max) + atmp->GetBinWidth(max)));
mean = atmp->GetBinLowEdge(min) +
(atmp->GetBinLowEdge(max) + atmp->GetBinWidth(max) -
atmp->GetBinLowEdge(min))/2.0;
// !!!!!!!!!!!!!!!!!!!!
return hfin;//->Rebin();
}
示例5: DynamicZoom
//________________________________________________________________
void KVCanvas::DynamicZoom(Int_t Sign, Int_t px, Int_t py)
{
// Zoom in or out of histogram with mouse wheel
// Info("DynamicZoom","px=%d py=%d",px,py);
if (!fSelected) return;
TH2* TheHisto = (TH2*) FindHisto();//fSelected;
Double_t percent = 0.15 - Sign * 0.05;
Int_t dX = 0;
Int_t dY = 0;
Double_t ppx = AbsPixeltoX(px);
Double_t ppy = AbsPixeltoY(py);
TAxis* ax = TheHisto->GetXaxis();
Int_t NbinsXtmp = ax->GetNbins();
Int_t X0tmp = ax->GetFirst();
Int_t X1tmp = ax->GetLast();
Int_t step = TMath::Min(TMath::Max(1, (Int_t)(percent * (X1tmp - X0tmp))), NbinsXtmp / 2);
step *= Sign;
X0tmp = TMath::Min(TMath::Max(X0tmp + step, 1), X1tmp - step);
X1tmp = TMath::Max(TMath::Min(X1tmp - step, NbinsXtmp), X0tmp);
if (X0tmp >= X1tmp) X0tmp = X1tmp - 1;
if (Sign > 0) dX = (Int_t)(X0tmp + (X1tmp - X0tmp) * 0.5 - ax->FindBin(ppx));
if ((X0tmp - dX) < 0) ax->SetRange(0, X1tmp - X0tmp);
else if ((X1tmp - dX) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (X1tmp - X0tmp), ax->GetNbins());
else ax->SetRange(X0tmp - dX, X1tmp - dX);
ax = TheHisto->GetYaxis();
Int_t NbinsYtmp = ax->GetNbins();
Int_t Y0tmp = ax->GetFirst();
Int_t Y1tmp = ax->GetLast();
step = TMath::Min(TMath::Max(1, (Int_t)(percent * (Y1tmp - Y0tmp))), NbinsYtmp / 2);
step *= Sign;
Y0tmp = TMath::Min(TMath::Max(Y0tmp + step, 1), Y1tmp - step);
Y1tmp = TMath::Max(TMath::Min(Y1tmp - step, NbinsYtmp), Y0tmp);
if (Y0tmp >= Y1tmp) Y0tmp = Y1tmp - 1;
if (Sign > 0) dY = (Int_t)(Y0tmp + (Y1tmp - Y0tmp) * 0.5 - ax->FindBin(ppy));
if ((Y0tmp - dY) < 0) ax->SetRange(0, Y1tmp - Y0tmp);
else if ((Y1tmp - dY) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (Y1tmp - Y0tmp), ax->GetNbins());
else ax->SetRange(Y0tmp - dY, Y1tmp - dY);
Modified();
Update();
return;
}
示例6: HandleInput
//______________________________________________________________________________
void KVCanvas::HandleInput(EEventType event, Int_t px, Int_t py)
{
// Handle Input Events.
//
// Handle input events, like button up/down in current canvas.
if (fFreezed) return;
TPad* pad;
TPad* prevSelPad = (TPad*) fSelectedPad;
TObject* prevSelObj = fSelected;
fPadSave = (TPad*)gPad;
cd(); // make sure this canvas is the current canvas
fEvent = event;
fEventX = px;
fEventY = py;
Int_t sign = 0;
Bool_t sendOrder = true;
if (fHasDisabledClasses && fSelected) {
if (fDisabledClasses.Contains(fSelected->ClassName())) sendOrder = false;
}
if (fHasDisabledObject && fSelected) {
if (fDisabledObjects.Contains(fSelected)) sendOrder = false;
}
switch (event) {
case kMouseMotion:
// highlight object tracked over
pad = Pick(px, py, prevSelObj);
if (!pad) return;
EnterLeave(prevSelPad, prevSelObj);
gPad = pad; // don't use cd() we will use the current
// canvas via the GetCanvas member and not via
// gPad->GetCanvas
if (sendOrder) fSelected->ExecuteEvent(event, px, py);
RunAutoExec();
if (fAgeOfEmpire && (fSelected->InheritsFrom("TH2"))) {
TH2* TheHisto = (TH2*) FindHisto();//fSelected;
Double_t size = 0.4 - 0.35 * fVenerMode;
Int_t dX = 0;
Int_t dY = 0;
Double_t ppx = AbsPixeltoX(px);
Double_t ppy = AbsPixeltoY(py);
TAxis* ax = TheHisto->GetXaxis();
Int_t X0 = ax->GetFirst();
Int_t X1 = ax->GetLast();
Int_t NbinsX = ax->GetNbins();
px = ax->FindBin(ppx);
Double_t ddX = (X1 + X0) * 0.5 - px;
Double_t distX = TMath::Abs(ddX) / (X1 - X0);
if (distX >= 0.5) return;
TAxis* ay = TheHisto->GetYaxis();
Int_t Y0 = ay->GetFirst();
Int_t Y1 = ay->GetLast();
Int_t NbinsY = ay->GetNbins();
py = ay->FindBin(ppy);
Double_t ddY = (Y1 + Y0) * 0.5 - py;
Double_t distY = TMath::Abs(ddY) / (Y1 - Y0);
if (distY >= 0.5) return;
if ((distX <= size) && (distY <= size)) return;
dX = TMath::Nint(ddX * (0.05 + 0.05 * fVenerMode));
dY = TMath::Nint(ddY * (0.05 + 0.05 * fVenerMode));
if (TMath::Abs(dX) < 1) dX = TMath::Sign(1., ddX);
if (TMath::Abs(dY) < 1) dY = TMath::Sign(1., ddY);
Bool_t up = false;
if ((X0 - dX > 0) && (X1 - dX < NbinsX)) {
ax->SetRange(X0 - dX, X1 - dX);
up = true;
}
if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) {
ay->SetRange(Y0 - dY, Y1 - dY);
up = true;
}
if (up) {
Modified();
Update();
}
//.........这里部分代码省略.........
示例7: writeSignalHistosForModel
void writeSignalHistosForModel(std::vector<TH1D *>& vsd,
const TString& sigmodel,
TFile *allHistFile)
{
for (int ichan=0; ichan<NUMCHAN; ichan++) {
TH1D * sdh = vsd[ichan];
// Find limit window from gaussian fit to signal peak.
//
double wid = sdh->GetRMS();
double mean = sdh->GetMean();
//TCanvas *c1 = new TCanvas(s,s,300,300);
TFitResultPtr r = sdh->Fit("gaus","QNS","",mean-2.5*wid,mean+2.5*wid);
cout<<" mean= "<<mean<<", RMS= "<<wid<<", Fit sigma= "<<r->Parameter(2)<<endl;
//cout<<r->Parameter(0)<<" "<<r->Parameter(1)<<" "<<r->Parameter(2)<<endl;
TAxis *xax = sdh->GetXaxis();
#if 0
int lobin = xax->FindFixBin(r->Parameter(1)-2*r->Parameter(2));
int hibin = xax->FindFixBin(r->Parameter(1)+2*r->Parameter(2));
sd.sumwinmin = xax->GetBinLowEdge(lobin);
sd.sumwinmax = xax->GetBinUpEdge(hibin);
#elif 0
int lobin = xax->FindFixBin(140); sd.sumwinmin=140; // 1 bin left,
int hibin = xax->FindFixBin(170)-1; sd.sumwinmax=170; // 2 bins right
#else
int lobin = xax->FindFixBin(sumwinmin);
int hibin = xax->FindFixBin(sumwinmax)-1;
#endif
int nbins = hibin-lobin+1;
// for variable binning - all histos must have the same binning per channel
TVectorD xbins = TVectorD(sdh->GetNbinsX(),sdh->GetXaxis()->GetXbins()->GetArray());
TVectorD xwindow = xbins.GetSub(lobin-1,hibin);
xax->SetRange(lobin,hibin);
// Copy contents to window-restricted signal histogram
// and write to output file.
//
TString name = Form("Signal%s_%s",sigmodel.Data(),channames[ichan]);
printf("Booking TH1D(%s,%s,%d,xwindowarray)\n",
name.Data(),sdh->GetTitle(),nbins);
TH1D *signm = new TH1D(name.Data(),
sdh->GetTitle(),
nbins,
xwindow.GetMatrixArray());
// make copies of the histograms that are restricted to the
// bin range lobin-hibin
//
for (int ibin=lobin; ibin<=hibin; ibin++)
signm->SetBinContent((ibin-lobin+1),
sdh->GetBinContent(ibin)
*sdh->GetBinWidth(ibin)
);
if (!sigmodel.CompareTo("wh"))
signm->Scale(whsigscaleto);
else
signm->Scale(sigscaleto);
allHistFile->WriteTObject(signm);
} // channel loop
} // writeSignalHistosForModel
示例8: CmpRate
void TMRCScanner::CmpRate(const char * rootfile1,
const char * rootfile2,
const char * rootfile3,
const char * rootfile4,
const char * rootfile5,
const char * rootfile6,
const char * rootfile7,
const char * rootfile8,
const char * rootfile9)
{
if (rootfile1!=NULL) {
//TCanvas *c1 = new TCanvas("c1","c1",600,500);
TLegend* leg = new TLegend(0.1,0.7,0.48,0.9);
// leg->SetHeader("The Legend Title");
leg->SetHeader("Pre-Amp Gain");
Color_t color1 = kRed; //23
Color_t color2 = kBlue; //24
Color_t color3 = kMagenta; //25
// Color_t color4 = kRed; //26
Color_t color4 = kCyan; //26
// Color_t color5 = kRed+3; //27
Color_t color5 = kYellow; //27
Color_t color6 = kGreen; //28
Color_t color7 = kCyan; //29
Color_t color8 = kYellow; //30
Color_t color9 = kMagenta;
TFile* f1 = new TFile(rootfile1);
if (f1->IsOpen()) {
TTree * mytree1 = (TTree*) f1->Get("T");
mytree1->SetMarkerStyle(22);
mytree1->SetMarkerColor(kRed);
mytree1->Draw("(HITEntries[2048]/Duration):DAC>>hDAC(800,160,860,1000,0,1000)","HITEntries!=0");
// mytree1->Draw("(HITEntries[2048]/Duration):DAC>>hDAC(1024,0,1023,1000,0,1000)","HITEntries!=0","P");
// mytree1->Draw("(HITEntries[]/Duration):DAC>>hDAC(1024,0,1023,1000,0,1000)","HITEntries!=0","L");
TH2F *h = (TH2F*)gPad->GetPrimitive("hDAC");
TAxis *xaxis = h->GetXaxis();
xaxis->SetTitle("Threshold [DAC unit]");
xaxis->SetRange(0,1024);
TAxis *yaxis = h->GetYaxis();
yaxis->SetTitle("Rate [Hz]");
yaxis->SetRange(0,1000);
h->SetTitle("Pulse Amplitude Integral Distribution");
h->Draw();
for (int i =2049 ; i<2112; i++) {
mytree1->SetLineColor(color1);
mytree1->Draw(Form("(HITEntries[%d]/Duration):DAC>>h",i),"HITEntries!=0","SAME");
}
mytree1->SetMarkerColor(color1);
// leg->AddEntry(mytree1,rootfile1,"L");
leg->AddEntry(mytree1,"Gain 0.5","P");
}else {
printf("File %s not opened \n",foutfile);
}
if (rootfile2!=NULL) {
TFile* f2 = new TFile(rootfile2);
TTree * mytree2 = (TTree*) f2->Get("T");
mytree2->SetMarkerStyle(22);
mytree2->SetMarkerColor(color2);
for (int i =2048 ; i<2112; i++) {
mytree2->SetLineColor(color2);
// mytree2->Draw(Form("(HITEntries[%d]/Duration):DAC",i),"HITEntries!=0","SAME,L");
mytree2->Draw(Form("(HITEntries[%d]/Duration):DAC>>h",i),"HITEntries!=0","SAME");
}
mytree2->SetMarkerColor(color2);
leg->AddEntry(mytree2,"Gain 1.0","P");
}
if (rootfile3!=NULL) {
TFile* f3 = new TFile(rootfile3);
TTree * mytree3 = (TTree*) f3->Get("T");
mytree3->SetMarkerStyle(22);
mytree3->SetMarkerColor(color3);
for (int i =2048 ; i<2112; i++) {
mytree3->SetLineColor(color3);
mytree3->Draw(Form("(HITEntries[%d]/Duration):DAC>>h",i),"HITEntries!=0","SAME");
// mytree3->Draw(Form("(HITEntries[%d]/Duration):DAC",i),"HITEntries!=0","SAME,L");
}
mytree3->SetMarkerColor(color3);
//leg->AddEntry(mytree3,rootfile3,"L");
leg->AddEntry(mytree3,"Gain 1.5","P");
}
if (rootfile4!=NULL) {
TFile* f4 = new TFile(rootfile4);
TTree * mytree4 = (TTree*) f4->Get("T");
mytree4->SetMarkerStyle(22);
mytree4->SetMarkerColor(color4);
for (int i =2048 ; i<2112; i++) {
mytree4->SetLineColor(color4);
mytree4->Draw(Form("(HITEntries[%d]/Duration):DAC>>h",i),"HITEntries!=0","SAME");
// mytree4->Draw(Form("(HITEntries[%d]/Duration):DAC",i),"HITEntries!=0","SAME,L");
}
mytree4->SetMarkerColor(color4);
//leg->AddEntry(mytree4,rootfile4,"L");
//.........这里部分代码省略.........