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


C++ TDirectory::FindObjectAny方法代码示例

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


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

示例1: Run

void Run( const char *inFileName, const char *outFileName, 
	  const char *dirname, const char *treeName) {  
  char name[500];
  sprintf(name, "%s.root",inFileName);
  TFile *infile = TFile::Open(name);
  TDirectory *dir = (TDirectory*)infile->FindObjectAny(dirname);
  TTree *tree = (TTree*)dir->FindObjectAny(treeName);
  std::cout << tree << " tree with nentries (tracks): " << tree->GetEntries() << std::endl;
  CalibTree t(tree);
  sprintf(name, "%s_%s_%s.root", outFileName, inFileName, dirname);
  std::string outFile(name);
  t.BookHisto(outFile);

  double cvgs[100], itrs[100]; 
  unsigned int k(0);
  for (; k<20; ++k) {
    double cvg = t.Loop(k);
    itrs[k] = k;
    cvgs[k] = cvg;
    //    if (cvg < 0.00001) break;
  }
  TGraph *g_cvg;
  g_cvg = new TGraph(k, itrs, cvgs);
  t.fout->WriteTObject(g_cvg, "g_cvg");
  std::cout << "Finish looping after " << k << " iterations" << std::endl;
}
开发者ID:tj710,项目名称:TTEmulator,代码行数:26,代码来源:CalibTree.C

示例2: doit

void doit()
{
   TFile* base = new TFile("f.db","recreate");
   TDirectory* a = base->mkdir("a","First Level Dir");
   a->cd();
   TH1D* ha = new TH1D("ha","ha",10,0,1);
   TDirectory* aa = a->mkdir("aa","Second Level Dira");
   aa->cd();
   TH1D* haa = new TH1D("haa","haa",10,0,1);
   
   a->ls();
   
   printf(" a: [email protected] %p  [email protected] %p\n", a,base->FindObjectAny("a"));
   printf("ha: [email protected] %p  [email protected] %p\n",ha,base->FindObjectAny("ha"));
   printf("ha: [email protected] %p  [email protected] %p\n",ha,base->FindObjectAny("a/ha"));
#ifdef ClingWorkAroundMissingImplicitAuto
   TDirectory *k = (TDirectory*)base->FindObjectAny("a");
#else
   k = (TDirectory*)base->FindObjectAny("a");
#endif
   printf("ha: [email protected] %p  [email protected] %p\n",ha,k->FindObjectAny("ha"));
   
   printf("aa: [email protected] %p  [email protected] %p\n",aa,base->FindObjectAny("aa"));
   printf("aa: [email protected] %p  [email protected] %p\n",aa,base->FindObjectAny("a/aa"));
   printf("aa: [email protected] %p  [email protected] %p\n",aa,k->FindObjectAny("aa"));
   
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("aa/haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("a/aa/haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,k->FindObjectAny("haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,k->FindObjectAny("aa/haa"));
#ifdef ClingWorkAroundMissingImplicitAuto
   TDirectory *kk = (TDirectory*)k->FindObjectAny("aa");
#else
   kk = (TDirectory*)k->FindObjectAny("aa");
#endif
   printf("haa: [email protected] %p  [email protected] %p\n",haa,kk->FindObjectAny("haa"));
   
   base->Write();
   
}
开发者ID:jlsalmon,项目名称:roottest,代码行数:41,代码来源:testFindObjectAny.C

示例3: doit2

void doit2()
{
   TFile* base = new TFile("f.db","READ");
   
   TH1D *ha = 0;
   TH1D *haa = 0;
   TDirectory *aa = 0;

#ifdef ClingWorkAroundMissingDynamicScope
   TDirectory *a = (TDirectory*)base->Get("a");
#endif
   a->ls();
   
   printf(" a: [email protected] %p  [email protected] %p\n", a,base->FindObjectAny("a"));
   printf("ha: [email protected] %p  [email protected] %p\n",ha,base->FindObjectAny("ha"));
   printf("ha: [email protected] %p  [email protected] %p\n",ha,base->FindObjectAny("a/ha"));
#ifdef ClingWorkAroundMissingImplicitAuto
   TDirectory *k = (TDirectory*)base->FindObjectAny("a");
#else
   k = (TDirectory*)base->FindObjectAny("a");
#endif
   printf("ha: [email protected] %p  [email protected] %p\n",ha,k->FindObjectAny("ha"));
   
   printf("aa: [email protected] %p  [email protected] %p\n",aa,base->FindObjectAny("aa"));
   printf("aa: [email protected] %p  [email protected] %p\n",aa,base->FindObjectAny("a/aa"));
   printf("aa: [email protected] %p  [email protected] %p\n",aa,k->FindObjectAny("aa"));
   
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("aa/haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,base->FindObjectAny("a/aa/haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,k->FindObjectAny("haa"));
   printf("haa: [email protected] %p  [email protected] %p\n",haa,k->FindObjectAny("aa/haa"));
#ifdef ClingWorkAroundMissingImplicitAuto
   TDirectory *kk = (TDirectory*)k->FindObjectAny("aa");
#else
   kk = (TDirectory*)k->FindObjectAny("aa");
#endif
   printf("haa: [email protected] %p  [email protected] %p\n",haa,kk->FindObjectAny("haa"));
   
}
开发者ID:jlsalmon,项目名称:roottest,代码行数:40,代码来源:testFindObjectAny.C

示例4: testFindObjectAny

int testFindObjectAny() 
{ 
   TDirectory* db = gROOT->mkdir("db","db"); 
   TDirectory* a = db->mkdir("a","a"); 
   TDirectory* aa = a->mkdir("aa","aa"); 
   aa->cd(); 
   TH1D* haa_new = new TH1D("haa","haa",10,0,1); 
   TH1D* haa_find = (TH1D*)db->FindObjectAny("haa");
#ifdef ClingWorkAroundMissingDynamicScope
   TH1D* haa = haa_find;
#endif
   if (!haa) {
      cout << "haa missing\n";
   } else if (haa_new != haa_find) {
      cout << "haa not found correctly!\n";
   }
   
   TFile* base = new TFile("fdb.root","recreate");
#ifdef ClingReinstateRedeclarationAllowed
   TDirectory* a = base->mkdir("a","First Level Dir");
#else
   a = base->mkdir("a","First Level Dir");
#endif
   a->cd();
   TH1D* ha = new TH1D("ha","ha",10,0,1);
#ifdef ClingReinstateRedeclarationAllowed
   TDirectory* aa = a->mkdir("aa","Second Level Dira");
#else
   aa = a->mkdir("aa","Second Level Dira");
#endif
   aa->cd();
#ifdef ClingWorkAroundMissingDynamicScope
   haa = new TH1D("haa","haa",10,0,1);
#else
   TH1D* haa = new TH1D("haa","haa",10,0,1);
#endif
   
   testing(   a, base->FindObjectAny("a"));
   testing(  ha, base->FindObjectAny("ha"));
   testing(  ha,    a->FindObjectAny("ha"));
   testing(  aa, base->FindObjectAny("aa"));
   testing(  aa,    a->FindObjectAny("aa"));
   testing( haa, base->FindObjectAny("haa"));
   testing( haa,    a->FindObjectAny("haa"));
   testing( haa,   aa->FindObjectAny("haa"));   
   base->Write();
   
   delete base;
   base = TFile::Open("fdb.root","READ");
   testing(   0, base->FindObjectAny("a"));
   testing(   0, base->FindObjectAny("ha"));
   a = (TDirectory*)base->FindObjectAny("a");
   testing(   0,    a->FindObjectAny("ha"));
   testing(   0, base->FindObjectAny("aa"));
   testing(   0,    a->FindObjectAny("aa"));
   testing(   0, base->FindObjectAny("haa"));
   testing(   0,    a->FindObjectAny("haa"));
   aa = (TDirectory*)base->FindObjectAny("aa");
   testing(   0,   aa->FindObjectAny("haa"));
   
   return 0;
}
开发者ID:jlsalmon,项目名称:roottest,代码行数:62,代码来源:testFindObjectAny.C

示例5: dumpStg6Results

void dumpStg6Results(string inFile,string outFile, int nEvents = 0,bool useRBM = 1,double theta2Cut = 0.03, bool NoFromStg5 = true,string Stg5Path = "/data/veritas/bzitzer/bootes_1/data/root/")
{
  gROOT->SetBatch(true);
  TH1D* hSigRF = new TH1D("SigDistRF","Significance Distrbution RF",50,-5,5);
  TH1D* hSigCBG = new TH1D("SigDistCBG","Significance Distrbution CBG",50,-5,5);
  
  // Opening files and getting VEGAS objects:
  TFile* f = new TFile(inFile.c_str(),"READ");
  if(!f->IsOpen() )
    {
      cerr << "Problem opening ROOT file!" << endl;
      return;
    }
  TTree* EventTree = (TTree*)gDirectory->Get("EventStatsTree");
  if( EventTree == NULL )
    {
      cout << "No Event Tree!" << endl;
      return;
    }
  TTree* RunTree = (TTree*)gDirectory->Get("RunStatsTree");
  if( RunTree == NULL )
    {
      cout << "No Run Tree!" << endl;
      return;
    }
  VASkyMap* vaMapOn = (VASkyMap*)gDirectory->Get("RingBackgroundModelAnalysis/SkyMapOn");
  VASkyMap* vaMapAlpha = (VASkyMap*)gDirectory->Get("RingBackgroundModelAnalysis/fAlphaMap");
  VACoordinatePair onCenter = vaMapOn->GetCenter();
  VACoordinatePair eventCoord;
  VACoordinatePair trackCoord;
  VACoordinatePair fRootCoord;
  VACoordinatePair sourceCoord;

  // --------------------
  //  Exclusion regions:
  // --------------------
    
  TDirectory* RBMExclusion = (TDirectory*)gDirectory->Get("RingBackgroundModelAnalysis/ExclusionRegions");

  if( RBMExclusion == NULL )
    {
      cerr << "Problem loading the RBM exclusion directory!" << endl;
      return;
    }
  int nRegions = RBMExclusion->GetNkeys();
  VASkyMapExclusionRegion* hSourceExclusion;
  const int tmp = nRegions;
  VASkyMapExclusionRegion* exclList[tmp];
  vector<VASkyMapExclusionRegion*> vaSourceExcl;

  TIter next(RBMExclusion->GetListOfKeys());
  TKey *key;
  int i=0;
  while(key=(TKey*)next())
    {
      hSourceExclusion = (VASkyMapExclusionRegion*)RBMExclusion->FindObjectAny(key->GetName())->Clone();
      if( hSourceExclusion != NULL)
	{
	  if( hSourceExclusion->wasUsed() )
	    {
	      cout << i << endl;
	      exclList[i] = hSourceExclusion;
	      vaSourceExcl.push_back(hSourceExclusion);
	      cout << hSourceExclusion->GetName() << endl;
	      //cout << "Exclusion Center RA: " << hSourceExclusion->center().getRA_J2000_Deg() << endl;
	      cout << "Exclusion Center RA: " << exclList[i]->center().getRA_J2000_Deg() << endl;
	      
	      cout << "Exclusion Center Dec: " << hSourceExclusion->center().getDec_J2000_Deg() << endl;	  
	      cout << "Exclusion Radius: " << hSourceExclusion->radius_Deg() << endl;
	      i++;
	    }
	}
    }
  nRegions = i;
  dumpExcl(exclList,nRegions,outFile);


  double TelLatRad = 5.52828386357865242e-01;
  double TelLongRad = -1.93649167430676461e+00;
  Float_t EffArea,EnergyGeV,El,Az;
  double RA,Dec;
  double RATrack,DecTrack;
  double DayNS;
  UInt_t MJD;
  UInt_t RunID;
  Float_t El_track,Az_track;
  Float_t El_check,Az_check;
  double MJDDbl;
  Double_t W;
  Double_t liveTime;
  Double_t PsiEventTree;

  int NumRuns = RunTree->GetEntries(); 
  Bool_t IsOn,IsOff;
  double Noise;
  Float_t RA_fRoot,Dec_fRoot;

  EventTree->SetBranchAddress("RunNum",&RunID);
  EventTree->SetBranchAddress("Azimuth",&Az);
  EventTree->SetBranchAddress("Elevation",&El);
//.........这里部分代码省略.........
开发者ID:mbuchove,项目名称:analysis-tools-m,代码行数:101,代码来源:dumpStg6Results.C

示例6: ST_Monitoring_Eff

// File: ST_Monitoring_Efficiency.C
// Last Modified: 05/27/2015
// Creator: Mahmoud Kamel [email protected]
// Purpose: Displaying histograms for online monitoring purposes
void ST_Monitoring_Eff () {
  // Define the directory that contains the histograms
  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("st_tracking");
  if(dir) dir->cd();
  // Grab 1D histograms 
  TH1D *MacropEff     = (TH1D*)dir->FindObjectAny("MacropEff");
  TH1D *MacropEff_adc     = (TH1D*)dir->FindObjectAny("MacropEff_adc");
  TH1D *h_phi_sec_pred_hit_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_pred_hit_cntr");
  TH1D *h_phi_sec_hit_cntr  = (TH1D*)dir->FindObjectAny("h_phi_sec_hit_cntr");
  TH1D *h_phi_sec_adc_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_adc_cntr");

  // get Binomial errors in an efficiency plot
  // hit object efficiency
  h_phi_sec_hit_cntr->Sumw2();
  h_phi_sec_pred_hit_cntr->Sumw2();
  MacropEff->Sumw2();
  MacropEff->Divide(h_phi_sec_hit_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");

  // adc efficiency
  h_phi_sec_adc_cntr->Sumw2();
  MacropEff_adc->Sumw2();
  MacropEff_adc->Divide(h_phi_sec_adc_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");

  //Create the canvas
  if(gPad == NULL)
    {
      TCanvas *c1 = new TCanvas("c1","Start Counter 1D Histograms", 200, 10, 600, 480);
      c1->cd(0);
      c1->Draw();
      c1->Update();
    }
  if(!gPad) return;
  TCanvas *c1 = gPad->GetCanvas();
  c1->Divide(2,1);
  // ST ADC Efficiency histogram
  c1->cd(1);
  gStyle->SetOptStat(0);
  gStyle->SetErrorX(0); 
  gPad->SetTicks();
  gPad->SetGrid();
  if (MacropEff_adc) {
   MacropEff_adc->Draw("E1");
   MacropEff_adc->SetMarkerStyle(21);
   MacropEff_adc->SetMarkerSize(1.5);
   MacropEff_adc->SetMarkerColor(4.0);
   MacropEff_adc->SetAxisRange(0., 1.,"Y");
   MacropEff_adc->GetYaxis()->SetTitleOffset(1.26);
   Double_t TWA_adc=0;
   Double_t sumE_adc=0;
   Double_t Final_adc=0;
   Double_t error_adc=0.;
   Double_t BC_adc=0.;
   Double_t WA_adc=0.;
   //Double_t Final_adc=0.;
   for (int i = 0; i < 30; i++)
     {
       error_adc =   MacropEff_adc->GetBinError(i+2);
       sumE_adc = sumE_adc + error_adc;
       BC_adc =   MacropEff_adc->GetBinContent(i+2);
       WA_adc = BC_adc*error_adc;
       TWA_adc = TWA_adc + WA_adc ;
       Final_adc = TWA_adc/sumE_adc;
       // cout << "error_adc =  "<< error_adc << endl;
       // cout << "BC_adc =  "<< BC_adc << endl;
       // cout << "Final_adc =  "<< Final_adc << endl;
     } 
   TLine *line = new TLine(1,Final_adc,30,Final_adc);
   line->SetLineWidth(3);
   line->SetLineColor(2);
   //Write the eff value on the histogram 
   char tFinal_adc[40];
   char terror_adc[40];
   sprintf(tFinal_adc,"ADC Efficiency (%%) = %g",Final_adc*100);
   sprintf(terror_adc,"ADC Efficiency error (%%) = %g",error_adc*100);
   line->Draw();
   TPaveLabel *p = new TPaveLabel(0.3,0.6,0.7,0.7,tFinal_adc,"brNDC");
   p->Draw();
   TPaveLabel *p1 = new TPaveLabel(0.3,0.5,0.7,0.6,terror_adc,"brNDC");
   p1->Draw();
  }
  // ST Hit Efficiency histogram
  c1->cd(2);
  gPad->SetTicks();
  gPad->SetGrid();
  if (MacropEff) {
    MacropEff->Draw("E1");
    MacropEff->SetMarkerStyle(21);
    MacropEff->SetMarkerSize(1.5);
    MacropEff->SetMarkerColor(4.0);
    MacropEff->SetAxisRange(0., 1.,"Y");
    MacropEff->GetYaxis()->SetTitleOffset(1.26);
    Double_t TWA=0;
    Double_t sumE=0;
    Double_t Final=0; 
    Double_t error=0.;
    Double_t BC=0.;
//.........这里部分代码省略.........
开发者ID:JeffersonLab,项目名称:sim-recon,代码行数:101,代码来源:ST_Monitoring_Eff.C


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