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


C++ TObject类代码示例

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


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

示例1: exec1

// echo object at mouse position
void exec1()
{
   //example of macro called when a pad is redrawn
   //one must create a TExec object in the following way
   // TExec ex("ex",".x exec1.C");
   // ex.Draw();
   // this macro prints the bin number and the bin content when one clicks
   //on the histogram contour of any histogram in a pad
   //Author: Rene Brun
   
   if (!gPad) {
      Error("exec1", "gPad is null, you are not supposed to run this macro");
      return;
   }
   
   int event = gPad->GetEvent();
   if (event != 11) return;
   int px = gPad->GetEventX();
   TObject *select = gPad->GetSelected();
   if (!select) return;
   if (select->InheritsFrom(TH1::Class())) {
      TH1 *h = (TH1*)select;
      Float_t xx = gPad->AbsPixeltoX(px);
      Float_t x  = gPad->PadtoX(xx);
      Int_t binx = h->GetXaxis()->FindBin(x);
      printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
   }
}
开发者ID:adevress,项目名称:root-1,代码行数:29,代码来源:exec1.C

示例2: HighlightFragment

//______________________________________________________________________________
void HighlightFragment()
{
  // TODO templates: what and how highlighing
  if (!gPad || !gr) return;

  // not correct
  TVirtualPad *ph = (TVirtualPad *)gPad->FindObject("ph");
  if (!ph) {
    ph = new TPad("ph", "ph", 0.0, 0.2, 1.0, 1.0);
    ph->SetFillColor(kBlue-10);
    ph->Draw();
  }

  Int_t ih = gr->GetHighlightPoint();
  if (ih == -1) return;
  TRsnFragment *frag = group->FragmentAt(ih);
  if (!frag) return;

  TVirtualPad *save = gPad;
  ph->cd();
  TObject *element = frag->FindElement(tagname);
  if (!element) ph->Clear();
  else element->Draw();
  save->cd();
}
开发者ID:musinsky,项目名称:RsnResults,代码行数:26,代码来源:Highlight.C

示例3: eff2

// Method by name
TH2F* eff2(const char* name1, const char* name2, const char* name="eff"){

  // Get a list of object and their iterator
  TList* list = gDirectory->GetList() ;
  TIterator* iter = list->MakeIterator();

  // Loop over objects, set the pointers
  TObject* obj;
  TH2F* h1=0;
  TH2F* h2=0;
  TString str1 = Form("%s",name1);
  TString str2 = Form("%s",name2);
  while(obj=iter->Next()) {
    TString objName = obj->GetName();
    if (objName == str1) h1 = (TH2F*) obj;
    if (objName == str2) h2 = (TH2F*) obj;
  }

  // quit if not found
  if (h1 == 0) {
    cout << "Histogram " << name1 << " not found" << endl;
    return 0;
  }
  if (h2 == 0) {
    cout << "Histogram " << name2 << " not found" << endl;
    return 0;
  }

  // Call the method by pointer
  TH2F* temp = eff2(h1, h2, name);
  return temp;
}
开发者ID:cmstas,项目名称:fakeRate,代码行数:33,代码来源:eff2.C

示例4: getHisto

TH1F * getHisto(TFile * file, const char * name, double fMin, double fMax, unsigned int rebin) {
  TObject * h = file->Get(name);
  if(h == 0)
    cout  << "Can't find object " << name << "\n";
  TH1F * histo = dynamic_cast<TH1F*>(h);
  if(histo == 0)
    cout << "Object " << name << " is of type " << h->ClassName() << ", not TH1\n";
  TH1F * new_histo = new TH1F(name, name, (int) (fMax-fMin), fMin, fMax);
  int bin_num=0;
  for (int i = (int)fMin; i <= (int)fMax; ++i ) {
    bin_num= (i - (int)fMin + 1);  
    new_histo->SetBinContent( bin_num, histo->GetBinContent(i) );				    
  } 
  delete histo;
  new_histo->Sumw2();
  new_histo->Rebin(rebin);
  for(int i = 1; i <= new_histo->GetNbinsX(); ++i) {
    if(new_histo->GetBinContent(i) == 0.00) {
      cout<< " WARNING: histo " << name << " has 0 enter in bin number " << i << endl;   
        }
    if(new_histo->GetBinContent(i) < 0.1) {
      new_histo->SetBinContent(i, 0.0);
      new_histo->SetBinError(i, 0.0);
       cout<< " WARNING: setting value 0.0 to histo " << name << " for bin number " << i << endl;   
    }  
  }
  
  return new_histo;
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:29,代码来源:zMuMuRooFit.cpp

示例5: next

void DMAHCALBooker::SetAxis(std::string type, std::string x_axis, std::string y_axis)
{
    for(std::map<std::string, TList*>::iterator it = m_objectList.begin(); it != m_objectList.end(); it++)
    {
        if(it->first == type)
        {
            TList *pList = it->second;
            TIter next(pList);
            TObject *obj;

            while ((obj = next()))
            {
                if(obj->InheritsFrom("TH1"))
                {
                    TH1F *h1 = static_cast<TH1F*>(obj);
                    h1->GetXaxis()->SetTitle(x_axis.c_str());
                    h1->GetYaxis()->SetTitle(y_axis.c_str());
                }
                if(obj->InheritsFrom("TH2"))
                {
                    TH1F *h2 = static_cast<TH1F*>(obj);
                    h2->GetXaxis()->SetTitle(x_axis.c_str());
                    h2->GetYaxis()->SetTitle(y_axis.c_str());
                }
            }
        }
        else
        {
            emit log("ERROR", QString("Type %1 not defined").arg(QString::fromStdString(type)));
            return;
        }
    }
}
开发者ID:CALICETB,项目名称:QtReco,代码行数:33,代码来源:DMAHCALBooker.cpp

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

示例7: DoChanged

void __fastcall TVersionInfo::DoChanged(void)
{
  TCMVersionInfoComponent NotificationMessage = { };

  NotificationMessage.Msg = CM_VERSIONINFOCHANGE;
  NotificationMessage.Component = this;
//Changed Roy:
  for (int i = 0; i < FUiElements->Count; ++i)
  {
	TObject* AnUiElement;

	// Trick: Since in our UI elements the message map as implemented
	//        through the overridden Dispatch method is not public,
	//        we down-cast to a descendant (TObject) where Dispatch is
	//        public and then call Dispatch.
	//        This technique works because Dispatch is virtual.
	AnUiElement = static_cast<TObject*>(FUiElements->Items[i]);
	assert(AnUiElement != NULL);
	AnUiElement->Dispatch(&NotificationMessage);
  }

  if (FOnChange != NULL)
  {
    FOnChange(this);
  }
}
开发者ID:SkylineNando,项目名称:Delphi,代码行数:26,代码来源:VersionInfoComponent.cpp

示例8: switch

bool Entity::matches(const TObject& other) const
{
    if (tObject_ == other) return true;

    bool ret = false;

    switch (matchLevel_) {
        case LevelNone:     // Never matches
            break;
        case LevelAny:     // Any TObject will do
            ret = true;
            break;
        case LevelTOType:
            ret = const_cast<TObjectType&>(tObject_.getType()) == other.getType();
            break;
        case LevelTOValue:
            ret = tObject_ == other;
            break;
        case LevelTOName:
            ret = tObject_.getName() == other.getName();
            break;
        default:
            break;
    }

    return ret;
}
开发者ID:lawarner,项目名称:aft,代码行数:27,代码来源:entity.cpp

示例9: GetACQParamList

void KVHarpeeSi::SetCalibrators()
{
   // Pulse Height Defect calibrator as well as the calibrators of
   // KVVAMOSDetector.

   KVVAMOSDetector::SetCalibrators();

   // Set PHD calibrator only if the detector has an acq. parameter
   // with type 'E'
   TObject* par = GetACQParamList()->FindObjectByType("E");
   if (!par) return;

   TString type("channel->MeV ");
   type.Append(par->GetName());
   fCanalE = (KVFunctionCal*)GetCalibrator(type.Data());

   if (!fCanalE) Error("SetCalibrators", "channel->MeV calibrator not found");

   KVRecombination* c = new KVRecombination(this);
   type = c->GetType();
   type.Append(" ");
   type.Append(par->GetName());
   c->SetType(type.Data());
   if (!AddCalibrator(c)) delete c;

   fPHD = (KVRecombination*)GetCalibrator(type.Data());
}
开发者ID:FableQuentin,项目名称:kaliveda,代码行数:27,代码来源:KVHarpeeSi.cpp

示例10: fileDirectory

TDirectory* fileDirectory( TDirectory *target, std::string s) 
{
    TDirectory *retval = 0;

    // loop over all keys in this directory
    TIter nextkey(target->GetListOfKeys());
    TKey *key, *oldkey=0;
    while((key = (TKey*)nextkey())) 
    {
	//keep only the highest cycle number for each key
	if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue;

	// read object from file
	target->cd();
	TObject *obj = key->ReadObj();
	
	if(obj->IsA()->InheritsFrom(TDirectory::Class())) 
	{
	    // it's a subdirectory
	    //cout << "Found subdirectory " << obj->GetName() << endl;
	    if(strcmp(s.c_str(), obj->GetName()) == 0) return (TDirectory*)obj;
	    
	    if((retval = fileDirectory((TDirectory*)obj, s))) break;
	    
	}
	else break;
    }
    return retval;
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:29,代码来源:SinglePi.C

示例11: SetVersionInfo

void __fastcall TCustomVersionInfoLabel::SetVersionInfo(TVersionInfo* Value)
{
  if (Value != FVersionInfo)
  {
    TCMVersionInfoUi NotifcationMessage = { };
    TObject* Downcast;

    NotifcationMessage.UiElement = this;

    if (FVersionInfo != NULL)
    {
      NotifcationMessage.Msg = CM_VERSIONINFOUIDETACH;
      Downcast = FVersionInfo;
      Downcast->Dispatch(&NotifcationMessage);
    }

    FVersionInfo = Value;

    if (FVersionInfo != NULL)
    {
      NotifcationMessage.Msg = CM_VERSIONINFOUIATTACH;
      Downcast = FVersionInfo;
      Downcast->Dispatch(&NotifcationMessage);
    }

    UpdateLabelContent();
  }
}
开发者ID:SkylineNando,项目名称:Delphi,代码行数:28,代码来源:VersionInfoUI.cpp

示例12: nextobj

TH1 *hist_extract(TPad *c)
{
    TIter nextobj(c->GetListOfPrimitives());
    for( TObject *ptr; NULL!=(ptr=nextobj.Next()); )
    {
        printf("==========>>> %s\n",ptr->GetName());
    }
}
开发者ID:WarShoe,项目名称:STRAW-soft,代码行数:8,代码来源:ud_cmp.C

示例13: MergeSimpleHistogramFile

//________________________________________________________________________________
void MergeSimpleHistogramFile( const Char_t *TargetName=0, const Char_t *inputFilesPattern=0) 
{
   // This is the deprecated version. To be dleted after debugging
  if (TargetName && TargetName[0] && inputFilesPattern && inputFilesPattern[0] ) {
    TStopwatch time;
    Int_t fileCounter = 0;
    Int_t histogramCounter = 0;
     // Create the output file
     TFile *outFile = TFile::Open(TargetName,"RECREATE");     
     TDirIter listOfFiles(inputFilesPattern);
     const char *fileName = 0;
     while ( (fileName =  listOfFiles.NextFile() ) ) {
        printf(".");
        fileCounter++;
        TFileIter file(fileName);
        TObject *obj = 0;
        while ( (obj = *file) ) {
           if ( obj->IsA()->InheritsFrom( "TH1" ) ) {
              // descendant of TH1 -> merge it
              // printf("Merging histogram: %s\n",obj->GetName() ); 
//              std::cout << "Merging histogram " << obj->GetName() << std::endl;
              TH1 *h1 = (TH1*)obj;
              TH1 *dstHistogram = 0;
              // Check whether we found the new histogram
              if ( (dstHistogram = (TH1 *)outFile->FindObject(h1->GetName()))) {
                 // Accumulate  the  histogram
                  dstHistogram->Add(h1);
                  delete h1;  // Optional, to reduce the memory consumption
                  printf("+");
              } else {
                // First time - move the histogram
                h1->SetDirectory(outFile);
                printf(" The new Histogram found: %s \n", h1->GetName() );
                histogramCounter++;
              }
           } else {
              // printf("Skipping object: %s\n",obj->GetName() ); 
           }
           ++file;
        }
              
     }
     printf("\n Finishing  . . . \n");
     outFile->ls();
     outFile->Write();
     outFile->Close();     
     delete outFile;
     printf(" Total files merged: %d \n", fileCounter);
     printf(" Total histograms merged: %d \n", histogramCounter);
     time.Print("Merge");
  } else {
     printf("\nUsage: root MergeHistogramFile.C(\"DestinationFileName\",\"InputFilesPattern\",kTRUE)\n");     
     printf("------        where InputFilesPattern  ::= <regexp_pattern_for_the_input_files>|@indirect_file_list\n");
     printf("                    indirect_file_list ::= a text file with the list of the files\n");
     printf("                    indirect_file_list can be create by the shell command:\n");
     printf("                         ls -1 --color=never *.root>indirect_file_list \n\n");
  }
}
开发者ID:kalanand,项目名称:UserCode,代码行数:59,代码来源:MergeHistogramFile.C

示例14: ProfileX

void KVCanvas::ProfileX(TH2* hh)
{
   TObject* pfx = 0;
   if ((pfx = FindObject(Form("%s_pfx", hh->GetName())))) pfx->Delete();
   hh->ProfileX("_pfx", 1, -1, "i,d,same");
   if ((pfx = FindObject(Form("%s_pfx", hh->GetName()))))((TProfile*)pfx)->SetLineColor(kBlack);
   Modified();
   Update();
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:9,代码来源:KVCanvas.cpp

示例15: it

TH1* KVCanvas::FindHisto()
{
   TObject* hh = 0;
   TIter it(GetListOfPrimitives());
   while ((hh = (TObject*)it())) {
      if (hh->InheritsFrom("TH1")) return (TH1*) hh;
   }
   return 0;
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:9,代码来源:KVCanvas.cpp


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