CMS 3D CMS Logo

VisTrackTwig Class Reference

#include <VisReco/VisMuon/interface/VisTrackTwig.h>

Inheritance diagram for VisTrackTwig:

VisQueuedTwig IgSimpleTwig VisEventObserver IgCompoundTwig IgTwig IgRepresentable

List of all members.

Public Member Functions

virtual void configChanged (void)
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)
 VisTrackTwig (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

VisAnimate m_animate
VisMuonAnnotation m_annot
VisBField m_BField
VisCounterMax m_counterMax
VisCounterMin m_counterMin
VisMuonDt m_dt
VisCounterFrequency m_frequency
const std::string m_friendlyName
const std::string m_instanceName
const std::string m_moduleLabel
const std::string m_processName
VisRMax m_RMax
VisMuonT0 m_t0
std::string m_text
std::vector< reco::Trackm_tracks
VisZMax m_ZMax


Detailed Description

Definition at line 27 of file VisTrackTwig.h.


Constructor & Destructor Documentation

VisTrackTwig::VisTrackTwig ( 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 VisTrackTwig.cc.

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

00066     : VisQueuedTwig (state, parent, name),
00067       m_text ("no info"),
00068       m_friendlyName (friendlyName),
00069       m_moduleLabel (moduleLabel),
00070       m_instanceName (instanceName),
00071       m_processName (processName),
00072       m_animate (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00073       m_counterMax (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00074       m_counterMin (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00075       m_frequency (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00076       m_BField (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00077       m_RMax (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00078       m_ZMax (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00079       m_t0 (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00080       m_dt (state, lat::CreateCallback (this, &VisTrackTwig::configChanged)),
00081       m_annot (state, lat::CreateCallback (this, &VisTrackTwig::configChanged))
00082 {
00083     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00084     if (! tfService)
00085     {
00086         tfService = new VisTwigFactroyService (state);
00087     }
00088     edm::TypeID trackID (typeid (reco::TrackCollection));
00089     tfService->registerTwig (trackID.friendlyClassName (), &createThisTwig);
00090 }


Member Function Documentation

void VisTrackTwig::configChanged ( void   )  [virtual]

Definition at line 93 of file VisTrackTwig.cc.

References IgRepSet::invalidate(), and IgTwig::SELF_MASK.

00094 { IgRepSet::invalidate (this, SELF_MASK); }

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

Reimplemented from VisQueuedTwig.

Definition at line 97 of file VisTrackTwig.cc.

References arg, c, e, end, exception, i, edm::Event::id(), m_friendlyName, m_instanceName, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_processName, m_text, m_tracks, VisQueuedTwig::onBaseInvalidate(), VisQueuedTwig::onNewEvent(), and track.

00099 {    
00100     // Get debugging dump.
00101     VisQueuedTwig::onNewEvent (event, eventSetup);
00102 
00103     typedef std::vector<edm::Handle<reco::TrackCollection> > Collections;
00104     Collections trackCollections;
00105 
00106     m_tracks.clear ();
00107 
00108     m_text = (QString ("Run # %1, event # %2")
00109               .arg (event.id ().run ())
00110               .arg (event.id ().event ()).latin1 ());
00111 
00112     try
00113     {
00114         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00115         {
00116             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00117             event.getMany (visSel, trackCollections);
00118         }
00119         else
00120         {
00121             event.getManyByType (trackCollections);
00122         }
00123     }
00124     catch (cms::Exception& e)
00125     {
00126         if (this->m_onCmsException)
00127             this->m_onCmsException (&e);
00128     }
00129     catch (lat::Error &e) 
00130     {
00131         if (this->m_onError)
00132             this->m_onError (&e);
00133     }
00134     catch (std::exception &e) 
00135     {
00136         if (this->m_onException)
00137             this->m_onException (&e);
00138     }
00139     catch (...) 
00140     {
00141         if (this->m_onUnhandledException)
00142             this->m_onUnhandledException ();
00143     }
00144     if (! trackCollections.empty ())
00145     {
00146         Collections::iterator i (trackCollections.begin ()), end (trackCollections.end ());
00147         for (; i != end; ++i)
00148         {
00149             const reco::TrackCollection c = *(*i).product ();
00150             for (reco::TrackCollection::const_iterator track = c.begin (), tEnd = c.end (); track != tEnd; ++track)
00151             {
00152                 m_tracks.push_back (*track);
00153             }
00154         }
00155     }
00156 
00157     VisQueuedTwig::onBaseInvalidate ();
00158 }

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

Reimplemented from VisQueuedTwig.

Definition at line 389 of file VisTrackTwig.cc.

References Ig3DBaseRep::clear(), counter(), IgSoIdealTrack::dt, end, IgParticleChar::getByName(), i, IgSoIdealTrack::initialise(), int, label, m_animate, m_annot, m_BField, m_counterMax, m_counterMin, m_dt, m_frequency, m_RMax, m_t0, m_tracks, m_ZMax, Ig3DBaseRep::node(), IgSoIdealTrack::setBField(), IgSoIdealTrack::setRMax(), IgSoIdealTrack::setZMax(), IgSoIdealTrack::t0, IgSbColorMap::unpack(), VisQueuedTwig::update(), and VisActiveConfigurable< T >::value().

00390 {
00391     // Get debugging dump.
00392     VisQueuedTwig::update (rep);
00393 
00394     IgQtLock ();
00395     rep->clear ();
00396 
00397     if (! m_tracks.empty ())
00398     {
00399         SoSeparator *sep = new SoSeparator;    
00400 
00401         SoMaterial *mat = new SoMaterial;
00402         float rgbcomponents [4];
00403         IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00404         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00405         sep->addChild (mat);
00406  
00407         SoTimeCounter *counter = new SoTimeCounter;
00408         counter->max = (short int) m_counterMax.value ();
00409         counter->min = (short int) m_counterMin.value ();
00410         counter->frequency = m_frequency.value ();
00411 
00412         std::vector<reco::Track>::iterator i (m_tracks.begin ()), end (m_tracks.end ());
00413         for (; i != end; ++i) 
00414         {
00415             SoSeparator *labelSep = new SoSeparator;
00416             QString label;
00417             SoText2  *trackLabel = new SoText2;
00418             SoTranslation *trackLabelTranslation = new SoTranslation;
00419             
00420             SbVec3f pos = SbVec3f ((*i).px (),
00421                                    (*i).py (),
00422                                    (*i).pz ());
00423             pos.normalize ();
00424             
00425             trackLabelTranslation->translation = pos * m_ZMax.value ();
00426             labelSep->addChild (trackLabelTranslation);
00427             labelSep->addChild (trackLabel);
00428 
00429             IgSoIdealTrack* myTraj = new IgSoIdealTrack;
00430             myTraj->setBField(m_BField.value ());
00431             myTraj->setRMax(m_RMax.value ());
00432             myTraj->setZMax(m_ZMax.value ());
00433 
00434             IgParticleChar *pid;
00435             (*i).charge () >= 0 ? pid = IgParticleChar::getByName ("muon") : pid = IgParticleChar::getByName ("antimuon");
00436 
00437             // SL: IgSoIdealTrack wants vertex coordinates in meter, not centimeter
00438             myTraj->initialise ((*i).vx()/100., (*i).vy()/100., (*i).vz()/100.,
00439                                 (*i).px(), (*i).py(), (*i).pz(),
00440                                 0.0,
00441                                 pid);
00442             label = QString ("%1 GeV").arg ((*i).pt(), 0, 'f', 2);
00443             trackLabel->string = label.latin1 (); 
00444             
00445             myTraj->t0.setValue (m_t0.value ());
00446             myTraj->dt.setValue (m_dt.value ());
00447             
00448             if (m_animate.value ())
00449                 myTraj->dt.connectFrom (&counter->output);
00450 
00451             sep->addChild (myTraj);         
00452 
00453             if (m_annot.value () == true)
00454             {
00455                 sep->addChild (labelSep);
00456             }           
00457         }
00458         rep->node ()->addChild (sep);
00459     }
00460 }

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

Reimplemented from VisQueuedTwig.

Definition at line 315 of file VisTrackTwig.cc.

References Ig3DBaseRep::clear(), counter(), IgSoIdealTrack::dt, end, IgParticleChar::getByName(), i, IgSoIdealTrack::initialise(), int, label, m_animate, m_annot, m_BField, m_counterMax, m_counterMin, m_dt, m_frequency, m_RMax, m_t0, m_tracks, m_ZMax, Ig3DBaseRep::node(), IgSoIdealTrack::setBField(), IgSoIdealTrack::setRMax(), IgSoIdealTrack::setZMax(), IgSoIdealTrack::t0, IgSbColorMap::unpack(), VisQueuedTwig::update(), and VisActiveConfigurable< T >::value().

00316 {
00317     // Get debugging dump.
00318     VisQueuedTwig::update (rep);
00319 
00320     IgQtLock ();
00321     rep->clear ();
00322 
00323     if (! m_tracks.empty ())
00324     {
00325         SoSeparator *sep = new SoSeparator;    
00326 
00327         SoMaterial *mat = new SoMaterial;
00328         float rgbcomponents [4];
00329         IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00330         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00331         sep->addChild (mat);
00332  
00333         SoTimeCounter *counter = new SoTimeCounter;
00334         counter->max = (short int) m_counterMax.value ();
00335         counter->min = (short int) m_counterMin.value ();
00336         counter->frequency = m_frequency.value ();
00337 
00338         std::vector<reco::Track>::iterator i (m_tracks.begin ()), end (m_tracks.end ());
00339         for (; i != end; ++i) 
00340         {
00341             SoSeparator *labelSep = new SoSeparator;
00342             QString label;
00343             SoText2  *trackLabel = new SoText2;
00344             SoTranslation *trackLabelTranslation = new SoTranslation;
00345             
00346             SbVec3f pos = SbVec3f ((*i).px (),
00347                                    (*i).py (),
00348                                    (*i).pz ());
00349             pos.normalize ();
00350             
00351             trackLabelTranslation->translation = pos * m_ZMax.value ();
00352             labelSep->addChild (trackLabelTranslation);
00353             labelSep->addChild (trackLabel);
00354 
00355             IgSoIdealTrack* myTraj = new IgSoIdealTrack;
00356             myTraj->setBField(m_BField.value ());
00357             myTraj->setRMax(m_RMax.value ());
00358             myTraj->setZMax(m_ZMax.value ());
00359 
00360             IgParticleChar *pid;
00361             (*i).charge () >= 0 ? pid = IgParticleChar::getByName ("muon") : pid = IgParticleChar::getByName ("antimuon");
00362 
00363             // SL: IgSoIdealTrack wants vertex coordinates in meter, not centimeter
00364             myTraj->initialise ((*i).vx()/100., (*i).vy()/100., (*i).vz()/100.,
00365                                 (*i).px(), (*i).py(), (*i).pz(),
00366                                 0.0,
00367                                 pid);
00368             label = QString ("%1 GeV").arg ((*i).pt(), 0, 'f', 2);
00369             trackLabel->string = label.latin1 (); 
00370             
00371             myTraj->t0.setValue (m_t0.value ());
00372             myTraj->dt.setValue (m_dt.value ());
00373             
00374             if (m_animate.value ())
00375                 myTraj->dt.connectFrom (&counter->output);
00376 
00377             sep->addChild (myTraj);         
00378 
00379             if (m_annot.value () == true)
00380             {
00381                 sep->addChild (labelSep);
00382             }           
00383         }
00384         rep->node ()->addChild (sep);
00385     }
00386 }

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

Reimplemented from VisQueuedTwig.

Definition at line 161 of file VisTrackTwig.cc.

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

00162 {
00163     // Get debugging dump.
00164     VisQueuedTwig::update (rep);
00165 
00166     std::ostringstream text;
00167 
00168     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00169     text.setf (std::ios::right, std::ios::adjustfield);
00170 
00171     text << "Reconstructed Tracks = ";
00172 
00173     IgQtLock ();
00174 
00175     try
00176     {    
00177         text << std::setw (3) << m_tracks.size ();
00178         int nt = 0;
00179 
00180         if (! m_tracks.empty ())
00181         {
00182             std::vector<reco::Track>::iterator i (m_tracks.begin ()), end (m_tracks.end ());
00183             for (; i != end; ++i) 
00184             {
00185                 std::ostringstream out_pt;
00186                 out_pt << (*i).pt (); 
00187                 text << "<table width='100%' border=1>"
00188                      << "<TR align = center>"
00189                      << "<TD COLSPAN =4>Track number = " << nt++ 
00190                      << " with Pt = " << out_pt.str () 
00191                      << " and charge = " << (*i).charge ()
00192                      << "</TD></TR><TR align = center>"
00193                      << "<TH>Reference Point (vx, vy, vz)</TH>" 
00194                      << "<TH>px, py, pz</TH>"
00195                      << "<TH>Phi</TH>"
00196                      << "<TH>Eta</TH>"
00197                      << "</TR>";
00198 
00199                 text << "<TR><TD>" << std::setw (3) << (*i).vx ()/100. << ", " << (*i).vy()/100. << ", " << (*i).vz()/100. << "</TD>"
00200                      << "<TD>" << std::setw (3) << (*i).px () << ", " << (*i).py() << ", " << (*i).pz() << "</TD>"
00201                      << "<TD>" << std::setw (3) << (*i).phi () << "</TD>"
00202                      << "<TD>" << std::setw (3) << (*i).eta () << "</TD></TR>";
00203 
00204                 text << "</table>";  
00205             }       
00206         }
00207     }
00208     catch (cms::Exception& e)
00209     {
00210         if (this->m_onCmsException)
00211             this->m_onCmsException (&e);
00212     }
00213     catch (lat::Error &e) 
00214     {
00215         if (this->m_onError)
00216             this->m_onError (&e);
00217     }
00218     catch (std::exception &e) 
00219     {
00220         if (this->m_onException)
00221             this->m_onException (&e);
00222     }
00223     catch (...) 
00224     {
00225         if (this->m_onUnhandledException)
00226             this->m_onUnhandledException ();
00227     }
00228 
00229     IgQtLock ();
00230     rep->setText (text.str ());
00231 }

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

Reimplemented from VisQueuedTwig.

Definition at line 234 of file VisTrackTwig.cc.

References VisQueuedTwig::update().

00235 {
00236     // Get debugging dump.
00237     VisQueuedTwig::update (rep);
00238 }

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

Reimplemented from VisQueuedTwig.

Definition at line 241 of file VisTrackTwig.cc.

References Ig3DBaseRep::clear(), counter(), IgSoIdealTrack::dt, end, IgParticleChar::getByName(), i, IgSoIdealTrack::initialise(), int, label, m_animate, m_annot, m_BField, m_counterMax, m_counterMin, m_dt, m_frequency, m_RMax, m_t0, m_tracks, m_ZMax, Ig3DBaseRep::node(), IgSoIdealTrack::setBField(), IgSoIdealTrack::setRMax(), IgSoIdealTrack::setZMax(), IgSoIdealTrack::t0, IgSbColorMap::unpack(), VisQueuedTwig::update(), and VisActiveConfigurable< T >::value().

00242 {
00243     // Get debugging dump.
00244     VisQueuedTwig::update (rep);
00245 
00246     IgQtLock ();
00247     rep->clear ();
00248 
00249     if (! m_tracks.empty ())
00250     {
00251         SoSeparator *sep = new SoSeparator;    
00252 
00253         SoMaterial *mat = new SoMaterial;
00254         float rgbcomponents [4];
00255         IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00256         mat->diffuseColor.setValue (SbColor (rgbcomponents));
00257         sep->addChild (mat);
00258  
00259         SoTimeCounter *counter = new SoTimeCounter;
00260         counter->max = (short int) m_counterMax.value ();
00261         counter->min = (short int) m_counterMin.value ();
00262         counter->frequency = m_frequency.value ();
00263 
00264         std::vector<reco::Track>::iterator i (m_tracks.begin ()), end (m_tracks.end ());
00265         for (; i != end; ++i) 
00266         {
00267             SoSeparator *labelSep = new SoSeparator;
00268             QString label;
00269             SoText2  *trackLabel = new SoText2;
00270             SoTranslation *trackLabelTranslation = new SoTranslation;
00271             
00272             SbVec3f pos = SbVec3f ((*i).px (),
00273                                    (*i).py (),
00274                                    (*i).pz ());
00275             pos.normalize ();
00276             
00277             trackLabelTranslation->translation = pos * m_ZMax.value ();
00278             labelSep->addChild (trackLabelTranslation);
00279             labelSep->addChild (trackLabel);
00280 
00281             IgSoIdealTrack* myTraj = new IgSoIdealTrack;
00282             myTraj->setBField(m_BField.value ());
00283             myTraj->setRMax(m_RMax.value ());
00284             myTraj->setZMax(m_ZMax.value ());
00285 
00286             IgParticleChar *pid;
00287             (*i).charge () >= 0 ? pid = IgParticleChar::getByName ("muon") : pid = IgParticleChar::getByName ("antimuon");
00288 
00289             // SL: IgSoIdealTrack wants vertex coordinates in meter, not centimeter
00290             myTraj->initialise ((*i).vx()/100., (*i).vy()/100., (*i).vz()/100.,
00291                                 (*i).px(), (*i).py(), (*i).pz(),
00292                                 0.0,
00293                                 pid);
00294             label = QString ("%1 GeV").arg ((*i).pt(), 0, 'f', 2);
00295             trackLabel->string = label.latin1 (); 
00296             
00297             myTraj->t0.setValue (m_t0.value ());
00298             myTraj->dt.setValue (m_dt.value ());
00299             
00300             if (m_animate.value ())
00301                 myTraj->dt.connectFrom (&counter->output);
00302 
00303             sep->addChild (myTraj);         
00304 
00305             if (m_annot.value () == true)
00306             {
00307                 sep->addChild (labelSep);
00308             }           
00309         }
00310         rep->node ()->addChild (sep);
00311     }
00312 }


Member Data Documentation

VisAnimate VisTrackTwig::m_animate [private]

Definition at line 55 of file VisTrackTwig.h.

Referenced by update().

VisMuonAnnotation VisTrackTwig::m_annot [private]

Definition at line 64 of file VisTrackTwig.h.

Referenced by update().

VisBField VisTrackTwig::m_BField [private]

Definition at line 59 of file VisTrackTwig.h.

Referenced by update().

VisCounterMax VisTrackTwig::m_counterMax [private]

Definition at line 56 of file VisTrackTwig.h.

Referenced by update().

VisCounterMin VisTrackTwig::m_counterMin [private]

Definition at line 57 of file VisTrackTwig.h.

Referenced by update().

VisMuonDt VisTrackTwig::m_dt [private]

Definition at line 63 of file VisTrackTwig.h.

Referenced by update().

VisCounterFrequency VisTrackTwig::m_frequency [private]

Definition at line 58 of file VisTrackTwig.h.

Referenced by update().

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

Definition at line 51 of file VisTrackTwig.h.

Referenced by onNewEvent().

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

Definition at line 53 of file VisTrackTwig.h.

Referenced by onNewEvent().

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

Definition at line 52 of file VisTrackTwig.h.

Referenced by onNewEvent().

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

Definition at line 54 of file VisTrackTwig.h.

Referenced by onNewEvent().

VisRMax VisTrackTwig::m_RMax [private]

Definition at line 60 of file VisTrackTwig.h.

Referenced by update().

VisMuonT0 VisTrackTwig::m_t0 [private]

Definition at line 62 of file VisTrackTwig.h.

Referenced by update().

std::string VisTrackTwig::m_text [private]

Definition at line 50 of file VisTrackTwig.h.

Referenced by onNewEvent().

std::vector<reco::Track> VisTrackTwig::m_tracks [private]

Definition at line 66 of file VisTrackTwig.h.

Referenced by onNewEvent(), and update().

VisZMax VisTrackTwig::m_ZMax [private]

Definition at line 61 of file VisTrackTwig.h.

Referenced by 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