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

References m_button, and m_text.

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

Definition at line 69 of file FWInvMassDialog.cc.

70 {
71 }
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().

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

Definition at line 94 of file FWInvMassDialog.cc.

References m_firstLine, and m_text.

Referenced by Calculate().

95 {
96  m_text->Clear();
97  m_firstLine = true;
98 }
TGTextView * m_text
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.

121 {
122  const std::set<FWModelId>& sted = m_selectionMgr->selected();
123 
124  beginUpdate();
125 
126  addLine(TString::Format(" %d items in selection", (int) sted.size()));
127  addLine("");
128  addLine("--------------------------------------------------+--------------");
129  addLine(" px py pz pT | Collection");
130  addLine("--------------------------------------------------+--------------");
131 
132  TClass *rc_class = TClass::GetClass(typeid(reco::Candidate));
133  TClass *rtb_class = TClass::GetClass(typeid(reco::TrackBase));
134 
135  math::XYZVector sum;
136  double sum_len = 0;
137  double sum_len_xy = 0;
138 
139  math::XYZVector first, second; int n = 0;
140 
141  for (std::set<FWModelId>::const_iterator i = sted.begin(); i != sted.end(); ++i, ++n)
142  {
143  TString line;
144 
145  TClass *model_class = const_cast<TClass*>(i->item()->modelType());
146  void *model_data = const_cast<void*> (i->item()->modelData(i->index()));
147 
149  bool ok_p = false;
150 
151  reco::Candidate *rc = reinterpret_cast<reco::Candidate*>
152  (model_class->DynamicCast(rc_class, model_data));
153 
154  if (rc != 0)
155  {
156  ok_p = true;
157  v.SetXYZ(rc->px(), rc->py(), rc->pz());
158  }
159  else
160  {
161  reco::TrackBase *rtb = reinterpret_cast<reco::TrackBase*>
162  (model_class->DynamicCast(rtb_class, model_data));
163 
164  if (rtb != 0)
165  {
166  ok_p = true;
167  v.SetXYZ(rtb->px(), rtb->py(), rtb->pz());
168  }
169  }
170 
171  if (ok_p)
172  {
173  sum += v;
174  sum_len += TMath::Sqrt(v.mag2());
175  sum_len_xy += TMath::Sqrt(v.perp2());
176 
177  line = TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));
178 
179  }
180  else
181  {
182  line = TString::Format(" -------- not a Candidate or TrackBase --------");
183  }
184  line += TString::Format(" | %s[%d]", i->item()->name().c_str(), i->index());
185 
186  addLine(line);
187 
188  if (n == 0) first = v; else if (n == 1) second = v;
189  }
190 
191  addLine("--------------------------------------------------+--------------");
192  addLine(TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f | Sum", sum.x(), sum.y(), sum.z(), TMath::Sqrt(sum.perp2())));
193  addLine("");
194  addLine(TString::Format("m = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len * sum_len - sum.mag2()))));
195  addLine(TString::Format("mT = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len_xy * sum_len_xy - sum.perp2()))));
196  addLine(TString::Format("HT = %10.3f", sum_len_xy));
197 
198  if (n == 2) {
199  addLine(TString::Format("deltaPhi = %+6.4f", deltaPhi(first.Phi(), second.Phi())));
200  addLine(TString::Format("deltaEta = %+6.4f", first.Eta()- second.Eta()));
201  addLine(TString::Format("deltaR = % 6.4f", deltaR(first.Eta(), first.Phi(), second.Eta(), second.Phi())));
202  }
203 
204  endUpdate();
205 }
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
U second(std::pair< T, U > const &p)
void addLine(const TString &line)
virtual double py() const =0
y coordinate of momentum vector
bool first
Definition: L1TdeRCT.cc:94
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
virtual double px() const =0
x coordinate of momentum vector
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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 73 of file FWInvMassDialog.cc.

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

Definition at line 115 of file FWInvMassDialog.cc.

References m_text.

Referenced by Calculate().

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