CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 {
17 }
19 {
20 }
21 
22 
23 namespace {
24  double wrapPi(double val)
25  {
26  using namespace TMath;
27 
28  if (val< -Pi())
29  {
30  return val += TwoPi();
31  }
32  if (val> Pi())
33  {
34  return val -= TwoPi();
35  }
36  return val;
37  }
38 }
39 
40 
41 void
43 {
45 }
46 
47 void
49 {
50 
51  if(0!=m_hist) {
52  m_hist->Reset();
53  }
55 }
56 
57 bool
59 {
60  if (m_hist == 0)
61  {
62  // add new slice
63  Bool_t status = TH1::AddDirectoryStatus();
64  TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
65  m_hist = new TH2F("caloHist",
66  "caloHist",
68  72, -M_PI, M_PI);
69  TH1::AddDirectory(status);
70  TEveCaloDataHist* ch = static_cast<TEveCaloDataHist*>(m_caloData);
71  m_sliceIndex = ch->AddHistogram(m_hist);
72 
73 
74 
75  m_caloData->RefSliceInfo(m_sliceIndex).Setup(item()->name().c_str(), 0.,
76  item()->defaultDisplayProperties().color(),
77  item()->defaultDisplayProperties().transparency());
78 
79  // add new selector
81  if (m_caloData->GetUserData())
82  {
83  FWFromEveSelectorBase* base = reinterpret_cast<FWFromEveSelectorBase*>(m_caloData->GetUserData());
84  assert(0!=base);
85  sel = dynamic_cast<FWFromTEveCaloDataSelector*> (base);
86  assert(0!=sel);
87  }
88  else
89  {
91  //make sure it is accessible via the base class
92  m_caloData->SetUserData(static_cast<FWFromEveSelectorBase*>(sel));
93  }
96 
97  return true;
98  }
99  return false;
100  }
101 
102 
103 void FWCaloDataHistProxyBuilder::addEntryToTEveCaloData(float eta, float phi, float Et, bool isSelected)
104 {
105  using namespace TMath;
106  static float d = 2.5*Pi()/180;
107  // printf("comapre %f, %f \n", fw3dlego::xbins[80], fw3dlego::xbins[61] );
108 
109 
111  if (Abs(eta) > fw3dlego::xbins[80])
112  {
113  m_hist->Fill(eta,wrapPi(phi - 3*d), Et *0.25);
114  m_hist->Fill(eta,wrapPi(phi - d), Et *0.25);
115  m_hist->Fill(eta,wrapPi(phi + d), Et *0.25);
116  m_hist->Fill(eta,wrapPi(phi + 3*d), Et *0.25);
117  }
118  else if (Abs(eta) > fw3dlego::xbins[61])
119  {
120  m_hist->Fill(eta,wrapPi(phi - d), Et *0.5);
121  m_hist->Fill(eta,wrapPi(phi + d), Et *0.5);
122  }
123  else
124  {
125  m_hist->Fill(eta,phi, Et);
126  }
127  }
128  else
129  {
130  m_hist->Fill(eta,phi, Et);
131  }
132 
133  TEveCaloData::vCellId_t& selected = m_caloData->GetCellsSelected();
134  if(isSelected) {
135  //NOTE: I tried calling TEveCalo::GetCellList but it always returned 0, probably because of threshold issues
136  // but looking at the TEveCaloHist::GetCellList code the CellId_t is just the histograms bin # and the slice
137  // printf("applyChangesToAllModels ...check selected \n");
138 
139 
141  if (Abs(eta) > fw3dlego::xbins[80])
142  {
143  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi -3*d)),m_sliceIndex));
144  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi -d)) ,m_sliceIndex));
145  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi +d)) ,m_sliceIndex));
146  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi +3*d)),m_sliceIndex));
147  }
148  if (Abs(eta) > fw3dlego::xbins[60])
149  {
150  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi -d)), m_sliceIndex));
151  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta, wrapPi(phi +d)), m_sliceIndex));
152  }
153  else
154  {
155  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta,phi),m_sliceIndex));
156  }
157  }
158  else
159  {
160  selected.push_back(TEveCaloData::CellId_t(m_hist->FindBin(eta,phi),m_sliceIndex));
161  }
162  }
163 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
const double TwoPi
const double Pi
const fireworks::Context & context() const
const double xbins[]
assert(m_qm.get())
void addSliceSelector(int iSlice, FWFromSliceSelector *)
const FWEventItem * item() const
virtual FWHistSliceSelector * instantiateSliceSelector()=0
T Abs(T a)
Definition: MathUtil.h:49
TEveCaloDataHist * getCaloData() const
Definition: Context.h:80
#define M_PI
void addEntryToTEveCaloData(float eta, float phi, float Et, bool isSelected)
virtual void itemBeingDestroyed(const FWEventItem *)
const int xbins_n
virtual void setCaloData(const fireworks::Context &)
Geom::Phi< T > phi() const
virtual bool aggregatePhiCells() const
tuple status
Definition: ntuplemaker.py:245
virtual void itemBeingDestroyed(const FWEventItem *)