title: plotting histograms in ROOT with varying variable names
body: <p>I am not sure how to phrase this question correctly, but this is what I am trying to do.</p>
  
  <p>A single histogram can be plotted using cern ROOT with a following command,</p>
  
  <pre><code>(TH1F*)electron-&gt;Draw();
  </code></pre>
  
  <p>But I have tens of histograms named in a sequence, such as electron1, elecron2, electron3, etc, and I want to write a simple loop to plot them all. I tried using sprintf and a simple for loop, but ROOT doesn't like it.</p>
  
  <pre><code>char name[20];
  (TH1F*)electron-&gt;Draw();
  for(int j=0;j&lt;5;j++){
              sprintf(name, "%s%d","electron",j);
              (TH1F*)name-&gt;Draw("same");
   }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks in advance.</p>