Changeset 8680 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 08/20/07 11:04:58 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r8676 r8680 18 18 ! Author(s): Thomas Bretz, 4/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 520 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 62 62 #include "../mhflux/MHAlpha.h" 63 63 #include "../mhflux/MHCollectionArea.h" 64 //#include "../mhflux/MHThreshold.h"65 64 #include "../mhflux/MHEnergyEst.h" 66 65 #include "../mhflux/MMcSpectrumWeight.h" … … 80 79 #include "MFillH.h" 81 80 #include "MHillasCalc.h" 82 //#include "MSrcPosCalc.h"83 81 #include "MContinue.h" 84 82 … … 89 87 MJSpectrum::MJSpectrum(const char *name, const char *title) 90 88 : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0), 91 fEstimateEnergy(0), fCalcHadronness(0), fRefill(kFALSE), 92 /*fSimpleMode(kTRUE),*/ fForceTheta(kFALSE), 93 fRawMc(kFALSE), fNoThetaWeights(kFALSE) 89 fEstimateEnergy(0), fCalcHadronness(0), fForceTheta(kFALSE) 94 90 { 95 91 fName = name ? name : "MJSpectrum"; 96 92 fTitle = title ? title : "Standard program to calculate spectrum"; 97 } 98 93 94 // Make sure that fDisplay is maintained properly 95 // (i.e. removed via RecursiveRemove if closed) 96 gROOT->GetListOfCleanups()->Add(this); 97 } 98 99 // -------------------------------------------------------------------------- 100 // 101 // Delete all the fCut* data members and fCalcHadronness/fEstimateEnergy 102 // 99 103 MJSpectrum::~MJSpectrum() 100 104 { … … 128 132 } 129 133 134 // -------------------------------------------------------------------------- 135 // 136 // Read a MTask named name into task from the open file. If this task is 137 // required mustexist can be set. Depending on success kTRUE or kFALSE is 138 // returned. If the task is a MContinue SetAllowEmpty is called. 139 // The name of the task is set to name. 140 // 130 141 Bool_t MJSpectrum::ReadTask(MTask* &task, const char *name, Bool_t mustexist) const 131 142 { 143 // If a task is set delete task 132 144 if (task) 133 145 { … … 136 148 } 137 149 150 // Try to get task from file 138 151 task = (MTask*)gFile->Get(name); 139 152 if (!task) … … 144 157 return kFALSE; 145 158 } 159 160 // Check if task inherits from MTask 146 161 if (!task->InheritsFrom(MTask::Class())) 147 162 { … … 151 166 } 152 167 168 // Set name of task 153 169 task->SetName(name); 154 170 171 // SetAllowEmpty for MContinue tasks 155 172 if (dynamic_cast<MContinue*>(task)) 156 173 dynamic_cast<MContinue*>(task)->SetAllowEmpty(); … … 159 176 } 160 177 178 // -------------------------------------------------------------------------- 179 // 180 // Print setup used for the MC processing, namely MAlphaFitter ans all fCut*. 181 // 161 182 void MJSpectrum::PrintSetup(const MAlphaFitter &fit) const 162 183 { … … 194 215 } 195 216 196 // Read the first corsika RunHeader from the MC files 197 TChain chain("RunHeaders"); 198 if (!set.AddFilesOn(chain)) 199 return kFALSE; 200 201 MMcCorsikaRunHeader *h=0; 202 chain.SetBranchAddress("MMcCorsikaRunHeader.", &h); 203 chain.GetEntry(1); 204 205 if (!h) 206 { 207 *fLog << err << "ERROR - Couldn't read MMcCorsikaRunHeader from DataSet." << endl; 208 return kFALSE; 209 } 210 211 // Propagate the run header to MMcSpectrumWeight 212 if (!w.Set(*h)) 213 { 214 *fLog << err << "ERROR - Initializing MMcSpectrumWeight failed." << endl; 215 return kFALSE; 216 } 217 218 // Print new setup of MMcSpectrumWeight 219 w.Print(); 217 w.Print("new"); 218 220 219 return kTRUE; 221 220 } … … 281 280 } 282 281 282 // -------------------------------------------------------------------------- 283 // 284 // return maximum value of MMcRunHeader.fImpactMax stored in the RunHeaders 285 // of the files from the MC dataset 286 // 287 Bool_t MJSpectrum::AnalyzeMC(const MDataSet &set, Float_t &impactmax, Float_t &emin/*, Float_t emax*/) const 288 { 289 if (fDisplay) 290 fDisplay->SetStatusLine1("Analyzing Monte Carlo headers..."); 291 292 // ----- Create chain ----- 293 *fLog << inf << "Getting files... " << flush; 294 TChain chain("RunHeaders"); 295 if (!set.AddFilesOn(chain)) 296 return kFALSE; 297 *fLog << "done. " << endl; 298 299 *fLog << all; 300 *fLog << "Searching for maximum impact... " << flush; 301 impactmax = chain.GetMaximum("MMcRunHeader.fImpactMax"); 302 *fLog << "found " << impactmax/100 << "m" << endl; 303 304 *fLog << "Searching for minimum lower energy limit... " << flush; 305 emin = chain.GetMinimum("MMcCorsikaRunHeader.fELowLim"); 306 *fLog << "found " << emin << "GeV" << endl; 307 308 *fLog << "Searching for maximum lower energy limit... " << flush; 309 const Float_t emin2 = chain.GetMaximum("MMcCorsikaRunHeader.fELowLim"); 310 *fLog << "found " << emin2 << "GeV" << endl; 311 312 if (emin2>emin) 313 { 314 *fLog << warn; 315 *fLog << "WARNING - You are using files with different lower limits for the simulated" << endl; 316 *fLog << " energy, i.e. that the collection area and your correction" << endl; 317 *fLog << " coefficients between " << emin << "GeV and "; 318 *fLog << emin2 << "GeV might be wrong." << endl; 319 } 320 321 /* 322 *fLog << "Getting maximum energy... " << flush; 323 emax = chain.GetMaximum("MMcCorsikaRunHeader.fEUppLim"); 324 *fLog << "found " << emax << "GeV" << endl; 325 */ 326 return kTRUE; 327 } 328 283 329 Bool_t MJSpectrum::ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &weight) const 284 330 { … … 286 332 fLog->Separator("Compiling original MC distribution"); 287 333 288 // The name of the input container is MMcEvtBasic 289 weight.SetNameMcEvt("MMcEvtBasic"); 290 // Get the corresponding rule for the weights 291 const TString w(weight.GetFormulaWeights()); 292 // Set back to MMcEvt 293 weight.SetNameMcEvt(); 294 295 *fLog << inf << "Using weights: " << w << endl; 296 *fLog << "Please stand by, this may take a while..." << endl; 297 298 if (fDisplay) 299 fDisplay->SetStatusLine1("Getting maximum impact..."); 300 301 // ----- Create chain ----- 302 *fLog << "Getting files... " << flush; 303 TChain chain("RunHeaders"); 304 if (!set.AddFilesOn(chain)) 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; 334 Float_t impactmax=0, Emin=0; 335 if (!AnalyzeMC(set, impactmax, Emin)) 336 return kFALSE; 337 338 *fLog << inf << "Getting files... " << flush; 313 339 MDirIter iter; 314 340 if (!set.AddFilesOn(iter)) 315 341 return kFALSE; 316 342 *fLog << "done. " << endl; 343 344 const Int_t tot = iter.GetNumEntries(); 317 345 318 346 // Prepare histogram … … 339 367 340 368 if (fDisplay) 341 fDisplay->SetStatusLine1("Reading OriginalMC ");369 fDisplay->SetStatusLine1("Reading OriginalMC distribution..."); 342 370 343 371 TH1 *hfill = (TH1*)h.Clone(h.InheritsFrom(TH2::Class())?"ThetaEMC":"ThetaMC"); 344 372 hfill->SetDirectory(0); 345 373 374 *fLog << all << "Compiling simulated source spectrum... please stand by, this may take a while." << endl; 375 376 Double_t evts = 0; 377 Int_t num = 0; 378 379 // Reading this with a eventloop is five times slower :( 346 380 TString fname; 347 while (1) 348 { 381 while (fDisplay) 382 { 383 if (fDisplay) 384 fDisplay->SetProgressBarPosition(Float_t(num++)/tot); 385 386 // Get next filename 349 387 fname = iter.Next(); 350 388 if (fname.IsNull()) 351 389 break; 352 390 391 if (fDisplay) 392 fDisplay->SetStatusLine2(fname); 393 394 // open file 353 395 TFile file(fname); 354 396 if (file.IsZombie()) … … 358 400 } 359 401 402 // Get tree OriginalMC 403 TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC")); 404 if (!t) 405 { 406 *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl; 407 return kFALSE; 408 } 409 if (t->GetEntries()==0) 410 { 411 *fLog << warn << "WARNING - OriginalMC of " << fname << " empty." << endl; 412 continue; 413 } 414 415 // Get tree RunHeaders 360 416 TTree *rh = dynamic_cast<TTree*>(file.Get("RunHeaders")); 361 417 if (!rh) … … 364 420 return kFALSE; 365 421 } 366 367 422 if (rh->GetEntries()!=1) 368 423 { … … 371 426 } 372 427 373 TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC")); 374 if (!t) 428 // Get corsika run header 429 MMcCorsikaRunHeader *head=0; 430 rh->SetBranchAddress("MMcCorsikaRunHeader.", &head); 431 rh->GetEntry(0); 432 if (!head) 375 433 { 376 *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl;434 *fLog << err << "ERROR - Couldn't read MMcCorsikaRunHeader from " << fname << "." << endl; 377 435 return kFALSE; 378 436 } 379 437 438 // Get the maximum impact parameter of this file. Due to different 439 // production areas an additional scale-factor is applied. 440 // 441 // Because it is assumed that the efficiency outside the production 442 // area is nearly zero no additional weight has to be applied to the 443 // events after cuts. 444 const Double_t impact = rh->GetMaximum("MMcRunHeader.fImpactMax"); 445 const Double_t scale = impactmax/impact; 446 447 // Propagate the run header to MMcSpectrumWeight 448 if (!weight.Set(*head)) 449 { 450 *fLog << err << "ERROR - Initializing MMcSpectrumWeight failed." << endl; 451 return kFALSE; 452 } 453 454 // Get the corresponding rule for the weights 455 const TString weights(weight.GetFormulaWeights("MMcEvtBasic")); 456 457 // No we found everything... go on reading contents 380 458 *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 area393 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 459 397 460 // Fill histogram from tree … … 403 466 } 404 467 hfill->SetDirectory(0); 468 469 evts += hfill->GetEntries(); 470 471 // ----- Complete incomplete energy ranges ----- 472 // ----- and apply production area weights ----- 473 weight.CompleteEnergySpectrum(*hfill, Emin); 474 475 hfill->Scale(scale*scale); 476 477 // Add weighted data from file to final histogram 405 478 h.Add(hfill); 406 479 } 407 480 delete hfill; 408 481 409 *fLog << "Total number of events from file: " << h.GetEntries()<< endl;482 *fLog << all << "Total number of events from files in Monte Carlo dataset: " << evts << endl; 410 483 if (fDisplay) 411 484 fDisplay->SetStatusLine2("done."); 412 485 413 if ( h.GetEntries()>0)486 if (!fDisplay || h.GetEntries()>0) 414 487 return kTRUE; 415 488 416 *fLog << err << "ERROR - Histogram with original MC distribution empty..." << endl; 417 489 *fLog << err << "ERROR - Histogram with distribution from OriginalMC empty..." << endl; 418 490 return kFALSE; 419 491 } 420 492 421 Bool_t MJSpectrum::GetThetaDistribution(TH1D &temp1, TH1D &temp2) const 422 { 493 void MJSpectrum::GetThetaDistribution(TH1D &temp1, TH2D &hist2) const 494 { 495 TH1D &temp2 = *hist2.ProjectionX(); 496 423 497 // Display some stuff 424 498 if (fDisplay) … … 430 504 c.cd(1); 431 505 gPad->SetBorderMode(0); 506 gPad->SetGridx(); 507 gPad->SetGridy(); 432 508 temp1.DrawCopy(); 433 509 … … 435 511 c.cd(2); 436 512 gPad->SetBorderMode(0); 513 gPad->SetGridx(); 514 gPad->SetGridy(); 437 515 temp2.SetName("NVsTheta"); 438 516 temp2.DrawCopy("hist"); … … 440 518 c.cd(4); 441 519 gPad->SetBorderMode(0); 520 gPad->SetGridx(); 521 gPad->SetGridy(); 442 522 443 523 c.cd(3); 444 524 gPad->SetBorderMode(0); 525 gPad->SetGridx(); 526 gPad->SetGridy(); 445 527 } 446 528 447 529 // Calculate the Probability 448 530 temp1.Divide(&temp2); 449 temp1.Scale( fNoThetaWeights ? 1./temp1.GetMaximum() :1./temp1.Integral());531 temp1.Scale(1./temp1.Integral()); 450 532 451 533 // Some cosmetics: Name, Axis, etc. … … 456 538 temp1.DrawCopy("hist"); 457 539 458 return kTRUE;540 delete &temp2; 459 541 } 460 542 … … 492 574 } 493 575 576 // Check whether histogram is empty 494 577 if (proj.GetMaximum()==0) 495 578 { … … 497 580 *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap" << endl; 498 581 *fLog << " with the Zenith Angle distribution of your observation." << endl; 499 *fLog << " Maybe the energy binning is not defined or wrong." << endl; 582 *fLog << " Maybe the energy binning is undefined or wrong (from "; 583 *fLog << h2.GetYaxis()->GetXmin() << "GeV to " << h2.GetYaxis()->GetXmax() << "GeV)" << endl; 500 584 theta->SetLineColor(kRed); 501 585 return kFALSE;; 502 586 } 503 587 588 // scale histogram and set new maximum for display 504 589 proj.Scale(theta->GetMaximum()/proj.GetMaximum()); 505 590 theta->SetMaximum(1.05*TMath::Max(theta->GetMaximum(), proj.GetMaximum())); 506 591 592 // draw project 507 593 proj.Draw("same"); 508 594 … … 688 774 fill0.SetFilter(&sel1); 689 775 690 if (!fRawMc)776 //if (!fRawMc) 691 777 tlist1.AddToList(&sel1); 692 778 tlist1.AddToList(&fill0); … … 767 853 TArrayD MJSpectrum::FitSpectrum(TH1D &spectrum) const 768 854 { 769 TF1 f("f", "[1]*(x/1e3)^[0]", 10, 3e4); 770 f.SetParameter(0, -2.5); 771 f.SetParameter(1, spectrum.GetBinContent(spectrum.GetXaxis()->FindFixBin(1000))); 855 Axis_t lo, hi; 856 MH::GetRangeUser(spectrum, lo, hi); 857 858 TF1 f("f", "[1]*(x/500)^[0]", lo, hi); 859 f.SetParameter(0, -3.0); 860 f.SetParameter(1, spectrum.GetMaximum()); 772 861 f.SetLineColor(kBlue); 773 spectrum.Fit(&f, "NI", "", 80, 1150); // M skipped 862 f.SetLineWidth(2); 863 spectrum.Fit(&f, "NIR"); // M skipped 774 864 f.DrawCopy("same"); 775 865 … … 881 971 spec = (TH1D*)spectrum.DrawCopy(); 882 972 883 // Calculate Spectrum * E^2 884 for (int i=0; i<spectrum.GetNbinsX(); i++) 885 { 886 const Double_t e = TMath::Sqrt(spectrum.GetBinLowEdge(i+1)*spectrum.GetBinLowEdge(i+2))*1e-3; 887 888 spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)*e*e); 889 spectrum.SetBinError( i+1, spectrum.GetBinError(i+1) *e*e); 890 } 973 TF1 fc("Crab", "7.0e-6*(x/300)^(-2.31-0.26*log10(x/300))", 100, 6000); 974 fc.SetLineStyle(7); 975 fc.SetLineWidth(2); 976 fc.SetLineColor(14); 977 fc.DrawCopy("same"); 978 979 TF1 fa("PG1553", "1.8e-6*(x/200)^-4.21", 90, 600); 980 static_cast<const TAttLine&>(fc).Copy(fa); 981 fa.DrawCopy("same"); 891 982 892 983 // Display dN/dE*E^2 for conveinience … … 896 987 gPad->SetGrid(); 897 988 989 // Calculate Spectrum * E^2 990 for (int i=0; i<spectrum.GetNbinsX(); i++) 991 { 992 const Double_t e = TMath::Sqrt(spectrum.GetBinLowEdge(i+1)*spectrum.GetBinLowEdge(i+2))*1e-3; 993 994 spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)*e*e); 995 spectrum.SetBinError( i+1, spectrum.GetBinError(i+1) *e*e); 996 } 997 898 998 spectrum.SetName("FluxStd"); 899 999 spectrum.SetMarkerStyle(kFullDotMedium); 900 1000 spectrum.SetTitle("Differential flux times E^{2}"); 901 spectrum.SetYTitle("E^{2} dN/dE [NTeV/sm^{2}]");1001 spectrum.SetYTitle("E^{2}#cdot dN/dE [N#cdot TeV/sm^{2}]"); 902 1002 spectrum.SetDirectory(0); 903 1003 spectrum.DrawCopy(); 1004 1005 TF1 fc2("Crab*E^2", "x^2*Crab*1e-6", 100, 6000); 1006 static_cast<const TAttLine&>(fc).Copy(fc2); 1007 fc2.DrawCopy("same"); 1008 1009 TF1 fa2("PG1553*E^2", "x^2*PG1553*1e-6", 100, 6000); 1010 static_cast<const TAttLine&>(fc).Copy(fa2); 1011 fa2.DrawCopy("same"); 904 1012 905 1013 // Fit Spectrum … … 943 1051 return res; 944 1052 */ 945 /*946 // Plot other spectra from Whipple947 f.SetParameter(0, -2.45);948 f.SetParameter(1, 3.3e-7);949 f.SetRange(300, 8000);950 f.SetLineColor(kBlack);951 f.SetLineStyle(kDashed);952 f.DrawCopy("same");953 954 // Plot other spectra from Cangaroo955 f.SetParameter(0, -2.53);956 f.SetParameter(1, 2.0e-7);957 f.SetRange(7000, 50000);958 f.SetLineColor(kBlack);959 f.SetLineStyle(kDashed);960 f.DrawCopy("same");961 962 // Plot other spectra from Robert963 f.SetParameter(0, -2.59);964 f.SetParameter(1, 2.58e-7);965 f.SetRange(150, 1500);966 f.SetLineColor(kBlack);967 f.SetLineStyle(kDashed);968 f.DrawCopy("same");969 970 // Plot other spectra from HEGRA971 f.SetParameter(0, -2.61);972 f.SetParameter(1, 2.7e-7);973 f.SetRange(1000, 20000);974 f.SetLineColor(kBlack);975 f.SetLineStyle(kDashed);976 f.DrawCopy("same");977 */978 1053 } 979 1054 … … 1179 1254 *fLog << endl; 1180 1255 1256 // Setup everything which is read from the ganymed file 1181 1257 MBinning bins1("BinningAlpha"); 1182 1258 MBinning bins2("BinningEnergyEst"); … … 1191 1267 MBinning binsa("BinningAsym"); 1192 1268 MBinning binsb("BinningConc1"); 1193 1194 1269 1195 1270 MAlphaFitter fit; … … 1209 1284 plist.AddToList(&fit); 1210 1285 1211 TH1D temp1, size; 1212 const Float_t ontime = ReadInput(plist, temp1, size); 1286 // Read from the ganymed file 1287 TH1D htheta, size; 1288 const Float_t ontime = ReadInput(plist, htheta, size); 1213 1289 if (ontime<0) 1214 1290 { … … 1217 1293 } 1218 1294 1219 plist.AddToList(&bins2); 1220 1221 // Initialize weighting to a new spectrum 1222 // as defined in the resource file 1295 // Set Zenith angle binning to binning from the ganymed-file 1296 bins3.SetEdges(htheta, 'x'); 1297 1298 // Read energy binning from resource file 1299 if (!CheckEnv(bins2)) 1300 { 1301 *fLog << err << "ERROR - Reading energy binning from resources failed." << endl; 1302 return kFALSE; 1303 } 1304 plist.AddToList(&bins2); // For later use in MC processing 1305 1306 // Initialize weighting to a new spectrum as defined in the resource file 1223 1307 MMcSpectrumWeight weight; 1224 1308 if (!InitWeighting(set, weight)) 1225 1309 return kFALSE; 1226 1310 1227 bins3.SetEdges(temp1, 'x'); 1228 1229 // Read the MC distribution as produced by corsika into 1230 // temp2 (1D) and apply the weights previously determined 1231 TH1D temp2(temp1); 1232 if (!ReadOrigMCDistribution(set, temp2, weight)) 1233 return kFALSE; 1234 1235 // Calculate the weights according to the zenith angle distribution 1236 // of the raw-data which have to be applied to the MC events 1237 if (!GetThetaDistribution(temp1, temp2)) 1238 return kFALSE; 1239 1240 // Tell the weighting task about the ZA-weights 1241 if (!fNoThetaWeights) 1242 weight.SetWeightsZd(&temp1); 1311 // Print Theta and energy binning for cross-checks 1312 *fLog << all << endl; 1313 bins2.Print(); 1314 bins3.Print(); 1315 1316 // Now we read the MC distribution as produced by corsika 1317 // vs zenith angle and energy. 1318 // Weight for the new energy spectrum defined in MMcSpectumWeight 1319 // are applied. 1320 // Also correction for different lower energy bounds and 1321 // different production areas (impact parameters) are applied. 1322 TH2D hist; 1323 hist.UseCurrentStyle(); 1324 MH::SetBinning(&hist, &bins3, &bins2); 1325 if (!ReadOrigMCDistribution(set, hist, weight)) 1326 return kFALSE; 1327 1328 // Check if user has closed the display 1329 if (!fDisplay) 1330 return kTRUE; 1331 1332 // Display histograms and calculate za-weights into htheta 1333 GetThetaDistribution(htheta, hist); 1334 1335 // Give the zenoith angle weights to the weighting task 1336 weight.SetWeightsZd(&htheta); 1337 1338 // No we apply the the zenith-angle-weights to the corsika produced 1339 // MC distribution. Unfortunately this must be done manually 1340 // because we are multiplying column by column 1341 for (int y=0; y<hist.GetNbinsY(); y++) 1342 for (int x=0; x<hist.GetNbinsX(); x++) 1343 { 1344 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*htheta.GetBinContent(x)); 1345 hist.SetBinError(x, y, hist.GetBinError(x, y) *htheta.GetBinContent(x)); 1346 } 1347 1348 // Display the resulting distribution and check it matches 1349 // the observation time distribution (this could be false 1350 // for example if you miss MCs of some zenith angles, which you have 1351 // data for) 1352 if (!DisplayResult(hist)) 1353 return kFALSE; 1354 1355 // -------------- Fill excess events versus energy --------------- 1243 1356 1244 1357 // Refill excess histogram to determin the excess events … … 1247 1360 return kFALSE; 1248 1361 1249 // Print the setup and result of the MAlphaFitter 1250 // Print used cuts 1362 // Print the setup and result of the MAlphaFitter, print used cuts 1251 1363 PrintSetup(fit); 1252 1253 TH2D hist;1254 MH3 mh1("MMcEvtBasic.fTelescopeTheta*kRad2Deg", "MMcEvtBasic.fEnergy");1255 //if (fSimpleMode)1256 {1257 // Now we read the MC distribution as produced by corsika again1258 // with the spectral weights applied into a histogram vs.1259 // zenith angle and energy1260 hist.UseCurrentStyle();1261 MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/);1262 if (!ReadOrigMCDistribution(set, hist, weight))1263 return kFALSE;1264 1265 // No we apply the the zenith-angle-weights to the corsika produced1266 // MC distribution. Unfortunately this must be done manually1267 // because we are multiplying column by column1268 if (!fRawMc)1269 {1270 for (int y=0; y<hist.GetNbinsY(); y++)1271 for (int x=0; x<hist.GetNbinsX(); x++)1272 {1273 hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x));1274 hist.SetBinError(x, y, hist.GetBinError(x, y) *temp1.GetBinContent(x));1275 }1276 }1277 }/*1278 else1279 {1280 // This rereads the original MC spectrum and aplies both1281 // weights, spectral weights and ZA-weights.1282 weight.SetNameMcEvt("MMcEvtBasic");1283 if (!IntermediateLoop(plist, mh1, temp1, set, weight))1284 return kFALSE;1285 weight.SetNameMcEvt();1286 }*/1287 1288 if (!DisplayResult(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/))1289 return kFALSE;1290 1364 1291 1365 // ------------------------- Final loop -------------------------- … … 1304 1378 1305 1379 // Selector to get correct (final) theta-distribution 1306 temp1.SetXTitle("MPointingPos.fZd");1307 1308 MH3 mh3(temp1);1309 1310 MFEventSelector2 sel2(mh3);1311 sel2.SetHistIsProbability();1312 1313 MContinue contsel(&sel2);1314 contsel.SetInverted();1380 //temp1.SetXTitle("MPointingPos.fZd"); 1381 // 1382 //MH3 mh3(temp1); 1383 // 1384 //MFEventSelector2 sel2(mh3); 1385 //sel2.SetHistIsProbability(); 1386 // 1387 //MContinue contsel(&sel2); 1388 //contsel.SetInverted(); 1315 1389 1316 1390 // Get correct source position … … 1318 1392 1319 1393 // Calculate corresponding Hillas parameters 1320 /* 1321 MHillasCalc hcalc1; 1322 MHillasCalc hcalc2("MHillasCalcAnti"); 1323 hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc); 1324 hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc); 1325 hcalc2.SetNameHillasSrc("MHillasSrcAnti"); 1326 hcalc2.SetNameSrcPosCam("MSrcPosAnti"); 1327 */ 1394 //MHillasCalc hcalc1; 1395 //MHillasCalc hcalc2("MHillasCalcAnti"); 1396 //hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc); 1397 //hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc); 1398 //hcalc2.SetNameHillasSrc("MHillasSrcAnti"); 1399 //hcalc2.SetNameSrcPosCam("MSrcPosAnti"); 1328 1400 1329 1401 // Fill collection area and energy estimator (unfolding) … … 1331 1403 MHCollectionArea area0("TriggerArea"); 1332 1404 MHCollectionArea area1; 1333 area0.SetHistAll( /*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);1334 area1.SetHistAll( /*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);1405 area0.SetHistAll(hist); 1406 area1.SetHistAll(hist); 1335 1407 1336 1408 MHEnergyEst hest; … … 1371 1443 MFillH fill7a("MHNewParMCPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost"); 1372 1444 MFillH fill8a("ExcessMC [MH3]", "", "FillExcessMC"); 1445 fill0a.SetNameTab("EvtDist"); 1373 1446 fill1a.SetNameTab("PreCut"); 1374 1447 fill2a.SetNameTab("PostCut"); … … 1399 1472 // be thrown away according to the theta distribution 1400 1473 // it is enabled here 1401 if (!fRawMc && fNoThetaWeights)1402 tlist2.AddToList(&contsel);1474 //if (!fRawMc && fNoThetaWeights) 1475 // tlist2.AddToList(&contsel); 1403 1476 //tlist2.AddToList(&calc); 1404 1477 //tlist2.AddToList(&hcalc1); -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
r8676 r8680 33 33 MTask *fCalcHadronness; 34 34 35 Bool_t fRefill;36 //Bool_t fSimpleMode;37 35 Bool_t fForceTheta; 38 Bool_t fRawMc;39 Bool_t fNoThetaWeights;40 36 41 37 // Read Input 42 Bool_t ReadTask(MTask* &task, const char *name, Bool_t mustexist=kTRUE) const; 43 Float_t ReadInput(MParList &plist, TH1D &h1, TH1D &size); 44 Bool_t ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &w) const; 45 Bool_t GetThetaDistribution(TH1D &temp1, TH1D &temp2) const; 46 Bool_t Refill(MParList &plist, TH1D &h) /*const*/; 47 Bool_t InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const; 38 Bool_t ReadTask(MTask* &task, const char *name, Bool_t mustexist=kTRUE) const; 39 Float_t ReadInput(MParList &plist, TH1D &h1, TH1D &size); 40 Bool_t AnalyzeMC(const MDataSet &set, Float_t &impactmax, Float_t &emin/*, Float_t emax*/) const; 41 Bool_t ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &w) const; 42 void GetThetaDistribution(TH1D &temp1, TH2D &temp2) const; 43 Bool_t Refill(MParList &plist, TH1D &h) /*const*/; 44 Bool_t InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const; 48 45 49 46 // Display Output … … 63 60 Bool_t Process(const MDataSet &set); 64 61 65 void EnableRefilling(Bool_t b=kTRUE) { fRefill=b; } 66 //void EnableSimpleMode(Bool_t b=kTRUE) { fSimpleMode=b; } 67 void EnableRawMc(Bool_t b=kTRUE) { fRawMc=b; } 68 void ForceTheta(Bool_t b=kTRUE) { fForceTheta=b; } 62 void ForceTheta(Bool_t b=kTRUE) { fForceTheta=b; } 69 63 70 64 void SetEnergyEstimator(const MTask *task);
Note:
See TracChangeset
for help on using the changeset viewer.