CMS 3D CMS Logo

VisGenJetCollectionTwig Class Reference

#include <VisReco/VisRecoJets/interface/VisGenJetCollectionTwig.h>

Inheritance diagram for VisGenJetCollectionTwig:

VisQueuedTwig IgSimpleTwig VisEventObserver IgCompoundTwig IgTwig IgRepresentable

List of all members.

Public Member Functions

virtual void onNewEvent (const edm::Event &event, const edm::EventSetup &eventSetup)
virtual void scaleChanged (void)
virtual void update (IgRZRep *rep)
virtual void update (IgRPhiRep *rep)
virtual void update (IgLegoRep *rep)
 Update object.
virtual void update (Ig3DRep *rep)
 Update object.
virtual void update (IgTextRep *rep)
 VisGenJetCollectionTwig (IgState *state, IgTwig *parent, const std::string &name="", const std::string &friendlyName="", const std::string &moduleLabel="", const std::string &instanceName="", const std::string &processName="")

Private Attributes

VisCaloAnnotation m_annotation
VisEnergyCut m_cut
VisCaloEnergyScale m_escale
const std::string m_friendlyName
const std::string m_instanceName
reco::GenJetCollection m_jets
const std::string m_moduleLabel
const std::string m_processName
VisLegoScale m_scale
std::string m_text


Detailed Description

Definition at line 20 of file VisGenJetCollectionTwig.h.


Constructor & Destructor Documentation

VisGenJetCollectionTwig::VisGenJetCollectionTwig ( IgState state,
IgTwig parent,
const std::string &  name = "",
const std::string &  friendlyName = "",
const std::string &  moduleLabel = "",
const std::string &  instanceName = "",
const std::string &  processName = "" 
)

Definition at line 67 of file VisGenJetCollectionTwig.cc.

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

00073     : VisQueuedTwig (state, parent, name),
00074       m_text (name),
00075       m_friendlyName (friendlyName),
00076       m_moduleLabel (moduleLabel),
00077       m_instanceName (instanceName),
00078       m_processName (processName),
00079       m_scale (state, lat::CreateCallback (this, &VisGenJetCollectionTwig::scaleChanged)),
00080       m_cut (state, lat::CreateCallback (this, &VisGenJetCollectionTwig::scaleChanged)),
00081       m_escale (state, lat::CreateCallback (this, &VisGenJetCollectionTwig::scaleChanged)),
00082       m_annotation (state, lat::CreateCallback (this, &VisGenJetCollectionTwig::scaleChanged))
00083 {
00084     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00085     if (! tfService)
00086     {
00087         tfService = new VisTwigFactroyService (state);
00088     }   
00089     edm::TypeID genJetsID (typeid (reco::GenJetCollection));
00090     tfService->registerTwig (genJetsID.friendlyClassName (), &createThisTwig);
00091 }


Member Function Documentation

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

Reimplemented from VisQueuedTwig.

Definition at line 99 of file VisGenJetCollectionTwig.cc.

References arg, c, IgCompoundTwig::children(), IgCompoundTwig::destroy(), e, exception, i, edm::Event::id(), IgRepSet::invalidate(), j, pfTauBenchmarkGeneric_cfi::jets, m_friendlyName, m_instanceName, m_jets, m_moduleLabel, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_processName, m_text, IgSimpleTwig::name(), VisQueuedTwig::onNewEvent(), IgTwig::SELF_MASK, VisQueuedTwig::state(), and IgTwig::STRUCTURE_MASK.

00101 {
00102     // Get debugging dump.
00103     VisQueuedTwig::onNewEvent (event, eventSetup);
00104 
00105     if (children ()) destroy ();
00106     
00107     m_text = QString ("Run # %1, event # %2")
00108              .arg (event.id ().run ())
00109              .arg (event.id ().event ()).latin1 ();
00110     
00111     std::vector<edm::Handle<reco::GenJetCollection> > jets;
00112     try 
00113     {
00114         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00115         {
00116             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00117             event.getMany (visSel, jets);
00118         }
00119 //      else
00120 //      {
00121 //          event.getManyByType (jets);
00122 //      }
00123     }
00124     catch (cms::Exception& e)
00125     {
00126         if (this->m_onCmsException)
00127             this->m_onCmsException (&e);
00128     }
00129     catch (lat::Error &e) 
00130     {
00131         if (this->m_onError)
00132             this->m_onError (&e);
00133     }
00134     catch (std::exception &e) 
00135     {
00136         if (this->m_onException)
00137             this->m_onException (&e);
00138     }
00139     catch (...) 
00140     {
00141         if (this->m_onUnhandledException)
00142             this->m_onUnhandledException ();
00143     }
00144     
00145     m_jets.clear ();
00146 
00147     if (! jets.empty ()) 
00148     {
00149         std::vector<edm::Handle<reco::GenJetCollection> >::iterator i;
00150         std::vector<edm::Handle<reco::GenJetCollection> >::iterator iEnd;
00151         for (i = jets.begin (), iEnd = jets.end (); i != iEnd; ++i) 
00152         {
00153             const reco::GenJetCollection& c = *(*i);
00154             QString sizeStr = (QString ("%1").arg (c.size ()));
00155             QString nameStr = QString (this->name ());
00156             int ib = nameStr.find ("[");
00157             int ie = nameStr.find ("]");
00158             nameStr.replace (ib + 1, ie - 1, sizeStr);
00159             
00160             this->name (nameStr);
00161         
00162             for (reco::GenJetCollection::const_iterator j = c.begin (), jEnd = c.end (); j != jEnd; ++j) 
00163             {
00164                 m_jets.push_back (*j);
00165                 QString name = QString ("GenJet with Et = %1 GeV")
00166                                .arg ((*j).et (), 0, 'f', 2);
00167                 
00168                 new VisGenJetTwig (state (), this, name.latin1 (), event, eventSetup, (*j));
00169             }
00170         }
00171     }
00172             
00173     IgRepSet::invalidate (this->parent (), IgTwig::SELF_MASK | IgTwig::STRUCTURE_MASK);
00174 }

void VisGenJetCollectionTwig::scaleChanged ( void   )  [virtual]

Definition at line 94 of file VisGenJetCollectionTwig.cc.

References IgRepSet::invalidate(), and IgTwig::SELF_MASK.

00095 { IgRepSet::invalidate (this, SELF_MASK); }

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

Reimplemented from VisQueuedTwig.

Definition at line 471 of file VisGenJetCollectionTwig.cc.

00472 {}

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

Reimplemented from VisQueuedTwig.

Definition at line 467 of file VisGenJetCollectionTwig.cc.

00468 {}

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

Update object.

Reimplemented from VisQueuedTwig.

Definition at line 346 of file VisGenJetCollectionTwig.cc.

References Ig3DBaseRep::clear(), e, exception, i, it, reco::btau::jetEta, reco::btau::jetPhi, label, m_cut, m_jets, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_scale, Ig3DBaseRep::node(), IgSbColorMap::unpack(), VisQueuedTwig::update(), and VisActiveConfigurable< T >::value().

00347 {
00348     // Get debugging dump.
00349     VisQueuedTwig::update (rep);
00350     
00351     // Lock the Qt application.
00352     IgQtLock ();
00353     rep->clear ();
00354 
00355     SoSeparator *contents = new SoSeparator;
00356     
00357     SoSeparator *jetsSep = new SoSeparator;
00358     contents->addChild (jetsSep);
00359     
00360     SoSeparator *labelSep = new SoSeparator;
00361     contents->addChild (labelSep);
00362     
00363     if (! m_jets.empty ()) 
00364     {
00365         try 
00366         {
00367             unsigned colour [10] = { 0xff000000, 0xffff0000, 0x00ff0000, // red yellow green
00368                                      0xff00ff00, 0x00ffff00, 0xd0dfff00, // magenta cyan
00369                                      0xff000fff, 0x00ffff00, 0xe00fff00,
00370                                      0xff00ee00};
00371             int i = 0;
00372         
00373             for (reco::GenJetCollection::const_iterator it = m_jets.begin (), itEnd = m_jets.end (); 
00374                  it != itEnd; ++it)
00375             {
00376                 double jetEt = (*it).et ();
00377                 if (jetEt > m_cut.value ()) 
00378                 {
00379                     if (i == 10) i = 0;
00380             
00381                     SoSeparator *sep = new SoSeparator;
00382                     jetsSep->addChild (sep);
00383                     SoMaterial *mat = new SoMaterial;
00384                     float rgbcomponents [4];
00385                     IgSbColorMap::unpack (colour [i++], rgbcomponents);
00386                     mat->diffuseColor.setValue (rgbcomponents);
00387                     sep->addChild (mat);
00388             
00389                     double jetPhi = (*it).phi();
00390                     if (jetPhi < 0) jetPhi += 2 * M_PI;
00391                     double jetEta = (*it).eta ();
00392             
00393                     QString label = QString ("Et = %1 GeV")
00394                                     .arg (jetEt, 0, 'f', 2);
00395                     SoSeparator *labelSep = new SoSeparator;
00396                     SoText2  *jetLabel = new SoText2;
00397                     jetLabel->string = label.latin1 ();
00398                     SoTranslation *jetLabelTranslation = new SoTranslation;
00399             
00400                     jetLabelTranslation->translation = SbVec3f (jetPhi, jetEt / m_scale.value () + 0.01, jetEta);
00401             
00402                     labelSep->addChild (jetLabelTranslation);
00403                     labelSep->addChild (jetLabel);
00404                     sep->addChild (labelSep);
00405             
00406                     //      std::vector<CaloTowerDetId> caloTowers = (*it).getTowerIndices ();
00407             
00408                     //      for (std::vector<CaloTowerDetId>::const_iterator j = caloTowers.begin (); 
00409                     //           j != caloTowers.end (); j++) 
00410                     //      {
00411                     //          for (std::vector <std::pair < CaloTowerDetId, CaloTower> >::const_iterator i = m_towers.begin ();
00412                     //               i != m_towers.end (); i++)
00413                     //          {
00414                     //              if ((*i).first == (*j))
00415                     //              {
00416                     //                  double eta = (*i).second.eta ();
00417                     //                  double phi = (*i).second.phi ();
00418                     //                  if (phi < 0) phi += 2 * M_PI;
00419                     //                  double et = (*i).second.et ();
00420 
00421                     //                  SoSeparator *tsep = new SoSeparator;
00422                     
00423                     //                  SoTranslation *localTransl = new SoTranslation;
00424                     //                  localTransl->translation.setValue (SbVec3f (phi, et / (2 * 20.0), eta)); // m_scale.value ()
00425                     
00426                     //                  SoCube *towerBox = new SoCube;
00427                     //                  towerBox->height = et / 20.0 + 0.001; // m_scale.value ()
00428                     //                  if (fabs(eta) > 1.74) towerBox->width = 0.176f;
00429                     //                  else towerBox->width  = 0.089;
00430                     //                  towerBox->depth  = VisHcalGrid::phi4eta (fabs(eta)) + 0.002;
00431                     
00432                     //                  tsep->addChild (localTransl);
00433                     //                  tsep->addChild (towerBox);
00434                     //                  sep->addChild (tsep);
00435                     //              }
00436                     //                 } 
00437                     //      }
00438                 }
00439             }
00440         }
00441         catch (cms::Exception& e)
00442         {
00443             if (this->m_onCmsException)
00444                 this->m_onCmsException (&e);
00445         }
00446         catch (lat::Error &e) 
00447         {
00448             if (this->m_onError)
00449                 this->m_onError (&e);
00450         }
00451         catch (std::exception &e) 
00452         {
00453             if (this->m_onException)
00454                 this->m_onException (&e);
00455         }
00456         catch (...) 
00457         {
00458             if (this->m_onUnhandledException)
00459                 this->m_onUnhandledException ();
00460         }
00461     }
00462 
00463     rep->node ()->addChild (contents);
00464 }

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

Update object.

Reimplemented from VisQueuedTwig.

Definition at line 261 of file VisGenJetCollectionTwig.cc.

References funct::cos(), ct, IgSoJet::energy, funct::exp(), DBSPlugin::get(), i, it, reco::btau::jetEta, reco::btau::jetPhi, label, m_jets, Ig3DBaseRep::node(), IgSoJet::phi, funct::sin(), st, VisQueuedTwig::state(), IgSoJet::theta, IgSbColorMap::unpack(), and VisQueuedTwig::update().

00262 {
00263     // Get debugging dump.
00264     VisQueuedTwig::update (rep);
00265     
00266     // Lock the Qt application.
00267     IgQtLock ();
00268     SoGroup *contents = rep->node ();
00269     contents->removeAllChildren ();
00270     
00271     SoSeparator *jetsSep = new SoSeparator;
00272     contents->addChild (jetsSep);
00273     
00274     SoSeparator *labelSep = new SoSeparator;
00275     contents->addChild (labelSep);
00276     
00277     try 
00278     {
00279         unsigned colour [10] = { 0xff000000, 0xffff0000, 0x00ff0000, // red yellow green
00280                                  0xff00ff00, 0x00ffff00, 0xd0dfff00, // magenta cyan
00281                                  0xff000fff, 0x00ffff00, 0xe00fff00,
00282                                  0xff00ee00};
00283         int i = 0;
00284         
00285         for (reco::GenJetCollection::const_iterator it = m_jets.begin (); 
00286              it != m_jets.end (); it++)
00287         {
00288             if (i == 10) i = 0;
00289             
00290             SoSeparator *sep = new SoSeparator;
00291             jetsSep->addChild (sep);
00292             SoMaterial *mat = new SoMaterial;
00293             float rgbcomponents [4];
00294             IgSbColorMap::unpack (colour [i++], rgbcomponents);
00295             mat->diffuseColor.setValue (rgbcomponents);
00296             sep->addChild (mat);
00297             
00298             double jetEt = (*it).et ();
00299             double jetPhi = (*it).phi();
00300             if (jetPhi < 0) jetPhi += 2 * M_PI;
00301             double jetEta = (*it).eta ();
00302             double jetTheta = 2.0 * atan (exp (-jetEta));
00303             
00304             QString label = QString ("Et = %1 GeV")
00305                             .arg (jetEt, 0, 'f', 2);
00306             SoSeparator *labelSep = new SoSeparator;
00307             SoText2  *jetLabel = new SoText2;
00308             jetLabel->string = label.latin1 ();
00309             SoTranslation *jetLabelTranslation = new SoTranslation;
00310             
00311             double ct = cos (jetTheta);
00312             double st = sin (jetTheta);
00313             double cp = cos (jetPhi);
00314             double sp = sin (jetPhi);
00315             
00316             float length1 = ct ? 4.0 / fabs (ct) : 4.0;
00317             float length2 = st ? 2.0 / fabs (st) : 2.0;
00318             float bodyHeight = length1 < length2 ? length1 : length2;
00319             float hatHeight = 2.0 * jetEt / 100.0;
00320             jetLabelTranslation->translation = SbVec3f ((bodyHeight + hatHeight) * st * cp,
00321                                                         (bodyHeight + hatHeight) * st * sp,
00322                                                         (bodyHeight + hatHeight) * ct);
00323             
00324             labelSep->addChild (jetLabelTranslation);
00325             labelSep->addChild (jetLabel);
00326             sep->addChild (labelSep);
00327             
00328             IgSoJet *recoJet = new IgSoJet;
00329             recoJet->theta.setValue (jetTheta);
00330             recoJet->phi.setValue (jetPhi);
00331             recoJet->energy.setValue (jetEt);
00332             sep->addChild (recoJet); 
00333         }
00334     }
00335     catch (...)
00336     {   
00337         if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (state ()))
00338         {
00339             sbar->setMessage ("EXCEPTION VisGenJetTwig::update (Ig3DRep *rep) : Cannot show GenJets.");
00340         }
00341     }
00342 }

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

Reimplemented from VisQueuedTwig.

Definition at line 177 of file VisGenJetCollectionTwig.cc.

References e, exception, it, m_cut, m_jets, VisQueuedTwig::m_onCmsException, VisQueuedTwig::m_onError, VisQueuedTwig::m_onException, VisQueuedTwig::m_onUnhandledException, m_text, IgTextRep::setText(), VisQueuedTwig::update(), and VisActiveConfigurable< T >::value().

00178 {
00179     // Get debugging dump.
00180     VisQueuedTwig::update (rep);
00181 
00182     // Prepare property description.
00183     std::ostringstream  text;
00184 
00185     text << m_text << "<br>";
00186 
00187     text << "<table width='100%' border=1>"
00188          << "<TR align = center>"
00189          << "<TH>Number</TH>"
00190          << "<TH>E<SUB>t (GeV)</TH>"
00191          << "<TH>E<SUB>em (GeV)</TH>"
00192          << "<TH>E<SUB>had</TH>"
00193          << "<TH>E<SUB>inv</TH>"
00194          << "<TH>E<SUB>aux</TH>"
00195          << "<TH>Eta</TH>"
00196          << "<TH>Phi</TH>"
00197          << "</TR>";
00198     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00199     text.setf (std::ios::right, std::ios::adjustfield);
00200     
00201     int nJets = 0;
00202     if (! m_jets.empty ()) 
00203     {
00204         try 
00205         {
00206             for (reco::GenJetCollection::const_iterator it = m_jets.begin (), itEnd = m_jets.end (); 
00207                  it != itEnd; ++it)
00208             {
00209                 double jetEt = (*it).et ();
00210                 if (jetEt > m_cut.value ())
00211                 {
00212                     double eEm = (*it).emEnergy ();
00213                     double eHad = (*it).hadEnergy ();
00214                     double eInv = (*it).invisibleEnergy ();
00215                     double eAux = (*it).auxiliaryEnergy ();
00216         
00217                     text << "<TR align = right>"
00218                          << "<TD>" << std::setw (3) << nJets++ << "</TD>"
00219                          << "<TD>" << std::setw (2) << std::setprecision (3) << jetEt << "</TD>"
00220                          << "<TD>" << std::setw (2) << std::setprecision (3) << eEm << "</TD>"
00221                          << "<TD>" << std::setw (6) << std::setprecision (3) << eHad << "</TD>"
00222                          << "<TD>" << std::setw (5) << std::setprecision (3) << eInv << "</TD>"
00223                          << "<TD>" << std::setw (5) << std::setprecision (3) << eAux << "</TD>"
00224                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*it).eta () << "</TD>"
00225                          << "<TD>" << std::setw (5) << std::setprecision (3) << (*it).phi () << "</TD></TR>";
00226                 }
00227             }
00228         }
00229         catch (cms::Exception& e)
00230         {
00231             if (this->m_onCmsException)
00232                 this->m_onCmsException (&e);
00233         }
00234         catch (lat::Error &e) 
00235         {
00236             if (this->m_onError)
00237                 this->m_onError (&e);
00238         }
00239         catch (std::exception &e) 
00240         {
00241             if (this->m_onException)
00242                 this->m_onException (&e);
00243         }
00244         catch (...) 
00245         {
00246             if (this->m_onUnhandledException)
00247                 this->m_onUnhandledException ();
00248         }
00249     }
00250     
00251     text << "</table>";
00252     
00253     // Send it over.
00254     IgQtLock ();
00255 
00256     rep->setText (text.str ());
00257 }


Member Data Documentation

VisCaloAnnotation VisGenJetCollectionTwig::m_annotation [private]

Definition at line 51 of file VisGenJetCollectionTwig.h.

VisEnergyCut VisGenJetCollectionTwig::m_cut [private]

Definition at line 49 of file VisGenJetCollectionTwig.h.

Referenced by update().

VisCaloEnergyScale VisGenJetCollectionTwig::m_escale [private]

Definition at line 50 of file VisGenJetCollectionTwig.h.

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

Definition at line 44 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent().

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

Definition at line 46 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent().

reco::GenJetCollection VisGenJetCollectionTwig::m_jets [private]

Definition at line 52 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent(), and update().

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

Definition at line 45 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent().

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

Definition at line 47 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent().

VisLegoScale VisGenJetCollectionTwig::m_scale [private]

Definition at line 48 of file VisGenJetCollectionTwig.h.

Referenced by update().

std::string VisGenJetCollectionTwig::m_text [private]

Definition at line 43 of file VisGenJetCollectionTwig.h.

Referenced by onNewEvent(), and update().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:35:26 2009 for CMSSW by  doxygen 1.5.4