// make_cbnt_task.cxx // // David Adams // August 2003 // // Executable to create a task for use with dial_cbnt. // // This program should be run from the NFS directory where // the generated HBOOK files are to be written. These will // have names of the form evid.hbk.jobid. // // The following files must be present when this program is run: // init.kumac - PAW macro that creates the histograms // cbnt.f - FORTRAN function called each event to fill these // histograms // // The following files are produced: // cbnt.hbk - HBOOK file with empty histograms // task - XML description of task #include #include #include "dataset_util/FileStatus.h" #include "dataset_util/FileName.h" #include "dataset_util/Text.h" #include "dataset_util/getcwd.h" #include "dataset_xml/XmlParser.h" #include "dataset_file/FileCatalog.h" #include "dataset_id/UniqueIdGenerator.h" #include "dataset_credential/GssCredentialManager.h" #include "dial_task/Task.h" #include "dial_com/dial_init.h" using std::string; using std::cout; using std::endl; using dset::FileCatalog; using dset::GssCredentialManager; using dial::Task; int main(int argc, char* carg[]) { FileStatus fsinit("init.kumac"); FileStatus fsproc("cbnt.f"); FileStatus fshbk("cbnt.hbk"); FileStatus fstsk("task.xml"); // Display help if requested (any argument). if ( argc > 1 ) { cout << "Usage: " << carg[0] << endl; cout << " Generates a DIAL task for use with dial_cbnt." << endl; cout << " " << "Current directory should be NFS mounted" << " to all processing nodes." << endl; cout << " " << "Generated HBOOK files will be written to this directory." << endl; cout << " Input:" << endl; cout << " " << fsinit.name() << " - PAW macro to create histograms" << endl; cout << " " << fsproc.name() << " - FORTRAN function called each event to fill" << endl; cout << " Output:" << endl; cout << " " << fshbk.name() << " - HBOOK file with empty histograms (stays here)" << endl; cout << " " << fstsk.name() << " - XML description of task " "(copy to run directory)" << endl; return 0; } if ( dial::dial_init() != 0 ) { cout << "Initialization failed." << endl; return 1; } // Check files. if ( ! fsinit.is_readable() ) { cout << fsinit.name() << " cannot be read." << endl; return 11; } if ( ! fsproc.is_readable() ) { cout << fsproc.name() << " cannot be read." << endl; return 12; } if ( fshbk.exists() ) { cout << fshbk.name() << " exists." << endl; cout << "Please delete." << endl; return 13; } if ( fstsk.exists() ) { cout << fstsk.name() << " exists." << endl; cout << "Please delete." << endl; return 14; } // Check the task ID generator. if ( ! Task::generator().is_valid() || ! Task::generator().is_global() ) { cout << "Unable to open Task ID generator" << endl; return 21; } // Set the credential for this thread. // This is needed to find owner for task. int cstat = GssCredentialManager::set_default(); if ( cstat != 0 ) { cout << "Unable to find credential" << endl; return 18; } // Create HBOOK file. /* No longer needed - DLA mar04 system("rm -f make_histos.kumac"); Text kumac("make_histos.kumac"); kumac.append("exec init.kumac"); kumac.append("hi/file 1 cbnt.hbk chopt=n"); kumac.append("hrout *"); kumac.append("close 1"); kumac.write(); system("paw -b make_histos.kumac >paw.log 2>&1"); system("rm -f make_histos.kumac"); fshbk.update(); assert( fshbk.is_readable() ); */ // Create task. Task::NameList files; files.push_back(fsproc.name()); files.push_back(fsinit.name()); Task tsk(files); const XmlElement* pxtsk = tsk.xml(); if ( pxtsk == 0 ) { cout << "Unable to generate task XML." << endl; return 41; } XmlParser parser; int wstat = parser.write(fstsk.name(), *pxtsk); delete pxtsk; if ( wstat != 0 ) { cout << "Unable to write task XML." << endl; return 42; } return 0; }