Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveCaloData.hxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_REveCaloData
13#define ROOT_REveCaloData
14
15#include <vector>
16#include "ROOT/REveElement.hxx"
18
19#include "TMath.h"
20#include "TAxis.h"
21
22class TH2F;
23class THStack;
24
25namespace ROOT {
26namespace Experimental {
27
28class REveCaloDataSelector;
29
31 public REveAuntAsList,
33{
34public:
36 {
37 TString fName; // Name of the slice, eg. ECAL, HCAL.
38 Float_t fThreshold; // Only display towers with higher energy.
39 Color_t fColor; // Color used to draw this longitudinal slice.
40 Color_t fTransparency; // Transparency used to draw this longitudinal slice.
41
43
44 virtual ~SliceInfo_t() {}
45
46 void Setup(const char* name, Float_t threshold, Color_t col, Char_t transp = 101)
47 {
48 fName = name;
49 fThreshold = threshold;
50 fColor = col;
51 if (transp <= 100) fTransparency = transp;
52 };
53 };
54
55 typedef std::vector<SliceInfo_t> vSliceInfo_t;
56 typedef std::vector<SliceInfo_t>::iterator vSliceInfo_i;
57
58 /**************************************************************************/
59
60 struct CellId_t
61 {
62 // Cell ID inner structure.
63
66
68
69 CellId_t() : fTower(0), fSlice(0), fFraction(0) {}
70 CellId_t(Int_t t, Int_t s, Float_t f=1.0f) : fTower(t), fSlice(s), fFraction(f) {}
71
72 bool operator<(const CellId_t& o) const
73 { return (fTower == o.fTower) ? fSlice < o.fSlice : fTower < o.fTower; }
74 };
75
77 {
78 // Cell geometry inner structure.
79
84
85 Float_t fThetaMin; // cached
86 Float_t fThetaMax; // cached
87
89 CellGeom_t(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax) {Configure(etaMin, etaMax, phiMin, phiMax);}
90 virtual ~CellGeom_t() {}
91
92 void Configure(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax);
93
94 Float_t EtaMin() const { return fEtaMin; }
95 Float_t EtaMax() const { return fEtaMax; }
96 Float_t Eta() const { return (fEtaMin+fEtaMax)*0.5f; }
97 Float_t EtaDelta() const { return fEtaMax-fEtaMin; }
98
99 Float_t PhiMin() const { return fPhiMin; }
100 Float_t PhiMax() const { return fPhiMax; }
101 Float_t Phi() const { return (fPhiMin+fPhiMax)*0.5f; }
102 Float_t PhiDelta() const { return fPhiMax-fPhiMin; }
103
104 Float_t ThetaMin() const { return fThetaMin; }
105 Float_t ThetaMax() const { return fThetaMax; }
106 Float_t Theta() const { return (fThetaMax+fThetaMin)*0.5f; }
108
110 {
111 const Float_t phi = Phi();
112 return ((phi > 0 && phi <= TMath::Pi()) || phi < - TMath::Pi());
113 }
114
115 virtual void Dump() const;
116 };
117
118 struct CellData_t : public CellGeom_t
119 {
120 // Cell data inner structure.
121
123
125 ~CellData_t() override {}
126
127 Float_t Value(Bool_t) const;
128 void Dump() const override;
129 };
130
131
133 {
135
136 std::vector<Float_t> fSliceData;
137 std::vector<Int_t> fBinData;
138
140
141 void Clear()
142 {
143 fSliceData.clear();
144 fBinData.clear();
145 }
146 };
147
148 /**************************************************************************/
149
150 typedef std::vector<CellId_t> vCellId_t;
151 typedef std::vector<CellId_t>::iterator vCellId_i;
152
153 typedef std::vector<CellGeom_t> vCellGeom_t;
154 typedef std::vector<CellGeom_t>::iterator vCellGeom_i;
155 typedef std::vector<CellGeom_t>::const_iterator vCellGeom_ci;
156
157private:
159
160protected:
162
163 std::unique_ptr<TAxis> fEtaAxis;
164 std::unique_ptr<TAxis> fPhiAxis;
165
167
169 Float_t fMaxValE; // cached
170
172
173 std::unique_ptr<REveCaloDataSelector> fSelector;
174
175public:
176 REveCaloData(const char* n="REveCaloData", const char* t="");
177 ~REveCaloData() override {}
178
179 void FillImpliedSelectedSet(Set_t& impSelSet, const std::set<int>& sec_idcs) override;
180
181 virtual void GetCellList(Float_t etaMin, Float_t etaMax,
182 Float_t phi, Float_t phiRng,
183 vCellId_t &out) const = 0;
184
185 void ProcessSelection(vCellId_t& sel_cells, UInt_t selectionId, Bool_t multi);
186
187 virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const = 0;
188
189
190 virtual void GetCellData(const CellId_t &id, CellData_t& data) const = 0;
191
192 virtual void InvalidateUsersCellIdCache();
193 virtual void DataChanged();
194
195 Int_t GetNSlices() const { return fSliceInfos.size(); }
197 void SetSliceThreshold(Int_t slice, Float_t threshold);
198 Float_t GetSliceThreshold(Int_t slice) const;
199 void SetSliceColor(Int_t slice, Color_t col);
200 Color_t GetSliceColor(Int_t slice) const;
201 void SetSliceTransparency(Int_t slice, Char_t t);
202 Char_t GetSliceTransparency(Int_t slice) const;
203
204 virtual void GetEtaLimits(Double_t &min, Double_t &max) const = 0;
205
206 virtual void GetPhiLimits(Double_t &min, Double_t &max) const = 0;
207
208 virtual Float_t GetMaxVal(Bool_t et) const { return et ? fMaxValEt : fMaxValE; }
209 Bool_t Empty() const { return fMaxValEt < 1e-5; }
210
211 virtual TAxis* GetEtaBins() const { return fEtaAxis.get(); }
212 virtual void SetEtaBins(std::unique_ptr<TAxis> ax) { fEtaAxis = std::move(ax); }
213
214 virtual TAxis* GetPhiBins() const { return fPhiAxis.get(); }
215 virtual void SetPhiBins(std::unique_ptr<TAxis> ax) { fPhiAxis= std::move(ax); }
216
217 virtual Float_t GetEps() const { return fEps; }
218 virtual void SetEps(Float_t eps) { fEps=eps; }
219
220 Bool_t GetWrapTwoPi() const { return fWrapTwoPi; }
222
223 void SetSelector(REveCaloDataSelector* iSelector) { fSelector.reset(iSelector); }
225
226 Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
227
228 static Float_t EtaToTheta(Float_t eta);
229
230 bool RequiresExtraSelectionData() const override { return true; };
231 void FillExtraSelectionData(nlohmann::json&, const std::set<int>&) const override;
232
234 std::string GetHighlightTooltip(const std::set<int>& secondary_idcs) const override;
235};
236
237/**************************************************************************/
238/**************************************************************************/
239
241{
242
243private:
245
246protected:
247 typedef std::vector<Float_t> vFloat_t;
248 typedef std::vector<Float_t>::iterator vFloat_i;
249
250 typedef std::vector<vFloat_t> vvFloat_t;
251 typedef std::vector<vFloat_t>::iterator vvFloat_i;
252
255
256 Int_t fTower; // current tower
257
260
263
264public:
265 REveCaloDataVec(Int_t nslices);
266 ~REveCaloDataVec() override;
267
268 Int_t AddSlice();
269 Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax);
270 void FillSlice(Int_t slice, Float_t value);
271 void FillSlice(Int_t slice, Int_t tower, Float_t value);
272
273 Int_t GetNCells() { return fGeomVec.size(); }
274 std::vector<Float_t>& GetSliceVals(Int_t slice) { return fSliceVec[slice]; }
275 std::vector<REveCaloData::CellGeom_t>& GetCellGeom() { return fGeomVec; }
276
277 void GetCellList(Float_t etaMin, Float_t etaMax,
278 Float_t phi, Float_t phiRng,
279 vCellId_t &out) const override;
280
281 void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override;
282
283 void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t& data) const override;
284 void GetEtaLimits(Double_t &min, Double_t &max) const override { min=fEtaMin, max=fEtaMax;}
285 void GetPhiLimits(Double_t &min, Double_t &max) const override { min=fPhiMin; max=fPhiMax;}
286
287
288 void DataChanged() override;
289 void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001);
290};
291
292/**************************************************************************/
293/**************************************************************************/
294
296{
297private:
299
300protected:
301 THStack* fHStack{nullptr};
302
303public:
305 ~REveCaloDataHist() override;
306
307 void GetCellList( Float_t etaMin, Float_t etaMax,
308 Float_t phi, Float_t phiRng, vCellId_t &out) const override;
309
310 void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override;
311
312 void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t& data) const override;
313
314 void GetEtaLimits(Double_t &min, Double_t &max) const override;
315 void GetPhiLimits(Double_t &min, Double_t &max) const override;
316
317
318 void DataChanged() override;
319
320 THStack* GetStack() { return fHStack; }
321
322 TH2F* GetHist(Int_t slice) const;
323
324 Int_t AddHistogram(TH2F* hist);
325};
326
327/**************************************************************************/
328/**************************************************************************/
330{
331private:
332 int fSliceIdx{-1};
333
334public:
336 int GetSliceIndex() {return fSliceIdx;}
337
338 virtual ~REveCaloDataSliceSelector() = default;
339
340 virtual void ProcessSelection(REveCaloData::vCellId_t& sel_cells, UInt_t selectionId, bool multi) = 0;
341 virtual void GetCellsFromSecondaryIndices(const std::set<int>& idcs, REveCaloData::vCellId_t& out) = 0;
342};
343
345{
346private:
348 std::vector< std::unique_ptr<REveCaloDataSliceSelector> > fSliceSelectors;
349
350public:
351 void ProcessSelection( REveCaloData::vCellId_t& sel_cells, UInt_t selectionId, Bool_t multi);
352 void GetCellsFromSecondaryIndices(const std::set<int>&, REveCaloData::vCellId_t& out);
353
354 void AddSliceSelector(std::unique_ptr<REveCaloDataSliceSelector> s) {fSliceSelectors.push_back(std::move(s));}
355 void SetActiveSlice(int s){ fActiveSlice = s;}
356
357 virtual ~REveCaloDataSelector() = default;
358};
359
360} // namespace Experimental
361} // namespace ROOT
362#endif
363
#define f(i)
Definition RSha256.hxx:104
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Definition RtypesCore.h:63
short Color_t
Definition RtypesCore.h:92
char Char_t
Definition RtypesCore.h:37
float Float_t
Definition RtypesCore.h:57
@ kRed
Definition Rtypes.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
Int_t AddHistogram(TH2F *hist)
Add new slice to calo tower.
~REveCaloDataHist() override
Destructor.
void DataChanged() override
Update limits and notify data users.
void GetEtaLimits(Double_t &min, Double_t &max) const override
Get eta limits.
void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const override
Get cell geometry and value from cell ID.
void GetPhiLimits(Double_t &min, Double_t &max) const override
Get phi limits.
void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const override
Get list of cell IDs in given eta and phi range.
void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override
Rebin.
REveCaloDataHist & operator=(const REveCaloDataHist &)=delete
void GetCellsFromSecondaryIndices(const std::set< int > &, REveCaloData::vCellId_t &out)
GetCellsFromSecondaryIndices used in implied selection.
void ProcessSelection(REveCaloData::vCellId_t &sel_cells, UInt_t selectionId, Bool_t multi)
Process selection. Called from REveCaloViz object.
void AddSliceSelector(std::unique_ptr< REveCaloDataSliceSelector > s)
std::vector< std::unique_ptr< REveCaloDataSliceSelector > > fSliceSelectors
virtual void ProcessSelection(REveCaloData::vCellId_t &sel_cells, UInt_t selectionId, bool multi)=0
virtual void GetCellsFromSecondaryIndices(const std::set< int > &idcs, REveCaloData::vCellId_t &out)=0
std::vector< Float_t > & GetSliceVals(Int_t slice)
REveCaloDataVec & operator=(const REveCaloDataVec &)=delete
std::vector< Float_t >::iterator vFloat_i
void GetCellData(const REveCaloData::CellId_t &id, REveCaloData::CellData_t &data) const override
Get cell geometry and value from cell ID.
std::vector< vFloat_t > vvFloat_t
void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override
Rebin cells.
void GetPhiLimits(Double_t &min, Double_t &max) const override
void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const override
Get list of cell-ids for given eta/phi range.
Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
Add tower within eta/phi range.
void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001)
Set XY axis from cells geometry.
void GetEtaLimits(Double_t &min, Double_t &max) const override
std::vector< vFloat_t >::iterator vvFloat_i
std::vector< REveCaloData::CellGeom_t > & GetCellGeom()
~REveCaloDataVec() override
Destructor.
void DataChanged() override
Update limits and notify data users.
void FillSlice(Int_t slice, Float_t value)
Fill given slice in the current tower.
Color_t GetSliceColor(Int_t slice) const
Get color for given slice.
void SetSelector(REveCaloDataSelector *iSelector)
std::vector< SliceInfo_t > vSliceInfo_t
virtual Float_t GetMaxVal(Bool_t et) const
Char_t GetSliceTransparency(Int_t slice) const
Get transparency for given slice.
virtual void SetPhiBins(std::unique_ptr< TAxis > ax)
bool RequiresExtraSelectionData() const override
std::vector< CellId_t >::iterator vCellId_i
void SetSliceThreshold(Int_t slice, Float_t threshold)
Set threshold for given slice.
virtual void GetCellData(const CellId_t &id, CellData_t &data) const =0
virtual void SetEtaBins(std::unique_ptr< TAxis > ax)
virtual TAxis * GetEtaBins() const
std::vector< CellGeom_t >::const_iterator vCellGeom_ci
void SetSliceTransparency(Int_t slice, Char_t t)
Set transparency for given slice.
static Float_t EtaToTheta(Float_t eta)
REveCaloData & operator=(const REveCaloData &)=delete
std::unique_ptr< REveCaloDataSelector > fSelector
std::unique_ptr< TAxis > fEtaAxis
void FillExtraSelectionData(nlohmann::json &, const std::set< int > &) const override
std::string GetHighlightTooltip(const std::set< int > &secondary_idcs) const override
virtual void DataChanged()
Tell users (REveCaloViz instances using this data) that data has changed and they should update the l...
std::unique_ptr< TAxis > fPhiAxis
REveCaloDataSelector * GetSelector()
std::vector< SliceInfo_t >::iterator vSliceInfo_i
virtual Float_t GetEps() const
virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const =0
void ProcessSelection(vCellId_t &sel_cells, UInt_t selectionId, Bool_t multi)
Process newly selected cells with given select-record.
Float_t GetSliceThreshold(Int_t slice) const
Get threshold for given slice.
SliceInfo_t & RefSliceInfo(Int_t s)
virtual void GetEtaLimits(Double_t &min, Double_t &max) const =0
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const =0
virtual TAxis * GetPhiBins() const
virtual void InvalidateUsersCellIdCache()
Invalidate cell ids cache on back ptr references.
std::vector< CellId_t > vCellId_t
void SetSliceColor(Int_t slice, Color_t col)
Set color for given slice.
std::vector< CellGeom_t >::iterator vCellGeom_i
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core json.
virtual void SetEps(Float_t eps)
std::vector< CellGeom_t > vCellGeom_t
virtual void GetPhiLimits(Double_t &min, Double_t &max) const =0
void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &sec_idcs) override
Populate set impSelSet with derived / dependant elements.
virtual std::string GetHighlightTooltip(const std::set< int > &) const
std::set< REveElement * > Set_t
Class to manage histogram axis.
Definition TAxis.h:31
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
The Histogram stack class.
Definition THStack.h:40
Basic string class.
Definition TString.h:139
const char * GetHist()
const Int_t n
Definition legend1.C:16
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
constexpr Double_t Pi()
Definition TMath.h:37
void Dump() const override
Print member data.
void Configure(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
CellGeom_t(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
virtual void Dump() const
Print member data.
CellId_t(Int_t t, Int_t s, Float_t f=1.0f)
bool operator<(const CellId_t &o) const
void Setup(const char *name, Float_t threshold, Color_t col, Char_t transp=101)