CMS 3D CMS Logo

VisPFClusterTwig Class Reference

Twig class for PFCluster visualization. More...

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

Inheritance diagram for VisPFClusterTwig:

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)
 VisPFClusterTwig (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

std::vector< reco::PFClusterm_EBclusters
std::vector< RecHitm_EBrechits
std::vector< reco::PFClusterm_EEclusters
std::vector< RecHitm_EErechits
const std::string m_friendlyName
std::vector< reco::PFClusterm_HBclusters
std::vector< RecHitm_HBrechits
const std::string m_instanceName
const std::string m_moduleLabel
const std::string m_name
edm::ESHandle< CaloGeometrym_pDD
const std::string m_processName
std::string m_text

Classes

struct  RecHit


Detailed Description

Twig class for PFCluster visualization.

Todo:
Support for PS?
Todo:
HB: same problem as w/ PFRecHit; HCAL det id?
Todo:
It appears that I have to cache the PFRecHitFraction information (something with copy constructor?)
Author:
T. McCauley
Date:
February 2008

Definition at line 27 of file VisPFClusterTwig.h.


Constructor & Destructor Documentation

VisPFClusterTwig::VisPFClusterTwig ( 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 56 of file VisPFClusterTwig.cc.

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

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


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 82 of file VisPFClusterTwig.cc.

References c, GenMuonPlsPt100GeV_cfg::cout, VisPFClusterTwig::RecHit::detId, e, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, lat::endl(), VisPFClusterTwig::RecHit::energy, exception, VisPFClusterTwig::RecHit::fraction, edm::EventSetup::get(), PFLayer::HCAL_BARREL1, i, m_EBclusters, m_EBrechits, m_EEclusters, m_EErechits, m_friendlyName, m_HBclusters, m_HBrechits, m_instanceName, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, m_processName, VisQueuedTwig::onBaseInvalidate(), and VisQueuedTwig::onNewEvent().

00084 {
00085     VisQueuedTwig::onNewEvent(event, eventSetup);
00086 
00087     m_EBclusters.clear();
00088     m_HBclusters.clear();
00089     m_EEclusters.clear();
00090 
00091     m_EBrechits.clear();
00092     m_HBrechits.clear();
00093     m_EErechits.clear();
00094 
00095     std::vector<edm::Handle<reco::PFClusterCollection> > clusterCollections;
00096 
00097     try
00098     {
00099         eventSetup.get<IdealGeometryRecord>().get(m_pDD);
00100     }
00101 
00102     catch (cms::Exception& e)
00103     {
00104         if (this->m_onCmsException)
00105             this->m_onCmsException(&e);
00106     }
00107 
00108     try
00109     {
00110         if ( (! m_friendlyName.empty ()) || 
00111              (! m_moduleLabel.empty ())  || 
00112              (! m_instanceName.empty ()) || 
00113              (! m_processName.empty ()) )
00114         {
00115             VisEventSelector visSel(m_friendlyName, m_moduleLabel, 
00116                                     m_instanceName, m_processName);
00117             
00118             event.getMany(visSel, clusterCollections);
00119         }
00120 
00121         else
00122         {
00123             event.getManyByType(clusterCollections);
00124         }          
00125     }
00126     
00127     catch (cms::Exception& e)
00128     {
00129         if (this->m_onCmsException)
00130             this->m_onCmsException(&e);
00131     }
00132 
00133     catch (lat::Error &e) 
00134     {
00135         if (this->m_onError)
00136             this->m_onError(&e);
00137     } 
00138 
00139     catch (std::exception &e) 
00140     {
00141         if (this->m_onException)
00142             this->m_onException(&e);
00143     }
00144 
00145     catch (...) 
00146     {
00147         if (this->m_onUnhandledException)
00148             this->m_onUnhandledException();
00149     }
00150 
00151     if ( ! clusterCollections.empty() )
00152     {
00153         for (std::vector<edm::Handle<reco::PFClusterCollection> >::iterator i = 
00154                  clusterCollections.begin(), iEnd = clusterCollections.end(); 
00155              i != iEnd; ++i) 
00156         {   
00157             const reco::PFClusterCollection& c = *(*i);
00158 
00159             for (std::vector<reco::PFCluster>::const_iterator ipfc = c.begin(), ipfcEnd = c.end();
00160                  ipfc != ipfcEnd; ++ipfc)
00161             {
00162                 if ( (*ipfc).layer() == PFLayer::ECAL_BARREL )
00163                 {
00164                     m_EBclusters.push_back((*ipfc));
00165 
00166                     std::vector<reco::PFRecHitFraction>::const_iterator iR;
00167        
00168                     for ( iR  = (*ipfc).recHitFractions().begin();
00169                           iR != (*ipfc).recHitFractions().end();
00170                           ++iR )
00171                     {
00172                         RecHit recHit;
00173          
00174                         recHit.fraction = (*iR).fraction();
00175                         recHit.energy = (*iR).recHitRef()->energy();
00176                         recHit.detId = (*iR).recHitRef()->detId();
00177             
00178                         m_EBrechits.push_back(recHit);
00179                     }
00180                 }
00181                 
00182                 
00183                 if ( (*ipfc).layer() == PFLayer::HCAL_BARREL1 )
00184                 {
00185                     m_HBclusters.push_back((*ipfc));
00186                 
00187                     std::vector<reco::PFRecHitFraction>::const_iterator iR;
00188        
00189                     for ( iR  = (*ipfc).recHitFractions().begin();
00190                           iR != (*ipfc).recHitFractions().end();
00191                           ++iR )
00192                     {
00193                         RecHit recHit;
00194          
00195                         recHit.fraction = (*iR).fraction();
00196                         recHit.energy = (*iR).recHitRef()->energy();
00197                         recHit.detId = (*iR).recHitRef()->detId();
00198             
00199                         m_HBrechits.push_back(recHit);
00200                     }
00201                 }
00202                 
00203 
00204                 if ( (*ipfc).layer() == PFLayer::ECAL_ENDCAP )
00205                 {    
00206                     m_EEclusters.push_back((*ipfc));
00207 
00208                     std::vector<reco::PFRecHitFraction>::const_iterator iR;
00209        
00210                     for ( iR  = (*ipfc).recHitFractions().begin();
00211                           iR != (*ipfc).recHitFractions().end();
00212                           ++iR )
00213                     {
00214                         RecHit recHit;
00215          
00216                         recHit.fraction = (*iR).fraction();
00217                         recHit.energy = (*iR).recHitRef()->energy();
00218                         recHit.detId = (*iR).recHitRef()->detId();
00219             
00220                         m_EErechits.push_back(recHit);
00221                     }
00222                 }
00223                 
00224             }
00225         }
00226     }
00227 
00228     else
00229         std::cout<<"DEBUG: clusterCollections.empty()"<<std::endl;
00230     
00231    
00232     VisQueuedTwig::onBaseInvalidate();
00233 }

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

Reimplemented from VisQueuedTwig.

Definition at line 855 of file VisPFClusterTwig.cc.

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

00856 {
00857     VisQueuedTwig::update(rep);
00858 
00859     IgQtLock();
00860     rep->clear();
00861 }

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

Reimplemented from VisQueuedTwig.

Definition at line 672 of file VisPFClusterTwig.cc.

References Ig3DBaseRep::clear(), e, IgSoCircularHist::energies, relval_parameters_module::energy, exception, first, int, prof2calltree::last, IgSoCircularHist::layer, IgSoCircularHist::logScale, m_EBclusters, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, IgSoCircularHist::maxRadius, IgSoCircularHist::minRadius, Ig3DBaseRep::node(), IgSoCircularHist::numberOfBins, phi, IgSoCircularHist::scaleFactor, and VisQueuedTwig::update().

00673 {
00674     VisQueuedTwig::update(rep);
00675     
00676     IgQtLock();
00677     rep->clear();
00678     
00679     SoSeparator* sep = new SoSeparator;    
00680     SoSeparator* posSep = new SoSeparator;    
00681     SoSeparator* negSep = new SoSeparator;
00682     sep->addChild(posSep);
00683     sep->addChild(negSep);
00684 
00685     int binNumber;
00686 
00687     try
00688     {
00689         if ( ! m_EBclusters.empty() )
00690         {
00691             SoMaterial* posEBmat = new SoMaterial;
00692             posEBmat->ambientColor.setValue(1.0, 0.0, 153.0 / 255.0);
00693             posEBmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00694             posEBmat->specularColor.setValue(1.0, 0.0, 153.0 / 255.0);
00695             posEBmat->emissiveColor.setValue(1.0, 0.0, 153.0 / 255.0);
00696             posSep->addChild(posEBmat);
00697     
00698             SoMaterial* negEBmat = new SoMaterial;
00699             negEBmat->ambientColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00700             negEBmat->diffuseColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00701             negEBmat->specularColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00702             negEBmat->emissiveColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00703             negSep->addChild(negEBmat);
00704 
00705             int nbrOfBins = 360;
00706 
00707             std::vector<float> bufferPositive(nbrOfBins);
00708             std::vector<float> bufferNegative(nbrOfBins);
00709             
00710             std::vector<reco::PFCluster>::const_iterator iC;
00711             
00712             for ( iC  = m_EBclusters.begin();
00713                   iC != m_EBclusters.end(); ++iC)
00714             {           
00715                 double energy = (*iC).energy();
00716                 double phi = (*iC).position().Phi();
00717                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00718 
00719                 binNumber = (int) floor (phi / (2 * M_PI / nbrOfBins));
00720  
00721                 (energy >= 0.0) ? bufferPositive[binNumber] += energy :  bufferNegative[binNumber] += energy;
00722             }
00723             
00724             std::vector<float>::const_iterator first = bufferPositive.begin();
00725             std::vector<float>::const_iterator last  = bufferPositive.end();
00726             
00727             if ( *max_element(first, last) > 0.0 )
00728             {
00729                 IgSoCircularHist* posEBclusters = new IgSoCircularHist;
00730                 posEBclusters->minRadius = 1.29;
00731                 posEBclusters->maxRadius = -1;
00732                 posEBclusters->scaleFactor = 1.0;
00733                 posEBclusters->numberOfBins = nbrOfBins;
00734                 posEBclusters->energies.setValues(0, nbrOfBins, &bufferPositive[0]);
00735                 posEBclusters->logScale = false;
00736                 posEBclusters->layer = 5.5;
00737                 posSep->addChild(posEBclusters);
00738             }
00739             
00740             std::vector<float>::const_iterator nfirst = bufferNegative.begin();
00741             std::vector<float>::const_iterator nlast  = bufferNegative.end();
00742             
00743             if ( fabs(*max_element(nfirst, nlast)) > 0.0 )
00744             {
00745                 IgSoCircularHist* negEBclusters = new IgSoCircularHist;
00746                 negEBclusters->minRadius = 1.29;
00747                 negEBclusters->maxRadius = -1;
00748                 negEBclusters->scaleFactor = 1.0;
00749                 negEBclusters->numberOfBins = nbrOfBins;
00750                 negEBclusters->energies.setValues(0, nbrOfBins, &bufferNegative[0]);
00751                 negEBclusters->logScale = false;
00752                 negEBclusters->layer = 5.0;
00753 
00754                 negSep->addChild(negEBclusters);
00755             }
00756         }
00757         
00758         /*
00759         if ( ! m_HBclusters.empty() )
00760         {
00761             SoMaterial* posHBmat = new SoMaterial;
00762             posHBmat->ambientColor.setValue(0.0, 0.4, 1.0);
00763             posHBmat->diffuseColor.setValue(0.0, 0.4, 1.0);
00764             posHBmat->specularColor.setValue(0.0, 0.4, 1.0);
00765             posHBmat->emissiveColor.setValue(0.0, 0.4, 1.0);
00766             posSep->addChild(posHBmat);
00767     
00768             SoMaterial* negHBmat = new SoMaterial;
00769             negHBmat->ambientColor.setValue(1.0, 0.0, 0.0);
00770             negHBmat->diffuseColor.setValue(1.0, 0.0, 0.0);
00771             negHBmat->specularColor.setValue(1.0, 0.0, 0.0);
00772             negHBmat->emissiveColor.setValue(1.0, 0.0, 0.0);
00773             negSep->addChild(negHBmat);
00774 
00775             int nbrOfBins = 72;
00776 
00777             std::vector<float> bufferPositive(nbrOfBins);
00778             std::vector<float> bufferNegative(nbrOfBins);
00779 
00780             std::vector<reco::PFCluster>::const_iterator iC;
00781 
00782             for ( iC  = m_HBclusters.begin();
00783                   iC != m_HBclusters.end(); ++iC)
00784             {           
00785                 double energy = (*iC).energy();
00786                 double phi = (*iC).position().Phi();
00787                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00788 
00789                 binNumber = (int) floor (phi / (2 * M_PI / nbrOfBins));
00790  
00791                 (energy >= 0.0) ? bufferPositive[binNumber] += energy :  bufferNegative[binNumber] += energy;
00792             }
00793             
00794             std::vector<float>::const_iterator first = bufferPositive.begin();
00795             std::vector<float>::const_iterator last  = bufferPositive.end();
00796             
00797             if ( *max_element(first, last) > 0.0 )
00798             {
00799                 IgSoCircularHist* posHBclusters = new IgSoCircularHist;
00800                 posHBclusters->minRadius = 1.9;
00801                 posHBclusters->maxRadius = -1;
00802                 posHBclusters->scaleFactor = 1.0;
00803                 posHBclusters->numberOfBins = nbrOfBins;
00804                 posHBclusters->energies.setValues(0, nbrOfBins, &bufferPositive[0]);
00805                 posHBclusters->logScale = false;
00806                 posHBclusters->layer = 5.5;
00807                 posSep->addChild(posHBclusters);
00808             }
00809             
00810             std::vector<float>::const_iterator nfirst = bufferNegative.begin();
00811             std::vector<float>::const_iterator nlast  = bufferNegative.end();
00812             
00813             if ( fabs(*max_element(nfirst, nlast)) > 0.0 )
00814             {
00815                 IgSoCircularHist* negHBclusters = new IgSoCircularHist;
00816                 negHBclusters->minRadius = 1.9;
00817                 negHBclusters->maxRadius = -1;
00818                 negHBclusters->scaleFactor = 1.0;
00819                 negHBclusters->numberOfBins = nbrOfBins;
00820                 negHBclusters->energies.setValues(0, nbrOfBins, &bufferNegative[0]);
00821                 negHBclusters->logScale = false;
00822                 negHBclusters->layer = 5.0;
00823 
00824                 negSep->addChild(negHBclusters);
00825             }
00826         }
00827         */
00828         
00829     }
00830    
00831     catch (cms::Exception& e)
00832     {
00833         if (this->m_onCmsException)
00834             this->m_onCmsException (&e);
00835     }
00836     catch (lat::Error &e) 
00837     {
00838         if (this->m_onError)
00839             this->m_onError (&e);
00840     }
00841     catch (std::exception &e) 
00842     {
00843         if (this->m_onException)
00844             this->m_onException (&e);
00845     }
00846     catch (...) 
00847     {
00848         if (this->m_onUnhandledException)
00849             this->m_onUnhandledException ();
00850     }
00851     
00852     rep->node()->addChild(sep);
00853 }

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

Reimplemented from VisQueuedTwig.

Definition at line 550 of file VisPFClusterTwig.cc.

References e, relval_parameters_module::energy, eta, exception, m_EBclusters, m_EEclusters, m_HBclusters, m_name, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_text, phi, IgTextRep::setText(), and VisQueuedTwig::update().

00551 {
00552     VisQueuedTwig::update(rep);
00553 
00554     std::ostringstream  text;
00555 
00556     text << m_name << " from ";
00557  
00558     text << m_text << "<br>";
00559     text << "Total: " << m_EBclusters.size () << " EB PFClusters.<br>";
00560     text << "Total: " << m_HBclusters.size () << " HB PFClusters.<br>";
00561     text << "Total: " << m_EEclusters.size () << " EE PFClusters.<br>";
00562 
00563     text << "<table width='100%' border=1>"
00564          << "<TR align = center>"
00565          << "<TH>Number</TH>"
00566          << "<TH>Detector</TH>"
00567          << "<TH>Energy (GeV)</TH>"
00568          << "<TH>Eta</TH>"
00569          << "<TH>Phi (deg)</TH>"
00570          << "</TR>";
00571 
00572     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00573     text.setf (std::ios::right, std::ios::adjustfield);
00574     
00575     int nClusters;
00576 
00577     try
00578     {
00579         std::vector<reco::PFCluster>::const_iterator iC;
00580         
00581         if ( ! m_EBclusters.empty() )
00582         {
00583             nClusters = 0;
00584             
00585             for ( iC  = m_EBclusters.begin();
00586                   iC != m_EBclusters.end(); ++iC)
00587             {
00588                 double energy = (*iC).energy();
00589                 double eta = (*iC).position().Eta();
00590                 double phi = (*iC).position().Phi();
00591 
00592                 text << "<TR align = right>"
00593                      << "<TD>" << std::setw (3) << nClusters++ << "</TD>"
00594                      << "<TD> EB </TD>"
00595                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00596                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00597                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00598                      << "</TR>";
00599             }       
00600         }
00601 
00602         if ( ! m_HBclusters.empty() )
00603         {
00604             nClusters = 0;
00605             
00606             for ( iC  = m_HBclusters.begin();
00607                   iC != m_HBclusters.end(); ++iC)
00608             {
00609                 double energy = (*iC).energy();
00610                 double eta = (*iC).position().Eta();
00611                 double phi = (*iC).position().Phi();
00612 
00613                 text << "<TR align = right>"
00614                      << "<TD>" << std::setw (3) << nClusters++ << "</TD>"
00615                      << "<TD> HB </TD>"
00616                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00617                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00618                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00619                      << "</TR>";
00620             }       
00621         }
00622         
00623         if ( ! m_EEclusters.empty() )
00624         {
00625             nClusters = 0;
00626             
00627             for ( iC  = m_EEclusters.begin();
00628                   iC != m_EEclusters.end(); ++iC)
00629             {
00630                 double energy = (*iC).energy();
00631                 double eta = (*iC).position().Eta();
00632                 double phi = (*iC).position().Phi();
00633 
00634                 text << "<TR align = right>"
00635                      << "<TD>" << std::setw (3) << nClusters++ << "</TD>"
00636                      << "<TD> EE </TD>"
00637                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00638                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00639                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00640                      << "</TR>";
00641             }       
00642         }
00643     }
00644     
00645     catch (cms::Exception& e)
00646     {
00647         if (this->m_onCmsException)
00648             this->m_onCmsException (&e);
00649     }
00650     catch (lat::Error &e) 
00651     {
00652         if (this->m_onError)
00653             this->m_onError (&e);
00654     }
00655     catch (std::exception &e) 
00656     {
00657         if (this->m_onException)
00658             this->m_onException (&e);
00659     }
00660     catch (...) 
00661     {
00662         if (this->m_onUnhandledException)
00663             this->m_onUnhandledException ();
00664     }   
00665 
00666     text << "</table>";
00667   
00668     IgQtLock();
00669     rep->setText(text.str());
00670 }

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

Reimplemented from VisQueuedTwig.

Definition at line 433 of file VisPFClusterTwig.cc.

References Ig3DBaseRep::clear(), e, IgSoTower::emFraction, IgSoTower::energy, relval_parameters_module::energy, eta, IgSoTower::etaWidth, exception, m_EBclusters, m_EEclusters, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, Ig3DBaseRep::node(), phi, IgSoTower::phiWidth, IgSoTower::position, IgSoTower::scaleFactor, and VisQueuedTwig::update().

00434 {
00435      VisQueuedTwig::update(rep);
00436      
00437      IgQtLock();
00438      rep->clear();
00439     
00440      SoSeparator* sep = new SoSeparator();
00441 
00442      try
00443      {
00444          if ( ! m_EBclusters.empty() )
00445          {
00446              std::vector<reco::PFCluster>::const_iterator iC;
00447              
00448              for ( iC  = m_EBclusters.begin();
00449                    iC != m_EBclusters.end(); ++iC)
00450              {
00451                  IgSoTower* tower = new IgSoTower();
00452                 
00453                  double energy = (*iC).energy();
00454                  tower->energy = energy;
00455                  
00456                  double eta = (*iC).position().Eta();
00457                  double phi = (*iC).position().Phi();
00458                  (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00459                  tower->position = SbVec2f(phi, eta);
00460                 
00461                  tower->scaleFactor = 1.0;
00462                  tower->etaWidth = 0.0174;
00463                  tower->phiWidth = 0.0174;
00464                  tower->emFraction = 1.0;
00465 
00466                  sep->addChild(tower);
00467              }     
00468          } 
00469     
00470          /*
00471          if ( ! m_HBclusters.empty() )
00472          { 
00473              std::vector<reco::PFCluster>::const_iterator iC;
00474             
00475              for ( iC  = m_HBclusters.begin();
00476                    iC != m_HBclusters.end(); ++iC)
00477              {
00478                  IgSoTower* tower = new IgSoTower();
00479                 
00480                  double energy = (*iC).energy();
00481                  tower->energy = energy;
00482                 
00483                  double eta = (*iC).position().Eta();
00484                  double phi = (*iC).position().Phi();
00485                  (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00486                  tower->position = SbVec2f(phi, eta);
00487         
00488                  tower->scaleFactor = 1.0;
00489                  tower->emFraction = 0.0;
00490 
00491                  sep->addChild(tower);
00492              }   
00493          }
00494          */
00495 
00496          if ( ! m_EEclusters.empty() )
00497          {
00498              std::vector<reco::PFCluster>::const_iterator iC;
00499              
00500              for ( iC  = m_EEclusters.begin();
00501                    iC != m_EEclusters.end(); ++iC)
00502              {
00503                  IgSoTower* tower = new IgSoTower();
00504                 
00505                  double energy = (*iC).energy();
00506                  tower->energy = energy;
00507                  
00508                  double eta = (*iC).position().Eta();
00509                  double phi = (*iC).position().Phi();
00510                  (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00511                  tower->position = SbVec2f(phi, eta);
00512                 
00513                  tower->scaleFactor = 1.0;
00514                  tower->etaWidth = 0.0174;
00515                  tower->phiWidth = 0.0174;
00516                  tower->emFraction = 1.0;
00517 
00518                  sep->addChild(tower);
00519              }     
00520          } 
00521      }
00522      
00523      catch (cms::Exception& e)
00524      {  
00525          if (this->m_onCmsException)
00526              this->m_onCmsException (&e);
00527      }  
00528     
00529      catch (lat::Error &e) 
00530      {
00531          if (this->m_onError)
00532              this->m_onError (&e);
00533      }
00534 
00535      catch (std::exception &e) 
00536      {
00537          if (this->m_onException)
00538              this->m_onException (&e);
00539      }
00540 
00541      catch (...) 
00542      {
00543          if (this->m_onUnhandledException)
00544              this->m_onUnhandledException ();
00545      }  
00546      
00547      rep->node()->addChild(sep);
00548 }

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

Reimplemented from VisQueuedTwig.

Definition at line 235 of file VisPFClusterTwig.cc.

References Ig3DBaseRep::clear(), e, exception, CaloCellGeometry::getCorners(), edm::ESHandle< T >::isValid(), m_EBrechits, m_EErechits, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_pDD, Ig3DBaseRep::node(), EZArrayFL< T >::size(), VisQueuedTwig::update(), x, y, and z.

00236 { 
00237     VisQueuedTwig::update(rep);     
00238  
00239     IgQtLock();
00240     rep->clear();
00241 
00242     SoSeparator* sep = new SoSeparator;
00243    
00244     try
00245     {
00246         std::vector<RecHit>::iterator iR;
00247         
00248         if ( ! m_EBrechits.empty() && m_pDD.isValid() )
00249         {
00250             SoMaterial* EBmat = new SoMaterial;
00251             EBmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00252             sep->addChild(EBmat);
00253 
00254             for ( iR  = m_EBrechits.begin();
00255                   iR != m_EBrechits.end();
00256                   ++iR )
00257             {   
00258                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId);
00259                     
00260                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00261                 assert(corners.size () == 8);
00262                 
00263                 IgSoCrystalHit* eb_crystalHit = new IgSoCrystalHit;
00264                 eb_crystalHit->energy.setValue((*iR).energy);               
00265                 eb_crystalHit->scale.setValue(1.0*(*iR).fraction);
00266                 eb_crystalHit->relativeWidth.setValue(1.0);
00267                 eb_crystalHit->drawCrystal.setValue(true);
00268                 eb_crystalHit->drawHit.setValue(true);
00269                         
00270                 eb_crystalHit->front1.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00271                 eb_crystalHit->front2.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00272                 eb_crystalHit->front3.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00273                 eb_crystalHit->front4.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00274                 
00275                 eb_crystalHit->back1.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00276                 eb_crystalHit->back2.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00277                 eb_crystalHit->back3.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00278                 eb_crystalHit->back4.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00279                 
00280                 sep->addChild(eb_crystalHit);
00281             }
00282         }
00283         
00284         /*
00285         std::vector<reco::PFCluster>::const_iterator iC;
00286         
00287         if ( ! m_EBclusters.empty() && m_pDD.isValid() )
00288         {  
00289             SoMaterial* EBmat = new SoMaterial;
00290             EBmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00291             sep->addChild(EBmat);
00292              
00293             for ( iC  = m_EBclusters.begin();
00294                   iC != m_EBclusters.end(); ++iC)
00295             {
00296                 double energy = (*iC).energy();
00297               
00298                 std::vector<reco::PFRecHitFraction>::const_iterator iR;
00299                 
00300                 if ( ! (*iC).recHitFractions().empty() )
00301                 {   
00302                     for ( iR  = (*iC).recHitFractions().begin();
00303                           iR != (*iC).recHitFractions().end(); 
00304                           ++iR )
00305                     {
00306                         const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).recHitRef()->detId());
00307                     
00308                         const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00309                         assert(corners.size () == 8);
00310                     
00311                         IgSoCrystalHit* eb_crystalHit = new IgSoCrystalHit;
00312                         eb_crystalHit->energy.setValue((*iR).recHitRef()->energy());                
00313                         eb_crystalHit->scale.setValue(1.0);
00314                         eb_crystalHit->relativeWidth.setValue(1.0);
00315                         eb_crystalHit->drawCrystal.setValue(true);
00316                         eb_crystalHit->drawHit.setValue(true);
00317                     
00318                         eb_crystalHit->front1.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00319                         eb_crystalHit->front2.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00320                         eb_crystalHit->front3.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00321                         eb_crystalHit->front4.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00322                     
00323                         eb_crystalHit->back1.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00324                         eb_crystalHit->back2.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00325                         eb_crystalHit->back3.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00326                         eb_crystalHit->back4.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00327                     
00328                         sep->addChild(eb_crystalHit);
00329                     }    
00330                 }
00331             }
00332         }
00333         */
00334 
00335         /*
00336         if ( ! m_HBrechits.empty() && m_pDD.isValid() )
00337         { 
00338             SoMaterial* HBmat = new SoMaterial;
00339             HBmat->diffuseColor.setValue(0.0, 0.4, 1.0);
00340             sep->addChild(HBmat);
00341 
00342             for ( iR  = m_HBrechits.begin();
00343                   iR != m_HBrechits.end(); ++iR)
00344             {
00345                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId);
00346 
00347                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00348                 assert(corners.size () == 8);
00349                 
00350                 IgSoCrystalHit* hb_crystalHit = new IgSoCrystalHit;
00351                 hb_crystalHit->energy.setValue((*iR).energy);               
00352                 hb_crystalHit->scale.setValue(1.0*(*iR).fraction);
00353                 hb_crystalHit->relativeWidth.setValue(0.9);
00354                 hb_crystalHit->drawCrystal.setValue(false);
00355                 hb_crystalHit->drawHit.setValue(true);
00356 
00357                 hb_crystalHit->front1.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00358                 hb_crystalHit->front2.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00359                 hb_crystalHit->front3.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00360                 hb_crystalHit->front4.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00361                     
00362                 hb_crystalHit->back1.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00363                 hb_crystalHit->back2.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00364                 hb_crystalHit->back3.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00365                 hb_crystalHit->back4.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00366                     
00367                 sep->addChild(hb_crystalHit); 
00368             }       
00369         }
00370         */
00371         
00372         if ( ! m_EErechits.empty() && m_pDD.isValid() )
00373         {
00374             SoMaterial* EEmat = new SoMaterial;
00375             EEmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00376             sep->addChild(EEmat);
00377 
00378             for ( iR  = m_EErechits.begin();
00379                   iR != m_EErechits.end();
00380                   ++iR )
00381             {   
00382                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId);
00383                     
00384                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00385                 assert(corners.size () == 8);
00386                 
00387                 IgSoCrystalHit* ee_crystalHit = new IgSoCrystalHit;
00388                 ee_crystalHit->energy.setValue((*iR).energy);               
00389                 ee_crystalHit->scale.setValue(1.0*(*iR).fraction);
00390                 ee_crystalHit->relativeWidth.setValue(1.0);
00391                 ee_crystalHit->drawCrystal.setValue(true);
00392                 ee_crystalHit->drawHit.setValue(true);
00393                         
00394                 ee_crystalHit->front1.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00395                 ee_crystalHit->front2.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00396                 ee_crystalHit->front3.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00397                 ee_crystalHit->front4.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00398                 
00399                 ee_crystalHit->back1.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00400                 ee_crystalHit->back2.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00401                 ee_crystalHit->back3.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00402                 ee_crystalHit->back4.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00403                 
00404                 sep->addChild(ee_crystalHit);
00405             }
00406         }
00407     }
00408     
00409     catch (cms::Exception& e)
00410     {
00411         if (this->m_onCmsException)
00412             this->m_onCmsException (&e);
00413     }
00414     catch (lat::Error &e) 
00415     {
00416         if (this->m_onError)
00417             this->m_onError (&e);
00418     }
00419     catch (std::exception &e) 
00420     {
00421         if (this->m_onException)
00422             this->m_onException (&e);
00423     }
00424     catch (...) 
00425     {
00426         if (this->m_onUnhandledException)
00427             this->m_onUnhandledException ();
00428     }   
00429 
00430     rep->node()->addChild(sep);
00431 }


Member Data Documentation

std::vector<reco::PFCluster> VisPFClusterTwig::m_EBclusters [private]

Definition at line 64 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

std::vector<RecHit> VisPFClusterTwig::m_EBrechits [private]

Definition at line 68 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

std::vector<reco::PFCluster> VisPFClusterTwig::m_EEclusters [private]

Definition at line 66 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

std::vector<RecHit> VisPFClusterTwig::m_EErechits [private]

Definition at line 70 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

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

Definition at line 59 of file VisPFClusterTwig.h.

Referenced by onNewEvent().

std::vector<reco::PFCluster> VisPFClusterTwig::m_HBclusters [private]

Definition at line 65 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

std::vector<RecHit> VisPFClusterTwig::m_HBrechits [private]

Definition at line 69 of file VisPFClusterTwig.h.

Referenced by onNewEvent().

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

Definition at line 61 of file VisPFClusterTwig.h.

Referenced by onNewEvent().

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

Definition at line 60 of file VisPFClusterTwig.h.

Referenced by onNewEvent().

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

Reimplemented from IgSimpleTwig.

Definition at line 58 of file VisPFClusterTwig.h.

Referenced by update().

edm::ESHandle<CaloGeometry> VisPFClusterTwig::m_pDD [private]

Definition at line 72 of file VisPFClusterTwig.h.

Referenced by onNewEvent(), and update().

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

Definition at line 62 of file VisPFClusterTwig.h.

Referenced by onNewEvent().

std::string VisPFClusterTwig::m_text [private]

Definition at line 56 of file VisPFClusterTwig.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