11 #include "TEveScalableStraightLineSet.h"
12 #include "TEveStraightLineSet.h"
13 #include "TEveTrans.h"
14 #include "TEveGeoNode.h"
15 #include "TEveGeoShape.h"
21 std::pair<double, double>
getPhiRange(
const std::vector<double>& phis,
double phi) {
25 for (std::vector<double>::const_iterator
i = phis.begin();
i != phis.end(); ++
i) {
28 if (aphi - phi >
M_PI)
30 if (phi - aphi >
M_PI)
39 return std::pair<double, double>(0, 0);
41 return std::pair<double, double>(
min,
max);
44 TEveGeoShape*
getShape(
const char*
name, TGeoBBox* shape, Color_t color) {
45 TEveGeoShape* egs =
new TEveGeoShape(name);
46 TColor*
c = gROOT->GetColor(color);
47 Float_t rgba[4] = {1, 0, 0, 1};
49 rgba[0] = c->GetRed();
50 rgba[1] = c->GetGreen();
51 rgba[2] = c->GetBlue();
53 egs->SetMainColorRGB(rgba[0], rgba[1], rgba[2]);
59 TEveElement* container,
65 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
66 double z1 = r_ecal /
tan(theta_min);
71 double z2 = r_ecal /
tan(theta_max);
76 double r1 = z_ecal * fabs(
tan(theta_min));
81 double r2 = z_ecal * fabs(
tan(theta_max));
87 if (fabs(r2 - r1) > 1) {
88 TGeoBBox* sc_box =
new TGeoBBox(0., fabs(r2 - r1) / 2, 1);
89 TEveGeoShape* element =
new TEveGeoShape(
"r-segment");
90 element->SetShape(sc_box);
91 TEveTrans&
t = element->RefMainTrans();
93 t(2, 4) = (r2 +
r1) / 2;
94 t(3, 4) = fabs(z2) > fabs(z1) ? z2 : z1;
97 if (fabs(z2 - z1) > 1) {
98 TGeoBBox* sc_box =
new TGeoBBox(0., 1, (z2 - z1) / 2);
99 TEveGeoShape* element =
new TEveGeoShape(
"z-segment");
100 element->SetShape(sc_box);
101 TEveTrans&
t = element->RefMainTrans();
103 t(2, 4) = fabs(r2) > fabs(r1) ? r2 :
r1;
104 t(3, 4) = (z2 + z1) / 2;
112 size_t pos = text.find(
'\n');
113 if (pos != std::string::npos)
114 text = text.substr(0, pos);
121 struct tm* xx = localtime(&
t);
123 size_t pos = text.find(
'\n');
124 if (pos != std::string::npos)
125 text = text.substr(0, pos);
153 TEveBox* eveBox =
new TEveBox(
"Box");
154 eveBox->SetDrawFrame(
false);
155 eveBox->SetPickable(
true);
156 eveBox->SetVertices(&corners[0]);
164 const unsigned int nLineSegments,
167 TEveStraightLineSet* container =
new TEveStraightLineSet;
169 for (
unsigned int iphi = 0; iphi < nLineSegments; ++iphi) {
170 container->AddLine(eta + radius *
cos(2 *
M_PI / nLineSegments * iphi),
171 phi + radius *
sin(2 *
M_PI / nLineSegments * iphi),
173 eta + radius *
cos(2 *
M_PI / nLineSegments * (iphi + 1)),
174 phi + radius *
sin(2 *
M_PI / nLineSegments * (iphi + 1)),
181 TEveScalableStraightLineSet* marker =
new TEveScalableStraightLineSet;
182 marker->SetLineWidth(1);
183 marker->SetLineStyle(2);
184 marker->AddLine(0, 0, 0, size *
cos(phi), size *
sin(phi), 0);
185 marker->AddLine(size * 0.9 *
cos(phi + 0.03), size * 0.9 *
sin(phi + 0.03), 0, size *
cos(phi), size *
sin(phi), 0);
186 marker->AddLine(size * 0.9 *
cos(phi - 0.03), size * 0.9 *
sin(phi - 0.03), 0, size *
cos(phi), size *
sin(phi), 0);
192 if (theta < pb->
context().caloTransAngle() ||
M_PI - theta < pb->
context().caloTransAngle())
197 TEveStraightLineSet* marker =
new TEveStraightLineSet;
198 marker->SetLineWidth(2);
199 marker->SetLineStyle(2);
200 marker->AddLine(r *
cos(phi) *
sin(theta),
201 r *
sin(phi) *
sin(theta),
203 (r + size) *
cos(phi) *
sin(theta),
204 (r + size) *
sin(phi) *
sin(theta),
205 (r + size) *
cos(theta));
210 TEveStraightLineSet* mainLine =
new TEveStraightLineSet;
211 mainLine->AddLine(-5.191, phi, 0.01, 5.191, phi, 0.01);
214 phi = phi > 0 ? phi -
M_PI : phi +
M_PI;
215 TEveStraightLineSet* secondLine =
new TEveStraightLineSet;
216 secondLine->SetLineStyle(7);
217 secondLine->AddLine(-5.191, phi, 0.01, 5.191, phi, 0.01);
223 std::vector<float> centre(3, 0);
225 for (
unsigned int i = 0;
i < 24;
i += 3) {
226 centre[0] += corners[
i];
227 centre[1] += corners[
i + 1];
228 centre[2] += corners[
i + 2];
231 for (
unsigned int i = 0;
i < 3; ++
i)
232 centre[
i] *= 1.0
f / 8.0
f;
235 for (
unsigned int i = 0;
i < 24;
i += 3) {
236 scaledCorners[
i] = centre[0] + (corners[
i] - centre[0]) * scale;
237 scaledCorners[
i + 1] = centre[1] + (corners[
i + 1] - centre[1]) * scale;
238 scaledCorners[
i + 2] = centre[2] + (corners[
i + 2] - centre[2]) * scale;
246 std::vector<float> scaledCorners(24);
248 addBox(scaledCorners, comp, pb);
253 const float* corners,
float energy,
float maxEnergy, std::vector<float>& scaledCorners,
bool invert) {
254 std::vector<float> centre(3, 0);
256 for (
unsigned int i = 0;
i < 24;
i += 3) {
257 centre[0] += corners[
i];
258 centre[1] += corners[
i + 1];
259 centre[2] += corners[
i + 2];
262 for (
unsigned int i = 0;
i < 3; ++
i)
263 centre[
i] *= 1.0
f / 8.0
f;
265 TEveVector
c(centre[0], centre[1], centre[2]);
266 float scale = energy / maxEnergy *
sin(c.Theta());
269 for (
unsigned int i = 0;
i < 24;
i += 3) {
270 scaledCorners[
i] = centre[0] + (corners[
i] - centre[0]) * scale;
271 scaledCorners[
i + 1] = centre[1] + (corners[
i + 1] - centre[1]) * scale;
272 scaledCorners[
i + 2] = centre[2] + (corners[
i + 2] - centre[2]) * scale;
281 std::vector<float> scaledCorners(24);
283 addBox(scaledCorners, comp, pb);
288 for (
int i = 0;
i < 24; ++
i)
289 scaledCorners[
i] = corners[
i];
294 for (
unsigned int i = 0;
i < 12;
i += 3) {
296 corners[
i] - corners[
i + 12], corners[
i + 1] - corners[
i + 13], corners[
i + 2] - corners[
i + 14]);
300 scaledCorners[
i] = corners[
i] + diff.fX;
301 scaledCorners[
i + 1] = corners[
i + 1] + diff.fY;
302 scaledCorners[
i + 2] = corners[
i + 2] + diff.fZ;
305 for (
unsigned int i = 0;
i < 12;
i += 3) {
307 corners[
i + 12] - corners[
i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2]);
311 scaledCorners[
i] = corners[i + 12];
312 scaledCorners[i + 1] = corners[i + 13];
313 scaledCorners[i + 2] = corners[i + 14];
315 scaledCorners[i + 12] = corners[i + 12] + diff.fX;
316 scaledCorners[i + 13] = corners[i + 13] + diff.fY;
317 scaledCorners[i + 14] = corners[i + 14] + diff.fZ;
323 std::vector<float> scaledCorners(24);
325 addBox(scaledCorners, comp, pb);
331 for (
int i = 0;
i < 24; ++
i)
332 scaledCorners[
i] = corners[
i];
337 for (
unsigned int i = 0;
i < 12;
i += 3) {
339 corners[
i] - corners[
i + 12], corners[
i + 1] - corners[
i + 13], corners[
i + 2] - corners[
i + 14]);
341 diff *= (scale *
sin(diff.Theta()));
343 scaledCorners[
i] = corners[
i] + diff.fX;
344 scaledCorners[
i + 1] = corners[
i + 1] + diff.fY;
345 scaledCorners[
i + 2] = corners[
i + 2] + diff.fZ;
348 for (
unsigned int i = 0;
i < 12;
i += 3) {
350 corners[
i + 12] - corners[
i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2]);
352 diff *= (scale *
sin(diff.Theta()));
354 scaledCorners[
i] = corners[i + 12];
355 scaledCorners[i + 1] = corners[i + 13];
356 scaledCorners[i + 2] = corners[i + 14];
358 scaledCorners[i + 12] = corners[i + 12] + diff.fX;
359 scaledCorners[i + 13] = corners[i + 13] + diff.fY;
360 scaledCorners[i + 14] = corners[i + 14] + diff.fZ;
366 std::vector<float> scaledCorners(24);
368 addBox(scaledCorners, comp, pb);
const fireworks::Context & context() const
const edm::EventSetup & c
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
void addDoubleLines(double phi, TEveElement *comp, FWProxyBuilderBase *pb)
void etTower3DCorners(const float *corners, float scale, std::vector< float > &, bool reflect=false)
void drawEnergyScaledBox3D(const float *corners, float scale, TEveElement *, FWProxyBuilderBase *, bool invert=false)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
static float caloZ2(bool offset=true)
void addDashedLine(double phi, double theta, double size, TEveElement *comp, FWProxyBuilderBase *pb)
void drawEtTower3D(const float *corners, float scale, TEveElement *, FWProxyBuilderBase *, bool reflect=false)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void invertBox(std::vector< float > &corners)
void addDashedArrow(double phi, double size, TEveElement *comp, FWProxyBuilderBase *pb)
Cos< T >::type cos(const T &t)
static float caloR1(bool offset=true)
Tan< T >::type tan(const T &t)
void addCircle(double eta, double phi, double radius, const unsigned int nLineSegments, TEveElement *comp, FWProxyBuilderBase *pb)
std::string getTimeGMT(const edm::EventBase &event)
void energyTower3DCorners(const float *corners, float scale, std::vector< float > &, bool reflect=false)
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
void energyScaledBox3DCorners(const float *corners, float scale, std::vector< float > &, bool invert=false)
void addBox(const std::vector< float > &corners, TEveElement *, FWProxyBuilderBase *)
std::string getLocalTime(const edm::EventBase &event)
void etScaledBox3DCorners(const float *corners, float energy, float maxEnergy, std::vector< float > &scaledCorners, bool reflect=false)
void drawEnergyTower3D(const float *corners, float scale, TEveElement *, FWProxyBuilderBase *, bool reflect=false)
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
TimeValue_t value() const
tuple size
Write out results.
edm::Timestamp time() const
void drawEtScaledBox3D(const float *corners, float energy, float maxEnergy, TEveElement *, FWProxyBuilderBase *, bool reflect=false)