Purpose: To use Uthbook to book histograms into shared memory which allows them to be accessed and viewed by other users simultaneously. To book a histogram into shared memory: To book a histogram into shared memory, use the functions defined in the Uthbook_fun.h file listed below. void uthCreateSharedMem (); void uthBook1Shared (const char *title, int nbinx, hvar xmin, hvar xmax); void uthBook2Shared (const char *title, int nbinx, hvar xmin, hvar xmax, int nbiny, hvar ymin, hvar ymax); void uthFillShared (int id, hvar x, hvar y, hvar weight); Example code: #include #include #include #include // Uthbook items #include "Uthbook.h" using namespace std; int main(int narg, char *argv[]) { // create shared memory uthCreateSharedMem(); // create histogram 1 and data const char* title1 = "Histogram 1"; int nBin1 = 6; float xMin1 = -1.0; float xMax1 = 11.0; float myData1[] = { -1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 11 }; // book histogram 1 into shared memory uthBook1Shared(title1, nBin1, xMin1, xMax1); for (int i = 0; i < (sizeof(myData1) / sizeof(float)); i++) { uthFillShared(0, myData1[i], 0, 1); } // waits until done cout << "enter letter to quit..." << endl; string hold; cin >> hold; // requesting the removal of the shm object -- shm_unlink() if (shm_unlink(shmPath) != 0) {perror("In shm_unlink()");} } The code above creates a single 1D Histogram named “Histogram 1” with 6 bins, a minimum value of -1, and a maximum value of 11, and is then filled with the data from the myData1 array. These values are sorted and increment the proper bins. As long as this program stays running the histogram is available in shared memory. To access Histograms in shared memory via RootSpy: To access a histogram in shared memory via RootSpy, first start the cMsg server and cMsg monitor using star_cmsg_server and start_cmsg_monitor. “rootspy” must replace “myNameSpace” in the monitor's UDL. Next, run RootSpy. The histograms in shared memory can now be viewed via the RootSpy display.