#include <string>
#include <iostream>
#include <sstream>
#include <TTree.h>
#include <TFile.h>
#include <TH1.h>
#include <cstdio>
#include "TVectorT.h"

using namespace std;

TVectorD nevents(long int run_number, long int last_run){

  Int_t size = last_run - run_number;
  TVectorD n_events (size+1);
  Int_t count = 0;

    for (long int i=run_number;i<last_run+1;i++)
    {
      string s;
      char run_n[30];
      
      sprintf(run_n,"%ld",i);
      s = string(run_n);
      
      string rootfile_name;
      string recofile_name;

      if (i < 10)
	{
	  rootfile_name = "../RootData/Run000" + s + ".root";
	  recofile_name = "../RootData/Run000" + s + "_reco.root";
	}
      else
	{
	  if (i < 100)
	    {
	      rootfile_name = "../RootData/Run00" + s + ".root";
	      recofile_name = "../RootData/Run00" + s + "_reco.root";
	    }
	  else
	    {
	      rootfile_name = "../RootData/Run0" + s + ".root";
	      recofile_name = "../RootData/Run0" + s + "_reco.root";
	    }
	}

      TFile file0(recofile_name.c_str()); 

      TH1F* heffbgch = dynamic_cast<TH1F*>(file0.Get("heffbgch"));	
      n_events[count] = heffbgch->GetEntries();
      count++;

      }
 
    return n_events;
}
