hi, guys
I used a tntuple object to store data of charges (X,Y,Z,Q) and drawn a 2-D distribution of X vs Y.
but when I tried to get the Mean and the StdDev of the distribution, I got all “0” values and I dont know why.
my code is as follows:
gROOT->cd();
TNtuple* npc=new TNtuple("n","n","x:y:z:charge");
npc->SetMarkerStyle(20);
npc->SetMarkerSize(0.1);
unsigned long pc_total_charge_count=0;
for(int i=0;i<10;i++)//PropagatedCharge_tree->GetEntries();++i)
{
PropagatedCharge_tree->GetEntry(i);
float x,y,z; //local position
unsigned long q; //charge
unsigned long pc_event_charge_count=0;
for(auto& propagated_charge:propagated_charges)
{
x=propagated_charge->getLocalPosition().X();
y=propagated_charge->getLocalPosition().Y();
z=propagated_charge->getLocalPosition().Z();
q=propagated_charge->getCharge();
npc->Fill(x*1000.0,y*1000.0,z*1000.0,q);//convert to um
pc_total_charge_count+=q;
pc_event_charge_count+=q;
}
cpc_2d->cd();
npc->Draw("y:x");
TH2F* htemp=(TH2F*)gPad->GetPrimitive("htemp");
htemp->GetXaxis()->SetLimits(-1000,1000);
std::cout<<"sigma x:"<<htemp->GetStdDev(1)<<" sigma y:"<<htemp->GetStdDev(2)<<"mean :"<<htemp->GetMean(1)<<htemp->GetMean(2)<<htemp->GetMean(3)<<std::endl;
}
Can someone help me with this? Thanks~
data_gene_simple_1_1s.root (56.9 KB) readpc2d.C (4.4 KB)