StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.filter.C
1 // macro to instantiate the Geant3 from within
2 // STAR C++ framework and get the starsim prompt
3 // To use it do
4 // root4star starsim.C
5 
6 class St_geant_Maker;
7 St_geant_Maker *geant_maker = 0;
8 
9 class StarGenEvent;
10 StarGenEvent *event = 0;
11 
12 class StarPrimaryMaker;
13 StarPrimaryMaker *_primary = 0;
14 
15 class StarFilterMaker;
16 StarFilterMaker *filter = 0;
17 
18 // ----------------------------------------------------------------------------
19 void geometry( TString tag, Bool_t agml=true )
20 {
21  TString cmd = "DETP GEOM "; cmd += tag;
22  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
23  geant_maker -> LoadGeometry(cmd);
24 }
25 // ----------------------------------------------------------------------------
26 void command( TString cmd )
27 {
28  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
29  geant_maker -> Do( cmd );
30 }
31 // ----------------------------------------------------------------------------
32 // trig() -- generates one event
33 // trig(n) -- generates n events.
34 void trig( Int_t n=1 )
35 {
36  chain->EventLoop(n);
37 
38 }
39 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
42 void Pythia8( TString config="pp:W", Double_t ckin3=0.0, Double_t ckin4=-1.0 )
43 {
44 
45  gSystem->Load( "Pythia8_1_62.so" );
46 
47  //
48  // Create the pythia 8 event generator and add it to
49  // the primary generator
50  //
51  StarPythia8 *pythia8 = new StarPythia8();
52  if ( config=="pp:W" )
53  {
54  pythia8->SetFrame("CMS", 510.0);
55  pythia8->SetBlue("proton");
56  pythia8->SetYell("proton");
57 
58  pythia8->Set("WeakSingleBoson:all=off");
59  pythia8->Set("WeakSingleBoson:ffbar2W=on");
60  pythia8->Set("24:onMode=0"); // switch off all W+/- decaus
61  pythia8->Set("24:onIfAny 11 -11"); // switch on for decays to e+/-
62 
63  }
64  if ( config=="pp:minbias" )
65  {
66  pythia8->SetFrame("CMS", 500.0);
67  pythia8->SetBlue("proton");
68  pythia8->SetYell("proton");
69 
70  pythia8->Set("HardQCD:all = on");
71 
72  }
73 
74  // Setup phase space cuts
75  pythia8 -> Set(Form("PhaseSpace:ptHatMin=%f", ckin3 ));
76  pythia8 -> Set(Form("PhaseSpace:ptHatMax=%f", ckin4 ));
77 
78  _primary -> AddGenerator( pythia8 );
79 
80 }
81 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
83 // ----------------------------------------------------------------------------
84 void Pythia6( TString mode="pp:minbias", Double_t ckin3=0.0, Double_t ckin4=-1.0, Int_t tune=320, Int_t rngSeed=1234 )
85 {
86 
87  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
88  gSystem->Load( "libPythia6_4_23.so");
89  // gSystem->Load( "StarPythia6.so" );
90 
91  // Setup RNG seed and captuire ROOT TRandom
92  StarRandom::seed(rngSeed);
94 
95  StarPythia6 *pythia6 = new StarPythia6("pythia6");
96 
97  //
98  // Common blocks for configuration
99  //
100  PySubs_t &pysubs = pythia6->pysubs();
101 
102  if ( mode=="pp:W" )
103  {
104  pythia6->SetFrame("CMS", 510.0 );
105  pythia6->SetBlue("proton");
106  pythia6->SetYell("proton");
107  if ( tune ) pythia6->PyTune( tune );
108 
109  // Setup pythia process
110 
111  pysubs.msel = 12;
112 
113  }
114  if ( mode == "pp:minbias" )
115  {
116  pythia6->SetFrame("CMS", 510.0 );
117  pythia6->SetBlue("proton");
118  pythia6->SetYell("proton");
119  pythia6->PyTune( tune );
120 
121  // Setup pythia process
122 
123  pysubs.msel = 1;
124 
125  }
126 
127  pysubs.ckin(3)=ckin3;
128  pysubs.ckin(4)=ckin4;
129 
130  _primary->AddGenerator(pythia6);
131 
132 }
133 
134 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
137 void starsim( Int_t nevents=1, Double_t ckin3=7.0, Double_t ckin4=-1.0 )
138 {
139 
140  gROOT->ProcessLine(".L bfc.C");
141  {
142  TString simple = "y2012 geant gstar usexgeom agml ";
143  bfc(0, simple );
144  }
145 
146  gSystem->Load( "libVMC.so");
147 
148  gSystem->Load( "StarGeneratorUtil.so");
149  gSystem->Load( "StarGeneratorEvent.so");
150  gSystem->Load( "StarGeneratorBase.so" );
151  gSystem->Load( "libMathMore.so" );
152 
153 
154 
155  // gSystem->Load("StarFilterMaker.so") ;
156  gSystem->Load( "StarGeneratorFilt.so" );
157 
158  gMessMgr->SetLevel(999);
159 
160  //
161  // Create the primary event generator and insert it
162  // before the geant maker
163  //
164  _primary = new StarPrimaryMaker();
165  {
166  _primary -> SetFileName( Form("filter_%f_%f.gener.root",ckin3,ckin4) );
167  _primary -> SetVertex( 0.1, -0.2, 0.0 );
168  _primary -> SetSigma ( 0.1, 0.1, 30.0 );
169  chain -> AddBefore( "geant", _primary );
170  }
171 
172  //
173  // Setup an event generator
174  //
175  Pythia8("pp:minbias", ckin3, ckin4 );
176  // Pythia6("pp:minbias", ckin3, ckin4 );
177 
178  //
179  // Setup the generator filter
180  //
181  filter = new StDijetFilter();
182  _primary -> AddFilter( filter );
183 
184  // If set to 1, tracks will be saved in the tree on events which were
185  // rejected. If the tree size is too big (because the filter is too
186  // powerful) you may want to set this equal to zero. In which case
187  // only header information is saved for the event.
188  _primary->SetAttr("FilterKeepAll", int(1));
189 
190  // By default, the primary maker enters an infinite loop and executes
191  // the event generator until it yields an event which passes the filter.
192  // The big full chain treats this as a single event.
193  //
194  // If you want the BFC to see an empty event, set the FilterSkipRejects
195  // attribute on the primary maker and give it the priveledge it needs
196  // to kill the event.
197  //--- primary->SetAttr("FilterSkipRejects", int(1) ); // enables event skipping
198  //--- chain->SetAttr(".Privilege",1,"StarPrimaryMaker::*" );
199 
200 
201  //
202  // Initialize primary event generator and all sub makers
203  //
204  _primary -> Init();
205 
206  //
207  // Setup geometry and set starsim to use agusread for input
208  //
209 
210  command("gkine -4 0");
211  command( Form("gfile o filter_%f_%f.starsim.fzd",ckin3,ckin4) );
212 
213 
214  //
215  // Trigger on nevents
216  //
217  trig( nevents );
218 
219  //
220  // Finish the chain
221  //
222  chain->Finish();
223 
224  //
225  // EXIT starsim
226  //
227  command("call agexit"); // Make sure that STARSIM exits properly
228 
229 }
230 // ----------------------------------------------------------------------------
231 
void PyTune(Int_t tune)
Calls the pytune function.
Definition: StarPythia6.cxx:44
void SetFrame(const Char_t *frame, const Double_t val)
virtual Int_t Finish()
Definition: StChain.cxx:85
Main filter class. Goes anywhere in the chain, filters StarGenEvent objects.
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
PySubs_t & pysubs()
Returns a reference to the /PYSUBS/ common block.
Definition: StarPythia6.h:61
static void seed(UInt_t s)
Definition: StarRandom.cxx:119
Base class for event records.
Definition: StarGenEvent.h:81
Interface to pythia 6.
Definition: StarPythia6.h:48
Main steering class for event generation.
void SetYell(const Char_t *y)
Sets the particle species for the yellow beam.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
void Set(const char *s)
Pass a string to Pythia8::Pythia::readString(), for user configuration.
Definition: StarPythia8.h:91