| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Daniel Mazin, 8/2004 <mailto:mazin@mppmu.mpg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MSkyPlot
|
|---|
| 29 | //
|
|---|
| 30 | // Create a false source plot. For the Binning in x,y the object MBinning
|
|---|
| 31 | // "BinningFalseSource" is taken from the paremeter list.
|
|---|
| 32 | //
|
|---|
| 33 | // The binning in alpha is currently fixed as 18bins from 0 to 90deg.
|
|---|
| 34 | //
|
|---|
| 35 | // If MTime, MObservatory and MPointingPos is available in the paremeter
|
|---|
| 36 | // list each image is derotated.
|
|---|
| 37 | //
|
|---|
| 38 | // MSkyPlot fills a 3D histogram with alpha distribution for
|
|---|
| 39 | // each (derotated) x and y position.
|
|---|
| 40 | //
|
|---|
| 41 | // Only a radius of 1.2deg around the camera center is taken into account.
|
|---|
| 42 | //
|
|---|
| 43 | // The displayed histogram is the projection of alpha<fAlphaCut into
|
|---|
| 44 | // the x,y plain and the projection of alpha>90-fAlphaCut
|
|---|
| 45 | //
|
|---|
| 46 | // By using the context menu (find it in a small region between the single
|
|---|
| 47 | // pads) you can change the AlphaCut 'online'
|
|---|
| 48 | //
|
|---|
| 49 | // Each Z-Projection (Alpha-histogram) is scaled such, that the number
|
|---|
| 50 | // of entries fits the maximum number of entries in all Z-Projections.
|
|---|
| 51 | // This should correct for the different acceptance in the center
|
|---|
| 52 | // and at the border of the camera. This, however, produces more noise
|
|---|
| 53 | // at the border.
|
|---|
| 54 | //
|
|---|
| 55 | // Here is a slightly simplified version of the algorithm:
|
|---|
| 56 | // ------------------------------------------------------
|
|---|
| 57 | // MHillas hil; // Taken as second argument in MFillH
|
|---|
| 58 | //
|
|---|
| 59 | // MSrcPosCam src;
|
|---|
| 60 | // MHillasSrc hsrc;
|
|---|
| 61 | // hsrc.SetSrcPos(&src);
|
|---|
| 62 | //
|
|---|
| 63 | // for (int ix=0; ix<nx; ix++)
|
|---|
| 64 | // for (int iy=0; iy<ny; iy++)
|
|---|
| 65 | // {
|
|---|
| 66 | // TVector2 v(cx[ix], cy[iy]); //cx center of x-bin ix
|
|---|
| 67 | // if (rho!=0) //cy center of y-bin iy
|
|---|
| 68 | // v=v.Rotate(rho); //image rotation angle
|
|---|
| 69 | //
|
|---|
| 70 | // src.SetXY(v); //source position in the camera
|
|---|
| 71 | //
|
|---|
| 72 | // if (!hsrc.Calc(hil)) //calc source dependant hillas
|
|---|
| 73 | // return;
|
|---|
| 74 | //
|
|---|
| 75 | // //fill absolute alpha into histogram
|
|---|
| 76 | // const Double_t alpha = hsrc.GetAlpha();
|
|---|
| 77 | // fHist.Fill(cx[ix], cy[iy], TMath::Abs(alpha), w);
|
|---|
| 78 | // }
|
|---|
| 79 | // }
|
|---|
| 80 | //
|
|---|
| 81 | // Use MHFalse Source like this:
|
|---|
| 82 | // -----------------------------
|
|---|
| 83 | // MFillH fill("MSkyPlot", "MHillas");
|
|---|
| 84 | // or
|
|---|
| 85 | // MSkyPlot hist;
|
|---|
| 86 | // hist.SetAlphaCut(12.5); // The default value
|
|---|
| 87 | // hist.SetBgmean(55); // The default value
|
|---|
| 88 | // MFillH fill(&hist, "MHillas");
|
|---|
| 89 | //
|
|---|
| 90 | // To be implemented:
|
|---|
| 91 | // ------------------
|
|---|
| 92 | // - a switch to use alpha or |alpha|
|
|---|
| 93 | // - taking the binning for alpha from the parlist (binning is
|
|---|
| 94 | // currently fixed)
|
|---|
| 95 | // - a possibility to change the fit-function (eg using a different TF1)
|
|---|
| 96 | // - a possibility to change the fit algorithm (eg which paremeters
|
|---|
| 97 | // are fixed at which time)
|
|---|
| 98 | // - use a different varaible than alpha
|
|---|
| 99 | // - a possiblity to change the algorithm which is used to calculate
|
|---|
| 100 | // alpha (or another parameter) is missing (this could be done using
|
|---|
| 101 | // a tasklist somewhere...)
|
|---|
| 102 | // - a more clever (and faster) algorithm to fill the histogram, eg by
|
|---|
| 103 | // calculating alpha once and fill the two coils around the mean
|
|---|
| 104 | // - more drawing options...
|
|---|
| 105 | // - Move Significance() to a more 'general' place and implement
|
|---|
| 106 | // also different algorithms like (Li/Ma)
|
|---|
| 107 | // - implement fit for best alpha distribution -- online (Paint)
|
|---|
| 108 | // - currently a constant pointing position is assumed in Fill()
|
|---|
| 109 | // - the center of rotation need not to be the camera center
|
|---|
| 110 | // - ERRORS on each alpha bin to estimate the chi^2 correctly!
|
|---|
| 111 | // (sqrt(N)/binwidth) needed for WOlfgangs proposed caluclation
|
|---|
| 112 | // of alpha(Li/Ma)
|
|---|
| 113 | //
|
|---|
| 114 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 115 | #include "MSkyPlot.h"
|
|---|
| 116 |
|
|---|
| 117 | #include <TF1.h>
|
|---|
| 118 | #include <TH2.h>
|
|---|
| 119 | #include <TH1.h>
|
|---|
| 120 | #include <TGraph.h>
|
|---|
| 121 | #include <TStyle.h>
|
|---|
| 122 | #include <TLatex.h>
|
|---|
| 123 | #include <TCanvas.h>
|
|---|
| 124 | #include <TPaveLabel.h>
|
|---|
| 125 | #include <TPaveText.h>
|
|---|
| 126 | #include <TStopwatch.h>
|
|---|
| 127 | #include <TFile.h>
|
|---|
| 128 |
|
|---|
| 129 | #include "MGeomCam.h"
|
|---|
| 130 | #include "MSrcPosCam.h"
|
|---|
| 131 | #include "MReportDrive.h"
|
|---|
| 132 | #include "MHillasSrc.h"
|
|---|
| 133 | #include "MHillas.h"
|
|---|
| 134 | #include "MHillasExt.h"
|
|---|
| 135 | #include "MNewImagePar.h"
|
|---|
| 136 | #include "MHadronness.h"
|
|---|
| 137 | #include "MTime.h"
|
|---|
| 138 | #include "MObservatory.h"
|
|---|
| 139 | #include "MPointingPos.h"
|
|---|
| 140 | #include "MAstroCatalog.h"
|
|---|
| 141 | #include "MAstroSky2Local.h"
|
|---|
| 142 | #include "MStarCamTrans.h"
|
|---|
| 143 | #include "MStatusDisplay.h"
|
|---|
| 144 | #include "MMath.h"
|
|---|
| 145 | #include "MSupercuts.h"
|
|---|
| 146 |
|
|---|
| 147 | #include "MBinning.h"
|
|---|
| 148 | #include "MParList.h"
|
|---|
| 149 |
|
|---|
| 150 | #include "MLog.h"
|
|---|
| 151 | #include "MLogManip.h"
|
|---|
| 152 |
|
|---|
| 153 | #include <TOrdCollection.h>
|
|---|
| 154 |
|
|---|
| 155 | ClassImp(MSkyPlot);
|
|---|
| 156 |
|
|---|
| 157 | using namespace std;
|
|---|
| 158 |
|
|---|
| 159 | // --------------------------------------------------------------------------
|
|---|
| 160 | //
|
|---|
| 161 | // Default Constructor
|
|---|
| 162 | //
|
|---|
| 163 | MSkyPlot::MSkyPlot(const char *name, const char *title)
|
|---|
| 164 | : fGeomCam(NULL),
|
|---|
| 165 | fTime(NULL),
|
|---|
| 166 | fPointPos(NULL),
|
|---|
| 167 | fRepDrive(NULL),
|
|---|
| 168 | fSrcPosCam(NULL),
|
|---|
| 169 | fPntPosCam(NULL),
|
|---|
| 170 | fObservatory(NULL),
|
|---|
| 171 | fHillas(NULL),
|
|---|
| 172 | fHillasExt(NULL),
|
|---|
| 173 | fHillasSrc(NULL),
|
|---|
| 174 | fNewImagePar(NULL),
|
|---|
| 175 | fMm2Deg(-1)
|
|---|
| 176 | {
|
|---|
| 177 |
|
|---|
| 178 | *fLog << warn << "entering default constructor in MSkyPlot" << endl;
|
|---|
| 179 | //
|
|---|
| 180 | // set the name and title of this object
|
|---|
| 181 | //
|
|---|
| 182 | fName = name ? name : "MSkyPlot";
|
|---|
| 183 | fTitle = title ? title : "sky plot vs x, y";
|
|---|
| 184 |
|
|---|
| 185 | fSetCenter=kTRUE;
|
|---|
| 186 |
|
|---|
| 187 | fHistSignif.SetDirectory(NULL);
|
|---|
| 188 | fHistNexcess.SetDirectory(NULL);
|
|---|
| 189 | fHistOn.SetDirectory(NULL);
|
|---|
| 190 | fHistSignifGaus.SetDirectory(NULL);
|
|---|
| 191 |
|
|---|
| 192 | fHistSignif.UseCurrentStyle();
|
|---|
| 193 | fHistNexcess.UseCurrentStyle();
|
|---|
| 194 | fHistOn.UseCurrentStyle();
|
|---|
| 195 | fHistSignifGaus.UseCurrentStyle();
|
|---|
| 196 |
|
|---|
| 197 | fHistSignif.SetName("SkyPlotSignif");
|
|---|
| 198 | fHistSignif.SetTitle("Sky Plot of significance vs x, y");
|
|---|
| 199 | fHistSignif.SetXTitle("x [\\circ]");
|
|---|
| 200 | fHistSignif.SetYTitle("y [\\circ]");
|
|---|
| 201 |
|
|---|
| 202 | fHistNexcess.SetName("SkyPlotNexcess");
|
|---|
| 203 | fHistNexcess.SetTitle("Sky Plot of number of excess vs x, y");
|
|---|
| 204 | fHistNexcess.SetXTitle("x [\\circ]");
|
|---|
| 205 | fHistNexcess.SetYTitle("y [\\circ]");
|
|---|
| 206 |
|
|---|
| 207 | fHistOn.SetName("SkyPlotOn");
|
|---|
| 208 | fHistOn.SetTitle("Sky Plot of number of On events vs x, y");
|
|---|
| 209 | fHistOn.SetXTitle("x [\\circ]");
|
|---|
| 210 | fHistOn.SetYTitle("y [\\circ]");
|
|---|
| 211 |
|
|---|
| 212 | fHistSignifGaus.SetName("SignifDistrib");
|
|---|
| 213 | fHistSignifGaus.SetTitle("Distribution of the significances from the sky plot");
|
|---|
| 214 | fHistSignifGaus.SetXTitle("significance");
|
|---|
| 215 | fHistSignifGaus.SetYTitle("counts");
|
|---|
| 216 |
|
|---|
| 217 | // set some values for the sky plot geometry:
|
|---|
| 218 | fMinXGrid =-1.; // [deg]
|
|---|
| 219 | fMaxXGrid = 1.; // [deg] , right edge of the skyplot
|
|---|
| 220 | fMinYGrid =-1.; // [deg] , upper edge of the skyplot
|
|---|
| 221 | fMaxYGrid = 1.; // [deg] , lower edge of the skyplot
|
|---|
| 222 | fBinStepGrid = 0.05; // [deg],
|
|---|
| 223 | fAlphaONMax = 5.; // [deg] , upper cut for alpha ON region in the alpha plot
|
|---|
| 224 | // [deg], ON region in the alpha plot, maybe 5 deg is better
|
|---|
| 225 | // NOTE: up to now only values of 5, 10, 15, 20 degrees are possible
|
|---|
| 226 | // ra,dec lines from wolfgang:
|
|---|
| 227 | fGridBinning = 0.50; // degrees
|
|---|
| 228 | fGridFineBin = 0.01; // degrees
|
|---|
| 229 |
|
|---|
| 230 | // elapsed time:
|
|---|
| 231 | fElaTime = 0.;
|
|---|
| 232 |
|
|---|
| 233 | // some filter cuts:
|
|---|
| 234 | fSizeMin = 2000.; // min size in photons
|
|---|
| 235 | fSizeMax = 100000.; // max size in photons
|
|---|
| 236 | fLeakMax = 0.25; // leakmax in per cent
|
|---|
| 237 | fMaxDist = 1.4; // dist max cut (ever possible)
|
|---|
| 238 | fMinDist = 0.1; // dist max cut (ever possible)
|
|---|
| 239 | fHadrCut = 0.2; // hadronness cut
|
|---|
| 240 |
|
|---|
| 241 | fNumBinsAlpha = 36; // number of bins for alpha histograms
|
|---|
| 242 | fAlphaLeftEdge = 0.; // [deg] left edge
|
|---|
| 243 | fAlphaRightEdge = 90.; // [deg] left edge
|
|---|
| 244 |
|
|---|
| 245 | fAlphaBgLow = 30.;
|
|---|
| 246 | fAlphaBgUp = 90.;
|
|---|
| 247 |
|
|---|
| 248 | {
|
|---|
| 249 | // SET DEFAULT VALUES HERE
|
|---|
| 250 | fLengthUp[0] = 0.2;
|
|---|
| 251 | fLengthUp[1] = 0.0;
|
|---|
| 252 | fLengthUp[2] = 0.0;
|
|---|
| 253 | fLengthUp[3] = 0.0;
|
|---|
| 254 | fLengthUp[4] = 0.0;
|
|---|
| 255 | fLengthUp[5] = 0.0;
|
|---|
| 256 | fLengthUp[6] = 0.0;
|
|---|
| 257 | fLengthUp[7] = 0.0;
|
|---|
| 258 |
|
|---|
| 259 | fLengthLo[0] = 0.;
|
|---|
| 260 | fLengthLo[1] = 0.;
|
|---|
| 261 | fLengthLo[2] = 0.;
|
|---|
| 262 | fLengthLo[3] = 0.;
|
|---|
| 263 | fLengthLo[4] = 0.;
|
|---|
| 264 | fLengthLo[5] = 0.;
|
|---|
| 265 | fLengthLo[6] = 0.;
|
|---|
| 266 | fLengthLo[7] = 0.;
|
|---|
| 267 |
|
|---|
| 268 | fWidthUp[0] = 0.1;
|
|---|
| 269 | fWidthUp[1] = 0.0;
|
|---|
| 270 | fWidthUp[2] = 0.0;
|
|---|
| 271 | fWidthUp[3] = 0.0;
|
|---|
| 272 | fWidthUp[4] = 0.0;
|
|---|
| 273 | fWidthUp[5] = 0.0;
|
|---|
| 274 | fWidthUp[6] = 0.0;
|
|---|
| 275 | fWidthUp[7] = 0.0;
|
|---|
| 276 |
|
|---|
| 277 | fWidthLo[0] = 0.;
|
|---|
| 278 | fWidthLo[1] = 0.;
|
|---|
| 279 | fWidthLo[2] = 0.;
|
|---|
| 280 | fWidthLo[3] = 0.;
|
|---|
| 281 | fWidthLo[4] = 0.;
|
|---|
| 282 | fWidthLo[5] = 0.;
|
|---|
| 283 | fWidthLo[6] = 0.;
|
|---|
| 284 | fWidthLo[7] = 0.;
|
|---|
| 285 |
|
|---|
| 286 | fDistUp[0] = 1.e10;
|
|---|
| 287 | fDistUp[1] = 0.0;
|
|---|
| 288 | fDistUp[2] = 0.0;
|
|---|
| 289 | fDistUp[3] = 0.0;
|
|---|
| 290 | fDistUp[4] = 0.0;
|
|---|
| 291 | fDistUp[5] = 0.0;
|
|---|
| 292 | fDistUp[6] = 0.0;
|
|---|
| 293 | fDistUp[7] = 0.0;
|
|---|
| 294 |
|
|---|
| 295 | fDistLo[0] = 0.0;
|
|---|
| 296 | fDistLo[1] = 0.0;
|
|---|
| 297 | fDistLo[2] = 0.0;
|
|---|
| 298 | fDistLo[3] = 0.0;
|
|---|
| 299 | fDistLo[4] = 0.0;
|
|---|
| 300 | fDistLo[5] = 0.0;
|
|---|
| 301 | fDistLo[6] = 0.0;
|
|---|
| 302 | fDistLo[7] = 0.0;
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | fSaveAlphaPlots=kTRUE;
|
|---|
| 306 | fSaveSkyPlots=kTRUE;
|
|---|
| 307 | fSaveNexPlot=kTRUE;
|
|---|
| 308 | fUseRF=kFALSE;
|
|---|
| 309 | fAlphaHName = "alphaplot.root";
|
|---|
| 310 | fSkyHName = "skyplot.root";
|
|---|
| 311 | fNexHName = "Nexcess.gif";
|
|---|
| 312 |
|
|---|
| 313 | fHistAlpha = new TOrdCollection();
|
|---|
| 314 | fHistAlpha->SetOwner();
|
|---|
| 315 |
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | MSkyPlot::~MSkyPlot()
|
|---|
| 319 | {
|
|---|
| 320 |
|
|---|
| 321 | if (fHistAlpha)
|
|---|
| 322 | delete fHistAlpha;
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | // --------------------------------------------------------------------------
|
|---|
| 326 | //
|
|---|
| 327 | // Get i-th hist
|
|---|
| 328 | //
|
|---|
| 329 | TH1D *MSkyPlot::GetAlphaPlot(Int_t i)
|
|---|
| 330 | {
|
|---|
| 331 | if (GetSize() == 0)
|
|---|
| 332 | return NULL;
|
|---|
| 333 |
|
|---|
| 334 | return static_cast<TH1D*>(i==-1 ? fHistAlpha->At(GetSize()/2+1) : fHistAlpha->At(i));
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | // --------------------------------------------------------------------------
|
|---|
| 338 | //
|
|---|
| 339 | // Get i-th hist
|
|---|
| 340 | //
|
|---|
| 341 | const TH1D *MSkyPlot::GetAlphaPlot(Int_t i) const
|
|---|
| 342 | {
|
|---|
| 343 | if (GetSize() == 0)
|
|---|
| 344 | return NULL;
|
|---|
| 345 |
|
|---|
| 346 | return static_cast<TH1D*>(i==-1 ? fHistAlpha->At(GetSize()/2+1) : fHistAlpha->At(i));
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 | void MSkyPlot::ReadCuts(const TString parSCinit="OptSCParametersONOFFThetaRange0_1570mRad.root")
|
|---|
| 351 | {
|
|---|
| 352 |
|
|---|
| 353 | cout << " parameters read from file: " << parSCinit << endl;
|
|---|
| 354 | //--------------------------------
|
|---|
| 355 | // create container for the supercut parameters
|
|---|
| 356 | // and set them to their initial values
|
|---|
| 357 | MSupercuts super;
|
|---|
| 358 |
|
|---|
| 359 | // read the cuts coefficients
|
|---|
| 360 | TFile inparam(parSCinit);
|
|---|
| 361 | super.Read("MSupercuts");
|
|---|
| 362 | inparam.Close();
|
|---|
| 363 | *fLog << "MFindSupercutsONOFF::FindParams; initial values of parameters are taken from file "
|
|---|
| 364 | << parSCinit << endl;
|
|---|
| 365 |
|
|---|
| 366 | TArrayD params = super.GetParameters();
|
|---|
| 367 | TArrayD steps = super.GetStepsizes();
|
|---|
| 368 | // TMP2
|
|---|
| 369 | if (params.GetSize() == steps.GetSize())
|
|---|
| 370 | {
|
|---|
| 371 | *fLog << "SC parameters and Setps are: " << endl;
|
|---|
| 372 | for (Int_t z = 0; z < params.GetSize(); z++)
|
|---|
| 373 | {
|
|---|
| 374 | cout << params[z] << setw(20) << steps[z] << endl;
|
|---|
| 375 | }
|
|---|
| 376 | }
|
|---|
| 377 | // ENDTMP2
|
|---|
| 378 | for (Int_t i=0; i<8; i++)
|
|---|
| 379 | {
|
|---|
| 380 | fLengthUp[i] = params[i];
|
|---|
| 381 | fLengthLo[i] = params[i+8];
|
|---|
| 382 | fWidthUp[i] = params[i+16];
|
|---|
| 383 | fWidthLo[i] = params[i+24];
|
|---|
| 384 | fDistUp[i] = params[i+32];
|
|---|
| 385 | fDistLo[i] = params[i+40];
|
|---|
| 386 | }
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | void MSkyPlot::SetSkyPlot(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t step)
|
|---|
| 390 | {
|
|---|
| 391 | Float_t temp;
|
|---|
| 392 |
|
|---|
| 393 | if (xmax<xmin)
|
|---|
| 394 | {
|
|---|
| 395 | *fLog << warn << "SetSkyPlot: xmax is smaller xmin ... exchanging them." << endl;
|
|---|
| 396 | temp = xmax;
|
|---|
| 397 | xmax = xmin;
|
|---|
| 398 | xmin = temp;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | if (ymax<ymin)
|
|---|
| 402 | {
|
|---|
| 403 | *fLog << warn << "SetSkyPlot: ymax is smaller ymin ... exchanging them." << endl;
|
|---|
| 404 | temp = ymax;
|
|---|
| 405 | ymax = ymin;
|
|---|
| 406 | ymin = temp;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | if (step<0)
|
|---|
| 410 | *fLog << warn << "SetSkyPlot: step<0... taking absolute value." << endl;
|
|---|
| 411 |
|
|---|
| 412 | fBinStepGrid = TMath::Abs(step);
|
|---|
| 413 | fMinXGrid = xmin;
|
|---|
| 414 | fMaxXGrid = xmax;
|
|---|
| 415 | fMinYGrid = ymin;
|
|---|
| 416 | fMaxYGrid = ymax;
|
|---|
| 417 |
|
|---|
| 418 | *fLog << endl << inf << " SetSkyPlot: fMinXGrid, fMaxXGrid, fMinYGrid, fMaxYGrid, fBinStepGrid: " << endl;
|
|---|
| 419 | *fLog << inf << " " << fMinXGrid << ", " << fMaxXGrid << ", " << fMinYGrid << ", "
|
|---|
| 420 | << fMaxYGrid<< ", " << fBinStepGrid << endl;
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | // --------------------------------------------------------------------------
|
|---|
| 424 | //
|
|---|
| 425 | // Set the alpha cut (|alpha|<fAlphaCut) which is use to estimate the
|
|---|
| 426 | // number of excess events
|
|---|
| 427 | //
|
|---|
| 428 | void MSkyPlot::SetAlphaCut(Float_t alpha)
|
|---|
| 429 | {
|
|---|
| 430 | if (alpha<0)
|
|---|
| 431 | *fLog << warn << "Alpha<0... taking absolute value." << endl;
|
|---|
| 432 |
|
|---|
| 433 | fAlphaONMax = TMath::Abs(alpha);
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | // --------------------------------------------------------------------------
|
|---|
| 437 | //
|
|---|
| 438 | // Set the upper and lower limit for the background region in the alpha plot
|
|---|
| 439 | // to estimate the number of background events
|
|---|
| 440 | //
|
|---|
| 441 | void MSkyPlot::SetAlphaBGLimits(Float_t alphalow, Float_t alphaup)
|
|---|
| 442 | {
|
|---|
| 443 | Float_t alphatemp;
|
|---|
| 444 | if (alphalow<0)
|
|---|
| 445 | *fLog << warn << "Alpha<0... taking absolute value." << endl;
|
|---|
| 446 |
|
|---|
| 447 | if (alphaup<0)
|
|---|
| 448 | *fLog << warn << "Alpha<0... taking absolute value." << endl;
|
|---|
| 449 |
|
|---|
| 450 | if (TMath::Abs(alphaup)<TMath::Abs(alphalow)) {
|
|---|
| 451 | *fLog << warn << "AlphaLow > AlphaUp... exchanging limits." << endl;
|
|---|
| 452 | alphatemp = alphaup;
|
|---|
| 453 | alphaup = alphalow;
|
|---|
| 454 | alphalow = alphatemp;
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | fAlphaBgLow = TMath::Abs(alphalow);
|
|---|
| 458 | fAlphaBgUp = TMath::Abs(alphaup);
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | // calculate the values for the cuts:
|
|---|
| 462 | Double_t MSkyPlot::CalcLimit(Double_t *a, Double_t ls, Double_t ls2, Double_t dd2)
|
|---|
| 463 | {
|
|---|
| 464 |
|
|---|
| 465 | Double_t limit = a[0] + a[1] * dd2 +
|
|---|
| 466 | ls * (a[3] + a[4] * dd2) +
|
|---|
| 467 | ls2 * (a[6] + a[7] * dd2);
|
|---|
| 468 |
|
|---|
| 469 | return limit;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | // --------------------------------------------------------------------------
|
|---|
| 473 | //
|
|---|
| 474 | // Set binnings (takes BinningFalseSource) and prepare filling of the
|
|---|
| 475 | // histogram.
|
|---|
| 476 | //
|
|---|
| 477 | // Also search for MTime, MObservatory and MPointingPos
|
|---|
| 478 | //
|
|---|
| 479 | Int_t MSkyPlot::PreProcess(MParList *plist)
|
|---|
| 480 | {
|
|---|
| 481 |
|
|---|
| 482 | *fLog << warn << "entering PreProcess in MSkyPlot::PreProcess" << endl;
|
|---|
| 483 |
|
|---|
| 484 | fGeomCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 485 | if (!fGeomCam)
|
|---|
| 486 | {
|
|---|
| 487 | *fLog << err << "MGeomCam not found... aborting." << endl;
|
|---|
| 488 | return kFALSE;
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | fMm2Deg = fGeomCam->GetConvMm2Deg();
|
|---|
| 492 |
|
|---|
| 493 | fRepDrive = (MReportDrive*)plist->FindObject(AddSerialNumber("MReportDrive"));
|
|---|
| 494 | if (!fRepDrive)
|
|---|
| 495 | *fLog << warn << "MReportDrive not found... could be problem for sky map." << endl;
|
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 | fSrcPosCam = (MSrcPosCam*)plist->FindCreateObj(AddSerialNumber("MSrcPosCam"));
|
|---|
| 499 | if (!fSrcPosCam)
|
|---|
| 500 | *fLog << warn << "MSrcPosCam not found... no sky map." << endl;
|
|---|
| 501 |
|
|---|
| 502 | /*
|
|---|
| 503 | fPntPosCam = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MPntPosCam"));
|
|---|
| 504 | if (!fPntPosCam)
|
|---|
| 505 | *fLog << warn << "MPntPosCam not found... no sky map." << endl;
|
|---|
| 506 | */
|
|---|
| 507 |
|
|---|
| 508 | fPointPos = (MPointingPos*)plist->FindObject(AddSerialNumber("MPointingPos"));
|
|---|
| 509 | if (!fPointPos)
|
|---|
| 510 | *fLog << warn << "MPointingPos not found... no sky map." << endl;
|
|---|
| 511 |
|
|---|
| 512 | fTime = (MTime*)plist->FindObject(AddSerialNumber("MTime"));
|
|---|
| 513 | if (!fTime)
|
|---|
| 514 | *fLog << warn << "MTime not found... could be problem for sky map." << endl;
|
|---|
| 515 |
|
|---|
| 516 | fObservatory = (MObservatory*)plist->FindObject(AddSerialNumber("MObservatory"));
|
|---|
| 517 | if (!fObservatory)
|
|---|
| 518 | *fLog << warn << "MObservatory not found... no sky map." << endl;
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 | fHillas = (MHillas*)plist->FindObject(AddSerialNumber("MHillas"));
|
|---|
| 522 | if (!fHillas)
|
|---|
| 523 | *fLog << err << "MHillas not found... no sky map." << endl;
|
|---|
| 524 |
|
|---|
| 525 | fHillasExt = (MHillasExt*)plist->FindObject(AddSerialNumber("MHillasExt"));
|
|---|
| 526 | if (!fHillasExt)
|
|---|
| 527 | *fLog << err << "MHillasExt not found... no sky map." << endl;
|
|---|
| 528 |
|
|---|
| 529 | fHillasSrc = (MHillasSrc*)plist->FindObject(AddSerialNumber("MHillasSrc"));
|
|---|
| 530 | if (!fHillasSrc)
|
|---|
| 531 | *fLog << err << "MHillasSrc not found... no sky map." << endl;
|
|---|
| 532 |
|
|---|
| 533 | fNewImagePar = (MNewImagePar*)plist->FindObject(AddSerialNumber("MNewImagePar"));
|
|---|
| 534 | if (!fNewImagePar)
|
|---|
| 535 | *fLog << err << "MNewImagePar not found... no sky map." << endl;
|
|---|
| 536 |
|
|---|
| 537 | if(fUseRF)
|
|---|
| 538 | {
|
|---|
| 539 | fHadron = (MHadronness*)plist->FindObject(AddSerialNumber("MHadronness"));
|
|---|
| 540 | if (!fHadron)
|
|---|
| 541 | *fLog << err << "MHadronness not found although specified... no sky map." << endl;
|
|---|
| 542 |
|
|---|
| 543 | *fLog << inf << "Hadronness cut set to : " << fHadrCut << endl;
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | // FIXME: Because the pointing position could change we must check
|
|---|
| 547 | // for the current pointing position and add a offset in the
|
|---|
| 548 | // Fill function!
|
|---|
| 549 |
|
|---|
| 550 | // prepare skyplot
|
|---|
| 551 | fNumStepsX = (int) ((fMaxXGrid - fMinXGrid) / fBinStepGrid + 1.5);
|
|---|
| 552 | fNumStepsY = (int) ((fMaxYGrid - fMinYGrid) / fBinStepGrid + 1.5);
|
|---|
| 553 | fNumalphahist = (int) (fNumStepsX * fNumStepsY + 0.5);
|
|---|
| 554 |
|
|---|
| 555 | *fLog << inf << "SetSkyPlot: fNumStepsX, fNumStepsY, fNumalphahist: "
|
|---|
| 556 | << fNumStepsX << ", " << fNumStepsY << ", " << fNumalphahist << endl;
|
|---|
| 557 |
|
|---|
| 558 | // fHistSignif.SetName("SPSignif2ndOrder");
|
|---|
| 559 | // fHistSignif.SetTitle("Sky Plot of significance (2nd order fit)");
|
|---|
| 560 | fHistSignif.SetBins(fNumStepsX, fMinXGrid-0.5*fBinStepGrid, fMaxXGrid+0.5*fBinStepGrid,
|
|---|
| 561 | fNumStepsY, fMinYGrid-0.5*fBinStepGrid, fMaxYGrid+0.5*fBinStepGrid);
|
|---|
| 562 | fHistSignif.SetFillStyle(4000);
|
|---|
| 563 |
|
|---|
| 564 | // fHistNexcess.SetName("SPNex2ndOrder");
|
|---|
| 565 | // fHistNexcess.SetTitle("Sky Plot of Number of excess events (2nd order fit)");
|
|---|
| 566 | fHistNexcess.SetBins(fNumStepsX, fMinXGrid-0.5*fBinStepGrid, fMaxXGrid+0.5*fBinStepGrid,
|
|---|
| 567 | fNumStepsY, fMinYGrid-0.5*fBinStepGrid, fMaxYGrid+0.5*fBinStepGrid);
|
|---|
| 568 | fHistNexcess.SetFillStyle(4000);
|
|---|
| 569 |
|
|---|
| 570 | // fHistOn.SetName("SPOnCounted");
|
|---|
| 571 | // fHistOn.SetTitle("Sky Plot of ON events (counted)");
|
|---|
| 572 | fHistOn.SetBins(fNumStepsX, fMinXGrid-0.5*fBinStepGrid, fMaxXGrid+0.5*fBinStepGrid,
|
|---|
| 573 | fNumStepsY, fMinYGrid-0.5*fBinStepGrid, fMaxYGrid+0.5*fBinStepGrid);
|
|---|
| 574 | fHistOn.SetFillStyle(4000);
|
|---|
| 575 |
|
|---|
| 576 | //fHistSignifGaus.SetName("SignifDistrib");
|
|---|
| 577 | fHistSignifGaus.SetTitle("Distribution of the significances from the sky plot");
|
|---|
| 578 | fHistSignifGaus.SetBins(100, -10., 10.);
|
|---|
| 579 |
|
|---|
| 580 | // create alpha histograms
|
|---|
| 581 | for (Int_t i=0; i< fNumalphahist; i++)
|
|---|
| 582 | {
|
|---|
| 583 | // temp histogram for an alpha plot
|
|---|
| 584 | TH1D *temp = new TH1D("alphaplot","alphaplot",fNumBinsAlpha,fAlphaLeftEdge,fAlphaRightEdge);
|
|---|
| 585 | temp->SetDirectory(NULL);
|
|---|
| 586 | fHistAlpha->AddAt(temp,i);
|
|---|
| 587 | }
|
|---|
| 588 |
|
|---|
| 589 | fHistAlphaBinWidth = GetAlphaPlot()->GetBinWidth(1);
|
|---|
| 590 | //cout << " (*fHistAlpha)[10].GetBinContent(5) " << (*fHistAlpha)[10].GetBinContent(5) << endl;
|
|---|
| 591 |
|
|---|
| 592 | return kTRUE;
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | // --------------------------------------------------------------------------
|
|---|
| 596 | //
|
|---|
| 597 | // Fill the histogram. For details see the code or the class description
|
|---|
| 598 | //
|
|---|
| 599 | Int_t MSkyPlot::Process()
|
|---|
| 600 | {
|
|---|
| 601 |
|
|---|
| 602 | // *fLog << err << "MPointingPos ENTERING the process" << endl;
|
|---|
| 603 | // *fLog << err << "MPointingPos:: fUseRF " << (int)fUseRF << endl;
|
|---|
| 604 | // check whether MPointingPos comtains something:
|
|---|
| 605 | if (TMath::Abs(fPointPos->GetRa())<1e-3 && TMath::Abs(fPointPos->GetDec())<1e-3)
|
|---|
| 606 | {
|
|---|
| 607 | *fLog << warn << "MPointingPos is not filled ... event skipped" << endl;
|
|---|
| 608 | return kTRUE;
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | // Get RA_0, DEC_0 for the camera center (Tracking MDrive?, can be set from outside)
|
|---|
| 612 | if (fSetCenter==kTRUE)
|
|---|
| 613 | {
|
|---|
| 614 | if (fRepDrive)
|
|---|
| 615 | {
|
|---|
| 616 | fRa0 = fRepDrive->GetRa(); // [h]
|
|---|
| 617 | fDec0 = fRepDrive->GetDec(); // [deg]
|
|---|
| 618 | if (fRa0 < 0. || fRa0 > 24. || fDec0 < -90. || fDec0 > 90. || (fRa0==0 && fDec0==0)) return kTRUE; // temp!, should be changed
|
|---|
| 619 | }
|
|---|
| 620 | else
|
|---|
| 621 | {
|
|---|
| 622 | fRa0 = fPointPos->GetRa();
|
|---|
| 623 | fDec0 = fPointPos->GetDec();
|
|---|
| 624 | }
|
|---|
| 625 | *fLog << inf << "Ra (center) = " << fRa0 << ", Dec = " << fDec0 << endl;
|
|---|
| 626 | fSetCenter=kFALSE;
|
|---|
| 627 | }
|
|---|
| 628 |
|
|---|
| 629 | // some filter cuts:
|
|---|
| 630 | if ( fHillas->GetSize() > fSizeMin && fHillas->GetSize() < fSizeMax && fNewImagePar->GetLeakage1() < fLeakMax)
|
|---|
| 631 | {
|
|---|
| 632 |
|
|---|
| 633 | Double_t xsource, ysource, cosgam, singam, x_0, y_0, xsourcam, ysourcam;
|
|---|
| 634 | Double_t dx, dy, beta, tanbeta, alphapar, distpar;
|
|---|
| 635 | Double_t logsize, lgsize, lgsize2, dist2, hadr;
|
|---|
| 636 | const Double_t log3000n = log(3000.*0.18); // now in phe, thus must shift the offset
|
|---|
| 637 | const Float_t fDistOffset = 0.9;
|
|---|
| 638 |
|
|---|
| 639 | //Get Hadronness if available:
|
|---|
| 640 | if(fUseRF)
|
|---|
| 641 | {
|
|---|
| 642 | hadr=fHadron->GetHadronness();
|
|---|
| 643 | // cout << " will use RF " << hadr << endl;
|
|---|
| 644 | }
|
|---|
| 645 | // Get camera rotation angle
|
|---|
| 646 | Double_t rho = 0;
|
|---|
| 647 | if (fTime && fObservatory && fPointPos)
|
|---|
| 648 | {
|
|---|
| 649 | rho = fPointPos->RotationAngle(*fObservatory, *fTime);
|
|---|
| 650 | //*fLog << inf << " rho = " << rho*180./TMath::Pi() << ", Zd = " << fPointPos->GetZd() <<
|
|---|
| 651 | // ", Az = " << fPointPos->GetAz() << ", Ra = " << fPointPos->GetRa() << ", Dec = " << fPointPos->GetDec() << endl;
|
|---|
| 652 |
|
|---|
| 653 | // => coord. system: xtilde, ytilde with center in RA_0, DEC_0
|
|---|
| 654 |
|
|---|
| 655 | // Get Rot. Angle:
|
|---|
| 656 | cosgam = TMath::Cos(rho);
|
|---|
| 657 | singam = TMath::Sin(rho);
|
|---|
| 658 | // Get x_0, y_0 for RA_0,DEC_0 of the current event
|
|---|
| 659 | }
|
|---|
| 660 | else
|
|---|
| 661 | {
|
|---|
| 662 | // rho = fPointPos->RotationAngle(*fObservatory);
|
|---|
| 663 | Double_t theta, phi, sing, cosg;
|
|---|
| 664 | theta = fPointPos->GetZd()*TMath::Pi()/180.;
|
|---|
| 665 | phi = fPointPos->GetAz()*TMath::Pi()/180.;
|
|---|
| 666 | printf("theta: %5.3f, phi: %5.3f\n", theta*180./4.1415, phi*180./4.1415);
|
|---|
| 667 | fObservatory->RotationAngle(theta, phi, sing, cosg);
|
|---|
| 668 | cosgam = cosg;
|
|---|
| 669 | singam = sing;
|
|---|
| 670 | }
|
|---|
| 671 | // if (fPointPos)
|
|---|
| 672 | // rho = fPointPos->RotationAngle(*fObservatory);
|
|---|
| 673 |
|
|---|
| 674 | /*
|
|---|
| 675 | //TEMP
|
|---|
| 676 | // theta = mcevt->GetTelescopeTheta();
|
|---|
| 677 | Double_t theta, phi, sing, cosg;
|
|---|
| 678 | theta = fPointPos->GetZd()*TMath::Pi()/180.;
|
|---|
| 679 | phi = fPointPos->GetAz()*TMath::Pi()/180.;
|
|---|
| 680 | // printf("theta: %5.3f, phi: %5.3f\n", theta*180./4.1415, phi*180./4.1415);
|
|---|
| 681 | fObservatory->RotationAngle(theta, phi, sing, cosg);
|
|---|
| 682 |
|
|---|
| 683 | // conclusion: diffference in rho = 7 deg
|
|---|
| 684 | // *fLog << "new thetaTel, phiTel, cosal, sinal, rho = " << theta << ", "
|
|---|
| 685 | // << phi << ", " << cosg << ", " << sing << ", " << TMath::ATan2(sing,cosg)*180./TMath::Pi() << endl;
|
|---|
| 686 |
|
|---|
| 687 | Double_t a1 = 0.876627;
|
|---|
| 688 | Double_t a3 = -0.481171;
|
|---|
| 689 | Double_t thetaTel=theta, phiTel=phi;
|
|---|
| 690 |
|
|---|
| 691 | Double_t denom = 1./ sqrt( sin(thetaTel)*sin(phiTel) * sin(thetaTel)*sin(phiTel) +
|
|---|
| 692 | ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) ) *
|
|---|
| 693 | ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) ) );
|
|---|
| 694 | Double_t cosal = - (a3 * sin(thetaTel) + a1 * cos(thetaTel) * cos(phiTel)) * denom;
|
|---|
| 695 | Double_t sinal = a1 * sin(phiTel) * denom;
|
|---|
| 696 |
|
|---|
| 697 | // *fLog << "old thetaTel, phiTel, cosal, sinal, rho = " << thetaTel << ", "
|
|---|
| 698 | // << phiTel << ", " << cosal << ", " << sinal << ", " << TMath::ATan2(sinal,cosal)*180./TMath::Pi() << endl;
|
|---|
| 699 |
|
|---|
| 700 | // END TEMP
|
|---|
| 701 | */
|
|---|
| 702 |
|
|---|
| 703 | // make the center of the plot different from the center of the camera
|
|---|
| 704 | /*
|
|---|
| 705 | x_0 = fPntPosCam->GetX()*fMm2Deg;
|
|---|
| 706 | y_0 = fPntPosCam->GetY()*fMm2Deg;
|
|---|
| 707 | */
|
|---|
| 708 | x_0 = 0.;
|
|---|
| 709 | y_0 = 0.;
|
|---|
| 710 |
|
|---|
| 711 | Int_t index = 0; // index for alpha histograms
|
|---|
| 712 | // loop over xtilde
|
|---|
| 713 | for (Int_t gridy = 0; gridy < fNumStepsY; gridy++)
|
|---|
| 714 | {
|
|---|
| 715 | ysource = fMinYGrid + gridy * fBinStepGrid;
|
|---|
| 716 | // loop over ytilde
|
|---|
| 717 | for (Int_t gridx = 0; gridx < fNumStepsX; gridx++)
|
|---|
| 718 | {
|
|---|
| 719 |
|
|---|
| 720 | xsource = fMinXGrid + gridx * fBinStepGrid;
|
|---|
| 721 |
|
|---|
| 722 | /* derotation : rotate into camera coordinates */
|
|---|
| 723 | /* formel: (x_cam) (cos(gam) -sin(gam)) (xtilde) (x_0)
|
|---|
| 724 | ( ) = - ( ) * ( ) + ( )
|
|---|
| 725 | (y_cam) (sin(gam) cos(gam)) (ytilde) (y_0)
|
|---|
| 726 | */
|
|---|
| 727 | xsourcam = - (cosgam * xsource - singam * ysource) + x_0;
|
|---|
| 728 | ysourcam = - (singam * xsource + cosgam * ysource) + y_0;
|
|---|
| 729 |
|
|---|
| 730 |
|
|---|
| 731 | /* end derotatiom */
|
|---|
| 732 | // xsourcam = xsource;
|
|---|
| 733 | // ysourcam = ysource;
|
|---|
| 734 |
|
|---|
| 735 | /* calculate ALPHA und DIST according to the source position */
|
|---|
| 736 | dx = fHillas->GetMeanX()*fMm2Deg - xsourcam;
|
|---|
| 737 | dy = fHillas->GetMeanY()*fMm2Deg - ysourcam;
|
|---|
| 738 | tanbeta = dy / dx ;
|
|---|
| 739 | beta = TMath::ATan(tanbeta);
|
|---|
| 740 | alphapar = (fHillas->GetDelta() - beta) * 180./ TMath::Pi();
|
|---|
| 741 | distpar = sqrt( dy*dy + dx*dx );
|
|---|
| 742 | if(alphapar > 90.) alphapar -= 180.;
|
|---|
| 743 | if(alphapar < -90.) alphapar += 180.;
|
|---|
| 744 | alphapar = TMath::Abs(alphapar);
|
|---|
| 745 |
|
|---|
| 746 | if(fUseRF)
|
|---|
| 747 | {
|
|---|
| 748 |
|
|---|
| 749 | // cout << " will use RF " << hadr << endl;
|
|---|
| 750 | if(hadr<fHadrCut && distpar < fMaxDist && distpar > fMinDist)
|
|---|
| 751 | {
|
|---|
| 752 | TH1D *hist = GetAlphaPlot(index);
|
|---|
| 753 | hist->Fill(alphapar);
|
|---|
| 754 | }
|
|---|
| 755 | }
|
|---|
| 756 | else
|
|---|
| 757 | {
|
|---|
| 758 | // apply cuts
|
|---|
| 759 | logsize = log(fHillas->GetSize());
|
|---|
| 760 | lgsize = logsize-log3000n;
|
|---|
| 761 | lgsize2 = lgsize*lgsize;
|
|---|
| 762 | dist2 = distpar*distpar - fDistOffset*fDistOffset;
|
|---|
| 763 |
|
|---|
| 764 | if ( (fHillas->GetLength()*fMm2Deg) < CalcLimit(fLengthUp, lgsize, lgsize2, dist2) &&
|
|---|
| 765 | (fHillas->GetLength()*fMm2Deg) > CalcLimit(fLengthLo, lgsize, lgsize2, dist2))
|
|---|
| 766 | if ( (fHillas->GetWidth()*fMm2Deg) < CalcLimit(fWidthUp, lgsize, lgsize2, dist2) &&
|
|---|
| 767 | (fHillas->GetWidth()*fMm2Deg) > CalcLimit(fWidthLo, lgsize, lgsize2, dist2))
|
|---|
| 768 | if ( distpar < CalcLimit(fDistUp, lgsize, lgsize2, dist2) &&
|
|---|
| 769 | distpar > CalcLimit(fDistLo, lgsize, lgsize2, dist2) &&
|
|---|
| 770 | distpar < fMaxDist && distpar > fMinDist)
|
|---|
| 771 | {
|
|---|
| 772 | // gamma candidates!
|
|---|
| 773 | //*fLog << "Length : " << fHillas->GetLength()*fMm2Deg << ", Width : " << fHillas->GetWidth()*fMm2Deg << endl;
|
|---|
| 774 | //*fLog << "distpar: " << distpar << ", Size : " << fHillas->GetSize() << endl;
|
|---|
| 775 | TH1D *hist = GetAlphaPlot(index);
|
|---|
| 776 | hist->Fill(alphapar);
|
|---|
| 777 | }
|
|---|
| 778 | }
|
|---|
| 779 | index++;
|
|---|
| 780 | }
|
|---|
| 781 | }
|
|---|
| 782 | }
|
|---|
| 783 | return kTRUE;
|
|---|
| 784 | }
|
|---|
| 785 |
|
|---|
| 786 | // calculate number of events below alphacut, number of excess events, significance
|
|---|
| 787 |
|
|---|
| 788 | Int_t MSkyPlot::PostProcess()
|
|---|
| 789 | {
|
|---|
| 790 |
|
|---|
| 791 | Int_t nrow, ncolumn;
|
|---|
| 792 | Double_t Non, chisquarefit, numdegfreed, Noff_fit, Nex, Sign;
|
|---|
| 793 | const Int_t onbinsalpha = TMath::Nint(fAlphaONMax/fHistAlphaBinWidth);
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 | // fit function for the background
|
|---|
| 797 | TF1 * fitbgpar = new TF1("fbgpar", "[0]*x*x + [1]", fAlphaBgLow, fAlphaBgUp);
|
|---|
| 798 | fitbgpar->SetLineColor(2);
|
|---|
| 799 |
|
|---|
| 800 | // number degrees of freedom:
|
|---|
| 801 | numdegfreed = (fAlphaBgUp - fAlphaBgLow) / fHistAlphaBinWidth - 2.;
|
|---|
| 802 |
|
|---|
| 803 | int index2 = 0; // index of the TH2F histograms
|
|---|
| 804 |
|
|---|
| 805 | TOrdCollectionIter Next(fHistAlpha);
|
|---|
| 806 | TH1D *alpha_iterator = NULL;
|
|---|
| 807 |
|
|---|
| 808 | fHistNexcess.Reset();
|
|---|
| 809 | fHistOn.Reset();
|
|---|
| 810 | fHistSignif.Reset();
|
|---|
| 811 | fHistSignifGaus.Reset();
|
|---|
| 812 |
|
|---|
| 813 | while ( (alpha_iterator = (TH1D*)Next())) {
|
|---|
| 814 | // find the bin in the 2dim histogram
|
|---|
| 815 | nrow = index2/fHistOn.GetNbinsX() + 1; // row of the histogram (y)
|
|---|
| 816 | ncolumn = index2%fHistOn.GetNbinsX()+1; // column of the histogram (x)
|
|---|
| 817 | //ncolumn = TMath::Nint(fmod(index2,fHistOn.GetNbinsX()))+1; // column of the histogram (x)
|
|---|
| 818 |
|
|---|
| 819 | // number of ON events below fAlphaONMax
|
|---|
| 820 | Non = 0.;
|
|---|
| 821 | for(Int_t i=1; i<=onbinsalpha;i++) Non += (*alpha_iterator).GetBinContent(i);
|
|---|
| 822 |
|
|---|
| 823 | fHistOn.SetBinContent(ncolumn, nrow, Non); // fill in the fHistOn
|
|---|
| 824 |
|
|---|
| 825 | // fit parabola to a background region
|
|---|
| 826 | alpha_iterator->Fit(fitbgpar,"EQRN"); // NWR OK?????????????????????????
|
|---|
| 827 | // get Chi2
|
|---|
| 828 | chisquarefit = fitbgpar->GetChisquare();
|
|---|
| 829 | if (chisquarefit/numdegfreed<2. && chisquarefit/numdegfreed>0.01);
|
|---|
| 830 | else *fLog << warn << "Fit is bad, chi2/ndf = " << chisquarefit/numdegfreed << endl;
|
|---|
| 831 |
|
|---|
| 832 | // estimate Noff from the fit:
|
|---|
| 833 | Noff_fit = (1./3. * (fitbgpar->GetParameter(0)) * TMath::Power(fAlphaONMax,3.) +
|
|---|
| 834 | (fitbgpar->GetParameter(1)) * fAlphaONMax) / fHistAlphaBinWidth;
|
|---|
| 835 |
|
|---|
| 836 | Nex = Non - Noff_fit;
|
|---|
| 837 |
|
|---|
| 838 | fHistNexcess.SetBinContent(ncolumn, nrow, Nex); // fill in the fHistNexcess
|
|---|
| 839 |
|
|---|
| 840 | if (Noff_fit<0.) Sign = 0.;
|
|---|
| 841 | // else Sign = LiMa17(Non,Noff_fit,1.);
|
|---|
| 842 | else Sign = MMath::SignificanceLiMaSigned(Non, Noff_fit, 1.);
|
|---|
| 843 |
|
|---|
| 844 | fHistSignif.SetBinContent(ncolumn, nrow, Sign); // fill in the fHistSignif
|
|---|
| 845 | fHistSignifGaus.Fill(Sign);
|
|---|
| 846 |
|
|---|
| 847 | index2++;
|
|---|
| 848 | }
|
|---|
| 849 |
|
|---|
| 850 | // fit with gaus
|
|---|
| 851 | fHistSignifGaus.Fit("gaus","N");
|
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 | //temp
|
|---|
| 855 | /*
|
|---|
| 856 | Double_t decl, hang;
|
|---|
| 857 | MStarCamTrans mstarc(*fGeomCam, *fObservatory);
|
|---|
| 858 | mstarc.LocToCel(fRepDrive->GetNominalZd(),fRepDrive->GetNominalAz(),decl, hang);
|
|---|
| 859 |
|
|---|
| 860 | *fLog << warn << "MDrive, RA, DEC = " << fRepDrive->GetRa() << ", " << fRepDrive->GetDec() << endl;
|
|---|
| 861 | *fLog << warn << "MStarCamTrans, H angle , DEC = " << hang << ", " << decl << endl;
|
|---|
| 862 | */
|
|---|
| 863 | //endtemp
|
|---|
| 864 |
|
|---|
| 865 |
|
|---|
| 866 | // save alpha plots:
|
|---|
| 867 | // TString stri1 = "alphaplots.root";
|
|---|
| 868 | if(fSaveAlphaPlots==kTRUE) SaveAlphaPlots(fAlphaHName);
|
|---|
| 869 |
|
|---|
| 870 | // save sky plots:
|
|---|
| 871 | // TString stri2 = "skyplots.root";
|
|---|
| 872 | if(fSaveSkyPlots==kTRUE) SaveSkyPlots(fSkyHName);
|
|---|
| 873 |
|
|---|
| 874 | // save nex plot:
|
|---|
| 875 | if(fSaveNexPlot==kTRUE) SaveNexPlot(fNexHName);
|
|---|
| 876 |
|
|---|
| 877 | fHistAlpha->Clear();
|
|---|
| 878 |
|
|---|
| 879 | delete fitbgpar;
|
|---|
| 880 |
|
|---|
| 881 | return kTRUE;
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 |
|
|---|
| 885 | // --------------------------------------------------------------------------
|
|---|
| 886 | //
|
|---|
| 887 | // Get the MAstroCatalog corresponding to fRa, fDec. The limiting magnitude
|
|---|
| 888 | // is set to 9, while the fov is equal to the current fov of the false
|
|---|
| 889 | // source plot.
|
|---|
| 890 | //
|
|---|
| 891 | TObject *MSkyPlot::GetCatalog()
|
|---|
| 892 | {
|
|---|
| 893 | const Double_t maxr = 0.98*TMath::Abs(fHistSignif.GetBinCenter(1));
|
|---|
| 894 |
|
|---|
| 895 | // Create catalog...
|
|---|
| 896 | MAstroCatalog stars;
|
|---|
| 897 | stars.SetLimMag(9);
|
|---|
| 898 | stars.SetGuiActive(kFALSE);
|
|---|
| 899 | stars.SetRadiusFOV(maxr);
|
|---|
| 900 | stars.SetRaDec(fRa*TMath::DegToRad()*15, fDec*TMath::DegToRad());
|
|---|
| 901 | stars.ReadBSC("bsc5.dat");
|
|---|
| 902 |
|
|---|
| 903 | TObject *o = (MAstroCatalog*)stars.Clone();
|
|---|
| 904 | o->SetBit(kCanDelete);
|
|---|
| 905 |
|
|---|
| 906 | return o;
|
|---|
| 907 | }
|
|---|
| 908 |
|
|---|
| 909 | void MSkyPlot::SaveNexPlot(TString nexplotname)
|
|---|
| 910 | {
|
|---|
| 911 | gStyle->SetCanvasBorderMode(0);
|
|---|
| 912 | gStyle->SetCanvasBorderSize(0);
|
|---|
| 913 | gStyle->SetCanvasColor(10);
|
|---|
| 914 | // gStyle->SetPadBorderMode(0);
|
|---|
| 915 | // gStyle->SetPadBorderSize(0);
|
|---|
| 916 | gStyle->SetPadColor(10);
|
|---|
| 917 | gStyle->SetOptFit(0);
|
|---|
| 918 | gStyle->SetOptStat(0);
|
|---|
| 919 | gStyle->SetStatColor(10);
|
|---|
| 920 | gStyle->SetPalette(1);
|
|---|
| 921 | gStyle->SetPadRightMargin(0.16);
|
|---|
| 922 | gStyle->SetPadLeftMargin(0.13);
|
|---|
| 923 |
|
|---|
| 924 | Char_t timet[100];
|
|---|
| 925 |
|
|---|
| 926 | TH2D tmp = fHistNexcess;
|
|---|
| 927 | tmp.SetMaximum(470);
|
|---|
| 928 | tmp.SetMinimum(-90);
|
|---|
| 929 | TCanvas can("SkyPlot","SkyPlot", 0, 0, 800, 400);
|
|---|
| 930 | can.Divide(2,1);
|
|---|
| 931 | can.cd(1);
|
|---|
| 932 | tmp.GetYaxis()->SetTitleOffset(1.3);
|
|---|
| 933 | tmp.Draw("colz");
|
|---|
| 934 | TPaveLabel myname(fMinXGrid-0.5,fMinYGrid-0.4,fMinXGrid+0.3,fMinYGrid-0.2,"by D. Mazin");
|
|---|
| 935 | myname.Draw();
|
|---|
| 936 |
|
|---|
| 937 | can.cd(2);
|
|---|
| 938 | fHistNexcess.SetMaximum(470);
|
|---|
| 939 | fHistNexcess.SetMinimum(-40);
|
|---|
| 940 | fHistNexcess.GetXaxis()->SetTitleOffset(1.3);
|
|---|
| 941 | fHistNexcess.GetYaxis()->SetTitleOffset(1.6);
|
|---|
| 942 | gPad->SetTheta(20);
|
|---|
| 943 | fHistNexcess.Draw("lego2");
|
|---|
| 944 | TLatex tu(0.5,0.8,"elapsed time:");
|
|---|
| 945 | tu.Draw();
|
|---|
| 946 | sprintf(timet,"%.1f min",fElaTime);
|
|---|
| 947 | TLatex tut(0.5,0.7,timet);
|
|---|
| 948 | tut.Draw();
|
|---|
| 949 |
|
|---|
| 950 | can.Print(nexplotname);
|
|---|
| 951 | // can.Print("test.root");
|
|---|
| 952 | }
|
|---|
| 953 |
|
|---|
| 954 | void MSkyPlot::SaveSkyPlots(TString skyplotfilename)
|
|---|
| 955 | {
|
|---|
| 956 |
|
|---|
| 957 | TFile rootfile(skyplotfilename, "RECREATE",
|
|---|
| 958 | "sky plots in some variations");
|
|---|
| 959 | fHistSignif.Write();
|
|---|
| 960 | fHistNexcess.Write();
|
|---|
| 961 | fHistOn.Write();
|
|---|
| 962 | fHistSignif.Write();
|
|---|
| 963 |
|
|---|
| 964 | // from Wolfgang:
|
|---|
| 965 | //--------------------------------------------------------------------
|
|---|
| 966 | // Dec-Hour lines
|
|---|
| 967 | Double_t rho, sinrho, cosrho;
|
|---|
| 968 | Double_t theta, phi, sing, cosg;
|
|---|
| 969 | // do I need it?
|
|---|
| 970 | if (fTime && fObservatory && fPointPos)
|
|---|
| 971 | {
|
|---|
| 972 | rho = fPointPos->RotationAngle(*fObservatory, *fTime);
|
|---|
| 973 | sinrho=TMath::Sin(rho);
|
|---|
| 974 | cosrho=TMath::Cos(rho);
|
|---|
| 975 | }
|
|---|
| 976 |
|
|---|
| 977 | theta = fPointPos->GetZd()*TMath::Pi()/180.;
|
|---|
| 978 | phi = fPointPos->GetAz()*TMath::Pi()/180.;
|
|---|
| 979 | // printf("theta: %5.3f, phi: %5.3f\n", theta*180./4.1415, phi*180./4.1415);
|
|---|
| 980 | fObservatory->RotationAngle(theta, phi, sing, cosg);
|
|---|
| 981 |
|
|---|
| 982 | *fLog << "1: sinrho, cosrho = " << sinrho << ", " << cosrho << endl;
|
|---|
| 983 | *fLog << "2: sinrho, cosrho = " << sing << ", " << cosg << endl;
|
|---|
| 984 | sinrho=sing;
|
|---|
| 985 | cosrho=cosg;
|
|---|
| 986 |
|
|---|
| 987 | Double_t fDistCam = fGeomCam->GetCameraDist() * 1000.0; // [mm]
|
|---|
| 988 | Double_t gridbinning = fGridBinning;
|
|---|
| 989 | Double_t gridfinebin = fGridFineBin;
|
|---|
| 990 | Int_t numgridlines = (Int_t)(4.0/gridbinning);
|
|---|
| 991 | Double_t aberr = 1.07;
|
|---|
| 992 | Double_t mmtodeg = 180.0 / TMath::Pi() / fDistCam ;
|
|---|
| 993 |
|
|---|
| 994 | Double_t declin, hangle; // [deg], [h]
|
|---|
| 995 | MStarCamTrans mstarc(*fGeomCam, *fObservatory);
|
|---|
| 996 | if (fRepDrive) mstarc.LocToCel(fRepDrive->GetNominalZd(),fRepDrive->GetNominalAz(),declin, hangle);
|
|---|
| 997 | else mstarc.LocToCel(theta*180./TMath::Pi(),phi*180./TMath::Pi(),declin, hangle); // NOT GOOD!
|
|---|
| 998 |
|
|---|
| 999 | TLatex *pix;
|
|---|
| 1000 |
|
|---|
| 1001 | Char_t tit[100];
|
|---|
| 1002 | Double_t xtxt;
|
|---|
| 1003 | Double_t ytxt;
|
|---|
| 1004 |
|
|---|
| 1005 | Double_t xlo = -534.0 * mmtodeg;
|
|---|
| 1006 | Double_t xup = 534.0 * mmtodeg;
|
|---|
| 1007 |
|
|---|
| 1008 | Double_t ylo = -534.0 * mmtodeg;
|
|---|
| 1009 | Double_t yup = 534.0 * mmtodeg;
|
|---|
| 1010 |
|
|---|
| 1011 | Double_t xx, yy;
|
|---|
| 1012 |
|
|---|
| 1013 |
|
|---|
| 1014 | // direction for the center of the camera
|
|---|
| 1015 | Double_t dec0 = declin;
|
|---|
| 1016 | Double_t h0 = hangle*360./24.; //deg
|
|---|
| 1017 | // Double_t RaHOffset = fRepDrive->GetRa() - h0;
|
|---|
| 1018 | //trans.LocToCel(theta0, phi0, dec0, h0);
|
|---|
| 1019 |
|
|---|
| 1020 | gStyle->SetOptFit(0);
|
|---|
| 1021 | gStyle->SetOptStat(0);
|
|---|
| 1022 | gStyle->SetPalette(1);
|
|---|
| 1023 | TCanvas *c1 = new TCanvas("SPlotsRaDecLines","SPlotsRaDecLines", 400, 0, 700, 600);
|
|---|
| 1024 | c1->Divide(2,2);
|
|---|
| 1025 | c1->cd(1);
|
|---|
| 1026 | fHistSignif.Draw("colz");
|
|---|
| 1027 | c1->cd(2);
|
|---|
| 1028 | fHistNexcess.Draw("colz");
|
|---|
| 1029 | c1->cd(3);
|
|---|
| 1030 | fHistOn.Draw("colz");
|
|---|
| 1031 | c1->cd(4);
|
|---|
| 1032 | gPad->SetLogy();
|
|---|
| 1033 | fHistSignifGaus.Draw();
|
|---|
| 1034 |
|
|---|
| 1035 | //----- lines for fixed dec ------------------------------------
|
|---|
| 1036 |
|
|---|
| 1037 | const Int_t Ndec = numgridlines;
|
|---|
| 1038 | Double_t dec[Ndec];
|
|---|
| 1039 | Double_t ddec = gridbinning;
|
|---|
| 1040 |
|
|---|
| 1041 | Int_t nh = (Int_t)(4.0/gridfinebin);
|
|---|
| 1042 | const Int_t Nh = nh+1;
|
|---|
| 1043 | Double_t h[Nh];
|
|---|
| 1044 | Double_t dh = gridfinebin/cos(dec0/180.0*3.1415926);
|
|---|
| 1045 | if ( dh > 360.0/((Double_t)(Nh-1)) )
|
|---|
| 1046 | dh = 360.0/((Double_t)(Nh-1));
|
|---|
| 1047 |
|
|---|
| 1048 | // start to copy
|
|---|
| 1049 | for (Int_t j=0; j<Ndec; j++)
|
|---|
| 1050 | {
|
|---|
| 1051 | dec[j] = dec0 + ((Double_t)j)*ddec
|
|---|
| 1052 | - ((Double_t)(Ndec/2)-1.0)*ddec;
|
|---|
| 1053 | }
|
|---|
| 1054 |
|
|---|
| 1055 | for (Int_t k=0; k<Nh; k++)
|
|---|
| 1056 | {
|
|---|
| 1057 | h[k] = h0 + ((Double_t)k)*dh - ((Double_t)(Nh/2)-1.0)*dh;
|
|---|
| 1058 | }
|
|---|
| 1059 |
|
|---|
| 1060 | Double_t xh[Nh];
|
|---|
| 1061 | Double_t yh[Nh];
|
|---|
| 1062 |
|
|---|
| 1063 | for (Int_t j=0; j<Ndec; j++)
|
|---|
| 1064 | {
|
|---|
| 1065 | if (fabs(dec[j]) > 90.0) continue;
|
|---|
| 1066 |
|
|---|
| 1067 | for (Int_t k=0; k<Nh; k++)
|
|---|
| 1068 | {
|
|---|
| 1069 | Double_t hh0 = h0 *24.0/360.0;
|
|---|
| 1070 | Double_t hx = h[k]*24.0/360.0;
|
|---|
| 1071 | mstarc.Cel0CelToCam(dec0, hh0, dec[j], hx,
|
|---|
| 1072 | xx, yy);
|
|---|
| 1073 | xx = xx * mmtodeg * aberr;
|
|---|
| 1074 | yy = yy * mmtodeg * aberr;
|
|---|
| 1075 | // xh[k] = xx * mmtodeg * aberr;
|
|---|
| 1076 | // yh[k] = yy * mmtodeg * aberr;
|
|---|
| 1077 | xh[k] = cosg * xx + sing * yy;
|
|---|
| 1078 | yh[k] =-sing * xx + cosg * yy;
|
|---|
| 1079 | // xh[k] = cosrho * xx + sinrho * yy;
|
|---|
| 1080 | // yh[k] =-sinrho * xx + cosrho * yy;
|
|---|
| 1081 |
|
|---|
| 1082 |
|
|---|
| 1083 | //gLog << "dec0, h0 = " << dec0 << ", " << h0
|
|---|
| 1084 | // << " : dec, h, xh, yh = " << dec[j] << ", "
|
|---|
| 1085 | // << h[k] << "; " << xh[k] << ", " << yh[k] << endl;
|
|---|
| 1086 | }
|
|---|
| 1087 |
|
|---|
| 1088 | // c1->cd(2);
|
|---|
| 1089 | TGraph * graph1 = new TGraph(Nh,xh,yh);
|
|---|
| 1090 | //graph1->SetLineColor(j+1);
|
|---|
| 1091 | graph1->SetLineColor(36);
|
|---|
| 1092 | graph1->SetLineStyle(1);
|
|---|
| 1093 | graph1->SetLineWidth(1);
|
|---|
| 1094 | //graph1->SetMarkerColor(j+1);
|
|---|
| 1095 | graph1->SetMarkerColor(1);
|
|---|
| 1096 | graph1->SetMarkerSize(.2);
|
|---|
| 1097 | graph1->SetMarkerStyle(20);
|
|---|
| 1098 |
|
|---|
| 1099 | c1->cd(1);
|
|---|
| 1100 | graph1->Draw("L");
|
|---|
| 1101 | c1->cd(2);
|
|---|
| 1102 | graph1->Draw("L");
|
|---|
| 1103 | c1->cd(3);
|
|---|
| 1104 | graph1->Draw("L");
|
|---|
| 1105 | //delete graph1;
|
|---|
| 1106 | // graphvec.push_back(*graph1);
|
|---|
| 1107 | // graphvec[j].Draw("L");
|
|---|
| 1108 |
|
|---|
| 1109 | sprintf(tit,"Dec = %6.2f", dec[j]);
|
|---|
| 1110 | xtxt = xlo + (xup-xlo)*0.1;
|
|---|
| 1111 | ytxt = ylo + (yup-ylo)*0.80 - ((Double_t)j) *(yup-ylo)/20.0;
|
|---|
| 1112 | pix = new TLatex(xtxt, ytxt, tit);
|
|---|
| 1113 | pix->SetTextColor(36);
|
|---|
| 1114 | pix->SetTextSize(.03);
|
|---|
| 1115 | //pix->Draw("");
|
|---|
| 1116 | //delete pix;
|
|---|
| 1117 |
|
|---|
| 1118 | }
|
|---|
| 1119 | //stop copy
|
|---|
| 1120 | //----- lines for fixed hour angle ------------------------------------
|
|---|
| 1121 |
|
|---|
| 1122 | Int_t ndec1 = (Int_t)(4.0/gridfinebin);
|
|---|
| 1123 | const Int_t Ndec1 = ndec1;
|
|---|
| 1124 | Double_t dec1[Ndec1];
|
|---|
| 1125 | Double_t ddec1 = gridfinebin;
|
|---|
| 1126 |
|
|---|
| 1127 | const Int_t Nh1 = numgridlines;
|
|---|
| 1128 | Double_t h1[Nh1];
|
|---|
| 1129 | Double_t dh1 = gridbinning/cos(dec0/180.0*3.1415926);
|
|---|
| 1130 | if ( dh1 > 360.0/((Double_t)Nh1) )
|
|---|
| 1131 | dh1 = 360.0/((Double_t)Nh1);
|
|---|
| 1132 |
|
|---|
| 1133 | // start copy
|
|---|
| 1134 | for (Int_t j=0; j<Ndec1; j++)
|
|---|
| 1135 | {
|
|---|
| 1136 | dec1[j] = dec0 + ((Double_t)j)*ddec1
|
|---|
| 1137 | - ((Double_t)(Ndec1/2)-1.0)*ddec1;
|
|---|
| 1138 | }
|
|---|
| 1139 |
|
|---|
| 1140 | for (Int_t k=0; k<Nh1; k++)
|
|---|
| 1141 | {
|
|---|
| 1142 | h1[k] = h0 + ((Double_t)k)*dh1 - ((Double_t)(Nh1/2)-1.0)*dh1;
|
|---|
| 1143 | }
|
|---|
| 1144 |
|
|---|
| 1145 | Double_t xd[Ndec1];
|
|---|
| 1146 | Double_t yd[Ndec1];
|
|---|
| 1147 |
|
|---|
| 1148 | for (Int_t k=0; k<Nh1; k++)
|
|---|
| 1149 | {
|
|---|
| 1150 | Int_t count = 0;
|
|---|
| 1151 | for (Int_t j=0; j<Ndec1; j++)
|
|---|
| 1152 | {
|
|---|
| 1153 | if (fabs(dec1[j]) > 90.0) continue;
|
|---|
| 1154 |
|
|---|
| 1155 | Double_t hh0 = h0 *24.0/360.0;
|
|---|
| 1156 | Double_t hhx = h1[k]*24.0/360.0;
|
|---|
| 1157 | mstarc.Cel0CelToCam(dec0, hh0, dec1[j], hhx,
|
|---|
| 1158 | xx, yy);
|
|---|
| 1159 | // xd[count] = xx * mmtodeg * aberr;
|
|---|
| 1160 | // yd[count] = yy * mmtodeg * aberr;
|
|---|
| 1161 |
|
|---|
| 1162 | xx = xx * mmtodeg * aberr;
|
|---|
| 1163 | yy = yy * mmtodeg * aberr;
|
|---|
| 1164 | xd[count] = cosg * xx + sing * yy;
|
|---|
| 1165 | yd[count] =-sing * xx + cosg * yy;
|
|---|
| 1166 |
|
|---|
| 1167 | //gLog << "dec0, h0 = " << dec0 << ", " << h0
|
|---|
| 1168 | // << " : dec1, h1, xd, yd = " << dec1[j] << ", "
|
|---|
| 1169 | // << h1[k] << "; " << xd[count] << ", " << yd[count] << endl;
|
|---|
| 1170 |
|
|---|
| 1171 | count++;
|
|---|
| 1172 | }
|
|---|
| 1173 |
|
|---|
| 1174 | // c1->cd(2);
|
|---|
| 1175 | TGraph * graph1 = new TGraph(count,xd,yd);
|
|---|
| 1176 | //graph1->SetLineColor(k+1);
|
|---|
| 1177 | graph1->SetLineColor(36);
|
|---|
| 1178 | graph1->SetLineWidth(2);
|
|---|
| 1179 | graph1->SetLineStyle(1);
|
|---|
| 1180 | //graph1->SetMarkerColor(k+1);
|
|---|
| 1181 | graph1->SetMarkerColor(1);
|
|---|
| 1182 | graph1->SetMarkerSize(.2);
|
|---|
| 1183 | graph1->SetMarkerStyle(20);
|
|---|
| 1184 | c1->cd(1);
|
|---|
| 1185 | graph1->Draw("L");
|
|---|
| 1186 | c1->cd(2);
|
|---|
| 1187 | graph1->Draw("L");
|
|---|
| 1188 | c1->cd(3);
|
|---|
| 1189 | graph1->Draw("L");
|
|---|
| 1190 |
|
|---|
| 1191 | sprintf(tit,"RA = %6.2f", fRa0 + (h0 - h1[k]));
|
|---|
| 1192 | Double_t xtxt = xlo + (xup-xlo)*0.75;
|
|---|
| 1193 | Double_t ytxt = ylo + (yup-ylo)*0.80 - ((Double_t)k) *(yup-ylo)/20.0;
|
|---|
| 1194 | pix = new TLatex(xtxt, ytxt, tit);
|
|---|
| 1195 | pix->SetTextColor(36);
|
|---|
| 1196 | pix->SetTextSize(.03);
|
|---|
| 1197 | //pix->Draw("");
|
|---|
| 1198 | //delete pix;
|
|---|
| 1199 |
|
|---|
| 1200 | }
|
|---|
| 1201 |
|
|---|
| 1202 | // c1->cd(2);
|
|---|
| 1203 | sprintf(tit,"Dec0 = %6.2f [deg] Ra0 = %6.2f [h]", dec0, fRa0);
|
|---|
| 1204 | xtxt = xlo + (xup-xlo)*0.05 + 0.80;
|
|---|
| 1205 | ytxt = ylo + (yup-ylo)*0.75;
|
|---|
| 1206 | pix = new TLatex(xtxt, ytxt, tit);
|
|---|
| 1207 | pix->SetTextColor(1);
|
|---|
| 1208 | pix->SetTextSize(.05);
|
|---|
| 1209 | c1->cd(1);
|
|---|
| 1210 | pix->Draw("");
|
|---|
| 1211 | c1->cd(2);
|
|---|
| 1212 | pix->Draw("");
|
|---|
| 1213 | c1->cd(3);
|
|---|
| 1214 | pix->Draw("");
|
|---|
| 1215 | //delete pix;
|
|---|
| 1216 |
|
|---|
| 1217 | c1->Write();
|
|---|
| 1218 | // we suppose that the {skyplotfilename} ends with .root
|
|---|
| 1219 | Int_t sizeofout = skyplotfilename.Sizeof();
|
|---|
| 1220 | TString outps = skyplotfilename.Remove(sizeofout-5,5) + "ps";
|
|---|
| 1221 | c1->Print(outps); // temporary!!!!!
|
|---|
| 1222 |
|
|---|
| 1223 | TCanvas *c2 = new TCanvas("SkyPlotsWithRaDecLines","SkyPlotsWithRaDecLines", 0, 0, 300, 600);
|
|---|
| 1224 | c2->Divide(1,2);
|
|---|
| 1225 | c2->SetBorderMode(0);
|
|---|
| 1226 | c2->cd(1);
|
|---|
| 1227 | fHistSignif.Draw("colz");
|
|---|
| 1228 | c2->cd(2);
|
|---|
| 1229 | fHistNexcess.Draw("colz");
|
|---|
| 1230 | c2->Write();
|
|---|
| 1231 |
|
|---|
| 1232 | rootfile.Close();
|
|---|
| 1233 | delete c1;
|
|---|
| 1234 | delete c2;
|
|---|
| 1235 | delete pix;
|
|---|
| 1236 |
|
|---|
| 1237 | }
|
|---|
| 1238 |
|
|---|
| 1239 | void MSkyPlot::SaveAlphaPlots(const TString alphaplotfilename)
|
|---|
| 1240 | {
|
|---|
| 1241 | TFile rootfile(alphaplotfilename, "RECREATE",
|
|---|
| 1242 | "all the alpha plots");
|
|---|
| 1243 |
|
|---|
| 1244 | int index = 0; // index of the TH2F histograms
|
|---|
| 1245 | Char_t strtitle[100];
|
|---|
| 1246 | Char_t strname[100];
|
|---|
| 1247 | Float_t xpos, ypos, signif, nex;
|
|---|
| 1248 | Int_t nrow, ncolumn, non;
|
|---|
| 1249 |
|
|---|
| 1250 | TH1D *alpha_iterator = NULL;
|
|---|
| 1251 | TOrdCollectionIter Next(fHistAlpha);
|
|---|
| 1252 |
|
|---|
| 1253 | while( (alpha_iterator = (TH1D*)Next())) {
|
|---|
| 1254 |
|
|---|
| 1255 | nrow = index/fHistOn.GetNbinsX() + 1; // row of the histogram (y)
|
|---|
| 1256 | //ncolumn = TMath::Nint(fmod(index,fHistOn.GetNbinsX()))+1; // column of the histogram (x)
|
|---|
| 1257 | ncolumn = index%fHistOn.GetNbinsX()+1; // column of the histogram (x)
|
|---|
| 1258 | xpos = fMinXGrid + fBinStepGrid*(ncolumn-1);
|
|---|
| 1259 | ypos = fMinYGrid + fBinStepGrid*(nrow-1);
|
|---|
| 1260 | non = TMath::Nint(fHistOn.GetBinContent(ncolumn,nrow));
|
|---|
| 1261 | nex = fHistNexcess.GetBinContent(ncolumn,nrow);
|
|---|
| 1262 | signif = fHistSignif.GetBinContent(ncolumn,nrow);
|
|---|
| 1263 |
|
|---|
| 1264 | sprintf(strname,"AlphaPlotX%.2fY%.2f", xpos, ypos);
|
|---|
| 1265 | sprintf(strtitle,"for x= %.2f deg, y= %.2f deg: S= %.2f sigma, Nex= %.2f, Non= %d",
|
|---|
| 1266 | xpos, ypos, signif, nex, non);
|
|---|
| 1267 |
|
|---|
| 1268 | alpha_iterator->SetName(strname);
|
|---|
| 1269 | alpha_iterator->SetTitle(strtitle);
|
|---|
| 1270 | alpha_iterator->Write();
|
|---|
| 1271 | index++;
|
|---|
| 1272 | }
|
|---|
| 1273 |
|
|---|
| 1274 | rootfile.Close();
|
|---|
| 1275 | }
|
|---|
| 1276 |
|
|---|
| 1277 |
|
|---|
| 1278 | // --------------------------------------------------------------------------
|
|---|
| 1279 | //
|
|---|
| 1280 | // This is a preliminary implementation of a alpha-fit procedure for
|
|---|
| 1281 | // all possible source positions. It will be moved into its own
|
|---|
| 1282 | // more powerfull class soon.
|
|---|
| 1283 | //
|
|---|
| 1284 | // The fit function is "gaus(0)+pol2(3)" which is equivalent to:
|
|---|
| 1285 | // [0]*exp(-0.5*((x-[1])/[2])^2) + [3] + [4]*x + [5]*x^2
|
|---|
| 1286 | // or
|
|---|
| 1287 | // A*exp(-0.5*((x-mu)/sigma)^2) + a + b*x + c*x^2
|
|---|
| 1288 | //
|
|---|
| 1289 | // Parameter [1] is fixed to 0 while the alpha peak should be
|
|---|
| 1290 | // symmetric around alpha=0.
|
|---|
| 1291 | //
|
|---|
| 1292 | // Parameter [4] is fixed to 0 because the first derivative at
|
|---|
| 1293 | // alpha=0 should be 0, too.
|
|---|
| 1294 | //
|
|---|
| 1295 | // In a first step the background is fitted between bgmin and bgmax,
|
|---|
| 1296 | // while the parameters [0]=0 and [2]=1 are fixed.
|
|---|
| 1297 | //
|
|---|
| 1298 | // In a second step the signal region (alpha<sigmax) is fittet using
|
|---|
| 1299 | // the whole function with parameters [1], [3], [4] and [5] fixed.
|
|---|
| 1300 | //
|
|---|
| 1301 | // The number of excess and background events are calculated as
|
|---|
| 1302 | // s = int(0, sigint, gaus(0)+pol2(3))
|
|---|
| 1303 | // b = int(0, sigint, pol2(3))
|
|---|
| 1304 | //
|
|---|
| 1305 | // The Significance is calculated using the Significance() member
|
|---|
| 1306 | // function.
|
|---|
| 1307 | //
|
|---|
| 1308 |
|
|---|
| 1309 | // I might need this
|
|---|
| 1310 | /*
|
|---|
| 1311 | TCanvas *c=new TCanvas;
|
|---|
| 1312 |
|
|---|
| 1313 | gStyle->SetPalette(1, 0);
|
|---|
| 1314 |
|
|---|
| 1315 | c->Divide(3,2, 0, 0);
|
|---|
| 1316 | c->cd(1);
|
|---|
| 1317 | gPad->SetBorderMode(0);
|
|---|
| 1318 | hists->Draw("colz");
|
|---|
| 1319 | hists->SetBit(kCanDelete);
|
|---|
| 1320 | catalog->Draw("mirror same");
|
|---|
| 1321 | c->cd(2);
|
|---|
| 1322 | gPad->SetBorderMode(0);
|
|---|
| 1323 | hist->Draw("colz");
|
|---|
| 1324 | hist->SetBit(kCanDelete);
|
|---|
| 1325 | catalog->Draw("mirror same");
|
|---|
| 1326 | c->cd(3);
|
|---|
| 1327 | gPad->SetBorderMode(0);
|
|---|
| 1328 | histb->Draw("colz");
|
|---|
| 1329 | histb->SetBit(kCanDelete);
|
|---|
| 1330 | catalog->Draw("mirror same");
|
|---|
| 1331 | c->cd(4);
|
|---|
| 1332 | gPad->Divide(1,3, 0, 0);
|
|---|
| 1333 | TVirtualPad *p=gPad;
|
|---|
| 1334 | p->SetBorderMode(0);
|
|---|
| 1335 | p->cd(1);
|
|---|
| 1336 | gPad->SetBorderMode(0);
|
|---|
| 1337 | h0b.DrawCopy();
|
|---|
| 1338 | h0a.DrawCopy("same");
|
|---|
| 1339 | p->cd(2);
|
|---|
| 1340 | gPad->SetBorderMode(0);
|
|---|
| 1341 | h3.DrawCopy();
|
|---|
| 1342 | p->cd(3);
|
|---|
| 1343 | gPad->SetBorderMode(0);
|
|---|
| 1344 | h2.DrawCopy();
|
|---|
| 1345 |
|
|---|
| 1346 | */
|
|---|