diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 27dd5ee3c1..5a76666a89 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -36,7 +36,6 @@ #include "TParticle.h" #include "TVector3.h" #include "TVirtualMC.h" -#include "UpstreamTaggerHit.h" #include "UpstreamTaggerPoint.h" using ROOT::TSeq; using ShipUnit::cm; @@ -44,17 +43,50 @@ using ShipUnit::m; using std::cout; using std::endl; +constexpr uint64_t hash(std::string_view str) { + uint64_t hash = 0; + for (char c : str) { + hash = (hash * 131) + c; + } + return hash; +} + +constexpr uint64_t operator"" _hash(const char* str, size_t len) { + return hash(std::string_view(str, len)); +} + +constexpr const int detPieces(std::string_view pieceName) noexcept { + switch (hash(pieceName)) { + case "Upstream_Tagger_Plastic"_hash: + return 0; + case "ubt_gas_UBT1_y2_layer"_hash: + return 1; + case "ubt_gas_UBT1_v_layer"_hash: + return 2; + case "ubt_gas_UBT1_u_layer"_hash: + return 3; + case "ubt_gas_UBT1_y1_layer"_hash: + return 4; + default: + return 10; + } +} + +UpstreamTagger::UpstreamTagger(std::string medium) + : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), + fMedium(medium), + det_zPos(0), + UpstreamTagger_fulldet(0) {} + UpstreamTagger::UpstreamTagger() : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), det_zPos(0), - UpstreamTagger_fulldet(0), - scoringPlaneUBText(0) {} + UpstreamTagger_fulldet(0) {} UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) : Detector(name, active, kUpstreamTagger), det_zPos(0), - UpstreamTagger_fulldet(0), - scoringPlaneUBText(0) {} + UpstreamTagger_fulldet(0) {} Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ @@ -66,10 +98,11 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { gMC->TrackPosition(fPos); gMC->TrackMomentum(fMom); } - // Sum energy loss for all steps in the active volume fELoss += gMC->Edep(); + // fELoss += 0.0001; + // Create vetoPoint at exit of active volume if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) { @@ -81,6 +114,9 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { fEventID = gMC->CurrentEvent(); Int_t uniqueId; gMC->CurrentVolID(uniqueId); + const char* volName = gMC->CurrentVolName(); + // std::cout<<"volume id: "< 1000000) // Solid scintillator case { Int_t vcpy; @@ -111,34 +147,290 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { return kTRUE; } +void UpstreamTagger::SetzPositions(Double_t z1) { + f_T1_z = z1; //! z-position of tracking station 1 +} + +void UpstreamTagger::SetApertureArea(Double_t width, Double_t height, + Double_t length) { + f_aperture_width = width; //! Aperture width (x) + f_aperture_height = height; //! Aperture height (y) + f_station_length = length; +} + +void UpstreamTagger::SetStrawDiameter(Double_t outer_straw_diameter, + Double_t wall_thickness) { + f_outer_straw_diameter = outer_straw_diameter; //! Outer straw diameter + f_inner_straw_diameter = + outer_straw_diameter - 2 * wall_thickness; //! Inner straw diameter +} + +void UpstreamTagger::SetStrawPitch(Double_t straw_pitch, + Double_t layer_offset) { + f_straw_pitch = straw_pitch; //! Distance (y) between straws in a layer + f_offset_layer = layer_offset; //! Offset (y) of straws between layers +} + +void UpstreamTagger::SetDeltazLayer(Double_t delta_z_layer) { + f_delta_z_layer = delta_z_layer; //! Distance (z) between layers +} + +void UpstreamTagger::SetStereoAngle(Double_t stereo_angle) { + f_view_angle = stereo_angle; //! Stereo view angle +} + +void UpstreamTagger::SetWireThickness(Double_t wire_thickness) { + f_wire_thickness = wire_thickness; //! Sense wire thickness +} + +void UpstreamTagger::SetDeltazView(Double_t delta_z_view) { + f_delta_z_view = delta_z_view; //! Distance (z) between stereo views +} + +void UpstreamTagger::SetFrameMaterial(TString frame_material) { + f_frame_material = frame_material; //! Structure frame material +} + void UpstreamTagger::ConstructGeometry() { + /** If you are using the standard ASCII input for the geometry + just copy this and use it for your detector, otherwise you can + implement here you own way of constructing the geometry. */ + + std::cout << "Making a geometry" << std::endl; + TGeoVolume* top = gGeoManager->GetTopVolume(); + ShipGeo::InitMedium("air"); + TGeoMedium* air = gGeoManager->GetMedium("air"); + ShipGeo::InitMedium("mylar"); + TGeoMedium* mylar = gGeoManager->GetMedium("mylar"); - ////////////////////////////////////////////////////// + ShipGeo::InitMedium("UBTMixture"); + TGeoMedium* sttmix8020_1bar = gGeoManager->GetMedium("UBTMixture"); + ShipGeo::InitMedium("WReWire"); + TGeoMedium* WReWire = gGeoManager->GetMedium("WReWire"); + ShipGeo::InitMedium(f_frame_material); - /////////////////////////////////////////////////////// + TGeoMedium* FrameMatPtr = gGeoManager->GetMedium(f_frame_material); + ShipGeo::InitMedium(fMedium.c_str()); + TGeoMedium* med = gGeoManager->GetMedium(fMedium.c_str()); - /////////////////////////////////////////////////////// + gGeoManager->SetVisLevel(4); + gGeoManager->SetTopVisible(); - ShipGeo::InitMedium("vacuum"); - TGeoMedium* Vacuum_box = gGeoManager->GetMedium("vacuum"); - /////////////////////////////////////////////////////////////////// + Double_t eps = 0.0001; // Epsilon to avoid overlapping volumes + Double_t straw_length = + f_aperture_width; // + 2. * eps; // Straw (half) length + Double_t frame_width = 20.; // Width of frame metal + Double_t floor_offset = 14.; // Offset due to floor space limitation + Double_t rmin, rmax, T_station_z; + Double_t max_stereo_growth = + TMath::Tan(TMath::Abs(f_view_angle) * TMath::Pi() / 180.0) * straw_length; - // Adding UBT Extension - if (!Vacuum_box) { - Fatal("ConstructGeometry", "Medium 'vacuum' not found."); - } + // Arguments of boxes are half-lengths + TGeoBBox* detbox1 = new TGeoBBox( + "ubt_detbox1", (straw_length + frame_width), + (f_aperture_height + 4 * max_stereo_growth /* + frame_width */ - + floor_offset / 2.), // No top and bottom frame + f_station_length); + TGeoBBox* detbox2 = new TGeoBBox( + "ubt_detbox2", (straw_length + eps), + (f_aperture_height + 4 * max_stereo_growth - floor_offset / 2. + eps), + f_station_length + eps); + + TGeoTranslation* move_up = + new TGeoTranslation("ubt_move_up", 0, floor_offset / 2., 0); + move_up->RegisterYourself(); + + // Composite shape to create frame + TGeoCompositeShape* detcomp1 = new TGeoCompositeShape( + "ubt_detcomp1", "ubt_detbox1:ubt_move_up - ubt_detbox2:ubt_move_up"); + + // Volume: straw - Third argument is half-length of tube + TGeoTube* straw_tube = + new TGeoTube("ubt_straw", f_inner_straw_diameter / 2., + f_outer_straw_diameter / 2., straw_length); + TGeoVolume* straw = new TGeoVolume("ubt_straw", straw_tube, mylar); + straw->SetLineColor(4); + // Volume: gas - Only the gas is sensitive + // TGeoTube *gas_tube = new TGeoTube("ubt_gas", f_wire_thickness / 2. + + // eps, f_inner_straw_diameter / 2. - eps, straw_length - 2. * eps); + // TGeoVolume *gas = new TGeoVolume("ubt_gas", gas_tube, sttmix8020_1bar); + // gas->SetLineColor(5); + // AddSensitiveVolume(gas); + // Volume: wire + TGeoTube* wire_tube = new TGeoTube("ubt_wire", 0., f_wire_thickness / 2., + straw_length - 4. * eps); + TGeoVolume* wire = new TGeoVolume("ubt_wire", wire_tube, WReWire); + wire->SetLineColor(6); - UpstreamTagger_fulldet = - gGeoManager->MakeBox("Upstream_Tagger", Vacuum_box, xbox_fulldet / 2.0, - ybox_fulldet / 2.0, zbox_fulldet / 2.0); - UpstreamTagger_fulldet->SetLineColor(kGreen); + // Station box to contain all components + TGeoBBox* statbox = + new TGeoBBox("ubt_statbox", straw_length + frame_width, + f_aperture_height + frame_width + 4 * max_stereo_growth - + floor_offset / 2., + f_station_length); + f_frame_material.ToLower(); - top->AddNode(UpstreamTagger_fulldet, 1, - new TGeoTranslation(0.0, 0.0, det_zPos)); - AddSensitiveVolume(UpstreamTagger_fulldet); - cout << " Z Position (Upstream Tagger1) " << det_zPos << endl; - ////////////////////////////////////////////////////////////////// + for (Int_t statnb = 1; statnb < 2; statnb++) { + // Tracking station loop + TString nmstation = "UBT"; + std::stringstream ss; + ss << statnb; + nmstation = nmstation + ss.str(); + switch (statnb) { + case 1: + T_station_z = f_T1_z; + break; + default: + T_station_z = f_T1_z; + } + + TGeoVolume* vol = new TGeoVolume(nmstation, statbox, med); + // z-translate the station to its (absolute) position + top->AddNode(vol, statnb, + new TGeoTranslation(0, floor_offset / 2., T_station_z)); + + TGeoVolume* statframe = + new TGeoVolume(nmstation + "_frame", detcomp1, FrameMatPtr); + vol->AddNode(statframe, statnb * 1e6, + new TGeoTranslation(0, -floor_offset / 2., 0)); + statframe->SetLineColor(kOrange); + // Loop over the 4 stereo layers + for (Int_t vnb = 0; vnb < 4; vnb++) { + // View loop + TString nmview; + Double_t angle; + Double_t stereo_growth; + Double_t stereo_pitch; + Double_t offset_layer; + Int_t straws_per_layer; + + switch (vnb) { + case 0: + angle = 0.; + nmview = nmstation + "_y1"; + break; + case 1: + angle = f_view_angle; + nmview = nmstation + "_u"; + break; + case 2: + angle = -f_view_angle; + nmview = nmstation + "_v"; + break; + case 3: + angle = 0.; + nmview = nmstation + "_y2"; + break; + default: + angle = 0.; + nmview = nmstation + "_y1"; + } + + // Adjustments in the stereo views + // stereo_growth: extension of stereo views beyond aperture + // stereo_pitch: straw pitch in stereo views + // offset_layer: layer offset in stereo views + // straws_per_layer: number of straws in one layer with stereo extension + // If angle == 0., all numbers return the case of non-stereo views. + stereo_growth = + TMath::Tan(TMath::Abs(angle) * TMath::Pi() / 180.0) * straw_length; + stereo_pitch = + f_straw_pitch / TMath::Cos(TMath::Abs(angle) * TMath::Pi() / 180.0); + offset_layer = + f_offset_layer / TMath::Cos(TMath::Abs(angle) * TMath::Pi() / 180.0); + straws_per_layer = + std::floor(2 * (f_aperture_height + stereo_growth) / stereo_pitch); + + // Two sets of straws per layer + for (Int_t lnb = 0; lnb < 2; lnb++) { + // Layer loop + TString nmlayer = nmview + "_layer"; + TString gasname = "ubt_gas_" + nmlayer; - return; + // Volume: gas - Only the gas is sensitive + TGeoTube* gas_tube = new TGeoTube(gasname, f_wire_thickness / 2. + eps, + f_inner_straw_diameter / 2. - eps, + straw_length - 2. * eps); + TGeoVolume* gas = new TGeoVolume(gasname, gas_tube, sttmix8020_1bar); + gas->SetLineColor(5); + AddSensitiveVolume(gas); + nmlayer += lnb; + + TGeoBBox* layer = new TGeoBBox( + "layer box", straw_length + eps / 4, + f_aperture_height + stereo_growth * 2 + offset_layer + eps / 4, + f_outer_straw_diameter / 2. + eps / 4); + TGeoVolume* layerbox = new TGeoVolume(nmlayer, layer, med); + + // The layer box sits in the viewframe. + // Hence, z-translate the layer w.r.t. the view + vol->AddNode( + layerbox, statnb * 1e6 + vnb * 1e5 + lnb * 1e4, + new TGeoTranslation(0, -floor_offset / 2., + (vnb - 3. / 2.) * f_delta_z_view + + (lnb - 1. / 2.) * f_delta_z_layer)); + + TGeoRotation r6s; + TGeoTranslation t6s; + // Loop over the straws + for (Int_t snb = 1; snb <= straws_per_layer; snb++) { + // y-translate the straw to its position + t6s.SetTranslation(0, + f_aperture_height + stereo_growth - + (snb - 1. / 2.) * stereo_pitch + + lnb * offset_layer, + 0); + // Rotate the straw with stereo angle + r6s.SetAngles(90 + angle, 90, 0); + TGeoCombiTrans c6s(t6s, r6s); + TGeoHMatrix* h6s = new TGeoHMatrix(c6s); + layerbox->AddNode( + straw, statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 1e3 + snb, h6s); + layerbox->AddNode( + gas, statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 2e3 + snb, h6s); + layerbox->AddNode( + wire, statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 3e3 + snb, h6s); + } + + if (lnb == 1) { + // Add one more straw at the bottom of the second layer to cover + // aperture entirely + t6s.SetTranslation(0, + f_aperture_height + stereo_growth - + (straws_per_layer - 1. / 2.) * stereo_pitch - + lnb * offset_layer, + 0); + r6s.SetAngles(90 + angle, 90, 0); + TGeoCombiTrans c6s(t6s, r6s); + TGeoHMatrix* h6s = new TGeoHMatrix(c6s); + layerbox->AddNode( + straw, + statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 1e3 + straws_per_layer + 1, + h6s); + layerbox->AddNode( + gas, + statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 2e3 + straws_per_layer + 1, + h6s); + layerbox->AddNode( + wire, + statnb * 1e6 + vnb * 1e5 + lnb * 1e4 + 3e3 + straws_per_layer + 1, + h6s); + } + // End of layer loop + } + // End of view loop + } + // A layer of plastic scintillator detector + ShipGeo::InitMedium("polyvinyltoluene"); + TGeoMedium* Vacuum_box = gGeoManager->GetMedium("polyvinyltoluene"); + UpstreamTagger_plastic = + gGeoManager->MakeBox("Upstream_Tagger_Plastic", Vacuum_box, + straw_length, f_aperture_height, 1); + UpstreamTagger_plastic->SetLineColor(kGreen); + vol->AddNode(UpstreamTagger_plastic, 1, new TGeoTranslation(0.0, 0.0, -30)); + AddSensitiveVolume(UpstreamTagger_plastic); + std::cout << "geometry constructed" << std::endl; + // End of tracking station loop + } } diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index 34f0f33d2b..72ff4e7cf1 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -48,7 +48,7 @@ class UpstreamTagger : public SHiP::Detector { * kFALSE for inactive detectors */ UpstreamTagger(const char* Name, Bool_t Active); - + UpstreamTagger(std::string medium); /** default constructor */ UpstreamTagger(); @@ -59,32 +59,51 @@ class UpstreamTagger : public SHiP::Detector { /** Sets detector position and sizes */ void SetZposition(Double_t z) { det_zPos = z; } - void SetBoxDimensions(Double_t x, Double_t y, Double_t z) { - xbox_fulldet = x; - ybox_fulldet = y; - zbox_fulldet = z; - } + void SetzPositions(Double_t z1); + void SetApertureArea(Double_t width, Double_t height, Double_t length); + void SetStrawDiameter(Double_t outer_straw_diameter, Double_t wall_thickness); + void SetStrawPitch(Double_t straw_pitch, Double_t layer_offset); + void SetDeltazLayer(Double_t delta_z_layer); + void SetStereoAngle(Double_t stereo_angle); + void SetWireThickness(Double_t wire_thickness); + void SetFrameMaterial(TString frame_material); + void SetDeltazView(Double_t delta_z_view); + static std::tuple StrawDecode(Int_t detID); + static void StrawEndPoints(Int_t detID, TVector3& top, TVector3& bot); /** Create the detector geometry */ + void ConstructGeometry() override; Double_t module[11][3]; // x,y,z centre positions for each module - // TODO Avoid 1-indexed array! + // TODO Avoid 1-indexed array! /** Detector parameters.*/ + Double_t f_aperture_width; + Double_t f_aperture_height; + Double_t f_station_length; + Double_t f_straw_pitch; + Double_t f_view_angle; + Double_t f_offset_layer; + Double_t f_inner_straw_diameter; + Double_t f_outer_straw_diameter; + Double_t f_wire_thickness; + Double_t f_T1_z; + Double_t f_delta_z_view; + Double_t f_delta_z_layer; + TString f_frame_material; + std::string fMedium; + /** Detector parameters.*/ + Double_t det_zPos; //! z-position of detector (set via SetZposition) - // Detector box dimensions (set via SetBoxDimensions, defaults provided below) - Double_t xbox_fulldet = 4.4 * m; //! X dimension (default: 4.4 m) - Double_t ybox_fulldet = 6.4 * m; //! Y dimension (default: 6.4 m) - Double_t zbox_fulldet = - 16.0 * cm; //! Z dimension/thickness (default: 16 cm) private: - TGeoVolume* UpstreamTagger_fulldet; // Timing_detector_1 object - TGeoVolume* scoringPlaneUBText; // new scoring plane /** container for data points */ + TGeoVolume* UpstreamTagger_plastic; + TGeoVolume* UpstreamTagger_fulldet; + UpstreamTagger(const UpstreamTagger&) = delete; UpstreamTagger& operator=(const UpstreamTagger&) = delete; diff --git a/UpstreamTagger/UpstreamTaggerHit.cxx b/UpstreamTagger/UpstreamTaggerHit.cxx index d57645e593..bc5eb53f24 100644 --- a/UpstreamTagger/UpstreamTaggerHit.cxx +++ b/UpstreamTagger/UpstreamTaggerHit.cxx @@ -34,6 +34,8 @@ UpstreamTaggerHit::UpstreamTaggerHit(UpstreamTaggerPoint* p, Double_t t0, // Smear time with Gaussian resolution fTime = gRandom->Gaus(p->GetTime() + t0, time_res); + + // fSubDetID = p->GetLayerID(); } // ----- Print ------------------------------ diff --git a/UpstreamTagger/UpstreamTaggerHit.h b/UpstreamTagger/UpstreamTaggerHit.h index eb57679252..c956e1e84e 100644 --- a/UpstreamTagger/UpstreamTaggerHit.h +++ b/UpstreamTagger/UpstreamTaggerHit.h @@ -52,10 +52,11 @@ class UpstreamTaggerHit : public SHiP::DetectorHit { void Print() const; private: - Double_t fX; ///< Smeared x position (cm) - Double_t fY; ///< Smeared y position (cm) - Double_t fZ; ///< Smeared z position (cm) - Double_t fTime; ///< Smeared time (ns) + Double_t fX; ///< Smeared x position (cm) + Double_t fY; ///< Smeared y position (cm) + Double_t fZ; ///< Smeared z position (cm) + Double_t fTime; ///< Smeared time (ns) + Int_t fSubDetID; ///< Which layer of the UBT is this ClassDefOverride(UpstreamTaggerHit, 2); }; diff --git a/geometry/media.geo b/geometry/media.geo index 4ddd5cf93f..cb7e8c81ef 100644 --- a/geometry/media.geo +++ b/geometry/media.geo @@ -2202,6 +2202,11 @@ tungstensifon 1 183.84 74. 19.2 0 1 20. .001 0 +// Tunsten-Rhenium 75/25 wire +WReWire 2 183.84 186.207 74. 75. 19.3 0.97 0.03 + 0 1 20. 0.001 + 0 + tantalum 1 180.95 73. 16.7 0 1 20. .001 0 @@ -2280,6 +2285,10 @@ GEMmixture 3 39.948 12.01 15.9994 18. 6. 8. 0.001843 0.7 0.1 0.2 MDTMixture 3 39.948 12.01 15.9994 18. 6. 8. 0.001843 0.476 0.143 0.381 1 1 20. 0.001 0 +// Argon Ethane (50/50) +UBTMixture 3 39.948 12.011 1.008 18. 6. 1. 0.00146 0.5706 0.3431 0.0864 + 0 1 20. 0.001 + 0 // Si:0:H=1:6:8 for aerogel in RICH, density 0.1 g/cm3, everything like in HERMES Aerogel 3 28.086 15.9994 1.00797 14. 8. 1. 0.1 0.21 0.73 0.06 diff --git a/geometry/ubt_config.yaml b/geometry/ubt_config.yaml new file mode 100644 index 0000000000..4d62f59acd --- /dev/null +++ b/geometry/ubt_config.yaml @@ -0,0 +1,13 @@ +# Geometry configuration of UBT (veto) in FairShip +UBT: + width: 50 # Aperture width (x) in cm (half length) + height: 150 # Aperture height (y) in cm (half length) + wire_thickness: 0.0025 # Sense wire thickness in cm + wall_thickness: 0.0015 # Straw wall thickness in cm + outer_straw_diameter: 0.5 # in cm + straw_pitch: 0.6 # Distance (y) between straws in a layer in cm + y_layer_offset: 0.25 # Offset (y) of straws between layers in cm + delta_z_layer: 0.433 # Distance (z = sqrt(3)/2 * D) between layers in cm + delta_z_view: 6 # Distance (z) between stereo views in cm + view_angle: 15 # Stereo angle in degree + station_length: 32 # (z = outer_straw_diameter + delta_z_layer + delta_z_view + space for plastic) in cm (half length) diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 501e3dc3bf..6fd779461d 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -346,6 +346,8 @@ # Configure FairLogger verbosity based on debug level ROOT.gInterpreter.ProcessLine('#include "FairLogger.h"') +ROOT.gInterpreter.ProcessLine('fair::Logger::SetFileSeverity("fatal");') +ROOT.gInterpreter.ProcessLine('fair::Logger::SetVerbosity("verylow");') if options.debug == 0: ROOT.gInterpreter.ProcessLine('fair::Logger::SetConsoleSeverity("info");') elif options.debug == 1: @@ -732,8 +734,11 @@ # fieldMaker.plotField(1, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-300.0, 300.0, 6.0), 'Bzx.png') # fieldMaker.plotField(2, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-400.0, 400.0, 6.0), 'Bzy.png') +print("about to run: ", options.nEvents) + # -----Start run---------------------------------------------------- run.Run(options.nEvents) +print("all sorted") # -----Runtime database--------------------------------------------- kParameterMerged = ROOT.kTRUE parOut = ROOT.FairParRootFileIo(kParameterMerged) @@ -750,6 +755,8 @@ saveBasicParameters.execute(geofile_name, ship_geo) +ROOT.gErrorIgnoreLevel = ROOT.kFatal + # checking for overlaps if options.check_overlaps: ROOT.gROOT.SetWebDisplay("off") # Workaround for https://github.com/root-project/root/issues/18881 diff --git a/python/ShipGeo.py b/python/ShipGeo.py new file mode 100644 index 0000000000..d896ff62f1 --- /dev/null +++ b/python/ShipGeo.py @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration + +import ROOT +import shipunit as u + +fDesign = 2 + + +class ShipGeo: + def __init__(self, z=0): + self.z = z + + +def zPositions(): + main = sys.modules["__main__"] + if hasattr(main, "ShipGeo"): + for x in ShipGeo: + if hasattr(eval("ShipGeo." + x), "z"): + print(x, "z=", eval("ShipGeo." + x + ".z")) + + +# vetoStation = ShipGeo(-2390.*u.cm) +TrackStation1 = ShipGeo(1510.0 * u.cm) +TrackStation2 = ShipGeo(1710.0 * u.cm) +TrackStation3 = ShipGeo(2150.0 * u.cm) +TrackStation4 = ShipGeo(2370.0 * u.cm) + +UBTStation1 = ShipGeo(2390.0 * u.cm) +UBTStation2 = ShipGeo(2395.0 * u.cm) +UBTStation3 = ShipGeo(2400.0 * u.cm) +UBTStation4 = ShipGeo(2405.0 * u.cm) + + +z = TrackStation2.z + 0.5 * (TrackStation3.z - TrackStation2.z) +Bfield = ShipGeo(z) +Bfield.max = 1.5 * u.kilogauss # was 1.15 in EOI + +# target absorber muon shield setup +decayVolume = ShipGeo(0 * u.cm) +decayVolume.length = 50 * u.m + +muShield = ShipGeo(0 * u.cm) +muShield.dZ1 = 2.5 * u.m +muShield.dZ2 = 3.5 * u.m +muShield.dZ3 = 3.0 * u.m +muShield.dZ4 = 3.0 * u.m +muShield.dZ5 = 2.5 * u.m +muShield.dZ6 = 2.5 * u.m +muShield.LE = 5 * u.m +# for passive design, fDesign==1 +if fDesign == 1: + muShield.length = 70 * u.m +# for active design, fDesign==2 +if fDesign == 2: + muShield.length = ( + 2 * (muShield.dZ1 + muShield.dZ2 + muShield.dZ3 + muShield.dZ4 + muShield.dZ5 + muShield.dZ6) + muShield.LE + ) # leave some space for nu-tau detector +muShield.z = -decayVolume.length / 2.0 - muShield.length / 2.0 + +hadronAbsorber = ShipGeo(0 * u.cm) +hadronAbsorber.length = 3.0 * u.m +hadronAbsorber.z = muShield.z - muShield.length / 2.0 - hadronAbsorber.length / 2.0 + +target = ShipGeo(0 * u.cm) +target.length = 50 * u.cm +target.z = hadronAbsorber.z - hadronAbsorber.length / 2.0 - target.length / 2.0 + +# interaction point, start of target +target.z0 = target.z - target.length / 2.0 + +# straws of tracking stations +straw = ShipGeo(0 * u.cm) +straw.length = 250.0 * u.cm +straw.resol = 0.01 * u.cm +straw.pitch = 1.0 * u.cm +straw.stereoAngle = 5.0 / 180.0 * ROOT.TMath.Pi() diff --git a/python/geometry_config.py b/python/geometry_config.py index 71045b6113..c3249ee038 100644 --- a/python/geometry_config.py +++ b/python/geometry_config.py @@ -320,6 +320,8 @@ def create_config( c.Chamber1 = AttrDict(z=z4 - 4666.0 * u.cm - magnetIncrease - extraVesselLength) c.Chamber6 = AttrDict(z=z4 + 30.0 * u.cm + windowBulge / 2.0) + c.UBTStation1 = AttrDict(z=c.decayVolume.z0 - 50 * u.cm) + c.Bfield = AttrDict() c.Bfield.z = c.z c.Bfield.max = 0 # 1.4361*u.kilogauss # was 1.15 in EOI @@ -420,8 +422,13 @@ def create_config( c.UpstreamTagger = AttrDict() c.UpstreamTagger.BoxX = 4.4 * u.m # X dimension (width) c.UpstreamTagger.BoxY = 6.4 * u.m # Y dimension (height) - c.UpstreamTagger.BoxZ = 16.0 * u.cm # Z dimension (thickness) + # <<<<<<< HEAD + c.UpstreamTagger.BoxZ = 2.0 * u.cm # Z dimension (thickness) c.UpstreamTagger.Z_Position = -25.400 * u.m + c.decayVolume.z # Relative position of UBT to decay vessel centre + # ======= + # c.UpstreamTagger.BoxZ = 16.0 * u.cm # Z dimension (thickness) + # c.UpstreamTagger.Z_Position = -25.400 * u.m + c.decayVolume.z # Relative position of UBT to decay vessel centre + # >>>>>>> mymaster c.UpstreamTagger.PositionResolution = 1.0 * u.cm # Position smearing resolution c.UpstreamTagger.TimeResolution = 0.3 # Time resolution in ns diff --git a/python/shipDet_conf.py b/python/shipDet_conf.py index add53602f7..37b4f9d73d 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -262,6 +262,45 @@ def configure_strawtubes(yaml_file: str, ship_geo) -> None: detectorList.append(strawtubes) +def configure_upstreamTagger(yaml_file, ship_geo): + with open(yaml_file) as file: + config = yaml.safe_load(file) + + ship_geo.ubt_geo = AttrDict(config["UBT"]) + + # Straw tubes in decay vessel if vacuum, otherwise outside in air + ship_geo.ubt_geo.medium = "vacuums" if ship_geo.DecayVolumeMedium == "vacuums" else "air" + + ship_geo.ubt_geo.frame_material = "DIRCcarbonFiber" + + ubt = ROOT.UpstreamTagger(ship_geo.ubt_geo.medium) + ubt.SetzPositions( + ship_geo.UBTStation1.z, + ) + ubt.SetApertureArea(ship_geo.ubt_geo.width, ship_geo.ubt_geo.height, ship_geo.ubt_geo.station_length) + ubt.SetStrawDiameter( + ship_geo.ubt_geo.outer_straw_diameter, + ship_geo.ubt_geo.wall_thickness, + ) + ubt.SetStrawPitch( + ship_geo.ubt_geo.straw_pitch, + ship_geo.ubt_geo.y_layer_offset, + ) + ubt.SetDeltazLayer(ship_geo.ubt_geo.delta_z_layer) + ubt.SetStereoAngle(ship_geo.ubt_geo.view_angle) + ubt.SetWireThickness(ship_geo.ubt_geo.wire_thickness) + ubt.SetDeltazView(ship_geo.ubt_geo.delta_z_view) + ubt.SetFrameMaterial(ship_geo.ubt_geo.frame_material) + + # For digitization + # strawtubes.SetStrawResolution( + # ship_geo.strawtubesDigi.v_drift, + # ship_geo.strawtubesDigi.sigma_spatial, + # ) + + detectorList.append(ubt) + + def configure(run, ship_geo): # ---- for backward compatibility ---- if not hasattr(ship_geo, "DecayVolumeMedium"): @@ -422,12 +461,15 @@ def configure(run, ship_geo): SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength) detectorList.append(SplitCal) - upstreamTagger = ROOT.UpstreamTagger("UpstreamTagger", ROOT.kTRUE) - upstreamTagger.SetZposition(ship_geo.UpstreamTagger.Z_Position) - upstreamTagger.SetBoxDimensions( - ship_geo.UpstreamTagger.BoxX, ship_geo.UpstreamTagger.BoxY, ship_geo.UpstreamTagger.BoxZ - ) - detectorList.append(upstreamTagger) + # <<<<<<< HEAD + configure_upstreamTagger(os.path.join(os.environ["FAIRSHIP"], "geometry", "ubt_config.yaml"), ship_geo) + # ======= + # upstreamTagger = ROOT.UpstreamTagger("UpstreamTagger", ROOT.kTRUE) + # upstreamTagger.SetZposition(ship_geo.UpstreamTagger.Z_Position) + # upstreamTagger.SetBoxDimensions( + # ship_geo.UpstreamTagger.BoxX, ship_geo.UpstreamTagger.BoxY, ship_geo.UpstreamTagger.BoxZ + # >>>>>>> mymaster + # ) timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE) timeDet.SetZposition(ship_geo.TimeDet.z) @@ -457,7 +499,7 @@ def configure(run, ship_geo): ) run.SetField(fMagField) - exclusionList = [] + exclusionList = ["TargetStation"] # exclusionList = ["strawtubes","TargetTrackers","NuTauTarget",\ # "SiliconTarget","Veto","Magnet","MuonShield","TargetStation", "TimeDet", "UpstreamTagger"]