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
|
//
// Macro to read in geomdet positions and draw them
//
int x3d( TString cut )
{
int showFlag = 2;
return x3d( cut, showFlag );
}
int x3d( TString cut, int showFlag )
{
// Retrieve trees and apply cut
TFile* alignedFile = new TFile("aligned.root");
TTree* tmpTree = (TTree*)alignedFile->Get("theTree");
TTree* alignedTree = (TTree*)tmpTree->CopyTree(cut);
TFile* misalignedFile = new TFile("misaligned.root");
tmpTree = (TTree*)misalignedFile->Get("theTree");
TTree* misalignedTree = (TTree*)tmpTree->CopyTree(cut);
// Set tree branches
float x,y,z,phi,theta,length,thick,width;
float mx,my,mz,mphi,mtheta,mlength,mthick,mwidth;
TRotMatrix* rot;
TRotMatrix* mrot;
double rad2deg = 180./3.1415926;
alignedTree->SetBranchAddress( "x", &x );
alignedTree->SetBranchAddress( "y", &y );
alignedTree->SetBranchAddress( "z", &z );
alignedTree->SetBranchAddress( "phi", &phi );
alignedTree->SetBranchAddress( "theta", &theta );
alignedTree->SetBranchAddress( "length", &length );
alignedTree->SetBranchAddress( "width", &width );
alignedTree->SetBranchAddress( "thick", &thick );
alignedTree->SetBranchAddress( "rot", &rot );
misalignedTree->SetBranchAddress( "x", &mx );
misalignedTree->SetBranchAddress( "y", &my );
misalignedTree->SetBranchAddress( "z", &mz );
misalignedTree->SetBranchAddress( "phi", &mphi );
misalignedTree->SetBranchAddress( "theta", &mtheta );
misalignedTree->SetBranchAddress( "length", &mlength );
misalignedTree->SetBranchAddress( "width", &mwidth );
misalignedTree->SetBranchAddress( "thick", &mthick );
misalignedTree->SetBranchAddress( "rot", &mrot );
// Create canvas
TCanvas* c1 = new TCanvas("c1","Detector units", 200, 10, 700, 500);
c1->cd();
TBRIK* IP = new TBRIK("IP","IP","void",0.,0.,0.);
TNode* rootNode = new TNode("Root","Root","IP",0.,0.,0.);
rootNode->cd();
int entry = 0;
while ( alignedTree->GetEntry(entry) && misalignedTree->GetEntry(entry) )
{
entry++;
std::ostringstream name;
// Aligned detector
name << "aBrik" << entry;
TBRIK* aBrik = new TBRIK(name.str().c_str(),"Aligned detector unit","void",
0.01,0.01,length);
aBrik->SetLineColor(4);
// Detector node (position and orientation)
name.str("aNode"); name << entry;
TNode* aNode = new TNode(name.str().c_str(),name.str().c_str(),aBrik,x,y,z);
// Misaligned detector
name.str("mBrik");
name << entry;
TBRIK* mBrik = new TBRIK(name.str().c_str(),"Misaligned detector unit","void",
0.01,0.01,mlength);
mBrik->SetLineColor(2);
// Detector node (position and orientation)
name.str("mNode"); name << entry;
TNode* mNode = new TNode(name.str().c_str(),name.str().c_str(),mBrik,mx,my,mz);
//if (entry>5) break;
}
rootNode->cd();
rootNode->Draw();
c1->GetViewer3D();
return 0;
}
|