ROOT Version: 6.18.00 Platform: UBUNTU 18.04.4 Compiler: Not Provided
Good afternoon.
I’m run a MakeClass and my histogram was empty I think that was any wrong with code, but I’m not sure, can anyone help? I’m searching for understand what is wrong but I can’t know whtat is…
root [0] .L EnerKin.C
root [1] EnerKin t
(EnerKin &) @0x10745a0f8
root [2] t.GetEntry(12);
Error in <TFile::TFile>: file /home/gamos/brachy_VMBox/Etapas/teste/sample/testeSA_tree_1000.root does not exist
Error in <TFile::TFile>: file /home/gamos/brachy_VMBox/Etapas/teste/sample/testeSA_tree_1001.root does not exist
Error in <TFile::TFile>: file /home/gamos/brachy_VMBox/Etapas/teste/sample/testeSA_tree_1002.root does not exist
Error in <TFile::TFile>: file /home/gamos/brachy_VMBox/Etapas/teste/sample/testeSA_tree_1003.root does not exist
root [3]
So I wade a change in the code that provides me a histogram that seems to be right, but I can’t understand what exactly this change do, can anyone help me with this?
The change is with ** in the code bellow:
for (Long64_t jentry=0; jentry<500000;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
cout<<"size total = " <<nentries<<endl;
cout<<"entry = "<<jentry<<endl;
cout<<endl;
if(Step_FinalMaterial->size()>0){ mm++; // garantir que o size não é zero ||
Int_t cont=0; Int_t count=0;
**while((cont<Step_FinalMaterial->size()-1)){cont++;}**
**while((cont<Step_FinalMaterial->size()-1)){count++;}**
//ana1->Fill(Step_FinalKineticEnergy->at(cont),TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2))); ||((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2))>0.40)&&((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2)))<22.))
if((Step_FinalMaterial->at(cont)=="G4_WATER")||((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2))>0.40)&&((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2)))<22.))){mm2++;
//ana->Fill(Step_FinalKineticEnergy->at(cont),TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2)));
for(Int_t l=0;l<Step_FinalMaterial->size();l++){
ekin=Step_FinalKineticEnergy->at(l);
ana->Fill(ekin,TMath::Sqrt(pow(Step_FinalPosX->at(l),2)+pow(Step_FinalPosY->at(l),2)+pow(Step_FinalPosZ->at(l),2)));
}
**sumKin= Step_FinalKineticEnergy->at(count);**
ana1->Fill(sumKin,TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2)));
}else{
if((Step_FinalMaterial->at(cont)=="NIST_Air")||((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2))>=22.)&&((TMath::Sqrt(pow(Step_FinalPosX->at(cont),2)+pow(Step_FinalPosY->at(cont),2)+pow(Step_FinalPosZ->at(cont),2))<750.)))){mm7++;}
else{
if(Step_FinalLogicalVolume->at(cont)=="OutOfWorld"){mm20++;}
}
}
}
}
I’m curious what this new line does and how it works exactly:
Correct me if I’m wrong, but as far as the loop is concerned, the cont is a constant and equals zero in every iteration. Then the Step_FinalMaterial->size() is clearly a const in all iterations. Only count increments starting from zero. So if the program enters this loop (that is, if cont is indeed smaller than Step_FinalMaterial->size()-1, it’s going to be an infinite loop. Consider a simpler example:
int a = 0;
while (0<2) {a++;}
You never wrote you observed an infinite loop, so I’m guessing the upstream condition
if (Step_FinalMaterial->size() > 0)
just never returns true, and your loop never runs.
For the question that you do, seems to me that either the your suggestion doesn’t correspond. Because, correct if I was wrong, these suggestion is correct all histogram was empty but the not all histogram was empty, just one (ana1, in the code attached in the first message). I will attached here some images.