Changeset 4889 for trunk/MagicSoft/Mars/mhvstime
- Timestamp:
- 09/08/04 18:49:00 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mhvstime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc
r3539 r4889 194 194 { 195 195 TAxis *axe = h->GetXaxis(); 196 axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 ");196 axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT"); 197 197 axe->SetTimeDisplay(1); 198 198 axe->SetLabelSize(0.033); -
trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc
r3394 r4889 247 247 { 248 248 TAxis *axe = h->GetXaxis(); 249 axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 ");249 axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT"); 250 250 axe->SetTimeDisplay(1); 251 251 axe->SetLabelSize(0.025); -
trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
r4828 r4889 49 49 #include <TCanvas.h> 50 50 51 #include <TGraph .h>51 #include <TGraphErrors.h> 52 52 53 53 #include "MLog.h" … … 71 71 // see MDataChain. 72 72 // 73 MHVsTime::MHVsTime(const char *rule) 74 : fGraph(NULL), fData(NULL), fScale(1), fMaxPts(-1), fUseEventNumber(0) 75 { 73 MHVsTime::MHVsTime(const char *rule, const char *error) 74 : fGraph(NULL), fData(NULL), fError(0), fScale(1), fMaxPts(-1), 75 fNumEvents(1), fUseEventNumber(0) 76 { 76 77 fName = gsDefName; 77 78 fTitle = gsDefTitle; … … 80 81 return; 81 82 82 fGraph = new TGraph;83 83 fData = new MDataChain(rule); 84 84 85 fGraph->SetMarkerStyle(kFullDotMedium); 85 if (error) 86 fError = new MDataChain(error); 87 88 fGraph = error ? new TGraphErrors : new TGraph; 89 fGraph->SetPoint(0, 0, 0); // Dummy point! 90 fGraph->SetEditable(); // Used as flag: First point? yes/no 86 91 } 87 92 … … 116 121 Bool_t MHVsTime::SetupFill(const MParList *plist) 117 122 { 118 // reset histogram (necessary if the same eventloop is run more than once) 119 //fGraph->Reset(); 120 121 if (fData && !fData->PreProcess(plist)) 123 if (!fGraph || !fData) 124 { 125 *fLog << err << "ERROR - MHVsTime cannot be used with its default constructor!" << endl; 122 126 return kFALSE; 123 124 if (fGraph) 125 { 126 delete fGraph; 127 fGraph = new TGraph; 128 } 127 } 128 129 if (!fData->PreProcess(plist)) 130 return kFALSE; 131 132 if (fError && !fError->PreProcess(plist)) 133 return kFALSE; 134 135 fGraph->Set(1); 136 fGraph->SetPoint(0, 0, 0); // Dummy point! 137 fGraph->SetEditable(); // Used as flag: First point? yes/no 129 138 130 139 TString title(fData ? GetRule() : (TString)"Histogram"); … … 183 192 if (!*tm) 184 193 return kTRUE; 194 195 // Do not fill events with equal time 196 if (*tm==fLast || *tm==MTime()) 197 return kTRUE; 198 199 fLast = *tm; 200 185 201 t = tm->GetAxisTime(); 186 202 } 187 203 188 const Double_t v = fData->GetValue()*fScale; 189 190 if (fMaxPts>0 && fGraph->GetN()>fMaxPts) 191 fGraph->RemovePoint(0); 192 193 fMean += v; 204 const Double_t v = fData->GetValue(); 205 const Double_t e = fError ? fError->GetValue() : 0; 206 207 //*fLog << all << "ADD " << v << " " << e << endl; 208 209 fMean += v; 210 fMeanErr += e; 194 211 fN++; 195 212 196 213 if (fN==fNumEvents) 197 214 { 198 fGraph->SetPoint(fGraph->GetN(), t, fMean/fN); 215 if (fMaxPts>0 && fGraph->GetN()>fMaxPts || fGraph->IsEditable()) 216 { 217 fGraph->RemovePoint(0); 218 fGraph->SetEditable(kFALSE); 219 } 220 221 fGraph->SetPoint(fGraph->GetN(), t, fMean/fN*fScale); 222 223 if (fError) 224 static_cast<TGraphErrors*>(fGraph)->SetPointError(fGraph->GetN()-1, 0, fMeanErr/fN*fScale); 225 199 226 fMean = 0; 227 fMeanErr = 0; 200 228 fN = 0; 201 229 } 202 230 203 231 return kTRUE; 232 } 233 234 void MHVsTime::Paint(Option_t *opt) 235 { 236 // SetPoint deletes the histogram! 237 if (fUseEventNumber) 238 fGraph->GetHistogram()->SetXTitle("Event Number"); 239 else 240 { 241 fGraph->GetHistogram()->SetXTitle("Time"); 242 fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033); 243 fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT"); 244 fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1); 245 } 246 247 fGraph->GetHistogram()->SetMarkerStyle(kFullDotMedium); 248 fGraph->GetHistogram()->SetYTitle(fAxisTitle.IsNull() ? GetRule() : fAxisTitle); 249 if (fTitle!=gsDefTitle) 250 fGraph->GetHistogram()->SetTitle(fTitle); 251 252 if (TestBit(kIsLogy)) 253 gPad->SetLogy(); 254 255 // This is a workaround if the TGraph has only one point. 256 // Otherwise MStatusDisplay::Update hangs. 257 gPad->GetListOfPrimitives()->Remove(fGraph); 258 gPad->GetListOfPrimitives()->Add(fGraph, fGraph->GetN()<2 ? "A" : opt); 204 259 } 205 260 … … 212 267 void MHVsTime::Draw(Option_t *opt) 213 268 { 269 if (!fGraph) 270 return; 271 214 272 if (fGraph->GetN()==0) 215 273 return; … … 218 276 pad->SetBorderMode(0); 219 277 220 AppendPad("");221 222 278 TString str(opt); 223 224 if (fUseEventNumber)225 fGraph->GetHistogram()->SetXTitle("Event Number");226 else227 {228 fGraph->GetHistogram()->SetXTitle("Time");229 fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");230 fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);231 fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);232 }233 fGraph->GetHistogram()->SetYTitle(GetRule());234 279 235 280 if (!str.Contains("A")) … … 244 289 } 245 290 291 AppendPad(str); 246 292 fGraph->Draw(str); 247 if (fGraph->TestBit(kIsLogy))248 pad->SetLogy();249 250 pad->Modified();251 pad->Update();252 293 } 253 294 -
trunk/MagicSoft/Mars/mhvstime/MHVsTime.h
r4828 r4889 4 4 #ifndef MARS_MH 5 5 #include "MH.h" 6 #endif 7 8 #ifndef MARS_MTime 9 #include "MTime.h" 6 10 #endif 7 11 … … 15 19 TGraph *fGraph; // Histogram to fill 16 20 MDataChain *fData; // Object from which the data is filled 21 MDataChain *fError; // Object from which the error is filled 17 22 Double_t fScale; // Scale for axis (eg unit) 18 23 Int_t fMaxPts; // Maximum number of data points 19 24 20 25 Int_t fNumEvents; // Number of events to average 26 21 27 Double_t fMean; //! Mean value 22 Int_t fN; 28 Double_t fMeanErr; //! Mean error 29 Int_t fN; //! Number of entries in fMean 30 MTime fLast; //! For checks 23 31 32 TString fAxisTitle; 24 33 25 34 enum { 26 kIsLogy = BIT(18), 27 kUseEventNumber = BIT(20) 35 kIsLogy = BIT(18) 28 36 }; 29 37 … … 31 39 32 40 public: 33 MHVsTime(const char *rule=NULL );41 MHVsTime(const char *rule=NULL, const char *ruleerr=NULL); 34 42 ~MHVsTime(); 35 43 … … 40 48 void SetName(const char *name); 41 49 void SetTitle(const char *title); 50 51 void SetLogy(Bool_t b=kTRUE) { b ? SetBit(kIsLogy) : ResetBit(kIsLogy); } 52 void SetAxisTitle(const char *y) { fAxisTitle=y; } 42 53 43 54 Bool_t SetupFill(const MParList *pList); … … 59 70 60 71 void Draw(Option_t *opt=NULL); 72 void Paint(Option_t *opt=NULL); 61 73 62 74 MParContainer *New() const;
Note:
See TracChangeset
for help on using the changeset viewer.