-
Notifications
You must be signed in to change notification settings - Fork 6
/
generalDisplay.C
252 lines (226 loc) · 8.6 KB
/
generalDisplay.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
std::map<TString,Int_t> getMaterialKolor();
void isThereOverlap( TGeoManager *geo, Int_t checkoverlaps );
void paintingVolumes( TGeoManager *geo );
TEveLine *getEveLine();
TEvePointSet *getEvePointArgonCube(TGeoManager *geo);
TEvePointSet *getEvePointDipole(TGeoManager *geo);
//============================================
//============================================
// generalDisplay
//============================================
//============================================
void generalDisplay( TString filename, Bool_t drawbeam=kTRUE, Int_t checkoverlaps=0, Int_t vislevel=10 )
{
TEveManager::Create();
TFile::SetCacheFileDir(".");
TGeoManager *geo2 = gEve->GetGeometry(filename);
if ( checkoverlaps ) isThereOverlap( geo2, checkoverlaps );
paintingVolumes( geo2 );
TEveGeoTopNode* tn = new TEveGeoTopNode( geo2, geo2->GetTopNode() );
tn->SetVisLevel(vislevel);
gEve->AddGlobalElement(tn);
if ( drawbeam )
{
TEveLine *eveline = getEveLine();
gEve->AddGlobalElement( eveline );
}
TEvePointSet* markerArgonCube = getEvePointArgonCube( geo2 );
gEve->AddGlobalElement(markerArgonCube);
TEvePointSet* markerDipole = getEvePointDipole( geo2 );
gEve->AddGlobalElement(markerDipole);
gEve->FullRedraw3D(kTRUE);
TGLViewer *v = gEve->GetDefaultGLViewer();
// EClipType not exported to CINT (see TGLUtil.h):
// 0 - no clip, 1 - clip plane, 2 - clip box
v->GetClipSet()->SetClipType(TGLClip::EType(0));
v->ColorSet().Background().SetColor(kMagenta+4);
v->SetGuideState(TGLUtil::kAxesOrigin, kTRUE, kFALSE, 0);
v->RefreshPadEditor(v);
//v->CurrentCamera().RotateRad(-1.2, 0.5);
v->DoDraw();
}
//============================================
// getMaterialKolor
//============================================
std::map<TString,Int_t> getMaterialKolor()
{
std::map<TString,Int_t> KKolor;
KKolor["Steel"] = kGreen;
KKolor["Copper"] = kYellow;
KKolor["Aluminum"] = kRed;
KKolor["FR4"] = kGray;
KKolor["Scintillator"] = kGray;
return KKolor;
}
//============================================
// getKolor
//============================================
void isThereOverlap( TGeoManager *geo, Int_t checkoverlaps )
{
if ( checkoverlaps == 1 )
{
geo->CheckOverlaps(1e-5,"d");
geo->PrintOverlaps();
}
else if ( checkoverlaps == 2 )
{
geo->CheckOverlaps(1e-5,"s10000000");
geo->PrintOverlaps();
}
else
cout << " WARNING: checkoverlaps input no defined" << endl;
}
//============================================
// paintingVolumes
//============================================
void paintingVolumes( TGeoManager *geo )
{
Int_t PriKolor[] = { 2, 3, 4, 5, 6, 7, 8, 9, 28, 30, 38, 40, 41, 42, 46 };
Int_t PriIndex = 0;
std::map<TString,Int_t> materialKolor = getMaterialKolor();
TGeoVolume *volume = NULL;
TObjArray *volumes = geo->GetListOfVolumes();
Int_t nvolumes = volumes->GetEntries();
for ( int i = 0; i < nvolumes; i++ )
{
volume = (TGeoVolume*)volumes->At(i);
volume->SetVisContainers(kTRUE);
if ( TString(volume->GetName()).Contains("DetEnclosure"))
{
volume->SetVisibility(kFALSE);
continue;
}
if ( TString(volume->GetMaterial()->GetName()).Contains("Air"))
{
volume->SetVisibility(kFALSE);
continue;
}
if ( materialKolor[volume->GetMaterial()->GetName()] == 0 )
{
PriIndex = PriIndex == sizeof(PriKolor) /sizeof(PriKolor[0]) ? 0 : PriIndex + 1;
volume->SetLineColor( PriKolor[PriIndex] );
}
else
{
volume->SetLineColor( materialKolor[volume->GetMaterial()->GetName()] );
}
Int_t daughters = volume->GetNdaughters();
switch ( daughters )
{
case 0: volume->SetTransparency(100);
case 1: volume->SetTransparency(80);
case 2: volume->SetTransparency(60);
case 3: volume->SetTransparency(40);
default: volume->SetTransparency(20);
}
}
}
//============================================
// getEveLine
//============================================
TEveLine *getEveLine()
{
TEveLine* line = new TEveLine;
line->SetMainColor(kRed);
line->SetLineWidth(4);
int pdg=14;
int m1=0; int m2=0; int d1=0; int d2=0;
double p=1.0;
double beam_angle=0.101;
double py=-p*sin(beam_angle);
double pz= p*cos(beam_angle);
double px=0;
double vx=0;
double vz=-762; //Front of hall at -762 in global coordinate system
double hall_start_z_in_hall_coordinates=-15.02e2;// ~15m
double hall_length=-2*hall_start_z_in_hall_coordinates;
double hall_back_global=-762 + hall_length;
double beam_entering_height=592.2 - hall_start_z_in_hall_coordinates*tan(0.101);
double global_y0_height=335;
double vy=beam_entering_height-global_y0_height;
cout<<"Beam enters the hall at a height of "<<beam_entering_height<<" cm"<<endl;
cout<<"That is y= "<<vy<<" in the global coordinate system"<<endl;
int npoints=200;
double step=hall_length/(1.0*npoints);
for (int ipoint=0; ipoint<npoints; ipoint++)
{
double dz=step*ipoint;
double dy=-dz*tan(beam_angle);
double z=vz+dz;
double y=vy+dy;
cout << y << " " << z << endl;
line->SetNextPoint(0,y,z);
}
return line;
}
//============================================
// getEvePointArgonCube
//============================================
TEvePointSet *getEvePointArgonCube(TGeoManager *geo)
{
//geo->cd("/volWorld_1/volDetEnclosure_0/volArgonCubeDetector_0/volArgonCubeCryostat_0/volReinforcedConcrete_0/volArgonCubeActive_0");
TString pathname = "/volWorld_1/volDetEnclosure_0/volArgonCubeDetector_0/volArgonCubeCryostat_0/";
pathname += "volReinforcedConcrete_0/volMoistureBarrier_0/volInsulationBoard2_0/";
pathname += "volGREBoard2_0/volInsulationBoard1_0/volGREBoard1_0/volFireproofBoard_0/";
pathname += "volSSMembrane_0/volArgonCubeService_0/volArgonCube_0/volArgonCubeActive_0";
if ( geo->CheckPath(pathname) )
{
cout << " cd into : " << pathname << endl;
geo->cd(pathname);
}
//geo->cd(pathname);
TGeoMatrix *active = gGeoManager->GetCurrentMatrix();
double local_active[3]={0,0,0};
double master_active[3]={0,0,0};
active->LocalToMaster(local_active,master_active);
cout<<"The center of ArgonCubeActive in the global coordinate system: \n"<<" ( "<<master_active[0]<<", "<<master_active[1]<<", "<<master_active[2]<<" )"<<endl;
geo->cd("/volWorld_1/volDetEnclosure_0");
TGeoMatrix *enclosure = gGeoManager->GetCurrentMatrix();
double local_enclosure[3]={0,0,0};
double master_enclosure[3]={0,0,0};
enclosure->LocalToMaster(local_enclosure,master_enclosure);
cout<<"The center of DetEnclosure in the global coordinate system: \n"<<" ( "<<master_enclosure[0]<<", "<<master_enclosure[1]<<", "<<master_enclosure[2]<<" )"<<endl;
double active_in_enclosure[3]={0,0,0};
enclosure->MasterToLocal(master_active,active_in_enclosure);
cout<<"The center of ArgonCubeActive in the DetEnclosure coordinate system: \n"<<" ( "<<active_in_enclosure[0]<<", "<<active_in_enclosure[1]<<", "<<active_in_enclosure[2]<<" )"<<endl;
TEvePointSet *marker = new TEvePointSet(1);
marker->SetName("ArgonCube Marker");
marker->SetMarkerColor(6);
marker->SetMarkerStyle(29);
marker->SetMarkerSize(2);
marker->SetPoint(0, master_active[0], master_active[1], master_active[2]);
return marker;
}
//============================================
// getEvePointDipole
//============================================
TEvePointSet *getEvePointDipole(TGeoManager *geo)
{
TString pathname = "/volWorld_1/volDetEnclosure_0/volIronDipole_0/innerDet_volume_0/";
if ( geo->CheckPath(pathname) )
{
cout << " cd into : " << pathname << endl;
geo->cd(pathname);
}
//geo->cd(pathname);
TGeoMatrix *active = gGeoManager->GetCurrentMatrix();
double local_active[3]={0,0,0};
double master_active[3]={0,0,0};
active->LocalToMaster(local_active,master_active);
cout<<"The center of Dipole in the global coordinate system: \n"<<" ( "<<master_active[0]<<", "<<master_active[1]<<", "<<master_active[2]<<" )"<<endl;
geo->cd("/volWorld_1/volDetEnclosure_0");
TGeoMatrix *enclosure = gGeoManager->GetCurrentMatrix();
double local_enclosure[3]={0,0,0};
double master_enclosure[3]={0,0,0};
enclosure->LocalToMaster(local_enclosure,master_enclosure);
double active_in_enclosure[3]={0,0,0};
enclosure->MasterToLocal(master_active,active_in_enclosure);
cout<<"The center of Dipole in the DetEnclosure coordinate system: \n"<<" ( "<<active_in_enclosure[0]<<", "<<active_in_enclosure[1]<<", "<<active_in_enclosure[2]<<" )"<<endl;
TEvePointSet *marker = new TEvePointSet(1);
marker->SetName("Dipole Marker");
marker->SetMarkerColor(6);
marker->SetMarkerStyle(29);
marker->SetMarkerSize(2);
marker->SetPoint(0, master_active[0], master_active[1], master_active[2]);
return marker;
}