]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4MaterialsFrames.cxx
Updated SDigitizer
[u/mrichter/AliRoot.git] / TGeant4 / TG4MaterialsFrames.cxx
CommitLineData
4b1d6659 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
5//
6//========================================================
7//
8//------------TG4MaterialsFrames.cxx--------------------------------//
9//--------- Frames for the the display of materials properties---//
10//
11//=========================================================
12
13#include "TG4MaterialsFrames.h"
14#include "TG4Globals.h"
15
16#include <TGTextBuffer.h>
17#include <TGTextEntry.h>
18#include <TGComboBox.h>
19#include <TGLabel.h>
f9ea40e1 20#include <TGTab.h>
4b1d6659 21
22#include <G4Material.hh>
23#include <G4Element.hh>
24
25
26
27 ClassImp(TG4MaterialsFrames)
28
f9ea40e1 29TG4MaterialsFrames::TG4MaterialsFrames( TGTab* Tab, TGMainFrame* ActionFrame )
4b1d6659 30{
31//---> creates the materials properties display frame
32//---> and plunges it into the main frame
2ced62e8 33 TGCompositeFrame* parent = Tab->AddTab("Materials Properties");
34 fCapFrame = new TGCompositeFrame(parent, 60, 20, kHorizontalFrame);
20380626 35 ULong_t back= TGFrame::GetBlackPixel();
36 fCapFrame->ChangeBackground(back);
4b1d6659 37 fMatSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
38 fMatFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
39
40 // ComboBox for materials
41 fMaterialsCombo = new TGComboBox(fMatSubframe1, 200);
42 TGLayoutHints* lLayoutHints3 =
43 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
44 2, 2, 2, 2);
45 Text_t* lComboLabelText = " Pick up a material here ";
46 fComboLabel = new TGLabel( fMatSubframe1, lComboLabelText);
47 fMatSubframe1->AddFrame(fComboLabel, lLayoutHints3);
48 fMatSubframe1->AddFrame(fMaterialsCombo, fMatFrameLayout);
49
50
39dd4871 51 fMaterialsCombo->Resize(200, 30);
4b1d6659 52 fMaterialsCombo->Associate(ActionFrame);
53
54
55
56// text labels with material properties
57 Text_t* labelText[8] =
58 {"Index ",
59 "Number of elements",
60 "Elements list ",
61 "Atomic mass ",
62 "Density ",
63 "State ",
64 "Radiation Length ",
65 "Abs. Length " };
66
67// Entries for material properties
68 TGLayoutHints* lLayoutHints4 =
69 new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
70 TGLayoutHints* lLayoutHints5 =
71 new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
72 fMatSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
73
74 { // local scope for i
75 for (Int_t i=0; i<8; i++) {
76 Int_t idT=i+1;
77 fHframe[i] = new TGHorizontalFrame(fMatSubframe2, 500, 100, kFixedWidth);
78 fMatTextBuff[i] = new TGTextBuffer(200);
79 fMatTextEntry[i] = new TGTextEntry(fHframe[i], fMatTextBuff[i], 300);
80 fLabel[i] = new TGLabel(fHframe[i], labelText[i]);
81 fHframe[i]->AddFrame(fLabel[i], lLayoutHints5);
82 fHframe[i]->AddFrame(fMatTextEntry[i], lLayoutHints5);
83 fMatSubframe2->AddFrame(fHframe[i], lLayoutHints4);
84 fMatTextEntry[i]->Associate(ActionFrame);
85 }
86 }
87
88// making up Materials frame
89 fCapFrame->AddFrame(fMatSubframe1,fMatFrameLayout);
90 fCapFrame->AddFrame(fMatSubframe2,fMatFrameLayout);
91
92// going to the main frame
2ced62e8 93 parent->AddFrame(fCapFrame, fMatFrameLayout);
4b1d6659 94
95}
96
97TG4MaterialsFrames::TG4MaterialsFrames(const TG4MaterialsFrames& mf)
98{
99// Dummy copy constructor
100 TG4Globals::Exception(
101 "Attempt to use TG4MaterialsFrames copy constructor.");
102}
103
104TG4MaterialsFrames& TG4MaterialsFrames::operator=(const TG4MaterialsFrames& mf)
105{
106 // check assignement to self
107 if (this == &mf) return *this;
108
109 TG4Globals::Exception(
110 "Attempt to assign TG4MaterialsFrames singleton.");
111
112 return *this;
113}
114
115TG4MaterialsFrames::~TG4MaterialsFrames()
116{
117 //---> liquidator
118
119 G4cout << "\n Now in TG4MaterialsFrames destructor \n"<< G4endl;
120 delete fMatSubframe1;
121 delete fMatFrameLayout;
122 delete fMaterialsCombo;
123 delete fComboLabel;
124 delete fMatSubframe2;
125 delete fCapFrame;
126
127 Int_t i;
128 for (i=0; i<8; i++) {
129 delete fHframe[i];
130 delete fMatTextBuff[i];
131 delete fMatTextEntry[i];
132 delete fLabel[i];
133 }
134
135}
136
137void TG4MaterialsFrames::SetMaterialsComboEntries()
138{
139//---> puts names of materials into the combo box entries
140
141 const G4MaterialTable* lComboEntries = G4Material::GetMaterialTable();
142
193795c0 143 G4int ig = lComboEntries->size();
4b1d6659 144 G4String name;
145
146 for (int ii=0; ii < ig; ii++)
147 { name = ((*lComboEntries )[ii])->GetName() ;
148 AddMaterialName( name, ii+1);
149 };
150
151 name = " " ;
152 AddMaterialName( name, ig+1);
153
154}
155
156void TG4MaterialsFrames::AddMaterialName( const char* name, Int_t index) const
157{
158
159//-----> adds a material name to the combo box
160
161 fMaterialsCombo->AddEntry( name, index);
162 fMaterialsCombo->Select(index);
163 fMaterialsCombo->Resize(200, 20);
164}
165
39dd4871 166void TG4MaterialsFrames::DisplayMaterialCharacteristics( int qmat)
4b1d6659 167{
168
39dd4871 169//---> shows informations about materials listed in G4MaterialTable
170//---> qmat eq 0 means clicking in the MaterialsFrames ComboBox
171//---> qmat gt 0 means clicking in the VolumesFrames ComboBox
4b1d6659 172
173 const G4MaterialTable* lComboEntries = G4Material::GetMaterialTable();
193795c0 174 G4int ientr = lComboEntries->size();
39dd4871 175 G4int index = qmat ;
176
177 if ( !(qmat < 1) )
178 fMaterialsCombo->Select( index );
179
180 if ( qmat < 1 )
181 index = fMaterialsCombo->GetSelected();
4b1d6659 182
183 G4cout << "\nThe clicked-on material has the index: " << index << G4endl;
184
185 if( index < ientr+1 ) {
186
187 G4int ii = index-1;
188 G4Material* lvMaterial = (*lComboEntries )[ii];
189 const G4ElementVector* allElements = lvMaterial->GetElementVector();
190
191 G4cout << lvMaterial->GetName() << " "
192 << lvMaterial->GetNumberOfElements() << " "
193 << (*allElements )[0]->GetName() << "... "
39dd4871 194 << lvMaterial->GetDensity()/(g/cm3) << "(g/cm3) "
4b1d6659 195 << lvMaterial->GetState() << " "
39dd4871 196 << lvMaterial->GetRadlen()/(cm) << "(cm) "
4b1d6659 197 << G4endl;
198
199 char buff[200];
39dd4871 200 G4String line = " ";
4b1d6659 201
39dd4871 202 sprintf(buff, "%12i",index );
4b1d6659 203 fMatTextBuff[0]->Clear();
204 fMatTextBuff[0]->AddText(0, buff);
205 gClient->NeedRedraw(fMatTextEntry[0]);
206
207 G4int noe = lvMaterial->GetNumberOfElements();
39dd4871 208 sprintf(buff, "%12i", noe);
4b1d6659 209 fMatTextBuff[1]->Clear();
210 fMatTextBuff[1]->AddText(0, buff);
211 gClient->NeedRedraw(fMatTextEntry[1]);
212
213 G4String stringOfElements = " ";
214 for (G4int ie=0; ie < noe; ie++) {
215 stringOfElements += (*allElements )[ie]->GetName();
216 stringOfElements += " ";
217 };
218 sprintf(buff, stringOfElements);
219 fMatTextBuff[2]->Clear();
220 fMatTextBuff[2]->AddText(0, buff);
221 gClient->NeedRedraw(fMatTextEntry[2]);
222
39dd4871 223 sprintf(buff, " Multi element material" );
224 if( noe < 2 )
225 sprintf(buff, "%12.5e", lvMaterial->GetA()/(g) );
226 line += buff;
4b1d6659 227 if( noe < 2 )
39dd4871 228 line += " (g)";
4b1d6659 229 fMatTextBuff[3]->Clear();
39dd4871 230 fMatTextBuff[3]->AddText(0, line);
4b1d6659 231 gClient->NeedRedraw(fMatTextEntry[3]);
39dd4871 232 line = " ";
4b1d6659 233
39dd4871 234 sprintf(buff, "%12.5e", lvMaterial->GetDensity()/(g/cm3) );
235 line += buff;
236 line += " (g/cm3)";
4b1d6659 237 fMatTextBuff[4]->Clear();
39dd4871 238 fMatTextBuff[4]->AddText(0, line);
4b1d6659 239 gClient->NeedRedraw(fMatTextEntry[4]);
39dd4871 240 line = " ";
4b1d6659 241
39dd4871 242 sprintf(buff,"%12i", lvMaterial->GetState());
4b1d6659 243 fMatTextBuff[5]->Clear();
244 fMatTextBuff[5]->AddText(0, buff);
245 gClient->NeedRedraw(fMatTextEntry[5]);
246
39dd4871 247 sprintf(buff,"%12.5e", lvMaterial->GetRadlen()/(cm));
248 line += buff;
249 line += " (cm)";
4b1d6659 250 fMatTextBuff[6]->Clear();
39dd4871 251 fMatTextBuff[6]->AddText(0, line);
4b1d6659 252 gClient->NeedRedraw(fMatTextEntry[6]);
39dd4871 253 line = " ";
4b1d6659 254
255 sprintf(buff, " " );
256 fMatTextBuff[7]->Clear();
257 fMatTextBuff[7]->AddText(0, buff);
258 gClient->NeedRedraw(fMatTextEntry[7]);
259
260 };
261
262 if( index == ientr+1 ) {
263
264 for ( G4int ii=0; ii<8; ii++) {
265 fMatTextBuff[ii]->Clear();
266 gClient->NeedRedraw(fMatTextEntry[ii]);
267 };
268 };
269
270}
271