Re: CINT for loop problem

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Thu, 12 Aug 2010 09:29:17 +0200


CINT does not like declarations within loops. Move the declaration of pix[2] outside the loops and your code will run faster too.

Rene Brun

OKUMURA, Akira wrote:
> Hello ROOTers,
>
> The following macro does not run in CINT, while it is a very simple code. If you use ACLiC or comment out the line of an array declaration, it runs as I expected. Does anyone have a workaround?
>
> ====================================
> #include "TH2.h"
> #include <iostream>
>
> void tmp()
> {
> TH2D h("", "", 100, 0, 1, 100, 0, 1);
> for(int y = 1; y <= h.GetYaxis()->GetNbins(); y++){
> for(int x = 1; x <= h.GetXaxis()->GetNbins(); x++){
> std::cout << x << "\t" << y << std::endl;
> if(h.GetBinContent(x, y) == 0){
> continue;
> } // if
> Double_t pix[2] = {x, y}; // the macro runs if you comment out this line
> } // x
> } // y
> }
> ====================================
>
> Regards,
>
> --
> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
> Institute of Space and Astronautical Science (ISAS/JAXA)
> Now at KIPAC/SLAC/Stanford
> Varian Physics #306
> 382 Via Pueblo Mall, MC 406 Stanford, CA94305
> TEL 650-736-0971/FAX 650-724-5065
> Skype : okumura.akira
>
>
Received on Thu Aug 12 2010 - 09:29:23 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 13 2010 - 23:50:01 CEST