forked from JeffersonLab/EVe_HallC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WireChamber3D.cxx
142 lines (104 loc) · 5.51 KB
/
WireChamber3D.cxx
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
#include "WireChamber3D.h"
#include "TMath.h"
#include <cstring>
#include <cstdio>
#include <iostream>
#include <sstream>
#include "GetVariables.h"
#include <vector>
#include <string>
#include <map>
using namespace std;
WireChamber3D::WireChamber3D(char* ChamberName, vector<string> PlaneNames, GetVariables* DB,
TGeoVolume* top, TGeoManager* mgr)
{
double H= 100.0*DB->GetDouble(Form("%s.Height =",ChamberName));
double W= 100.0*DB->GetDouble(Form("%s.Width =",ChamberName));
double CT= DB->GetDouble(Form("%s.Thickness =",ChamberName));
double WT= DB->GetDouble(Form("%s.WallThickness =",ChamberName));
TGeoBBox *ChamberBox = new TGeoBBox(Form("%s.ChamberBox",ChamberName),5.0*CT/2.0,1.5*W/2.0,1.5*H/2.0);
Chamber3D = new TGeoVolume(Form("%s.Chamber",ChamberName),ChamberBox);
//Drawing Frame of the WireChamber
TGeoBBox *LRWall = new TGeoBBox("LRWall",1.0*CT/2.0,WT/2.0,H/2.0);
LeftWall = new TGeoVolume("LeftWall",LRWall);
LeftWall->SetLineColor(kBlack);
Chamber3D->AddNode(LeftWall,1,new TGeoTranslation(0,(W+WT)/2.0,0));
Chamber3D->AddNode(LeftWall,2,new TGeoTranslation(0,-(W+WT)/2.0,0));
TGeoBBox *ULWall = new TGeoBBox("ULWall",1.0*CT/2.0,W/2.0+WT,WT/2.0);
UpperWall = new TGeoVolume("UpperWall",ULWall);
UpperWall->SetLineColor(kBlack);
Chamber3D->AddNode(UpperWall,1, new TGeoTranslation(0,0,(H+WT)/2.0));
Chamber3D->AddNode(UpperWall,2, new TGeoTranslation(0,0,-(H+WT)/2.0));
//Draw all WirePlanes for the WireChamber
for(unsigned int i=0; i< PlaneNames.size(); i++) {
WirePlanes.insert(std::pair<string, WirePlane3D>(PlaneNames[i],
WirePlane3D(ChamberName,PlaneNames[i],Chamber3D, DB, top, mgr, i+2)));
}
//Get Rotation and Translation, AddNode to top Volume
TGeoRotation r1;
TGeoTranslation t1;
TGeoCombiTrans *comb;
double tilt = DB-> GetDouble(Form("%s.Tilt =",ChamberName));
double x0 = DB-> GetDouble(Form("%s.xPos =",ChamberName));
double y0 = DB-> GetDouble(Form("%s.yPos =",ChamberName));
double z0 = DB-> GetDouble(Form("%s.zPos =",ChamberName));
//cerr << Form("%s.xpos is ",ChamberName) << x0 <<Form(" %s.ypos is ",ChamberName) << y0 <<Form(" %s.zpos is ",ChamberName) << z0 << endl;
r1.SetAngles(90 - tilt,0,90,90,tilt,180);
t1.SetTranslation(x0+CT/2.0, y0, z0);
comb = new TGeoCombiTrans(t1, r1);
top->AddNodeOverlap(Chamber3D,1,comb);
// Test all TGeoVolume visibility related setting function:
// Volume hierachy is : top -> Chamber3D -> LeftWall, UpperWall
// -> WirePlanes -> Wires
// General rule 1:
// For Chamber 3D: since is not a final level, global setting will make it invisible, even SetVisibility is flag kTRUE
// Rule 2:
// All below functions have already set default values when TGeoVolume constructors have been called. For example, SetVisibility default setting is kTRUE.
// InvisibleAll(kTRUE) will set Chamber3D and its direct daughters (LeftWall, UpperWall and WirePlanes in this case)
// to invisible, but Wires will still be visible in 3D view
//Chamber3D->InvisibleAll(kTRUE);
// SetVisibility(kFALSE) will set Chamber3D invisible. But since global setting has already made it, it won't make any change.
//Chamber3D->SetVisibility(kTRUE);
// VisibleDaughters (kFALSE) will set Chamber3D's Daughters invisible, and since SetVIsbility is default kTRUE, Chamber3D itself will be shown in 3D view.
//Chamber3D->VisibleDaughters(kFALSE);
// Unkown function, will not make changes here but can make LeftWall invisible.
//Chamber3D->SetAttVisibility(kFALSE);
// Below 3 functions didn't make any change. However SetVisOnly may related to TGeoVolume::DrawOnly() method.
//Chamber3D->SetVisContainers(kTRUE);
//Chamber3D->SetVisOnly(kFALSE);
//Chamber3D->SetVisLeaves(kFALSE);
// Use those functions for LeftWall Volume, the difference is that LeftWall is 'leaves' (it contains no volume)
// This will make LeftWall and its replicate (RightWall) invisible.
//LeftWall->InvisibleAll(kTRUE);
// This will make LeftWall and it replicate invisible.
//LeftWall->SetVisibility(kFALSE);
// This will not make any change either kTRUE or kFALSE
//LeftWall->VisibleDaughters(kFALSE);
// This can make LeftWall invisible.
//LeftWall->SetAttVisibility(kFALSE);
// Below functions will not change visibilities of LeftWall.
//LeftWall->SetVisContainers(kFALSE);
//LeftWall->SetVisOnly(kTRUE);
//LeftWall-> SetVisLeaves(kFALSE);
// Test code to test Setvisibility function: when used in constructor, it will change visibility.
// When used in WireHit3D() and clear () below, after click 'Shwo this Event' button, the whole 3D view will be blank. Reason is unknown.
//LeftWall->SetVisibility (kFALSE);
//UpperWall->SetVisibility (kTRUE);
cout<<"Chamber 3D is created!"<<endl;
}
WireChamber3D::~WireChamber3D() {}
void WireChamber3D::WireHit3D(string PlaneName, int WireNum)
{
//TGeoTube *tube= (TGeoTube *) WirePlanes.find(PlaneName) ->second.Wires[(int) (WireNum/SPARSIFY)]->wire->GetShape();
WirePlanes.find(PlaneName)->second.Wire3DHit(WireNum);
//LeftWall->SetVisibility (kFALSE);
//UpperWall->SetVisibility (kTRUE);
}
void WireChamber3D::clear()
{
std::map<string, WirePlane3D>:: iterator itr;
for (itr=WirePlanes.begin(); itr!= WirePlanes.end(); itr++)
itr->second.clear();
//LeftWall->SetVisibility (kTRUE);
//UpperWall->SetVisibility (kTRUE);
}