#ifdef __CLING__ R__LOAD_LIBRARY(mca8000a.cxx+g) #endif MCA8000 *mca = NULL; void rootlogon() { const char setred[] = "\033[31m"; const char setgreen[] = "\033[32m"; const char setblue[] = "\033[34m"; const char setblack[] = "\033[39m"; Int_t rvers_need = 53418; Int_t rvers = gROOT->GetVersionInt(); if ( rvers < rvers_need ) { printf("%sTrying to load library for MCA8000a%s\n", setgreen, setblack); printf("%sCurrent MARABOU Version is: %d needed:: %d\n", setred, rvers, rvers_need); printf("Please exit HistPresent and execute:\n"); printf("%smodule unload marabou\n", setblue); printf("module load marabou/5.34.30 %s\n", setblack); return; } TString line; TString device("/dev/ttyS0"); TString cmd ("fuser -u "); cmd += device; cmd += " 2>&1"; FILE *fp = gSystem->OpenPipe(cmd, "r"); line.Gets(fp); if (line.Length() > 0) { cout << setred << "Serial device already in use: " << line << endl << "Will not load MCA8000a library" << setblack<< endl; return; } Int_t dev_ok = 0; cmd = "if [ -w "; cmd += device.Data(); cmd += " ]; then echo ok; else echo no ; fi"; fp = gSystem->OpenPipe(cmd, "r"); line.Gets(fp); if ( line.Contains("no") ) { cout << setred << "You have no write access to " << device.Data() << setblack<< endl; // return; } else { dev_ok = 1; cout << "Write access ok: " << device.Data() << endl; } printf("%sLoading library for MCA8000a%s\n", setgreen, setblack); #ifndef __CLING__ gROOT->ProcessLine(".L mca8000a.cxx+"); #endif // preset for n_run_secs Int_t nrun_secs = 5; Int_t ntimes = 3; MCA8000 * mca = new MCA8000(); // mca->StartGui(); Int_t ndev = 0; if (dev_ok == 1) ndev = mca->OpenDevice(); if (ndev == 20) { printf("%sMCA connected%s\n", setblue, setblack); } else { mca->fSimulation = 1; mca->SetVerbose(0); mca->fRunTime = nrun_secs; printf("%s Cannot connect to MCA, Simulation only%s\n", setred, setblack); // return; } // start loop: TDatime dt; TString outfile_name("histos_"); outfile_name+=dt.GetDate(); outfile_name+="_"; outfile_name+=dt.GetTime(); outfile_name+=".root"; TString hname; TString htitle; auto outfile =new TFile(outfile_name, "RECREATE"); do { if (ndev == 1) mca->SetPresetTime(nrun_secs); cout << "StartAcq()" << endl; mca->StartAcq(); gSystem->Sleep(1000* (nrun_secs+2)); if (mca->fSimulation == 1) { mca->StopAcq(); } else if (mca->IsRunning()) { cout << "Still running after: " << nrun_secs+2 << " secs, stop it" << endl; mca->StopAcq(); } // cout << "FillHistogram" << endl; mca->FillHistogram(); // automatic name and title // mca->SetHistTitle("myname"); TH1F *hist = mca->GetHistogram(); if (hist){ hist->Write(); ntimes --; } else { cout << "No hist???" << endl; } } while (ntimes > 0); }