CMS 3D CMS Logo

IgSoRectHist Class Reference

#include <Iguana/Inventor/interface/IgSoRectHist.h>

Inheritance diagram for IgSoRectHist:

IgSoShapeKit

List of all members.

Public Types

enum  n_barrelEndcap { BARREL, ENDCAP }
enum  n_leftRight { LEFT, RIGHT }
enum  n_lowerUpper { LOWER, UPPER }

Public Member Functions

 IgSoRectHist ()
void setLineColor (const float &red, const float &green, const float &blue)

Static Public Member Functions

static void initClass (void)

Public Attributes

SoMFFloat energies
SoSFFloat layer
SoSFBool logScale
SoSFFloat maxRr
SoSFFloat maxRz
SoSFFloat nr
SoSFFloat nz
SoSFFloat offsetR
SoSFFloat offsetZ
SoSFFloat Rr
SoSFFloat Rz
SoSFFloat scaleFactor
SoSFBool showAnnotations

Protected Member Functions

virtual void refresh (void)

Private Member Functions

void checkNumberOfBins ()
SbVec3f CMStoIgBarrel (const float &deltaTheta, const float &thetaRight, const float &thetaIndex, const float &energy, const n_lowerUpper upperBarrel)
SbVec3f CMStoIgEndcap (const float &deltaTheta, const float &thetaRight, const float &thetaIndex, const float &energy, const n_leftRight leftRight)
std::vector< intgenerateFaceIndices (const std::vector< float > &localEnergies, const int nr, const int nz)
SbVec3f generateLabelCoords (const int binNo, const float &deltaThetaEndcap, const float &deltaThetaBarrel, const float &thetaRightEndcap, const float &thetaRightBarrel, const float &energy)
std::vector< SbVec3f > generateVertexData (std::vector< float > &localEnergies, const int nOfBins, const float &deltaThetaEndcap, const float &deltaThetaBarrel, const float &thetaRightEndcap, const float &thetaRightBarrel, const float &thetaOffset, const float &scale)
std::vector< float > getNegativeEnergies (std::vector< float > &localEnergies)
 SO_KIT_CATALOG_ENTRY_HEADER (soAnnotation)
 SO_KIT_CATALOG_ENTRY_HEADER (negativeFaceSet)
 SO_KIT_CATALOG_ENTRY_HEADER (negativeMaterial)
 SO_KIT_CATALOG_ENTRY_HEADER (negativeShapeHints)
 SO_KIT_CATALOG_ENTRY_HEADER (faceSet)
 SO_KIT_CATALOG_ENTRY_HEADER (shapeHints)
 SO_KIT_HEADER (IgSoRectHist)

Private Attributes

float lineColor_ [3]


Detailed Description

Definition at line 28 of file IgSoRectHist.h.


Member Enumeration Documentation

enum IgSoRectHist::n_barrelEndcap

Enumerator:
BARREL 
ENDCAP 

Definition at line 64 of file IgSoRectHist.h.

00064 {BARREL, ENDCAP};

enum IgSoRectHist::n_leftRight

Enumerator:
LEFT 
RIGHT 

Definition at line 63 of file IgSoRectHist.h.

00063 {LEFT, RIGHT};

enum IgSoRectHist::n_lowerUpper

Enumerator:
LOWER 
UPPER 

Definition at line 62 of file IgSoRectHist.h.

00062 {LOWER, UPPER};


Constructor & Destructor Documentation

IgSoRectHist::IgSoRectHist (  ) 

Definition at line 516 of file IgSoRectHist.cc.

References energies, FALSE, layer, lineColor_, logScale, maxRr, maxRz, nr, nz, offsetR, offsetZ, Rr, Rz, scaleFactor, IgSoShapeKit::setUpConnections(), showAnnotations, and TRUE.

00517 {
00518 
00519     SO_KIT_CONSTRUCTOR (IgSoRectHist);
00520         
00521     // parameters of the constructor
00522     SO_KIT_ADD_FIELD (Rz,               (10.));
00523     SO_KIT_ADD_FIELD (Rr,               (5.));
00524     SO_KIT_ADD_FIELD (offsetR,  (0.));
00525     SO_KIT_ADD_FIELD (offsetZ,  (0.));
00526     SO_KIT_ADD_FIELD (nr,               (10.));
00527     SO_KIT_ADD_FIELD (nz,               (10.));
00528     SO_KIT_ADD_FIELD (energies, (0.0));
00529     SO_KIT_ADD_FIELD (layer,    (0.0)); 
00530         
00531     SO_KIT_ADD_FIELD (logScale, (FALSE));
00532     SO_KIT_ADD_FIELD (scaleFactor,      (1));
00533     SO_KIT_ADD_FIELD (maxRr,    (0.0));
00534     SO_KIT_ADD_FIELD (maxRz,    (0.0));
00535         
00536     SO_KIT_ADD_FIELD (showAnnotations,  (FALSE));
00537         
00538     SO_KIT_ADD_CATALOG_ENTRY (shapeHints, SoShapeHints, FALSE, separator,\x0, TRUE);
00539     SO_KIT_ADD_CATALOG_ENTRY (faceSet, SoIndexedFaceSet, FALSE, separator,\x0, TRUE);
00540 
00541     //NEGATIVE ENERGIES 
00542     SO_KIT_ADD_CATALOG_ENTRY (negativeShapeHints, SoShapeHints, FALSE, separator,\x0, TRUE);
00543     SO_KIT_ADD_CATALOG_ENTRY (negativeMaterial, SoMaterial, FALSE, separator,\x0, TRUE);
00544     SO_KIT_ADD_CATALOG_ENTRY (negativeFaceSet, SoIndexedFaceSet, FALSE, separator,\x0, TRUE);
00545 
00546     //LABELS
00547     SO_KIT_ADD_CATALOG_ENTRY (soAnnotation, SoAnnotation, FALSE, separator,\x0,TRUE);
00548         
00549     SO_KIT_INIT_INSTANCE ();
00550     setUpConnections (true, true);
00551         
00552     //default colors for the line: black
00553     lineColor_[0]=0.0;
00554     lineColor_[1]=0.0;
00555     lineColor_[2]=0.0;
00556 }


Member Function Documentation

void IgSoRectHist::checkNumberOfBins (  )  [private]

SbVec3f IgSoRectHist::CMStoIgBarrel ( const float &  deltaTheta,
const float &  thetaRight,
const float &  thetaIndex,
const float &  energy,
const n_lowerUpper  upperBarrel 
) [private]

Definition at line 110 of file IgSoRectHist.cc.

References layer, offsetR, Rr, and funct::tan().

Referenced by generateLabelCoords(), and generateVertexData().

00116 {
00117     SbVec3f OIcoords;
00118     OIcoords[1]= upperBarrel ? 
00119                  Rr.getValue() + offsetR.getValue() + energy : 
00120                  -(Rr.getValue() + offsetR.getValue() + energy);
00121     //thetaIndex runs from zero to the number of bins
00122     //when drawing the 2 lower vertexes of the face, thetaIndex corresponds to the number of the bin
00123     //when drawing the upper vertexes, thetaIndex is binNo + 1 
00124     OIcoords[2] = OIcoords[1]* tan (M_PI/2. - (thetaRight + deltaTheta * (float)thetaIndex));
00125     OIcoords[0] = layer.getValue();
00126         
00127     return OIcoords;
00128 }

SbVec3f IgSoRectHist::CMStoIgEndcap ( const float &  deltaTheta,
const float &  thetaRight,
const float &  thetaIndex,
const float &  energy,
const n_leftRight  leftRight 
) [private]

Definition at line 132 of file IgSoRectHist.cc.

References layer, offsetZ, Rz, and funct::tan().

Referenced by generateLabelCoords(), and generateVertexData().

00137 {
00138     SbVec3f OIcoords;
00139         
00140     OIcoords[2] = leftRight ? 
00141                   Rz.getValue() + offsetZ.getValue() + energy : 
00142                   -(Rz.getValue() + offsetZ.getValue() + energy);
00143     OIcoords[1] = leftRight ? 
00144                   OIcoords[2] * tan (deltaTheta * (float)thetaIndex) :
00145                   OIcoords[2] * tan (M_PI - (thetaRight - deltaTheta * (float)thetaIndex) );
00146     OIcoords[0] = layer.getValue();
00147 
00148     return OIcoords;
00149 }

std::vector< int > IgSoRectHist::generateFaceIndices ( const std::vector< float > &  localEnergies,
const int  nr,
const int  nz 
) [private]

Definition at line 460 of file IgSoRectHist.cc.

References a, b, c, d, and i.

Referenced by refresh().

00463 {
00464 
00465     //additive parameters for the algorithm of assigning indexes
00466     int a=0;
00467     int b=1;
00468     int c=2;
00469     int d=3;
00470 
00471     std::vector<int> faceIndices;
00472         
00473     //setting first one 
00474     if (localEnergies[0]!=0) {
00475         
00476         faceIndices.push_back(0);
00477         faceIndices.push_back(1);
00478         faceIndices.push_back(2);
00479         faceIndices.push_back(3);
00480         faceIndices.push_back(0);
00481         faceIndices.push_back(SO_END_FACE_INDEX);
00482 
00483                 
00484     }
00485                 
00486     for (int i=1; i < (2*nr + 2*nz); i++) {
00487                 
00488         if (i==nr/2. || i==(nr/2.+nz) || i==(nr*3./2.+nz) || i==(nr*3./2.+2*nz) ) {
00489             a++; b++; c++; d++;
00490         }
00491                 
00492         if (localEnergies[i]!=0) {
00493                 
00494             faceIndices.push_back(i*3+a);
00495             faceIndices.push_back(i*3+b);
00496             faceIndices.push_back(i*3+c);
00497             faceIndices.push_back(i*3+d);
00498             faceIndices.push_back(i*3+a);
00499             faceIndices.push_back(SO_END_FACE_INDEX);
00500 
00501         }//end of if (energy was not zero)
00502 
00503     }//end loop on bins
00504 
00505     return faceIndices;
00506 }

SbVec3f IgSoRectHist::generateLabelCoords ( const int  binNo,
const float &  deltaThetaEndcap,
const float &  deltaThetaBarrel,
const float &  thetaRightEndcap,
const float &  thetaRightBarrel,
const float &  energy 
) [private]

Definition at line 420 of file IgSoRectHist.cc.

References CMStoIgBarrel(), CMStoIgEndcap(), findBinPlacement(), int, LEFT, LEFTENDCAP, LOWER, LOWERBARREL, LOWERRIGHTENDCAP, nr, nz, RIGHT, UPPER, UPPERBARREL, and UPPERRIGHTENDCAP.

Referenced by refresh().

00426 {
00427  
00428     int _nr=(int)nr.getValue();
00429     int _nz=(int)nz.getValue();
00430          
00431     n_placement placement = findBinPlacement(_nr, _nz, binNo);
00432     SbVec3f coords;
00433         
00434     if (placement == UPPERRIGHTENDCAP || placement == LOWERRIGHTENDCAP) {
00435         coords = CMStoIgEndcap (deltaThetaEndcap, thetaRightEndcap, binNo + 0.5, energy, RIGHT);
00436     }
00437         
00438     if (placement == UPPERBARREL) {
00439         coords = CMStoIgBarrel (deltaThetaBarrel, thetaRightBarrel, binNo - _nr/2 + 0.5, energy, UPPER);
00440     }
00441         
00442     if (placement == LEFTENDCAP) {
00443         coords = CMStoIgEndcap (deltaThetaEndcap, thetaRightEndcap, binNo - (_nr/2 + _nz) + 0.5, energy, LEFT);
00444     }
00445         
00446     if (placement == LOWERBARREL) {
00447         coords = CMStoIgBarrel (deltaThetaBarrel, thetaRightBarrel, binNo - (_nr * 3./2. + _nz) + 0.5, energy, LOWER);
00448     }
00449 
00450     if (placement == LOWERRIGHTENDCAP) {
00451         coords = CMStoIgEndcap (deltaThetaEndcap, thetaRightEndcap, binNo-(_nr*3./2.+2*_nz)-_nr/2+0.5,   energy, RIGHT);
00452     }
00453         
00454     return coords;
00455 
00456 
00457 }

std::vector< SbVec3f > IgSoRectHist::generateVertexData ( std::vector< float > &  localEnergies,
const int  nOfBins,
const float &  deltaThetaEndcap,
const float &  deltaThetaBarrel,
const float &  thetaRightEndcap,
const float &  thetaRightBarrel,
const float &  thetaOffset,
const float &  scale 
) [private]

Definition at line 267 of file IgSoRectHist.cc.

References CMStoIgBarrel(), CMStoIgEndcap(), funct::cos(), i, int, layer, LEFT, LOWER, nr, nz, offsetR, offsetZ, RIGHT, Rr, Rz, and UPPER.

Referenced by refresh().

00275 {
00276     float currentEnergy=0, projectedEnergy=0;
00277     int _nr=(int)nr.getValue();
00278     int _nz=(int)nz.getValue();
00279     float _Rr=Rr.getValue();
00280     float _Rz=Rz.getValue();
00281     float _offsetRr=offsetR.getValue();
00282     float _offsetRz=offsetZ.getValue();
00283     float _layer=layer.getValue();
00284     SbVec3f vertexBuffer;
00285     std::vector<SbVec3f> vertexData;
00286 
00287     //numbering of points in face (if CCW):
00288     //3---------------------2
00289     //|                     | 
00290     //|                     |  
00291     //0---------------------1
00292     //note: point 3 is shared by the next face
00293         
00294     //----------------ENDCAP RIGHT
00295 
00296     //POINT 0
00297     vertexBuffer.setValue(_layer , 0, _Rz+_offsetRz);
00298     vertexData.push_back(vertexBuffer);
00299         
00300     for (int i=0; i<_nr/2; i++) {
00301 
00302         currentEnergy=localEnergies[i];
00303         projectedEnergy=currentEnergy*cos(i*deltaThetaEndcap+deltaThetaEndcap/2.);
00304                 
00305         //POINT 1
00306         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i, projectedEnergy, RIGHT);
00307         vertexData.push_back(vertexBuffer);
00308                 
00309         //POINT 2
00310         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i+1, projectedEnergy, RIGHT);
00311         vertexData.push_back(vertexBuffer);
00312                 
00313         //POINT 3
00314         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i+1, 0, RIGHT);
00315         vertexData.push_back(vertexBuffer);
00316     }
00317 
00318     //----------------UPPER BARREL
00319         
00320     //POINT 0
00321     vertexBuffer.setValue(_layer , _Rr+_offsetRr, _Rz);
00322     vertexData.push_back(vertexBuffer);
00323         
00324     for (int i=_nr/2; i<_nr/2+_nz; i++) {
00325 
00326         currentEnergy=localEnergies[i];
00327         projectedEnergy=currentEnergy*cos( M_PI/2. - (thetaRightBarrel + (i-(_nr/2))*deltaThetaBarrel + +deltaThetaBarrel/2.));
00328                 
00329         //POINT 1
00330         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i-(_nr/2), projectedEnergy, UPPER);
00331         vertexData.push_back(vertexBuffer);
00332                 
00333         //POINT 2
00334         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i+1-(_nr/2), projectedEnergy, UPPER);
00335         vertexData.push_back(vertexBuffer);
00336                 
00337         //POINT 3
00338         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i+1-(_nr/2), 0, UPPER);
00339         vertexData.push_back(vertexBuffer);
00340 
00341     }
00342         
00343     //----------------LEFT ENDCAP
00344 
00345     //POINT 0
00346     vertexBuffer.setValue(_layer, _Rr, -(_Rz + _offsetRz));
00347     vertexData.push_back(vertexBuffer);
00348         
00349     for (int i=_nr/2+_nz; i<_nr*3/2+_nz; i++) {
00350 
00351         currentEnergy=localEnergies[i];
00352         projectedEnergy=-currentEnergy*cos(M_PI-thetaRightEndcap+deltaThetaEndcap/2.+(i-(_nr/2+_nz))*deltaThetaEndcap);
00353                 
00354         //POINT 1
00355         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i-(_nr/2+_nz), projectedEnergy, LEFT);
00356         vertexData.push_back(vertexBuffer);
00357                 
00358         //POINT 2
00359         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i-(_nr/2+_nz)+1, projectedEnergy, LEFT);
00360         vertexData.push_back(vertexBuffer);
00361                 
00362         //POINT 3
00363         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i-(_nr/2+_nz)+1, 0, LEFT);
00364         vertexData.push_back(vertexBuffer);
00365     }
00366         
00367     //----------------LOWER BARREL
00368         
00369     //POINT 0
00370     vertexBuffer.setValue(_layer , -(_Rr+_offsetRr), -_Rz);
00371     vertexData.push_back(vertexBuffer);
00372 
00373     for (int i=_nr*3/2+_nz; i<_nr*3/2+2*_nz; i++) {
00374 
00375         currentEnergy=localEnergies[i];
00376         projectedEnergy=currentEnergy * cos(M_PI/2. - (thetaRightBarrel + deltaThetaBarrel * (i-(_nr*3/2+_nz)) + deltaThetaBarrel/2.));
00377                 
00378         //POINT 1
00379         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i-(_nr*3./2.+_nz), projectedEnergy, LOWER);
00380         vertexData.push_back(vertexBuffer);
00381                 
00382         //POINT 2
00383         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i+1-(_nr*3./2.+_nz), projectedEnergy, LOWER);
00384         vertexData.push_back(vertexBuffer);
00385                 
00386         //POINT 3
00387         vertexBuffer=CMStoIgBarrel(deltaThetaBarrel, thetaRightBarrel, i+1-(_nr*3./2.+_nz), 0, LOWER);
00388         vertexData.push_back(vertexBuffer);
00389     }
00390 
00391     //----------------LOWER RIGHT ENDCAP
00392 
00393     //POINT 0
00394     vertexBuffer.setValue(_layer , -_Rr, _Rz+_offsetRz);
00395     vertexData.push_back(vertexBuffer);
00396 
00397     for (int i=_nr*3/2+2*_nz; i<2*_nz+2*_nr; i++) {
00398                 
00399         currentEnergy=localEnergies[i];
00400         projectedEnergy=currentEnergy*cos(-deltaThetaEndcap*(i-(_nr*3/2+2*_nz)-_nr/2)-deltaThetaEndcap/2.);
00401                 
00402         //POINT 1
00403         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap,i-(_nr*3./2.+2*_nz)-_nr/2, projectedEnergy, RIGHT);
00404         vertexData.push_back(vertexBuffer);
00405                 
00406         //POINT 2
00407         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap,i-(_nr*3./2.+2*_nz)-_nr/2+1, projectedEnergy, RIGHT);
00408         vertexData.push_back(vertexBuffer);
00409                 
00410         //POINT 3
00411         vertexBuffer=CMStoIgEndcap(deltaThetaEndcap, thetaRightEndcap, i-(_nr*3./2.+2*_nz)-_nr/2+1, 0, RIGHT);
00412         vertexData.push_back(vertexBuffer);
00413     }
00414 
00415     return vertexData;
00416 }

std::vector< float > IgSoRectHist::getNegativeEnergies ( std::vector< float > &  localEnergies  )  [private]

Definition at line 157 of file IgSoRectHist.cc.

References i, int, nr, nz, offsetR, offsetZ, Rr, and Rz.

Referenced by refresh().

00158 {
00159     float _Rz=Rz.getValue();
00160     float _Rr=Rr.getValue();
00161     int _nr=(int)nr.getValue();
00162     int _nz=(int)nz.getValue();
00163     float _offsetR=offsetR.getValue();
00164     float _offsetZ=offsetZ.getValue();
00165 
00166     std::vector<float> negativeEnergies(localEnergies.size());
00167         
00168     //TODO: clean the code here
00169     for (int i=0; i<_nr/2; i++) 
00170     {
00171         if (localEnergies[i] < 0) 
00172         {               
00173             negativeEnergies[i]=localEnergies[i];
00174                         
00175             //rescale if it has a chance of overlapping the centre
00176             if (fabs(negativeEnergies[i]) > _Rz+_offsetZ) 
00177             {
00178                 negativeEnergies[i]=-(_Rz+_offsetZ);
00179             }
00180                         
00181             //set the local energy vector value to zero
00182             localEnergies[i]=0;
00183         }
00184         else negativeEnergies[i]=0;
00185     }
00186         
00187     for (int i=_nr/2; i<_nr/2+_nz; i++) 
00188     {
00189         if (localEnergies[i] < 0) 
00190         {       
00191             negativeEnergies[i]=localEnergies[i];
00192                         
00193             //rescale if it has a chance of overlapping the centre
00194             if (fabs(negativeEnergies[i]) > _Rr+_offsetR) 
00195             {
00196                 negativeEnergies[i]=-(_Rr+_offsetR);
00197             }
00198                         
00199             //set the local energy vector value to zero
00200             localEnergies[i]=0;
00201         }
00202                 
00203         else negativeEnergies[i]=0;
00204     }
00205         
00206     for (int i=_nr/2+_nz; i<_nr*3/2+_nz; i++) 
00207     {
00208         if (localEnergies[i] < 0) 
00209         {       
00210             negativeEnergies[i]=localEnergies[i];
00211                         
00212             //rescale if it has a chance of overlapping the centre
00213             if (fabs(negativeEnergies[i]) > _Rz+_offsetZ) 
00214             {
00215                 negativeEnergies[i]=-(_Rz+_offsetZ);
00216             }
00217                         
00218             //set the local energy vector value to zero
00219             localEnergies[i]=0;
00220         }
00221                 
00222         else negativeEnergies[i]=0;
00223     }
00224         
00225     for (int i=_nr*3/2+_nz; i<_nr*3/2+2*_nz; i++) 
00226     {
00227         if (localEnergies[i] < 0) 
00228         {       
00229             negativeEnergies[i]=localEnergies[i];
00230                         
00231             //rescale if it has a chance of overlapping the centre
00232             if (fabs(negativeEnergies[i]) > _Rr+_offsetR) 
00233             {
00234                 negativeEnergies[i]=-(_Rr+_offsetR);
00235             }
00236                         
00237             //set the local energy vector value to zero
00238             localEnergies[i]=0;
00239         }
00240                 
00241         else negativeEnergies[i]=0;
00242     }
00243         
00244     for (int i=_nr*3/2+2*_nz; i<2*_nz+2*_nr; i++) 
00245     {
00246         if (localEnergies[i] < 0) 
00247         {               
00248             negativeEnergies[i]=localEnergies[i];
00249                         
00250             //rescale if it has a chance of overlapping the centre
00251             if (fabs(negativeEnergies[i]) > _Rz+_offsetZ) 
00252             {
00253                 negativeEnergies[i]=-(_Rz+_offsetZ);
00254             }
00255                         
00256             //set the local energy vector value to zero
00257             localEnergies[i]=0;
00258         }
00259         else negativeEnergies[i]=0;
00260     }
00261     return negativeEnergies;
00262 }

void IgSoRectHist::initClass ( void   )  [static]

Reimplemented from IgSoShapeKit.

Definition at line 512 of file IgSoRectHist.cc.

Referenced by initNodes(), and initShapes().

00513 { SO_KIT_INIT_CLASS (IgSoRectHist, IgSoShapeKit, "IgSoShapeKit"); }

void IgSoRectHist::refresh ( void   )  [protected, virtual]

Reimplemented from IgSoShapeKit.

Definition at line 559 of file IgSoRectHist.cc.

References energies, findMaxEnergyBin(), generateFaceIndices(), generateLabelCoords(), generateVertexData(), getNegativeEnergies(), i, int, iter, label, lineColor_, logScale, logScaleEnergies(), nr, NULL, nz, offsetR, offsetZ, Rr, Rz, scaleEnergies(), scaleFactor, and showAnnotations.

00560 {
00561 
00562     int nOfBins=energies.getNum();
00563         
00564     float deltaThetaEndcap = 2*atan(Rr.getValue()/(Rz.getValue()+offsetZ.getValue())) /  nr.getValue();
00565     float deltaThetaBarrel = 2*atan(Rz.getValue()/(Rr.getValue()+offsetR.getValue())) /  nz.getValue();
00566         
00567     float thetaRightEndcap = atan(Rr.getValue() / ( Rz.getValue() + offsetZ.getValue() ) ); 
00568     float thetaRightBarrel = atan((Rr.getValue()  + offsetR.getValue() )/Rz.getValue() ); 
00569 
00570     //if no energies, don't draw the shape      
00571     if (nOfBins == 1) {
00572         
00573         setPart ("shapeHints",  NULL);
00574         setPart ("faceSet",     NULL);
00575         setPart ("negativeShapeHints", NULL);
00576         setPart ("negativeMaterial", NULL);
00577         setPart ("negativeFaceSet", NULL);
00578         setPart ("soAnnotation", NULL);
00579         return;
00580                 
00581     }
00582         
00583     //for scaling purposes: local copy of energy vector
00584     std::vector<float> localEnergies(nOfBins);
00585         
00586     for (int i=0; i<nOfBins; i++) {
00587         localEnergies[i]=energies[i];
00588     }
00589 
00590     //calculating max energy & max energy bin before any scaling is done
00591     int maxEnergyBin = findMaxEnergyBin(localEnergies);
00592     std::vector<float>::iterator iter;
00593     iter=max_element(localEnergies.begin(), localEnergies.end());
00594     float maxEnergy=*iter;
00595 
00596     //preparing the vector for negative energies
00597     std::vector<float> negativeEnergies(nOfBins);
00598     negativeEnergies = getNegativeEnergies (localEnergies);
00599         
00600     //scaling
00601     if (scaleFactor.getValue() !=1) {
00602         scaleEnergies (localEnergies, negativeEnergies, scaleFactor.getValue());
00603     }
00604         
00605     //log scaling
00606     if (logScale.getValue()) {
00607         logScaleEnergies(localEnergies, negativeEnergies);
00608     }
00609 
00610     //------------SHAPEHINTS
00611         
00612     SoShapeHints* shapeHints = new SoShapeHints;
00613     shapeHints->faceType = SoShapeHints::CONVEX;
00614     shapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
00615         
00616     SoShapeHints* negativeShapeHints = new SoShapeHints;
00617     negativeShapeHints->faceType = SoShapeHints::CONVEX;
00618     negativeShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE;
00619         
00620     //------------MATERIALS
00621         
00622     SoMaterial * lineMaterial = new SoMaterial;
00623     SoMaterial * negativeMaterial = new SoMaterial;
00624     lineMaterial->diffuseColor.setValue (lineColor_[0], lineColor_[1] , lineColor_[2] );
00625     negativeMaterial ->diffuseColor.setValue (51.0 / 255.0, 1.0, 102.0 / 255.0);
00626          
00627     //------------FACESETS
00628         
00629     SoIndexedFaceSet* faceSet = new SoIndexedFaceSet;
00630     SoIndexedFaceSet* negativeFaceSet = new SoIndexedFaceSet;
00631         
00632     //-----------VERTEXES       
00633     std::vector<SbVec3f> vertexData = generateVertexData(localEnergies, nOfBins, deltaThetaEndcap, deltaThetaBarrel, thetaRightEndcap, thetaRightBarrel, 0, 1);
00634         
00635     std::vector<SbVec3f> negativeVertexData = generateVertexData(negativeEnergies, nOfBins, deltaThetaEndcap, deltaThetaBarrel, thetaRightEndcap, thetaRightBarrel, 0, 1);
00636                 
00637     //setting vertexProperty to vertexData
00638         
00639     SoVertexProperty* vtx = new SoVertexProperty;
00640     SoVertexProperty* negativeVtx = new SoVertexProperty;
00641 
00642     vtx->vertex.setValues (0, vertexData.size(), &vertexData[0]);
00643     vtx->materialBinding = SoMaterialBinding::PER_FACE_INDEXED;
00644         
00645     negativeVtx->vertex.setValues (0, negativeVertexData.size(), &negativeVertexData[0]);
00646     negativeVtx->materialBinding = SoMaterialBinding::PER_FACE_INDEXED;
00647         
00648     faceSet->vertexProperty = vtx;
00649     negativeFaceSet->vertexProperty = negativeVtx;
00650         
00651     //-----------FACE INDEXES
00652     std::vector< int > faceIndices = generateFaceIndices(localEnergies, (int)nr.getValue(), (int)nz.getValue());
00653     std::vector< int > negativeFaceIndices = generateFaceIndices(negativeEnergies, (int)nr.getValue(), (int)nz.getValue());
00654         
00655     faceSet->coordIndex.setValues (0, faceIndices.size(), &faceIndices[0]);
00656     negativeFaceSet->coordIndex.setValues (0, negativeFaceIndices.size(), &negativeFaceIndices[0]);
00657         
00658     //------------LINESET
00659     SoIndexedLineSet* lineSet = new SoIndexedLineSet;
00660         
00661     //-----------VERTEXES       
00662     lineSet->vertexProperty = vtx;
00663                                 
00664     //-----------FACE INDEXES
00665     lineSet->coordIndex.setValues (0, faceIndices.size(), &faceIndices[0]);
00666 
00667         
00668     //-------------ANNOTATIONS
00669         
00670     if (showAnnotations.getValue()) {
00671         
00672         SoAnnotation * soAnnotation = new SoAnnotation;
00673         
00674         char label [50];
00675         
00676         SbVec3f labelCoordsVec = generateLabelCoords (maxEnergyBin, deltaThetaEndcap, deltaThetaBarrel, thetaRightEndcap, thetaRightBarrel, maxEnergy);
00677         
00678         if (maxEnergy >= 100.0) {
00679             sprintf (label, "Emax = %.1f TeV ", maxEnergy / 1000.0);
00680         }
00681         
00682         else {
00683             sprintf (label, "Emax = %.1f GeV ", maxEnergy);
00684         }
00685         
00686         SoText2* text = new SoText2;
00687         text->string = label;
00688         text->justification = SoText2::CENTER;
00689             
00690         SoFont* labelFont = new SoFont;
00691         labelFont->size.setValue (14.0);
00692         labelFont->name.setValue ("Arial");
00693         
00694         SoMaterial * textMaterial = new SoMaterial;
00695         textMaterial->diffuseColor.setValue (0.4, 0.4, 0.4);
00696         
00697         SoTranslation* textTranslation = new SoTranslation;
00698         textTranslation->translation.setValue(labelCoordsVec);
00699         
00700         
00701         soAnnotation->addChild(lineMaterial);
00702         soAnnotation->addChild(lineSet);
00703         
00704         soAnnotation->addChild(textMaterial);
00705         soAnnotation->addChild(textTranslation);
00706         soAnnotation->addChild(labelFont);
00707         soAnnotation->addChild(text);
00708         
00709         setPart ("soAnnotation", soAnnotation);
00710         
00711     }
00712         
00713     else setPart ("soAnnotation", NULL);
00714         
00715         
00716     //------------SETTING PARTS
00717         
00718     setPart("shapeHints", shapeHints);
00719     setPart ("faceSet",    faceSet);
00720     setPart("lineMaterial", lineMaterial);      
00721 
00722         
00723     setPart ("negativeShapeHints",    negativeShapeHints);
00724     setPart ("negativeMaterial",    negativeMaterial);
00725     setPart ("negativeFaceSet",    negativeFaceSet);    
00726 }

void IgSoRectHist::setLineColor ( const float &  red,
const float &  green,
const float &  blue 
)

Definition at line 728 of file IgSoRectHist.cc.

References lineColor_.

00731 {
00732     lineColor_[0]=red;
00733     lineColor_[1]=green;
00734     lineColor_[2]=blue;
00735 }

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( soAnnotation   )  [private]

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( negativeFaceSet   )  [private]

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( negativeMaterial   )  [private]

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( negativeShapeHints   )  [private]

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( faceSet   )  [private]

IgSoRectHist::SO_KIT_CATALOG_ENTRY_HEADER ( shapeHints   )  [private]

IgSoRectHist::SO_KIT_HEADER ( IgSoRectHist   )  [private]


Member Data Documentation

SoMFFloat IgSoRectHist::energies

Definition at line 50 of file IgSoRectHist.h.

Referenced by IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::layer

Definition at line 51 of file IgSoRectHist.h.

Referenced by CMStoIgBarrel(), CMStoIgEndcap(), generateVertexData(), and IgSoRectHist().

float IgSoRectHist::lineColor_[3] [private]

Definition at line 76 of file IgSoRectHist.h.

Referenced by IgSoRectHist(), refresh(), and setLineColor().

SoSFBool IgSoRectHist::logScale

Definition at line 54 of file IgSoRectHist.h.

Referenced by IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::maxRr

Definition at line 56 of file IgSoRectHist.h.

Referenced by IgSoRectHist().

SoSFFloat IgSoRectHist::maxRz

Definition at line 57 of file IgSoRectHist.h.

Referenced by IgSoRectHist().

SoSFFloat IgSoRectHist::nr

Definition at line 48 of file IgSoRectHist.h.

Referenced by generateLabelCoords(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::nz

Definition at line 49 of file IgSoRectHist.h.

Referenced by generateLabelCoords(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::offsetR

Definition at line 46 of file IgSoRectHist.h.

Referenced by CMStoIgBarrel(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::offsetZ

Definition at line 47 of file IgSoRectHist.h.

Referenced by CMStoIgEndcap(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::Rr

Definition at line 44 of file IgSoRectHist.h.

Referenced by CMStoIgBarrel(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::Rz

Definition at line 45 of file IgSoRectHist.h.

Referenced by CMStoIgEndcap(), generateVertexData(), getNegativeEnergies(), IgSoRectHist(), and refresh().

SoSFFloat IgSoRectHist::scaleFactor

Definition at line 55 of file IgSoRectHist.h.

Referenced by IgSoRectHist(), and refresh().

SoSFBool IgSoRectHist::showAnnotations

Definition at line 60 of file IgSoRectHist.h.

Referenced by IgSoRectHist(), and refresh().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:43 2009 for CMSSW by  doxygen 1.5.4