| 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): Abelardo Moralejo 12/2003 <mailto:moralejo@pd.infn.it>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MMcPedestalRead //
|
|---|
| 28 | // //
|
|---|
| 29 | // This task looks for the ìnformation about FADC pedestals in //
|
|---|
| 30 | // MMcFadcHeader and translates it to the pedestal values in //
|
|---|
| 31 | // MPedestalCam. It is intended for camera >= 0.7 files //
|
|---|
| 32 | // //
|
|---|
| 33 | // //
|
|---|
| 34 | // Input Containers: //
|
|---|
| 35 | // MMcFadcHeader //
|
|---|
| 36 | // //
|
|---|
| 37 | // Output Containers: //
|
|---|
| 38 | // MPedestalCam //
|
|---|
| 39 | // //
|
|---|
| 40 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 41 |
|
|---|
| 42 | #include "MMcPedestalRead.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "MParList.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MLog.h"
|
|---|
| 47 | #include "MLogManip.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MPedestalPix.h"
|
|---|
| 50 | #include "MPedestalCam.h"
|
|---|
| 51 |
|
|---|
| 52 | #include "MRawRunHeader.h"
|
|---|
| 53 | #include "MMcFadcHeader.hxx"
|
|---|
| 54 |
|
|---|
| 55 | ClassImp(MMcPedestalRead);
|
|---|
| 56 |
|
|---|
| 57 | using namespace std;
|
|---|
| 58 |
|
|---|
| 59 | MMcPedestalRead::MMcPedestalRead(const char *name, const char *title)
|
|---|
| 60 | {
|
|---|
| 61 | fName = name ? name : "MMcPedestalRead";
|
|---|
| 62 | fTitle = title ? title : "Copy MC pedestals into MPedestal Container";
|
|---|
| 63 |
|
|---|
| 64 | //
|
|---|
| 65 | // This is not needed here using MReadMarsFile because for the
|
|---|
| 66 | // RunHeader tree the auto scheme is disabled by default
|
|---|
| 67 | //
|
|---|
| 68 |
|
|---|
| 69 | AddToBranchList("MMcFadcHeader.fPedesMean");
|
|---|
| 70 | AddToBranchList("MMcFadcHeader.fPedesSigmaHigh");
|
|---|
| 71 |
|
|---|
| 72 | // FIXME: may be we'll have to take into account the low gain
|
|---|
| 73 | // pedestal sigma in the future.
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | // --------------------------------------------------------------------------
|
|---|
| 77 | //
|
|---|
| 78 | // Check for the run type. Return kTRUE if it is a MC run or if there
|
|---|
| 79 | // is no MC run header (old camera files) kFALSE in case of a different
|
|---|
| 80 | // run type
|
|---|
| 81 | //
|
|---|
| 82 | Bool_t MMcPedestalRead::CheckRunType(MParList *pList) const
|
|---|
| 83 | {
|
|---|
| 84 | const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 85 | if (!run)
|
|---|
| 86 | {
|
|---|
| 87 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
|---|
| 88 | return kTRUE;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | return run->GetRunType() == kRTMonteCarlo;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // Check runtype and search for MPedestalCam and MMcFadcHeader.
|
|---|
| 97 | // If the runtype check fails the task is removed from the task list.
|
|---|
| 98 | //
|
|---|
| 99 | Int_t MMcPedestalRead::PreProcess(MParList *pList)
|
|---|
| 100 | {
|
|---|
| 101 | if (!CheckRunType(pList))
|
|---|
| 102 | {
|
|---|
| 103 | *fLog << warn << dbginf << " MMcPedestalRead is for Monte Carlo files only... ";
|
|---|
| 104 | *fLog << "removing task from list." << endl;
|
|---|
| 105 | return kSKIP;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
|---|
| 109 | if (!fPedCam)
|
|---|
| 110 | return kFALSE;
|
|---|
| 111 |
|
|---|
| 112 | fMcPed = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
|---|
| 113 | if (!fMcPed)
|
|---|
| 114 | {
|
|---|
| 115 | *fLog << warn << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
|---|
| 116 | return kFALSE;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | return kTRUE;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // --------------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // Check for the runtype.
|
|---|
| 125 | // Initialize the size of MPedestalCam to the number of pixels from
|
|---|
| 126 | // MMcFadcHeader.
|
|---|
| 127 | //
|
|---|
| 128 | Bool_t MMcPedestalRead::ReInit(MParList *pList)
|
|---|
| 129 | {
|
|---|
| 130 | if (!CheckRunType(pList))
|
|---|
| 131 | return kFALSE;
|
|---|
| 132 |
|
|---|
| 133 | const int num = fPedCam->GetSize();
|
|---|
| 134 |
|
|---|
| 135 | for (int i=0; i<num; i++)
|
|---|
| 136 | {
|
|---|
| 137 | MPedestalPix &pix = (*fPedCam)[i];
|
|---|
| 138 |
|
|---|
| 139 | const Float_t pedest = fMcPed->GetPedestal(i);
|
|---|
| 140 | const Float_t sigma = fMcPed->GetPedestalRmsHigh(i);
|
|---|
| 141 |
|
|---|
| 142 | pix.Set(pedest, sigma);
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | return kTRUE;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|