Warning, file /include/root/TEveCaloData.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TEveCaloData
0013 #define ROOT_TEveCaloData
0014
0015 #include <vector>
0016 #include "TEveElement.h"
0017
0018 #include "TMath.h"
0019
0020 class TGLSelectRecord;
0021
0022 class TH2F;
0023 class TAxis;
0024 class THStack;
0025
0026 class TEveCaloData: public TEveElement,
0027 public TNamed
0028 {
0029 public:
0030 struct SliceInfo_t
0031 {
0032 TString fName;
0033 Float_t fThreshold;
0034 Color_t fColor;
0035 Color_t fTransparency;
0036
0037 SliceInfo_t(): fName(""), fThreshold(0), fColor(kRed), fTransparency(0) {}
0038
0039 virtual ~SliceInfo_t() {}
0040
0041 void Setup(const char* name, Float_t threshold, Color_t col, Char_t transp = 101)
0042 {
0043 fName = name;
0044 fThreshold = threshold;
0045 fColor = col;
0046 if (transp <= 100) fTransparency = transp;
0047 };
0048
0049 ClassDef(SliceInfo_t, 0);
0050 };
0051
0052 typedef std::vector<SliceInfo_t> vSliceInfo_t;
0053 typedef std::vector<SliceInfo_t>::iterator vSliceInfo_i;
0054
0055
0056
0057 struct CellId_t
0058 {
0059
0060
0061 Int_t fTower;
0062 Int_t fSlice;
0063
0064 Float_t fFraction;
0065
0066 CellId_t(Int_t t, Int_t s, Float_t f=1.0f) : fTower(t), fSlice(s), fFraction(f) {}
0067
0068 bool operator<(const CellId_t& o) const
0069 { return (fTower == o.fTower) ? fSlice < o.fSlice : fTower < o.fTower; }
0070 };
0071
0072 struct CellGeom_t
0073 {
0074
0075
0076 Float_t fPhiMin;
0077 Float_t fPhiMax;
0078 Float_t fEtaMin;
0079 Float_t fEtaMax;
0080
0081 Float_t fThetaMin;
0082 Float_t fThetaMax;
0083
0084 CellGeom_t(): fPhiMin(0), fPhiMax(0), fEtaMin(0), fEtaMax(0), fThetaMin(0), fThetaMax(0) {}
0085 CellGeom_t(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax) {Configure(etaMin, etaMax, phiMin, phiMax);}
0086 virtual ~CellGeom_t() {}
0087
0088 void Configure(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax);
0089
0090 Float_t EtaMin() const { return fEtaMin; }
0091 Float_t EtaMax() const { return fEtaMax; }
0092 Float_t Eta() const { return (fEtaMin+fEtaMax)*0.5f; }
0093 Float_t EtaDelta() const { return fEtaMax-fEtaMin; }
0094
0095 Float_t PhiMin() const { return fPhiMin; }
0096 Float_t PhiMax() const { return fPhiMax; }
0097 Float_t Phi() const { return (fPhiMin+fPhiMax)*0.5f; }
0098 Float_t PhiDelta() const { return fPhiMax-fPhiMin; }
0099
0100 Float_t ThetaMin() const { return fThetaMin; }
0101 Float_t ThetaMax() const { return fThetaMax; }
0102 Float_t Theta() const { return (fThetaMax+fThetaMin)*0.5f; }
0103 Float_t ThetaDelta() const { return fThetaMax-fThetaMin; }
0104
0105 Bool_t IsUpperRho() const
0106 {
0107 const Float_t phi = Phi();
0108 return ((phi > 0 && phi <= TMath::Pi()) || phi < - TMath::Pi());
0109 }
0110
0111 virtual void Dump() const;
0112 };
0113
0114 struct CellData_t : public CellGeom_t
0115 {
0116
0117
0118 Float_t fValue;
0119
0120 CellData_t() : CellGeom_t(), fValue(0) {}
0121 ~CellData_t() override {}
0122
0123 Float_t Value(Bool_t) const;
0124 void Dump() const override;
0125 };
0126
0127
0128 struct RebinData_t
0129 {
0130 Int_t fNSlices;
0131
0132 std::vector<Float_t> fSliceData;
0133 std::vector<Int_t> fBinData;
0134
0135 Float_t* GetSliceVals(Int_t bin);
0136
0137 void Clear()
0138 {
0139 fSliceData.clear();
0140 fBinData.clear();
0141 }
0142 };
0143
0144
0145
0146 typedef std::vector<CellId_t> vCellId_t;
0147 typedef std::vector<CellId_t>::iterator vCellId_i;
0148
0149 typedef std::vector<CellGeom_t> vCellGeom_t;
0150 typedef std::vector<CellGeom_t>::iterator vCellGeom_i;
0151 typedef std::vector<CellGeom_t>::const_iterator vCellGeom_ci;
0152
0153 private:
0154 TEveCaloData(const TEveCaloData&);
0155 TEveCaloData& operator=(const TEveCaloData&);
0156
0157 protected:
0158 vSliceInfo_t fSliceInfos;
0159
0160 TAxis* fEtaAxis;
0161 TAxis* fPhiAxis;
0162
0163 Bool_t fWrapTwoPi;
0164
0165 Float_t fMaxValEt;
0166 Float_t fMaxValE;
0167
0168 Float_t fEps;
0169
0170 vCellId_t fCellsSelected;
0171 vCellId_t fCellsHighlighted;
0172
0173 public:
0174 TEveCaloData(const char* n="TEveCalData", const char* t="");
0175 ~TEveCaloData() override {}
0176
0177 void UnSelected() override;
0178 void UnHighlighted() override;
0179
0180 TString GetHighlightTooltip() override;
0181
0182 void FillImpliedSelectedSet(Set_t& impSelSet) override;
0183
0184 virtual void GetCellList(Float_t etaMin, Float_t etaMax,
0185 Float_t phi, Float_t phiRng,
0186 vCellId_t &out) const = 0;
0187
0188 vCellId_t& GetCellsSelected() { return fCellsSelected; }
0189 vCellId_t& GetCellsHighlighted() { return fCellsHighlighted; }
0190 void PrintCellsSelected();
0191 void ProcessSelection(vCellId_t& sel_cells, TGLSelectRecord& rec);
0192
0193 virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const = 0;
0194
0195
0196 virtual void GetCellData(const CellId_t &id, CellData_t& data) const = 0;
0197
0198 virtual void InvalidateUsersCellIdCache();
0199 virtual void DataChanged();
0200 virtual void CellSelectionChanged();
0201
0202 Int_t GetNSlices() const { return fSliceInfos.size(); }
0203 SliceInfo_t& RefSliceInfo(Int_t s) { return fSliceInfos[s]; }
0204 void SetSliceThreshold(Int_t slice, Float_t threshold);
0205 Float_t GetSliceThreshold(Int_t slice) const;
0206 void SetSliceColor(Int_t slice, Color_t col);
0207 Color_t GetSliceColor(Int_t slice) const;
0208 void SetSliceTransparency(Int_t slice, Char_t t);
0209 Char_t GetSliceTransparency(Int_t slice) const;
0210
0211 virtual void GetEtaLimits(Double_t &min, Double_t &max) const = 0;
0212
0213 virtual void GetPhiLimits(Double_t &min, Double_t &max) const = 0;
0214
0215 virtual Float_t GetMaxVal(Bool_t et) const { return et ? fMaxValEt : fMaxValE; }
0216 Bool_t Empty() const { return fMaxValEt < 1e-5; }
0217
0218 virtual TAxis* GetEtaBins() const { return fEtaAxis; }
0219 virtual void SetEtaBins(TAxis* ax) { fEtaAxis=ax; }
0220
0221 virtual TAxis* GetPhiBins() const { return fPhiAxis; }
0222 virtual void SetPhiBins(TAxis* ax) { fPhiAxis=ax; }
0223
0224 virtual Float_t GetEps() const { return fEps; }
0225 virtual void SetEps(Float_t eps) { fEps=eps; }
0226
0227 Bool_t GetWrapTwoPi() const { return fWrapTwoPi; }
0228 void SetWrapTwoPi(Bool_t w) { fWrapTwoPi=w; }
0229
0230 static Float_t EtaToTheta(Float_t eta);
0231
0232
0233 ClassDefOverride(TEveCaloData, 0);
0234 };
0235
0236
0237
0238
0239 class TEveCaloDataVec: public TEveCaloData
0240 {
0241
0242 private:
0243 TEveCaloDataVec(const TEveCaloDataVec&);
0244 TEveCaloDataVec& operator=(const TEveCaloDataVec&);
0245
0246 protected:
0247 typedef std::vector<Float_t> vFloat_t;
0248 typedef std::vector<Float_t>::iterator vFloat_i;
0249
0250 typedef std::vector<vFloat_t> vvFloat_t;
0251 typedef std::vector<vFloat_t>::iterator vvFloat_i;
0252
0253 vvFloat_t fSliceVec;
0254 vCellGeom_t fGeomVec;
0255
0256 Int_t fTower;
0257
0258 Float_t fEtaMin;
0259 Float_t fEtaMax;
0260
0261 Float_t fPhiMin;
0262 Float_t fPhiMax;
0263
0264 public:
0265 TEveCaloDataVec(Int_t nslices);
0266 ~TEveCaloDataVec() override;
0267
0268 Int_t AddSlice();
0269 Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax);
0270 void FillSlice(Int_t slice, Float_t value);
0271 void FillSlice(Int_t slice, Int_t tower, Float_t value);
0272
0273 Int_t GetNCells() { return fGeomVec.size(); }
0274 std::vector<Float_t>& GetSliceVals(Int_t slice) { return fSliceVec[slice]; }
0275 std::vector<TEveCaloData::CellGeom_t>& GetCellGeom() { return fGeomVec; }
0276
0277 void GetCellList(Float_t etaMin, Float_t etaMax,
0278 Float_t phi, Float_t phiRng,
0279 vCellId_t &out) const override;
0280
0281 void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override;
0282
0283 void GetCellData(const TEveCaloData::CellId_t &id, TEveCaloData::CellData_t& data) const override;
0284 void GetEtaLimits(Double_t &min, Double_t &max) const override { min=fEtaMin, max=fEtaMax;}
0285 void GetPhiLimits(Double_t &min, Double_t &max) const override { min=fPhiMin; max=fPhiMax;}
0286
0287
0288 void DataChanged() override;
0289 void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001);
0290
0291 ClassDefOverride(TEveCaloDataVec, 0);
0292 };
0293
0294
0295
0296
0297 class TEveCaloDataHist: public TEveCaloData
0298 {
0299 private:
0300 TEveCaloDataHist(const TEveCaloDataHist&);
0301 TEveCaloDataHist& operator=(const TEveCaloDataHist&);
0302
0303 protected:
0304 THStack* fHStack;
0305
0306 public:
0307 TEveCaloDataHist();
0308 ~TEveCaloDataHist() override;
0309
0310 void GetCellList( Float_t etaMin, Float_t etaMax,
0311 Float_t phi, Float_t phiRng, vCellId_t &out) const override;
0312
0313 void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const override;
0314
0315 void GetCellData(const TEveCaloData::CellId_t &id, TEveCaloData::CellData_t& data) const override;
0316
0317 void GetEtaLimits(Double_t &min, Double_t &max) const override;
0318 void GetPhiLimits(Double_t &min, Double_t &max) const override;
0319
0320
0321 void DataChanged() override;
0322
0323 THStack* GetStack() { return fHStack; }
0324
0325 TH2F* GetHist(Int_t slice) const;
0326
0327 Int_t AddHistogram(TH2F* hist);
0328
0329 ClassDefOverride(TEveCaloDataHist, 0);
0330 };
0331
0332 #endif
0333