11 #include "TEveScalableStraightLineSet.h" 12 #include "TEveStraightLineSet.h" 13 #include "TEveTrans.h" 14 #include "TEveGeoNode.h" 21 std::pair<double,double>
getPhiRange(
const std::vector<double>& phis,
double phi )
26 for( std::vector<double>::const_iterator
i = phis.begin();
27 i != phis.end(); ++
i )
31 if( aphi - phi >
M_PI ) aphi -= 2*
M_PI;
32 if( phi - aphi >
M_PI ) aphi += 2*
M_PI;
33 if( aphi > max ) max = aphi;
34 if( aphi < min ) min = aphi;
37 if( min > max )
return std::pair<double,double>( 0, 0 );
39 return std::pair<double,double>(
min,
max );
46 TEveGeoShape* egs =
new TEveGeoShape( name );
47 TColor*
c = gROOT->GetColor( color );
48 Float_t rgba[4] = { 1, 0, 0, 1 };
51 rgba[0] = c->GetRed();
52 rgba[1] = c->GetGreen();
53 rgba[2] = c->GetBlue();
55 egs->SetMainColorRGB( rgba[0], rgba[1], rgba[2] );
56 egs->SetShape( shape );
61 double r_ecal,
double z_ecal,
62 double theta_min,
double theta_max,
65 TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
66 double z1 = r_ecal /
tan( theta_min );
67 if( z1 > z_ecal ) z1 = z_ecal;
68 if( z1 < -z_ecal ) z1 = -z_ecal;
69 double z2 = r_ecal /
tan( theta_max );
70 if( z2 > z_ecal ) z2 = z_ecal;
71 if( z2 < -z_ecal ) z2 = -z_ecal;
72 double r1 = z_ecal * fabs(
tan( theta_min ));
73 if( r1 > r_ecal ) r1 = r_ecal;
74 if( phi < 0 ) r1 = -
r1;
75 double r2 = z_ecal * fabs(
tan( theta_max ));
76 if( r2 > r_ecal ) r2 = r_ecal;
77 if( phi < 0 ) r2 = -
r2;
79 if( fabs(r2 - r1) > 1 )
81 TGeoBBox *sc_box =
new TGeoBBox( 0., fabs( r2 - r1 ) / 2, 1 );
82 TEveGeoShape *element =
new TEveGeoShape(
"r-segment");
83 element->SetShape(sc_box);
84 TEveTrans &
t = element->RefMainTrans();
87 t(3,4) = fabs(z2)>fabs(z1) ? z2 : z1;
90 if( fabs(z2 - z1) > 1 )
92 TGeoBBox *sc_box =
new TGeoBBox( 0., 1, ( z2 - z1 ) / 2 );
93 TEveGeoShape *element =
new TEveGeoShape(
"z-segment");
94 element->SetShape( sc_box );
95 TEveTrans &
t = element->RefMainTrans();
97 t(2,4) = fabs(r2)>fabs(r1) ? r2 :
r1;
107 size_t pos = text.find(
'\n' );
108 if( pos != std::string::npos ) text = text.substr( 0, pos );
117 struct tm *
xx = localtime( &
t );
119 size_t pos = text.find(
'\n');
120 if( pos != std::string::npos ) text = text.substr( 0, pos );
150 TEveBox* eveBox =
new TEveBox(
"Box" );
151 eveBox->SetDrawFrame(
false );
152 eveBox->SetPickable(
true );
153 eveBox->SetVertices( &corners[0] );
160 TEveStraightLineSet* container =
new TEveStraightLineSet;
162 for(
unsigned int iphi = 0; iphi < nLineSegments; ++iphi )
164 container->AddLine( eta + radius *
cos( 2 *
M_PI / nLineSegments * iphi ),
165 phi + radius *
sin( 2 *
M_PI / nLineSegments * iphi ),
167 eta + radius *
cos( 2 *
M_PI / nLineSegments * ( iphi + 1 )),
168 phi + radius *
sin( 2 *
M_PI / nLineSegments * ( iphi + 1 )),
176 TEveScalableStraightLineSet*
marker =
new TEveScalableStraightLineSet;
177 marker->SetLineWidth( 1 );
178 marker->SetLineStyle( 2 );
179 marker->AddLine( 0, 0, 0, size *
cos( phi ), size *
sin( phi ), 0 );
180 marker->AddLine( size * 0.9 *
cos( phi + 0.03 ), size * 0.9 *
sin( phi + 0.03 ), 0, size *
cos( phi ), size *
sin( phi ), 0 );
181 marker->AddLine( size * 0.9 *
cos( phi - 0.03 ), size * 0.9 *
sin( phi - 0.03 ), 0, size *
cos( phi ), size *
sin( phi ), 0 );
188 if( theta < pb->context().caloTransAngle() ||
M_PI - theta < pb->context().caloTransAngle())
193 TEveStraightLineSet*
marker =
new TEveStraightLineSet;
194 marker->SetLineWidth( 2 );
195 marker->SetLineStyle( 2 );
196 marker->AddLine( r *
cos( phi ) *
sin( theta ), r *
sin( phi ) *
sin( theta ), r *
cos( theta ),
197 ( r + size ) *
cos( phi ) *
sin( theta ), ( r + size ) *
sin( phi ) *
sin( theta ), ( r + size ) *
cos( theta ));
203 TEveStraightLineSet* mainLine =
new TEveStraightLineSet;
204 mainLine->AddLine( -5.191, phi, 0.01, 5.191, phi, 0.01 );
207 phi = phi > 0 ? phi -
M_PI : phi +
M_PI;
208 TEveStraightLineSet* secondLine =
new TEveStraightLineSet;
209 secondLine->SetLineStyle( 7 );
210 secondLine->AddLine( -5.191, phi, 0.01, 5.191, phi, 0.01 );
217 std::vector<float> centre( 3, 0 );
219 for(
unsigned int i = 0;
i < 24;
i += 3 )
221 centre[0] += corners[
i];
222 centre[1] += corners[
i + 1];
223 centre[2] += corners[
i + 2];
226 for(
unsigned int i = 0;
i < 3; ++
i )
227 centre[
i] *= 1.0
f / 8.0
f;
230 for(
unsigned int i = 0;
i < 24;
i += 3 )
232 scaledCorners[
i] = centre[0] + ( corners[
i] - centre[0] ) * scale;
233 scaledCorners[
i + 1] = centre[1] + ( corners[
i + 1] - centre[1] ) * scale;
234 scaledCorners[
i + 2] = centre[2] + ( corners[
i + 2] - centre[2] ) * scale;
243 std::vector<float> scaledCorners( 24 );
245 addBox( scaledCorners, comp, pb );
251 std::vector<float> centre( 3, 0 );
253 for(
unsigned int i = 0;
i < 24;
i += 3 )
255 centre[0] += corners[
i];
256 centre[1] += corners[
i + 1];
257 centre[2] += corners[
i + 2];
260 for(
unsigned int i = 0;
i < 3; ++
i )
261 centre[
i] *= 1.0
f / 8.0
f;
263 TEveVector
c( centre[0], centre[1], centre[2] );
264 float scale = energy / maxEnergy *
sin( c.Theta());
267 for(
unsigned int i = 0;
i < 24;
i += 3 )
269 scaledCorners[
i] = centre[0] + ( corners[
i] - centre[0] ) * scale;
270 scaledCorners[
i + 1] = centre[1] + ( corners[
i + 1] - centre[1] ) * scale;
271 scaledCorners[
i + 2] = centre[2] + ( corners[
i + 2] - centre[2] ) * scale;
280 std::vector<float> scaledCorners( 24 );
282 addBox( scaledCorners, comp, pb );
288 for(
int i = 0;
i < 24; ++
i )
289 scaledCorners[
i] = corners[
i];
295 for(
unsigned int i = 0;
i < 12;
i += 3 )
297 TEveVector
diff( corners[
i] - corners[
i + 12], corners[
i + 1] - corners[
i + 13], corners[
i + 2] - corners[
i + 14] );
301 scaledCorners[
i] = corners[
i] + diff.fX;
302 scaledCorners[
i + 1] = corners[
i + 1] + diff.fY;
303 scaledCorners[
i + 2] = corners[
i + 2] + diff.fZ;
308 for(
unsigned int i = 0;
i < 12;
i += 3 )
310 TEveVector
diff( corners[
i + 12] - corners[
i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2] );
314 scaledCorners[
i] = corners[i + 12];
315 scaledCorners[i + 1] = corners[i + 13];
316 scaledCorners[i + 2] = corners[i + 14];
318 scaledCorners[i + 12] = corners[i + 12] + diff.fX;
319 scaledCorners[i + 13] = corners[i + 13] + diff.fY;
320 scaledCorners[i + 14] = corners[i + 14] + diff.fZ;
327 std::vector<float> scaledCorners( 24 );
329 addBox( scaledCorners, comp, pb );
336 for(
int i = 0;
i < 24; ++
i )
337 scaledCorners[
i] = corners[
i];
343 for(
unsigned int i = 0;
i < 12;
i += 3 )
345 TEveVector
diff( corners[
i] - corners[
i + 12], corners[
i + 1] - corners[
i + 13], corners[
i + 2] - corners[
i + 14] );
347 diff *= ( scale *
sin( diff.Theta()));
349 scaledCorners[
i] = corners[
i] + diff.fX;
350 scaledCorners[
i + 1] = corners[
i + 1] + diff.fY;
351 scaledCorners[
i + 2] = corners[
i + 2] + diff.fZ;
356 for(
unsigned int i = 0;
i < 12;
i += 3 )
358 TEveVector
diff( corners[
i + 12] - corners[
i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2] );
360 diff *= ( scale *
sin( diff.Theta()));
362 scaledCorners[
i] = corners[i + 12];
363 scaledCorners[i + 1] = corners[i + 13];
364 scaledCorners[i + 2] = corners[i + 14];
366 scaledCorners[i + 12] = corners[i + 12] + diff.fX;
367 scaledCorners[i + 13] = corners[i + 13] + diff.fY;
368 scaledCorners[i + 14] = corners[i + 14] + diff.fZ;
376 std::vector<float> scaledCorners( 24 );
378 addBox( scaledCorners, comp, pb );
const fireworks::Context & context() const
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
edm::Timestamp time() const
void drawEtScaledBox3D(const float *corners, float energy, float maxEnergy, TEveElement *, FWProxyBuilderBase *, bool reflect=false)