Two-step process (phi in medium -> K K -> K K_scatter)


double f_my_function(double *x, double * par)
{
    if (x[0] > 0.8) return 1;
    return 0;
}

fermi_rescattering() {

    gErrorIgnoreLevel=kWarning;

    makeDistributionManager()->Exec("nucleus_fermi:proton");
    Double_t fragment_mass = makeStaticData()->GetParticleMass("6Li") -
        makeStaticData()->GetParticleMass("n");
    makeStaticData()->AddParticle(999, "fragment",fragment_mass);

    //Now we have to do some preparation:
    PFermiDistributions* model = 
        new PFermiDistributions("6Li_fermi@6Li/fermi","Fermi momentum of 6Li",-1);
    model->SetRange(0,2.);
    makeDistributionManager()->Add(model);

    //This is the real reaction:
    PParticle * beam  =new PParticle("p",3.5);
    PParticle * target=new PParticle("7Li");
    PParticle * s= new PParticle(*beam+*target);

    //Quasi-free sub-reaction:
    PParticle * beam2  =new PParticle("p");
    PParticle * target2=new PParticle("n");
    PParticle * s2= new PParticle(*beam2+*target2);

    PParticle * spectator=new PParticle("6Li");
    PParticle * cc1[]={s,s2,spectator};

    //The outgoing products of the p-n scattering:
    PParticle * p1  =new PParticle("p");
    PParticle * p2  =new PParticle("n");
    PParticle * phi =new PParticle("phi");

    PParticle * cc2[]={s2,p1,p2,phi};

    //decay of the phi:
    PParticle * kp  =new PParticle("K+");
    PParticle * km  =new PParticle("K-");

    PParticle * cc3[]={phi,kp,km};

    //scatter the K+ again, this is like treating it as a "beam particle"
    //the "real reaction" in this case is K+ + 6Li
    //Use the "Scatter" method to keep the original pointers
    PParticle * rescatter= new PParticle("dummy");
    rescatter->Scatter(kp,spectator);

    //Next quasi-free sub-reaction:
    PParticle * beam3  =new PParticle("K+");
    PParticle * target3=new PParticle("n");
    PParticle * s3= new PParticle(*beam3+*target3);

    PParticle * spectator3=new PParticle("fragment");
    PParticle * cc4[]={rescatter,s3,spectator3};

   //The outgoing products of the final re-scattering:
    PParticle * final_kp  =new PParticle("K+");
    PParticle * final_n  =new PParticle("n");

    PParticle * cc5[]={s3,final_kp,final_n};

    //after this point our new particles and decays are pre-defined

    PFermiMomentumGA *pmodel = 
        new PFermiMomentumGA("K+n_in_6Li@K+ + 6Li_to_K+ + n_fragment",
                             "Quasi-free particle production",-1);      
    // Now add all particles
    // Define spectators and final decay products (the granddaughters)
    pmodel->Add("q,parent");                                       
    pmodel->Add("K+,grandparent,beam");                            
    pmodel->Add("6Li,grandparent,target");
    pmodel->Add("fragment,daughter,spectator");
    pmodel->Add("q,daughter,composite");
    pmodel->Add("n,granddaughter,participant"); 
    pmodel->Add("K+,granddaughter,p2"); 
    makeDistributionManager()->Add(pmodel);


    //Add a dummy angular distribution
    //In this case it is just a step function, it is without any physical meaning!
    PAngularDistribution *ang = new PAngularDistribution("my_angle","My angular dist");
    ang->Add("q,parent,reference");
    ang->Add("n,daughter");
    ang->Add("K+,daughter,primary");
    ang->Add("n,grandparent,base_reference");
    TF1 *angles2=new TF1("angles2",f_my_function,-1,1,1);
    ang->SetAngleFunction(angles2);
    makeDistributionManager()->Add(ang);


    PChannel *c1=new PChannel(cc1,2);
    PChannel *c2=new PChannel(cc2,3);
    PChannel *c3=new PChannel(cc3,2);
    PChannel *c4=new PChannel(cc4,2);
    PChannel *c5=new PChannel(cc5,2);

    PChannel *cc[]={c1,c2,c3,c4,c5};


    //Some online histograms: compare the undistorted phi shape with
    //the reconstructed one
    PReaction *r=new PReaction(cc,"fermi_rescattering",5);
    TH1F * histo1 = new TH1F ("histo1","phi mass",100,0.9,1.2);
    r->Do(histo1,"_x = [phi]->M()");
    TH1F * histo2 = new TH1F ("histo2","phi mass (scatter)",100,0.9,1.2);
    r->Do(histo2,"_x = ([K+,2] + [K-])->M()");

    r->Print();


    r->loop(10000);

    histo1->Draw();
    histo2->Draw("same");

}
 plugin_fermi_rescattering.C:1
 plugin_fermi_rescattering.C:2
 plugin_fermi_rescattering.C:3
 plugin_fermi_rescattering.C:4
 plugin_fermi_rescattering.C:5
 plugin_fermi_rescattering.C:6
 plugin_fermi_rescattering.C:7
 plugin_fermi_rescattering.C:8
 plugin_fermi_rescattering.C:9
 plugin_fermi_rescattering.C:10
 plugin_fermi_rescattering.C:11
 plugin_fermi_rescattering.C:12
 plugin_fermi_rescattering.C:13
 plugin_fermi_rescattering.C:14
 plugin_fermi_rescattering.C:15
 plugin_fermi_rescattering.C:16
 plugin_fermi_rescattering.C:17
 plugin_fermi_rescattering.C:18
 plugin_fermi_rescattering.C:19
 plugin_fermi_rescattering.C:20
 plugin_fermi_rescattering.C:21
 plugin_fermi_rescattering.C:22
 plugin_fermi_rescattering.C:23
 plugin_fermi_rescattering.C:24
 plugin_fermi_rescattering.C:25
 plugin_fermi_rescattering.C:26
 plugin_fermi_rescattering.C:27
 plugin_fermi_rescattering.C:28
 plugin_fermi_rescattering.C:29
 plugin_fermi_rescattering.C:30
 plugin_fermi_rescattering.C:31
 plugin_fermi_rescattering.C:32
 plugin_fermi_rescattering.C:33
 plugin_fermi_rescattering.C:34
 plugin_fermi_rescattering.C:35
 plugin_fermi_rescattering.C:36
 plugin_fermi_rescattering.C:37
 plugin_fermi_rescattering.C:38
 plugin_fermi_rescattering.C:39
 plugin_fermi_rescattering.C:40
 plugin_fermi_rescattering.C:41
 plugin_fermi_rescattering.C:42
 plugin_fermi_rescattering.C:43
 plugin_fermi_rescattering.C:44
 plugin_fermi_rescattering.C:45
 plugin_fermi_rescattering.C:46
 plugin_fermi_rescattering.C:47
 plugin_fermi_rescattering.C:48
 plugin_fermi_rescattering.C:49
 plugin_fermi_rescattering.C:50
 plugin_fermi_rescattering.C:51
 plugin_fermi_rescattering.C:52
 plugin_fermi_rescattering.C:53
 plugin_fermi_rescattering.C:54
 plugin_fermi_rescattering.C:55
 plugin_fermi_rescattering.C:56
 plugin_fermi_rescattering.C:57
 plugin_fermi_rescattering.C:58
 plugin_fermi_rescattering.C:59
 plugin_fermi_rescattering.C:60
 plugin_fermi_rescattering.C:61
 plugin_fermi_rescattering.C:62
 plugin_fermi_rescattering.C:63
 plugin_fermi_rescattering.C:64
 plugin_fermi_rescattering.C:65
 plugin_fermi_rescattering.C:66
 plugin_fermi_rescattering.C:67
 plugin_fermi_rescattering.C:68
 plugin_fermi_rescattering.C:69
 plugin_fermi_rescattering.C:70
 plugin_fermi_rescattering.C:71
 plugin_fermi_rescattering.C:72
 plugin_fermi_rescattering.C:73
 plugin_fermi_rescattering.C:74
 plugin_fermi_rescattering.C:75
 plugin_fermi_rescattering.C:76
 plugin_fermi_rescattering.C:77
 plugin_fermi_rescattering.C:78
 plugin_fermi_rescattering.C:79
 plugin_fermi_rescattering.C:80
 plugin_fermi_rescattering.C:81
 plugin_fermi_rescattering.C:82
 plugin_fermi_rescattering.C:83
 plugin_fermi_rescattering.C:84
 plugin_fermi_rescattering.C:85
 plugin_fermi_rescattering.C:86
 plugin_fermi_rescattering.C:87
 plugin_fermi_rescattering.C:88
 plugin_fermi_rescattering.C:89
 plugin_fermi_rescattering.C:90
 plugin_fermi_rescattering.C:91
 plugin_fermi_rescattering.C:92
 plugin_fermi_rescattering.C:93
 plugin_fermi_rescattering.C:94
 plugin_fermi_rescattering.C:95
 plugin_fermi_rescattering.C:96
 plugin_fermi_rescattering.C:97
 plugin_fermi_rescattering.C:98
 plugin_fermi_rescattering.C:99
 plugin_fermi_rescattering.C:100
 plugin_fermi_rescattering.C:101
 plugin_fermi_rescattering.C:102
 plugin_fermi_rescattering.C:103
 plugin_fermi_rescattering.C:104
 plugin_fermi_rescattering.C:105
 plugin_fermi_rescattering.C:106
 plugin_fermi_rescattering.C:107
 plugin_fermi_rescattering.C:108
 plugin_fermi_rescattering.C:109
 plugin_fermi_rescattering.C:110
 plugin_fermi_rescattering.C:111
 plugin_fermi_rescattering.C:112
 plugin_fermi_rescattering.C:113
 plugin_fermi_rescattering.C:114
 plugin_fermi_rescattering.C:115
 plugin_fermi_rescattering.C:116
 plugin_fermi_rescattering.C:117
 plugin_fermi_rescattering.C:118
 plugin_fermi_rescattering.C:119
 plugin_fermi_rescattering.C:120
 plugin_fermi_rescattering.C:121
 plugin_fermi_rescattering.C:122
 plugin_fermi_rescattering.C:123
 plugin_fermi_rescattering.C:124