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