/////////////////////////////////////////////////////////////////////////////// // grab number of the L3 events and livetime from the database // step 1: run get_l3_rates and save output in the text file // step 2: run awk and convert time into seconds // cat l3_rates.txt | sed 's/:/ /g' | less | \ // awk '{ x = $4*3600+$5*60+$6; // rate=$3/x; // printf "%8i %10i %10i %10.3f %10.3f \n",$1,$2,$3,x,rate // }' > l3_rates_hz.txt // step 3: run plot_l3_rates on l3_rates_hz.txt // // "l3_rate" is event rate out of Level3, offline sees L3_rata*1.1 /////////////////////////////////////////////////////////////////////////////// int get_l3_rates (int RunMin, int RunMax) { TObjArray* list_of_good_runs = new TObjArray(10); cdfrep01.GetListOfGoodRuns(list_of_good_runs,RunMin,RunMax); int nruns = list_of_good_runs->GetEntriesFast(); int found, rn; TString query; for (int i=0; iAt(i); rn = r->RunNumber(); query = "select runnumber, CSL_NEVENTSOUTPUT, CSL_EVENTSUNIQUE, "; query += "rundb.clock_to_time(LIVETIME) from runconfigurations " ; query += Form("where runnumber = %i",rn); cdfrep01.Query(query.Data()); } } //----------------------------------------------------------------------------- // reads file in format: // // run_number N(CSL) N(L3) livetime L3 rate // // 138425 680528 644883 17551.800 36.742 // 138428 213059 202213 8257.500 24.488 // 138430 434313 412603 18501.600 22.301 // // data taking history: // // 2002: 138425-156486 // 2003: 158000-168889 // 2004: 174000-186598 // 2005: 190000-210000 (dont know yet) //----------------------------------------------------------------------------- plot_l3_rates(const char* Filename) { char c[1000]; int rn, ncsl, nl3, loc; float livetime, l3_rate; int done(0); //----------------------------------------------------------------------------- // do yearly stats, year starts from 2002 //----------------------------------------------------------------------------- int nl3_year[10], ncsl_year[10]; double ave_rate[10]; float x[100000], y[100000]; int n(0); for (int i=0; i<10; i++) { nl3_year [i] = 0; ncsl_year[i] = 0; ave_rate [i] = 0; } FILE* f = fopen(Filename,"r"); if (f) { while ( ((c[0]=getc(f)) != EOF) && !done) { // check if it is a comment line if (c[0] != '#') { ungetc(c[0],f); // read channel number fscanf(f,"%i",&rn); fscanf(f,"%i",&ncsl ); fscanf(f,"%i",&nl3 ); fscanf(f,"%f",&livetime); fscanf(f,"%f",&l3_rate ); } //----------------------------------------------------------------------------- // read until the end of line //----------------------------------------------------------------------------- fgets(c,100,f); //----------------------------------------------------------------------------- // prepare data for the graph //----------------------------------------------------------------------------- x[n] = rn; y[n] = l3_rate; n++; //----------------------------------------------------------------------------- // calculate per year averages ( 0 means 2002 etc) //----------------------------------------------------------------------------- if (rn <= 156484) loc = 0; else if (rn <= 168889) loc = 1; else if (rn <= 186598) loc = 2; else if (rn <= 210000) loc = 3; nl3_year [loc] += nl3; ncsl_year[loc] += ncsl; ave_rate [loc] += nl3*l3_rate; // printf(" %10i %10.3f\n",rn,l3_rate); } } fclose(f); //----------------------------------------------------------------------------- // plot the graph //----------------------------------------------------------------------------- TGraph* gr = new TGraph(n,x,y); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.3); gr->SetTitle("average L3 output rate vs run number"); gr->GetXaxis()->SetTitle("run number"); gr->GetYaxis()->SetTitle("L3 rate, Hz"); gr->Draw("ap"); for (int i=0; i<10; i++) { int year = 2002+i; if (nl3_year[i] > 0) { printf (" year, nl3, ncsl, rate: %10i %12i %12i %10.3f\n", year, nl3_year[i], ncsl_year[i],ave_rate[i]/nl3_year[i]); } } }