| 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 | !   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2000-2003 | 
|---|
| 22 | ! | 
|---|
| 23 | ! | 
|---|
| 24 | \* ======================================================================== */ | 
|---|
| 25 |  | 
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 27 | // | 
|---|
| 28 | //  MFCT1SelStandard | 
|---|
| 29 | // | 
|---|
| 30 | //  This is a class to evaluate the Standard Cuts | 
|---|
| 31 | // | 
|---|
| 32 | //  WHAT ARE THE STANDARD CUTS?                                                                       // | 
|---|
| 33 | // | 
|---|
| 34 | //  to be called after the calculation of the image parameters | 
|---|
| 35 | //               before the g/h separation | 
|---|
| 36 | // | 
|---|
| 37 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 38 |  | 
|---|
| 39 | #include "MFCT1SelStandard.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MParList.h" | 
|---|
| 42 |  | 
|---|
| 43 | #include "MMcEvt.hxx" | 
|---|
| 44 |  | 
|---|
| 45 | #include "MGeomPix.h" | 
|---|
| 46 | #include "MGeomCam.h" | 
|---|
| 47 |  | 
|---|
| 48 | #include "MCerPhotEvt.h" | 
|---|
| 49 |  | 
|---|
| 50 | #include "MLog.h" | 
|---|
| 51 | #include "MLogManip.h" | 
|---|
| 52 |  | 
|---|
| 53 | #include "MHillas.h" | 
|---|
| 54 | #include "MHillasExt.h" | 
|---|
| 55 | #include "MHillasSrc.h" | 
|---|
| 56 | #include "MNewImagePar.h" | 
|---|
| 57 |  | 
|---|
| 58 | ClassImp(MFCT1SelStandard); | 
|---|
| 59 |  | 
|---|
| 60 | // -------------------------------------------------------------------------- | 
|---|
| 61 | // | 
|---|
| 62 | // Default constructor. | 
|---|
| 63 | // | 
|---|
| 64 | MFCT1SelStandard::MFCT1SelStandard(const char *hilsrcname, | 
|---|
| 65 | const char *name, const char *title) | 
|---|
| 66 | : fHilName("MHillas"), fHilSrcName(hilsrcname), fImgParName("MNewImagePar") | 
|---|
| 67 | { | 
|---|
| 68 | fName  = name  ? name  : "MFCT1SelStandard"; | 
|---|
| 69 | fTitle = title ? title : "Class to evaluate the Standard Cuts"; | 
|---|
| 70 |  | 
|---|
| 71 | // default values of cuts | 
|---|
| 72 | SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0); | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | // -------------------------------------------------------------------------- | 
|---|
| 76 | // | 
|---|
| 77 | // Set the values for the cuts | 
|---|
| 78 | // | 
|---|
| 79 | // | 
|---|
| 80 | void MFCT1SelStandard::SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin, | 
|---|
| 81 | Float_t sizemin, Float_t distmin, Float_t distmax, | 
|---|
| 82 | Float_t lengthmin, Float_t widthmin) | 
|---|
| 83 | { | 
|---|
| 84 | fUsedPixelsMax = usedpixelsmax; | 
|---|
| 85 | fCorePixelsMin = corepixelsmin; | 
|---|
| 86 | fSizeMin       = sizemin; | 
|---|
| 87 | fDistMin       = distmin; | 
|---|
| 88 | fDistMax       = distmax; | 
|---|
| 89 | fLengthMin     = lengthmin; | 
|---|
| 90 | fWidthMin      = widthmin; | 
|---|
| 91 |  | 
|---|
| 92 | *fLog << inf << "MFCT1SelStandard cut values : fUsedPixelsMax, fCorePixelsMin = "; | 
|---|
| 93 | *fLog << fUsedPixelsMax << ",  " << fCorePixelsMin << endl; | 
|---|
| 94 | *fLog << inf << "     fSizeMin, fDistMin, fDistMax = " << fSizeMin ; | 
|---|
| 95 | *fLog << ",  " << fDistMin << ",  " << fDistMax << endl; | 
|---|
| 96 | *fLog << inf << "     fLengthMin, fWidthMin = " << fLengthMin ; | 
|---|
| 97 | *fLog << ",  " << fWidthMin << endl; | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | // -------------------------------------------------------------------------- | 
|---|
| 101 | // | 
|---|
| 102 | // MISSING | 
|---|
| 103 | // | 
|---|
| 104 | Bool_t MFCT1SelStandard::PreProcess(MParList *pList) | 
|---|
| 105 | { | 
|---|
| 106 | fHil = (MHillas*)pList->FindObject(fHilName, "MHillas"); | 
|---|
| 107 | if (!fHil) | 
|---|
| 108 | { | 
|---|
| 109 | *fLog << err << fHilName << " [MHillas] not found... aborting." << endl; | 
|---|
| 110 | return kFALSE; | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|
| 113 | fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc"); | 
|---|
| 114 | if (!fHilSrc) | 
|---|
| 115 | { | 
|---|
| 116 | *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl; | 
|---|
| 117 | return kFALSE; | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | fNewImgPar = (MNewImagePar*)pList->FindObject(fImgParName, "MNewImagePar"); | 
|---|
| 121 | if (!fNewImgPar) | 
|---|
| 122 | { | 
|---|
| 123 | *fLog << err << fImgParName << " [MNewImagePar] not found... aborting." << endl; | 
|---|
| 124 | return kFALSE; | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam"); | 
|---|
| 128 | if (!cam) | 
|---|
| 129 | { | 
|---|
| 130 | *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl; | 
|---|
| 131 | return kFALSE; | 
|---|
| 132 | } | 
|---|
| 133 |  | 
|---|
| 134 | fMm2Deg = cam->GetConvMm2Deg(); | 
|---|
| 135 |  | 
|---|
| 136 | memset(fCut, 0, sizeof(fCut)); | 
|---|
| 137 |  | 
|---|
| 138 | return kTRUE; | 
|---|
| 139 | } | 
|---|
| 140 |  | 
|---|
| 141 | // -------------------------------------------------------------------------- | 
|---|
| 142 | // | 
|---|
| 143 | // Evaluate standard cuts | 
|---|
| 144 | // | 
|---|
| 145 | // if selections are fulfilled set fResult = kTRUE; | 
|---|
| 146 | // | 
|---|
| 147 | // | 
|---|
| 148 | Bool_t MFCT1SelStandard::Process() | 
|---|
| 149 | { | 
|---|
| 150 | const Double_t length     = fHil->GetLength() * fMm2Deg; | 
|---|
| 151 | const Double_t width      = fHil->GetWidth()  * fMm2Deg; | 
|---|
| 152 | const Double_t dist       = fHilSrc->GetDist()* fMm2Deg; | 
|---|
| 153 | //const Double_t delta      = fHil->GetDelta()  * kRad2Deg; | 
|---|
| 154 | const Double_t size       = fHil->GetSize(); | 
|---|
| 155 | const Int_t numusedpixels = fNewImgPar->GetNumUsedPixels(); | 
|---|
| 156 | const Int_t numcorepixels = fNewImgPar->GetNumCorePixels(); | 
|---|
| 157 |  | 
|---|
| 158 | Int_t rc = 0; | 
|---|
| 159 | fResult  = kFALSE; | 
|---|
| 160 |  | 
|---|
| 161 | if ( numusedpixels >= fUsedPixelsMax  ||  numcorepixels <= fCorePixelsMin ) | 
|---|
| 162 | { | 
|---|
| 163 | rc = 1; | 
|---|
| 164 | fResult = kTRUE; | 
|---|
| 165 | } | 
|---|
| 166 | else if ( size <= fSizeMin ) | 
|---|
| 167 | { | 
|---|
| 168 | rc = 2; | 
|---|
| 169 | fResult = kTRUE; | 
|---|
| 170 | } | 
|---|
| 171 | else if ( dist< fDistMin   ||  dist > fDistMax ) | 
|---|
| 172 | { | 
|---|
| 173 | rc = 3; | 
|---|
| 174 | fResult = kTRUE; | 
|---|
| 175 | } | 
|---|
| 176 | else if ( length <= fLengthMin   ||  width <= fWidthMin ) | 
|---|
| 177 | { | 
|---|
| 178 | rc = 4; | 
|---|
| 179 | fResult = kTRUE; | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | fCut[rc]++; | 
|---|
| 183 |  | 
|---|
| 184 | return kTRUE; | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | // -------------------------------------------------------------------------- | 
|---|
| 188 | // | 
|---|
| 189 | //  Prints some statistics about the Standard selections. | 
|---|
| 190 | // | 
|---|
| 191 | Bool_t MFCT1SelStandard::PostProcess() | 
|---|
| 192 | { | 
|---|
| 193 | if (GetNumExecutions()==0) | 
|---|
| 194 | return kTRUE; | 
|---|
| 195 |  | 
|---|
| 196 | *fLog << inf << endl; | 
|---|
| 197 | *fLog << GetDescriptor() << " execution statistics:" << endl; | 
|---|
| 198 | *fLog << dec << setfill(' '); | 
|---|
| 199 | *fLog << " " << setw(7) << fCut[1] << " (" << setw(3); | 
|---|
| 200 | *fLog << (int)(fCut[1]*100/GetNumExecutions()) ; | 
|---|
| 201 | *fLog << "%) Evts skipped due to: Used pixels >= " << fUsedPixelsMax ; | 
|---|
| 202 | *fLog << " or Core pixels <= " << fCorePixelsMin << endl; | 
|---|
| 203 |  | 
|---|
| 204 | *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ; | 
|---|
| 205 | *fLog << (int)(fCut[2]*100/GetNumExecutions()) ; | 
|---|
| 206 | *fLog << "%) Evts skipped due to: SIZE <= " << fSizeMin << endl; | 
|---|
| 207 |  | 
|---|
| 208 | *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ; | 
|---|
| 209 | *fLog << (int)(fCut[3]*100/GetNumExecutions()) ; | 
|---|
| 210 | *fLog << "%) Evts skipped due to: DIST < " << fDistMin; | 
|---|
| 211 | *fLog << " or DIST > " << fDistMax << endl; | 
|---|
| 212 |  | 
|---|
| 213 | *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ; | 
|---|
| 214 | *fLog << (int)(fCut[4]*100/GetNumExecutions()) ; | 
|---|
| 215 | *fLog << "%) Evts skipped due to: LENGTH <= " << fLengthMin; | 
|---|
| 216 | *fLog << " or WIDTH <= " << fWidthMin << endl; | 
|---|
| 217 |  | 
|---|
| 218 | *fLog << " " << fCut[0] << " (" ; | 
|---|
| 219 | *fLog << (int)(fCut[0]*100/GetNumExecutions()) ; | 
|---|
| 220 | *fLog << "%) Evts survived Standard selections!" << endl; | 
|---|
| 221 | *fLog << endl; | 
|---|
| 222 |  | 
|---|
| 223 | return kTRUE; | 
|---|
| 224 | } | 
|---|