[Bio] / MExplorer / xduGen.cc Repository:
ViewVC logotype

Diff of /MExplorer/xduGen.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Dec 20 20:12:20 2002 UTC revision 1.2, Mon Jan 6 23:32:23 2003 UTC
# Line 3  Line 3 
3  //  //
4  //************************************************************************  //************************************************************************
5    
6    #include <stdio.h>
7  #include <string>  #include <string>
8  #include <vector>  #include <vector>
9  #include <iterator>  #include <iterator>
# Line 13  Line 14 
14  #include "RecoReadoutOracle/EFRecoElemImpl.hh"  #include "RecoReadoutOracle/EFRecoElemImpl.hh"
15  #include "RecoReadoutOracle/OracleMgr.hh"  #include "RecoReadoutOracle/OracleMgr.hh"
16    
17    void usage( void );
18  int  xduGen( RecoElem& r, std::string path );  int  xduGen( RecoElem& r, std::string path );
19  void editName( std::string& s );  void editName( std::string& s );
20    
21  //************************************************************************  //************************************************************************
22  int  int
23  main(int argc, char* arg[] ) {  main(int argc, char* argv[] ) {
24  //************************************************************************  //************************************************************************
25    
26    // Normally, we'd consult a Reco dictionary to find a reco we cared    if ( 2 != argc ) {
27    // about.  But that's not built yet.  So, I'm going to cook up      usage();
28    // the top of a reconstruction I know is in the database.  In real      return 1;
29    // life, you'd peruse the dictionary and just be handed a RecoElem    }
30    // to mess with.  
31      unsigned int topNodeId = atoi( argv[1] );
32      cout << "going for node " << topNodeId << endl;
33    
34    
35    OracleMgr::mgr().startJob();    OracleMgr::mgr().startJob();
36    RecoElem recoTop( new EFRecoElemImpl(  "Top of Everything", 20000 ));    RecoElem recoTop( new EFRecoElemImpl(  "FoobieBletch", topNodeId ));
37    
38    // OK.  Mess with it.  Get its kids and print them out.    // OK.  Mess with it.  Get its kids and print them out.
39    
40    std::string path="";    std::string path="";
41    xduGen( recoTop, path );    xduGen( recoTop, path );
42    
43      OracleMgr::mgr().endJob();
44    return 0;    return 0;
45  }  }
46    
47  //************************************************************************  //************************************************************************
48    void
49    usage( void ) {
50    //************************************************************************
51      cout << endl;
52      cout << "usage: xduGen TopNodeId" << endl;
53      cout << "   TopNodeId is the ProcessId of the top of the reconstruction." << endl;
54      cout << "   You can find the top node of a reconstruction with lsCat," << endl;
55      cout << "   which lists the Catalog." << endl;
56      cout << endl;
57    
58      return;
59    }
60    
61  int  int
62  xduGen( RecoElem& r, std::string path ) {  xduGen( RecoElem& r, std::string path ) {
63  //************************************************************************  //************************************************************************
64    int         result  = 0;    int         result  = 0;
65    std::string s;    std::string s;
66      enum        {MaxDigits = 32};
67      char        idAsStr[32];
68    
69    vector<RecoElem>& kids = r.getSubElements( );    vector<RecoElem>& kids = r.getSubElements( );
70    int nKid = kids.size();    int nKid = kids.size();
# Line 51  Line 72 
72    s=r.getName();                // copy so we don't mod the orig    s=r.getName();                // copy so we don't mod the orig
73    editName( s );                // xdu has bugs.  must mod the name a little    editName( s );                // xdu has bugs.  must mod the name a little
74    if ( 0 == nKid ) {    if ( 0 == nKid ) {
75      cout << "1 " << path << "/" << s << endl;      cout << "1 " << path << "/" <<s << "[" << r.getId() << "]" << endl;
76      return 1;      return 1;
77    } else {    } else {
78      for (int i=0; i<nKid; i++ ) {      for (int i=0; i<nKid; i++ ) {
79        result += xduGen( kids[i], path+"/"+s );        snprintf(idAsStr, MaxDigits, "%d", r.getId() );
80          result += xduGen( kids[i], path + "/" + s + "[" + idAsStr + "]" );
81      }      }
82      cout << result << " " << path+"/"+s << endl;      cout << result << " " << path << "/" << s << "[" <<  r.getId() << "]"
83             << endl;
84      return result;      return result;
85    }    }
86  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3