• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TTree

///
/// Converts a RooDataSet to a TTree which then can be
/// browsed.
///
TTree* Utils::convertRooDatasetToTTree(RooDataSet *d)
{
	// set up the TTree based on the content of the first
	// row of the dataset
	map<string,float> variables;  ///< the proxy variables
	TTree* t = new TTree("tree", "tree");
	TIterator* it = d->get(0)->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		variables.insert(pair<string,float>(p->GetName(),p->getVal()));
		t->Branch(p->GetName(), &variables[p->GetName()], TString(p->GetName())+"/F");
	}
	delete it;

	// loop over the dataset, filling the tree
	int nEntries = d->sumEntries();
	for ( int i=0; i<nEntries; i++ ){
		it = d->get(i)->createIterator();
		while ( RooRealVar* p = (RooRealVar*)it->Next() ){
			variables[p->GetName()] = p->getVal();
		}
		delete it;
		t->Fill();
	}

	return t;
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:30,代码来源:Utils.cpp


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


示例3: NoLabelInicialisationException

QString Include::GetFile()
{
	if(Root.IsNull())
	{
		throw NoLabelInicialisationException("Include: label do not inicialised.");
	}

	if(Root.IsNull())
	{
		throw NoLabelInicialisationException("Include: label do not inicialised.");
	}

	TIterator TITER;

	TITER.Init(Root, false);
	while (TITER.More())
	{
		TElement val = TITER.Value();
		QString name = val.GetName();
		if(name == "File name")
		{
			TString valint = (TString)val;
			return valint.GetValue();
		}
		TITER.Next();
	}

	return "";
}
开发者ID:laduga,项目名称:pradis,代码行数:29,代码来源:Include.cpp


示例4: NoLabelInicialisationException

af::TList Scheme::GetIncludeList()
{
	if(Root.IsNull())
	{
		throw NoLabelInicialisationException("Scheme: label do not inicialised.");
	}
	
	
//	return IncludeList;
	
	
	TIterator TITER;

	TList valls;
	TITER.Init(Root, false);
	while (TITER.More())
	{
		TList val = (TList)TITER.Value();
		QString name = val.GetName();

		if(name == "IncludeList")
		{
			return val;
		}
		TITER.Next();
	}

	TElement e(Root);
	throw NoExistException("Scheme: Include List do not exists.", e);

	return valls;
}
开发者ID:laduga,项目名称:pradis,代码行数:32,代码来源:Scheme.cpp


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


示例6: mergeNamedSets

///
/// Merge two named sets of variables inside a RooWorkspace.
/// Duplicate variables will only be contained once.
///
void Utils::mergeNamedSets(RooWorkspace *w, TString mergedSet, TString set1, TString set2)
{
	// 1. fill all variables into a vector
	vector<string> varsAll;
	TIterator* it = w->set(set1)->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ) varsAll.push_back(p->GetName());
	delete it;
	it = w->set(set2)->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ) varsAll.push_back(p->GetName());
	delete it;

	// 2. remove duplicates
	sort(varsAll.begin(), varsAll.end());
	vector<string> vars;
	vars.push_back(varsAll[0]);
	string previous = varsAll[0];
	for ( int i=1; i<varsAll.size(); i++ ){
		if ( previous==varsAll[i] ) continue;
		vars.push_back(varsAll[i]);
		previous=varsAll[i];
	}

	// 3. make new, combined set on the workspace
	TString varsCommaList = "";
	for ( int i=0; i<vars.size(); i++ ){
		varsCommaList.Append(vars[i]);
		if ( i<vars.size()-1 ) varsCommaList.Append(",");
	}
	w->defineSet(mergedSet, varsCommaList);
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:34,代码来源:Utils.cpp


示例7: floatParameters

///
/// Float each parameter in the named set "parname" inside workspace "w".
///
void Utils::floatParameters(RooWorkspace* w, TString parname)
{
	TIterator* it = w->set(parname)->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		p->setConstant(false);
	}
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:10,代码来源:Utils.cpp


示例8: assert

/**
 * @brief Write all TObjects from a given TCollection into a certain directory structure in the file
 *
 * @param col pointer to a TCollection-based container
 * @param dirname name of a directory inside the output file to which the objects should be written
 * @param subdirname optional name of a subdirectory inside dirname to which the objects should be written
 *
 * This method whites all TObject-based objects contained in the TCollection-based container (see ROOT documentation)
 * into a directory whose name is given by dirname inside the output file. If dirname does not exist
 * in the output file, it will be created. Otherwise, contents of the col collection will be appended to an existing
 * directory.
 *
 * If the optional subdirectory name is specified (subdirname parameter, defaults to empty string) then the
 * contents of the collection will be written to "dirname/subdirname". If the "subdirname" directory does not
 * exist inside the "dirname" directory, it will be created.
 *
 */
void JPetWriter::writeCollection(const TCollection* col, const char* dirname, const char* subdirname)
{

  TDirectory* current =  fFile->GetDirectory(dirname);

  if (!current) {
    current = fFile->mkdir(dirname);
  }

  assert(current);

  // use a subdirectory if requested by user
  if (!std::string(subdirname).empty()) {

    if (current->GetDirectory(subdirname)) {
      current = current->GetDirectory(subdirname);
    } else {
      current = current->mkdir(subdirname);
    }
  }

  assert(current);

  current->cd();

  TIterator* it = col->MakeIterator();

  TObject* obj;
  while ((obj = it->Next())) {
    obj->Write();
  }

  fFile->cd();
}
开发者ID:flukson,项目名称:j-pet-framework,代码行数:51,代码来源:JPetWriter.cpp


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


示例10: NoLabelInicialisationException

af::Model OutValue::GetModelOfValue()
{
	if(Root.IsNull())
	{
		throw NoLabelInicialisationException("OutValue: label do not inicialised.");
	}

	TIterator TITER;

	Model vallr;
	TITER.Init(Root, false);
	while (TITER.More())
	{
		Model val = (Model)TITER.Value();
		QString name = val.GetName();

		if(name == "Model")
		{
			return val;
		}
		TITER.Next();
	}

	TElement e(Root);
	throw NoExistException("OutValue: Model Of Value do not exists.", e);

	return vallr;
}
开发者ID:laduga,项目名称:pradis,代码行数:28,代码来源:OutValue.cpp


示例11: eff

// Method by name
TH1F* eff(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;
  TH1F* h1=0;
  TH1F* h2=0;
  TString str1 = Form("%s",name1);
  TString str2 = Form("%s",name2);
  while(obj=iter->Next()) {
    TString objName = obj->GetName();
    if (objName == str1) h1 = (TH1F*) obj;
    if (objName == str2) h2 = (TH1F*) 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
  TH1F* temp = eff(h1, h2, name);
  return temp;
}
开发者ID:cmstas,项目名称:fakeRate,代码行数:33,代码来源:eff.C


示例12: loadParameterLimits

///
/// load Parameter limits
/// by default the "free" limit is loaded, can be changed to "phys" by command line argument
///
void MethodDatasetsProbScan::loadParameterLimits() {
    TString rangeName = arg->enforcePhysRange ? "phys" : "free";
    if ( arg->debug ) cout << "DEBUG in Combiner::loadParameterLimits() : loading parameter ranges: " << rangeName << endl;
    TIterator* it = w->set(pdf->getParName())->createIterator();
    while ( RooRealVar* p = (RooRealVar*)it->Next() ) setLimit(w, p->GetName(), rangeName);
    delete it;
}
开发者ID:gammacombo,项目名称:gammacombo,代码行数:11,代码来源:MethodDatasetsProbScan.cpp


示例13: while

RooFitResult *breakDownFit(RooSimultaneous *m, RooAbsData *d, RooRealVar *mass, bool precondition = false){
	if(precondition){
		 const char *catsName = m->indexCat().GetName();
		 TIterator *it = m->indexCat().typeIterator();
		 while(RooCatType* ci = dynamic_cast<RooCatType*>(it->Next())) {
			 const Text_t *catLabel = ci->GetName();
			 RooAbsPdf *pdf = m->getPdf(Form("%s",catLabel));
			 RooAbsData *reduced = d->reduce(SelectVars(*mass),Cut(Form("%s==%s::%s",catsName, catsName, catLabel)));
			 RooFitResult *r = pdf->fitTo(*reduced,PrintLevel(-1),Save(),
					 Minimizer("Minuit2","migrad"),Strategy(0),Hesse(false),Minos(false),Optimize(false)
					 );
			 cout << catsName << " " << catLabel << " M2migrad0 " << r->status() << endl;
			 if(r->status()!=0){
				 RooFitResult *r = pdf->fitTo(*reduced, PrintLevel(-1), Save());
				 cout << catsName << " " << catLabel << " Mmigrad1 " << r->status() << endl;
			 }
		 }
	}

	RooFitResult *r = m->fitTo(*d, Save(), PrintLevel(-1),
			Strategy(0));
	cout << "Global fit Mmigrad0 " << r->status() << endl;
	if(r->status()!=0){
	 RooFitResult *r = m->fitTo(*d, PrintLevel(-1), Save(),
			 Minimizer("Minuit","minimize"),Strategy(2));
	 cout << "Global fit Mminimize2 " << r->status() << endl;
	 return r;
	}

	return r;
}
开发者ID:h2gglobe,项目名称:UserCode,代码行数:31,代码来源:diySeparation.cpp


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


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


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


示例17: getParameters

///
/// Fills vector with floating pars names
///
void Utils::getParameters(const RooFitResult &result, std::vector<TString> &names){
	RooArgList pars           = result.floatParsFinal();
	TIterator * it            = pars.createIterator();
	while(RooRealVar* p = (RooRealVar*) it->Next()){
		names.push_back(TString(p->GetName()));
	}
};
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:10,代码来源:Utils.cpp


示例18: switch

void PDF_GLWADS_DKDpi_K3pi::setObservables(config c)
{
	switch(c)
	{
		case truth:{
					   setObservablesTruth();
					   break;
				   }
		case toy:{
					 setObservablesToy();
					 break;
				 }
		case lumi1fb:{
						 obsValSource = "1fb-1, ExpNll/sept2012K3PIResult.root";
						 TString File = this->dir+"/ExpNll/sept2012K3PIResult.root";
						 TFile *fr = TFile::Open(File);
						 RooFitResult *r = (RooFitResult*)fr->Get("fitresult_model_reducedData_binned");
						 assert(r);
						 TIterator* it = observables->createIterator();
						 while ( RooRealVar* pObs = (RooRealVar*)it->Next() )
						 {
							 RooRealVar* pRes = (RooRealVar*)r->floatParsFinal().find(obsTmkToMalcolm(pObs->GetName()));
							 pObs->setVal(pRes->getVal());
						 }
						 fr->Close();
						 delete r;
						 delete fr;
						 break;
					 }
		case lumi3fb:{
						 obsValSource = "3fb-1 ANA v7 unblind"; // https://twiki.cern.ch/twiki/pub/LHCbPhysics/B2D0K/LHCb-ANA-2014-071-v7.pdf (see Vavas email 04/08/15)

						 // these get transformed over from the new inputs using ExpNll/transportGLWADS_new_to_old.py
						 // in the case of the DK only (robust) combination some of the observables don't exist
						 // usemap as the temp store
						 std::map< TString, double > vals;
						 vals["rkp_k3pi_obs"]      =  0.0793;
						 vals["afav_dk_k3pi_obs"]  =  -0.0004;
						 vals["afav_dpi_k3pi_obs"] =  0.0;
						 vals["rp_dk_k3pi_obs"]    =  0.018369;
						 vals["rm_dk_k3pi_obs"]    =  0.009611;
						 vals["rp_dpi_k3pi_obs"]   =  0.003683;
						 vals["rm_dpi_k3pi_obs"]   =  0.003857;

						 // now can loop the observables and set the values
						 TIterator* it = observables->createIterator();
						 while ( RooRealVar* pObs = (RooRealVar*)it->Next() ){
							 pObs->setVal(vals[pObs->GetName()]);
						 }

						 vals.clear();
						 break;
				}
		default:{
					cout << "PDF_GLWADS_DKDpi_K3pi::setObservables() : ERROR : config "+ConfigToTString(c)+" not found." << endl;
					exit(1);
				}
	}
}
开发者ID:PashaPodolsky,项目名称:pygammacombo,代码行数:59,代码来源:PDF_GLWADS_DKDpi_K3pi.cpp


示例19: setParameters

///
/// Set each parameter in setMe to the value found in values.
/// Do nothing if parameter is not found in values.
///
void Utils::setParameters(const RooAbsCollection* setMe, const RooAbsCollection* values)
{
	TIterator* it = setMe->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		RooRealVar *var = (RooRealVar*)values->find(p->GetName());
		if ( var ) p->setVal(var->getVal());
	}
	delete it;
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:13,代码来源:Utils.cpp


示例20: randomizeParameters

//
// Randomize all parameters of a set defined in a given
// workspace.
//
void Utils::randomizeParameters(RooWorkspace* w, TString setname)
{
	TIterator* it = w->set(setname)->createIterator();
	while ( RooRealVar* p = (RooRealVar*)it->Next() ){
		if ( p->isConstant() ) continue;
		// sample from uniform distribution
		p->randomize();
	}
}
开发者ID:KonstantinSchubert,项目名称:gammacombo,代码行数:13,代码来源:Utils.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TJNICache类代码示例发布时间:2022-05-31
下一篇:
C++ TIter类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap