From 57abf466ad277dd9edeb1255b6f0ac3c7bc746f1 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Fri, 14 Nov 2025 16:55:25 +0100 Subject: [PATCH 01/53] some messing --- UpstreamTagger/UpstreamTagger.cxx | 531 +++++++++++++++++++++++------- UpstreamTagger/UpstreamTagger.h | 158 ++++----- 2 files changed, 499 insertions(+), 190 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index a7890fbd1f..a81715f5a8 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -1,68 +1,70 @@ -// RPC Timing Detector -// 17/12/2019 -// celso.franco@cern.ch +// Construction of SST tracker stations +// Last update: 15 Aug 2025 +// Contact: W.-C. Marty Lee #include "UpstreamTagger.h" -#include "UpstreamTaggerPoint.h" -#include "UpstreamTaggerHit.h" -#include "FairVolume.h" -#include "FairGeoVolume.h" -#include "FairGeoNode.h" -#include "FairRootManager.h" -#include "FairGeoLoader.h" +#include "FairGeoBuilder.h" #include "FairGeoInterface.h" +#include "FairGeoLoader.h" #include "FairGeoMedia.h" -#include "FairGeoBuilder.h" +#include "FairGeoNode.h" +#include "FairGeoVolume.h" +#include "FairLogger.h" +#include "FairRootManager.h" #include "FairRun.h" #include "FairRuntimeDb.h" +#include "FairVolume.h" #include "ShipDetectorList.h" #include "ShipStack.h" - #include "TClonesArray.h" -#include "TVirtualMC.h" -#include "TGeoManager.h" #include "TGeoBBox.h" #include "TGeoCompositeShape.h" -#include "TGeoTube.h" +#include "TGeoManager.h" #include "TGeoMaterial.h" #include "TGeoMedium.h" +#include "TGeoTube.h" #include "TMath.h" #include "TParticle.h" #include "TVector3.h" +#include "TVirtualMC.h" +#include "UpstreamTaggerPoint.h" -#include #include #include +#include using std::cout; using std::endl; -using ROOT::TSeq; -using ShipUnit::m; -using ShipUnit::cm; - UpstreamTagger::UpstreamTagger() - : FairDetector("UpstreamTagger", kTRUE, kUpstreamTagger), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - // - det_zPos(0), - - // - UpstreamTagger_fulldet(0), - scoringPlaneUBText(0), - // - fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) + : FairDetector("UpstreamTagger", kTRUE, kStraw) + , fTrackID(-1) + , fVolumeID(-1) + , fPos() + , fMom() + , fTime(-1.) + , fLength(-1.) + , fELoss(-1) + , fMedium("air") + , fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) +{} + +UpstreamTagger::UpstreamTagger(std::string medium) + : FairDetector("UpstreamTagger", kTRUE, kStraw) + , fTrackID(-1) + , fVolumeID(-1) + , fPos() + , fMom() + , fTime(-1.) + , fLength(-1.) + , fELoss(-1) + , fMedium(medium) + , fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) { } UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) - : FairDetector(name, active, kUpstreamTagger), + : FairDetector(name, active, kStraw), fTrackID(-1), fVolumeID(-1), fPos(), @@ -70,24 +72,10 @@ UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) fTime(-1.), fLength(-1.), fELoss(-1), - // - det_zPos(0), - - // - UpstreamTagger_fulldet(0), - scoringPlaneUBText(0), // Initialize new scoring plane to nullptr - // fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) { } - -void UpstreamTagger::Initialize() -{ - FairDetector::Initialize(); -} - - UpstreamTagger::~UpstreamTagger() { if (fUpstreamTaggerPointCollection) { @@ -96,11 +84,16 @@ UpstreamTagger::~UpstreamTagger() } } +void UpstreamTagger::Initialize() +{ + FairDetector::Initialize(); +// FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); +// vetoGeoPar* par=(vetoGeoPar*)(rtdb->getContainer("vetoGeoPar")); +} - +// ----- Private method InitMedium Int_t UpstreamTagger::InitMedium(const char* name) { - static FairGeoLoader *geoLoad=FairGeoLoader::Instance(); static FairGeoInterface *geoFace=geoLoad->getGeoInterface(); static FairGeoMedia *media=geoFace->getMedia(); @@ -118,12 +111,8 @@ Int_t UpstreamTagger::InitMedium(const char* name) return ShipMedium->getMediumIndex(); return geoBuild->createMedium(ShipMedium); - - return 0; } - - Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ @@ -135,52 +124,60 @@ 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(); - // Create vetoPoint at exit of active volume + // Create UpstreamTaggerPoint at exit of active volume if ( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) { if (fELoss == 0. ) { return kFALSE; } - - fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); - - Int_t uniqueId; - gMC->CurrentVolID(uniqueId); - if (uniqueId>1000000) //Solid scintillator case - { - Int_t vcpy; - gMC->CurrentVolOffID(1, vcpy); - if (vcpy==5) uniqueId+=4; //Copy of half - } - - TParticle* p = gMC->GetStack()->GetCurrentTrack(); + TParticle* p=gMC->GetStack()->GetCurrentTrack(); Int_t pdgCode = p->GetPdgCode(); + fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); + Int_t straw_uniqueId; + gMC->CurrentVolID(straw_uniqueId); + if (fVolumeID == straw_uniqueId) { + //std::cout << pdgCode<< " same volume again ? "<< straw_uniqueId << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl; + return kTRUE; } + fVolumeID = straw_uniqueId; + // # d = |pq . u x v|/|u x v| + TVector3 bot,top; + StrawEndPoints(straw_uniqueId,bot,top); TLorentzVector Pos; gMC->TrackPosition(Pos); - TLorentzVector Mom; - gMC->TrackMomentum(Mom); Double_t xmean = (fPos.X()+Pos.X())/2. ; Double_t ymean = (fPos.Y()+Pos.Y())/2. ; Double_t zmean = (fPos.Z()+Pos.Z())/2. ; - - AddHit(fTrackID, uniqueId, TVector3(xmean, ymean, zmean), - TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, - fELoss,pdgCode,TVector3(Pos.X(), Pos.Y(), Pos.Z()), - TVector3(Mom.Px(), Mom.Py(), Mom.Pz()) ); - - // Increment number of veto det points in TParticle + TVector3 pq = TVector3(top.x()-xmean,top.y()-ymean,top.z()-zmean ); + TVector3 u = TVector3(bot.x()-top.x(),bot.y()-top.y(),bot.z()-top.z() ); + TVector3 v = TVector3(fPos.X()-Pos.X(),fPos.Y()-Pos.Y(),fPos.Z()-Pos.Z()); + TVector3 uCrossv = u.Cross(v); + Double_t dist2Wire = fabs(pq.Dot(uCrossv))/(uCrossv.Mag()+1E-8); + Double_t deltaTrackLength = gMC->TrackLength() - fLength; + AddHit(fTrackID, straw_uniqueId, TVector3(xmean, ymean, zmean), + TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, deltaTrackLength, + fELoss,pdgCode,dist2Wire); + if (dist2Wire > f_inner_straw_diameter / 2){ + std::cout << "addhit " << dist2Wire<< " straw id " << straw_uniqueId << " pdgcode " << pdgCode<< " dot prod " << pq.Dot(uCrossv)<< std::endl; + std::cout << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl; + std::cout << " entry:" << fPos.X()<< " " << fPos.Y()<< " " << fPos.Z() << std::endl; + std::cout << " exit:" << Pos.X()<< " " << Pos.Y()<< " " << Pos.Z() << std::endl; + std::cout << " mean:" << xmean<< " " << ymean << " " << zmean << std::endl; + std::cout << " bot:" << bot.x()<< " " << bot.y() << " " << bot.z() << std::endl; + std::cout << " top:" << top.x()<< " " << top.y() << " " << top.z() << std::endl; + pq.Print(); + u.Print(); + v.Print(); + uCrossv.Print(); + } + // Increment number of UpstreamTagger det points in TParticle ShipStack* stack = dynamic_cast(gMC->GetStack()); - stack->AddPoint(kUpstreamTagger); + stack->AddPoint(kStraw); } - return kTRUE; } - - void UpstreamTagger::EndOfEvent() { fUpstreamTaggerPointCollection->Clear(); @@ -202,62 +199,364 @@ void UpstreamTagger::Register() } - TClonesArray* UpstreamTagger::GetCollection(Int_t iColl) const { if (iColl == 0) { return fUpstreamTaggerPointCollection; } else { return NULL; } } - - void UpstreamTagger::Reset() { fUpstreamTaggerPointCollection->Clear(); } - - - -void UpstreamTagger::ConstructGeometry() +void UpstreamTagger::SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4) { - TGeoVolume *top = gGeoManager->GetTopVolume(); - - ////////////////////////////////////////////////////// + f_T1_z = z1; //! z-position of tracking station 1 + f_T2_z = z2; //! z-position of tracking station 2 + f_T3_z = z3; //! z-position of tracking station 3 + f_T4_z = z4; //! z-position of tracking station 4 +} - /////////////////////////////////////////////////////// +void UpstreamTagger::SetApertureArea(Double_t width, Double_t height) +{ + f_aperture_width = width; //! Aperture width (x) + f_aperture_height = height; //! Aperture height (y) +} - /////////////////////////////////////////////////////// +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 +} - InitMedium("vacuum"); - TGeoMedium *Vacuum_box =gGeoManager->GetMedium("vacuum"); - /////////////////////////////////////////////////////////////////// +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 +} - // Adding UBT Extension - if (!Vacuum_box) { - Fatal("ConstructGeometry", "Medium 'vacuum' not found."); - } +void UpstreamTagger::SetDeltazLayer(Double_t delta_z_layer) +{ + f_delta_z_layer = delta_z_layer; //! Distance (z) between layers +} - UpstreamTagger_fulldet = gGeoManager->MakeBox("Upstream_Tagger", Vacuum_box, xbox_fulldet/2.0, ybox_fulldet/2.0, zbox_fulldet/2.0); - UpstreamTagger_fulldet->SetLineColor(kGreen); +void UpstreamTagger::SetStereoAngle(Double_t stereo_angle) +{ + f_view_angle = stereo_angle; //! Stereo view angle +} - top->AddNode(UpstreamTagger_fulldet, 1, new TGeoTranslation(0.0, 0.0, det_zPos)); - AddSensitiveVolume(UpstreamTagger_fulldet); - cout << " Z Position (Upstream Tagger1) " << det_zPos << endl; - ////////////////////////////////////////////////////////////////// +void UpstreamTagger::SetWireThickness(Double_t wire_thickness) +{ + f_wire_thickness = wire_thickness; //! Sense wire thickness +} - return; +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::SetStationEnvelope(Double_t x, Double_t y, Double_t z) +{ + f_station_width = x; //! Station envelope width (x) + f_station_height = y; //! Station envelope height (y) + f_station_length = z; //! Station envelope length (z) +} +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. */ + + TGeoVolume *top = gGeoManager->GetTopVolume(); + InitMedium("air"); + TGeoMedium *air = gGeoManager->GetMedium("air"); + InitMedium("ShipSens"); + TGeoMedium *Se = gGeoManager->GetMedium("ShipSens"); + InitMedium("aluminium"); + TGeoMedium *Al = gGeoManager->GetMedium("aluminium"); + InitMedium("mylar"); + TGeoMedium *mylar = gGeoManager->GetMedium("mylar"); + InitMedium("STTmix8020_1bar"); + TGeoMedium *sttmix8020_1bar = gGeoManager->GetMedium("STTmix8020_1bar"); + InitMedium("tungsten"); + TGeoMedium *tungsten = gGeoManager->GetMedium("tungsten"); + InitMedium(f_frame_material); + TGeoMedium *FrameMatPtr = gGeoManager->GetMedium(f_frame_material); + InitMedium(fMedium.c_str()); + TGeoMedium* med = gGeoManager->GetMedium(fMedium.c_str()); + + gGeoManager->SetVisLevel(4); + gGeoManager->SetTopVisible(); + + // Epsilon to avoid overlapping volumes + Double_t eps = 0.0001; + // Straw (half) length + Double_t straw_length = f_aperture_width + 2. * eps; + // Width of frame: standard HEA 500 I-beam width + Double_t frame_width = 49.; + // Offset due to floor space limitation + Double_t floor_offset = 14.; + + Double_t rmin, rmax, T_station_z; + + // Arguments of boxes are half-lengths + TGeoBBox* detbox1 = new TGeoBBox( + "detbox1", f_aperture_width + frame_width, f_aperture_height + frame_width - floor_offset / 2., f_station_length); + TGeoBBox* detbox2 = new TGeoBBox( + "detbox2", + straw_length + eps, + f_aperture_height + TMath::Tan(f_view_angle * TMath::Pi() / 180.0) * straw_length * 2 + f_offset_layer / TMath::Cos(f_view_angle * TMath::Pi() / 180.0) + eps, + f_station_length + eps); + TGeoTranslation* move_up = new TGeoTranslation("move_up", 0, floor_offset / 2., 0); + move_up->RegisterYourself(); + + // Composite shape to create frame + TGeoCompositeShape* detcomp1 = new TGeoCompositeShape("detcomp1", "(detbox1:move_up)-detbox2"); + + // Volume: straw + rmin = f_inner_straw_diameter / 2.; + rmax = f_outer_straw_diameter / 2.; + // Third argument is half-length of tube + TGeoTube *straw_tube = new TGeoTube("straw", rmin, rmax, straw_length); + TGeoVolume *straw = new TGeoVolume("straw", straw_tube, mylar); + straw->SetLineColor(4); + straw->SetVisibility(kTRUE); + + // Volume: gas + rmin = f_wire_thickness / 2. + eps; + rmax = f_inner_straw_diameter / 2. - eps; + TGeoTube *gas_tube = new TGeoTube("gas", rmin, rmax, straw_length - 2. * eps); + TGeoVolume *gas = new TGeoVolume("gas", gas_tube, sttmix8020_1bar); + gas->SetLineColor(5); + // Only the gas is sensitive + AddSensitiveVolume(gas); + + // Volume: wire + rmin = 0.; + rmax = f_wire_thickness / 2.; + TGeoTube *wire_tube = new TGeoTube("wire", rmin, rmax, straw_length - 4. * eps); + TGeoVolume *wire = new TGeoVolume("wire", wire_tube, tungsten); + wire->SetLineColor(6); + + // Tracking stations + // statnb = station number; vnb = view number; lnb = layer number; snb = straw number + + // Station box to contain all components + TGeoBBox* statbox = new TGeoBBox("statbox", f_station_width, f_station_height - floor_offset / 2., f_station_length); + + f_frame_material.ToLower(); + + for (Int_t statnb = 1; statnb < 5; statnb++) { + // Tracking station loop + TString nmstation = "Tr"; + std::stringstream ss; + ss << statnb; + nmstation = nmstation + ss.str(); + switch (statnb) { + case 1: + T_station_z = f_T1_z; + break; + case 2: + T_station_z = f_T2_z; + break; + case 3: + T_station_z = f_T3_z; + break; + case 4: + T_station_z = f_T4_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(kRed); + + 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::ceil(2 * (f_aperture_height + stereo_growth) / stereo_pitch); + + for (Int_t lnb = 0; lnb < 2; lnb++) { + // Layer loop + TString nmlayer = nmview + "_layer_"; + 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; + for (Int_t snb = 1; snb <= straws_per_layer; snb++) { + // Straw loop + // 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); + // End of straw loop + } + + 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 + } + // End of tracking station loop + } +} +// ----- Public method StrawDecode ------------------------------------------- +// ----- returns station, view, layer, straw number in a tuple ----------------------------------- +std::tuple UpstreamTagger::StrawDecode(Int_t detID) +{ + Int_t statnb, vnb, lnb, snb; + statnb = detID / 1e6; + vnb = (detID - statnb * 1e6) / 1e5; + lnb = (detID - statnb * 1e6 - vnb * 1e5) / 1e4; + snb = detID - statnb * 1e6 - vnb * 1e5 - lnb * 1e4 - 2e3; + + if (statnb < 1 || statnb > 4 || vnb < 0 || vnb > 3 || lnb < 0 || lnb > 1 || snb < 1 || snb > 317) { + LOG(warning) << "Invalid UpstreamTagger detID:"; + LOG(warning) << detID << " -> station: " << statnb << ", view: " << vnb << ", layer: " << lnb + << ", straw: " << snb; + LOG(warning) << "UpstreamTagger detID is 7-digit!"; + return std::make_tuple(0, -1, -1, 0); + } else { + return std::make_tuple(statnb, vnb, lnb, snb); + } +} +// ----- Public method StrawEndPoints ------------------------------------------- +// ----- returns top (left) and bottom (right) coordinates of straw ----------------------------------- +void UpstreamTagger::StrawEndPoints(Int_t fDetectorID, TVector3 &vbot, TVector3 &vtop) +// method to get end points from TGeoNavigator +{ + const auto [statnb, vnb, lnb, snb] = StrawDecode(fDetectorID); + TString stat = "Tr"; stat += statnb; stat += "_"; stat += statnb; + TString view; + switch (vnb) { + case 0: + view = "_y1"; + break; + case 1: + view = "_u"; + break; + case 2: + view = "_v"; + break; + case 3: + view = "_y2"; + break; + default: + view = "_y1"; + } + TGeoNavigator* nav = gGeoManager->GetCurrentNavigator(); + TString prefix = "Tr"; + prefix += statnb; + prefix += view; + prefix += "_"; + TString layer = prefix + "layer_"; + layer += lnb; + layer += "_"; + layer += statnb; + layer += vnb; + layer += lnb; + layer += "0000"; + TString wire = "wire_"; + wire += fDetectorID + 1e3; + TString path = "/"; + path += stat; + path += "/"; + path += layer; + path += "/"; + path += wire; + Bool_t rc = nav->cd(path); + if (!rc) { + LOG(warning) << "UpstreamTagger::StrawDecode, TGeoNavigator failed" << path; + return; + } + TGeoNode* W = nav->GetCurrentNode(); + TGeoTube* S = dynamic_cast(W->GetVolume()->GetShape()); + Double_t top[3] = {0, 0, S->GetDZ()}; + Double_t bot[3] = {0, 0, -S->GetDZ()}; + Double_t Gtop[3], Gbot[3]; + nav->LocalToMaster(top, Gtop); nav->LocalToMaster(bot, Gbot); + vtop.SetXYZ(Gtop[0], Gtop[1], Gtop[2]); + vbot.SetXYZ(Gbot[0], Gbot[1], Gbot[2]); +} UpstreamTaggerPoint* UpstreamTagger::AddHit(Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, - Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode,TVector3 Lpos, TVector3 Lmom) + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss, Int_t pdgCode, Double_t dist2Wire) { TClonesArray& clref = *fUpstreamTaggerPointCollection; Int_t size = clref.GetEntriesFast(); - + //std::cout << "adding hit detid " < StrawDecode(Int_t detID); + static void StrawEndPoints(Int_t detID, TVector3& top, TVector3& bot); +// for the digitizing step + void SetStrawResolution(Double_t a, Double_t b) + { + v_drift = a; + sigma_spatial = b; } + Double_t StrawVdrift() {return v_drift;} + Double_t StrawSigmaSpatial() {return sigma_spatial;} - /** Create the detector geometry */ + /** Create the detector geometry */ void ConstructGeometry(); + + /** This method is an example of how to add your own point - * of type TimeRpcPoint to the clones array + * of type UpstreamTaggerPoint to the clones array */ UpstreamTaggerPoint* AddHit(Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, - Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode,TVector3 Lpos, TVector3 Lmom); + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss, Int_t pdgCode, Double_t dist2Wire); + + /** The following methods can be implemented if you need to make + * any optional action in your detector during the transport. + */ + virtual void CopyClones( TClonesArray* cl1, TClonesArray* cl2 , + Int_t offset) {;} + virtual void SetSpecialPhysicsCuts() {;} virtual void EndOfEvent(); virtual void FinishPrimary() {;} virtual void FinishRun() {;} @@ -94,39 +96,47 @@ class UpstreamTagger: public FairDetector virtual void PreTrack() {;} virtual void BeginEvent() {;} - Double_t module[11][3]; // x,y,z centre positions for each module - // TODO Avoid 1-indexed array! - - /** Track information to be stored until the track leaves the active volume.*/ - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss - - /** 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 + /** Track information to be stored until the track leaves the + active volume. + */ + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! position at entrance + TLorentzVector fMom; //! momentum at entrance + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + Double_t f_T1_z; //! z-position of tracking station 1 + Double_t f_T2_z; //! z-position of tracking station 2 + Double_t f_T3_z; //! z-position of tracking station 3 + Double_t f_T4_z; //! z-position of tracking station 4 + Double_t f_aperture_width; //! Aperture width (x) + Double_t f_aperture_height; //! Aperture height (y) + Double_t f_inner_straw_diameter; //! Inner Straw diameter + Double_t f_outer_straw_diameter; //! Outer Straw diameter + Double_t f_straw_pitch; //! Distance (y) between straws in a layer + Double_t f_offset_layer; //! Offset (y) of straws between layers + Double_t f_delta_z_layer; //! Distance (z) between layers + Double_t f_view_angle; //! Stereo view angle + Double_t f_wire_thickness; //! Sense wire thickness + TString f_frame_material; //! Structure frame material + Double_t f_delta_z_view; //! Distance (z) between stereo views + Double_t f_station_width; //! Station envelope width (x) + Double_t f_station_height; //! Station envelope height (y) + Double_t f_station_length; //! Station envelope length (z) + Double_t v_drift; //! drift velocity + Double_t sigma_spatial; //! spatial resolution + std::string fMedium; //! vacuum box medium /** container for data points */ + TClonesArray* fUpstreamTaggerPointCollection; UpstreamTagger(const UpstreamTagger&); UpstreamTagger& operator=(const UpstreamTagger&); Int_t InitMedium(const char* name); - - - ClassDef(UpstreamTagger,1) + ClassDef(UpstreamTagger, 6) }; -#endif // UPSTREAMTAGGER_UPSTREAMTAGGER_H_ +#endif // UpstreamTagger_UpstreamTagger_H_ From 34493b483dad2cb07d512f752db2da5f8aee9347 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Thu, 25 Dec 2025 00:40:25 +0100 Subject: [PATCH 02/53] alterations --- UpstreamTagger/UpstreamTagger.cxx | 362 ++++++++++++++---------------- UpstreamTagger/UpstreamTagger.h | 165 ++++++++------ macro/run_simScript.py | 17 +- python/ShipGeo.py | 8 +- python/geometry_config.py | 7 +- python/shipDet_conf.py | 69 +++++- 6 files changed, 351 insertions(+), 277 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 7402a29248..850a721399 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -6,68 +6,68 @@ // celso.franco@cern.ch #include "UpstreamTagger.h" +#include "UpstreamTaggerPoint.h" +#include "UpstreamTaggerHit.h" -#include "FairGeoBuilder.h" -#include "FairGeoInterface.h" -#include "FairGeoLoader.h" -#include "FairGeoMedia.h" -#include "FairGeoNode.h" +#include "FairVolume.h" #include "FairGeoVolume.h" -#include "FairLogger.h" +#include "FairGeoNode.h" #include "FairRootManager.h" +#include "FairGeoLoader.h" +#include "FairGeoInterface.h" +#include "FairGeoMedia.h" +#include "FairGeoBuilder.h" #include "FairRun.h" #include "FairRuntimeDb.h" -#include "FairVolume.h" #include "ShipDetectorList.h" #include "ShipStack.h" + #include "TClonesArray.h" +#include "TVirtualMC.h" +#include "TGeoManager.h" #include "TGeoBBox.h" #include "TGeoCompositeShape.h" -#include "TGeoManager.h" +#include "TGeoTube.h" #include "TGeoMaterial.h" #include "TGeoMedium.h" -#include "TGeoTube.h" #include "TMath.h" #include "TParticle.h" #include "TVector3.h" -#include "TVirtualMC.h" -#include "UpstreamTaggerPoint.h" +#include #include #include -#include using std::cout; using std::endl; +using ROOT::TSeq; +using ShipUnit::m; +using ShipUnit::cm; + UpstreamTagger::UpstreamTagger() - : FairDetector("UpstreamTagger", kTRUE, kStraw) - , fTrackID(-1) - , fVolumeID(-1) - , fPos() - , fMom() - , fTime(-1.) - , fLength(-1.) - , fELoss(-1) - , fMedium("air") - , fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) -{} + : FairDetector("UpstreamTagger", kTRUE, kUpstreamTagger), + fTrackID(-1), + fVolumeID(-1), + fPos(), + fMom(), + fTime(-1.), + fLength(-1.), + fELoss(-1), + // + det_zPos(0), -UpstreamTagger::UpstreamTagger(std::string medium) - : FairDetector("UpstreamTagger", kTRUE, kStraw) - , fTrackID(-1) - , fVolumeID(-1) - , fPos() - , fMom() - , fTime(-1.) - , fLength(-1.) - , fELoss(-1) - , fMedium(medium) - , fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) + // + UpstreamTagger_fulldet(0), + scoringPlaneUBText(0), + // + fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) { } -UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) - : FairDetector(name, active, kStraw), +//UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) +UpstreamTagger::UpstreamTagger(std::string medium) + : FairDetector("UpstreamTagger", kTRUE, kUpstreamTagger), + fMedium(medium), fTrackID(-1), fVolumeID(-1), fPos(), @@ -75,28 +75,38 @@ UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) fTime(-1.), fLength(-1.), fELoss(-1), + // + det_zPos(0), + + // + UpstreamTagger_fulldet(0), + scoringPlaneUBText(0), // Initialize new scoring plane to nullptr + // fUpstreamTaggerPointCollection(new TClonesArray("UpstreamTaggerPoint")) { } + +void UpstreamTagger::Initialize() +{ + FairDetector::Initialize(); +} + + UpstreamTagger::~UpstreamTagger() { + std::cout<<"destroyer droid"<Delete(); delete fUpstreamTaggerPointCollection; } } -void UpstreamTagger::Initialize() -{ - FairDetector::Initialize(); -// FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); -// vetoGeoPar* par=(vetoGeoPar*)(rtdb->getContainer("vetoGeoPar")); -} -// ----- Private method InitMedium + Int_t UpstreamTagger::InitMedium(const char* name) { + static FairGeoLoader *geoLoad=FairGeoLoader::Instance(); static FairGeoInterface *geoFace=geoLoad->getGeoInterface(); static FairGeoMedia *media=geoFace->getMedia(); @@ -114,10 +124,15 @@ Int_t UpstreamTagger::InitMedium(const char* name) return ShipMedium->getMediumIndex(); return geoBuild->createMedium(ShipMedium); + + return 0; } + + Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { + std::cout<<"processing a hit"<IsTrackEntering() ) { @@ -127,60 +142,54 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) gMC->TrackPosition(fPos); gMC->TrackMomentum(fMom); } + std::cout<<"gello"<Edep(); + std::cout<<"eLoss: "<IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) { if (fELoss == 0. ) { return kFALSE; } - TParticle* p=gMC->GetStack()->GetCurrentTrack(); - Int_t pdgCode = p->GetPdgCode(); + std::cout<<"going well"<GetStack()->GetCurrentTrackNumber(); - Int_t straw_uniqueId; - gMC->CurrentVolID(straw_uniqueId); - if (fVolumeID == straw_uniqueId) { - //std::cout << pdgCode<< " same volume again ? "<< straw_uniqueId << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl; - return kTRUE; } - fVolumeID = straw_uniqueId; - // # d = |pq . u x v|/|u x v| - TVector3 bot,top; - StrawEndPoints(straw_uniqueId,bot,top); + + Int_t uniqueId; + gMC->CurrentVolID(uniqueId); + if (uniqueId>1000000) //Solid scintillator case + { + Int_t vcpy; + gMC->CurrentVolOffID(1, vcpy); + if (vcpy==5) uniqueId+=4; //Copy of half + } + + TParticle* p = gMC->GetStack()->GetCurrentTrack(); + Int_t pdgCode = p->GetPdgCode(); TLorentzVector Pos; gMC->TrackPosition(Pos); + TLorentzVector Mom; + gMC->TrackMomentum(Mom); Double_t xmean = (fPos.X()+Pos.X())/2. ; Double_t ymean = (fPos.Y()+Pos.Y())/2. ; Double_t zmean = (fPos.Z()+Pos.Z())/2. ; - TVector3 pq = TVector3(top.x()-xmean,top.y()-ymean,top.z()-zmean ); - TVector3 u = TVector3(bot.x()-top.x(),bot.y()-top.y(),bot.z()-top.z() ); - TVector3 v = TVector3(fPos.X()-Pos.X(),fPos.Y()-Pos.Y(),fPos.Z()-Pos.Z()); - TVector3 uCrossv = u.Cross(v); - Double_t dist2Wire = fabs(pq.Dot(uCrossv))/(uCrossv.Mag()+1E-8); - Double_t deltaTrackLength = gMC->TrackLength() - fLength; - AddHit(fTrackID, straw_uniqueId, TVector3(xmean, ymean, zmean), - TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, deltaTrackLength, - fELoss,pdgCode,dist2Wire); - if (dist2Wire > f_inner_straw_diameter / 2){ - std::cout << "addhit " << dist2Wire<< " straw id " << straw_uniqueId << " pdgcode " << pdgCode<< " dot prod " << pq.Dot(uCrossv)<< std::endl; - std::cout << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl; - std::cout << " entry:" << fPos.X()<< " " << fPos.Y()<< " " << fPos.Z() << std::endl; - std::cout << " exit:" << Pos.X()<< " " << Pos.Y()<< " " << Pos.Z() << std::endl; - std::cout << " mean:" << xmean<< " " << ymean << " " << zmean << std::endl; - std::cout << " bot:" << bot.x()<< " " << bot.y() << " " << bot.z() << std::endl; - std::cout << " top:" << top.x()<< " " << top.y() << " " << top.z() << std::endl; - pq.Print(); - u.Print(); - v.Print(); - uCrossv.Print(); - } - // Increment number of UpstreamTagger det points in TParticle + + AddHit(fTrackID, uniqueId, TVector3(xmean, ymean, zmean), + TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, + fELoss,pdgCode,TVector3(Pos.X(), Pos.Y(), Pos.Z()), + TVector3(Mom.Px(), Mom.Py(), Mom.Pz()) ); + + // Increment number of veto det points in TParticle ShipStack* stack = dynamic_cast(gMC->GetStack()); - stack->AddPoint(kStraw); + stack->AddPoint(kUpstreamTagger); } + return kTRUE; } + + void UpstreamTagger::EndOfEvent() { fUpstreamTaggerPointCollection->Clear(); @@ -202,16 +211,21 @@ void UpstreamTagger::Register() } + TClonesArray* UpstreamTagger::GetCollection(Int_t iColl) const { if (iColl == 0) { return fUpstreamTaggerPointCollection; } else { return NULL; } } + + void UpstreamTagger::Reset() { fUpstreamTaggerPointCollection->Clear(); } + + void UpstreamTagger::SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4) { f_T1_z = z1; //! z-position of tracking station 1 @@ -273,10 +287,13 @@ void UpstreamTagger::SetStationEnvelope(Double_t x, Double_t y, Double_t z) void UpstreamTagger::ConstructGeometry() { - /** If you are using the standard ASCII input for the geometry + + /** 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"<GetTopVolume(); InitMedium("air"); TGeoMedium *air = gGeoManager->GetMedium("air"); @@ -299,11 +316,11 @@ void UpstreamTagger::ConstructGeometry() gGeoManager->SetTopVisible(); // Epsilon to avoid overlapping volumes - Double_t eps = 0.0001; + Double_t eps = 0.01; // Straw (half) length Double_t straw_length = f_aperture_width + 2. * eps; // Width of frame: standard HEA 500 I-beam width - Double_t frame_width = 49.; + Double_t frame_width = 49.; // Offset due to floor space limitation Double_t floor_offset = 14.; @@ -311,24 +328,27 @@ void UpstreamTagger::ConstructGeometry() // Arguments of boxes are half-lengths TGeoBBox* detbox1 = new TGeoBBox( - "detbox1", f_aperture_width + frame_width, f_aperture_height + frame_width - floor_offset / 2., f_station_length); + "ubt_detbox1", (f_station_width + frame_width), (f_station_height + frame_width - floor_offset / 2.), f_station_length); TGeoBBox* detbox2 = new TGeoBBox( - "detbox2", - straw_length + eps, - f_aperture_height + TMath::Tan(f_view_angle * TMath::Pi() / 180.0) * straw_length * 2 + f_offset_layer / TMath::Cos(f_view_angle * TMath::Pi() / 180.0) + eps, + "ubt_detbox2", + (straw_length + eps), + (f_station_height + TMath::Tan(f_view_angle * TMath::Pi() / 180.0) * straw_length * 2 + f_offset_layer / TMath::Cos(f_view_angle * TMath::Pi() / 180.0) + eps), f_station_length + eps); + + std::cout<<"frame height: "<RegisterYourself(); // Composite shape to create frame - TGeoCompositeShape* detcomp1 = new TGeoCompositeShape("detcomp1", "(detbox1:move_up)-detbox2"); + TGeoCompositeShape* detcomp1 = new TGeoCompositeShape("ubt_detcomp1", "ubt_detbox1:move_up - ubt_detbox2"); // Volume: straw rmin = f_inner_straw_diameter / 2.; rmax = f_outer_straw_diameter / 2.; // Third argument is half-length of tube - TGeoTube *straw_tube = new TGeoTube("straw", rmin, rmax, straw_length); - TGeoVolume *straw = new TGeoVolume("straw", straw_tube, mylar); + TGeoTube *straw_tube = new TGeoTube("ubt_straw", rmin, rmax, straw_length); + TGeoVolume *straw = new TGeoVolume("ubt_straw", straw_tube, mylar); straw->SetLineColor(4); straw->SetVisibility(kTRUE); @@ -352,13 +372,13 @@ void UpstreamTagger::ConstructGeometry() // statnb = station number; vnb = view number; lnb = layer number; snb = straw number // Station box to contain all components - TGeoBBox* statbox = new TGeoBBox("statbox", f_station_width, f_station_height - floor_offset / 2., f_station_length); + TGeoBBox* statbox = new TGeoBBox("ubt_statbox", 0.01*f_station_width, 0.01*f_station_height - floor_offset / 2., 0.01*f_station_length); f_frame_material.ToLower(); - for (Int_t statnb = 1; statnb < 5; statnb++) { + for (Int_t statnb = 1; statnb < 2; statnb++) { // Tracking station loop - TString nmstation = "Tr"; + TString nmstation = "UBT"; std::stringstream ss; ss << statnb; nmstation = nmstation + ss.str(); @@ -366,15 +386,6 @@ void UpstreamTagger::ConstructGeometry() case 1: T_station_z = f_T1_z; break; - case 2: - T_station_z = f_T2_z; - break; - case 3: - T_station_z = f_T3_z; - break; - case 4: - T_station_z = f_T4_z; - break; default: T_station_z = f_T1_z; } @@ -385,16 +396,16 @@ void UpstreamTagger::ConstructGeometry() TGeoVolume* statframe = new TGeoVolume(nmstation + "_frame", detcomp1, FrameMatPtr); vol->AddNode(statframe, statnb * 1e6, new TGeoTranslation(0, -floor_offset / 2., 0)); - statframe->SetLineColor(kRed); + statframe->SetLineColor(kOrange); 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; + Double_t stereo_growth; + Double_t stereo_pitch; + Double_t offset_layer; + Int_t straws_per_layer; switch (vnb) { case 0: @@ -471,95 +482,66 @@ void UpstreamTagger::ConstructGeometry() } // End of view loop } - // End of tracking station loop + // A layer of plastic scintillator detector + InitMedium("polyvinyltoluene"); + TGeoMedium *Vacuum_box =gGeoManager->GetMedium("polyvinyltoluene"); + UpstreamTagger_plastic = gGeoManager->MakeBox("Upstream_Tagger_Plastic", Vacuum_box, 150, 150, 1); + UpstreamTagger_plastic->SetLineColor(kGreen); + vol->AddNode(UpstreamTagger_plastic, 1, new TGeoTranslation(0.0, 0.0, -50)); + std::cout<<"geometry constructed"<GetTopVolume(); + + ////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////// + + InitMedium("STTmix8020_1bar"); + TGeoMedium *Vacuum_box =gGeoManager->GetMedium("STTmix8020_1bar"); + /////////////////////////////////////////////////////////////////// + + // Adding UBT Extension + if (!Vacuum_box) { + Fatal("ConstructGeometry", "Medium 'vacuum' not found."); + } + + UpstreamTagger_fulldet = gGeoManager->MakeBox("Upstream_Tagger", Vacuum_box, xbox_fulldet/2.0, ybox_fulldet/2.0, zbox_fulldet/2.0); + UpstreamTagger_fulldet->SetLineColor(kGreen); + + UpstreamTagger_fulldet_1 = gGeoManager->MakeBox("Upstream_Tagger_firstLayer", Vacuum_box, xbox_fulldet/2.0, ybox_fulldet/2.0, zbox_fulldet/2.0); + UpstreamTagger_fulldet_1->SetLineColor(kGreen); + UpstreamTagger_fulldet_3 = gGeoManager->MakeBox("Upstream_Tagger_lastLayer", Vacuum_box, xbox_fulldet/2.0, ybox_fulldet/2.0, zbox_fulldet/2.0); + UpstreamTagger_fulldet_3->SetLineColor(kGreen); + + top->AddNode(UpstreamTagger_fulldet, 1, new TGeoTranslation(0.0, 0.0, det_zPos)); + top->AddNode(UpstreamTagger_fulldet_1, 1, new TGeoTranslation(0.0, 0.0, det_zPos-4.*cm)); + top->AddNode(UpstreamTagger_fulldet_3, 1, new TGeoTranslation(0.0, 0.0, det_zPos+4.*cm)); + + AddSensitiveVolume(UpstreamTagger_fulldet); + AddSensitiveVolume(UpstreamTagger_fulldet_1); + AddSensitiveVolume(UpstreamTagger_fulldet_3); + + cout << " Z Position (Upstream Tagger1) " << det_zPos << endl; + ////////////////////////////////////////////////////////////////// + + return; +*/ } -// ----- Public method StrawDecode ------------------------------------------- -// ----- returns station, view, layer, straw number in a tuple ----------------------------------- -std::tuple UpstreamTagger::StrawDecode(Int_t detID) -{ - Int_t statnb, vnb, lnb, snb; - statnb = detID / 1e6; - vnb = (detID - statnb * 1e6) / 1e5; - lnb = (detID - statnb * 1e6 - vnb * 1e5) / 1e4; - snb = detID - statnb * 1e6 - vnb * 1e5 - lnb * 1e4 - 2e3; - - if (statnb < 1 || statnb > 4 || vnb < 0 || vnb > 3 || lnb < 0 || lnb > 1 || snb < 1 || snb > 317) { - LOG(warning) << "Invalid UpstreamTagger detID:"; - LOG(warning) << detID << " -> station: " << statnb << ", view: " << vnb << ", layer: " << lnb - << ", straw: " << snb; - LOG(warning) << "UpstreamTagger detID is 7-digit!"; - return std::make_tuple(0, -1, -1, 0); - } else { - return std::make_tuple(statnb, vnb, lnb, snb); - } -} -// ----- Public method StrawEndPoints ------------------------------------------- -// ----- returns top (left) and bottom (right) coordinates of straw ----------------------------------- -void UpstreamTagger::StrawEndPoints(Int_t fDetectorID, TVector3 &vbot, TVector3 &vtop) -// method to get end points from TGeoNavigator -{ - const auto [statnb, vnb, lnb, snb] = StrawDecode(fDetectorID); - TString stat = "Tr"; stat += statnb; stat += "_"; stat += statnb; - TString view; - switch (vnb) { - case 0: - view = "_y1"; - break; - case 1: - view = "_u"; - break; - case 2: - view = "_v"; - break; - case 3: - view = "_y2"; - break; - default: - view = "_y1"; - } - TGeoNavigator* nav = gGeoManager->GetCurrentNavigator(); - TString prefix = "Tr"; - prefix += statnb; - prefix += view; - prefix += "_"; - TString layer = prefix + "layer_"; - layer += lnb; - layer += "_"; - layer += statnb; - layer += vnb; - layer += lnb; - layer += "0000"; - TString wire = "wire_"; - wire += fDetectorID + 1e3; - TString path = "/"; - path += stat; - path += "/"; - path += layer; - path += "/"; - path += wire; - Bool_t rc = nav->cd(path); - if (!rc) { - LOG(warning) << "UpstreamTagger::StrawDecode, TGeoNavigator failed" << path; - return; - } - TGeoNode* W = nav->GetCurrentNode(); - TGeoTube* S = dynamic_cast(W->GetVolume()->GetShape()); - Double_t top[3] = {0, 0, S->GetDZ()}; - Double_t bot[3] = {0, 0, -S->GetDZ()}; - Double_t Gtop[3], Gbot[3]; - nav->LocalToMaster(top, Gtop); nav->LocalToMaster(bot, Gbot); - vtop.SetXYZ(Gtop[0], Gtop[1], Gtop[2]); - vbot.SetXYZ(Gbot[0], Gbot[1], Gbot[2]); -} + + + UpstreamTaggerPoint* UpstreamTagger::AddHit(Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, - Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode, Double_t dist2Wire) + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss, Int_t pdgCode,TVector3 Lpos, TVector3 Lmom) { TClonesArray& clref = *fUpstreamTaggerPointCollection; Int_t size = clref.GetEntriesFast(); - //std::cout << "adding hit detid " < StrawDecode(Int_t detID); static void StrawEndPoints(Int_t detID, TVector3& top, TVector3& bot); -// for the digitizing step - void SetStrawResolution(Double_t a, Double_t b) - { - v_drift = a; - sigma_spatial = b; - } - Double_t StrawVdrift() {return v_drift;} - Double_t StrawSigmaSpatial() {return sigma_spatial;} - /** Create the detector geometry */ + /** Create the detector geometry */ void ConstructGeometry(); - - /** This method is an example of how to add your own point - * of type UpstreamTaggerPoint to the clones array + * of type TimeRpcPoint to the clones array */ UpstreamTaggerPoint* AddHit(Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, - Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode, Double_t dist2Wire); + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss, Int_t pdgCode,TVector3 Lpos, TVector3 Lmom); - /** The following methods can be implemented if you need to make - * any optional action in your detector during the transport. - */ - - virtual void CopyClones( TClonesArray* cl1, TClonesArray* cl2 , - Int_t offset) {;} - virtual void SetSpecialPhysicsCuts() {;} virtual void EndOfEvent(); virtual void FinishPrimary() {;} virtual void FinishRun() {;} @@ -99,47 +110,59 @@ class UpstreamTagger: public FairDetector virtual void PreTrack() {;} virtual void BeginEvent() {;} + Double_t module[11][3]; // x,y,z centre positions for each module + // TODO Avoid 1-indexed array! + + /** Track information to be stored until the track leaves the active volume.*/ + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! position at entrance + TLorentzVector fMom; //! momentum at entrance + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + + Double_t f_aperture_width; + Double_t f_aperture_height; + Double_t f_station_length; + Double_t f_station_width; + Double_t f_station_height; + 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,f_T2_z,f_T3_z,f_T4_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: - /** Track information to be stored until the track leaves the - active volume. - */ - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss - Double_t f_T1_z; //! z-position of tracking station 1 - Double_t f_T2_z; //! z-position of tracking station 2 - Double_t f_T3_z; //! z-position of tracking station 3 - Double_t f_T4_z; //! z-position of tracking station 4 - Double_t f_aperture_width; //! Aperture width (x) - Double_t f_aperture_height; //! Aperture height (y) - Double_t f_inner_straw_diameter; //! Inner Straw diameter - Double_t f_outer_straw_diameter; //! Outer Straw diameter - Double_t f_straw_pitch; //! Distance (y) between straws in a layer - Double_t f_offset_layer; //! Offset (y) of straws between layers - Double_t f_delta_z_layer; //! Distance (z) between layers - Double_t f_view_angle; //! Stereo view angle - Double_t f_wire_thickness; //! Sense wire thickness - TString f_frame_material; //! Structure frame material - Double_t f_delta_z_view; //! Distance (z) between stereo views - Double_t f_station_width; //! Station envelope width (x) - Double_t f_station_height; //! Station envelope height (y) - Double_t f_station_length; //! Station envelope length (z) - Double_t v_drift; //! drift velocity - Double_t sigma_spatial; //! spatial resolution - std::string fMedium; //! vacuum box medium - /** container for data points */ + TGeoVolume* UpstreamTagger_plastic; + TGeoVolume* UpstreamTagger_fulldet; // Timing_detector_1 object + TGeoVolume* UpstreamTagger_fulldet_1; // Timing_detector_1 object + TGeoVolume* UpstreamTagger_fulldet_3; // Timing_detector_1 object + TGeoVolume* scoringPlaneUBText; // new scoring plane + /** container for data points */ TClonesArray* fUpstreamTaggerPointCollection; UpstreamTagger(const UpstreamTagger&); UpstreamTagger& operator=(const UpstreamTagger&); Int_t InitMedium(const char* name); - ClassDef(UpstreamTagger, 6) + + + ClassDef(UpstreamTagger,1) }; -#endif // UpstreamTagger_UpstreamTagger_H_ +#endif // UPSTREAMTAGGER_UPSTREAMTAGGER_H_ diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 37ad2c276a..d231a3130f 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -591,17 +591,20 @@ # Plot the field example #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") # -----Start run---------------------------------------------------- run.Run(options.nEvents) +print("RUN OVER: KNACKERED") # -----Runtime database--------------------------------------------- -kParameterMerged = ROOT.kTRUE -parOut = ROOT.FairParRootFileIo(kParameterMerged) -parOut.open(parFile) -rtdb.setOutput(parOut) -rtdb.saveOutput() -rtdb.printParamContexts() +#kParameterMerged = ROOT.kTRUE +#parOut = ROOT.FairParRootFileIo(kParameterMerged) +#parOut.open(parFile) +#rtdb.setOutput(parOut) +#rtdb.saveOutput() +#rtdb.printParamContexts() getattr(rtdb,"print")() + +print("ABOUT TO GEMOFILE") # ------------------------------------------------------------------------ run.CreateGeometryFile(f"{options.outputDir}/geofile_full.{tag}.root") # save ShipGeo dictionary in geofile diff --git a/python/ShipGeo.py b/python/ShipGeo.py index e9d47c3df2..21dc4eb766 100644 --- a/python/ShipGeo.py +++ b/python/ShipGeo.py @@ -14,12 +14,18 @@ def zPositions(): for x in ShipGeo: if hasattr(eval('ShipGeo.'+x),'z'): print(x,'z=',eval('ShipGeo.'+x+'.z')) -vetoStation = ShipGeo(-2390.*u.cm) +#vetoStation = ShipGeo(-2390.*u.cm) TrackStation1 = ShipGeo(1510.*u.cm) TrackStation2 = ShipGeo(1710.*u.cm) TrackStation3 = ShipGeo(2150.*u.cm) TrackStation4 = ShipGeo(2370.*u.cm) +UBTStation1 = ShipGeo(2390.*u.cm) +UBTStation2 = ShipGeo(2395.*u.cm) +UBTStation3 = ShipGeo(2400.*u.cm) +UBTStation4 = ShipGeo(2405.*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 diff --git a/python/geometry_config.py b/python/geometry_config.py index 9b375a11a9..e8b4e61bda 100644 --- a/python/geometry_config.py +++ b/python/geometry_config.py @@ -424,6 +424,11 @@ 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 - 25*u.cm) + c.UBTStation2 = AttrDict(z = c.decayVolume.z0 - 20*u.cm) + c.UBTStation3 = AttrDict(z = c.decayVolume.z0 - 15*u.cm) + c.UBTStation4 = AttrDict(z = c.decayVolume.z0 - 10*u.cm) + c.Bfield = AttrDict() c.Bfield.z = c.z c.Bfield.max = 0 # 1.4361*u.kilogauss # was 1.15 in EOI @@ -537,7 +542,7 @@ 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) + 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 diff --git a/python/shipDet_conf.py b/python/shipDet_conf.py index 160c95d59a..beed6259fd 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -260,6 +260,56 @@ def configure_strawtubes(yaml_file, ship_geo): 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, + ship_geo.UBTStation2.z, + ship_geo.UBTStation3.z, + ship_geo.UBTStation4.z, + ) + ubt.SetApertureArea( + ship_geo.ubt_geo.width, + ship_geo.ubt_geo.height, + ) + 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) + ubt.SetStationEnvelope( + ship_geo.ubt_geo.station_width, + ship_geo.ubt_geo.station_height, + ship_geo.ubt_geo.station_length, + ) + + + #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 ---- @@ -444,14 +494,19 @@ def configure(run, ship_geo): Muon.SetFilterThickness(ship_geo.Muon.FilterThickness) detectorList.append(Muon) - 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 +# 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) + + configure_upstreamTagger( + os.path.join(os.environ["FAIRSHIP"], "geometry", "ubt_config.yaml"), + ship_geo, ) - detectorList.append(upstreamTagger) timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE) timeDet.SetZposition(ship_geo.TimeDet.z) From 26af83910994d5c349c578ee3ba5daacd55b63ef Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Tue, 20 Jan 2026 14:15:08 +0100 Subject: [PATCH 03/53] UBT stuff --- python/geometry_config.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/geometry_config.py b/python/geometry_config.py index e8b4e61bda..1bee6de57a 100644 --- a/python/geometry_config.py +++ b/python/geometry_config.py @@ -424,10 +424,7 @@ 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 - 25*u.cm) - c.UBTStation2 = AttrDict(z = c.decayVolume.z0 - 20*u.cm) - c.UBTStation3 = AttrDict(z = c.decayVolume.z0 - 15*u.cm) - c.UBTStation4 = AttrDict(z = c.decayVolume.z0 - 10*u.cm) + c.UBTStation1 = AttrDict(z = c.decayVolume.z0 - 50*u.cm) c.Bfield = AttrDict() c.Bfield.z = c.z From 24e73f947d771156a60c42446e49006789103fcc Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Tue, 20 Jan 2026 14:18:59 +0100 Subject: [PATCH 04/53] UBT stuff --- geometry/ubt_config.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 geometry/ubt_config.yaml diff --git a/geometry/ubt_config.yaml b/geometry/ubt_config.yaml new file mode 100644 index 0000000000..e6e8d2d3cb --- /dev/null +++ b/geometry/ubt_config.yaml @@ -0,0 +1,14 @@ +# Geometry configuration of UBT (veto) in FairShip + +UBT: + width: 150 # Aperture width (x) in cm (half length) + height: 150 # Aperture height (y) in cm (half length) + wire_thickness: 0.003 # Sense wire thickness in cm + wall_thickness: 0.0036 # Straw wall thickness in cm + outer_straw_diameter: 2 # in cm + straw_pitch: 2 # Distance (y) between straws in a layer in cm + y_layer_offset: 1 # Offset (y) of straws between layers in cm + delta_z_layer: 1.732 # Distance (z) between layers in cm + delta_z_view: 12 # Distance (z) between stereo views in cm + view_angle: 4.57 # Stereo angle in degree + station_length: 40 # (z) in cm (half length) From aeaa050d7022e7fed514e3470ed36bb1feb29890 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 21 Jan 2026 11:31:32 +0100 Subject: [PATCH 05/53] UBT stuff --- UpstreamTagger/UpstreamTagger.cxx | 36 ++++++++++++++++++++++++-- UpstreamTagger/UpstreamTagger.h | 2 +- UpstreamTagger/UpstreamTaggerPoint.cxx | 2 ++ UpstreamTagger/UpstreamTaggerPoint.h | 3 ++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index c1f127bf26..d26112b35c 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -43,6 +43,36 @@ 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() : FairDetector("UpstreamTagger", kTRUE, kUpstreamTagger), fTrackID(-1), @@ -141,6 +171,7 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) gMC->CurrentVolID(uniqueId); const char* volName = gMC->CurrentVolName(); std::cout<<"volume id: "< 1000000) // Solid scintillator case { Int_t vcpy; @@ -158,7 +189,7 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) Double_t ymean = (fPos.Y() + Pos.Y()) / 2.; Double_t zmean = (fPos.Z() + Pos.Z()) / 2.; - AddHit(fTrackID, uniqueId, TVector3(xmean, ymean, zmean), + AddHit(fTrackID, uniqueId, subDetID, TVector3(xmean, ymean, zmean), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss, pdgCode, TVector3(Pos.X(), Pos.Y(), Pos.Z()), TVector3(Mom.Px(), Mom.Py(), Mom.Pz())); @@ -448,11 +479,12 @@ void UpstreamTagger::ConstructGeometry() } UpstreamTaggerPoint* UpstreamTagger::AddHit(Int_t trackID, Int_t detID, + Int_t subDetID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode, TVector3 Lpos, TVector3 Lmom) { - fUpstreamTaggerPoints->emplace_back(trackID, detID, pos, mom, time, length, + fUpstreamTaggerPoints->emplace_back(trackID, detID, subDetID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom); return &(fUpstreamTaggerPoints->back()); } diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index 7e86a882ba..b655e22815 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -101,7 +101,7 @@ class UpstreamTagger : public FairDetector, public ISTLPointContainer { /** This method is an example of how to add your own point * of type TimeRpcPoint to the clones array */ - UpstreamTaggerPoint* AddHit(Int_t trackID, Int_t detID, TVector3 pos, + UpstreamTaggerPoint* AddHit(Int_t trackID, Int_t detID, Int_t subDetID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode, TVector3 Lpos, TVector3 Lmom); diff --git a/UpstreamTagger/UpstreamTaggerPoint.cxx b/UpstreamTagger/UpstreamTaggerPoint.cxx index d413f6dd2b..de2caff7d4 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.cxx +++ b/UpstreamTagger/UpstreamTaggerPoint.cxx @@ -14,12 +14,14 @@ UpstreamTaggerPoint::UpstreamTaggerPoint() : FairMCPoint() {} // ----- Standard constructor ------------------------------------------ UpstreamTaggerPoint::UpstreamTaggerPoint(Int_t trackID, Int_t detID, + Int_t subDetID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Int_t pdgcode, TVector3 Lpos, TVector3 Lmom) : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss), fPdgCode(pdgcode), + fSubDetID(subDetID), fLpos{Lpos.X(), Lpos.Y(), Lpos.Z()}, fLmom{Lmom.X(), Lmom.Y(), Lmom.Z()} {} // ------------------------------------------------------------------------- diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index c6ff1f3a75..2a7cdbeb78 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -27,7 +27,7 @@ class UpstreamTaggerPoint : public FairMCPoint { *@param length Track length since creation [cm] *@param eLoss Energy deposit [GeV] **/ - UpstreamTaggerPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, + UpstreamTaggerPoint(Int_t trackID, Int_t detID, Int_t subDetID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Int_t pdgCode, TVector3 Lpos, TVector3 Lmom); @@ -47,6 +47,7 @@ class UpstreamTaggerPoint : public FairMCPoint { private: Int_t fPdgCode; + Int_t fSubDetID; std::array fLpos, fLmom; ClassDef(UpstreamTaggerPoint, 3) From f0cef424b72e4aa9d656fd527a54dd2420fc34e6 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 21 Jan 2026 16:21:58 +0100 Subject: [PATCH 06/53] ubt stuff --- UpstreamTagger/UpstreamTaggerHit.cxx | 2 ++ UpstreamTagger/UpstreamTaggerHit.h | 1 + UpstreamTagger/UpstreamTaggerPoint.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/UpstreamTagger/UpstreamTaggerHit.cxx b/UpstreamTagger/UpstreamTaggerHit.cxx index 01d788fbf4..09a9e564c1 100644 --- a/UpstreamTagger/UpstreamTaggerHit.cxx +++ b/UpstreamTagger/UpstreamTaggerHit.cxx @@ -29,6 +29,8 @@ UpstreamTaggerHit::UpstreamTaggerHit(UpstreamTaggerPoint* p, Double_t t0, // Smear time with Gaussian resolution fTime = gRandom->Gaus(p->GetTime() + t0, time_res); + + fSubDetID = p->GetLayerID(); } // ----- Destructor ------------------------- diff --git a/UpstreamTagger/UpstreamTaggerHit.h b/UpstreamTagger/UpstreamTaggerHit.h index f9bce7a2d6..258f697785 100644 --- a/UpstreamTagger/UpstreamTaggerHit.h +++ b/UpstreamTagger/UpstreamTaggerHit.h @@ -56,6 +56,7 @@ class UpstreamTaggerHit : public ShipHit { 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 ClassDef(UpstreamTaggerHit, 2); }; diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index 2a7cdbeb78..39367b78d6 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -44,6 +44,8 @@ class UpstreamTaggerPoint : public FairMCPoint { Int_t PdgCode() const { return fPdgCode; } TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } + Int_t GetLayerID() const { return fSubDetID; }; + private: Int_t fPdgCode; From ea006b70b0b8a6ba3e3db74a7afccbb8e7d9bb8f Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Tue, 3 Feb 2026 17:57:42 +0100 Subject: [PATCH 07/53] thing --- macro/run_simScript.py | 17 +++++++---------- python/shipDet_conf.py | 25 ------------------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 235abda41a..60e9c4ad5a 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -581,20 +581,17 @@ # Plot the field example #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") + # -----Start run---------------------------------------------------- run.Run(options.nEvents) -print("RUN OVER: KNACKERED") # -----Runtime database--------------------------------------------- -#kParameterMerged = ROOT.kTRUE -#parOut = ROOT.FairParRootFileIo(kParameterMerged) -#parOut.open(parFile) -#rtdb.setOutput(parOut) -#rtdb.saveOutput() -#rtdb.printParamContexts() +kParameterMerged = ROOT.kTRUE +parOut = ROOT.FairParRootFileIo(kParameterMerged) +parOut.open(parFile) +rtdb.setOutput(parOut) +rtdb.saveOutput() +rtdb.printParamContexts() getattr(rtdb,"print")() - -print("ABOUT TO GEMOFILE") # ------------------------------------------------------------------------ geofile_name = f"{options.outputDir}/geo_{run_identifier}.root" run.CreateGeometryFile(geofile_name) diff --git a/python/shipDet_conf.py b/python/shipDet_conf.py index 811d8b10af..6fbdaee834 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -471,31 +471,6 @@ def configure(run, ship_geo): SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength) detectorList.append(SplitCal) - Muon = ROOT.muon("Muon", ROOT.kTRUE) - Muon.SetZStationPositions( - ship_geo.MuonStation0.z, - ship_geo.MuonStation1.z, - ship_geo.MuonStation2.z, - ship_geo.MuonStation3.z, - ) - Muon.SetZFilterPositions( - ship_geo.MuonFilter0.z, ship_geo.MuonFilter1.z, ship_geo.MuonFilter2.z - ) - Muon.SetXMax(ship_geo.Muon.XMax) - Muon.SetYMax(ship_geo.Muon.YMax) - Muon.SetActiveThickness(ship_geo.Muon.ActiveThickness) - Muon.SetFilterThickness(ship_geo.Muon.FilterThickness) - detectorList.append(Muon) - -# 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) - configure_upstreamTagger( os.path.join(os.environ["FAIRSHIP"], "geometry", "ubt_config.yaml"), ship_geo, From 9eee80a1635f3fa8d4d21d563f6ca38706b5f862 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 4 Feb 2026 17:09:44 +0100 Subject: [PATCH 08/53] fix test --- tests/test_rntuple_io.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_rntuple_io.cxx b/tests/test_rntuple_io.cxx index 82852c8b17..aa580161d7 100644 --- a/tests/test_rntuple_io.cxx +++ b/tests/test_rntuple_io.cxx @@ -349,9 +349,9 @@ int main(int argc, char** argv) { TVector3 mom(0.1, 0.2, 0.3); TVector3 lpos(1.1, 2.1, 3.1); TVector3 lmom(0.11, 0.21, 0.31); - objects.emplace_back(1, 1001, pos, mom, 123.45, 234.56, 0.001, 2212, lpos, + objects.emplace_back(1, 1001, 1, pos, mom, 123.45, 234.56, 0.001, 2212, lpos, lmom); - objects.emplace_back(2, 2002, pos, mom, 345.67, 456.78, 0.002, 211, lpos, + objects.emplace_back(2, 2002, 1, pos, mom, 345.67, 456.78, 0.002, 211, lpos, lmom); total++; if (test_rntuple_io("UpstreamTaggerPoint", objects)) passed++; From dca7376b9b3f6c1e69193866743b370fa487f84c Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Fri, 6 Feb 2026 15:42:05 +0100 Subject: [PATCH 09/53] add TChain to input files --- shipgen/MuonBackGenerator.cxx | 105 +++++++++++++++++++++++++++++++++- shipgen/MuonBackGenerator.h | 3 + 2 files changed, 106 insertions(+), 2 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index 25988d0844..c22682726d 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -21,6 +21,7 @@ #include "TRandom.h" #include "TSystem.h" #include "TVector.h" +#include "TChain.h" #include "vetoPoint.h" using ShipUnit::cm; @@ -38,6 +39,106 @@ MuonBackGenerator::MuonBackGenerator() Bool_t MuonBackGenerator::Init(const char* fileName) { return Init(fileName, 0); } + +Bool_t MuonBackGenerator::Init(std::vector fileNames){ + return Init(fileNames, 0); +} + +Bool_t MuonBackGenerator::Init(std::vector fileNames, const int firstEvent){ + LOG(info) << "Opening input file " << fileNames.at(0); + TFile testFile(fileNames.at(0)); + auto testKeys = testFile.GetListOfKeys(); +// if (testFile == NULL) { +// LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); +// } + fn = firstEvent; + fPaintBeam = 5 * cm; // default value for painting beam + fSameSeed = 0; + fPhiRandomize = false; // default value for phi randomization + fsmearBeam = 8 * mm; // default value for smearing beam + fdownScaleDiMuon = kFALSE; // only needed for muflux simulation + if (testKeys->FindObject("pythia8-Geant4")) { + fTree = new TChain("pythia8-Geant4"); + for(auto &f : fileNames){ + LOG(info) << "Opening input file " << f; + static_cast(fTree)->Add(f); + } + fNevents = fTree->GetEntries(); + LOG(info) << "Reading "<SetBranchAddress("id", &id); // particle id + fTree->SetBranchAddress("parentid", + &parentid); // parent id, could be different + fTree->SetBranchAddress("pythiaid", + &pythiaid); // pythiaid original particle + fTree->SetBranchAddress("ecut", &ecut); // energy cut used in simulation + fTree->SetBranchAddress("w", &w); // weight of event + // check if ntuple has information of momentum at origin + if (fTree->GetListOfLeaves()->GetSize() < 17) { + fTree->SetBranchAddress( + "x", &vx); // position with respect to startOfTarget at -89.27m + fTree->SetBranchAddress("y", &vy); + fTree->SetBranchAddress("z", &vz); + fTree->SetBranchAddress("px", &px); // momentum + fTree->SetBranchAddress("py", &py); + fTree->SetBranchAddress("pz", &pz); + } else { + fTree->SetBranchAddress( + "ox", &vx); // position with respect to startOfTarget at -50m + fTree->SetBranchAddress("oy", &vy); + fTree->SetBranchAddress("oz", &vz); + fTree->SetBranchAddress("opx", &px); // momentum + fTree->SetBranchAddress("opy", &py); + fTree->SetBranchAddress("opz", &pz); + } + } else { + id = -1; +// fTree = fInputFile->Get("cbmsim"); + fTree = new TChain("cbmsim"); + for(auto &f : fileNames){ + LOG(info) << "Opening input file " << f; + static_cast(fTree)->Add(f); + } + fNevents = fTree->GetEntries(); + LOG(info) << "Reading "<GetBranch("MCTrack"); + if (!mcBranch) { + LOG(fatal) << "MCTrack branch not found in input file"; + } + + if (fTree->GetBranch("PlaneHAPoint")) { + // New STL format + fUseSTL = true; + MCTrack_vec = nullptr; + vetoPoints_vec = nullptr; + auto mcStatus = fTree->SetBranchAddress("MCTrack", &MCTrack_vec); + auto vetoStatus = + fTree->SetBranchAddress("PlaneHAPoint", &vetoPoints_vec); + if (mcStatus < 0 || vetoStatus < 0) { + LOG(fatal) << "Failed to set branch addresses for STL vector format"; + } + LOG(info) << "Using STL vector format (PlaneHAPoint)"; + } else if (fTree->GetBranch("vetoPoint")) { + // Old TClonesArray format + fUseSTL = false; + MCTrack = new TClonesArray("ShipMCTrack"); + vetoPoints = new TClonesArray("vetoPoint"); + auto mcStatus = fTree->SetBranchAddress("MCTrack", &MCTrack); + auto vetoStatus = fTree->SetBranchAddress("vetoPoint", &vetoPoints); + if (mcStatus < 0 || vetoStatus < 0) { + LOG(fatal) << "Failed to set branch addresses for TClonesArray format"; + } + LOG(info) << "Using TClonesArray format (vetoPoint)"; + } else { + LOG(fatal) + << "Neither PlaneHAPoint nor vetoPoint branch found in input file"; + } + } + return kTRUE; +} + // ----- Default constructor ------------------------------------------- Bool_t MuonBackGenerator::Init(const char* fileName, const int firstEvent) { LOG(info) << "Opening input file " << fileName; @@ -228,8 +329,8 @@ Bool_t MuonBackGenerator::ReadEvent(FairPrimaryGenerator* cpg) { } } } - if (fn > fNevents - 1) { - LOGF(info, "End of file reached %i", fNevents); + if (fn == fNevents) { + LOGF(info, "End of tree reached %i", fNevents); return kFALSE; } if (fSameSeed) { diff --git a/shipgen/MuonBackGenerator.h b/shipgen/MuonBackGenerator.h index 169477129c..ca6ba2b5c2 100644 --- a/shipgen/MuonBackGenerator.h +++ b/shipgen/MuonBackGenerator.h @@ -29,6 +29,9 @@ class MuonBackGenerator : public FairGenerator { Bool_t ReadEvent(FairPrimaryGenerator*); virtual Bool_t Init(const char*, int); //! virtual Bool_t Init(const char*); //! + virtual Bool_t Init(std::vector, int); //! + virtual Bool_t Init(std::vector); //! + Int_t GetNevents(); //! void CloseFile(); //! void FollowAllParticles() { followMuons = false; }; From 29dc09061035e8851bf3dc4f86a550fb15e318c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:43:22 +0000 Subject: [PATCH 10/53] style: pre-commit fixes --- shipgen/MuonBackGenerator.cxx | 33 +++++++++++++++++---------------- shipgen/MuonBackGenerator.h | 8 ++++---- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index c22682726d..4201c0835c 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -13,6 +13,7 @@ #include "FairPrimaryGenerator.h" #include "ShipMCTrack.h" #include "ShipUnit.h" +#include "TChain.h" #include "TDatabasePDG.h" // for TDatabasePDG #include "TFile.h" #include "TMCProcess.h" @@ -21,7 +22,6 @@ #include "TRandom.h" #include "TSystem.h" #include "TVector.h" -#include "TChain.h" #include "vetoPoint.h" using ShipUnit::cm; @@ -40,17 +40,18 @@ Bool_t MuonBackGenerator::Init(const char* fileName) { return Init(fileName, 0); } -Bool_t MuonBackGenerator::Init(std::vector fileNames){ - return Init(fileNames, 0); +Bool_t MuonBackGenerator::Init(std::vector fileNames) { + return Init(fileNames, 0); } -Bool_t MuonBackGenerator::Init(std::vector fileNames, const int firstEvent){ +Bool_t MuonBackGenerator::Init(std::vector fileNames, + const int firstEvent) { LOG(info) << "Opening input file " << fileNames.at(0); TFile testFile(fileNames.at(0)); auto testKeys = testFile.GetListOfKeys(); -// if (testFile == NULL) { -// LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); -// } + // if (testFile == NULL) { + // LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); + // } fn = firstEvent; fPaintBeam = 5 * cm; // default value for painting beam fSameSeed = 0; @@ -59,12 +60,12 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames, const int fir fdownScaleDiMuon = kFALSE; // only needed for muflux simulation if (testKeys->FindObject("pythia8-Geant4")) { fTree = new TChain("pythia8-Geant4"); - for(auto &f : fileNames){ - LOG(info) << "Opening input file " << f; - static_cast(fTree)->Add(f); + for (auto& f : fileNames) { + LOG(info) << "Opening input file " << f; + static_cast(fTree)->Add(f); } fNevents = fTree->GetEntries(); - LOG(info) << "Reading "<SetBranchAddress("id", &id); // particle id fTree->SetBranchAddress("parentid", @@ -93,14 +94,14 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames, const int fir } } else { id = -1; -// fTree = fInputFile->Get("cbmsim"); + // fTree = fInputFile->Get("cbmsim"); fTree = new TChain("cbmsim"); - for(auto &f : fileNames){ - LOG(info) << "Opening input file " << f; - static_cast(fTree)->Add(f); + for (auto& f : fileNames) { + LOG(info) << "Opening input file " << f; + static_cast(fTree)->Add(f); } fNevents = fTree->GetEntries(); - LOG(info) << "Reading "<GetBranch("MCTrack"); diff --git a/shipgen/MuonBackGenerator.h b/shipgen/MuonBackGenerator.h index ca6ba2b5c2..f3a297804f 100644 --- a/shipgen/MuonBackGenerator.h +++ b/shipgen/MuonBackGenerator.h @@ -27,13 +27,13 @@ class MuonBackGenerator : public FairGenerator { /** public method ReadEvent **/ Bool_t ReadEvent(FairPrimaryGenerator*); - virtual Bool_t Init(const char*, int); //! - virtual Bool_t Init(const char*); //! + virtual Bool_t Init(const char*, int); //! + virtual Bool_t Init(const char*); //! virtual Bool_t Init(std::vector, int); //! virtual Bool_t Init(std::vector); //! - Int_t GetNevents(); //! - void CloseFile(); //! + Int_t GetNevents(); //! + void CloseFile(); //! void FollowAllParticles() { followMuons = false; }; void SetSmearBeam(Double_t sb) { fsmearBeam = sb; }; void SetPaintRadius(Double_t r) { fPaintBeam = r; }; From e767590644309475cb40adfb7f724f03996b25f7 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Fri, 6 Feb 2026 16:02:25 +0100 Subject: [PATCH 11/53] check for file --- shipgen/MuonBackGenerator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index c22682726d..619a4fa39c 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -45,12 +45,12 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames){ } Bool_t MuonBackGenerator::Init(std::vector fileNames, const int firstEvent){ - LOG(info) << "Opening input file " << fileNames.at(0); + LOG(info) << "Looking for keys in file " << fileNames.at(0); TFile testFile(fileNames.at(0)); auto testKeys = testFile.GetListOfKeys(); -// if (testFile == NULL) { -// LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); -// } + if (testFile == nullptr) { + LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); + } fn = firstEvent; fPaintBeam = 5 * cm; // default value for painting beam fSameSeed = 0; From a491cd5a4a453946ec2af3a876466231892f8afe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:28:38 +0000 Subject: [PATCH 12/53] style: pre-commit fixes --- shipgen/MuonBackGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index fcd27ee514..3be00fbaea 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -50,7 +50,7 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames, TFile testFile(fileNames.at(0)); auto testKeys = testFile.GetListOfKeys(); if (testKeys == nullptr) { - LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); + LOG(fatal) << "Error opening the Signal file: " << fileNames.at(0); } fn = firstEvent; fPaintBeam = 5 * cm; // default value for painting beam From 1611dbc2e26ee3a993a990eb7af1de4a170e0436 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Fri, 6 Feb 2026 17:46:49 +0100 Subject: [PATCH 13/53] remove duplication --- shipgen/MuonBackGenerator.cxx | 83 +---------------------------------- 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index fcd27ee514..d92f0706bc 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -142,87 +142,8 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames, // ----- Default constructor ------------------------------------------- Bool_t MuonBackGenerator::Init(const char* fileName, const int firstEvent) { - LOG(info) << "Opening input file " << fileName; - fInputFile = TFile::Open(fileName); - if (!fInputFile) { - LOG(fatal) << "Error opening the Signal file: " << fileName; - } - fn = firstEvent; - fPaintBeam = 5 * cm; // default value for painting beam - fSameSeed = 0; - fPhiRandomize = false; // default value for phi randomization - fsmearBeam = 8 * mm; // default value for smearing beam - fdownScaleDiMuon = kFALSE; // only needed for muflux simulation - fTree = fInputFile->Get("pythia8-Geant4"); - if (fTree) { - fNevents = fTree->GetEntries(); - // count only events with muons - fTree->SetBranchAddress("id", &id); // particle id - fTree->SetBranchAddress("parentid", - &parentid); // parent id, could be different - fTree->SetBranchAddress("pythiaid", - &pythiaid); // pythiaid original particle - fTree->SetBranchAddress("ecut", &ecut); // energy cut used in simulation - fTree->SetBranchAddress("w", &w); // weight of event - // check if ntuple has information of momentum at origin - if (fTree->GetListOfLeaves()->GetSize() < 17) { - fTree->SetBranchAddress( - "x", &vx); // position with respect to startOfTarget at -89.27m - fTree->SetBranchAddress("y", &vy); - fTree->SetBranchAddress("z", &vz); - fTree->SetBranchAddress("px", &px); // momentum - fTree->SetBranchAddress("py", &py); - fTree->SetBranchAddress("pz", &pz); - } else { - fTree->SetBranchAddress( - "ox", &vx); // position with respect to startOfTarget at -50m - fTree->SetBranchAddress("oy", &vy); - fTree->SetBranchAddress("oz", &vz); - fTree->SetBranchAddress("opx", &px); // momentum - fTree->SetBranchAddress("opy", &py); - fTree->SetBranchAddress("opz", &pz); - } - } else { - id = -1; - fTree = fInputFile->Get("cbmsim"); - fNevents = fTree->GetEntries(); - - // Detect format by checking branch name: - // STL format uses PlaneHAPoint, TClonesArray uses vetoPoint - TBranch* mcBranch = fTree->GetBranch("MCTrack"); - if (!mcBranch) { - LOG(fatal) << "MCTrack branch not found in input file"; - } - - if (fTree->GetBranch("PlaneHAPoint")) { - // New STL format - fUseSTL = true; - MCTrack_vec = nullptr; - vetoPoints_vec = nullptr; - auto mcStatus = fTree->SetBranchAddress("MCTrack", &MCTrack_vec); - auto vetoStatus = - fTree->SetBranchAddress("PlaneHAPoint", &vetoPoints_vec); - if (mcStatus < 0 || vetoStatus < 0) { - LOG(fatal) << "Failed to set branch addresses for STL vector format"; - } - LOG(info) << "Using STL vector format (PlaneHAPoint)"; - } else if (fTree->GetBranch("vetoPoint")) { - // Old TClonesArray format - fUseSTL = false; - MCTrack = new TClonesArray("ShipMCTrack"); - vetoPoints = new TClonesArray("vetoPoint"); - auto mcStatus = fTree->SetBranchAddress("MCTrack", &MCTrack); - auto vetoStatus = fTree->SetBranchAddress("vetoPoint", &vetoPoints); - if (mcStatus < 0 || vetoStatus < 0) { - LOG(fatal) << "Failed to set branch addresses for TClonesArray format"; - } - LOG(info) << "Using TClonesArray format (vetoPoint)"; - } else { - LOG(fatal) - << "Neither PlaneHAPoint nor vetoPoint branch found in input file"; - } - } - return kTRUE; + std::vector fileNames = {fileName}; + return Init(fileNames, firstEvent); } // ----- Destructor ---------------------------------------------------- MuonBackGenerator::~MuonBackGenerator() { From 77dbe1eb88757a0a5efd64c7e9ad2ffaf06b7ad6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:49:35 +0000 Subject: [PATCH 14/53] style: pre-commit fixes --- shipgen/MuonBackGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index fbff27e0dc..e5bde3a878 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -142,8 +142,8 @@ Bool_t MuonBackGenerator::Init(std::vector fileNames, // ----- Default constructor ------------------------------------------- Bool_t MuonBackGenerator::Init(const char* fileName, const int firstEvent) { - std::vector fileNames = {fileName}; - return Init(fileNames, firstEvent); + std::vector fileNames = {fileName}; + return Init(fileNames, firstEvent); } // ----- Destructor ---------------------------------------------------- MuonBackGenerator::~MuonBackGenerator() { From ae86e68dfaaa9cd49008585e291af19ea4496583 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Fri, 6 Feb 2026 18:23:24 +0100 Subject: [PATCH 15/53] add list of files --- python/rootUtils.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/python/rootUtils.py b/python/rootUtils.py index b31bee3210..82a0539d4e 100644 --- a/python/rootUtils.py +++ b/python/rootUtils.py @@ -81,14 +81,30 @@ def errorSummary(): print("Summary of recorded incidents:") for e in _error_log: print(e, ':', _error_log[e]) + def checkFileExists(x): - if x[0:4] == "/eos": f=gSystem.Getenv("EOSSHIP")+x - else: f=x - test = TFile.Open(f) - if not test: - print("input file",f," does not exist. Missing authentication?") - os._exit(1) - if test.FindObjectAny('cbmsim'): - return 'tree' + + if isinstance(x, list): + print("I'm a list") + for _f in x: + if _f[0:4] == "/eos": f=gSystem.Getenv("EOSSHIP")+_f + else: f=_f + test = TFile.Open(f) + if not test: + print("input file",f," does not exist. Missing authentication?") + os._exit(1) + if test.FindObjectAny('cbmsim'): + return 'tree' + else: + return 'ntuple' else: - return 'ntuple' + if x[0:4] == "/eos": f=gSystem.Getenv("EOSSHIP")+x + else: f=x + test = TFile.Open(f) + if not test: + print("input file",f," does not exist. Missing authentication?") + os._exit(1) + if test.FindObjectAny('cbmsim'): + return 'tree' + else: + return 'ntuple' From d64f88879591b8fe71ec7e28108392e613aea8ed Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Mon, 9 Feb 2026 13:23:28 +0100 Subject: [PATCH 16/53] mash run sim scripty --- macro/run_simScript.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 6025dc0e4d..90bbcbeef3 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -125,7 +125,7 @@ parser.add_argument("-i", "--firstEvent", help="First event of input file to use", default=0, type=int) parser.add_argument("-s", "--seed", dest="theSeed", help="Seed for random number. Only for experts, see TRrandom::SetSeed documentation", default=0, type=int) parser.add_argument("-S", "--sameSeed",dest="sameSeed", help="can be set to an integer for the muonBackground simulation with specific seed for each muon, only for experts!", default=False, type=int) -group.add_argument("-f", dest="inputFile", help="Input file if not default file", default=False) +group.add_argument("-f", dest="inputFile", nargs = "*", help="Input file if not default file", default=False) parser.add_argument("-g", dest="geofile", help="geofile for muon shield geometry, for experts only", default=None) parser.add_argument("-o", "--output", dest="outputDir", help="Output directory", default=".") parser.add_argument("-Y", dest="dy", help="max height of vacuum tank", default=6.0, type=float) @@ -487,7 +487,8 @@ testf.Close() if options.sameSeed: MuonBackgen.SetSameSeed(options.sameSeed) primGen.AddGenerator(MuonBackgen) - options.nEvents = min(options.nEvents,MuonBackgen.GetNevents()) + options.nEvents = min(options.nEvents,MuonBackgen.GetNevents())-1 + print("nEvents: ", options.nEvents) MCTracksWithHitsOnly = True # otherwise, output file becomes too big print('Process ', options.nEvents, ' from input file, with 𝜎 = ', options.PaintBeam, ', with smear radius r = ', options.SmearBeam * u.cm, 'with MCTracksWithHitsOnly', MCTracksWithHitsOnly) if options.followMuon : @@ -581,15 +582,18 @@ #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) -parOut.open(parFile) -rtdb.setOutput(parOut) -rtdb.saveOutput() -rtdb.printParamContexts() +#parOut = ROOT.FairParRootFileIo(kParameterMerged) +#parOut.open(parFile) +#rtdb.setOutput(parOut) +#rtdb.saveOutput() +#rtdb.printParamContexts() getattr(rtdb,"print")() # ------------------------------------------------------------------------ geofile_name = f"{options.outputDir}/geo_{run_identifier}.root" @@ -655,11 +659,11 @@ empty = True for containerName in pointContainers: container = getattr(sTree, containerName) - if container.size() > 0: - empty = False - break +# if container.size() > 0: +# empty = False +# break - if not empty: +# if not empty: sTree.Fill() nEvents += 1 From 332b524b71d1590077b00bfa34656cf2dcbb8f5f Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Thu, 19 Feb 2026 12:46:57 +0100 Subject: [PATCH 17/53] adjust --- UpstreamTagger/UpstreamTagger.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index d26112b35c..9e1e38ac6f 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -469,7 +469,7 @@ void UpstreamTagger::ConstructGeometry() // A layer of plastic scintillator detector InitMedium("polyvinyltoluene"); TGeoMedium *Vacuum_box =gGeoManager->GetMedium("polyvinyltoluene"); - UpstreamTagger_plastic = gGeoManager->MakeBox("Upstream_Tagger_Plastic", Vacuum_box, straw_length, f_aperture_width, 1); + 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); From 7772f941953321de8de099d080090d260d48cd8a Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Mon, 2 Mar 2026 19:06:42 +0100 Subject: [PATCH 18/53] my changes --- UpstreamTagger/UpstreamTagger.cxx | 4 +++- geometry/ubt_config.yaml | 2 +- macro/run_simScript.py | 4 ++++ python/shipDet_conf.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 9e1e38ac6f..3a749f1065 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -160,6 +160,8 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) // 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() || @@ -170,7 +172,7 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) Int_t uniqueId; gMC->CurrentVolID(uniqueId); const char* volName = gMC->CurrentVolName(); - std::cout<<"volume id: "< 1000000) // Solid scintillator case { diff --git a/geometry/ubt_config.yaml b/geometry/ubt_config.yaml index e6e8d2d3cb..dfec3c30eb 100644 --- a/geometry/ubt_config.yaml +++ b/geometry/ubt_config.yaml @@ -2,7 +2,7 @@ UBT: width: 150 # Aperture width (x) in cm (half length) - height: 150 # Aperture height (y) in cm (half length) + height: 300 # Aperture height (y) in cm (half length) wire_thickness: 0.003 # Sense wire thickness in cm wall_thickness: 0.0036 # Straw wall thickness in cm outer_straw_diameter: 2 # in cm diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 2722618a2f..19c01c1ce6 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -350,6 +350,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: @@ -750,6 +752,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/shipDet_conf.py b/python/shipDet_conf.py index 2991c07b3a..9c4352b6a2 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -504,7 +504,7 @@ def configure(run, ship_geo): ) run.SetField(fMagField) - exclusionList = [] + exclusionList = ['TargetStation'] # exclusionList = ["strawtubes","TargetTrackers","NuTauTarget",\ # "SiliconTarget","Veto","Magnet","MuonShield","TargetStation", "TimeDet", "UpstreamTagger"] From dedb653ad25df7a82ab5a6a1b864de59848a66d9 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Thu, 5 Mar 2026 11:58:14 +0100 Subject: [PATCH 19/53] thing --- UpstreamTagger/UpstreamTaggerHit.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UpstreamTagger/UpstreamTaggerHit.cxx b/UpstreamTagger/UpstreamTaggerHit.cxx index 09a9e564c1..38b4534ab3 100644 --- a/UpstreamTagger/UpstreamTaggerHit.cxx +++ b/UpstreamTagger/UpstreamTaggerHit.cxx @@ -30,7 +30,7 @@ UpstreamTaggerHit::UpstreamTaggerHit(UpstreamTaggerPoint* p, Double_t t0, // Smear time with Gaussian resolution fTime = gRandom->Gaus(p->GetTime() + t0, time_res); - fSubDetID = p->GetLayerID(); +// fSubDetID = p->GetLayerID(); } // ----- Destructor ------------------------- From 1563667ec4f9e70ca88f37b7036cd2aa33160b66 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 12:03:21 +0000 Subject: [PATCH 20/53] fix: remove detector names --- Detector/DetectorPoint.cxx | 7 +------ Detector/DetectorPoint.h | 3 +-- TimeDet/TimeDetPoint.cxx | 2 -- TimeDet/TimeDetPoint.h | 2 +- UpstreamTagger/UpstreamTaggerPoint.cxx | 4 ---- UpstreamTagger/UpstreamTaggerPoint.h | 5 +++-- splitcal/splitcalPoint.cxx | 2 -- splitcal/splitcalPoint.h | 2 +- strawtubes/strawtubesPoint.cxx | 2 -- strawtubes/strawtubesPoint.h | 2 +- veto/vetoPoint.cxx | 2 -- veto/vetoPoint.h | 2 +- 12 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Detector/DetectorPoint.cxx b/Detector/DetectorPoint.cxx index 75a5b64cf6..7040b757d8 100644 --- a/Detector/DetectorPoint.cxx +++ b/Detector/DetectorPoint.cxx @@ -15,7 +15,6 @@ SHiP::DetectorPoint::DetectorPoint(Int_t eventID, Int_t trackID, Int_t detID, fPdgCode(pdgcode), fLpos{Lpos.X(), Lpos.Y(), Lpos.Z()}, fLmom{Lmom.X(), Lmom.Y(), Lmom.Z()} { - setDetectorName(); } // ----- Standard constructor ---------------- @@ -27,12 +26,11 @@ SHiP::DetectorPoint::DetectorPoint(Int_t eventID, Int_t trackID, Int_t detID, fPdgCode(pdgcode), fLpos{pos.X(), pos.Y(), pos.Z()}, fLmom{mom.X(), mom.Y(), mom.Z()} { - setDetectorName(); } // ----- Public method Print ------------------------------------------- void SHiP::DetectorPoint::Print() const { - LOG(info) << "-I- " << fDetectorName << " point for track " << fTrackID + LOG(info) << "-I- " << DetectorName() << " point for track " << fTrackID << " in detector " << fDetectorID; LOG(info) << " Position (" << fX << ", " << fY << ", " << fZ << ") cm"; LOG(info) << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV"; @@ -42,9 +40,6 @@ void SHiP::DetectorPoint::Print() const { } // ------------------------------------------------------------------------- -void SHiP::DetectorPoint::setDetectorName() { - fDetectorName = "GenericDetector"; -} void SHiP::DetectorPoint::extraPrintInfo() const { LOG(info) << "Nothing to see here"; diff --git a/Detector/DetectorPoint.h b/Detector/DetectorPoint.h index b3e3eb5362..fc8ff2e60d 100644 --- a/Detector/DetectorPoint.h +++ b/Detector/DetectorPoint.h @@ -35,14 +35,13 @@ class DetectorPoint : public FairMCPoint { TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } - virtual void setDetectorName(); + virtual const char* DetectorName() const {return "GenericDetector";}; virtual void extraPrintInfo() const; protected: Int_t fPdgCode; std::array fLpos, fLmom; - std::string fDetectorName = "detector"; private: ClassDef(SHiP::DetectorPoint, 1); diff --git a/TimeDet/TimeDetPoint.cxx b/TimeDet/TimeDetPoint.cxx index 3d965ac473..b9bda353f3 100644 --- a/TimeDet/TimeDetPoint.cxx +++ b/TimeDet/TimeDetPoint.cxx @@ -16,8 +16,6 @@ TimeDetPoint::TimeDetPoint() : SHiP::DetectorPoint() {} TimeDetPoint::~TimeDetPoint() {} // ------------------------------------------------------------------------- -void TimeDetPoint::setDetectorName() { fDetectorName = "TimeDetector"; } - void TimeDetPoint::extraPrintInfo() const { LOG(info) << "This is the time detector"; } diff --git a/TimeDet/TimeDetPoint.h b/TimeDet/TimeDetPoint.h index c1e7d00611..081b169550 100644 --- a/TimeDet/TimeDetPoint.h +++ b/TimeDet/TimeDetPoint.h @@ -21,7 +21,7 @@ class TimeDetPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~TimeDetPoint(); - void setDetectorName() override; + virtual const char* DetectorName() const { return "timeDetector"; } void extraPrintInfo() const override; private: diff --git a/UpstreamTagger/UpstreamTaggerPoint.cxx b/UpstreamTagger/UpstreamTaggerPoint.cxx index 0696a14003..50b24367b8 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.cxx +++ b/UpstreamTagger/UpstreamTaggerPoint.cxx @@ -16,10 +16,6 @@ UpstreamTaggerPoint::UpstreamTaggerPoint() : SHiP::DetectorPoint() {} UpstreamTaggerPoint::~UpstreamTaggerPoint() {} // ------------------------------------------------------------------------- -void UpstreamTaggerPoint::setDetectorName() { - fDetectorName = "UpstreamTagger"; -} - void UpstreamTaggerPoint::extraPrintInfo() const { LOG(info) << "This is the upstream tagger"; } diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index ef2d0c8671..ed19970827 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -22,11 +22,12 @@ class UpstreamTaggerPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~UpstreamTaggerPoint(); - void setDetectorName() override; + virtual const char* DetectorName() const { return "UpstreamTagger"; } + void extraPrintInfo() const override; private: - ClassDefOverride(UpstreamTaggerPoint, 4) + ClassDefOverride(UpstreamTaggerPoint, 5) }; #endif // UPSTREAMTAGGER_UPSTREAMTAGGERPOINT_H_ diff --git a/splitcal/splitcalPoint.cxx b/splitcal/splitcalPoint.cxx index 1e7868a87b..e3f0f334a8 100644 --- a/splitcal/splitcalPoint.cxx +++ b/splitcal/splitcalPoint.cxx @@ -16,8 +16,6 @@ splitcalPoint::splitcalPoint() : DetectorPoint() {} splitcalPoint::~splitcalPoint() {} // ------------------------------------------------------------------------- -void splitcalPoint::setDetectorName() { fDetectorName = "splitCal"; } - void splitcalPoint::extraPrintInfo() const { LOG(info) << "This is the splitcal"; } diff --git a/splitcal/splitcalPoint.h b/splitcal/splitcalPoint.h index 54c3d75eea..fbdb451fa1 100644 --- a/splitcal/splitcalPoint.h +++ b/splitcal/splitcalPoint.h @@ -19,7 +19,7 @@ class splitcalPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~splitcalPoint(); - void setDetectorName() override; + virtual const char* DetectorName() const { return "splitcalDetector"; } void extraPrintInfo() const override; private: diff --git a/strawtubes/strawtubesPoint.cxx b/strawtubes/strawtubesPoint.cxx index c382550339..815dcebcb4 100644 --- a/strawtubes/strawtubesPoint.cxx +++ b/strawtubes/strawtubesPoint.cxx @@ -28,8 +28,6 @@ strawtubesPoint::strawtubesPoint(Int_t eventID, Int_t trackID, Int_t detID, strawtubesPoint::~strawtubesPoint() {} // ------------------------------------------------------------------------- -void strawtubesPoint::setDetectorName() { fDetectorName = "UpstreamTagger"; } - void strawtubesPoint::extraPrintInfo() const { LOG(info) << " Position (" << fX << ", " << fY << ", " << fZ << ", " << fdist2Wire << ") cm"; diff --git a/strawtubes/strawtubesPoint.h b/strawtubes/strawtubesPoint.h index bbcd26a790..882bceee38 100644 --- a/strawtubes/strawtubesPoint.h +++ b/strawtubes/strawtubesPoint.h @@ -37,7 +37,7 @@ class strawtubesPoint : public SHiP::DetectorPoint { Double_t dist2Wire() const { return fdist2Wire; } - void setDetectorName() override; + virtual const char* DetectorName() const { return "strawtubesDetector"; } void extraPrintInfo() const override; private: diff --git a/veto/vetoPoint.cxx b/veto/vetoPoint.cxx index 8a551cd0f2..0b879cae07 100644 --- a/veto/vetoPoint.cxx +++ b/veto/vetoPoint.cxx @@ -18,8 +18,6 @@ vetoPoint::~vetoPoint() {} // ----- Public method Print ------------------------------------------- -void vetoPoint::setDetectorName() { fDetectorName = "vetoPoint"; } - void vetoPoint::extraPrintInfo() const { LOG(info) << "This is the veto detector"; } diff --git a/veto/vetoPoint.h b/veto/vetoPoint.h index 11b0350304..18754096ef 100644 --- a/veto/vetoPoint.h +++ b/veto/vetoPoint.h @@ -33,7 +33,7 @@ class vetoPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~vetoPoint(); - void setDetectorName() override; + virtual const char* DetectorName() const { return "vetoDetector"; } void extraPrintInfo() const override; /** Output to screen **/ From fb6d33f6f1b15fd169f4d953f82db51f3f5632a5 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 12:05:09 +0000 Subject: [PATCH 21/53] changes --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46c340b136..59f679c28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,7 @@ it in future. -* Add DetectorPoint base class for the various detector points. Adds EventID as well to each. #1059 +* Add DetectorPoint base class for the various detector points. Adds EventID as well to each. #1059 #1075 * Change a const char* in SHiP::Generator to optional. #1053 * Only get evtNo in ShipStack if there are tracks. Prevents seg faults from accessing empty events at the end of the run. #1051 * makeGenieEvents: automatically set GXMLPATH to the genie_config folder. Remove option --nudet since now GXMLPATH always needs to be set. From dd205526a0a9dff2abd2784664b4a8d94c81aa61 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 12:06:24 +0000 Subject: [PATCH 22/53] revert --- UpstreamTagger/UpstreamTaggerPoint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index ed19970827..a556f4ef8b 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -27,7 +27,7 @@ class UpstreamTaggerPoint : public SHiP::DetectorPoint { void extraPrintInfo() const override; private: - ClassDefOverride(UpstreamTaggerPoint, 5) + ClassDefOverride(UpstreamTaggerPoint, 4) }; #endif // UPSTREAMTAGGER_UPSTREAMTAGGERPOINT_H_ From 96dda3960da316eb1e8629a248756d30865960ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:06:52 +0000 Subject: [PATCH 23/53] style: pre-commit fixes --- Detector/DetectorPoint.cxx | 7 ++----- Detector/DetectorPoint.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Detector/DetectorPoint.cxx b/Detector/DetectorPoint.cxx index 7040b757d8..1f4400571b 100644 --- a/Detector/DetectorPoint.cxx +++ b/Detector/DetectorPoint.cxx @@ -14,8 +14,7 @@ SHiP::DetectorPoint::DetectorPoint(Int_t eventID, Int_t trackID, Int_t detID, : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss, eventID), fPdgCode(pdgcode), fLpos{Lpos.X(), Lpos.Y(), Lpos.Z()}, - fLmom{Lmom.X(), Lmom.Y(), Lmom.Z()} { -} + fLmom{Lmom.X(), Lmom.Y(), Lmom.Z()} {} // ----- Standard constructor ---------------- SHiP::DetectorPoint::DetectorPoint(Int_t eventID, Int_t trackID, Int_t detID, @@ -25,8 +24,7 @@ SHiP::DetectorPoint::DetectorPoint(Int_t eventID, Int_t trackID, Int_t detID, : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss, eventID), fPdgCode(pdgcode), fLpos{pos.X(), pos.Y(), pos.Z()}, - fLmom{mom.X(), mom.Y(), mom.Z()} { -} + fLmom{mom.X(), mom.Y(), mom.Z()} {} // ----- Public method Print ------------------------------------------- void SHiP::DetectorPoint::Print() const { @@ -40,7 +38,6 @@ void SHiP::DetectorPoint::Print() const { } // ------------------------------------------------------------------------- - void SHiP::DetectorPoint::extraPrintInfo() const { LOG(info) << "Nothing to see here"; } diff --git a/Detector/DetectorPoint.h b/Detector/DetectorPoint.h index fc8ff2e60d..01a55c0510 100644 --- a/Detector/DetectorPoint.h +++ b/Detector/DetectorPoint.h @@ -35,7 +35,7 @@ class DetectorPoint : public FairMCPoint { TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } - virtual const char* DetectorName() const {return "GenericDetector";}; + virtual const char* DetectorName() const { return "GenericDetector"; }; virtual void extraPrintInfo() const; From 417e1ba8ac2d0d19f42c5b10ac16fafb28869a3e Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 16:31:27 +0000 Subject: [PATCH 24/53] start --- Detector/CMakeLists.txt | 2 +- Detector/Detector.cxx | 27 +++++++++++++++++++++++ Detector/Detector.h | 49 +++++++++++++++++++++++++++++++++++++++++ Detector/LinkDef.h | 1 + TimeDet/TimeDet.cxx | 8 ------- TimeDet/TimeDet.h | 19 ++-------------- TimeDet/TimeDetPoint.h | 2 +- 7 files changed, 81 insertions(+), 27 deletions(-) create mode 100644 Detector/Detector.cxx create mode 100644 Detector/Detector.h diff --git a/Detector/CMakeLists.txt b/Detector/CMakeLists.txt index c63a559409..844d28d4c2 100644 --- a/Detector/CMakeLists.txt +++ b/Detector/CMakeLists.txt @@ -3,7 +3,7 @@ ship_add_library( NAME Detector - SOURCES DetectorPoint.cxx + SOURCES Detector.cxx DetectorPoint.cxx LINKDEF LinkDef.h DEPENDENCIES Base ShipData FairLogger::FairLogger ) diff --git a/Detector/Detector.cxx b/Detector/Detector.cxx new file mode 100644 index 0000000000..5366eebcdf --- /dev/null +++ b/Detector/Detector.cxx @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP +// Collaboration + +#include "Detector.h" +#include "DetectorPoint.h" +#include "FairLogger.h" + +SHiP::Detector::Detector(const char* Name, Bool_t Active) + : FairDetector(Name, Active), + fEventID(-1), + fTrackID(-1), + fVolumeID(-1), + fPos(), + fMom(), + fTime(-1.), + fLength(-1.), + fELoss(-1) + {} + +std::shared_ptr SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, Int_t detID, + const TVector3 &pos, const TVector3 &mom, Double_t time, + Double_t length, Double_t eLoss, Int_t pdgCode, + const TVector3 &Lpos, const TVector3 &Lmom) { + fDetPoints.push_back(std::make_shared(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom)); + return fDetPoints.back(); +} diff --git a/Detector/Detector.h b/Detector/Detector.h new file mode 100644 index 0000000000..9c7dc73f4a --- /dev/null +++ b/Detector/Detector.h @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP +// Collaboration + +#ifndef DETECTOR_DETECTOR_H_ +#define DETECTOR_DETECTOR_H_ + +#include "FairDetector.h" +#include "ISTLPointContainer.h" +#include "TVector3.h" +#include "TLorentzVector.h" + +#include "DetectorPoint.h" +#include + +namespace SHiP{ +class Detector: public FairDetector, public ISTLPointContainer { + public: + Detector() = default ; + virtual ~Detector() = default; + Detector(const char* Name, Bool_t Active); + + std::shared_ptr AddHit(Int_t eventID, Int_t trackID, Int_t detID, + const TVector3& pos, const TVector3& mom, Double_t time, + Double_t length, Double_t eLoss, Int_t pdgCode, + const TVector3& Lpos, const TVector3& Lmom); + + /** Create the detector geometry */ + virtual void ConstructGeometry(); + + protected: + + /** Track information to be stored until the track leaves the active volume.*/ + Int_t fEventID; //! event index + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! position at entrance + TLorentzVector fMom; //! momentum at entrance + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + std::vector> fDetPoints; + + TGeoVolume* fDetector = nullptr; // Timing detector object + private: +}; +} // namespace SHiP + +#endif // DETECTOR_DETECTOR_H_ diff --git a/Detector/LinkDef.h b/Detector/LinkDef.h index 3fb8cb8cd0..d38facd5fc 100644 --- a/Detector/LinkDef.h +++ b/Detector/LinkDef.h @@ -10,6 +10,7 @@ #pragma link off all functions; #pragma link C++ namespace SHiP; +#pragma link C++ class SHiP::Detector+; #pragma link C++ class SHiP::DetectorPoint+; #endif diff --git a/TimeDet/TimeDet.cxx b/TimeDet/TimeDet.cxx index 5d3b03cced..a5a3a44bcd 100644 --- a/TimeDet/TimeDet.cxx +++ b/TimeDet/TimeDet.cxx @@ -268,14 +268,6 @@ void TimeDet::ConstructGeometry() { return; } -TimeDetPoint* TimeDet::AddHit(Int_t eventID, Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - TVector3 Lpos, TVector3 Lmom) { - fTimeDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, - eLoss, pdgCode, Lpos, Lmom); - return &(fTimeDetPoints->back()); -} void TimeDet::GetBarRowCol(int ib, int& irow, int& icol) const { irow = ib / fNCol; diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index 8e79e58f27..f31d4a3b11 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -8,8 +8,7 @@ #include #include -#include "FairDetector.h" -#include "ISTLPointContainer.h" +#include "Detector.h" #include "TLorentzVector.h" #include "TVector3.h" @@ -17,7 +16,7 @@ class TimeDetPoint; class FairVolume; class TClonesArray; -class TimeDet : public FairDetector, public ISTLPointContainer { +class TimeDet : public SHiP::Detector { public: /** Name : Detector Name * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -86,15 +85,6 @@ class TimeDet : public FairDetector, public ISTLPointContainer { virtual void BeginEvent() { ; } private: - /** Track information to be stored until the track leaves the active volume.*/ - Int_t fEventID; //! event index - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss /** Detector parameters.*/ Double_t fzPos; //! z-position of veto station @@ -119,11 +109,6 @@ class TimeDet : public FairDetector, public ISTLPointContainer { Double_t fxOv; //! Overlap along x Double_t fyOv; //! Overlap along y - TGeoVolume* fDetector; // Timing detector object - - /** container for data points */ - std::vector* fTimeDetPoints; - TimeDet(const TimeDet&); TimeDet& operator=(const TimeDet&); Int_t InitMedium(const char* name); diff --git a/TimeDet/TimeDetPoint.h b/TimeDet/TimeDetPoint.h index 081b169550..ac0923fd9a 100644 --- a/TimeDet/TimeDetPoint.h +++ b/TimeDet/TimeDetPoint.h @@ -21,7 +21,7 @@ class TimeDetPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~TimeDetPoint(); - virtual const char* DetectorName() const { return "timeDetector"; } + virtual const char* DetectorName() const override { return "timeDetector"; }; void extraPrintInfo() const override; private: From 3ac006fe1f0846999119784a8a28b8073c63aad7 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 16:33:52 +0000 Subject: [PATCH 25/53] make real --- Detector/DetectorPoint.h | 2 +- TimeDet/TimeDetPoint.h | 2 +- UpstreamTagger/UpstreamTaggerPoint.h | 2 +- splitcal/splitcalPoint.h | 2 +- strawtubes/strawtubesPoint.h | 2 +- veto/vetoPoint.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Detector/DetectorPoint.h b/Detector/DetectorPoint.h index fc8ff2e60d..9bd91240d2 100644 --- a/Detector/DetectorPoint.h +++ b/Detector/DetectorPoint.h @@ -35,7 +35,7 @@ class DetectorPoint : public FairMCPoint { TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } - virtual const char* DetectorName() const {return "GenericDetector";}; + virtual const char* DetectorName() const {return "GenericDetector";} virtual void extraPrintInfo() const; diff --git a/TimeDet/TimeDetPoint.h b/TimeDet/TimeDetPoint.h index 081b169550..e61260ea7a 100644 --- a/TimeDet/TimeDetPoint.h +++ b/TimeDet/TimeDetPoint.h @@ -21,7 +21,7 @@ class TimeDetPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~TimeDetPoint(); - virtual const char* DetectorName() const { return "timeDetector"; } + const char* DetectorName() const override { return "timeDetector"; } void extraPrintInfo() const override; private: diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index a556f4ef8b..45087ba32e 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -22,7 +22,7 @@ class UpstreamTaggerPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~UpstreamTaggerPoint(); - virtual const char* DetectorName() const { return "UpstreamTagger"; } + const char* DetectorName() const override { return "UpstreamTagger"; } void extraPrintInfo() const override; diff --git a/splitcal/splitcalPoint.h b/splitcal/splitcalPoint.h index fbdb451fa1..311539a817 100644 --- a/splitcal/splitcalPoint.h +++ b/splitcal/splitcalPoint.h @@ -19,7 +19,7 @@ class splitcalPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~splitcalPoint(); - virtual const char* DetectorName() const { return "splitcalDetector"; } + const char* DetectorName() const override { return "splitcalDetector"; } void extraPrintInfo() const override; private: diff --git a/strawtubes/strawtubesPoint.h b/strawtubes/strawtubesPoint.h index 882bceee38..1905c59100 100644 --- a/strawtubes/strawtubesPoint.h +++ b/strawtubes/strawtubesPoint.h @@ -37,7 +37,7 @@ class strawtubesPoint : public SHiP::DetectorPoint { Double_t dist2Wire() const { return fdist2Wire; } - virtual const char* DetectorName() const { return "strawtubesDetector"; } + const char* DetectorName() const override { return "strawtubesDetector"; } void extraPrintInfo() const override; private: diff --git a/veto/vetoPoint.h b/veto/vetoPoint.h index 18754096ef..f0a609dbd5 100644 --- a/veto/vetoPoint.h +++ b/veto/vetoPoint.h @@ -33,7 +33,7 @@ class vetoPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~vetoPoint(); - virtual const char* DetectorName() const { return "vetoDetector"; } + const char* DetectorName() const override { return "vetoDetector"; } void extraPrintInfo() const override; /** Output to screen **/ From 534a87f9c87779df0dfefda229b60a3fc08399bb Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Fri, 6 Mar 2026 16:36:33 +0000 Subject: [PATCH 26/53] tidy --- Detector/DetectorPoint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detector/DetectorPoint.h b/Detector/DetectorPoint.h index 01a55c0510..d939c92b06 100644 --- a/Detector/DetectorPoint.h +++ b/Detector/DetectorPoint.h @@ -35,7 +35,7 @@ class DetectorPoint : public FairMCPoint { TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } - virtual const char* DetectorName() const { return "GenericDetector"; }; + virtual const char* DetectorName() const { return "GenericDetector"; } virtual void extraPrintInfo() const; From 6261bfc157a1a2af06d9cdb27b427b1dcf5bddc9 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 15:29:03 +0000 Subject: [PATCH 27/53] start --- Detector/CMakeLists.txt | 2 +- Detector/Detector.cxx | 31 +++++++++++++++++---- Detector/Detector.h | 52 ++++++++++++++++++++++++++++++----- TimeDet/TimeDet.cxx | 61 +++++------------------------------------ TimeDet/TimeDet.h | 26 ++---------------- veto/veto.cxx | 47 ++----------------------------- veto/veto.h | 43 +++-------------------------- 7 files changed, 87 insertions(+), 175 deletions(-) diff --git a/Detector/CMakeLists.txt b/Detector/CMakeLists.txt index 844d28d4c2..4f1f98d575 100644 --- a/Detector/CMakeLists.txt +++ b/Detector/CMakeLists.txt @@ -3,7 +3,7 @@ ship_add_library( NAME Detector - SOURCES Detector.cxx DetectorPoint.cxx + SOURCES Detector.h DetectorPoint.cxx LINKDEF LinkDef.h DEPENDENCIES Base ShipData FairLogger::FairLogger ) diff --git a/Detector/Detector.cxx b/Detector/Detector.cxx index 5366eebcdf..5c8f5e9ccb 100644 --- a/Detector/Detector.cxx +++ b/Detector/Detector.cxx @@ -2,12 +2,13 @@ // SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP // Collaboration +#include "FairRootManager.h" #include "Detector.h" #include "DetectorPoint.h" #include "FairLogger.h" -SHiP::Detector::Detector(const char* Name, Bool_t Active) - : FairDetector(Name, Active), +SHiP::Detector::Detector(const char* Name, Bool_t Active, Int_t detID) + : FairDetector(Name, Active, detID), fEventID(-1), fTrackID(-1), fVolumeID(-1), @@ -15,13 +16,31 @@ SHiP::Detector::Detector(const char* Name, Bool_t Active) fMom(), fTime(-1.), fLength(-1.), - fELoss(-1) + fELoss(-1), + fDetPoints(NULL) {} -std::shared_ptr SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, Int_t detID, +SHiP::Detector::Detector(const char* Name, Bool_t Active) : + Detector(Name, Active, 0) + {} + +SHiP::Detector::~SHiP::Detector() { + if (fDetPoints) { + fDetPoints->clear(); + delete fDetPoints; + } +} + +void SHiP::Detector::Initialize() { FairDetector::Initialize(); } + +void SHiP::Detector::Reset() { fDetPoints->clear(); } + +SHiP::DetectorPoint* SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, Int_t detID, const TVector3 &pos, const TVector3 &mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode, const TVector3 &Lpos, const TVector3 &Lmom) { - fDetPoints.push_back(std::make_shared(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom)); - return fDetPoints.back(); + fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom); + return &(fDetPoints->back()); } + +void SHiP::Detector::EndOfEvent() { fDetPoints->clear(); } diff --git a/Detector/Detector.h b/Detector/Detector.h index 9c7dc73f4a..95483c1a7a 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -6,6 +6,7 @@ #define DETECTOR_DETECTOR_H_ #include "FairDetector.h" +#include "FairRootManager.h" #include "ISTLPointContainer.h" #include "TVector3.h" #include "TLorentzVector.h" @@ -14,19 +15,56 @@ #include namespace SHiP{ +template class Detector: public FairDetector, public ISTLPointContainer { public: Detector() = default ; - virtual ~Detector() = default; - Detector(const char* Name, Bool_t Active); + virtual ~Detector(){delete fDetPoints;}; + Detector(const char* Name, Bool_t Active, Int_t detID) : FairDetector(Name, Active, detID), + fEventID(-1), + fTrackID(-1), + fVolumeID(-1), + fPos(), + fMom(), + fTime(-1.), + fLength(-1.), + fELoss(-1), + fDetPoints(NULL) + {}; + + Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0){}; - std::shared_ptr AddHit(Int_t eventID, Int_t trackID, Int_t detID, + + DetectorPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, const TVector3& pos, const TVector3& mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode, - const TVector3& Lpos, const TVector3& Lmom); + const TVector3& Lpos, const TVector3& Lmom){ + fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom); + return &(fDetPoints->back()); + }; /** Create the detector geometry */ - virtual void ConstructGeometry(); + virtual void ConstructGeometry() = 0; + + virtual void Initialize(){FairDetector::Initialize();}; + + virtual void Reset() {fDetPoints->clear();}; + + virtual void EndOfEvent(){ fDetPoints->clear();}; + + virtual void Register(){ + fDetPoints = new std::vector(); + static PointType t; + FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); + }; + + + virtual void FinishPrimary() { ; } + virtual void FinishRun() { ; } + virtual void BeginPrimary() { ; } + virtual void PostTrack() { ; } + virtual void PreTrack() { ; } + virtual void BeginEvent() { ; } protected: @@ -39,9 +77,9 @@ class Detector: public FairDetector, public ISTLPointContainer { Double_t fTime; //! time Double_t fLength; //! length Double_t fELoss; //! energy loss - std::vector> fDetPoints; + std::vector* fDetPoints = nullptr; - TGeoVolume* fDetector = nullptr; // Timing detector object + TGeoVolume* fDetector = nullptr; // Detector object private: }; } // namespace SHiP diff --git a/TimeDet/TimeDet.cxx b/TimeDet/TimeDet.cxx index a5a3a44bcd..04c78abb16 100644 --- a/TimeDet/TimeDet.cxx +++ b/TimeDet/TimeDet.cxx @@ -40,16 +40,7 @@ using std::cout; using std::endl; TimeDet::TimeDet() - : FairDetector("TimeDet", kTRUE, kTimeDet), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - // + : Detector("TimeDet", kTRUE, kTimeDet), fzPos(0), fxSize(450), fySize(650), @@ -61,11 +52,8 @@ TimeDet::TimeDet() fNCol(3), fNRow(148), fxCenter(0), - fyCenter(0), - // - fDetector(0), - // - fTimeDetPoints(nullptr) { + fyCenter(0) + { fNBars = fNCol * fNRow; if (fNCol > 1) fxOv = (fxBar * fNCol - fxSize) / static_cast(fNCol - 1); @@ -78,15 +66,7 @@ TimeDet::TimeDet() } TimeDet::TimeDet(const char* name, Bool_t active) - : FairDetector(name, active, kTimeDet), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), + : Detector(name, active, kTimeDet), // fzPos(0), fxSize(450), @@ -99,11 +79,8 @@ TimeDet::TimeDet(const char* name, Bool_t active) fNCol(3), fNRow(148), fxCenter(0), - fyCenter(0), - // - fDetector(0), - // - fTimeDetPoints(nullptr) { + fyCenter(0) + { fNBars = fNCol * fNRow; if (fNCol > 1) fxOv = (fxBar * fNCol - fxSize) / static_cast(fNCol - 1); @@ -115,15 +92,6 @@ TimeDet::TimeDet(const char* name, Bool_t active) fyOv = 0; } -void TimeDet::Initialize() { FairDetector::Initialize(); } - -TimeDet::~TimeDet() { - if (fTimeDetPoints) { - fTimeDetPoints->clear(); - delete fTimeDetPoints; - } -} - Int_t TimeDet::InitMedium(const char* name) { static FairGeoLoader* geoLoad = FairGeoLoader::Instance(); static FairGeoInterface* geoFace = geoLoad->getGeoInterface(); @@ -202,24 +170,11 @@ Bool_t TimeDet::ProcessHits(FairVolume* vol) { return kTRUE; } -void TimeDet::EndOfEvent() { fTimeDetPoints->clear(); } - -void TimeDet::Register() { - /** This will create a branch in the output tree called - TimeDetPoint, setting the last parameter to kFALSE means: - this collection will not be written to the file, it will exist - only during the simulation. - */ - - fTimeDetPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny("TimeDetPoint", fTimeDetPoints, - kTRUE); -} TClonesArray* TimeDet::GetCollection(Int_t iColl) const { return nullptr; } void TimeDet::UpdatePointTrackIndices(const std::map& indexMap) { - for (auto& point : *fTimeDetPoints) { + for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); if (iter != indexMap.end()) { @@ -229,8 +184,6 @@ void TimeDet::UpdatePointTrackIndices(const std::map& indexMap) { } } -void TimeDet::Reset() { fTimeDetPoints->clear(); } - void TimeDet::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index f31d4a3b11..c72165facc 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -16,7 +16,7 @@ class TimeDetPoint; class FairVolume; class TClonesArray; -class TimeDet : public SHiP::Detector { +class TimeDet : public SHiP::Detector { public: /** Name : Detector Name * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -28,27 +28,22 @@ class TimeDet : public SHiP::Detector { TimeDet(); /** destructor */ - virtual ~TimeDet(); + virtual ~TimeDet() = default; /** Initialization of the detector is done here */ - virtual void Initialize(); +// virtual void Initialize(); /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Registers the produced collections in FAIRRootManager. */ - virtual void Register(); - /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** has to be called after each event to reset the containers */ - virtual void Reset(); /** Sets detector position along z */ void SetZposition(Double_t z) { fzPos = z; } @@ -68,21 +63,6 @@ class TimeDet : public SHiP::Detector { /** Create the detector geometry */ void ConstructGeometry(); - /** This method is an example of how to add your own point - * of type TimeDetPoint to the clones array - */ - TimeDetPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, TVector3 pos, - TVector3 mom, Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode, TVector3 Lpos, - TVector3 Lmom); - - virtual void EndOfEvent(); - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } private: diff --git a/veto/veto.cxx b/veto/veto.cxx index 21acafedab..890dfbdaec 100644 --- a/veto/veto.cxx +++ b/veto/veto.cxx @@ -62,36 +62,13 @@ Double_t mm = 0.1 * cm; // mm * */ veto::veto() - : FairDetector("Veto", kTRUE, kVETO), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), + : SHiP::Detector("Veto", kTRUE, kVETO), fFastMuon(kFALSE), - fFollowMuon(kFALSE), - fvetoPoints(nullptr) { + fFollowMuon(kFALSE) { fUseSupport = 1; fLiquidVeto = 1; } -/** - * @brief Destructor for the Veto class. - * - * Cleans up any resources used by the Veto detector. - */ -veto::~veto() { - if (fvetoPoints) { - fvetoPoints->clear(); - delete fvetoPoints; - } -} - -void veto::Initialize() { FairDetector::Initialize(); } - TGeoVolume* veto::GeoTrapezoid(TString xname, Double_t z_thick, Double_t x_thick_start, Double_t x_thick_end, Double_t y_thick_start, Double_t y_thick_end, @@ -846,8 +823,6 @@ Bool_t veto::ProcessHits(FairVolume* vol) { return kTRUE; } -void veto::EndOfEvent() { fvetoPoints->clear(); } - void veto::PreTrack() { if (!fFastMuon) { return; @@ -856,14 +831,6 @@ void veto::PreTrack() { gMC->StopTrack(); } } -void veto::Register() // create a branch in the output tree -{ - fvetoPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny( - "vetoPoint", fvetoPoints, - kTRUE); // kFALSE -> this collection will not be written to the file, - // will exist only during simulation. -} TClonesArray* veto::GetCollection(Int_t iColl) const { return nullptr; } @@ -878,8 +845,6 @@ void veto::UpdatePointTrackIndices(const std::map& indexMap) { } } -void veto::Reset() { fvetoPoints->clear(); } - /** * @brief Constructs the detector geometry. * @@ -939,11 +904,3 @@ void veto::ConstructGeometry() { } } -vetoPoint* veto::AddHit(Int_t eventID, Int_t trackID, Int_t detID, TVector3 pos, - TVector3 mom, Double_t time, Double_t length, - Double_t eLoss, Int_t pdgCode, TVector3 Lpos, - TVector3 Lmom) { - fvetoPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, - eLoss, pdgCode, Lpos, Lmom); - return &(fvetoPoints->back()); -} diff --git a/veto/veto.h b/veto/veto.h index 9a204a66d1..05d10a5e0c 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -8,8 +8,7 @@ #include #include -#include "FairDetector.h" -#include "ISTLPointContainer.h" +#include "Detector.h" #include "TGeoVolume.h" #include "TLorentzVector.h" #include "TVector3.h" @@ -27,7 +26,7 @@ class TClonesArray; * the detector geometry, processing hits, and handling input parameters. */ -class veto : public FairDetector, public ISTLPointContainer { +class veto : public SHiP::Detector { public: /** Name : Veto * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -37,18 +36,14 @@ class veto : public FairDetector, public ISTLPointContainer { veto(); /** destructor */ - virtual ~veto(); + virtual ~veto() = default; - /** Initialization of the detector is done here */ - virtual void Initialize(); /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Registers the produced collections in FAIRRootManager. */ - virtual void Register(); /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; @@ -56,8 +51,6 @@ class veto : public FairDetector, public ISTLPointContainer { /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** has to be called after each event to reset the containers */ - virtual void Reset(); void SetFastMuon() { fFastMuon = true; } // kill all tracks except of muons void SetFollowMuon() { @@ -88,13 +81,6 @@ class veto : public FairDetector, public ISTLPointContainer { f_RibThickness = r; } - /** This method is an example of how to add your own point - * of type vetoPoint to the clones array - */ - vetoPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, TVector3 pos, - TVector3 mom, Double_t time, Double_t length, - Double_t eLoss, Int_t pdgcode, TVector3 Lpos, - TVector3 Lmom); /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. @@ -104,13 +90,8 @@ class veto : public FairDetector, public ISTLPointContainer { ; } virtual void SetSpecialPhysicsCuts() { ; } - virtual void EndOfEvent(); - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } + virtual void PreTrack(); - virtual void BeginEvent() { ; } inline void SetUseSupport(Int_t use = 1) { fUseSupport = use; } inline Int_t GetUseSupport() const { return fUseSupport; } @@ -122,22 +103,6 @@ class veto : public FairDetector, public ISTLPointContainer { /** Track information to be stored until the track leaves the active volume. */ - //! event index - Int_t fEventID; - //! track index - Int_t fTrackID; - //! volume id - Int_t fVolumeID; - //! position at entrance - TLorentzVector fPos; - //! momentum at entrance - TLorentzVector fMom; - //! time - Float_t fTime; - //! length - Float_t fLength; - //! energy loss - Float_t fELoss; Bool_t fFastMuon, fFollowMuon; From 46eebb3d19f059866f1027bae97199a28457cae0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:30:18 +0000 Subject: [PATCH 28/53] style: pre-commit fixes --- Detector/Detector.cxx | 26 ++++---- Detector/Detector.h | 144 +++++++++++++++++++++--------------------- TimeDet/TimeDet.cxx | 8 +-- TimeDet/TimeDet.h | 5 +- veto/veto.cxx | 1 - veto/veto.h | 4 -- 6 files changed, 88 insertions(+), 100 deletions(-) diff --git a/Detector/Detector.cxx b/Detector/Detector.cxx index 5c8f5e9ccb..7b2e7f4e2a 100644 --- a/Detector/Detector.cxx +++ b/Detector/Detector.cxx @@ -2,10 +2,11 @@ // SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP // Collaboration -#include "FairRootManager.h" #include "Detector.h" + #include "DetectorPoint.h" #include "FairLogger.h" +#include "FairRootManager.h" SHiP::Detector::Detector(const char* Name, Bool_t Active, Int_t detID) : FairDetector(Name, Active, detID), @@ -17,12 +18,10 @@ SHiP::Detector::Detector(const char* Name, Bool_t Active, Int_t detID) fTime(-1.), fLength(-1.), fELoss(-1), - fDetPoints(NULL) - {} + fDetPoints(NULL) {} -SHiP::Detector::Detector(const char* Name, Bool_t Active) : - Detector(Name, Active, 0) - {} +SHiP::Detector::Detector(const char* Name, Bool_t Active) + : Detector(Name, Active, 0) {} SHiP::Detector::~SHiP::Detector() { if (fDetPoints) { @@ -35,12 +34,15 @@ void SHiP::Detector::Initialize() { FairDetector::Initialize(); } void SHiP::Detector::Reset() { fDetPoints->clear(); } -SHiP::DetectorPoint* SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, Int_t detID, - const TVector3 &pos, const TVector3 &mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - const TVector3 &Lpos, const TVector3 &Lmom) { - fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom); - return &(fDetPoints->back()); +SHiP::DetectorPoint* SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, + Int_t detID, const TVector3& pos, + const TVector3& mom, Double_t time, + Double_t length, Double_t eLoss, + Int_t pdgCode, const TVector3& Lpos, + const TVector3& Lmom) { + fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, + eLoss, pdgCode, Lpos, Lmom); + return &(fDetPoints->back()); } void SHiP::Detector::EndOfEvent() { fDetPoints->clear(); } diff --git a/Detector/Detector.h b/Detector/Detector.h index 95483c1a7a..0fe848e30a 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -5,83 +5,81 @@ #ifndef DETECTOR_DETECTOR_H_ #define DETECTOR_DETECTOR_H_ +#include + +#include "DetectorPoint.h" #include "FairDetector.h" #include "FairRootManager.h" #include "ISTLPointContainer.h" -#include "TVector3.h" #include "TLorentzVector.h" +#include "TVector3.h" -#include "DetectorPoint.h" -#include - -namespace SHiP{ -template -class Detector: public FairDetector, public ISTLPointContainer { - public: - Detector() = default ; - virtual ~Detector(){delete fDetPoints;}; - Detector(const char* Name, Bool_t Active, Int_t detID) : FairDetector(Name, Active, detID), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fDetPoints(NULL) - {}; - - Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0){}; - - - DetectorPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, - const TVector3& pos, const TVector3& mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - const TVector3& Lpos, const TVector3& Lmom){ - fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, eLoss, pdgCode, Lpos, Lmom); - return &(fDetPoints->back()); - }; - - /** Create the detector geometry */ - virtual void ConstructGeometry() = 0; - - virtual void Initialize(){FairDetector::Initialize();}; - - virtual void Reset() {fDetPoints->clear();}; - - virtual void EndOfEvent(){ fDetPoints->clear();}; - - virtual void Register(){ - fDetPoints = new std::vector(); - static PointType t; - FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); - }; - - - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } - - protected: - - /** Track information to be stored until the track leaves the active volume.*/ - Int_t fEventID; //! event index - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss - std::vector* fDetPoints = nullptr; - - TGeoVolume* fDetector = nullptr; // Detector object - private: +namespace SHiP { +template +class Detector : public FairDetector, public ISTLPointContainer { + public: + Detector() = default; + virtual ~Detector() { delete fDetPoints; }; + Detector(const char* Name, Bool_t Active, Int_t detID) + : FairDetector(Name, Active, detID), + fEventID(-1), + fTrackID(-1), + fVolumeID(-1), + fPos(), + fMom(), + fTime(-1.), + fLength(-1.), + fELoss(-1), + fDetPoints(NULL) {}; + + Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0) {}; + + DetectorPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, + const TVector3& pos, const TVector3& mom, Double_t time, + Double_t length, Double_t eLoss, Int_t pdgCode, + const TVector3& Lpos, const TVector3& Lmom) { + fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, + eLoss, pdgCode, Lpos, Lmom); + return &(fDetPoints->back()); + }; + + /** Create the detector geometry */ + virtual void ConstructGeometry() = 0; + + virtual void Initialize() { FairDetector::Initialize(); }; + + virtual void Reset() { fDetPoints->clear(); }; + + virtual void EndOfEvent() { fDetPoints->clear(); }; + + virtual void Register() { + fDetPoints = new std::vector(); + static PointType t; + FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); + }; + + virtual void FinishPrimary() { ; } + virtual void FinishRun() { ; } + virtual void BeginPrimary() { ; } + virtual void PostTrack() { ; } + virtual void PreTrack() { ; } + virtual void BeginEvent() { ; } + + protected: + /** Track information to be stored until the track leaves the active volume.*/ + Int_t fEventID; //! event index + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! position at entrance + TLorentzVector fMom; //! momentum at entrance + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + std::vector* fDetPoints = nullptr; + + TGeoVolume* fDetector = nullptr; // Detector object + private: }; -} // namespace SHiP +} // namespace SHiP -#endif // DETECTOR_DETECTOR_H_ +#endif // DETECTOR_DETECTOR_H_ diff --git a/TimeDet/TimeDet.cxx b/TimeDet/TimeDet.cxx index 04c78abb16..a47a8c360c 100644 --- a/TimeDet/TimeDet.cxx +++ b/TimeDet/TimeDet.cxx @@ -52,8 +52,7 @@ TimeDet::TimeDet() fNCol(3), fNRow(148), fxCenter(0), - fyCenter(0) - { + fyCenter(0) { fNBars = fNCol * fNRow; if (fNCol > 1) fxOv = (fxBar * fNCol - fxSize) / static_cast(fNCol - 1); @@ -79,8 +78,7 @@ TimeDet::TimeDet(const char* name, Bool_t active) fNCol(3), fNRow(148), fxCenter(0), - fyCenter(0) - { + fyCenter(0) { fNBars = fNCol * fNRow; if (fNCol > 1) fxOv = (fxBar * fNCol - fxSize) / static_cast(fNCol - 1); @@ -170,7 +168,6 @@ Bool_t TimeDet::ProcessHits(FairVolume* vol) { return kTRUE; } - TClonesArray* TimeDet::GetCollection(Int_t iColl) const { return nullptr; } void TimeDet::UpdatePointTrackIndices(const std::map& indexMap) { @@ -221,7 +218,6 @@ void TimeDet::ConstructGeometry() { return; } - void TimeDet::GetBarRowCol(int ib, int& irow, int& icol) const { irow = ib / fNCol; icol = (ib % fNCol); diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index c72165facc..1d35f17d74 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -31,7 +31,7 @@ class TimeDet : public SHiP::Detector { virtual ~TimeDet() = default; /** Initialization of the detector is done here */ -// virtual void Initialize(); + // virtual void Initialize(); /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) @@ -44,7 +44,6 @@ class TimeDet : public SHiP::Detector { /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** Sets detector position along z */ void SetZposition(Double_t z) { fzPos = z; } void SetBarZspacing(Double_t row, Double_t column) { @@ -63,9 +62,7 @@ class TimeDet : public SHiP::Detector { /** Create the detector geometry */ void ConstructGeometry(); - private: - /** Detector parameters.*/ Double_t fzPos; //! z-position of veto station diff --git a/veto/veto.cxx b/veto/veto.cxx index 890dfbdaec..68955365db 100644 --- a/veto/veto.cxx +++ b/veto/veto.cxx @@ -903,4 +903,3 @@ void veto::ConstructGeometry() { } } } - diff --git a/veto/veto.h b/veto/veto.h index 05d10a5e0c..47c44c2c86 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -38,20 +38,17 @@ class veto : public SHiP::Detector { /** destructor */ virtual ~veto() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - void SetFastMuon() { fFastMuon = true; } // kill all tracks except of muons void SetFollowMuon() { fFollowMuon = true; @@ -81,7 +78,6 @@ class veto : public SHiP::Detector { f_RibThickness = r; } - /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. */ From 57b1ce9a3da8f8961db533f0ad146b36d3b4afd3 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 15:33:09 +0000 Subject: [PATCH 29/53] tidy --- Detector/Detector.cxx | 48 ------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 Detector/Detector.cxx diff --git a/Detector/Detector.cxx b/Detector/Detector.cxx deleted file mode 100644 index 7b2e7f4e2a..0000000000 --- a/Detector/Detector.cxx +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP -// Collaboration - -#include "Detector.h" - -#include "DetectorPoint.h" -#include "FairLogger.h" -#include "FairRootManager.h" - -SHiP::Detector::Detector(const char* Name, Bool_t Active, Int_t detID) - : FairDetector(Name, Active, detID), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fDetPoints(NULL) {} - -SHiP::Detector::Detector(const char* Name, Bool_t Active) - : Detector(Name, Active, 0) {} - -SHiP::Detector::~SHiP::Detector() { - if (fDetPoints) { - fDetPoints->clear(); - delete fDetPoints; - } -} - -void SHiP::Detector::Initialize() { FairDetector::Initialize(); } - -void SHiP::Detector::Reset() { fDetPoints->clear(); } - -SHiP::DetectorPoint* SHiP::Detector::AddHit(Int_t eventID, Int_t trackID, - Int_t detID, const TVector3& pos, - const TVector3& mom, Double_t time, - Double_t length, Double_t eLoss, - Int_t pdgCode, const TVector3& Lpos, - const TVector3& Lmom) { - fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, - eLoss, pdgCode, Lpos, Lmom); - return &(fDetPoints->back()); -} - -void SHiP::Detector::EndOfEvent() { fDetPoints->clear(); } From e185b58872ae6e5952708df3d8f712642c78c01a Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 16:11:01 +0000 Subject: [PATCH 30/53] add detectors --- Detector/Detector.h | 11 ++--- UpstreamTagger/UpstreamTagger.cxx | 70 +++-------------------------- UpstreamTagger/UpstreamTagger.h | 43 ++---------------- splitcal/splitcal.cxx | 62 ++------------------------ splitcal/splitcal.h | 40 ++--------------- strawtubes/strawtubes.cxx | 74 +++---------------------------- strawtubes/strawtubes.h | 39 ++-------------- 7 files changed, 29 insertions(+), 310 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 0fe848e30a..61f0f8355f 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -6,7 +6,7 @@ #define DETECTOR_DETECTOR_H_ #include - +#include #include "DetectorPoint.h" #include "FairDetector.h" #include "FairRootManager.h" @@ -34,12 +34,9 @@ class Detector : public FairDetector, public ISTLPointContainer { Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0) {}; - DetectorPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, - const TVector3& pos, const TVector3& mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - const TVector3& Lpos, const TVector3& Lmom) { - fDetPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, - eLoss, pdgCode, Lpos, Lmom); + template + PointType* AddHit(Args&&... args) { + fDetPoints->emplace_back(std::forward(args)...); return &(fDetPoints->back()); }; diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 0501c9d93a..ba5f65e33c 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -45,51 +45,16 @@ using std::cout; using std::endl; UpstreamTagger::UpstreamTagger() - : FairDetector("UpstreamTagger", kTRUE, kUpstreamTagger), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - // + : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), det_zPos(0), - - // UpstreamTagger_fulldet(0), - scoringPlaneUBText(0), - // - fUpstreamTaggerPoints(nullptr) {} + scoringPlaneUBText(0) {} UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) - : FairDetector(name, active, kUpstreamTagger), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - // + : Detector(name, active, kUpstreamTagger), det_zPos(0), - - // UpstreamTagger_fulldet(0), - scoringPlaneUBText(0), // Initialize new scoring plane to nullptr - // - fUpstreamTaggerPoints(nullptr) {} - -void UpstreamTagger::Initialize() { FairDetector::Initialize(); } - -UpstreamTagger::~UpstreamTagger() { - if (fUpstreamTaggerPoints) { - fUpstreamTaggerPoints->clear(); - delete fUpstreamTaggerPoints; - } -} + scoringPlaneUBText(0) {} Int_t UpstreamTagger::InitMedium(const char* name) { static FairGeoLoader* geoLoad = FairGeoLoader::Instance(); @@ -166,27 +131,13 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { return kTRUE; } -void UpstreamTagger::EndOfEvent() { fUpstreamTaggerPoints->clear(); } - -void UpstreamTagger::Register() { - /** This will create a branch in the output tree called - UpstreamTaggerPoint, setting the last parameter to kFALSE means: - this collection will not be written to the file, it will exist - only during the simulation. - */ - - fUpstreamTaggerPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny("UpstreamTaggerPoint", - fUpstreamTaggerPoints, kTRUE); -} - TClonesArray* UpstreamTagger::GetCollection(Int_t iColl) const { return nullptr; } void UpstreamTagger::UpdatePointTrackIndices( const std::map& indexMap) { - for (auto& point : *fUpstreamTaggerPoints) { + for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); if (iter != indexMap.end()) { @@ -196,7 +147,6 @@ void UpstreamTagger::UpdatePointTrackIndices( } } -void UpstreamTagger::Reset() { fUpstreamTaggerPoints->clear(); } void UpstreamTagger::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); @@ -230,13 +180,3 @@ void UpstreamTagger::ConstructGeometry() { return; } -UpstreamTaggerPoint* UpstreamTagger::AddHit(Int_t eventID, Int_t trackID, - Int_t detID, TVector3 pos, - TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, - Int_t pdgCode, TVector3 Lpos, - TVector3 Lmom) { - fUpstreamTaggerPoints->emplace_back(eventID, trackID, detID, pos, mom, time, - length, eLoss, pdgCode, Lpos, Lmom); - return &(fUpstreamTaggerPoints->back()); -} diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index b6453b3ffa..33139d315c 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -8,8 +8,7 @@ #include #include -#include "FairDetector.h" -#include "ISTLPointContainer.h" +#include "Detector.h" #include "ShipUnit.h" #include "TLorentzVector.h" #include "TVector3.h" @@ -42,7 +41,7 @@ using ShipUnit::m; * - Configured via SetZposition() and SetBoxDimensions() */ -class UpstreamTagger : public FairDetector, public ISTLPointContainer { +class UpstreamTagger : public SHiP::Detector { public: /** Name : Detector Name * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -54,28 +53,20 @@ class UpstreamTagger : public FairDetector, public ISTLPointContainer { UpstreamTagger(); /** destructor */ - virtual ~UpstreamTagger(); + virtual ~UpstreamTagger() = default; - /** Initialization of the detector is done here */ - virtual void Initialize(); /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Registers the produced collections in FAIRRootManager. */ - virtual void Register(); - /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** has to be called after each event to reset the containers */ - virtual void Reset(); - /** Sets detector position and sizes */ void SetZposition(Double_t z) { det_zPos = z; } void SetBoxDimensions(Double_t x, Double_t y, Double_t z) { @@ -87,35 +78,10 @@ class UpstreamTagger : public FairDetector, public ISTLPointContainer { /** Create the detector geometry */ void ConstructGeometry(); - /** This method is an example of how to add your own point - * of type TimeRpcPoint to the clones array - */ - UpstreamTaggerPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - TVector3 Lpos, TVector3 Lmom); - - virtual void EndOfEvent(); - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } Double_t module[11][3]; // x,y,z centre positions for each module // TODO Avoid 1-indexed array! - /** Track information to be stored until the track leaves the active volume.*/ - Int_t fEventID; //! event index - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss - /** Detector parameters.*/ Double_t det_zPos; //! z-position of detector (set via SetZposition) @@ -129,13 +95,12 @@ class UpstreamTagger : public FairDetector, public ISTLPointContainer { TGeoVolume* UpstreamTagger_fulldet; // Timing_detector_1 object TGeoVolume* scoringPlaneUBText; // new scoring plane /** container for data points */ - std::vector* fUpstreamTaggerPoints; UpstreamTagger(const UpstreamTagger&); UpstreamTagger& operator=(const UpstreamTagger&); Int_t InitMedium(const char* name); - ClassDef(UpstreamTagger, 2) + ClassDefOverride(UpstreamTagger, 2) }; #endif // UPSTREAMTAGGER_UPSTREAMTAGGER_H_ diff --git a/splitcal/splitcal.cxx b/splitcal/splitcal.cxx index 8af9a04b55..77c7b97e43 100644 --- a/splitcal/splitcal.cxx +++ b/splitcal/splitcal.cxx @@ -37,42 +37,11 @@ using std::cout; using std::endl; splitcal::splitcal() - : FairDetector("splitcal", kTRUE, kSplitCal), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fsplitcalPoints(nullptr) {} + : Detector("splitcal", kTRUE, kSplitCal) {} splitcal::splitcal(const char* name, Bool_t active) - : FairDetector(name, active, kSplitCal), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fsplitcalPoints(nullptr) {} - -splitcal::~splitcal() { - if (fsplitcalPoints) { - fsplitcalPoints->clear(); - delete fsplitcalPoints; - } -} + : Detector(name, active, kSplitCal) {} -void splitcal::Initialize() { - FairDetector::Initialize(); - // FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); - // splitcalGeoPar* - // par=(splitcalGeoPar*)(rtdb->getContainer("splitcalGeoPar")); -} // ----- Private method InitMedium Int_t splitcal::InitMedium(const char* name) { static FairGeoLoader* geoLoad = FairGeoLoader::Instance(); @@ -144,24 +113,10 @@ Bool_t splitcal::ProcessHits(FairVolume* vol) { return kTRUE; } -void splitcal::EndOfEvent() { fsplitcalPoints->clear(); } - -void splitcal::Register() { - /** This will create a branch in the output tree called - splitcalPoint, setting the last parameter to kFALSE means: - this collection will not be written to the file, it will exist - only during the simulation. - */ - - fsplitcalPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny("splitcalPoint", fsplitcalPoints, - kTRUE); -} - TClonesArray* splitcal::GetCollection(Int_t iColl) const { return nullptr; } void splitcal::UpdatePointTrackIndices(const std::map& indexMap) { - for (auto& point : *fsplitcalPoints) { + for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); if (iter != indexMap.end()) { @@ -171,8 +126,6 @@ void splitcal::UpdatePointTrackIndices(const std::map& indexMap) { } } -void splitcal::Reset() { fsplitcalPoints->clear(); } - void splitcal::SetZStart(Double_t ZStart) { fZStart = ZStart; } void splitcal::SetEmpty(Double_t Empty, Double_t BigGap, Double_t ActiveECAL_gas_gap, @@ -450,12 +403,3 @@ void splitcal::ConstructGeometry() { // c1->SaveAs(TString("splitcal.eps")); // c1->SaveAs(TString("splitcal.pdf")); } - -splitcalPoint* splitcal::AddHit(Int_t eventID, Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, - Int_t pdgCode) { - fsplitcalPoints->emplace_back(eventID, trackID, detID, pos, mom, time, length, - eLoss, pdgCode); - return &(fsplitcalPoints->back()); -} diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index af0c4e0890..fcceaf6220 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -8,8 +8,7 @@ #include #include -#include "FairDetector.h" -#include "ISTLPointContainer.h" +#include "Detector.h" #include "TLorentzVector.h" #include "TVector3.h" @@ -17,7 +16,7 @@ class splitcalPoint; class FairVolume; class TClonesArray; -class splitcal : public FairDetector, public ISTLPointContainer { +class splitcal : public SHiP::Detector { public: /** Name : Detector Name * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -29,28 +28,19 @@ class splitcal : public FairDetector, public ISTLPointContainer { splitcal(); /** destructor */ - virtual ~splitcal(); - - /** Initialization of the detector is done here */ - virtual void Initialize(); + virtual ~splitcal()=default; /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Registers the produced collections in FAIRRootManager. */ - virtual void Register(); - /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** has to be called after each event to reset the containers */ - virtual void Reset(); - void SetZStart(Double_t ZStart); void SetEmpty(Double_t Empty, Double_t BigGap, Double_t ActiveECAL_gas_gap, Double_t first_precision_layer, Double_t second_precision_layer, @@ -81,13 +71,6 @@ class splitcal : public FairDetector, public ISTLPointContainer { /** Create the detector geometry */ void ConstructGeometry(); - /** This method is an example of how to add your own point - * of type splitcalPoint to the clones array - */ - splitcalPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, TVector3 pos, - TVector3 mom, Double_t time, Double_t length, - Double_t eLoss, Int_t pdgcode); - /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. */ @@ -96,26 +79,11 @@ class splitcal : public FairDetector, public ISTLPointContainer { ; } virtual void SetSpecialPhysicsCuts() { ; } - virtual void EndOfEvent(); - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } private: /** Track information to be stored until the track leaves the active volume. */ - Int_t fEventID; //! event id; - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss Double_t fActiveECALThickness, fActiveHCALThickness, fFilterECALThickness, xfFilterECALThickness, fFilterECALThickness_first, fFilterHCALThickness; Double_t fActiveECALMaterial, fActiveHCALMaterial, fFilterECALMaterial, @@ -135,8 +103,6 @@ class splitcal : public FairDetector, public ISTLPointContainer { /** container for data points */ - std::vector* fsplitcalPoints; - splitcal(const splitcal&); splitcal& operator=(const splitcal&); Int_t InitMedium(const char* name); diff --git a/strawtubes/strawtubes.cxx b/strawtubes/strawtubes.cxx index 57d45f2b5c..e9fe400fb7 100644 --- a/strawtubes/strawtubes.cxx +++ b/strawtubes/strawtubes.cxx @@ -42,55 +42,16 @@ using std::cout; using std::endl; strawtubes::strawtubes() - : FairDetector("strawtubes", kTRUE, kStraw), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fMedium("air"), - fstrawtubesPoints(nullptr) {} + : Detector("strawtubes", kTRUE, kStraw), + fMedium("air"){} strawtubes::strawtubes(std::string medium) - : FairDetector("strawtubes", kTRUE, kStraw), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fMedium(medium), - fstrawtubesPoints(nullptr) {} + : Detector("strawtubes", kTRUE, kStraw), + fMedium(medium) {} strawtubes::strawtubes(const char* name, Bool_t active) - : FairDetector(name, active, kStraw), - fEventID(-1), - fTrackID(-1), - fVolumeID(-1), - fPos(), - fMom(), - fTime(-1.), - fLength(-1.), - fELoss(-1), - fstrawtubesPoints(nullptr) {} - -strawtubes::~strawtubes() { - if (fstrawtubesPoints) { - fstrawtubesPoints->clear(); - delete fstrawtubesPoints; - } -} + : Detector(name, active, kStraw) {} -void strawtubes::Initialize() { - FairDetector::Initialize(); - // FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); - // vetoGeoPar* par=(vetoGeoPar*)(rtdb->getContainer("vetoGeoPar")); -} // ----- Private method InitMedium Int_t strawtubes::InitMedium(const char* name) { @@ -191,25 +152,12 @@ Bool_t strawtubes::ProcessHits(FairVolume* vol) { return kTRUE; } -void strawtubes::EndOfEvent() { fstrawtubesPoints->clear(); } - -void strawtubes::Register() { - /** This will create a branch in the output tree called - strawtubesPoint, setting the last parameter to kFALSE means: - this collection will not be written to the file, it will exist - only during the simulation. - */ - - fstrawtubesPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny("strawtubesPoint", fstrawtubesPoints, - kTRUE); -} TClonesArray* strawtubes::GetCollection(Int_t iColl) const { return nullptr; } void strawtubes::UpdatePointTrackIndices( const std::map& indexMap) { - for (auto& point : *fstrawtubesPoints) { + for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); if (iter != indexMap.end()) { @@ -219,7 +167,6 @@ void strawtubes::UpdatePointTrackIndices( } } -void strawtubes::Reset() { fstrawtubesPoints->clear(); } void strawtubes::SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4) { f_T1_z = z1; //! z-position of tracking station 1 @@ -595,11 +542,4 @@ void strawtubes::StrawEndPoints(Int_t fDetectorID, TVector3& vbot, vtop.SetXYZ(Gtop[0], Gtop[1], Gtop[2]); vbot.SetXYZ(Gbot[0], Gbot[1], Gbot[2]); } -strawtubesPoint* strawtubes::AddHit(Int_t eventID, Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, - Int_t pdgCode, Double_t dist2Wire) { - fstrawtubesPoints->emplace_back(eventID, trackID, detID, pos, mom, time, - length, eLoss, pdgCode, dist2Wire); - return &(fstrawtubesPoints->back()); -} + diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index f820a911d3..343cc7659c 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -8,8 +8,7 @@ #include #include -#include "FairDetector.h" -#include "ISTLPointContainer.h" +#include "Detector.h" #include "TLorentzVector.h" #include "TVector3.h" @@ -18,7 +17,7 @@ class FairVolume; class TClonesArray; class tuple; -class strawtubes : public FairDetector, public ISTLPointContainer { +class strawtubes : public SHiP::Detector { public: /** Name : Detector Name * Active: kTRUE for active detectors (ProcessHits() will be called) @@ -32,18 +31,13 @@ class strawtubes : public FairDetector, public ISTLPointContainer { strawtubes(); /** destructor */ - virtual ~strawtubes(); - - /** Initialization of the detector is done here */ - virtual void Initialize(); + virtual ~strawtubes() = default; /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Registers the produced collections in FAIRRootManager. */ - virtual void Register(); /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; @@ -51,8 +45,6 @@ class strawtubes : public FairDetector, public ISTLPointContainer { /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - /** has to be called after each event to reset the containers */ - virtual void Reset(); void SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4); void SetApertureArea(Double_t width, Double_t height); @@ -77,14 +69,6 @@ class strawtubes : public FairDetector, public ISTLPointContainer { /** Create the detector geometry */ void ConstructGeometry(); - /** This method is an example of how to add your own point - * of type strawtubesPoint to the clones array - */ - strawtubesPoint* AddHit(Int_t eventID, Int_t trackID, Int_t detID, - TVector3 pos, TVector3 mom, Double_t time, - Double_t length, Double_t eLoss, Int_t pdgCode, - Double_t dist2Wire); - /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. */ @@ -93,26 +77,11 @@ class strawtubes : public FairDetector, public ISTLPointContainer { ; } virtual void SetSpecialPhysicsCuts() { ; } - virtual void EndOfEvent(); - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } private: /** Track information to be stored until the track leaves the active volume. */ - Int_t fEventID; //! event id - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! position at entrance - TLorentzVector fMom; //! momentum at entrance - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss Double_t f_T1_z; //! z-position of tracking station 1 Double_t f_T2_z; //! z-position of tracking station 2 Double_t f_T3_z; //! z-position of tracking station 3 @@ -136,8 +105,6 @@ class strawtubes : public FairDetector, public ISTLPointContainer { std::string fMedium; //! vacuum box medium /** container for data points */ - std::vector* fstrawtubesPoints; - strawtubes(const strawtubes&); strawtubes& operator=(const strawtubes&); Int_t InitMedium(const char* name); From ec117cc0284e5f1dd813136e80df7c1f10334564 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:12:41 +0000 Subject: [PATCH 31/53] style: pre-commit fixes --- Detector/Detector.h | 5 +++-- UpstreamTagger/UpstreamTagger.cxx | 2 -- UpstreamTagger/UpstreamTagger.h | 2 -- splitcal/splitcal.cxx | 3 +-- splitcal/splitcal.h | 2 +- strawtubes/strawtubes.cxx | 9 ++------- strawtubes/strawtubes.h | 2 -- 7 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 61f0f8355f..4f2a9e4bfa 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -5,8 +5,9 @@ #ifndef DETECTOR_DETECTOR_H_ #define DETECTOR_DETECTOR_H_ -#include #include +#include + #include "DetectorPoint.h" #include "FairDetector.h" #include "FairRootManager.h" @@ -34,7 +35,7 @@ class Detector : public FairDetector, public ISTLPointContainer { Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0) {}; - template + template PointType* AddHit(Args&&... args) { fDetPoints->emplace_back(std::forward(args)...); return &(fDetPoints->back()); diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index ba5f65e33c..cf4e64f502 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -147,7 +147,6 @@ void UpstreamTagger::UpdatePointTrackIndices( } } - void UpstreamTagger::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); @@ -179,4 +178,3 @@ void UpstreamTagger::ConstructGeometry() { return; } - diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index 33139d315c..7f955e4c54 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -55,7 +55,6 @@ class UpstreamTagger : public SHiP::Detector { /** destructor */ virtual ~UpstreamTagger() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ @@ -78,7 +77,6 @@ class UpstreamTagger : public SHiP::Detector { /** Create the detector geometry */ void ConstructGeometry(); - Double_t module[11][3]; // x,y,z centre positions for each module // TODO Avoid 1-indexed array! diff --git a/splitcal/splitcal.cxx b/splitcal/splitcal.cxx index 77c7b97e43..9beff5f13c 100644 --- a/splitcal/splitcal.cxx +++ b/splitcal/splitcal.cxx @@ -36,8 +36,7 @@ using std::cout; using std::endl; -splitcal::splitcal() - : Detector("splitcal", kTRUE, kSplitCal) {} +splitcal::splitcal() : Detector("splitcal", kTRUE, kSplitCal) {} splitcal::splitcal(const char* name, Bool_t active) : Detector(name, active, kSplitCal) {} diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index fcceaf6220..78707a007f 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -28,7 +28,7 @@ class splitcal : public SHiP::Detector { splitcal(); /** destructor */ - virtual ~splitcal()=default; + virtual ~splitcal() = default; /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) diff --git a/strawtubes/strawtubes.cxx b/strawtubes/strawtubes.cxx index e9fe400fb7..c28f68410b 100644 --- a/strawtubes/strawtubes.cxx +++ b/strawtubes/strawtubes.cxx @@ -42,17 +42,14 @@ using std::cout; using std::endl; strawtubes::strawtubes() - : Detector("strawtubes", kTRUE, kStraw), - fMedium("air"){} + : Detector("strawtubes", kTRUE, kStraw), fMedium("air") {} strawtubes::strawtubes(std::string medium) - : Detector("strawtubes", kTRUE, kStraw), - fMedium(medium) {} + : Detector("strawtubes", kTRUE, kStraw), fMedium(medium) {} strawtubes::strawtubes(const char* name, Bool_t active) : Detector(name, active, kStraw) {} - // ----- Private method InitMedium Int_t strawtubes::InitMedium(const char* name) { static FairGeoLoader* geoLoad = FairGeoLoader::Instance(); @@ -152,7 +149,6 @@ Bool_t strawtubes::ProcessHits(FairVolume* vol) { return kTRUE; } - TClonesArray* strawtubes::GetCollection(Int_t iColl) const { return nullptr; } void strawtubes::UpdatePointTrackIndices( @@ -542,4 +538,3 @@ void strawtubes::StrawEndPoints(Int_t fDetectorID, TVector3& vbot, vtop.SetXYZ(Gtop[0], Gtop[1], Gtop[2]); vbot.SetXYZ(Gbot[0], Gbot[1], Gbot[2]); } - diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index 343cc7659c..80f0738db4 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -38,14 +38,12 @@ class strawtubes : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ virtual TClonesArray* GetCollection(Int_t iColl) const; /** Update track indices in point collection (for std::vector migration) */ void UpdatePointTrackIndices(const std::map& indexMap); - void SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4); void SetApertureArea(Double_t width, Double_t height); void SetStrawDiameter(Double_t outer_straw_diameter, Double_t wall_thickness); From 30f112b19e4a0be3f6e1f4209eff2f4901621816 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 16:28:02 +0000 Subject: [PATCH 32/53] move more to base class --- Detector/Detector.h | 18 +++++++++++++++--- TimeDet/TimeDet.cxx | 12 ------------ TimeDet/TimeDet.h | 5 ----- UpstreamTagger/UpstreamTagger.cxx | 16 ---------------- UpstreamTagger/UpstreamTagger.h | 6 ------ splitcal/splitcal.cxx | 13 ------------- splitcal/splitcal.h | 8 +------- strawtubes/strawtubes.cxx | 14 -------------- strawtubes/strawtubes.h | 6 ------ veto/veto.cxx | 13 ------------- veto/veto.h | 6 ------ 11 files changed, 16 insertions(+), 101 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 4f2a9e4bfa..ee56572727 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -30,8 +30,7 @@ class Detector : public FairDetector, public ISTLPointContainer { fMom(), fTime(-1.), fLength(-1.), - fELoss(-1), - fDetPoints(NULL) {}; + fELoss(-1) {}; Detector(const char* Name, Bool_t Active) : Detector(Name, Active, 0) {}; @@ -56,6 +55,20 @@ class Detector : public FairDetector, public ISTLPointContainer { FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); }; + virtual TClonesArray* GetCollection(Int_t iColl) const { return nullptr; } + + virtual void UpdatePointTrackIndices( + const std::map& indexMap) { + for (auto& point : *fDetPoints) { + Int_t oldTrackID = point.GetTrackID(); + auto iter = indexMap.find(oldTrackID); + if (iter != indexMap.end()) { + point.SetTrackID(iter->second); + point.SetLink(FairLink("MCTrack", iter->second)); + } + } + } + virtual void FinishPrimary() { ; } virtual void FinishRun() { ; } virtual void BeginPrimary() { ; } @@ -76,7 +89,6 @@ class Detector : public FairDetector, public ISTLPointContainer { std::vector* fDetPoints = nullptr; TGeoVolume* fDetector = nullptr; // Detector object - private: }; } // namespace SHiP diff --git a/TimeDet/TimeDet.cxx b/TimeDet/TimeDet.cxx index 9fce9e58a4..ccb5958280 100644 --- a/TimeDet/TimeDet.cxx +++ b/TimeDet/TimeDet.cxx @@ -168,18 +168,6 @@ Bool_t TimeDet::ProcessHits(FairVolume* vol) { return kTRUE; } -TClonesArray* TimeDet::GetCollection(Int_t iColl) const { return nullptr; } - -void TimeDet::UpdatePointTrackIndices(const std::map& indexMap) { - for (auto& point : *fDetPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } - } -} void TimeDet::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index 1d35f17d74..ac9e1c7121 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -38,11 +38,6 @@ class TimeDet : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ - virtual TClonesArray* GetCollection(Int_t iColl) const; - - /** Update track indices in point collection (for std::vector migration) */ - void UpdatePointTrackIndices(const std::map& indexMap); /** Sets detector position along z */ void SetZposition(Double_t z) { fzPos = z; } diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index cf4e64f502..28319f60c7 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -131,22 +131,6 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { return kTRUE; } -TClonesArray* UpstreamTagger::GetCollection(Int_t iColl) const { - return nullptr; -} - -void UpstreamTagger::UpdatePointTrackIndices( - const std::map& indexMap) { - for (auto& point : *fDetPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } - } -} - void UpstreamTagger::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index 7f955e4c54..9d381fcc88 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -60,12 +60,6 @@ class UpstreamTagger : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ - virtual TClonesArray* GetCollection(Int_t iColl) const; - - /** Update track indices in point collection (for std::vector migration) */ - void UpdatePointTrackIndices(const std::map& indexMap); - /** Sets detector position and sizes */ void SetZposition(Double_t z) { det_zPos = z; } void SetBoxDimensions(Double_t x, Double_t y, Double_t z) { diff --git a/splitcal/splitcal.cxx b/splitcal/splitcal.cxx index 9beff5f13c..4f4f7cb4b5 100644 --- a/splitcal/splitcal.cxx +++ b/splitcal/splitcal.cxx @@ -112,19 +112,6 @@ Bool_t splitcal::ProcessHits(FairVolume* vol) { return kTRUE; } -TClonesArray* splitcal::GetCollection(Int_t iColl) const { return nullptr; } - -void splitcal::UpdatePointTrackIndices(const std::map& indexMap) { - for (auto& point : *fDetPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } - } -} - void splitcal::SetZStart(Double_t ZStart) { fZStart = ZStart; } void splitcal::SetEmpty(Double_t Empty, Double_t BigGap, Double_t ActiveECAL_gas_gap, diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index 78707a007f..2d23c17b2d 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -28,19 +28,13 @@ class splitcal : public SHiP::Detector { splitcal(); /** destructor */ - virtual ~splitcal() = default; + virtual ~splitcal()=default; /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ - virtual TClonesArray* GetCollection(Int_t iColl) const; - - /** Update track indices in point collection (for std::vector migration) */ - void UpdatePointTrackIndices(const std::map& indexMap); - void SetZStart(Double_t ZStart); void SetEmpty(Double_t Empty, Double_t BigGap, Double_t ActiveECAL_gas_gap, Double_t first_precision_layer, Double_t second_precision_layer, diff --git a/strawtubes/strawtubes.cxx b/strawtubes/strawtubes.cxx index c28f68410b..5f813e3ed3 100644 --- a/strawtubes/strawtubes.cxx +++ b/strawtubes/strawtubes.cxx @@ -149,20 +149,6 @@ Bool_t strawtubes::ProcessHits(FairVolume* vol) { return kTRUE; } -TClonesArray* strawtubes::GetCollection(Int_t iColl) const { return nullptr; } - -void strawtubes::UpdatePointTrackIndices( - const std::map& indexMap) { - for (auto& point : *fDetPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } - } -} - void strawtubes::SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4) { f_T1_z = z1; //! z-position of tracking station 1 diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index 80f0738db4..499a6061e8 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -38,12 +38,6 @@ class strawtubes : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ - virtual TClonesArray* GetCollection(Int_t iColl) const; - - /** Update track indices in point collection (for std::vector migration) */ - void UpdatePointTrackIndices(const std::map& indexMap); - void SetzPositions(Double_t z1, Double_t z2, Double_t z3, Double_t z4); void SetApertureArea(Double_t width, Double_t height); void SetStrawDiameter(Double_t outer_straw_diameter, Double_t wall_thickness); diff --git a/veto/veto.cxx b/veto/veto.cxx index 3e5e89ccc2..192f6eaff6 100644 --- a/veto/veto.cxx +++ b/veto/veto.cxx @@ -831,19 +831,6 @@ void veto::PreTrack() { } } -TClonesArray* veto::GetCollection(Int_t iColl) const { return nullptr; } - -void veto::UpdatePointTrackIndices(const std::map& indexMap) { - for (auto& point : *fvetoPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } - } -} - /** * @brief Constructs the detector geometry. * diff --git a/veto/veto.h b/veto/veto.h index 47c44c2c86..796f150501 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -43,12 +43,6 @@ class veto : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Gets the produced collections */ - virtual TClonesArray* GetCollection(Int_t iColl) const; - - /** Update track indices in point collection (for std::vector migration) */ - void UpdatePointTrackIndices(const std::map& indexMap); - void SetFastMuon() { fFastMuon = true; } // kill all tracks except of muons void SetFollowMuon() { fFollowMuon = true; From a307de27ca2487face7eb96cf5b5a9ac6e1abec1 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 16:29:23 +0000 Subject: [PATCH 33/53] tidy --- Detector/CMakeLists.txt | 2 +- Detector/LinkDef.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Detector/CMakeLists.txt b/Detector/CMakeLists.txt index 4f1f98d575..c63a559409 100644 --- a/Detector/CMakeLists.txt +++ b/Detector/CMakeLists.txt @@ -3,7 +3,7 @@ ship_add_library( NAME Detector - SOURCES Detector.h DetectorPoint.cxx + SOURCES DetectorPoint.cxx LINKDEF LinkDef.h DEPENDENCIES Base ShipData FairLogger::FairLogger ) diff --git a/Detector/LinkDef.h b/Detector/LinkDef.h index d38facd5fc..3fb8cb8cd0 100644 --- a/Detector/LinkDef.h +++ b/Detector/LinkDef.h @@ -10,7 +10,6 @@ #pragma link off all functions; #pragma link C++ namespace SHiP; -#pragma link C++ class SHiP::Detector+; #pragma link C++ class SHiP::DetectorPoint+; #endif From 103c373b878d35ab4af4ab818646d3a02d0ffaf3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:30:54 +0000 Subject: [PATCH 34/53] style: pre-commit fixes --- Detector/Detector.h | 17 ++++++++--------- TimeDet/TimeDet.cxx | 1 - TimeDet/TimeDet.h | 1 - splitcal/splitcal.h | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index ee56572727..df67de61c3 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -57,16 +57,15 @@ class Detector : public FairDetector, public ISTLPointContainer { virtual TClonesArray* GetCollection(Int_t iColl) const { return nullptr; } - virtual void UpdatePointTrackIndices( - const std::map& indexMap) { - for (auto& point : *fDetPoints) { - Int_t oldTrackID = point.GetTrackID(); - auto iter = indexMap.find(oldTrackID); - if (iter != indexMap.end()) { - point.SetTrackID(iter->second); - point.SetLink(FairLink("MCTrack", iter->second)); - } + virtual void UpdatePointTrackIndices(const std::map& indexMap) { + for (auto& point : *fDetPoints) { + Int_t oldTrackID = point.GetTrackID(); + auto iter = indexMap.find(oldTrackID); + if (iter != indexMap.end()) { + point.SetTrackID(iter->second); + point.SetLink(FairLink("MCTrack", iter->second)); } + } } virtual void FinishPrimary() { ; } diff --git a/TimeDet/TimeDet.cxx b/TimeDet/TimeDet.cxx index ccb5958280..75f3d37e3d 100644 --- a/TimeDet/TimeDet.cxx +++ b/TimeDet/TimeDet.cxx @@ -168,7 +168,6 @@ Bool_t TimeDet::ProcessHits(FairVolume* vol) { return kTRUE; } - void TimeDet::ConstructGeometry() { TGeoVolume* top = gGeoManager->GetTopVolume(); diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index ac9e1c7121..ef9924cc02 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -38,7 +38,6 @@ class TimeDet : public SHiP::Detector { */ virtual Bool_t ProcessHits(FairVolume* v = 0); - /** Sets detector position along z */ void SetZposition(Double_t z) { fzPos = z; } void SetBarZspacing(Double_t row, Double_t column) { diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index 2d23c17b2d..39b80780b1 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -28,7 +28,7 @@ class splitcal : public SHiP::Detector { splitcal(); /** destructor */ - virtual ~splitcal()=default; + virtual ~splitcal() = default; /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) From ed87675d1c8aee938af3e4c4e43a71a6fab95e9e Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 17:01:46 +0000 Subject: [PATCH 35/53] fix --- Detector/Detector.h | 1 + TimeDet/TimeDet.h | 2 +- UpstreamTagger/UpstreamTagger.h | 2 +- splitcal/splitcal.h | 2 +- strawtubes/strawtubes.h | 2 +- veto/veto.h | 4 +--- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index ee56572727..422f4281e8 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -89,6 +89,7 @@ class Detector : public FairDetector, public ISTLPointContainer { std::vector* fDetPoints = nullptr; TGeoVolume* fDetector = nullptr; // Detector object + }; } // namespace SHiP diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index ac9e1c7121..23dd43ee65 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -85,7 +85,7 @@ class TimeDet : public SHiP::Detector { TimeDet& operator=(const TimeDet&); Int_t InitMedium(const char* name); - ClassDef(TimeDet, 4) + ClassDef(TimeDet, 5) }; #endif // TIMEDET_TIMEDET_H_ diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index 9d381fcc88..977704b944 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -92,7 +92,7 @@ class UpstreamTagger : public SHiP::Detector { UpstreamTagger& operator=(const UpstreamTagger&); Int_t InitMedium(const char* name); - ClassDefOverride(UpstreamTagger, 2) + ClassDefOverride(UpstreamTagger, 3) }; #endif // UPSTREAMTAGGER_UPSTREAMTAGGER_H_ diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index 2d23c17b2d..bcc40ce2fe 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -101,7 +101,7 @@ class splitcal : public SHiP::Detector { splitcal& operator=(const splitcal&); Int_t InitMedium(const char* name); - ClassDef(splitcal, 2) + ClassDef(splitcal, 3) }; #endif // SPLITCAL_SPLITCAL_H_ diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index 499a6061e8..3881ae68b6 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -100,7 +100,7 @@ class strawtubes : public SHiP::Detector { strawtubes(const strawtubes&); strawtubes& operator=(const strawtubes&); Int_t InitMedium(const char* name); - ClassDef(strawtubes, 7) + ClassDef(strawtubes, 8) }; #endif // STRAWTUBES_STRAWTUBES_H_ diff --git a/veto/veto.h b/veto/veto.h index 796f150501..ea4095cea3 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -134,8 +134,6 @@ class veto : public SHiP::Detector { Int_t fUseSupport; //! Flag option for Liquid Scintillator (Default=True). Int_t fLiquidVeto; - /** container for data points */ - std::vector* fvetoPoints; veto(const veto&); veto& operator=(const veto&); @@ -208,7 +206,7 @@ class veto : public SHiP::Detector { TGeoVolume* MakeSegments(); - ClassDef(veto, 2) + ClassDef(veto, 3) }; #endif // VETO_VETO_H_ From e0949eb8e514ec402b84cbb48f9e06c7e3458220 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:03:04 +0000 Subject: [PATCH 36/53] style: pre-commit fixes --- Detector/Detector.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 205a644474..df67de61c3 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -88,7 +88,6 @@ class Detector : public FairDetector, public ISTLPointContainer { std::vector* fDetPoints = nullptr; TGeoVolume* fDetector = nullptr; // Detector object - }; } // namespace SHiP From ddafb6ea5cdef186b83b53b1aa50e64e8202596a Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 20:41:07 +0000 Subject: [PATCH 37/53] fix streaming --- TimeDet/LinkDef.h | 1 + UpstreamTagger/LinkDef.h | 1 + splitcal/LinkDef.h | 1 + strawtubes/LinkDef.h | 1 + veto/LinkDef.h | 1 + veto/veto.h | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TimeDet/LinkDef.h b/TimeDet/LinkDef.h index 431140059e..02091953e8 100644 --- a/TimeDet/LinkDef.h +++ b/TimeDet/LinkDef.h @@ -10,6 +10,7 @@ #pragma link C++ namespace SHiP; #pragma link C++ class TimeDet+; #pragma link C++ class TimeDetPoint+; +#pragma link C++ class std::vector+; #pragma link C++ class TimeDetHit+; #endif diff --git a/UpstreamTagger/LinkDef.h b/UpstreamTagger/LinkDef.h index bbd35cebec..200c8f6b50 100644 --- a/UpstreamTagger/LinkDef.h +++ b/UpstreamTagger/LinkDef.h @@ -11,6 +11,7 @@ #pragma link C++ class UpstreamTagger+; #pragma link C++ class UpstreamTaggerPoint+; +#pragma link C++ class std::vector+; #pragma link C++ class UpstreamTaggerHit+; #endif diff --git a/splitcal/LinkDef.h b/splitcal/LinkDef.h index eeaf25fc05..bda49b52a7 100644 --- a/splitcal/LinkDef.h +++ b/splitcal/LinkDef.h @@ -10,6 +10,7 @@ #pragma link C++ class splitcalContFact; #pragma link C++ class splitcal+; #pragma link C++ class splitcalPoint+; +#pragma link C++ class std::vector+; #pragma link C++ class splitcalHit+; #pragma link C++ class splitcalCluster+; #endif diff --git a/strawtubes/LinkDef.h b/strawtubes/LinkDef.h index 046f3a21bf..9453e5e59e 100644 --- a/strawtubes/LinkDef.h +++ b/strawtubes/LinkDef.h @@ -10,6 +10,7 @@ #pragma link C++ class strawtubesContFact; #pragma link C++ class strawtubes+; #pragma link C++ class strawtubesPoint+; +#pragma link C++ class std::vector+; #pragma link C++ class strawtubesHit+; #pragma link C++ class Tracklet+; diff --git a/veto/LinkDef.h b/veto/LinkDef.h index 95c525e15d..6bdcf2efa9 100644 --- a/veto/LinkDef.h +++ b/veto/LinkDef.h @@ -10,6 +10,7 @@ #pragma link C++ class vetoContFact; #pragma link C++ class veto+; #pragma link C++ class vetoPoint+; +#pragma link C++ class std::vector+; #pragma link C++ class vetoHit+; #pragma link C++ class vetoHitOnTrack+; diff --git a/veto/veto.h b/veto/veto.h index 319e5cc19b..40e80b52cd 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -206,7 +206,7 @@ class veto : public SHiP::Detector { TGeoVolume* MakeSegments(); - ClassDef(veto, 3) + ClassDef(veto, 4) }; #endif // VETO_VETO_H_ From 8c93d178951feee709ccd17aedf4b6cf46b019ae Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 21:16:34 +0000 Subject: [PATCH 38/53] refinement --- Detector/Detector.h | 29 +++++++++++++++-------------- TimeDet/TimeDet.h | 7 ++----- UpstreamTagger/UpstreamTagger.h | 2 +- splitcal/splitcal.h | 5 ++--- strawtubes/strawtubes.h | 5 ++--- veto/veto.h | 7 +++---- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index df67de61c3..6c8c96b0b9 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -41,23 +41,23 @@ class Detector : public FairDetector, public ISTLPointContainer { }; /** Create the detector geometry */ - virtual void ConstructGeometry() = 0; + virtual void ConstructGeometry() override = 0; - virtual void Initialize() { FairDetector::Initialize(); }; + virtual void Initialize() override { FairDetector::Initialize(); } - virtual void Reset() { fDetPoints->clear(); }; + virtual void Reset() override { fDetPoints->clear(); } - virtual void EndOfEvent() { fDetPoints->clear(); }; + virtual void EndOfEvent() override { fDetPoints->clear(); } - virtual void Register() { + virtual void Register() override { fDetPoints = new std::vector(); static PointType t; FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); - }; + } - virtual TClonesArray* GetCollection(Int_t iColl) const { return nullptr; } + virtual TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; } - virtual void UpdatePointTrackIndices(const std::map& indexMap) { + virtual void UpdatePointTrackIndices(const std::map& indexMap) override { for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); @@ -68,12 +68,13 @@ class Detector : public FairDetector, public ISTLPointContainer { } } - virtual void FinishPrimary() { ; } - virtual void FinishRun() { ; } - virtual void BeginPrimary() { ; } - virtual void PostTrack() { ; } - virtual void PreTrack() { ; } - virtual void BeginEvent() { ; } + virtual void SetSpecialPhysicsCuts() override { ; } + virtual void FinishPrimary() override { ; } + virtual void FinishRun() override { ; } + virtual void BeginPrimary() override { ; } + virtual void PostTrack() override { ; } + virtual void PreTrack() override { ; } + virtual void BeginEvent() override { ; } protected: /** Track information to be stored until the track leaves the active volume.*/ diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index 56b51114e0..982787ae14 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -30,9 +30,6 @@ class TimeDet : public SHiP::Detector { /** destructor */ virtual ~TimeDet() = default; - /** Initialization of the detector is done here */ - // virtual void Initialize(); - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ @@ -54,7 +51,7 @@ class TimeDet : public SHiP::Detector { double GetZBar(int ir, int ic) const; /** Create the detector geometry */ - void ConstructGeometry(); + void ConstructGeometry() override; private: /** Detector parameters.*/ @@ -84,7 +81,7 @@ class TimeDet : public SHiP::Detector { TimeDet& operator=(const TimeDet&); Int_t InitMedium(const char* name); - ClassDef(TimeDet, 5) + ClassDefOverride(TimeDet, 5) }; #endif // TIMEDET_TIMEDET_H_ diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index da5a63896f..ed28a532d4 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -69,7 +69,7 @@ class UpstreamTagger : public SHiP::Detector { } /** Create the detector geometry */ - void ConstructGeometry(); + void ConstructGeometry() override; Double_t module[11][3]; // x,y,z centre positions for each module // TODO Avoid 1-indexed array! diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index 69044b7d1f..99740886d1 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -63,7 +63,7 @@ class splitcal : public SHiP::Detector { void SetYMax(Double_t yMax); /** Create the detector geometry */ - void ConstructGeometry(); + void ConstructGeometry() override; /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. @@ -72,7 +72,6 @@ class splitcal : public SHiP::Detector { void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override { ; } - virtual void SetSpecialPhysicsCuts() { ; } private: /** Track information to be stored until the track leaves the @@ -101,7 +100,7 @@ class splitcal : public SHiP::Detector { splitcal& operator=(const splitcal&); Int_t InitMedium(const char* name); - ClassDef(splitcal, 3) + ClassDefOverride(splitcal, 3) }; #endif // SPLITCAL_SPLITCAL_H_ diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index dc4e6c893f..423c45fb3d 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -59,7 +59,7 @@ class strawtubes : public SHiP::Detector { Double_t StrawSigmaSpatial() { return sigma_spatial; } /** Create the detector geometry */ - void ConstructGeometry(); + void ConstructGeometry() override; /** The following methods can be implemented if you need to make * any optional action in your detector during the transport. @@ -68,7 +68,6 @@ class strawtubes : public SHiP::Detector { void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override { ; } - virtual void SetSpecialPhysicsCuts() { ; } private: /** Track information to be stored until the track leaves the @@ -100,7 +99,7 @@ class strawtubes : public SHiP::Detector { strawtubes(const strawtubes&); strawtubes& operator=(const strawtubes&); Int_t InitMedium(const char* name); - ClassDef(strawtubes, 8) + ClassDefOverride(strawtubes, 8) }; #endif // STRAWTUBES_STRAWTUBES_H_ diff --git a/veto/veto.h b/veto/veto.h index 40e80b52cd..6c8c7a2f8e 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -57,7 +57,7 @@ class veto : public SHiP::Detector { } /** Create the detector geometry */ - void ConstructGeometry(); + void ConstructGeometry() override; void SetVesselStructure(Float_t a, Float_t b, Float_t c, TString d, Float_t l, TString e, TString f, TString v, Float_t r) { @@ -79,9 +79,8 @@ class veto : public SHiP::Detector { void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override { ; } - virtual void SetSpecialPhysicsCuts() { ; } - virtual void PreTrack(); + void PreTrack() override; inline void SetUseSupport(Int_t use = 1) { fUseSupport = use; } inline Int_t GetUseSupport() const { return fUseSupport; } @@ -206,7 +205,7 @@ class veto : public SHiP::Detector { TGeoVolume* MakeSegments(); - ClassDef(veto, 4) + ClassDefOverride(veto, 3) }; #endif // VETO_VETO_H_ From 615e5573a0c01374153bfc74e1ddefd8fa83cb7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:16:59 +0000 Subject: [PATCH 39/53] style: pre-commit fixes --- Detector/Detector.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 6c8c96b0b9..bf49438f9b 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -55,9 +55,12 @@ class Detector : public FairDetector, public ISTLPointContainer { FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); } - virtual TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; } + virtual TClonesArray* GetCollection(Int_t iColl) const override { + return nullptr; + } - virtual void UpdatePointTrackIndices(const std::map& indexMap) override { + virtual void UpdatePointTrackIndices( + const std::map& indexMap) override { for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); auto iter = indexMap.find(oldTrackID); From 379fa2f1a35ae535e26d5fef06017e26d481e3b3 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 21:22:36 +0000 Subject: [PATCH 40/53] tidy --- Detector/Detector.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index bf49438f9b..a441bbbc3b 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -41,25 +41,25 @@ class Detector : public FairDetector, public ISTLPointContainer { }; /** Create the detector geometry */ - virtual void ConstructGeometry() override = 0; + void ConstructGeometry() override = 0; - virtual void Initialize() override { FairDetector::Initialize(); } + void Initialize() override { FairDetector::Initialize(); } - virtual void Reset() override { fDetPoints->clear(); } + void Reset() override { fDetPoints->clear(); } - virtual void EndOfEvent() override { fDetPoints->clear(); } + void EndOfEvent() override { fDetPoints->clear(); } - virtual void Register() override { + void Register() override { fDetPoints = new std::vector(); static PointType t; FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); } - virtual TClonesArray* GetCollection(Int_t iColl) const override { + TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; } - virtual void UpdatePointTrackIndices( + void UpdatePointTrackIndices( const std::map& indexMap) override { for (auto& point : *fDetPoints) { Int_t oldTrackID = point.GetTrackID(); @@ -71,13 +71,13 @@ class Detector : public FairDetector, public ISTLPointContainer { } } - virtual void SetSpecialPhysicsCuts() override { ; } - virtual void FinishPrimary() override { ; } - virtual void FinishRun() override { ; } - virtual void BeginPrimary() override { ; } - virtual void PostTrack() override { ; } - virtual void PreTrack() override { ; } - virtual void BeginEvent() override { ; } + void SetSpecialPhysicsCuts() override { ; } + void FinishPrimary() override { ; } + void FinishRun() override { ; } + void BeginPrimary() override { ; } + void PostTrack() override { ; } + void PreTrack() override { ; } + void BeginEvent() override { ; } protected: /** Track information to be stored until the track leaves the active volume.*/ From 16219473a865bfde5e9ef79261e1e492fbb151e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:23:07 +0000 Subject: [PATCH 41/53] style: pre-commit fixes --- Detector/Detector.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index a441bbbc3b..bb74eaaa2d 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -55,9 +55,7 @@ class Detector : public FairDetector, public ISTLPointContainer { FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); } - TClonesArray* GetCollection(Int_t iColl) const override { - return nullptr; - } + TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; } void UpdatePointTrackIndices( const std::map& indexMap) override { From ed6a0c494b6451131b5df50e32583744a12201fd Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 21:37:51 +0000 Subject: [PATCH 42/53] inherit destructor --- TimeDet/TimeDet.h | 7 ++----- UpstreamTagger/UpstreamTagger.h | 3 --- splitcal/splitcal.h | 7 ++----- strawtubes/strawtubes.h | 7 ++----- veto/veto.h | 3 --- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/TimeDet/TimeDet.h b/TimeDet/TimeDet.h index 982787ae14..c87033fa4b 100644 --- a/TimeDet/TimeDet.h +++ b/TimeDet/TimeDet.h @@ -27,9 +27,6 @@ class TimeDet : public SHiP::Detector { /** default constructor */ TimeDet(); - /** destructor */ - virtual ~TimeDet() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ @@ -77,8 +74,8 @@ class TimeDet : public SHiP::Detector { Double_t fxOv; //! Overlap along x Double_t fyOv; //! Overlap along y - TimeDet(const TimeDet&); - TimeDet& operator=(const TimeDet&); + TimeDet(const TimeDet&) = delete; + TimeDet& operator=(const TimeDet&) = delete; Int_t InitMedium(const char* name); ClassDefOverride(TimeDet, 5) diff --git a/UpstreamTagger/UpstreamTagger.h b/UpstreamTagger/UpstreamTagger.h index ed28a532d4..c18fac828a 100644 --- a/UpstreamTagger/UpstreamTagger.h +++ b/UpstreamTagger/UpstreamTagger.h @@ -52,9 +52,6 @@ class UpstreamTagger : public SHiP::Detector { /** default constructor */ UpstreamTagger(); - /** destructor */ - virtual ~UpstreamTagger() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ diff --git a/splitcal/splitcal.h b/splitcal/splitcal.h index 99740886d1..9130c219e9 100644 --- a/splitcal/splitcal.h +++ b/splitcal/splitcal.h @@ -27,9 +27,6 @@ class splitcal : public SHiP::Detector { /** default constructor */ splitcal(); - /** destructor */ - virtual ~splitcal() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ @@ -96,8 +93,8 @@ class splitcal : public SHiP::Detector { /** container for data points */ - splitcal(const splitcal&); - splitcal& operator=(const splitcal&); + splitcal(const splitcal&) = delete; + splitcal& operator=(const splitcal&) = delete; Int_t InitMedium(const char* name); ClassDefOverride(splitcal, 3) diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index 423c45fb3d..179609bbd2 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -30,9 +30,6 @@ class strawtubes : public SHiP::Detector { /** default constructor */ strawtubes(); - /** destructor */ - virtual ~strawtubes() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ @@ -96,8 +93,8 @@ class strawtubes : public SHiP::Detector { std::string fMedium; //! vacuum box medium /** container for data points */ - strawtubes(const strawtubes&); - strawtubes& operator=(const strawtubes&); + strawtubes(const strawtubes&) = delete; + strawtubes& operator=(const strawtubes&) = delete; Int_t InitMedium(const char* name); ClassDefOverride(strawtubes, 8) }; diff --git a/veto/veto.h b/veto/veto.h index 6c8c7a2f8e..b71bb754ad 100644 --- a/veto/veto.h +++ b/veto/veto.h @@ -35,9 +35,6 @@ class veto : public SHiP::Detector { veto(); - /** destructor */ - virtual ~veto() = default; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ From 4b3548048b0a335e8a3b421acc3830add8d5855e Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 22:16:41 +0000 Subject: [PATCH 43/53] add static variable --- Detector/Detector.h | 3 +-- Detector/DetectorPoint.h | 3 ++- TimeDet/TimeDetPoint.h | 3 ++- UpstreamTagger/UpstreamTaggerPoint.h | 3 ++- splitcal/splitcalPoint.h | 3 ++- strawtubes/strawtubesPoint.h | 4 ++-- veto/vetoPoint.h | 3 ++- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index a441bbbc3b..6b100b146c 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -51,8 +51,7 @@ class Detector : public FairDetector, public ISTLPointContainer { void Register() override { fDetPoints = new std::vector(); - static PointType t; - FairRootManager::Instance()->RegisterAny(t.GetName(), fDetPoints, kTRUE); + FairRootManager::Instance()->RegisterAny(PointType::BranchName, fDetPoints, kTRUE); } TClonesArray* GetCollection(Int_t iColl) const override { diff --git a/Detector/DetectorPoint.h b/Detector/DetectorPoint.h index d939c92b06..689f7655a8 100644 --- a/Detector/DetectorPoint.h +++ b/Detector/DetectorPoint.h @@ -35,7 +35,8 @@ class DetectorPoint : public FairMCPoint { TVector3 LastPoint() const { return TVector3(fLpos[0], fLpos[1], fLpos[2]); } TVector3 LastMom() const { return TVector3(fLmom[0], fLmom[1], fLmom[2]); } - virtual const char* DetectorName() const { return "GenericDetector"; } + static constexpr const char* BranchName = "GenericDetector"; + virtual const char* DetectorName() const { return BranchName; } virtual void extraPrintInfo() const; diff --git a/TimeDet/TimeDetPoint.h b/TimeDet/TimeDetPoint.h index 2a8ce3ce39..5763f7479e 100644 --- a/TimeDet/TimeDetPoint.h +++ b/TimeDet/TimeDetPoint.h @@ -21,7 +21,8 @@ class TimeDetPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~TimeDetPoint(); - const char* DetectorName() const override { return "timeDetector"; } + static constexpr const char* BranchName = "timeDetector"; + const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; private: diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index 45087ba32e..a88f5231ca 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -22,7 +22,8 @@ class UpstreamTaggerPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~UpstreamTaggerPoint(); - const char* DetectorName() const override { return "UpstreamTagger"; } + static constexpr const char* BranchName = "UpstreamTagger"; + const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; diff --git a/splitcal/splitcalPoint.h b/splitcal/splitcalPoint.h index 311539a817..87f0d43643 100644 --- a/splitcal/splitcalPoint.h +++ b/splitcal/splitcalPoint.h @@ -19,7 +19,8 @@ class splitcalPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~splitcalPoint(); - const char* DetectorName() const override { return "splitcalDetector"; } + static constexpr const char* BranchName = "splitcalDetector"; + const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; private: diff --git a/strawtubes/strawtubesPoint.h b/strawtubes/strawtubesPoint.h index 1905c59100..9fb88a897d 100644 --- a/strawtubes/strawtubesPoint.h +++ b/strawtubes/strawtubesPoint.h @@ -36,8 +36,8 @@ class strawtubesPoint : public SHiP::DetectorPoint { /** Output to screen **/ Double_t dist2Wire() const { return fdist2Wire; } - - const char* DetectorName() const override { return "strawtubesDetector"; } + static constexpr const char* BranchName = "strawtubesDetector"; + const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; private: diff --git a/veto/vetoPoint.h b/veto/vetoPoint.h index 2fe99fa71d..58d605699e 100644 --- a/veto/vetoPoint.h +++ b/veto/vetoPoint.h @@ -33,7 +33,8 @@ class vetoPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~vetoPoint(); - const char* DetectorName() const override { return "vetoDetector"; } + static constexpr const char* BranchName = "vetoDetector"; + const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; /** Output to screen **/ From 9fd1a181df84e071c19847c72e06721ce3785d2e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Mar 2026 22:17:35 +0000 Subject: [PATCH 44/53] style: pre-commit fixes --- Detector/Detector.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Detector/Detector.h b/Detector/Detector.h index 0a7832f428..8f9f23c899 100644 --- a/Detector/Detector.h +++ b/Detector/Detector.h @@ -51,7 +51,8 @@ class Detector : public FairDetector, public ISTLPointContainer { void Register() override { fDetPoints = new std::vector(); - FairRootManager::Instance()->RegisterAny(PointType::BranchName, fDetPoints, kTRUE); + FairRootManager::Instance()->RegisterAny(PointType::BranchName, fDetPoints, + kTRUE); } TClonesArray* GetCollection(Int_t iColl) const override { return nullptr; } From 6bfe325f2e3b98422da5d61642f736efc16dcc34 Mon Sep 17 00:00:00 2001 From: Mark E Smith Date: Sun, 8 Mar 2026 23:07:16 +0000 Subject: [PATCH 45/53] fix naming --- CHANGELOG.md | 1 + TimeDet/TimeDetPoint.h | 2 +- UpstreamTagger/UpstreamTaggerPoint.h | 2 +- splitcal/splitcalPoint.h | 2 +- strawtubes/strawtubesPoint.h | 2 +- veto/vetoPoint.h | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5170f439..4dfb1862b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ it in future. ### Changed +* Implement Detector base class. Now the veto detector uses doubles rather than floats. #1079 * Modernise C++: replace NULL with nullptr, C headers with C++ equivalents, normalise include guards, add override specifier, use = delete for non-copyable classes * Take vectors by const ref in ShipTargetStation::SetLayerPosMat; fix assert logic bug * Expand clang-tidy config with modernize-use-nullptr, modernize-use-override, modernize-use-equals-default, performance-unnecessary-value-param diff --git a/TimeDet/TimeDetPoint.h b/TimeDet/TimeDetPoint.h index 5763f7479e..6f3b680b4c 100644 --- a/TimeDet/TimeDetPoint.h +++ b/TimeDet/TimeDetPoint.h @@ -21,7 +21,7 @@ class TimeDetPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~TimeDetPoint(); - static constexpr const char* BranchName = "timeDetector"; + static constexpr const char* BranchName = "TimeDetPoint"; const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; diff --git a/UpstreamTagger/UpstreamTaggerPoint.h b/UpstreamTagger/UpstreamTaggerPoint.h index a88f5231ca..c4e53318b1 100644 --- a/UpstreamTagger/UpstreamTaggerPoint.h +++ b/UpstreamTagger/UpstreamTaggerPoint.h @@ -22,7 +22,7 @@ class UpstreamTaggerPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~UpstreamTaggerPoint(); - static constexpr const char* BranchName = "UpstreamTagger"; + static constexpr const char* BranchName = "UpstreamTaggerPoint"; const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; diff --git a/splitcal/splitcalPoint.h b/splitcal/splitcalPoint.h index 87f0d43643..81e88f9a84 100644 --- a/splitcal/splitcalPoint.h +++ b/splitcal/splitcalPoint.h @@ -19,7 +19,7 @@ class splitcalPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~splitcalPoint(); - static constexpr const char* BranchName = "splitcalDetector"; + static constexpr const char* BranchName = "splitcalPoint"; const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; diff --git a/strawtubes/strawtubesPoint.h b/strawtubes/strawtubesPoint.h index 9fb88a897d..36ca947328 100644 --- a/strawtubes/strawtubesPoint.h +++ b/strawtubes/strawtubesPoint.h @@ -36,7 +36,7 @@ class strawtubesPoint : public SHiP::DetectorPoint { /** Output to screen **/ Double_t dist2Wire() const { return fdist2Wire; } - static constexpr const char* BranchName = "strawtubesDetector"; + static constexpr const char* BranchName = "strawtubesPoint"; const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; diff --git a/veto/vetoPoint.h b/veto/vetoPoint.h index 58d605699e..b4215c4138 100644 --- a/veto/vetoPoint.h +++ b/veto/vetoPoint.h @@ -33,7 +33,7 @@ class vetoPoint : public SHiP::DetectorPoint { /** Destructor **/ virtual ~vetoPoint(); - static constexpr const char* BranchName = "vetoDetector"; + static constexpr const char* BranchName = "vetoPoint"; const char* DetectorName() const override { return BranchName; } void extraPrintInfo() const override; From 2c7f7a44e14ce9bc525e3b5120f1f90c8bde8cf1 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Tue, 10 Mar 2026 12:58:07 +0100 Subject: [PATCH 46/53] tidy --- shipgen/MuonBackGenerator.cxx | 2 +- strawtubes/strawtubes.h | 1 - strawtubes/strawtubesPoint.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/shipgen/MuonBackGenerator.cxx b/shipgen/MuonBackGenerator.cxx index 17566e95e4..51af7d20ea 100644 --- a/shipgen/MuonBackGenerator.cxx +++ b/shipgen/MuonBackGenerator.cxx @@ -195,7 +195,7 @@ Bool_t MuonBackGenerator::ReadEvent(FairPrimaryGenerator* cpg) { return fUseSTL ? MCTrack_vec->size() : MCTrack->GetEntries(); }; - while (fn < fNevents - 1) { + while (fn < fNevents) { fTree->GetEntry(fn); muList.clear(); moList.clear(); diff --git a/strawtubes/strawtubes.h b/strawtubes/strawtubes.h index 661cf102b1..1d2f16e18c 100644 --- a/strawtubes/strawtubes.h +++ b/strawtubes/strawtubes.h @@ -87,7 +87,6 @@ class strawtubes : public SHiP::Detector { strawtubes(const strawtubes&) = delete; strawtubes& operator=(const strawtubes&) = delete; - ClassDefOverride(strawtubes, 8) }; diff --git a/strawtubes/strawtubesPoint.h b/strawtubes/strawtubesPoint.h index b3d9bac7ef..af56ad8896 100644 --- a/strawtubes/strawtubesPoint.h +++ b/strawtubes/strawtubesPoint.h @@ -36,7 +36,6 @@ class strawtubesPoint : public SHiP::DetectorPoint { /** Output to screen **/ Double_t dist2Wire() const { return fdist2Wire; } - void extraPrintInfo() const override; private: From d3165818c03d5ae9d9bf63ddc48bce68f0d1f315 Mon Sep 17 00:00:00 2001 From: carlgwilliam Date: Wed, 18 Mar 2026 15:03:43 +0000 Subject: [PATCH 47/53] Update analysis_example.py Test from GitHub.com --- examples/analysis_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/analysis_example.py b/examples/analysis_example.py index 33efae5117..efbc014c1e 100644 --- a/examples/analysis_example.py +++ b/examples/analysis_example.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration -"""Example script for usage of the analysis_toolkit for signal selection.""" +"""Example script for usage of the analysis_toolkit for signal selection.""" from argparse import ArgumentParser From af1d27f11fa160a90ed202c94569aa0045e88ffd Mon Sep 17 00:00:00 2001 From: Carl Gwilliam Date: Mon, 16 Mar 2026 17:32:56 +0000 Subject: [PATCH 48/53] Update UBT geometry --- UpstreamTagger/UpstreamTagger.cxx | 10 ++++++---- geometry/ubt_config.yaml | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 752f8c026e..27fd2c0667 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -214,11 +214,13 @@ void UpstreamTagger::ConstructGeometry() TGeoMedium *air = gGeoManager->GetMedium("air"); ShipGeo::InitMedium("mylar"); TGeoMedium *mylar = gGeoManager->GetMedium("mylar"); + ShipGeo::InitMedium("STTmix8020_1bar"); - TGeoMedium *sttmix8020_1bar = gGeoManager->GetMedium("STTmix8020_1bar"); + TGeoMedium *sttmix8020_1bar = gGeoManager->GetMedium("STTmix8020_1bar"); // Should be argon-ethane ShipGeo::InitMedium("tungsten"); - TGeoMedium *tungsten = gGeoManager->GetMedium("tungsten"); + TGeoMedium *tungsten = gGeoManager->GetMedium("tungsten"); // Should be tungsten rhenium ShipGeo::InitMedium(f_frame_material); + TGeoMedium *FrameMatPtr = gGeoManager->GetMedium(f_frame_material); ShipGeo::InitMedium(fMedium.c_str()); TGeoMedium* med = gGeoManager->GetMedium(fMedium.c_str()); @@ -237,7 +239,7 @@ void UpstreamTagger::ConstructGeometry() TGeoBBox* detbox1 = new TGeoBBox( "ubt_detbox1", (straw_length + frame_width), - (f_aperture_height + 4*max_stereo_growth + frame_width - floor_offset / 2.), + (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", @@ -249,7 +251,7 @@ void UpstreamTagger::ConstructGeometry() move_up->RegisterYourself(); // Composite shape to create frame - TGeoCompositeShape* detcomp1 = new TGeoCompositeShape("ubt_detcomp1", "ubt_detbox1:ubt_move_up - ubt_detbox2"); + 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); diff --git a/geometry/ubt_config.yaml b/geometry/ubt_config.yaml index dfec3c30eb..24b438d3e9 100644 --- a/geometry/ubt_config.yaml +++ b/geometry/ubt_config.yaml @@ -1,14 +1,15 @@ # Geometry configuration of UBT (veto) in FairShip UBT: - width: 150 # Aperture width (x) in cm (half length) - height: 300 # Aperture height (y) in cm (half length) - wire_thickness: 0.003 # Sense wire thickness in cm - wall_thickness: 0.0036 # Straw wall thickness in cm - outer_straw_diameter: 2 # in cm - straw_pitch: 2 # Distance (y) between straws in a layer in cm - y_layer_offset: 1 # Offset (y) of straws between layers in cm - delta_z_layer: 1.732 # Distance (z) between layers in cm - delta_z_view: 12 # Distance (z) between stereo views in cm - view_angle: 4.57 # Stereo angle in degree - station_length: 40 # (z) in cm (half length) + 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) + From 9d7cc30fa11c04132ac7a5388ef92a2676692cd4 Mon Sep 17 00:00:00 2001 From: Carl Gwilliam Date: Tue, 17 Mar 2026 16:10:28 +0000 Subject: [PATCH 49/53] Update materials and frame of UBT --- UpstreamTagger/UpstreamTagger.cxx | 12 ++++++------ geometry/media.geo | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 27fd2c0667..5be013e90b 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -215,10 +215,10 @@ void UpstreamTagger::ConstructGeometry() ShipGeo::InitMedium("mylar"); TGeoMedium *mylar = gGeoManager->GetMedium("mylar"); - ShipGeo::InitMedium("STTmix8020_1bar"); - TGeoMedium *sttmix8020_1bar = gGeoManager->GetMedium("STTmix8020_1bar"); // Should be argon-ethane - ShipGeo::InitMedium("tungsten"); - TGeoMedium *tungsten = gGeoManager->GetMedium("tungsten"); // Should be tungsten rhenium + 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); @@ -230,7 +230,7 @@ void UpstreamTagger::ConstructGeometry() 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 = 9.; // Width of frame metal + 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; @@ -264,7 +264,7 @@ void UpstreamTagger::ConstructGeometry() // 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, tungsten); + TGeoVolume *wire = new TGeoVolume("ubt_wire", wire_tube, WReWire); wire->SetLineColor(6); // Station box to contain all components diff --git a/geometry/media.geo b/geometry/media.geo index 495df0c06e..275c63b7e3 100644 --- a/geometry/media.geo +++ b/geometry/media.geo @@ -2197,6 +2197,11 @@ tungstenalloySND 3 183.84 58.69 63.54 74. 28. 29. 18.78 .95 .03 .02 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 @@ -2275,6 +2280,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 From 87a8637976a1175ecf51f9c2c41f55e37bc987b4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 11:05:01 +0000 Subject: [PATCH 50/53] style: pre-commit fixes --- UpstreamTagger/UpstreamTagger.cxx | 546 ++++++++++++++------------- UpstreamTagger/UpstreamTagger.h | 61 ++- UpstreamTagger/UpstreamTaggerHit.cxx | 2 +- UpstreamTagger/UpstreamTaggerHit.h | 10 +- examples/analysis_example.py | 2 +- geometry/ubt_config.yaml | 24 +- python/ShipGeo.py | 98 ++--- python/geometry_config.py | 16 +- python/shipDet_conf.py | 42 +-- 9 files changed, 418 insertions(+), 383 deletions(-) diff --git a/UpstreamTagger/UpstreamTagger.cxx b/UpstreamTagger/UpstreamTagger.cxx index 5be013e90b..6ff4cd4b13 100644 --- a/UpstreamTagger/UpstreamTagger.cxx +++ b/UpstreamTagger/UpstreamTagger.cxx @@ -44,42 +44,40 @@ 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; + 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)); + 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; - } +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) {} + : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), + fMedium(medium), + det_zPos(0), + UpstreamTagger_fulldet(0) {} UpstreamTagger::UpstreamTagger() : Detector("UpstreamTagger", kTRUE, kUpstreamTagger), @@ -91,8 +89,7 @@ UpstreamTagger::UpstreamTagger(const char* name, Bool_t active) det_zPos(0), UpstreamTagger_fulldet(0) {} -Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) -{ +Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ // Set parameters at entrance of volume. Reset ELoss. if (gMC->IsTrackEntering()) { @@ -105,20 +102,21 @@ Bool_t UpstreamTagger::ProcessHits(FairVolume* vol) // Sum energy loss for all steps in the active volume fELoss += gMC->Edep(); -// fELoss += 0.0001; + // fELoss += 0.0001; // Create vetoPoint at exit of active volume - if ( gMC->IsTrackExiting() || - gMC->IsTrackStop() || - gMC->IsTrackDisappeared() ) { - if (fELoss == 0. ) { return kFALSE; } + if (gMC->IsTrackExiting() || gMC->IsTrackStop() || + gMC->IsTrackDisappeared()) { + if (fELoss == 0.) { + return kFALSE; + } fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); fEventID = gMC->CurrentEvent(); Int_t uniqueId; gMC->CurrentVolID(uniqueId); const char* volName = gMC->CurrentVolName(); -// std::cout<<"volume id: "< 1000000) // Solid scintillator case { @@ -150,250 +148,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::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::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::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::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::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::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::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::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::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"<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(); - - 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; - - // 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); - - // 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(); - - 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; +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(); + + 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; + + // 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); + + // 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(); + + 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; + + // 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); } - 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; - - // 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 + 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); + 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"< { /** Sets detector position and sizes */ void SetZposition(Double_t z) { det_zPos = 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); + 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) + 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) private: /** 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 cf25786ead..bc5eb53f24 100644 --- a/UpstreamTagger/UpstreamTaggerHit.cxx +++ b/UpstreamTagger/UpstreamTaggerHit.cxx @@ -35,7 +35,7 @@ UpstreamTaggerHit::UpstreamTaggerHit(UpstreamTaggerPoint* p, Double_t t0, // Smear time with Gaussian resolution fTime = gRandom->Gaus(p->GetTime() + t0, time_res); -// fSubDetID = p->GetLayerID(); + // fSubDetID = p->GetLayerID(); } // ----- Print ------------------------------ diff --git a/UpstreamTagger/UpstreamTaggerHit.h b/UpstreamTagger/UpstreamTaggerHit.h index dd3736701e..4da2275481 100644 --- a/UpstreamTagger/UpstreamTaggerHit.h +++ b/UpstreamTagger/UpstreamTaggerHit.h @@ -52,11 +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) - Int_t fSubDetID; ///< Which layer of the UBT is this + 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 ClassDef(UpstreamTaggerHit, 2); }; diff --git a/examples/analysis_example.py b/examples/analysis_example.py index efbc014c1e..33efae5117 100644 --- a/examples/analysis_example.py +++ b/examples/analysis_example.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration -"""Example script for usage of the analysis_toolkit for signal selection.""" +"""Example script for usage of the analysis_toolkit for signal selection.""" from argparse import ArgumentParser diff --git a/geometry/ubt_config.yaml b/geometry/ubt_config.yaml index 24b438d3e9..4d62f59acd 100644 --- a/geometry/ubt_config.yaml +++ b/geometry/ubt_config.yaml @@ -1,15 +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) - + 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/python/ShipGeo.py b/python/ShipGeo.py index 21dc4eb766..d896ff62f1 100644 --- a/python/ShipGeo.py +++ b/python/ShipGeo.py @@ -1,67 +1,77 @@ # SPDX-License-Identifier: LGPL-3.0-or-later # SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration -import shipunit as u import ROOT +import shipunit as u + fDesign = 2 -class ShipGeo(): - def __init__(self,z=0): - self.z = z + + +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')) + 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.*u.cm) -TrackStation2 = ShipGeo(1710.*u.cm) -TrackStation3 = ShipGeo(2150.*u.cm) -TrackStation4 = ShipGeo(2370.*u.cm) -UBTStation1 = ShipGeo(2390.*u.cm) -UBTStation2 = ShipGeo(2395.*u.cm) -UBTStation3 = ShipGeo(2400.*u.cm) -UBTStation4 = ShipGeo(2405.*u.cm) +# 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 +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 +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 +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.-muShield.length/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. - hadronAbsorber.length/2. +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. - target.length/2. +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. +target.z0 = target.z - target.length / 2.0 # straws of tracking stations -straw = ShipGeo(0*u.cm) -straw.length = 250.*u.cm -straw.resol = 0.01*u.cm -straw.pitch = 1.*u.cm -straw.stereoAngle = 5./180.*ROOT.TMath.Pi() +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 4eff307f4b..411a85a0a3 100644 --- a/python/geometry_config.py +++ b/python/geometry_config.py @@ -315,7 +315,7 @@ 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.UBTStation1 = AttrDict(z=c.decayVolume.z0 - 50 * u.cm) c.Bfield = AttrDict() c.Bfield.z = c.z @@ -417,15 +417,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) -#<<<<<<< HEAD + # <<<<<<< 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.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 0004df2502..cc3cfdac69 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -260,11 +260,12 @@ 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']) + 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" @@ -275,11 +276,7 @@ def configure_upstreamTagger(yaml_file, ship_geo): 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.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, @@ -294,12 +291,11 @@ def configure_upstreamTagger(yaml_file, ship_geo): 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, -# ) + # For digitization + # strawtubes.SetStrawResolution( + # ship_geo.strawtubesDigi.v_drift, + # ship_geo.strawtubesDigi.sigma_spatial, + # ) detectorList.append(ubt) @@ -464,17 +460,15 @@ def configure(run, ship_geo): SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength) detectorList.append(SplitCal) -#<<<<<<< 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 -# ) + # <<<<<<< 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) @@ -504,7 +498,7 @@ def configure(run, ship_geo): ) run.SetField(fMagField) - exclusionList = ['TargetStation'] + exclusionList = ["TargetStation"] # exclusionList = ["strawtubes","TargetTrackers","NuTauTarget",\ # "SiliconTarget","Veto","Magnet","MuonShield","TargetStation", "TimeDet", "UpstreamTagger"] From 4d25142aa77e5b8acb85776ac7d85e85e42630a7 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 17 Jun 2026 17:11:31 +0200 Subject: [PATCH 51/53] tidy --- python/shipDet_conf.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/python/shipDet_conf.py b/python/shipDet_conf.py index fcb75438c4..27043d2f36 100644 --- a/python/shipDet_conf.py +++ b/python/shipDet_conf.py @@ -464,15 +464,7 @@ def configure(run, ship_geo): SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength) detectorList.append(SplitCal) - # <<<<<<< 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) @@ -503,7 +495,7 @@ def configure(run, ship_geo): run.SetField(fMagField) ROOT.SetOwnership(fMagField, False) # C++ FairRunSim takes ownership - exclusionList = ["TargetStation"] + exclusionList = [] # exclusionList = ["strawtubes","TargetTrackers","NuTauTarget",\ # "SiliconTarget","Veto","Magnet","MuonShield","TargetStation", "TimeDet", "UpstreamTagger"] From d5b89733fedf21732eccec48c85337934bd5fc2e Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 17 Jun 2026 17:14:08 +0200 Subject: [PATCH 52/53] tidy --- macro/run_simScript.py | 7 ------- python/geometry_config.py | 5 ----- 2 files changed, 12 deletions(-) diff --git a/macro/run_simScript.py b/macro/run_simScript.py index 0628109a30..b6f1593d09 100755 --- a/macro/run_simScript.py +++ b/macro/run_simScript.py @@ -477,8 +477,6 @@ def _fraction_0_1(value: str) -> float: # 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: @@ -943,11 +941,8 @@ def _fraction_0_1(value: str) -> float: # 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) @@ -966,8 +961,6 @@ def _fraction_0_1(value: str) -> float: 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/geometry_config.py b/python/geometry_config.py index 6f11947645..604ecf15ef 100644 --- a/python/geometry_config.py +++ b/python/geometry_config.py @@ -423,13 +423,8 @@ 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) - # <<<<<<< 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 From b140986961acb77e6fc8f847f163f73dc7a3a6e2 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 17 Jun 2026 17:15:21 +0200 Subject: [PATCH 53/53] tidy --- UpstreamTagger/UpstreamTaggerHit.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UpstreamTagger/UpstreamTaggerHit.cxx b/UpstreamTagger/UpstreamTaggerHit.cxx index bc5eb53f24..5afa0fcc6c 100644 --- a/UpstreamTagger/UpstreamTaggerHit.cxx +++ b/UpstreamTagger/UpstreamTaggerHit.cxx @@ -35,7 +35,7 @@ UpstreamTaggerHit::UpstreamTaggerHit(UpstreamTaggerPoint* p, Double_t t0, // Smear time with Gaussian resolution fTime = gRandom->Gaus(p->GetTime() + t0, time_res); - // fSubDetID = p->GetLayerID(); + fSubDetID = p->GetLayerID(); } // ----- Print ------------------------------