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


C++ TClass::New方法代码示例

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


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

示例1: CloneScaleStore

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

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

示例3: execInterpClassNew

int execInterpClassNew()
{
   gROOT->ProcessLine(".L classlib.cxx+");
   TClass * c = TClass::GetClass("class1");
   if (!c) {
     fprintf(stderr,"Error: Could retrieve the TClass for class1\n");
     return 0;
   }
   if (c->IsLoaded()) {
     fprintf(stderr,"Error: The TClass for class1 is marker as loaded.n");
     return 0;
   }
   void *p = c->New();
   if (!p) {
     fprintf(stderr,"Error: Could not create an object of type class1.\n");
     return 1;
  }
  return 0;
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:19,代码来源:execInterpClassNew.C

示例4: CalculateDeltaE_EGrid

//_____________________________________________________________________________________________________//
KVIDGrid* KVIDTelescope::CalculateDeltaE_EGrid(TH2* haa_zz, Bool_t Zonly, Int_t npoints)
{
   //Genere une grille dE-E (perte d'energie - energie residuelle)
   //Le calcul est fait pour chaque couple comptant de charge (Z) et masse (A)
   //au moins un coup dans l'histogramme haa_zz definit :
   // Axe X -> Z
   // Axe Y -> A
   //
   //- Si Zonly=kTRUE (kFALSE par defaut), pour un Z donne, le A choisi est la valeur entiere la
   //plus proche de la valeur moyenne <A>
   //- Si Zonly=kFALSE et que pour un Z donne il n'y a qu'un seul A associe, les lignes correspondants
   //a A-1 et A+1 sont ajoutes
   //- Si a un Z donne, il n'y a aucun A, pas de ligne tracee
   //un noyau de A et Z donne n'est considere que s'il retourne KVNucleus::IsKnown() = kTRUE
   //
   // Warning : the grid is not added to the list of the telescope and MUST BE DELETED by the user !

   if (GetSize() <= 1) return 0;

   TClass* cl = new TClass(GetDefaultIDGridClass());
   KVIDGrid* idgrid = (KVIDGrid*)cl->New();
   delete cl;

   idgrid->AddIDTelescope(this);
   idgrid->SetOnlyZId(Zonly);

   KVDetector* det_de = GetDetector(1);
   if (!det_de)      return 0;
   KVDetector* det_eres = GetDetector(2);
   if (!det_eres)    return 0;

   KVNucleus part;
   Info("CalculateDeltaE_EGrid",
        "Calculating dE-E grid: dE detector = %s, E detector = %s",
        det_de->GetName(), det_eres->GetName());

   KVIDCutLine* B_line = (KVIDCutLine*)idgrid->Add("OK", "KVIDCutLine");
   Int_t npoi_bragg = 0;
   B_line->SetName("Bragg_line");
   B_line->SetAcceptedDirection("right");

   Double_t SeuilE = 0.1;

   for (Int_t nx = 1; nx <= haa_zz->GetNbinsX(); nx += 1) {

      Int_t zz = TMath::Nint(haa_zz->GetXaxis()->GetBinCenter(nx));
      KVNumberList nlA;
      Double_t sumA = 0, sum = 0;
      for (Int_t ny = 1; ny <= haa_zz->GetNbinsY(); ny += 1) {
         Double_t stat = haa_zz->GetBinContent(nx, ny);
         if (stat > 0) {
            Double_t val = haa_zz->GetYaxis()->GetBinCenter(ny);
            nlA.Add(TMath::Nint(val));
            sumA += val * stat;
            sum  += stat;
         }
      }
      sumA /= sum;
      Int_t nA = nlA.GetNValues();
      if (nA == 0) {
         Warning("CalculateDeltaE_EGrid", "no count for Z=%d", zz);
      } else {
         if (Zonly) {
            nlA.Clear();
            nlA.Add(TMath::Nint(sumA));
         } else {
            if (nA == 1) {
               Int_t aref = nlA.Last();
               nlA.Add(aref - 1);
               nlA.Add(aref + 1);
            }
         }
         part.SetZ(zz);
//            printf("zz=%d\n",zz);
         nlA.Begin();
         while (!nlA.End()) {
            Int_t aa = nlA.Next();
            part.SetA(aa);
//                printf("+ aa=%d known=%d\n",aa,part.IsKnown());
            if (part.IsKnown()) {

               //loop over energy
               //first find :
               //  ****E1 = energy at which particle passes 1st detector and starts to enter in the 2nd one****
               //      E2 = energy at which particle passes the 2nd detector
               //then perform npoints calculations between these two energies and use these
               //to construct a KVIDZALine

               Double_t E1, E2;
               //find E1
               //go from SeuilE MeV to det_de->GetEIncOfMaxDeltaE(part.GetZ(),part.GetA()))
               Double_t E1min = SeuilE, E1max = det_de->GetEIncOfMaxDeltaE(zz, aa);
               E1 = (E1min + E1max) / 2.;

               while ((E1max - E1min) > SeuilE) {

                  part.SetEnergy(E1);
                  det_de->Clear();
                  det_eres->Clear();
//.........这里部分代码省略.........
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:101,代码来源:KVIDTelescope.cpp


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