本文整理匯總了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