| 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): Robert Wagner, 10/2002 <rwagner@mppmu.mpg.de> | 
|---|
| 19 | !   Author(s): Thomas Bretz, 4/2003 <tbretz@astro.uni-wuerzburg.de> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2000-2003 | 
|---|
| 22 | ! | 
|---|
| 23 | ! | 
|---|
| 24 | \* ======================================================================== */ | 
|---|
| 25 |  | 
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 27 | //                                                                         // | 
|---|
| 28 | //  MSigmabarCalc                                                          // | 
|---|
| 29 | //                                                                         // | 
|---|
| 30 | //  This task calculates Sigmabar using the MSigmabar container and stores // | 
|---|
| 31 | //  its extremal values together with the corresponding Theta values       // | 
|---|
| 32 | //  in MSigmabarParam. For the time being, Theta is taken from a Monte     // | 
|---|
| 33 | //  Carlo container. This is preliminary and to be changed ASAP.           // | 
|---|
| 34 | //                                                                         // | 
|---|
| 35 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 36 | #include "MSigmabarCalc.h" | 
|---|
| 37 |  | 
|---|
| 38 | #include "MLog.h" | 
|---|
| 39 | #include "MLogManip.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MParList.h" | 
|---|
| 42 |  | 
|---|
| 43 | #include "MGeomCam.h" | 
|---|
| 44 | #include "MPedestalCam.h" | 
|---|
| 45 |  | 
|---|
| 46 | #include "MSigmabar.h" | 
|---|
| 47 | #include "MSigmabarParam.h" | 
|---|
| 48 |  | 
|---|
| 49 | #include "MMcEvt.hxx" | 
|---|
| 50 |  | 
|---|
| 51 | ClassImp(MSigmabarCalc); | 
|---|
| 52 |  | 
|---|
| 53 | using namespace std; | 
|---|
| 54 |  | 
|---|
| 55 | // -------------------------------------------------------------------------- | 
|---|
| 56 | // | 
|---|
| 57 | // Default constructor. | 
|---|
| 58 | // | 
|---|
| 59 | MSigmabarCalc::MSigmabarCalc(const char *name, const char *title) | 
|---|
| 60 | { | 
|---|
| 61 | fName  = name  ? name  : "MSigmabarCalc"; | 
|---|
| 62 | fTitle = title ? title : "Task to calculate Sigmabar"; | 
|---|
| 63 |  | 
|---|
| 64 | Reset(); | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | // -------------------------------------------------------------------------- | 
|---|
| 68 | // | 
|---|
| 69 | //  check if necessary containers exists in the Parameter list already. | 
|---|
| 70 | //  if not create one and add them to the list | 
|---|
| 71 | // | 
|---|
| 72 | Int_t MSigmabarCalc::PreProcess(MParList *pList) | 
|---|
| 73 | { | 
|---|
| 74 | fCam = (MGeomCam*)pList->FindObject("MGeomCam"); | 
|---|
| 75 | if (!fCam) | 
|---|
| 76 | { | 
|---|
| 77 | *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl; | 
|---|
| 78 | return kFALSE; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam"); | 
|---|
| 82 | if (!fPed) | 
|---|
| 83 | { | 
|---|
| 84 | *fLog << err << "MPedestalCam not found... aborting." << endl; | 
|---|
| 85 | return kFALSE; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader"); | 
|---|
| 89 | if (!fRun) | 
|---|
| 90 | { | 
|---|
| 91 | *fLog << err << "MRawRunHeader not found... aborting." << endl; | 
|---|
| 92 | return kFALSE; | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 | // This is needed for determining min/max Theta | 
|---|
| 96 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt"); | 
|---|
| 97 | if (!fMcEvt) | 
|---|
| 98 | { | 
|---|
| 99 | *fLog << warn << "MMcEvt not found... aborting." << endl; | 
|---|
| 100 | fThetaMin =  0; | 
|---|
| 101 | fThetaMax = 90; | 
|---|
| 102 | } | 
|---|
| 103 |  | 
|---|
| 104 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt"); | 
|---|
| 105 | if (!fEvt) | 
|---|
| 106 | { | 
|---|
| 107 | *fLog << err << "MCerPhotEvt not found... aborting." << endl; | 
|---|
| 108 | return kFALSE; | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 | fSig = (MSigmabar*)pList->FindCreateObj("MSigmabar"); | 
|---|
| 112 | if (!fSig) | 
|---|
| 113 | return kFALSE; | 
|---|
| 114 |  | 
|---|
| 115 | fSigParam = (MSigmabarParam*)pList->FindCreateObj("MSigmabarParam"); | 
|---|
| 116 | if (!fSigParam) | 
|---|
| 117 | return kFALSE; | 
|---|
| 118 |  | 
|---|
| 119 |  | 
|---|
| 120 | return kTRUE; | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 | // -------------------------------------------------------------------------- | 
|---|
| 124 | // | 
|---|
| 125 | // Calculating a new Sigmabar is not necessary on event basis as long as | 
|---|
| 126 | // we deal with CT1 data. Therefore, the real calculation is done in | 
|---|
| 127 | // the ReInit function. Process just takes care for finding the extremal | 
|---|
| 128 | // values. Preliminary. | 
|---|
| 129 | // | 
|---|
| 130 | Int_t MSigmabarCalc::Process() | 
|---|
| 131 | { | 
|---|
| 132 | const Double_t rc = fSig->Calc(*fCam, *fPed, *fEvt); | 
|---|
| 133 |  | 
|---|
| 134 | if (rc>fSigmabarMax) fSigmabarMax=rc; | 
|---|
| 135 | if (rc<fSigmabarMin) fSigmabarMin=rc; | 
|---|
| 136 |  | 
|---|
| 137 | if (!fMcEvt) | 
|---|
| 138 | return kTRUE; | 
|---|
| 139 |  | 
|---|
| 140 | const Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg; | 
|---|
| 141 |  | 
|---|
| 142 | if (theta>fSigmabarMax) fSigmabarMax=theta; | 
|---|
| 143 | if (theta<fSigmabarMax) fSigmabarMin=theta; | 
|---|
| 144 |  | 
|---|
| 145 | return kTRUE; | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 | // -------------------------------------------------------------------------- | 
|---|
| 149 | // | 
|---|
| 150 | // Calculates Sigmabar (for CT1 only needed at Reinit, i.e. when reading | 
|---|
| 151 | // a new file) | 
|---|
| 152 | // | 
|---|
| 153 | Bool_t MSigmabarCalc::ReInit(MParList *pList) | 
|---|
| 154 | { | 
|---|
| 155 | fSigParam->SetParams(1, fSigmabarMin, fSigmabarMax, fThetaMin, fThetaMax); | 
|---|
| 156 | fSigParam->SetRunNumber(fRun->GetRunNumber()); | 
|---|
| 157 |  | 
|---|
| 158 | Reset(); | 
|---|
| 159 |  | 
|---|
| 160 | return kTRUE; | 
|---|
| 161 | } | 
|---|
| 162 |  | 
|---|
| 163 | void MSigmabarCalc::Reset() | 
|---|
| 164 | { | 
|---|
| 165 | if (!fMcEvt) | 
|---|
| 166 | return; | 
|---|
| 167 |  | 
|---|
| 168 | fThetaMin    = FLT_MAX; | 
|---|
| 169 | fThetaMax    = 0; | 
|---|
| 170 | fSigmabarMin = FLT_MAX; | 
|---|
| 171 | fSigmabarMax = 0; | 
|---|
| 172 | } | 
|---|
| 173 |  | 
|---|