Play with the mass shape of a dummy resonance


Int_t decay_index, pid_resonance;

double f_my_function(double *x, double * par) {
    Double_t mass = x[0];

    //this is a dummy box:
    if ((mass < 1.2) || (mass > 1.5)) return 0;

    //add a smooth trailing edge - if wanted
    //(if not return a 1)
    Double_t width = makeDynamicData()->GetDecayPartialWidth(mass, decay_index);
    return width;
}

void user_mass(void) {

    //Add a user-defined particle with mass = 1.25 GeV
    pid_resonance = makeStaticData()->AddParticle(-1, "MyResonance", 1.25);
    //Set the width (important to enable the m1-decay model for the production)
    makeStaticData()->SetParticleTotalWidth("MyResonance", 0.25);
    //It must be a hadron:
    makeStaticData()->SetParticleBaryon("MyResonance", 1);

    //Add some user-defined decays:
    decay_index = makeStaticData()->AddDecay("MyResonance --> p + pi-", "MyResonance", 
					     "p,pi-", .5 );
    makeStaticData()->AddDecay("MyResonance --> n + pi0", "MyResonance", 
			       "n,pi0", .5 );
    makeStaticData()->AddDecay("MyResonance --> n + pi0 + pi0", "MyResonance", 
			       "n,pi0,pi0", 1 );
    //N.B.: Branching ratios are re-normalized

    listParticle("MyResonance"); //List the data base content
    
    //Add a user-defined mass distribution:
    PMassSampling *model = new PMassSampling("mymodel@MyResonance", "My model", -1);
    model->SetSamplingFunction(new TF1("mass_function",f_my_function,0.,10.,1));
    makeDistributionManager()->Add(model);

    //Create the reaction and a control histogram
    TH1F *histo = new TH1F("histo", "MyResonance mass", 100, 1., 1.6);
    PReaction r("1.25", "p", "p", "p MyResonance [p pi-]");
    //(Try what happens if you increase the beam energy!)
    r.Do(histo, "_x = [MyResonance]->M()");
    r.Print();
    r.Loop(10000);
    
    histo->Draw();
}
 user_mass.C:1
 user_mass.C:2
 user_mass.C:3
 user_mass.C:4
 user_mass.C:5
 user_mass.C:6
 user_mass.C:7
 user_mass.C:8
 user_mass.C:9
 user_mass.C:10
 user_mass.C:11
 user_mass.C:12
 user_mass.C:13
 user_mass.C:14
 user_mass.C:15
 user_mass.C:16
 user_mass.C:17
 user_mass.C:18
 user_mass.C:19
 user_mass.C:20
 user_mass.C:21
 user_mass.C:22
 user_mass.C:23
 user_mass.C:24
 user_mass.C:25
 user_mass.C:26
 user_mass.C:27
 user_mass.C:28
 user_mass.C:29
 user_mass.C:30
 user_mass.C:31
 user_mass.C:32
 user_mass.C:33
 user_mass.C:34
 user_mass.C:35
 user_mass.C:36
 user_mass.C:37
 user_mass.C:38
 user_mass.C:39
 user_mass.C:40
 user_mass.C:41
 user_mass.C:42
 user_mass.C:43
 user_mass.C:44
 user_mass.C:45
 user_mass.C:46
 user_mass.C:47
 user_mass.C:48
 user_mass.C:49
 user_mass.C:50
 user_mass.C:51