CMS 3D CMS Logo

VisPFRecHitTwig.cc

Go to the documentation of this file.
00001 #include "VisReco/VisPF/interface/VisPFRecHitTwig.h"
00002 
00003 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00005 
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 
00009 #include "Iguana/Models/interface/IgTextRep.h"
00010 
00011 #include "Iguana/GLModels/interface/Ig3DRep.h"
00012 #include "Iguana/GLModels/interface/IgLegoRep.h"
00013 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00014 #include "Iguana/GLModels/interface/IgRZRep.h"
00015 
00016 #include "Iguana/Framework/interface/IgRepSet.h"
00017 
00018 #include "Iguana/Inventor/interface/IgSbColorMap.h"
00019 #include "Iguana/Inventor/interface/IgSoCrystalHit.h"
00020 #include "Iguana/Inventor/interface/IgSoCircularHist.h"
00021 #include "Iguana/Inventor/interface/IgSoRZHist.h"
00022 #include "Iguana/Inventor/interface/IgSoTower.h"
00023 
00024 #include "Iguana/Studio/interface/IgQtLock.h"
00025 
00026 #include <Inventor/nodes/SoMaterial.h>
00027 #include <Inventor/nodes/SoSeparator.h>
00028 
00029 #include "Math/GenVector/PositionVector3D.h"
00030 
00031 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
00032 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00033 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00034 
00035 #include <qstring.h>
00036 #include <classlib/utils/DebugAids.h>
00037 #include <algorithm>
00038 #include <iostream>
00039 #include <iomanip>
00040 
00041 namespace 
00042 {
00043     VisQueuedTwig* createThisTwig(IgState *state, IgTwig *parent,
00044                                   const std::string &name,
00045                                   const std::string &friendlyName,
00046                                   const std::string &modLabel,
00047                                   const std::string &instanceName,
00048                                   const std::string &processName)
00049     {
00050         return new VisPFRecHitTwig(state, parent, name, friendlyName, modLabel, instanceName, processName);
00051     }
00052 }
00053 
00054 VisPFRecHitTwig::VisPFRecHitTwig(IgState *state, IgTwig *parent, 
00055                                    const std::string &name,
00056                                    const std::string &friendlyName, 
00057                                    const std::string &moduleLabel, 
00058                                    const std::string &instanceName, 
00059                                    const std::string &processName) 
00060     : VisQueuedTwig(state, parent, name), 
00061       m_text("No Info"),
00062       m_name(name),
00063       m_friendlyName(friendlyName),
00064       m_moduleLabel(moduleLabel),
00065       m_instanceName(instanceName),
00066       m_processName(processName)
00067 {
00068     VisTwigFactroyService *tfService = VisTwigFactroyService::get(state);
00069     
00070     if (! tfService)
00071     {
00072         tfService = new VisTwigFactroyService(state);
00073     }
00074         
00075     edm::TypeID pfRecHitsID(typeid (reco::PFRecHitCollection));
00076     
00077     tfService->registerTwig(pfRecHitsID.friendlyClassName(), &createThisTwig);
00078 }
00079 
00080 void VisPFRecHitTwig::onNewEvent(const edm::Event &event,
00081                                   const edm::EventSetup &eventSetup)
00082 {
00083     VisQueuedTwig::onNewEvent(event, eventSetup);
00084 
00085     m_EBrechits.clear();
00086     m_HBrechits.clear();
00087     m_EErechits.clear();
00088     
00089     std::vector<edm::Handle<reco::PFRecHitCollection> > rechitCollections;
00090 
00091     try
00092     {
00093         eventSetup.get<IdealGeometryRecord>().get(m_pDD);
00094     }
00095 
00096     catch (cms::Exception& e)
00097     {
00098         if (this->m_onCmsException)
00099             this->m_onCmsException(&e);
00100     }
00101 
00102     catch (lat::Error &e) 
00103     {
00104         if (this->m_onError)
00105             this->m_onError(&e);
00106     }
00107 
00108     catch (std::exception &e) 
00109     {
00110         if (this->m_onException)
00111             this->m_onException(&e);
00112     }
00113 
00114     catch (...) 
00115     {
00116         if (this->m_onUnhandledException)
00117             this->m_onUnhandledException();
00118     }
00119 
00120     try
00121     {
00122         if ( (! m_friendlyName.empty ()) || 
00123              (! m_moduleLabel.empty ())  || 
00124              (! m_instanceName.empty ()) || 
00125              (! m_processName.empty ()) )
00126         {
00127             VisEventSelector visSel(m_friendlyName, m_moduleLabel, 
00128                                     m_instanceName, m_processName);
00129             
00130             event.getMany(visSel, rechitCollections);
00131         }
00132 
00133         else
00134         {
00135             event.getManyByType(rechitCollections);
00136         }          
00137     }
00138     
00139     catch (cms::Exception& e)
00140     {
00141         if (this->m_onCmsException)
00142             this->m_onCmsException(&e);
00143     }
00144 
00145     catch (lat::Error &e) 
00146     {
00147         if (this->m_onError)
00148             this->m_onError(&e);
00149     }
00150 
00151     catch (std::exception &e) 
00152     {
00153         if (this->m_onException)
00154             this->m_onException(&e);
00155     }
00156 
00157     catch (...) 
00158     {
00159         if (this->m_onUnhandledException)
00160             this->m_onUnhandledException();
00161     }
00162     
00163     if (! rechitCollections.empty())
00164     {   
00165         for (std::vector<edm::Handle<reco::PFRecHitCollection> >::iterator i = 
00166                  rechitCollections.begin(), iEnd = rechitCollections.end(); 
00167              i != iEnd; ++i) 
00168         {
00169             const reco::PFRecHitCollection& c = *(*i);
00170 
00171             for (std::vector<reco::PFRecHit>::const_iterator ipfrh = c.begin(), ipfrhEnd = c.end();
00172                  ipfrh != ipfrhEnd; ++ipfrh)
00173             {
00174                 if ( (*ipfrh).layer() == PFLayer::ECAL_BARREL )
00175                     m_EBrechits.push_back((*ipfrh));
00176                 
00177                 if ( (*ipfrh).layer() == PFLayer::ECAL_ENDCAP )
00178                     m_EErechits.push_back((*ipfrh));
00179 
00180                 if ( (*ipfrh).layer() == PFLayer::HCAL_BARREL1 )
00181                     m_HBrechits.push_back((*ipfrh));
00182             }    
00183         }
00184     }
00185 
00186     else
00187         std::cout<<"DEBUG: rechitCollections.empty()"<<std::endl;
00188     
00189     VisQueuedTwig::onBaseInvalidate();
00190 }
00191 
00192 
00193 void  VisPFRecHitTwig::update(IgTextRep *rep)
00194 {
00195     VisQueuedTwig::update(rep);
00196 
00197     std::ostringstream  text;
00198 
00199     text << m_name << " from ";
00200     text << m_text << "<br>";
00201     text << "Total: " << m_EBrechits.size () << " EB PFRecHits.<br>";
00202     text << "Total: " << m_HBrechits.size () << " HB PFRecHits.<br>";
00203     text << "Total: " << m_EErechits.size () << " EE PFRecHits.<br>"; 
00204     
00205     text << "<table width='100%' border=1>"
00206          << "<TR align = center>"
00207          << "<TH>Number</TH>"
00208          << "<TH>Detector</TH>"
00209          << "<TH>Energy (GeV)</TH>"
00210          << "<TH>Eta</TH>"
00211          << "<TH>Phi (deg)</TH>"
00212          << "</TR>";
00213  
00214     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00215     text.setf (std::ios::right, std::ios::adjustfield);
00216 
00217     int nHits;
00218     
00219     try
00220     {
00221         std::vector<reco::PFRecHit>::const_iterator iRH;
00222         
00223         if ( ! m_EBrechits.empty() )
00224         {    
00225             nHits = 0;
00226             
00227             for ( iRH  = m_EBrechits.begin();
00228                   iRH != m_EBrechits.end(); ++iRH)
00229             {   
00230                 double energy = (*iRH).energy();
00231                 double eta = (*iRH).position().Eta();
00232                 double phi = (*iRH).position().Phi();
00233             
00234                 text << "<TR align = right>"
00235                      << "<TD>" << std::setw (3) << nHits++ << "</TD>"
00236                      << "<TD> EB </TD>" 
00237                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00238                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00239                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00240                      << "</TR>";
00241             }
00242         }
00243 
00244         if ( ! m_HBrechits.empty() )
00245         {   
00246             nHits = 0;
00247             
00248             for ( iRH  = m_HBrechits.begin();
00249                   iRH != m_HBrechits.end(); ++iRH)
00250             {   
00251                 double energy = (*iRH).energy();
00252                 double eta = (*iRH).position().Eta();
00253                 double phi = (*iRH).position().Phi();
00254             
00255                 text << "<TR align = right>"
00256                      << "<TD>" << std::setw (3) << nHits++ << "</TD>"
00257                      << "<TD> HB </TD>"
00258                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00259                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00260                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00261                      << "</TR>";
00262             }
00263         }
00264         
00265         if ( ! m_EErechits.empty() )
00266         {   
00267             nHits = 0;
00268             
00269             for ( iRH  = m_EErechits.begin();
00270                   iRH != m_EErechits.end(); ++iRH)
00271             {   
00272                 double energy = (*iRH).energy();
00273                 double eta = (*iRH).position().Eta();
00274                 double phi = (*iRH).position().Phi();
00275             
00276                 text << "<TR align = right>"
00277                      << "<TD>" << std::setw (3) << nHits++ << "</TD>"
00278                      << "<TD> EE </TD>"
00279                      << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00280                      << "<TD>" << std::setw (5) << std::setprecision (3) << eta << "</TD>"
00281                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00282                      << "</TR>";
00283             }
00284         }
00285 
00286     }
00287         
00288     catch (cms::Exception& e)
00289     {
00290         if (this->m_onCmsException)
00291             this->m_onCmsException (&e);
00292     }   
00293     catch (lat::Error &e) 
00294     {
00295         if (this->m_onError)
00296             this->m_onError (&e);
00297     }   
00298     catch (std::exception &e) 
00299     {
00300         if (this->m_onException)
00301             this->m_onException (&e);
00302     }   
00303     catch (...) 
00304     {
00305         if (this->m_onUnhandledException)
00306             this->m_onUnhandledException ();
00307     }
00308 
00309     text << "</table>";
00310    
00311 
00312     IgQtLock();
00313     rep->setText(text.str());
00314 }
00315 
00316 void  VisPFRecHitTwig::update(Ig3DRep *rep)
00317 {
00318     VisQueuedTwig::update(rep);      
00319     IgQtLock();
00320     rep->clear();
00321     
00322     SoSeparator* sep = new SoSeparator;
00323     
00324     try
00325     {
00326         std::vector<reco::PFRecHit>::const_iterator iR;
00327         
00328         if ( ! m_EBrechits.empty() && m_pDD.isValid() )
00329         {           
00330         
00331             SoMaterial* EBmat = new SoMaterial;
00332             EBmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00333             sep->addChild(EBmat);
00334 
00335             for ( iR  = m_EBrechits.begin();
00336                   iR != m_EBrechits.end(); ++iR)
00337             {
00338                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId());
00339 
00340                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00341                 assert(corners.size () == 8);
00342                 
00343                 IgSoCrystalHit* eb_crystalHit = new IgSoCrystalHit;
00344                 eb_crystalHit->energy.setValue((*iR).energy());             
00345                 eb_crystalHit->scale.setValue(1.0);
00346                 eb_crystalHit->relativeWidth.setValue(1.0);
00347                 eb_crystalHit->drawCrystal.setValue(true);
00348                 eb_crystalHit->drawHit.setValue(true);
00349                     
00350                 eb_crystalHit->front1.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00351                 eb_crystalHit->front2.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00352                 eb_crystalHit->front3.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00353                 eb_crystalHit->front4.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00354                     
00355                 eb_crystalHit->back1.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00356                 eb_crystalHit->back2.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00357                 eb_crystalHit->back3.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00358                 eb_crystalHit->back4.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00359                     
00360                 sep->addChild(eb_crystalHit); 
00361             }       
00362         }
00363 
00364         /*
00365           This needs a closer look:
00366           - One hit persists through all the events
00367           - They seem to be on HO instead of HB (though it looks like they correspond to regular HBRecHits)
00368           - Some lie off the end of the barrel (this seems to be because they appear to correspond to HERecHits)
00369         */
00370 
00371         /*
00372         if ( ! m_HBrechits.empty() && m_pDD.isValid() )
00373         { 
00374             SoMaterial* HBmat = new SoMaterial;
00375             HBmat->diffuseColor.setValue(0.0, 0.4, 1.0);
00376             sep->addChild(HBmat);
00377 
00378             for ( iR  = m_HBrechits.begin();
00379                   iR != m_HBrechits.end(); ++iR)
00380             {
00381                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId());
00382 
00383                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00384                 assert(corners.size () == 8);
00385                 
00386                 IgSoCrystalHit* hb_crystalHit = new IgSoCrystalHit;
00387                 hb_crystalHit->energy.setValue((*iR).energy());             
00388                 hb_crystalHit->scale.setValue(1.0);
00389                 hb_crystalHit->relativeWidth.setValue(0.9);
00390                 hb_crystalHit->drawCrystal.setValue(false);
00391                 hb_crystalHit->drawHit.setValue(true);
00392 
00393                 hb_crystalHit->front1.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00394                 hb_crystalHit->front2.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00395                 hb_crystalHit->front3.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00396                 hb_crystalHit->front4.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00397                     
00398                 hb_crystalHit->back1.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00399                 hb_crystalHit->back2.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00400                 hb_crystalHit->back3.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00401                 hb_crystalHit->back4.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00402                     
00403                 sep->addChild(hb_crystalHit); 
00404             }       
00405         }
00406         */
00407 
00408         if ( ! m_EErechits.empty() )
00409         {   
00410             SoMaterial* EEmat = new SoMaterial;
00411             EEmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00412             sep->addChild(EEmat);
00413 
00414             for ( iR  = m_EErechits.begin();
00415                   iR != m_EErechits.end(); ++iR)
00416             {
00417                 const CaloCellGeometry* cell = (*m_pDD).getGeometry((*iR).detId());
00418 
00419                 const CaloCellGeometry::CornersVec& corners = cell->getCorners();
00420                 assert(corners.size () == 8);
00421                 
00422                 IgSoCrystalHit* ee_crystalHit = new IgSoCrystalHit;
00423                 ee_crystalHit->energy.setValue((*iR).energy());             
00424                 ee_crystalHit->scale.setValue(1.0);
00425                 ee_crystalHit->relativeWidth.setValue(0.9);
00426                 ee_crystalHit->drawCrystal.setValue(false);
00427                 ee_crystalHit->drawHit.setValue(true);
00428 
00429                 ee_crystalHit->front1.setValue(corners[3].x()/100.0, corners[3].y()/100.0, corners[3].z()/100.0);
00430                 ee_crystalHit->front2.setValue(corners[2].x()/100.0, corners[2].y()/100.0, corners[2].z()/100.0);
00431                 ee_crystalHit->front3.setValue(corners[1].x()/100.0, corners[1].y()/100.0, corners[1].z()/100.0);
00432                 ee_crystalHit->front4.setValue(corners[0].x()/100.0, corners[0].y()/100.0, corners[0].z()/100.0);
00433                     
00434                 ee_crystalHit->back1.setValue(corners[7].x()/100.0, corners[7].y()/100.0, corners[7].z()/100.0);
00435                 ee_crystalHit->back2.setValue(corners[6].x()/100.0, corners[6].y()/100.0, corners[6].z()/100.0);
00436                 ee_crystalHit->back3.setValue(corners[5].x()/100.0, corners[5].y()/100.0, corners[5].z()/100.0);
00437                 ee_crystalHit->back4.setValue(corners[4].x()/100.0, corners[4].y()/100.0, corners[4].z()/100.0);
00438                     
00439                 sep->addChild(ee_crystalHit); 
00440             }       
00441         }
00442     }
00443     
00444     catch (cms::Exception& e)
00445     {
00446         if (this->m_onCmsException)
00447             this->m_onCmsException (&e);
00448     }
00449     catch (lat::Error &e) 
00450     {
00451         if (this->m_onError)
00452             this->m_onError (&e);
00453     }
00454     catch (std::exception &e) 
00455     {
00456         if (this->m_onException)
00457             this->m_onException (&e);
00458     }
00459     catch (...) 
00460     {
00461         if (this->m_onUnhandledException)
00462             this->m_onUnhandledException ();
00463     }   
00464 
00465     rep->node ()->addChild (sep);
00466  
00467 }
00468 
00469 void  VisPFRecHitTwig::update(IgLegoRep *rep)
00470 {
00471     VisQueuedTwig::update(rep);
00472 
00473     IgQtLock();
00474     rep->clear();
00475     
00476     SoSeparator* sep = new SoSeparator();
00477     
00478     try
00479     {
00480         if ( ! m_EBrechits.empty() )
00481         {
00482             std::vector<reco::PFRecHit>::const_iterator iRH;
00483             
00484             for ( iRH  = m_EBrechits.begin();
00485                   iRH != m_EBrechits.end(); ++iRH)
00486             {
00487                 IgSoTower* tower = new IgSoTower();
00488                 
00489                 double energy = (*iRH).energy();
00490                 tower->energy = energy;
00491                  
00492                 double eta = (*iRH).position().Eta();
00493                 double phi = (*iRH).position().Phi();
00494                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00495                 tower->position = SbVec2f(phi, eta);
00496                 
00497                 tower->scaleFactor = 1.0;
00498                 tower->etaWidth = 0.0174;
00499                 tower->phiWidth = 0.0174;
00500                 tower->emFraction = 1.0;
00501 
00502                 sep->addChild(tower);
00503             }   
00504         } 
00505 
00506         /*
00507         if ( ! m_HBrechits.empty() )
00508         { 
00509             std::vector<reco::PFRecHit>::const_iterator iRH;
00510             
00511             for ( iRH  = m_HBrechits.begin();
00512                   iRH != m_HBrechits.end(); ++iRH)
00513             {
00514                 IgSoTower* tower = new IgSoTower();
00515                 
00516                 double energy = (*iRH).energy();
00517                 tower->energy = energy;
00518                 
00519                 double eta = (*iRH).position().Eta();
00520                 double phi = (*iRH).position().Phi();
00521                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00522                 tower->position = SbVec2f(phi, eta);
00523         
00524                 tower->scaleFactor = 1.0;
00525                 tower->emFraction = 0.0;
00526 
00527                 sep->addChild(tower);
00528             }   
00529         }
00530         */
00531         if ( ! m_EErechits.empty() )
00532         {
00533             std::vector<reco::PFRecHit>::const_iterator iRH;
00534             
00535             for ( iRH  = m_EErechits.begin();
00536                   iRH != m_EErechits.end(); ++iRH)
00537             {
00538                 IgSoTower* tower = new IgSoTower();
00539                 
00540                 double energy = (*iRH).energy();
00541                 tower->energy = energy;
00542                 
00543                 double eta = (*iRH).position().Eta();
00544                 double phi = (*iRH).position().Phi();
00545                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00546                 tower->position = SbVec2f(phi, eta);
00547         
00548                 tower->scaleFactor = 1.0;
00549                 tower->etaWidth = 0.0174;
00550                 tower->phiWidth = 0.0174;
00551                 tower->emFraction = 1.0;
00552 
00553                 sep->addChild(tower);
00554             }   
00555         }
00556     }
00557      
00558     catch (cms::Exception& e)
00559     {
00560         if (this->m_onCmsException)
00561             this->m_onCmsException (&e);
00562     }   
00563     
00564     catch (lat::Error &e) 
00565     {
00566         if (this->m_onError)
00567             this->m_onError (&e);
00568     }
00569 
00570     catch (std::exception &e) 
00571     {
00572         if (this->m_onException)
00573             this->m_onException (&e);
00574     }
00575 
00576     catch (...) 
00577     {
00578         if (this->m_onUnhandledException)
00579             this->m_onUnhandledException ();
00580     }   
00581      
00582     rep->node()->addChild(sep);
00583 }
00584 
00585 
00586 void  VisPFRecHitTwig::update(IgRPhiRep *rep)
00587 {
00588     VisQueuedTwig::update(rep);
00589 
00590     IgQtLock();
00591     rep->clear();
00592 
00593     SoSeparator* sep = new SoSeparator;    
00594     SoSeparator* posSep = new SoSeparator;    
00595     SoSeparator* negSep = new SoSeparator;
00596     sep->addChild(posSep);
00597     sep->addChild(negSep);
00598 
00599     int binNumber;
00600 
00601     try
00602     {
00603         if ( ! m_EBrechits.empty() )
00604         {
00605             SoMaterial* posEBmat = new SoMaterial;
00606             posEBmat->ambientColor.setValue(1.0, 0.0, 153.0 / 255.0);
00607             posEBmat->diffuseColor.setValue(1.0, 0.0, 153.0 / 255.0);
00608             posEBmat->specularColor.setValue(1.0, 0.0, 153.0 / 255.0);
00609             posEBmat->emissiveColor.setValue(1.0, 0.0, 153.0 / 255.0);
00610             posSep->addChild(posEBmat);
00611     
00612             SoMaterial* negEBmat = new SoMaterial;
00613             negEBmat->ambientColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00614             negEBmat->diffuseColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00615             negEBmat->specularColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00616             negEBmat->emissiveColor.setValue(51.0 / 255.0, 1.0, 102.0 / 255.0);
00617             negSep->addChild(negEBmat);
00618 
00619             int nbrOfBins = 360;
00620 
00621             std::vector<float> bufferPositive(nbrOfBins);
00622             std::vector<float> bufferNegative(nbrOfBins);
00623             
00624             std::vector<reco::PFRecHit>::const_iterator iRH;
00625             
00626             for ( iRH  = m_EBrechits.begin();
00627                   iRH != m_EBrechits.end(); ++iRH)
00628             {           
00629 
00630                 double energy = (*iRH).energy();
00631                 double phi = (*iRH).position().Phi();
00632                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00633 
00634                 binNumber = (int) floor (phi / (2 * M_PI / nbrOfBins));
00635  
00636                 (energy >= 0.0) ? bufferPositive[binNumber] += energy :  bufferNegative[binNumber] += energy;
00637              
00638             }
00639             
00640             std::vector<float>::const_iterator first = bufferPositive.begin();
00641             std::vector<float>::const_iterator last  = bufferPositive.end();
00642             
00643             if ( *max_element(first, last) > 0.0 )
00644             {
00645                 IgSoCircularHist* posEBrechits = new IgSoCircularHist;
00646                 posEBrechits->minRadius = 1.29;
00647                 posEBrechits->maxRadius = -1;
00648                 posEBrechits->scaleFactor = 1.0;
00649                 posEBrechits->numberOfBins = nbrOfBins;
00650                 posEBrechits->energies.setValues(0, nbrOfBins, &bufferPositive[0]);
00651                 posEBrechits->logScale = false;
00652                 posEBrechits->layer = 5.5;
00653                 posSep->addChild(posEBrechits);
00654             }
00655             
00656             std::vector<float>::const_iterator nfirst = bufferNegative.begin();
00657             std::vector<float>::const_iterator nlast  = bufferNegative.end();
00658             
00659             if ( fabs(*max_element(nfirst, nlast)) > 0.0 )
00660             {
00661                 IgSoCircularHist* negEBrechits = new IgSoCircularHist;
00662                 negEBrechits->minRadius = 1.29;
00663                 negEBrechits->maxRadius = -1;
00664                 negEBrechits->scaleFactor = 1.0;
00665                 negEBrechits->numberOfBins = nbrOfBins;
00666                 negEBrechits->energies.setValues(0, nbrOfBins, &bufferNegative[0]);
00667                 negEBrechits->logScale = false;
00668                 negEBrechits->layer = 5.0;
00669 
00670                 negSep->addChild(negEBrechits);
00671             }
00672         }
00673 
00674         /*      
00675         if ( ! m_HBrechits.empty() )
00676         {
00677             SoMaterial* posHBmat = new SoMaterial;
00678             posHBmat->ambientColor.setValue(0.0, 0.4, 1.0);
00679             posHBmat->diffuseColor.setValue(0.0, 0.4, 1.0);
00680             posHBmat->specularColor.setValue(0.0, 0.4, 1.0);
00681             posHBmat->emissiveColor.setValue(0.0, 0.4, 1.0);
00682             posSep->addChild(posHBmat);
00683     
00684             SoMaterial* negHBmat = new SoMaterial;
00685             negHBmat->ambientColor.setValue(1.0, 0.0, 0.0);
00686             negHBmat->diffuseColor.setValue(1.0, 0.0, 0.0);
00687             negHBmat->specularColor.setValue(1.0, 0.0, 0.0);
00688             negHBmat->emissiveColor.setValue(1.0, 0.0, 0.0);
00689             negSep->addChild(negHBmat);
00690 
00691             int nbrOfBins = 72;
00692 
00693             std::vector<float> bufferPositive(nbrOfBins);
00694             std::vector<float> bufferNegative(nbrOfBins);
00695 
00696             std::vector<reco::PFRecHit>::const_iterator iRH;
00697 
00698             for ( iRH  = m_HBrechits.begin();
00699                   iRH != m_HBrechits.end(); ++iRH)
00700             {           
00701                 double energy = (*iRH).energy();
00702                 double phi = (*iRH).position().Phi();
00703                 (phi < 0.0) ? phi = 2 * M_PI + phi : phi;
00704 
00705                 binNumber = (int) floor (phi / (2 * M_PI / nbrOfBins));
00706  
00707                 (energy >= 0.0) ? bufferPositive[binNumber] += energy :  bufferNegative[binNumber] += energy;
00708             }
00709             
00710             std::vector<float>::const_iterator first = bufferPositive.begin();
00711             std::vector<float>::const_iterator last  = bufferPositive.end();
00712             
00713             if ( *max_element(first, last) > 0.0 )
00714             {
00715                 IgSoCircularHist* posHBrechits = new IgSoCircularHist;
00716                 posHBrechits->minRadius = 1.9;
00717                 posHBrechits->maxRadius = -1;
00718                 posHBrechits->scaleFactor = 1.0;
00719                 posHBrechits->numberOfBins = nbrOfBins;
00720                 posHBrechits->energies.setValues(0, nbrOfBins, &bufferPositive[0]);
00721                 posHBrechits->logScale = false;
00722                 posHBrechits->layer = 5.5;
00723                 posSep->addChild(posHBrechits);
00724             }
00725             
00726             std::vector<float>::const_iterator nfirst = bufferNegative.begin();
00727             std::vector<float>::const_iterator nlast  = bufferNegative.end();
00728             
00729             if ( fabs(*max_element(nfirst, nlast)) > 0.0 )
00730             {
00731                 IgSoCircularHist* negHBrechits = new IgSoCircularHist;
00732                 negHBrechits->minRadius = 1.9;
00733                 negHBrechits->maxRadius = -1;
00734                 negHBrechits->scaleFactor = 1.0;
00735                 negHBrechits->numberOfBins = nbrOfBins;
00736                 negHBrechits->energies.setValues(0, nbrOfBins, &bufferNegative[0]);
00737                 negHBrechits->logScale = false;
00738                 negHBrechits->layer = 5.0;
00739 
00740                 negSep->addChild(negHBrechits);
00741             }
00742         }
00743         */
00744     }
00745     
00746     catch (cms::Exception& e)
00747     {
00748         if (this->m_onCmsException)
00749             this->m_onCmsException(&e);
00750     }
00751     
00752     catch (lat::Error &e) 
00753     {
00754         if (this->m_onError)
00755             this->m_onError(&e);
00756     }
00757 
00758     catch (std::exception &e) 
00759     {
00760         if (this->m_onException)
00761             this->m_onException(&e);
00762     }   
00763 
00764     catch (...) 
00765     {
00766         if (this->m_onUnhandledException)
00767             this->m_onUnhandledException();
00768     }
00769     
00770     rep->node()->addChild(sep);
00771 }
00772     
00773 void  VisPFRecHitTwig::update(IgRZRep *rep)
00774 {
00775     VisQueuedTwig::update(rep);
00776     IgQtLock();
00777     rep->clear();
00778 }
00779 

Generated on Tue Jun 9 17:50:24 2009 for CMSSW by  doxygen 1.5.4