Changeset 1910 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 04/07/03 15:34:51 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHHadronness.cc
r1809 r1910 19 19 ! Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it> 20 20 ! 21 ! Copyright: MAGIC Software Development, 2000-200 221 ! Copyright: MAGIC Software Development, 2000-2003 22 22 ! 23 23 ! … … 51 51 // - blue cross: minimum of distance to (0, 1) 52 52 // 53 // As a default MHHadronness searches for the container "MHadronness". 54 // This can be overwritten by a different pointer specified in the 55 // Fill function (No type check is done!) Use a different name in 56 // MFillH. 57 // 53 58 //////////////////////////////////////////////////////////////////////////// 54 59 #include "MHHadronness.h" 55 56 /*57 // - blue: 2D distance of (acceptance_hadrons, acceptances_gammas)58 // to optimum (0, 1): 1-sqrt(Ag*Ag + (1-Ah)*(1-Ah))59 */60 60 61 61 #include <TPad.h> … … 107 107 fIntPhness->SetYTitle("Acceptance"); 108 108 109 /*110 fQfac = new TH1D("Qfac", "Naive Quality factor", nbins, 0, 1);111 fQfac->SetXTitle("Hadronness");112 fQfac->SetYTitle("Quality");113 */114 109 fQfac = new TGraph; 115 110 fQfac->SetTitle(" Naive Quality factor "); 116 111 117 /*118 fMinDist = new TH1D("MinDist", "Minimum Dist to (0, 1)", nbins, 0, 1);119 fMinDist->SetXTitle("Hadronness");120 fMinDist->SetYTitle("Distance");121 */122 123 //fQfac->SetDirectory(NULL);124 112 fGhness->SetDirectory(NULL); 125 113 fPhness->SetDirectory(NULL); 126 //fMinDist->SetDirectory(NULL);127 114 fIntGhness->SetDirectory(NULL); 128 115 fIntPhness->SetDirectory(NULL); … … 140 127 delete fIntPhness; 141 128 delete fQfac; 142 // delete fMinDist;143 129 delete fGraph; 144 130 } … … 159 145 160 146 fHadronness = (MHadronness*)plist->FindObject("MHadronness"); 161 if (!fHadronness)162 {163 *fLog << err << dbginf << "MHadronness not found... aborting." << endl;164 return kFALSE;165 }166 147 167 148 /* … … 186 167 // histogram dependant on the particle id. 187 168 // 169 // Every particle Id different than kGAMMA is considered a hadron. 170 // 171 // If you call Fill with a pointer (eg. from MFillH) this container is 172 // used as a hadronness (Warning: No type check is done!) otherwise 173 // the default is used ("MHadronness") 174 // 188 175 // Sometimes a distance is calculated as NaN (not a number). Such events 189 176 // are skipped at the moment. … … 192 179 { 193 180 // Preliminary Workaround: FIXME! 194 195 const Double_t h = fHadronness->GetHadronness(); 181 if (!par && !fHadronness) 182 { 183 *fLog << err << "MHHadronness::Fill: No MHadronness container specified!" << endl; 184 return kFALSE; 185 } 186 187 const MHadronness &had = par ? *(MHadronness*)par : *fHadronness; 188 189 const Double_t h = had.GetHadronness(); 196 190 197 191 if (TMath::IsNaN(h)) … … 235 229 } 236 230 237 Float_t retValue; 238 if (val2x-val1x != 0.0) 239 retValue = val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5); 240 else 241 retValue = 0.0; 242 243 return retValue; 231 return val2x-val1x == 0 ? 0 : val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5); 244 232 } 245 233 … … 258 246 fQfac->Set(n); 259 247 260 Stat_t sumg; 261 Stat_t sump; 262 263 sumg = fGhness->Integral(1, n); 264 sump = fPhness->Integral(1, n); 265 266 if (sumg == 0.0 || sump == 0.0) 267 { 268 *fLog << "MHHadronness::Finalize; sumg or sump is zero; sumg, sump = " 269 << sumg << ", " << sump << ". Cannot calculate hadronness" 270 << endl; 271 } 248 const Stat_t sumg = fGhness->Integral(); 249 const Stat_t sump = fPhness->Integral(); 250 251 *fLog << inf << "MHHadronness::Finalize - Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl; 252 253 if (sumg==0 || sump==0) 254 *fLog << warn << "MHHadronness::Finalize: Cannot calculate hadronness." << endl; 272 255 273 256 274 257 // Normalize photon distribution 275 Stat_t con; 276 if (sumg > 0.0) 277 for (Int_t i=1; i<=n; i++) 278 { 279 con = (fGhness->GetBinContent(i)) / sumg; 280 fGhness->SetBinContent(i, con); 281 } 258 if (sumg>0) 259 fGhness->Scale(1./sumg); 282 260 283 261 // Normalize hadron distribution 284 if (sump > 0.0) 285 for (Int_t i=1; i<=n; i++) 286 { 287 con = (fPhness->GetBinContent(i)) / sump; 288 fPhness->SetBinContent(i, con); 289 } 262 if (sump>0) 263 fGhness->Scale(1./sump); 290 264 291 265 // Calculate acceptances 292 sumg = fGhness->Integral(1, n);293 sump = fPhness->Integral(1, n);294 295 *fLog << "MHHadronness::Finalize; sumg, sump = " << sumg << ", "296 << sump << endl;297 298 266 Float_t max=0; 299 267 300 268 for (Int_t i=1; i<=n; i++) 301 269 { 302 Stat_t ip; 303 if (sump != 0.0) 304 ip = fPhness->Integral(1, i)/sump; 305 else 306 ip = 0; 307 308 Stat_t ig; 309 if (sumg != 0.0) 310 ig = fGhness->Integral(1, i)/sumg; 311 else 312 ig = 0; 270 const Stat_t ip = sump!=0 ? fPhness->Integral(1, i)/sump : 0; 271 const Stat_t ig = sumg!=0 ? fGhness->Integral(1, i)/sumg : 0; 313 272 314 273 fIntPhness->SetBinContent(i, ip); … … 319 278 if (ip<=0) 320 279 continue; 321 322 //fMinDist->SetBinContent(i, 1-sqrt(ip*ip + (ig-1)*(ig-1)));323 280 324 281 const Double_t val = ig/sqrt(ip); … … 432 389 *fLog << endl; 433 390 434 /*435 const Int_t h = fMinDist->GetMaximumBin();436 *fLog << "Minimum Distance to (0, 1): " << Form("%.2f", 1-fMinDist->GetMaximum()) << " @ H=" << fMinDist->GetBinCenter(h) << endl;437 *fLog << " Acc Gammas = " << Form("%3.0f", fIntGhness->GetBinContent(h)*100) << "%, ";438 *fLog << "Acc Hadrons = " << Form("%3.0f", fIntPhness->GetBinContent(h)*100) << "%" << endl;439 */440 441 391 *fLog << "Q-Factor @ Acc Gammas=0.5: Q(0.5)=" << Form("%.1f", GetQ05()) << endl; 442 392 *fLog << " Acc Hadrons = " << Form("%5.1f", GetHadronAcceptance(0.5)*100) << "%" << endl; … … 463 413 Getphness()->SetLineColor(kRed); 464 414 Getphness()->DrawCopy("same"); 415 465 416 c.cd(2); 466 417 //gStyle->SetOptStat(0); … … 468 419 Getiphness()->SetLineColor(kRed); 469 420 Getiphness()->DrawCopy("same"); 470 /* 471 fMinDist->SetLineColor(kBlue); 472 fMinDist->DrawCopy("same"); 473 */ 421 474 422 c.cd(3); 475 //GetQfac()->DrawCopy();476 423 TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*"); 477 424 g2.SetBit(kCanDelete); … … 489 436 gPad->Update(); 490 437 } 438 491 439 c.cd(4); 492 440 gPad->Modified(); … … 537 485 Getphness()->SetLineColor(kRed); 538 486 Getphness()->Draw("same"); 487 539 488 gPad->cd(2); 540 489 //gStyle->SetOptStat(0); … … 542 491 Getiphness()->SetLineColor(kRed); 543 492 Getiphness()->Draw("same"); 544 /* 545 fMinDist->SetLineColor(kBlue); 546 fMinDist->Draw("same"); 547 */ 493 548 494 gPad->cd(3); 549 //GetQfac()->Draw();550 495 fQfac->Draw("A*"); 551 496 gPad->Modified(); … … 578 523 gPad->Update(); 579 524 } 580 /* 581 const Int_t h = fMinDist->GetMaximumBin(); 582 TMarker *m = new TMarker(fIntPhness->GetBinContent(h), 583 fIntGhness->GetBinContent(h), kStar); 584 m->SetMarkerColor(kBlue); 585 m->SetBit(kCanDelete); 586 m->Draw(); 587 */ 588 } 525 } -
trunk/MagicSoft/Mars/mhist/MHHadronness.h
r1668 r1910 22 22 TH1D* fIntPhness; //-> Hadrons Acceptance 23 23 TH1D* fIntGhness; //-> Gammas Acceptance 24 //TH1D* fMinDist; //-> Minimum Distance to optimum acceptance25 24 26 25 TGraph *fQfac; //-> Quality factor
Note:
See TracChangeset
for help on using the changeset viewer.