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