CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

FWInvMassDialog Class Reference

#include <Fireworks/Core/interface/FWInvMassDialog.h>

List of all members.

Public Member Functions

void Calculate ()
virtual void CloseWindow ()
 FWInvMassDialog (FWSelectionManager *sm)
virtual ~FWInvMassDialog ()

Protected Member Functions

void addLine (const TString &line)
void beginUpdate ()
void endUpdate ()

Private Member Functions

 ClassDef (FWInvMassDialog, 0)
 FWInvMassDialog (const FWInvMassDialog &)
const FWInvMassDialogoperator= (const FWInvMassDialog &)

Private Attributes

TGTextButton * m_button
bool m_firstLine
FWSelectionManagerm_selectionMgr
TGTextView * m_text

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 33 of file FWInvMassDialog.h.


Constructor & Destructor Documentation

FWInvMassDialog::FWInvMassDialog ( FWSelectionManager sm)

Definition at line 43 of file FWInvMassDialog.cc.

References m_button, and m_text.

                                                       :
   TGMainFrame(gClient->GetRoot(), 470, 240),
   m_selectionMgr(sm),
   m_text(0),
   m_button(0)
{
   SetWindowName("Invariant Mass Dialog");
   SetCleanup(kDeepCleanup);

   m_text = new TGTextView(this);
   AddFrame(m_text, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));

   m_button = new TGTextButton(this, "Calculate");
   AddFrame(m_button, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1, 1, 1, 1));

   m_button->Connect("Clicked()","FWInvMassDialog", this, "Calculate()");

   Layout();
   MapSubwindows();
}
FWInvMassDialog::~FWInvMassDialog ( ) [virtual]

Definition at line 69 of file FWInvMassDialog.cc.

{
}
FWInvMassDialog::FWInvMassDialog ( const FWInvMassDialog ) [private]

Member Function Documentation

void FWInvMassDialog::addLine ( const TString &  line) [protected]

Definition at line 100 of file FWInvMassDialog.cc.

References m_firstLine, and m_text.

Referenced by Calculate().

{
   TGText *txt = m_text->GetText();

   if (m_firstLine)
   {
      txt->InsText(TGLongPosition(0, 0), line);
      m_firstLine = false;
   }
   else
   {
      txt->InsText(TGLongPosition(0, txt->RowCount()), line);
   }
}
void FWInvMassDialog::beginUpdate ( ) [protected]

Definition at line 94 of file FWInvMassDialog.cc.

References m_firstLine, and m_text.

Referenced by Calculate().

{
   m_text->Clear();
   m_firstLine = true;
}
void FWInvMassDialog::Calculate ( )

Definition at line 120 of file FWInvMassDialog.cc.

References addLine(), beginUpdate(), SiPixelRawToDigiRegional_cfi::deltaPhi, deltaR(), endUpdate(), first, i, geometryCSVtoXML::line, m_selectionMgr, siStripFEDMonitor_P5_cff::Max, n, reco::Candidate::px(), reco::TrackBase::px(), reco::Candidate::py(), reco::TrackBase::py(), reco::Candidate::pz(), reco::TrackBase::pz(), edm::second(), FWSelectionManager::selected(), and v.

{
   const std::set<FWModelId>& sted = m_selectionMgr->selected();

   beginUpdate();

   addLine(TString::Format(" %d items in selection", (int) sted.size()));
   addLine("");
   addLine("--------------------------------------------------+--------------");
   addLine("       px          py          pz          pT     | Collection");
   addLine("--------------------------------------------------+--------------");

   TClass *rc_class  = TClass::GetClass(typeid(reco::Candidate));
   TClass *rtb_class = TClass::GetClass(typeid(reco::TrackBase));

   math::XYZVector sum;
   double          sum_len = 0;
   double          sum_len_xy = 0;

   math::XYZVector first, second; int n = 0;

   for (std::set<FWModelId>::const_iterator i = sted.begin(); i != sted.end(); ++i, ++n)
   {
      TString line;

      TClass *model_class = const_cast<TClass*>(i->item()->modelType());
      void   *model_data  = const_cast<void*>  (i->item()->modelData(i->index()));

      math::XYZVector v;
      bool            ok_p = false;

      reco::Candidate *rc = reinterpret_cast<reco::Candidate*>
         (model_class->DynamicCast(rc_class, model_data));

      if (rc != 0)
      {
         ok_p = true;
         v.SetXYZ(rc->px(), rc->py(), rc->pz());
      }
      else
      {
         reco::TrackBase *rtb = reinterpret_cast<reco::TrackBase*>
            (model_class->DynamicCast(rtb_class, model_data));

         if (rtb != 0)
         {
            ok_p = true;
            v.SetXYZ(rtb->px(), rtb->py(), rtb->pz());
         }
      }

      if (ok_p)
      {
         sum        += v;
         sum_len    += TMath::Sqrt(v.mag2());
         sum_len_xy += TMath::Sqrt(v.perp2());

         line = TString::Format("  %+10.3f  %+10.3f  %+10.3f  %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));

      }
      else
      {
         line = TString::Format("  -------- not a Candidate or TrackBase --------");
      }
      line += TString::Format("  | %s[%d]", i->item()->name().c_str(), i->index());

      addLine(line);

      if (n == 0) first = v; else if (n == 1) second = v;
   }

   addLine("--------------------------------------------------+--------------");
   addLine(TString::Format("  %+10.3f  %+10.3f  %+10.3f  %10.3f  | Sum", sum.x(), sum.y(), sum.z(), TMath::Sqrt(sum.perp2())));
   addLine("");
   addLine(TString::Format("m  = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len    * sum_len    - sum.mag2()))));
   addLine(TString::Format("mT = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len_xy * sum_len_xy - sum.perp2()))));
   addLine(TString::Format("HT = %10.3f", sum_len_xy));
 
   if (n == 2) {
      addLine(TString::Format("deltaPhi  = %+6.4f", deltaPhi(first.Phi(), second.Phi())));
      addLine(TString::Format("deltaEta  = %+6.4f", first.Eta()- second.Eta()));
      addLine(TString::Format("deltaR    = % 6.4f", deltaR(first.Eta(), first.Phi(), second.Eta(), second.Phi())));
   }

   endUpdate();
}
FWInvMassDialog::ClassDef ( FWInvMassDialog  ,
 
) [private]
void FWInvMassDialog::CloseWindow ( ) [virtual]

Definition at line 73 of file FWInvMassDialog.cc.

{
   UnmapWindow();
}
void FWInvMassDialog::endUpdate ( ) [protected]

Definition at line 115 of file FWInvMassDialog.cc.

References m_text.

Referenced by Calculate().

{
   m_text->Update();
}
const FWInvMassDialog& FWInvMassDialog::operator= ( const FWInvMassDialog ) [private]

Member Data Documentation

TGTextButton* FWInvMassDialog::m_button [private]

Definition at line 65 of file FWInvMassDialog.h.

Referenced by FWInvMassDialog().

Definition at line 67 of file FWInvMassDialog.h.

Referenced by addLine(), and beginUpdate().

Definition at line 62 of file FWInvMassDialog.h.

Referenced by Calculate().

TGTextView* FWInvMassDialog::m_text [private]

Definition at line 64 of file FWInvMassDialog.h.

Referenced by addLine(), beginUpdate(), endUpdate(), and FWInvMassDialog().