本文整理汇总了C++中TList::LastIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::LastIndex方法的具体用法?C++ TList::LastIndex怎么用?C++ TList::LastIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::LastIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AutoSetYRange
double AutoSetYRange(TCanvas& canv, double maxScale) {
TList* list = canv.GetListOfPrimitives();
double maximum = 0;
int firstHist = -1;
// int isCanvasLogY = canv.GetLogy();
for (int iPrims = 0; iPrims <= list->LastIndex(); ++iPrims) {
TH1* hist = dynamic_cast<TH1*>(list->At(iPrims));
if (hist) {
//Remember histo to set maximum of, which is the first one drawn
if (firstHist == -1) {
firstHist = iPrims;
}
if (hist->GetMaximum() > maximum) {
maximum = hist->GetMaximum();
}
}
}
if (firstHist != -1) {
dynamic_cast<TH1*>(list->At(firstHist))->SetMaximum(maximum * maxScale);
return maximum * maxScale;
} else {
std::cout << __func__ << " No Histograms found" << std::endl;
return -1;
}
}
示例2: addn2
//.........这里部分代码省略.........
*/
//--------------------------------------------------------------------
// copy f1 to f0:
f1.cd();
cout << "keys:\n";
f1.GetListOfKeys()->Print();
cout << "pwd: ";
f1.pwd();
cout << "ls: \n";
f1.ls();
// f1 has sub-dir:
cout << "First: " << f1.GetListOfKeys()->First()->GetName() << endl;
cout << "First: " << f1.GetListOfKeys()->First()->ClassName() << endl;
char* dir1 = f1.GetListOfKeys()->First()->GetName();
cout << "cd to " << dir1 << endl;
f1.cd( dir1 );
cout << "we are in ";
gDirectory->pwd();
gDirectory->ReadAll(); // load histos
TList * lst = gDirectory->GetList();
cout << lst->GetName() << endl;
cout << lst->GetTitle() << endl;
cout << "size " << lst->GetSize() << endl;
cout << "entries " << lst->GetEntries() << endl;
cout << "last " << lst->LastIndex() << endl;
TIterator *iter = lst->MakeIterator();
int ii = 0;
TObject *obj;
TH1D *h;
TH1D *h0;
TH2D *H;
TH2D *H0;
while( obj = iter->Next() ){
ii++;
cout << setw(4) << ii << ": ";
cout << obj->ClassName() << " ";
cout << obj->InheritsFrom("TH1D") << " ";
cout << obj->GetName() << " \"";
cout << obj->GetTitle() << "\"";
cout << endl;
// if( obj->ClassName() == "TH1D" ){
if( obj->InheritsFrom("TH1D") ){
h = (TH1D*) obj;
cout << " 1D";
cout << h->GetNbinsX() << " bins, ";
cout << h->GetEntries() << " entries, ";
cout << h->GetSumOfWeights() << " inside, ";
cout << h->GetBinContent(0) << " under, ";
cout << h->GetBinContent(h->GetNbinsX()+1) << " over";
cout << endl;
f0.cd(); // output file
// TH1D* h0 = (TH1D*) h->Clone();
h0 = h; // copy