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


C++ TClass类代码示例

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


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

示例1: rewrite

void rewrite(const char *filename = "inherit.root")
{
   TFile *file = TFile::Open(filename,"READ");
   TFile *out = TFile::Open("inherit-2.root","RECREATE");
   
   fprintf(stdout,"Testing Directory\n");
   void *h = file->Get("holder");
   // gDebug = 7;
   fprintf(stdout,"Testing Writing\n");
   out->WriteObjectAny(h,"Holder","holdercopy");
   
   fprintf(stdout,"Delete original\n");
   TClass *cl = TClass::GetClass("Holder");
   cl->Destructor(h);
   
   fprintf(stdout,"Testing the re-wrote object\n");
   h = out->Get("holdercopy");
   fprintf(stdout,"Delete copy\n");
   cl->Destructor(h);
   
//   fprintf(stdout,"Testing TTree\n");
//   TTree *tree; file->GetObject("tree",tree);
//   tree->GetEntry(0);
//   delete tree;
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:25,代码来源:rewrite.C

示例2: RegisterEnum

TSClass* RegisterEnum(TClassRegistryParams& params, const char* source)
{
	auto syntax = params.syntax;
	TClass* cl = new TClass(syntax->base_class.get());
	syntax->base_class->AddNested(cl);
	syntax->lexer.ParseSource(source);
	cl->AnalyzeSyntax(syntax->lexer);
	syntax->lexer.GetToken(TTokenType::Done);

	TSClass* scl = new TSClass(syntax->sem_base_class.get(), cl);
	syntax->sem_base_class->AddClass(scl);
	scl->Build();

	std::vector<TSClassField*> static_fields;
	std::vector<TSLocalVar*> static_variables;

	TGlobalBuildContext global_build_context(&static_fields, &static_variables);

	scl->LinkSignature(global_build_context);
	scl->InitAutoMethods();
	scl->LinkBody(global_build_context);
	scl->CheckForErrors();

	std::vector<TSClass*> owners;
	scl->CalculateSizes(owners);
	scl->CalculateMethodsSizes();

	owners.clear();
	syntax->sem_base_class->CalculateSizes(owners);//т.к. в этом классе могут использоваться другие шаблонные класса, реализацию которых нужно обновить

	InitializeStaticClassFields(static_fields, *params.static_objects);
	InitializeStaticVariables(static_variables, *params.static_objects);

	return scl;
}
开发者ID:HumMan,项目名称:BaluEngine,代码行数:35,代码来源:ScriptClassesRegistry.cpp

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

示例4: TClass

void KVIDentifier::CloneScaleStore(Int_t newzt, Int_t newar, Double_t dy, Double_t sx, Double_t sy)
{
   // Create a new line from the selected one
   // with a new Z and A (optional)
   // this new line is scale from the selected one with a vertical sy
   // and horizontal sx (optional) factor
   // you need to undraw and draw the grid to see its implementation

   TClass* cl = new TClass(this->IsA()->GetName());
   KVIDentifier* idbis = (KVIDentifier*)cl->New();
   Double_t xx, yy;
   for (Int_t nn = 0; nn < this->GetN(); nn += 1) {
      this->GetPoint(nn, xx, yy);
      idbis->SetPoint(nn, xx, yy + dy);
   }
   idbis->SetOnlyZId(OnlyZId());
   idbis->SetZ(newzt);
   idbis->SetMassFormula(GetMassFormula());
   idbis->SetEditable(IsEditable());
   if (newar != -1) {
      idbis->SetA(newar);
   }
   if ((sx > 0.) && (sy > 0.)) idbis->Scale(sx, sy);
   this->GetParent()->AddIdentifier(idbis);

   this->GetParent()->UnDraw();
   this->GetParent()->Draw();


   delete cl;
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:31,代码来源:KVIDentifier.cpp

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

示例6: while

void TestSchemaEvolution::gatherAllClasses() {
  static const char *classes[] = {"TH1F",
                                  "TH1S",
                                  "TH1D",
                                  "TH1I",
                                  "TH2F",
                                  "TH2S",
                                  "TH2D",
                                  "TH2I",
                                  "TH3F",
                                  "TH3S",
                                  "TH3D",
                                  "TH3I",
                                  "TProfile",
                                  "TProfile2D",
                                  "TF1",
                                  0};

  int i = 0;
  while (classes[i]) {
    TClass *tcl = TClass::GetClass(classes[i]);
    if (!tcl)
      continue;
    unique_classes_.insert(std::make_pair(classes[i], tcl->GetClassVersion()));
    analyseClass(tcl);
    ++i;
  }
}
开发者ID:hroskes,项目名称:cmssw,代码行数:28,代码来源:testSchemaEvolution.cpp

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

示例8: GetInputVariableNames

 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

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

示例11: Error

KVVarGlob *KVEventSelector::AddGV(const Char_t * class_name,
                                  const Char_t * name)
{
   //Add a global variable to the list of variables for the analysis.
   //
   //"class_name" must be the name of a valid class inheriting from KVVarGlob, e.g. any of the default global
   //variable classes defined as part of the standard KaliVeda package (in libKVvVarGlob.so). See
   //"Class Reference" page on website for the available classes (listed by category under "Global Variables: ...").
   //
   //USER-DEFINED GLOBAL VARIABLES
   //The user may use her own global variables in an analysis class, without having to add them to the main libraries.
   //If the given class name is not known, it is assumed to be a user-defined class and we attempt to compile and load
   //the class from the user's source code. For this to work, the user must:
   //
   //      (1) add to the ROOT macro path the directory where her class's source code is kept, e.g. in $HOME/.rootrc
   //              add the following line:
   //
   //              +Unix.*.Root.MacroPath:      $(HOME)/myVarGlobs
   //
   //      (2) for each user-defined class, add a line to $HOME/.kvrootrc to define a "plugin". E.g. for a class called MyNewVarGlob,
   //
   //              +Plugin.KVVarGlob:    MyNewVarGlob    MyNewVarGlob     MyNewVarGlob.cpp+   "MyNewVarGlob()"
   //
   //      It is assumed that MyNewVarGlob.h and MyNewVarGlob.cpp will be found in $HOME/myVarGlobs (in this example).
   //
   //"name" is a unique name for the new global variable object which will be created and added to the internal
   //list of global variables. This name can be used to retrieve the object (see GetGV) in the user's analysis.
   //
   //Returns pointer to new global variable object in case more than the usual default initialisation is necessary.

   KVVarGlob *vg = 0;
   TClass *clas = gROOT->GetClass(class_name);
   if (!clas) {
      //class not in dictionary - user-defined class ? Look for plugin.
      TPluginHandler *ph = KVBase::LoadPlugin("KVVarGlob", class_name);
      if (!ph) {
         //not found
         Error("AddGV(const Char_t*,const Char_t*)",
               "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
               class_name);
         return 0;
      } else {
         vg = (KVVarGlob *) ph->ExecPlugin(0);
      }
   } else if (!clas->InheritsFrom("KVVarGlob")) {
      Error("AddGV(const Char_t*,const Char_t*)",
            "%s is not a valid class deriving from KVVarGlob.",
            class_name);
      return 0;
   } else {
      vg = (KVVarGlob *) clas->New();
   }
   vg->SetName(name);
   AddGV(vg);
   return vg;
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:56,代码来源:KVEventSelector.cpp

示例12: runCintexReflexOrder

void runCintexReflexOrder() {
   gSystem->Setenv("LINES","-1");
   gSystem->Load("libCintex");
   gSystem->Load("libReflexDict");
   ROOT::Cintex::Cintex::Enable();
   TClass* cl = TClass::GetClass("Reflex::Scope");
   TMethod* m = (TMethod*) cl->GetListOfMethods()->FindObject("AddMemberTemplate");
   TMethodArg* arg = (TMethodArg*) m->GetListOfMethodArgs()->First();
   cout << "AddMemberTemplate() arg0: " << arg->GetFullTypeName() << endl;
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:10,代码来源:runCintexReflexOrder.C

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

示例14: next

void TestSchemaEvolution::loopOnDataMembers(TClass *tcl) {
  TList *dms = tcl->GetListOfDataMembers();
  TIter next(dms);
  while (TObject *obj = next()) {
    TClass *cl = TClass::GetClass(((TDataMember *)obj)->GetFullTypeName());
    if (cl && cl->HasDictionary()) {
      unique_classes_.insert(std::make_pair(cl->GetName(), cl->GetClassVersion()));
      analyseClass(cl);
    }
  }
}
开发者ID:hroskes,项目名称:cmssw,代码行数:11,代码来源:testSchemaEvolution.cpp

示例15: print_root_classname

template <class T> bool print_root_classname(const T *obj, const char* expect) {
  TClass *cl = testGetClass(typeid(*obj));
  if (!cl || strcmp(cl->GetName(),expect)!=0 ) {
    cerr << "ERROR: in retrieving TClass";
    if (cl) { cerr << " found " << cl->GetName() << endl; }
    else { cerr << " NOT found!" << endl; };
    return 0;
  }
  cerr << cl->GetName() << endl;
  return 1;
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:11,代码来源:typeidtest.C


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