| 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 02/2003 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MSelFinal //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is a task to evaluate the Final Cuts //
|
|---|
| 30 | // (these cuts define the final sample of gammas; //
|
|---|
| 31 | // relevant for the calculation of the effective collection areas) //
|
|---|
| 32 | // //
|
|---|
| 33 | // to be called after the calculation of the hadroness //
|
|---|
| 34 | // //
|
|---|
| 35 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 36 |
|
|---|
| 37 | #include "math.h"
|
|---|
| 38 | #include "MSelFinal.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MParList.h"
|
|---|
| 41 |
|
|---|
| 42 | #include "MHillas.h"
|
|---|
| 43 | #include "MHillasExt.h"
|
|---|
| 44 | #include "MHillasSrc.h"
|
|---|
| 45 | #include "MCerPhotEvt.h"
|
|---|
| 46 | #include "MMcEvt.hxx"
|
|---|
| 47 | #include "MGeomCam.h"
|
|---|
| 48 | #include "MGeomPix.h"
|
|---|
| 49 | #include "MHadronness.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MLog.h"
|
|---|
| 52 | #include "MLogManip.h"
|
|---|
| 53 |
|
|---|
| 54 | ClassImp(MSelFinal);
|
|---|
| 55 |
|
|---|
| 56 | // --------------------------------------------------------------------------
|
|---|
| 57 | //
|
|---|
| 58 | // Default constructor.
|
|---|
| 59 | //
|
|---|
| 60 | MSelFinal::MSelFinal(const char *HilName, const char *HilSrcName,
|
|---|
| 61 | const char *name, const char *title)
|
|---|
| 62 | {
|
|---|
| 63 | fName = name ? name : "MSelFinal";
|
|---|
| 64 | fTitle = title ? title : "Task to evaluate the Final Cuts";
|
|---|
| 65 |
|
|---|
| 66 | fHilName = HilName;
|
|---|
| 67 | fHilSrcName = HilSrcName;
|
|---|
| 68 |
|
|---|
| 69 | // default values of cuts
|
|---|
| 70 | fHadronnessMax = 1.0;
|
|---|
| 71 | fAlphaMax = 100.0; //degrees
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | // --------------------------------------------------------------------------
|
|---|
| 75 | //
|
|---|
| 76 | //
|
|---|
| 77 | //
|
|---|
| 78 | //
|
|---|
| 79 | //
|
|---|
| 80 | Bool_t MSelFinal::PreProcess(MParList *pList)
|
|---|
| 81 | {
|
|---|
| 82 | fHil = (MHillasExt*)pList->FindObject(fHilName, "MHillasExt");
|
|---|
| 83 | if (!fHil)
|
|---|
| 84 | {
|
|---|
| 85 | *fLog << dbginf << "MHillasExt object " << fHilName << " not found... aborting." << endl;
|
|---|
| 86 | return kFALSE;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
|
|---|
| 90 | if (!fHilSrc)
|
|---|
| 91 | {
|
|---|
| 92 | *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
|
|---|
| 93 | return kFALSE;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | fHadronness = (MHadronness*)pList->FindObject("MHadronness");
|
|---|
| 98 | if (!fHadronness)
|
|---|
| 99 | {
|
|---|
| 100 | *fLog << dbginf << "MHadronness not found... aborting." << endl;
|
|---|
| 101 | return kFALSE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 106 | if (!fMcEvt)
|
|---|
| 107 | {
|
|---|
| 108 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
|---|
| 109 | return kFALSE;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | memset(fCut, 0, sizeof(fCut));
|
|---|
| 113 |
|
|---|
| 114 | return kTRUE;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // --------------------------------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // Evaluate final cuts
|
|---|
| 120 | //
|
|---|
| 121 | // if cuts are fulfilled : return 0
|
|---|
| 122 | // if they are not fullfilled : skip the remaining tasks for this event
|
|---|
| 123 | //
|
|---|
| 124 | Bool_t MSelFinal::Process()
|
|---|
| 125 | {
|
|---|
| 126 | //*fLog << "Entry MSelFinal; fHilSrc = " << fHilSrc << endl;
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | Int_t rc = 0;
|
|---|
| 131 |
|
|---|
| 132 | Double_t modalpha = fabs( fHilSrc->GetAlpha() );
|
|---|
| 133 |
|
|---|
| 134 | Double_t h = fHadronness->GetHadronness();
|
|---|
| 135 |
|
|---|
| 136 | if ( h>fHadronnessMax )
|
|---|
| 137 | {
|
|---|
| 138 | //*fLog << "MSelFinal::Process; h, alpha = " << h << ", "
|
|---|
| 139 | // << fHilSrc->GetAlpha() << endl;
|
|---|
| 140 | rc = 1;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | else if ( modalpha > fAlphaMax )
|
|---|
| 144 | {
|
|---|
| 145 | //*fLog << "MSelFinal::Process; h, alpha = " << h << ", "
|
|---|
| 146 | // << fHilSrc->GetAlpha() << endl;
|
|---|
| 147 | rc = 2;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | fCut[rc]++;
|
|---|
| 151 |
|
|---|
| 152 | return rc==0 ? kTRUE : kCONTINUE;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | // --------------------------------------------------------------------------
|
|---|
| 156 | //
|
|---|
| 157 | // Prints some statistics about the Final selections.
|
|---|
| 158 | //
|
|---|
| 159 | Bool_t MSelFinal::PostProcess()
|
|---|
| 160 | {
|
|---|
| 161 | if (GetNumExecutions()==0)
|
|---|
| 162 | return kTRUE;
|
|---|
| 163 |
|
|---|
| 164 | *fLog << inf << endl;
|
|---|
| 165 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
|---|
| 166 | *fLog << dec << setfill(' ');
|
|---|
| 167 | *fLog << " " << setw(7) << fCut[1] << " (" << setw(3)
|
|---|
| 168 | << (int)(fCut[1]*100/GetNumExecutions())
|
|---|
| 169 | << "%) Evts skipped due to: hadroness > "<< fHadronnessMax << endl;
|
|---|
| 170 |
|
|---|
| 171 | *fLog << " " << setw(7) << fCut[2] << " (" << setw(3)
|
|---|
| 172 | << (int)(fCut[2]*100/GetNumExecutions())
|
|---|
| 173 | << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax
|
|---|
| 174 | << " [degrees]" << endl;
|
|---|
| 175 |
|
|---|
| 176 | *fLog << " " << fCut[0] << " ("
|
|---|
| 177 | << (int)(fCut[0]*100/GetNumExecutions())
|
|---|
| 178 | << "%) Evts survived Final selections!" << endl;
|
|---|
| 179 | *fLog << endl;
|
|---|
| 180 |
|
|---|
| 181 | return kTRUE;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|