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 32 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(), SiPixelRawToDigiRegional_cfi::deltaPhi, deltaR(), endUpdate(), plotBeamSpotDB::first, i, geometryCSVtoXML::line, m_selectionMgr, Max(), gen::n, reco::Candidate::px(), reco::TrackBase::px(), reco::Candidate::py(), reco::TrackBase::py(), reco::Candidate::pz(), reco::TrackBase::pz(), edm::second(), FWSelectionManager::selected(), and findQualityFiles::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  math::XYZVector first, second; int n = 0;
139 
140  for (std::set<FWModelId>::const_iterator i = sted.begin(); i != sted.end(); ++i, ++n)
141  {
142  TString line;
143 
144  TClass *model_class = const_cast<TClass*>(i->item()->modelType());
145  void *model_data = const_cast<void*> (i->item()->modelData(i->index()));
146 
148  bool ok_p = false;
149 
150  reco::Candidate *rc = reinterpret_cast<reco::Candidate*>
151  (model_class->DynamicCast(rc_class, model_data));
152 
153  if (rc != 0)
154  {
155  ok_p = true;
156  v.SetXYZ(rc->px(), rc->py(), rc->pz());
157  }
158  else
159  {
160  reco::TrackBase *rtb = reinterpret_cast<reco::TrackBase*>
161  (model_class->DynamicCast(rtb_class, model_data));
162 
163  if (rtb != 0)
164  {
165  ok_p = true;
166  v.SetXYZ(rtb->px(), rtb->py(), rtb->pz());
167  }
168  }
169 
170  if (ok_p)
171  {
172  sum += v;
173  sum_len += TMath::Sqrt(v.mag2());
174  sum_len_xy += TMath::Sqrt(v.perp2());
175 
176  line = TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));
177 
178  }
179  else
180  {
181  line = TString::Format(" -------- not a Candidate or TrackBase --------");
182  }
183  line += TString::Format(" | %s[%d]", i->item()->name().c_str(), i->index());
184 
185  addLine(line);
186 
187  if (n == 0) first = v; else if (n == 1) second = v;
188  }
189 
190  addLine("--------------------------------------------------+--------------");
191  addLine(TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f | Sum", sum.x(), sum.y(), sum.z(), TMath::Sqrt(sum.perp2())));
192  addLine("");
193  addLine(TString::Format("m = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len * sum_len - sum.mag2()))));
194  addLine(TString::Format("mT = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len_xy * sum_len_xy - sum.perp2()))));
195  addLine(TString::Format("HT = %10.3f", sum_len_xy));
196 
197  if (n == 2) {
198  addLine(TString::Format("deltaPhi = %+6.4f", deltaPhi(first.Phi(), second.Phi())));
199  addLine(TString::Format("deltaEta = %+6.4f", first.Eta()- second.Eta()));
200  addLine(TString::Format("deltaR = % 6.4f", deltaR(first.Eta(), first.Phi(), second.Eta(), second.Phi())));
201  }
202 
203  endUpdate();
204 }
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:580
U second(std::pair< T, U > const &p)
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:592
virtual double px() const =0
x coordinate of momentum vector
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
T Max(T a, T b)
Definition: MathUtil.h:44
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
FWSelectionManager * m_selectionMgr
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:586
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 64 of file FWInvMassDialog.h.

Referenced by FWInvMassDialog().

bool FWInvMassDialog::m_firstLine
private

Definition at line 66 of file FWInvMassDialog.h.

Referenced by addLine(), and beginUpdate().

FWSelectionManager* FWInvMassDialog::m_selectionMgr
private

Definition at line 61 of file FWInvMassDialog.h.

Referenced by Calculate().

TGTextView* FWInvMassDialog::m_text
private

Definition at line 63 of file FWInvMassDialog.h.

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