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


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

本文整理汇总了C++中TList::AddLast方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::AddLast方法的具体用法?C++ TList::AddLast怎么用?C++ TList::AddLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TList的用法示例。


在下文中一共展示了TList::AddLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindALine

//________________________________________________________________
void KVZALineFinder::FindALine(Int_t zz, Int_t width)
{
    fLinearHisto->SetAxisRange(zz-0.5,zz+0.5,"Y");

    KVIDLine* line = (KVIDLine*)fGrid->GetIdentifier(zz,2*zz+1); // A=2*zz+1 : dummy, A is ignored in this case
    if(!line)
    {
        int i=1;
        while(!(line = (KVIDLine*)fGrid->GetIdentifier(zz+i,2*zz+1))) i++;
    }
    if(!line) return;

    Double_t lX, lY;
    line->GetStartPoint(lX,lY);
    Int_t xbmin = 0;//fLinearHisto->GetYaxis()->FindBin(lX);
    line->GetEndPoint(lX,lY);
    Int_t xbmax = fLinearHisto->GetXaxis()->FindBin(lX);
    
    // create lines
    TList Lines;
    KVSpiderLine* tmp = 0;

    fLinearHisto->SetAxisRange(fLinearHisto->GetXaxis()->GetBinCenter(50),lX,"X");//fLinearHisto->GetXaxis()->GetXmax(),"X");
    TH1* tmph = fLinearHisto->ProjectionX(Form("tmph%d",zz));
    Int_t startBin = (Int_t)(tmph->GetMaximumBin()*0.95);
    delete tmph;

    TH1* projey = 0;
    if(startBin)
    {
        projey = fLinearHisto->ProjectionY("ProjectionAfterLin",startBin-width*3,startBin+width*3);
        int nfound = fSpectrum.Search(projey,0.05,"goff",0.0001);
        Info("FindALine","%d peack found...",nfound);
#if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
        Double_t* xpeaks = fSpectrum.GetPositionX();
        Double_t* ypeaks = fSpectrum.GetPositionY();
#else
        Float_t* xpeaks = fSpectrum.GetPositionX();
        Float_t* ypeaks = fSpectrum.GetPositionY();
#endif
        for(int p=0;p<nfound;p++)
        {
            if(p>8) break;
            if(ypeaks[p]<10) continue;
            Double_t xline = fLinearHisto->GetXaxis()->GetBinCenter(startBin);
            Double_t yline = xpeaks[p];
            KVSpiderLine* tmp = 0;
            TIter next(&Lines);
            while((tmp=(KVSpiderLine*)next()))
            {
                Info("FindALine","line found but I don't know why...");
                if(TMath::Abs(tmp->GetY()-yline)<0.05) continue;
            }
            tmp = new KVSpiderLine(zz,-1);
            Lines.AddLast(tmp);
            tmp->AddPoint(xline,yline);
            fPoints->SetPoint(fNPoints,xline,yline);
            fNPoints++;
        }
        if(projey) delete projey;
    }
    else Error("FindALine","not starting bin indicated...");
    SortLines(&Lines);

    Int_t nLines = Lines.GetSize();
    tmp = 0;
    for(int xx=startBin-width; xx>xbmin; xx-=width)
    {
        projey = fLinearHisto->ProjectionY("ProjectionAfterLin",xx-width/2,xx+width/2);
        int nfound = fSpectrum.Search(projey,0.05,"goff",0.02);
#if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
        Double_t* xpeaks = fSpectrum.GetPositionX();
        Double_t* ypeaks = fSpectrum.GetPositionY();
#else
        Float_t* xpeaks = fSpectrum.GetPositionX();
        Float_t* ypeaks = fSpectrum.GetPositionY();
#endif
        for(int p=0;p<nfound;p++)
        {
            if(p>=nLines+1) continue;
            if(ypeaks[p]<5) continue;
            Double_t xline = fLinearHisto->GetXaxis()->GetBinCenter(xx);
            Double_t yline = xpeaks[p];
            KVSpiderLine* tmp = 0;
            TIter next(&Lines);
            while((tmp=(KVSpiderLine*)next()))
            {
                if((TMath::Abs(tmp->GetY()-yline)<0.05)) break;
            }
            if(tmp)
            {
                if((TMath::Abs(tmp->GetX()-xline)<10*width)) tmp->AddPoint(xline,yline);
            }
        }
        if(projey) delete projey;
    }

    TIter nextli(&Lines);
    while((tmp=(KVSpiderLine*)nextli()))tmp->Sort(true);
//.........这里部分代码省略.........
开发者ID:pwigg,项目名称:kaliveda,代码行数:101,代码来源:KVZALineFinder.cpp

示例2: nextlf

NTPReplay( Char_t* fname, Int_t qfRecon = -1 )
{
  // Histogram energies, momenta, from Tree created by kinematics generator
  // AcquMC....ensure physics library is loaded 1st
  gROOT->Reset();
  if (!gROOT->GetClass("TLorentzVector")) gSystem->Load("libPhysics");
  //
  // Tree file contains 4-momenta produced by MCGenerator
  TFile* tFile = new TFile( fname );
  TTree* tree = (TTree*)tFile->Get("h1");
  tree->Print();
  Int_t nbr = tree->GetNbranches();
  Int_t nparticle = (nbr - 3)/5;                  // # particles in reaction
  printf(" %d particles in experiment\n", nparticle );
  TObjArray* leaves = tree->GetListOfBranches(); // linked list of leaves
  printf(" %d leaves in branch\n",nbr);
  TIter nextlf( tree->GetListOfBranches() );
  char** hname = new char*[nbr];               // histogram parameters
  Float_t* p4i = new Float_t[nbr];
  for( Int_t n=0; n<nbr; n++ ){
    TBranch* lf = (TBranch*)nextlf();           // Double_t leaf
    hname[n] = lf->GetName();                 // its name
    tree->SetBranchAddress(hname[n], p4i+n);
  }
  Int_t nevent = tree->GetEntries();           // # events generated
  printf(" %d events started\n", nevent );
  //
  //  Create linked list of 1D histograms
  Int_t i,j,k;
  //  for(i=0,j=0; i<nparticle; i++) if( Track[i] ) j++;  // #particles tracked
  j = nparticle;
  printf(" %d final-state particles tracked\n", j );
  Int_t np4 = j;
  Int_t nhist = 4*j + 7;                              // # 1D histograms
  Int_t nchan = 1000;                                 // 1000 channels each
  Char_t* title;                                      // title is file name
  if( !(title = strrchr(fname,'/')) ) title = fname;
  else title++;
  TList* hl = new TList();
  TList* hAng = new TList();
  TH1F* h;
  for( i=0; i<nhist; i++ ){
    h = new TH1F( hname[i], title, nchan, 0, 0 );
    hl->AddLast(h);
  }
  Char_t angName[256];
  // Angular ranges (deg) for plotting
  Double_t thetaMin[] = {
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
  };
  Double_t thetaMax[] = {
    0.5, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0,
    180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0, 180.0
  };
  Double_t phiMin[] = {
    -200, -200, -200, -200, -200, -200, -200, -200, -200, -200,
    -200, -200, -200, -200, -200, -200, -200, -200, -200, -200, -200
  };
  Double_t phiMax[] = {
    200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0,
    200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0, 200.0
  };
  for( i=0; i<=np4; i++ ){
    sprintf( angName, "Theta_%d", i );
    h = new TH1F( angName, title, 180, thetaMin[i], thetaMax[i] );
    hAng->AddLast(h);
    sprintf( angName, "Phi_%d", i );
    h = new TH1F( angName, title, 180, phiMin[i], phiMax[i] );
    hAng->AddLast(h);
    sprintf( angName, "P_%d", i );
    h = new TH1F( angName, title, 1000, 0, 0 );
    hAng->AddLast(h);
  }    
  TIter next(hl);                             // list iterator
  TIter nextAng(hAng);                       // list iterator
  //
  // For some 4-momentum analysis
  TLorentzVector* P4 = new TLorentzVector[nparticle];
  TLorentzVector P4tot;
  TLorentzVector P4beamQF;
  i = 0;
  TH2F* h2a = new TH2F("Vertex-X-Y",title,300,-3,3,300,-3,3);
  TH2F* h2b = new TH2F("Vertex-Z-R",title,300,-3,3,300,-3,3);
  TH1F* h1a = new TH1F("Momentum-Balance",title,1000,-1,1);
  TH1F* h1b;
  if( qfRecon >= 0 ) h1b = new TH1F("QF-recon-Beam-Energy",title,2000,-5,5);
  //
  // Read events from branch
  Double_t r;
  Float_t* p;
  for(i=0; i<nevent; i++){
    next.Reset();
    nextAng.Reset();
    tree->GetEntry(i);
    p = p4i + 3;
    P4tot.SetXYZT(0,0,0,0);
    if( qfRecon >= 0 )P4beamQF.SetXYZT(0,0,0,0);
    for(j=0; j<=np4; j++,p+=5){
      P4[j].SetXYZT(p[0]*p[3],p[1]*p[3],p[2]*p[3],p[4]);
//.........这里部分代码省略.........
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:101,代码来源:NTPReplay.C


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