CMS 3D CMS Logo

VisTrackingParticleTwig Class Reference

#include <VisReco/VisPF/interface/VisTrackingParticleTwig.h>

Inheritance diagram for VisTrackingParticleTwig:

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)
 VisTrackingParticleTwig (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
const std::string m_name
const std::string m_processName
std::string m_text
std::vector< std::pair
< TrackingParticle, SbVec3f > > 
m_tracks


Detailed Description

Definition at line 18 of file VisTrackingParticleTwig.h.


Constructor & Destructor Documentation

VisTrackingParticleTwig::VisTrackingParticleTwig ( 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 47 of file VisTrackingParticleTwig.cc.

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

00053     : VisQueuedTwig(state, parent, name), 
00054       m_text("No Info"),
00055       m_name(name),
00056       m_friendlyName(friendlyName),
00057       m_moduleLabel(moduleLabel),
00058       m_instanceName(instanceName),
00059       m_processName(processName)
00060 {
00061     VisTwigFactroyService *tfService = VisTwigFactroyService::get(state);
00062     
00063     if (! tfService)
00064     {
00065         tfService = new VisTwigFactroyService(state);
00066     }
00067         
00068     edm::TypeID pfTracksID(typeid(TrackingParticleCollection));
00069     
00070     tfService->registerTwig(pfTracksID.friendlyClassName(), &createThisTwig);
00071 }


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 73 of file VisTrackingParticleTwig.cc.

References c, e, exception, i, m_friendlyName, m_instanceName, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_processName, m_tracks, VisQueuedTwig::onBaseInvalidate(), VisQueuedTwig::onNewEvent(), p, x, y, and z.

00075 {
00076     VisQueuedTwig::onNewEvent(event, eventSetup);
00077 
00078     std::vector<edm::Handle<TrackingParticleCollection> > trackCollections;
00079     //std::vector<edm::Handle<TrackingVertexCollection> > vertexCollections;
00080 
00081     m_tracks.clear();
00082     
00083     try
00084     {
00085         if ( (! m_friendlyName.empty ()) || 
00086              (! m_moduleLabel.empty ())  || 
00087              (! m_instanceName.empty ()) || 
00088              (! m_processName.empty ()) )
00089         {
00090             VisEventSelector visSel(m_friendlyName, m_moduleLabel, 
00091                                     m_instanceName, m_processName);
00092             
00093             event.getMany(visSel, trackCollections);
00094         }
00095 
00096         else
00097         {
00098             event.getManyByType(trackCollections);
00099         }
00100 
00101         //event.getManyByType(vertexCollections);
00102     }
00103     
00104     catch (cms::Exception& e)
00105     {
00106         if (this->m_onCmsException)
00107             this->m_onCmsException(&e);
00108     }
00109 
00110     catch (lat::Error &e) 
00111     {
00112         if (this->m_onError)
00113             this->m_onError(&e);
00114     }
00115 
00116     catch (std::exception &e) 
00117     {
00118         if (this->m_onException)
00119             this->m_onException(&e);
00120     }
00121 
00122     catch (...) 
00123     {
00124         if (this->m_onUnhandledException)
00125             this->m_onUnhandledException();
00126     }
00127     
00128     if (! trackCollections.empty())
00129     {
00130         for ( std::vector<edm::Handle<TrackingParticleCollection> >::iterator i = trackCollections.begin();
00131               i != trackCollections.end(); ++i )
00132         {
00133             const TrackingParticleCollection& c = *(*i);
00134             
00135             for ( std::vector<TrackingParticle>::const_iterator itp = c.begin();
00136                   itp != c.end(); ++itp )
00137             {
00138                 double x = (*itp).parentVertex()->position().x()/100.0;
00139                 double y = (*itp).parentVertex()->position().y()/100.0;
00140                 double z = (*itp).parentVertex()->position().z()/100.0;
00141 
00142                 if ( (*itp).pt() > 1.0 )
00143                 {
00144                     std::pair<TrackingParticle, SbVec3f> p((*itp), SbVec3f(x,y,z));
00145                     m_tracks.push_back(p);
00146                 }
00147             }
00148         } 
00149     }
00150 
00151     //std::cout<<"DEBUG: "<< m_tracks.size() <<" TrackingParticles"<<std::endl;
00152     
00153 
00154     /*
00155     if (! vertexCollections.empty ())
00156     {
00157         for (std::vector<edm::Handle<TrackingVertexCollection> >::iterator i = vertexCollections.begin (); 
00158              i != vertexCollections.end (); ++i) 
00159         {
00160             const TrackingVertexCollection& c = *(*i);
00161 
00162             for (std::vector<TrackingVertex>::const_iterator itv = c.begin();
00163                  itv != c.end(); ++itv)
00164             {
00165                 m_vertices.push_back((*itv));
00166             }    
00167         }
00168     }
00169     */
00170     VisQueuedTwig::onBaseInvalidate();
00171 }

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

Reimplemented from VisQueuedTwig.

Definition at line 506 of file VisTrackingParticleTwig.cc.

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

00507 {
00508     VisQueuedTwig::update(rep);
00509 
00510     IgQtLock();
00511     rep->clear();
00512 }

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

Reimplemented from VisQueuedTwig.

Definition at line 375 of file VisTrackingParticleTwig.cc.

References Ig3DBaseRep::clear(), IgSoSimpleTrajectory::controlPoints, e, exception, IgParticleChar::getByName(), i, IgSoIdealTrack::initialise(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_tracks, IgSoSimpleTrajectory::markerPoints, Ig3DBaseRep::node(), funct::sqrt(), track, VisQueuedTwig::update(), x, y, and z.

00376 {
00377     VisQueuedTwig::update (rep);
00378 
00379     IgQtLock ();
00380     rep->clear ();
00381 
00382     if ( ! m_tracks.empty () ) 
00383     {
00384         SoSeparator *sep = new SoSeparator;
00385         
00386         try 
00387         {
00388             std::vector<std::pair<TrackingParticle, SbVec3f> >::const_iterator i;
00389 
00390             for ( i = m_tracks.begin(); i != m_tracks.end(); ++i ) 
00391             {
00392                   
00393                 IgSoIdealTrack *kit = new IgSoIdealTrack;
00394                             
00395                 float pt = i->first.pt();
00396                 
00397                 double x0 = (i->second)[0];
00398                 double y0 = (i->second)[1];
00399                 double z0 = (i->second)[2];
00400                 
00401                 double px = i->first.px();
00402                 double py = i->first.py();
00403                 double pz = i->first.pz();
00404                 
00405                 switch (i->first.pdgId())
00406                 {       
00407                 case 11:
00408                     kit->initialise (x0, y0, z0, px, py, pz, 
00409                                      0.0, IgParticleChar::getByName ("electron"));
00410                     sep->addChild (kit);
00411                     break;
00412                 
00413                 case -11:
00414                     kit->initialise (x0, y0, z0, px, py, pz, 
00415                                      0.0, IgParticleChar::getByName ("positron"));
00416                     sep->addChild (kit);
00417                     break;
00418         
00419                 case 211:
00420                     kit->initialise(x0, y0, z0, px, py, pz, 
00421                                     0.0, IgParticleChar::getByName ("antipion"));
00422                     sep->addChild(kit);
00423                     break;
00424                 case -211:
00425                     kit->initialise(x0, y0, z0, px, py, pz, 
00426                                     0.0, IgParticleChar::getByName ("pion"));               
00427                     sep->addChild (kit);
00428                     break;
00429 
00430                 case 22:
00431                     {
00432                         SoSeparator *gammas = new SoSeparator;
00433                         SoMaterial *gammaMaterial = new SoMaterial;
00434                         gammaMaterial->ambientColor.setValue (0.000, 0.000, 0.000); 
00435                         gammaMaterial->diffuseColor.setValue (1.000, 1.000, 0.000);  
00436                         gammaMaterial->emissiveColor.setValue (1.000, 1.000, 0.000); 
00437                         gammaMaterial->specularColor.setValue (0.000, 0.000, 0.000); 
00438                         gammaMaterial->shininess = 0.0;
00439                         gammaMaterial->transparency = 0.0;
00440                         gammas->addChild (gammaMaterial);
00441                          
00442                         IgSoSimpleTrajectory *track = new IgSoSimpleTrajectory;
00443                         
00444                         track->controlPoints.set1Value (0, SbVec3f (x0, y0, z0));
00445                         track->markerPoints.set1Value (0, SbVec3f (x0, y0, z0));
00446                         
00447                         double x = x0;
00448                         double y = y0;
00449                         double z = z0;
00450                         
00451                         do 
00452                         {
00453                             x += 0.1*px;
00454                             y += 0.1*py;
00455                             z += 0.1*pz;
00456                         }
00457                         while ( sqrt(x*x+y*y) < 1.24 && fabs(z) < 3.14 );
00458                         
00459         
00460                         SbVec3f pos = SbVec3f(x,y,z);
00461                         
00462                         track->controlPoints.set1Value (1, pos);
00463                         track->markerPoints.set1Value (1, pos);
00464                         gammas->addChild (track);
00465                           
00466                         sep->addChild (gammas);
00467                           
00468                         break;
00469         
00470                     }
00471                    
00472                     
00473                 default:
00474                     break;
00475                 }                   
00476             }
00477         }
00478 
00479         catch (cms::Exception& e)
00480         {
00481             if (this->m_onCmsException)
00482                 this->m_onCmsException (&e);
00483         }
00484         catch (lat::Error &e) 
00485         {
00486             if (this->m_onError)
00487                 this->m_onError (&e);
00488         }
00489         catch (std::exception &e) 
00490         {
00491             if (this->m_onException)
00492                 this->m_onException (&e);
00493         }
00494         catch (...) 
00495         {
00496             if (this->m_onUnhandledException)
00497                 this->m_onUnhandledException ();
00498         }
00499 
00500         rep->node ()->addChild (sep);
00501     }
00502         
00503 
00504 }

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

Reimplemented from VisQueuedTwig.

Definition at line 313 of file VisTrackingParticleTwig.cc.

References e, exception, i, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_tracks, IgTextRep::setText(), and VisQueuedTwig::update().

00314 {
00315     VisQueuedTwig::update(rep);
00316 
00317     std::ostringstream  text;
00318     text<< m_tracks.size() <<" TrackingParticles";
00319     
00320     text << "<table width='100%' border=1>"
00321          << "<TR align = center>"
00322          << "<TH>Number</TH>"
00323          << "<TH>P<SUB>T</TH>"
00324          << "<TH>PDG Code</TH>"
00325          << "</TR>";
00326 
00327     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00328     text.setf (std::ios::right, std::ios::adjustfield);
00329 
00330     if (! m_tracks.empty()) 
00331     {
00332         int nTracks = 0;
00333         
00334         try 
00335         {
00336             std::vector<std::pair<TrackingParticle, SbVec3f> >::const_iterator i;
00337             
00338             for ( i = m_tracks.begin(); i != m_tracks.end(); ++i ) 
00339             {
00340                 text << "<TR align = right>"
00341                      << "<TD>" << std::setw (3) << nTracks++ << "</TD>"
00342                      << "<TD>" << std::setw (3) << i->first.pt() << "</TD>"
00343                      << "<TD>" << std::setw (3) << i->first.pdgId() << "</TD></TR>";
00344                 
00345             }
00346         }
00347         catch (cms::Exception& e)
00348         {
00349             if (this->m_onCmsException)
00350                 this->m_onCmsException (&e);
00351         }
00352         catch (lat::Error &e) 
00353         {
00354             if (this->m_onError)
00355                 this->m_onError (&e);
00356         }
00357         catch (std::exception &e) 
00358         {
00359             if (this->m_onException)
00360                 this->m_onException (&e);
00361         }
00362         catch (...) 
00363         {
00364             if (this->m_onUnhandledException)
00365                 this->m_onUnhandledException ();
00366         }
00367     }
00368     text << "</table>";
00369 
00370 
00371     IgQtLock();
00372     rep->setText(text.str());
00373 }

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

Reimplemented from VisQueuedTwig.

Definition at line 308 of file VisTrackingParticleTwig.cc.

References VisQueuedTwig::update().

00309 {
00310      VisQueuedTwig::update(rep);
00311 }

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

Reimplemented from VisQueuedTwig.

Definition at line 173 of file VisTrackingParticleTwig.cc.

References Ig3DBaseRep::clear(), IgSoSimpleTrajectory::controlPoints, e, exception, IgParticleChar::getByName(), i, IgSoIdealTrack::initialise(), VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_tracks, IgSoSimpleTrajectory::markerPoints, Ig3DBaseRep::node(), funct::sqrt(), track, VisQueuedTwig::update(), x, y, and z.

00174 {
00175     VisQueuedTwig::update(rep);
00176     IgQtLock();
00177     rep->clear();
00178 
00179     if ( ! m_tracks.empty () ) 
00180     {
00181         SoSeparator *sep = new SoSeparator;
00182         
00183         try 
00184         {
00185             std::vector<std::pair<TrackingParticle, SbVec3f> >::const_iterator i;
00186 
00187             for ( i = m_tracks.begin(); i != m_tracks.end(); ++i ) 
00188             {
00189                 
00190                 /*
00191                   Core dump when I try to get parentVertex() from TrackingParticle
00192                 double x0 = (*i).parentVertex()->position().x () / 100.0;
00193                 double y0 = (*i).parentVertex()->position().y () / 100.0;
00194                 double z0 = (*i).parentVertex()->position().z () / 100.0;
00195                 */
00196           
00197                 IgSoIdealTrack *kit = new IgSoIdealTrack;
00198                             
00199                 float pt = i->first.pt();
00200                 
00201                 double x0 = (i->second)[0];
00202                 double y0 = (i->second)[1];
00203                 double z0 = (i->second)[2];
00204                 
00205                 double px = i->first.px();
00206                 double py = i->first.py();
00207                 double pz = i->first.pz();
00208                 
00209                 switch (i->first.pdgId())
00210                 {       
00211                 case 11:
00212                     kit->initialise (x0, y0, z0, px, py, pz, 
00213                                      0.0, IgParticleChar::getByName ("electron"));
00214                     sep->addChild (kit);
00215                     break;
00216                 
00217                 case -11:
00218                     kit->initialise (x0, y0, z0, px, py, pz, 
00219                                      0.0, IgParticleChar::getByName ("positron"));
00220                     sep->addChild (kit);
00221                     break;
00222         
00223                 case 211:
00224                     kit->initialise(x0, y0, z0, px, py, pz, 
00225                                     0.0, IgParticleChar::getByName ("antipion"));
00226                     sep->addChild(kit);
00227                     break;
00228                 case -211:
00229                     kit->initialise(x0, y0, z0, px, py, pz, 
00230                                     0.0, IgParticleChar::getByName ("pion"));               
00231                     sep->addChild (kit);
00232                     break;
00233 
00234                 case 22:
00235                     {
00236                         SoSeparator *gammas = new SoSeparator;
00237                         SoMaterial *gammaMaterial = new SoMaterial;
00238                         gammaMaterial->ambientColor.setValue (0.000, 0.000, 0.000); 
00239                         gammaMaterial->diffuseColor.setValue (1.000, 1.000, 0.000);  
00240                         gammaMaterial->emissiveColor.setValue (1.000, 1.000, 0.000); 
00241                         gammaMaterial->specularColor.setValue (0.000, 0.000, 0.000); 
00242                         gammaMaterial->shininess = 0.0;
00243                         gammaMaterial->transparency = 0.0;
00244                         gammas->addChild (gammaMaterial);
00245                          
00246                         IgSoSimpleTrajectory *track = new IgSoSimpleTrajectory;
00247                         
00248                         track->controlPoints.set1Value (0, SbVec3f (x0, y0, z0));
00249                         track->markerPoints.set1Value (0, SbVec3f (x0, y0, z0));
00250                         
00251                         double x = x0;
00252                         double y = y0;
00253                         double z = z0;
00254                         
00255                         do 
00256                         {
00257                             x += 0.1*px;
00258                             y += 0.1*py;
00259                             z += 0.1*pz;
00260                         }
00261                         while ( sqrt(x*x+y*y) < 1.24 && fabs(z) < 3.14 );
00262                                 
00263                         SbVec3f pos = SbVec3f(x,y,z);
00264                         
00265                         track->controlPoints.set1Value (1, pos);
00266                         track->markerPoints.set1Value (1, pos);
00267                         gammas->addChild (track);
00268                           
00269                         sep->addChild (gammas);
00270                           
00271                         break;
00272                     }
00273                    
00274                     
00275                 default:
00276                     break;
00277                 }                   
00278             }
00279         }
00280 
00281         catch (cms::Exception& e)
00282         {
00283             if (this->m_onCmsException)
00284                 this->m_onCmsException (&e);
00285         }
00286         catch (lat::Error &e) 
00287         {
00288             if (this->m_onError)
00289                 this->m_onError (&e);
00290         }
00291         catch (std::exception &e) 
00292         {
00293             if (this->m_onException)
00294                 this->m_onException (&e);
00295         }
00296         catch (...) 
00297         {
00298             if (this->m_onUnhandledException)
00299                 this->m_onUnhandledException ();
00300         }
00301 
00302         rep->node ()->addChild (sep);
00303     }
00304         
00305     
00306 }


Member Data Documentation

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

Definition at line 42 of file VisTrackingParticleTwig.h.

Referenced by onNewEvent().

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

Definition at line 44 of file VisTrackingParticleTwig.h.

Referenced by onNewEvent().

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

Definition at line 43 of file VisTrackingParticleTwig.h.

Referenced by onNewEvent().

const std::string VisTrackingParticleTwig::m_name [private]

Reimplemented from IgSimpleTwig.

Definition at line 41 of file VisTrackingParticleTwig.h.

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

Definition at line 45 of file VisTrackingParticleTwig.h.

Referenced by onNewEvent().

std::string VisTrackingParticleTwig::m_text [private]

Definition at line 39 of file VisTrackingParticleTwig.h.

std::vector<std::pair<TrackingParticle,SbVec3f> > VisTrackingParticleTwig::m_tracks [private]

Definition at line 47 of file VisTrackingParticleTwig.h.

Referenced by onNewEvent(), and update().


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