#include #include #include #include #include #include "TNtuple.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" #include "TH3F.h" #include "TTree.h" #include "TChain.h" #include "TCanvas.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TF1.h" #include "TStyle.h" #include "TCut.h" #include "TGaxis.h" #include "TVector.h" #include "TPaveText.h" #include "TEllipse.h" #include "TROOT.h" #include "TObjArray.h" #include "TObject.h" #include "TRandom.h" #include "TMath.h" void Study(bool write=false){ // Global Variables float cut1=2.5; // File output TFile *f2 = new TFile("plots.root","RECREATE"); f2->cd(); gRandom->Gaus(2.,4.5); // histograms and other variables TObjArray *array_z_x2y2 = new TObjArray() ; TH2D *h_z_x2y2 = new TH2D("h_z_x2y2","h_z_x2y2",500,0,4.0,500,0,4.0); //Loop on etries and fill week by week for(int i=0;i<3e5;i++){ if( (gRandom->Gaus(0,4.5) ) < cut1 ) { h_z_x2y2->Fill(gRandom->Gaus(0,4.5),gRandom->Gaus(0,4.5)); } if( (h_z_x2y2->GetEntries()>25000) ){ array_z_x2y2->AddLast( h_z_x2y2 ); cout << "before:" << h_z_x2y2->GetEntries() << endl; h_z_x2y2->Reset(); cout << "after:" << h_z_x2y2->GetEntries() << endl; cout << "size array_z_x2y2:" << array_z_x2y2->GetEntriesFast() << endl; } } array_z_x2y2->AddLast( h_z_x2y2 ); f2->cd(); if(write)array_z_x2y2->Write("array_z_x2y2",TObject::kSingleKey); TCanvas *c_array_z_x2y2 = new TCanvas("array_z_x2y2","array_z_x2y2",800,800); c_array_z_x2y2->SetFillColor(10); c_array_z_x2y2->Divide(3,3); for(int j=1;j<10;j++){ if(j>array_z_x2y2->GetEntriesFast()) break; c_array_z_x2y2->cd(j); array_z_x2y2->At(j-1)->Draw("COLZ"); TH2D *loc_histo = (TH2D *)array_z_x2y2->At(j-1); cout << j << " size:" << loc_histo->GetEntries() << endl; c_array_z_x2y2->Update(); } c_array_z_x2y2->Update(); }