| 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 | // MFCT1SelBasic //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is a class to evaluate basic cuts //
|
|---|
| 30 | // //
|
|---|
| 31 | // to be called after the calibration (when the number of photons is //
|
|---|
| 32 | // available for all pixels) //
|
|---|
| 33 | // //
|
|---|
| 34 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 35 |
|
|---|
| 36 | #include "MFCT1SelBasic.h"
|
|---|
| 37 |
|
|---|
| 38 | #include "MParList.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MHillas.h"
|
|---|
| 41 | #include "MCerPhotEvt.h"
|
|---|
| 42 | #include "MMcEvt.hxx"
|
|---|
| 43 | #include "MRawRunHeader.h"
|
|---|
| 44 | #include "MGeomCam.h"
|
|---|
| 45 | #include "MPedestalCam.h"
|
|---|
| 46 | #include "MPedestalPix.h"
|
|---|
| 47 | #include "MGeomPix.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MLog.h"
|
|---|
| 50 | #include "MLogManip.h"
|
|---|
| 51 |
|
|---|
| 52 | ClassImp(MFCT1SelBasic);
|
|---|
| 53 |
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // Default constructor.
|
|---|
| 57 | //
|
|---|
| 58 | MFCT1SelBasic::MFCT1SelBasic(const char *name, const char *title)
|
|---|
| 59 | {
|
|---|
| 60 | fName = name ? name : "MFCT1SelBasic";
|
|---|
| 61 | fTitle = title ? title : "Filter to evaluate basic cuts";
|
|---|
| 62 |
|
|---|
| 63 | // default values of cuts
|
|---|
| 64 | SetCuts(13.0, 0.0, 60.0);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // --------------------------------------------------------------------------
|
|---|
| 68 | //
|
|---|
| 69 | // Set the cut values
|
|---|
| 70 | //
|
|---|
| 71 | //
|
|---|
| 72 | void MFCT1SelBasic::SetCuts(Float_t minphotons,
|
|---|
| 73 | Float_t thetamin, Float_t thetamax)
|
|---|
| 74 | {
|
|---|
| 75 | fMinPhotons = minphotons;
|
|---|
| 76 | fThetaMin = thetamin;
|
|---|
| 77 | fThetaMax = thetamax;
|
|---|
| 78 |
|
|---|
| 79 | *fLog << inf << "MFCT1SelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = "
|
|---|
| 80 | << fMinPhotons <<", " << fThetaMin << ", " << fThetaMax << endl;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Set the pointers
|
|---|
| 86 | //
|
|---|
| 87 | //
|
|---|
| 88 | Bool_t MFCT1SelBasic::PreProcess(MParList *pList)
|
|---|
| 89 | {
|
|---|
| 90 | fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 91 | if (!fRawRun)
|
|---|
| 92 | {
|
|---|
| 93 | *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 94 | return kFALSE;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 98 | if (!fMcEvt)
|
|---|
| 99 | {
|
|---|
| 100 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
|---|
| 101 | return kFALSE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
|---|
| 105 | if (!fEvt)
|
|---|
| 106 | {
|
|---|
| 107 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
|---|
| 108 | return kFALSE;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | fCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 113 | if (!fCam)
|
|---|
| 114 | {
|
|---|
| 115 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
|---|
| 116 | return kFALSE;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
|---|
| 120 | if (!fPed)
|
|---|
| 121 | {
|
|---|
| 122 | *fLog << dbginf << "MPedestalCam missing in Parameter List... aborting." << endl;
|
|---|
| 123 | return kFALSE;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | memset(fCut, 0, sizeof(fCut));
|
|---|
| 127 |
|
|---|
| 128 | return kTRUE;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // --------------------------------------------------------------------------
|
|---|
| 132 | //
|
|---|
| 133 | // Evaluate basic cuts
|
|---|
| 134 | //
|
|---|
| 135 | // if cuts are fulfilled : fResult = kTRUE;
|
|---|
| 136 | // if they are not fullfilled : fResult = kFALSE;
|
|---|
| 137 | //
|
|---|
| 138 | Bool_t MFCT1SelBasic::Process()
|
|---|
| 139 | {
|
|---|
| 140 | Int_t rc = 0;
|
|---|
| 141 | fResult = kFALSE;
|
|---|
| 142 |
|
|---|
| 143 | //if ( fRawRun->GetRunNumber() < 16279 )
|
|---|
| 144 | //{
|
|---|
| 145 | // rc = 1;
|
|---|
| 146 | // fResult = kTRUE;
|
|---|
| 147 | //}
|
|---|
| 148 |
|
|---|
| 149 | Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
|
|---|
| 150 | if ( theta < fThetaMin )
|
|---|
| 151 | {
|
|---|
| 152 | rc = 1;
|
|---|
| 153 | fResult = kTRUE;
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | else if ( theta > fThetaMax )
|
|---|
| 157 | {
|
|---|
| 158 | rc = 2;
|
|---|
| 159 | fResult = kTRUE;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | else if ( !SwTrigger() )
|
|---|
| 163 | {
|
|---|
| 164 | //*fLog << "MFCT1SelBasic::Process; SwTrigger = " << SwTrigger << endl;
|
|---|
| 165 | rc = 3;
|
|---|
| 166 | fResult = kTRUE;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | fCut[rc]++;
|
|---|
| 170 |
|
|---|
| 171 | return kTRUE;
|
|---|
| 172 | }
|
|---|
| 173 | // --------------------------------------------------------------------------
|
|---|
| 174 | //
|
|---|
| 175 | // Software trigger
|
|---|
| 176 | //
|
|---|
| 177 | // require 2 neighboring pixels (which are not in the outermost ring),
|
|---|
| 178 | // each having at least 'fMinPhotons' photons
|
|---|
| 179 | //
|
|---|
| 180 | //
|
|---|
| 181 | Bool_t MFCT1SelBasic::SwTrigger()
|
|---|
| 182 | {
|
|---|
| 183 | const Int_t entries = fEvt->GetNumPixels();
|
|---|
| 184 |
|
|---|
| 185 | for (Int_t i=0; i<entries; i++)
|
|---|
| 186 | {
|
|---|
| 187 | MCerPhotPix &pix = (*fEvt)[i];
|
|---|
| 188 | Int_t id = pix.GetPixId();
|
|---|
| 189 | if (!pix.IsPixelUsed()) continue;
|
|---|
| 190 |
|
|---|
| 191 | Double_t photons = pix.GetNumPhotons();
|
|---|
| 192 | if (photons < fMinPhotons) continue;
|
|---|
| 193 |
|
|---|
| 194 | // this pixel is used and has the required no.of photons
|
|---|
| 195 | // check whether this is also true for a neigboring pixel
|
|---|
| 196 |
|
|---|
| 197 | MGeomPix &gpix = (*fCam)[id];
|
|---|
| 198 | if ( gpix.IsInOutermostRing() ) continue;
|
|---|
| 199 |
|
|---|
| 200 | const Int_t nneighbors = gpix.GetNumNeighbors();
|
|---|
| 201 | for (Int_t n=0; n<nneighbors; n++)
|
|---|
| 202 | {
|
|---|
| 203 | const Int_t id1 = gpix.GetNeighbor(n);
|
|---|
| 204 | if ( !fEvt->IsPixelUsed(id1) ) continue;
|
|---|
| 205 |
|
|---|
| 206 | MGeomPix &gpix1 = (*fCam)[id1];
|
|---|
| 207 | if ( gpix1.IsInOutermostRing() ) continue;
|
|---|
| 208 |
|
|---|
| 209 | MCerPhotPix &pix1 = *(fEvt->GetPixById(id1));
|
|---|
| 210 |
|
|---|
| 211 | Double_t photons1 = pix1.GetNumPhotons();
|
|---|
| 212 | if (photons1 >= fMinPhotons) return kTRUE;
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 | return kFALSE;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | // --------------------------------------------------------------------------
|
|---|
| 219 | //
|
|---|
| 220 | // Prints some statistics about the Basic selections.
|
|---|
| 221 | //
|
|---|
| 222 | Bool_t MFCT1SelBasic::PostProcess()
|
|---|
| 223 | {
|
|---|
| 224 | if (GetNumExecutions()==0)
|
|---|
| 225 | return kTRUE;
|
|---|
| 226 |
|
|---|
| 227 | *fLog << inf << endl;
|
|---|
| 228 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
|---|
| 229 | *fLog << dec << setfill(' ');
|
|---|
| 230 | *fLog << " " << setw(7) << fCut[1] << " (" << setw(3)
|
|---|
| 231 | << (int)(fCut[1]*100/GetNumExecutions())
|
|---|
| 232 | << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
|
|---|
| 233 |
|
|---|
| 234 | *fLog << " " << setw(7) << fCut[2] << " (" << setw(3)
|
|---|
| 235 | << (int)(fCut[2]*100/GetNumExecutions())
|
|---|
| 236 | << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
|
|---|
| 237 |
|
|---|
| 238 | *fLog << " " << setw(7) << fCut[3] << " (" << setw(3)
|
|---|
| 239 | << (int)(fCut[3]*100/GetNumExecutions())
|
|---|
| 240 | << "%) Evts skipped due to: Software trigger not fullfilled"
|
|---|
| 241 | << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
|
|---|
| 242 |
|
|---|
| 243 | *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions())
|
|---|
| 244 | << "%) Evts survived Basic selections!" << endl;
|
|---|
| 245 | *fLog << endl;
|
|---|
| 246 |
|
|---|
| 247 | return kTRUE;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|