RooAddPdf with several pdf

Dear RooFit users,

I want to define a PDF made by the sum of several gaussian (at least 11) using RooAddPdf. I define an array of RooGaussian like that

RooRealVar Nphe[Npeak];
RooRealVar frac[Npeak];
RooRealVar sigmaNphe[Npeak];
RooGaussian G[Npeak];

for(Int_t i=0;i<Npeak;i++){

new Nphe[i](Form("%dNphe",i+1),Form("%d photoelectron",i),i+1,i,i+2);
new frac[i](Form(“frac%d”,i+1),Frac(“fraction %d”,i+1), 0.,1.);
new sigmaNphe[i](Form("#sigma%d",i+1),Form(“sigma peak %d”,%d),0.,10.); ///vedere dai dati
new G[i](Form(“G%d”,i+1),Form(“distribution %dst phe”,i+1),N,Nphe[i],sigmaNph[i]);


everything works fine till this point. Now I want to sum all those RooGaussianPdf by using RooAdd PDF

I’d like too avoid something like

RooAddPdf Sig(“singlaPDF”,“gauss sum”,RooArgList(G[0],G[1]…frac[Npeak-1]),RooArgList(frac[0],frac[1],…frac[Npeak-1]))

I guess there should be a smarter more compact way to define it. Does someone has any suggestion?

thank you very much

This is a duplicate of [ … 598#p83958](Passing array of RooAbsArg to RooArgList