FairShip
Loading...
Searching...
No Matches
MTCDetector Class Reference

#include <MTCDetector.h>

Inheritance diagram for MTCDetector:
[legend]
Collaboration diagram for MTCDetector:
[legend]

Public Member Functions

 MTCDetector (const char *name, Bool_t Active, const char *Title="", Int_t DetId=0)
 MTCDetector ()
void SetMTCParameters (Double_t width, Double_t height, Double_t fiber_tilt_angle, Double_t iron_thickness, Double_t scifi_thickness, Int_t num_of_agg_channels, Double_t scint_cell_size, Double_t scint_thickness, Int_t number_of_layers, Double_t z_position, Double_t field_strength)
virtual void CreateScintModule (const char *name, TGeoVolumeAssembly *modMotherVol, Double_t z_shift, Double_t width, Double_t height, Double_t thickness, Double_t cellSizeX, Double_t cellSizeY, TGeoMedium *material, Int_t color, Double_t transparency, Int_t LayerId)
virtual void CreateSciFiModule (const char *name, TGeoVolumeAssembly *modMotherVol, Double_t width, Double_t height, Double_t thickness, Int_t LayerId)
void ConstructGeometry () override
void GetPosition (Int_t fDetectorID, TVector3 &vLeft, TVector3 &vRight)
TVector3 GetLocalPos (Int_t fDetectorID, TVector3 *glob)
void GetSiPMPosition (Int_t SiPMChan, TVector3 &A, TVector3 &B)
void SiPMmapping ()
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > GetSiPMmapU ()
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > GetFibresMapU ()
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > GetSiPMmapV ()
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > GetFibresMapV ()
std::map< Int_t, float > GetSiPMPos_U ()
std::map< Int_t, float > GetSiPMPos_V ()
Int_t Get_NSiPMChan () const
Float_t Get_SciFiActiveX () const
virtual void SiPMOverlap ()
Bool_t ProcessHits (FairVolume *vol=nullptr) override
Public Member Functions inherited from SHiP::Detector< MTCDetPoint >
 Detector ()=default
 ~Detector () override=default
MTCDetPoint * AddHit (Args &&... args)
void Initialize () override
void Reset () override
void EndOfEvent () override
void Register () override
TClonesArray * GetCollection (Int_t iColl) const override
void UpdatePointTrackIndices (const std::vector< Int_t > &indexMap) override
 Update track indices in point collection after track filtering.
void SetSpecialPhysicsCuts () override
void FinishPrimary () override
void FinishRun () override
void BeginPrimary () override
void PostTrack () override
void PreTrack () override
void BeginEvent () override
void CopyClones (TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override
Public Member Functions inherited from ISTLPointContainer
virtual ~ISTLPointContainer ()=default

Private Member Functions

 MTCDetector (const MTCDetector &)=delete
 local SiPM channel position
MTCDetector & operator= (const MTCDetector &)=delete

Private Attributes

Double_t fWidth
Double_t fHeight
Double_t fSciFiActiveX
Double_t fSciFiActiveY
Double_t fSciFiBendingAngle
Double_t fIronThick
Double_t fSciFiThick
Double_t fScintThick
Double_t fScintCellSize
Int_t fLayers
Double_t fZCenter
Double_t fFieldY
Double_t fZEpoxyMat
Double_t fiberMatThick = 0.135
Double_t fFiberLength
Double_t fFiberPitch = 0.025
Double_t lowerIronThick = 0.3
Double_t airGap = 0.1
Double_t upperIronThick = 0.3
Double_t zLowerIronInt = -3.5 / 10
Double_t zFiberMat1 = -1.325 / 10
Double_t zAirGap = -0.15 / 10
Double_t zFiberMat2 = 1.025 / 10
Double_t zUpperIronInt = 3.2 / 10
Double_t fFiberRadius = 0.01125
Int_t numFiberLayers = 6
Int_t fNSiPMChan
Int_t fChannelAggregated
Int_t fNSiPMs = 1
Int_t fNMats = 1
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > fibresSiPM_U
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > siPMFibres_U
 mapping of fibres to SiPM channels
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > fibresSiPM_V
 inverse mapping
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > siPMFibres_V
 mapping of fibres to SiPM channels
std::map< Int_t, float > SiPMPos_U
 inverse mapping
std::map< Int_t, float > SiPMPos_V

Static Private Attributes

static constexpr Int_t kMaxChannelsPerSiPM = 1000

Additional Inherited Members

Protected Attributes inherited from SHiP::Detector< MTCDetPoint >
Int_t fEventID
Int_t fTrackID
 event index
Int_t fVolumeID
 track index
TLorentzVector fPos
 volume id
TLorentzVector fMom
 position at entrance
Double_t fTime
 momentum at entrance
Double_t fLength
 time
Double_t fELoss
 length
std::vector< MTCDetPoint > * fDetPoints
 energy loss
TGeoVolume * fDetector

Detailed Description

Definition at line 21 of file MTCDetector.h.

Constructor & Destructor Documentation

◆ MTCDetector() [1/3]

MTCDetector::MTCDetector ( const char * name,
Bool_t Active,
const char * Title = "",
Int_t DetId = 0 )

Definition at line 144 of file MTCDetector.cxx.

146 : Detector(name, Active, kMTC) {}
@ kMTC

◆ MTCDetector() [2/3]

Definition at line 142 of file MTCDetector.cxx.

142: Detector("MTC", kTRUE, kMTC) {}

◆ MTCDetector() [3/3]

MTCDetector::MTCDetector ( const MTCDetector & )
privatedelete

local SiPM channel position

Member Function Documentation

◆ ConstructGeometry()

void MTCDetector::ConstructGeometry ( )
overridevirtual

Create the detector geometry

Implements SHiP::Detector< MTCDetPoint >.

Definition at line 316 of file MTCDetector.cxx.

316 {
317 // Initialize media (using FairROOT's interface)
318 ShipGeo::InitMedium("SciFiMat");
319 ShipGeo::InitMedium("Epoxy");
320 ShipGeo::InitMedium("air");
321 ShipGeo::InitMedium("iron");
322 TGeoMedium* air = gGeoManager->GetMedium("air");
323 TGeoMedium* ironMed = gGeoManager->GetMedium("iron");
324 // For the scintillator, you may use the same medium as SciFiMat or another if
325 // defined.
326 TGeoMedium* scintMed = gGeoManager->GetMedium("SciFiMat");
327 ShipGeo::InitMedium("silicon");
328
329 // Define the module spacing based on three sublayers:
330 // fIronThick (outer iron), fSciFiThick (SciFi module/fiber module),
331 // fScintThick (scintillator)
332 Double_t moduleSpacing = fIronThick + fSciFiThick + fScintThick;
333 Double_t totalLength = fLayers * moduleSpacing;
334
335 // --- Create an envelope volume for the detector (green, semi-transparent)
336 // ---
337 auto envBox =
338 new TGeoBBox("MTC_env", fWidth / 2, fHeight / 2, totalLength / 2);
339 auto envVol = new TGeoVolume("MTC", envBox, air);
340 envVol->SetLineColor(kGreen);
341 envVol->SetTransparency(50);
342
343 // --- Outer Iron Layer (gray) ---
344 auto ironBox =
345 new TGeoBBox("MTC_iron", fWidth / 2, fHeight / 2, fIronThick / 2);
346 auto ironVol = new TGeoVolume("MTC_iron", ironBox, ironMed);
347 ironVol->SetLineColor(kGray + 1);
348 ironVol->SetTransparency(20);
349 // Enable the field in the iron volume
350 if (fFieldY != 0) ironVol->SetField(new TGeoUniformMagField(0, fFieldY, 0));
351
352 // --- Assemble the layers into the envelope ---
353 TGeoVolumeAssembly* sensitiveModule = new TGeoVolumeAssembly("MTC_layer");
354 // Define a layer for the SciFi module
355 CreateSciFiModule("MTC", sensitiveModule, fWidth, fHeight, fSciFiThick, 1);
356 CreateScintModule("MTC", sensitiveModule, fSciFiThick / 2 + fScintThick / 2,
358 fScintCellSize, scintMed, kAzure + 7, 30, 1);
359
360 for (Int_t i = 0; i < fLayers; i++) {
361 // Compute the center position (z) for the current module
362 Double_t zPos = -totalLength / 2 + i * moduleSpacing;
363
364 // Place the Outer Iron layer (shifted down by half the SciFi+scint
365 // thickness)
366 envVol->AddNode(ironVol, i,
367 new TGeoTranslation(0, 0, zPos + fIronThick / 2));
368 // Place the sensitive module (SciFi + Scintillator) at the correct z
369 // position
370 envVol->AddNode(
371 sensitiveModule, i,
372 new TGeoTranslation(0, 0, zPos + fIronThick + fSciFiThick / 2));
373 }
374
375 // Finally, add the envelope to the top volume with the global z offset
376 // fZCenter
377 gGeoManager->GetTopVolume()->AddNode(envVol, 1,
378 new TGeoTranslation(0, 0, fZCenter));
379}
Double_t fIronThick
Definition MTCDetector.h:78
Double_t fWidth
Definition MTCDetector.h:73
Double_t fSciFiThick
Definition MTCDetector.h:79
Double_t fHeight
Definition MTCDetector.h:74
Double_t fScintCellSize
Definition MTCDetector.h:81
virtual void CreateScintModule(const char *name, TGeoVolumeAssembly *modMotherVol, Double_t z_shift, Double_t width, Double_t height, Double_t thickness, Double_t cellSizeX, Double_t cellSizeY, TGeoMedium *material, Int_t color, Double_t transparency, Int_t LayerId)
virtual void CreateSciFiModule(const char *name, TGeoVolumeAssembly *modMotherVol, Double_t width, Double_t height, Double_t thickness, Int_t LayerId)
Double_t fScintThick
Definition MTCDetector.h:80
Int_t fLayers
Definition MTCDetector.h:82
Double_t fFieldY
Definition MTCDetector.h:84
Int_t InitMedium(const char *name)
Definition ShipGeoUtil.h:22

◆ CreateSciFiModule()

void MTCDetector::CreateSciFiModule ( const char * name,
TGeoVolumeAssembly * modMotherVol,
Double_t width,
Double_t height,
Double_t thickness,
Int_t LayerId )
virtual

Definition at line 202 of file MTCDetector.cxx.

205 {
206 // --- Lower Internal Iron ---
207 TGeoBBox* lowerIronBox = new TGeoBBox(Form("%s_lowerIron", name), width / 2,
208 height / 2, lowerIronThick / 2);
209 TGeoVolume* lowerIronVol = new TGeoVolume(
210 Form("%s_lowerIron", name), lowerIronBox, gGeoManager->GetMedium("iron"));
211 lowerIronVol->SetLineColor(kGray + 1);
212 lowerIronVol->SetTransparency(20);
213 modMotherVol->AddNode(lowerIronVol, 0,
214 new TGeoTranslation(0, 0, zLowerIronInt));
215
216 // --- Lower Epoxy matrix (replaces SciFiMat layer) ---
217 TGeoVolumeAssembly* ScifiVolU =
218 new TGeoVolumeAssembly(Form("%s_scifi_U", name));
219 modMotherVol->AddNode(ScifiVolU, 0, new TGeoTranslation(0, 0, 0));
220 TGeoBBox* epoxyMatBoxU = new TGeoBBox(Form("%s_epoxyMat", name), width / 2,
221 height / 2, fiberMatThick / 2);
222 TGeoVolume* ScifiMatVolU = new TGeoVolume(
223 Form("%s_epoxyMat", name), epoxyMatBoxU, gGeoManager->GetMedium("Epoxy"));
224 ScifiMatVolU->SetLineColor(kYellow - 2);
225 ScifiMatVolU->SetTransparency(30);
226 ScifiMatVolU->SetVisibility(kFALSE);
227 ScifiMatVolU->SetVisDaughters(kFALSE);
228 ScifiVolU->AddNode(ScifiMatVolU, 0, new TGeoTranslation(0, 0, zFiberMat1));
229
230 // --- Upper Epoxy matrix (replaces SciFiMat layer) ---
231 TGeoVolumeAssembly* ScifiVolV =
232 new TGeoVolumeAssembly(Form("%s_scifi_V", name));
233 modMotherVol->AddNode(ScifiVolV, 0, new TGeoTranslation(0, 0, 0));
234 TGeoBBox* epoxyMatBoxV = new TGeoBBox(Form("%s_epoxyMat", name), width / 2,
235 height / 2, fiberMatThick / 2);
236 TGeoVolume* ScifiMatVolV = new TGeoVolume(
237 Form("%s_epoxyMat", name), epoxyMatBoxV, gGeoManager->GetMedium("Epoxy"));
238 ScifiMatVolV->SetLineColor(kYellow - 2);
239 ScifiMatVolV->SetTransparency(30);
240 ScifiMatVolV->SetVisibility(kFALSE);
241 ScifiMatVolV->SetVisDaughters(kFALSE);
242 ScifiVolV->AddNode(ScifiMatVolV, 0, new TGeoTranslation(0, 0, zFiberMat2));
243
244 // --- Upper Internal Iron ---
245 TGeoBBox* upperIronBox = new TGeoBBox(Form("%s_upperIron", name), width / 2,
246 height / 2, upperIronThick / 2);
247 TGeoVolume* upperIronVol = new TGeoVolume(
248 Form("%s_upperIron", name), upperIronBox, gGeoManager->GetMedium("iron"));
249 upperIronVol->SetLineColor(kGray + 1);
250 upperIronVol->SetTransparency(20);
251 modMotherVol->AddNode(upperIronVol, 0,
252 new TGeoTranslation(0, 0, zUpperIronInt));
253
254 // -----------------------------
255 // Now build the fibers inside each Epoxy block:
256 // Common fiber parameters (cm)
257 Double_t layerThick = fiberMatThick / numFiberLayers;
258 fFiberLength = fSciFiActiveY / cos(fSciFiBendingAngle * TMath::DegToRad()) -
259 2 * fFiberRadius * sin(fSciFiBendingAngle * TMath::DegToRad());
260 LOG(info) << "Fiber length set to " << fFiberLength << " cm";
261 Int_t fNumFibers = static_cast<Int_t>(fSciFiActiveX / fFiberPitch);
262
263 // --- Define the SciFi fiber volume ---
264 TGeoTube* fiberTube =
265 new TGeoTube("FiberTube", 0, fFiberRadius, fFiberLength / 2);
266 TGeoVolume* fiberVol =
267 new TGeoVolume("FiberVol", fiberTube, gGeoManager->GetMedium("SciFiMat"));
268 AddSensitiveVolume(fiberVol);
269 fiberVol->SetLineColor(kMagenta);
270 fiberVol->SetTransparency(15);
271 fiberVol->SetVisibility(kFALSE);
272
273 // --- Rotations for U/V fibers ---
274 TGeoRotation* rotU = new TGeoRotation();
275 rotU->RotateY(fSciFiBendingAngle);
276 rotU->RotateX(90.);
277 TGeoRotation* rotV = new TGeoRotation();
278 rotV->RotateY(-fSciFiBendingAngle);
279 rotV->RotateX(90.);
280
281 // --- Place U-fibers inside lower Epoxy ---
282 for (int layer = 0; layer < numFiberLayers; ++layer) {
283 Double_t z0 = -fiberMatThick / 2 + (layer + 0.5) * (layerThick);
284 for (int j = 0; j < fNumFibers; ++j) {
285 Double_t x0 = -fSciFiActiveX / 2 + (j + 0.5) * fFiberPitch;
286 if (layer % 2 == 1) {
287 if (j == fNumFibers - 1) {
288 continue; // Skip the last layer for odd layers
289 }
290 x0 += fFiberPitch / 2;
291 }
292 TGeoCombiTrans* ct = new TGeoCombiTrans("", x0, 0, z0, rotU);
293 Int_t copyNo = 100000000 + 1000000 + 0 * 100000 + layer * 10000 + j;
294 ScifiMatVolU->AddNode(fiberVol, copyNo, ct);
295 }
296 }
297
298 // --- Place V-fibers inside upper Epoxy ---
299 for (int layer = 0; layer < numFiberLayers; ++layer) {
300 Double_t z0 = -fiberMatThick / 2 + (layer + 0.5) * (layerThick);
301 for (int j = 0; j < fNumFibers; ++j) {
302 Double_t x0 = -fSciFiActiveX / 2 + (j + 0.5) * fFiberPitch;
303 if (layer % 2 == 1) {
304 if (j == fNumFibers - 1) {
305 continue; // Skip the last layer for odd layers
306 }
307 x0 += fFiberPitch / 2;
308 }
309 TGeoCombiTrans* ct = new TGeoCombiTrans("", x0, 0, z0, rotV);
310 Int_t copyNo = 100000000 + 1000000 + 1 * 100000 + layer * 10000 + j;
311 ScifiMatVolV->AddNode(fiberVol, copyNo, ct);
312 }
313 }
314}
Double_t fSciFiBendingAngle
Definition MTCDetector.h:77
Double_t fFiberLength
Definition MTCDetector.h:87
Int_t numFiberLayers
Double_t upperIronThick
Definition MTCDetector.h:93
Double_t zUpperIronInt
Definition MTCDetector.h:98
Double_t lowerIronThick
Definition MTCDetector.h:91
Double_t fiberMatThick
Definition MTCDetector.h:86
Double_t fSciFiActiveY
Definition MTCDetector.h:76
Double_t zLowerIronInt
Definition MTCDetector.h:94
Double_t fFiberRadius
Definition MTCDetector.h:99
Double_t fSciFiActiveX
Definition MTCDetector.h:75
Double_t zFiberMat2
Definition MTCDetector.h:97
Double_t fFiberPitch
Definition MTCDetector.h:88
Double_t zFiberMat1
Definition MTCDetector.h:95

◆ CreateScintModule()

void MTCDetector::CreateScintModule ( const char * name,
TGeoVolumeAssembly * modMotherVol,
Double_t z_shift,
Double_t width,
Double_t height,
Double_t thickness,
Double_t cellSizeX,
Double_t cellSizeY,
TGeoMedium * material,
Int_t color,
Double_t transparency,
Int_t LayerId )
virtual

Definition at line 170 of file MTCDetector.cxx.

176 {
177 modMotherVol->SetLineColor(color);
178 modMotherVol->SetTransparency(transparency);
179 auto scint_volume = new TGeoVolumeAssembly(Form("%s_scint", name));
180 modMotherVol->AddNode(scint_volume, 0, new TGeoTranslation(0, 0, z_shift));
181 auto scint_mat = new TGeoVolumeAssembly(Form("%s_scint_mat", name));
182 scint_volume->AddNode(scint_mat, 0, new TGeoTranslation(0, 0, 0));
183 auto cell = new TGeoBBox(Form("%s_cell", name), cellSizeX / 2, cellSizeY / 2,
184 thickness / 2);
185 auto cellVol = new TGeoVolume(Form("%s_cell", name), cell, material);
186 cellVol->SetLineColor(color);
187 cellVol->SetTransparency(transparency);
188 AddSensitiveVolume(cellVol);
189 Int_t nX = Int_t(width / cellSizeX);
190 Int_t nY = Int_t(height / cellSizeY);
191
192 for (Int_t i = 0; i < nX; i++) {
193 for (Int_t j = 0; j < nY; j++) {
194 Double_t x = -width / 2 + cellSizeX * (i + 0.5);
195 Double_t y = -height / 2 + cellSizeY * (j + 0.5);
196 scint_mat->AddNode(cellVol, 1e8 + 1e6 + 2e5 + 0e4 + i * nY + j,
197 new TGeoTranslation(x, y, 0));
198 }
199 }
200}

◆ Get_NSiPMChan()

Int_t MTCDetector::Get_NSiPMChan ( ) const
inline

Definition at line 67 of file MTCDetector.h.

67{ return fNSiPMChan; }
Int_t fNSiPMChan

◆ Get_SciFiActiveX()

Float_t MTCDetector::Get_SciFiActiveX ( ) const
inline

Definition at line 68 of file MTCDetector.h.

68{ return fSciFiActiveX; }

◆ GetFibresMapU()

std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > MTCDetector::GetFibresMapU ( )
inline

Definition at line 56 of file MTCDetector.h.

56 {
57 return siPMFibres_U;
58 }
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > siPMFibres_U
mapping of fibres to SiPM channels

◆ GetFibresMapV()

std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > MTCDetector::GetFibresMapV ( )
inline

Definition at line 62 of file MTCDetector.h.

62 {
63 return siPMFibres_V;
64 }
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > siPMFibres_V
mapping of fibres to SiPM channels

◆ GetLocalPos()

TVector3 MTCDetector::GetLocalPos ( Int_t fDetectorID,
TVector3 * glob )

Transform global position to local position in plane

Definition at line 567 of file MTCDetector.cxx.

567 {
568 Int_t station_number = static_cast<int>(fDetectorID / 1e6) % 100;
569 Int_t plane_type = static_cast<int>(fDetectorID / 1e5) %
570 10; // 0 for horizontal, 1 for vertical
571
572 TString sID, stationID;
573 sID.Form("%i", fDetectorID);
574 stationID.Form("%i", station_number);
575 // Basic hierarchy:
576 // /cave/MTC_1/MTC_layer_1/MTC_sciFi_mother_1/MTC_sciFi_epoxyMat_U_1/FiberVol_101010187
577 TString path = "/cave/MTC_1/MTC_layer_" + stationID +
578 ((plane_type == 0) ? "/MTC_scifi_U_0" : "/MTC_scifi_V_0");
579 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
580 nav->cd(path);
581 Double_t aglob[3];
582 Double_t aloc[3];
583 glob->GetXYZ(aglob);
584 nav->MasterToLocal(aglob, aloc);
585 return TVector3(aloc[0], aloc[1], aloc[2]);
586}

◆ GetPosition()

void MTCDetector::GetPosition ( Int_t fDetectorID,
TVector3 & vLeft,
TVector3 & vRight )

Get position of single fibre in global coordinate system

Definition at line 519 of file MTCDetector.cxx.

519 {
520 /*
521 Example of fiberID: 123051820, where:
522 - 1: MTC unique ID
523 - 23: layer number
524 - 0: station type (0 for +5 degrees, 1 for -5 degrees, 2 for scint plane)
525 - 5: z-layer number (0-5)
526 - 1820: local fibre ID within the station
527 Example of SiPM global channel (what is seen in the output file): 123001123,
528 where:
529 - 1: MTC unique ID
530 - 23: layer number
531 - 0: station type (0 for +5 degrees, 1 for -5 degrees)
532 - 0: mat number (only 0 by June 2025)
533 - 1: SiPM number (automatically assigned based on fibre aggregation
534 settings)
535 - 123: number of the SiPM channel (0-N). The channel number depends on the
536 fibre aggregation setting.
537 */
538
539 Int_t station_number = static_cast<int>(fDetectorID / 1e6) % 100;
540 Int_t plane_type = static_cast<int>(fDetectorID / 1e5) %
541 10; // 0 for horizontal, 1 for vertical
542
543 TString sID, stationID;
544 sID.Form("%i", fDetectorID);
545 stationID.Form("%i", station_number);
546 // Basic hierarchy:
547 // /cave/MTC_1/MTC_layer_1/MTC_sciFi_mother_1/MTC_sciFi_epoxyMat_U_1/FiberVol_101010187
548 TString path =
549 "/cave/MTC_1/MTC_layer_" + stationID +
550 ((plane_type == 0) ? "/MTC_scifi_U_0/MTC_epoxyMat_0/FiberVol_1010"
551 : "/MTC_scifi_V_0/MTC_epoxyMat_0/FiberVol_1011");
552 path += sID(4, 5);
553 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
554 nav->cd(path);
555 TGeoNode* W = nav->GetCurrentNode();
556 TGeoBBox* S = dynamic_cast<TGeoBBox*>(W->GetVolume()->GetShape());
557
558 Double_t top[3] = {0, 0, (S->GetDZ())};
559 Double_t bot[3] = {0, 0, -(S->GetDZ())};
560 Double_t Gtop[3], Gbot[3];
561 nav->LocalToMaster(top, Gtop);
562 nav->LocalToMaster(bot, Gbot);
563 A.SetXYZ(Gtop[0], Gtop[1], Gtop[2]);
564 B.SetXYZ(Gbot[0], Gbot[1], Gbot[2]);
565}

◆ GetSiPMmapU()

std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > MTCDetector::GetSiPMmapU ( )
inline

Definition at line 53 of file MTCDetector.h.

53 {
54 return fibresSiPM_U;
55 }
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > fibresSiPM_U

◆ GetSiPMmapV()

std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > MTCDetector::GetSiPMmapV ( )
inline

Definition at line 59 of file MTCDetector.h.

59 {
60 return fibresSiPM_V;
61 }
std::map< Int_t, std::map< Int_t, std::array< float, 2 > > > fibresSiPM_V
inverse mapping

◆ GetSiPMPos_U()

std::map< Int_t, float > MTCDetector::GetSiPMPos_U ( )
inline

Definition at line 65 of file MTCDetector.h.

65{ return SiPMPos_U; }
std::map< Int_t, float > SiPMPos_U
inverse mapping

◆ GetSiPMPos_V()

std::map< Int_t, float > MTCDetector::GetSiPMPos_V ( )
inline

Definition at line 66 of file MTCDetector.h.

66{ return SiPMPos_V; }
std::map< Int_t, float > SiPMPos_V

◆ GetSiPMPosition()

void MTCDetector::GetSiPMPosition ( Int_t SiPMChan,
TVector3 & A,
TVector3 & B )

mean position of fibre2 associated with SiPM channel

Definition at line 588 of file MTCDetector.cxx.

588 {
589 /* STMRFFF
590 Example of fiberID: 123051820, where:
591 - 1: MTC unique ID
592 - 23: layer number
593 - 0: station type (0 for +5 degrees, 1 for -5 degrees, 2 for scint
594 plane)
595 - 5: z-layer number (0-5)
596 - 1820: local fibre ID within the station
597 Example of SiPM global channel (what is seen in the output file):
598 123001123, where:
599 - 1: MTC unique ID
600 - 23: layer number
601 - 0: station type (0 for +5 degrees, 1 for -5 degrees)
602 - 0: mat number (only 0 by June 2025)
603 - 1: SiPM number (automatically assigned based on fibre aggregation
604 settings)
605 - 123: number of the SiPM channel (0-N). The channel number depends on
606 the fibre aggregation setting.
607 */
608 Int_t locNumber = SiPMChan % 1000000;
609 Int_t station_number = static_cast<int>(SiPMChan / 1e6) % 100;
610 Int_t plane_type = static_cast<int>(SiPMChan / 1e5) %
611 10; // 0 for horizontal, 1 for vertical
612 Float_t locPosition;
613 locPosition =
614 (plane_type == 0 ? SiPMPos_U
615 : SiPMPos_V)[locNumber]; // local position in U/V plane
616 TString stationID;
617 stationID.Form("%i", station_number);
618
619 Double_t loc[3] = {0, 0, 0};
620 TString path = "/cave/MTC_1/MTC_layer_" + stationID +
621 ((plane_type == 0) ? "/MTC_scifi_U_0/MTC_epoxyMat_0"
622 : "/MTC_scifi_V_0/MTC_epoxyMat_0");
623 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
624 Double_t glob[3] = {0, 0, 0};
625 loc[0] = locPosition;
626 loc[1] = -fFiberLength / 2;
627 loc[2] = 7.47;
628 nav->cd(path);
629 nav->LocalToMaster(loc, glob);
630 A.SetXYZ(glob[0], glob[1], glob[2]);
631 loc[0] = locPosition;
632 loc[1] = fFiberLength / 2;
633 loc[2] = 7.47; // hardcoded for now, for some reason required to get the
634 // correct local position
635 nav->LocalToMaster(loc, glob);
636 B.SetXYZ(glob[0], glob[1], glob[2]);
637}

◆ operator=()

MTCDetector & MTCDetector::operator= ( const MTCDetector & )
privatedelete

◆ ProcessHits()

Bool_t MTCDetector::ProcessHits ( FairVolume * vol = nullptr)
override

This method is called from the MC stepping

Definition at line 381 of file MTCDetector.cxx.

381 {
383 // Set parameters at entrance of volume. Reset ELoss.
384 if (gMC->IsTrackEntering()) {
385 fELoss = 0.;
386 fTime = gMC->TrackTime() * 1.0e09;
387 fLength = gMC->TrackLength();
388 gMC->TrackPosition(fPos);
389 gMC->TrackMomentum(fMom);
390 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
391 Int_t vol_local_id = nav->GetCurrentNode()->GetNumber() %
392 1000000; // Local ID within the mat or scint.
393 Int_t layer_id = nav->GetMother(3)->GetNumber(); // Get layer ID.
394 fVolumeID = 100000000 + layer_id * 1000000 +
395 vol_local_id; // 1e8 + layer_id * 1e6 + fibre_local_id;
396 }
397 // Sum energy loss for all steps in the active volume
398 fELoss += gMC->Edep();
399
400 // Create vetoPoint when exiting active volume
401 if (gMC->IsTrackExiting() || gMC->IsTrackStop() ||
402 gMC->IsTrackDisappeared()) {
403 if (fELoss == 0.) {
404 return kFALSE;
405 } // if you do not want hits with zero eloss
406
407 TParticle* p = gMC->GetStack()->GetCurrentTrack();
408 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
409 Int_t pdgCode = p->GetPdgCode();
410 TLorentzVector Pos;
411 gMC->TrackPosition(Pos);
412 TLorentzVector Mom;
413 gMC->TrackMomentum(Mom);
414 Double_t x, y, z;
415 // 0 and 1 are for SciFi planes, 2 is for scintillating tiles
416 if ((fVolumeID / 100000) % 10 == 2) {
417 x = (fPos.X() + Pos.X()) / 2.;
418 y = (fPos.Y() + Pos.Y()) / 2.;
419 z = (fPos.Z() + Pos.Z()) / 2.;
420 } else {
421 x = fPos.X();
422 y = fPos.Y();
423 z = (fPos.Z() + Pos.Z()) / 2.;
424 }
425
426 AddHit(fTrackID, fVolumeID, TVector3(x, y, z),
427 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), // entrance momentum
428 fTime, fLength, fELoss, pdgCode);
429 // hit->Print();
430 ShipStack* stack = dynamic_cast<ShipStack*>(gMC->GetStack());
431 stack->AddPoint(kMTC);
432 }
433 return kTRUE;
434}
MTCDetPoint * AddHit(Args &&... args)
Definition Detector.h:38

◆ SetMTCParameters()

void MTCDetector::SetMTCParameters ( Double_t width,
Double_t height,
Double_t fiber_tilt_angle,
Double_t iron_thickness,
Double_t scifi_thickness,
Int_t num_of_agg_channels,
Double_t scint_cell_size,
Double_t scint_thickness,
Int_t number_of_layers,
Double_t z_position,
Double_t field_strength )

Definition at line 148 of file MTCDetector.cxx.

153 {
154 fWidth = width;
155 fHeight = height;
156 fSciFiBendingAngle = fiber_tilt_angle;
157 fIronThick = iron_thickness;
158 fSciFiThick = scifi_thickness;
159 fChannelAggregated = num_of_agg_channels;
160 fScintCellSize = scint_cell_size;
161 fScintThick = scint_thickness;
162 fLayers = number_of_layers;
163 fZCenter = z_position;
164 fFieldY = field_strength;
165 fSciFiActiveX = fWidth - fWidth * tan(fSciFiBendingAngle * TMath::DegToRad());
167}
Int_t fChannelAggregated
Double_t fZCenter
Definition MTCDetector.h:83

◆ SiPMmapping()

void MTCDetector::SiPMmapping ( )

Definition at line 639 of file MTCDetector.cxx.

639 {
640 // check if containers are already filled
641 if (!fibresSiPM_U.empty() || !fibresSiPM_V.empty() || !SiPMPos_U.empty() ||
642 !SiPMPos_V.empty()) {
643 LOG(warning) << "SiPM mapping already done, skipping.";
644 return;
645 }
646 Float_t fibresRadius = -1;
647 Float_t dSiPM = -1;
648 TGeoNode* vol;
649 TGeoNode* fibre;
650 SiPMOverlap();
651 // Loop over both U and V planes
652 std::vector<std::pair<const char*, const char*>> sipm_planes = {
653 {"SiPMmapVolU", "MTC_scifi_U"}, {"SiPMmapVolV", "MTC_scifi_V"}};
654 for (const auto& [sipm_vol, scifi_vol] : sipm_planes) {
655 auto sipm = gGeoManager->FindVolumeFast(sipm_vol);
656 if (!sipm) continue;
657 TObjArray* Nodes = sipm->GetNodes();
658 auto plane = gGeoManager->FindVolumeFast(scifi_vol);
659 if (!plane) continue;
660 for (int imat = 0; imat < plane->GetNodes()->GetEntries(); imat++) {
661 auto mat = static_cast<TGeoNode*>(plane->GetNodes()->At(imat));
662 auto vmat = mat->GetVolume();
663 for (int ifibre = 0; ifibre < vmat->GetNodes()->GetEntriesFast();
664 ifibre++) {
665 fibre = static_cast<TGeoNode*>(vmat->GetNodes()->At(ifibre));
666 if (fibresRadius < 0) {
667 auto tmp = fibre->GetVolume()->GetShape();
668 auto S = dynamic_cast<TGeoBBox*>(tmp);
669 fibresRadius = S->GetDX();
670 }
671 Int_t fID =
672 fibre->GetNumber() % 1000000 +
673 imat * 1e4; // local fibre number, global fibre number = SO+fID
674 TVector3 Atop, Bbot;
675 GetPosition(fibre->GetNumber(), Atop, Bbot);
676 Float_t a = Bbot[0];
677
678 // check for overlap with any of the SiPM channels in the same mat
679 for (Int_t nChan = 0; nChan < Nodes->GetEntriesFast();
680 nChan++) { // 7 SiPMs total times 128 channels
681 vol = static_cast<TGeoNode*>(Nodes->At(nChan));
682 Int_t N = vol->GetNumber();
683 Float_t xcentre = vol->GetMatrix()->GetTranslation()[0];
684 if (dSiPM < 0) {
685 TGeoBBox* B = dynamic_cast<TGeoBBox*>(vol->GetVolume()->GetShape());
686 dSiPM = B->GetDX();
687 }
688
689 if (TMath::Abs(xcentre - a) > 3 * dSiPM / 2) {
690 continue;
691 } // no need to check further
692 Float_t W = area(a, fibresRadius, xcentre - dSiPM, xcentre + dSiPM);
693 if (W < 0) {
694 continue;
695 }
696 std::array<float, 2> Wa;
697 Wa[0] = W;
698 Wa[1] = a;
699
700 if (sipm_vol == std::string("SiPMmapVolU")) {
701 fibresSiPM_U[N][fID] = Wa;
702 } else {
703 fibresSiPM_V[N][fID] = Wa;
704 }
705 }
706 }
707 }
708 // calculate also local SiPM positions based on fibre positions and their
709 // fraction probably an overkill, maximum difference between weighted
710 // average and central position < 6 micron.
711 if (sipm_vol == std::string("SiPMmapVolU")) {
712 for (auto [N, it] : fibresSiPM_U) {
713 Float_t m = 0;
714 Float_t w = 0;
715 for (auto [current_fibre, Wa] : it) {
716 m += Wa[0] * Wa[1];
717 w += Wa[0];
718 }
719 SiPMPos_U[N] = m / w;
720 }
721 // make inverse mapping, which fibre is associated to which SiPMs
722 for (auto [N, it] : fibresSiPM_U) {
723 for (auto [nfibre, Wa] : it) {
724 siPMFibres_U[nfibre][N] = Wa;
725 }
726 }
727 } else if (sipm_vol == std::string("SiPMmapVolV")) {
728 for (auto [N, it] : fibresSiPM_V) {
729 Float_t m = 0;
730 Float_t w = 0;
731 for (auto [current_fibre, Wa] : it) {
732 m += Wa[0] * Wa[1];
733 w += Wa[0];
734 }
735 SiPMPos_V[N] = m / w;
736 }
737 // make inverse mapping, which fibre is associated to which SiPMs
738 for (auto [N, it] : fibresSiPM_V) {
739 for (auto [nfibre, Wa] : it) {
740 siPMFibres_V[nfibre][N] = Wa;
741 }
742 }
743 }
744 }
745}
constexpr Double_t m
void GetPosition(Int_t fDetectorID, TVector3 &vLeft, TVector3 &vRight)

◆ SiPMOverlap()

void MTCDetector::SiPMOverlap ( )
virtual

Definition at line 436 of file MTCDetector.cxx.

436 {
437 if (gGeoManager->FindVolumeFast("SiPMmapVolU") ||
438 gGeoManager->FindVolumeFast("SiPMmapVolV")) {
439 return;
440 }
441 Double_t fLengthScifiMat = fSciFiActiveY;
442 Double_t fWidthChannel = fFiberPitch * fChannelAggregated;
443 fNSiPMChan = std::ceil(fWidth / fWidthChannel);
444 if (fNSiPMChan > kMaxChannelsPerSiPM) {
445 LOG(warn) << "Number of SiPM channels (" << fNSiPMChan
446 << ") exceeds maximum per SiPM (" << kMaxChannelsPerSiPM
447 << "), redistributing across multiple SiPMs";
448
449 fNSiPMs = static_cast<int>(
450 std::ceil(static_cast<double>(fNSiPMChan) / kMaxChannelsPerSiPM));
451
452 LOG(info) << "Increasing number of SiPMs up to " << fNSiPMs;
453
454 // define redistribution of channels among SiPMs
455 fNSiPMChan =
456 static_cast<int>(std::ceil(fNSiPMChan / static_cast<float>(fNSiPMs)));
457
458 LOG(info) << "New fNSiPMChan = " << fNSiPMChan;
459 }
460 Double_t fEdge = (fWidth - fNSiPMs * fNSiPMChan * fWidthChannel) / 2;
461 Double_t firstChannelX = -fWidth / 2;
462
463 LOG(info) << "SiPM Overlap parameters:\n"
464 << " fLengthScifiMat = " << fLengthScifiMat << " cm\n"
465 << " fWidthChannel = " << fWidthChannel << " cm\n"
466 << " fFiberPitch = " << fFiberPitch << " cm\n"
467 << " fChannelAggregated = " << fChannelAggregated << "\n"
468 << " fNSiPMChan = " << fNSiPMChan << "\n"
469 << " fNSiPMs = " << fNSiPMs << "\n"
470 << " fNMats = " << fNMats << "\n"
471 << " fEdge = " << fEdge << " cm\n"
472 << " firstChannelX = " << firstChannelX << " cm";
473 // Contains all plane SiPMs, defined for horizontal fiber plane
474 // To obtain SiPM map for vertical fiber plane rotate by 90 degrees around Z
475 TGeoVolumeAssembly* SiPMmapVolU = new TGeoVolumeAssembly("SiPMmapVolU");
476 TGeoVolumeAssembly* SiPMmapVolV = new TGeoVolumeAssembly("SiPMmapVolV");
477
478 TGeoBBox* ChannelVol_box = new TGeoBBox(
479 "ChannelVol", fWidthChannel / 2, fLengthScifiMat / 2, fiberMatThick / 2);
480 TGeoVolume* ChannelVol = new TGeoVolume("ChannelVol", ChannelVol_box,
481 gGeoManager->GetMedium("silicon"));
482 /*
483 Example of fiberID: 123051820, where:
484 - 1: MTC unique ID
485 - 23: layer number
486 - 0: station type (0 for +5 degrees, 1 for -5 degrees, 2 for scint plane)
487 - 5: z-layer number (0-5)
488 - 1820: local fibre ID within the station
489 Example of SiPM global channel (what is seen in the output file): 123001123,
490 where:
491 - 1: MTC unique ID
492 - 23: layer number
493 - 0: station type (0 for +5 degrees, 1 for -5 degrees)
494 - 0: mat number (only 0 by June 2025)
495 - 1: SiPM number (automatically assigned based on fibre aggregation
496 settings)
497 - 123: number of the SiPM channel (0-N). The channel number depends on the
498 fibre aggregation setting.
499 */
500
501 Double_t pos = fEdge + firstChannelX;
502 for (int imat = 0; imat < fNMats; imat++) {
503 for (int isipms = 0; isipms < fNSiPMs; isipms++) {
504 for (int ichannel = 0; ichannel < fNSiPMChan; ichannel++) {
505 // +5 degrees
506 SiPMmapVolU->AddNode(
507 ChannelVol, 100000 * 0 + imat * 10000 + isipms * 1000 + ichannel,
508 new TGeoTranslation(pos, 0, 0));
509 // -5 degrees
510 SiPMmapVolV->AddNode(
511 ChannelVol, 100000 * 1 + imat * 10000 + isipms * 1000 + ichannel,
512 new TGeoTranslation(-pos, 0, 0));
513 pos += fWidthChannel;
514 }
515 }
516 }
517}

Member Data Documentation

◆ airGap

Double_t MTCDetector::airGap = 0.1
private

Definition at line 92 of file MTCDetector.h.

◆ fChannelAggregated

Int_t MTCDetector::fChannelAggregated
private

Definition at line 102 of file MTCDetector.h.

◆ fFiberLength

Double_t MTCDetector::fFiberLength
private

Definition at line 87 of file MTCDetector.h.

◆ fFiberPitch

Double_t MTCDetector::fFiberPitch = 0.025
private

Definition at line 88 of file MTCDetector.h.

◆ fFiberRadius

Double_t MTCDetector::fFiberRadius = 0.01125
private

Definition at line 99 of file MTCDetector.h.

◆ fFieldY

Double_t MTCDetector::fFieldY
private

Definition at line 84 of file MTCDetector.h.

◆ fHeight

Double_t MTCDetector::fHeight
private

Definition at line 74 of file MTCDetector.h.

◆ fiberMatThick

Double_t MTCDetector::fiberMatThick = 0.135
private

Definition at line 86 of file MTCDetector.h.

◆ fibresSiPM_U

std::map<Int_t, std::map<Int_t, std::array<float, 2> > > MTCDetector::fibresSiPM_U
private

Definition at line 108 of file MTCDetector.h.

◆ fibresSiPM_V

std::map<Int_t, std::map<Int_t, std::array<float, 2> > > MTCDetector::fibresSiPM_V
private

inverse mapping

Definition at line 112 of file MTCDetector.h.

◆ fIronThick

Double_t MTCDetector::fIronThick
private

Definition at line 78 of file MTCDetector.h.

◆ fLayers

Int_t MTCDetector::fLayers
private

Definition at line 82 of file MTCDetector.h.

◆ fNMats

Int_t MTCDetector::fNMats = 1
private

Definition at line 106 of file MTCDetector.h.

◆ fNSiPMChan

Int_t MTCDetector::fNSiPMChan
private

Definition at line 101 of file MTCDetector.h.

◆ fNSiPMs

Int_t MTCDetector::fNSiPMs = 1
private

Definition at line 103 of file MTCDetector.h.

◆ fSciFiActiveX

Double_t MTCDetector::fSciFiActiveX
private

Definition at line 75 of file MTCDetector.h.

◆ fSciFiActiveY

Double_t MTCDetector::fSciFiActiveY
private

Definition at line 76 of file MTCDetector.h.

◆ fSciFiBendingAngle

Double_t MTCDetector::fSciFiBendingAngle
private

Definition at line 77 of file MTCDetector.h.

◆ fSciFiThick

Double_t MTCDetector::fSciFiThick
private

Definition at line 79 of file MTCDetector.h.

◆ fScintCellSize

Double_t MTCDetector::fScintCellSize
private

Definition at line 81 of file MTCDetector.h.

◆ fScintThick

Double_t MTCDetector::fScintThick
private

Definition at line 80 of file MTCDetector.h.

◆ fWidth

Double_t MTCDetector::fWidth
private

Definition at line 73 of file MTCDetector.h.

◆ fZCenter

Double_t MTCDetector::fZCenter
private

Definition at line 83 of file MTCDetector.h.

◆ fZEpoxyMat

Double_t MTCDetector::fZEpoxyMat
private

Definition at line 85 of file MTCDetector.h.

◆ kMaxChannelsPerSiPM

Int_t MTCDetector::kMaxChannelsPerSiPM = 1000
staticconstexprprivate

Definition at line 104 of file MTCDetector.h.

◆ lowerIronThick

Double_t MTCDetector::lowerIronThick = 0.3
private

Definition at line 91 of file MTCDetector.h.

◆ numFiberLayers

Int_t MTCDetector::numFiberLayers = 6
private

Definition at line 100 of file MTCDetector.h.

◆ siPMFibres_U

std::map<Int_t, std::map<Int_t, std::array<float, 2> > > MTCDetector::siPMFibres_U
private

mapping of fibres to SiPM channels

Definition at line 110 of file MTCDetector.h.

◆ siPMFibres_V

std::map<Int_t, std::map<Int_t, std::array<float, 2> > > MTCDetector::siPMFibres_V
private

mapping of fibres to SiPM channels

Definition at line 114 of file MTCDetector.h.

◆ SiPMPos_U

std::map<Int_t, float> MTCDetector::SiPMPos_U
private

inverse mapping

Definition at line 115 of file MTCDetector.h.

◆ SiPMPos_V

std::map<Int_t, float> MTCDetector::SiPMPos_V
private

Definition at line 115 of file MTCDetector.h.

◆ upperIronThick

Double_t MTCDetector::upperIronThick = 0.3
private

Definition at line 93 of file MTCDetector.h.

◆ zAirGap

Double_t MTCDetector::zAirGap = -0.15 / 10
private

Definition at line 96 of file MTCDetector.h.

◆ zFiberMat1

Double_t MTCDetector::zFiberMat1 = -1.325 / 10
private

Definition at line 95 of file MTCDetector.h.

◆ zFiberMat2

Double_t MTCDetector::zFiberMat2 = 1.025 / 10
private

Definition at line 97 of file MTCDetector.h.

◆ zLowerIronInt

Double_t MTCDetector::zLowerIronInt = -3.5 / 10
private

Definition at line 94 of file MTCDetector.h.

◆ zUpperIronInt

Double_t MTCDetector::zUpperIronInt = 3.2 / 10
private

Definition at line 98 of file MTCDetector.h.


The documentation for this class was generated from the following files: