Pluto v6.3.0
Loading...
Searching...
No Matches
eta_pileup.C
Go to the documentation of this file.
1//TITLE Using a batch script to simulate pileup
2
3{
4
5 //first, we define in the data base:
6 //1.) The mean time difference between 2 events
7 // N.B. the time in Pluto is in mm/s, so we have to convert it
8 // let us start with 100000 events/s
9 makeStaticData()->SetBatchValue("beam_particle_mean_time", 10e-5 * TMath::C() / 10e-3);
10
11 //2.) The time of the first event (we choose 0)
12 makeStaticData()->SetBatchValue("absolute_event_time", 0);
13
14 //3.) The threshold for a pile-up event (just e.g. 50% of beam_particle_mean_time)
15 makeStaticData()->SetBatchValue("pileup_time_theshold", 0.5 * 10e-5 * TMath::C() / 10e-3);
16
17 //4.) Just a flag for pileup
18 makeStaticData()->SetBatchValue("pileup_flag", 0);
19
20 //this just constructs the temporary particles:
21 makeDynamicData()->GetBatchParticle("p1");
22 makeDynamicData()->GetBatchParticle("p2");
23 makeDynamicData()->GetBatchParticle("eta1");
24
25 //**************************************************************
26 PReaction my_reaction("_T1=2.2", "p", "p", "p p eta", "pileup_eta");
27 my_reaction.trackedParticles(); //this removes the "empty events"
28 //**************************************************************
29
30 //the following loop sets the absolute time for each particle
31 my_reaction.Do("foreach(*); event_time = [*]->T(); [*]->SetT(event_time + absolute_event_time)");
32
33 //set a event time difference based on a "flat" distribution
34 my_reaction.Do("timediff = sampleFlat()*2*beam_particle_mean_time");
35
36 //check if the last event was pileup and has been removed:
37 my_reaction.Do("if !pileup_flag; goto check_pileup");
38 my_reaction.Do("push(p1); push(p2); push(eta1);");
39 my_reaction.Do("pileup_flag = 0");
40 my_reaction.Do("goto event_ok");
41
42 //check if we are below threshold
43 my_reaction.Do("check_pileup:");
44 my_reaction.Do("if timediff > pileup_time_theshold; goto event_ok");
45
46 //if yes, store particles and kill event
47 my_reaction.Do("p1 = [p,1]; p2 = [p,2]; eta1 = [eta];");
48 my_reaction.Do("[p,1]->SetInActive(); [p,2]->SetInActive(); [eta]->SetInActive();");
49 my_reaction.Do("pileup_flag = 1");
50
51
52 my_reaction.Do("event_ok:");
53 //set the new time for the next event
54 my_reaction.Do("absolute_event_time = absolute_event_time + timediff");
55
56
57
58 //this is just for debugging:
59 my_reaction.Do("time = [p,1]->T(); echo $time");
60 my_reaction.Do("foreach(*); [*]->Print();");
61
62 my_reaction.Print(); //The "Print()" statement is optional
63 my_reaction.Loop(100);
64}
PReaction my_reaction("_T1=2.2", "p", "p", "p p eta", "pileup_eta")
makeStaticData() -> SetBatchValue("absolute_event_time", 0)
makeDynamicData() -> GetBatchParticle("p1")
PReaction my_reaction("3.5","p","7Li","p (n) phi [K+ K-] (6Li)","delme")