CMS 3D CMS Logo

VisTrackerClusterTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 #include "VisReco/VisTracker/interface/VisTrackerClusterTwig.h"
00003 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00006 #include "DataFormats/Common/interface/DetSetVector.h"
00007 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00008 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/Framework/interface/EventSetup.h"
00011 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00012 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00013 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00014 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00015 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00016 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00017 #include "Iguana/Inventor/interface/IgSbColorMap.h"
00018 #include "Iguana/Inventor/interface/IgSoTower.h"
00019 #include "Iguana/Studio/interface/IgDocumentData.h"
00020 #include "Inventor/nodes/SoIndexedLineSet.h"
00021 #include "Iguana/Models/interface/IgTextRep.h"
00022 #include "Iguana/GLModels/interface/Ig3DRep.h"
00023 #include "Iguana/GLModels/interface/IgLegoRep.h"
00024 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00025 #include "Iguana/GLModels/interface/IgRZRep.h"
00026 #include "Iguana/Framework/interface/IgRepSet.h"
00027 #include "Iguana/Studio/interface/IgQtLock.h"
00028 #include <Inventor/nodes/SoSeparator.h>
00029 #include <Inventor/nodes/SoDrawStyle.h>
00030 #include <Inventor/nodes/SoMarkerSet.h>
00031 #include <Inventor/nodes/SoMaterial.h>
00032 #include <Inventor/nodes/SoPointSet.h>
00033 #include <Inventor/nodes/SoTranslation.h>
00034 #include "Inventor/nodes/SoIndexedLineSet.h"
00035 #include <Inventor/nodes/SoVertexProperty.h>
00036 #include <qstring.h>
00037 #include <iostream>
00038 #include <iomanip>
00039 
00040 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00041 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00042 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00043 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00044 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00045 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00046 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00047 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00048 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00049 
00050 namespace 
00051 {
00052     VisQueuedTwig *
00053     createThisTwig (IgState *state, IgTwig *parent,
00054                     const std::string &name,
00055                     const std::string &friendlyName,
00056                     const std::string &modLabel,
00057                     const std::string &instanceName,
00058                     const std::string &processName)
00059     {
00060         IgTwig *rootTwig = IgDocumentData::get (state)->root ();
00061         IgTwig *eventTwig = 0;
00062         eventTwig = rootTwig->lookup ("/Objects/CMS Event and Detector/Tracker Event/SiStrip Clusters");
00063         
00064         if (! eventTwig)
00065             eventTwig = parent;
00066 
00067       return new VisTrackerClusterTwig (state, eventTwig, "[N/A] SiStrip Cluster (" + name + ")", 
00068                                         friendlyName, modLabel, instanceName, processName);
00069     }
00070 }
00071 
00072 using namespace edm;
00073 VisTrackerClusterTwig::VisTrackerClusterTwig (IgState *state, IgTwig *parent,
00074                                               const std::string &name /* = "" */,
00075                                               const std::string &friendlyName /* = "" */,
00076                                               const std::string &moduleLabel /* = "" */,
00077                                               const std::string &instanceName /* = "" */,
00078                                               const std::string &processName /* = "" */)
00079     : VisQueuedTwig (state, parent, name),
00080       m_text (name),
00081       m_friendlyName (friendlyName),
00082       m_moduleLabel (moduleLabel),
00083       m_instanceName (instanceName),
00084       m_processName (processName),
00085       m_clusterPointSize (state, lat::CreateCallback (this, &VisTrackerClusterTwig::twigChanged)),
00086       m_siStripClusterRep (state, lat::CreateCallback (this, &VisTrackerClusterTwig::twigChanged)),
00087       m_scale (state, lat::CreateCallback (this, &VisTrackerClusterTwig::twigChanged))
00088 {
00089     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00090     if (! tfService)
00091     {
00092         tfService = new VisTwigFactroyService (state);
00093     }   
00094     edm::TypeID clusterCollID (typeid (edmNew::DetSetVector<SiStripCluster>));
00095     tfService->registerTwig (clusterCollID.friendlyClassName (), &createThisTwig);
00096 }
00097 
00098 void
00099 VisTrackerClusterTwig::twigChanged (void)
00100 { IgRepSet::invalidate (this, SELF_MASK); }
00101 
00102 void
00103 VisTrackerClusterTwig::onNewEvent (const edm::Event &event,
00104                                    const edm::EventSetup &eventSetup)
00105 {
00106     // Get debugging dump.
00107     VisQueuedTwig::onNewEvent (event, eventSetup);
00108     
00109     s_cluster.clear ();
00110   
00111     m_text = QString ("Run %1, Event %2, LS %3, Orbit %4, BX %5")
00112              .arg (event.id ().run ())
00113              .arg (event.id ().event ())
00114              .arg (event.luminosityBlock ())
00115              .arg (event.orbitNumber ())
00116              .arg (event.bunchCrossing ())
00117              .latin1 ();
00118 
00119     std::vector< edm::Handle<edmNew::DetSetVector<SiStripCluster> > > cluster_collections;
00120     try
00121     {
00122         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00123         {
00124             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00125             event.getMany (visSel, cluster_collections);
00126         }
00127         eventSetup.get<TrackerDigiGeometryRecord> ().get (m_pDD);
00128     }
00129     catch (lat::Error& e)
00130     {
00131         if (this->m_onError)
00132             this->m_onError (&e);
00133     }
00134     catch (cms::Exception& e)
00135     {
00136         e.append (" from VisTrackerClusterTwig: ");
00137         e.append (this->name ());    
00138         
00139         if (this->m_onCmsException)
00140             this->m_onCmsException (&e);
00141     }
00142     catch (std::exception& e)
00143     {
00144         if (this->m_onException)
00145             this->m_onException (&e);
00146     }
00147     catch (...)
00148     {
00149         if (this->m_onUnhandledException)
00150             this->m_onUnhandledException ();
00151     }
00152   
00153     if (! cluster_collections.empty ())
00154     {
00155         std::vector< edm::Handle<edmNew::DetSetVector<SiStripCluster> > >::iterator i;
00156         std::vector< edm::Handle<edmNew::DetSetVector<SiStripCluster> > >::iterator iEnd;
00157         for (i = cluster_collections.begin (), iEnd = cluster_collections.end (); i != iEnd; ++i) 
00158         {
00159             const edmNew::DetSetVector<SiStripCluster> &c = *(*i);
00160             QString sizeStr = (QString ("%1").arg (c.size ()));
00161             QString nameStr = QString (this->name ());
00162             int ib = nameStr.find ("[");
00163             int ie = nameStr.find ("]");
00164             nameStr.replace (ib + 1, ie - 1, sizeStr);
00165             
00166             this->name (nameStr);
00167           
00168             edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter = c.begin ();
00169             edmNew::DetSetVector<SiStripCluster>::const_iterator DSViterEnd = c.end ();
00170 
00171             LOG (2, trace, LFfwvis, "There are " <<  c.size () << "SiStrip culsters\n");
00172 
00173             for (; DSViter != DSViterEnd; ++DSViter)
00174             {
00175                 edmNew::DetSet<SiStripCluster> ds = *DSViter;
00176                 const uint32_t detID = DSViter->detId();
00177                 DetId detid (detID);
00178                 edmNew::DetSet<SiStripCluster>::const_iterator icluster = DSViter->begin();
00179                 edmNew::DetSet<SiStripCluster>::const_iterator iclusterEnd = DSViter->end();
00180                 for (; icluster != iclusterEnd; ++icluster)
00181                 { 
00182                     std::pair<DetId, SiStripCluster> p;
00183                     p.first = detid;
00184                     p.second = (*icluster);
00185                     s_cluster.push_back (p);
00186                 }
00187             }
00188         }
00189     }
00190 
00191     IgRepSet::invalidate (this, IgTwig::SELF_MASK | IgTwig::STRUCTURE_MASK);
00192 }
00193 
00194 void
00195 VisTrackerClusterTwig::update (IgTextRep *rep)
00196 {
00197     // Get debugging dump.
00198     VisQueuedTwig::update (rep);
00199   
00200     // Prepare property description.
00201     std::ostringstream  text;
00202 
00203     text << m_text << "<br>";
00204 
00205     text << "Total " << s_cluster.size () << " Silicon Strip clusters from";
00206 
00207     if (s_cluster.size () > 100)
00208     {
00209         text << " input file: printing only first 100 " << "<br>";
00210     }
00211     else 
00212         text << " input file: " << m_text << "<br>";
00213   
00214     text << "<table width='100%' border=1>"
00215          << "<TR align = center>"
00216          << "<TH>Number</TH>"
00217          << "<TH>GeomdetId</TH>"
00218          << "<TH>Position</TH>"
00219          << "<TH>ClusterSize</TH>"
00220          << "<TH>Barycenter</TH>"
00221          << "</TR>";
00222   
00223     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00224     text.setf (std::ios::right, std::ios::adjustfield);
00225   
00226     if ((! s_cluster.empty ()) && m_pDD.isValid ()) 
00227     {     
00228         int nSClusters = 0;
00229         try 
00230         {
00231             for (std::vector<std::pair<DetId, SiStripCluster> >::const_iterator i = s_cluster.begin (), iEnd = s_cluster.end (); i != iEnd; ++i) 
00232             {
00233                 const DetId& id = (*i).first;
00234               
00235                 SiStripCluster c = (*i).second;
00236                 short firststrip = c.firstStrip (); 
00237                 const StripGeomDetUnit*  theStripDet = dynamic_cast<const StripGeomDetUnit*>((m_pDD->idToDet (id)));
00238                 const StripTopology* theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00239                 GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().toGlobal (theStripTopol->localPosition (firststrip));
00240               
00241                 text << "<TR align = right>"
00242                      << "<TD>" << std::setw (3) << nSClusters++ << "</TD>"
00243                      << "<TD>" << std::setw (11) << ((*i).first).rawId()<< "</TD>"
00244                      << "<TD>" << pos.x () << ", " << pos.y () << ", " << pos.z () << "</TD>"
00245                      << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.amplitudes().size() << "</TD>"
00246                      << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.barycenter() << "</TD>";
00247                 if (nSClusters>100) break;
00248             }
00249         }
00250         catch (cms::Exception& e)
00251         {
00252             e.append (" from VisTrackerClusterTwig: ");
00253             e.append (this->name ());    
00254         
00255             if (this->m_onCmsException)
00256                 this->m_onCmsException (&e);
00257         }
00258         catch (lat::Error &e) 
00259         {
00260             if (this->m_onError)
00261                 this->m_onError (&e);
00262         }
00263         catch (std::exception &e) 
00264         {
00265             if (this->m_onException)
00266                 this->m_onException (&e);
00267         }
00268         catch (...) 
00269         {
00270             if (this->m_onUnhandledException)
00271                 this->m_onUnhandledException ();
00272         }
00273     }
00274     
00275     text << "</table>";
00276     
00277     // Send it over.
00278     IgQtLock ();
00279     rep->setText (text.str ());
00280 }
00281 
00282 void
00283 VisTrackerClusterTwig::update (Ig3DRep *rep)
00284 {
00285     // Get debugging dump.
00286     VisQueuedTwig::update (rep);
00287     IgQtLock ();
00288     rep->clear ();
00289   
00290     if (! s_cluster.empty () && m_pDD.isValid ())
00291     {
00292         SoMaterial *mat = new SoMaterial;       
00293         float rgbcomponents [4];
00294         IgSbColorMap::unpack (0x6600FF00, rgbcomponents); // Electric indigo
00295         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00296 
00297         SoDrawStyle *drawStyle = new SoDrawStyle;
00298         drawStyle->pointSize = m_clusterPointSize.value ();
00299       
00300         SoSeparator *sep = new SoSeparator; // global
00301         sep->addChild (mat);
00302         sep->addChild (drawStyle);
00303       
00304         try 
00305         {            
00306             SoVertexProperty *vertices = new SoVertexProperty;
00307             SoVertexProperty *vtx = new SoVertexProperty;
00308             SoIndexedLineSet *strips = new SoIndexedLineSet;
00309             int nVrtx = 0;
00310             int n = 0;
00311             int coord = 0;
00312             SoMFInt32 coords;
00313 
00314             for (std::vector<std::pair<DetId, SiStripCluster> >::const_iterator 
00315                      i = s_cluster.begin (), iEnd = s_cluster.end (); i != iEnd; ++i)
00316             {
00317                 const DetId& id = (*i).first;
00318 
00319                 SiStripCluster c = (*i).second; 
00320                 short firststrip = c.firstStrip (); 
00321                 const StripGeomDetUnit*  theStripDet = dynamic_cast<const StripGeomDetUnit*>( (m_pDD->idToDet (id)));
00322                 const StripTopology* theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00323                 GlobalPoint pos =  (m_pDD->idToDet (id))->surface().toGlobal(theStripTopol->localPosition(firststrip));
00324                 if (m_siStripClusterRep.value () == "strip")
00325                 {
00326                     MeasurementPoint mp1((float)firststrip,(float)-0.5);LocalPoint lp1=theStripTopol->localPosition(mp1); 
00327                     MeasurementPoint mp2((float)firststrip,(float)+0.5);LocalPoint lp2=theStripTopol->localPosition(mp2);
00328                     GlobalPoint pos1 =  (m_pDD->idToDet (id))->surface().toGlobal(lp1);
00329                     GlobalPoint pos2 =  (m_pDD->idToDet (id))->surface().toGlobal(lp2);
00330                     vtx->vertex.set1Value(n,SbVec3f(pos1.x()/100.0,pos1.y()/100.0,pos1.z()/100.0));
00331                     coords.set1Value (coord, n);
00332                     coord++;n++;
00333                     vtx->vertex.set1Value(n,SbVec3f(pos2.x()/100.0,pos2.y()/100.0,pos2.z()/100.0));
00334                     coords.set1Value (coord, n);
00335                     coord++;n++;
00336                     coords.set1Value (coord, SO_END_LINE_INDEX);
00337                     coord++;
00338                 }
00339 
00340                 //Surface::GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().position ();
00341                 float x = pos.x () / 100.0;  // cm -> m
00342                 float y = pos.y () / 100.0;  // cm -> m
00343                 float z = pos.z () / 100.0;  // cm -> m
00344 
00345                 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00346             }
00347             
00348             vertices->vertex.setNum (nVrtx);
00349             SoMFInt32 markerIndex;
00350             markerIndex.setValue (SoMarkerSet::CIRCLE_FILLED_5_5);
00351 
00352             SoMarkerSet *points = new SoMarkerSet;
00353             points->markerIndex = markerIndex;
00354             points->vertexProperty.setValue (vertices);
00355             points->numPoints.setValue (nVrtx);
00356 
00357             sep->addChild (points);
00358             if (m_siStripClusterRep.value () == "strip")
00359             {
00360                 strips->vertexProperty = vtx;
00361                 strips->coordIndex = coords;
00362                 sep->addChild (strips);
00363             }
00364         }
00365         catch (cms::Exception& e)
00366         {
00367             e.append (" from VisTrackerClusterTwig: ");
00368             e.append (this->name ());    
00369         
00370             if (this->m_onCmsException)
00371                 this->m_onCmsException (&e);
00372         }
00373         catch (lat::Error &e) 
00374         {
00375             if (this->m_onError)
00376                 this->m_onError (&e);
00377         }
00378         catch (std::exception &e) 
00379         {
00380             if (this->m_onException)
00381                 this->m_onException (&e);
00382         }
00383         catch (...) 
00384         {
00385             if (this->m_onUnhandledException)
00386                 this->m_onUnhandledException ();
00387         }
00388     
00389         rep->node ()->addChild (sep);
00390     }
00391 }
00392 
00393 void
00394 VisTrackerClusterTwig::update (IgLegoRep *rep)
00395 {
00396     // Get debugging dump.
00397     VisQueuedTwig::update (rep);
00398 
00399     IgQtLock ();
00400     rep->clear ();
00401     
00402     SoSeparator *sep = new SoSeparator; // global
00403 
00404     if (! s_cluster.empty () && m_pDD.isValid ())
00405     {    
00406         try 
00407         {
00408             for (std::vector<std::pair<DetId, SiStripCluster> >::const_iterator i = s_cluster.begin (); i != s_cluster.end (); ++i) 
00409             {
00410                 const DetId& id = (*i).first;
00411 
00412                 SiStripCluster c = (*i).second;
00413                 short firststrip = c.firstStrip(); 
00414                 const StripGeomDetUnit*  theStripDet = dynamic_cast<const StripGeomDetUnit*>( (m_pDD->idToDet (id)));
00415                 const StripTopology* theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00416                 GlobalPoint pos =  (m_pDD->idToDet (id))->surface().toGlobal(theStripTopol->localPosition(firststrip));
00417 
00418                 double eta = pos.eta ();
00419                 double phi = pos.phi ();
00420                 if (phi < 0.0) phi = 2 * M_PI + phi; // correction in absence of one convention
00421             
00422                 int clusterCharge = 0;
00423                 int sas = (*i).second.amplitudes ().size ();
00424 
00425                 for (int j = 0; j < sas; j++)
00426                 {
00427                     clusterCharge += (*i).second.amplitudes ()[j];
00428                 }
00429             
00430                 IgSoTower *tower = new IgSoTower;
00431                 tower->position = SbVec2f (phi, eta); // eta, phi
00432                 tower->etaWidth = 0.02;
00433                 tower->phiWidth = 0.02;
00434                 tower->scaleFactor = m_scale.value ();
00435                 tower->energy = clusterCharge  * 250.0 * 3.61e-09;
00436                 tower->orderedRGBA.set1Value (6, SbColor (0.4, 0.0, 1.0).getPackedValue ());
00437                 sep->addChild (tower);
00438             }
00439         }
00440         catch (cms::Exception& e)
00441         {
00442             e.append (" from VisTrackerClusterTwig: ");
00443             e.append (this->name ());    
00444         
00445             if (this->m_onCmsException)
00446                 this->m_onCmsException (&e);
00447         }
00448         catch (lat::Error &e) 
00449         {
00450             if (this->m_onError)
00451                 this->m_onError (&e);
00452         }
00453         catch (std::exception &e) 
00454         {
00455             if (this->m_onException)
00456                 this->m_onException (&e);
00457         }
00458         catch (...) 
00459         {
00460             if (this->m_onUnhandledException)
00461                 this->m_onUnhandledException ();
00462         }
00463     }
00464     
00465     rep->node ()->addChild (sep);
00466 }
00467 
00468 void
00469 VisTrackerClusterTwig::update (IgRPhiRep *rep)
00470 {
00471     // Get debugging dump.
00472     VisQueuedTwig::update (rep);
00473 
00474     IgQtLock ();
00475     rep->clear ();
00476     
00477     if (! s_cluster.empty () && m_pDD.isValid ()) 
00478     {
00479         SoSeparator *sep = new SoSeparator;    
00480         SoSeparator *colorSep = new SoSeparator;    
00481         sep->addChild (colorSep);
00482 
00483         SoTranslation *trans = new SoTranslation;
00484         trans->translation = SbVec3f (0, 0, 0.05);
00485         sep->addChild (trans);
00486 
00487         SoSeparator *yellowSep = new SoSeparator;    
00488         sep->addChild (yellowSep);
00489 
00490         SoMaterial *mat = new SoMaterial;
00491         float rgbcomponents [4];
00492         IgSbColorMap::unpack (0x6600FF00, rgbcomponents); // Electric indigo
00493         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00494         colorSep->addChild (mat);
00495         
00496         // Electric lime
00497         SoDrawStyle *drawStyle = new SoDrawStyle;
00498         drawStyle->pointSize = m_clusterPointSize.value ();
00499         colorSep->addChild (drawStyle);
00500 
00501         SoMaterial *yellowMat = new SoMaterial;
00502         IgSbColorMap::unpack (0xCCFF0000, rgbcomponents); // Electric lime
00503         yellowMat->diffuseColor.setValue (SbColor (rgbcomponents));
00504         yellowSep->addChild (yellowMat);
00505 
00506         SoDrawStyle *yellowDrawStyle = new SoDrawStyle;
00507         if (m_clusterPointSize.value () > 2)
00508             yellowDrawStyle->pointSize = m_clusterPointSize.value () - 2;
00509         yellowSep->addChild (yellowDrawStyle);
00510 
00511         try 
00512         {
00513             SoVertexProperty *vertices = new SoVertexProperty;
00514             int nVrtx = 0;
00515             for (std::vector<std::pair<DetId, SiStripCluster> >::const_iterator 
00516                      i = s_cluster.begin (), iEnd = s_cluster.end (); i != iEnd; ++i)
00517             {
00518                 const DetId& id = (*i).first;
00519 
00520                 SiStripCluster c = (*i).second;
00521                 short firststrip = c.firstStrip (); 
00522                 const StripGeomDetUnit*  theStripDet = dynamic_cast<const StripGeomDetUnit*>( (m_pDD->idToDet (id)));
00523                 // Draw only if in barrel.
00524                 int subdet = theStripDet->geographicalId().subdetId();
00525                 if (subdet == 1 || subdet == 3 || subdet == 5)
00526                 {
00527                     const StripTopology* theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00528                     GlobalPoint pos =  (m_pDD->idToDet (id))->surface().toGlobal(theStripTopol->localPosition(firststrip));
00529 
00530                     float x = pos.x () / 100.0;  // cm -> m
00531                     float y = pos.y () / 100.0;  // cm -> m
00532                     float z = 3.1;  // Z layer
00533 
00534                     vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00535                 }
00536             }
00537             
00538             vertices->vertex.setNum (nVrtx);
00539             SoPointSet *points = new SoPointSet;
00540             points->vertexProperty.setValue (vertices);
00541             points->numPoints.setValue (nVrtx);
00542 
00543             colorSep->addChild (points);
00544             yellowSep->addChild (points);
00545         }
00546         catch (cms::Exception& e)
00547         {
00548             e.append (" from VisTrackerClusterTwig: ");
00549             e.append (this->name ());    
00550         
00551             if (this->m_onCmsException)
00552                 this->m_onCmsException (&e);
00553         }
00554         catch (lat::Error &e) 
00555         {
00556             if (this->m_onError)
00557                 this->m_onError (&e);
00558         }
00559         catch (std::exception &e) 
00560         {
00561             if (this->m_onException)
00562                 this->m_onException (&e);
00563         }
00564         catch (...) 
00565         {
00566             if (this->m_onUnhandledException)
00567                 this->m_onUnhandledException ();
00568         }
00569     
00570         rep->node ()->addChild (sep);
00571     }
00572 }
00573 
00574 void
00575 VisTrackerClusterTwig::update (IgRZRep *rep)
00576 {
00577     // Get debugging dump.
00578     VisQueuedTwig::update (rep);
00579 
00580     IgQtLock ();
00581     rep->clear ();
00582 
00583     if (! s_cluster.empty () && m_pDD.isValid ()) 
00584     {
00585         SoSeparator *sep = new SoSeparator;    
00586         SoSeparator *colorSep = new SoSeparator;    
00587         sep->addChild (colorSep);
00588 
00589         SoTranslation *trans = new SoTranslation;
00590         trans->translation = SbVec3f (-0.05, 0, 0);
00591         sep->addChild (trans);
00592 
00593         SoSeparator *yellowSep = new SoSeparator;    
00594         sep->addChild (yellowSep);
00595 
00596         SoMaterial *mat = new SoMaterial;
00597         float rgbcomponents [4];
00598         IgSbColorMap::unpack (0x6600FF00, rgbcomponents); // Electric indigo
00599         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00600         colorSep->addChild (mat);
00601 
00602         SoDrawStyle *drawStyle = new SoDrawStyle;
00603         drawStyle->pointSize = m_clusterPointSize.value ();
00604         colorSep->addChild (drawStyle);
00605  
00606         SoMaterial *yellowMat = new SoMaterial;
00607         IgSbColorMap::unpack (0xCCFF0000, rgbcomponents); // Electric lime
00608         yellowMat->diffuseColor.setValue (SbColor (rgbcomponents));
00609         yellowSep->addChild (yellowMat);
00610 
00611         SoDrawStyle *yellowDrawStyle = new SoDrawStyle;
00612         if (m_clusterPointSize.value () > 2)
00613             yellowDrawStyle->pointSize = m_clusterPointSize.value () - 2;
00614         yellowSep->addChild (yellowDrawStyle);
00615    
00616         try 
00617         {
00618             SoVertexProperty *vertices = new SoVertexProperty;
00619             int nVrx = 0;
00620 
00621             for (std::vector<std::pair<DetId, SiStripCluster> >::const_iterator i = s_cluster.begin (), iEnd = s_cluster.end (); i != iEnd; ++i) 
00622             {
00623                 const DetId& id = (*i).first;
00624 
00625                 SiStripCluster c = (*i).second;
00626                 short firststrip = c.firstStrip (); 
00627                 const StripGeomDetUnit*  theStripDet = dynamic_cast<const StripGeomDetUnit*>( (m_pDD->idToDet (id)));
00628                 const StripTopology* theStripTopol = dynamic_cast<const StripTopology *>( &(theStripDet->specificTopology ()));
00629                 GlobalPoint pos = (m_pDD->idToDet (id))->surface ().toGlobal (theStripTopol->localPosition (firststrip));
00630                 float x = -3.1;
00631                 float y = sqrt (pos.x () * pos.x () + pos.y () * pos.y ()) / 100.0; 
00632                 if (pos.y () < 0.0) y = - y;   
00633                 float z = pos.z () / 100.0;  // cm -> m
00634                 
00635                 vertices->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00636             }
00637 
00638             vertices->vertex.setNum (s_cluster.size());
00639 
00640             SoPointSet *points = new SoPointSet;
00641             points->vertexProperty.setValue (vertices);
00642             points->numPoints.setValue (s_cluster.size());
00643 
00644             colorSep->addChild (points);
00645             yellowSep->addChild (points);
00646         }    
00647         catch (cms::Exception& e)
00648         {
00649             e.append (" from VisTrackerClusterTwig: ");
00650             e.append (this->name ());    
00651         
00652             if (this->m_onCmsException)
00653                 this->m_onCmsException (&e);
00654         }
00655         catch (lat::Error &e) 
00656         {
00657             if (this->m_onError)
00658                 this->m_onError (&e);
00659         }
00660         catch (std::exception &e) 
00661         {
00662             if (this->m_onException)
00663                 this->m_onException (&e);
00664         }
00665         catch (...) 
00666         {
00667             if (this->m_onUnhandledException)
00668                 this->m_onUnhandledException ();
00669         }
00670 
00671         rep->node ()->addChild (sep);
00672     }
00673 }
00674 

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