28 #include "TGTextView.h"
44 TGMainFrame(gClient->GetRoot(), 470, 240),
49 SetWindowName(
"Invariant Mass Dialog");
50 SetCleanup(kDeepCleanup);
52 m_text =
new TGTextView(
this);
53 AddFrame(
m_text,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
55 m_button =
new TGTextButton(
this,
"Calculate");
56 AddFrame(
m_button,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1, 1, 1, 1));
58 m_button->Connect(
"Clicked()",
"FWInvMassDialog",
this,
"Calculate()");
102 TGText *txt =
m_text->GetText();
106 txt->InsText(TGLongPosition(0, 0), line);
111 txt->InsText(TGLongPosition(0, txt->RowCount()), line);
126 addLine(TString::Format(
" %d items in selection", (
int) sted.size()));
128 addLine(
"--------------------------------------------------+--------------");
129 addLine(
" px py pz pT | Collection");
130 addLine(
"--------------------------------------------------+--------------");
137 double sum_len_xy = 0;
141 for (std::set<FWModelId>::const_iterator
i = sted.begin();
i != sted.end(); ++
i, ++
n)
145 TClass *model_class =
const_cast<TClass*
>(
i->item()->modelType());
146 void *model_data =
const_cast<void*
> (
i->item()->modelData(
i->index()));
152 (model_class->DynamicCast(rc_class, model_data));
157 v.SetXYZ(rc->
px(), rc->
py(), rc->
pz());
162 (model_class->DynamicCast(rtb_class, model_data));
167 v.SetXYZ(rtb->
px(), rtb->
py(), rtb->
pz());
174 sum_len += TMath::Sqrt(v.mag2());
175 sum_len_xy += TMath::Sqrt(v.perp2());
177 line = TString::Format(
" %+10.3f %+10.3f %+10.3f %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));
182 line = TString::Format(
" -------- not a Candidate or TrackBase --------");
184 line += TString::Format(
" | %s[%d]",
i->item()->name().c_str(),
i->index());
188 if (n == 0) first =
v;
else if (n == 1) second =
v;
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())));
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));
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())));
const std::set< FWModelId > & selected() const
virtual ~FWInvMassDialog()
virtual double pz() const =0
z coordinate of momentum vector
virtual void CloseWindow()
double px() const
x coordinate of momentum vector
FWInvMassDialog(FWSelectionManager *sm)
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
virtual double px() const =0
x coordinate of momentum vector
double deltaR(double eta1, double eta2, double phi1, double phi2)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
FWSelectionManager * m_selectionMgr
double py() const
y coordinate of momentum vector