CMS 3D CMS Logo

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 ()
 
void CloseWindow () override
 
 FWInvMassDialog (FWSelectionManager *sm)
 
 ~FWInvMassDialog () override
 

Protected Member Functions

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

Private Member Functions

 ClassDefOverride (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() [1/2]

FWInvMassDialog::FWInvMassDialog ( FWSelectionManager sm)

Definition at line 42 of file FWInvMassDialog.cc.

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

References m_button, and m_text.

◆ ~FWInvMassDialog()

FWInvMassDialog::~FWInvMassDialog ( )
override

Definition at line 64 of file FWInvMassDialog.cc.

64 {}

◆ FWInvMassDialog() [2/2]

FWInvMassDialog::FWInvMassDialog ( const FWInvMassDialog )
private

Member Function Documentation

◆ addLine()

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

Definition at line 89 of file FWInvMassDialog.cc.

89  {
90  TGText *txt = m_text->GetText();
91 
92  if (m_firstLine) {
93  txt->InsText(TGLongPosition(0, 0), line);
94  m_firstLine = false;
95  } else {
96  txt->InsText(TGLongPosition(0, txt->RowCount()), line);
97  }
98 }

References mps_splice::line, m_firstLine, and m_text.

Referenced by Calculate().

◆ beginUpdate()

void FWInvMassDialog::beginUpdate ( )
protected

Definition at line 84 of file FWInvMassDialog.cc.

84  {
85  m_text->Clear();
86  m_firstLine = true;
87 }

References m_firstLine, and m_text.

Referenced by Calculate().

◆ Calculate()

void FWInvMassDialog::Calculate ( )

Definition at line 102 of file FWInvMassDialog.cc.

102  {
103  const std::set<FWModelId> &sted = m_selectionMgr->selected();
104 
105  beginUpdate();
106 
107  addLine(TString::Format(" %d items in selection", (int)sted.size()));
108  addLine("");
109  addLine("--------------------------------------------------+--------------");
110  addLine(" px py pz pT | Collection");
111  addLine("--------------------------------------------------+--------------");
112 
113  TClass *rc_class = TClass::GetClass(typeid(reco::Candidate));
114  TClass *rtb_class = TClass::GetClass(typeid(reco::TrackBase));
115 
116  math::XYZVector sum;
117  double sum_len = 0;
118  double sum_len_xy = 0;
119 
121  int n = 0;
122 
123  for (std::set<FWModelId>::const_iterator i = sted.begin(); i != sted.end(); ++i, ++n) {
124  TString line;
125 
126  TClass *model_class = const_cast<TClass *>(i->item()->modelType());
127  void *model_data = const_cast<void *>(i->item()->modelData(i->index()));
128 
130  bool ok_p = false;
131 
132  reco::Candidate *rc = reinterpret_cast<reco::Candidate *>(model_class->DynamicCast(rc_class, model_data));
133 
134  if (rc != nullptr) {
135  ok_p = true;
136  v.SetXYZ(rc->px(), rc->py(), rc->pz());
137  } else {
138  reco::TrackBase *rtb = reinterpret_cast<reco::TrackBase *>(model_class->DynamicCast(rtb_class, model_data));
139 
140  if (rtb != nullptr) {
141  ok_p = true;
142  v.SetXYZ(rtb->px(), rtb->py(), rtb->pz());
143  }
144  }
145 
146  if (ok_p) {
147  sum += v;
148  sum_len += TMath::Sqrt(v.mag2());
149  sum_len_xy += TMath::Sqrt(v.perp2());
150 
151  line = TString::Format(" %+10.3f %+10.3f %+10.3f %10.3f", v.x(), v.y(), v.z(), TMath::Sqrt(v.perp2()));
152 
153  } else {
154  line = TString::Format(" -------- not a Candidate or TrackBase --------");
155  }
156  line += TString::Format(" | %s[%d]", i->item()->name().c_str(), i->index());
157 
158  addLine(line);
159 
160  if (n == 0)
161  first = v;
162  else if (n == 1)
163  second = v;
164  }
165 
166  addLine("--------------------------------------------------+--------------");
167  addLine(TString::Format(
168  " %+10.3f %+10.3f %+10.3f %10.3f | Sum", sum.x(), sum.y(), sum.z(), TMath::Sqrt(sum.perp2())));
169  addLine("");
170  addLine(TString::Format("m = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len * sum_len - sum.mag2()))));
171  addLine(TString::Format("mT = %10.3f", TMath::Sqrt(TMath::Max(0.0, sum_len_xy * sum_len_xy - sum.perp2()))));
172  addLine(TString::Format("HT = %10.3f", sum_len_xy));
173 
174  if (n == 2) {
175  addLine(TString::Format("deltaPhi = %+6.4f", deltaPhi(first.Phi(), second.Phi())));
176  addLine(TString::Format("deltaEta = %+6.4f", first.Eta() - second.Eta()));
177  addLine(TString::Format("deltaR = % 6.4f", deltaR(first.Eta(), first.Phi(), second.Eta(), second.Phi())));
178  }
179 
180  endUpdate();
181 }

References addLine(), beginUpdate(), SiPixelRawToDigiRegional_cfi::deltaPhi, PbPb_ZMuSkimMuonDPG_cff::deltaR, endUpdate(), first, mps_fire::i, mps_splice::line, m_selectionMgr, Max(), dqmiodumpmetadata::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.

◆ ClassDefOverride()

FWInvMassDialog::ClassDefOverride ( FWInvMassDialog  ,
 
)
private

◆ CloseWindow()

void FWInvMassDialog::CloseWindow ( )
override

Definition at line 66 of file FWInvMassDialog.cc.

66 { UnmapWindow(); }

◆ endUpdate()

void FWInvMassDialog::endUpdate ( )
protected

Definition at line 100 of file FWInvMassDialog.cc.

100 { m_text->Update(); }

References m_text.

Referenced by Calculate().

◆ operator=()

const FWInvMassDialog& FWInvMassDialog::operator= ( const FWInvMassDialog )
private

Member Data Documentation

◆ m_button

TGTextButton* FWInvMassDialog::m_button
private

Definition at line 62 of file FWInvMassDialog.h.

Referenced by FWInvMassDialog().

◆ m_firstLine

bool FWInvMassDialog::m_firstLine
private

Definition at line 64 of file FWInvMassDialog.h.

Referenced by addLine(), and beginUpdate().

◆ m_selectionMgr

FWSelectionManager* FWInvMassDialog::m_selectionMgr
private

Definition at line 59 of file FWInvMassDialog.h.

Referenced by Calculate().

◆ m_text

TGTextView* FWInvMassDialog::m_text
private

Definition at line 61 of file FWInvMassDialog.h.

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

FWInvMassDialog::m_text
TGTextView * m_text
Definition: FWInvMassDialog.h:61
FWInvMassDialog::m_firstLine
bool m_firstLine
Definition: FWInvMassDialog.h:64
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
reco::TrackBase::px
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWInvMassDialog::m_button
TGTextButton * m_button
Definition: FWInvMassDialog.h:62
FWInvMassDialog::endUpdate
void endUpdate()
Definition: FWInvMassDialog.cc:100
reco::Candidate::pz
virtual double pz() const =0
z coordinate of momentum vector
reco::TrackBase::py
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
FWSelectionManager::selected
const std::set< FWModelId > & selected() const
Definition: FWSelectionManager.cc:168
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
reco::Candidate::py
virtual double py() const =0
y coordinate of momentum vector
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::TrackBase
Definition: TrackBase.h:62
Max
T Max(T a, T b)
Definition: MathUtil.h:44
reco::Candidate
Definition: Candidate.h:27
reco::Candidate::px
virtual double px() const =0
x coordinate of momentum vector
reco::TrackBase::pz
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
FWInvMassDialog::m_selectionMgr
FWSelectionManager * m_selectionMgr
Definition: FWInvMassDialog.h:59
FWInvMassDialog::beginUpdate
void beginUpdate()
Definition: FWInvMassDialog.cc:84
mps_splice.line
line
Definition: mps_splice.py:76
FWInvMassDialog::addLine
void addLine(const TString &line)
Definition: FWInvMassDialog.cc:89