10 Int_t hid( Int_t z, Int_t a, Int_t l=0 )
36 double _vxyz[3] = { 0, 0, 0 };
37 double _sxyz[3] = { 0, 0, 0 };
40 unsigned int _seed = 0;
42 double _eventtime = 0;
44 double _magfield = -5.005;
48 int _pid[50]={1,2,3,8,9,11,12,14,15,10017,10007,45,50045,49,50049,37,61053,61054,62053,62054,60008,60009,95,98,97};
49 TString _pnm[50]={
"gamma",
"positron",
"electron",
"pi+",
"pi-",
"K+",
"K-",
"proton",
"antiproton",
"eta",
"pi0",
"deuteron",
"antideuteron",
"he3",
"antihe3",
"D0",
"HyperT_2body",
"HyperT_bar_2body",
"HyperT_3body",
"HyperT_bar_3body",
"PQ1730_k0lam",
"PQ1730_kpluslam",
"K0s_piplus_piminus",
"lambda_p_piminus",
"lambdabar_pbar_piplus"};
50 TString _part =
"pi+";
56 bool _rapiditymode =
true;
60 TString _geometry =
"y2014x";
62 TString SDT =
"sdt20140610";
64 const int maxEvents = 1000;
74 TString sid = gSystem->Getenv(
"JOBID"); sid.Resize(8);
75 TString six = gSystem->Getenv(
"JOBINDEX");
77 unsigned long long id = gROOT->ProcessLine(Form(
"0x%s", sid.Data() ) );
78 unsigned int id1 = (0xffff&id);
79 unsigned int id2 = gROOT->ProcessLine( six.Data() );
88 void geometry( TString tag, Bool_t agml=
true )
90 TString cmd =
"DETP GEOM "; cmd += tag;
91 if ( !geant_maker ) geant_maker = (
St_geant_Maker *)chain->GetMaker(
"geant");
92 geant_maker -> LoadGeometry(cmd);
98 void command( TString cmd )
100 if ( !geant_maker ) geant_maker = (
St_geant_Maker *)chain->GetMaker(
"geant");
101 geant_maker -> Do( cmd );
109 for (
int i=0; i<n; i++ ) {
111 if ( i+1 > maxEvents )
break;
119 cout <<
"_unprimaries = " << _unprimaries << endl;
121 _primary->
SetVertex( _vxyz[0], _vxyz[1], _vxyz[2] );
129 if ( _fpart < 1.0 ) {
130 npart = int(_unprimaries * _fpart) ;
131 if ( npart < _npart ) npart = _npart;
133 else npart = int(_fpart);
135 if(i==0) _part_save=_part;
136 if(_part_save ==
"antideuteron" || _part_save ==
"he3" || _part_save ==
"antihe3"){
144 cout << Form(
"run=%i event=%i seed=%i part=%s npart=%i %i vxyz=%f %f %f",
151 _vxyz[0],_vxyz[1],_vxyz[2]) << endl;
153 command( Form(
"RUNG %i %i", _runnumber, _evtnumber-1 ) );
154 chain->SetDateTime(
int(_eventtime),
int( 100000*(_eventtime-
int(_eventtime)) ) );
158 if ( 0==ptDist ) kinematics->
Kine( npart, _part, _ptmn, _ptmx, _etamn, _etamx );
161 if ( ptDist ) kinematics->
Dist( npart, _part, ptDist, etaDist );
167 if (StarMagField::Instance() && StarMagField::Instance()->IsLocked()) {
168 float scale = StarMagField::Instance()->GetFactor();
169 delete StarMagField::Instance();
171 cout <<
"New mag field. Don't lock, let it be updated" << endl;
191 gSystem->Load(
"libKinematics.so");
196 kinematics->SetAttr(
"rapidity", 1 );
203 void runEmbeddingSimulation2014(
204 const char* tagfile=
"/star/data100/GRID/daq/2014/st_physics_adc_15161060_raw_5000043.tags.root",
206 unsigned int rngSeed=1234,
214 _tagfile = TFile::Open(tagfile);
215 _tags = (TTree*) _tagfile -> Get(
"MoreTags");
217 _tags->SetBranchAddress(
"RunId", &_runnumber );
218 _tags->SetBranchAddress(
"EvtId", &_evtnumber );
219 _tags->SetBranchAddress(
"VX", &_vxyz[0] );
220 _tags->SetBranchAddress(
"VY", &_vxyz[1] );
221 _tags->SetBranchAddress(
"VZ", &_vxyz[2] );
222 _tags->SetBranchAddress(
"nRefMult", &_unprimaries );
224 _tags->SetBranchAddress(
"EvtTime", &_eventtime );
225 _tags->SetBranchAddress(
"ProdTime", &_prodtime );
226 _tags->SetBranchAddress(
"magField", &_magfield );
231 SDT = Form(
"sdt%i",
int(_eventtime));
232 if ( DBV ==
"" ) DBV = Form(
"dbv%i",
int(_prodtime));
235 if ( nevents < 0 ) nevents = _tags->GetEntries();
237 cout <<
"####################################################################" << endl;
238 cout <<
"## Processing nevents = " << nevents << endl;
239 cout <<
"## geometry : " << _geometry.Data() << endl;
240 cout <<
"## sdt timestamp: " << SDT.Data() << endl;
241 cout <<
"## dbv timestamp: " << DBV.Data() << endl;
242 cout <<
"####################################################################" << endl;
256 gROOT->ProcessLine(
".L bfc.C");
258 TString simple = _geometry; simple +=
" ";
259 simple += SDT; simple +=
" ";
260 simple += DBV; simple +=
" ";
261 simple +=
" geant gstar usexgeom agml misalign newtpcalignment bigbig ";
272 gSystem->Load(
"libVMC.so");
274 gSystem->Load(
"StarGeneratorUtil.so" );
275 gSystem->Load(
"StarGeneratorEvent.so" );
276 gSystem->Load(
"StarGeneratorBase.so" );
277 gSystem->Load(
"StarGeneratorDecay.so" );
278 gSystem->Load(
"libPythia8_1_62.so");
279 gSystem->Load(
"libMathMore.so" );
282 gSystem->Load(
"gstar.so" );
283 command(
"call gstar");
301 _primary -> SetFileName(
"kinematics.starsim.root");
302 chain -> AddBefore(
"geant", _primary );
317 pdb.
AddParticle(
"HyperT_2body",
new TParticlePDG(
"HyperpT_2body",
"HyperTriton --> He3 pi-", 2.99131,
false, 0.0, +3.0,
"hypernucleus", +hid(1,3,1), 0, 61053 ));
318 pdb.
AddParticle(
"HyperT_bar_2body",
new TParticlePDG(
"HyperT_bar_2body",
"AntiHyperTriton --> He3bar pi+", 2.99131,
false, 0.0, -3.0,
"hypernucleus", -hid(1,3,1), 0, 61054 ));
319 pdb.
AddParticle(
"HyperT_3body",
new TParticlePDG(
"HyperT_3body",
"HyperTriton --> d p pi-", 2.99131,
false, 0.0, +3.0,
"hypernucleus", +hid(1,3,1), 0, 62053 ));
320 pdb.
AddParticle(
"HyperT_bar_3body",
new TParticlePDG(
"HyperT_bar_3body",
"AntiHyperTriton --> dbar pbar pi+", 2.99131,
false, 0.0, -3.0,
"hypernucleus", -hid(1,3,1), 0, 62054 ));
322 pdb.
AddParticle(
"deuteron",
new TParticlePDG(
"deuteron",
"Deuteron", 1.876,
true, 0.0, 3.0,
"hion", hid(1,2,0), 0, 45 ));
323 pdb.
AddParticle(
"antideuteron",
new TParticlePDG(
"antideuteron",
"anti Deuteron", 1.876,
true, 0.0, -3.0,
"hion", -hid(1,2,0), 0, 50045 ));
324 pdb.
AddParticle(
"he3",
new TParticlePDG(
"he3",
"Helium-3", 2.809,
true, 0.0, 6.0,
"hion", hid(2,3,0), 0, 49 ));
325 pdb.
AddParticle(
"antihe3",
new TParticlePDG(
"antihe3",
"anti Helium-3", 2.809,
true, 0.0, -6.0,
"hion", -hid(2,3,0), 0, 50049 ));
340 data.
AddParticleToG3(
"D0", 0.186483E+01, 0.41010E-12, 0., 3, 421, 37, 0, 0 );
346 decayPy8->
Set(
"421:onMode = off");
347 decayPy8->
Set(
"421:onIfMatch = 211 321");
350 data.
AddParticleToG3(
"eta",5.47853e-01, 0.50244E-18, 0., 3, 221, 17, 0, 0 );
356 decayPy8->
Set(
"221:onMode = off");
357 decayPy8->
Set(
"221:onIfMatch = 22 11 -11");
360 data.
AddParticleToG3(
"pi0",1.34977e-01, 0.85200E-16, 0., 3, 111, 7, 0, 0 );
366 decayPy8->
Set(
"111:onMode = off");
367 decayPy8->
Set(
"111:onIfMatch = 22 11 -11");
369 if(_part ==
"deuteron" || _part ==
"antideuteron"){
370 data.
AddParticleToG3(
"deuteron", 0.1876E+01, 0.10000E+16, 1., 8, 1000010020, 45, 0, 0 );
371 TParticlePDG* deuteron = data.
GetParticle(
"deuteron");
374 if(_part ==
"antideuteron"){
375 data.
AddParticleToG3(
"antideuteron", 0.1876E+01, 0.10000E+16, -1., 8, -1000010020, 50045, 0, 0 );
376 TParticlePDG* antideuteron = data.
GetParticle(
"antideuteron");
377 antideuteron->Print();
379 if(_part ==
"PQ1730_k0lam") {
380 double bratio[] = { 0.5, 0.5, 0.0, 0., 0., 0.0 };
381 int mode[] = {9598,9597, 0, 0, 0, 0 };
382 data.
AddParticleToG3(
"PQ1730_k0lam", 0.1730E+01, 1E-16, 0., 3, 912323, 60008, bratio, mode );
383 TParticlePDG* mypart = data.
GetParticle(
"PQ1730_k0lam");
386 if(_part ==
"PQ1730_kpluslam") {
387 double bratio[] = { 0.5, 0.5, 0.0, 0., 0., 0.0 };
388 int mode[] = {9698,9697, 0, 0, 0, 0 };
389 data.
AddParticleToG3(
"PQ1730_kpluslam", 0.1730E+01, 1E-16, 0., 3, 912323, 60009, bratio, mode );
390 TParticlePDG* mypart = data.
GetParticle(
"PQ1730_kpluslam");
394 if(_part ==
"K0s_piplus_piminus") {
395 double bratio[] = { 0.5, 0.5, 0.0, 0., 0., 0.0 };
396 int mode[] = {908,809, 0, 0, 0, 0 };
397 data.
AddParticleToG3(
"K0s_piplus_piminus", 0.4977, 0.1E-23, 0., 4, 310, 95, bratio, mode );
398 TParticlePDG* mypart = data.
GetParticle(
"K0s_piplus_piminus");
403 if(_part ==
"lambdabar_pbar_piplus") {
404 double bratio[] = { 0.5, 0.5, 0.0, 0., 0., 0.0 };
405 int mode[] = {914,1409, 0, 0, 0, 0 };
406 data.
AddParticleToG3(
"lambdabar_pbar_piplus", 0.1116E+1, 0.2632E-9, 0., 3, -3122, 97, bratio, mode );
407 TParticlePDG* mypart = data.
GetParticle(
"lambdabar_pbar_piplus");
410 if(_part ==
"lambda_p_piminus") {
411 double bratio[] = { 0.5, 0.5, 0.0, 0., 0., 0.0 };
412 int mode[] = {815,1508, 0, 0, 0, 0 };
413 data.
AddParticleToG3(
"lambda_p_piminus", 0.1116E+1, 0.2632E-9, 0., 3, 3122, 98, bratio, mode );
414 TParticlePDG* mypart = data.
GetParticle(
"lambda_p_piminus");
429 geometry(Form(
" field=%f %s", _magfield, _geometry.Data()));
430 command(
"gkine -4 0");
438 command(Form(
"gfile o %s", fzdfile));
445 command(
"call agexit");
459 TTable* gtable = (
TTable* ) chain->GetDataSet(
"g2t_track");
467 for (
int itable=1; itable<ntable; itable++ )
469 g2t_track_st*
track = (g2t_track_st*)gtable->
At(itable);
470 if ( 0 == track->eg_label ) { Etest += track->e; }
473 cout <<
"Egener = " << Etotal << endl;
474 cout <<
"Egeant = " << Etest << endl;
475 cout <<
"Violation = " << 100*(Etest / Etotal - 1) <<
"%" << endl;
480 void runEmbeddingSimulation2014(
482 const unsigned int seed,
498 if ( dbv ) DBV = dbv;
501 for (indx=0;indx<50;indx++) {
502 if ( _pid[indx] == pid ) {
507 if ( indx == 50 ) cout<<
"WRONG GeantID: "<<pid<<
" !!!"<<endl;
511 if ( _part.Contains(
"D0") )
513 ptDist =
new TF1(
"ptDist",
"(1/[0])/(1+(x/[0])^2)^[1]",_ptmn,_ptmx);
514 ptDist->SetParameter(0, 3.0);
515 ptDist->SetParameter(1, 5.0);
517 etaDist =
new TF1(
"etaDist",
"1.0",_etamn,_etamx);
523 runEmbeddingSimulation2014( tagfile, fzdfile, seed, ne );
void SetSigma(Double_t sx, Double_t sy, Double_t sz, Double_t rho=0)
void Print(const Option_t *opts="head") const
Star Simple Kinematics Generator.
Yet another particle class.
virtual void Clear(Option_t *option="")
User defined functions.
Float_t GetEnergy()
Get the energy.
static StarParticleData & instance()
Returns a reference to the single instance of this class.
TParticlePDG * GetParticle(const Char_t *name)
Get a particle by name.
Interface to PDG information.
void AddGenerator(StarGenerator *gener)
Connects VMC to class(es) which handle particle decays.
void Dist(Int_t ntrack, const Char_t *type, TF1 *pt, TF1 *y, TF1 *phi=0)
void AddParticle(const Char_t *name, TParticlePDG *particle)
Add a particle to the database.
Int_t Init()
Initialize generator.
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
static void seed(UInt_t s)
Base class for event records.
StarGenEvent * event()
Return a pointer to the event.
Main steering class for event generation.
void AddDecayer(Int_t pdgid, TVirtualMCDecayer *decayer)
void SetDebug(int dbg=1)
Set the debug level.
void Print(const Option_t *opts="") const
Print the particle.
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
static void capture()
Capture gRandom random number generator.
Sparse class to hold track kinematics.
void Kine(Int_t ntrack, const Char_t *type="pi+,pi-,K+,K-,proton,antiproton", Double_t ptlow=0.0, Double_t pthigh=500.0, Double_t ylow=-10.0, Double_t yhigh=+10.0, Double_t philow=0.0, Double_t phihigh=TMath::TwoPi())
TParticlePDG * AddParticleToG3(const char *name, const double mass, const double lifetime, const double charge, const int tracktype, const int pdgcode, const int g3code, const double *bratio=0, const int *mode=0)
void Set(const char *cmd)
Modify pythia8 behavior.
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.