Changeset 6044
- Timestamp:
- 01/27/05 13:17:48 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/mifae/macros/DispSkymap.C
r6030 r6044 9 9 //************************************************************************ 10 10 11 void DispSkymap(TString filename = "hillasfile.root") 11 void DispSkymap(TString onfilename = "ONhillasfile.root", 12 TString offfilename = "OFFhillasfile.root", 13 TString outfilename = "skymaps.root", 14 Float_t HadronnessCut = 0.06, 15 Float_t SizeCut = 1000.) 12 16 { 13 17 //====================================================================== … … 20 24 21 25 // Input root file/s storing the computed Hillas and Disp parameters 22 gLog << "Input file/s: " << filename << endl; 23 26 gLog << "Input ON file/s: " << onfilename << endl; 27 gLog << "Input OFF file/s: " << offfilename << endl; 28 29 24 30 //---------------------------------------------------- 25 MTaskList tlist; 26 MParList plist; 27 28 // MReadMarsFile read("Events", filename); 29 MReadTree read("Parameters", filename); 30 read.DisableAutoScheme(); 31 MTaskList tliston; 32 MParList pliston; 33 34 MTaskList tlistoff; 35 MParList plistoff; 36 37 // MReadMarsFile readon("Events", onfilename); 38 MReadTree readon("Parameters", onfilename); 39 readon.DisableAutoScheme(); 40 41 // MReadMarsFile readoff("Events", offfilename); 42 MReadTree readoff("Parameters", offfilename); 43 readoff.DisableAutoScheme(); 31 44 32 45 MGeomCamMagic geomcam; … … 37 50 // fdisp->SetCuts(0,1,7,600,0,600,0.,3000000.,0.,0.,0.,0.,0.,0.); 38 51 // MContinue contdisp(fdisp); 39 52 53 // Hadroness cut 54 TString hadrcut = "MHadronness.fHadronness<"; 55 hadrcut += HadronnessCut; 56 gLog << "Hadronness Cut applied = " << hadrcut << endl; 57 MF hadrfilter(hadrcut); 58 MContinue conthadr(&hadrfilter); 59 conthadr.SetInverted(kTRUE); 60 61 // Size cut 62 TString sizecut = "MHillas.fSize>"; 63 sizecut += SizeCut; 64 gLog << "Size Cut applied = " << sizecut << endl; 65 MF sizefilter(sizecut); 66 MContinue contsize(&sizefilter); 67 contsize.SetInverted(kTRUE); 68 40 69 // make Disp plots 41 70 // SelectedPos = 1 means choose the right source position … … 43 72 // 3 the position according to M3Long 44 73 // 4 the position according to Asym 45 MHDisp hdisp1; 46 hdisp1.SetName("MHDispCorr"); 47 hdisp1.SetSelectedPos(1); 48 MFillH filldisp1("MHDispCorr[MHDisp]", ""); 49 50 MHDisp hdisp2; 51 hdisp2.SetName("MHDispWrong"); 52 hdisp2.SetSelectedPos(2); 53 MFillH filldisp2("MHDispWrong[MHDisp]", ""); 54 55 MHDisp hdisp3; 56 hdisp3.SetName("MHDispM3Long"); 57 hdisp3.SetSelectedPos(3); 58 MFillH filldisp3("MHDispM3Long[MHDisp]", ""); 59 60 MHDisp hdisp4; 61 hdisp4.SetName("MHDispAsym"); 62 hdisp4.SetSelectedPos(4); 63 MFillH filldisp4("MHDispAsym[MHDisp]", ""); 74 MHDisp hdispon; 75 hdispon.SetName("MHDispAsymOn"); 76 hdispon.SetSelectedPos(4); 77 MFillH filldispon("MHDispAsymOn[MHDisp]", ""); 78 79 MHDisp hdispoff; 80 hdispoff.SetName("MHDispAsymOff"); 81 hdispoff.SetSelectedPos(4); 82 MFillH filldispoff("MHDispAsymOff[MHDisp]", ""); 64 83 65 84 66 85 //***************************** 67 // entries in MParList 68 plist.AddToList(&tlist); 69 plist.AddToList(&geomcam); 70 plist.AddToList(&hdisp1); 71 plist.AddToList(&hdisp2); 72 plist.AddToList(&hdisp3); 73 plist.AddToList(&hdisp4); 86 // entries in MParList On 87 pliston.AddToList(&tliston); 88 pliston.AddToList(&geomcam); 89 pliston.AddToList(&hdispon); 90 91 // entries in MParList Off 92 plistoff.AddToList(&tlistoff); 93 plistoff.AddToList(&geomcam); 94 plistoff.AddToList(&hdispoff); 95 74 96 75 97 //***************************** 76 // entries in MTaskList 77 tlist.AddToList(&read); 98 // entries in MTaskList On 99 tliston.AddToList(&readon); 100 if (fdisp != NULL) 101 tliston.AddToList(&contdisp); 102 tliston.AddToList(&conthadr); 103 tliston.AddToList(&contsize); 104 tliston.AddToList(&filldispon); 105 106 // entries in MTaskList Off 107 tlistoff.AddToList(&readoff); 78 108 if (fdisp != NULL) 79 109 tlist.AddToList(&contdisp); 80 tlist.AddToList(&filldisp1); 81 // tlist.AddToList(&filldisp2); 82 tlist.AddToList(&filldisp3); 83 tlist.AddToList(&filldisp4); 110 tlistoff.AddToList(&conthadr); 111 tlistoff.AddToList(&contsize); 112 tlistoff.AddToList(&filldispoff); 84 113 85 114 //***************************** 86 115 87 116 //------------------------------------------- 88 // Execute event loop 89 // 90 MProgressBar bar; 91 MEvtLoop evtloop; 92 evtloop.SetParList(&plist); 93 evtloop.SetProgressBar(&bar); 94 95 Int_t maxevents = -1; 96 if ( !evtloop.Eventloop(maxevents) ) 117 // Execute event loop On 118 MProgressBar barOn; 119 MEvtLoop evtloopOn; 120 evtloopOn.SetParList(&pliston); 121 evtloopOn.SetProgressBar(&barOn); 122 123 Int_t maxeventsOn = -1; 124 if ( !evtloopOn.Eventloop(maxeventsOn) ) 97 125 return; 98 126 99 tlist.PrintStatistics(0, kTRUE); 100 101 //------------------------------------------- 102 // Display the histograms 103 // 104 // hdisp1.DrawClone(); 105 // hdisp2.DrawClone(); 106 // hdisp3.DrawClone(); 107 // hdisp4.DrawClone(); 108 109 gLog << "Drawing DISP Skymap for the FoV (srcpos solution selected according Asym sign)..." << endl; 110 TCanvas *c = new TCanvas("c","Disp Skymap",0,0,900,900); 127 tliston.PrintStatistics(0, kTRUE); 128 129 //------------------------------------------- 130 // Execute event loop Off 131 MProgressBar barOff; 132 MEvtLoop evtloopOff; 133 evtloopOff.SetParList(&plistoff); 134 evtloopOff.SetProgressBar(&barOff); 135 136 Int_t maxeventsOff = -1; 137 if ( !evtloopOff.Eventloop(maxeventsOff) ) 138 return; 139 140 tlistoff.PrintStatistics(0, kTRUE); 141 142 143 //------------------------------------------- 144 // Get the skymaps 145 TH2F *skymapOn = hdispon.GetSkymapXY(); 146 skymapOn->SetName("fSkymapXYOn"); 147 skymapOn->SetTitle("ON DATA: Disp estimated source positions Skymap"); 148 skymapOn->SetTitleOffset(1.2,"Y"); 149 TH2F *skymapOff = hdispoff.GetSkymapXY(); 150 skymapOff->SetName("fSkymapXYOff"); 151 skymapOff->SetTitle("OFF DATA: Disp estimated source positions Skymap"); 152 skymapOff->SetTitleOffset(1.2,"Y"); 153 154 // Normalize to the number of events and subtract Off to On skymap 155 Double_t onentries = skymapOn->GetEntries(); 156 Double_t offentries = skymapOff->GetEntries(); 157 Double_t norm = onentries/offentries; 158 cout << "Number of ON events after cuts = " << onentries << endl; 159 cout << "Number of OFF events after cuts = " << offentries << endl; 160 cout << "Normalization factor = " << norm << endl; 161 162 TH2F *skymap = new TH2F("fSkymapXY", 163 "ON-OFF: Disp estimated source positions Skymap", 71, -2., 2., 71, -2., 2.); 164 skymap->Add(skymapOn,skymapOff,1.,-norm); 165 skymap->SetTitleOffset(1.2,"Y"); 166 167 //------------------------------------------- 168 // Display the skymaps 169 gLog << endl; 170 gLog << "Drawing DISP Skymaps for the FoV ...... " << endl; 171 gLog << "(srcpos solution selected according Asym sign)" << endl; 172 173 gStyle->SetPalette(1); 174 gStyle->SetOptStat(11); 175 176 TCanvas *c = new TCanvas("c","Disp Skymaps",0,0,900,900); 111 177 c->SetBorderMode(0); 112 gStyle->SetPalette(1); 113 TH2F *skymap = hdisp4.GetSkymapXY(); 114 skymap->SetTitleOffset(1.2,"Y"); 115 // skymap->SetStats(0); 178 c->Divide(2,2); 179 180 c->cd(1); 181 gPad->SetBorderMode(0); 182 skymapOn->DrawClone("COLZ"); 183 skymapOn->SetBit(kCanDelete); 184 gPad->Modified(); 185 186 c->cd(2); 187 gPad->SetBorderMode(0); 188 skymapOff->DrawClone("COLZ"); 189 skymapOff->SetBit(kCanDelete); 190 gPad->Modified(); 191 192 c->cd(3); 193 gPad->SetBorderMode(0); 116 194 skymap->DrawClone("COLZ"); 117 195 skymap->SetBit(kCanDelete); 118 119 120 //------------------------------------------- 121 gLog << endl << "Disp plots were made for file '" << filename << endl; 196 gPad->Modified(); 197 198 //------------------------------------------- 199 // Save the skymaps in a .root file 200 TFile outfile(outfilename,"RECREATE"); 201 skymapOn->Write(); 202 skymapOff->Write(); 203 skymap->Write(); 204 outfile.Close(); 205 gLog << endl << "Skymaps stored in file: " << outfilename <<endl; 206 207 //------------------------------------------- 208 gLog << endl << "Disp plots were made for files: " << endl; 209 gLog << "ON data: " << onfilename << endl; 210 gLog << "OFF data: " << offfilename << endl; 122 211 gLog << "-----------------------------------------------------" << endl; 123 212
Note:
See TracChangeset
for help on using the changeset viewer.