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


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

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


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

示例1: validateInput

void validateInput(const char* filename, int level=0)
{
  TFile* file = new TFile(filename, "update");
  TIter nextDirectory(file->GetListOfKeys());
  TKey* idir;
  while((idir = (TKey*)nextDirectory())){
    file->cd();
    if( idir->IsFolder() ){
      if( level>-1 ){ std::cout << "Found directory: " << idir->GetName() << std::endl; }
      file->cd(idir->GetName());
      validateFolder(file, idir->GetName(), level);
    }
    else{
      if( level> 0 ){ std::cout << "Found histogram: " << idir->GetName() << std::endl; }
      if( level>-1 ){ 
	TH1F* h = (TH1F*)file->Get(idir->GetName());
	if(h->Integral() == 0){
	  std::cout << "----- E R R O R ----- : histogram has 0 integral please fix this: --> " << idir->GetName() << std::endl; 
	}
      }
    }
  }
  file->Close();
  return;
}
开发者ID:JehadMousa,项目名称:HiggsAnalysis-HiggsToTauTau,代码行数:25,代码来源:validateInput.C

示例2: next

std::vector<std::string>
signalList(const char* dirName="", const char* pattern="", unsigned int debug=0)
{
  std::vector<std::string> histnames;
  TIter next(gDirectory->GetListOfKeys());
  TKey* iobj;
  unsigned int idx=0;
  while((iobj = (TKey*)next())){
    if(iobj->IsFolder()) continue;
    if(debug>2){ std::cout << "[" << ++idx << "] ...Found object: " << iobj->GetName() << " of type: " << iobj->GetClassName() << std::endl; }
    std::string fullpath(dirName); 
    fullpath += fullpath == std::string("") ? "" : "/"; fullpath += iobj->GetName();
    // why does \\w*_\\d+ not work to catch them all?!?
    if(std::string(pattern).empty()){
      std::map<const char*, const char*> dict = httDictionary();
      for(std::map<const char*, const char*>::const_iterator name = dict.begin(); name!=dict.end(); ++name){
	if(match(iobj->GetName(), (char*)name->first)){
	  histnames.push_back(fullpath);
	}
      }
    }
    else if(!std::string(pattern).empty() && match(iobj->GetName(), (char*)pattern)){
      histnames.push_back(fullpath);
    }
  }
  return histnames;
}
开发者ID:JehadMousa,项目名称:HiggsAnalysis-HiggsToTauTau,代码行数:27,代码来源:rescale2SM4.C

示例3: next

std::pair<TH3F*,TH3F*> getEffHists(const char *file, const char *dirC, 
				     const char *histN, const char *histD){

     TFile *efile = new TFile(file,"read");
     TDirectoryFile *efileDIR = (TDirectoryFile*) efile->GetDirectory(dirC);

     TIter next(efileDIR->GetListOfKeys());
     TKey *key;

     Char_t name[100];

     TH3F *hpneff3d=0;
     TH3F *hpdeff3d=0;

     while ((key=(TKey*)next())) {
	sprintf(name,"%s",key->GetName());
	if(strcmp((key->GetName()),(histN))==0){
	  //cout<<"[getEffHists] Your numerator for Eff "<<name<<endl; 
	   hpneff3d = (TH3F*) efileDIR->Get(name);
	}
	if(strcmp((key->GetName()),(histD))==0){
	  //cout<<"[getEffHists] Your denominator for Eff "<<name<<endl; 
	   hpdeff3d = (TH3F*) efileDIR->Get(name);
	}
     }

     //efileDIR->Close(); 
     //efile->Close(); 
     return std::pair<TH3F*,TH3F*>(hpneff3d,hpdeff3d);
  }
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:30,代码来源:HiCorrectTypeOneNSave.C

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

示例5: stripTrees

int stripTrees(char* filename = "all.root") {
  
  char outfilename[100];
  std::string filenameString(filename);
  std::cout << filenameString.size() << std::endl; 
  std::string filenameStripped = filenameString.substr(filenameString.size()-5, filenameString.size());
  //  filenameStripped.erase(filenameStripped
  sprintf(outfilename, "%s_histograms.root", filenameString.c_str());

  std::vector<TTree*> trees;
  std::vector<TH1F*> th1fs;
  std::vector<TH2F*> th2fs;
  std::vector<TProfile*> tprofiles;

  TFile* f = new TFile(filename);

  // Create an iterator on the list of keys
  TIter nextTopLevelKey = NULL;
  nextTopLevelKey=(f->GetListOfKeys());
  
  TKey *keyTopLevel;
  while (keyTopLevel = (TKey*)nextTopLevelKey()) {
    
    TString name(keyTopLevel->GetName());
    TString className(keyTopLevel->GetClassName());
    
    if ((className.CompareTo("TTree") != 0) || 
	((name.CompareTo("plotvariables") == 0) || (name.CompareTo("inputfiles") == 0))) {
      std::cout << "Adding " << keyTopLevel->GetName() << std::endl;
      
      if (className.CompareTo("TTree") == 0)
	trees.push_back((TTree*) f->Get(name));
      else if (className.CompareTo("TH1F") == 0)
	th1fs.push_back((TH1F*) f->Get(name));
      else if (className.CompareTo("TH2F") == 0)
	th2fs.push_back((TH2F*) f->Get(name));
      else if (className.CompareTo("TProfile") == 0)
	tprofiles.push_back((TProfile*) f->Get(name));
    }
  }

  TFile* out = new TFile(outfilename, "recreate");
  out->cd();
  for (unsigned int i=0; i<trees.size(); i++) 
    trees[i]->Write();

  for (unsigned int i=0; i<th1fs.size(); i++) 
    th1fs[i]->Write();

  for (unsigned int i=0; i<th2fs.size(); i++) 
    th2fs[i]->Write();

  for (unsigned int i=0; i<tprofiles.size(); i++) 
    tprofiles[i]->Write();

  out->Close();
  
  return 0;
}
开发者ID:ArnabPurohit,项目名称:h2gglobe,代码行数:59,代码来源:stripTrees.C

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

示例7: regexXY

void
plotMultidimFit(const char* filename, const char* channel, int mass=125, bool temp_=false, bool log_=false, std::string dataset_="CMS Preliminary,  H#rightarrow#tau#tau,  4.9 fb^{-1} at 7 TeV, 19.4 fb^{-1} at 8 TeV", std::string xaxis_="#kappa_{V}", std::string yaxis_="#kappa_{F}", bool mssm_=false)
{
  TFile* file = TFile::Open(filename);
  TString style = temp_ ? "graph" : "filled";

  // retrieve TGraphs from file
  TH2F* plot2D;
  TRegexp regex2D(TString::Format("plot2D_%d_*", mass));
  TGraph* bestfit;
  TRegexp regexXY(TString::Format("bestfit_%d_*", mass));
  std::vector<TGraph*> graph68;
  TRegexp regex68(TString::Format("%s68_%d_*", style.Data(), mass));
  std::vector<TGraph*> graph95;
  TRegexp regex95(TString::Format("%s95_%d_*", style.Data(), mass));

  file->cd(channel);
  TIter next(gDirectory->GetListOfKeys());
  TKey* iobj;
  while((iobj = (TKey*)next())){
    TString obj(iobj->GetName());
    if(obj.Contains(regex2D)){
      plot2D = (TH2F*)file->Get(TString::Format("%s/%s", channel, obj.Data()));
    }
    if(obj.Contains(regexXY)){
      bestfit = (TGraph*)file->Get(TString::Format("%s/%s", channel, obj.Data()));
    }
    if(obj.Contains(regex68)){
      std::cout << " ...found object: " << iobj->GetName() << std::endl; 
      graph68.push_back((TGraph*)file->Get(TString::Format("%s/%s", channel, obj.Data())));
    }
    if(obj.Contains(regex95)){
      std::cout << " ...found object: " << iobj->GetName() << std::endl; 
      graph95.push_back((TGraph*)file->Get(TString::Format("%s/%s", channel, obj.Data())));
    }
  }
  //return;

  // set up styles
  SetStyle();
  // do the plotting 
  TCanvas canv = TCanvas("canv", "Limits", 600, 600);
  std::string masslabel = mssm_ ? std::string("m_{#phi}") : std::string("m_{H}");
  plotting2DScan(canv, plot2D, graph95 , graph68 , bestfit, xaxis_, yaxis_, masslabel, mass, -1, -1, -1, -1, temp_, log_); 
  /// setup the CMS Preliminary
  CMSPrelim(dataset_.c_str(), "", 0.145, 0.835);
  // write results to files
  canv.Print(std::string(channel).append("_scan2D").append(".png").c_str());
  canv.Print(std::string(channel).append("_scan2D").append(".pdf").c_str()); 
  canv.Print(std::string(channel).append("_scan2D").append(".eps").c_str()); 
  return;
}
开发者ID:JehadMousa,项目名称:HiggsAnalysis-HiggsToTauTau,代码行数:52,代码来源:plotMultidimFit.C

示例8: GetNumberOfInputVariables

 Int_t GetNumberOfInputVariables( TDirectory *dir )
 {
    TIter next(dir->GetListOfKeys());
    TKey* key    = 0;
    Int_t noVars = 0;
       
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;
       
       // count number of variables (signal is sufficient), exclude target(s)
       if (TString(key->GetName()).Contains("__Signal") || (TString(key->GetName()).Contains("__Regression") && !(TString(key->GetName()).Contains("__Regression_target")))) noVars++;
    }
    
    return noVars;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:15,代码来源:tmvaglob.C

示例9: FindMethod

 TKey* FindMethod( TString name, TDirectory *dir=0 )
 {
    // find the key for a method
    if (dir==0) dir = gDirectory;
    TIter mnext(dir->GetListOfKeys());
    TKey *mkey;
    TKey *retkey=0;
    Bool_t loop=kTRUE;
    while (loop) {
       mkey = (TKey*)mnext();
       if (mkey==0) {
          loop = kFALSE;
       } 
       else {
          TString clname = mkey->GetClassName();
          TClass *cl = gROOT->GetClass(clname);
          if (cl->InheritsFrom("TDirectory")) {
             TString mname = mkey->GetName(); // method name
             TString tname = "Method_"+name;  // target name
             if (mname==tname) { // target found!
                loop = kFALSE;
                retkey = mkey;
             }
          }
       }
    }
    return retkey;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:28,代码来源:tmvaglob.C

示例10: FillHistograms

void FillHistograms(TString SAMPLE)
{
  cout<<"Processing sample "<<SAMPLE<<endl;
  //TString PATH("root://eoscms//eos/cms/store/cmst3/user/kkousour/ttH/flat/");
  TString PATH("/afs/cern.ch/work/k/kkousour/private/CMSSW_7_4_12/src/KKousour/TopAnalysis/prod/ttH/");
  TFile *inf  = TFile::Open(PATH+"flatTree_"+SAMPLE+".root");
  TFile *outf = TFile::Open(TString::Format("Histo_%s.root",SAMPLE.Data()),"RECREATE");

  TIter nextKey(inf->GetListOfKeys());
  TKey *key;
  while ((key = (TKey*)nextKey())) {
    TString dirName(key->GetName());
    cout<<"Found directory "<<dirName<<endl;
    
    TH1F *hPass = (TH1F*)inf->Get(dirName+"/TriggerPass");
    outf->mkdir(dirName);  
    TDirectory *dir = (TDirectory*)outf->Get(dirName); 
    TTree *tr   = (TTree*)inf->Get(dirName+"/events");
    
    TreeClass myTree(tr);
    dir->cd();
    hPass->Write("TriggerPass");
    myTree.Loop(dir);
    cout<<"Loop finished"<<endl;
    dir->Close();
    delete tr;
  }
  outf->Close();
  inf->Close();
}
开发者ID:isildakbora,项目名称:UserCode,代码行数:30,代码来源:FillHistograms.C

示例11: GetFileObjects

void OnlineGUI::GetFileObjects() 
{
  // Utility to find all of the objects within a File (TTree, TH1F, etc).
  //  The pair stored in the vector is <ObjName, ObjType>
  //  If there's no good keys.. do nothing.
#ifdef DEBUG
  cout << "Keys = " << fRootFile->ReadKeys() << endl;
#endif
  if(fRootFile->ReadKeys()==0) {
    fUpdate = kFALSE;
//     delete fRootFile;
//     fRootFile = 0;
//     CheckRootFile();
    return;
  }
  fileObjects.clear();
  TIter next(fRootFile->GetListOfKeys());
  TKey *key = new TKey();

  // Do the search
  while((key=(TKey*)next())!=0) {
#ifdef DEBUG
    cout << "Key = " << key << endl;    
#endif
    TString objname = key->GetName();
    TString objtype = key->GetClassName();
#ifdef DEBUG
    cout << objname << " " << objtype << endl;
#endif
    fileObjects.push_back(make_pair(objname,objtype));
  }
  fUpdate = kTRUE;
  delete key;
}
开发者ID:cipriangal,项目名称:pan,代码行数:34,代码来源:online.C

示例12: i

std::vector<TString> histoList( TString currentfile, TString theDir )
{

 gROOT ->Reset();
 const char*  sfilename = currentfile.Data();

 delete gROOT->GetListOfFiles()->FindObject(sfilename);

 TFile * sfile = new TFile(sfilename);

 const char* baseDir=theDir.Data();

 sfile->cd(baseDir);

 TDirectory * d = gDirectory;

 std::vector<TString> theHistList;

 TIter i( d->GetListOfKeys() );
 TKey *k;
 while( (k = (TKey*)i())) {
   TClass * c1 = gROOT->GetClass(k->GetClassName());
   if ( !c1->InheritsFrom("TH1")) continue;
   theHistList.push_back(k->GetName());
 }
 
 std::cout << "Histograms considered: " << std::endl;
 for (unsigned int index = 0; index < theHistList.size() ; index++ ) {
   std::cout << index << " " << theHistList[index] << std::endl;
 }

 return theHistList;

}
开发者ID:DesyTau,项目名称:cmssw,代码行数:34,代码来源:DetailedCompare.C

示例13: next

 std::vector<TString> GetInputVariableNames(TDirectory *dir )
 {
    TIter next(dir->GetListOfKeys());
    TKey* key = 0;
    //set<std::string> varnames;
    std::vector<TString> names;
    
    while ((key = (TKey*)next())) {
       if (key->GetCycle() != 1) continue;
       TClass *cl = gROOT->GetClass(key->GetClassName());
       if (!cl->InheritsFrom("TH1")) continue;
       TString name(key->GetName());
       Int_t pos = name.First("__");
       name.Remove(pos);
       Bool_t hasname = false;
       std::vector<TString>::const_iterator iter = names.begin();
       while(iter != names.end()){
          if(name.CompareTo(*iter)==0)
             hasname=true;
          iter++;
       }
       if(!hasname)
          names.push_back(name);
    }
    return names;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:26,代码来源:tmvaglob.C

示例14: 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;
        key->Write();
      } else {
	key->ReadObj();
      }
    }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:28,代码来源:sistrip_reduce_file.C

示例15: fill

void fill(TDirectory & out, TObject * o, double w) {
  TDirectory * dir;
  TH1F * th1f;
  TH1D * th1d;
  TH2F * th2f;
  TH2D * th2d;
  if((dir  = dynamic_cast<TDirectory*>(o)) != 0) {
    const char * name = dir->GetName();
    TDirectory * outDir = dynamic_cast<TDirectory*>(out.Get(name));
    if(outDir == 0) {
      cerr << "can't find directory " << name << " in output file" << endl;
      exit(-1);
    }
    TIter next(dir->GetListOfKeys());
    TKey *key;
    while( (key = dynamic_cast<TKey*>(next())) ) {
      string className(key->GetClassName());
      string name(key->GetName());
      TObject * obj = dir->Get(name.c_str());
      if(obj == 0) {
	cerr <<"error: key " << name << " not found in directory " << dir->GetName() << endl;
	exit(-1);
      }
      fill(*outDir, obj, w);
    }
  } else if((th1f = dynamic_cast<TH1F*>(o)) != 0) {
    const char * name = th1f->GetName();
    TH1F * outTh1f = dynamic_cast<TH1F*>(out.Get(name));
    if(outTh1f == 0) {
      cerr <<"error: histogram TH1F" << name << " not found in directory " << out.GetName() << endl;
      exit(-1);	
    }
    outTh1f->Add(th1f, w);
  } else if((th1d = dynamic_cast<TH1D*>(o)) != 0) {
    const char * name = th1d->GetName();
    TH1D * outTh1d = dynamic_cast<TH1D*>(out.Get(name));
    if(outTh1d == 0) {
      cerr <<"error: histogram TH1D" << name << " not found in directory " << out.GetName() << endl;
      exit(-1);	
    } 
    outTh1d->Add(th1d, w);
  } else if((th2f = dynamic_cast<TH2F*>(o)) != 0) {
    const char * name = th2f->GetName();
    TH2F * outTh2f = dynamic_cast<TH2F*>(out.Get(name));
    if(outTh2f == 0) {
      cerr <<"error: histogram TH2F" << name << " not found in directory " << out.GetName() << endl;
      exit(-1);	
    }
    outTh2f->Add(th2f, w);
  } else if((th2d = dynamic_cast<TH2D*>(o)) != 0) {
    const char * name = th2d->GetName();
    TH2D * outTh2d = dynamic_cast<TH2D*>(out.Get(name));
    if(outTh2d == 0) {
      cerr <<"error: histogram TH2D" << name << " not found in directory " << out.GetName() << endl;
      exit(-1);	
    }
    outTh2d->Add(th2d, w);
  }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:59,代码来源:mergeTFileServiceHistograms.cpp


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