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


C++ TKey::ReadObj方法代码示例

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


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

示例1: initialize

  void initialize( const char* countdbfn = "counts.root" )
  {
    XSWeightTool::update( "Xsection8TeV_bkg_v4.txt" );
    XSWeightTool::update( "Xsection8TeV_sig_v4.txt" );
    // XSWeightTool::print();

    using namespace std;

    TFile* f = TFile::Open( countdbfn, "read" );
    if( f == NULL || f->IsZombie() )
    {
      return;
    }

    TIter next( f->GetListOfKeys() ); 
    TKey *key;
    int nhist = 0;
    while( (key = (TKey*)next()) ) {
      nhist++;
      // cout << "Key " << nhist << endl;
      // cout << " Classname " << key->GetClassName() << endl;
      // cout << " Title " <<key->GetTitle() << endl;
      if( key->ReadObj()->InheritsFrom( TH1::Class() ) )
      {
	TH1* h = (TH1*)( key->ReadObj() );
	long run_num = TString( h->GetName() ).Atoi();
	num_events[run_num] = h->GetBinContent( 1 );
	// cout << " Run, # of events : " << run_num << ", " <<  h->GetBinContent( 21 ) << endl;
      }
    }
    // cout << "Done" << endl;
  }
开发者ID:dtmori,项目名称:HWW,代码行数:32,代码来源:mcweights.c

示例2: parseStructure

void parseStructure(TDirectory* td1, TDirectory* td2) {
  string dir_name = td1->GetTitle();
  string dir_path = td1->GetPath();
  //  cout << "ParseStructure: dir_name=" << dir_name << ", dir_path=" << dir_path << endl;
  dir_path = dir_path.substr(dir_path.find("DQMData")+8);
  setPath(dir_path, td2);
  TIter next(td1->GetListOfKeys());
  TKey *key;
  while  ( (key = dynamic_cast<TKey*>(next())) ) 
    {
      string clName(key->GetClassName());
      if (clName == "TDirectoryFile") {
        string name(key->GetName());
        if (name.find("forward_") == string::npos  && 
            name.find("backward_") == string::npos &&
            name.find("ring_") == string::npos) {
	  td1->cd(name.c_str());
	  TDirectory *curr_dir = gDirectory; // dynamic_cast<TDirectory*>(obj);
	  parseStructure(curr_dir, td2);
        } else return;
      } else if (clName == "TObjString") {
	//	cout << clName << "  " << key->GetName() << endl;
        TObject* obj = key->ReadObj();
        obj->Write();
      } else {
	key->ReadObj();
      }
    }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:29,代码来源:sistrip_reduce_file.C

示例3: network

// input: - Input file (result from TMVA),
//        - use of TMVA plotting TStyle
void network( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
{
   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );

   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );  
   Network_GFile = file;

   TKey* mkey = TMVAGlob::FindMethod("MLP"); 
   if (mkey==0) {
      cout << "Could not locate directory MLP in file " << fin << endl;
      return;
   }
   TDirectory *dir = (TDirectory *)mkey->ReadObj();
   dir->cd();  
   TList titles;
   UInt_t ni = TMVAGlob::GetListOfTitles( dir, titles );
   if (ni==0) {
      cout << "No titles found for Method_MLP" << endl;
      return;
   }
   TIter nextTitle(&titles);
   TKey *titkey;
   TDirectory *titDir;
   while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
      titDir = (TDirectory *)titkey->ReadObj();
      cout << "Drawing title: " << titDir->GetName() << endl;
      draw_network(titDir);
   }
}
开发者ID:TopBrussels,项目名称:TopTreeAnalysisBase,代码行数:33,代码来源:network.C

示例4: singleFile

void singleFile(TString name, double scalingFactor){
  // get the files
  loadingFiles(name); 
  // ---------------------------------------
  // !!! definition of output file(name) !!!
  // ---------------------------------------
  std::string path = (string)(name);
  size_t separator = path.find_last_of("/");
  TString file = (TString)(path.substr(separator+1));
  //  std::cout << "path: " << path << std::endl;
  //  std::cout << "separator: " << separator << std::endl;
  //  std::cout << "file: " << file << std::endl;

  TString outputfile="./diffXSecFromSignal/analysisRootFilesL1CorrPU/"+file+".root";
  TFile f(outputfile, "recreate");
  std::cout << "output file: " << outputfile << std::endl;
  std::cout << "scaling factor: " << setprecision(9) << fixed << scalingFactor;
  // ---------------------------------------------------------
  // !!! list of plots you want to combine !!!
  // and their directories within the input samples
  // example: addAndWeight("MyPlotFolder", "MyPlot", luminosity, f)
  // ---------------------------------------------------------
  TString folder ="";
  TString plot = "";
  // go to file
  files_[0]->cd();
  // loop objects in file
  TIter fileIterator(gDirectory->GetListOfKeys());
  TKey *fileKey;
  while( (fileKey = (TKey*)fileIterator()) ) {
    TObject *fileObject = fileKey->ReadObj(); 
    // check if object is a directory
    if(fileObject->InheritsFrom("TDirectory")){
      folder = (TString)fileObject->GetName();
      std::cout << std::endl << " - folder: " << folder << std::endl << "   plots: ";
      // go to directory
      ((TDirectory*)fileObject)->cd();
      // loop objects in directory
      TIter folderIterator(gDirectory->GetListOfKeys());
      TKey *folderKey;
      while( (folderKey = (TKey*)folderIterator()) ) {
	TObject *folderObject = folderKey->ReadObj(); 
	// check if object is a TH1 or TH2
	if( (folderObject->InheritsFrom("TH1")) || (folderObject->InheritsFrom("TH2"))){
	  plot = folderObject->GetName();
	  addAndWeight(folder, plot, f, scalingFactor);
	}
      }
    }
  }
  files_[0]->Close();
  

  f.Close();
}
开发者ID:eschliec,项目名称:TopAnalysis,代码行数:55,代码来源:combineAndWeightAnalysisFiles.C

示例5: FindPeaks

//________________________________________________________________________________
void FindPeaks(Int_t np=10) {
  TString Out("Results.");
  Out += gSystem->BaseName(gDirectory->GetName());
  Out.ReplaceAll(".root","");
  Out.ReplaceAll(" ","");
  out.open(Out, ios::out);
  TIter nextkey(gDirectory->GetListOfKeys() );
  TKey *key;
  Int_t i = 0;
  Int_t nhists = 0;
  while ((key = (TKey*) nextkey())) {
    TObject *obj = key->ReadObj();
    if (! obj->IsA()->InheritsFrom( "TH1" ) ) continue;
    TH1 *h1 = (TH1*)obj;
    if (h1->GetEntries() < 1000) continue;
    nhists++;
  }
  Int_t nxy = nhists;
  Int_t nx =  (Int_t) TMath::Sqrt(nxy) + 1;
  Int_t ny = nxy/nx + 1;
  c2 = new TCanvas("Anodes","Anodes");
  c2->Divide(nx,ny);
  nextkey.Reset();
  Int_t histNo = 1;
  while ((key = (TKey*) nextkey())) {
    TObject *obj = key->ReadObj();
    if (! obj->IsA()->InheritsFrom( "TH1" ) ) continue;
    if ( obj->IsA()->InheritsFrom( "TH1C" ) ||
	 obj->IsA()->InheritsFrom( "TH1S" ) ||
	 obj->IsA()->InheritsFrom( "TH1I" ) ||
	 obj->IsA()->InheritsFrom( "TH1F" ) ) {
      cout << "Found histogram " << obj->GetName() << endl;
      TH1 *h1 = (TH1*)obj;
      if (h1->GetEntries() < 1000) {
	TString LineH("  {\"");  LineH +=  h1->GetName(); LineH += "\"";
	TString Line("");
	LineH +=  ",-99";
	for (Int_t p = 0; p < np; p++) Line += ",0,0";
	Line += "},// dead";
	cout << LineH << Line << endl;
	out  << LineH << Line << endl;
	continue;
      }
      peaks(h1,np,histNo);
      histNo++;
      //      break;
      if (i < 99) {
	cout << "Type something" << endl;
	cin >> i;
	if (i <= 0) break;
      }
    }
开发者ID:star-bnl,项目名称:star-svt,代码行数:53,代码来源:FindPeaks.C

示例6: main

int main(int argc, char **argv){
    if (argc<2) {
        cout<<"usage: inpector <filename> "<<endl;
        return 0;
    }

    vector<mTree> m_trees;
    
    string fn = argv[1];
    TFile *f = TFile::Open(fn.c_str());
    
    TIter nextkey( f->GetListOfKeys() );
    TKey *key;
    while ( (key = (TKey*)nextkey())) {
        TObject *obj = key->ReadObj();
        if ( obj->IsA()->InheritsFrom( "TTree" ) ) {
            TTree *tree = (TTree*)f->Get(obj->GetName());
            int exist=0;
            for(vector<mTree>::iterator i=m_trees.begin();i!=m_trees.end();i++)
                if (obj->GetName()==(*i).name) exist=1;
            if (!exist) m_trees.push_back(mTree(tree));
        }
    }
    cout<<m_trees.size()<<endl;
    for (vector<mTree>::iterator it = m_trees.begin();it != m_trees.end(); it++)
        it->print();
f->Close();        
    return 0;
}
开发者ID:DHTC-Tools,项目名称:UC3,代码行数:29,代码来源:inspector.C

示例7: GetListOfJobs

   UInt_t GetListOfJobs( TFile* file, TList& jobdirs)
   {
      // get a list of all jobs in all method directories
      // based on ideas by Peter and Joerg found in macro deviations.C
      TIter next(file->GetListOfKeys());
      TKey *key(0);   
      while ((key = (TKey*)next())) {
         
         if (TString(key->GetName()).BeginsWith("Method_")) {
            if (gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory")) {

               TDirectory* mDir = (TDirectory*)key->ReadObj();
               
               TIter keyIt(mDir->GetListOfKeys());
               TKey *jobkey;
               while ((jobkey = (TKey*)keyIt())) {
                  if (!gROOT->GetClass(jobkey->GetClassName())->InheritsFrom("TDirectory")) continue;
                  
                  TDirectory *jobDir = (TDirectory *)jobkey->ReadObj();
                  cout << "jobdir name  " << jobDir->GetName() << endl;
                  jobdirs.Add(jobDir);
               }
            }
         }
      }
      return jobdirs.GetSize();
   }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:27,代码来源:tmvaglob.C

示例8: CopyDir

void CopyDir(TDirectory *source) {
   //copy all objects and subdirs of directory source as a subdir of the current directory   
   source->ls();
   TDirectory *savdir = gDirectory;
   TDirectory *adir = savdir->mkdir(source->GetName());
   adir->cd();
   //loop on all entries of this directory
   TKey *key;
   TIter nextkey(source->GetListOfKeys());
   while ((key = (TKey*)nextkey())) {
      const char *classname = key->GetClassName();
      TClass *cl = gROOT->GetClass(classname);
      if (!cl) continue;
      if (cl->InheritsFrom(TDirectory::Class())) {
         source->cd(key->GetName());
         TDirectory *subdir = gDirectory;
         adir->cd();
         CopyDir(subdir);
         adir->cd();
      } else if (cl->InheritsFrom(TTree::Class())) {
         TTree *T = (TTree*)source->Get(key->GetName());
         adir->cd();
         TTree *newT = T->CloneTree(-1,"fast");
         newT->Write();
      } else {
         source->cd();
         TObject *obj = key->ReadObj();
         adir->cd();
         obj->Write();
         delete obj;
     }
  }
  adir->SaveSelf(kTRUE);
  savdir->cd();
}
开发者ID:fcostanz,项目名称:StopAnalysis,代码行数:35,代码来源:mergeFiles.C

示例9: efficiencies

void efficiencies( TString fin = "TMVA.root", Int_t type = 2, Bool_t useTMVAStyle = kTRUE )
{
   // argument: type = 1 --> plot efficiency(B) versus eff(S)
   //           type = 2 --> plot rejection (B) versus efficiency (S)
  
   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );

   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );  

   // check if multi-cut MVA or only one set of MVAs
   Bool_t multiMVA=kFALSE;
   TIter nextDir(file->GetListOfKeys());
   TKey *key;
   // loop over all directories and check if
   // one contains the key word 'multicutMVA'
   while ((key = (TKey*)nextDir())) {
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TDirectory")) continue;    
      TDirectory *d = (TDirectory*)key->ReadObj();    
      TString path(d->GetPath());
      if (path.Contains("multicutMVA")){         
         multiMVA=kTRUE;
         plot_efficiencies( file, type, d );
      }
   }
   plot_efficiencies( file, type, gDirectory );

   return;
}
开发者ID:ETHZ,项目名称:ASAnalysis,代码行数:31,代码来源:efficiencies.C

示例10: draw_test

void draw_test(const char* infile)
{
    TFile *filein=new TFile(infile);

    TDirectory* dir_ref=filein->GetDirectory("reference");
    if(!dir_ref){
        printf("error!can't get \"reference\" in %s\n",filein->GetName());
        exit(1);
    }

    TList *keys=dir_ref->GetListOfKeys();
    std::cout<< "total run numbers:"<<keys->GetSize()<<std::endl;

    TH1F *hist=new TH1F("hist","hist",1000,0.98,1.02);
    std::vector<PTAnaPMTRefRaw*> raws;
    TKey *key;
    TIter next(keys);
    Int_t counter=0;
    if(keys){
        while (key=(TKey*)next()) {
            raws.push_back(dynamic_cast<PTAnaPMTRefRaw*>(key->ReadObj()));
            std::cout<<raws[counter]->GetName()<<std::endl;
            counter++;
        }
    }
    else {
        std::cout<< "Error reading references"<<std::endl;
    }

    ///
    //std::vector<int,double> averages;
    std::map<int,TArrayD>  arrays;
    std::map<int,PTAnaPMTFitData>::iterator it;
    for(it=raws[0]->fLEDCalibData.begin();it!=raws[0]->fLEDCalibData.end();it++){
        if(it->second.IsValid()){
            for(int i=0;i<counter;i++){
                if(i==0){
                    arrays[it->first].Set(counter);
                }
                arrays[it->first].AddAt(raws[i]->fLEDCalibData[it->first].fDy8Mean,i);
            }
        }
    }
    std::cout<<"Total tested amplitudes:"<<raws[0]->fLEDCalibData.size()<<std::endl;
    std::cout<<"Valid tested amplitudes:"<<arrays.size()<<std::endl;

    //
    std::map<int,TArrayD>::iterator it2;
    for(it2=arrays.begin();it2!=arrays.end();it2++){
        //if(700==PTAnaBase::DecodeVoltage(it2->first)){
            for(int i=0;i<counter;i++){
                hist->Fill(it2->second.At(i)/it2->second.GetSum()*counter);
            }
        //}
    }
    hist->SetDirectory(0);
    hist->Draw();

    delete filein;
}
开发者ID:ufan,项目名称:pmt_analysis,代码行数:60,代码来源:draw_test.C

示例11: likelihoodrefs

void likelihoodrefs( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
{
   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );
  
   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );  

   // get all titles of the method likelihood
   TList titles;
   TString metlike="Method_Likelihood";
   UInt_t ninst = TMVAGlob::GetListOfTitles(metlike,titles);
   if (ninst==0) {
      cout << "Could not locate directory 'Method_Likelihood' in file " << fin << endl;
      return;
   }
   // loop over all titles
   TIter keyIter(&titles);
   TDirectory *lhdir;
   TKey *key;
   while ((key = TMVAGlob::NextKey(keyIter,"TDirectory"))) {
      lhdir = (TDirectory *)key->ReadObj();
      likelihoodrefs( lhdir );
   }
}
开发者ID:gasperkm,项目名称:corsika-offline-analysis-tool,代码行数:25,代码来源:likelihoodrefs.C

示例12: rulevisHists

// This macro plots the distributions of the different input variables overlaid on
// the sum of importance per bin.
// The scale goes from violett (no importance) to red (high importance).
// Areas where many important rules are active, will thus be very red.
//
// input: - Input file (result from TMVA),
//        - normal/decorrelated/PCA
//        - use of TMVA plotting TStyle
void rulevisHists( TString fin = "TMVA.root", TMVAGlob::TypeOfPlot type = TMVAGlob::kNormal, bool useTMVAStyle=kTRUE )
{
   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );
   
   // checks if file with name "fin" is already open, and if not opens one
   TFile *file = TMVAGlob::OpenFile( fin );

   // get all titles of the method rulefit
   TList titles;
   UInt_t ninst = TMVAGlob::GetListOfTitles("Method_RuleFit",titles);
   if (ninst==0) return;

   // get top dir containing all hists of the variables
   TDirectory* vardir = TMVAGlob::GetInputVariablesDir( type );
   if (vardir==0) return;

   TDirectory* corrdir = TMVAGlob::GetCorrelationPlotsDir( type, vardir );
   if (corrdir==0) return;

   // loop over all titles
   TIter keyIter(&titles);
   TDirectory *rfdir;
   TKey *rfkey;
   while ((rfkey = TMVAGlob::NextKey(keyIter,"TDirectory"))) {
      rfdir = (TDirectory *)rfkey->ReadObj();
      rulevisHists( rfdir, vardir, corrdir, type );
   }
}
开发者ID:aatos,项目名称:chep09tmva,代码行数:37,代码来源:rulevisHists.C

示例13: getDistHistogram

void getDistHistogram(TFile *f1, const char *type, const char *dist, TH1D *h1)
{
  
  char dir[20];
  sprintf(dir,"%s/%s",dist,type);
  
  f1->cd(dir);
  
  char name[20];
  sprintf(name,"%s_%d",dist,1);
  
  TObject *obj = new TObject();
  TKey *key = gDirectory->FindKey(name);
  obj = key->ReadObj();
  
  if(obj != NULL) {
    h1 = (TH1D*)obj;
  }
  else { print_message("Error: histogram not found"); exit(1); }
  
  delete obj;
  
  ///

}
开发者ID:andres0sorio,项目名称:CMSWork,代码行数:25,代码来源:Utilities.C

示例14: read_histograms

void read_histograms(TString file){
    
    TIter nextkey(fName[file]->GetListOfKeys());
    TKey *key;
    
    while((key=(TKey*)nextkey())){
        TString className=key->ReadObj()->ClassName();
        TString keyName=key->GetName();
        if(className=="TH1F" && (keyName.Contains("EventCategories") )){
            TH1F *h=(TH1F*)key->ReadObj();
            h->SetStats(kFALSE);
            hName[h->GetName()+file]=h;
        }
    }
    
}
开发者ID:btcarlso,项目名称:UserCode,代码行数:16,代码来源:stealth_plots.c

示例15: th2polyUSA

void th2polyUSA()
{
   Int_t i, bin;
   const Int_t nx = 48;
   char *states [nx] = {
      "alabama",      "arizona",        "arkansas",       "california",
      "colorado",     "connecticut",    "delaware",       "florida",
      "georgia",      "idaho",          "illinois",       "indiana",
      "iowa",         "kansas",         "kentucky",       "louisiana",
      "maine",        "maryland",       "massachusetts",  "michigan",
      "minnesota",    "mississippi",    "missouri",       "montana",
      "nebraska",     "nevada",         "new_hampshire",  "new_jersey",
      "new_mexico",   "new_york",       "north_carolina", "north_dakota",
      "ohio",         "oklahoma",       "oregon",         "pennsylvania",
      "rhode_island", "south_carolina", "south_dakota",   "tennessee",
      "texas",        "utah",           "vermont",        "virginia",
      "washington",   "west_virginia",  "wisconsin",      "wyoming"
   };
   Float_t pop[nx] = {
    4708708, 6595778,  2889450, 36961664, 5024748,  3518288,  885122, 18537969,
    9829211, 1545801, 12910409,  6423113, 3007856,  2818747, 4314113,  4492076,
    1318301, 5699478,  6593587,  9969727, 5266214,  2951996, 5987580,   974989,
    1796619, 2643085,  1324575,  8707739, 2009671, 19541453, 9380884,   646844,
   11542645, 3687050,  3825657, 12604767, 1053209,  4561242,  812383,  6296254,
   24782302, 2784572,   621760,  7882590, 6664195,  1819777, 5654774,   544270
   };

   gStyle->SetCanvasPreferGL(true);
   TCanvas *usa = new TCanvas("USA", "USA");
   usa->ToggleEventStatus();
   Double_t lon1 = -130;
   Double_t lon2 = -65;
   Double_t lat1 = 24;
   Double_t lat2 = 50;
   TH2Poly *p = new TH2Poly("USA","USA Population",lon1,lon2,lat1,lat2);

   TFile *f;
   f = TFile::Open("http://root.cern.ch/files/usa.root");

   // Define the TH2Poly bins.
   TMultiGraph *mg;
   TKey *key;
   TIter nextkey(gDirectory->GetListOfKeys());
   while (key = (TKey*)nextkey()) {
      obj = key->ReadObj();
      if (obj->InheritsFrom("TMultiGraph")) {
         mg = (TMultiGraph*)obj;
         bin = p->AddBin(mg);
      }
   }

   // Fill TH2Poly.
   for (i=0; i<nx; i++) p->Fill(states[i], pop[i]);

   gStyle->SetOptStat(11);
   gStyle->SetPalette(1);
   p->Draw("gllego");
}
开发者ID:My-Source,项目名称:root,代码行数:58,代码来源:th2polyUSA.C


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