Hello experts,
I am having trouble selecting the bins in following code.Feel like I selected some underflows.Could you please help me figure it out?
ntheta=4;
Double_t pLowBinEdge[6]= {0.30, 0.45, 0.65, 0.95, 1.65, 2.00};
TH1F *Pbins = new TH1F("Pbins","Pbins",5,pLowBinEdge);
TH1F *ithetabins = new TH1F("ithetabins","ithetabins",4,0,4);
int i_theta_bins=4;
int n_p=5;
TH1F *h_pipCDMX2array_3fold[i_theta_bins][n_p];
char histName[64];
for (int ith=0; ith<i_theta_bins; ith++) { //is this bin selection is correct??
for (int ipipCD=0; ipipCD<n_p; ipipCD++) {
sprintf(histName,"h_pipCDMX2array_3fold_p%03d_th%03d",ipipCD,ith);
h_pipCDMX2array_3fold[ith][ipipCD] = new TH1F(histName,"3fold pip missing CD",300,-0.1,0.29);
h_pipCDMX2array_3fold[ith][ipipCD]->SetTitle(Form("P bin %d / th bin %d ",ipipCD,ith));
}
}
itheta = ( (Miss_pipCD_3fold.Theta()*TMath::RadToDeg()-theta_min_pipCD->Eval(pPip_3fold) )/ (theta_max_pipCD->Eval(pPip_3fold)-theta_min_pipCD->Eval(pPip_3fold)) );
itheta *=(double)ntheta;
//is this correct way of binning histogram?
int Pbinning = Pbins->GetXaxis()->FindBin(pPip_3fold)-1;
int Thetabinning = ithetabins->GetXaxis()->FindBin(itheta)-1;
//Is following bin selection is correct?
if (itheta>0 && itheta<=ntheta) if(Pbinning>-1 && Pbinning<n_p && Thetabinning>-1 && Thetabinning<i_theta_bins)
h_pipCDMX2array_3fold[Thetabinning][Pbinning]->Fill(Miss_pipCD_3fold.M2());
```
Thanks