EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDetector.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDetector.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairDetector source file -----
3 // ----- Created 06/01/04 by M. Al-Turany/ D. Bertini -----
4 // -------------------------------------------------------------------------
5 
6 
7 
8 #include "FairDetector.h"
9 
10 
11 #include "FairModule.h"
12 #include "FairVolume.h"
13 #include "FairGeoNode.h"
14 #include "FairLogger.h"
15 
16 
17 #include "TVirtualMC.h"
18 #include "TString.h"
19 #include "TFolder.h"
20 #include "TROOT.h"
21 // -------------------------------------------------------------------------
22 
23 FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId )
24  :FairModule(Name, "FAIR Detector", Active),
25  fDetId(DetId),
26  fLogger(FairLogger::GetLogger())
27 {
28  flGeoPar = new TList();
29  TString lname( GetName());
30  lname += "GeoPar";
31  flGeoPar->SetName(lname.Data());
32  kGeoSaved = kFALSE;
33 
34 
35 }
36 // -------------------------------------------------------------------------
37 
39 {
40 
41  if ( flGeoPar ) { delete flGeoPar; }
42 
43 }
44 // -------------------------------------------------------------------------
45 
47  :fDetId(0)
48 {
49 
50 }
51 // -------------------------------------------------------------------------
52 
54 {
55 // Registers hits collection in Root manager;
56 // sets sensitive volumes.
57 // ---
58  Int_t NoOfEntries=svList->GetEntries();
59  Int_t fMCid;
60  FairGeoNode* fN;
61  TString cutName;
62  TString copysign="#";
63  for (Int_t i = 0 ; i < NoOfEntries ; i++ ) {
64  FairVolume* aVol = (FairVolume*) svList->At(i);
65  cutName = aVol->GetName();
66  Ssiz_t pos = cutName.Index (copysign, 1);
67  if(pos>1) { cutName.Resize(pos); }
68  if ( aVol->getModId() == GetModId() ) {
69  fMCid=gMC->VolId(cutName.Data());
70  aVol->setMCid(fMCid);
71  fN=aVol->getGeoNode();
72  if (fN) { fN->setMCid(fMCid); }
73  }
74  }
75 
76 }
77 // -------------------------------------------------------------------------
78 
80 {
81 
82  if ( ! kGeoSaved ) {
83  fLogger->Info(MESSAGE_ORIGIN,"Detector: %s Geometry parameters saved ... ", GetName());
84  TFolder* mf = (TFolder*) gROOT->FindObjectAny("cbmroot");
85  TFolder* stsf = NULL;
86  if (mf ) { stsf = (TFolder*) mf->FindObjectAny(GetName()); }
87  if (stsf) {
88  TFolder* newf = stsf->AddFolder("Parameters","Detector parameters",NULL);
89  newf->Add( flGeoPar ) ;
90  }
91  kGeoSaved = kTRUE;
92  }
93 }
94 // -------------------------------------------------------------------------
95 
96 
98 
99 
100 
101