// Module header
//
// ipdvplots - create all ipdvplots + html for given time period

#include "utils.h"
#include "TestBoxConfig.h"
#include "TTMSummaryChain.h"
#include "TTMOptions.h"
#include <TROOT.h>
#include <TApplication.h>
#include <iostream.h>

static char const rcsid[] = "$Id: ipdvplots.C,v 1.4 2003/06/02 10:42:19 ruben Exp $";
static char const *rcsid_p = rcsid;   // Prevent g++ from optimizing out rcsid

int main (int argc, char** argv) {

	// get options XXX should use TTMOptions and should have the ipdv.C code

	// reasanably safe static limits

	char commandline[1024];
	char outputdir[256];
	char timeperiod[64];

	
	// get the period argument directly from argv[] list
	// (ugly hack, but easier than remaking timestructs etc.)

	for (int argno=0; argno<argc; argno++) {
		if (strcmp(argv[argno], "-p") == 0) {
			strcpy(timeperiod, argv[argno+1]);
			break;
		}
	}

	TTMOptions options(argc, argv, "6p:o:");
	TestBoxConfig config(options);

// now we can start ...

        TestBox **tblist = config.GetTBList(); 

	for (int i=0; i<config.GetNumEntries(); i++) {
		sprintf(commandline, "ipdv -s %d -o %s -h -f gif -p %s -%d",
			tblist[i]->GetId(), options.OutputPath(),
			timeperiod, options.IPversion());
		system(commandline);
	}

	return(0);
}
