TVectors and vectors in ROOT

I would like to use vectors in ROOT, and I fail somehow.

#include <vector>
#include "TMath.h"
#include "TVector.h"

Double_t  calc_sigma (vector <int> array) {
  Double _t sigma; 

  sigma = TMath::RMS(array.begin(), array.end()) ;  //root does not recognize this. 
  
 return sigma;

}

int outside_function() {
  float sigma;
  vector<int> vec;

  //I call calc_sigma () from above
  sigma = calc_sigma( vec);  //I fail here. Error : Function RMS(array.begin(),array.end()) is not defined in current scope 
................
}

What was missing or wrong with the code? Many thanks

Hi,

The signature

sigma = TMath::RMS(array.begin(), array.end()) 

is not recognized by CINT (it is a template function). You need either to compile your macro with ACLIC or use instead

sigma = TMath::RMS(array.size(), &array[0]) 

Lorenzo

.