00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdexcept>
00011
00012 #include "TTreeFormula.h"
00013 #include "TTree.h"
00014 #include "TMath.h"
00015 #include "TH3.h"
00016
00017 #include "TGLPlotCamera.h"
00018 #include "TGL5DPainter.h"
00019 #include "TGL5D.h"
00020
00021 ClassImp(TGL5DDataSet)
00022
00023 namespace {
00024
00025 void FindRange(Long64_t size, const Double_t *src, Rgl::Range_t &range);
00026
00027 }
00028
00029
00030 TGL5DDataSet::TGL5DDataSet(TTree *tree)
00031 : TNamed("TGL5DataSet", "TGL5DataSet"),
00032 fNP(0),
00033 fV1(0), fV2(0), fV3(0), fV4(0), fV5(0),
00034 fV1Range(1.), fV2Range(1.), fV3Range(1.),
00035 fV4IsString(kFALSE)
00036 {
00037
00038
00039 if (!tree) {
00040 Error("TGL5Data", "Null pointer tree.");
00041 throw std::runtime_error("");
00042 }
00043
00044 fNP = tree->GetSelectedRows();
00045
00046 Info("TGL5DDataSet", "Number of selected rows: %d", Int_t(fNP)) ;
00047
00048 fV1 = tree->GetVal(0);
00049 fV2 = tree->GetVal(1);
00050 fV3 = tree->GetVal(2);
00051 fV4 = tree->GetVal(3);
00052 fV5 = tree->GetVal(4);
00053
00054 fV4IsString = tree->GetVar(3)->IsString();
00055
00056 if (!fV1 || !fV2 || !fV3 || !fV4 || !fV5) {
00057 Error("TGL5DDataSet", "One or all of vN is a null pointer.");
00058 throw std::runtime_error("");
00059 }
00060
00061 FindRange(fNP, fV1, fV1MinMax);
00062 FindRange(fNP, fV2, fV2MinMax);
00063 FindRange(fNP, fV3, fV3MinMax);
00064 FindRange(fNP, fV4, fV4MinMax);
00065 FindRange(fNP, fV5, fV5MinMax);
00066
00067 const Double_t v1Add = 0.1 * (fV1MinMax.second - fV1MinMax.first);
00068 const Double_t v2Add = 0.1 * (fV2MinMax.second - fV2MinMax.first);
00069 const Double_t v3Add = 0.1 * (fV3MinMax.second - fV3MinMax.first);
00070
00071 fV1MinMax.first -= v1Add, fV1MinMax.second += v1Add;
00072 fV1Range = fV1MinMax.second - fV1MinMax.first;
00073 fV2MinMax.first -= v2Add, fV2MinMax.second += v2Add;
00074 fV2Range = fV2MinMax.second - fV2MinMax.first;
00075 fV3MinMax.first -= v3Add, fV3MinMax.second += v3Add;
00076 fV3Range = fV3MinMax.second - fV3MinMax.first;
00077
00078 TH3F hist("tmp", "tmp", 2, -1., 1., 2, -1., 1., 2, -1., 1.);
00079
00080
00081
00082 hist.GetXaxis()->Copy(fXAxis);
00083 hist.GetYaxis()->Copy(fYAxis);
00084 hist.GetZaxis()->Copy(fZAxis);
00085
00086 fXAxis.Set(kDefaultNB, fV1MinMax.first, fV1MinMax.second);
00087 fYAxis.Set(kDefaultNB, fV2MinMax.first, fV2MinMax.second);
00088 fZAxis.Set(kDefaultNB, fV3MinMax.first, fV3MinMax.second);
00089
00090 fPainter.reset(new TGLHistPainter(this));
00091 SetBit(kCanDelete);
00092 }
00093
00094
00095 Int_t TGL5DDataSet::DistancetoPrimitive(Int_t px, Int_t py)
00096 {
00097
00098 return fPainter->DistancetoPrimitive(px, py);
00099 }
00100
00101
00102 void TGL5DDataSet::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00103 {
00104
00105 return fPainter->ExecuteEvent(event, px, py);
00106 }
00107
00108
00109 char *TGL5DDataSet::GetObjectInfo(Int_t , Int_t ) const
00110 {
00111
00112 static char mess[] = {"5d data set"};
00113 return mess;
00114 }
00115
00116
00117 void TGL5DDataSet::Paint(Option_t * )
00118 {
00119
00120 fPainter->Paint("dummyoption");
00121 }
00122
00123
00124 TGL5DPainter *TGL5DDataSet::GetRealPainter()const
00125 {
00126
00127 return static_cast<TGL5DPainter *>(fPainter->GetRealPainter());
00128 }
00129
00130
00131 void TGL5DDataSet::SelectPoints(Double_t v4Level, Double_t range)
00132 {
00133
00134
00135 fIndices.clear();
00136
00137 for (Int_t i = 0; i < fNP; ++i)
00138 if (TMath::Abs(fV4[i] - v4Level) < range)
00139 fIndices.push_back(i);
00140 }
00141
00142
00143 UInt_t TGL5DDataSet::SelectedSize()const
00144 {
00145
00146 return UInt_t(fIndices.size());
00147 }
00148
00149
00150 Double_t TGL5DDataSet::V1(UInt_t ind)const
00151 {
00152
00153 return V1ToUnitCube(fV1[fIndices[ind]]);
00154 }
00155
00156
00157 Double_t TGL5DDataSet::V2(UInt_t ind)const
00158 {
00159
00160 return V2ToUnitCube(fV2[fIndices[ind]]);
00161 }
00162
00163
00164 Double_t TGL5DDataSet::V3(UInt_t ind)const
00165 {
00166
00167 return V3ToUnitCube(fV3[fIndices[ind]]);
00168 }
00169
00170
00171 TAxis *TGL5DDataSet::GetXAxis()const
00172 {
00173
00174 return &fXAxis;
00175 }
00176
00177
00178 TAxis *TGL5DDataSet::GetYAxis()const
00179 {
00180
00181 return &fYAxis;
00182 }
00183
00184
00185 TAxis *TGL5DDataSet::GetZAxis()const
00186 {
00187
00188 return &fZAxis;
00189 }
00190
00191
00192 const Rgl::Range_t &TGL5DDataSet::GetXRange()const
00193 {
00194
00195 return fV1MinMax;
00196 }
00197
00198
00199 const Rgl::Range_t &TGL5DDataSet::GetYRange()const
00200 {
00201
00202 return fV2MinMax;
00203 }
00204
00205
00206 const Rgl::Range_t &TGL5DDataSet::GetZRange()const
00207 {
00208
00209 return fV3MinMax;
00210 }
00211
00212
00213 const Rgl::Range_t &TGL5DDataSet::GetV4Range()const
00214 {
00215
00216 return fV4MinMax;
00217 }
00218
00219
00220 Double_t TGL5DDataSet::V1ToUnitCube(Double_t v1)const
00221 {
00222
00223 return (v1 - fV1MinMax.first) / fV1Range;
00224 }
00225
00226
00227 Double_t TGL5DDataSet::V2ToUnitCube(Double_t v2)const
00228 {
00229
00230 return (v2 - fV2MinMax.first) / fV2Range;
00231 }
00232
00233
00234 Double_t TGL5DDataSet::V3ToUnitCube(Double_t v3)const
00235 {
00236
00237 return (v3 - fV3MinMax.first) / fV3Range;
00238 }
00239
00240 namespace {
00241
00242
00243 void FindRange(Long64_t size, const Double_t *src, Rgl::Range_t &range)
00244 {
00245
00246 range.first = src[0];
00247 range.second = src[0];
00248
00249 for (Long64_t i = 1; i < size; ++i) {
00250 range.first = TMath::Min(range.first, src[i]);
00251 range.second = TMath::Max(range.second, src[i]);
00252 }
00253 }
00254
00255 }