CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
FWInvMassDialog Class Reference

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

Inheritance diagram for FWInvMassDialog:

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 42 of file FWInvMassDialog.cc.

References m_button, and m_text.

42  :
43  TGMainFrame(gClient->GetRoot(), 470, 240),
44  m_selectionMgr(sm),
45  m_text(0),
46  m_button(0)
47 {
48  SetWindowName("Invariant Mass Dialog");
49  SetCleanup(kDeepCleanup);
50 
51  m_text = new TGTextView(this);
52  AddFrame(m_text, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
53 
54  m_button = new TGTextButton(this, "Calculate");
55  AddFrame(m_button, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1, 1, 1, 1));
56 
57  m_button->Connect("Clicked()","FWInvMassDialog", this, "Calculate()");
58 
59  Layout();
60  MapSubwindows();
61 }
TGTextView * m_text
TGTextButton * m_button
FWSelectionManager * m_selectionMgr
FWInvMassDialog::~FWInvMassDialog ( )
virtual

Definition at line 68 of file FWInvMassDialog.cc.

69 {
70 }
FWInvMassDialog::FWInvMassDialog ( const FWInvMassDialog )
private

Member Function Documentation

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

Definition at line 99 of file FWInvMassDialog.cc.

References m_firstLine, and m_text.

Referenced by Calculate().

100 {
101  TGText *txt = m_text->GetText();
102 
103  if (m_firstLine)
104  {
105  txt->InsText(TGLongPosition(0, 0), line);
106  m_firstLine = false;
107  }
108  else
109  {
110  txt->InsText(TGLongPosition(0, txt->RowCount()), line);
111  }
112 }
TGTextView * m_text
void FWInvMassDialog::beginUpdate ( )
protected

Definition at line 93 of file FWInvMassDialog.cc.

References m_firstLine, and m_text.

Referenced by Calculate().

94 {
95  m_text->Clear();
96  m_firstLine = true;
97 }
TGTextView * m_text
void FWInvMassDialog::Calculate ( )

Definition at line 119 of file FWInvMassDialog.cc.

References addLine(), beginUpdate(), endUpdate(), i, geometryCSVtoXML::line, m_selectionMgr, siStripFEDMonitor_P5_cff::Max, reco::Candidate::px(), reco::TrackBase::px(), reco::Candidate::py(), reco::TrackBase::py(), reco::Candidate::pz(), reco::TrackBase::pz(), FWSelectionManager::selected(), and v.

120 {
121  const std::set<FWModelId>& sted = m_selectionMgr->selected();
122 
123  beginUpdate();
124 
125  addLine(TString::Format(" %d items in selection", (int) sted.size()));
126  addLine("");
127  addLine("--------------------------------------------------+--------------");
128  addLine(" px py pz pT | Collection");
129  addLine("--------------------------------------------------+--------------");
130 
131  TClass *rc_class = TClass::GetClass(typeid(reco::Candidate));
132  TClass *rtb_class = TClass::GetClass(typeid(reco::TrackBase));
133 
134  math::XYZVector sum;
135  double sum_len = 0;
136  double sum_len_xy = 0;
137 
138  for (std::set<FWModelId>::const_iterator i = sted.begin(); i != sted.end(); ++i)
139  {
140  TString line;
141 
142  TClass *model_class = const_cast<TClass*>(i->item()->modelType());
143  void *model_data = const_cast<void*> (i->item()->modelData(i->index()));
144 
146  bool ok_p = false;
147 
148  reco::Candidate *rc = reinterpret_cast<reco::Candidate*>
149  (model_class->DynamicCast(rc_class, model_data));
150 
151  if (rc != 0)
152  {
153  ok_p = true;
154  v.SetXYZ(rc->px(), rc->py(), rc->pz());
155  }
156  else
157  {
158  reco::TrackBase *rtb = reinterpret_cast<reco::TrackBase*>
159  (model_class->DynamicCast(rtb_class, model_data));
160 
161  if (rtb != 0)
162  {
163  ok_p = true;
164  v.SetXYZ(rtb->px(), rtb->py(), rtb->pz());
165  }
166  }
167 
168  if (ok_p)
169  {
170  sum += v;
171  sum_len += TMath::Sqrt(v.mag2());
172  sum_len_xy += TMath::Sqrt(v.perp2());
173 
174  line = TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));
175 
176  }
177  else
178  {
179  line = TString::Format(" -------- not a Candidate or TrackBase --------");
180  }
181  line += TString::Format(" | %s[%d]", i->item()->name().c_str(), i->index());
182 
183  addLine(line);
184  }
185 
186  addLine("--------------------------------------------------+--------------");
187  addLine(TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f | Sum", sum.x(), sum.y(), sum.z(), TMath::Sqrt(sum.perp2())));
188  addLine("");
189  addLine(TString::Format("m = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len * sum_len - sum.mag2()))));
190  addLine(TString::Format("mT = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len_xy * sum_len_xy - sum.perp2()))));
191 
192  endUpdate();
193 }
const std::set< FWModelId > & selected() const
int i
Definition: DBlmapReader.cc:9
virtual double pz() const =0
z coordinate of momentum vector
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
void addLine(const TString &line)
virtual double py() const =0
y coordinate of momentum vector
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
virtual double px() const =0
x coordinate of momentum vector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
FWSelectionManager * m_selectionMgr
mathSSE::Vec4< T > v
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135
FWInvMassDialog::ClassDef ( FWInvMassDialog  ,
 
)
private
void FWInvMassDialog::CloseWindow ( )
virtual

Definition at line 72 of file FWInvMassDialog.cc.

73 {
74  UnmapWindow();
75 }
void FWInvMassDialog::endUpdate ( )
protected

Definition at line 114 of file FWInvMassDialog.cc.

References m_text.

Referenced by Calculate().

115 {
116  m_text->Update();
117 }
TGTextView * m_text
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().

bool FWInvMassDialog::m_firstLine
private

Definition at line 67 of file FWInvMassDialog.h.

Referenced by addLine(), and beginUpdate().

FWSelectionManager* FWInvMassDialog::m_selectionMgr
private

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().