当前位置: 首页>>代码示例>>C++>>正文


C++ TList::LastIndex方法代码示例

本文整理汇总了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;
    }
  }
开发者ID:FCALSW,项目名称:FCalClusterer,代码行数:26,代码来源:RootUtils.cpp

示例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
开发者ID:andreavargas,项目名称:Psi46testDesy,代码行数:67,代码来源:addn2.C


注:本文中的TList::LastIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。