Eventually, I saw " segmentation violation" message. Is it impossible to use the variable as an index of a histogram? I mean, Like “ipt” or “isg” in this code. In C/C++, I know that the index should be constant when it is declared but could be variable when the array is accessed after its declaration. How about in ROOT? I’m using the version of 5.18/00.
I would suggest to compile your macro with ACLiC. Then you will be able to:
see compilation warning, like uninitialized variable:
[color=red]warning C4700: uninitialized local variable ‘ipmt’ used[/color]
debug your code, in particular this line:
[color=blue]ipt=cc_segm[cc[0]-1]/1000; isg=iseg-8;[/color]
which may lead to isg being -1 when iseg == 7 (and then used as array index)!!!
Anyway, you should check to be sure it is greather or equal to zero before to use it as array index! Otherwise, don’t be surprised to have crashes in your code
– Bertrand.
Well, I added printf(“isg=%d iseg=%d (isg=iseg-7)\n”,isg,iseg); in the code and it was printing values going from 7 to 17 for iseg on my machine… But anyway, You know better then me what you are doing
And using ACLiC will allow you to solve the problem anyway.
Cheers, Bertrand.