Changeset 4889
- Timestamp:
- 09/08/04 18:49:00 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4887 r4889 19 19 20 20 -*-*- END OF LINE -*-*- 21 22 2004/09/08: Thomas Bretz 23 24 * mbadpixels/MBadPixelsCam.[h,cc], mbase/MParContainer.[h,cc], 25 mhvstime/MHPixVsTime.cc, mhvstime/MHSectorVsTime.cc: 26 - replaces ifstream by istream in AsciiRead 27 28 * mbase/MTime.[h,cc]: 29 - fixed comment about SetTimeFormat 30 - added AsciiRead 31 - added AsciiWrite 32 - added Minus1ns 33 34 * mfileio/MWriteAsciiFile.cc: 35 - write all containers if one has its SetReadyToSaveFlag set 36 37 * mhist/MHEffectiveOnTime.[h,cc]: 38 - for MEffectiveOnTime fit the whole projection instead 39 of using the sum of the theta-bins 40 41 * mhvstime/MHVsTime.[h,cc]: 42 - replaces ifstream by istream in AsciiRead 43 - fixed to support MStatusDisplay 44 - do not fill the same time twice 45 - added support for error bars 46 47 * mjobs/MJStar.cc: 48 - replaced MReadMarsFile by MReadReports 49 - added MEventRateCalc and corresponding histogram 50 - added MHEffectiveOnTime 51 52 21 53 22 54 2004/09/07: Thomas Bretz -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
r4793 r4889 33 33 #include "MBadPixelsCam.h" 34 34 35 #include < fstream>35 #include <iostream> 36 36 37 37 #include <TClonesArray.h> … … 530 530 // 1235: 17 193 292 293 531 531 // 532 void MBadPixelsCam::AsciiRead(i fstream &fin, UInt_t run=0)532 void MBadPixelsCam::AsciiRead(istream &fin, UInt_t run=0) 533 533 { 534 534 Int_t len; -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h
r4679 r4889 44 44 Short_t GetNumMaxCluster(const MGeomCam &geom, Int_t aidx=-1) { return GetNumMaxCluster(MBadPixelsPix::kUnsuitableRun, geom, aidx); } 45 45 46 void AsciiRead(i fstream &fin, UInt_t run);47 void AsciiRead(i fstream &fin) { AsciiRead(fin, 0); }46 void AsciiRead(istream &fin, UInt_t run); 47 void AsciiRead(istream &fin) { AsciiRead(fin, 0); } 48 48 Bool_t AsciiWrite(ostream &out, UInt_t run) const; 49 49 Bool_t AsciiWrite(ostream &out) const { return AsciiWrite(out, 0); } -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r4601 r4889 56 56 57 57 #include <ctype.h> // isdigit 58 #include <fstream> // ofstream , AsciiWrite58 #include <fstream> // ofstream 59 59 60 60 #include <TEnv.h> // Env::Lookup … … 296 296 // container, overload this function. 297 297 // 298 void MParContainer::AsciiRead(i fstream &fin)298 void MParContainer::AsciiRead(istream &fin) 299 299 { 300 300 *fLog << warn << "To use the the ascii input of " << GetName(); -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r4828 r4889 112 112 Bool_t WriteDataMember(ostream &out, const TList *list) const; 113 113 114 virtual void AsciiRead(i fstream &fin);114 virtual void AsciiRead(istream &fin); 115 115 virtual Bool_t AsciiWrite(ostream &out) const; 116 116 -
trunk/MagicSoft/Mars/mbase/MTime.cc
r4887 r4889 170 170 // local time (while here we return UTC) such, that you may encounter 171 171 // strange offsets. You can get rid of this by calling: 172 // TAxis::SetTimeFormat("[your-format] %F1995-01-01 00:00:00"); 173 // 174 // Be carefull: It seems that root takes sommer and winter time into account! 175 // In some circumstances you may need 176 // TAxis::SetTimeFormat("[your-format] %F1995-01-00 23:00:00"); 172 // TAxis::SetTimeFormat("[your-format] %F1995-01-01 00:00:00 GMT"); 177 173 // 178 174 Double_t MTime::GetAxisTime() const … … 573 569 fTime -= 11*kHour; 574 570 } 571 572 void MTime::Minus1ns() 573 { 574 if (fNanoSec>0) 575 { 576 fNanoSec--; 577 return; 578 } 579 580 fTime -= 1; 581 fNanoSec = 999999; 582 583 if ((Long_t)fTime>=-(Long_t)kDay*11) 584 return; 585 586 fTime = 13*kDay-1; 587 fMjd--; 588 } 589 575 590 /* 576 591 MTime MTime::operator-(const MTime &tm1) … … 688 703 SetMjd(mean); 689 704 } 705 706 void MTime::AsciiRead(istream &fin) 707 { 708 fin >> *this; 709 } 710 711 Bool_t MTime::AsciiWrite(ostream &out) const 712 { 713 out << *this; 714 return out; 715 } -
trunk/MagicSoft/Mars/mbase/MTime.h
r4887 r4889 118 118 istream &ReadBinary(istream &fin); 119 119 120 void AsciiRead(istream &fin); 121 Bool_t AsciiWrite(ostream &out) const; 122 120 123 // Conversion functions 121 124 operator double() const; //[s] … … 124 127 // Calculation functions 125 128 void AddMilliSeconds(UInt_t ms); 129 void Minus1ns(); 126 130 void SetMean(const MTime &t0, const MTime &t1); 127 131 void SetMean(Double_t t0, Double_t t1); -
trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
r4694 r4889 24 24 25 25 ///////////////////////////////////////////////////////////////////////////// 26 // //27 // MWriteAsciiFile //28 // //29 // If you want to store a single container into an Ascii file you have //30 // to use this class. You must know the name of the file you wanne write //31 // (you should know it) and the name of the container you want to write. //32 // This can be the name of the class or a given name, which identifies //33 // the container in a parameter container list (MParList). //34 // The container is written to the ascii file if its ReadyToSave flag is //35 // set (MParContainer) //36 // //37 // You can write more than one container in one line of the file, see //38 // AddContainer. //39 // //40 // You can also write single data members of a container (like fWidth //41 // of MHillas). For more details see AddContainer. Make sure, that a //42 // getter method for the data member exist. The name of the method //43 // must be the same than the data member itself, but the f must be //44 // replaced by a Get. //45 // //26 // 27 // MWriteAsciiFile 28 // 29 // If you want to store a single container into an Ascii file you have 30 // to use this class. You must know the name of the file you wanne write 31 // (you should know it) and the name of the container you want to write. 32 // This can be the name of the class or a given name, which identifies 33 // the container in a parameter container list (MParList). 34 // The container is written to the ascii file if its ReadyToSave flag is 35 // set (MParContainer) 36 // 37 // You can write more than one container in one line of the file, see 38 // AddContainer. 39 // 40 // You can also write single data members of a container (like fWidth 41 // of MHillas). For more details see AddContainer. Make sure, that a 42 // getter method for the data member exist. The name of the method 43 // must be the same than the data member itself, but the f must be 44 // replaced by a Get. 45 // 46 46 ///////////////////////////////////////////////////////////////////////////// 47 48 47 #include "MWriteAsciiFile.h" 49 48 … … 51 50 52 51 #include <TMethodCall.h> // TMethodCall, AsciiWrite 52 53 #include "MIter.h" 53 54 54 55 #include "MDataList.h" // MDataList … … 190 191 Bool_t MWriteAsciiFile::CheckAndWrite() 191 192 { 193 MParContainer *obj = NULL; 194 195 // 196 // Check for the Write flag 197 // 198 Bool_t write = kFALSE; 199 MIter Next(&fList); 200 while ((obj=Next())) 201 if (obj->IsReadyToSave()) 202 { 203 write = kTRUE; 204 break; 205 } 206 207 // 208 // Do not write if not at least one ReadyToSave-flag set 209 // 210 if (!write) 211 return kTRUE; 212 192 213 Bool_t written = kFALSE; 193 194 MParContainer *obj = NULL;195 196 214 Int_t num = fList.GetEntries(); 197 215 198 TIter Next(&fList);199 while ((obj= (MParContainer*)Next()))216 Next.Reset(); 217 while ((obj=Next())) 200 218 { 201 // 202 // Check for the Write flag 203 // 204 if (!obj->IsReadyToSave()) 205 continue; 219 if (written) 220 *fOut << " "; 206 221 207 222 // … … 224 239 225 240 if (num!=0) 226 *fLog << warn << "W arning - given number of objects doesn't fit number of written objects." << endl;241 *fLog << warn << "WARNING - Number of objects written mismatch!" << endl; 227 242 } 228 243 return kTRUE; -
trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.cc
r4887 r4889 42 42 #include <TCanvas.h> 43 43 #include <TMinuit.h> 44 #include <TRandom.h> 44 45 45 46 #include "MTime.h" … … 62 63 // 63 64 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title) 64 : /*fLastTime(0), fFirstTime(-1),*/fIsFinalized(kFALSE), fInterval(60)65 : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), fInterval(60) 65 66 { 66 67 // … … 141 142 } 142 143 143 Double_t testval = 0; 144 Double_t testerr = 0; 144 // FIXME: Just for a preliminary check 145 static Double_t testval = 0; 146 static Double_t testerr = 0; 145 147 146 148 // -------------------------------------------------------------------------- … … 185 187 Bool_t MHEffectiveOnTime::Finalize() 186 188 { 187 Fit(); 189 FitThetaBins(); 190 Calc(); 191 188 192 fIsFinalized = kTRUE; 193 189 194 return kTRUE; 190 195 } 191 196 192 void MHEffectiveOnTime::Fit() 193 { 197 void MHEffectiveOnTime::FitThetaBins() 198 { 199 const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999)); 200 194 201 // nbins = number of Theta bins 195 202 const Int_t nbins = fHTimeDiff.GetNbinsY(); 196 203 204 TH1D *h=0; 197 205 for (int i=1; i<=nbins; i++) 198 206 { 199 207 // TH1D &h = *hist->ProjectionX("Calc-theta", i, i); 200 TH1D *h = fHTimeDiff.ProjectionX("CalcTheta", i, i, "E"); 201 202 const Double_t Nm = h->Integral(); 203 204 if (Nm<=0) 208 h = fHTimeDiff.ProjectionX(name, i, i, "E"); 209 210 Double_t res[7]; 211 if (!FitH(h, res)) 205 212 continue; 206 213 207 // determine range (yq[0], yq[1]) of time differences 208 // where fit should be performed; 209 // require a fraction >=xq[0] of all entries to lie below yq[0] 210 // and a fraction <=xq[1] of all entries to lie below yq[1]; 211 // within the range (yq[0], yq[1]) there must be no empty bin; 212 // choose pedestrian approach as long as GetQuantiles is not available 213 Double_t xq[2] = { 0.15, 0.95 }; 214 Double_t yq[2]; 215 216 // GetQuantiles doesn't seem to be available in root 3.01/06 217 h->GetQuantiles(2, yq, xq); 218 219 // Nmdel = Nm * binwidth, with Nm = number of observed events 220 const Double_t Nmdel = h->Integral("width"); 221 222 // 223 // Setup Poisson function for the fit: 224 // lambda [Hz], N0 = ideal no of evts, del = bin width of dt 225 // 226 // parameter 0 = lambda 227 // parameter 1 = N0*del 228 // 229 TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)", yq[0], yq[1]); 230 func.SetParNames("lambda", "N0", "del"); 231 232 func.SetParameter(0, 100); // Hz 233 func.SetParameter(1, Nm); 234 func.FixParameter(2, Nmdel/Nm); 235 236 // options : 0 do not plot the function 237 // I use integral of function in bin rather than value at bin center 238 // R use the range specified in the function range 239 // Q quiet mode 240 h->Fit(&func, "0IRQ"); 241 242 const Double_t chi2 = func.GetChisquare(); 243 const Int_t NDF = func.GetNDF(); 244 245 // was fit successful ? 246 if (NDF>0 && chi2<2.5*NDF) 247 { 248 const Double_t lambda = func.GetParameter(0); 249 const Double_t N0 = func.GetParameter(1); 250 const Double_t prob = func.GetProb(); 251 252 /* 253 *fLog << all << "Nm/lambda=" << Nm/lambda << " chi2/NDF="; 254 *fLog << (NDF ? chi2/NDF : 0.0) << " lambda="; 255 *fLog << lambda << " N0=" << N0 << endl; 256 */ 257 258 Double_t emat[2][2]; 259 gMinuit->mnemat((Double_t*)emat, 2); 260 261 const Double_t dldl = emat[0][0]; 262 //const Double_t dN0dN0 = emat[1][1]; 263 264 const Double_t teff = Nm/lambda; 265 const Double_t dteff = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm); 266 267 const Double_t dl = TMath::Sqrt(dldl); 268 269 //const Double_t kappa = Nm/N0; 270 //const Double_t Rdead = 1.0 - kappa; 271 //const Double_t dRdead = kappa * TMath::Sqrt(dN0dN0/(N0*N0) + 1.0/Nm); 272 273 // the effective on time is Nm/lambda 274 fHEffOn.SetBinContent(i, teff); 275 fHEffOn.SetBinError (i, dteff); 276 277 // plot chi2-probability of fit 278 fHProb.SetBinContent(i, prob*100); 279 280 // plot chi2/NDF of fit 281 fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0); 282 283 // lambda of fit 284 fHLambda.SetBinContent(i, lambda); 285 fHLambda.SetBinError (i, dl); 286 287 // N0 of fit 288 fHN0.SetBinContent(i, N0); 289 290 // Rdead (from fit) is the fraction from real time lost by the dead time 291 //fHRdead.SetBinContent(i, Rdead); 292 //fHRdead.SetBinError (i,dRdead); 293 } 294 214 // the effective on time is Nm/lambda 215 fHEffOn.SetBinContent(i, res[0]); 216 fHEffOn.SetBinError (i, res[1]); 217 218 // plot chi2-probability of fit 219 fHProb.SetBinContent(i, res[2]); 220 221 // plot chi2/NDF of fit 222 fHChi2.SetBinContent(i, res[3]); 223 224 // lambda of fit 225 fHLambda.SetBinContent(i, res[4]); 226 fHLambda.SetBinError (i, res[5]); 227 228 // N0 of fit 229 fHN0.SetBinContent(i, res[6]); 230 231 // Rdead (from fit) is the fraction from real time lost by the dead time 232 //fHRdead.SetBinContent(i, Rdead); 233 //fHRdead.SetBinError (i,dRdead); 234 } 235 236 // Histogram is reused via gROOT->FindObject() 237 // Need to be deleted only once 238 if (h) 295 239 delete h; 296 } 297 } 298 240 } 241 242 Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res) const 243 { 244 const Double_t Nm = h->Integral(); 245 246 // FIXME: Do fit only if contents of bin has changed 247 if (Nm<=0) 248 return kFALSE; 249 250 // determine range (yq[0], yq[1]) of time differences 251 // where fit should be performed; 252 // require a fraction >=xq[0] of all entries to lie below yq[0] 253 // and a fraction <=xq[1] of all entries to lie below yq[1]; 254 // within the range (yq[0], yq[1]) there must be no empty bin; 255 // choose pedestrian approach as long as GetQuantiles is not available 256 Double_t xq[2] = { 0.05, 0.95 }; 257 Double_t yq[2]; 258 h->GetQuantiles(2, yq, xq); 259 260 // Nmdel = Nm * binwidth, with Nm = number of observed events 261 const Double_t Nmdel = h->Integral("width"); 262 263 // 264 // Setup Poisson function for the fit: 265 // lambda [Hz], N0 = ideal no of evts, del = bin width of dt 266 // 267 // parameter 0 = lambda 268 // parameter 1 = N0*del 269 // 270 TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)", yq[0], yq[1]); 271 func.SetParNames("lambda", "N0", "del"); 272 273 func.SetParameter(0, 100); // Hz 274 func.SetParameter(1, Nm); 275 func.FixParameter(2, Nmdel/Nm); 276 277 // options : 0 do not plot the function 278 // I use integral of function in bin rather than value at bin center 279 // R use the range specified in the function range 280 // Q quiet mode 281 h->Fit(&func, "0IRQ"); 282 283 const Double_t chi2 = func.GetChisquare(); 284 const Int_t NDF = func.GetNDF(); 285 286 // was fit successful ? 287 if (NDF<=0 || chi2>=2.5*NDF) 288 return kFALSE; 289 290 const Double_t lambda = func.GetParameter(0); 291 const Double_t N0 = func.GetParameter(1); 292 const Double_t prob = func.GetProb(); 293 294 /* 295 *fLog << all << "Nm/lambda=" << Nm/lambda << " chi2/NDF="; 296 *fLog << (NDF ? chi2/NDF : 0.0) << " lambda="; 297 *fLog << lambda << " N0=" << N0 << endl; 298 */ 299 300 Double_t emat[2][2]; 301 gMinuit->mnemat((Double_t*)emat, 2); 302 303 const Double_t dldl = emat[0][0]; 304 //const Double_t dN0dN0 = emat[1][1]; 305 306 const Double_t teff = Nm/lambda; 307 const Double_t dteff = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm); 308 309 const Double_t dl = TMath::Sqrt(dldl); 310 311 //const Double_t kappa = Nm/N0; 312 //const Double_t Rdead = 1.0 - kappa; 313 //const Double_t dRdead = kappa * TMath::Sqrt(dN0dN0/(N0*N0) + 1.0/Nm); 314 315 // the effective on time is Nm/lambda 316 res[0] = teff; 317 res[1] = dteff; 318 319 // plot chi2-probability of fit 320 res[2] = prob*100; 321 322 // plot chi2/NDF of fit 323 res[3] = NDF ? chi2/NDF : 0.0; 324 325 // lambda of fit 326 res[4] = lambda; 327 res[5] = dl; 328 329 // N0 of fit 330 res[6] = N0; 331 332 // Rdead (from fit) is the fraction from real time lost by the dead time 333 //fHRdead.SetBinContent(i, Rdead); 334 //fHRdead.SetBinError (i,dRdead); 335 336 return kTRUE; 337 } 299 338 300 339 void MHEffectiveOnTime::Paint(Option_t *opt) … … 320 359 321 360 if (!fIsFinalized) 322 Fit ();361 FitThetaBins(); 323 362 } 324 363 if (o==(TString)"paint") … … 386 425 void MHEffectiveOnTime::Calc() 387 426 { 388 const Double_t val = fHEffOn.Integral(); 389 390 Double_t error = 0; 391 for (int i=0; i<fHEffOn.GetXaxis()->GetNbins(); i++) 392 error += fHEffOn.GetBinError(i); 427 TH1D *h = fHTimeDiff.ProjectionX("", -1, 99999, "E"); 428 h->SetDirectory(0); 429 430 Double_t res[7]; 431 Bool_t rc = FitH(h, res); 432 delete h; 433 434 if (!rc) 435 return; 436 437 const Double_t val = res[0]; 438 const Double_t error = res[1]; 393 439 394 440 fParam->SetVal(val-fEffOnTime0, error-fEffOnErr0); … … 403 449 MTime now(*fTime); 404 450 now.AddMilliSeconds(fInterval*1000); 451 405 452 *fLog <<all << now << " - ";// << fLastTime-fTime; 406 453 *fLog << Form("T_{eff} = %.1fs \\pm %.1fs", … … 435 482 436 483 *fTime = *time; 437 // fTime->MinusNull() 484 485 // Make this just a ns before the first event 486 fTime->Minus1ns(); 438 487 } 439 488 440 489 if (*fTime+fInterval<*time) 441 490 { 442 Fit ();491 FitThetaBins(); 443 492 Calc(); 444 493 } -
trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.h
r4887 r4889 24 24 { 25 25 private: 26 MPointingPos *fPointPos; //!27 MTime fLastTime; //!26 MPointingPos *fPointPos; //! 27 MTime fLastTime; //! 28 28 29 Double_t fEffOnTime0; //!30 Double_t fEffOnErr0; //!29 Double_t fEffOnTime0; //! 30 Double_t fEffOnErr0; //! 31 31 32 MTime *fTime; 33 MParameterDerr *fParam; 32 MTime *fTime; //! 33 MParameterDerr *fParam; //! 34 34 35 35 TH2D fHTimeDiff; … … 44 44 Int_t fInterval; 45 45 46 void Fit(); 46 Bool_t FitH(TH1D *h, Double_t *res) const; 47 void FitThetaBins(); 47 48 void Calc(); 48 49 -
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; -
trunk/MagicSoft/Mars/mjobs/MJStar.cc
r4760 r4889 43 43 #include "MStatusDisplay.h" 44 44 45 #include "MH3.h" 46 #include "MHVsTime.h" 45 47 #include "MHCamEvent.h" 46 47 #include "MReadMarsFile.h" 48 #include "MBinning.h" 49 50 #include "MReadReports.h" 48 51 #include "MGeomApply.h" 52 #include "MEventRateCalc.h" 49 53 #include "MImgCleanStd.h" 50 54 #include "MHillasCalc.h" 51 55 #include "MFillH.h" 52 56 #include "MWriteRootFile.h" 57 58 #include "MPointingPosCalc.h" 59 //#include "MSrcPosFromModel.h" 53 60 54 61 ClassImp(MJStar); … … 138 145 plist.AddToList(&tlist); 139 146 140 MReadMarsFile read("Events"); 141 read.DisableAutoScheme(); 147 MReadReports read; 148 read.AddTree("Events", "MTime.", kTRUE); 149 read.AddTree("Drive"); 150 //read.AddTree("Trigger"); 151 //read.AddTree("Camera"); 152 //read.AddTree("CC"); 153 //read.AddTree("Currents"); 142 154 read.AddFiles(iter); 143 //read.AddFiles(fnamein); 155 156 // ------------------ Setup general tasks ---------------- 144 157 145 158 MGeomApply apply; // Only necessary to craete geometry 159 MEventRateCalc rate; 160 /* 161 MEventRateCalc rate10000; 162 rate10000.SetNameEventRate("MEventRate10000"); 163 rate10000.SetNumEvents(10000); 164 */ 146 165 //MBadPixelsMerge merge(&badpix); 147 166 MImgCleanStd clean; 148 167 MHillasCalc hcalc; 149 168 169 // ------------------ Setup histograms and fill tasks ---------------- 150 170 MHCamEvent evt0("Cleaned"); 151 171 evt0.SetType(0); 172 173 MH3 h1("MEventRate.fRate"); 174 h1.SetName("MHEventRate"); 175 h1.SetLogy(); 176 /* 177 MH3 h12("MEventRate10000.fRate"); 178 h12.SetName("MHEventRate"); 179 h12.SetLogy(); 180 */ 181 MBinning b1("BinningMHEventRate"); 182 b1.SetEdges(150, 0, 1500); 183 plist.AddToList(&b1); 184 185 MHVsTime h2("MEffectiveOnTime.fVal", "MEffectiveOnTime.fErr"); 186 h2.SetAxisTitle("T_{eff}"); 187 h2.SetTitle("Effective On-Time T_{eff} vs. Time"); 188 152 189 MFillH fill0(&evt0, "MCerPhotEvt", "FillCerPhotEvt"); 153 190 MFillH fill1("MHHillas", "MHillas", "FillHillas"); 154 MFillH fill2("MHHillasExt", " MHillasExt","FillHillasExt");191 MFillH fill2("MHHillasExt", "", "FillHillasExt"); 155 192 MFillH fill3("MHHillasSrc", "MHillasSrc", "FillHillasSrc"); 156 193 MFillH fill4("MHImagePar", "MImagePar", "FillImagePar"); 157 194 MFillH fill5("MHNewImagePar", "MNewImagePar", "FillNewImagePar"); 158 MFillH fill6("MHCerPhot"); 159 160 MWriteRootFile write(2, "images/{s/_Y_/_I_}"); 161 write.AddContainer("MMcEvt", "Events", kFALSE); 195 MFillH fill6("MHImageParTime","MImageParTime","FillImageParTime"); 196 MFillH fill7("MHNewImagePar2","MNewImagePar2","FillNewImagePar2"); 197 MFillH fill8(&h1, "", "FillEventRate"); 198 MFillH fill9("MHEffectiveOnTime", "MTime", "FillEffOnTime"); 199 MFillH filla(&h2, "MTimeEffectiveOnTime", "FillEffOnTimeVsTime"); 200 //MFillH fillb(&h12, "", "FillEvtRate2"); 201 //MFillH fill9("MHCerPhot"); 202 203 fill8.SetNameTab("EvtRate"); 204 fill9.SetNameTab("EffOnTime"); 205 fill9.SetNameTab("EffOnVsTime"); 206 207 // ------------------ Setup write task ---------------- 208 209 MWriteRootFile write(2, Form("%s{s/_Y_/_I_}", fPathOut.Data()), fOverwrite); 210 // Data 162 211 write.AddContainer("MHillas", "Events"); 163 212 write.AddContainer("MHillasExt", "Events"); … … 165 214 write.AddContainer("MImagePar", "Events"); 166 215 write.AddContainer("MNewImagePar", "Events"); 216 write.AddContainer("MNewImagePar2", "Events"); 217 write.AddContainer("MImageParTime", "Events"); 167 218 write.AddContainer("MTime", "Events"); 168 219 write.AddContainer("MRawEvtHeader", "Events"); 169 write.AddContainer("MRawRunHeader", "RunHeaders"); 170 write.AddContainer("MBadPixelsCam", "RunHeaders"); 171 write.AddContainer("MGeomCam", "RunHeaders"); 220 // Monte Carlo 221 write.AddContainer("MMcEvt", "Events", kFALSE); 222 write.AddContainer("MMcTrig", "Events", kFALSE); 223 // Run Header 224 write.AddContainer("MRawRunHeader", "RunHeaders"); 225 write.AddContainer("MBadPixelsCam", "RunHeaders"); 226 write.AddContainer("MGeomCam", "RunHeaders"); 172 227 //write.AddContainer("MObservatory", "RunHeaders"); 228 // Monte Carlo Headers 229 write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE); 230 write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE); 231 write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE); 232 // Drive 233 //write.AddContainer("MSrcPosCam", "Drive"); 234 write.AddContainer("MPointingPos", "Drive"); 235 write.AddContainer("MReportDrive", "Drive"); 236 write.AddContainer("MTimeDrive", "Drive"); 237 // Effective On Time 238 write.AddContainer("MEffectiveOnTime", "EffectiveOnTime"); 239 write.AddContainer("MTimeEffectiveOnTime", "EffectiveOnTime"); 240 241 MTaskList tlist2; 242 tlist2.AddToList(&apply); 243 tlist2.AddToList(&rate); 244 //tlist2.AddToList(&rate10000); 245 tlist2.AddToList(&fill8); 246 tlist2.AddToList(&fill9); 247 tlist2.AddToList(&filla); 248 //tlist2.AddToList(&fillb); 249 tlist2.AddToList(&clean); 250 tlist2.AddToList(&fill0); 251 tlist2.AddToList(&hcalc); 252 tlist2.AddToList(&fill1); 253 tlist2.AddToList(&fill2); 254 tlist2.AddToList(&fill3); 255 tlist2.AddToList(&fill4); 256 tlist2.AddToList(&fill5); 257 tlist2.AddToList(&fill6); 258 tlist2.AddToList(&fill7); 259 //tlist2.AddToList(&fill9); 260 261 MPointingPosCalc pcalc; 262 //MSrcPosFromModel srcpos; 263 264 MTaskList tlist3; 265 tlist3.AddToList(&pcalc); 266 //tlist3.AddToList(&srcpos); 173 267 174 268 tlist.AddToList(&read); 175 tlist.AddToList(&apply); 176 tlist.AddToList(&clean); 177 tlist.AddToList(&fill0); 178 tlist.AddToList(&hcalc); 179 tlist.AddToList(&fill1); 180 tlist.AddToList(&fill2); 181 tlist.AddToList(&fill3); 182 tlist.AddToList(&fill4); 183 tlist.AddToList(&fill5); 184 //tlist.AddToList(&fill6); 269 tlist.AddToList(&tlist3, "Drive"); 270 tlist.AddToList(&tlist2, "Events"); 185 271 tlist.AddToList(&write); 186 272
Note:
See TracChangeset
for help on using the changeset viewer.