| 1 | //************************************************************************
|
|---|
| 2 | //
|
|---|
| 3 | // Authors : Eva Domingo, 1/2005 <mailto:domingo@ifae.es>
|
|---|
| 4 | //
|
|---|
| 5 | //
|
|---|
| 6 | // Macro for generating DISP Skymap of the FoV
|
|---|
| 7 | // -------------------------------------------
|
|---|
| 8 | //
|
|---|
| 9 | //************************************************************************
|
|---|
| 10 |
|
|---|
| 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.)
|
|---|
| 16 | {
|
|---|
| 17 | //======================================================================
|
|---|
| 18 | // Make Disp plots
|
|---|
| 19 | //======================================================================
|
|---|
| 20 |
|
|---|
| 21 | gLog << "-----------------------------------------------------" << endl;
|
|---|
| 22 | gLog << "Make Disp related plots" << endl;
|
|---|
| 23 | gLog << "-----------------------------------------------------" << endl;
|
|---|
| 24 |
|
|---|
| 25 | // Input root file/s storing the computed Hillas and Disp parameters
|
|---|
| 26 | gLog << "Input ON file/s: " << onfilename << endl;
|
|---|
| 27 | gLog << "Input OFF file/s: " << offfilename << endl;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | //----------------------------------------------------
|
|---|
| 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();
|
|---|
| 44 |
|
|---|
| 45 | MGeomCamMagic geomcam;
|
|---|
| 46 |
|
|---|
| 47 | // set cuts to select an event sample to apply Disp
|
|---|
| 48 | MFDisp *fdisp = NULL;
|
|---|
| 49 | // fdisp = new MFDisp;
|
|---|
| 50 | // fdisp->SetCuts(0,1,7,600,0,600,0.,3000000.,0.,0.,0.,0.,0.,0.);
|
|---|
| 51 | // MContinue contdisp(fdisp);
|
|---|
| 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 |
|
|---|
| 69 | // make Disp plots
|
|---|
| 70 | // SelectedPos = 1 means choose the right source position
|
|---|
| 71 | // 2 wrong
|
|---|
| 72 | // 3 the position according to M3Long
|
|---|
| 73 | // 4 the position according to Asym
|
|---|
| 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]", "");
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | //*****************************
|
|---|
| 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 |
|
|---|
| 96 |
|
|---|
| 97 | //*****************************
|
|---|
| 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);
|
|---|
| 108 | if (fdisp != NULL)
|
|---|
| 109 | tlist.AddToList(&contdisp);
|
|---|
| 110 | tlistoff.AddToList(&conthadr);
|
|---|
| 111 | tlistoff.AddToList(&contsize);
|
|---|
| 112 | tlistoff.AddToList(&filldispoff);
|
|---|
| 113 |
|
|---|
| 114 | //*****************************
|
|---|
| 115 |
|
|---|
| 116 | //-------------------------------------------
|
|---|
| 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) )
|
|---|
| 125 | return;
|
|---|
| 126 |
|
|---|
| 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);
|
|---|
| 177 | c->SetBorderMode(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);
|
|---|
| 194 | skymap->DrawClone("COLZ");
|
|---|
| 195 | skymap->SetBit(kCanDelete);
|
|---|
| 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;
|
|---|
| 211 | gLog << "-----------------------------------------------------" << endl;
|
|---|
| 212 |
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|