| 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 | MSigmabarCalc::~MSigmabarCalc()
|
|---|
| 68 | {
|
|---|
| 69 | // nothing special yet.
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | // --------------------------------------------------------------------------
|
|---|
| 73 | //
|
|---|
| 74 | // check if necessary containers exists in the Parameter list already.
|
|---|
| 75 | // if not create one and add them to the list
|
|---|
| 76 | //
|
|---|
| 77 | Bool_t MSigmabarCalc::PreProcess(MParList *pList)
|
|---|
| 78 | {
|
|---|
| 79 | fCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 80 | if (!fCam)
|
|---|
| 81 | {
|
|---|
| 82 | *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
|
|---|
| 83 | return kFALSE;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
|---|
| 87 | if (!fPed)
|
|---|
| 88 | {
|
|---|
| 89 | *fLog << err << "MPedestalCam not found... aborting." << endl;
|
|---|
| 90 | return kFALSE;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | fSig = (MSigmabar*)pList->FindCreateObj("MSigmabar");
|
|---|
| 94 | if (!fSig)
|
|---|
| 95 | {
|
|---|
| 96 | *fLog << err << "MSigmabar not found... aborting." << endl;
|
|---|
| 97 | return kFALSE;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | fSigParam = (MSigmabarParam*)pList->FindCreateObj("MSigmabarParam");
|
|---|
| 101 | if (!fSigParam)
|
|---|
| 102 | {
|
|---|
| 103 | *fLog << err << "MSigmabarParam not found... aborting." << endl;
|
|---|
| 104 | return kFALSE;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 108 | if (!fRun)
|
|---|
| 109 | {
|
|---|
| 110 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 111 | return kFALSE;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // This is needed for determining min/max Theta
|
|---|
| 115 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 116 | if (!fMcEvt)
|
|---|
| 117 | {
|
|---|
| 118 | *fLog << err << "MMcEvt not found... aborting." << endl;
|
|---|
| 119 | return kFALSE;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
|---|
| 123 | if (!fEvt)
|
|---|
| 124 | {
|
|---|
| 125 | *fLog << err << "MCerPhotEvt not found... aborting." << endl;
|
|---|
| 126 | return kFALSE;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | return kTRUE;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | // --------------------------------------------------------------------------
|
|---|
| 133 | //
|
|---|
| 134 | // Calculating a new Sigmabar is not necessary on event basis as long as
|
|---|
| 135 | // we deal with CT1 data. Therefore, the real calculation is done in
|
|---|
| 136 | // the ReInit function. Process just takes care for finding the extremal
|
|---|
| 137 | // values. Preliminary.
|
|---|
| 138 | //
|
|---|
| 139 | Bool_t MSigmabarCalc::Process()
|
|---|
| 140 | {
|
|---|
| 141 | const Double_t rc = fSig->Calc(*fCam, *fPed, *fEvt);
|
|---|
| 142 |
|
|---|
| 143 | fSigmabarMax = TMath::Max(rc, fSigmabarMax);
|
|---|
| 144 | fSigmabarMin = TMath::Min(rc, fSigmabarMin);
|
|---|
| 145 |
|
|---|
| 146 | const Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
|
|---|
| 147 |
|
|---|
| 148 | fThetaMax = TMath::Max(theta, fThetaMax);
|
|---|
| 149 | fThetaMin = TMath::Min(theta, fThetaMin);
|
|---|
| 150 |
|
|---|
| 151 | return kTRUE;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | // --------------------------------------------------------------------------
|
|---|
| 155 | //
|
|---|
| 156 | // Calculates Sigmabar (for CT1 only needed at Reinit, i.e. when reading
|
|---|
| 157 | // a new file)
|
|---|
| 158 | //
|
|---|
| 159 | Bool_t MSigmabarCalc::ReInit(MParList *pList)
|
|---|
| 160 | {
|
|---|
| 161 | fSigParam->SetParams(1, fSigmabarMin, fSigmabarMax, fThetaMin, fThetaMax);
|
|---|
| 162 | fSigParam->SetRunNumber(fRun->GetRunNumber());
|
|---|
| 163 |
|
|---|
| 164 | Reset();
|
|---|
| 165 |
|
|---|
| 166 | return kTRUE;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | void MSigmabarCalc::Reset()
|
|---|
| 170 | {
|
|---|
| 171 | fThetaMin = 200; // there must be a function which gives me the hightest
|
|---|
| 172 | fThetaMax = 0; // value allowed for a certain type!
|
|---|
| 173 | fSigmabarMin = 200;
|
|---|
| 174 | fSigmabarMax = 0;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|