CMS 3D CMS Logo

VisHORecHitTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/VisHcal/interface/VisHORecHitTwig.h"
00004 #include "VisReco/VisHcal/interface/VisHcalSubdetector.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00006 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00007 #include "VisFramework/VisEventSetup/interface/VisEventSetupService.h"
00008 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00009 #include "DataFormats/HcalRecHit/interface/HORecHit.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "Iguana/Framework/interface/IgRepSet.h"
00012 #include "Iguana/Models/interface/IgTextRep.h"
00013 #include "Iguana/GLModels/interface/Ig3DRep.h"
00014 #include "Iguana/GLModels/interface/IgLegoRep.h"
00015 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00016 #include "Iguana/GLModels/interface/IgRZRep.h"
00017 #include "Iguana/Inventor/interface/IgSbColorMap.h"
00018 #include "Iguana/Inventor/interface/IgSoCrystalHit.h"
00019 #include "Iguana/Inventor/interface/IgSoCircularHist.h"
00020 #include "Iguana/Inventor/interface/IgSoRectColHist.h"
00021 #include "Iguana/Inventor/interface/IgSoTower.h"
00022 #include "Iguana/Studio/interface/IgDocumentData.h"
00023 #include "Iguana/Studio/interface/IgQtAppStatusBarService.h"
00024 #include "Iguana/Studio/interface/IgQtLock.h"
00025 #include <Inventor/nodes/SoDrawStyle.h>
00026 #include <Inventor/nodes/SoMaterial.h>
00027 #include <Inventor/nodes/SoSeparator.h>
00028 #include <qapplication.h>
00029 #include <qstring.h>
00030 #include <classlib/utils/DebugAids.h>
00031 #include <algorithm>
00032 #include <iostream>
00033 #include <iomanip>
00034 
00035 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00036 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00037 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00038 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00039 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00040 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00041 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00042 
00043 namespace 
00044 {
00045     VisQueuedTwig *
00046     createThisTwig (IgState *state, IgTwig *parent,
00047                     const std::string &name,
00048                     const std::string &friendlyName,
00049                     const std::string &modLabel,
00050                     const std::string &instanceName,
00051                     const std::string &processName)
00052     {
00053         IgTwig *rootTwig = IgDocumentData::get (state)->root ();
00054         IgTwig *eventTwig = 0;
00055         eventTwig = rootTwig->lookup ("/Objects/CMS Event and Detector/HCAL Event/Hcal Outer RecHits");
00056         
00057         if (! eventTwig) 
00058             eventTwig = parent;
00059                 
00060         return new VisHORecHitTwig (state, eventTwig, "[N/A] HO RecHits (" + name + ")", 
00061                                     friendlyName, modLabel, instanceName, processName);
00062     }
00063 }
00064 
00065 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00066 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00067 
00068 VisHORecHitTwig::VisHORecHitTwig (IgState *state, IgTwig *parent,
00069                                   const std::string &name /* = "" */,
00070                                   const std::string &friendlyName /* = "" */,
00071                                   const std::string &moduleLabel /* = "" */,
00072                                   const std::string &instanceName /* = "" */,
00073                                   const std::string &processName /* = "" */,
00074                                   unsigned colour /* = 0x99ff0000 */)
00075     : VisQueuedTwig (state, parent, name),
00076       m_name (name),
00077       m_friendlyName (friendlyName),
00078       m_moduleLabel (moduleLabel),
00079       m_instanceName (instanceName),
00080       m_processName (processName),
00081       m_binning (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00082       m_annotation (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00083       m_escale (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00084       m_cut (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00085       m_scale (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00086       m_phiStart (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00087       m_phiDelta (state, lat::CreateCallback (this, &VisHORecHitTwig::twigChanged)),
00088       m_text ("no info"),
00089       m_recHits (402),
00090       m_rgba (colour)
00091 {
00092     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00093     if (! tfService)
00094     {
00095         tfService = new VisTwigFactroyService (state);
00096     }
00097     edm::TypeID recHitCollID (typeid (HORecHitCollection));
00098     tfService->registerTwig (recHitCollID.friendlyClassName (), &createThisTwig);
00099 }
00100 
00101 void
00102 VisHORecHitTwig::twigChanged (void)
00103 { IgRepSet::invalidate (this, SELF_MASK); }
00104 
00105 void
00106 VisHORecHitTwig::onNewEvent (const edm::Event &event,
00107                              const edm::EventSetup &eventSetup)
00108 {
00109     // Get debugging dump.
00110     VisQueuedTwig::onNewEvent (event, eventSetup);
00111 
00112     m_recHits.clear ();
00113 
00114     m_text = (QString ("Run # %1, event # %2")
00115               .arg (event.id ().run ())
00116               .arg (event.id ().event ()).latin1 ());
00117     
00118     std::vector<edm::Handle<HORecHitCollection> > recHits;
00119     try
00120     {
00121         QApplication::setOverrideCursor (Qt::waitCursor);
00122             
00123         if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (state ()))
00124             sbar->setMessage ("Retrieving an HORecHitCollection...");
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, recHits);
00130         }
00131 
00132         if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (state ()))
00133             sbar->setMessage ("HORecHitCollection done.");    
00134  
00135         QApplication::restoreOverrideCursor ();
00136     }
00137     catch (cms::Exception& e)
00138     {
00139         e.append (" from VisHORecHitTwig::onNewEvent ");
00140         e.append (this->name ());    
00141 
00142         if (this->m_onCmsException)
00143             this->m_onCmsException (&e);
00144     }
00145     catch (lat::Error &e) 
00146     {
00147         if (this->m_onError)
00148             this->m_onError (&e);
00149     }
00150     catch (std::exception &e) 
00151     {
00152         if (this->m_onException)
00153             this->m_onException (&e);
00154     }
00155     catch (...) 
00156     {
00157         if (this->m_onUnhandledException)
00158             this->m_onUnhandledException ();
00159     }
00160     if (! recHits.empty ())
00161     {
00162         for (std::vector<edm::Handle<HORecHitCollection> >::iterator i = recHits.begin (), iEnd = recHits.end (); i != iEnd; ++i) 
00163         {
00164             const HORecHitCollection& c = *(*i);
00165             QString sizeStr = (QString ("%1").arg (c.size ()));
00166             QString nameStr = QString (this->name ());
00167             int ib = nameStr.find ("[");
00168             int ie = nameStr.find ("]");
00169             nameStr.replace (ib + 1, ie - 1, sizeStr);
00170             this->name (nameStr);
00171             for (std::vector<HORecHit>::const_iterator ci = c.begin (), ciEnd = c.end (); 
00172                  ci != ciEnd; ++ci)
00173             {
00174                 m_recHits.push_back (*ci);
00175             }
00176         }
00177     }
00178         
00179     VisQueuedTwig::onBaseInvalidate ();
00180 
00181     if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (state ()))
00182         sbar->setMessage (QString (m_text));
00183 }
00184 
00185 void
00186 VisHORecHitTwig::update (IgTextRep *rep)
00187 {
00188     // Get debugging dump.
00189     VisQueuedTwig::update (rep);
00190 
00191     // Prepare property description.
00192     std::ostringstream  text;
00193     text << this->name ()  << " from ";
00194     text << m_text << "<br>";
00195     
00196     if (m_friendlyName.empty () && m_moduleLabel.empty () && m_instanceName.empty () && m_processName.empty ())
00197     {
00198         text << "Please, select the branches of this Twig for more information.";       
00199     }
00200     else
00201     {
00202         text << "Displayed only above  " << m_cut.value () << " GeV:<br>";
00203 
00204         text << "<table width='100%' border=1>"
00205              << "<TR align = center>"
00206              << "<TH>Number</TH>"
00207              << "<TH>Energy</TH>"
00208              << "<TH>Time</TH>"
00209              << "<TH>Subdetector</TH>"
00210              << "<TH>ietaAbs</TH>"
00211              << "<TH>ieta</TH>"
00212              << "<TH>iphi [rad]</TH>"
00213              << "<TH>Depth</TH>"
00214              << "</TR>";
00215         text << setiosflags (std::ios::showpoint | std::ios::fixed);
00216         text.setf (std::ios::right, std::ios::adjustfield);
00217     
00218         int nDigis = 0;
00219         try 
00220         {
00221             for (std::vector<HORecHit>::const_iterator i = m_recHits.begin (), iEnd = m_recHits.end (); i != iEnd; ++i) 
00222             {
00223                 float energy = (*i).energy ();
00224                 if (energy > m_cut.value ())
00225                 {
00226                     text << "<TR align = right>"
00227                          << "<TD>" << std::setw (3) << nDigis++ << "</TD>"
00228                          << "<TD>" << std::setw (5) << std::setprecision (3) << energy << "</TD>"
00229                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).time () << "</TD>"
00230                          << "<TD>" << std::setw (2) << VisHcalSubdetector::subDetName ((*i).id ().subdet ()) << "</TD>"
00231                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().ietaAbs () << "</TD>"
00232                          << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).id ().ieta () << "</TD>"
00233                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().iphi () << "</TD>"
00234                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().depth() << "</TD>"
00235                          << "</TR>";
00236                 }
00237             }   
00238         }
00239         catch (cms::Exception& e)
00240         {
00241             e.append (" from VisHORecHitTwig::update(IgTextRep*) ");
00242             e.append (this->name ());    
00243 
00244             if (this->m_onCmsException)
00245                 this->m_onCmsException (&e);
00246         }
00247         catch (lat::Error &e) 
00248         {
00249             if (this->m_onError)
00250                 this->m_onError (&e);
00251         }
00252         catch (std::exception &e) 
00253         {
00254             if (this->m_onException)
00255                 this->m_onException (&e);
00256         }
00257         catch (...) 
00258         {
00259             if (this->m_onUnhandledException)
00260                 this->m_onUnhandledException ();
00261         }
00262 
00263         text << "</table>";
00264     }
00265     
00266     // Send it over.
00267     IgQtLock ();
00268     rep->setText (text.str ());
00269 }
00270 
00271 void
00272 VisHORecHitTwig::update (Ig3DRep *rep)
00273 {
00274     // Get debugging dump.
00275     VisQueuedTwig::update (rep);
00276 
00277     IgQtLock ();
00278     rep->clear ();
00279 
00280     SoSeparator *sep = new SoSeparator;
00281 
00282     SoMaterial *mat = new SoMaterial;
00283     float rgbcomponents [4];
00284     IgSbColorMap::unpack (m_rgba, rgbcomponents);
00285     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00286     sep->addChild (mat);
00287     
00288     if (! m_recHits.empty ())
00289     {
00290         VisEventSetupService *esService = VisEventSetupService::get (state ());
00291         ASSERT (esService);
00292 
00293         try 
00294         {
00295             for (std::vector<HORecHit>::const_iterator i = m_recHits.begin (), iEnd = m_recHits.end (); i != iEnd; ++i) 
00296             {
00297                 float energy = (*i).energy ();
00298                 if (energy > m_cut.value ()) 
00299                 {
00300                     const CaloCellGeometry::CornersVec& corners = esService->getCorners ((*i).detid ());
00301                     ASSERT (corners.size () == 8);
00302                 
00303                     IgSoCrystalHit *crystalHit = new IgSoCrystalHit;
00304                     crystalHit->energy.setValue (energy);
00305                     
00306                     crystalHit->scale.setValue (100.0 * m_escale.value ()); //FIXME: the HO cell geometry needs a 100 times scale
00307                     crystalHit->relativeWidth.setValue (0.9);
00308                     crystalHit->drawCrystal.setValue (false);
00309                     crystalHit->drawHit.setValue (true);
00310 
00311                     crystalHit->front1.setValue (corners [0].x () / 100.0, corners [0].y () / 100.0, corners [0].z () / 100.0);
00312                     crystalHit->front2.setValue (corners [1].x () / 100.0, corners [1].y () / 100.0, corners [1].z () / 100.0);
00313                     crystalHit->front3.setValue (corners [2].x () / 100.0, corners [2].y () / 100.0, corners [2].z () / 100.0);
00314                     crystalHit->front4.setValue (corners [3].x () / 100.0, corners [3].y () / 100.0, corners [3].z () / 100.0);
00315                     
00316                     crystalHit->back1.setValue  (corners [4].x () / 100.0, corners [4].y () / 100.0, corners [4].z () / 100.0);
00317                     crystalHit->back2.setValue  (corners [5].x () / 100.0, corners [5].y () / 100.0, corners [5].z () / 100.0);
00318                     crystalHit->back3.setValue  (corners [6].x () / 100.0, corners [6].y () / 100.0, corners [6].z () / 100.0);
00319                     crystalHit->back4.setValue  (corners [7].x () / 100.0, corners [7].y () / 100.0, corners [7].z () / 100.0);
00320                     
00321                     sep->addChild (crystalHit);
00322                 }
00323             }
00324         }
00325         catch (cms::Exception& e)
00326         {
00327             e.append (" from VisHORecHitTwig::update(Ig3DRep*) ");
00328             e.append (this->name ());    
00329 
00330             if (this->m_onCmsException)
00331                 this->m_onCmsException (&e);
00332         }
00333         catch (lat::Error &e) 
00334         {
00335             if (this->m_onError)
00336                 this->m_onError (&e);
00337         }
00338         catch (std::exception &e) 
00339         {
00340             if (this->m_onException)
00341                 this->m_onException (&e);
00342         }
00343         catch (...) 
00344         {
00345             if (this->m_onUnhandledException)
00346                 this->m_onUnhandledException ();
00347         }
00348     }
00349     
00350     rep->node ()->addChild (sep);
00351 }
00352 
00353 void
00354 VisHORecHitTwig::update (IgLegoRep *rep)
00355 {
00356     // Get debugging dump.
00357     VisQueuedTwig::update (rep);
00358 
00359     IgQtLock ();
00360     rep->clear ();
00361     
00362     SoSeparator *sep = new SoSeparator;    
00363 
00364     try 
00365     {
00366         if (! m_recHits.empty ())
00367         {
00368             for (std::vector<HORecHit>::const_iterator i = m_recHits.begin (), iEnd = m_recHits.end (); i != iEnd; ++i) 
00369             {
00370                 float et = (*i).energy ();
00371                 if (fabs (et) > m_cut.value ()) 
00372                 {
00373                     int iphi = (*i).id ().iphi ();
00374                     int ieta = (*i).id ().ieta ();
00375                     
00376                     float phi = (iphi - 1) * 0.087 + 0.087 / 2.0;
00377                     float eta = ieta * 0.087 + 0.087 / 2.0;
00378             
00379                     IgSoTower *tower = new IgSoTower;
00380                     tower->position = SbVec2f (phi, eta); // eta, phi
00381                     tower->scaleFactor = m_scale.value ();
00382                     tower->energy = et;
00383                     tower->emFraction = 0.0; // EM/Total 0%
00384                     sep->addChild (tower);
00385                 }
00386             }
00387         }
00388     }
00389     catch (cms::Exception& e)
00390     {
00391         e.append (" from VisHORecHitTwig::update(IgLegoRep *) ");
00392         e.append (this->name ());    
00393 
00394         if (this->m_onCmsException)
00395             this->m_onCmsException (&e);
00396     }
00397     catch (lat::Error &e) 
00398     {
00399         if (this->m_onError)
00400             this->m_onError (&e);
00401     }
00402     catch (std::exception &e) 
00403     {
00404         if (this->m_onException)
00405             this->m_onException (&e);
00406     }
00407     catch (...) 
00408     {
00409         if (this->m_onUnhandledException)
00410             this->m_onUnhandledException ();
00411     }
00412 
00413     rep->node ()->addChild (sep);
00414 }
00415 
00416 void
00417 VisHORecHitTwig::update (IgRPhiRep *rep)
00418 {
00419     // Get debugging dump.
00420     VisQueuedTwig::update (rep);
00421 
00422     IgQtLock ();
00423     rep->clear ();
00424     
00425     SoSeparator *sep = new SoSeparator;    
00426     SoSeparator *posSep = new SoSeparator;    
00427     SoSeparator *negSep = new SoSeparator;
00428     sep->addChild (posSep);
00429     sep->addChild (negSep);
00430     
00431     SoMaterial *mat = new SoMaterial;
00432     mat->ambientColor.setValue (0.0, 0.1, 1.0);
00433     mat->diffuseColor.setValue (0.0, 0.1, 1.0);
00434     mat->specularColor.setValue (0.0, 0.1, 1.0);
00435     mat->emissiveColor.setValue (0.0, 0.1, 1.0);
00436     posSep->addChild (mat);
00437     
00438     SoMaterial *negMat = new SoMaterial;
00439     negMat->ambientColor.setValue (1.0, 0.0, 0.0);
00440     negMat->diffuseColor.setValue (1.0, 0.0, 0.0);
00441     negMat->specularColor.setValue (1.0, 0.0, 0.0);
00442     negMat->emissiveColor.setValue (1.0, 0.0, 0.0);
00443     negSep->addChild (negMat);
00444 
00445     int nbrOfBins = 72;
00446     int binNumber;
00447 
00448     std::vector<float> bufferPositive (nbrOfBins);
00449     std::vector<float> bufferNegative (nbrOfBins);
00450     try 
00451     {
00452         if (! m_recHits.empty ())
00453         {
00454             for (std::vector<HORecHit>::const_iterator i = m_recHits.begin (), iEnd = m_recHits.end (); i != iEnd; ++i) 
00455             {
00456                 float energy = (*i).energy ();
00457                 if (energy > m_cut.value ())
00458                 {
00459                     int iphi = (*i).id ().iphi ();
00460                     binNumber = iphi - 1;
00461  
00462                     if (binNumber >= 0 && binNumber < 72) 
00463                         if (m_binning.value () == "project")
00464                         {                               
00465                             if ((energy > 0.0) && (energy > bufferPositive [binNumber]))
00466                                 bufferPositive [binNumber] = energy;
00467                             else if ((energy < 0.0) && (energy < bufferNegative [binNumber]))
00468                                 bufferNegative [binNumber] = energy;
00469                         }
00470                         else
00471                             (energy > 0.0) ?  bufferPositive [binNumber] += energy : bufferNegative [binNumber] += energy;
00472                 }
00473             }
00474             
00475             if (*max_element (bufferPositive.begin (), bufferPositive.end ()) > 0.0)
00476             {
00477                 IgSoCircularHist *recHits = new IgSoCircularHist;
00478                 recHits->minRadius = 4.02f;// 2.864;
00479                 recHits->maxRadius = -1;
00480                 recHits->scaleFactor = m_escale.value ();
00481                 recHits->numberOfBins = nbrOfBins;
00482                 recHits->energies.setValues (0, nbrOfBins, &bufferPositive [0]);
00483                 recHits->logScale = false;
00484                 recHits->showAnnotations = m_annotation.value ();
00485                 recHits->layer = 5.3;
00486                 posSep->addChild (recHits);
00487             }
00488             
00489             std::vector<float>::const_iterator nfirst = bufferNegative.begin ();
00490             std::vector<float>::const_iterator nlast = bufferNegative.end ();
00491 
00492             if (fabs(*max_element (nfirst, nlast)) > 0.0)
00493             {
00494                 IgSoCircularHist *negRecHits = new IgSoCircularHist;
00495                 negRecHits->minRadius = 4.02f;// 2.864;
00496                 negRecHits->maxRadius = -1;
00497                 negRecHits->scaleFactor = m_escale.value ();
00498                 negRecHits->numberOfBins = nbrOfBins;
00499                 negRecHits->energies.setValues (0, nbrOfBins, &bufferNegative [0]);
00500                 negRecHits->logScale = false;
00501                 negRecHits->showAnnotations = m_annotation.value ();
00502                 negRecHits->layer = 5.3;
00503                 negSep->addChild (negRecHits);
00504             }       
00505         }
00506     }
00507     catch (cms::Exception& e)
00508     {
00509         e.append (" from VisHORecHitTwig::update (IgRPhiRep*) ");
00510         e.append (this->name ());    
00511 
00512         if (this->m_onCmsException)
00513             this->m_onCmsException (&e);
00514     }
00515     catch (lat::Error &e) 
00516     {
00517         if (this->m_onError)
00518             this->m_onError (&e);
00519     }
00520     catch (std::exception &e) 
00521     {
00522         if (this->m_onException)
00523             this->m_onException (&e);
00524     }
00525     catch (...) 
00526     {
00527         if (this->m_onUnhandledException)
00528             this->m_onUnhandledException ();
00529     }
00530     
00531     rep->node ()->addChild (sep);
00532 }
00533 
00534 void
00535 VisHORecHitTwig::update (IgRZRep *rep)
00536 {
00537     // Get debugging dump.
00538     VisQueuedTwig::update (rep);
00539         
00540     IgQtLock ();
00541     rep->clear ();
00542         
00543     SoSeparator *sep = new SoSeparator;    
00544 
00545     SoMaterial *mat = new SoMaterial;
00546     float rgbcomponents [4];
00547     IgSbColorMap::unpack (m_rgba, rgbcomponents);
00548     mat->ambientColor.setValue (SbColor (rgbcomponents));
00549     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00550     mat->specularColor.setValue (SbColor (rgbcomponents));
00551     mat->emissiveColor.setValue (SbColor (rgbcomponents));
00552     sep->addChild (mat);
00553 
00554     VisEventSetupService *esService = VisEventSetupService::get (state ());
00555     ASSERT (esService);
00556 
00557     unsigned binNumber = 0;
00558     const unsigned nBinsZ = 32;
00559     const unsigned nBinsR = 2;
00560     const unsigned nbrOfBins = 2 * (nBinsZ + nBinsR);
00561     const float radiusR = 4.02f;// 2.864f;
00562     const float radiusZ = 6.5f;
00563     const float barrelMaxEta = 1.444f;            // max eta of HCAL Barrel
00564     std::vector<float> energies (nbrOfBins * 2); // times 2 for the other energy (which is not used)
00565     try 
00566     {
00567         if (! m_recHits.empty ())
00568         {
00569             for (std::vector<HORecHit>::const_iterator i = m_recHits.begin (), iEnd = m_recHits.end (); i != iEnd; ++i) 
00570             {
00571                 float energy = (*i).energy ();
00572                 if (energy > m_cut.value ()) 
00573                 {
00574                     binNumber = esService->getBinNumber ((*i).detid (), nBinsR, nBinsZ, radiusR, radiusZ, barrelMaxEta);
00575                     if (binNumber < nbrOfBins)
00576                     {
00577                         if (m_binning.value () == "project")
00578                             (energies[binNumber] > energy) ? energies[binNumber] : energies[binNumber] = energy;
00579                         else
00580                             energies[binNumber] += energy;
00581                     }
00582                     else
00583                     {
00584                         std::cerr << "Bin number (" << binNumber << ") exceeds the number of bins (" <<  nbrOfBins << ")"<< std::endl;
00585                     }
00586                 }
00587             }
00588                         
00589             if (*max_element (energies.begin (), energies.end ()) > 0.0)
00590             {
00591                 SoMaterial *mat = new SoMaterial;
00592                 mat->ambientColor.setValue (0.0, 0.1, 1.0);
00593                 mat->diffuseColor.setValue (0.0, 0.1, 1.0);
00594                 mat->specularColor.setValue (0.0, 0.1, 1.0);
00595                 mat->emissiveColor.setValue (0.0, 0.1, 1.0);
00596 
00597                 SoDrawStyle *drawStyle = new SoDrawStyle;
00598                 drawStyle->lineWidth.setValue (2.0);
00599 
00600                 IgSoRectColHist* hist = new IgSoRectColHist;
00601                 hist->radiusR = radiusR;
00602                 hist->radiusZ = radiusZ;
00603                 hist->numR = nBinsR;
00604                 hist->numZ = nBinsZ;
00605                 hist->energies.setValues (0, energies.size(), &energies [0]);
00606                 hist->logScale = false;
00607                 hist->layer = -5.3;
00608                 hist->scaleFactor = m_escale.value ();
00609                                 
00610                 std::vector<SbColor> colors (4);
00611                 colors[0] = SbColor (0.0, 0.1, 0.9);
00612                 colors[1] = SbColor (1.0, 0.0, 1.0);
00613                 colors[2] = SbColor (1.0, 0.4, 1.0);
00614                 colors[3] = SbColor (1.0, 1.0, 0.0);
00615                                 
00616                 hist->faceColors.setValues (0, colors.size (), &colors[0]);
00617                 sep->addChild (mat);
00618                 sep->addChild (drawStyle);
00619                 sep->addChild (hist);
00620             }
00621         }
00622     }
00623     catch (cms::Exception& e)
00624     {
00625         e.append (" from VisHORecHitTwig::update(IgRZRep*) ");
00626         e.append (this->name ());    
00627 
00628         if (this->m_onCmsException)
00629             this->m_onCmsException (&e);
00630     }
00631     catch (lat::Error &e) 
00632     {
00633         if (this->m_onError)
00634             this->m_onError (&e);
00635     }
00636     catch (std::exception &e) 
00637     {
00638         if (this->m_onException)
00639             this->m_onException (&e);
00640     }
00641     catch (...) 
00642     {
00643         if (this->m_onUnhandledException)
00644             this->m_onUnhandledException ();
00645     }
00646         
00647     rep->node ()->addChild (sep);
00648 }

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