/* DW modified this macro to be a bit more intelligent and automated about things like the directory, naming files and particle type etc. etc. DATE: 04-06-22 MODIFIED: 04-06-24 */ /* Modified for low-energy showers by EB: 03-08-04 */ #include "root-utilities.C" dw_avghist() { TFile* fin = new TFile("~/chicos/LowE_summary.root"); int i;//counter int ans = 1;//initialize instead of do-loop int disp;//for flow of image int path;//name the directory where stuff is found i.e. 1.00E18/0.95 char part_type[10];//define the particle as electron or muon char name[75];//name the average histogram file output name char title[75];//give a title for the average histogram char hname[100];//for the histogram/directory/file TH1F* h[10];//for the runs while (ans == 1){ cout<<"Input path:\n\n"; cout<<"\t1-3 - 1.00e16 @ 95(1)-75(3)\n"; cout<<"\t4-6 - 3.16e16 @ 95(4)-75(6)\n"; cout<<"\t7-9 - 1.00e17 etc\n"; cout<<"\t10-12 - 3.16e17 etc\n"; cin>>path; cin.ignore(80,'\n'); cout<<"e, m, efine, mfine, etc? "; cin.getline(part_type,10,'\n'); fin->cd("iron"); switch (path){ case 1: gDirectory->cd("1.00e16/0.95"); sprintf(name,"1.00e16/0.95_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{16} at Cos #theta = 0.95"); break; case 2: gDirectory->cd("1.00e16/0.85"); sprintf(name,"1.00e16/0.85_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{16} at Cos #theta = 0.85"); break; case 3: gDirectory->cd("1.00e16/0.75"); sprintf(name,"1.00e16/0.75_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{16} at Cos #theta = 0.75"); break; case 4: gDirectory->cd("3.16e16/0.95"); sprintf(name,"3.16e16/0.95_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{16} at Cos #theta = 0.95"); break; case 5: gDirectory->cd("3.16e16/0.85"); sprintf(name,"3.16e16/0.85_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{16} at Cos #theta = 0.85"); break; case 6: gDirectory->cd("3.16e16/0.75"); sprintf(name,"3.16e16/0.75_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{16} at Cos #theta = 0.75"); break; case 7: gDirectory->cd("1.00e17/0.95"); sprintf(name,"1.00e17/0.95_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{17} at Cos #theta = 0.95"); break; case 8: gDirectory->cd("1.00e17/0.85"); sprintf(name,"1.00e17/0.85_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{17} at Cos #theta = 0.85"); break; case 9: gDirectory->cd("1.00e17/0.75"); sprintf(name,"1.00e17/0.75_%s",part_type); sprintf(title,"Average Histogram for NRG 1x10^{17} at Cos #theta = 0.75"); break; case 10: gDirectory->cd("3.16e17/0.95"); sprintf(name,"3.16e17/0.95_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{17} at Cos #theta = 0.95"); break; case 11: gDirectory->cd("3.16e17/0.85"); sprintf(name,"3.16e17/0.85_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{17} at Cos #theta = 0.85"); break; case 12: gDirectory->cd("3.16e17/0.75"); sprintf(name,"3.16e17/0.75_%s",part_type); sprintf(title,"Average Histogram for NRG 3x10^{17} at Cos #theta = 0.75"); break; default: cout<<"Error.\n"; exit(1); };//end of SWITCH printf("\n"); for (i=0;i<10;i++){ sprintf(hname,"%.3d/%s_3",i+1,part_type); printf("%s\n",hname); h[i] = (TH1F*)gDirectory->Get(hname); }//end of FOR TH1F* have = averageHist(h,10); have->SetName(name); have->SetTitle(title); cout<>disp; cin.ignore(80,'\n'); if (disp == 1){ have->Draw("P E"); gPad->SetLogy(); gPad->Update(); }//end of IF TFile* fout = new TFile("avg_histo.root","UPDATE"); have->Write(); fout->Close(); cout<>ans; cin.ignore(80,'\n'); }//end of WHILE }//end of MACRO