vendredi 28 juillet 2017

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad

In the loop of my program when bin=8 I have this sentence

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad

and it stops i send you a part of my program that have problem

   ds=(smax-smin)/sn;    
for(int bin=0; bin<sn; bin++){
s1=smin+(bin*ds);
s2=smin+((bin+1)*ds);
s=(s1+s2)/2;
if(S[j]<=s1+0.05 && S[j]>=s1-0.05){
E11=E1[j];
E12=E2[j];
}

if(S[j]<=s2+0.05 && S[j]>=s2-0.05){
 E21=E1[j];
 E22=E2[j];
}
} 
slop=(E22-E12)/(E21-E11);
cout<<"bin="<<bin<<"\n";
n=-1/slop;
b=-slop*E21+E22;
b1=-n*E11+E12;
b2=-n*E21+E22;

double x1=-b1/n; 
double x2=-b2/n; 
double x3=140;       
double x4=140;
double y3=(n*x3)+b2; 
double y4=(n*x4)+b1;
double y11=0.0;
double y2=0.0;
double  h[5]={x1,x2,x3,x4,x1};
double k[5]={y11,y2,y3,y4,y11};
sprintf(cha[1],"cut%d",bin); 
cut[bin]=new TCutG(cha[1],5,h,k);
  for (Long64_t jentry=evSta; jentry<g; jentry++)
    {

if (cut[bin]->IsInside(nEout,nEin)){
hp[bin]->Fill(nEout,nEin);
H=-(slop*nEout+b-nEin)/sqrt(1+slop*slop);
Np[bin]->Fill(H);
}
}

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire