#include "Analyzer.h" using namespace std; Analyzer::Analyzer() { hfile = new TFile("Analyzer.root","RECREATE","XXX"); hrating_per_day = new TH1F("rating_per_day","rating_per_day",3000 ,0.5 ,3000.5 ); hrating_per_month = new TH1F("rating_per_month","rating_per_month",100 ,0.5 ,100.5 ); hrating_all = new TH1F("rating_all","rating_all",5 ,.5 ,5.5 ); havg_rating = new TH1F("avg_rating","avg_rating",100, .5 ,100.5 ); havg_rating_d = new TH1F("avg_rating_d","avg_rating_d",100, .5 ,100.5 ); hratings_per_user = new TH1F("ratings_per_user","ratings_per_user",150 ,0. ,1500 ); htest_ratings_per_user = new TH1F("test_ratings_per_user","test_ratings_per_user",20 ,0.5 ,20.5 ); hratings_vs_test = new TH2F("ratings_vs_test","ratings_vs_test", 150, 0.5,1500.5,20, .5, 20.5 ); hfirst_rating_each_user = new TH1F("first_rating_each_user","first_rating_each_user",100 ,0.5 ,100.5 ); hlast_rating_each_user = new TH1F("last_rating_each_user","last_rating_each_user",100 ,0.5 ,100.5 ); htime_1st_to_last_rating= new TH1F("time_1st_to_last_rating","time_1st_to_last_rating",101 ,-.5 ,100.5 ); hratings_per_session_per_user = new TH1F("ratings_per_session_per_user","ratings_per_session_per_user",100 , .5,100.5 ); hrating_sessions_per_user= new TH1F("rating_sessions_per_user","rating_sessions_per_user", 100,.5 ,100.5 ); } // h = new TH1F("","", , , ); Analyzer::~Analyzer() { // Save all objects in this file hfile->Write(); } void Analyzer::a1(char* filename) { int count1=0; int count10k=0; int current_user =-1; int r_p_user=0; int r_p_0_user=0; int prev_lmonth=0; int first_lmonth=0; int current_lday=-1; int rating_sessions=0;; int ratings_this_session=0;; datafile.open(filename); while ( !datafile.eof() ) { datafile.getline( &line[0], 5000000, '\n'); if (datafile.eof()) break; count1++; count10k++; if (count10k>9999){ count10k = 0; cout<Fill(lday); hrating_per_month->Fill(lmonth); hrating_all->Fill(rating); if (rating>0){ havg_rating->Fill(lmonth, rating); havg_rating_d->Fill(lmonth); } if (rating !=0) r_p_user++; if (rating ==0) r_p_0_user++; if (current_user != user){ // user switched if (current_user >0){ // not first one hratings_per_user->Fill(r_p_user); htest_ratings_per_user->Fill(r_p_0_user); hratings_vs_test->Fill(r_p_user,r_p_0_user); r_p_user=0; r_p_0_user=0; hfirst_rating_each_user->Fill(lmonth); hlast_rating_each_user->Fill(prev_lmonth); htime_1st_to_last_rating->Fill(prev_lmonth - first_lmonth); hrating_sessions_per_user->Fill(rating_sessions); rating_sessions=1; hratings_per_session_per_user->Fill(ratings_this_session); ratings_this_session=1; current_lday = lday; } rating_sessions=1; current_lday=lday; first_lmonth=lmonth; current_user = user; } // user switch else{ //same user if (current_lday != lday){ // new rating session hratings_per_session_per_user->Fill(ratings_this_session); ratings_this_session=1; rating_sessions++; } ratings_this_session++; } prev_lmonth=lmonth; current_lday = lday; } // while over file } // ------------------------------------------------------------------------------- void Analyzer::makesmall(char* filename) { int count1=0; int count10k=0; outfile.open("/tmp/user_date100.txt"); datafile.open(filename); int current_user =-1; int user_cnt=0; int user_cnt10k=0; int output_user=0; while ( !datafile.eof() ) { datafile.getline( &line[0], 5000000, '\n'); strcpy(line1, line); if (datafile.eof()) break; count1++; count10k++; if (count10k>9999){ count10k = 0; cout<99){ user_cnt10k=0; output_user=1; } } if (output_user) outfile< 10) { cout << "2 <= msize <= 10" <Load("libMatrix"); cout << "--------------------------------------------------------" < 6 x 6 but for smaller sizes, the // inversion is performed according to Cramer's rule by explicitly calculating // all Jacobi's sub-determinants . For instance for a 6 x 6 matrix this means: // # of 5 x 5 determinant : 36 // # of 4 x 4 determinant : 75 // # of 3 x 3 determinant : 80 // # of 2 x 2 determinant : 45 (see TMatrixD/FCramerInv.cxx) // // The only "quality" control in this process is to check whether the 6 x 6 // determinant is unequal 0 . But speed gains are significant compared to Invert() , // upto an order of magnitude for sizes <= 4 x 4 // // The inversion is done "in place", so the original matrix will be overwritten // If a pointer to a Double_t is supplied the determinant is calculated // cout << "1. Use .InvertFast(&det)" < 6) cout << " for ("< 1 // - The last step is a standard forward/backward substitution . // // It is important to realize that both InvertFast() and Invert() are "one-shot" deals , speed // comes at a price . If something goes wrong because the matrix is (near) singular, you have // overwritten your original matrix and no factorization is available anymore to get more // information like condition number or change the tolerance number . // // All other calls in the matrix classes involving inversion like the ones with the "smart" // constructors (kInverted,kInvMult...) use this inversion method . // cout << "2. Use .Invert(&det)" < slower) and several operations can be performed without having to repeat // the decomposition step . // Inverting a matrix is nothing else than solving a set of equations where the rhs is given // by the unit matrix, so the steps to take are identical to those solving a linear equation : // cout << "3. Use TDecompLU" <