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


C++ TObjArray::GetSize方法代码示例

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


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

示例1: runtime_error

/// Open new data file
bool DDG4EventHandler::Open(const std::string&, const std::string& name)   {
    if ( m_file.first ) m_file.first->Close();
    m_hasFile = false;
    m_hasEvent = false;
    TFile* f = TFile::Open(name.c_str());
    if ( f && !f->IsZombie() )  {
        m_file.first = f;
        TTree* t = (TTree*)f->Get("EVENT");
        if ( t )   {
            TObjArray* br = t->GetListOfBranches();
            m_file.second = t;
            m_entry = -1;
            m_branches.clear();
            for(Int_t i=0; i<br->GetSize(); ++i)  {
                TBranch* b = (TBranch*)br->At(i);
                if ( !b ) continue;
                m_branches[b->GetName()] = make_pair(b,(void*)0);
                printout(INFO,"DDG4EventHandler::open","+++ Branch %s has %ld entries.",b->GetName(),b->GetEntries());
            }
            for(Int_t i=0; i<br->GetSize(); ++i)  {
                TBranch* b = (TBranch*)br->At(i);
                if ( !b ) continue;
                b->SetAddress(&m_branches[b->GetName()].second);
            }
            m_hasFile = true;
            return true;
        }
        throw runtime_error("+++ Failed to access tree EVENT in ROOT file:"+name);
    }
    throw runtime_error("+++ Failed to open ROOT file:"+name);
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:32,代码来源:DDG4EventHandler.cpp

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

示例3: scanDiffRecoTracks

void scanDiffRecoTracks(std::string eName, std::string eoName,
			std::string branchReg = "recoTracks_*"){
  gSystem->Load("libFWCoreFWLite");
  gROOT->ProcessLine("AutoLibraryLoader::enable();");
  TChain* e = new TChain("Events");
  e->SetScanField(0);

  e->Add(eName.c_str());

  TChain* eo = new TChain("Events");
  eo->SetScanField(0);

  eo->Add(eoName.c_str());
  e->AddFriend(eo, "eo");

  TRegexp regg(branchReg.c_str(), kTRUE);

  TChain* tc = e ;
  TObjArray* tl = tc->GetListOfBranches();
 
  Int_t nBr = tl->GetSize();
  for (int iB=0;iB<nBr;++iB){
    TBranch* br = (TBranch*)(tl->At(iB)); 
    TString ts(br->GetName()); 
    if(ts.Index(regg)>=0){
      std::cout<<ts.Data()<<std::endl;
      tc->Scan(Form("Sum$(%s.obj.pt()>0):Sum$(eo.%s.obj.pt()>0):Sum$(%s.obj.pt()):Sum$(%s.obj.pt())-Sum$(eo.%s.obj.pt())",
 		    ts.Data(), ts.Data(), ts.Data(), ts.Data(), ts.Data()),"", "");
    }
  } //> e.tecoTracks.recoT0.txt

}
开发者ID:StoyanStoynev,项目名称:cms-reco-tools,代码行数:32,代码来源:scanDiffRecoTracks.C

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

示例5: darklightcolor

///
/// Copied from TColor::GetColorDark(Int_t n), but customized
/// the 'darkness'.
///
int ColorBuilder::darklightcolor(int n, float scale)
{
	if (n < 0) return -1;

	// Get list of all defined colors
	TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
	Int_t ncolors = colors->GetSize();
	// Get existing color at index n
	TColor *color = 0;
	if (n < ncolors) color = (TColor*)colors->At(n);
	if (!color) return -1;

	// Get the rgb of the the new dark color corresponding to color n
	Float_t r,g,b;
	TColor::HLStoRGB(color->GetHue(), scale*color->GetLight(), color->GetSaturation(), r, g, b);

	// Build the dark color (unless the slot nd is already used)
	Int_t nd = scale<1. ? n+100 : n+150;
	TColor *colord = 0;
	if (nd < ncolors) colord = (TColor*)colors->At(nd);
	if (colord) return nd;
	colord = new TColor(nd,r,g,b);
	colord->SetName(scale<1. ? Form("%s_dark",color->GetName()) : Form("%s_light",color->GetName()));
	colors->AddAtAndExpand(colord,nd);
	return nd;
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:30,代码来源:ColorBuilder.cpp

示例6: bright_colors

void bright_colors(Float_t value=1)
{
  // Notes:
  // you can store the original colors by creating a clone of
  // (TObjArray*)gROOT->GetListOfColors() and restore the colors by
  // assigning the vector with original values to the list of colors
  // that gROOT handles.

  if (value > 5)
  {
    printf("Value %f too high - maximum is 5.\n", value);
    return;
  }
  value *= 0.1f;

  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
  TColor    *color  = 0;
  Float_t    r, g, b;
  for (int i = 0; i < colors->GetSize(); ++i)
  {
    if ((color = dynamic_cast<TColor*>(colors->At(i))) != 0)
    {
      color->GetRGB(r, g, b);
      if (r < 0.01 && g < 0.01 && b < 0.01) continue; // skip black
      if (r > 0.95 && g > 0.95 && b > 0.95) continue; // skip white
      r = TMath::Min(r + value, 1.0f);
      g = TMath::Min(g + value, 1.0f);
      b = TMath::Min(b + value, 1.0f);
      color->SetRGB(r, g, b);
    }
  }

  if (gEve)
    gEve->FullRedraw3D();
}
开发者ID:alisw,项目名称:AliRoot,代码行数:35,代码来源:bright_colors.C

示例7: GetLegendOf

//________________________________________________________
TLegend* GFHistManager::GetLegendOf(Int_t layer, Int_t histoNum)
{
  // if it already exists!
  if(!this->CheckHistNum("AddLegend", layer, histoNum)) return NULL;

  TObjArray* legendsOfLayer = this->MakeLegends(layer);
  TLegend* legend = (legendsOfLayer->GetSize() < histoNum ? 
		     NULL : static_cast<TLegend*>(legendsOfLayer->At(histoNum)));
  return legend;
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:11,代码来源:GFHistManager.C

示例8: VariablePrint1

void VariablePrint1() {
TFile *f = new TFile("/home/francji/data/subsets/small_training_sample/p17_CC_diboson_EqOneTag_EqThreeJet_zero_Topo_small_training_sample.root");
TTree *t = (TTree *) f->Get("TopologicalVariables");
TObjArray *arr = t->GetListOfBranches();
    for (int i = 0; i < arr->GetSize(); i++) {
      char s[1000];
      strcpy(s, arr->At(i)->GetTitle());
      char c = s[strlen(s)-1];
      s[strlen(s)-2] = '\0';
      printf("%i  %s \n", i, s);
    }
}
开发者ID:lamatko,项目名称:root_scripts,代码行数:12,代码来源:VariablePrint.C

示例9: classtype

void D3PDSelector::loadBranch(std::string key )
{
   //std::cout << "Getting List Of Leaves" << std::endl;
   TObjArray* leaves = fChain->GetListOfLeaves();
   //std::cout << "Got List Of Leaves" << std::endl;
   //std::cout << "key " << key << std::endl;
   
   for (int c=0; c<leaves->GetSize(); c++)
   {
      TLeaf* leaf = (TLeaf*)leaves->UncheckedAt(c);
      TLeafObject* leafobj = (TLeafObject*)leaf;

      const char* curbraname = leafobj->GetName();

      //std::cout << "Got Leave " <<  curbraname << std::endl;

      if (strcmp(curbraname, key.c_str()) == 0)
      {
        const char* curtitle = leafobj->GetTypeName();
        std::string classtype(leafobj->ClassName());
        m_types[key] = std::string(curtitle);

        void* address;
 
        //if (m_types[key].find("<") == std::string::npos) //vector type? //old check
        //TLeafElement means it's a pointer to an obect
        //Else its a more primitve type (int, float etc)
        if (classtype.find("TLeafElement") == std::string::npos)
        {
          void* tmpfl = (void* )(new double(0.)); //make sure enough space, so make doube
          address = tmpfl;
        }
        else
        {
          void** tmp = new void*; //works   1
          *tmp = 0;      
          address=tmp;
        }
      
        m_data[key] = (void**)address;
        TBranch* cur_branch = 0;
        m_branches[key] = cur_branch;
        fChain->SetBranchAddress(key.c_str(), m_data[key] , &m_branches[key] );
        //m_branches[key]->GetEntry(m_curentry); //Entry is loaded in loadData method

        return;
      }
   }
   //std::cout << "Got All List Of Leaves" << std::endl;
   //std::cout << "key " << key << std::endl;
   std::cout << "WARNING: Requested variable " << key << " not found. The program might crash now." << std::endl;

}
开发者ID:akanevm,项目名称:HCCRAB3,代码行数:53,代码来源:D3PDSelector.C

示例10: ContourGraph

TGraph* ContourGraph( TH2F* hist,double xmin=16, double xmax=90) {

    //temporary canvas
    TCanvas* MOO = new TCanvas( TString::Format("dummy_canvas_%s", hist->GetName()), "A scan of m_{0} versus m_{12}", 0, 0, 650,640);
    MOO->cd();

    TGraph* gr0 = new TGraph();
    TH2F* h = (TH2F*)hist->Clone();
    TGraph* gr = (TGraph*)gr0->Clone(TString::Format("gr_%s", h->GetName()));

    cout << "==> Will dumb histogram: " << h->GetName() << " into a graph" <<endl;

    h->SetContour( 1 );
    //h->GetXaxis()->SetRangeUser(250,1200);
    h->GetXaxis()->SetRangeUser(xmin, xmax);
    //h->GetYaxis()->SetRangeUser(2,50);

    double pval = CombinationGlob::cl_percent[1];
    std::cout << pval << std::endl; 
    double signif = TMath::NormQuantile(1-pval);
    h->SetContourLevel( 0, signif );
    h->Draw("CONT LIST");
    h->SetDirectory(0);
    gPad->Update();

    TObjArray *contours = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
    Int_t ncontours     = contours->GetSize();
    cout << "Found " << ncontours << " contours " << endl;

    TList *list = (TList*)contours->At(0);
    contours->Print("v");
    if(!list) return NULL;

    gr = (TGraph*)list->First();
    if(!gr) return NULL;

    gr->SetName(TString::Format("gr_%s", hist->GetName()));
    //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->Draw("ALP");

    delete MOO;

    cout << "Generated graph " << gr << " with name " << gr->GetName() << endl;
    return gr;
}
开发者ID:lawrenceleejr,项目名称:ZeroLeptonAnalysis,代码行数:52,代码来源:ContourUtils.C

示例11: SetElectronContainerPrefix

void D3PDSelector::Init(TTree *tree)
{

   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set object pointer
  // Set branch addresses and branch pointers


  std::cout << "INIT" << std::endl;

  SetElectronContainerPrefix("el");
  SetMuonContainerPrefix("mu_staco");
  SetJetContainerPrefix("jet_AntiKt4TopoNewEM");
//  SetJetContainerPrefix("jet_AntiKt4TopoEM");
  //SetPhotonContainerPrefix("ph");

  //Reset intenral data structure to Branch Addresses  
  m_data.clear();
  m_branches.clear();
  m_types.clear();

  if (!tree) return;
  fChain = tree;
  fChain->SetMakeClass(1);
  
  TObjArray* leaves =  tree->GetListOfLeaves();

  for (int c=0; c<leaves->GetSize(); c++)
  {
    TLeaf* leaf = (TLeaf*)leaves->UncheckedAt(c);
    TLeafObject* leafobj = (TLeafObject*)leaf;
  
  
    //TLeafObject* curbra = (TLeafObject*)tor->At(c);
    const char* curbraname = leafobj->GetName();
    const char* curtitle = leafobj->GetTypeName();
    //const char* classn = leafobj->ClassName();
  
    if (m_verbose) 
      std::cout << curbraname << "    " << /*curbraclassName <<"    " << */curtitle << std::endl;
  }

}
开发者ID:akanevm,项目名称:HCCRAB3,代码行数:50,代码来源:D3PDSelector.C

示例12: tokenize

// Helper function to avoid code mess with TString's Tokenize
inline vector<TString> tokenize(TString line, const char* delim=" ") {
  vector<TString> retvec;
  line = line.Strip();
  // Tokenize the string, use blank as delimiter
  TObjArray* tokens = line.Tokenize(delim);
  for (int i=0; i<tokens->GetSize(); i++) {
    // For some reasons Tokenize produces an awfull lot of Null-pointers  
    if (tokens->At(i)!=0) {
      // We need to explicitly cast the array contents to TObjString  
      TString t = dynamic_cast<TObjString *>(tokens->At(i))->GetString();
      retvec.push_back(t);
    }
  }
  return retvec;
}
开发者ID:istaslis,项目名称:pPbmacro,代码行数:16,代码来源:HelperProcess.C

示例13: VariablesPrint

void VariablesPrint() {
TFile *f = new TFile("/work/budvar-clued0/francji/subsets/small_training_sample/p17_CC_diboson_EqOneTag_EqThreeJet_zero_Topo_small_training_sample.root");
TTree *t = (TTree *) f->Get("TopologicalVariables");
TObjArray *arr = t->GetListOfBranches();
int j = 1;
for (int i = 0; i < arr->GetSize(); i++) {
      char s[1000];
      strcpy(s, arr->At(i)->GetTitle());
      char c = s[strlen(s)-1];
      s[strlen(s)-2] = '\0';
      if (c == 'D') {
        printf("%5i  D %s \n", j, s);
        j++;
      } else if (c == 'I') {
        printf("%5i  I %s \n", j, s);
        j++;
      } else {};
      }
}
开发者ID:lamatko,项目名称:root_scripts,代码行数:19,代码来源:VariablesPrint.C

示例14: AddLegend

//_____________________________________________________
void GFHistManager::AddLegend(TLegend* leg, Int_t layer, Int_t histoNum)
{
  // hist and layer must already exist
  if(!this->CheckHistNum("AddLegend", layer, histoNum)) return;

  TObjArray* legendsOfLayer = this->MakeLegends(layer);
  TLegend* legend = (legendsOfLayer->GetSize() < histoNum ? 
		     NULL : static_cast<TLegend*>(legendsOfLayer->At(histoNum)));
  if(legend) {
    this->Error("AddLegend", "legend exists, replacing it");
    delete legend;
  }
  legend = leg;
  legendsOfLayer->AddAtAndExpand(legend, histoNum);

  if(layer < fCanArrays->GetEntriesFast()) {
    this->Update(layer); // if canvas already drawn
  }
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:20,代码来源:GFHistManager.C

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


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