CMS 3D CMS Logo

FWCaloDataHistProxyBuilder.cc
Go to the documentation of this file.
4 
7 
8 #include "Rtypes.h"
9 #include "TEveCaloData.h"
10 #include "TMath.h"
11 #include "TEveCalo.h"
12 #include "TH2F.h"
13 
14 FWCaloDataHistProxyBuilder::FWCaloDataHistProxyBuilder() : m_hist(nullptr), m_sliceSelector(nullptr) {}
16 
17 namespace {
18  double wrapPi(double val) {
19  using namespace TMath;
20 
21  if (val < -Pi()) {
22  return val += TwoPi();
23  }
24  if (val > Pi()) {
25  return val -= TwoPi();
26  }
27  return val;
28  }
29 } // namespace
30 
32 
34  if (nullptr != m_hist) {
35  m_hist->Reset();
36  }
38 }
39 
41  if (m_hist == nullptr) {
42  // add new slice
43  Bool_t status = TH1::AddDirectoryStatus();
44  TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
45  m_hist = new TH2F("caloHist", "caloHist", fw3dlego::xbins_n - 1, fw3dlego::xbins, 72, -M_PI, M_PI);
46  TH1::AddDirectory(status);
47  TEveCaloDataHist* ch = static_cast<TEveCaloDataHist*>(m_caloData);
48  m_sliceIndex = ch->AddHistogram(m_hist);
49 
50  m_caloData->RefSliceInfo(m_sliceIndex)
51  .Setup(item()->name().c_str(),
52  0.,
53  item()->defaultDisplayProperties().color(),
54  item()->defaultDisplayProperties().transparency());
55 
56  // add new selector
58  if (m_caloData->GetUserData()) {
59  FWFromEveSelectorBase* base = reinterpret_cast<FWFromEveSelectorBase*>(m_caloData->GetUserData());
60  assert(nullptr != base);
61  sel = dynamic_cast<FWFromTEveCaloDataSelector*>(base);
62  assert(nullptr != sel);
63  } else {
65  //make sure it is accessible via the base class
66  m_caloData->SetUserData(static_cast<FWFromEveSelectorBase*>(sel));
67  }
69  sel->addSliceSelector(m_sliceIndex, m_sliceSelector);
70 
71  return true;
72  }
73  return false;
74 }
75 
77  using namespace TMath;
78  static float d = 2.5 * Pi() / 180;
79  // printf("comapre %f, %f \n", fw3dlego::xbins[80], fw3dlego::xbins[61] );
80 
82  if (Abs(eta) > fw3dlego::xbins[80]) {
83  m_hist->Fill(eta, wrapPi(phi - 3 * d), Et * 0.25);
84  m_hist->Fill(eta, wrapPi(phi - d), Et * 0.25);
85  m_hist->Fill(eta, wrapPi(phi + d), Et * 0.25);
86  m_hist->Fill(eta, wrapPi(phi + 3 * d), Et * 0.25);
87  } else if (Abs(eta) > fw3dlego::xbins[61]) {
88  m_hist->Fill(eta, wrapPi(phi - d), Et * 0.5);
89  m_hist->Fill(eta, wrapPi(phi + d), Et * 0.5);
90  } else {
91  m_hist->Fill(eta, phi, Et);
92  }
93  } else {
94  m_hist->Fill(eta, phi, Et);
95  }
96 
97  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
98  if (isSelected) {
99  //NOTE: I tried calling TEveCalo::GetCellList but it always returned 0, probably because of threshold issues
100  // but looking at the TEveCaloHist::GetCellList code the CellId_t is just the histograms bin # and the slice
101  // printf("applyChangesToAllModels ...check selected \n");
102 
104  if (Abs(eta) > fw3dlego::xbins[80]) {
105  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi - 3 * d)), m_sliceIndex));
106  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi - d)), m_sliceIndex));
107  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi + d)), m_sliceIndex));
108  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi + 3 * d)), m_sliceIndex));
109  }
110  if (Abs(eta) > fw3dlego::xbins[60]) {
111  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi - d)), m_sliceIndex));
112  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi + d)), m_sliceIndex));
113  } else {
114  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, phi), m_sliceIndex));
115  }
116  } else {
117  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, phi), m_sliceIndex));
118  }
119  }
120 }
const double TwoPi
const double Pi
const double xbins[]
void itemBeingDestroyed(const FWEventItem *) override
TEveCaloDataHist * getCaloData() const
Definition: Context.h:69
assert(be >=bs)
virtual bool aggregatePhiCells() const
const fireworks::Context & context() const
virtual FWHistSliceSelector * instantiateSliceSelector()=0
void itemBeingDestroyed(const FWEventItem *) override
void setCaloData(const fireworks::Context &) override
d
Definition: ztail.py:151
void addEntryToTEveCaloData(float eta, float phi, float Et, bool isSelected)
#define M_PI
const int xbins_n
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
const FWEventItem * item() const