CMS 3D CMS Logo

VisCaloJetTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 #define QT_NO_EMIT
00003 
00004 #include "VisReco/VisRecoJets/interface/VisCaloJetTwig.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisEventProcessorService.h"
00006 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00007 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00008 #include "VisFramework/VisEventSetup/interface/VisEventSetupService.h"
00009 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00010 #include "DataFormats/JetReco/interface/CaloJet.h"
00011 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00012 #include "DataFormats/Common/interface/Ref.h"
00013 #include "DataFormats/Common/interface/RefVector.h"
00014 #include "DataFormats/Common/interface/SortedCollection.h"
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/Utilities/interface/TypeID.h"
00018 #include "Iguana/Inventor/interface/IgSoCircularHist.h"
00019 #include "Iguana/Inventor/interface/IgSoRectColHist.h"
00020 #include "Iguana/Inventor/interface/IgSoTower.h"
00021 #include "Iguana/Inventor/interface/IgSbColorMap.h"
00022 #include "Iguana/Inventor/interface/IgSoJet.h"
00023 #include "Iguana/Models/interface/IgTextRep.h"
00024 #include "Iguana/GLModels/interface/Ig3DRep.h"
00025 #include "Iguana/GLModels/interface/IgLegoRep.h"
00026 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00027 #include "Iguana/GLModels/interface/IgRZRep.h"
00028 #include "Iguana/Framework/interface/IgRepSet.h"
00029 #include "Iguana/Studio/interface/IgDocumentData.h"
00030 #include "Iguana/Studio/interface/IgQtLock.h"
00031 #include "Iguana/Studio/interface/IgQtAppStatusBarService.h"
00032 #include <Inventor/nodes/SoFont.h>
00033 #include <Inventor/nodes/SoSelection.h>
00034 #include <Inventor/nodes/SoCube.h>
00035 #include <Inventor/nodes/SoText2.h>
00036 #include <Inventor/nodes/SoTranslation.h>
00037 #include <Inventor/nodes/SoSeparator.h>
00038 #include <Inventor/nodes/SoMaterial.h>
00039 #include <qstring.h>
00040 #include <sstream>
00041 #include <iomanip>
00042 
00043 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00044 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00045 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00046 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00047 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00048 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00049 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00050 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00051 
00052 namespace 
00053 {
00054     VisQueuedTwig *
00055     createThisTwig (IgState *state, IgTwig *parent,
00056                     const std::string &name,
00057                     const std::string &friendlyName,
00058                     const std::string &modLabel,
00059                     const std::string &instanceName,
00060                     const std::string &processName)
00061     {
00062         IgTwig *rootTwig = IgDocumentData::get (state)->root ();
00063         IgTwig *eventTwig = 0;
00064         eventTwig = rootTwig->lookup ("/Objects/CMS Event and Detector/CaloJets");
00065         
00066         if (! eventTwig)
00067             eventTwig = parent;
00068 
00069         return new VisCaloJetTwig (state, eventTwig, "[N/A] CaloJet (" + name + ")", 
00070                                    friendlyName, modLabel, instanceName, processName);
00071     }
00072 }
00073 
00074 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00075 
00076 VisCaloJetTwig::VisCaloJetTwig (IgState *state, IgTwig *parent,
00077                                 const std::string &name /* = "" */,
00078                                 const std::string &friendlyName /* = "" */,
00079                                 const std::string &moduleLabel /* = "" */,
00080                                 const std::string &instanceName /* = "" */,
00081                                 const std::string &processName /* = "" */)
00082     : VisQueuedTwig (state, parent, name),
00083       m_text (name),
00084       m_friendlyName (friendlyName),
00085       m_moduleLabel (moduleLabel),
00086       m_instanceName (instanceName),
00087       m_processName (processName),
00088       m_binning (state, lat::CreateCallback (this, &VisCaloJetTwig::twigChanged)),
00089       m_annotation (state, lat::CreateCallback (this, &VisCaloJetTwig::twigChanged)),
00090       m_scale (state, lat::CreateCallback (this, &VisCaloJetTwig::twigChanged)),
00091       m_cut (state, lat::CreateCallback (this, &VisCaloJetTwig::twigChanged)),
00092       m_escale (state, lat::CreateCallback (this, &VisCaloJetTwig::twigChanged))
00093 {
00094     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00095     if (! tfService)
00096     {
00097         tfService = new VisTwigFactroyService (state);
00098     }   
00099     edm::TypeID caloJetsID (typeid (reco::CaloJetCollection));
00100     tfService->registerTwig (caloJetsID.friendlyClassName (), &createThisTwig);
00101 }
00102 
00103 void
00104 VisCaloJetTwig::twigChanged (void)
00105 { IgRepSet::invalidate (this, SELF_MASK); }
00106 
00107 void
00108 VisCaloJetTwig::onNewEvent (const edm::Event &event,
00109                             const edm::EventSetup &eventSetup)
00110 {
00111     // Get debugging dump.
00112     VisQueuedTwig::onNewEvent (event, eventSetup);
00113 
00114     m_text = QString ("Run %1, Event %2, LS %3, Orbit %4, BX %5")
00115              .arg (event.id ().run ())
00116              .arg (event.id ().event ())
00117              .arg (event.luminosityBlock ())
00118              .arg (event.orbitNumber ())
00119              .arg (event.bunchCrossing ())
00120              .latin1 ();
00121     
00122     std::vector<edm::Handle<reco::CaloJetCollection> > jets;
00123 //std::vector<edm::Handle<CaloTowerCollection> > towers;
00124     try 
00125     {
00126         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00127         {
00128             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00129             event.getMany (visSel, jets);
00130         }
00131         //event.getManyByType (towers);
00132     }
00133     catch (cms::Exception& e)
00134     {
00135         if (this->m_onCmsException)
00136             this->m_onCmsException (&e);
00137     }
00138     catch (lat::Error &e) 
00139     {
00140         if (this->m_onError)
00141             this->m_onError (&e);
00142     }
00143     catch (std::exception &e) 
00144     {
00145         if (this->m_onException)
00146             this->m_onException (&e);
00147     }
00148     catch (...) 
00149     {
00150         if (this->m_onUnhandledException)
00151             this->m_onUnhandledException ();
00152     }
00153     
00154     m_jets.clear ();
00155 //    m_towers.clear ();
00156 
00157     if (! jets.empty ()) 
00158     {
00159         std::vector<edm::Handle<reco::CaloJetCollection> >::iterator i;
00160         std::vector<edm::Handle<reco::CaloJetCollection> >::iterator iEnd;
00161         for (i = jets.begin (), iEnd = jets.end (); i != iEnd; ++i) 
00162         {
00163             const reco::CaloJetCollection& c = *(*i);
00164             QString sizeStr = (QString ("%1").arg (c.size ()));
00165             QString nameStr = QString (this->name ());
00166             int ib = nameStr.find ("[");
00167             int ie = nameStr.find ("]");
00168             nameStr.replace (ib + 1, ie - 1, sizeStr);
00169             
00170             this->name (nameStr);
00171         
00172             for (reco::CaloJetCollection::const_iterator j = c.begin (), jEnd = c.end (); j != jEnd; ++j) 
00173             {
00174                 m_jets.push_back (*j);
00175             }
00176         }
00177     }
00178 //     if (! towers.empty ())
00179 //     {
00180 //      std::vector<edm::Handle<CaloTowerCollection> >::iterator i;
00181 //      std::vector<edm::Handle<CaloTowerCollection> >::iterator iEnd;
00182 //      for (i = towers.begin (), iEnd = towers.end (); i != iEnd; ++i) 
00183 //      {
00184 //          const CaloTowerCollection& c = *(*i);
00185         
00186 //          for (CaloTowerCollection::const_iterator j = c.begin (), jEnd = c.end (); j != jEnd; ++j) 
00187 //          {
00188 //              std::pair <CaloTowerDetId, CaloTower> p;
00189 //              p.first = (*j).id ();
00190 //              p.second = (*j);
00191 //              m_towers.push_back (p);
00192 //          }
00193 //      }
00194 //     }
00195     VisQueuedTwig::onBaseInvalidate ();
00196 }
00197 
00198 void
00199 VisCaloJetTwig::update (IgTextRep *rep)
00200 {
00201     // Get debugging dump.
00202     VisQueuedTwig::update (rep);
00203 
00204     // Prepare property description.
00205     std::ostringstream  text;
00206 
00207     text << m_text << "<br>";
00208 
00209     text << "<table width='100%' border=1>"
00210          << "<TR align = center>"
00211          << "<TH>Number</TH>"
00212          << "<TH>E<SUB>T (GeV)</TH>"
00213          << "<TH>eta</TH>"
00214          << "<TH>phi [rad]</TH>"
00215          << "</TR>";
00216     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00217     text.setf (std::ios::right, std::ios::adjustfield);
00218     
00219     int nJets = 0;
00220     if (! m_jets.empty ()) 
00221     {
00222         try 
00223         {
00224             for (std::vector< reco::CaloJet >::const_iterator it = m_jets.begin (), itEnd = m_jets.end (); 
00225                  it != itEnd; ++it)
00226             {
00227                 double jetEt = (*it).et ();
00228                 if (jetEt > m_cut.value ())
00229                 {
00230                     double jetPhi = (*it).phi();
00231                     double jetEta = (*it).eta ();
00232         
00233                     text << "<TR align = right>"
00234                          << "<TD>" << std::setw (3) << nJets++ << "</TD>"
00235                          << "<TD>" << std::setw (2) << std::setprecision (3) << jetEt << "</TD>"
00236                          << "<TD>" << std::setw (6) << std::setprecision (3) << jetEta << "</TD>"
00237                          << "<TD>" << std::setw (5) << std::setprecision (3) << jetPhi << "</TD>"
00238                          << "</TR>";
00239                 }
00240             }
00241         }
00242         catch (cms::Exception& e)
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        
00264     text << "</table>";
00265     
00266     // Send it over.
00267     IgQtLock ();
00268 
00269     rep->setText (text.str ());
00270 }
00271 
00273 void
00274 VisCaloJetTwig::update (Ig3DRep *rep)
00275 {
00276     // Get debugging dump.
00277     VisQueuedTwig::update (rep);
00278     
00279     // Lock the Qt application.
00280     IgQtLock ();
00281     rep->clear ();
00282     
00283     SoSeparator *contents = new SoSeparator;
00284     SoSeparator *jetsSep = new SoSeparator;
00285     contents->addChild (jetsSep);
00286     
00287     SoSeparator *labelSep = new SoSeparator;
00288     contents->addChild (labelSep);
00289     
00290     if (! m_jets.empty ()) 
00291     {
00292         try 
00293         {
00294             unsigned colour [10] = { 0xff000000, 0x00ff0000, 0xffff0000, // red green yellow
00295                                      0xff00ff00, 0x00ffff00, 0xd0dfff00, // magenta cyan
00296                                      0xff000fff, 0x00ffff00, 0xe00fff00,
00297                                      0xff00ee00};
00298             int i = 0;
00299         
00300             for (std::vector< reco::CaloJet >::const_iterator it = m_jets.begin (), itEnd = m_jets.end (); 
00301                  it != itEnd; ++it)
00302             {
00303                 double jetEt = (*it).et ();
00304                 if (jetEt > m_cut.value ()) 
00305                 {
00306                     if (i == 10) i = 0;
00307             
00308                     SoSeparator *sep = new SoSeparator;
00309                     jetsSep->addChild (sep);
00310                     SoMaterial *mat = new SoMaterial;
00311                     float rgbcomponents [4];
00312                     IgSbColorMap::unpack (colour [i++], rgbcomponents);
00313                     mat->diffuseColor.setValue (rgbcomponents);
00314                     sep->addChild (mat);
00315 
00316                     SoFont *font = new SoFont;
00317                     font->name = "Times-Roman";
00318                     font->size = 14.0;
00319                     sep->addChild (font);
00320             
00321                     double jetPhi = (*it).phi();
00322                     (jetPhi < 0) ? jetPhi += 2 * M_PI : jetPhi;
00323                     double jetEta = (*it).eta ();
00324                     double jetTheta = 2.0 * atan (exp (-jetEta));
00325             
00326                     QString label = QString ("Et = %1 GeV")
00327                                     .arg (jetEt, 0, 'f', 2);
00328                     SoSeparator *labelSep = new SoSeparator;
00329                     SoText2  *jetLabel = new SoText2;
00330                     jetLabel->string = label.latin1 ();
00331                     SoTranslation *jetLabelTranslation = new SoTranslation;
00332             
00333                     double ct = cos (jetTheta);
00334                     double st = sin (jetTheta);
00335                     double cp = cos (jetPhi);
00336                     double sp = sin (jetPhi);
00337             
00338                     float length1 = ct ? 4.0 / fabs (ct) : 4.0;
00339                     float length2 = st ? 2.0 / fabs (st) : 2.0;
00340                     float bodyHeight = length1 < length2 ? length1 : length2;
00341                     float hatHeight = 2.0 * jetEt / 100.0;
00342                     jetLabelTranslation->translation = SbVec3f ((bodyHeight + hatHeight) * st * cp,
00343                                                                 (bodyHeight + hatHeight) * st * sp,
00344                                                                 (bodyHeight + hatHeight) * ct);
00345             
00346                     labelSep->addChild (jetLabelTranslation);
00347                     labelSep->addChild (jetLabel);
00348                     sep->addChild (labelSep);
00349             
00350                     IgSoJet *recoJet = new IgSoJet;
00351                     recoJet->theta.setValue (jetTheta);
00352                     recoJet->phi.setValue (jetPhi);
00353                     recoJet->energy.setValue (jetEt);
00354                     sep->addChild (recoJet);
00355                 }
00356             }
00357         }
00358         catch (cms::Exception& e)
00359         {
00360             if (this->m_onCmsException)
00361                 this->m_onCmsException (&e);
00362         }
00363         catch (lat::Error &e) 
00364         {
00365             if (this->m_onError)
00366                 this->m_onError (&e);
00367         }
00368         catch (std::exception &e) 
00369         {
00370             if (this->m_onException)
00371                 this->m_onException (&e);
00372         }
00373         catch (...) 
00374         {
00375             if (this->m_onUnhandledException)
00376                 this->m_onUnhandledException ();
00377         }
00378     }
00379 
00380     rep->node ()->addChild (contents);
00381 }
00382 
00384 void
00385 VisCaloJetTwig::update (IgLegoRep *rep)
00386 {
00387     // Get debugging dump.
00388     VisQueuedTwig::update (rep);
00389     
00390     // Lock the Qt application.
00391     IgQtLock ();
00392     rep->clear ();
00393     
00394     VisEventSetupService *esService = VisEventSetupService::get (state ());
00395     ASSERT (esService);
00396 
00397     SoSeparator *contents = new SoSeparator;
00398     
00399     SoSeparator *jetsSep = new SoSeparator;
00400     contents->addChild (jetsSep);
00401     
00402     SoSeparator *labelSep = new SoSeparator;
00403     contents->addChild (labelSep);
00404     
00405     if (! m_jets.empty ()) 
00406     {
00407         try 
00408         {
00409             unsigned colour [10] = { 0xff000000, 0x00ff0000, 0xffff0000, // red green yellow 
00410                                      0xff00ff00, 0x00ffff00, 0xd0dfff00, // magenta cyan
00411                                      0xff000fff, 0x00ffff00, 0xe00fff00,
00412                                      0xff00ee00};
00413             int i = 0;
00414         
00415             for (std::vector< reco::CaloJet >::const_iterator jit = m_jets.begin (), jitEnd = m_jets.end (); 
00416                  jit != jitEnd; ++jit)
00417             {
00418                 double jetEt = (*jit).et ();
00419                 if (jetEt > m_cut.value ()) 
00420                 {
00421                     if (i == 10) i = 0;
00422             
00423                     SoSeparator *sep = new SoSeparator;
00424                     jetsSep->addChild (sep);
00425                     SoMaterial *mat = new SoMaterial;
00426                     float rgbcomponents [4];
00427                     IgSbColorMap::unpack (colour [i++], rgbcomponents);
00428                     mat->diffuseColor.setValue (rgbcomponents);
00429                     sep->addChild (mat);
00430 
00431                     SoFont *font = new SoFont;
00432                     font->name = "Arial";
00433                     font->size = 14.0;
00434                     sep->addChild (font);
00435             
00436                     double jetPhi = (*jit).phi();
00437                     (jetPhi < 0) ? jetPhi += 2 * M_PI : jetPhi;
00438                     double jetEta = (*jit).eta ();
00439             
00440                     QString label = QString ("Et = %1 GeV")
00441                                     .arg (jetEt, 0, 'f', 2);
00442                     SoSeparator *labelSep = new SoSeparator;
00443                     SoText2  *jetLabel = new SoText2;
00444                     jetLabel->string = label.latin1 ();
00445                     SoTranslation *jetLabelTranslation = new SoTranslation;
00446                     double jetLabelHight = 0.0;
00447 
00448                     std::vector<CaloTowerDetId> caloTowerIds = (*jit).getTowerIndices ();                   
00449                     std::vector<CaloTowerPtr> caloTowers = (*jit).getCaloConstituents ();
00450 
00451                     if (! caloTowers.empty ()) 
00452                     {
00453                         for (std::vector<CaloTowerPtr>::const_iterator cit = caloTowers.begin (), citEnd = caloTowers.end (); 
00454                              cit != citEnd; ++cit) 
00455                         {
00456                             if ((*cit).isNonnull () && (*cit).isAvailable ())
00457                             {                           
00458                                 double eta = (*cit)->eta ();
00459                                 double phi = (*cit)->phi ();
00460                                 if (phi < 0) phi += 2 * M_PI;
00461                                 double et = (*cit)->et ();
00462                                 et > jetLabelHight ? jetLabelHight = et : jetLabelHight;
00463                         
00464                                 SoSeparator *tsep = new SoSeparator;
00465                     
00466                                 SoTranslation *localTransl = new SoTranslation;
00467                                 localTransl->translation.setValue (SbVec3f (phi, et / (2 * m_scale.value ()), eta));
00468                     
00469                                 SoCube *towerBox = new SoCube;
00470                                 towerBox->height = et / m_scale.value () + 0.001;
00471                                 if (fabs(eta) > 1.74) towerBox->width = 0.176f;
00472                                 else towerBox->width  = 0.089;
00473                                 towerBox->depth  = esService->phi4eta (fabs(eta)) + 0.002;
00474                     
00475                                 tsep->addChild (localTransl);
00476                                 tsep->addChild (towerBox);
00477                                 sep->addChild (tsep);
00478                             }                       
00479                         }
00480                     }
00481 
00482                     jetLabelHight == 0 ? jetLabelHight = jetEta / m_scale.value () + 0.2 : jetLabelHight = jetLabelHight / m_scale.value () + 0.2;
00483             
00484                     jetLabelTranslation->translation = SbVec3f (jetPhi, jetLabelHight, jetEta);
00485             
00486                     labelSep->addChild (jetLabelTranslation);
00487                     labelSep->addChild (jetLabel);
00488                     sep->addChild (labelSep);
00489                 }
00490             }
00491         }
00492         catch (cms::Exception& e)
00493         {
00494             if (this->m_onCmsException)
00495                 this->m_onCmsException (&e);
00496         }
00497         catch (lat::Error &e) 
00498         {
00499             if (this->m_onError)
00500                 this->m_onError (&e);
00501         }
00502         catch (std::exception &e) 
00503         {
00504             if (this->m_onException)
00505                 this->m_onException (&e);
00506         }
00507         catch (...) 
00508         {
00509             if (this->m_onUnhandledException)
00510                 this->m_onUnhandledException ();
00511         }
00512     }
00513     rep->node ()->addChild (contents);
00514 }
00515 
00516 void
00517 VisCaloJetTwig::update (IgRPhiRep *rep) 
00518 {
00519     // Get debugging dump.
00520     VisQueuedTwig::update (rep);
00521 
00522     IgQtLock ();
00523     rep->clear ();
00524     
00525     VisEventSetupService *esService = VisEventSetupService::get (state ());
00526     ASSERT (esService);
00527 
00528     SoSeparator *sep = new SoSeparator;    
00529     SoSeparator *emSep = new SoSeparator;    
00530     SoSeparator *hadSep = new SoSeparator;
00531     sep->addChild (emSep);
00532     sep->addChild (hadSep);
00533 
00534     SoFont *font = new SoFont;
00535     font->name = "Arial";
00536     font->size = 14.0;
00537     sep->addChild (font);
00538     
00539     SoMaterial *mat = new SoMaterial;
00540     mat->ambientColor.setValue (0.5, 1.0, 0.5);
00541     mat->diffuseColor.setValue (0.5, 1.0, 0.5);
00542     mat->specularColor.setValue (0.5, 1.0, 0.5);
00543     mat->emissiveColor.setValue (0.5, 1.0, 0.5);
00544     emSep->addChild (mat);
00545     
00546     SoMaterial *hadMat = new SoMaterial;
00547     hadMat->ambientColor.setValue (0.5, 0.5, 1.0);
00548     hadMat->diffuseColor.setValue (0.5, 0.5, 1.0);
00549     hadMat->specularColor.setValue (0.5, 0.5, 1.0);
00550     hadMat->emissiveColor.setValue (0.5, 0.5, 1.0);
00551     hadSep->addChild (hadMat);
00552 
00553     int nbrOfBins = 72;
00554     int binNumber;
00555 
00556     std::vector<float> bufferEm (nbrOfBins);
00557     std::vector<float> bufferHad (nbrOfBins);
00558     if (! m_jets.empty ()) 
00559     {
00560         try 
00561         {
00562             unsigned colour [10] = { 0xff000000, 0x00ff0000, 0xffff0000, // red green yellow 
00563                                      0xff00ff00, 0x00ffff00, 0xd0dfff00, // magenta cyan
00564                                      0xff000fff, 0x00ffff00, 0xe00fff00,
00565                                      0xff00ee00};
00566             int i = 0;
00567         
00568             for (std::vector< reco::CaloJet >::const_iterator jit = m_jets.begin (), jitEnd = m_jets.end (); 
00569                  jit != jitEnd; ++jit)
00570             {
00571                 double jetEt = (*jit).et ();
00572                 if (jetEt > m_cut.value ()) 
00573                 {
00574                     if (i == 10) i = 0;
00575             
00576                     SoSeparator *jetSep = new SoSeparator;
00577                     sep->addChild (jetSep);
00578                     SoMaterial *mat = new SoMaterial;
00579                     float rgbcomponents [4];
00580                     IgSbColorMap::unpack (colour [i++], rgbcomponents);
00581                     mat->diffuseColor.setValue (rgbcomponents);
00582                     jetSep->addChild (mat);
00583             
00584                     double jetPhi = (*jit).phi();
00585                     (jetPhi < 0) ? jetPhi += 2 * M_PI : jetPhi;
00586                     double jetEta = (*jit).eta ();
00587             
00588                     QString label = QString ("Et = %1 GeV")
00589                                     .arg (jetEt, 0, 'f', 2);
00590                     SoSeparator *labelSep = new SoSeparator;
00591                     SoText2  *jetLabel = new SoText2;
00592                     jetLabel->string = label.latin1 ();
00593                     SoTranslation *jetLabelTranslation = new SoTranslation;
00594                     double jetLabelHight = 0.0;
00595 
00596                     std::vector<CaloTowerPtr> caloTowers = (*jit).getCaloConstituents ();
00597 
00598                     if (! caloTowers.empty ()) 
00599                     {
00600                         bool doubleWidth = false;
00601                         
00602                         for (std::vector<CaloTowerPtr>::const_iterator cit = caloTowers.begin (), citEnd = caloTowers.end (); 
00603                              cit != citEnd; ++cit) 
00604                         {
00605                             if ((*cit).isNonnull () && (*cit).isAvailable ())
00606                             {                           
00607                                 double phi = (*cit)->phi ();
00608                                 if (phi < 0) phi += 2 * M_PI;
00609 
00610                                 float et = (*cit)->et ();
00611                                 float em = (*cit)->emEt ();
00612                                 float eta = (*cit)->eta ();
00613                                 int iphi = (*cit)->id ().iphi ();
00614                                 binNumber = iphi - 1;
00615                                 if ((fabs (eta) > 1.74f) && binNumber < 71)
00616                                     doubleWidth = true;
00617                                 else 
00618                                     doubleWidth = false;
00619 
00620                                 if (binNumber >= 0 && binNumber < 72)
00621                                 {
00622                                     if (m_binning.value () == "project")
00623                                     {                           
00624                                         if (et > bufferHad [binNumber])
00625                                             bufferHad [binNumber] = et;
00626                                         if (em > bufferEm [binNumber])
00627                                             bufferEm [binNumber] = em;
00628                                         if (doubleWidth)
00629                                         {
00630                                             if (et > bufferHad [binNumber + 1])
00631                                                 bufferHad [binNumber + 1] = et;
00632                                             if (em > bufferEm [binNumber + 1])
00633                                                 bufferEm [binNumber + 1] = em;
00634                                         }                                   
00635                                     }
00636                                     else
00637                                     {
00638                                         bufferHad [binNumber] += et;
00639                                         bufferEm [binNumber] += em;
00640                                         if (doubleWidth)
00641                                         {
00642                                             bufferHad [binNumber + 1] += et;
00643                                             bufferEm [binNumber + 1] += em;
00644                                         }
00645                                     }
00646                                 }
00647                                 et > jetLabelHight ? jetLabelHight = et : jetLabelHight;
00648                             }
00649                         }
00650                     }
00651                     
00652                     jetLabelHight == 0 ? jetLabelHight = jetEta / m_scale.value () + 0.2 : jetLabelHight = jetLabelHight / m_scale.value () + 0.2;
00653             
00654                     jetLabelTranslation->translation = SbVec3f (jetPhi, jetLabelHight, jetEta);
00655             
00656                     labelSep->addChild (jetLabelTranslation);
00657                     labelSep->addChild (jetLabel);
00658                     sep->addChild (labelSep);
00659                 }
00660 
00661             }
00662             if (*max_element (bufferHad.begin (), bufferHad.end ()) > 0.0)
00663             {
00664                 IgSoCircularHist *tower = new IgSoCircularHist;
00665                 tower->minRadius = 1.9;
00666                 tower->maxRadius = -1;
00667                 tower->scaleFactor = m_escale.value ();
00668                 tower->numberOfBins = nbrOfBins;
00669                 tower->energies.setValues (0, nbrOfBins, &bufferHad [0]);
00670                 tower->logScale = false;
00671                 tower->showAnnotations = m_annotation.value ();
00672                 tower->layer = 5.6;
00673                 hadSep->addChild (tower);
00674             }
00675             if (*max_element (bufferEm.begin (), bufferEm.end ()) > 0.0)
00676             {
00677                 IgSoCircularHist *emtower = new IgSoCircularHist;
00678                 emtower->minRadius = 1.9;
00679                 emtower->maxRadius = -1;
00680                 emtower->scaleFactor = m_escale.value ();
00681                 emtower->numberOfBins = nbrOfBins;
00682                 emtower->energies.setValues (0, nbrOfBins, &bufferEm [0]);
00683                 emtower->logScale = false;
00684                 emtower->showAnnotations = m_annotation.value ();
00685                 emtower->layer = 5.8;
00686                 emSep->addChild (emtower);
00687             }
00688         }
00689         catch (cms::Exception& e)
00690         {
00691             if (this->m_onCmsException)
00692                 this->m_onCmsException (&e);
00693         }
00694         catch (lat::Error &e) 
00695         {
00696             if (this->m_onError)
00697                 this->m_onError (&e);
00698         }
00699         catch (std::exception &e) 
00700         {
00701             if (this->m_onException)
00702                 this->m_onException (&e);
00703         }
00704         catch (...) 
00705         {
00706             if (this->m_onUnhandledException)
00707                 this->m_onUnhandledException ();
00708         }
00709     }
00710     rep->node ()->addChild (sep);
00711 }
00712 
00713 void
00714 VisCaloJetTwig::update (IgRZRep *rep) 
00715 {}
00716 

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