40 likes | 119 Vues
Same code. Different Histograms. #include <HbookHistogramFactory.h> HbookHistogramFactory hbf(0); HistogramFactory * getHF() { return &hbf; } int usercode(); int main() { return usercode(); }. #include <RootHistogramFactory.h> RootHistogramFactory hbf();
E N D
Same code. Different Histograms #include <HbookHistogramFactory.h> HbookHistogramFactory hbf(0); HistogramFactory * getHF() { return &hbf; } int usercode(); int main() { return usercode(); } #include <RootHistogramFactory.h> RootHistogramFactory hbf(); HistogramFactory * getHF() { return &hbf; } int usercode(); int main() { return usercode(); } #include <CorbaHistogramFactory.h> CorbaHistogramFactory hbf(“mlp.rhic”,5007); HistogramFactory * getHF() { return &hbf; } int usercode(); int main() { return usercode(); } #include <simpleRandom.h> #include <HistogramFactory.h> HistogramFactory * getHF(); int usercode() { simpleRandom *R = new simpleRandom(987678); HistogramFactory *hf = getHF(); Histo1d *hpx = hf->create1dHistogram(100, "This is the px distribution" ,100,-4,4); for ( int i=0; i<10000; i++) { hpx->fill(R->gauss(0., 10.)); } hf->save("file"); return 0; } This code examples are a bit older - interfaces are more modern, singletons, etc.
Recent code snippet #include <Event.h> #include <PhHistogramFactory.hh> #include <TH1.h> #include <time.h> #include <pmonitor.h> PhHistogramFactory *hf; int init_done = 0; PhH1 *h; // the one histogram int pinit() { if (init_done) return 1; init_done = 1; hf = PhHistogramFactory::instance(); if (hf) { h = hf->CreateH1F("H1", "Channel 0", 101,-49.5,49.5); return 0; } else return -1; } int process_event (Event * e) { // static int i = 0; Packet *p = e->getPacket(1003); if (p) { h->Fill (p->iValue(0)); delete p; } nsleep(100); // 100 milliseconds return 0; }
DistributedProcesses DistributedProcesses { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } DistributedProcesses DistributedProcesses Single Process { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } DistributedProcesses DistributedProcesses { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); { if ( file_is_open) return -1; sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number); if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL ) { cerr << "file not opened " << strerror(errno) << endl; *fp = 0; return -1; } *fp = the_file; file_is_open = 1; // cout << "opened file " << ctrlbuf->current_filename << endl; return 0; } int ndd_control::close_file() { if ( !file_is_open) return -1; fclose(the_file); } Single process now -- distributed tomorrow Processes on reconstruction farm Corba Histogram Server Process
DD Pool DD Pool Different types of histograms, no changes to the user code from Experiment from Experiment Online Monitoring Process Online Monitoring Process Online Monitoring Process Online Monitoring Process Use local histograms Histo corba server