Changeset 8674 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 08/18/07 12:04:44 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MDataSet.cc
r8666 r8674 274 274 } 275 275 276 //--------------------------------------------------------------------------- 277 // 278 // Make sure that the name used for writing doesn't contain a full path 279 // 280 const char *MDataSet::GetName() const 281 { 282 const char *pos = strrchr(GetRcName(), '/'); 283 return pos>0 ? pos+1 : GetRcName(); 284 } 285 286 276 287 // -------------------------------------------------------------------------- 277 288 // … … 299 310 return; 300 311 } 312 gLog << "# Path: " << GetRcName() << endl; 313 gLog << "# Name: " << GetName() << endl; 314 gLog << endl; 301 315 gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl; 302 316 -
trunk/MagicSoft/Mars/mjobs/MDataSet.h
r8666 r8674 67 67 MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { } 68 68 MDataSet(const char *fname, TString sequences="", TString data=""); 69 70 const char *GetName() const; 71 const char *GetRcName() const { return fName; } 69 72 70 73 void Copy(TObject &obj) const … … 153 156 154 157 // TObject 155 void Print(Option_t *o="") const; //*MENU* 158 void Print(Option_t *o) const; 159 void Print() const { Print(); } //*MENU* 156 160 157 161 ClassDef(MDataSet, 2) -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r8665 r8674 47 47 #include "MLogManip.h" 48 48 49 #include "MDirIter.h" 50 49 51 #include "MStatusArray.h" 50 52 #include "MStatusDisplay.h" … … 88 90 : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0), 89 91 fEstimateEnergy(0), fCalcHadronness(0), fRefill(kFALSE), 90 fSimpleMode(kTRUE), fRawMc(kFALSE), fNoThetaWeights(kFALSE) 92 /*fSimpleMode(kTRUE),*/ fForceTheta(kFALSE), 93 fRawMc(kFALSE), fNoThetaWeights(kFALSE) 91 94 { 92 95 fName = name ? name : "MJSpectrum"; … … 291 294 292 295 *fLog << inf << "Using weights: " << w << endl; 293 *fLog << "Please stand by, this may take a while..." << flush;296 *fLog << "Please stand by, this may take a while..." << endl; 294 297 295 298 if (fDisplay) 296 fDisplay->SetStatusLine1(" Compiling MC distribution...");299 fDisplay->SetStatusLine1("Getting maximum impact..."); 297 300 298 301 // Create chain 299 TChain chain("OriginalMC"); 302 *fLog << "Getting files... " << flush; 303 TChain chain("RunHeaders"); 300 304 if (!set.AddFilesOn(chain)) 301 305 return kFALSE; 306 *fLog << "done. " << endl; 307 308 *fLog << "Getting maximum impact... " << flush; 309 const Double_t impactmax = chain.GetMaximum("MMcRunHeader.fImpactMax"); 310 *fLog << "found " << impactmax/100 << "m" << endl; 311 312 *fLog << "Getting files... " << flush; 313 MDirIter iter; 314 if (!set.AddFilesOn(iter)) 315 return kFALSE; 316 *fLog << "done. " << endl; 302 317 303 318 // Prepare histogram 304 319 h.Reset(); 305 320 h.Sumw2(); 306 307 // Fill histogram from chain308 h.SetDirectory(gROOT);309 321 if (h.InheritsFrom(TH2::Class())) 310 322 { … … 312 324 h.SetXTitle("\\Theta [\\circ]"); 313 325 h.SetYTitle("E [GeV]"); 314 h.SetZTitle("Counts"); 315 chain.Draw("MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC", w, "goff"); 326 h.SetZTitle(Form("Counts normalized to r=%.0fm", impactmax/100)); 316 327 } 317 328 else … … 319 330 h.SetNameTitle("ThetaMC", "Event-Distribution vs Theta for MC (produced)"); 320 331 h.SetXTitle("\\Theta [\\circ]"); 321 h.SetYTitle("Counts"); 322 chain.Draw("MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC", w, "goff"); 332 h.SetYTitle(Form("Counts normalized to r=%.0fm", impactmax/100)); 323 333 } 324 334 h.SetDirectory(0); 325 335 326 *fLog << "done." << endl; 336 const TString cont = h.InheritsFrom(TH2::Class()) ? 337 "MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC" : 338 "MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC"; 339 340 if (fDisplay) 341 fDisplay->SetStatusLine1("Reading OriginalMC"); 342 343 TH1 *hfill = (TH1*)h.Clone(h.InheritsFrom(TH2::Class())?"ThetaEMC":"ThetaMC"); 344 hfill->SetDirectory(0); 345 346 TString fname; 347 while (1) 348 { 349 fname = iter.Next(); 350 if (fname.IsNull()) 351 break; 352 353 TFile file(fname); 354 if (file.IsZombie()) 355 { 356 *fLog << err << "ERROR - Couldn't open file " << fname << endl; 357 return kFALSE; 358 } 359 360 TTree *rh = dynamic_cast<TTree*>(file.Get("RunHeaders")); 361 if (!rh) 362 { 363 *fLog << err << "ERROR - File " << fname << " doesn't contain tree RunHeaders." << endl; 364 return kFALSE; 365 } 366 367 if (rh->GetEntries()!=1) 368 { 369 *fLog << err << "ERROR - RunHeaders of " << fname << " doesn't contain exactly one entry." << endl; 370 return kFALSE; 371 } 372 373 TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC")); 374 if (!t) 375 { 376 *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl; 377 return kFALSE; 378 } 379 380 *fLog << inf << "Reading OriginalMC of " << fname << endl; 381 382 if (t->GetEntries()==0) 383 { 384 *fLog << warn << "WARNING - OriginalMC of " << fname << " empty." << endl; 385 continue; 386 } 387 388 // Why does it crash if closed within loop (no update?) 389 //if (fDisplay) 390 // fDisplay->SetStatusLine2(fname); 391 392 // Normalize by deviding through production area 393 const Double_t impact = rh->GetMaximum("MMcRunHeader.fImpactMax"); 394 const Double_t scale = impactmax/impact; 395 const TString weights = Form("%.16e*(%s)", scale*scale, w.Data()); 396 397 // Fill histogram from tree 398 hfill->SetDirectory(&file); 399 t->Draw(cont, weights, "goff"); 400 hfill->SetDirectory(0); 401 h.Add(hfill); 402 } 403 delete hfill; 404 405 *fLog << "Total number of events from file: " << h.GetEntries() << endl; 327 406 if (fDisplay) 328 407 fDisplay->SetStatusLine2("done."); … … 333 412 *fLog << err << "ERROR - Histogram with original MC distribution empty..." << endl; 334 413 335 return h.GetEntries()>0;414 return kFALSE; 336 415 } 337 416 … … 412 491 { 413 492 *fLog << err; 414 *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap"; 415 *fLog << " with the the Zenith Angle distribution of your observation."; 493 *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap" << endl; 494 *fLog << " with the Zenith Angle distribution of your observation." << endl; 495 *fLog << " Maybe the energy binning is not defined or wrong." << endl; 416 496 theta->SetLineColor(kRed); 417 497 return kFALSE;; … … 424 504 425 505 // Compare both histograms 426 const Double_t prob = proj.Chi2Test(theta, ""); 506 *fLog << inf << "Comparing theta distributions for data and MCs." << endl; 507 const Double_t prob = proj.Chi2Test(theta, "P"); 427 508 if (prob==1) 428 509 return kTRUE; … … 431 512 { 432 513 *fLog << inf; 433 *fLog << "The Zenith Angle distribution of your Monte Carlos fits well"; 434 *fLog << "with the the Zenith Angle distribution of your observation."; 514 *fLog << "The Zenith Angle distribution of your Monte Carlos fits well" << endl; 515 *fLog << "with the Zenith Angle distribution of your observation." << endl; 516 *fLog << "The probability for identical Theta distributions is " << prob << endl; 435 517 return kTRUE; 436 518 } 437 519 438 // <0.01: passen gar nicht439 // ==1: passen perfekt440 // >0.99: passer sehr gut441 442 520 if (prob<0.01) 443 521 { 444 522 *fLog << err; 445 *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit"; 446 *fLog << " with the the Zenith Angle distribution of your observation."; 523 *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit" << endl; 524 *fLog << " with the Zenith Angle distribution of your observation." << endl; 525 *fLog << " The probability for identical Theta distributions is " << prob << endl; 526 if (!fForceTheta) 527 *fLog << " To force processing use --force-theta (with care!)" << endl; 447 528 theta->SetLineColor(kRed); 448 return kFALSE;529 return fForceTheta; 449 530 } 450 531 451 532 *fLog << warn; 452 *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well"; 453 *fLog << " with the the Zenith Angle distribution of your observation."; 533 *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well" << endl; 534 *fLog << " with the Zenith Angle distribution of your observation." << endl; 535 *fLog << " The probability for identical Theta distributions is " << prob << endl; 454 536 return kTRUE; 455 537 } … … 1167 1249 TH2D hist; 1168 1250 MH3 mh1("MMcEvtBasic.fTelescopeTheta*kRad2Deg", "MMcEvtBasic.fEnergy"); 1169 if (fSimpleMode)1251 //if (fSimpleMode) 1170 1252 { 1171 1253 // Now we read the MC distribution as produced by corsika again … … 1189 1271 } 1190 1272 } 1191 } 1273 }/* 1192 1274 else 1193 1275 { … … 1198 1280 return kFALSE; 1199 1281 weight.SetNameMcEvt(); 1200 } 1201 1202 if (!DisplayResult( fSimpleMode ? hist : (TH2D&)mh1.GetHist()))1282 }*/ 1283 1284 if (!DisplayResult(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/)) 1203 1285 return kFALSE; 1204 1286 … … 1245 1327 MHCollectionArea area0("TriggerArea"); 1246 1328 MHCollectionArea area1; 1247 area0.SetHistAll( fSimpleMode ? hist : (TH2D&)mh1.GetHist());1248 area1.SetHistAll( fSimpleMode ? hist : (TH2D&)mh1.GetHist());1329 area0.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/); 1330 area1.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/); 1249 1331 1250 1332 MHEnergyEst hest; … … 1400 1482 TObjArray cont; 1401 1483 cont.Add((TObject*)GetEnv()); 1484 cont.Add(&area0); 1485 cont.Add(&area1); 1486 cont.Add(&hest); 1487 cont.Add(const_cast<TEnv*>(GetEnv())); 1402 1488 1403 1489 if (fDisplay) -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r8434 r8674 478 478 } 479 479 480 //--------------------------------------------------------------------------- 481 // 482 // Make sure that the name used for writing doesn't contain a full path 483 // 484 const char *MSequence::GetName() const 485 { 486 const char *pos = strrchr(GetRcName(), '/'); 487 return pos>0 ? pos+1 : GetRcName(); 488 } 489 490 480 491 // -------------------------------------------------------------------------- 481 492 // … … 490 501 return; 491 502 } 503 gLog << "# Path: " << GetRcName() << endl; 504 gLog << "# Name: " << GetName() << endl; 505 gLog << endl; 492 506 gLog << "Sequence: " << fSequence << endl; 493 507 if (fMonteCarlo) -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r8434 r8674 78 78 79 79 // TObject 80 void Print(Option_t *o="") const; //*MENU* 80 void Print(Option_t *o) const; 81 void Print() const { Print(); } //*MENU* 82 83 const char *GetName() const; 84 const char *GetRcName() const { return fName; } 81 85 82 86 // Genaral interface
Note:
See TracChangeset
for help on using the changeset viewer.