Histogram empty

Please read tips for efficient and successful posting and posting code

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…

In attached was the files input.

Best regards!
EnerKin.C (8.4 KB) EnerKin.h (13.5 KB)

we cannot run your macro:

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] 

Thanks @couet!

I will go place here the same code with the root files to run… I must compress the files that have 2Gb and I can’t place here…

This link has all the root files that was used to generated the makeclass above.

Best regards!

Good morning!

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; 
      if(Step_FinalMaterial->size()>0){ mm++; // garantir que o size não é zero  ||
      Int_t cont=0; Int_t count=0; 
      //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.))
           for(Int_t l=0;l<Step_FinalMaterial->size();l++){
            **sumKin= Step_FinalKineticEnergy->at(count);**

Best regards!

It is not clear to me what the new version is ?

So I create a new counter that depends of the other already created aparently when I do this worked…

I already had a counter named cont than I created a new counter (named count) also depend of cont.


And used to generated the events for the kinetic energy.

That seems right, isn’t?

Best Regards

I guess so, you know better your analysis macro than me …

Hi David,

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.

I understand the question I’m running a test here to see if this case o curso ans I Will return here a answer ok?

Thanks @yus for the question

Best Regards

Sure, take your time!

Hello @yus!

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.

As for the question of the line


I don’t know how it works but I suppose that somehow this line allows that all histograms works.
histogram_ana.pdf (1.3 MB)

histogram_ana1.pdf (31.9 KB)

Best Regards