Dear all,
Here is a macro with a loop that stops when a maximum number of events
is reached or when a time limit is reached. The macro runs on a local ROOT
session (root 5.05/01, RH9) .. however when running it on the PROOF cluster
it does not work as expected and always stop when the max number of
events is reached.
It seems that the timer is not working properly. Is there something wrong ?
Thanks for your help,
Olivier
-- ========================================================== Olivier Stézowski Institut de Physique Nucléaire de Lyon Universite Claude Bernard - Lyon I 43, boulevard du 11 Novembre 1918 F-69622 Villeurbanne Cedex FRANCE e-mail : stezow_at_ipnl.in2p3.fr web : http://agata.in2p3.fr ==========================================================Received on Tue Oct 25 2005 - 16:02:26 MEST
#ifndef __CINT__
#include <TTimer.h>
#include <TRandom.h>
#include <TSystem.h>
#include <TFile.h>
#include <TH1F.h>
#include <TStopwatch.h>
#include <iostream>
using namespace std;
#endif
Int_t MAX_CASCADE = 10000000, MAX_TIME = 1; Bool_t is_timeout = kFALSE; void StopSimu() { is_timeout = kTRUE; } void InitSimu(Int_t nbcas, Int_t maxtime) { is_timeout = kFALSE; MAX_CASCADE = nbcas; MAX_TIME = maxtime; } void DoSimu() { TFile f("rnd.root","RECREATE"); TH1F h("g","g",100,0,1); // start timer limit TTimer *timer = new TTimer; timer->SetCommand("StopSimu()"); timer->Start(MAX_TIME*1000); // check time TStopwatch watch; watch.Start(); Int_t nb_cascades = 0; Bool_t keepon = kTRUE; cout << " Start simulation with maximum " << MAX_CASCADE << " cascades or max time (s) " << MAX_TIME << endl; // loop while ( keepon ) { // my random ... h.Fill(gRandom->Gaus(0.5,0.2)); gSystem->ProcessEvents(); // process timer & external events if ( is_timeout ) { cout << " TIME OUT " << endl; keepon = kFALSE; } else { nb_cascades++; } if ( nb_cascades == MAX_CASCADE ) { cout << " MAX CASCADES " << endl; keepon = kFALSE; } } // while watch.Print(); cout << nb_cascades << " cascades simulated on " << gSystem->HostName() << endl; f.Write(); delete timer; }
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET