int main(){

  std::vector<Double_t> radii;
  radii.push_back(2.0); // 1.
  radii.push_back(3.0); // 3.5
  radii.push_back(6.0);
  radii.push_back(9.0);
  radii.push_back(17.0);
  radii.push_back(20.0);
  radii.push_back(25.5);
  radii.push_back(28.0); //Added!!!
  radii.push_back(30.0);
  radii.push_back(34.0);
  radii.push_back(36.5); //Added!!!
  radii.push_back(38.0);
  radii.push_back(46.0);
  radii.push_back(54.5); // 54.0
  radii.push_back(57.0);
  radii.push_back(61.5); // 61.0
  radii.push_back(65.0);

  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-26., 26., 1., 20.));
  geoCuts.push_back(GeoCut(-66., 66., 20., 65.));

  Double_t boxSize = 30.;
  MatPlot myPlot("XY", -boxSize, boxSize, -boxSize, boxSize, 0.2, 0.05);
  myPlot.SetEffRadii(&radii);
  myPlot.SetGeoCuts(&geoCuts);

  //
  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  TChain *convmc = new TChain("ntupleR2S");
  convmc->Add("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  convmc->Add("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04_v2.root");
  niR2SforMatPlot convMC(convmc);
  //  niR2SforMatPlot convMC("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  myPlot.FillMC(&convMC); // All events

  TChain *convsim = new TChain("ntupleS2R");
  convsim->Add("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  convsim->Add("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04_v2.root");
  niS2RforMatPlot convSim(convsim);
  //  niS2RforMatPlot convSim("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  //  myPlot.responseTrain(&convSim, &convMC, 5000000, 20000000); //Remaining events
  myPlot.FillSim(&convSim); // All events

  niR2SforMatPlot convData("../7TeV/ntuple_nuclint_CMSSW358p3_goodcoll7TeV_2010-06-04.root");
  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  myPlot.FillData(&convData);
  //  myPlot.doUnfold();

  myPlot.test();
  myPlot.PlotAll();

}
int main(){

  Double_t pi = 3.141592653589793;

  std::vector<GeoCut> geoCuts;

  Double_t thetaMax = 2.*atan(exp(1.));
  Double_t thetaMin = 2.*atan(exp(-1.));
			    
  std::cout << " thetaMin " << thetaMin << " thetaMax " << thetaMax << std::endl;

  // eta = -log(tan(theta/2.)) ==> theta= 2.*tan(exp(-eta))
  geoCuts.push_back(GeoCut(thetaMin, thetaMax, 2., 13.));

  Double_t binW = (thetaMax-thetaMin)/40.;

  std::cout << " thetaMin " << thetaMin << " thetaMax " << thetaMax << " binW " << binW << std::endl;

  MatPlot myPlot("Theta", thetaMin, thetaMax, binW, binW, -1.);
  myPlot.SetGeoCuts(&geoCuts);
  myPlot.SetUIndex(5, 5);
  myPlot.SetVIndex(0, 4);

  //
  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  //MC Reco
  //
#include "src/files_conv_minbias_reco.cxx"
  convR2SforMatPlot convMC(mc);
  myPlot.FillMC(&convMC);

  //MC Sim
  //
#include "src/files_conv_minbias_sim.cxx"
  convS2RforMatPlot convSim(sim);
  myPlot.FillSim(&convSim, 1, 10000000);

  //Data
  //
#include "src/files_conv_run2012ABCD.cxx"
  convR2SforMatPlot convData(data);
  //  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  //
  // run2012D
  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/TkAlignmentPixelPosition 
  convData.SetCenterCoord(-0.10822, -0.376969, -0.410475);
  myPlot.FillData(&convData);

  myPlot.test();
  myPlot.PlotAll();


 
}
int main(){

  std::vector<Double_t> radii;
  radii.push_back(1.0);
  radii.push_back(6.0);
  radii.push_back(9.0);
  radii.push_back(17.0);
  radii.push_back(20.0);
  radii.push_back(25.5);
  radii.push_back(30.0);
  radii.push_back(34.0);
  radii.push_back(38.0);
  radii.push_back(46.0);
  radii.push_back(54.0);
  radii.push_back(57.0);
  radii.push_back(61.0);
  radii.push_back(65.0);

  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-33., -29., 1., 30.));

  Double_t boxSize = 30.;
  MatPlot myPlot("XY", -boxSize, boxSize, -boxSize, boxSize, 0.2, 0.05);
  myPlot.SetEffRadii(&radii);
  myPlot.SetGeoCuts(&geoCuts);

  /*
  // Normalization factors 
  Float_t nDataEv = 10809460;
  Float_t nSimEv = 6106513;
  // Float_t nSimEv = 6106513*5./11.;
  Float_t scaleFact = nDataEv/nSimEv;
  myPlot.SetMCScaleFact(scaleFact);
  myPlot.SetSimScaleFact(scaleFact);
  myPlot.SetDataScaleFact(1.);
  */

  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  niR2SforMatPlot convMC("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  myPlot.FillMC(&convMC); // All events

  niS2RforMatPlot convSim("../7TeV/ntuple_nuclint_CMSSW358p3_minbias7TeV_2010-06-04.root");
  //  myPlot.responseTrain(&convSim, &convMC, 5000000, 20000000); //Remaining events
  myPlot.FillSim(&convSim); // All events

  niR2SforMatPlot convData("../7TeV/ntuple_nuclint_CMSSW358p3_goodcoll7TeV_2010-06-04.root");
  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  myPlot.FillData(&convData);
  //  myPlot.doUnfold();

  myPlot.test();
  myPlot.PlotAll();

}
int main(){

  Double_t pi = 3.141592653589793;

  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(13., 29., 26., 50.));

  Double_t binW = 10.*pi/180.;

  MatPlot myPlot("Phi", -pi, pi, binW, binW, -1.);
  myPlot.SetGeoCuts(&geoCuts);
  myPlot.SetUIndex(6, 3); //phi, Z
  myPlot.SetVIndex(0, 4); //--, R

  //
  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  //MC Reco
  //
#include "src/files_conv_minbias_reco.cxx"
  convR2SforMatPlot convMC(mc);
  myPlot.FillMC(&convMC);

  //MC Sim
  //
#include "src/files_conv_minbias_sim.cxx"
  convS2RforMatPlot convSim(sim);
  myPlot.FillSim(&convSim, 1, 10000000);

  //Data
  //
#include "src/files_conv_run2012ABCD.cxx"
  convR2SforMatPlot convData(data);
  //  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  //
  // run2012D
  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/TkAlignmentPixelPosition 
  convData.SetCenterCoord(-0.10822, -0.376969, -0.410475);
  myPlot.FillData(&convData);

  myPlot.test();
  myPlot.PlotAll();


 
}
int main(){

  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-26., 26., 1., 65.));

  MatPlot myPlotR("R", 1., 60., 0.5, 0.5);
  myPlotR.SetGeoCuts(&geoCuts);
  Float_t nDataEv = 10809460;
  // Float_t nSimEv = 6106513;
  Float_t nSimEv = 6106513*5./11.;
  Float_t scaleFact = nDataEv/nSimEv;
  //
  // Assumo che il numero di eventi iniziale fosse 11000000
  //
  // I primi 5M si usano come pseudo dati
  // i secondi 6M per il training...
  //

  //
  myPlotR.SetMCScaleFact(scaleFact);
  myPlotR.SetSimScaleFact(scaleFact);
  myPlotR.SetDataScaleFact(1.);
  //  MatPlot myPlotEta("Eta", -3., 3., 0.1, 0.01);
  //  myPlotEta.SetGeoCuts(&geoCuts);

  //  Double_t boxSize = 60.;
  //  MatPlot myPlotXY("XY", -boxSize, boxSize, -boxSize, boxSize, 1., 0.1);
  //  myPlotXY.SetGeoCuts(&geoCuts);

  convR2SforMatPlot convMC("../7TeV/ntuple_conversion_CMSSW356_minbias7TeV_2010-05-10.root");
  myPlotR.FillMC(&convMC, 1, 5000000); // First 5M events
  //  myPlotXY.FillMC(&convMC);

  convS2RforMatPlot convSim("../7TeV/ntuple_conversion_CMSSW356_minbias7TeV_2010-05-10.root");
  myPlotR.responseTrain(&convSim, &convMC, 5000000, 20000000); //Remaining events
  myPlotR.FillSim(&convSim, 1, 5000000); // First 5000000 events
  //  myPlotXY.FillSim(&convSim);

  convR2SforMatPlot convData("../7TeV/ntuple_conversion_goodcoll7TeV_2010-05-10.root");
  myPlotR.FillData(&convData);
  myPlotR.doUnfold();
  //  myPlotXY.FillData(&convData);

  myPlotR.PlotAll();
  //  myPlotXY.PlotAll();
 
}
int main(){

  Double_t rMax = 65.;
  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-26., 26., 2., 20.));
  geoCuts.push_back(GeoCut(-66., 66., 20., rMax));

  MatPlot myPlot("R", 1., rMax, 0.5, 0.5, -1.);
  myPlot.SetGeoCuts(&geoCuts);
  myPlot.SetUIndex(4, 3); //Radius for plot, z for cut
  myPlot.SetVIndex(0, 4); //Plot is 1d, radius for cut

  //
  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  //MC Reco
  //
#include "src/files_conv_minbias_reco.cxx"
  convR2SforMatPlot convMC(mc);
  myPlot.FillMC(&convMC);

  //MC Sim
  //
#include "src/files_conv_minbias_sim.cxx"
  convS2RforMatPlot convSim(sim);
  myPlot.FillSim(&convSim, 1, 10000000);

  //Data
  //
#include "src/files_conv_run2012ABCD.cxx"
  convR2SforMatPlot convData(data);
  //  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  //
  // run2012D
  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/TkAlignmentPixelPosition 
  convData.SetCenterCoord(-0.10822, -0.376969, -0.410475);
  myPlot.FillData(&convData);

  myPlot.test();
  myPlot.PlotAll();


 
}
int main(){

  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-26., 26., 1., 20.));
  geoCuts.push_back(GeoCut(-66., 66., 20., 54.));
  geoCuts.push_back(GeoCut(-105., 105., 54., 120.));

  Double_t boxSize = 120.;
  //MatPlot myPlot("XY", -boxSize, boxSize, -boxSize, boxSize, 1., 0.1);
  //binsize, binsizesim, binsizeeff
  MatPlot myPlot("XY", -boxSize, boxSize, -boxSize, boxSize, 0.5, 0.2, -1.); // era 2 
  myPlot.SetGeoCuts(&geoCuts);

  //
  myPlot.SetMCScaleFact(-1.);
  myPlot.SetSimScaleFact(-1.);
  myPlot.SetDataScaleFact(1.);

  //MC Reco
  //
#include "src/files_conv_minbias_reco.cxx"
  convR2SforMatPlot convMC(mc);
  myPlot.FillMC(&convMC);

  //MC Sim
  //
#include "src/files_conv_minbias_sim.cxx"
  convS2RforMatPlot convSim(sim);
  myPlot.FillSim(&convSim, 1, 10000000);

  //Data
  //
#include "src/files_conv_run2012D.cxx"
  convR2SforMatPlot convData(data);
  //  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  //
  // run2012D
  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/TkAlignmentPixelPosition 
  convData.SetCenterCoord(-0.10822, -0.376969, -0.410475);
  myPlot.FillData(&convData);

  myPlot.test();
  myPlot.PlotAll();

}
matrix *calcWeights(matrix *m, int n, int k, int *knots) {
	
	//double w[m->rows][m->cols][n];
	matrix *w;
	matrix *z;
	
	w = new_matrix(m->rows, n * m->cols);
	z =convData(m, n, k);
	
	int i, j, t;
	
	for (i = 0; i < m->rows; ++i) {
		for (t = 0; t < n; ++t) {
			for (j = 0; j < m->cols; ++j) {
				w->m[i][t * m->cols + j] = BSpline(t, k, z->m[i][j], knots, n);
				//if (w->m[i][t*n + j] > 1)
				//printf("bad weight %lf\n", w->m[i][t*n +j]); 
			}
		}
	} 
	
	/*matrix *p;
	p = new_matrix(m->rows, n);
	//printf("p: %d, %d\n", p->rows, p->cols);
	
	double sum;
	
	for (i = 0; i < m->rows; ++i) {
		for (t = 0; t < n; ++t) {
			sum = 0;
			for (j = 0; j < m->cols; ++j) {
				sum += w[i][j][t];
			}
			sum /= n;
			p->m[i][t] = sum;
		}
	}
	*/
	//printf("p2: %d, %d\n", p->rows, p->cols);
	
	free_matrix(z);
	
	return w;
	
}
Exemple #9
0
	byte *doConvert(iconv_t &ctx, byte *data, size_t nIn, size_t nOut, size_t &size) {
		size_t inBytes  = nIn;
		size_t outBytes = nOut;

		ScopedArray<byte> convData(new byte[outBytes]);

		byte *outBuf = convData.get();

		// Reset the converter's state
		iconv(ctx, 0, 0, 0, 0);

		// Convert
		if (iconv(ctx, const_cast<ICONV_CONST char **>(reinterpret_cast<char **>(&data)), &inBytes,
		          reinterpret_cast<char **>(&outBuf), &outBytes) == ((size_t) -1)) {

			warning("iconv() failed: %s", strerror(errno));
			return 0;
		}

		size = nOut - outBytes;

		return convData.release();
	}
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[] )

{
  double  *x;             /* input data, size N*n */
  double  *y;             /* output data, size N*1 */
  double   C;             /* upper bound for Lagrange multipliers */
  double   e;             /* insensitivity zone epsilon */
  long     n;             /* dimension of input space */
  long     N;             /* number of input data */
  long     k;             /* counter */
  int      d0,d1;         /* true number of dimensions of arguments #0 and #1 */
  int      label1,label2; /* different class labels */
  kernel   ker;           /* kernel function */
  options  opt;           /* optimizer settings */
  const mxArray *mlopt;   /* mxArray for getOptionsStruct and getOptions */

  struct svm_problem prob;      /* LIBSVM problem (i.e. data) */
  struct svm_parameter param;   /* LIBSVM parameters */
  struct svm_model *model;      /* calculated LIBSVM model */

  if (nrhs<4)
    mexErrMsgTxt("Invalid number of input arguments.");

  /* --- get input and output data --- */

  if ( mxIsEmpty(prhs[0]) ||
       !mxIsDouble(prhs[0]) ||
       mxIsComplex(prhs[0]) )
    mexErrMsgTxt("Invalid first argument (input data).");

  d0 = mxGetNumberOfDimensions(prhs[0]);    /* compute true number of dims #0 */
  while ( mxGetDimensions(prhs[0])[d0-1] == 1 )
    d0--;

  if ( mxIsEmpty(prhs[1]) ) {               /* one-class SVM */
    n = mxGetDimensions(prhs[0])[d0-1];
    N = mxGetNumberOfElements(prhs[0])/n;
  }
  else if ( !mxIsDouble(prhs[1]) ||
            mxIsComplex(prhs[1]) ) {
    mexErrMsgTxt("Invalid second argument (output data).");
  }
  else {
    d1 = mxGetNumberOfDimensions(prhs[1]);  /* compute true number of dims #1 */
    while ( mxGetDimensions(prhs[1])[d1-1] == 1 )
      d1--;

    if ( d1 == d0 )                         /* exatly 1 regressor */
      n = 1;
    else if ( d1 == d0-1 )                  /* more than 1 regressor */
      n = mxGetDimensions(prhs[0])[d1];
    else
      mexErrMsgTxt("Sizes of input and output data do not match.");

    N = 1;                                  /* get number of data */
    for (k=0; k<d1; k++) {
      if ( mxGetDimensions(prhs[1])[k] != mxGetDimensions(prhs[0])[k] )
        mexErrMsgTxt("Sizes of first and second argument do not match.");
      else
        N *= mxGetDimensions(prhs[1])[k];
    }
  }

  if ( mxGetNumberOfElements(prhs[2]) != 1 ||
       !mxIsDouble(prhs[2]) ||
       mxIsComplex(prhs[2]) ||
       mxGetScalar(prhs[2]) <= 0 )
    mexErrMsgTxt("Invalid third argument (upper bound).");

  x = mxGetPr(prhs[0]);             /* get the input arguments */
  y = mxGetPr(prhs[1]);
  C = mxGetScalar(prhs[2]);

  /* set default values */
  opt.tol     = 1e-3;               /* tolerance for KKT check */
  opt.shrink  = 1;                  /* enable shrinking */
  opt.cache   = 40.0;               /* cache size in MB */
  opt.weight  = 1.0;                /* weight for class wlabel */
  opt.wlabel  = -1;                 /* class to be weighted */
  opt.verbose = 0;                  /* no verbosity */
  opt.style   = 0;                  /* C/eps style */
  opt.prob    = 0;                  /* no probability information */

  /* --- SVM classification --- */

  if ( mxGetNumberOfElements(prhs[3]) == 1 &&
       mxIsStruct(prhs[3]) ) {

    /* check lables for struct output (1 argument) */
    if ( !mxIsEmpty(prhs[1]) && nlhs == 1 ) { /* allow different class labels */
      label1 = (int)y[0];
      for (k=0; k<N; k++) {
        label2 = (int)y[k];
        if (label1 != label2)
          break;
      }
      for (k=0; k<N; k++)
        if ( y[k]!=label1 && y[k]!=label2 )
          mexErrMsgTxt("Only two different class labels are allowed.");
    }

    /* check lables for vector output (2 arguments) */
    if ( !mxIsEmpty(prhs[1]) && nlhs>1 ) {  /* class labels must be -1 or +1 */
      for (k=0; k<N; k++)
        if ( y[k]!=1 && y[k]!=-1 )
          mexErrMsgTxt("Only class labels +1 and -1 are allowed.");
      label1 = +1;
      label2 = -1;
    }

    /* get kernel and options */
    if ( getKernel(&ker,prhs[3],n) ||
         ker.type == KERNEL_GAUSS )
      mexErrMsgTxt("Invalid fourth argument (kernel function).");

    if ( nrhs>4 ) {
      getOptionsStruct(&mlopt,prhs+4,nrhs-4);
      getOptions(&opt,mlopt,N);
    }

    /* compute probability information only if it can be returned */
    if ( nlhs>1 )
      opt.prob = 0;

    /* check if weighting makes sense */
    if ( !mxIsEmpty(prhs[1]) &&
         opt.wlabel!=label1 && opt.wlabel!=label2 ) {
      opt.weight = 1;
      mexWarnMsgTxt("Class to be weighted does not exist.");
    }

    /* check nu value (C is treated as nu) */
    if ( opt.style == 1 && C > 1 )
      mexErrMsgTxt("nu must be in the range (0,1]");

    /* solve the classification problem */
    if ( mxIsEmpty(prhs[1]) ) {
      if ( C > 1 )
        mexErrMsgTxt("nu must be in the range (0,1]");
      convOptions(&param,C,0,&ker,&opt,2);
    }
    else {
      convOptions(&param,C,0,&ker,&opt,1);
    }
    convData(&prob,x,y,n,N);

    /* dump information about options and settings into MATLAB window */
    e = -1;
    if (opt.verbose > 0) {
      if ( mxIsEmpty(prhs[1]) )
        dumpOptions(&ker,&opt,C,e,2);
      else
        dumpOptions(&ker,&opt,C,e,1);
    }

    /* compute the solution */
    model = svm_train(&prob,&param);
    if ( mxIsEmpty(prhs[1]) )
      buildSolution(plhs,prhs[3],model,&prob,&opt,nlhs,2,N);
    else
      buildSolution(plhs,prhs[3],model,&prob,&opt,nlhs,1,N);


    /* dump information about solution into MATLAB window */
    if (opt.verbose > 0) {
      if ( mxIsEmpty(prhs[1]) )
        dumpSolution(&opt,model,&prob,y,C,2,N,(nlhs>1));
      else
        dumpSolution(&opt,model,&prob,y,C,1,N,(nlhs>1));
    }

    /* the model is no longer needed */
    svm_destroy_model(model);
  }

  /* --- SVM regression --- */

  else if ( !mxIsEmpty(prhs[1]) &&   /* one-class SVM not allowed */
            mxGetNumberOfElements(prhs[3]) == 1 &&
            mxIsDouble(prhs[3]) &&
            !mxIsComplex(prhs[3]) &&
            mxGetScalar(prhs[3]) >= 0 ) {

    if (nrhs<5)
      mexErrMsgTxt("Invalid number of input arguments.");

    if ( mxGetNumberOfElements(prhs[4]) != 1 ||
         !mxIsStruct(prhs[4]) )
      mexErrMsgTxt("Invalid fifth argument (kernel function).");

    /* get epsilon, kernel and options */
    e = mxGetScalar(prhs[3]);

    if ( getKernel(&ker,prhs[4],n) ||
         ker.type == KERNEL_GAUSS )
      mexErrMsgTxt("Invalid fourth argument (kernel function).");

    if ( nrhs>5 ) {
      getOptionsStruct(&mlopt,prhs+5,nrhs-5);
      getOptions(&opt,mlopt,N);
    }

    /* check nu value (e is treated as nu) */
    if ( opt.style == 1 && e > 1 )
      mexErrMsgTxt("Invalid fourth argument (nu).");

    /* solve the regression problem */
    convOptions(&param,C,e,&ker,&opt,0);
    convData(&prob,x,y,n,N);

    /* dump information about options and settings into MATLAB window */
    if (opt.verbose > 0)
      dumpOptions(&ker,&opt,C,e,0);

    model = svm_train(&prob,&param);
    buildSolution(plhs,prhs[4],model,&prob,&opt,nlhs,0,N);

    /* dump information about solution into MATLAB window */
    if (opt.verbose > 0)
      dumpSolution(&opt,model,&prob,y,C,0,N,(nlhs>1));

    /* the model is no longer needed */
    svm_destroy_model(model);
  }

  else
    mexErrMsgTxt("Invalid fourth argument (kernel function).");

}
int main(){

  std::vector<Double_t> radii;
  radii.push_back(2.0); // 1.
  radii.push_back(3.0); // 3.5
  radii.push_back(6.0);
  radii.push_back(9.0);
  radii.push_back(17.0);
  radii.push_back(22.0); // 20.0
  radii.push_back(25.5);
  radii.push_back(30.0);
  radii.push_back(34.0);
  radii.push_back(38.0);
  radii.push_back(45.5); // 46.0
  radii.push_back(54.5); // 54.0
  radii.push_back(57.0);
  radii.push_back(61.5); // 61.0
  radii.push_back(65.0);

  Double_t rMax = 65.;
  std::vector<GeoCut> geoCuts;
  geoCuts.push_back(GeoCut(-26., 26., 2., 20.));
  geoCuts.push_back(GeoCut(-66., 66., 20., rMax));

  MatPlot myPlotR("R", 1., rMax, 0.5, 0.5);
  myPlotR.SetEffRadii(&radii);
  myPlotR.SetGeoCuts(&geoCuts);
  Float_t nDataEv = 10809460;
  // Float_t nSimEv = 6106513;
  Float_t nSimEv = 6106513*5./11.;
  Float_t scaleFact = nDataEv/nSimEv;
  //
  // Assumo che il numero di eventi iniziale fosse 11000000
  //
  // I primi 5M si usano come pseudo dati
  // i secondi 6M per il training...
  //

  //
  myPlotR.SetMCScaleFact(-1.);
  myPlotR.SetSimScaleFact(-1.);
  myPlotR.SetDataScaleFact(1.);

  convR2SforMatPlot convMC("../7TeV/ntuple_conversion_CMSSW358p3_minbias7TeV_2010-06-04.root");
  myPlotR.FillMC(&convMC, 5000000, 100000000); // First 5M events

  convS2RforMatPlot convSim("../7TeV/ntuple_conversion_CMSSW358p3_minbias7TeV_2010-06-04.root");
  myPlotR.responseTrain(&convSim, &convMC, 1, 5000000); //Remaining events
  myPlotR.FillSim(&convSim, 5000000, 100000000); // First 5000000 events

  convR2SforMatPlot convData("../7TeV/TIB1Int_Plus15_2.root");
  //  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  myPlotR.FillData(&convData);
  myPlotR.doUnfold();

  /*
  myPlotR.SetMCScaleFact(scaleFact);
  myPlotR.SetSimScaleFact(scaleFact);
  myPlotR.SetDataScaleFact(1.);

  convR2SforMatPlot convMC("../7TeV/ntuple_conversion_CMSSW356_minbias7TeV_2010-05-10.root");
  myPlotR.FillMC(&convMC, 1, 5000000); // First 5M events

  convS2RforMatPlot convSim("../7TeV/ntuple_conversion_CMSSW356_minbias7TeV_2010-05-10.root");
  myPlotR.responseTrain(&convSim, &convMC, 5000000, 20000000); //Remaining events
  myPlotR.FillSim(&convSim, 1, 5000000); // First 5000000 events

  convR2SforMatPlot convData("../7TeV/ntuple_conversion_goodcoll7TeV_2010-05-10.root");
  convData.SetCenterCoord(-0.1475, -0.3782, -0.4847);
  myPlotR.FillData(&convData);
  myPlotR.doUnfold();
  */

  myPlotR.PlotAll();
  myPlotR.test();
 
}