Hi Rooters,
I have a Macro compiled in ACLIC and the virtual memory becomes really huge after a number of iterations …
I have a TTree from which I fill a gif (animated).
I put the code in attachment
[code]#include .
#include
#include “TMath.h”
#include “TTree.h”
#include “TFile.h”
#include “TH1.h”
#include “TH3.h”
#include “TH1F.h”
#include “TGraph.h”
#include “TGraphSmooth.h”
#include “TSpectrum.h”
#include “TCanvas.h”
#include “TStyle.h”
void Anim(char rfile[100],char outname[100])
{
gStyle->SetOptStat(0);
TCanvas *c1 = new TCanvas("c1","c1",600,600);
for(Int_t i=1;i<50;i++)
{
TFile *f = new TFile(rfile);
Int_t time=5*i;
TTree *AllDetectors= new TTree();
cout<<"Time-- > "<<i<<" ns"<<endl;
AllDetectors = (TTree*)gDirectory->Get("AllDetectors");
AllDetectors->SetBranchStatus("*",0);
AllDetectors->SetBranchStatus("Time",1);
AllDetectors->SetBranchStatus("Part",1);
AllDetectors->SetBranchStatus("X",1);
AllDetectors->SetBranchStatus("Y",1);
AllDetectors->SetBranchStatus("Z",1);
TH3F *hproj = new TH3F("hproj",Form("Time : %d ns",time),
20,0,45,20,-1.e7,1.e7,20,-1.e7,1.e7);
TH3F *hprojg = new TH3F("hprojg",Form("Time : %d ns",time),
20,0,45,20,-1.e7,1.e7,20,-1.e7,1.e7);
TH3F *hprojn = new TH3F("hprojn",Form("Time : %d ns",time),
20,0,45,20,-1.e7,1.e7,20,-1.e7,1.e7);
hprojg->SetMarkerColor(2);
hprojn->SetMarkerColor(4);
AllDetectors->Draw("X:Y:Z>>hproj",Form("Time<%d",time),"goff");
AllDetectors->Draw("X:Y:Z>>hprojg",Form("Time<%d && Part==22",time),"goff");
AllDetectors->Draw("X:Y:Z>>hprojn",Form("Time<%d && Part==2112",time),"goff");
c1->Clear();
gPad->SetPhi(-2);
hproj->Draw("");
hprojg->Draw("same");
hprojn->Draw("same");
c1->Update();
c1->Print(Form("%s+20",outname));
AllDetectors->Delete();
hproj->Delete();
hprojg->Delete();
hprojn->Delete();
f->Close();
}
c1->Print(Form("%s++",outname));
}[/code]
Thanks !