本文整理汇总了C++中TIterator类的典型用法代码示例。如果您正苦于以下问题:C++ TIterator类的具体用法?C++ TIterator怎么用?C++ TIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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 "";
}
示例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;
}
示例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
}
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
}