1 / 4

Same code. Different Histograms

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();

keran
Télécharger la présentation

Same code. Different Histograms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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.

  2. 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; }

  3. 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

  4. 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

More Related