本文整理汇总了C++中TAxis::GetFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ TAxis::GetFirst方法的具体用法?C++ TAxis::GetFirst怎么用?C++ TAxis::GetFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAxis
的用法示例。
在下文中一共展示了TAxis::GetFirst方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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: computeHistoMedian
double computeHistoMedian(TH1F * histo) {
// Get the x axis
TAxis * ax = histo->GetXaxis();
// Get the number of bins
const int nBins = histo->GetNbinsX();
double cont[nBins];
double x[nBins];
// Loop over all the bins
for (int bin=ax->GetFirst(); bin<=ax->GetLast(); bin++){
x[bin] = histo->GetBinCenter(bin);
cont[bin] = histo->GetBinContent(bin);
}
return TMath::Median(nBins, x, cont);
}
示例4: computePValue
double computePValue(TH1F * histo, double s) {
// Get the x axis
TAxis * ax = histo->GetXaxis();
double integ = histo->Integral();
double nAboveS = 0;
// Loop over all the bins
for (int bin=ax->GetFirst(); bin<=ax->GetLast(); bin++){
if(histo->GetBinCenter(bin) > s) {
nAboveS += histo->GetBinContent(bin);
}
}
double old = nAboveS/integ;
TString gName = "gaus_"+TString(histo->GetName());
TF1 *gaus = new TF1(gName.Data(),"gaus",0.2,100);
histo->Fit(gaus,"Q","",0.2,100);
double pvalue = gaus->Integral(s,10)/gaus->Integral(-10,10);
cout << " p-value computation for S: " << s << " with histo: " << old
<< " with fit: " << pvalue << endl;
return pvalue;
}
示例5: 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();
}
//.........这里部分代码省略.........
示例6: BaseSelector
TauAnalysisSelector::TauAnalysisSelector(const std::string& puWeight, bool isEmbedded,
const std::string& embeddingWTauMuFile, const std::string& embeddingWTauMuPath,
const std::string& mcTauMultiplicity, const std::string& mcTauMode,
const std::string& embeddingNormalizationMode,
TH1 *embeddingMuonWeights):
BaseSelector(),
//fMuons("Emb"),
fGenTaus(isEmbedded ? "gentausOriginal" : "gentaus", true),
fGenTausEmbedded("gentausEmbedded", true),
fPuWeightName(puWeight),
fIsEmbedded(isEmbedded),
fEmbeddingWTauMuWeights(0),
fMCTauMultiplicity(parseMCTauMultiplicity(mcTauMultiplicity)),
fMCTauMode(parseMCTauMode(mcTauMode)),
fEmbeddingNormalizationMode(parseEmbeddingNormalizationMode(embeddingNormalizationMode)),
fEmbeddingMuonWeights(embeddingMuonWeights),
cAll(fEventCounter.addCounter("All events")),
//cElectronVeto(fEventCounter.addCounter("Electron veto")),
cGeneratorWeight(fEventCounter.addCounter("Vis. pt weight")),
cTauBRWeight(fEventCounter.addCounter("Tau BR weighting")),
cGenTauFound(fEventCounter.addCounter("Gen tau found")),
cTauMCSelection(fEventCounter.addCounter("Tau MC requirement")),
cOnlyWMu(fEventCounter.addCounter("Only W->mu")),
cWTauMuWeight(fEventCounter.addCounter("W->tau->mu weighting")),
cTriggerEffWeight(fEventCounter.addCounter("Muon trigger eff weighting")),
cIdEffWeight(fEventCounter.addCounter("Muon ID eff weighting")),
cMuonWeight(fEventCounter.addCounter("Muon corr weighting (from argument)")),
cJetSelection(fEventCounter.addCounter("Jet selection")),
cPrimaryVertex(fEventCounter.addCounter("Primary vertex")),
cAllTauCandidates(fEventCounter.addCounter(">= 1 tau candidate")),
cPrePtCut(fEventCounter.addCounter("Pre Pt cut")),
cDecayModeFinding(fEventCounter.addCounter("Decay mode finding")),
cEtaCut(fEventCounter.addCounter("Eta cut")),
cPtCut(fEventCounter.addCounter("Pt cut")),
cLeadingTrackPtCut(fEventCounter.addCounter("Leading track pt")),
cEcalCracks(fEventCounter.addCounter("ECAL fiducial: cracks")),
cEcalGap(fEventCounter.addCounter("ECAL fiducial: gap")),
cAgainstElectron(fEventCounter.addCounter("Against electron")),
cAgainstMuon(fEventCounter.addCounter("Against muon")),
cIsolation(fEventCounter.addCounter("Isolation")),
cOneProng(fEventCounter.addCounter("One prong")),
cRtau(fEventCounter.addCounter("Rtau")),
cMuTrigger(fEventCounter.addCounter("Mu trigger"))
{
if(isEmbedded && !embeddingWTauMuFile.empty()) {
TFile *file = TFile::Open(embeddingWTauMuFile.c_str());
TEfficiency *eff = dynamic_cast<TEfficiency *>(file->Get(embeddingWTauMuPath.c_str()));
TAxis *xaxis = eff->GetPassedHistogram()->GetXaxis();
fEmbeddingWTauMuWeights = new TH1F("weights", "weights", xaxis->GetNbins(), xaxis->GetBinLowEdge(xaxis->GetFirst()), xaxis->GetBinUpEdge(xaxis->GetLast()));
fEmbeddingWTauMuWeights->SetDirectory(0);
for(int bin=1; bin <= xaxis->GetNbins(); ++bin) {
fEmbeddingWTauMuWeights->SetBinContent(bin, eff->GetEfficiency(bin));
std::cout << "Bin " << bin << " low edge " << fEmbeddingWTauMuWeights->GetXaxis()->GetBinLowEdge(bin) << " value " << fEmbeddingWTauMuWeights->GetBinContent(bin) << std::endl;
}
fEmbeddingWTauMuWeights->SetBinContent(xaxis->GetNbins()+1, fEmbeddingWTauMuWeights->GetBinContent(xaxis->GetNbins()));
file->Close();
}
if(isEmbedded) {
fMuons.setIdEfficiencyName("efficiency_Run2011AB");
fMuons.setTriggerEfficiencyName("efficiency_trigger");
}
}