CMS 3D CMS Logo

VisCSCRecHit2DTwig Class Reference

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

Inheritance diagram for VisCSCRecHit2DTwig:

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 (IgRZRep *rep)
 Update object property description.
virtual void update (IgRPhiRep *rep)
 Update object property description.
virtual void update (IgTextRep *rep)
 Update object property description.
virtual void update (IgLegoRep *rep)
 Update object property description.
virtual void update (Ig3DRep *rep)
 Update object property description.
 VisCSCRecHit2DTwig (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

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::vector< CSCRecHit2Dm_rechits
std::string m_text


Detailed Description

Definition at line 22 of file VisCSCRecHit2DTwig.h.


Constructor & Destructor Documentation

VisCSCRecHit2DTwig::VisCSCRecHit2DTwig ( 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 60 of file VisCSCRecHit2DTwig.cc.

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

00066     : VisQueuedTwig (state, parent, name),
00067       m_text (name),
00068       m_friendlyName (friendlyName),
00069       m_moduleLabel (moduleLabel),
00070       m_instanceName (instanceName),
00071       m_processName (processName)
00072 {
00073     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00074     if (! tfService)
00075     {
00076         tfService = new VisTwigFactroyService (state);
00077     }   
00078     edm::TypeID digiCollID (typeid (CSCRecHit2DCollection));
00079     tfService->registerTwig (digiCollID.friendlyClassName (), &createThisTwig);
00080 }


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 83 of file VisCSCRecHit2DTwig.cc.

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

00085 {
00086     // Get debugging dump.
00087     VisQueuedTwig::onNewEvent (event, eventSetup);
00088 
00089     m_rechits.clear ();
00090     m_text = (QString ("Run # %1, event # %2")
00091               .arg (event.id ().run ())
00092               .arg (event.id ().event ()).latin1 ());
00093 
00094     std::vector<edm::Handle<CSCRecHit2DCollection> > hitCollections;
00095     
00096     try
00097     {
00098         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00099         {
00100             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00101             event.getMany (visSel, hitCollections);
00102         }
00103         else
00104         {
00105             event.getManyByType (hitCollections);
00106         }
00107 
00108         eventSetup.get<MuonGeometryRecord> ().get (m_pDD);
00109     }
00110     catch (cms::Exception& e)
00111     {
00112         if (this->m_onCmsException)
00113             this->m_onCmsException (&e);
00114     }
00115     catch (lat::Error &e) 
00116     {
00117         if (this->m_onError)
00118             this->m_onError (&e);
00119     }
00120     catch (std::exception &e) 
00121     {
00122         if (this->m_onException)
00123             this->m_onException (&e);
00124     }
00125     catch (...) 
00126     {
00127         if (this->m_onUnhandledException)
00128             this->m_onUnhandledException ();
00129     }
00130 
00131     if (! hitCollections.empty ())
00132     {
00133         std::vector<edm::Handle<CSCRecHit2DCollection> >::iterator i;
00134         std::vector<edm::Handle<CSCRecHit2DCollection> >::iterator iEnd;
00135         for (i = hitCollections.begin (), iEnd = hitCollections.end (); i != iEnd; ++i) 
00136         {
00137             const CSCRecHit2DCollection& c = *(*i);
00138     
00139             CSCRecHit2DCollection::const_iterator hitIt;
00140             CSCRecHit2DCollection::const_iterator hitItEnd;
00141             for (hitIt = c.begin (), hitItEnd = c.end (); hitIt != hitItEnd; ++hitIt)
00142             {
00143                 m_rechits.push_back (*hitIt);
00144             }
00145         }
00146     }
00147     
00148     VisQueuedTwig::onBaseInvalidate ();
00149 }

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

Update object property description.

Reimplemented from VisQueuedTwig.

Definition at line 402 of file VisCSCRecHit2DTwig.cc.

References Ig3DBaseRep::clear(), e, exception, edm::ESHandle< T >::isValid(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_rechits, Ig3DBaseRep::node(), funct::sqrt(), GeomDet::surface(), Surface::toGlobal(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00403 {
00404     // Get debugging dump.
00405     VisQueuedTwig::update (rep);
00406 
00407     IgQtLock ();
00408 
00409     SoSeparator *sep = new SoSeparator;
00410     SoMaterial *mat = new SoMaterial;
00411     mat->ambientColor.setValue (0.135, 0.2225, 0.1575);
00412     mat->diffuseColor.setValue (0.54, 0.89, 0.63);
00413     mat->specularColor.setValue (0.316228, 0.316228, 0.316228);
00414     mat->emissiveColor.setValue(0.0, 0.0, 0.0);
00415     mat->shininess = 0.1;
00416     sep->addChild (mat);
00417     
00418     if (! m_rechits.empty () && m_pDD.isValid ())
00419     {
00420         try 
00421         {
00422             //
00423             // Muon Endcap Rechits
00424             // 
00425         
00426             for (std::vector<CSCRecHit2D>::const_iterator is = m_rechits.begin (), isEnd = m_rechits.end (); is != isEnd; ++is) 
00427             {
00428                 const GeomDetUnit *det = m_pDD->idToDetUnit ((*is).cscDetId ());
00429                 
00430 //              GlobalPoint pos = det->surface ().toGlobal ((*is).localPosition ());
00431             
00432 //              float x = pos.x () / 100.0;  // cm -> m
00433 //              float y = pos.y () / 100.0;  // cm -> m
00434 //              float z = pos.z () / 100.0;  // cm -> m
00435                 
00436                 LocalPoint xyzLocal = is->localPosition ();
00437                 float x = xyzLocal.x ();
00438                 float y = xyzLocal.y ();
00439                 float z = xyzLocal.z ();
00440                 float dx = std::sqrt( is->localPositionError ().xx () );
00441                 float dy = std::sqrt( is->localPositionError ().yy () );
00442                 
00443                 IgSo3DErrorBar *errorBar = new IgSo3DErrorBar;
00444                 GlobalPoint gp;
00445                 gp = det->surface ().toGlobal (LocalPoint (x - dx, y, z));
00446                 errorBar->u1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00447                 gp = det->surface ().toGlobal (LocalPoint (x + dx, y, z));
00448                 errorBar->u2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00449                 gp = det->surface ().toGlobal (LocalPoint (x, y - dy, z));
00450                 errorBar->v1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00451                 gp = det->surface ().toGlobal (LocalPoint (x, y + dy, z));
00452                 errorBar->v2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00453                 gp = det->surface ().toGlobal (xyzLocal); // no error in z
00454                 errorBar->w1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00455                 errorBar->w2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00456 
00457                 errorBar->lineWidth.setValue (1.0);
00458                 
00459                 sep->addChild (errorBar);
00460             }
00461         }
00462         catch (cms::Exception& e)
00463         {
00464             if (this->m_onCmsException)
00465                 this->m_onCmsException (&e);
00466         }
00467         catch (lat::Error &e) 
00468         {
00469             if (this->m_onError)
00470                 this->m_onError (&e);
00471         }
00472         catch (std::exception &e) 
00473         {
00474             if (this->m_onException)
00475                 this->m_onException (&e);
00476         }
00477         catch (...) 
00478         {
00479             if (this->m_onUnhandledException)
00480                 this->m_onUnhandledException ();
00481         }
00482     }
00483     
00484     rep->clear ();
00485     rep->node ()->addChild (sep);
00486 }

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

Update object property description.

Reimplemented from VisQueuedTwig.

Definition at line 313 of file VisCSCRecHit2DTwig.cc.

References Ig3DBaseRep::clear(), e, exception, edm::ESHandle< T >::isValid(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_rechits, Ig3DBaseRep::node(), funct::sqrt(), GeomDet::surface(), Surface::toGlobal(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00314 {
00315 
00316     // Get debugging dump.
00317     VisQueuedTwig::update (rep);
00318 
00319     IgQtLock ();
00320 
00321     SoSeparator *sep = new SoSeparator;
00322     SoMaterial *mat = new SoMaterial;
00323     mat->ambientColor.setValue (0.135, 0.2225, 0.1575);
00324     mat->diffuseColor.setValue (0.54, 0.89, 0.63);
00325     mat->specularColor.setValue (0.316228, 0.316228, 0.316228);
00326     mat->emissiveColor.setValue(0.0, 0.0, 0.0);
00327     mat->shininess = 0.1;
00328     sep->addChild (mat);
00329     
00330     if (! m_rechits.empty () && m_pDD.isValid ())
00331     {
00332         try 
00333         {
00334             //
00335             // Muon Endcap Rechits
00336             // 
00337         
00338             for (std::vector<CSCRecHit2D>::const_iterator is = m_rechits.begin (), isEnd = m_rechits.end (); is != isEnd; ++is) 
00339             {
00340                 const GeomDetUnit *det = m_pDD->idToDetUnit ((*is).cscDetId ());
00341                 
00342 //              GlobalPoint pos = det->surface ().toGlobal ((*is).localPosition ());
00343             
00344 //              float x = pos.x () / 100.0;  // cm -> m
00345 //              float y = pos.y () / 100.0;  // cm -> m
00346 //              float z = pos.z () / 100.0;  // cm -> m
00347                 
00348                 LocalPoint xyzLocal = is->localPosition ();
00349                 float x = xyzLocal.x ();
00350                 float y = xyzLocal.y ();
00351                 float z = xyzLocal.z ();
00352                 float dx = std::sqrt( is->localPositionError ().xx () );
00353                 float dy = std::sqrt( is->localPositionError ().yy () );
00354                 
00355                 IgSo3DErrorBar *errorBar = new IgSo3DErrorBar;
00356                 GlobalPoint gp;
00357                 gp = det->surface ().toGlobal (LocalPoint (x - dx, y, z));
00358                 errorBar->u1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00359                 gp = det->surface ().toGlobal (LocalPoint (x + dx, y, z));
00360                 errorBar->u2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00361                 gp = det->surface ().toGlobal (LocalPoint (x, y - dy, z));
00362                 errorBar->v1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00363                 gp = det->surface ().toGlobal (LocalPoint (x, y + dy, z));
00364                 errorBar->v2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00365                 gp = det->surface ().toGlobal (xyzLocal); // no error in z
00366                 errorBar->w1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00367                 errorBar->w2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00368 
00369                 errorBar->lineWidth.setValue (1.0);
00370                 
00371                 sep->addChild (errorBar);
00372             }
00373         }
00374         catch (cms::Exception& e)
00375         {
00376             if (this->m_onCmsException)
00377                 this->m_onCmsException (&e);
00378         }
00379         catch (lat::Error &e) 
00380         {
00381             if (this->m_onError)
00382                 this->m_onError (&e);
00383         }
00384         catch (std::exception &e) 
00385         {
00386             if (this->m_onException)
00387                 this->m_onException (&e);
00388         }
00389         catch (...) 
00390         {
00391             if (this->m_onUnhandledException)
00392                 this->m_onUnhandledException ();
00393         }
00394     }
00395     
00396     rep->clear ();
00397     rep->node ()->addChild (sep);
00398 }

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

Update object property description.

Reimplemented from VisQueuedTwig.

Definition at line 153 of file VisCSCRecHit2DTwig.cc.

References e, exception, edm::ESHandle< T >::isValid(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_rechits, IgTextRep::setText(), GeomDet::surface(), Surface::toGlobal(), and VisQueuedTwig::update().

00154 {
00155     // Get debugging dump.
00156     VisQueuedTwig::update (rep);
00157 
00158     // Prepare the property description.
00159     std::ostringstream text;
00160     text << "Muon Endcap: CSC Rec Hits 2D<br>";
00161 
00162     text << "<table width='100%' border=1>"
00163          << "<TR align = center>"
00164          << "<TH>Number</TH>"
00165          << "<TH>position</TH>"
00166          << "<TH>Error Within Strip</TH>"
00167          << "</TR>";
00168     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00169     text.setf (std::ios::right,std::ios::adjustfield);
00170 
00171     if (! m_rechits.empty () && m_pDD.isValid ())
00172     {
00173         try 
00174         {
00175             int nRecHits = 0;
00176         
00177             for (std::vector<CSCRecHit2D>::const_iterator ihit = m_rechits.begin (), ihitEnd = m_rechits.end (); ihit != ihitEnd; ++ihit) 
00178             {
00179                 const GeomDetUnit *det = m_pDD->idToDetUnit ((*ihit).cscDetId ());
00180                 
00181                 GlobalPoint pos = det->surface ().toGlobal ((*ihit).localPosition ());
00182             
00183                 text << "<TR align = right>"
00184                      << "<TD>" << std::setw (2) << nRecHits++ << "</TD>"
00185                      << "<TD>" << std::setw (6) << std::setprecision (2) << pos << "</TD>"
00186                      << "<TD>" << std::setw (6) << std::setprecision (2) << (*ihit).errorWithinStrip () << "</TD>"
00187                      << "</TR>";    
00188             }
00189         }
00190         catch (cms::Exception& e)
00191         {
00192             if (this->m_onCmsException)
00193                 this->m_onCmsException (&e);
00194         }
00195         catch (lat::Error &e) 
00196         {
00197             if (this->m_onError)
00198                 this->m_onError (&e);
00199         }
00200         catch (std::exception &e) 
00201         {
00202             if (this->m_onException)
00203                 this->m_onException (&e);
00204         }
00205         catch (...) 
00206         {
00207             if (this->m_onUnhandledException)
00208                 this->m_onUnhandledException ();
00209         }
00210     }
00211     text << "</table>";
00212     
00213     // Send it over.
00214     IgQtLock ();
00215     rep->setText (text.str ());
00216 }

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

Update object property description.

Reimplemented from VisQueuedTwig.

Definition at line 308 of file VisCSCRecHit2DTwig.cc.

00309 {}

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

Update object property description.

Reimplemented from VisQueuedTwig.

Definition at line 220 of file VisCSCRecHit2DTwig.cc.

References Ig3DBaseRep::clear(), e, exception, edm::ESHandle< T >::isValid(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_rechits, Ig3DBaseRep::node(), funct::sqrt(), GeomDet::surface(), Surface::toGlobal(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, PV3DBase< T, PVType, FrameType >::z(), and z.

00221 {
00222     // Get debugging dump.
00223     VisQueuedTwig::update (rep);
00224 
00225     IgQtLock ();
00226 
00227     SoSeparator *sep = new SoSeparator;
00228     SoMaterial *mat = new SoMaterial;
00229     mat->ambientColor.setValue (0.135, 0.2225, 0.1575);
00230     mat->diffuseColor.setValue (0.54, 0.89, 0.63); // pale green
00231     mat->specularColor.setValue (0.316228, 0.316228, 0.316228);
00232     mat->emissiveColor.setValue(0.0, 0.0, 0.0);
00233     mat->shininess = 0.1;
00234     sep->addChild (mat);
00235     
00236     if (! m_rechits.empty () && m_pDD.isValid ())
00237     {
00238         try 
00239         {
00240             //
00241             // Muon Endcap Rechits
00242             // 
00243         
00244             for (std::vector<CSCRecHit2D>::const_iterator is = m_rechits.begin (), isEnd = m_rechits.end (); is != isEnd; ++is) 
00245             {
00246                 const GeomDetUnit *det = m_pDD->idToDetUnit ((*is).cscDetId ());
00247                 
00248 //              GlobalPoint pos = det->surface ().toGlobal ((*is).localPosition ());
00249             
00250 //              float x = pos.x () / 100.0;  // cm -> m
00251 //              float y = pos.y () / 100.0;  // cm -> m
00252 //              float z = pos.z () / 100.0;  // cm -> m
00253                 
00254                 LocalPoint xyzLocal = is->localPosition ();
00255                 float x = xyzLocal.x ();
00256                 float y = xyzLocal.y ();
00257                 float z = xyzLocal.z ();
00258                 float dx = std::sqrt( is->localPositionError ().xx () );
00259                 float dy = std::sqrt( is->localPositionError ().yy () );
00260                 
00261                 IgSo3DErrorBar *errorBar = new IgSo3DErrorBar;
00262                 GlobalPoint gp;
00263                 gp = det->surface ().toGlobal (LocalPoint (x - dx, y, z));
00264                 errorBar->u1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00265                 gp = det->surface ().toGlobal (LocalPoint (x + dx, y, z));
00266                 errorBar->u2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00267                 gp = det->surface ().toGlobal (LocalPoint (x, y - dy, z));
00268                 errorBar->v1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00269                 gp = det->surface ().toGlobal (LocalPoint (x, y + dy, z));
00270                 errorBar->v2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00271                 gp = det->surface ().toGlobal (xyzLocal); // no error in z
00272                 errorBar->w1.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00273                 errorBar->w2.setValue (gp.x () / 100.0, gp.y () / 100.0, gp.z () / 100.0);
00274 
00275                 errorBar->lineWidth.setValue (1.0);
00276                 
00277                 sep->addChild (errorBar);
00278             }
00279         }
00280         catch (cms::Exception& e)
00281         {
00282             if (this->m_onCmsException)
00283                 this->m_onCmsException (&e);
00284         }
00285         catch (lat::Error &e) 
00286         {
00287             if (this->m_onError)
00288                 this->m_onError (&e);
00289         }
00290         catch (std::exception &e) 
00291         {
00292             if (this->m_onException)
00293                 this->m_onException (&e);
00294         }
00295         catch (...) 
00296         {
00297             if (this->m_onUnhandledException)
00298                 this->m_onUnhandledException ();
00299         }
00300     }
00301     
00302     rep->clear ();
00303     rep->node ()->addChild (sep);
00304 }


Member Data Documentation

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

Definition at line 45 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent().

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

Definition at line 47 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent().

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

Definition at line 46 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent().

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

Definition at line 50 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent(), and update().

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

Definition at line 48 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent().

std::vector<CSCRecHit2D> VisCSCRecHit2DTwig::m_rechits [private]

Definition at line 49 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent(), and update().

std::string VisCSCRecHit2DTwig::m_text [private]

Definition at line 44 of file VisCSCRecHit2DTwig.h.

Referenced by onNewEvent().


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