concatenate string and running index into string within a loop

Posted by user331706 on Stack Overflow See other posts from Stack Overflow or by user331706
Published on 2010-05-03T18:53:22Z Indexed on 2010/05/03 18:58 UTC
Read the original article Hit count: 333

Filed under:
|

To use a given graphic package I need to define, book and fill histogram. How can I get the name of the histogram which is a string to concatenate with 2 integer as a string ( hts_i_j ) in 3 for loop instead. That has to be done in c++ See the exemple below

to define

TH1F* hts_5_53; TH1F* hts_5_54; …… TH1F* hts_5_69;

to book

hts_5_53= HDir.make("hts_5_53")," Title", 100,0.,100.); hts_5_54->HDir.make("hts_5_54")," Title", 100,0.,100.); …… hts_16_69->HDir.make("hts_16_69")," Title", 100,0.,100.);

to fill

hts_5_53->Fill(f) hts_5_54->Fill(f) …… hts_16_69->Fill(f)

Instead I would like to define, book and fill in 3 for loops. e.g . for(int i=5, i<17, ++i){ for(int j=53, j<70, ++j){

hts_i_j

} } how can I get the string hts to concatenate with the indices ( i,j) in a simple short way while defining, booking and filling in 3 for loop instead

© Stack Overflow or respective owner

Related posts about concatenation

Related posts about c++