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


C++ TObject::InheritsFrom方法代码示例

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


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

示例1: SetAxis

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

示例2: extractObjectFromPad

TList* extractObjectFromPad(TPad* pad, const char* name)
{
  TList* objects = new TList();
  TList* primitivesList = pad->GetListOfPrimitives();
  assert(primitivesList);
  for (int i = 0; i < primitivesList->GetSize(); ++i) {
    TObject* object = primitivesList->At(i);
    std::cout << object->ClassName() << ' ' << object->GetName() << std::endl;
    if (object->InheritsFrom("TPad")) {
      TList* objectsFromPad = extractObjectFromPad(static_cast<TPad*>(object), name);
      for (int j = 0; j < objectsFromPad->GetSize(); ++j)
        objects->Add(objectsFromPad->At(j));
    } else if (object->InheritsFrom("THStack")) {
      TList* hList = (static_cast<THStack*>(object))->GetHists();
      for (int j = 0; j < hList->GetSize(); ++j)
        if (!strcmp(hList->At(j)->GetName(), name)) {
          objects->Add(hList->At(j));
        }
    } else if (!strcmp(object->GetName(), name)) {
      std::cout << "--->" << name << std::endl;
      objects->Add(object);
    }
  }
  return objects;
}
开发者ID:Dominik-Mitzel,项目名称:radiatedModule,代码行数:25,代码来源:dominik.C

示例3: yaxis

   void yaxis(const char* patORpfx, const char* title) {
      TRegexp reg(patORpfx, kFALSE);

      TList* list = gDirectory->GetList() ;
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      while (obj = iter->Next()) {
         if (! (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(THStack::Class()))) continue;

         TString name = obj->GetName();

         if (TString(patORpfx).MaybeRegexp()) {
            if (TString(obj->GetName()).Index(reg) < 0 ) continue;
         } else if (! name.BeginsWith(patORpfx)) continue;

         if (obj->InheritsFrom(TH1::Class()))
            ((TH1*)obj)->GetYaxis()->SetTitle(title);
         if (obj->InheritsFrom(THStack::Class())) {
            ((THStack*)obj)->Draw();
            ((THStack*)obj)->GetYaxis()->SetTitle(title);
         }
      }
   }
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:25,代码来源:histtools.C

示例4: normalize

   void normalize(const char* patORpfx) {
      TRegexp reg(patORpfx, kFALSE);

      TList* list = gDirectory->GetList() ;
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      while (obj = iter->Next()) {
         if (! obj->InheritsFrom(TH1::Class())) continue;

         TString name = obj->GetName();

         if (TString(patORpfx).MaybeRegexp()) {
            if (TString(obj->GetName()).Index(reg) < 0 ) continue;
         } else if (! name.BeginsWith(patORpfx)) continue;

         Double_t integral = 0;

         if (obj->InheritsFrom(TH2::Class()))
            integral = ((TH2*)obj)->Integral();
         else
            integral = ((TH1*)obj)->Integral();

         if (integral) {
            ((TH1*)obj)->Sumw2();
            ((TH1*)obj)->Scale(1./integral);
         }
      }
   }
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:30,代码来源:histtools.C

示例5: singleFile

void singleFile(TString name, double scalingFactor){
  // get the files
  loadingFiles(name); 
  // ---------------------------------------
  // !!! definition of output file(name) !!!
  // ---------------------------------------
  std::string path = (string)(name);
  size_t separator = path.find_last_of("/");
  TString file = (TString)(path.substr(separator+1));
  //  std::cout << "path: " << path << std::endl;
  //  std::cout << "separator: " << separator << std::endl;
  //  std::cout << "file: " << file << std::endl;

  TString outputfile="./diffXSecFromSignal/analysisRootFilesL1CorrPU/"+file+".root";
  TFile f(outputfile, "recreate");
  std::cout << "output file: " << outputfile << std::endl;
  std::cout << "scaling factor: " << setprecision(9) << fixed << scalingFactor;
  // ---------------------------------------------------------
  // !!! list of plots you want to combine !!!
  // and their directories within the input samples
  // example: addAndWeight("MyPlotFolder", "MyPlot", luminosity, f)
  // ---------------------------------------------------------
  TString folder ="";
  TString plot = "";
  // go to file
  files_[0]->cd();
  // loop objects in file
  TIter fileIterator(gDirectory->GetListOfKeys());
  TKey *fileKey;
  while( (fileKey = (TKey*)fileIterator()) ) {
    TObject *fileObject = fileKey->ReadObj(); 
    // check if object is a directory
    if(fileObject->InheritsFrom("TDirectory")){
      folder = (TString)fileObject->GetName();
      std::cout << std::endl << " - folder: " << folder << std::endl << "   plots: ";
      // go to directory
      ((TDirectory*)fileObject)->cd();
      // loop objects in directory
      TIter folderIterator(gDirectory->GetListOfKeys());
      TKey *folderKey;
      while( (folderKey = (TKey*)folderIterator()) ) {
	TObject *folderObject = folderKey->ReadObj(); 
	// check if object is a TH1 or TH2
	if( (folderObject->InheritsFrom("TH1")) || (folderObject->InheritsFrom("TH2"))){
	  plot = folderObject->GetName();
	  addAndWeight(folder, plot, f, scalingFactor);
	}
      }
    }
  }
  files_[0]->Close();
  

  f.Close();
}
开发者ID:eschliec,项目名称:TopAnalysis,代码行数:55,代码来源:combineAndWeightAnalysisFiles.C

示例6: WorkOnPad

void WorkOnPad(TPad* pad) {
	TIter nextobj(pad->GetListOfPrimitives());
	TObject *obj;
	while (obj = nextobj()) {
		//cout << "Pad Object: " << obj->GetName() << endl;
		if(obj->InheritsFrom("TPad")) {
			WorkOnPad((TPad*)obj);
		}
		else if(obj->InheritsFrom("TH1")) {
			WorkOnHist((TH1*)obj);
		}
	}
}
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:13,代码来源:ExtractAllHistograms.C

示例7: ColourStatsBoxes

//________________________________________________________
void GFHistManager::ColourStatsBoxes(GFHistArray *hists) const
{
  // colours stats boxes like hists' line colors and moves the next to each other
  if (!hists) return;
  Double_t x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
  for (Int_t iH = 0; iH < hists->GetEntriesFast(); ++iH) {
    TH1 *h = hists->At(iH);
    if (!h) continue;
    TObject *statObj = h->GetListOfFunctions()->FindObject("stats");
    if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
      TPaveStats *stats = static_cast<TPaveStats*>(statObj);
      stats->SetLineColor(hists->At(iH)->GetLineColor());
      stats->SetTextColor(hists->At(iH)->GetLineColor());
      stats->SetX1NDC(x1);
      stats->SetX2NDC(x2);
      stats->SetY1NDC(y1);
      stats->SetY2NDC(y2);
      y2 = y1 - 0.005; // shift down 2
      y1 = y2 - (fStatsY2 - fStatsY1); // shift down 1
      if (y1 < 0.) {
	y1 = fStatsY1; y2 = fStatsY2; // restart y-positions
	x2 = x1 - 0.005; // shift left 2
	x1 = x2 - (fStatsX2 - fStatsX1); // shift left 1
	if (x1 < 0.) { // give up, start again:
	  x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
	}
      }
    } else if (gStyle->GetOptStat() != 0) { // failure in case changed in list via TExec....
      this->Warning("ColourStatsBoxes", "No stats found for %s", hists->At(iH)->GetName());
    }
  }
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:33,代码来源:GFHistManager.C

示例8: Terminate

void rdphi::Terminate()
{
//cout << "total event: " << NevtAll << "rejected: " << rejected_events << endl; 

  TFile *f = new TFile("output.root","RECREATE");

  //Write output Histograms
  TList *tl = GetOutputList();
  int l = tl->GetEntries();
  for ( int i = 0 ; i < l ; i++ )
  {
    TObject *o = tl->At(i);

    if ( o->InheritsFrom("TH1") )
    {
      cout << "TresChorros: Saving Histogram: "
          << "  Class: " << o->ClassName()  
          << "  Name: "<< o->GetName() 
          << "  Title: " << o->GetTitle()
          << " " 
          << endl << flush;
      o->Write();
    }
    }
  f->Flush();
  f->Close();  

}
开发者ID:affablelochan,项目名称:DataAnalysis,代码行数:28,代码来源:rdphi_v1.C

示例9: scalebins

   void scalebins(const char* patORpfx, Double_t scale) {
      TRegexp reg(patORpfx, kFALSE);

      TList* list = gDirectory->GetList() ;
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      while (obj = iter->Next()) {
         if (! obj->InheritsFrom(TH1::Class())) continue;

         TString name = obj->GetName();

         if (TString(patORpfx).MaybeRegexp()) {
            if (TString(obj->GetName()).Index(reg) < 0 ) continue;
         } else if (! name.BeginsWith(patORpfx)) continue;

         Double_t binWidth, binContent, binError, newBinContent, newBinError;
         for (Int_t i = 1; i <= ((TH1*)obj)->GetNbinsX(); ++i) {
            binWidth = ((TH1*)obj)->GetBinWidth(i);
            binContent = ((TH1*)obj)->GetBinContent(i);
            binError = ((TH1*)obj)->GetBinError(i);
            newBinContent = (binContent*scale)/binWidth;
            newBinError = (binError*scale)/binWidth;

            ((TH1*)obj)->SetBinContent(i, newBinContent);
            ((TH1*)obj)->SetBinError(i, newBinContent);
            // Rename y axis with scale
         }
      }
   }
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:31,代码来源:histtools.C

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

示例11: ExtractAllHistograms

TList* ExtractAllHistograms(TFile* f) {
	TIter nextkey(f->GetListOfKeys());
	TKey *key;
	result = new TList();
	while (key = (TKey*)nextkey()) {
		cout << "Key: " << key->GetName() << endl;
		TObject* obj = key->ReadObj();
		if(obj->InheritsFrom("TPad")) {
			WorkOnPad((TPad*)obj);
		}
		else if(obj->InheritsFrom("TH1")) {
			WorkOnHist((TH1*)obj);
		}
	}
	return result;
}
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:16,代码来源:ExtractAllHistograms.C

示例12: colors

   void colors(TCanvas* canvas, Color_t color = 1) {
      if(! canvas) return 0;

      TList* list = canvas->GetListOfPrimitives();
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      //Hist color iterator
      Int_t colorIt = color;

      while (obj = iter->Next()) {
         if (! obj->InheritsFrom(TH1::Class())) continue;

         //yellow
         if (colorIt == 5)
            ++colorIt;

         hist::color(obj->GetName(), colorIt);
         if (colorIt == 40)
            colorIt = 1;
         else 
            ++colorIt;
      }
   }
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:25,代码来源:histtools.C

示例13: SetIDFuncInTelescopes

void KVRTGIDManager::SetIDFuncInTelescopes(UInt_t run){
	// For each identification function of the global list which is valid for this run, we add it in the associated telescope which
	// have to inherits from KVTGIDManager and from a KVIDTelescope.

	TIter next(fIDGlobalList);
	KVTGID *tgid = NULL;

	while( (tgid = (KVTGID *)next())){

		if(!tgid->IsValidForRun(run)) continue;

		// this list have to be deleted after use
                TCollection *lidtel = GetIDTelescopesForTGID(tgid);
		TIter nextidt(lidtel);
		TObject        *idt   = NULL;
		KVRTGIDManager *tgidm = NULL;

		while( (idt = nextidt()) ){
			if(!idt->InheritsFrom("KVRTGIDManager")){
				Error("KVRTGIDManager::SetIDFuncInTelescopes","The IDtelescope %s does not inherit from KVRTGIDManager",idt->GetName());
				continue;
			}
			tgidm = (KVRTGIDManager* )idt->IsA()->DynamicCast(KVRTGIDManager::Class(),idt);
			tgidm->SetTGID(tgid);
		}
		delete lidtel;
	}
}
开发者ID:pwigg,项目名称:kaliveda,代码行数:28,代码来源:KVRTGIDManager.cpp

示例14: legend

   TLegend* legend(THStack* stack, Option_t* option = "lp", Bool_t addColor = kFALSE, Int_t token = -1,
                   Float_t xmin = 0.50, Float_t ymin = 0.51, Float_t xmax = 0.85, Float_t ymax = 0.92) {
      if(! stack) return 0;

      TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
      TList* list = stack->GetHists();
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      //Hist color iterator
      Int_t colorIt = 1;

      while (obj = iter->Next()) {
         if (! obj->InheritsFrom(TH1::Class())) continue;

         if (addColor) {
            hist::color(obj->GetName(), colorIt);
            ++colorIt;
         }

         if (token == -1)
            leg->AddEntry(obj, obj->GetTitle(), option);
         else {
            TString name(obj->GetName());
            TObjArray* a = name.Tokenize("_");
            if (a->GetEntries() <= token)
               leg->AddEntry(obj, obj->GetName(), option);
            else
               leg->AddEntry(obj, a->At(token)->GetName(), option);
         }
      }

      return leg;
   }
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:35,代码来源:histtools.C

示例15: scaleToRate

void scaleToRate(const char* collectionName, double rateFactor) {
  TRegexp reg(collectionName, kTRUE);
  
  //    gDirectory->ls();
  TList* list = gDirectory->GetList() ;
  TIterator* iter = list->MakeIterator();
  TObject* obj = 0;
  
  while (obj = iter->Next()) {
    if (! obj->InheritsFrom(TH1::Class())) {
      //      cout << "bugger" << endl;
      continue;
    }
    
    
    TString name = obj->GetName();
    cout << "Testing name: " << name << " against " << collectionName << endl;
    
    if (TString(collectionName).MaybeRegexp()) {
      cout << "we have a possible match" << endl;
      cout << "Trying to match to " << TString(obj->GetName()) << endl;
      if (TString(obj->GetName()).Index(reg) < 0 ) {
	cout << "failure here.  Argument returns " << TString(obj->GetName()).Index(reg) << endl;
	continue;
      }
    }
    else if (! name.BeginsWith(collectionName)) continue;
    
    cout << "We're trying to scale" << name << endl;
    ((TH1*)obj)->Scale(rateFactor);
    
  }
  
}
开发者ID:vlimant,项目名称:usercode,代码行数:34,代码来源:rate_histMaker.C


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