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


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

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


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

示例1: getKS

/*************************************************************************************
 * getKS: Searches through the histograms in the plotter output, adds the MC together
 *        for each field, and compares the MC with the Data histogram using a KS test
 *  input:  the main() arguments array
 *  output: writes to stdout the (human-readable) KS statistics of pairs of histograms
 *
 *  Structure-wise: this is fine, can be implemented into class easily.
 ***********************************/
void getKS(const char* argv[]) {
  //open the input TFile
  TFile *f = new TFile(argv[2]);
  f->cd();

  //get the filesystem information from the file
  TList *alokDirs = (TList*) f->GetListOfKeys();

  //loop through the directories in the input file
  for(int idir=0; alokDirs->At(idir-1) != alokDirs->Last(); idir++) {
    TDirectory *cDir  = (TDirectory*) f->Get(alokDirs->At(idir)->GetName());
    TList *alokHistos = (TList*)      cDir->GetListOfKeys();

    // create the MC histogram and start collecting relevant MC histograms
    // from the current directory
    TList *aloh   = new TList;
    // loop through keys (histograms) in current directory
    for(int ihisto=0; alokHistos->At(ihisto) != alokHistos->Last(); ihisto++) {
      if(TString(alokHistos->At(ihisto)->GetName()).Contains("MC8TeV")) {
        TH1F *cHisto = (TH1F*) cDir->Get(alokHistos->At(ihisto)->GetName());
        aloh->Add(cHisto);
      }
    }
 
    //merge the data histograms into one histogram
    TH1F *MCHisto = (TH1F*) (aloh->Last())->Clone(TString(cDir->GetName()) + TString("MCHisto"));
    aloh->RemoveLast();
    MCHisto->Merge(aloh);

    cout<<"-------------------- "<<cDir->GetName()<<" -----------------------"<<endl;
    //now create the data histogram and run the KS test
    TH1F *DataHisto = (TH1F*) cDir->Get(alokHistos->Last()->GetName());
    cout<<"  ---> KS Test: "<<cDir->GetName()<<" has probability "<<MCHisto->KolmogorovTest(DataHisto, "D")<<"\n"<<endl;
  }
}
开发者ID:eacoleman,项目名称:MLBOutputProcessors,代码行数:43,代码来源:MLBWidthOProcessor.C

示例2: cmpLRD

void cmpLRD(TFile* f1, TFile* f2, const char* dName, const char* patt = 0, unsigned int logmod=0, unsigned int dOpt=1){
  //  std::cout<<"cmpLRD In "<< dName<<std::endl;
  TDirectory* td = gROOT->GetDirectory(dName);
  if (td){
    TList* tkl = td->GetListOfKeys();
    unsigned int tklSize = tkl->GetEntries();
    //    std::cout<<"\t size "<<tklSize<<std::endl;
    for (unsigned int iK=0; iK< tklSize; ++iK){
      //      std::cout<<"at "<<iK<<"\t " <<tkl->At(iK)->GetName()<<std::endl;
      if (TClass(((TKey*)tkl->At(iK))->GetClassName()).InheritsFrom("TDirectory")){
	TDirectory* tdc = (TDirectory*)((TKey*)tkl->At(iK))->ReadObj();
	if (tdc ==0) continue;
	TString tdcPFull(tdc->GetPath());
	TString pRel(tdcPFull.Tokenize(":")->At(1)->GetName());
	//	std::cout<<tdcPFull.Data()<<std::endl;
	
	//now execute compare 
	//	if(pRel.Index("/SiStrip/")>=0) continue; //this takes a huge time in alcareco and is irrelevant
	///DQMData/Run 1/Btag
	if (patt==0 || (patt!=0 && pRel.Index(patt)>=0)){
	  //	  std::cout<<"Comparing in " <<pRel.Data()<<std::endl;
	  compareInDir(f1, f2, pRel.Data(),logmod,dOpt);
	}
	cmpLRD(f1, f2, tdcPFull.Data(), patt,logmod,dOpt);
      }
    }
  }
}
开发者ID:HuguesBrun,项目名称:cms-bot,代码行数:28,代码来源:compareValHists.C

示例3: extractObjectFromPad

TList* extractObjectFromPad(TPad* pad, const char* name)
{
  TList* objects = new TList();
  TList* primitivesList = pad->GetListOfPrimitives();
  assert(primitivesList);
  for (int i = 0; i < primitivesList->GetSize(); ++i) {
    TObject* object = primitivesList->At(i);
    std::cout << object->ClassName() << ' ' << object->GetName() << std::endl;
    if (object->InheritsFrom("TPad")) {
      TList* objectsFromPad = extractObjectFromPad(static_cast<TPad*>(object), name);
      for (int j = 0; j < objectsFromPad->GetSize(); ++j)
        objects->Add(objectsFromPad->At(j));
    } else if (object->InheritsFrom("THStack")) {
      TList* hList = (static_cast<THStack*>(object))->GetHists();
      for (int j = 0; j < hList->GetSize(); ++j)
        if (!strcmp(hList->At(j)->GetName(), name)) {
          objects->Add(hList->At(j));
        }
    } else if (!strcmp(object->GetName(), name)) {
      std::cout << "--->" << name << std::endl;
      objects->Add(object);
    }
  }
  return objects;
}
开发者ID:Dominik-Mitzel,项目名称:radiatedModule,代码行数:25,代码来源:dominik.C

示例4: 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

示例5: assert

void
dumpToPDF(string inName, string fitName){
  TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);


  string outName = inName;
  outName.replace(outName.find(".root"), 5, ".pdf");

  //fitName = "HLT_10LS_delivered_vs_rate_Run190949-191090.root";
  TFile *fFit = TFile::Open(fitName.c_str(), "read"); assert(fFit);

  TCanvas c1;
  c1.Print(Form("%s[", outName.c_str()), "pdf"); //Open .pdf

  //get list of keys
  int nplots = fin->GetNkeys(); 
  int nfits = fFit->GetNkeys(); 
  printf("nplots: %i, nfits: %i\n", nplots, nfits);
  if(nplots != nfits){
    cout<<" PDF output will be wrong since different number of triggers in fit and current run"<<endl;
    abort();
  }
  TList* plots = fin->GetListOfKeys();  
  TList* fits  = fFit->GetListOfKeys();
  for(int i=0; i<nplots; ++i){
    TKey* plot = (TKey*) plots->At(i);
    TKey* fit = (TKey*) fits->At(i);//assume they're in the same order for now

    if(!fin->GetKey(plot->GetName())){
      cout<<"Didn't find "<<plot<<". Removing."<<endl;
      abort();
    }
    if(!fFit->GetKey(fit->GetName())){
      cout<<"Didn't find "<<fit<<". Removing."<<endl;
      abort();
    }
    TCanvas* c = new TCanvas();
    c->Divide(1,2);

    TCanvas* cPlot = (TCanvas*) fin->Get(plot->GetName());
    c->cd(1);
    cPlot->DrawClonePad();

    TCanvas* cFit  = (TCanvas*) fFit->Get(fit->GetName());
    c->cd(2);
    cFit->DrawClonePad();

    string bookmarkName = "Title: ";
    bookmarkName += plot->GetName();

    c->Print(outName.c_str(), bookmarkName.c_str());
  }

  c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf

}
开发者ID:drankincms,项目名称:RateMon,代码行数:56,代码来源:dumpToPDF.C

示例6: SelectPad

void
Pick(Int_t canvas_index)
{
  TObject *o;
  TCanvas* c = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index));
  c->cd();
  // std::cout << "______PICKED______\n\t" 
  // 	  << c->GetName() << " canvas_index=" << canvas_index << std::endl;
  //  ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index))->cd();
  

  TList *ll = toolcanvas->GetListOfPrimitives();
  // std::cout << ll->GetEntries() << std::endl;
  for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--)
    {
      o = ll->At(ii);
      // std::cout << ii << " removing " << ll->At(ii)->GetName() << std::endl;
      ll->Remove(o);
    }

  toolcanvas->cd();
  toolcanvas->SetWindowSize(toolw-28, toolh-8);
  //  toolcanvas->SetCanvasSize(toolw, toolh);
  pt->Draw();
  toolcanvas->Modified();
  toolcanvas->Update();
  canvas = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index));
  //Enlarge();
  SelectPad();
}
开发者ID:jrtomps,项目名称:phdwork,代码行数:30,代码来源:DoubleClickEnlarge.C

示例7: AddAllBaseConstructors

void KVClassFactory::AddAllBaseConstructors()
{
    // Add constructors with the same signature as all base class constructors
    // (apart from the default ctor or any copy constructors, which are a special case)
    // By default, all constructors are 'public'.

    if(!fBaseClass) return;

    KVHashList clist;
    clist.AddAll(fBaseClass->GetListOfMethods());
    KVSeqCollection* constructors = clist.GetSubListWithName(fBaseClassName);
    TIter next_ctor(constructors);
    TMethod* method;
    while( (method = (TMethod*)next_ctor()) )
    {
        if(!method->GetNargs()) continue; // ignore default ctor
        TList* args = method->GetListOfMethodArgs();
        TMethodArg* arg = (TMethodArg*)args->First();
        TString typenam=arg->GetFullTypeName();
        if(typenam.Contains(fBaseClassName)) continue; // ignore copy ctor
        KVClassMethod* ctor;
        if(arg->GetDefault()) ctor = AddConstructor( typenam, arg->GetName(), arg->GetDefault() );
        else ctor = AddConstructor(typenam, arg->GetName());
        for(int i=1; i<method->GetNargs(); i++){
            arg = (TMethodArg*)args->At(i);
            if(arg->GetDefault()) ctor->AddArgument( arg->GetFullTypeName(), arg->GetName(), arg->GetDefault() );
            else ctor->AddArgument(arg->GetFullTypeName(), arg->GetName());
        }
    }

    delete constructors;
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:32,代码来源:KVClassFactory.cpp

示例8: SaveOutput

// Save to .root file
void SaveOutput(TString name,TList &list)
{
	TFile *out = new TFile(name,"RECREATE");
	TDirectory *pwd = gDirectory;
	for(int i=0;i<list.GetSize();i++)
	{
		TDecayMode *dm = list.At(i);
		TDirectory *subdir = out->mkdir(dm->GetName());
		subdir->cd();
		subdir->Append(dm);
		subdir->Append(dm->histograms);
		pwd->cd();
	}
	if(!genDesc) cout<<"WARNING! No Generator description in files!"<<endl;
	else out->Append(genDesc);
	if(userHisto)
	{
		
		TDecayMode *uh = (TDecayMode*) userHisto;
		cout<<"INFO: Appending user histograms"<<endl;
		TDirectoryFile *histos = out->mkdir("USER_HISTOGRAMS");
		TIter  nexthist(uh->histograms);
		TKey  *key_hist=0;
		TH1D *h;
		while(h=(TH1D*)nexthist()) histos->Append(h);
	}
	out->Write();
	out->Close();
	delete out;
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:31,代码来源:MERGE.C

示例9: dominik

void dominik()
{
  TH1* matHistogramRoman = static_cast<TH1*>(extractObjectFromFile("lyRoman.root", "lightYieldProjectionY")->At(0));
  TList* objects = extractObjectFromFile("c.root", "chargeBins");
  TH1* matHistogramDominik = new TH1D("matHistogramDominik", ";channel;light yield / pixels", 512, -0.5, 512-0.5);
  int sipmIt = 0;
  for (int i = 0; i < objects->GetSize(); ++i) {
    TH1* h = static_cast<TH1*>(objects->At(i));
    if (h->GetLineColor() == 8) {
      for (int bin = 1; bin <= 128; ++bin) {
        matHistogramDominik->SetBinContent(512 - (sipmIt * 128 + bin - 1), h->GetBinContent(bin));
        if (h->GetBinError(bin) > 0)
          matHistogramDominik->SetBinError(512 - (sipmIt * 128 + bin - 1), h->GetBinError(bin));
      }
      ++sipmIt;
    }
  }
  TCanvas* c = new TCanvas;
  c->Divide(1, 2);
  c->cd(1);
  matHistogramDominik->Draw();
  matHistogramRoman->Draw("SAME");
  c->cd(2);
  TH1* h = static_cast<TH1*>(matHistogramDominik->Clone());
  h->Add(matHistogramRoman, -1);
  h->Draw();
}
开发者ID:Dominik-Mitzel,项目名称:radiatedModule,代码行数:27,代码来源:dominik.C

示例10: printf

TList* contourFromTH2(TH2 *h2in, double threshold) {
    std::cout << "Getting contour at threshold " << threshold << " from " << h2in->GetName() << std::endl;
    //http://root.cern.ch/root/html/tutorials/hist/ContourList.C.html
    Double_t contours[1];
    contours[0] = threshold;

    TH2D *h2 = frameTH2D((TH2D*)h2in);

    h2->SetContour(1, contours);

    // Draw contours as filled regions, and Save points
    h2->Draw("CONT Z LIST");
    gPad->Update(); // Needed to force the plotting and retrieve the contours in TGraphs

    // Get Contours
    TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
    TList* contLevel = NULL;

    if (conts == NULL || conts->GetSize() == 0){
        printf("*** No Contours Were Extracted!\n");
        return 0;
    }

    TList *ret = new TList();
    for(int i = 0; i < conts->GetSize(); i++){
        contLevel = (TList*)conts->At(i);
        printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
        for (int j = 0, n = contLevel->GetSize(); j < n; ++j) {
            TGraph *gr1 = (TGraph*) contLevel->At(j)->Clone();
            ret->Add(gr1);
        }
    }
    return ret;
}
开发者ID:alexeyfinkel,项目名称:ECALELF,代码行数:34,代码来源:mcmcDraw.C

示例11: Terminate

void rdphi::Terminate()
{
//cout << "total event: " << NevtAll << "rejected: " << rejected_events << endl; 

  TFile *f = new TFile("output.root","RECREATE");

  //Write output Histograms
  TList *tl = GetOutputList();
  int l = tl->GetEntries();
  for ( int i = 0 ; i < l ; i++ )
  {
    TObject *o = tl->At(i);

    if ( o->InheritsFrom("TH1") )
    {
      cout << "TresChorros: Saving Histogram: "
          << "  Class: " << o->ClassName()  
          << "  Name: "<< o->GetName() 
          << "  Title: " << o->GetTitle()
          << " " 
          << endl << flush;
      o->Write();
    }
    }
  f->Flush();
  f->Close();  

}
开发者ID:affablelochan,项目名称:DataAnalysis,代码行数:28,代码来源:rdphi_v1.C

示例12: getContourFilledX

TGraph* getContourFilledX(TH2D* inputHisto, TCanvas* goodCanvas, int Width, int Style, int FillStyle, double X){
       TCanvas* c1 = new TCanvas("temp", "temp",600,600);

       TH2D* histo = (TH2D*)inputHisto->Clone("temp");

       double levels[] = {X};
       histo->SetContour(1, levels);
       histo->Draw("CONT LIST");
       c1->Update();
       TObjArray* contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
       Int_t ncontours     = contours->GetSize();
       TList *list         = (TList*)contours->At(0);
       delete c1;

       goodCanvas->cd();
       printf("list size = %i\n", (int)list->GetSize());
       if(list->GetSize()<=0)return new TGraph(0);

       for(unsigned int i=0;i<list->GetSize();i++){
       TGraph* EXCLUSION   = (TGraph*)(list->At(i)->Clone("copy"));
       EXCLUSION->SetLineColor(1);
       EXCLUSION->SetLineWidth(Width);
       EXCLUSION->SetLineStyle(Style);
       EXCLUSION->SetFillColor(kBlack);
       EXCLUSION->SetFillStyle(FillStyle);
       //EXCLUSION->Draw("CL F same");
       }

       return EXCLUSION;
}
开发者ID:AlexandreMertens,项目名称:ZAPlotters,代码行数:30,代码来源:Plotter_sbatb2.C

示例13: GetData

//----------  Retrieve data histo  -----------------
TH1F* GetData(TFile* fin, string region, string varname)
{
    string cname = CHANNEL_NAME+string("/")+region+"/"+varname;
    TCanvas* c = (TCanvas*) fin->Get(cname.c_str());
    TList* l = c->GetListOfPrimitives();
    TPad* pad = (TPad*) l->At(0);
    string hname = "v:"+varname+"|r:"+region+string("|c:")+CHANNEL_NAME+string("|t:1DSumData");
    TH1F* h = (TH1F*) pad->GetPrimitive(hname.c_str());
    return (TH1F*) h->Clone();
}
开发者ID:oneLeptonStopAt13TeV,项目名称:StopAF,代码行数:11,代码来源:MTTailCorrectionClosureTests.C

示例14: TGraph

    TGraph*
ContourGraph( TH2F* hist)
{
    TGraph* gr0 = new TGraph();
    TH2F* h = (TH2F*)hist->Clone();
    gr = (TGraph*)gr0->Clone(h->GetName());
    //  cout << "==> Will dumb histogram: " << h->GetName() << " into a graph" <<endl;
    h->SetContour( 1 );
    double pval = CombinationGlob::cl_percent[1];
    double signif = TMath::NormQuantile(1-pval);
    h->SetContourLevel( 0, signif );
    h->Draw("CONT LIST");
    h->SetDirectory(0);
    gPad->Update();
    TObjArray *contours = gROOT->GetListOfSpecials()->FindObject("contours");
    Int_t ncontours     = contours->GetSize();
    TList *list = (TList*)contours->At(0);
    Int_t number_of_lists = list->GetSize();
    gr = (TGraph*)list->At(0);
    TGraph* grTmp = new TGraph();
    for (int k = 0 ; k<number_of_lists ; k++){
        grTmp = (TGraph*)list->At(k);
        Int_t N = gr->GetN();
        Int_t N_tmp = grTmp->GetN();
        if(N < N_tmp) gr = grTmp;
        //    mg->Add((TGraph*)list->At(k));
    }

    gr->SetName(hist->GetName());
    int N = gr->GetN();
    double x0, y0;

    //  for(int j=0; j<N; j++) {
    //    gr->GetPoint(j,x0,y0);
    //    cout << j << " : " << x0 << " : "<<y0 << endl;
    //  }
    //  //  gr->SetMarkerSize(2.0);
    //  gr->SetMarkerSize(2.0);
    //  gr->SetMarkerStyle(21);
    //  gr->Draw("LP");
    //  cout << "Generated graph " << gr << " with name " << gr->GetName() << endl;
    return gr;
}
开发者ID:lawrenceleejr,项目名称:ZeroLeptonAnalysis,代码行数:43,代码来源:SUSY_bRPV_m0_vs_m12_all_withBand_cls.C

示例15: MakeCutLog

void MakeCutLog(const char *inputRootFile = "AnalysisResults",const char *path = "./", const char* outputDir="./Output/"){

  fstream outputFile(Form("%sCutSelection.log",outputDir),ios::out);
  if(!outputFile.is_open()){
    cout<<"Problem opening file"<<endl;
    return;
  }

  //  Char_t filename_input1[200] = (Form("%s%s",path,input1));	
  TString filename = Form("%s%s.root",path,inputRootFile);	
  TFile f(filename.Data());  

  TList *directories = f.GetListOfKeys(); // get the list of directories in the file
  
  for(Int_t entFile=0;entFile<directories->GetEntries();entFile++){

    TObject * o = f.Get(directories->At(entFile)->GetName()); // get the object in the base directory

    if(TString(o->IsA()->GetName())=="TDirectoryFile"){ // means that this is a directory (PWGGA......)
      
      TDirectory *pwg4dir =(TDirectory*)o;
 
      TString baseDirName = pwg4dir->GetName();
      
      TString reconstructionFlagString = ""; // this is for new scheme where also the flags are coded in numbers in the PWGGA.... name

      if(baseDirName.Length()>31){
	reconstructionFlagString = baseDirName(baseDirName.Index("GammaConversion_")+16,8);
      }
      
      TList *pwg4list = pwg4dir->GetListOfKeys(); // list of the yeys inside the base directory

      for(Int_t entHist=0;entHist<pwg4list->GetEntries();entHist++){
	TString name = pwg4list->At(entHist)->GetName();

	if(name.Contains("container")==0){ // does not try to read the container (get errors if tried)
	  TObject * oHist = pwg4dir->Get(pwg4list->At(entHist)->GetName()); // get the object 
	  
	  if(TString(oHist->IsA()->GetName())=="TList"){ // check if the object is a TList
	    
	    TString listname = oHist->GetName();
	    cout<<"Reading: "<<listname.Data()<<endl;
	    
	    TString cutString = listname(listname.Index("_")+1,listname.Length()) + "\n";// get the Cut string from the name


	    outputFile << cutString.Data();
	  }
	}
      }
    }
  }
  outputFile.close();
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:54,代码来源:MakeCutLog.C


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