Hello @StephanH,
thanks for offering some help.
I have used your suggestion and had a look at the model tree. Given that the model is very complicated, I have tried to reduce a little bit the tree by including only the sample on to which the systematic has been added.
Below I am attaching quasi-code snippet that explains what I am doing
#define CUSTOMIZER_STRATEGY kTrue
//Define the templates file
TFile* fin = new TFile("Templates_File.root");
//----Define the measurement
RooStats::HistFactory::Measurement meas("R","R");
meas.SetLumi(1.0);
//---Define the channel
RooStats::HistFactory::Channel chan("chan");
chan.SetStatErrorConfig(1.e-5,"Poisson");
//----Define the channel
RooStats::HistFactory::Sample* Bd2DD = new RooStats::HistFactory::Sample("hNBd2DD", "hNBd2DD", "Templates_file.root")
Bd2DD->SetNormalizeByTheory(kFalse);
Bd2DD.AddNormFactor("NDD");
Bd2DD.AddNormFactor("MCBd2DD");
Bd2DD.AddNormFactor("fBd2DD");
Bd2DD.AddHistoSys("variation", "hNBd2DD_m1sigma", "Templates_file.root", "hNBd2DD_p1sigma", "Templates_file.root");
Bd2DD.AddHistoSys("quad_variation", "hNBd2DD_mqsigma_quad", "Templates_file.root", "hNBd2DD_p1sigma_quad", "Templates_file.root");
chan.AddSample(*Bd2DD);
chan.SetData("hNData", "Templates_file.root");
meas.AddChannel(chan);
int num_channels = 1;
//---Set some normalization parameters constant
meas.AddConstantParam("MCBd2DD");
meas.AddConstantParam("fBd2DD");
if(!CUSTOMIZER_STRATEGY){
//---Changing the Gaussian constraint to a uniform constraint
meas.AddUniformSyst("variation");
meas.AddUniformSyst("quad_variation");
}
//---Define the workspace of the measurement, and the ModelConfig attached
RooWorkSpace* w;
w = RooStats::HistFactory::MakeModelAndMeasurementFast(meas);
RooStats::ModelConfig *mc (RooStats::ModelConfig*) w->obj("ModelConfig");
//----Get the pdf and define a new pdf that will contain the modified model if CUSTOMIZER_STRATEGY is true
RooArgSet* obs = (RooArgSet*) mc->GetObservables();
Roocategory* idx = (RooCategory*) obs->find("channelCat");
RooSimultaneous* model = (RooSimultaneous*)mc->GetPdf();
RooSimultanoeus* model_cust = new RooSimultanoeus("simPdf_modified", "simPdf_modified", *idx);
if(CUSTOMIZER_STRATEGY){
//----Take the old gaussian constraint
RooRealVar* alpha_variation = (RooRealVar*) mc->GetNuisanceParameters()->find("alpha_variation");
RooRealVar* alpha_quad_variation = (RooRealVar*) mc->GetNuisanceParameters()->fing("alpha_quad_variation");
RooGaussian* alpha_variationConstraint = (RooGaussian*) w->pdf("alpha_variationConstraint");
RooGaussian* alpha__quad_variationConstraint = (RooGaussian*) w->pdf("alpha_quad_variationConstraint");
//---Define the new constraint
RooUniform* alpha_variationConstraint_Uniform = new RooUniform("alpha_variationConstraint_Uniform", "alpha_variationConstraint_Uniform", RooArgSet(*alpha_variation));
RooUniform* alpha_quad_variationConstraint_Unifofm = new RooUniform("alpha_quad_variationConstraint_Uniform", "alpha_quad_variationConstraint_Uniform", RooArgSet(*alpha_quad_variation));
//---Customize the model
RooCustomizer* cust_;
RooAbsPdf* pdf_;
for (unsigned int j=0; j<num_channels; j++){
idx->setIndex(j);
pdf_ = model->getPdf(idx->getLabel());
cust_ = new RooCustomizer(*pdf_, "cust_");
cust_->replaceArg(*alpha_variatonConstraint, *alpha_variationConstraint_Uniform);
cust_->replaceArg(*alpha_quad_variationConstraint, *alpha_quad_variationConstraint_Uniform);
model_cust->addPadf((RooAbsPdf&)*cust_->build(),idx->getLabel());
}
}
//---Print the model in a .dot file to be processed with graphViz
if(!CUSTOMIZER_STRATEGY){
model->graphVizTree("TreeUniform.dot");
}
else{
model_cust->graphVizTree("TreeUniform_RooCustomizer.dot");
}
The only channel that has been added has two systematics attached to it, called variaton and quad_variation. I then change the gaussian constraints with a uniform constraint, choosing between the two methods with the variable CUSTOMIZER_STRATEGY.
I have also attached the two graph trees i obtain with the two methods. I am sorry if the names do not fully coincide with the pseudo-code from above, but I have tried to change the names from my original code to keep the tree image compact.
TreeUniform_RooCustomizer.pdf (55.9 KB)
TreeUniform.pdf (57.2 KB)
The main difference I can see by eye is that when using the function AddUniformSyst() from the HistFactory::Measurement class, the PieceWiseInterpolation class that performs the template morphing does not take the alpha values directly from the alpha RooRealVar’s, but from a RooPolyVar with constant parameters +1 and -1 which x values are the alpha variables . Can you please explain why is this happening and if this can be the source of the different results?
Thanks a lot,
Simone