105 LOG(INFO) <<
"FixedTargetGenerator::Init Option not known "<<
Option.Data() <<
", abort";
109 std::vector<int> r = { 221, 221, 223, 223, 113, 331, 333};
110 std::vector<int> c = { 6 , 7, 5 , 7, 5, 6, 9};
113 fPythiaP->settings.mode(
"Beams:idB", 2212);
114 fPythiaN->settings.mode(
"Beams:idB", 2112);
116 fPythiaP->readString(
"ProcessLevel:all = off");
120 for(
const auto& fPythia : plist) {
121 if (pcount > 0 && (
Option !=
"Primary" ||
G4only)){
continue;}
124 fPythia->settings.mode(
"Random:seed",
fSeed);
125 fPythia->settings.mode(
"Next:numberCount",
heartbeat);
127 fPythia->settings.mode(
"Beams:idA", 2212);
128 fPythia->settings.mode(
"Beams:frameType", 2);
129 fPythia->settings.parm(
"Beams:eA",
fMom);
130 fPythia->settings.parm(
"Beams:eB",0.);
134 fPythia->readString(
"Onia:all(3S1) = on");
135 fPythia->readString(
"443:new J/psi J/psi 3 0 0 3.09692 0.00009 3.09602 3.09782 0. 1 1 0 1 0");
136 fPythia->readString(
"443:addChannel = 1 1. 0 -13 13");
137 fPythia->readString(
"553:new Upsilon Upsilon 3 0 0 9.46030 0.00005 9.45980 9.46080 0.00000e+00 0 1 0 1 0");
138 fPythia->readString(
"553:addChannel = 1 1. 0 -13 13");
141 fPythia->readString(
"WeakSingleBoson:ffbar2gmZ = on");
143 fPythia->readString(
"23:onMode = off");
144 fPythia->readString(
"23:onIfAll = 13 13");
145 fPythia->readString(
"23:mMin = 0.5");
146 fPythia->readString(
"PhaseSpace:mHatMin = 0.5");
147 fPythia->readString(
"PartonLevel:FSR = on");
148 fPythia->readString(
"PDF:pSet = 4");
151 fPythia->readString(
"PhotonCollision:gmgm2mumu = on");
154 fPythia->readString(
"SoftQCD:inelastic = on");
155 fPythia->readString(
"PhotonCollision:gmgm2mumu = on");
156 fPythia->readString(
"PromptPhoton:all = on");
157 fPythia->readString(
"WeakBosonExchange:all = on");
158 fPythia->readString(
"WeakSingleBoson:all = on");
161 fPythia->readString(
"431:new D_s+ D_s- 1 3 0 1.96849 0.00000 0.00000 0.00000 1.49900e-01 0 1 0 1 0");
162 fPythia->readString(
"431:addChannel = 1 0.0640000 0 -15 16");
168 n = fPythia->particleData.nextId(n);
170 ParticleDataEntry* p = fPythia->particleData.particleDataEntryPtr(n);
173 ParticleDataEntry* p = fPythia->particleData.particleDataEntryPtr(n);
175 Pythia8::ParticleDataEntryPtr p = fPythia->particleData.particleDataEntryPtr(n);
179 std::string particle = std::to_string(n)+
":mayDecay = false";
180 fPythia->readString(particle);
181 LOG(INFO) <<
"FixedTargetGenerator::Init Made "<< p->name().c_str() <<
" stable for Pythia, should decay in Geant4";
187 LOG(INFO) <<
"FixedTargetGenerator::Init Rescale BRs of dimuon decays in Pythia: "<<
fBoost;
188 for (
unsigned int i=0; i<r.size(); ++i) {
190 Pythia8::ParticleDataEntry* V = fPythia->particleData.particleDataEntryPtr(r[i]);
193 Pythia8::ParticleDataEntry* V = fPythia->particleData.particleDataEntryPtr(r[i]);
195 Pythia8::ParticleDataEntryPtr V = fPythia->particleData.particleDataEntryPtr(r[i]);
198 Pythia8::DecayChannel ch = V->channel(c[i]);
199 if (TMath::Abs(ch.product(0))!=13 || TMath::Abs(ch.product(1))!=13){
200 LOG(INFO) <<
"FixedTargetGenerator::Init this is not the right decay channel:"<<r[i] <<
" "<<c[i];
203 tmp+=r[i];tmp+=
":";tmp+= c[i];
206 fPythia->readString(tmp.Data());
214 TString SIMPATH=getenv(
"SIMPATH");
215 TString DecayFile =SIMPATH+
"/share/EvtGen/DECAY.DEC";
216 TString ParticleFile =SIMPATH +
"/share/EvtGen/evt.pdl";
219 std::cout <<
"Using $EVTGENDATA "<< getenv(
"EVTGENDATA") << std::endl;
220 DecayFile =TString(getenv(
"EVTGENDATA"))+
"/DECAY.DEC";
221 ParticleFile =TString(getenv(
"EVTGENDATA"))+
"/evt.pdl";
223 EvtAbsRadCorr *fsrPtrIn = 0;
224 EvtExternalGenList *extPtr =
new EvtExternalGenList();
225 std::list<EvtDecayBase*> models = extPtr->getListOfModels();
227 EvtRandomEngine* eng =
new EvtSimpleRandomEngine();
228 EvtRandom::setRandomEngine(eng);
229 EvtGen *myEvtGenPtr =
new EvtGen(DecayFile.Data(), ParticleFile.Data(),eng, fsrPtrIn, &models, 1,
false);
230 TString UdecayFile = getenv(
"FAIRSHIP");UdecayFile +=
"/gconfig/USERDECAY.DEC";
231 evtgenP =
new EvtGenDecays(
fPythiaP, DecayFile.Data(), ParticleFile.Data(),myEvtGenPtr);
232 evtgenP->readDecayFile(UdecayFile.Data());
235 evtgenN =
new EvtGenDecays(
fPythiaN, DecayFile.Data(), ParticleFile.Data(),myEvtGenPtr);
241 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
243 TGeoNode* target = nav->GetCurrentNode();
244 TObjArray* nodes = target->GetVolume()->GetNodes();
245 TGeoNode* first = (TGeoNode*)nodes->At(0);
246 Int_t ilast = nodes->GetSize()-5;
247 TGeoNode* last = (TGeoNode*)nodes->At(ilast);
249 TGeoBBox* sha = (TGeoBBox*)first->GetVolume()->GetShape();
250 Double_t dz = sha->GetDZ();
251 Double_t origin[3] = {0,0,-dz};
252 Double_t master[3] = {0,0,0};
253 nav->LocalToMaster(origin,master);
256 sha = (TGeoBBox*)first->GetVolume()->GetShape();
259 nav->LocalToMaster(origin,master);
269 TGeoVolume* top = gGeoManager->GetTopVolume();
272 LOG(ERROR) <<
"FixedTargetGenerator::Init target not found, "<<
targetName.Data() <<
", program will crash";
274 Double_t z_middle = target->GetMatrix()->GetTranslation()[2];
275 TGeoBBox* sha = (TGeoBBox*)target->GetVolume()->GetShape();
276 startZ = z_middle - sha->GetDZ();
277 endZ = z_middle + sha->GetDZ();
305 Double_t ZoverA = 1.;
309 Double_t prob2int = -1.;
313 Double_t zinterStart =
start[2];
316 if (!(
nTree->GetBranch(
"k"))){
ck=1;}
320 while (prob2int<rndm) {
322 zinter = gRandom->Uniform(zinterStart,
end[2]);
323 Double_t point[3]={
xOff,
yOff,zinter};
325 Double_t interLength =
mparam[8];
326 TGeoNode *node = gGeoManager->FindNode(point[0],point[1],point[2]);
327 TGeoMaterial *mat = 0;
328 if (node && !gGeoManager->IsOutside()) {
329 mat = node->GetVolume()->GetMaterial();
330 Double_t n = mat->GetDensity()/mat->GetA();
331 ZoverA = mat->GetZ() / mat->GetA();
332 sigma = 1./(n*mat->GetIntLen())/
mbarn;
337 rndm = gRandom->Uniform(0.,1.);
340 zinterStart = zinter;
345 Pythia8::Pythia* fPythia;
347 cpg->AddTrack(2212,0.,0.,
fMom,
xOff/
cm,
yOff/
cm,
start[2],-1,kTRUE,-1.,0.,1.);
349 }
else if (
Option ==
"Primary"){
350 if (gRandom->Uniform(0.,1.) < ZoverA ){
361 LOG(INFO) <<
"FixedTargetGenerator::readEvent Rewind input file: "<<
nEntry;
368 if (pt<1.e-5 &&
n_mid==2212){
371 Int_t idabs=int(TMath::Abs(
n_id));
375 fPythiaP->event.append(
int(
n_id),1,0,0,
n_px,
n_py,
n_pz,
n_E,
n_M,0.,9.);
376 TMCProcess procID = kPTransportation;
378 cpg->AddTrack(
int(
n_mid),
n_mpx,
n_mpy,
n_mpz,
xOff/
cm,
yOff/
cm,zinter/
cm,-1,kFALSE,
n_mE,0.,
wspill,procID);
381 if (nID1 *
n_id > 0){LOG(INFO) <<
"FixedTargetGenerator::readEvent same sign charm: "<<
nEntry<<
" "<< nID1<<
" "<<
n_id;}
383 fPythiaP->event.append(
int(
n_id),1,0,0,
n_px,
n_py,
n_pz,
n_E,
n_M,0.,9.);
388 fPythia->moreDecays();}
391 for(Int_t ii=1; ii<fPythia->event.size(); ii++){
392 Double_t e = fPythia->event[ii].e();
393 Double_t
m = fPythia->event[ii].m();
394 Double_t pz = fPythia->event[ii].pz();
395 Int_t
id = fPythia->event[ii].id();
396 Bool_t wanttracking=kTRUE;
397 if (e-m<EMax || !fPythia->event[ii].isFinal() || pz<0) {wanttracking=kFALSE;}
400 if (fabs(
id)!=13){wanttracking=kFALSE;}
402 Double_t z = fPythia->event[ii].zProd()+zinter;
403 Double_t x = fPythia->event[ii].xProd()+
xOff;
404 Double_t y = fPythia->event[ii].yProd()+
yOff;
405 Double_t tof = fPythia->event[ii].tProd() / (10*
c_light) ;
406 Double_t px = fPythia->event[ii].px();
407 Double_t py = fPythia->event[ii].py();
408 Int_t im = fPythia->event[ii].mother1()-1;
413 if (ii==1) {procID = kPHadronic;}
417 cpg->AddTrack(
id,px,py,pz,x/
cm,y/
cm,z/
cm,im,wanttracking,e,tof,
wspill,procID);
419 int idabs = TMath::Abs(
id);
420 if (idabs<10) {
continue;}
421 if (idabs<18 || idabs==22 || idabs==111 || idabs==221 || idabs==223 || idabs==331
422 || idabs==211 || idabs==113 || idabs==333 || idabs==321 || idabs==2212 ){
423 Int_t moID = fPythia->event[im+1].id();