Changeset 4891
- Timestamp:
- 09/09/04 10:51:39 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4889 r4891 19 19 20 20 -*-*- END OF LINE -*-*- 21 22 2004/09/09: Thomas Bretz 23 24 * mhvstime/MHPixVsTime.[h,cc], mhvstime/MHVsTime.[h,cc], 25 mhvstime/MHSectorVsTime.[h,cc], mhbase/MH3.[h,cc]: 26 - changed such that the axis titles can be set via the 27 title 28 29 21 30 22 31 2004/09/08: Thomas Bretz -
trunk/MagicSoft/Mars/mhbase/MBinning.cc
r4840 r4891 44 44 using namespace std; 45 45 46 static const TStringgsDefName = "MBinning";47 static const TStringgsDefTitle = "Container describing the binning of an axis";46 const TString MBinning::gsDefName = "MBinning"; 47 const TString MBinning::gsDefTitle = "Container describing the binning of an axis"; 48 48 49 49 // -------------------------------------------------------------------------- -
trunk/MagicSoft/Mars/mhbase/MBinning.h
r4840 r4891 15 15 class MBinning : public MParContainer 16 16 { 17 public: 18 static const TString gsDefName; 19 static const TString gsDefTitle; 20 17 21 private: 22 18 23 TArrayD fEdges; 19 24 … … 80 85 Bool_t IsUserArray() const { return fType==kIsUserArray; } 81 86 87 Bool_t HasTitle() const { return gsDefTitle!=fTitle; } 88 82 89 void Apply(TH1 &) const; 83 90 -
trunk/MagicSoft/Mars/mhbase/MH3.cc
r4829 r4891 48 48 // SetScaleY and SetScaleZ. 49 49 // 50 // 51 // Axis titles 52 // =========== 53 // 54 // 1) If no other title is given the rule for this axis is used. 55 // 2) If the MBinning used for this axis has a non-default Title 56 // (MBinning::HasTitle) this title is used for the corresponding axis 57 // 3) If the MH3 has a non-default title (MH3::SetTitle called) 58 // this title is set as the histogram title. It can be used to overwrite 59 // the axis titles. For more information see TH1::SetTitle, eg. 60 // SetTitle("MyHist;x[mm];y[cm];Counts"); 61 // 50 62 // For example: 51 63 // MH3 myhist("MHillas.fLength"); … … 83 95 using namespace std; 84 96 85 static const TStringgsDefName = "MH3";86 static const TString gsDefTitle = "Container for a %dD Mars Histogram";97 const TString MH3::gsDefName = "MH3"; 98 const TString MH3::gsDefTitle = "Container for a n-D Mars Histogram"; 87 99 88 100 // -------------------------------------------------------------------------- … … 113 125 114 126 fName = gsDefName; 115 fTitle = Form(gsDefTitle.Data(), fDimension);127 fTitle = gsDefTitle; 116 128 117 129 if (fHist) … … 141 153 142 154 fName = gsDefName; 143 fTitle = Form(gsDefTitle.Data(), 1);155 fTitle = gsDefTitle; 144 156 145 157 fHist->UseCurrentStyle(); … … 168 180 169 181 fName = gsDefName; 170 fTitle = Form(gsDefTitle.Data(), 2);182 fTitle = gsDefTitle; 171 183 172 184 fHist->UseCurrentStyle(); … … 195 207 196 208 fName = gsDefName; 197 fTitle = Form(gsDefTitle.Data(), 3);209 fTitle = gsDefTitle; 198 210 199 211 fHist->UseCurrentStyle(); … … 266 278 return kFALSE; 267 279 } 280 if (fData[2] && !fData[2]->PreProcess(plist)) 281 return kFALSE; 282 if (fData[2]) 283 fHist->SetZTitle(fData[2]->GetTitle()); 284 if (binsz->HasTitle()) 285 fHist->SetZTitle(binsz->GetTitle()); 268 286 if (binsz->IsLogarithmic()) 269 287 fHist->SetBit(kIsLogz); 270 if (fData[2]) fHist->SetZTitle(fData[2]->GetTitle());271 if (fData[2] && !fData[2]->PreProcess(plist))272 return kFALSE;273 288 case 2: 274 289 binsy = (MBinning*)plist->FindObject(bname+"Y", "MBinning"); … … 278 293 return kFALSE; 279 294 } 295 if (fData[1] && !fData[1]->PreProcess(plist)) 296 return kFALSE; 297 if (fData[1]) 298 fHist->SetYTitle(fData[1]->GetTitle()); 299 if (binsy->HasTitle()) 300 fHist->SetYTitle(binsy->GetTitle()); 280 301 if (binsy->IsLogarithmic()) 281 302 fHist->SetBit(kIsLogy); 282 if (fData[1]) fHist->SetYTitle(fData[1]->GetTitle());283 if (fData[1] && !fData[1]->PreProcess(plist))284 return kFALSE;285 303 case 1: 286 304 binsx = (MBinning*)plist->FindObject(bname+"X", "MBinning"); … … 297 315 298 316 } 317 if (fData[0] && !fData[0]->PreProcess(plist)) 318 return kFALSE; 319 if (fData[0]!=NULL) 320 fHist->SetXTitle(fData[0]->GetTitle()); 321 if (binsx->HasTitle()) 322 fHist->SetXTitle(binsx->GetTitle()); 299 323 if (binsx->IsLogarithmic()) 300 324 fHist->SetBit(kIsLogx); 301 302 if (fData[0]!=NULL) fHist->SetXTitle(fData[0]->GetTitle());303 if (fData[0] && !fData[0]->PreProcess(plist))304 return kFALSE;305 325 } 306 326 307 327 fHist->SetName(fName); 328 fHist->SetDirectory(0); 329 330 if (fTitle!=gsDefTitle) 331 { 332 fHist->SetTitle(fTitle); 333 return kTRUE; 334 } 308 335 309 336 TString title("Histogram for "); … … 325 352 return kTRUE; 326 353 } 327 cout << "Still alive...?" << endl; 328 return kTRUE; 354 355 *fLog << err << "ERROR - MH3 has " << fDimension << " dimensions!" << endl; 356 return kFALSE; 329 357 } 330 358 … … 335 363 void MH3::SetName(const char *name) 336 364 { 337 fHist->SetName(name); 365 if (fHist) 366 { 367 fHist->SetName(name); 368 fHist->SetDirectory(0); 369 } 338 370 MParContainer::SetName(name); 339 371 } … … 345 377 void MH3::SetTitle(const char *title) 346 378 { 347 fHist->SetTitle(title); 379 if (fHist) 380 fHist->SetTitle(title); 348 381 MParContainer::SetTitle(title); 349 382 } … … 644 677 out << " " << name << ".SetName(\"" << fName << "\");" << endl; 645 678 646 if (fTitle!= Form(gsDefTitle.Data(), fDimension))679 if (fTitle!=gsDefTitle) 647 680 out << " " << name << ".SetTitle(\"" << fTitle << "\");" << endl; 648 681 -
trunk/MagicSoft/Mars/mhbase/MH3.h
r4828 r4891 15 15 class MH3 : public MH 16 16 { 17 private: 18 static const TString gsDefName; 19 static const TString gsDefTitle; 20 17 21 protected: 18 22 // Could be const but root < 3.02/06 doesn't like this... -
trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc
r4889 r4891 18 18 ! Author(s): Thomas Bretz, 12/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2004 21 21 ! 22 22 ! … … 28 28 // 29 29 // Display the pixel content versus time or event number 30 // 31 // Axis titles 32 // =========== 33 // 34 // 1) If no other title is given the rule for the y-axis is used. 35 // 2) If the MH3 has a non-default title (MH3::SetTitle called) 36 // this title is set as the histogram title. It can be used to overwrite 37 // the axis titles. For more information see TH1::SetTitle, eg. 38 // SetTitle("MyGraph;;Counts"); 39 // The title for the x-axis is ignored and set automatically (MAKE SURE 40 // YOU HAVE TWO SEMICOLON!) 30 41 // 31 42 ///////////////////////////////////////////////////////////////////////////// … … 48 59 49 60 using namespace std; 61 62 const TString MHPixVsTime::gsDefName = "MHPixVsTime"; 63 const TString MHPixVsTime::gsDefTitle = "Graph of pixel content vs. time"; 50 64 51 65 // -------------------------------------------------------------------------- … … 59 73 // set the name and title of this object 60 74 // 61 fName = name ? name : "MHPixVsTime";62 fTitle = title ? title : "Average of MPixVsTimes";75 fName = name ? name : gsDefName.Data(); 76 fTitle = title ? title : gsDefTitle.Data(); 63 77 64 78 TString t("Pixel Index #"); … … 77 91 MHPixVsTime::~MHPixVsTime() 78 92 { 79 if(fGraph) 80 delete fGraph; 93 if (fGraph) 94 delete fGraph; 95 } 96 97 // -------------------------------------------------------------------------- 98 // 99 // Set the name of the TGraph and the MHPixVsTime container 100 // 101 void MHPixVsTime::SetName(const char *name) 102 { 103 fGraph->SetName(name); 104 MParContainer::SetName(name); 105 } 106 107 // -------------------------------------------------------------------------- 108 // 109 // Set the title of the TGraph and the MHPixVsTime container 110 // 111 void MHPixVsTime::SetTitle(const char *title) 112 { 113 fGraph->SetTitle(title); 114 MParContainer::SetTitle(title); 81 115 } 82 116 … … 124 158 } 125 159 160 if (fTitle!=gsDefTitle) 161 fGraph->SetTitle(fTitle); 162 126 163 return kTRUE; 127 164 } … … 190 227 191 228 h->SetXTitle("Time"); 192 h->SetYTitle("");193 229 if (!fNameTime.IsNull()) 194 230 { -
trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.h
r3394 r4891 20 20 { 21 21 private: 22 static const TString gsDefName; 23 static const TString gsDefTitle; 24 22 25 TGraphErrors *fGraph; 23 26 Int_t fIndex; … … 46 49 void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; } 47 50 51 void SetName(const char *name); 52 void SetTitle(const char *title); 53 48 54 TH1 *GetHistByName(const TString name=""); 49 55 TGraph *GetGraph() { return fGraph; } -
trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc
r4889 r4891 30 30 // single sector 31 31 // 32 // 1) If no other title is given the rule for the y-axis is used. 33 // 2) If the MH3 has a non-default title (MH3::SetTitle called) 34 // this title is set as the histogram title. It can be used to overwrite 35 // the axis titles. For more information see TH1::SetTitle, eg. 36 // SetTitle("MyGraph;;Counts"); 37 // The title for the x-axis is ignored and set automatically (MAKE SURE 38 // YOU HAVE TWO SEMICOLON!) 39 // 32 40 ///////////////////////////////////////////////////////////////////////////// 33 41 #include "MHSectorVsTime.h" … … 50 58 51 59 using namespace std; 60 61 const TString MHSectorVsTime::gsDefName = "MSectorHVsTime"; 62 const TString MHSectorVsTime::gsDefTitle = "Graph of sector mean vs. time"; 52 63 53 64 // -------------------------------------------------------------------------- … … 62 73 // set the name and title of this object 63 74 // 64 fName = name ? name : "MHSectorVsTime";65 fTitle = title ? title : "Sector mean vs time";75 fName = name ? name : gsDefName.Data(); 76 fTitle = title ? title : gsDefTitle.Data(); 66 77 } 67 78 … … 75 86 delete fGraph; 76 87 } 88 89 // -------------------------------------------------------------------------- 90 // 91 // Set the name of the TGraph and the MHVsTime container 92 // 93 void MHSectorVsTime::SetName(const char *name) 94 { 95 fGraph->SetName(name); 96 MParContainer::SetName(name); 97 } 98 99 // -------------------------------------------------------------------------- 100 // 101 // Set the title of the TGraph and the MHVsTime container 102 // 103 void MHSectorVsTime::SetTitle(const char *title) 104 { 105 fGraph->SetTitle(title); 106 MParContainer::SetTitle(title); 107 } 108 77 109 78 110 // -------------------------------------------------------------------------- … … 127 159 fGraph = fTypeErr<0 ? new TGraph : new TGraphErrors; 128 160 fGraph->SetName(fEvt ? dynamic_cast<TObject*>(fEvt)->GetName() : "MCamEvent"); 129 fGraph->SetTitle( "Camera");161 fGraph->SetTitle(fTitle==gsDefTitle?"Camera":fTitle); 130 162 131 163 fMin = FLT_MAX; … … 206 238 void MHSectorVsTime::Draw(Option_t *opt) 207 239 { 208 /* 240 if (!fGraph) 241 return; 242 209 243 if (fGraph->GetN()==0) 210 244 return; 211 */212 213 if (fGraph->GetN()==0)214 return;215 245 216 246 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this); … … 220 250 221 251 TString str(opt); 222 /* 223 fGraph->GetHistogram()->SetXTitle("Time"); 224 fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00"); 225 fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1); 226 fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033); 227 228 fGraph->GetHistogram()->SetYTitle(""); 229 */ 252 230 253 if (!str.Contains("A")) 231 254 str += "A"; … … 242 265 243 266 h->SetXTitle("Time"); 244 h->SetYTitle("");245 267 246 268 if (!fNameTime.IsNull()) … … 252 274 } 253 275 254 *fLog << dbg << "Draw: " << str << endl;255 276 fGraph->Draw(str); 256 /* 257 str.ReplaceAll("same", ""); 258 str.ReplaceAll("A", ""); 259 260 Int_t i=-1; 261 Int_t col=kRed; 262 while ((g=(TGraphErrors*)Next())) 263 { 264 i++; 265 *fLog << dbg << "Check" << i << ": " << str << endl; 266 267 while ((fMinSector>=0 && i<fMinSector) || (fMaxSector>=0 && i>fMaxSector)) 268 i++; 269 270 h = g->GetHistogram(); 271 g->SetLineColor(col++); 272 273 *fLog << dbg << "Draw" << i << ": " << g->GetTitle() << endl; 274 g->Draw(str); 275 276 } 277 278 pad->Modified(); 279 pad->Update();*/ 280 } 277 } -
trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h
r3394 r4891 20 20 class MHSectorVsTime : public MH 21 21 { 22 private: 23 static const TString gsDefName; 24 static const TString gsDefTitle; 25 22 26 private: 23 27 TGraph *fGraph; … … 51 55 ~MHSectorVsTime(); 52 56 57 void SetName(const char *name); 58 void SetTitle(const char *title); 59 53 60 void SetNameEvt(const TString name) { fNameEvt = name; } 54 61 void SetNameTime(const TString name) { fNameTime = name; } -
trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
r4889 r4891 29 29 // Use this class if you want to display any rule vs time (or event number) 30 30 // 31 // Axis titles 32 // =========== 33 // 34 // 1) If no other title is given the rule for the y-axis is used. 35 // 2) If the MH3 has a non-default title (MH3::SetTitle called) 36 // this title is set as the histogram title. It can be used to overwrite 37 // the axis titles. For more information see TH1::SetTitle, eg. 38 // SetTitle("MyGraph;;Counts"); 39 // The title for the x-axis is ignored and set automatically (MAKE SURE 40 // YOU HAVE TWO SEMICOLON!) 41 // 31 42 // eg. 32 43 // MHVsTime hist("MHillas.fAlpha"); … … 63 74 using namespace std; 64 75 65 static const TStringgsDefName = "MHVsTime";66 static const TStringgsDefTitle = "Container for a graph vs time/evtnumber";76 const TString MHVsTime::gsDefName = "MHVsTime"; 77 const TString MHVsTime::gsDefTitle = "Container for a graph vs time/evtnumber"; 67 78 68 79 // -------------------------------------------------------------------------- … … 89 100 fGraph->SetPoint(0, 0, 0); // Dummy point! 90 101 fGraph->SetEditable(); // Used as flag: First point? yes/no 102 fGraph->SetMarkerStyle(kFullDotMedium); 91 103 } 92 104 … … 137 149 fGraph->SetEditable(); // Used as flag: First point? yes/no 138 150 139 TString title(fData ? GetRule() : (TString)"Histogram"); 151 152 TString title(fData ? GetRule() : (TString)"Graph"); 140 153 title += " vs "; 141 154 title += fUseEventNumber ? "Event Number" : "Time"; 142 155 143 fGraph->SetNameTitle(fName, title);156 fGraph->SetNameTitle(fName, fTitle==gsDefTitle?title:fTitle); 144 157 145 158 fMean = 0; … … 245 258 } 246 259 247 fGraph->GetHistogram()->SetMarkerStyle(kFullDotMedium);248 fGraph->GetHistogram()->SetYTitle(fAxisTitle.IsNull() ? GetRule() : fAxisTitle);249 if (fTitle!=gsDefTitle)250 fGraph->GetHistogram()->SetTitle(fTitle);251 252 260 if (TestBit(kIsLogy)) 253 261 gPad->SetLogy(); -
trunk/MagicSoft/Mars/mhvstime/MHVsTime.h
r4889 r4891 15 15 class MHVsTime : public MH 16 16 { 17 private: 18 static const TString gsDefName; 19 static const TString gsDefTitle; 20 17 21 protected: 18 22 // Could be const but root < 3.02/06 doesn't like this... … … 29 33 Int_t fN; //! Number of entries in fMean 30 34 MTime fLast; //! For checks 31 32 TString fAxisTitle;33 35 34 36 enum { … … 50 52 51 53 void SetLogy(Bool_t b=kTRUE) { b ? SetBit(kIsLogy) : ResetBit(kIsLogy); } 52 void SetAxisTitle(const char *y) { fAxisTitle=y; }53 54 54 55 Bool_t SetupFill(const MParList *pList);
Note:
See TracChangeset
for help on using the changeset viewer.