Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309713
FROG_Element_Event_CaloTower.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Subscribers
None
FROG_Element_Event_CaloTower.h
View Options
#ifndef _FROG_ELEMENT_EVENT_CALOTOWER_H__
#define _FROG_ELEMENT_EVENT_CALOTOWER_H__
#include
"FROG_Element_Base.h"
class
FROG_Element_Event_CaloTower
:
public
FROG_Element_Base_With_DetId
{
public
:
float
Eem_
;
float
Ehad_
;
unsigned
int
Components_CollEvtId_
;
std
::
vector
<
unsigned
int
>
Components_Vector_
;
float
Em_Color_
[
4
];
FROG_Element_Geom_CaloMod
*
det
;
std
::
vector
<
FROG_Element_Base
*>
Components
;
virtual
bool
isCompactible
(){
return
false
;
}
static
unsigned
int
sizeOf
(){
return
FROG_Element_Base_With_DetId
::
sizeOf
()
+
2
*
sizeof
(
float
);
}
FROG_Element_Event_CaloTower
(
)
:
FROG_Element_Base_With_DetId
(
C_RECO_CALOTOWER
){}
FROG_Element_Event_CaloTower
(
unsigned
int
DetId
,
float
Eem
,
float
Ehad
)
:
FROG_Element_Base_With_DetId
(
C_RECO_CALOTOWER
,
DetId
),
Eem_
(
Eem
),
Ehad_
(
Ehad
)
{
size_
=
sizeOf
();
}
unsigned
int
read
(
FILE
*
pFile
,
unsigned
int
ToRead
){
unsigned
int
read
=
0
;
read
+=
fread
(
&
detId_
,
1
,
sizeof
(
detId_
)
,
pFile
);
read
+=
fread
(
&
Eem_
,
1
,
sizeof
(
Eem_
)
,
pFile
);
read
+=
fread
(
&
Ehad_
,
1
,
sizeof
(
Ehad_
)
,
pFile
);
if
(
Eem_
<
0
)
Eem_
*=-
1
;
if
(
read
>=
ToRead
)
return
read
;
read
+=
fread
(
&
Components_CollEvtId_
,
1
,
sizeof
(
unsigned
int
),
pFile
);
unsigned
int
NComp
=
(
ToRead
-
read
)
/
sizeof
(
unsigned
int
);
unsigned
int
TempComp
;
for
(
unsigned
int
i
=
0
;
i
<
NComp
;
i
++
){
read
+=
fread
(
&
TempComp
,
1
,
sizeof
(
unsigned
int
)
,
pFile
);
Components_Vector_
.
push_back
(
TempComp
);
}
return
read
;
}
virtual
void
write
()
{
size_
=
sizeOf
();
if
(
Components_Vector_
.
size
()
>
0
)
size_
+=
sizeof
(
unsigned
int
)
+
Components_Vector_
.
size
()
*
sizeof
(
unsigned
int
);
data_
=
new
unsigned
char
[
size_
-
6
];
data_
=
FillBuffer
(
data_
,
&
detId_
,
sizeof
(
detId_
));
data_
=
FillBuffer
(
data_
,
&
Eem_
,
sizeof
(
Eem_
));
data_
=
FillBuffer
(
data_
,
&
Ehad_
,
sizeof
(
Ehad_
));
if
(
Components_Vector_
.
size
()
>
0
){
data_
=
FillBuffer
(
data_
,
&
Components_CollEvtId_
,
sizeof
(
Components_CollEvtId_
));
for
(
unsigned
int
i
=
0
;
i
<
Components_Vector_
.
size
();
i
++
){
data_
=
FillBuffer
(
data_
,
&
Components_Vector_
[
i
],
sizeof
(
Components_Vector_
[
i
]));
}
}
data_
=
(
unsigned
char
*
)((
unsigned
long
)
data_
-
(
size_
-
6
)
);
}
virtual
void
printInfos
(
char
*
buffer
){
sprintf
(
buffer
,
"CaloTower : DetId=%i Eem=%7.2f Ehad=%7.2f"
,
detId_
,
Eem_
,
Ehad_
);
}
#ifdef FROG_OPENGL
void
Object_SmartDisplay
(){
GLfloat
*
positionData
=
NULL
;
GLfloat
*
normalData
=
NULL
;
if
(
DisplayList_
){
glCallList
(
DisplayList_
);
return
;
}
if
(
!
VBO_Vertices_
){
float
ERatioA
=
Eem_
/
style_
->
EMin_
;
float
ERatioB
=
Ehad_
/
style_
->
EMin_
;
float
ERatio
=
ERatioA
+
ERatioB
;
if
(
style_
->
DisplayMode_
%
4
==
0
){
ERatioA
=
0.75f
*
log10
(
ERatioA
);
if
(
ERatioA
<
0
)
ERatioA
=
0
;
ERatioB
=
0.75f
*
log10
(
ERatioB
);
if
(
ERatioB
<
0
)
ERatioB
=
0
;
ERatio
=
ERatioA
+
ERatioB
;
if
(
ERatio
>
1
){
ERatioA
/=
ERatio
;
ERatioB
/=
ERatio
;
ERatio
/=
ERatio
;
}
}
else
if
(
style_
->
DisplayMode_
%
4
==
1
){
ERatioA
=
0.75f
*
log10
(
ERatioA
);
if
(
ERatioA
<
0
)
ERatioA
=
0
;
ERatioB
=
0.75f
*
log10
(
ERatioB
);
if
(
ERatioB
<
0
)
ERatioB
=
0
;
ERatio
=
ERatioA
+
ERatioB
;
}
else
if
(
style_
->
DisplayMode_
%
4
==
2
){
ERatioA
=
0.1f
*
ERatioA
;
ERatioB
=
0.1f
*
ERatioB
;
ERatio
=
ERatioA
+
ERatioB
;
if
(
ERatio
>
1
){
ERatioA
/=
ERatio
;
ERatioB
/=
ERatio
;
ERatio
/=
ERatio
;
}
}
else
{
ERatioA
=
0.1f
*
ERatioA
;
ERatioB
=
0.1f
*
ERatioB
;
ERatio
=
ERatioA
+
ERatioB
;
}
float
ProjA
=
1
+
(
det
->
ProjFactor
-
1
)
*
ERatioA
;
float
ProjB
=
1
+
(
det
->
ProjFactor
-
1
)
*
ERatio
;
float
&
PosX
=
det
->
PosX
;
float
&
WX
=
det
->
WX
;
float
&
HX
=
det
->
HX
;
float
&
PosY
=
det
->
PosY
;
float
&
WY
=
det
->
WY
;
float
&
HY
=
det
->
HY
;
float
&
PosZ
=
det
->
PosZ
;
float
&
WZ
=
det
->
WZ
;
float
&
HZ
=
det
->
HZ
;
float
C1X
=
PosX
-
WX
-
HX
;
float
C1Y
=
PosY
-
WY
-
HY
;
float
C1Z
=
PosZ
-
WZ
-
HZ
;
float
C2X
=
PosX
+
WX
-
HX
;
float
C2Y
=
PosY
+
WY
-
HY
;
float
C2Z
=
PosZ
+
WZ
-
HZ
;
float
C3X
=
PosX
+
WX
+
HX
;
float
C3Y
=
PosY
+
WY
+
HY
;
float
C3Z
=
PosZ
+
WZ
+
HZ
;
float
C4X
=
PosX
-
WX
+
HX
;
float
C4Y
=
PosY
-
WY
+
HY
;
float
C4Z
=
PosZ
-
WZ
+
HZ
;
float
C5Xa
=
C1X
*
ProjA
;
float
C5Ya
=
C1Y
*
ProjA
;
float
C5Za
=
C1Z
*
ProjA
;
float
C6Xa
=
C2X
*
ProjA
;
float
C6Ya
=
C2Y
*
ProjA
;
float
C6Za
=
C2Z
*
ProjA
;
float
C7Xa
=
C3X
*
ProjA
;
float
C7Ya
=
C3Y
*
ProjA
;
float
C7Za
=
C3Z
*
ProjA
;
float
C8Xa
=
C4X
*
ProjA
;
float
C8Ya
=
C4Y
*
ProjA
;
float
C8Za
=
C4Z
*
ProjA
;
float
C5Xb
=
C1X
*
ProjB
;
float
C5Yb
=
C1Y
*
ProjB
;
float
C5Zb
=
C1Z
*
ProjB
;
float
C6Xb
=
C2X
*
ProjB
;
float
C6Yb
=
C2Y
*
ProjB
;
float
C6Zb
=
C2Z
*
ProjB
;
float
C7Xb
=
C3X
*
ProjB
;
float
C7Yb
=
C3Y
*
ProjB
;
float
C7Zb
=
C3Z
*
ProjB
;
float
C8Xb
=
C4X
*
ProjB
;
float
C8Yb
=
C4Y
*
ProjB
;
float
C8Zb
=
C4Z
*
ProjB
;
VBO_VerticesN_
=
48
;
positionData
=
new
GLfloat
[
3
*
VBO_VerticesN_
];
normalData
=
new
GLfloat
[
3
*
VBO_VerticesN_
];
positionData
[
0
]
=
C1X
;
positionData
[
1
]
=
C1Y
;
positionData
[
2
]
=
C1Z
;
positionData
[
3
]
=
C4X
;
positionData
[
4
]
=
C4Y
;
positionData
[
5
]
=
C4Z
;
positionData
[
6
]
=
C3X
;
positionData
[
7
]
=
C3Y
;
positionData
[
8
]
=
C3Z
;
positionData
[
9
]
=
C2X
;
positionData
[
10
]
=
C2Y
;
positionData
[
11
]
=
C2Z
;
positionData
[
12
]
=
C5Xa
;
positionData
[
13
]
=
C5Ya
;
positionData
[
14
]
=
C5Za
;
positionData
[
15
]
=
C6Xa
;
positionData
[
16
]
=
C6Ya
;
positionData
[
17
]
=
C6Za
;
positionData
[
18
]
=
C7Xa
;
positionData
[
19
]
=
C7Ya
;
positionData
[
20
]
=
C7Za
;
positionData
[
21
]
=
C8Xa
;
positionData
[
22
]
=
C8Ya
;
positionData
[
23
]
=
C8Za
;
positionData
[
24
]
=
C1X
;
positionData
[
25
]
=
C1Y
;
positionData
[
26
]
=
C1Z
;
positionData
[
27
]
=
C2X
;
positionData
[
28
]
=
C2Y
;
positionData
[
29
]
=
C2Z
;
positionData
[
30
]
=
C6Xa
;
positionData
[
31
]
=
C6Ya
;
positionData
[
32
]
=
C6Za
;
positionData
[
33
]
=
C5Xa
;
positionData
[
34
]
=
C5Ya
;
positionData
[
35
]
=
C5Za
;
positionData
[
36
]
=
C4X
;
positionData
[
37
]
=
C4Y
;
positionData
[
38
]
=
C4Z
;
positionData
[
39
]
=
C8Xa
;
positionData
[
40
]
=
C8Ya
;
positionData
[
41
]
=
C8Za
;
positionData
[
42
]
=
C7Xa
;
positionData
[
43
]
=
C7Ya
;
positionData
[
44
]
=
C7Za
;
positionData
[
45
]
=
C3X
;
positionData
[
46
]
=
C3Y
;
positionData
[
47
]
=
C3Z
;
positionData
[
48
]
=
C1X
;
positionData
[
49
]
=
C1Y
;
positionData
[
50
]
=
C1Z
;
positionData
[
51
]
=
C5Xa
;
positionData
[
52
]
=
C5Ya
;
positionData
[
53
]
=
C5Za
;
positionData
[
54
]
=
C8Xa
;
positionData
[
55
]
=
C8Ya
;
positionData
[
56
]
=
C8Za
;
positionData
[
57
]
=
C4X
;
positionData
[
58
]
=
C4Y
;
positionData
[
59
]
=
C4Z
;
positionData
[
60
]
=
C2X
;
positionData
[
61
]
=
C2Y
;
positionData
[
62
]
=
C2Z
;
positionData
[
63
]
=
C3X
;
positionData
[
64
]
=
C3Y
;
positionData
[
65
]
=
C3Z
;
positionData
[
66
]
=
C7Xa
;
positionData
[
67
]
=
C7Ya
;
positionData
[
68
]
=
C7Za
;
positionData
[
69
]
=
C6Xa
;
positionData
[
70
]
=
C6Ya
;
positionData
[
71
]
=
C6Za
;
positionData
[
72
]
=
C5Xa
;
positionData
[
73
]
=
C5Ya
;
positionData
[
74
]
=
C5Za
;
positionData
[
75
]
=
C8Xa
;
positionData
[
76
]
=
C8Ya
;
positionData
[
77
]
=
C8Za
;
positionData
[
78
]
=
C7Xa
;
positionData
[
79
]
=
C7Ya
;
positionData
[
80
]
=
C7Za
;
positionData
[
81
]
=
C6Xa
;
positionData
[
82
]
=
C6Ya
;
positionData
[
83
]
=
C6Za
;
positionData
[
84
]
=
C5Xb
;
positionData
[
85
]
=
C5Yb
;
positionData
[
86
]
=
C5Zb
;
positionData
[
87
]
=
C6Xb
;
positionData
[
88
]
=
C6Yb
;
positionData
[
89
]
=
C6Zb
;
positionData
[
90
]
=
C7Xb
;
positionData
[
91
]
=
C7Yb
;
positionData
[
92
]
=
C7Zb
;
positionData
[
93
]
=
C8Xb
;
positionData
[
94
]
=
C8Yb
;
positionData
[
95
]
=
C8Zb
;
positionData
[
96
]
=
C5Xa
;
positionData
[
97
]
=
C5Ya
;
positionData
[
98
]
=
C5Za
;
positionData
[
99
]
=
C6Xa
;
positionData
[
100
]
=
C6Ya
;
positionData
[
101
]
=
C6Za
;
positionData
[
102
]
=
C6Xb
;
positionData
[
103
]
=
C6Yb
;
positionData
[
104
]
=
C6Zb
;
positionData
[
105
]
=
C5Xb
;
positionData
[
106
]
=
C5Yb
;
positionData
[
107
]
=
C5Zb
;
positionData
[
108
]
=
C8Xa
;
positionData
[
109
]
=
C8Ya
;
positionData
[
110
]
=
C8Za
;
positionData
[
111
]
=
C8Xb
;
positionData
[
112
]
=
C8Yb
;
positionData
[
113
]
=
C8Zb
;
positionData
[
114
]
=
C7Xb
;
positionData
[
115
]
=
C7Yb
;
positionData
[
116
]
=
C7Zb
;
positionData
[
117
]
=
C7Xa
;
positionData
[
118
]
=
C7Ya
;
positionData
[
119
]
=
C7Za
;
positionData
[
120
]
=
C5Xa
;
positionData
[
121
]
=
C5Ya
;
positionData
[
122
]
=
C5Za
;
positionData
[
123
]
=
C5Xb
;
positionData
[
124
]
=
C5Yb
;
positionData
[
125
]
=
C5Zb
;
positionData
[
126
]
=
C8Xb
;
positionData
[
127
]
=
C8Yb
;
positionData
[
128
]
=
C8Zb
;
positionData
[
129
]
=
C8Xa
;
positionData
[
130
]
=
C8Ya
;
positionData
[
131
]
=
C8Za
;
positionData
[
132
]
=
C6Xa
;
positionData
[
133
]
=
C6Ya
;
positionData
[
134
]
=
C6Za
;
positionData
[
135
]
=
C7Xa
;
positionData
[
136
]
=
C7Ya
;
positionData
[
137
]
=
C7Za
;
positionData
[
138
]
=
C7Xb
;
positionData
[
139
]
=
C7Yb
;
positionData
[
140
]
=
C7Zb
;
positionData
[
141
]
=
C6Xb
;
positionData
[
142
]
=
C6Yb
;
positionData
[
143
]
=
C6Zb
;
//Compute Cloud Vertice BaryCenter
GetVerticesArrayBarycenter
(
positionData
,
VBO_VerticesN_
,
obj_pos_x
,
obj_pos_y
,
obj_pos_z
);
//COmpute Normals
SetNormalArray
(
positionData
,
normalData
,
0
,
48
,
4
);
if
(
FROG
::
Support_VBO_
){
//Use VBO
glGenBuffersARB
(
1
,
&
VBO_Vertices_
);
// Get A Valid Name
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Vertices_
);
// Bind The Buffer
glBufferDataARB
(
GL_ARRAY_BUFFER_ARB
,
3
*
VBO_VerticesN_
*
sizeof
(
float
),
positionData
,
GL_STATIC_DRAW_ARB
);
glGenBuffersARB
(
1
,
&
VBO_Normals_
);
// Get A Valid Name
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Normals_
);
// Bind The Buffer
glBufferDataARB
(
GL_ARRAY_BUFFER_ARB
,
3
*
VBO_VerticesN_
*
sizeof
(
float
),
normalData
,
GL_STATIC_DRAW_ARB
);
delete
[]
normalData
;
delete
[]
positionData
;
}
}
if
(
!
FROG
::
Support_VBO_
){
//VBO not Available --> Use DisplayList
DisplayList_
=
glGenListsOptimized
(
1
);
glNewList
(
DisplayList_
,
GL_COMPILE_AND_EXECUTE
);
}
glEnableClientState
(
GL_VERTEX_ARRAY
);
glEnableClientState
(
GL_NORMAL_ARRAY
);
if
(
FROG
::
Support_VBO_
){
//Use VBO
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Normals_
);
glNormalPointer
(
GL_FLOAT
,
0
,
(
char
*
)
NULL
);
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Vertices_
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
(
char
*
)
NULL
);
}
else
{
//VBO not Available --> Use DisplayList
glNormalPointer
(
GL_FLOAT
,
0
,
normalData
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
positionData
);
}
glDrawArrays
(
GL_QUADS
,
0
,
24
);
glPopAttrib
();
glDrawArrays
(
GL_QUADS
,
24
,
24
);
glDisableClientState
(
GL_NORMAL_ARRAY
);
glDisableClientState
(
GL_VERTEX_ARRAY
);
if
(
!
FROG
::
Support_VBO_
){
glEndList
();
delete
[]
normalData
;
delete
[]
positionData
;
}
}
virtual
void
display
(
bool
UseDisplayList
=
true
,
float
*
color
=
NULL
){
// first Init Colors & Style!
if
(
!
style_
)
init
();
if
(
Eem_
+
Ehad_
<
style_
->
EMin_
){
return
;}
//Decide if this objects has to be render now or later
if
(
Components
.
size
()
==
0
||
style_
->
DisplayMode_
>=
4
){
//Display The CaloTowers as a Tower
if
(
!
NeedPostRendering
()){
glLoadName
(
nameId_
);
if
(
color
){
glColor4f
(
color
[
0
]
+
0.4f
,
color
[
1
]
-
0.4f
,
color
[
2
]
-
0.4f
,
color
[
3
]);
}
else
{
glColor4fv
(
Em_Color_
);}
glPushAttrib
(
GL_CURRENT_BIT
);
//A glPushAttrib is call inside Object_SmartDisplay! (THIS IS SOMETHING UNUSUAL!)
if
(
color
){
glColor4fv
(
color
);}
else
{
glColor4fv
(
style_
->
color_
);}
Object_SmartDisplay
();
}
}
else
{
//Display the CaloTowers as a set of Cristals Hits
for
(
unsigned
int
i
=
0
;
i
<
Components
.
size
();
i
++
){
if
(
color
){
Components
[
i
]
->
display
(
false
,
color
);}
else
{
Components
[
i
]
->
display
(
false
,
style_
->
color_
);}
}
}
if
(
FROG
::
Views_Current_ShowDet_
&&
style_
->
ShowDet_
&&
det
){
glPushAttrib
(
GL_ALL_ATTRIB_BITS
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINE
);
glDisable
(
GL_CULL_FACE
);
det
->
display
();
glPopAttrib
();
}
}
#endif
virtual
void
init
(){
if
(
style_
)
return
;
init_standard
();
nameId_
=
((
FROG_Element_Event
*
)
FROG
::
Event_
)
->
name_map
.
size
();
((
FROG_Element_Event
*
)
FROG
::
Event_
)
->
name_map
.
push_back
(
this
);
Em_Color_
[
0
]
=
style_
->
color_
[
0
]
+
0.2f
;
Em_Color_
[
1
]
=
style_
->
color_
[
1
]
-
0.2f
;
Em_Color_
[
2
]
=
style_
->
color_
[
2
]
-
0.2f
;
Em_Color_
[
3
]
=
style_
->
color_
[
3
];
det
=
dynamic_cast
<
FROG_Element_Geom_CaloMod
*>
(((
FROG_Geometry
*
)
FROG
::
Geom_
)
->
FindByDetId
(
detId_
));
FROG_Element_Base_With_DetId
*
Coll
=
dynamic_cast
<
FROG_Element_Base_With_DetId
*>
(((
FROG_Element_Event
*
)
FROG
::
Event_
)
->
FindByDetId
(
Components_CollEvtId_
));
if
(
Coll
){
for
(
unsigned
int
i
=
0
;
i
<
Components_Vector_
.
size
();
i
++
){
FROG_Element_Base
*
tmp
=
Coll
->
FindByDetId_FromMap
(
Components_Vector_
[
i
]);
if
(
tmp
)
Components
.
push_back
(
tmp
);
}
}
}
};
#endif
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sat, Dec 21, 4:16 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4015402
Default Alt Text
FROG_Element_Event_CaloTower.h (12 KB)
Attached To
rFROGSVN frogsvn
Event Timeline
Log In to Comment