CMS 3D CMS Logo

VisPixelDigiTwig Class Reference

#include <VisReco/VisTracker/interface/VisPixelDigiTwig.h>

Inheritance diagram for VisPixelDigiTwig:

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)
virtual void update (IgRPhiRep *rep)
virtual void update (IgTextRep *rep)
virtual void update (IgLegoRep *rep)
virtual void update (Ig3DRep *rep)
 VisPixelDigiTwig (IgState *state, IgTwig *parent, const std::string &name="", unsigned int detType=0, unsigned int subDetType=0)

Private Attributes

SoCube * cubedigi
SoTransform * digiTransform
unsigned int m_detType
std::vector< std::pair< DetId,
PixelDigi > > 
m_digis
edm::ESHandle< TrackerGeometrym_pDD
unsigned int m_subDetType
std::string m_text
SoSeparator * sepcube
SoSeparator * sepmodule
const PixelGeomDetUnittheDet
float theNumOfCol
float theNumOfRow
float theOffsetX
float theOffsetY
float thePitchX
float thePitchY
const RectangularPixelTopologytheTopol


Detailed Description

Definition at line 28 of file VisPixelDigiTwig.h.


Constructor & Destructor Documentation

VisPixelDigiTwig::VisPixelDigiTwig ( IgState state,
IgTwig parent,
const std::string &  name = "",
unsigned int  detType = 0,
unsigned int  subDetType = 0 
)

Definition at line 41 of file VisPixelDigiTwig.cc.

00044     : VisQueuedTwig (state, parent, name),
00045       m_text ("no info"),
00046       m_detType (detType),
00047       m_subDetType (subDetType)
00048 {
00049 }


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 52 of file VisPixelDigiTwig.cc.

References cms::Exception::append(), arg, detId, reco_application_tbsim_simpleTBanalysis_cfg::digiCollection, e, exception, edm::EventSetup::get(), edm::Event::id(), IgRepSet::invalidate(), edm::Handle< T >::isValid(), m_digis, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_text, VisQueuedTwig::onNewEvent(), p, and IgTwig::SELF_MASK.

00054 {
00055     // Get debugging dump.
00056     VisQueuedTwig::onNewEvent (event, eventSetup);
00057 
00058     m_digis.clear ();
00059     m_text = (QString ("Run # %1, event # %2")
00060               .arg (event.id ().run ())
00061               .arg (event.id ().event ()).latin1 ());
00062 
00063     edm::Handle<PixelDigiCollection> digiCollection;
00064     
00065     try
00066     {
00067         event.getByLabel ("pixdigi", digiCollection);
00068         eventSetup.get<TrackerDigiGeometryRecord> ().get (m_pDD);
00069     }
00070     catch (cms::Exception& e)
00071     {
00072         e.append (" from VisPixelDigiTwig: ");
00073         e.append (this->name ());
00074             
00075         if (this->m_onCmsException)
00076             this->m_onCmsException (&e);
00077     }
00078     catch (lat::Error &e) 
00079     {
00080         if (this->m_onError)
00081             this->m_onError (&e);
00082     }
00083     catch (std::exception &e) 
00084     {
00085         if (this->m_onException)
00086             this->m_onException (&e);
00087     }
00088     catch (...) 
00089     {
00090         if (this->m_onUnhandledException)
00091             this->m_onUnhandledException ();
00092     }
00093 
00094     if (digiCollection.isValid ())
00095     {
00096         // Get vector of detIDs in map
00097         const std::vector<unsigned int> detIDs = digiCollection->detIDs ();
00098 
00099         //--- Loop over detunits.
00100         std::vector<unsigned int>::const_iterator detunit_it;
00101         for (detunit_it  = detIDs.begin (); detunit_it != detIDs.end (); 
00102              detunit_it++) 
00103         {
00104             unsigned int detid = *detunit_it;   // return uint, = rawid
00105 
00106             // Det id
00107             DetId detId = DetId (detid);            // Get the Detid
00108 //          unsigned int detType = detId.det ();    // det type, pixel=1
00109 //          unsigned int subid = detId.subdetId (); //subdetector type, barrel=1
00110      
00111 //          if (detType != m_detType) continue; // look only at pixels
00112             
00113 //          // Subdet it, pix barrel=1
00114 //          if (subid != m_subDetType)
00115 //          {
00116 //              //if (PRINT && subid == 2) cout << " forward hit " << endl;
00117 //              continue; // look only at barrel
00118 //          }
00119 
00120             // Look at digis now
00121             const PixelDigiCollection::Range digiRange = digiCollection->get (detid);
00122             PixelDigiCollection::ContainerIterator di;
00123             // Loop over Digis in this det unit
00124             for (di = digiRange.first; di != digiRange.second; ++di) 
00125             { 
00126 //              int adc = di->adc();    // charge
00127 //              int col = di->column(); // column 
00128 //              int row = di->row();    // row
00129                 //cout <<numberOfDigis<< " Col: " << col << " Row: " << row << " ADC: " 
00130                 //   << adc << endl;
00131 
00132                 std::pair<DetId, PixelDigi> p;
00133                 p.first = detId;
00134                 p.second = (*di);
00135                 //              (*digiIt).print ();
00136 
00137                 m_digis.push_back (p);
00138             } // for digis 
00139         } // for DetId
00140     }
00141     
00142     IgRepSet::invalidate (this, SELF_MASK);
00143 }

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

Reimplemented from VisQueuedTwig.

Definition at line 392 of file VisPixelDigiTwig.cc.

References Ig3DBaseRep::clear(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, m_digis, 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.

00393 {
00394     // Get debugging dump.
00395     VisQueuedTwig::update (rep);
00396 
00397     IgQtLock ();
00398     rep->clear ();
00399 
00400     if (! m_digis.empty ()) 
00401     {
00402         SoSeparator *sep = new SoSeparator;    
00403         SoMaterial *mat = new SoMaterial;
00404         mat->diffuseColor.setValue (0.3, 0.8, 0.0);
00405         sep->addChild (mat);
00406 
00407         SoDrawStyle *drawStyle = new SoDrawStyle;
00408         drawStyle->pointSize = 3.0;
00409         sep->addChild (drawStyle);
00410     
00411         try 
00412         {
00413             SoVertexProperty *vertices = new SoVertexProperty;
00414             int nVrx = 0;
00415 
00416             for (std::vector<std::pair<DetId, PixelDigi> >::const_iterator i = m_digis.begin (); i != m_digis.end (); ++i) 
00417             {
00418                 Surface::GlobalPoint pos =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00419 //              int strip = (*i).second.getStrip ();
00420 //              std::vector<int> adcCounts = (*i).second.getADCCounts ();
00421             
00422                 float x = pos.x () / 100.0;  // cm -> m
00423                 float y = pos.y () / 100.0;  // cm -> m
00424                 float z = pos.z () / 100.0;  // cm -> m
00425                 
00426                 vertices->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00427             }
00428             vertices->vertex.setNum (m_digis.size ());
00429 
00430             SoPointSet *points = new SoPointSet;
00431             points->vertexProperty.setValue (vertices);
00432             points->numPoints.setValue (m_digis.size ());
00433             sep->addChild (points);
00434         }    
00435         catch (...) 
00436         {
00437             std::cout << "No PixelDigi Digis." << std::endl;
00438         }
00439     
00440         rep->node ()->addChild (sep);
00441     }
00442 }

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

Reimplemented from VisQueuedTwig.

Definition at line 339 of file VisPixelDigiTwig.cc.

References Ig3DBaseRep::clear(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, m_digis, m_pDD, Ig3DBaseRep::node(), VisQueuedTwig::update(), PV3DBase< T, PVType, FrameType >::x(), x, PV3DBase< T, PVType, FrameType >::y(), y, and z.

00340 {
00341     // Get debugging dump.
00342     VisQueuedTwig::update (rep);
00343 
00344     IgQtLock ();
00345     rep->clear ();
00346     
00347     if (! m_digis.empty ()) 
00348     {
00349         SoSeparator *sep = new SoSeparator;    
00350 
00351         SoMaterial *mat = new SoMaterial;
00352         mat->diffuseColor.setValue (0.0, 0.0, 1.0);
00353         sep->addChild (mat);
00354 
00355         SoDrawStyle *drawStyle = new SoDrawStyle;
00356         drawStyle->pointSize = 6.0;
00357         sep->addChild (drawStyle);
00358 
00359         try 
00360         {
00361             SoVertexProperty *vertices = new SoVertexProperty;
00362             int nVrtx = 0;
00363             for (std::vector<std::pair<DetId, PixelDigi> >::const_iterator 
00364                      i = m_digis.begin (); i != m_digis.end (); ++i)
00365             {
00366                 const DetId& id = (*i).first;
00367 
00368                 Surface::GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().position ();
00369                 float x = pos.x () / 100.0;  // cm -> m
00370                 float y = pos.y () / 100.0;  // cm -> m
00371                 float z = 10.0;  // cm -> m
00372                 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00373             }
00374             
00375             vertices->vertex.setNum (nVrtx);
00376             SoPointSet *points = new SoPointSet;
00377             points->vertexProperty.setValue (vertices);
00378             points->numPoints.setValue (nVrtx);
00379 
00380             sep->addChild (points);
00381         }
00382         catch (...) 
00383         {
00384             std::cout << "No PixelDigi Digis." << std::endl;
00385         }
00386     
00387         rep->node ()->addChild (sep);
00388     }
00389 }

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

Reimplemented from VisQueuedTwig.

Definition at line 146 of file VisPixelDigiTwig.cc.

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

00147 {
00148     // Get debugging dump.
00149     VisQueuedTwig::update (rep);
00150 
00151     // Prepare property description.
00152     std::ostringstream  text;
00153     text << "Total " << m_digis.size () << " Pixel digis from";
00154     text << " Cosmic run: " << m_text << "<br>";
00155 
00156     text << "<table width='100%' border=1>"
00157          << "<TR align = center>"
00158          << "<TH>Number</TH>"
00159          << "<TH>Position</TH>"
00160          << "<TH>Charge</TH>"
00161          << "<TH>Column</TH>"
00162          << "<TH>Row</TH>"
00163          << "</TR>";
00164     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00165     text.setf (std::ios::right, std::ios::adjustfield);
00166 
00167     if ((! m_digis.empty ()) && m_pDD.isValid ()) 
00168     {
00169     
00170     int nDigis = 0;
00171     try 
00172     {
00173         for (std::vector<std::pair<DetId, PixelDigi> >::const_iterator i = m_digis.begin (); i != m_digis.end (); ++i) 
00174         {
00175             Surface::GlobalPoint pos =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00176             text << "<TR align = right>"
00177                  << "<TD>" << std::setw (3) << nDigis++ << "</TD>"
00178                  << "<TD>" << pos.x () << ", " << pos.y () << ", " << pos.z () << "</TD>"
00179                  << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.adc () << "</TD>"
00180                  << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.column () << "</TD>"
00181                  << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.row () << "</TD></TR>";
00182         }
00183     }
00184     catch (...)
00185     {
00186         text << "No Pixel digis.<br>";
00187     }
00188     text << "</table>";
00189     }
00190     
00191     // Send it over.
00192     IgQtLock ();
00193     rep->setText (text.str ());
00194 }

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

Reimplemented from VisQueuedTwig.

Definition at line 301 of file VisPixelDigiTwig.cc.

References Ig3DBaseRep::clear(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), IgSoTower::energy, eta, PV3DBase< T, PVType, FrameType >::eta(), i, m_digis, m_pDD, Ig3DBaseRep::node(), PV3DBase< T, PVType, FrameType >::phi(), phi, IgSoTower::position, IgSoTower::scaleFactor, and VisQueuedTwig::update().

00302 {
00303     // Get debugging dump.
00304     VisQueuedTwig::update (rep);
00305 
00306     IgQtLock ();
00307     rep->clear ();
00308     
00309     SoSeparator *sep = new SoSeparator; // global
00310     
00311     try 
00312     {
00313         for (std::vector<std::pair<DetId, PixelDigi> >::const_iterator i = m_digis.begin (); i != m_digis.end (); ++i) 
00314         {
00315             Surface::GlobalPoint pos =  (m_pDD->idToDet ((*i).first))->surface ().position ();
00316             double eta = pos.eta ();
00317             double phi = pos.phi ();
00318             if (phi < 0.0) phi = 2 * M_PI + phi; // correction in absence of one convention
00319 
00320             // int strip = (*i).second.getStrip ();
00321             int adcCounts = (*i).second.adc ();
00322 
00323             IgSoTower *tower = new IgSoTower;
00324             tower->position = SbVec2f (phi, eta); // eta, phi
00325             tower->scaleFactor = 20.0;
00326             tower->energy = adcCounts;
00327             sep->addChild (tower);
00328         }
00329     }
00330     catch (...) 
00331     {
00332         std::cout << "No PixelDigi Digis." << std::endl;
00333     }
00334     
00335     rep->node ()->addChild (sep);
00336 }

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

Reimplemented from VisQueuedTwig.

Definition at line 197 of file VisPixelDigiTwig.cc.

References PixelDigi::adc(), Ig3DBaseRep::clear(), PixelDigi::column(), GenMuonPlsPt100GeV_cfg::cout, cubedigi, digiTransform, lat::endl(), i, m_digis, m_pDD, RectangularPixelTopology::measurementPosition(), RectangularPixelTopology::ncolumns(), Ig3DBaseRep::node(), RectangularPixelTopology::nrows(), offset, p, RectangularPixelTopology::pitch(), PixelDigi::row(), sepcube, sepmodule, PixelGeomDetUnit::specificTopology(), theDet, theNumOfCol, theNumOfRow, theOffsetX, theOffsetY, thePitchX, thePitchY, theTopol, VisQueuedTwig::update(), PV2DBase< T, PVType, FrameType >::x(), x, PV2DBase< T, PVType, FrameType >::y(), y, and z.

00198 {
00199     // Get debugging dump.
00200     VisQueuedTwig::update (rep);
00201     IgQtLock ();
00202     rep->clear ();
00203   
00204     if (! m_digis.empty ())
00205     {
00206         SoMaterial *mat = new SoMaterial;
00207         mat->diffuseColor.setValue (0.0, 0.0, 1.0);
00208         mat->emissiveColor.setValue(0.0, 0.0, 1.0);
00209 
00210         SoMaterial *matcube = new SoMaterial;
00211         matcube->diffuseColor.setValue (0.0, 1.0, 1.0);
00212         matcube->emissiveColor.setValue(0.0, 1.0, 1.0);
00213 
00214         SoDrawStyle *drawStyle = new SoDrawStyle;
00215         drawStyle->pointSize = 6.0;
00216 
00217         SoSeparator *sep = new SoSeparator; // global
00218         sep->addChild (mat);
00219         sep->addChild (drawStyle);
00220 
00221         try 
00222         {
00223             SoVertexProperty *vertices = new SoVertexProperty;
00224             int nVrtx = 0;
00225             for (std::vector<std::pair<DetId, PixelDigi> >::const_iterator 
00226                      i = m_digis.begin (); i != m_digis.end (); ++i)
00227             {
00228                 sepmodule = new SoSeparator;
00229                 sepmodule->addChild (mat);
00230 
00231                 sepcube = new SoSeparator;
00232                 sepcube->addChild (matcube);
00233 
00234                 cubedigi = new SoCube ();
00235 
00236                 const DetId& id = (*i).first;
00237                 const GeomDetUnit *det = m_pDD->idToDetUnit (id);
00238 
00239                 theDet = dynamic_cast<const PixelGeomDetUnit*> (m_pDD->idToDet (id));
00240 
00241                 theTopol = dynamic_cast<const RectangularPixelTopology *>( &(theDet->specificTopology ()));
00242                 const PixelDigi pd = (*i).second;
00243                 theNumOfRow = theTopol->nrows ();      // rows in x
00244                 theNumOfCol = theTopol->ncolumns ();   // cols in y
00245                 std::pair<float, float> pitchxy = theTopol->pitch ();
00246                 thePitchX = pitchxy.first;            // pitch along x
00247                 thePitchY = pitchxy.second;           // pitch along y
00248 
00249                 cubedigi->width = 1./theNumOfRow;
00250                 cubedigi->height =1./theNumOfCol;
00251                 cubedigi->depth =(pd.adc())/10. ;
00252 
00253                 //--- Find the offset
00254                 MeasurementPoint  offset =
00255                   theTopol->measurementPosition( LocalPoint(0., 0.) );
00256                 theOffsetX = offset.x();
00257                 theOffsetY = offset.y();
00258 
00259                 float xlocal = (pd.row()*thePitchX + theOffsetX)/100.0 ;
00260                 float ylocal = (pd.column()*thePitchY + theOffsetY)/100.0 ;
00261                 LocalPoint p = LocalPoint(xlocal, ylocal);
00262 
00263                 //Surface::GlobalPoint pos =  (m_pDD->idToDet (id))->surface ().position ();
00264                 //float x = pos.x () / 100.0;  // cm -> m
00265                 //float y = pos.y () / 100.0;  // cm -> m
00266                 //float z = pos.z () / 100.0;  // cm -> m
00267 
00268                 float x = (m_pDD->idToDet (id))->surface().toGlobal(p).x() / 100.0;  // cm -> m
00269                 float y = (m_pDD->idToDet (id))->surface().toGlobal(p).y() / 100.0;  // cm -> m
00270                 float z = (m_pDD->idToDet (id))->surface().toGlobal(p).z() / 100.0;  // cm -> m
00271 
00272                 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00273 
00274                 digiTransform = new SoTransform;
00275                 digiTransform->translation.setValue (xlocal/(thePitchX*theNumOfRow), ylocal/(thePitchY*theNumOfCol),pd.adc()/20. );
00276                 sepcube->addChild (digiTransform);
00277                 sepcube->addChild (cubedigi);
00278 
00279                 sepmodule->addChild (sepcube);
00280 
00281                 rep->node ()->addChild (sepmodule);
00282             }
00283             
00284             vertices->vertex.setNum (nVrtx);
00285             SoPointSet *points = new SoPointSet;
00286             points->vertexProperty.setValue (vertices);
00287             points->numPoints.setValue (nVrtx);
00288 
00289             sep->addChild (points);
00290         }
00291         catch (...) 
00292         {
00293             std::cout << "No PixelDigi Digis." << std::endl;
00294         }
00295     
00296         rep->node ()->addChild (sep);
00297     }
00298 }


Member Data Documentation

SoCube* VisPixelDigiTwig::cubedigi [private]

Definition at line 61 of file VisPixelDigiTwig.h.

Referenced by update().

SoTransform* VisPixelDigiTwig::digiTransform [private]

Definition at line 62 of file VisPixelDigiTwig.h.

Referenced by update().

unsigned int VisPixelDigiTwig::m_detType [private]

Definition at line 49 of file VisPixelDigiTwig.h.

std::vector<std::pair<DetId, PixelDigi> > VisPixelDigiTwig::m_digis [private]

Definition at line 47 of file VisPixelDigiTwig.h.

Referenced by onNewEvent(), and update().

edm::ESHandle<TrackerGeometry> VisPixelDigiTwig::m_pDD [private]

Definition at line 48 of file VisPixelDigiTwig.h.

Referenced by onNewEvent(), and update().

unsigned int VisPixelDigiTwig::m_subDetType [private]

Definition at line 50 of file VisPixelDigiTwig.h.

std::string VisPixelDigiTwig::m_text [private]

Definition at line 46 of file VisPixelDigiTwig.h.

Referenced by onNewEvent(), and update().

SoSeparator* VisPixelDigiTwig::sepcube [private]

Definition at line 60 of file VisPixelDigiTwig.h.

Referenced by update().

SoSeparator* VisPixelDigiTwig::sepmodule [private]

Definition at line 59 of file VisPixelDigiTwig.h.

Referenced by update().

const PixelGeomDetUnit* VisPixelDigiTwig::theDet [private]

Definition at line 51 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::theNumOfCol [private]

Definition at line 56 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::theNumOfRow [private]

Definition at line 55 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::theOffsetX [private]

Definition at line 57 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::theOffsetY [private]

Definition at line 58 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::thePitchX [private]

Definition at line 53 of file VisPixelDigiTwig.h.

Referenced by update().

float VisPixelDigiTwig::thePitchY [private]

Definition at line 54 of file VisPixelDigiTwig.h.

Referenced by update().

const RectangularPixelTopology* VisPixelDigiTwig::theTopol [private]

Definition at line 52 of file VisPixelDigiTwig.h.

Referenced by update().


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