I want to define a Pdf that returns a different value depending on the discrete value of a variable tag that can be -1, 1 or 0.
RooCategory tag= new RooCategory(“tag”,“tag”);
tag->defineType(“R”,-1); tag->defineType(“W”,1); tag->defineType(“U”,0);
RooRealVar prob = new RooRealVar(“prob”,“NNet probability”,-2.5,1);
RooRealVar p_0 = new RooRealVar(“p_0”,“p_0”,mm,0.5mm,2.mm);
RooRealVar p_1 = new RooRealVar(“p_1”,“p_1”,1,0.5,2.);
RooRealVar MM = new RooRealVar(“Net_mean”,“Net mean”,mm,0.5mm,2mm); MM->setError(0.1mm);
RooRealVar* RMS = new RooRealVar(“Net_RMS”,“Net RMS”,rms,0.5rms,2rms); RMS->setError(0.1*rms);
If I type :
I see that tag is defined as RooAbsReal in the pippo.h(cxx) and when I try to compile in my code it gives me errors since there is a definition mismatch on tag.
So I changed the _tag definition to RooAbsCategory and the corresponding tag from RooRealProxy into RooCategoryProxy.
It compiles and apparently runs, but then if in the eval() method I write:
cout<< tag <<" "<<prob<<endl;
I see that rather frequently the tag variable is NOT the one I read from my file (I get -1 instead of 0. I can tell because I know that if tag=0 prob=-2).
So the question is:
Does the RooClassFactory support the RooCategory arguments?
How could I implement some code like this:
Double_t pippo::evaluate() const
cout<<" “<<tag<<” "<<prob<<endl;
if(tag>0) // Wrong Tag
weight = p_0+p_1(prob-Net_mean);
weight = 1-(p_0+p_1*(prob-Net_mean));