[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.1.1, Fri Dec 20 20:12:20 2002 UTC revision 1.3, Fri Mar 7 23:10:00 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 10  Line 11 
11  #include "RecoReadout/RecoElem.hh"  #include "RecoReadout/RecoElem.hh"
12  #include "RecoReadout/Reaction.hh"  #include "RecoReadout/Reaction.hh"
13    
 #include "RecoReadoutOracle/EFRecoElemImpl.hh"  
 #include "RecoReadoutOracle/OracleMgr.hh"  
   
14  int  xduGen( RecoElem& r, std::string path );  int  xduGen( RecoElem& r, std::string path );
15  void editName( std::string& s );  void editName( std::string& s );
16    
 //************************************************************************  
 int  
 main(int argc, char* arg[] ) {  
 //************************************************************************  
   
   // Normally, we'd consult a Reco dictionary to find a reco we cared  
   // about.  But that's not built yet.  So, I'm going to cook up  
   // the top of a reconstruction I know is in the database.  In real  
   // life, you'd peruse the dictionary and just be handed a RecoElem  
   // to mess with.  
   
   OracleMgr::mgr().startJob();  
   RecoElem recoTop( new EFRecoElemImpl(  "Top of Everything", 20000 ));  
17    
   // OK.  Mess with it.  Get its kids and print them out.  
   
   std::string path="";  
   xduGen( recoTop, path );  
   
   return 0;  
 }  
   
 //************************************************************************  
18  int  int
19  xduGen( RecoElem& r, std::string path ) {  xduGen( RecoElem& r, std::string path ) {
20  //************************************************************************  //************************************************************************
21    int         result  = 0;    int         result  = 0;
22    std::string s;    std::string s;
23      enum        {MaxDigits = 32};
24      char        idAsStr[32];
25    
26    vector<RecoElem>& kids = r.getSubElements( );    vector<RecoElem>& kids = r.getSubElements( );
27    int nKid = kids.size();    int nKid = kids.size();
# Line 51  Line 29 
29    s=r.getName();                // copy so we don't mod the orig    s=r.getName();                // copy so we don't mod the orig
30    editName( s );                // xdu has bugs.  must mod the name a little    editName( s );                // xdu has bugs.  must mod the name a little
31    if ( 0 == nKid ) {    if ( 0 == nKid ) {
32      cout << "1 " << path << "/" << s << endl;      cout << "1 " << path << "/" <<s << "[" << r.getId() << "]" << endl;
33      return 1;      return 1;
34    } else {    } else {
35      for (int i=0; i<nKid; i++ ) {      for (int i=0; i<nKid; i++ ) {
36        result += xduGen( kids[i], path+"/"+s );        snprintf(idAsStr, MaxDigits, "%d", r.getId() );
37          result += xduGen( kids[i], path + "/" + s + "[" + idAsStr + "]" );
38      }      }
39      cout << result << " " << path+"/"+s << endl;      cout << result << " " << path << "/" << s << "[" <<  r.getId() << "]"
40             << endl;
41      return result;      return result;
42    }    }
43  }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3