140 mparam[0]=0; mparam[1]=1; mparam[2]=0; mparam[3]=0; mparam[4]=0;
141 mparam[5]=0; mparam[6]=0; mparam[7]=0; mparam[8]=0; mparam[9]=0;
145 Double_t
mbarn = 1E-3*1E-24*TMath::Na();
147 for (Int_t i=0;i<7;i++) bparam[i]=0;
156 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
157 (end[1]-start[1])*(end[1]-start[1])+
158 (end[2]-start[2])*(end[2]-start[2]));
160 if (length<TGeoShape::Tolerance())
return 0.0;
161 Double_t invlen = 1./length;
162 dir[0] = (end[0]-start[0])*invlen;
163 dir[1] = (end[1]-start[1])*invlen;
164 dir[2] = (end[2]-start[2])*invlen;
167 TGeoNode *currentnode = 0;
168 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
174 TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial();
175 lparam[0] = material->GetDensity();
176 if (lparam[0] > mparam[7]) mparam[7]=lparam[0];
177 lparam[1] = material->GetRadLen();
178 lparam[2] = material->GetA();
179 lparam[3] = material->GetZ();
181 lparam[5] = lparam[3]/lparam[2];
182 lparam[6] = material->GetIntLen();
183 Double_t n = lparam[0]/lparam[2];
184 Double_t sigma = 1./(n*lparam[6])/
mbarn;
185 if (sigma > mparam[9]) mparam[9]=sigma;
186 if (material->IsMixture()) {
187 TGeoMixture * mixture = (TGeoMixture*)material;
190 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
191 sum += mixture->GetWmixt()[iel];
192 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
199 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
201 Double_t snext = gGeoManager->GetStep();
203 if (!gGeoManager->IsOnBoundary()) {
204 mparam[0] = lparam[0];
205 mparam[1] = lparam[4]/lparam[1];
206 mparam[2] = lparam[2];
207 mparam[3] = lparam[3];
208 mparam[4] = lparam[4];
209 mparam[8] = lparam[4]/lparam[6];
214 while (length>TGeoShape::Tolerance()) {
215 currentnode = gGeoManager->GetCurrentNode();
216 if (snext<2.*TGeoShape::Tolerance()) nzero++;
222 mparam[0] = bparam[0]/step;
223 mparam[1] = bparam[1];
224 mparam[2] = bparam[2]/step;
225 mparam[3] = bparam[3]/step;
226 mparam[5] = bparam[5]/step;
227 mparam[8] = bparam[6];
231 return bparam[0]/step;
235 bparam[1] += snext/lparam[1];
236 bparam[2] += snext*lparam[2];
237 bparam[3] += snext*lparam[3];
238 bparam[5] += snext*lparam[5];
239 bparam[6] += snext/lparam[6];
240 bparam[0] += snext*lparam[0];
242 if (snext>=length)
break;
243 if (!currentnode)
break;
245 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
246 lparam[0] = material->GetDensity();
247 if (lparam[0] > mparam[7]) mparam[7]=lparam[0];
248 lparam[1] = material->GetRadLen();
249 lparam[2] = material->GetA();
250 lparam[3] = material->GetZ();
251 lparam[5] = lparam[3]/lparam[2];
252 lparam[6] = material->GetIntLen();
253 n = lparam[0]/lparam[2];
254 sigma = 1./(n*lparam[6])/
mbarn;
255 if (sigma > mparam[9]) mparam[9]=sigma;
256 if (material->IsMixture()) {
257 TGeoMixture * mixture = (TGeoMixture*)material;
260 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
261 sum+= mixture->GetWmixt()[iel];
262 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
266 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
267 snext = gGeoManager->GetStep();
269 mparam[0] = bparam[0]/step;
270 mparam[1] = bparam[1];
271 mparam[2] = bparam[2]/step;
272 mparam[3] = bparam[3]/step;
273 mparam[5] = bparam[5]/step;
274 mparam[8] = bparam[6];
275 return bparam[0]/step;
336 TGeoVolume *top=gGeoManager->GetTopVolume();
337 TGeoNode *linner = top->FindNode(
"lidT1I_1");
338 TGeoNode *scint = top->FindNode(
"lidT1lisci_1");
339 TGeoNode *louter = top->FindNode(
"lidT1O_1");
340 TGeoNode *lidT6I = top->FindNode(
"lidT6I_1");
341 TGeoNode *t2I = top->FindNode(
"T2I_1");
342 TGeoNode *t1I = top->FindNode(
"T1I_1");
343 TGeoEltu *temp =
dynamic_cast<TGeoEltu*
>(linner->GetVolume()->GetShape());
345 temp =
dynamic_cast<TGeoEltu*
>(louter->GetVolume()->GetShape());
349 fEntrZ_inner = linner->GetMatrix()->GetTranslation()[2];
350 fEntrZ_outer = louter->GetMatrix()->GetTranslation()[2];
352 TGeoCompositeShape *tempC =
dynamic_cast<TGeoCompositeShape*
>(t2I->GetVolume()->GetShape());
355 tempC =
dynamic_cast<TGeoCompositeShape*
>(t1I->GetVolume()->GetShape());
356 fL1z = tempC->GetDZ()*2;
357 temp =
dynamic_cast<TGeoEltu*
>(scint->GetVolume()->GetShape());
361 cout <<
"Info GenieGenerator: A and B " <<
fEntrA <<
" "<<
fEntrB << endl;
362 cout <<
"Info GenieGenerator: vessel length heig<ht width " <<
Lvessel <<
" "<<
Yvessel<<
" "<<
Xvessel << endl;
363 cout <<
"Info GenieGenerator: scint thickness " <<
fScintDz << endl;
365 for(
int j=0; j<
boxs.size(); j++) {
366 cout <<
"Info GenieGenerator: nuMu X" << j <<
" - "<< -
boxs[j].X()+
dVecs[j].X() <<
" "<<
boxs[j].X()+
dVecs[j].X() << endl;
367 cout <<
"Info GenieGenerator: nuMu Y" << j <<
" - "<< -
boxs[j].Y()+
dVecs[j].Y() <<
" "<<
boxs[j].Y()+
dVecs[j].Y() << endl;
368 cout <<
"Info GenieGenerator: nuMu Z" << j <<
" - "<< -
boxs[j].Z()+
dVecs[j].Z() <<
" "<<
boxs[j].Z()+
dVecs[j].Z() << endl;
372 if (
fn==
fNevents) {LOG(WARNING) <<
"End of input file. Rewind.";}
376 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
387 Double_t where=gRandom->Uniform(0.,1.);
396 if (gRandom->Uniform(0.,1.)<0.5){
401 }
else if (where<0.64){
405 Double_t zrand = gRandom->Uniform(0,
Lvessel);
410 Double_t theta = gRandom->Uniform(0.,TMath::Pi());
412 if ( gRandom->Uniform(0.,1.)>0.5) {
419 x = (ea+rextra)*cos(theta);
420 y = sqrt(1.-(x*x)/((ea+rextra)*(ea+rextra)))*(eb+rextra);
421 if (gRandom->Uniform(-1.,1.)>0.) y=-y;
424 int j = int(gRandom->Uniform(0.,
boxs.size()+0.5));
437 cpg->AddTrack(
neu,pout[0],pout[1],pout[2],x,y,z,-1,
false);
442 Int_t oLPdgCode =
neu;
443 if (
cc){oLPdgCode = copysign(TMath::Abs(
neu)-1,
neu);}
444 if (
nuel){oLPdgCode = 11;}
445 cpg->AddTrack(oLPdgCode,pout[0],pout[1],pout[2],x,y,z,0,
true);
447 for(
int i=0; i<
nf; i++)
450 cpg->AddTrack(
pdgf[i],pout[0],pout[1],pout[2],x,y,z,0,
true);
465 if (
fTree->GetEntry(
fn) == 0 )
return kFALSE;
468 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
481 int outgoing_lepton_pdg =
neu;
482 if (
cc) outgoing_lepton_pdg = copysign(TMath::Abs(
neu)-1,
neu);
483 if (
nuel) outgoing_lepton_pdg = 11;
485 bool track_outgoing_lepton = (
cc ||
nuel) ?
true :
false;
486 cpg->AddTrack(outgoing_lepton_pdg,
490 track_outgoing_lepton);
493 for (
int i_hadron = 0; i_hadron <
nf; i_hadron++){
494 cpg->AddTrack(
pdgf[i_hadron],
495 pxf[i_hadron],
pyf[i_hadron],
pzf[i_hadron],
502 FairMCEventHeader* header = cpg->GetEvent();
503 header->SetEventID(
eventN);
504 header->SetRunID(
runN);
510 Double_t start[3]={0.,0.,
startZ};
511 Double_t end[3]={0.,0.,
endZ};
520 cout <<
"Info GenieGenerator: MaterialBudget " << start[2] <<
" - "<< end[2] << endl;
521 cout <<
"Info GenieGenerator: MaterialBudget " << bparam << endl;
522 cout <<
"Info GenieGenerator: MaterialBudget 0 " << mparam[0] << endl;
523 cout <<
"Info GenieGenerator: MaterialBudget 1 " << mparam[1] << endl;
524 cout <<
"Info GenieGenerator: MaterialBudget 2 " << mparam[2] << endl;
525 cout <<
"Info GenieGenerator: MaterialBudget 3 " << mparam[3] << endl;
526 cout <<
"Info GenieGenerator: MaterialBudget 4 " << mparam[4] << endl;
527 cout <<
"Info GenieGenerator: MaterialBudget 5 " << mparam[5] << endl;
528 cout <<
"Info GenieGenerator: MaterialBudget 6 " << mparam[6] << endl;
529 cout <<
"Info GenieGenerator: MaterialBudget " << mparam[0]*mparam[4] << endl;
532 printf(
"Reading (log10(p),log10(pt)) Hists from file: %s\n",
fInputFile->GetName());
533 for (Int_t idnu=12;idnu<17;idnu+=2){
534 for (Int_t idadd=-1;idadd<2;idadd+=2){
535 Int_t idhnu=idbase+idnu;
536 if (idadd<0) idhnu+=1000;
537 sprintf(ts,
"%d",idhnu);
541 printf(
"HISTID=%d, Title:%s\n",idhnu,h2tmp->GetTitle());
542 sprintf(ts,
"px_%d",idhnu);
544 pxhist[idhnu]=h2tmp->ProjectionX(ts,1,-1);
545 Int_t nbinx=h2tmp->GetNbinsX();
548 for (Int_t k=1;k<nbinx+1;k+=1){
549 sprintf(ts,
"h%d%d",idhnu,k);
551 pyslice[idhnu][k]=h2tmp->ProjectionY(ts,k,k);
558 if (
fn==
fNevents) {LOG(WARNING) <<
"End of input file. Rewind.";}
563 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
585 fTree->GetEntry(nuevent);
589 double pt = sqrt(pout[0]*pout[0] + pout[1]*pout[1]);
594 TParticle *nuparticle = (TParticle*)
ancstr->At(0);
595 TVector3 * nup =
new TVector3(nuparticle->Px(), nuparticle->Py(), nuparticle->Pz());
600 fTree->GetEntry(nuevent);
602 pout[0] = nup->Px()/nup->Pz() *
pzv;
603 pout[1] = nup->Py()/nup->Pz() *
pzv;
604 double pt = sqrt(pout[0]*pout[0] + pout[1]*pout[1]);
610 Int_t idhnu=TMath::Abs(
neu)+idbase;
611 if (
neu<0) idhnu+=1000;
612 Int_t nbinmx=
pxhist[idhnu]->GetNbinsX();
613 Double_t pl10=log10(
pzv);
614 Int_t nbx=
pxhist[idhnu]->FindBin(pl10);
617 if (nbx>nbinmx) nbx=nbinmx;
618 Double_t ptlog10=
pyslice[idhnu][nbx]->GetRandom();
620 Double_t pt=pow(10.,ptlog10)-0.01;
622 Double_t phi=gRandom->Uniform(0.,2*TMath::Pi());
623 pout[0] = cos(phi)*pt;
624 pout[1] = sin(phi)*pt;
629 pout[2]=TMath::Sqrt(pout[2]);
632 if (gRandom->Uniform(-1.,1.)<0.) pout[0]=-pout[0];
633 if (gRandom->Uniform(-1.,1.)<0.) pout[1]=-pout[1];
637 start[0]=(pout[0]/pout[2])*(start[2]-
ztarget);
638 start[1]=(pout[1]/pout[2])*(start[2]-
ztarget);
645 txnu=pout[0]/pout[2];
646 tynu=pout[1]/pout[2];
661 Double_t prob2int = -1.;
666 while (prob2int<gRandom->Uniform(0.,1.)) {
668 z=gRandom->Uniform(start[2],end[2]);
681 TGeoNode *node = gGeoManager->FindNode(x,y,z);
682 TGeoMaterial *mat = 0;
683 if (node && !gGeoManager->IsOutside()) {
684 mat = node->GetVolume()->GetMaterial();
687 prob2int= mat->GetDensity()/mparam[7];
688 if (prob2int>1.) cout <<
"***WARNING*** GenieGenerator: prob2int > Maximum density????" << prob2int <<
" maxrho:" << mparam[7] <<
" material: " << mat->GetName() << endl;
698 Double_t tof=TMath::Sqrt(x*x+y*y+zrelative*zrelative)/2.99792458e+6;
699 cpg->AddTrack(
neu,pout[0],pout[1],pout[2],x,y,z,-1,
false,TMath::Sqrt(pout[0]*pout[0]+pout[1]*pout[1]+pout[2]*pout[2]),tof,mparam[0]*mparam[4]);
703 Int_t oLPdgCode =
neu;
704 if (
cc){oLPdgCode = copysign(TMath::Abs(
neu)-1,
neu);}
705 if (
nuel){oLPdgCode = 11;}
706 cpg->AddTrack(oLPdgCode,pp[0],pp[1],pp[2],x,y,z,0,
true,
El,tof,mparam[0]*mparam[4]);
708 for(
int i=0; i<
nf; i++)
711 cpg->AddTrack(
pdgf[i],pp[0],pp[1],pp[2],x,y,z,0,
true,
Ef[i],tof,mparam[0]*mparam[4]);
719 FairMCEventHeader* header = cpg->GetEvent();
720 header->SetEventID(
eventN);
721 header->SetRunID(
runN);