Ignore:
Timestamp:
10/27/19 18:16:29 (5 years ago)
Author:
tbretz
Message:
Spaces removed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/root2csv.cc

    r19810 r19811  
    418418    // ------------------------- Setup all branches in tree -------------------
    419419
    420         TIter Next(leaves);
    421         TObject *o = 0;
    422         while ((o=Next()))
    423         {
    424             TLeaf *L = dynamic_cast<TLeaf*>(o);//c.GetLeaf(o->GetName());
    425             if (!L)
    426                 continue;
    427 
    428             string name = L->GetName();
     420    TIter Next(leaves);
     421    TObject *o = 0;
     422    while ((o=Next()))
     423    {
     424        TLeaf *L = dynamic_cast<TLeaf*>(o);//c.GetLeaf(o->GetName());
     425        if (!L)
     426            continue;
     427
     428        string name = L->GetName();
     429        if (verbose>2)
     430            cout << '\n' << L->GetTitle() << " {" << L->GetTypeName() << "}";
     431
     432        const string tn = L->GetTypeName();
     433
     434        // Check if this is a basic type, otherwise skip
     435        const auto it = FileEntry::LUT.root(tn);
     436        if (it==FileEntry::LUT.cend())
     437        {
    429438            if (verbose>2)
    430                 cout << '\n' << L->GetTitle() << " {" << L->GetTypeName() << "}";
    431 
    432             const string tn = L->GetTypeName();
    433 
    434             // Check if this is a basic type, otherwise skip
    435             const auto it = FileEntry::LUT.root(tn);
    436             if (it==FileEntry::LUT.cend())
     439                cout << " (-n/a-)";
     440            continue;
     441        }
     442
     443        // Check if this is an array, otherwise skip
     444        if (L->GetLenStatic()!=L->GetLen())
     445        {
     446            if (verbose>2)
     447                cout << " (-skipped-)";
     448            continue;
     449        }
     450
     451        // Check for renaming via auto-alias
     452        for (auto m=autoalias.cbegin(); m!=autoalias.cend(); m++)
     453            name = boost::regex_replace(name, boost::regex(m->first), m->second);
     454
     455        // if renaming has changed name, define alias
     456        if (name!=L->GetName())
     457        {
     458            if (!c.SetAlias(name.c_str(), L->GetName()))
    437459            {
    438                 if (verbose>2)
    439                     cout << " (-n/a-)";
    440                 continue;
     460                cerr << "\nERROR - Alias could not be established!\n";
     461                cerr << "   " << name << " = " << L->GetName() << endl;
     462                return 1;
    441463            }
    442 
    443             // Check if this is an array, otherwise skip
    444             if (L->GetLenStatic()!=L->GetLen())
     464            if (verbose==1 || verbose==2)
     465                cout << "\nAuto-alias: " << name << " = " << L->GetName();
     466            if (verbose>2)
     467                cout << " <alias:" << name << ">";
     468        }
     469
     470        // Check whether the un-aliased column is in the ignore list
     471        bool found = skip;
     472        for (auto b=_ignore.cbegin(); b!=_ignore.cend(); b++)
     473        {
     474            if (boost::regex_match(L->GetName(), boost::regex(*b)))
    445475            {
    446                 if (verbose>2)
    447                     cout << " (-skipped-)";
    448                 continue;
     476                found = true;
     477                break;
    449478            }
    450 
    451             // Check for renaming via auto-alias
    452             for (auto m=autoalias.cbegin(); m!=autoalias.cend(); m++)
    453                 name = boost::regex_replace(name, boost::regex(m->first), m->second);
    454 
    455             // if renaming has changed name, define alias
    456             if (name!=L->GetName())
     479        }
     480
     481        // Check whether the aliased column is in the ignore list
     482        for (auto b=_ignore.cbegin(); b!=_ignore.cend(); b++)
     483        {
     484            if (boost::regex_match(name.c_str(), boost::regex(*b)))
    457485            {
    458                 if (!c.SetAlias(name.c_str(), L->GetName()))
    459                 {
    460                     cerr << "\nERROR - Alias could not be established!\n";
    461                     cerr << "   " << name << " = " << L->GetName() << endl;
    462                     return 1;
    463                 }
    464                 if (verbose==1 || verbose==2)
    465                     cout << "\nAuto-alias: " << name << " = " << L->GetName();
    466                 if (verbose>2)
    467                     cout << " <alias:" << name << ">";
     486                found = true;
     487                break;
    468488            }
    469 
    470             // Check whether the un-aliased column is in the ignore list
    471             bool found = skip;
    472             for (auto b=_ignore.cbegin(); b!=_ignore.cend(); b++)
    473             {
    474                 if (boost::regex_match(L->GetName(), boost::regex(*b)))
    475                 {
    476                     found = true;
    477                     break;
    478                 }
    479             }
    480 
    481             // Check whether the aliased column is in the ignore list
    482             for (auto b=_ignore.cbegin(); b!=_ignore.cend(); b++)
    483             {
    484                 if (boost::regex_match(name.c_str(), boost::regex(*b)))
    485                 {
    486                     found = true;
    487                     break;
    488                 }
    489             }
    490 
    491             if (found)
    492             {
    493                 if (verbose>2)
    494                     cout << " (-ignored-)";
    495                 continue;
    496             }
    497 
    498             vec.emplace_back(L->GetName(), name, it->type, L->GetLenStatic());
    499             c.SetBranchAddress(L->GetName(), vec.back().ptr);
    500         }
    501 
    502         if (verbose>0)
    503         {
    504             cout << '\n';
    505             if (skip)
    506                 cout << "Default columns skipped: ";
    507             cout << vec.size() << " default leaf/leaves setup for reading." << endl;
    508         }
     489        }
     490
     491        if (found)
     492        {
     493            if (verbose>2)
     494                cout << " (-ignored-)";
     495            continue;
     496        }
     497
     498        vec.emplace_back(L->GetName(), name, it->type, L->GetLenStatic());
     499        c.SetBranchAddress(L->GetName(), vec.back().ptr);
     500    }
     501
     502    if (verbose>0)
     503    {
     504        cout << '\n';
     505        if (skip)
     506            cout << "Default columns skipped: ";
     507        cout << vec.size() << " default leaf/leaves setup for reading." << endl;
     508    }
    509509
    510510    // ------------------- Configure manual aliases ----------------------------
Note: See TracChangeset for help on using the changeset viewer.