CMS 3D CMS Logo

VisTkRecTrackDetsTwig Class Reference

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

Inheritance diagram for VisTkRecTrackDetsTwig:

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)
 VisTkRecTrackDetsTwig (IgState *state, IgTwig *parent, const std::string &name="", const std::string &friendlyName="", const std::string &moduleLabel="", const std::string &instanceName="", const std::string &processName="")
virtual ~VisTkRecTrackDetsTwig (void)
 Clean the scene graph.

Private Attributes

const std::string m_friendlyName
std::vector< const GeomDetUnit * > m_geomDetUnits
const std::string m_instanceName
const std::string m_moduleLabel
const std::string m_processName
const edm::ParameterSetm_pset
std::string m_text
std::vector< std::string > m_trackCollectionNames
edm::ESHandle
< GlobalTrackingGeometry
m_trackerGeometry


Detailed Description

Definition at line 30 of file VisTkRecTrackDetsTwig.h.


Constructor & Destructor Documentation

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

References createThisTwig(), edm::TypeID::friendlyClassName(), DBSPlugin::get(), edm::ParameterSet::getUntrackedParameter(), m_pset, m_trackCollectionNames, p, VisConfigurationService::pSet(), VisTwigFactroyService::registerTwig(), and VisConfigurationService_cff::VisConfigurationService.

00075     : VisQueuedTwig (state, parent, name),
00076       m_text ("no info"),
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 trackID (typeid (reco::TrackCollection));
00088     tfService->registerTwig (trackID.friendlyClassName (), &createThisTwig);
00089     m_pset = VisConfigurationService::pSet ();
00090     if (! m_pset)
00091     {
00092         edm::ParameterSet p;
00093         VisConfigurationService *visService = new VisConfigurationService (p);
00094         m_pset = visService->pSet ();
00095         delete visService;
00096     } 
00097 
00098     std::vector<std::string> notSpecified;
00099     m_trackCollectionNames = m_pset->getUntrackedParameter<std::vector<std::string> > ("trackCollectionNames", notSpecified);
00100 }

VisTkRecTrackDetsTwig::~VisTkRecTrackDetsTwig ( void   )  [virtual]

Clean the scene graph.

Definition at line 104 of file VisTkRecTrackDetsTwig.cc.

00105 {
00106 }


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 109 of file VisTkRecTrackDetsTwig.cc.

References cms::Exception::append(), arg, c, GeomDet::components(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), exception, edm::EventSetup::get(), edm::Event::getManyByType(), i, edm::Event::id(), edm::ESHandle< T >::isValid(), it, iter, LFfwvis, LOG, m_friendlyName, m_geomDetUnits, m_instanceName, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_processName, m_text, m_trackCollectionNames, m_trackerGeometry, VisQueuedTwig::onBaseInvalidate(), VisQueuedTwig::onNewEvent(), tc, GsfMatrixTools::trace(), track, and TrackValidation_HighPurity_cff::valid.

00111 {
00112     // Get debugging dump.
00113     VisQueuedTwig::onNewEvent (event, eventSetup);
00114 
00115     m_geomDetUnits.clear ();
00116     std::vector<DetId> trackIds;
00117 
00118     m_text = (QString ("Run # %1, event # %2")
00119               .arg (event.id ().run ())
00120               .arg (event.id ().event ()).latin1 ());
00121 
00122     std::vector<edm::Handle<reco::TrackCollection> > trackCollections;
00123   
00124     try
00125     {
00126         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00127         {
00128             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00129             event.getMany (visSel, trackCollections);
00130         }
00131         else
00132         {
00133             if (m_trackCollectionNames.empty ())
00134                 event.getManyByType (trackCollections);
00135             else 
00136             {
00137                 for (std::vector<std::string>::iterator tkColl = m_trackCollectionNames.begin (), tkCollEnd = m_trackCollectionNames.end ();
00138                     tkColl != tkCollEnd; ++tkColl) 
00139                 {
00140                     LOG (2, trace, LFfwvis, "Getting track Collection with label " << (*tkColl) << "\n");
00141 
00142                     edm::Handle<reco::TrackCollection> tcHandle;
00143 
00144                     event.getByLabel ((*tkColl), tcHandle);
00145                     trackCollections.push_back (tcHandle);
00146                 }
00147             }
00148         }
00149     }
00150     catch (cms::Exception& e)
00151     {
00152         e.append (" from VisTkRecTrackDetsTwig: ");
00153         e.append (this->name ());
00154             
00155         if (this->m_onCmsException)
00156             this->m_onCmsException (&e);
00157     }
00158     catch (lat::Error &e) 
00159     {
00160         if (this->m_onError)
00161             this->m_onError (&e);
00162     }
00163     catch (std::exception &e) 
00164     {
00165         if (this->m_onException)
00166             this->m_onException (&e);
00167     }
00168     catch (...) 
00169     {
00170         if (this->m_onUnhandledException)
00171             this->m_onUnhandledException ();
00172     }
00173   
00174     try
00175     { 
00176         eventSetup.get<GlobalTrackingGeometryRecord> ().get (m_trackerGeometry);
00177     }
00178     catch (cms::Exception& e)
00179     {
00180         e.append (" from VisTkRecTrackDetsTwig: ");
00181         e.append (this->name ());
00182             
00183         if (this->m_onCmsException)
00184             this->m_onCmsException (&e);
00185     }
00186     catch (lat::Error &e) 
00187     {
00188         if (this->m_onError)
00189             this->m_onError (&e);
00190     }
00191     catch (std::exception &e) 
00192     {
00193         if (this->m_onException)
00194             this->m_onException (&e);
00195     }
00196     catch (...) 
00197     {
00198         if (this->m_onUnhandledException)
00199             this->m_onUnhandledException ();
00200     }
00201   
00202     if ((! trackCollections.empty ()) && m_trackerGeometry.isValid ())
00203     {
00204         LOG (2, trace, LFfwvis, "OK: trackCollections is not empty and TrackingGeometry is valid===>>>\n");
00205 
00206         std::vector<edm::Handle<reco::TrackCollection> >::iterator i;
00207         std::vector<edm::Handle<reco::TrackCollection> >::iterator iEnd;
00208     
00209         LOG (2, trace, LFfwvis, "There are " << trackCollections.size () << " track collections.\n");
00210         int tc = 1;
00211         for (i = trackCollections.begin (), iEnd = trackCollections.end (); i != iEnd; ++i)
00212         {
00213             try 
00214             {
00215                 const reco::TrackCollection c = *(*i).product ();
00216                 LOG (3, trace, LFfwvis, "#" << tc++ << ":    track collection has " << c.size () << " tracks\n");
00217                 for (reco::TrackCollection::const_iterator track = c.begin (), trackEnd = c.end (); track != trackEnd; ++track)
00218                 {
00219                     if ((*track).extra ().isNonnull ())
00220                     {                   
00221                         LOG (3, trace, LFfwvis, "\nTrack with rechitsize = " << (*track).recHitsSize ()
00222                              << "\nCheck the validity of the RecHits:" << "\n");
00223 
00224                         bool valid = true;                  
00225                         for (trackingRecHit_iterator it = track->recHitsBegin (), itEnd = track->recHitsEnd ();  
00226                              it != itEnd; ++it)
00227                         {
00228                             if ((*it)->geographicalId ().null ()) 
00229                             {
00230                                 LOG (3, trace, LFfwvis, "\nWARNING: RecHit is not valid.\n");
00231                                 valid = false;
00232                             }
00233                             else
00234                             {
00235                                 LOG (3, trace, LFfwvis,  "\nRecHit is OK."
00236                                      << "\nPut id into trackIds.\n");
00237 
00238                                 trackIds.push_back ((*it)->geographicalId ());
00239                             }
00240                         }
00241                     }
00242                     else
00243                     {
00244                         LOG (3, trace, LFfwvis, "\nTrack has no Extras stored.\n");
00245                     }
00246                 }
00247                 
00248             }
00249             catch (cms::Exception& e)
00250             {
00251                 e.append (" from VisTkRecTrackDetsTwig: ");
00252                 e.append (this->name ());
00253             
00254                 if (this->m_onCmsException)
00255                     this->m_onCmsException (&e);
00256             }
00257             catch (lat::Error &e) 
00258             {
00259                 if (this->m_onError)
00260                     this->m_onError (&e);
00261             }
00262             catch (std::exception &e) 
00263             {
00264                 if (this->m_onException)
00265                     this->m_onException (&e);
00266             }
00267             catch (...) 
00268             {
00269                 if (this->m_onUnhandledException)
00270                     this->m_onUnhandledException ();
00271             }
00272         }
00273     }
00274     else
00275     {
00276         LOG (2, trace, LFfwvis, "Hmmm.. trackCollections is empty or GlobalTrackingGeometry is not valid.\n");
00277     }
00278     
00279     int nselected = 0;
00280     
00281     std::vector<DetId> cleanedDetIds;
00282     std::vector<DetId>::const_iterator iter;
00283     std::vector<DetId>::const_iterator jter;
00284     std::vector<DetId>::const_iterator iterEnd = trackIds.end ();
00285 
00286     try 
00287     {
00288         for (iter = trackIds.begin (); iter != iterEnd; ++iter) 
00289         {
00290             bool hasDup = false;
00291             for (jter = iter + 1; jter != iterEnd; ++jter) 
00292             {
00293                 if (*iter == *jter) hasDup = true;
00294             }
00295             if (! hasDup) cleanedDetIds.push_back (*iter);
00296         }
00297     }
00298     catch (cms::Exception& e)
00299     {
00300         e.append (" from VisTkRecTrackDetsTwig: ");
00301         e.append (this->name ());
00302             
00303         if (this->m_onCmsException)
00304             this->m_onCmsException (&e);
00305     }
00306     catch (lat::Error &e) 
00307     {
00308         if (this->m_onError)
00309             this->m_onError (&e);
00310     }
00311     catch (std::exception &e) 
00312     {
00313         if (this->m_onException)
00314             this->m_onException (&e);
00315     }
00316     catch (...) 
00317     {
00318         if (this->m_onUnhandledException)
00319             this->m_onUnhandledException ();
00320     }
00321 
00322     trackIds.clear ();
00323     trackIds.swap (cleanedDetIds);
00324 
00325     for (std::vector<DetId>::const_iterator detIdObject = trackIds.begin (); detIdObject != trackIds.end (); ++detIdObject) 
00326     {
00327         if (! (*detIdObject).null ()) 
00328         {               
00329             const GeomDet *gd = 0;
00330         
00331             unsigned int id = detIdObject->rawId ();
00332             try 
00333             {
00334                 gd = dynamic_cast<const GeomDet *>(m_trackerGeometry->idToDet (*detIdObject));
00335             }
00336             catch (cms::Exception& e)
00337             {
00338                 e.append (" from VisTkRecTrackDetsTwig: ");
00339                 e.append (this->name ());
00340             
00341                 if (this->m_onCmsException)
00342                     this->m_onCmsException (&e);
00343             }
00344             catch (lat::Error &e) 
00345             {
00346                 if (this->m_onError)
00347                     this->m_onError (&e);
00348             }
00349             catch (std::exception &e) 
00350             {
00351                 if (this->m_onException)
00352                     this->m_onException (&e);
00353             }
00354             catch (...) 
00355             {
00356                 if (this->m_onUnhandledException)
00357                     this->m_onUnhandledException ();
00358             }
00359             
00360             if (gd != 0)
00361             {
00362                 std::vector<const GeomDet*> comp = gd->components ();
00363 
00364                 if (comp.empty ())
00365                 {
00366                     //case 1 - only 1 real module associated
00367                     const GeomDetUnit *  geoUnit = 0;
00368                     try
00369                     {
00370                         geoUnit = dynamic_cast<const GeomDetUnit *>(m_trackerGeometry->idToDetUnit (*detIdObject));
00371                     }
00372                     catch (cms::Exception& e)
00373                     {
00374                         if (this->m_onCmsException)
00375                         this->m_onCmsException (&e);
00376                     }
00377 
00378                     if (geoUnit != 0)
00379                     {
00380                         // push back geoUnit
00381                         m_geomDetUnits.push_back(geoUnit);
00382                         nselected++;
00383                     }
00384                 }
00385                 if (comp.size () == 2)
00386                 {
00387                     // case 2 - stereo pair associated
00388                     const GeomDetUnit *  geoUnit1 =
00389                         dynamic_cast<const GeomDetUnit*> (comp [0]);
00390                     if (geoUnit1 != 0)
00391                     {
00392                         // push back geoUnit1
00393                         m_geomDetUnits.push_back (geoUnit1);
00394                         nselected++;
00395                     }
00396 
00397                     const GeomDetUnit *  geoUnit2 =
00398                         dynamic_cast<const GeomDetUnit*>(comp [1]);
00399                     if (geoUnit2 != 0)
00400                     {
00401                         //push back geoUnit2
00402                         m_geomDetUnits.push_back (geoUnit2);
00403                         nselected++;
00404                     }
00405                 }
00406 
00407                 if (comp.size () == 1 || comp.size () > 2) 
00408                 {
00409                     std::cout<<"module " << id << " intersected by rechit not found!"<<std::endl;
00410                 }
00411             } 
00412             else 
00413             {           
00414                 std::cout<<"module " << id << " intersected by rechit not found!"<<std::endl;
00415             }
00416         }
00417     }
00418     
00419     //    std::cout<<"size detid after unique "<<m_geomDetUnits.size()<<std::endl;
00420 
00421     VisQueuedTwig::onBaseInvalidate ();
00422 }

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

Reimplemented from VisQueuedTwig.

Definition at line 473 of file VisTkRecTrackDetsTwig.cc.

References ASSERT, VisEventSetupService::buildDet(), Ig3DBaseRep::clear(), DBSPlugin::get(), edm::ESHandle< T >::isValid(), m_geomDetUnits, m_trackerGeometry, Ig3DBaseRep::node(), VisEventSetupService::RZDet, VisQueuedTwig::state(), and VisQueuedTwig::update().

00474 {
00475     // Get debugging dump.
00476     VisQueuedTwig::update (rep);
00477 
00478     IgQtLock ();
00479     rep->clear ();
00480     if ((! m_geomDetUnits.empty ()) &&  m_trackerGeometry.isValid () )
00481     {
00482         VisEventSetupService *esService = VisEventSetupService::get (state ());
00483         ASSERT (esService);
00484 
00485         SoSeparator* sep = esService->buildDet (VisEventSetupService::RZDet, m_geomDetUnits);
00486 
00487         sep->ref ();
00488         rep->node ()->addChild (sep);
00489     }
00490 
00491 }

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

Reimplemented from VisQueuedTwig.

Definition at line 452 of file VisTkRecTrackDetsTwig.cc.

References ASSERT, VisEventSetupService::buildDet(), Ig3DBaseRep::clear(), DBSPlugin::get(), edm::ESHandle< T >::isValid(), m_geomDetUnits, m_trackerGeometry, Ig3DBaseRep::node(), VisEventSetupService::RPhiDet, VisQueuedTwig::state(), and VisQueuedTwig::update().

00453 {
00454     // Get debugging dump.
00455     VisQueuedTwig::update (rep);
00456 
00457     IgQtLock ();
00458     rep->clear ();
00459  
00460     if ((! m_geomDetUnits.empty ()) &&  m_trackerGeometry.isValid () )
00461     {
00462         VisEventSetupService *esService = VisEventSetupService::get (state ());
00463         ASSERT (esService);
00464 
00465         SoSeparator* sep = esService->buildDet (VisEventSetupService::RPhiDet, m_geomDetUnits);
00466 
00467         sep->ref ();
00468         rep->node ()->addChild (sep);
00469     }
00470 }

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

Reimplemented from VisQueuedTwig.

Definition at line 425 of file VisTkRecTrackDetsTwig.cc.

00426 {
00427     // Get debugging dump.
00428 
00429 }

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

Reimplemented from VisQueuedTwig.

Definition at line 495 of file VisTkRecTrackDetsTwig.cc.

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

00496 {
00497 
00498     // Get debugging dump.
00499     VisQueuedTwig::update (rep);
00500 
00501     IgQtLock ();
00502     rep->clear ();
00503 
00504     //........ still missing
00505 }

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

Reimplemented from VisQueuedTwig.

Definition at line 432 of file VisTkRecTrackDetsTwig.cc.

References ASSERT, VisEventSetupService::buildDet(), Ig3DBaseRep::clear(), VisEventSetupService::FullDet, DBSPlugin::get(), edm::ESHandle< T >::isValid(), m_geomDetUnits, m_trackerGeometry, Ig3DBaseRep::node(), NULL, VisQueuedTwig::state(), and VisQueuedTwig::update().

00433 {
00434     // Get debugging dump.  
00435     VisQueuedTwig::update (rep);
00436   
00437     IgQtLock ();
00438     rep->clear ();
00439 
00440     if ((! m_geomDetUnits.empty ()) &&  m_trackerGeometry.isValid () )
00441     {
00442         VisEventSetupService *esService = VisEventSetupService::get (state ());
00443         ASSERT (esService);
00444 
00445         SoSeparator* sep = esService->buildDet (VisEventSetupService::FullDet, m_geomDetUnits);
00446         if (sep != NULL)
00447             rep->node ()->addChild (sep);
00448     }
00449 }


Member Data Documentation

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

Definition at line 59 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent().

std::vector<const GeomDetUnit*> VisTkRecTrackDetsTwig::m_geomDetUnits [private]

Definition at line 66 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent(), and update().

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

Definition at line 61 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent().

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

Definition at line 60 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent().

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

Definition at line 62 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent().

const edm::ParameterSet* VisTkRecTrackDetsTwig::m_pset [private]

Definition at line 65 of file VisTkRecTrackDetsTwig.h.

Referenced by VisTkRecTrackDetsTwig().

std::string VisTkRecTrackDetsTwig::m_text [private]

Definition at line 58 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent().

std::vector<std::string> VisTkRecTrackDetsTwig::m_trackCollectionNames [private]

Definition at line 64 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent(), and VisTkRecTrackDetsTwig().

edm::ESHandle<GlobalTrackingGeometry> VisTkRecTrackDetsTwig::m_trackerGeometry [private]

Definition at line 67 of file VisTkRecTrackDetsTwig.h.

Referenced by onNewEvent(), and update().


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