CMS 3D CMS Logo

VisCSCWireDigiTwig Class Reference

#include <VisReco/VisMuonCSC/interface/VisCSCWireDigiTwig.h>

Inheritance diagram for VisCSCWireDigiTwig:

VisQueuedTwig IgSimpleTwig VisEventObserver IgCompoundTwig IgTwig IgRepresentable

List of all members.

Public Member Functions

virtual void onNewEvent (const edm::Event &event, const edm::EventSetup &eventSetup)
virtual void update (IgSpareRep *rep)
virtual void update (IgRZRep *rep)
virtual void update (IgRPhiRep *rep)
virtual void update (IgTextRep *rep)
virtual void update (IgLegoRep *rep)
virtual void update (Ig3DRep *rep)
 VisCSCWireDigiTwig (IgState *state, IgTwig *parent, const std::string &name="", const std::string &friendlyName="", const std::string &moduleLabel="", const std::string &instanceName="", const std::string &processName="")

Private Attributes

std::set< CSCDetIdm_dets
std::vector< std::pair
< CSCDetId, CSCWireDigi > > 
m_digis
const std::string m_friendlyName
const std::string m_instanceName
const std::string m_moduleLabel
edm::ESHandle< CSCGeometrym_pDD
const std::string m_processName
std::string m_text


Detailed Description

Definition at line 23 of file VisCSCWireDigiTwig.h.


Constructor & Destructor Documentation

VisCSCWireDigiTwig::VisCSCWireDigiTwig ( IgState state,
IgTwig parent,
const std::string &  name = "",
const std::string &  friendlyName = "",
const std::string &  moduleLabel = "",
const std::string &  instanceName = "",
const std::string &  processName = "" 
)

Definition at line 69 of file VisCSCWireDigiTwig.cc.

References createThisTwig(), edm::TypeID::friendlyClassName(), DBSPlugin::get(), and VisTwigFactroyService::registerTwig().

00075     : VisQueuedTwig (state, parent, name),
00076       m_text (name),
00077       m_friendlyName (friendlyName),
00078       m_moduleLabel (moduleLabel),
00079       m_instanceName (instanceName),
00080       m_processName (processName)
00081 {
00082     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00083     if (! tfService)
00084     {
00085         tfService = new VisTwigFactroyService (state);
00086     }   
00087     edm::TypeID caloJetsID (typeid (CSCWireDigiCollection));
00088     tfService->registerTwig (caloJetsID.friendlyClassName (), &createThisTwig);
00089 }


Member Function Documentation

void VisCSCWireDigiTwig::onNewEvent ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 92 of file VisCSCWireDigiTwig.cc.

References arg, c, e, exception, edm::EventSetup::get(), i, edm::Event::id(), m_digis, m_friendlyName, m_instanceName, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_processName, m_text, VisQueuedTwig::onBaseInvalidate(), VisQueuedTwig::onNewEvent(), p, and range.

00094 {
00095     // Get debugging dump.
00096     VisQueuedTwig::onNewEvent (event, eventSetup);
00097 
00098     m_digis.clear ();
00099     m_text = (QString ("Run # %1, event # %2")
00100               .arg (event.id ().run ())
00101               .arg (event.id ().event ()).latin1 ());
00102 
00103     std::vector<edm::Handle<CSCWireDigiCollection> > digiCollections;
00104 
00105     try
00106     {
00107         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00108         {
00109             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00110             event.getMany (visSel, digiCollections);
00111         }
00112         else
00113         {
00114             event.getManyByType (digiCollections);
00115         }
00116         
00117         eventSetup.get<MuonGeometryRecord> ().get (m_pDD);
00118     }
00119     catch (cms::Exception& e)
00120     {
00121         if (this->m_onCmsException)
00122             this->m_onCmsException (&e);
00123     }
00124     catch (lat::Error &e) 
00125     {
00126         if (this->m_onError)
00127             this->m_onError (&e);
00128     }
00129     catch (std::exception &e) 
00130     {
00131         if (this->m_onException)
00132             this->m_onException (&e);
00133     }
00134     catch (...) 
00135     {
00136         if (this->m_onUnhandledException)
00137             this->m_onUnhandledException ();
00138     }
00139 
00140     if (! digiCollections.empty ())
00141     {
00142         std::vector<edm::Handle<CSCWireDigiCollection> >::iterator i;
00143         std::vector<edm::Handle<CSCWireDigiCollection> >::iterator iEnd;
00144         for (i = digiCollections.begin (), iEnd = digiCollections.end (); i != iEnd; ++i) 
00145         {
00146             const CSCWireDigiCollection& c = *(*i);
00147         
00148             // Loop over the DetUnits with digis
00149             CSCWireDigiCollection::DigiRangeIterator detUnitIt;
00150             CSCWireDigiCollection::DigiRangeIterator detUnitItEnd;
00151             for (detUnitIt = c.begin (), detUnitItEnd = c.end (); detUnitIt != detUnitItEnd; ++detUnitIt)
00152             {
00153                 const CSCDetId &id = (*detUnitIt).first;
00154                 const CSCWireDigiCollection::Range &range = (*detUnitIt).second;
00155 
00156                 // Loop over the digis of this DetUnit
00157                 for (CSCWireDigiCollection::const_iterator digiIt = range.first;
00158                      digiIt != range.second;
00159                      ++digiIt)
00160                 {
00161                     std::pair< CSCDetId, CSCWireDigi > p;
00162                     p.first = id;
00163                     p.second = (*digiIt);
00164                     m_digis.push_back (p);
00165 //                  std::cout << "Hit: Id/Digi: " << id <<", " << *digiIt << std::endl; //DEBUG
00166                 } // for digis in layer
00167             } // for layers
00168         }
00169     }
00170     
00171     VisQueuedTwig::onBaseInvalidate ();
00172 }

void VisCSCWireDigiTwig::update ( IgSpareRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 588 of file VisCSCWireDigiTwig.cc.

References Ig3DBaseRep::clear(), e, exception, CSCLayer::geometry(), i, edm::ESHandle< T >::isValid(), CSCLayerGeometry::lengthOfWireGroup(), CSCLayerGeometry::localCenterOfWireGroup(), m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, Ig3DBaseRep::node(), TrapezoidalPlaneBounds::parameters(), PV3DBase< T, PVType, FrameType >::phi(), funct::sqrt(), VisQueuedTwig::update(), VisCaptions(), VisFont, VisFontSize, PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00589 {
00590     // Get debugging dump.
00591     VisQueuedTwig::update (rep);
00592     //
00593     IgQtLock ();
00594     rep->clear ();
00595     //
00596     if (! m_digis.empty () && m_pDD.isValid ()) 
00597     {
00598         SoSeparator *sep = new SoSeparator;    
00599         //
00600         SoMaterial *mat = new SoMaterial;
00601         mat->diffuseColor.setValue (0.0, 0.0, 0.0);
00602         sep->addChild (mat);
00603         try 
00604         {
00605             bool iterations = false;
00606             float OurPhi = 9999999.;
00607             float OurPhiSlice = 9999999.;
00608             float OurZ = 99999999.;
00609             for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = 
00610                      m_digis.begin (); i != m_digis.end (); ++i) 
00611             {
00612                 const CSCDetId& id = (*i).first;
00613                 //int EndCap  = id.endcap();
00614                 //int Station = id.station();
00615                 //int Ring    = id.ring();
00616                 //int Chamber = id.chamber();
00617                 const CSCLayer* layer_p = m_pDD->layer(id);
00618                 const CSCLayerGeometry* layerGeom=0;
00619               
00620                 if(layer_p){
00621                     layerGeom = layer_p->geometry();
00622                 }
00623                 else{// to be filled...
00624                 }
00625                 //
00626                 Surface::GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().position ();
00627                 float layer_x = pos.x () / 100.0;  // cm -> m
00628                 float layer_y = pos.y () / 100.0;  // cm -> m
00629                 float layer_z = pos.z () / 100.0;  // cm -> m
00630                 float layer_phi = pos.phi ();
00631                 float layer_r = sqrt(layer_x*layer_x + layer_y*layer_y);
00632                 if(!iterations){
00633                     // Make captions, some init
00634                     iterations=VisCaptions(layer_z, layer_phi, OurPhi, OurZ, sep);
00635                 }
00636                 const std::vector<float> trapezBounds = layerGeom->parameters();
00637                 OurPhiSlice = 2. * atan(trapezBounds[1]/(layer_r + trapezBounds[3])) * 0.8;
00638                 // Only adjacent chambers 
00639                 if (fabs(layer_phi - OurPhi) < 2. * OurPhiSlice){
00640                     int wireGroup_id = ((*i).second).getWireGroup();
00641                     LocalPoint centerWireGroup=layerGeom->localCenterOfWireGroup(wireGroup_id);
00642                     float wireLength = layerGeom->lengthOfWireGroup(wireGroup_id);
00643                     // Make frames
00644                     SoLineSet *trapez = new SoLineSet;
00645                     SoLineSet *rect_s = new SoLineSet;
00646                     SoLineSet *rect_w = new SoLineSet;
00647                     // bool FramesOK = VisFrames(trapezBounds,trapez,rect_w,rect_s);
00648                     // Translations
00649                     SoTranslation *trans = new SoTranslation; // trapez frames
00650                     SoTranslation *trans_caption = new SoTranslation; // captions
00651                     SoTranslation *trans_s = new SoTranslation; // strips
00652                     SoTranslation *trans_w = new SoTranslation; // wire groups
00653                     /* 
00654                     bool TransOK = MakeTrans(trapezBounds,
00655                                              id.station(), layer_r, layer_phi, layer_z, 
00656                                              OurPhi, OurZ,
00657                                              trans, trans_caption, trans_s, trans_w);
00658                     */                       
00659                     // caption
00660                     SoText3 *TextCaption = new SoText3;
00661                     char ch[10];
00662                     sprintf( ch,"%1.1f", layer_phi);
00663                     TextCaption->string = ch;
00664                     // font
00665                     SoFont *font_caption = new SoFont;
00666                     font_caption->name.setValue(VisFont);
00667                     font_caption->size.setValue(VisFontSize);
00668                     // Wire group as a line
00669                     SoVertexProperty *vert = new SoVertexProperty;
00670                     int nVrx = 0;
00671                     float x = (centerWireGroup.x()-wireLength/2.)/100.;
00672                     float y = centerWireGroup.y()/100.;
00673                     float z = 0.; 
00674                     vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00675                     //
00676                     x = (centerWireGroup.x()+wireLength/2.)/100.;
00677                     y = centerWireGroup.y()/100.;
00678                     z = 0.;
00679                     vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00680                     //
00681                     vert->vertex.setNum (nVrx);
00682                     SoLineSet *WireGroupVis = new SoLineSet;
00683                     WireGroupVis->vertexProperty.setValue (vert);
00684                     WireGroupVis->numVertices[2];
00685                     // Wire group projection - a point
00686                     SoVertexProperty *wireDots = new SoVertexProperty;
00687                     nVrx = 0;
00688                     x =  centerWireGroup.y()/ 100.0;  // cm -> m
00689                     y =  (trapezBounds[2]*1.1 -  id.layer()*2.*trapezBounds[2]/6.)/4.;
00690                     z = 0. / 100.0;  // cm -> m
00691                     //  " ,x:"<<x<<" ,y:"<<y<<std::endl;
00692                     if(3==id.station()) y=-y;// ...
00693                     //std::cout<<"new y:"<<y<<std::endl;
00694                     wireDots->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00695                     wireDots->vertex.setNum (nVrx);
00696                     int Npoints=nVrx;
00697                     // Colors
00698                     SoMaterial *matw = new SoMaterial;
00699                     SoMaterial *matf = new SoMaterial;
00700                     if(OurPhi == layer_phi){
00701                         matw->diffuseColor.setValue (0.3, 0.0, 0.3); // purple
00702                         matf->diffuseColor.setValue (0.0, 0.0, 0.0); // black
00703                     }
00704                     else{
00705                         matw->diffuseColor.setValue (0.6, 0.0, 6.0); // light purple
00706                         matf->diffuseColor.setValue(0.6, 0.6, 0.6); // grey
00707                     }
00708                     //  Build the "picture"
00709                     SoSeparator *shape = new SoSeparator;// frame
00710                     shape->addChild (matf); 
00711                     shape->addChild (trapez);
00712                     //
00713                     SoSeparator *caption = new SoSeparator;// caption
00714                     caption->addChild (matf); 
00715                     caption->addChild (trans_caption);
00716                     caption->addChild (font_caption);
00717                     caption->addChild (TextCaption);
00718                     //
00719                     SoSeparator *proj_s = new SoSeparator;// projection strip frame
00720                     proj_s->addChild (matf); 
00721                     proj_s->addChild (trans_s); 
00722                     proj_s->addChild (rect_s);
00723                     //
00724                     SoSeparator *proj_w = new SoSeparator;// projection wire frame
00725                     proj_w->addChild (matf); 
00726                     proj_w->addChild (trans_w); 
00727                     proj_w->addChild (rect_w);
00728                     //
00729                     SoDrawStyle *drawStylel = new SoDrawStyle;
00730                     drawStylel->pointSize = 2.0; // bigger 
00731                     //
00732                     SoSeparator *dotsWG = new SoSeparator; // projection wire groups
00733                     SoPointSet *points = new SoPointSet;
00734                     points->vertexProperty.setValue (wireDots);
00735                     points->numPoints.setValue (Npoints);
00736                     dotsWG->addChild (matw); 
00737                     dotsWG->addChild (drawStylel);
00738                     dotsWG->addChild (trans_w);
00739                     dotsWG->addChild (points);
00740                     //
00741                     SoSeparator *wiregroup = new SoSeparator;// wiregroup
00742                     wiregroup->addChild (matw);
00743                     wiregroup->addChild (WireGroupVis);
00744                     //
00745                     SoSeparator *layer = new SoSeparator;// layer
00746                     layer->addChild (trans);
00747                     layer->addChild (shape);
00748                     layer->addChild (wiregroup);
00749                     // Visualization of all
00750                     sep->addChild (layer);
00751                     sep->addChild (caption);
00752                     sep->addChild (proj_s);
00753                     sep->addChild (proj_w);
00754                     sep->addChild (dotsWG);
00755                 }
00756             }
00757         }
00758         catch (cms::Exception& e)
00759         {
00760             if (this->m_onCmsException)
00761                 this->m_onCmsException (&e);
00762         }
00763         catch (lat::Error &e) 
00764         {
00765             if (this->m_onError)
00766                 this->m_onError (&e);
00767         }
00768         catch (std::exception &e) 
00769         {
00770             if (this->m_onException)
00771                 this->m_onException (&e);
00772         }
00773         catch (...) 
00774         {
00775             if (this->m_onUnhandledException)
00776                 this->m_onUnhandledException ();
00777         }
00778         //
00779         // FIXME: Move to another rep type. 
00780         rep->node ()->addChild (sep);
00781     }
00782 }

void VisCSCWireDigiTwig::update ( IgRZRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 785 of file VisCSCWireDigiTwig.cc.

References Ig3DBaseRep::clear(), e, exception, i, edm::ESHandle< T >::isValid(), m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, Ig3DBaseRep::node(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00786 {
00787     // Get debugging dump.
00788     VisQueuedTwig::update (rep);
00789 
00790     IgQtLock ();
00791     rep->clear ();
00792 
00793     if (! m_digis.empty () && m_pDD.isValid ()) 
00794     {
00795         SoSeparator *sep = new SoSeparator;    
00796         SoMaterial *mat = new SoMaterial;
00797         mat->diffuseColor.setValue (0.3, 0.8, 0.0);
00798         sep->addChild (mat);
00799 
00800         SoDrawStyle *drawStyle = new SoDrawStyle;
00801         drawStyle->pointSize = 3.0;
00802         sep->addChild (drawStyle);
00803     
00804         try 
00805         {
00806             SoVertexProperty *vertices = new SoVertexProperty;
00807             int nVrx = 0;
00808 
00809             for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i) 
00810             {
00811                 Surface::GlobalPoint pos =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00812 //              int wire = (*i).second.getWireGroup ();
00813 //              int tbin = (*i).second.getBeamCrossingTag ();
00814             
00815                 float x = pos.x () / 100.0;  // cm -> m
00816                 float y = pos.y () / 100.0;  // cm -> m
00817                 float z = pos.z () / 100.0;  // cm -> m
00818                 
00819                 vertices->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00820             }
00821             vertices->vertex.setNum (m_digis.size ());
00822 
00823             SoPointSet *points = new SoPointSet;
00824             points->vertexProperty.setValue (vertices);
00825             points->numPoints.setValue (m_digis.size ());
00826             sep->addChild (points);
00827         }    
00828         catch (cms::Exception& e)
00829         {
00830             if (this->m_onCmsException)
00831                 this->m_onCmsException (&e);
00832         }
00833         catch (lat::Error &e) 
00834         {
00835             if (this->m_onError)
00836                 this->m_onError (&e);
00837         }
00838         catch (std::exception &e) 
00839         {
00840             if (this->m_onException)
00841                 this->m_onException (&e);
00842         }
00843         catch (...) 
00844         {
00845             if (this->m_onUnhandledException)
00846                 this->m_onUnhandledException ();
00847         }
00848         rep->node ()->addChild (sep);
00849     }
00850 }

void VisCSCWireDigiTwig::update ( IgRPhiRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 414 of file VisCSCWireDigiTwig.cc.

References angle(), Ig3DBaseRep::clear(), e, exception, f, CSCLayer::geometry(), i, edm::ESHandle< T >::isValid(), CSCLayerGeometry::lengthOfWireGroup(), CSCLayerGeometry::localCenterOfWireGroup(), m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, Ig3DBaseRep::node(), TrapezoidalPlaneBounds::parameters(), r, VisQueuedTwig::update(), width, PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00415 {
00416     // Get debugging dump.
00417     VisQueuedTwig::update (rep);
00418     //
00419     IgQtLock ();
00420     rep->clear ();
00421     //
00422     if (! m_digis.empty () && m_pDD.isValid ())
00423     {
00424         const float width= 0.02;// wire group visualization 
00425         const float depth = 0.01;// wire group visualization 
00426         //    
00427         SbColor grey35;
00428         float transparency = 0.0f;
00429         grey35.setPackedValue(static_cast<uint32_t>(0x00595959), transparency);
00430         SoMaterial *mat = new SoMaterial;
00431         mat->diffuseColor.setValue (grey35); // grey35
00432         mat->emissiveColor.setValue(grey35);
00433         //
00434         SoDrawStyle *drawStyle = new SoDrawStyle;
00435         drawStyle->pointSize = 5.0; // big point; useful for the centers of the layers
00436         //
00437         SoSeparator *sep = new SoSeparator;// global
00438         sep->addChild (mat);
00439         sep->addChild (drawStyle);
00440         //
00441         try 
00442         { 
00443             SoMaterial *matl = new SoMaterial;
00444             matl->diffuseColor.setValue (0.5, 0.0, 1.0); // purple
00445             matl->emissiveColor.setValue(0.5, 0.0, 1.0);          
00446             matl->shininess = 1.;  
00447             //
00448             SoDrawStyle *drawStylel = new SoDrawStyle;
00449             drawStylel->pointSize = 1.;
00450             //
00451             SoSeparator *pulses = new SoSeparator;// wire groups
00452             pulses->addChild (matl);
00453             pulses->addChild (drawStylel);
00454             //
00455             SoVertexProperty *vertices = new SoVertexProperty;
00456             int nVrtx = 0;
00457             for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator 
00458                      i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00459             {
00460                 const CSCDetId& id = (*i).first;
00461                 // This is the center of the (active) layer
00462                 Surface::GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().position (); 
00463                 float x = pos.x () / 100.0;  // cm -> m
00464                 float y = pos.y () / 100.0;  // cm -> m
00465                 float z = pos.z () / 100.0;  // cm -> m
00466                 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00467                 //
00468                 const CSCLayer* layer_p = m_pDD->layer(id);
00469                 const CSCLayerGeometry* layerGeom=0;
00470                 if (layer_p)
00471                 {
00472                     layerGeom = layer_p->geometry ();
00473                 }
00474                 else 
00475                 {
00476                     // to be filled...
00477                 }
00478                 // This is a frame around the (active) layer
00479                 bool framePlot = true;
00480                 if (framePlot)
00481                 {
00482                     const std::vector<float> trapezBounds = layerGeom->parameters ();
00483                     std::vector<Surface::GlobalPoint> CrossPoint;
00484                     CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00485                                           (LocalPoint (-trapezBounds [0], -trapezBounds [3], 0.)));
00486                     CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00487                                           (LocalPoint (trapezBounds [0], -trapezBounds [3], 0.)));
00488                     CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00489                                           (LocalPoint(trapezBounds [1], trapezBounds [3], 0.)));
00490                     CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00491                                           (LocalPoint (-trapezBounds [1], trapezBounds [3], 0.)));
00492                     //
00493                     SoVertexProperty *vert = new SoVertexProperty;
00494                     int nVrx = 0;
00495                     for (std::vector<Surface::GlobalPoint>::iterator _crossP = CrossPoint.begin (); _crossP != CrossPoint.end (); ++_crossP)
00496                     {
00497                         x = _crossP->x () / 100.0;  // cm -> m
00498                         y = _crossP->y () / 100.0;  // cm -> m
00499                         z = _crossP->z () / 100.0;  // cm -> m
00500                         vert->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00501                     }
00502                     std::vector<Surface::GlobalPoint>::reference closeCircle 
00503                         =  CrossPoint.front ();
00504                     x = closeCircle.x () / 100.0;  // cm -> m
00505                     y = closeCircle.y () / 100.0;  // cm -> m
00506                     z = closeCircle.z () / 100.0;  // cm -> m
00507                     vert->vertex.set1Value (nVrx++, SbVec3f (x, y, 0.f));
00508                     // 
00509                     vert->vertex.setNum (nVrx);
00510                     SoLineSet *trapez = new SoLineSet;
00511                     trapez->vertexProperty.setValue (vert);
00512                     trapez->numVertices [CrossPoint.size () + 1];
00513                     //
00514                     SoMaterial *mats = new SoMaterial;
00515                     mats->diffuseColor.setValue (1.0, 1.0, 1.0); // white
00516                     mats->emissiveColor.setValue (1.0, 1.0, 1.0);
00517                     //
00518                     SoSeparator *shape = new SoSeparator;// layer
00519                     shape->addChild (mats);
00520                     shape->addChild (trapez);
00521                     // Visualize the layer bounds
00522                     sep->addChild (shape);
00523                 }
00524                 //
00525                 int wireGroup_id = ((*i).second).getWireGroup ();
00526                 LocalPoint centerWireGroup = layerGeom->localCenterOfWireGroup (wireGroup_id);
00527                 pos = (m_pDD->idToDet (id))->surface ().toGlobal (centerWireGroup);
00528                 x = pos.x () / 100.0;  // cm -> m
00529                 y = pos.y () / 100.0;  // cm -> m
00530                 z = pos.z () / 100.0;  // cm -> m
00531                 //
00532                 SoTranslation   *inc = new SoTranslation;
00533                 inc->translation = SbVec3f (x, y, z);
00534                 //
00535                 SbVec3f axis (0., 0., 1.);      
00536                 float angle = -atan (x / y) - M_PI / 2;
00537                 SbRotation r (axis, angle);
00538                 //
00539                 SoTransform *xform = new SoTransform;
00540                 xform ->rotation = r;
00541                 //
00542                 SoCube *hit = new SoCube;
00543                 hit->width  = width;
00544                 hit->height = layerGeom->lengthOfWireGroup (wireGroup_id) / 100.;
00545                 hit->depth  = depth;
00546                 //
00547                 SoSeparator *pulse = new SoSeparator;// wire group
00548                 pulse->addChild (inc);
00549                 pulse->addChild (xform);
00550                 pulse->addChild (hit);
00551                 pulses->addChild (pulse);
00552                 // Visualize wire groups 
00553                 sep->addChild (pulses);// wire groups
00554             }
00555             //
00556             vertices->vertex.setNum (m_digis.size ());      
00557             SoPointSet *points = new SoPointSet;
00558             points->vertexProperty.setValue (vertices);
00559             points->numPoints.setValue (m_digis.size ());
00560             // Visualize the center of the layer
00561             sep->addChild (points);
00562         }
00563         catch (cms::Exception& e)
00564         {
00565             if (this->m_onCmsException)
00566                 this->m_onCmsException (&e);
00567         }
00568         catch (lat::Error &e) 
00569         {
00570             if (this->m_onError)
00571                 this->m_onError (&e);
00572         }
00573         catch (std::exception &e) 
00574         {
00575             if (this->m_onException)
00576                 this->m_onException (&e);
00577         }
00578         catch (...) 
00579         {
00580             if (this->m_onUnhandledException)
00581                 this->m_onUnhandledException ();
00582         }
00583         rep->node ()->addChild (sep);
00584     }
00585 }

void VisCSCWireDigiTwig::update ( IgTextRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 175 of file VisCSCWireDigiTwig.cc.

References e, exception, i, edm::ESHandle< T >::isValid(), m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_text, IgTextRep::setText(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

00176 {
00177     // Get debugging dump.
00178     VisQueuedTwig::update (rep);
00179 
00180     // Prepare property description.
00181     std::ostringstream  text;
00182     text << "Total " << m_digis.size () << " CSC wire digis: " << m_text << "<br>";
00183 
00184     text << "<table width='100%' border=1>"
00185          << "<TR align = center>"
00186          << "<TH>Number</TH>"
00187          << "<TH>Position</TH>"
00188          << "<TH>Wire group</TH>"
00189          << "<TH>Beam-crossing tag</TH>"
00190          << "<TH>Time bin</TH>"
00191          << "</TR>";
00192     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00193     text.setf (std::ios::right, std::ios::adjustfield);
00194     
00195     if ( ! m_digis.empty () ) 
00196     {
00197        
00198         int nDigis = 0;
00199         try 
00200         {
00201             for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i) 
00202             {
00203                 Surface::GlobalPoint pos( NAN, NAN, NAN );
00204                 if (m_pDD.isValid ()) pos  =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00205                 text << "<TR align = right>"
00206                      << "<TD>" << std::setw (3) << ++nDigis << "</TD>"
00207                      << "<TD>" << pos.x () << ", " << pos.y () << ", " << pos.z () << "</TD>"
00208                      << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).second.getWireGroup () << "</TD>"
00209                      << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).second.getBeamCrossingTag () << "</TD>"
00210                      << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.getTimeBin () << "</TD>"
00211                      << "</TR>";
00212             }
00213         }
00214         catch (cms::Exception& e)
00215         {
00216             if (this->m_onCmsException)
00217                 this->m_onCmsException (&e);
00218         }
00219         catch (lat::Error &e) 
00220         {
00221             if (this->m_onError)
00222                 this->m_onError (&e);
00223         }
00224         catch (std::exception &e) 
00225         {
00226             if (this->m_onException)
00227                 this->m_onException (&e);
00228         }
00229         catch (...) 
00230         {
00231             if (this->m_onUnhandledException)
00232                 this->m_onUnhandledException ();
00233         }
00234     }
00235     text << "</table>";
00236     
00237     // Send it over.
00238     IgQtLock ();
00239     rep->setText (text.str ());
00240 }

void VisCSCWireDigiTwig::update ( IgLegoRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 348 of file VisCSCWireDigiTwig.cc.

References Ig3DBaseRep::clear(), and VisQueuedTwig::update().

00349 {
00350     // Get debugging dump.
00351     VisQueuedTwig::update (rep);
00352 
00353     IgQtLock ();
00354     rep->clear ();
00355     
00356 //     SoSeparator *sep = new SoSeparator;    
00357 //     SoSeparator *posSep = new SoSeparator;    
00358 //     SoSeparator *negSep = new SoSeparator;
00359 
00360 //     SoMaterial *mat = new SoMaterial;
00361 //     mat->diffuseColor.setValue (0.0, 0.0, 1.0);
00362 //     posSep->addChild (mat);
00363 
00364 //     SoMaterial *negMat = new SoMaterial;
00365 //     negMat->diffuseColor.setValue (1.0, 0.0, 0.0);
00366 //     negSep->addChild (negMat);
00367 
00368 //     sep->addChild (posSep);
00369 //     sep->addChild (negSep);
00370 
00371 //     try 
00372 //     {
00373 //      for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = m_digis.begin (); i != m_digis.end (); ++i) 
00374 //      {
00375 //          Surface::GlobalPoint pos =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00376 //          double eta = pos.eta ();
00377 //          double phi = pos.phi ();
00378 //          if (phi < 0.0) phi = 2 * M_PI + phi; // correction in absence of one convention
00379 
00380 // //       int wire = (*i).second.getWireGroup ();
00381 // //       int tbin = (*i).second.getBeamCrossingTag ();
00382             
00383 //          IgSoTower *tower = new IgSoTower;
00384 //          tower->position = SbVec2f (phi, eta); // eta, phi
00385 //          tower->scaleFactor = 20.0;
00386 //          posSep->addChild (tower); 
00387 //      }
00388 //     }
00389 //      catch (cms::Exception& e)
00390 //      {
00391 //          if (this->m_onCmsException)
00392 //              this->m_onCmsException (&e);
00393 //      }
00394 //      catch (lat::Error &e) 
00395 //      {
00396 //          if (this->m_onError)
00397 //              this->m_onError (&e);
00398 //      }
00399 //      catch (std::exception &e) 
00400 //      {
00401 //          if (this->m_onException)
00402 //              this->m_onException (&e);
00403 //      }
00404 //      catch (...) 
00405 //      {
00406 //          if (this->m_onUnhandledException)
00407 //              this->m_onUnhandledException ();
00408 //      }
00409     
00410 //     rep->node ()->addChild (sep);
00411 }

void VisCSCWireDigiTwig::update ( Ig3DRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 243 of file VisCSCWireDigiTwig.cc.

References angle(), Ig3DBaseRep::clear(), d, e, exception, CSCLayer::geometry(), VisCSCChamberDrawer::getOutline(), i, edm::ESHandle< T >::isValid(), CSCLayerGeometry::lengthOfWireGroup(), CSCLayerGeometry::localCenterOfWireGroup(), m_dets, m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, Ig3DBaseRep::node(), r, VisQueuedTwig::update(), width, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

00244 {
00245     // Get debugging dump.
00246     VisQueuedTwig::update (rep);
00247     //
00248     IgQtLock ();
00249     rep->clear ();
00250     m_dets.clear ();
00251     //
00252     if (! m_digis.empty () && m_pDD.isValid ())
00253     {
00254         VisCSCChamberDrawer d;
00255         const float width= 0.02;// wire group visualization 
00256         const float depth = 0.01;// wire group visualization 
00257         //    
00258         //
00259         SoDrawStyle *drawStyle = new SoDrawStyle;
00260         drawStyle->pointSize = 5.0; // big point; useful for the centers of the layers
00261         //
00262         SoSeparator *sep = new SoSeparator;// global
00263         sep->addChild (drawStyle);
00264         //
00265         try 
00266         { 
00267             SoMaterial *matl = new SoMaterial;
00268             matl->diffuseColor.setValue (0.5, 0.0, 1.0); // purple
00269             matl->emissiveColor.setValue(0.5, 0.0, 1.0);          
00270             matl->shininess = 1.;  
00271             //
00272             SoDrawStyle *drawStylel = new SoDrawStyle;
00273             drawStylel->pointSize = 1.;
00274             //
00275             SoSeparator *pulses = new SoSeparator;// wire groups
00276             pulses->addChild (matl);
00277             pulses->addChild (drawStylel);
00278             //
00279             for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator 
00280                      i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00281             {
00282                 const CSCDetId& id = (*i).first;
00283                 if (m_dets.find(id) == m_dets.end() )
00284                 {
00285                     m_dets.insert(id);  
00286                     // This is a frame around the (active) layer
00287                     d.getOutline(sep, m_pDD, id);
00288 
00289                 }
00290                 //
00291                 const CSCLayer *layer_p = m_pDD->layer (id);
00292                 const CSCLayerGeometry *layerGeom = layer_p->geometry ();
00293                 const int wireGroup_id = ((*i).second).getWireGroup ();
00294                 const LocalPoint centerWireGroup = layerGeom->localCenterOfWireGroup (wireGroup_id);
00295                 const Surface::GlobalPoint pos = (m_pDD->idToDet (id))->surface ().toGlobal (centerWireGroup);
00296                 SbVec3f pt( pos.x(), pos.y(), pos.z() );
00297                 pt *= 0.01F; // cm -> m
00298                 //
00299                 SoTranslation   *inc = new SoTranslation;
00300                 inc->translation = pt;
00301                 //
00302                 SbVec3f axis (0., 0., 1.);      
00303                 float angle = -atan (pt[0] / pt[1]) - M_PI / 2;
00304                 SbRotation r (axis, angle);
00305                 //
00306                 SoTransform *xform = new SoTransform;
00307                 xform ->rotation = r;
00308                 //
00309                 SoCube *hit = new SoCube;
00310                 hit->width  = width;
00311                 hit->height = layerGeom->lengthOfWireGroup (wireGroup_id) / 100.;
00312                 hit->depth  = depth;
00313                 //
00314                 SoSeparator *pulse = new SoSeparator;// wire group
00315                 pulse->addChild (inc);
00316                 pulse->addChild (xform);
00317                 pulse->addChild (hit);
00318                 pulses->addChild (pulse);
00319                 // Visualize wire groups 
00320                 sep->addChild (pulses);// wire groups
00321             }
00322         }
00323         catch (cms::Exception& e)
00324         {
00325             if (this->m_onCmsException)
00326                 this->m_onCmsException (&e);
00327         }
00328         catch (lat::Error &e) 
00329         {
00330             if (this->m_onError)
00331                 this->m_onError (&e);
00332         }
00333         catch (std::exception &e) 
00334         {
00335             if (this->m_onException)
00336                 this->m_onException (&e);
00337         }
00338         catch (...) 
00339         {
00340             if (this->m_onUnhandledException)
00341                 this->m_onUnhandledException ();
00342         }
00343         rep->node ()->addChild (sep);
00344     }
00345 }


Member Data Documentation

std::set<CSCDetId> VisCSCWireDigiTwig::m_dets [private]

Definition at line 53 of file VisCSCWireDigiTwig.h.

Referenced by update().

std::vector< std::pair<CSCDetId, CSCWireDigi> > VisCSCWireDigiTwig::m_digis [private]

Definition at line 51 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent(), and update().

const std::string VisCSCWireDigiTwig::m_friendlyName [private]

Definition at line 47 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent().

const std::string VisCSCWireDigiTwig::m_instanceName [private]

Definition at line 49 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent().

const std::string VisCSCWireDigiTwig::m_moduleLabel [private]

Definition at line 48 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent().

edm::ESHandle<CSCGeometry> VisCSCWireDigiTwig::m_pDD [private]

Definition at line 52 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent(), and update().

const std::string VisCSCWireDigiTwig::m_processName [private]

Definition at line 50 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent().

std::string VisCSCWireDigiTwig::m_text [private]

Definition at line 46 of file VisCSCWireDigiTwig.h.

Referenced by onNewEvent(), and update().


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