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


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

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


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

示例1: fancyMerge

void fancyMerge( std::string beam, std::string target, std::string energy, std::string physlist, bool doScale=false )
{
      
   std::string output = beam + target + energy + "GeV" + physlist + ".root" ;
   
   targetFile = TFile::Open( output.c_str(), "RECREATE" );
   
   double scale = 1./32.;
   
   // std::string input = beam + target + model + energy + "GeV-1.root";
   // std::string input = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist +"-1.root";

   // std::string input = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";

   std::string input = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";
   
   TFile* iFile1 = TFile::Open( input.c_str() );
   TIter  next( iFile1->GetListOfKeys() );
   TKey*  key = (TKey*)next();
   TH1* h = 0;
   while ( key )
   {   
         if ( !(TClass::GetClass(key->GetClassName())->InheritsFrom(TH1::Class())) ) continue;
         const char* kName = key->GetName();
         h = (TH1*)key->ReadObj();
         const char* hName = h->GetName();
         std::cout << " histoname = " << hName << std::endl;
	 TH1F* h1 = h->Clone();
	 for ( int id=2; id<=32; id++ )
	 {
	    // std::string input_t = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist + "-" ;
	    // std::string input_t = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
	    std::string input_t = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
            char buf[5];
            sprintf( buf, "%i", id );
            input_t.append( buf ); 
            input_t += ".root"; 
	    TFile* iFile_t = TFile::Open( input_t.c_str() );
	    TH1F* h_t = (TH1F*)iFile_t->Get( h->GetName() );
	    h1->Add( h_t );  
	    iFile_t->Close();
	 }
	 if ( doScale )
	 {
	    if (!(strcmp(key->GetClassName(),"TProfile"))) h1->Scale( scale );
	 }
	 targetFile->cd();
	 h1->Write();
         key = (TKey*)next();
   }
   
   targetFile->Close();
     
   return;

}
开发者ID:gpestana,项目名称:thesis,代码行数:56,代码来源:PlotHARPAnalysis.C

示例2: Compare

Int_t Compare(TDirectory* from) {
   TFile * reffile = new TFile("dt_reference.root");
   
   TIter next(reffile->GetListOfKeys());
   TH1 *ref, *draw;
   const char* name;
   Int_t comp;
   Int_t fail = 0;
   TKey* key;

   while ((key=(TKey*)next())) {
      if (strcmp(key->GetClassName(),"TH1F")
          && strcmp(key->GetClassName(),"TH2F") ) 
        continue; //may be a TList of TStreamerInfo
      ref = (TH1*)reffile->Get(key->GetName());
      name = ref->GetName();
      if (strncmp(name,"ref",3)) continue;
      name += 3;
      draw = (TH1*)from->Get(name);
      if (!draw) {
         if (!gSkipped.FindObject(name)) {
            cerr << "Miss: " << name << endl;
            fail++;
         }
         continue;
      }
      comp = HistCompare(ref,draw);
      if (comp!=0) {
         cerr << "Fail: " << name << ":" << comp << endl;
         fail++;
         if (gInteractiveTest) {
            TCanvas * canv = new TCanvas();
            canv->Divide(2,1);
            canv->cd(1); 
            TString reftitle = "Ref: ";
            reftitle.Append(ref->GetTitle());
            ref->SetTitle(reftitle);
            ref->Draw();
            canv->cd(2); draw->Draw();
            return 1;
         }
      } else {
         if (gQuietLevel<1) cerr << "Succ: " << name << ":" << comp << endl;
      }
   }
   delete reffile;
   return fail;
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:48,代码来源:dt_RunDrawTest.C

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

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

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

示例6: GetListOfTitles

 UInt_t GetListOfTitles( TDirectory *rfdir, TList & titles )
 {
    // get a list of titles (i.e TDirectory) given a method dir
    UInt_t ni=0;
    if (rfdir==0) return 0;
    TList *keys = rfdir->GetListOfKeys();
    if (keys==0) {
       cout << "+++ Directory '" << rfdir->GetName() << "' contains no keys" << endl;
       return 0;
    }
    //
    TIter rfnext(rfdir->GetListOfKeys());
    TKey *rfkey;
    titles.Clear();
    titles.SetOwner(kFALSE);
    while ((rfkey = (TKey*)rfnext())) {
       // make sure, that we only look at histograms
       TClass *cl = gROOT->GetClass(rfkey->GetClassName());
       if (cl->InheritsFrom("TDirectory")) {
          titles.Add(rfkey);
          ni++;
       }
    }
    cout << "--- Found " << ni << " instance(s) of the method " << rfdir->GetName() << endl;
    return ni;
 }
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:26,代码来源:tmvaglob.C

示例7: CompDir

void CompDir(TDirectory *t1, TDirectory *tref, int run1, int runref) {
   t1->cd();
   //loop on all entries of this directory
   TKey *key;
   TIter nextkey(t1->GetListOfKeys());
   while ((key = (TKey*)nextkey())) {
      const char *classname = key->GetClassName();
      TClass *cl = gROOT->GetClass(classname);
      if (!cl) continue;
      if (cl->InheritsFrom("TDirectory")) {
         t1->cd(key->GetName());
         TDirectory *subdir = gDirectory;
         tref->cd(key->GetName());
         TDirectory *subdirref = gDirectory;
         CompDir(subdir,subdirref,run1,runref);
      } else if (cl->InheritsFrom("TObjArray")) {
         TObjArray *subdir = (TObjArray*)t1->Get(key->GetName());
         TObjArray *subdirref = (TObjArray*)tref->Get(key->GetName());
         CompDir(subdir,subdirref,run1,runref);
      } else if (TString(classname) == "TH1F") {
         TH1 *h1 = (TH1*)t1->Get(key->GetName());
         TH1 *href = (TH1*)tref->Get(key->GetName());
         CompHist(h1,href,run1,runref);
      } else {
         // do nothing
     }
  }
}
开发者ID:CMS-HIN-dilepton,项目名称:RunPreparation,代码行数:28,代码来源:compare.C

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

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

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

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

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

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

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

示例15: counts

void counts(int run, int lumistart, int lumiend, string type, map<string,vector<tripletI> > &cnt, vector<tripletD> &cntref, string hlttype, bool docnt, bool doref) {
   TString filename = basedir + Form("/DQM_V0001_HLTpb_R000%i.root",run);
   TFile *f = new TFile(filename);
   if (!f->IsOpen()) {
      cout << "Error, could not open " << filename << endl;
      return;
   }
   TString tdirname = Form("DQMData/Run %i/HLT/Run summary/TriggerRates/",run) + TString(type);
   f->cd(tdirname);
   TProfile *hlumi = (TProfile*) f->Get(Form("DQMData/Run %i/HLT/Run summary/LumiMonitoring/lumiVsLS",run));
   if (extrapol) extrapolate(hlumi);

   // if HLT: accept, error, pass L1 seed, pass prescaler, reject

   TIter next(gDirectory->GetListOfKeys());
   TKey *key;
   while ((key = (TKey*)next())) {
      TClass *cl = gROOT->GetClass(key->GetClassName());
      
      // it must be an histogram
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *h = (TH1*)key->ReadObj();

      // the name must match one of the requested patterns
      bool match=false; TString hname(h->GetName());
      for (vector<TRegexp>::const_iterator it=patterns.begin(); it!=patterns.end(); it++) {
         if (hname(*it).Length()!=0) {
            match=true;
            break;
         }
      }
      if (!match) continue;

      int nlumis = (lumiend+1-lumistart);

      if (extrapol) extrapolate(h);

      if (type != "HLT") fill(cnt[h->GetName()], h, run, lumistart, lumiend, docnt);
      else {
         string htitle(h->GetTitle());
         if (htitle.find(hlttype) == string::npos) continue;
         else {
            TString thepath; Ssiz_t from=0; TString(htitle).Tokenize(thepath,from," ");
            fill(cnt[thepath.Data()], h, run, lumistart, lumiend, docnt);
         }
      }
   }

   if (doref) {
      fill(cntref, hlumi, run, lumistart, lumiend);
   }

   f->Close();
   delete f;
}
开发者ID:CMS-HIN-dilepton,项目名称:RunPreparation,代码行数:55,代码来源:recorded_by_hltpath_fromDQM.C


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