137 mparam[0]=0; mparam[1]=1; mparam[2]=0; mparam[3]=0; mparam[4]=0;
138 mparam[5]=0; mparam[6]=0; mparam[7]=0; mparam[8]=0; mparam[9]=0;
142 Double_t
mbarn = 1E-3*1E-24*TMath::Na();
144 for (Int_t i=0;i<7;i++) bparam[i]=0;
153 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
154 (end[1]-start[1])*(end[1]-start[1])+
155 (end[2]-start[2])*(end[2]-start[2]));
157 if (length<TGeoShape::Tolerance())
return 0.0;
158 Double_t invlen = 1./length;
159 dir[0] = (end[0]-start[0])*invlen;
160 dir[1] = (end[1]-start[1])*invlen;
161 dir[2] = (end[2]-start[2])*invlen;
164 TGeoNode *currentnode = 0;
165 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
171 TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial();
172 lparam[0] = material->GetDensity();
173 if (lparam[0] > mparam[7]) mparam[7]=lparam[0];
174 lparam[1] = material->GetRadLen();
175 lparam[2] = material->GetA();
176 lparam[3] = material->GetZ();
178 lparam[5] = lparam[3]/lparam[2];
179 lparam[6] = material->GetIntLen();
180 Double_t n = lparam[0]/lparam[2];
181 Double_t sigma = 1./(n*lparam[6])/
mbarn;
182 if (sigma > mparam[9]) mparam[9]=sigma;
183 if (material->IsMixture()) {
184 TGeoMixture * mixture = (TGeoMixture*)material;
187 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
188 sum += mixture->GetWmixt()[iel];
189 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
196 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
198 Double_t snext = gGeoManager->GetStep();
200 if (!gGeoManager->IsOnBoundary()) {
201 mparam[0] = lparam[0];
202 mparam[1] = lparam[4]/lparam[1];
203 mparam[2] = lparam[2];
204 mparam[3] = lparam[3];
205 mparam[4] = lparam[4];
206 mparam[8] = lparam[4]/lparam[6];
211 while (length>TGeoShape::Tolerance()) {
212 currentnode = gGeoManager->GetCurrentNode();
213 if (snext<2.*TGeoShape::Tolerance()) nzero++;
219 mparam[0] = bparam[0]/step;
220 mparam[1] = bparam[1];
221 mparam[2] = bparam[2]/step;
222 mparam[3] = bparam[3]/step;
223 mparam[5] = bparam[5]/step;
224 mparam[8] = bparam[6];
228 return bparam[0]/step;
232 bparam[1] += snext/lparam[1];
233 bparam[2] += snext*lparam[2];
234 bparam[3] += snext*lparam[3];
235 bparam[5] += snext*lparam[5];
236 bparam[6] += snext/lparam[6];
237 bparam[0] += snext*lparam[0];
239 if (snext>=length)
break;
240 if (!currentnode)
break;
242 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
243 lparam[0] = material->GetDensity();
244 if (lparam[0] > mparam[7]) mparam[7]=lparam[0];
245 lparam[1] = material->GetRadLen();
246 lparam[2] = material->GetA();
247 lparam[3] = material->GetZ();
248 lparam[5] = lparam[3]/lparam[2];
249 lparam[6] = material->GetIntLen();
250 n = lparam[0]/lparam[2];
251 sigma = 1./(n*lparam[6])/
mbarn;
252 if (sigma > mparam[9]) mparam[9]=sigma;
253 if (material->IsMixture()) {
254 TGeoMixture * mixture = (TGeoMixture*)material;
257 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
258 sum+= mixture->GetWmixt()[iel];
259 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
263 gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
264 snext = gGeoManager->GetStep();
266 mparam[0] = bparam[0]/step;
267 mparam[1] = bparam[1];
268 mparam[2] = bparam[2]/step;
269 mparam[3] = bparam[3]/step;
270 mparam[5] = bparam[5]/step;
271 mparam[8] = bparam[6];
272 return bparam[0]/step;
333 TGeoVolume *top=gGeoManager->GetTopVolume();
334 TGeoNode *linner = top->FindNode(
"lidT1I_1");
335 TGeoNode *scint = top->FindNode(
"lidT1lisci_1");
336 TGeoNode *louter = top->FindNode(
"lidT1O_1");
337 TGeoNode *lidT6I = top->FindNode(
"lidT6I_1");
338 TGeoNode *t2I = top->FindNode(
"T2I_1");
339 TGeoNode *t1I = top->FindNode(
"T1I_1");
340 TGeoEltu *temp =
dynamic_cast<TGeoEltu*
>(linner->GetVolume()->GetShape());
342 temp =
dynamic_cast<TGeoEltu*
>(louter->GetVolume()->GetShape());
346 fEntrZ_inner = linner->GetMatrix()->GetTranslation()[2];
347 fEntrZ_outer = louter->GetMatrix()->GetTranslation()[2];
349 TGeoCompositeShape *tempC =
dynamic_cast<TGeoCompositeShape*
>(t2I->GetVolume()->GetShape());
352 tempC =
dynamic_cast<TGeoCompositeShape*
>(t1I->GetVolume()->GetShape());
353 fL1z = tempC->GetDZ()*2;
354 temp =
dynamic_cast<TGeoEltu*
>(scint->GetVolume()->GetShape());
358 cout <<
"Info GenieGenerator: A and B " <<
fEntrA <<
" "<<
fEntrB << endl;
359 cout <<
"Info GenieGenerator: vessel length heig<ht width " <<
Lvessel <<
" "<<
Yvessel<<
" "<<
Xvessel << endl;
360 cout <<
"Info GenieGenerator: scint thickness " <<
fScintDz << endl;
362 for(
int j=0; j<
boxs.size(); j++) {
363 cout <<
"Info GenieGenerator: nuMu X" << j <<
" - "<< -
boxs[j].X()+
dVecs[j].X() <<
" "<<
boxs[j].X()+
dVecs[j].X() << endl;
364 cout <<
"Info GenieGenerator: nuMu Y" << j <<
" - "<< -
boxs[j].Y()+
dVecs[j].Y() <<
" "<<
boxs[j].Y()+
dVecs[j].Y() << endl;
365 cout <<
"Info GenieGenerator: nuMu Z" << j <<
" - "<< -
boxs[j].Z()+
dVecs[j].Z() <<
" "<<
boxs[j].Z()+
dVecs[j].Z() << endl;
369 if (
fn==
fNevents) {LOG(WARNING) <<
"End of input file. Rewind.";}
373 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
384 Double_t where=gRandom->Uniform(0.,1.);
393 if (gRandom->Uniform(0.,1.)<0.5){
398 }
else if (where<0.64){
402 Double_t zrand = gRandom->Uniform(0,
Lvessel);
407 Double_t theta = gRandom->Uniform(0.,TMath::Pi());
409 if ( gRandom->Uniform(0.,1.)>0.5) {
416 x = (ea+rextra)*cos(theta);
417 y = sqrt(1.-(x*x)/((ea+rextra)*(ea+rextra)))*(eb+rextra);
418 if (gRandom->Uniform(-1.,1.)>0.) y=-y;
421 int j = int(gRandom->Uniform(0.,
boxs.size()+0.5));
434 cpg->AddTrack(
neu,pout[0],pout[1],pout[2],x,y,z,-1,
false);
439 Int_t oLPdgCode =
neu;
440 if (
cc){oLPdgCode = copysign(TMath::Abs(
neu)-1,
neu);}
441 if (
nuel){oLPdgCode = 11;}
442 cpg->AddTrack(oLPdgCode,pout[0],pout[1],pout[2],x,y,z,0,
true);
444 for(
int i=0; i<
nf; i++)
447 cpg->AddTrack(
pdgf[i],pout[0],pout[1],pout[2],x,y,z,0,
true);
462 if (
fTree->GetEntry(
fn) == 0 )
return kFALSE;
465 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
478 int outgoing_lepton_pdg =
neu;
479 if (
cc) outgoing_lepton_pdg = copysign(TMath::Abs(
neu)-1,
neu);
480 if (
nuel) outgoing_lepton_pdg = 11;
482 bool track_outgoing_lepton = (
cc ||
nuel) ?
true :
false;
483 cpg->AddTrack(outgoing_lepton_pdg,
487 track_outgoing_lepton);
490 for (
int i_hadron = 0; i_hadron <
nf; i_hadron++){
491 cpg->AddTrack(
pdgf[i_hadron],
492 pxf[i_hadron],
pyf[i_hadron],
pzf[i_hadron],
502 Double_t start[3]={0.,0.,
startZ};
503 Double_t end[3]={0.,0.,
endZ};
512 cout <<
"Info GenieGenerator: MaterialBudget " << start[2] <<
" - "<< end[2] << endl;
513 cout <<
"Info GenieGenerator: MaterialBudget " << bparam << endl;
514 cout <<
"Info GenieGenerator: MaterialBudget 0 " << mparam[0] << endl;
515 cout <<
"Info GenieGenerator: MaterialBudget 1 " << mparam[1] << endl;
516 cout <<
"Info GenieGenerator: MaterialBudget 2 " << mparam[2] << endl;
517 cout <<
"Info GenieGenerator: MaterialBudget 3 " << mparam[3] << endl;
518 cout <<
"Info GenieGenerator: MaterialBudget 4 " << mparam[4] << endl;
519 cout <<
"Info GenieGenerator: MaterialBudget 5 " << mparam[5] << endl;
520 cout <<
"Info GenieGenerator: MaterialBudget 6 " << mparam[6] << endl;
521 cout <<
"Info GenieGenerator: MaterialBudget " << mparam[0]*mparam[4] << endl;
524 printf(
"Reading (log10(p),log10(pt)) Hists from file: %s\n",
fInputFile->GetName());
525 for (Int_t idnu=12;idnu<17;idnu+=2){
526 for (Int_t idadd=-1;idadd<2;idadd+=2){
527 Int_t idhnu=idbase+idnu;
528 if (idadd<0) idhnu+=1000;
529 sprintf(ts,
"%d",idhnu);
533 printf(
"HISTID=%d, Title:%s\n",idhnu,h2tmp->GetTitle());
534 sprintf(ts,
"px_%d",idhnu);
536 pxhist[idhnu]=h2tmp->ProjectionX(ts,1,-1);
537 Int_t nbinx=h2tmp->GetNbinsX();
540 for (Int_t k=1;k<nbinx+1;k+=1){
541 sprintf(ts,
"h%d%d",idhnu,k);
543 pyslice[idhnu][k]=h2tmp->ProjectionY(ts,k,k);
550 if (
fn==
fNevents) {LOG(WARNING) <<
"End of input file. Rewind.";}
555 cout <<
"Info GenieGenerator: neutrino event-nr "<<
fn << endl;
577 fTree->GetEntry(nuevent);
581 double pt = sqrt(pout[0]*pout[0] + pout[1]*pout[1]);
586 TParticle *nuparticle = (TParticle*)
ancstr->At(0);
587 TVector3 * nup =
new TVector3(nuparticle->Px(), nuparticle->Py(), nuparticle->Pz());
592 fTree->GetEntry(nuevent);
594 pout[0] = nup->Px()/nup->Pz() *
pzv;
595 pout[1] = nup->Py()/nup->Pz() *
pzv;
596 double pt = sqrt(pout[0]*pout[0] + pout[1]*pout[1]);
602 Int_t idhnu=TMath::Abs(
neu)+idbase;
603 if (
neu<0) idhnu+=1000;
604 Int_t nbinmx=
pxhist[idhnu]->GetNbinsX();
605 Double_t pl10=log10(
pzv);
606 Int_t nbx=
pxhist[idhnu]->FindBin(pl10);
609 if (nbx>nbinmx) nbx=nbinmx;
610 Double_t ptlog10=
pyslice[idhnu][nbx]->GetRandom();
612 Double_t pt=pow(10.,ptlog10)-0.01;
614 Double_t phi=gRandom->Uniform(0.,2*TMath::Pi());
615 pout[0] = cos(phi)*pt;
616 pout[1] = sin(phi)*pt;
621 pout[2]=TMath::Sqrt(pout[2]);
624 if (gRandom->Uniform(-1.,1.)<0.) pout[0]=-pout[0];
625 if (gRandom->Uniform(-1.,1.)<0.) pout[1]=-pout[1];
629 start[0]=(pout[0]/pout[2])*(start[2]-
ztarget);
630 start[1]=(pout[1]/pout[2])*(start[2]-
ztarget);
637 txnu=pout[0]/pout[2];
638 tynu=pout[1]/pout[2];
653 Double_t prob2int = -1.;
658 while (prob2int<gRandom->Uniform(0.,1.)) {
660 z=gRandom->Uniform(start[2],end[2]);
673 TGeoNode *node = gGeoManager->FindNode(x,y,z);
674 TGeoMaterial *mat = 0;
675 if (node && !gGeoManager->IsOutside()) {
676 mat = node->GetVolume()->GetMaterial();
679 prob2int= mat->GetDensity()/mparam[7];
680 if (prob2int>1.) cout <<
"***WARNING*** GenieGenerator: prob2int > Maximum density????" << prob2int <<
" maxrho:" << mparam[7] <<
" material: " << mat->GetName() << endl;
690 Double_t tof=TMath::Sqrt(x*x+y*y+zrelative*zrelative)/2.99792458e+6;
691 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]);
695 Int_t oLPdgCode =
neu;
696 if (
cc){oLPdgCode = copysign(TMath::Abs(
neu)-1,
neu);}
697 if (
nuel){oLPdgCode = 11;}
698 cpg->AddTrack(oLPdgCode,pp[0],pp[1],pp[2],x,y,z,0,
true,
El,tof,mparam[0]*mparam[4]);
700 for(
int i=0; i<
nf; i++)
703 cpg->AddTrack(
pdgf[i],pp[0],pp[1],pp[2],x,y,z,0,
true,
Ef[i],tof,mparam[0]*mparam[4]);