FEDRA emulsion software from the OPERA Collaboration
rwc2edb.cpp File Reference
Include dependency graph for rwc2edb.cpp:

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
65 {
66  char rwcname[256]="\0", edbname[256]="\0", mapname[256]="\0", grsname[256]="\0";
67  char options[256]="\0";
68  bool addmap(false),addgrs(false);
69 
70  bool printusage=(argc<3)?true:false;
71  for (int i = 1; i < argc; i++) { // Skip argv[0] (program name)
72  if (!strcmp(argv[i], "-map")) { // Process optional arguments
73  if (i + 1 <= argc - 1) { sprintf(mapname,argv[++i]); addmap=true; }
74  else printusage=true;
75  }
76  else if (!strcmp(argv[i], "-grs")) { // Process optional arguments
77  if (i + 1 <= argc - 1) { sprintf(grsname,argv[++i]); addgrs=true; }
78  else printusage=true;
79  }
80  else if (!strcmp(argv[i], "-nocl")) strcat(options,"NOCL") ;
81  else if (!strcmp(argv[i], "-asum")) strcat(options,"SUM") ;
82  else if (!strcmp(argv[i], "-clframe")) strcat(options,"CLFRAME") ;
83  else { // Process non-optional arguments here
84  sprintf(rwcname,argv[i++]);
85  sprintf(edbname,argv[i]);
86  }
87  }
88  if(printusage) {
89  cout<< "usage: rwc2edb <input file (.rwc|.rwd|.txt)> <output file (.root)> [options] "<<endl;
90  cout << "\n options: -nocl = do not add the clusters" << endl;
91  cout << " -clframe = fill clusters.eFrame (default empty) -> +4% file size" << endl;
92  cout << " -map filename = add the fiducial marks file (.map) (only mswindows)" << endl;
93  cout << " -grs filename = merge raw data (.rwd) and grains (.txt) " << endl;
94  cout << " (if only grains: rwc2edb fname.txt fname.root)" << endl;
95  cout << " -asum = encode the sum of cluster areas in the segment puls" << endl;
96  cout << " (puls = (sum of clust areas)*1000 + (number of grains)" << endl;
97  return 0;
98  };
99 
100  bool testrun = false;
101  bool txtrun = false ;
102  if(rwcname[strlen(rwcname)-1]=='d') testrun=true; //if we have .rwd first
103  if(rwcname[strlen(rwcname)-1]=='t') txtrun =true; //if we have .txt first
104 
105  EdbRun* outrun;
106  outrun = new EdbRun(edbname,"CREATE");
107 
108  if(testrun)
109  {
110  // Add RWD
111  cout<<"TestRun"<<endl;
112  int fragID = 0;
113  AddRWD(outrun, rwcname, fragID, options);
114 
115  if (addgrs) // Add Clusters file (TXT) ....
116  {
117  char grsoutname[256];
118  strncpy( grsoutname + strlen(rwcname)-3, "grs", 3);
119  sprintf( grsoutname,"%s.root",grsoutname);
120 
121  EdbRun* outrun2;
122  outrun2 = new EdbRun(grsoutname,"CREATE");
123 
124  AddGrainsTXT(outrun2,grsname);
125  outrun2->Print();
126  outrun2->Close();
127  }
128  }
129  else if(txtrun)
130  {
131  // Add clusters file (TXT) ....
132  AddGrainsTXT(outrun,rwcname);
133  }
134  else
135  {
136  // Add RWC and all RWDs
137  printf("options 1: %s\n", options);
138  AddRWC(outrun, rwcname, true,options);
139  if (addmap) AddMAP(outrun, mapname);
140  }
141  outrun->Print();
142  outrun->Close();
143 
144  if (testrun) return 0;
145 }
Definition: EdbRun.h:74
void Close()
Definition: EdbRun.cxx:466
void Print() const
Definition: EdbRun.cxx:607
int AddGrainsTXT(EdbRun *run, char *txtname)
Definition: libDataConversion.cpp:340
int AddMAP(EdbRun *run, char *mapname)
Definition: libDataConversion.cpp:311
int AddRWD(EdbRun *run, char *rwdname, int fragID, const char *options)
Definition: libDataConversion.cpp:176
int AddRWC(EdbRun *run, char *rwcname, int bAddRWD, const char *options)
Definition: libDataConversion.cpp:64