Changeset 8674 for trunk/MagicSoft
- Timestamp:
- 08/18/07 12:04:44 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8673 r8674 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2007/08/18 Thomas Bretz 22 23 * sponde.cc: 24 - added new option --force-theta 25 26 * mbase/MEnv.[h,cc], mjobs/MSequence.[h,cc], mjobs/MDataSet.[h,cc]: 27 - GetName noe returns only the filename not the whole path. The 28 old behaviour made it impossible to access the container from 29 the file. 30 - GetRcName now returns the whole path/name. 31 - Print now outputs also path and file-name 32 33 * mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc: 34 - fixed typos in comments 35 36 * mhflux/MHCollectionArea.cc: 37 - reset fCorsikaVersion to 0 in PreProcess 38 - print old and new Cosika version if mismatch is found 39 40 * mhflux/MMcSpectrumWeight.cc: 41 - replaced the %.16f by %.16e. This is more accurate in cases 42 with high exponents 43 - added some sample/test code to weight the Zenith Angle 44 according to the sin-distribution produced by Corsika. 45 Currently not in use 46 47 * mjobs/MJSpectrum.cc: 48 - removed the simple/accurate mode. There is now reason why 49 the previous "accurate"-mode should be more accurate at all. 50 It is only slower 51 - Reading the OriginalMC tree now is done such that the 52 events are properly weighted by the production area. This 53 allowes to use different impact paramters from dfferent files. 54 - a check has been implemented which compared the zenith angle 55 distribution of the data and the resulting monte carlo data. 56 Execution of the program can be forced with a new option. 57 - write more information to output file. 58 59 20 60 21 61 2007/08/17 Thomas Bretz -
trunk/MagicSoft/Mars/NEWS
r8671 r8674 221 221 contents where exchanged.... fixed. 222 222 223 - sponde: the so called "accurate"-mode has been removed. It didn't 224 give any improvement in accuracy, only decreased execution speed. 225 226 - sponde: now checks whether the theta distribution of your on-data 227 and the theta-distribution of your Monte Carlo sample (after 228 weighting) fits. If it doesn't fit properly (eg. the Monte Carlo 229 sample is incomplete) execution is stopped. Execution can be forced 230 using the new option --force-theta. Use this option with care! 231 232 - sponde: Proper collection areas can now be constructed also from 233 Monte Carlo samples generated with different maximum impact 234 parameters. Note that in previous version you neither got 235 a warning or failure, nor was there any obvious sign that the 236 collection area was overestimated due to usage of files with 237 different maximum impact parameters. 238 239 - sponde: the output file now contains more information about 240 the spectrum (eg. the full 2D collection area histogram). 241 Note, that this information can only be written to the file 242 if it is stored automatically via command line argument. 243 If you only store the status display from within the display 244 the information is lost. 245 223 246 224 247 -
trunk/MagicSoft/Mars/mbase/MEnv.cc
r8539 r8674 71 71 if (GetEntries()<=0 && !fname.IsNull() && fname!=name) 72 72 ReadFile(fname, kEnvLocal);; 73 } 74 75 //--------------------------------------------------------------------------- 76 // 77 // Make sure that the name used for writing doesn't contain a full path 78 // 79 const char *MEnv::GetName() const 80 { 81 const char *pos = strrchr(GetRcName(), '/'); 82 return pos>0 ? pos+1 : GetRcName(); 73 83 } 74 84 … … 847 857 //--------------------------------------------------------------------------- 848 858 // 859 // Add name and full path to output 860 // 861 void MEnv::PrintEnv(EEnvLevel level) const 862 { 863 cout << "# Path: " << GetRcName() << endl; 864 cout << "# Name: " << GetName() << endl; 865 TEnv::PrintEnv(level); 866 } 867 868 //--------------------------------------------------------------------------- 869 // 849 870 // Print resources which have never been touched (for debugging) 850 871 // -
trunk/MagicSoft/Mars/mbase/MEnv.h
r8582 r8674 38 38 const char *GetValue(const char *name, const char *dflt); 39 39 40 const char *GetName() const { return GetRcName(); }40 const char *GetName() const { return strrchr(GetRcName(), '/')?strrchr(GetRcName(), '/')+1:GetRcName(); } 41 41 42 42 Int_t GetColor(const char *name, Int_t dftl); … … 67 67 void AddEnv(const TEnv &env, Bool_t overwrite=kTRUE); 68 68 69 void PrintEnv(EEnvLevel level = kEnvAll) const; 69 70 void Print(Option_t *option) const { TEnv::Print(option); } 70 void Print() const { TEnv::PrintEnv(kEnvLocal); } //*MENU*71 void Print() const { PrintEnv(kEnvLocal); } //*MENU* 71 72 72 73 void PrintUntouched() const; -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r8226 r8674 267 267 // list gets a new address. Therefor we reset all the autodel flags. 268 268 // 269 // MAKE SURE THAT ALL YO PUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY269 // MAKE SURE THAT ALL YOUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY 270 270 // 271 271 Bool_t MReadTree::Notify() … … 295 295 // list gets a new address. Therefor we reset all the autodel flags. 296 296 // 297 // MAKE SURE THAT ALL YO PUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY297 // MAKE SURE THAT ALL YOUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY 298 298 // 299 299 TIter NextB(fTree->GetListOfBranches()); -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r8642 r8674 35 35 // There is a special mode of operation which opens a new file for each new 36 36 // file read by the reading task (opening the new file is initiated by 37 // ReInit()) For more details se the corresponding constructor.37 // ReInit()) For more details see the corresponding constructor. 38 38 // 39 39 // Memory based trees -
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
r8673 r8674 183 183 MH::SetBinning(&fHistAll, &binst, &binse); 184 184 185 fMcAreaRadius = -1; 185 fMcAreaRadius = -1; 186 fCorsikaVersion = 0; 186 187 187 188 return kTRUE; … … 205 206 206 207 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion()) 207 *fLog << warn << "Warning - Read files have different Corsika versions..." << endl; 208 { 209 *fLog << warn; 210 *fLog << "Warning - Read files have different Corsika versions..." << endl; 211 *fLog << " Last file=" << fCorsikaVersion << " New file=" << runheader->GetCorsikaVersion() << endl; 212 } 208 213 fCorsikaVersion = runheader->GetCorsikaVersion(); 209 214 … … 285 290 // GetCollectionAreaAbs(), fMcAreaRadius); 286 291 const TString txt = Form("r_{max}=%.0fm --> A_{max}=%.0fm^{2}", 287 GetCollectionAreaAbs(), fMcAreaRadius);292 fMcAreaRadius, GetCollectionAreaAbs()); 288 293 289 294 TLatex text(0.31, 0.95, txt); -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
r8047 r8674 254 254 // are equal only fNorm is returned. 255 255 // 256 // The normalization constant is returned as %.16 f256 // The normalization constant is returned as %.16e 257 257 // 258 258 // Example: 0.3712780019*(pow(MMcEvt.fEnergy,-2.270))/(pow(MMcEvt.fEnergy,-2.600)) … … 261 261 { 262 262 if (GetFormulaSpecOld()==GetFormulaSpecNew()) 263 return Form("%.16 f", fNorm);263 return Form("%.16e", fNorm); 264 264 265 265 const Double_t iold = fNormEnergy<0 ? GetSpecOldIntegral() : CalcSpecOld(fNormEnergy); … … 268 268 const Double_t norm = fNorm*iold/inew; 269 269 270 return Form("%.16 f*(%s)/(%s)", norm, GetFormulaSpecNew().Data(), GetFormulaSpecOld().Data());270 return Form("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew().Data(), GetFormulaSpecOld().Data()); 271 271 } 272 272 … … 447 447 if (fWeightsZd) 448 448 { 449 /* 450 const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd()); 451 452 Double_t tmin = fWeightsZd->GetXaxis()->GetBinLowEdge(i) *TMath::DegToRad(); 453 Double_t tmax = fWeightsZd->GetXaxis()->GetBinLowEdge(i+1)*TMath::DegToRad(); 454 Double_t wdth = fWeightsZd->GetXaxis()->GetBinWidth(i) *TMath::DegToRad(); 455 456 Double_t cont = fWeightsZd->GetBinContent(i); 457 458 Double_t integ = cos(tmin)-cos(tmax); 459 460 w = sin(tmax)*cont/integ*wdth; 461 */ 462 449 463 const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd()); 450 464 w = fWeightsZd->GetBinContent(i); -
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 -
trunk/MagicSoft/Mars/sponde.cc
r8673 r8674 68 68 gLog << " --print-files Print Files taken from Sequences ('+' found, '-' missing)" << endl; 69 69 gLog << " --config=sponde.rc Resource file [default=sponde.rc]" << endl; 70 gLog << " --force-theta Force execution even with non-fitting theta distributions." << endl; 70 71 gLog << endl; 71 72 gLog << " --version, -V Show startup message with version number" << endl; … … 122 123 const Bool_t kRefill = arg.HasOnlyAndRemove("--refill"); 123 124 // const Bool_t kSimple = !arg.HasOnlyAndRemove("--accurate"); 125 const Bool_t kForceTheta = arg.HasOnlyAndRemove("--force-theta"); 124 126 const Bool_t kRawMc = arg.HasOnlyAndRemove("--raw-mc"); 125 127 … … 223 225 job.SetPathIn(kInfile); 224 226 227 job.ForceTheta(kForceTheta); 225 228 job.EnableRefilling(kRefill); 226 229 // job.EnableSimpleMode(kSimple);
Note:
See TracChangeset
for help on using the changeset viewer.