- Timestamp:
- 08/13/10 11:42:15 (14 years ago)
- Location:
- trunk/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/Changelog
r9857 r9858 34 34 * mfbase/MFEventSelector.cc: 35 35 - if the number of events to be selected is negative select all events 36 37 * mhbase/MHn.[h,cc]: 38 - fixed the complex display for five histograms 39 40 * mhbase/MHn.[h,cc], mhbase/MH3.[h,cc]: 41 - implemented a TProfile3D 42 - implemented an option to skip reset of the histograms in a new 43 eventloop 44 45 * mhbase/MH3.[h,cc]: 46 - moved the addition weight to a new data meber fWeight 47 - increased class version number 36 48 37 49 -
trunk/Mars/mhbase/MH3.cc
r9851 r9858 128 128 // 129 129 // 130 // Class Version 3:130 // Class Version 1: 131 131 // ---------------- 132 132 // - MData *fData[3]; … … 147 147 // + TFormula *fConversion 148 148 // 149 // Class Version 5: 150 // ---------------- 151 // + MData *fWeight; 152 // 149 153 ///////////////////////////////////////////////////////////////////////////// 150 154 #include "MH3.h" … … 168 172 #include <TProfile.h> 169 173 #include <TProfile2D.h> 174 #include <TProfile3D.h> 170 175 171 176 #include "MLog.h" … … 195 200 fStyleBits = 0; 196 201 202 fWeight = NULL; 203 204 fData[0] = NULL; 205 fData[1] = NULL; 206 fData[2] = NULL; 197 207 fData[3] = NULL; 198 208 … … 257 267 fHist = new TProfile2D; 258 268 fHist->SetZTitle("Average"); 259 if (type==kProfileSpread) 260 static_cast<TProfile2D*>(fHist)->SetErrorOption("s"); 269 static_cast<TProfile2D*>(fHist)->BuildOptions(0, 0, type==kProfileSpread?"s":""); 261 270 break; 262 271 case 3: 263 272 fHist = new TH3D; 264 273 break; 265 } 266 267 fData[0] = NULL; 268 fData[1] = NULL; 269 fData[2] = NULL; 274 case -3: 275 fHist = new TProfile2D; 276 fHist->SetZTitle("Average"); 277 static_cast<TProfile2D*>(fHist)->BuildOptions(0, 0, type==kProfileSpread?"s":""); 278 break; 279 } 270 280 271 281 Init(); … … 282 292 fHist->SetYTitle("Counts"); 283 293 294 Init(); 295 284 296 fData[0] = new MDataPhrase(memberx); 285 fData[1] = NULL;286 fData[2] = NULL;287 288 Init();289 297 } 290 298 … … 300 308 fDimension = 2; 301 309 310 if (h1.InheritsFrom(TProfile3D::Class())) 311 { 312 fDimension = -3; 313 *fLog << warn << "WARNING - MH3::MH3(TH1&) does not support TProfile3D." << endl; 314 } 302 315 if (h1.InheritsFrom(TProfile2D::Class())) 303 316 fDimension = -2; … … 307 320 fHist = (TH1*)h1.Clone(); 308 321 309 fData[0] = NULL; 310 fData[1] = NULL; 311 fData[2] = NULL; 322 Init(); // Before without SeUseCurrentStyle! 312 323 313 324 switch (fDimension) … … 322 333 fData[0] = new MDataPhrase(h1.GetXaxis()->GetTitle()); 323 334 } 324 325 Init(); // Before without SeUseCurrentStyle!326 335 } 327 336 … … 351 360 fHist->SetZTitle(fDimension>0?"Counts":"Average"); 352 361 362 Init(); 363 353 364 fData[0] = new MDataPhrase(memberx); 354 365 fData[1] = new MDataPhrase(membery); 355 fData[2] = NULL;356 357 Init();358 366 } 359 367 … … 374 382 case -2: 375 383 fHist = static_cast<TH1*>(new TProfile2D); 376 if (type==kProfileSpread) 377 static_cast<TProfile2D*>(fHist)->SetErrorOption("s"); 378 } 384 static_cast<TProfile2D*>(fHist)->BuildOptions(0, 0, type==kProfileSpread?"s":""); 385 } 386 387 Init(); 379 388 380 389 fData[0] = new MDataPhrase(memberx); 381 390 fData[1] = new MDataPhrase(membery); 382 391 fData[2] = new MDataPhrase(memberz); 392 } 393 394 // -------------------------------------------------------------------------- 395 // 396 // Creates an TH3D. memberx is filled into the X-bins. membery is filled 397 // into the Y-bins. membery is filled into the Z-bins. Weight is used as a 398 // weight for the profile histogram. For a more detailed description see the 399 // class description above. 400 // 401 MH3::MH3(const char *memberx, const char *membery, const char *memberz, const char *weight, Type_t type) 402 : fDimension(-3) 403 { 404 fHist = static_cast<TH1*>(new TProfile3D); 405 static_cast<TProfile3D*>(fHist)->BuildOptions(0, 0, type==kProfileSpread?"s":""); 383 406 384 407 Init(); 408 409 fData[0] = new MDataPhrase(memberx); 410 fData[1] = new MDataPhrase(membery); 411 fData[2] = new MDataPhrase(memberz); 412 fData[3] = new MDataPhrase(weight); 385 413 } 386 414 … … 396 424 if (fConversion) 397 425 delete fConversion; 426 427 if (fWeight) 428 delete fWeight; 398 429 399 430 for (int i=0; i<4; i++) … … 414 445 void MH3::SetWeight(const char *phrase) 415 446 { 416 if (f Data[3])417 delete f Data[3];418 f Data[3]= new MDataPhrase(phrase);447 if (fWeight) 448 delete fWeight; 449 fWeight = new MDataPhrase(phrase); 419 450 } 420 451 … … 573 604 Bool_t MH3::SetupFill(const MParList *plist) 574 605 { 575 // reset histogram (necessary if the same eventloop is run more than once) 576 fHist->Reset(); 606 // reset histogram (necessary if the same eventloop is run more than once) 607 if (!TestBit(kDoNotReset)) 608 fHist->Reset(); 577 609 578 610 // Tokenize name into name and binnings names … … 660 692 return kFALSE; 661 693 694 if (fWeight && !fWeight->PreProcess(plist)) 695 return kFALSE; 696 662 697 TString title(fDimension>0?"Histogram":"Profile"); 663 698 title += " for "; … … 748 783 Double_t y=0; 749 784 Double_t z=0; 785 Double_t t=0; 750 786 Double_t w=ww; 751 787 752 788 switch (fDimension) 753 789 { 790 case -3: 791 t = fData[3]->GetValue(); 754 792 case -2: 755 793 case 3: … … 762 800 } 763 801 764 if (fData[ 3])765 w *= fData[ 3]->GetValue();802 if (fData[4]) 803 w *= fData[4]->GetValue(); 766 804 767 805 // If label option is set, convert value to label … … 862 900 } 863 901 break; 902 case -3: 903 switch (type) 904 { 905 case kNoLabels: 906 static_cast<TProfile3D*>(fHist)->Fill(x, y, z, t, w); 907 return kTRUE; 908 default: 909 *fLog << err << "ERROR - Labels not supported in TProfile3D." << endl; 910 } 911 break; 864 912 } 865 913 … … 1148 1196 out << " " << name << ".SetTitle(\"" << fTitle << "\");" << endl; 1149 1197 1150 if (f Data[3])1151 out << " " << name << ".SetWeight(\"" << f Data[3]->GetRule() << "\");" << endl;1198 if (fWeight) 1199 out << " " << name << ".SetWeight(\"" << fWeight->GetRule() << "\");" << endl; 1152 1200 1153 1201 switch (fDimension) 1154 1202 { 1203 case -3: 1204 if (fScale[3]!=1) 1205 out << " " << name << ".SetScaleT(" << fScale[3] << ");" << endl; 1155 1206 case -2: 1156 1207 case 3: … … 1175 1226 case -2: 1176 1227 return TString(static_cast<TProfile2D*>(fHist)->GetErrorOption())=="s" ? kProfileSpread : kProfile; 1228 case -3: 1229 return TString(static_cast<TProfile3D*>(fHist)->GetErrorOption())=="s" ? kProfileSpread : kProfile; 1177 1230 } 1178 1231 return kHistogram; … … 1206 1259 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule(), GetType()); 1207 1260 break; 1261 case -3: 1262 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule(), fData[3]->GetRule()); 1263 break; 1208 1264 } 1209 1265 … … 1220 1276 } 1221 1277 1222 if (fData[ 3])1223 h->SetWeight(fData[ 3]->GetRule());1278 if (fData[4]) 1279 h->SetWeight(fData[4]->GetRule()); 1224 1280 1225 1281 return h; … … 1243 1299 case 'Z': 1244 1300 return fData[2] ? fData[2]->GetRule() : TString(""); 1301 case 't': 1302 case 'T': 1303 return fData[3] ? fData[3]->GetRule() : TString(""); 1245 1304 case 'w': 1246 1305 case 'W': 1247 return f Data[3] ? fData[3]->GetRule() : TString("");1306 return fWeight ? fWeight->GetRule() : TString(""); 1248 1307 default: 1249 1308 return "<n/a>"; -
trunk/Mars/mhbase/MH3.h
r9829 r9858 37 37 }; 38 38 39 enum { 40 kDoNotReset = BIT(20) 41 }; 42 43 39 44 private: 40 45 static const TString gsDefName; … … 63 68 Int_t fDimension; // Number of dimensions of histogram 64 69 TH1 *fHist; // Histogram to fill 65 MData *fData[4]; // Object from which the data is filled (+additional weight) 70 MData *fData[4]; // Object from which the data is filled 71 MData *fWeight; // Additional weight 66 72 MBinning *fBins[3]; // Binning set omitting the parlist access 67 73 Double_t fScale[3]; // Scale for the three axis (eg unit) … … 76 82 77 83 enum { 78 kIsLogx = BIT(17),79 kIsLogy = BIT(18),80 kIsLogz = BIT(19)84 kIsLogx = BIT(17), 85 kIsLogy = BIT(18), 86 kIsLogz = BIT(19) 81 87 }; 82 88 … … 87 93 MH3(const char *memberx, const char *membery, Type_t type=MH3::kHistogram); 88 94 MH3(const char *memberx, const char *membery, const char *memberz, Type_t type=MH3::kHistogram); 95 MH3(const char *memberx, const char *membery, const char *memberz, const char *weight, Type_t type=MH3::kProfile); 89 96 ~MH3(); 90 97 … … 171 178 void RecursiveRemove(TObject *obj); 172 179 173 ClassDef(MH3, 5) // Generalized 1/2/3D-histogram for Mars variables180 ClassDef(MH3, 6) // Generalized 1/2/3D-histogram for Mars variables 174 181 }; 175 182 -
trunk/Mars/mhbase/MHn.cc
r9821 r9858 254 254 // -------------------------------------------------------------------------- 255 255 // 256 // Add a new 3D-MH3 histogram. An internal pointer is set to it, so that 257 // InitName and InitTitle can be used for this histogram until a new 258 // histogram is added using AddHist 259 // 260 // e.g. AddHist("MHillas.fWidth", "MHillas.fLength", "MHillas.fSize", "MWeight.fVal") 261 // 262 Bool_t MHn::AddHist(const char *memberx, const char *membery, const char *memberz, const char *weight) 263 { 264 if (fNum==8) 265 { 266 *fLog << err << "ERROR - MHn doesn't support more than six histograms... AddHist ignored." << endl; 267 return kFALSE; 268 } 269 270 fHist[fNum] = new MH3(memberx, membery, memberz, weight); 271 272 InitHist(); 273 274 return kTRUE; 275 } 276 277 // -------------------------------------------------------------------------- 278 // 256 279 // Set the draw option of the n-th MH3. See MH3 for more details of the 257 280 // meaning of it. … … 500 523 { 501 524 for (int i=0; i<fNum; i++) 525 { 526 TestBit(kDoNotReset) ? fHist[i]->SetBit(kDoNotReset) : fHist[i]->ResetBit(kDoNotReset); 527 502 528 if (!fHist[i]->SetupFill(plist)) 503 529 return kFALSE; 530 } 504 531 505 532 return kTRUE; … … 581 608 break; 582 609 case 13: // 3 610 pad->Divide(2,2, 1e-5, 1e-5); 611 pad->GetPad(1)->SetPad(0.01, 0.505, 0.33, 0.99); 612 pad->GetPad(2)->SetPad(0.01, 0.01, 0.33, 0.495); 613 pad->GetPad(3)->SetPad(0.34, 0.01, 0.99, 0.99); 614 delete pad->GetPad(4); 583 615 break; 584 616 case 14: // 4 -
trunk/Mars/mhbase/MHn.h
r9821 r9858 10 10 public: 11 11 enum Layout_t { kSimple, kComplex }; 12 13 enum { kDoNotReset = BIT(20) }; 12 14 13 15 protected: … … 36 38 Bool_t AddHist(const char *memberx, const char *membery, MH3::Type_t type=MH3::kHistogram); 37 39 Bool_t AddHist(const char *memberx, const char *membery, const char *memberz, MH3::Type_t type=MH3::kHistogram); 40 Bool_t AddHist(const char *memberx, const char *membery, const char *memberz, const char *weight); 38 41 39 42 void InitName(const char *n) { InitName(fNum-1, n); }
Note:
See TracChangeset
for help on using the changeset viewer.