126 TGeoVolume *top=gGeoManager->FindVolumeFast(
"Detector");
127 if(!top) LOG(ERROR) <<
"no Detector volume found " ;
132 TGeoMedium *Fe =gGeoManager->GetMedium(
"iron");
134 TGeoMedium *Al =gGeoManager->GetMedium(
"aluminium");
136 TGeoMedium *Scint =gGeoManager->GetMedium(
"polyvinyltoluene");
138 TGeoMedium *concrete = gGeoManager->GetMedium(
"Concrete");
142 nSiPMs[0] =
conf_ints[
"MuFilter/VetonSiPMs"];
143 nSiPMs[1] =
conf_ints[
"MuFilter/UpstreamnSiPMs"];
144 nSiPMs[2] =
conf_ints[
"MuFilter/DownstreamnSiPMs"];
145 nSides[0] =
conf_ints[
"MuFilter/VetonSides"];
146 nSides[1] =
conf_ints[
"MuFilter/DownstreamnSides"];
147 nSides[2] =
conf_ints[
"MuFilter/UpstreamnSides"];
149 Int_t fNUpstreamPlanes =
conf_ints[
"MuFilter/NUpstreamPlanes"];
150 Int_t fNUpstreamBars =
conf_ints[
"MuFilter/NUpstreamBars"];
151 Int_t fNDownstreamPlanes =
conf_ints[
"MuFilter/NDownstreamPlanes"];
152 Int_t fNDownstreamBars =
conf_ints[
"MuFilter/NDownstreamBars"];
153 Double_t fDownstreamBarX_ver =
conf_floats[
"MuFilter/DownstreamBarX_ver"];
154 Double_t fDownstreamBarY_ver =
conf_floats[
"MuFilter/DownstreamBarY_ver"];
155 Double_t fDownstreamBarZ_ver =
conf_floats[
"MuFilter/DownstreamBarZ_ver"];
156 Double_t fDS4ZGap =
conf_floats[
"MuFilter/DS4ZGap"];
159 std::map<int, TVector3 > edge_Veto;
163 std::map<int, TVector3 > edge_Iron;
164 std::map<int, TVector3 > edge_MuFilter;
165 for (
int i=1;i<10;i++){
166 string si = to_string(i);
171 Double_t fVetoShiftX =
conf_floats[
"MuFilter/VetoShiftX"];
172 Double_t fVetoShiftY =
conf_floats[
"MuFilter/VetoShiftY"];
173 Double_t fVetoShiftZ =
conf_floats[
"MuFilter/VetoShiftZ"];
178 TVector3 displacement;
181 TGeoVolumeAssembly *volVeto =
new TGeoVolumeAssembly(
"volVeto");
184 Double_t fVetoBarX =
conf_floats[
"MuFilter/VetoBarX"];
185 Double_t fVetoBarY =
conf_floats[
"MuFilter/VetoBarY"];
186 Double_t fVetoBarZ =
conf_floats[
"MuFilter/VetoBarZ"];
187 Double_t fVeto3BarX =
conf_floats[
"MuFilter/Veto3BarX"];
188 Double_t fVeto3BarY =
conf_floats[
"MuFilter/Veto3BarY"];
189 Double_t fVeto3BarZ =
conf_floats[
"MuFilter/Veto3BarZ"];
190 Double_t fVetoBarGap =
conf_floats[
"MuFilter/VetoBarGap"];
191 Int_t fNVetoPlanes =
conf_ints[
"MuFilter/NVetoPlanes"];
192 Int_t fNVetoBars =
conf_ints[
"MuFilter/NVetoBars"];
193 Double_t fSupportBoxVW =
conf_floats[
"MuFilter/SupportBoxVW"];
195 Double_t fSupportBoxVB3 =
conf_floats[
"MuFilter/SupportBoxVB3"];
202 TVector3 VetoBoxDim = TVector3( VetoBox1.X()-VetoBox2.X(), VetoBox2.Y()-VetoBox1.Y(), VetoBox2.Z()-VetoBox1.Z() ) ;
204 TGeoBBox *supVetoBoxInner =
new TGeoBBox(
"supVetoBoxI",VetoBoxDim.X()/2,VetoBoxDim.Y()/2,VetoBoxDim.Z()/2);
205 TGeoBBox *supVetoBoxOuter =
new TGeoBBox(
"supVetoBoxO",VetoBoxDim.X()/2+fSupportBoxVW,VetoBoxDim.Y()/2+fSupportBoxVW,VetoBoxDim.Z()/2+fSupportBoxVW);
206 TGeoCompositeShape *subVetoBoxShape =
new TGeoCompositeShape(
"subVetoBoxShape",
"supVetoBoxO-supVetoBoxI");
207 TGeoVolume *subVetoBox =
new TGeoVolume(
"subVetoBox", subVetoBoxShape, Al);
208 subVetoBox->SetLineColor(kGray+1);
213 TVector3 Veto3BoxDim = TVector3( VetoBox3.X()-VetoBox4.X(), VetoBox4.Y()-VetoBox3.Y(), VetoBox4.Z()-VetoBox3.Z() ) ;
215 TGeoBBox *supVeto3BoxInner =
new TGeoBBox(
"supVeto3BoxI",Veto3BoxDim.X()/2,Veto3BoxDim.Y()/2,Veto3BoxDim.Z()/2);
216 TGeoBBox *supVeto3BoxOuter =
new TGeoBBox(
"supVeto3BoxO",Veto3BoxDim.X()/2+fSupportBoxVW,Veto3BoxDim.Y()/2+fSupportBoxVB3,Veto3BoxDim.Z()/2+fSupportBoxVW);
217 TGeoCompositeShape *subVeto3BoxShape =
new TGeoCompositeShape(
"subVeto3BoxShape",
"supVeto3BoxO-supVeto3BoxI");
218 TGeoVolume *subVeto3Box =
new TGeoVolume(
"subVeto3Box", subVeto3BoxShape, Al);
219 subVeto3Box->SetLineColor(kGray+1);
222 TGeoVolume *volVetoBar = gGeoManager->MakeBox(
"volVetoBar",Scint,fVetoBarX/2., fVetoBarY/2., fVetoBarZ/2.);
224 TGeoVolume *volVetoBar_ver = gGeoManager->MakeBox(
"volVetoBar_ver",Scint,fVeto3BarX/2., fVeto3BarY/2., fVeto3BarZ/2.);
226 volVetoBar->SetLineColor(kRed-3);
227 AddSensitiveVolume(volVetoBar);
229 volVetoBar_ver->SetLineColor(kRed-3);
230 AddSensitiveVolume(volVetoBar_ver);
233 TGeoVolume* volVetoPlane;
234 for (
int iplane=0; iplane < fNVetoPlanes; iplane++){
236 string name =
"volVetoPlane_"+to_string(iplane);
237 volVetoPlane =
new TGeoVolumeAssembly(name.c_str());
240 displacement = edge_Veto[iplane+1] + LocBarVeto + TVector3(-fVetoBarX/2, 0, 0);
241 volVeto->AddNode(volVetoPlane,iplane,
242 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
244 displacement = edge_Veto[iplane+1] + VetoBox1 + TVector3(-VetoBoxDim.X()/2,VetoBoxDim.Y()/2,VetoBoxDim.Z()/2);
245 volVeto->AddNode(subVetoBox,iplane,
246 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
248 displacement = TVector3(0, 0, 0);
249 for (Int_t ibar = 0; ibar < fNVetoBars; ibar++){
250 Double_t dy_bar = (fVetoBarY + fVetoBarGap)*ibar;
251 volVetoPlane->AddNode(volVetoBar, 1e+4+iplane*1e+3+ibar,
252 new TGeoTranslation(displacement.X(),displacement.Y()+dy_bar,displacement.Z()));
256 displacement = edge_Veto[iplane+1] + LocBarVeto_v + TVector3(-fVeto3BarX/2, fVeto3BarY/2, 0);
257 volVeto->AddNode(volVetoPlane,iplane,
258 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
260 displacement = edge_Veto[iplane+1] + VetoBox3 + TVector3(-fVeto3BarX/2, 0, 0) + TVector3(-Veto3BoxDim.X()/2,Veto3BoxDim.Y()/2,Veto3BoxDim.Z()/2);
261 volVeto->AddNode(subVeto3Box,iplane,
262 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
264 displacement = TVector3(0, 0, 0);
265 for (Int_t ibar = 0; ibar < fNVetoBars; ibar++){
266 Double_t dx_bar = (fVeto3BarX + fVetoBarGap)*ibar;
267 volVetoPlane->AddNode(volVetoBar_ver, 1e+4+iplane*1e+3+ibar,
268 new TGeoTranslation(displacement.X()-dx_bar,displacement.Y(),displacement.Z()));
274 top->AddNode(volVeto, 1,
new TGeoTranslation(fVetoShiftX,fVetoShiftY,fVetoShiftZ)) ;
279 TGeoVolumeAssembly *volMuFilter =
new TGeoVolumeAssembly(
"volMuFilter");
285 Double_t fFeBlockEndX =
conf_floats[
"MuFilter/FeEndX"];
286 Double_t fFeBlockEndY =
conf_floats[
"MuFilter/FeEndY"];
287 Double_t fFeBlockEndZ =
conf_floats[
"MuFilter/FeEndZ"];
288 Double_t fFeBlockBotX =
conf_floats[
"MuFilter/FeBotX"];
289 Double_t fFeBlockBotY =
conf_floats[
"MuFilter/FeBotY"];
290 Double_t fFeBlockBotZ =
conf_floats[
"MuFilter/FeBotZ"];
291 Double_t fSupportBoxW =
conf_floats[
"MuFilter/SupportBoxW"];
295 TVector3 DSBoxDim = TVector3( DSBox1.X()-DSBox2.X(), DSBox2.Y()-DSBox1.Y(), DSBox2.Z()-DSBox1.Z() ) ;
298 TVector3 USBoxDim = TVector3( USBox1.X()-USBox2.X(), USBox2.Y()-USBox1.Y(), USBox2.Z()-USBox1.Z() ) ;
301 TGeoVolume *volFeBlock = gGeoManager->MakeBox(
"volFeBlock",Fe,fFeBlockX/2, fFeBlockY/2, fFeBlockZ/2);
302 volFeBlock->SetLineColor(kGreen-4);
303 TGeoVolume *volFeBlockEnd = gGeoManager->MakeBox(
"volFeBlockEnd",Fe,fFeBlockEndX/2, fFeBlockEndY/2, fFeBlockEndZ/2);
304 volFeBlockEnd->SetLineColor(kGreen-4);
305 TGeoVolume *volBlockBot = gGeoManager->MakeBox(
"volBlockBot",concrete,fFeBlockBotX/2, fFeBlockBotY/2, fFeBlockBotZ/2);
306 volBlockBot->SetLineColor(kGreen-4);
309 TGeoBBox *supDSBoxInner =
new TGeoBBox(
"supDSBoxI",DSBoxDim.X()/2,DSBoxDim.Y()/2,DSBoxDim.Z()/2);
310 TGeoBBox *supDSBoxOuter =
new TGeoBBox(
"supDSBoxO",DSBoxDim.X()/2+fSupportBoxW,DSBoxDim.Y()/2+fSupportBoxW,DSBoxDim.Z()/2+fSupportBoxW);
311 TGeoCompositeShape *subDSBoxShape =
new TGeoCompositeShape(
"subDSBoxShape",
"supDSBoxO-supDSBoxI");
312 TGeoVolume *subDSBox =
new TGeoVolume(
"subDSBox", subDSBoxShape, Al);
313 subDSBox->SetLineColor(kGray+1);
314 TGeoBBox *supUSBoxInner =
new TGeoBBox(
"supUSBoxI",USBoxDim.X()/2,USBoxDim.Y()/2,USBoxDim.Z()/2);
315 TGeoBBox *supUSBoxOuter =
new TGeoBBox(
"supUSBoxO",USBoxDim.X()/2+fSupportBoxW,USBoxDim.Y()/2+fSupportBoxW,USBoxDim.Z()/2+fSupportBoxW);
316 TGeoCompositeShape *subUSBoxShape =
new TGeoCompositeShape(
"subUSBoxShape",
"supUSBoxO-supUSBoxI");
317 TGeoVolume *subUSBox =
new TGeoVolume(
"subUSBox", subUSBoxShape, Al);
318 subUSBox->SetLineColor(kGray+1);
320 top->AddNode(volMuFilter,1,
new TGeoTranslation(fShiftX,fShiftY,fShiftZ ));
325 Double_t fUpstreamDetZ =
conf_floats[
"MuFilter/UpstreamDetZ"];
328 TVector3 LocBarUS = TVector3(
333 TGeoVolume* volUpstreamDet;
334 Double_t fUpstreamBarX =
conf_floats[
"MuFilter/UpstreamBarX"];
335 Double_t fUpstreamBarY =
conf_floats[
"MuFilter/UpstreamBarY"];
336 Double_t fUpstreamBarZ =
conf_floats[
"MuFilter/UpstreamBarZ"];
337 Double_t fUpstreamBarGap =
conf_floats[
"MuFilter/UpstreamBarGap"];
340 TGeoVolume *volMuUpstreamBar = gGeoManager->MakeBox(
"volMuUpstreamBar",Scint,fUpstreamBarX/2, fUpstreamBarY/2, fUpstreamBarZ/2);
341 volMuUpstreamBar->SetLineColor(kBlue+2);
342 AddSensitiveVolume(volMuUpstreamBar);
343 for(Int_t l=0; l<fNUpstreamPlanes; l++)
345 string name =
"volMuUpstreamDet_"+std::to_string(l);
346 volUpstreamDet =
new TGeoVolumeAssembly(name.c_str());
348 displacement = edge_Iron[l+1] - TVector3(fFeBlockX/2,-fFeBlockY/2,-fFeBlockZ/2);
349 volMuFilter->AddNode(volFeBlock,l,
350 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
352 if (edge_Iron[9][2] <0.1 && l==0) {
353 TGeoVolume *volFeTarget = gGeoManager->MakeBox(
"volFeTarget",Fe,80./2, 60./2, 29.5/2);
354 volFeTarget->SetLineColor(kGreen-4);
355 displacement = edge_Iron[l+1] - TVector3(80/2,-60/2,29.5/2+fFeBlockZ );
356 volMuFilter->AddNode(volFeTarget,1,
357 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
359 displacement = edge_MuFilter[l+1]+LocBarUS + TVector3(-fUpstreamBarX/2, 0, 0);
360 volMuFilter->AddNode(volUpstreamDet,fNVetoPlanes+l,
361 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
364 displacement = edge_MuFilter[l+1] +USBox1 + TVector3(-USBoxDim.X()/2,USBoxDim.Y()/2,USBoxDim.Z()/2);
365 volMuFilter->AddNode(subUSBox,l+fNVetoPlanes,
366 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
368 displacement = TVector3(0, 0, 0);
369 for (Int_t ibar = 0; ibar < fNUpstreamBars; ibar++){
370 Double_t dy_bar = (fUpstreamBarY + fUpstreamBarGap)*ibar;
371 volUpstreamDet->AddNode(volMuUpstreamBar,2e+4+l*1e+3+ibar,
372 new TGeoTranslation(displacement.X(),displacement.Y()+
conf_floats[
"MuFilter/USOffZ"+to_string(l+1)]+dy_bar,displacement.Z()));
380 TGeoVolume* volDownstreamDet;
387 Double_t fDownstreamBarX =
conf_floats[
"MuFilter/DownstreamBarX"];
388 Double_t fDownstreamBarY =
conf_floats[
"MuFilter/DownstreamBarY"];
389 Double_t fDownstreamBarZ =
conf_floats[
"MuFilter/DownstreamBarZ"];
390 Double_t fDownstreamBarGap =
conf_floats[
"MuFilter/DownstreamBarGap"];
392 TGeoVolume *volMuDownstreamBar_hor = gGeoManager->MakeBox(
"volMuDownstreamBar_hor",Scint,fDownstreamBarX/2, fDownstreamBarY/2, fDownstreamBarZ/2);
393 volMuDownstreamBar_hor->SetLineColor(kAzure+7);
394 AddSensitiveVolume(volMuDownstreamBar_hor);
397 TGeoVolume *volMuDownstreamBar_ver = gGeoManager->MakeBox(
"volMuDownstreamBar_ver",Scint,fDownstreamBarX_ver/2, fDownstreamBarY_ver/2, fDownstreamBarZ/2);
398 volMuDownstreamBar_ver->SetLineColor(kViolet-2);
399 AddSensitiveVolume(volMuDownstreamBar_ver);
403 n_planes = fNDownstreamPlanes>1 ? fNDownstreamPlanes-1 : fNDownstreamPlanes;
405 for(Int_t l=0; l<fNDownstreamPlanes; l++)
408 displacement = edge_Iron[l+fNUpstreamPlanes+1] - TVector3(fFeBlockX/2,-fFeBlockY/2,-fFeBlockZ/2);
409 volMuFilter->AddNode(volFeBlock,l+fNUpstreamPlanes+fNVetoPlanes,
410 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
411 }
else if (edge_Iron[9][2] >0.1) {
413 displacement = edge_Iron[l+fNUpstreamPlanes+1] - TVector3(fFeBlockEndX/2,-fFeBlockEndY/2,-fFeBlockEndZ/2);
414 volMuFilter->AddNode(volFeBlockEnd,1,
415 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
416 displacement = edge_Iron[l+fNUpstreamPlanes+1] - TVector3(fFeBlockBotX/2-10.0, fFeBlockBotY/2,fFeBlockBotZ/2-fFeBlockEndZ);
417 volMuFilter->AddNode(volBlockBot,1,
418 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
422 string name =
"volMuDownstreamDet_"+std::to_string(l);
423 volDownstreamDet =
new TGeoVolumeAssembly(name.c_str());
424 displacement = edge_MuFilter[l+fNUpstreamPlanes+1] + LocBarH + TVector3(-fDownstreamBarX/2, 0,0);
426 volMuFilter->AddNode(volDownstreamDet,l+fNUpstreamPlanes+fNVetoPlanes,
427 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
431 displacement = TVector3(0, 0,0);
432 for (Int_t ibar = 0; ibar < fNDownstreamBars; ibar++){
434 Double_t dy_bar = (fDownstreamBarY + fDownstreamBarGap)*ibar;
435 volDownstreamDet->AddNode(volMuDownstreamBar_hor,3e+4+l*1e+3+ibar,
436 new TGeoTranslation(displacement.X(),displacement.Y()+dy_bar,displacement.Z()));
440 displacement = edge_MuFilter[l+fNUpstreamPlanes+1] +DSBox1 +
441 TVector3(-DSBoxDim.X()/2,DSBoxDim.Y()/2,DSBoxDim.Z()/2);
442 volMuFilter->AddNode(subDSBox,l+fNUpstreamPlanes+fNVetoPlanes,
443 new TGeoTranslation(displacement.X(),displacement.Y(),displacement.Z()));
445 displacement = LocBarV + TVector3(0, -fDownstreamBarY_ver/2,0) - LocBarH - TVector3(-fDownstreamBarX/2, 0,0);
446 for (Int_t i_vbar = 0; i_vbar<fNDownstreamBars; i_vbar++) {
447 Double_t dx_bar = (fDownstreamBarX_ver+ fDownstreamBarGap)*i_vbar;
448 Int_t i_vbar_rev = fNDownstreamBars-1-i_vbar;
449 volDownstreamDet->AddNode(volMuDownstreamBar_ver,3e+4+l*1e+3+i_vbar_rev+60,
450 new TGeoTranslation(displacement.X()+dx_bar,displacement.Y(),displacement.Z()));