| 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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MCT1SupercutsCalc //
|
|---|
| 28 | // //
|
|---|
| 29 | // this class calculates the hadronness for the supercuts //
|
|---|
| 30 | // the parameters of the supercuts are taken //
|
|---|
| 31 | // from the container MCT1Supercuts //
|
|---|
| 32 | // //
|
|---|
| 33 | // //
|
|---|
| 34 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 35 | #include "MCT1SupercutsCalc.h"
|
|---|
| 36 |
|
|---|
| 37 | #include <math.h>
|
|---|
| 38 | #include <fstream>
|
|---|
| 39 |
|
|---|
| 40 | #include "TFile.h"
|
|---|
| 41 | #include "TArrayD.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MParList.h"
|
|---|
| 44 | #include "MHillasExt.h"
|
|---|
| 45 | #include "MHillasSrc.h"
|
|---|
| 46 | #include "MMcEvt.hxx"
|
|---|
| 47 | #include "MCerPhotEvt.h"
|
|---|
| 48 | #include "MGeomCam.h"
|
|---|
| 49 | #include "MHadronness.h"
|
|---|
| 50 | #include "MHMatrix.h"
|
|---|
| 51 | #include "MCT1Supercuts.h"
|
|---|
| 52 |
|
|---|
| 53 | #include "MLog.h"
|
|---|
| 54 | #include "MLogManip.h"
|
|---|
| 55 |
|
|---|
| 56 | ClassImp(MCT1SupercutsCalc);
|
|---|
| 57 |
|
|---|
| 58 | using namespace std;
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | // --------------------------------------------------------------------------
|
|---|
| 62 | //
|
|---|
| 63 | // constructor
|
|---|
| 64 | //
|
|---|
| 65 |
|
|---|
| 66 | MCT1SupercutsCalc::MCT1SupercutsCalc(const char *hilname,
|
|---|
| 67 | const char *hilsrcname, const char *name, const char *title)
|
|---|
| 68 | : fHadronnessName("MHadronness"), fHilName(hilname), fHilSrcName(hilsrcname),
|
|---|
| 69 | fSuperName("MCT1Supercuts")
|
|---|
| 70 | {
|
|---|
| 71 | fName = name ? name : "MCT1SupercutsCalc";
|
|---|
| 72 | fTitle = title ? title : "Class to evaluate the Supercuts";
|
|---|
| 73 |
|
|---|
| 74 | fMatrix = NULL;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | // --------------------------------------------------------------------------
|
|---|
| 78 | //
|
|---|
| 79 | Int_t MCT1SupercutsCalc::PreProcess(MParList *pList)
|
|---|
| 80 | {
|
|---|
| 81 | MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 82 | if (!cam)
|
|---|
| 83 | {
|
|---|
| 84 | *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
|
|---|
| 85 | return kFALSE;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | fMm2Deg = cam->GetConvMm2Deg();
|
|---|
| 89 |
|
|---|
| 90 | fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
|
|---|
| 91 | if (!fHadronness)
|
|---|
| 92 | {
|
|---|
| 93 | *fLog << err << fHadronnessName << " [MHadronness] not found... aborting." << endl;
|
|---|
| 94 | return kFALSE;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | fSuper = (MCT1Supercuts*)pList->FindObject(fSuperName, "MCT1Supercuts");
|
|---|
| 98 | if (!fSuper)
|
|---|
| 99 | {
|
|---|
| 100 | *fLog << err << fSuperName << " [MCT1Supercuts] not found... aborting." << endl;
|
|---|
| 101 | return kFALSE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | if (fMatrix)
|
|---|
| 106 | return kTRUE;
|
|---|
| 107 |
|
|---|
| 108 | //-----------------------------------------------------------
|
|---|
| 109 | fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
|
|---|
| 110 | if (!fHil)
|
|---|
| 111 | {
|
|---|
| 112 | *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
|
|---|
| 113 | return kFALSE;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
|
|---|
| 117 | if (!fHilSrc)
|
|---|
| 118 | {
|
|---|
| 119 | *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
|
|---|
| 120 | return kFALSE;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 124 | if (!fMcEvt)
|
|---|
| 125 | {
|
|---|
| 126 | *fLog << err << "MMcEvt not found... aborting." << endl;
|
|---|
| 127 | return kFALSE;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | return kTRUE;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | // --------------------------------------------------------------------------
|
|---|
| 135 | //
|
|---|
| 136 | // Calculation of upper and lower limits
|
|---|
| 137 | //
|
|---|
| 138 | Double_t MCT1SupercutsCalc::CtsMCut(const Double_t* a, Double_t ls, Double_t ct,
|
|---|
| 139 | Double_t ls2, Double_t dd2) const
|
|---|
| 140 | {
|
|---|
| 141 | // define cut-function
|
|---|
| 142 | //
|
|---|
| 143 | // dNOMLOGSIZE = 4.1 (=log(60.0)
|
|---|
| 144 | // dNOMCOSZA = 1.0
|
|---|
| 145 | //
|
|---|
| 146 | // a: array of cut parameters
|
|---|
| 147 | // ls: log(SIZE) - dNOMLOGSIZE
|
|---|
| 148 | // ls2: ls^2
|
|---|
| 149 | // ct: Cos(ZA.) - dNOMCOSZA
|
|---|
| 150 | // dd2: DIST^2
|
|---|
| 151 | const Double_t limit =
|
|---|
| 152 | a[0] + a[1] * dd2 + a[2] * ct +
|
|---|
| 153 | ls * (a[3] + a[4] * dd2 + a[5] * ct) +
|
|---|
| 154 | ls2 * (a[6] + a[7] * dd2);
|
|---|
| 155 |
|
|---|
| 156 | //*fLog << "MCT1SupercutsCalc::CtsMCut; *a = "
|
|---|
| 157 | // << *a << ", " << *(a+1) << ", " << *(a+2) << ", "
|
|---|
| 158 | // << *(a+3) << ", " << *(a+4) << ", " << *(a+5) << ", "
|
|---|
| 159 | // << *(a+6) << ", " << *(a+7) << endl;
|
|---|
| 160 |
|
|---|
| 161 | //*fLog << "MCT1SupercutsCalc::CtsMCut; ls, ls2, ct, dd2, limit = " << ls
|
|---|
| 162 | // << ", " << ls2 << ", " << ct << ", " << dd2 << ", "
|
|---|
| 163 | // << limit << endl;
|
|---|
| 164 |
|
|---|
| 165 | return limit;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | // --------------------------------------------------------------------------
|
|---|
| 169 | //
|
|---|
| 170 | // Returns the mapped value from the Matrix
|
|---|
| 171 | //
|
|---|
| 172 | Double_t MCT1SupercutsCalc::GetVal(Int_t i) const
|
|---|
| 173 | {
|
|---|
| 174 | return (*fMatrix)[fMap[i]];
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | // --------------------------------------------------------------------------
|
|---|
| 178 | //
|
|---|
| 179 | // You can use this function if you want to use a MHMatrix instead of the
|
|---|
| 180 | // given containers. This function adds all necessary columns to the
|
|---|
| 181 | // given matrix. Afterward you should fill the matrix with the corresponding
|
|---|
| 182 | // data (eg from a file by using MHMatrix::Fill). If you now loop
|
|---|
| 183 | // through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
|
|---|
| 184 | // will take the values from the matrix instead of the containers.
|
|---|
| 185 | //
|
|---|
| 186 | void MCT1SupercutsCalc::InitMapping(MHMatrix *mat)
|
|---|
| 187 | {
|
|---|
| 188 | if (fMatrix)
|
|---|
| 189 | return;
|
|---|
| 190 |
|
|---|
| 191 | fMatrix = mat;
|
|---|
| 192 |
|
|---|
| 193 | fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
|
|---|
| 194 | fMap[1] = fMatrix->AddColumn("MHillas.fWidth");
|
|---|
| 195 | fMap[2] = fMatrix->AddColumn("MHillas.fLength");
|
|---|
| 196 | fMap[3] = fMatrix->AddColumn("MHillas.fSize");
|
|---|
| 197 | fMap[4] = fMatrix->AddColumn("MHillas.fMeanX");
|
|---|
| 198 | fMap[5] = fMatrix->AddColumn("MHillas.fMeanY");
|
|---|
| 199 | fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist");
|
|---|
| 200 | fMap[7] = fMatrix->AddColumn("fabs(MHillasSrc.fAlpha)");
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | // ---------------------------------------------------------------------------
|
|---|
| 204 | //
|
|---|
| 205 | // Evaluate dynamical supercuts for CT1 Mkn421 2001 (Daniel Kranich)
|
|---|
| 206 | // optimized for mkn 421 2001 data
|
|---|
| 207 | //
|
|---|
| 208 | // set hadronness to 0.25 if cuts are fullfilled
|
|---|
| 209 | // 0.75 otherwise
|
|---|
| 210 | //
|
|---|
| 211 | Int_t MCT1SupercutsCalc::Process()
|
|---|
| 212 | {
|
|---|
| 213 | const Double_t kNomLogSize = 4.1;
|
|---|
| 214 | const Double_t kNomCosZA = 1.0;
|
|---|
| 215 |
|
|---|
| 216 | const Double_t theta = fMatrix ? GetVal(0) : fMcEvt->GetTelescopeTheta();
|
|---|
| 217 | const Double_t width0 = fMatrix ? GetVal(1) : fHil->GetWidth();
|
|---|
| 218 | const Double_t length0 = fMatrix ? GetVal(2) : fHil->GetLength();
|
|---|
| 219 | const Double_t size = fMatrix ? GetVal(3) : fHil->GetSize();
|
|---|
| 220 | const Double_t meanx = fMatrix ? GetVal(4) : fHil->GetMeanX();
|
|---|
| 221 | const Double_t meany = fMatrix ? GetVal(5) : fHil->GetMeanY();
|
|---|
| 222 | const Double_t dist0 = fMatrix ? GetVal(6) : fHilSrc->GetDist();
|
|---|
| 223 |
|
|---|
| 224 | const Double_t newdist = dist0 * fMm2Deg;
|
|---|
| 225 |
|
|---|
| 226 | const Double_t dist2 = meanx*meanx + meany*meany;
|
|---|
| 227 | const Double_t dist = sqrt(dist2) * fMm2Deg;
|
|---|
| 228 | const Double_t dd2 = dist*dist;
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 | const Double_t dmls = log(size) - kNomLogSize;
|
|---|
| 232 | const Double_t dmls2 = dmls * dmls;
|
|---|
| 233 |
|
|---|
| 234 | const Double_t dmcza = cos(theta) - kNomCosZA;
|
|---|
| 235 |
|
|---|
| 236 | const Double_t length = length0 * fMm2Deg;
|
|---|
| 237 | const Double_t width = width0 * fMm2Deg;
|
|---|
| 238 |
|
|---|
| 239 | if (newdist < 1.05 &&
|
|---|
| 240 | newdist < CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 241 | newdist > CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 242 | dist < 1.05 &&
|
|---|
| 243 | length < CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 244 | length > CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 245 | width < CtsMCut (fSuper->GetWidthUp(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 246 | width > CtsMCut (fSuper->GetWidthLo(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 247 | //asym < CtsMCut (fSuper->GetAsymUp(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 248 | //asym > CtsMCut (fSuper->GetAsymLo(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 249 | dist < CtsMCut (fSuper->GetDistUp(), dmls, dmcza, dmls2, dd2) &&
|
|---|
| 250 | dist > CtsMCut (fSuper->GetDistLo(), dmls, dmcza, dmls2, dd2) )
|
|---|
| 251 | fHadronness->SetHadronness(0.25);
|
|---|
| 252 | else
|
|---|
| 253 | fHadronness->SetHadronness(0.75);
|
|---|
| 254 |
|
|---|
| 255 | fHadronness->SetReadyToSave();
|
|---|
| 256 |
|
|---|
| 257 | return kTRUE;
|
|---|
| 258 | }
|
|---|