CMS 3D CMS Logo

VisCSCDigiTools.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/VisMuonCSC/interface/VisCSCDigiTools.h"
00004 // This is to become a class better...
00005 // Some common Digi visualiszation parameters
00006 //
00007 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00008 //
00009 #include <Inventor/nodes/SoDrawStyle.h>
00010 #include <Inventor/nodes/SoMaterial.h>
00011 #include <Inventor/nodes/SoSeparator.h>
00012 #include <Inventor/nodes/SoCube.h>
00013 #include <Inventor/nodes/SoLineSet.h>
00014 #include <Inventor/nodes/SoTranslation.h>
00015 #include <Inventor/nodes/SoPointSet.h>
00016 #include <Inventor/nodes/SoTransform.h>
00017 #include <Inventor/nodes/SoRotation.h>
00018 #include <Inventor/nodes/SoText3.h>
00019 #include <Inventor/nodes/SoFont.h>
00020 #include <qstring.h>
00021 #include <iostream>
00022 #include <iomanip>
00023 #include <vector>
00024 
00025 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00026 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00027 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00028 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00029 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00030 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00031 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00032 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00033 
00034 // function is to be called once only
00035 bool VisCaptions(float const layer_z, 
00036                  float const layer_phi, 
00037                  float &OurPhi, 
00038                  float &OurZ, 
00039                  SoSeparator *sep){
00040   OurPhi = layer_phi; // init
00041   OurZ = layer_z; // init
00042   //
00043   SoTranslation *trans_me1 = new SoTranslation;
00044   SoTranslation *trans_me2 = new SoTranslation;
00045   SoTranslation *trans_me3 = new SoTranslation;
00046   SoTranslation *trans_me4 = new SoTranslation;
00047   //
00048   trans_me1->translation.setValue(MEsHorisontal_X,MEsHorisontal_Y,0.);
00049   trans_me2->translation.setValue(MEsHorisontal_X+MEsHorisontal_stepX,MEsHorisontal_Y,0.);
00050   trans_me3->translation.setValue(MEsHorisontal_X+2.*MEsHorisontal_stepX,MEsHorisontal_Y,0.);
00051   trans_me4->translation.setValue(MEsHorisontal_X+3.*MEsHorisontal_stepX,MEsHorisontal_Y,0.);
00052   //
00053   SoTranslation *trans_me1_v = new SoTranslation;
00054   SoTranslation *trans_me2_v = new SoTranslation;
00055   SoTranslation *trans_me3_v = new SoTranslation;
00056   SoTranslation *trans_me4_v = new SoTranslation;
00057   //
00058   trans_me1_v->translation.setValue(MEsVertical_X,
00059                                     MEsVertical_Y,0.);
00060   trans_me2_v->translation.setValue(MEsVertical_X,
00061                                     MEsVertical_Y-MEsVertical_stepY,0.);
00062   trans_me3_v->translation.setValue(MEsVertical_X,
00063                                     MEsVertical_Y-2.*MEsVertical_stepY,0.);
00064   trans_me4_v->translation.setValue(MEsVertical_X,
00065                                     MEsVertical_Y-3.*MEsVertical_stepY,0.);
00066   //
00067   SoTranslation *trans_strips = new SoTranslation;
00068   SoTranslation *trans_wires = new SoTranslation;
00069   SoTranslation *trans_phi = new SoTranslation;
00070   SoTranslation *trans_format = new SoTranslation;
00071   //
00072   trans_strips->translation.setValue(Digis_X,Digis_Y,0.);
00073   trans_wires->translation.setValue(Digis_X+Digis_stepX,Digis_Y,0.);
00074   trans_phi->translation.setValue(PHI_X,PHI_Y,0.);
00075   trans_format->translation.setValue(PHI_X-0.5,PHI_Y-0.3,0.);
00076   //  
00077   SoText3 *TextME1 = new SoText3;
00078   SoText3 *TextME2 = new SoText3;
00079   SoText3 *TextME3 = new SoText3;
00080   SoText3 *TextME4 = new SoText3;
00081   //
00082   TextME1->string = "ME1";
00083   TextME2->string = "ME2";
00084   TextME3->string = "ME3";
00085   TextME4->string = "ME4";
00086   //
00087   SoText3 *TextStrips = new SoText3;
00088   SoText3 *TextWires = new SoText3;
00089   SoText3 *TextPhi = new SoText3;
00090   SoText3 *TextFormat = new SoText3;
00091   //
00092   TextStrips->string = "Strips";
00093   TextWires->string = "Wire groups";
00094   TextPhi->string = "Phi:";
00095   //TextFormat->string = "----------------------------------------------------------------------------";
00096   //
00097   SoMaterial *mat = new SoMaterial;
00098   mat->diffuseColor.setValue (0.0, 0.0, 0.0);
00099   //
00100   SoMaterial *matInfo = new SoMaterial;
00101   matInfo->diffuseColor.setValue (0.0, 0.0, 1.0);
00102   //
00103   SoMaterial *matText = new SoMaterial;
00104   matText->diffuseColor.setValue (1.0, 0.0, 0.0);
00105   //root->addChild(africaSep);
00106   //
00107   SoSeparator *Station1_h = new SoSeparator;
00108   SoSeparator *Station2_h = new SoSeparator;
00109   SoSeparator *Station3_h = new SoSeparator;
00110   SoSeparator *Station4_h = new SoSeparator;
00111   //
00112   SoSeparator *Station1_v = new SoSeparator;
00113   SoSeparator *Station2_v = new SoSeparator;
00114   SoSeparator *Station3_v = new SoSeparator;
00115   SoSeparator *Station4_v = new SoSeparator;
00116   //
00117   SoSeparator *strips_txt =  new SoSeparator;
00118   SoSeparator *wires_txt =  new SoSeparator;
00119   SoSeparator *phi_txt =  new SoSeparator;
00120   SoSeparator *format_txt =  new SoSeparator;
00121   //
00122   
00123   Station1_h->addChild(trans_me1);
00124   Station1_h->addChild(TextME1);
00125   //
00126   Station2_h->addChild(trans_me2);
00127   Station2_h->addChild(TextME2);
00128   //
00129   Station3_h->addChild(trans_me3);
00130   Station3_h->addChild(TextME3);
00131   //
00132   Station4_h->addChild(trans_me4);
00133   Station4_h->addChild(TextME4);
00134   //
00135   Station1_v->addChild(trans_me1_v);
00136   Station1_v->addChild(TextME1);
00137   //
00138   Station2_v->addChild(trans_me2_v);
00139   Station2_v->addChild(TextME2);
00140   //
00141   Station3_v->addChild(trans_me3_v);
00142   Station3_v->addChild(TextME3);
00143   //
00144   Station4_v->addChild(trans_me4_v);
00145   Station4_v->addChild(TextME4);
00146   //
00147   strips_txt->addChild(trans_strips);
00148   strips_txt->addChild(matInfo);
00149   strips_txt->addChild(TextStrips);
00150   //
00151   wires_txt->addChild(trans_wires);
00152   wires_txt->addChild(matInfo);
00153   wires_txt->addChild(TextWires);
00154   //
00155   phi_txt->addChild(trans_phi);
00156   phi_txt->addChild(mat);
00157   phi_txt->addChild(TextPhi);
00158   //
00159   format_txt->addChild(trans_format);
00160   format_txt->addChild(mat);
00161   format_txt->addChild(TextFormat);
00162   //
00163   SoFont *font = new SoFont;
00164   //font->name.setValue("Courier-BoldOblique");
00165   font->name.setValue(VisFont);
00166   font->size.setValue(VisFontSize);
00167   //
00168   SoSeparator *TitleStations = new SoSeparator;
00169   SoSeparator *info = new SoSeparator;
00170   //
00171   TitleStations->addChild(font);
00172   TitleStations->addChild(matText);
00173   TitleStations->addChild(Station1_h);
00174   TitleStations->addChild(Station2_h);
00175   TitleStations->addChild(Station3_h);
00176   TitleStations->addChild(Station4_h);
00177   TitleStations->addChild(Station1_v);
00178   TitleStations->addChild(Station2_v);
00179   TitleStations->addChild(Station3_v);
00180   TitleStations->addChild(Station4_v);
00181   //
00182   info->addChild(font);
00183   info->addChild(strips_txt);
00184   info->addChild(wires_txt);
00185   info->addChild(phi_txt);
00186   info->addChild(format_txt);
00187   //
00188   sep->addChild (TitleStations);
00189   sep->addChild (info);
00190   //
00191   return true;
00192 }
00193 //              
00194 bool VisFrames(const std::vector<float> trapezBounds, 
00195                SoLineSet *trapez,
00196                SoLineSet *rect_w, 
00197                SoLineSet *rect_s){
00198   if(4!=trapezBounds.size()) return false;
00199   // Layer (chamber) bounds
00200   int nVrx = 0;
00201   float x, y, z;
00202   //       
00203   std::vector<LocalPoint> CrossPoint;
00204   CrossPoint.push_back( LocalPoint(-trapezBounds[0], -trapezBounds[3], 0.));
00205   CrossPoint.push_back( LocalPoint(trapezBounds[0], -trapezBounds[3], 0.));
00206   CrossPoint.push_back( LocalPoint(trapezBounds[1], trapezBounds[3], 0.));
00207   CrossPoint.push_back( LocalPoint(-trapezBounds[1], trapezBounds[3], 0.));
00208   CrossPoint.push_back( LocalPoint(-trapezBounds[0], -trapezBounds[3], 0.));
00209   //
00210   SoVertexProperty *vert = new SoVertexProperty;
00211   for (std::vector<LocalPoint>::iterator _crossP = 
00212          CrossPoint.begin (); _crossP != CrossPoint.end (); ++_crossP){
00213     x = _crossP->x()/100.0;  // cm -> m
00214     y = _crossP->y()/100.0;  // cm -> m
00215     z = _crossP->z()/100.0;  // cm -> m
00216     vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00217   }
00218   vert->vertex.setNum (nVrx);
00219   trapez->vertexProperty.setValue (vert);
00220   trapez->numVertices[CrossPoint.size()];
00221   // "Strip" bounds
00222   CrossPoint.clear();
00223   CrossPoint.push_back( LocalPoint(-trapezBounds[1], -trapezBounds[2], 0.));
00224   CrossPoint.push_back( LocalPoint(trapezBounds[1], -trapezBounds[2], 0.));
00225   CrossPoint.push_back( LocalPoint(trapezBounds[1], trapezBounds[2], 0.));
00226   CrossPoint.push_back( LocalPoint(-trapezBounds[1], trapezBounds[2], 0.));
00227   CrossPoint.push_back( LocalPoint(-trapezBounds[1], -trapezBounds[2], 0.));
00228   //
00229   vert = new SoVertexProperty;
00230   nVrx = 0;   
00231   for (std::vector<LocalPoint>::iterator _crossP = 
00232          CrossPoint.begin (); _crossP != CrossPoint.end (); ++_crossP){
00233     x = _crossP->x()/100.0;  // cm -> m
00234     y = _crossP->y()/4.;  // cm -> m
00235     z = _crossP->z()/100.0;  // cm -> m
00236     vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00237   }
00238   vert->vertex.setNum (nVrx);
00239   rect_s->vertexProperty.setValue (vert);
00240   rect_s->numVertices[CrossPoint.size()];
00241   // "Wire" bounds 
00242   CrossPoint.clear();
00243   CrossPoint.push_back( LocalPoint(-trapezBounds[3], -trapezBounds[2], 0.));
00244   CrossPoint.push_back( LocalPoint(trapezBounds[3], -trapezBounds[2], 0.));
00245   CrossPoint.push_back( LocalPoint(trapezBounds[3], trapezBounds[2], 0.));
00246   CrossPoint.push_back( LocalPoint(-trapezBounds[3], trapezBounds[2], 0.));
00247   CrossPoint.push_back( LocalPoint(-trapezBounds[3], -trapezBounds[2], 0.));
00248   //
00249   vert = new SoVertexProperty;
00250   nVrx = 0;  
00251   for (std::vector<LocalPoint>::iterator _crossP = 
00252          CrossPoint.begin (); _crossP != CrossPoint.end (); ++_crossP){
00253     x = _crossP->x()/100.0;  // cm -> m
00254     y = _crossP->y()/4.;  // cm -> m
00255     z = _crossP->z()/100.0;  // cm -> m
00256     vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00257   }
00258   vert->vertex.setNum (nVrx);
00259   rect_w->vertexProperty.setValue (vert);
00260   rect_w->numVertices[CrossPoint.size()];
00261   //
00262   return true;  
00263 }
00264 
00265 bool MakeTrans(const std::vector<float> trapezBounds,
00266                float const station_id, 
00267                float const layer_r,
00268                float const layer_phi,
00269                float const layer_z,
00270                float const OurPhi,
00271                float const OurZ,
00272                SoTranslation *trans,
00273                SoTranslation *trans_caption,
00274                SoTranslation *trans_s,
00275                SoTranslation *trans_w){
00276   // Translations
00277   float Xtrans = MEsFrames_X + 
00278     MEsFrames_Xstep*(station_id-1); // put diff. Stations at diff. place
00279   float Xtrans_m = MEsFrames_X + 
00280     MEsFrames_Xstep*(station_id-1) - MEsFrames_Xstep/10.;
00281   float Xtrans_p = MEsFrames_X + 
00282     MEsFrames_Xstep*(station_id-1) + MEsFrames_Xstep/10.;
00283   //      
00284   trans->translation = SbVec3f(Xtrans,layer_r,0.);
00285   trans_caption->translation.setValue(Xtrans-0.4,0.,0.);
00286   //
00287   float Ytrans = MEsFrames_Y - MEsFrames_Ystep*(station_id-1);
00288   float Ytrans_m = MEsFrames_Y - 
00289     MEsFrames_Ystep*(station_id-1) - MEsFrames_Ystep/3.;
00290   float Ytrans_p = MEsFrames_Y - 
00291     MEsFrames_Ystep*(station_id-1) + MEsFrames_Ystep/3.;
00292   trans_s->translation = SbVec3f(MEsFrames_X,Ytrans,0.);
00293   //
00294   float Xtrans_w = layer_r-MEsFrames_Xstep;
00295   trans_w->translation = SbVec3f(Xtrans_w,Ytrans,0.);
00296   // Colors, shifts
00297   if(OurPhi != layer_phi){
00298     float Ytrans_strip;
00299     if(OurZ < layer_z){ // shift chambers
00300       Ytrans_strip=Ytrans_m;
00301       trans_w->translation = SbVec3f(Xtrans_w,Ytrans_m,0.);
00302     }
00303     else{
00304       Ytrans_strip=Ytrans_p;
00305       trans_w->translation = SbVec3f(Xtrans_w,Ytrans_p,0.);
00306     }
00307     if (layer_phi<OurPhi){ // shift chambers a bit
00308       trans->translation = SbVec3f(Xtrans_m,layer_r,0.);
00309       trans_caption->translation.setValue(Xtrans_m-0.8,0.,0.);
00310       trans_s->translation = SbVec3f(MEsFrames_X-2.*0.8*trapezBounds[1]/100.,
00311                                      Ytrans_strip,0.);
00312     }
00313     else{ 
00314       trans->translation = SbVec3f(Xtrans_p,layer_r,0.);
00315       trans_caption->translation.setValue(Xtrans_p,0.,0.);
00316       trans_s->translation = SbVec3f(MEsFrames_X+2.*0.8*trapezBounds[1]/100.,
00317                                      Ytrans_strip,0.);
00318     }
00319   }
00320   return true;
00321 }
00322 
00323 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00324 

Generated on Tue Jun 9 17:50:20 2009 for CMSSW by  doxygen 1.5.4