196 int NTungstenPlatesTB24 =
conf_ints[
"EmulsionDet/n_tungsten_plates_tb24"];
197 bool testbeam_2024_setup =
false;
199 TGeoVolume *top=gGeoManager->FindVolumeFast(
"Detector");
200 if(!top) LOG(ERROR) <<
"no Detector volume found " ;
201 gGeoManager->SetVisLevel(10);
207 TGeoMedium *vacuum =gGeoManager->GetMedium(
"vacuum");
210 TGeoMedium *air =gGeoManager->GetMedium(
"air");
213 TGeoMedium *Al = gGeoManager->GetMedium(
"Aluminum");
216 TGeoMedium *PBase =gGeoManager->GetMedium(
"PlasticBase");
219 TGeoMedium *NEmu =gGeoManager->GetMedium(
"NuclearEmulsion");
221 TGeoMaterial *NEmuMat = NEmu->GetMaterial();
222 TGeoMaterial *PBaseMat = PBase->GetMaterial();
224 TGeoMixture * emufilmmixture =
new TGeoMixture(
"EmulsionFilmMixture", 2.00);
227 emufilmmixture->AddElement(NEmuMat,frac_emu);
228 emufilmmixture->AddElement(PBaseMat,1. - frac_emu);
230 TGeoMedium *Emufilm =
new TGeoMedium(
"EmulsionFilm",100,emufilmmixture);
233 TGeoMedium *tungsten = gGeoManager->GetMedium(
"tungstensifon");
243 TGeoVolumeAssembly *volTarget =
new TGeoVolumeAssembly(
"volTarget");
260 TGeoTranslation * Wallborderpos =
new TGeoTranslation(
"Walborderpos",0,0,
WallZBorder_offset);
261 Wallborderpos->RegisterYourself();
263 TGeoCompositeShape *Wallborder =
new TGeoCompositeShape(
"wallborder",
"walltot - (wallint:Walborderpos)");
264 TGeoVolume *volWallborder =
new TGeoVolume(
"volWallborder", Wallborder, Al);
265 volWallborder->SetLineColor(kGray);
267 TGeoVolume *volWall =
new TGeoVolume(
"Wall",Wallint,air);
268 TGeoVolume *volWall_2 =
new TGeoVolume(
"Wall_2",Wallint,air);
272 TGeoVolume *volRow =
new TGeoVolume(
"Row",Row,air);
274 TGeoVolume *volRow_W2 =
new TGeoVolume(
"Row_W2",Row_W2,air);
278 TGeoVolume *volBrick =
new TGeoVolume(
"Brick",Brick,air);
279 volBrick->SetLineColor(kCyan);
280 volBrick->SetTransparency(1);
283 TGeoVolume *volBrick_W2 =
new TGeoVolume(
"Brick_W2",Brick_W2,air);
284 volBrick_W2->SetLineColor(kOrange);
285 volBrick_W2->SetTransparency(1);
288 TGeoVolume *volPassive =
new TGeoVolume(
"volPassive",Passive,tungsten);
289 volPassive->SetTransparency(1);
290 volPassive->SetLineColor(kGray);
293 float UpstreamPlasticThickness = (NPlates-NTungstenPlatesTB24)*
AllPlateWidth;
296 float UpstreamPlasticThickness_W2 = UpstreamPlasticThickness - correction_W2;
297 TGeoBBox *Passive_plastic =
new TGeoBBox(
"Passive_plastic", (
EmulsionX-2.)/2, (
EmulsionY-2.)/2, UpstreamPlasticThickness/2);
298 TGeoVolume *volPassive_plastic =
new TGeoVolume(
"volPassive_plastic",Passive_plastic,PBase);
299 volPassive_plastic->SetLineColor(kMagenta);
300 volPassive_plastic->SetVisibility(kTRUE);
302 TGeoBBox *Passive_plastic_W2 =
new TGeoBBox(
"Passive_plastic_W2", (
EmulsionX-2.)/2, (
EmulsionY-2.)/2, UpstreamPlasticThickness_W2/2);
303 TGeoVolume *volPassive_plastic_W2 =
new TGeoVolume(
"volPassive_plastic_W2",Passive_plastic_W2,PBase);
304 volPassive_plastic_W2->SetLineColor(kMagenta+2);
305 volPassive_plastic_W2->SetVisibility(kTRUE);
307 float accumulatve_width = UpstreamPlasticThickness_W2;
309 for(Int_t n=0; n<NPlates; n++)
311 if (n==0 && testbeam_2024_setup){
312 volBrick->AddNode(volPassive_plastic, n,
313 new TGeoTranslation(0,0,-
BrickZ/2 + UpstreamPlasticThickness/2));
314 volBrick_W2->AddNode(volPassive_plastic_W2, n,
new TGeoTranslation(0,0,-
BrickZ/2 + UpstreamPlasticThickness_W2/2));
316 if (n>=(NPlates-NTungstenPlatesTB24) || !testbeam_2024_setup) {
317 volBrick->AddNode(volPassive, n,
319 if (testbeam_2024_setup){
321 volBrick_W2->AddNode(volPassive, n,
329 TGeoVolume *volEmulsionFilm =
new TGeoVolume(
"Emulsion",EmulsionFilm,Emufilm);
330 volEmulsionFilm->SetLineColor(kBlue);
331 LOG(INFO) <<
"EmulsionDet : Passive option (0: all active, 1: all passive) set to " <<
fPassiveOption ;
333 if (!testbeam_2024_setup){
334 for(Int_t n=0; n<NPlates+1; n++)
340 volBrick->SetVisibility(kTRUE);
341 if (testbeam_2024_setup) {
342 volBrick_W2->SetVisibility(kTRUE);
350 top->AddNode(volTarget,1,
new TGeoTranslation(0,0,0));
356 if (!testbeam_2024_setup){
357 for(
int l = 0; l <
fNWall; l++) {
375 for(
int k= 0; k<
fNRow; k++)
377 volWall->AddNode(volRow,k,
new TGeoTranslation(0, d_cl_y +
BrickY/2,0));
378 if (testbeam_2024_setup){
379 volWall_2->AddNode(volRow_W2,k,
new TGeoTranslation(0, d_cl_y +
BrickY/2,0));
388 for(
int j= 0; j <
fNCol; j++)
390 volRow->AddNode(volBrick,j,
new TGeoTranslation(d_cl_x+
BrickX/2, 0, 0));
391 if (testbeam_2024_setup){
392 volRow_W2->AddNode(volBrick_W2,j,
new TGeoTranslation(d_cl_x+
BrickX/2, 0, 0));
406 if ( gMC->IsTrackEntering() ) {
408 fTime = gMC->TrackTime() * 1.0e09;
410 gMC->TrackPosition(
fPos);
411 gMC->TrackMomentum(
fMom);
417 if ( gMC->IsTrackExiting() ||
418 gMC->IsTrackStop() ||
419 gMC->IsTrackDisappeared() ) {
420 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
425 Int_t MaxLevel = gGeoManager->GetLevel();
426 const Int_t MaxL = MaxLevel;
435 name = gMC->CurrentVolName();
439 Int_t NWall = -2, NColumn =-2, NRow =-2;
441 for(Int_t i = 0; i <= MaxL;i++)
443 gMC->CurrentVolOffID(i, motherV[i]);
444 const char *mumname = gMC->CurrentVolOffName(i);
446 if(strcmp(mumname,
"Brick") == 0) NColumn = (1-motherV[i]);
447 if(strcmp(mumname,
"Row") == 0) NRow = motherV[i];
448 if(strcmp(mumname,
"Wall") == 0) NWall = motherV[i];
452 detID = (NWall+1)*1E4+(NRow*2+NColumn+1)*1E3+(NPlate+1);
456 TParticle* p=gMC->GetStack()->GetCurrentTrack();
457 Int_t pdgCode = p->GetPdgCode();
458 if (pdgCode == 22) {
return kFALSE; }
461 gMC->TrackPosition(Pos);
462 Double_t xmean = (
fPos.X()+Pos.X())/2. ;
463 Double_t ymean = (
fPos.Y()+Pos.Y())/2. ;
464 Double_t zmean = (
fPos.Z()+Pos.Z())/2. ;
467 gMC->TrackMomentum(Mom);
470 fELoss,pdgCode,TVector3(Pos.X(), Pos.Y(), Pos.Z()),TVector3(Mom.Px(), Mom.Py(), Mom.Pz()) );