| 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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MMcPedestalCopy //
|
|---|
| 28 | // //
|
|---|
| 29 | // Input Containers: //
|
|---|
| 30 | // MMcFadcHeader //
|
|---|
| 31 | // //
|
|---|
| 32 | // Output Containers: //
|
|---|
| 33 | // MPedestalCam //
|
|---|
| 34 | // //
|
|---|
| 35 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 36 |
|
|---|
| 37 | #include "MMcPedestalCopy.h"
|
|---|
| 38 |
|
|---|
| 39 | #include "MParList.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MLog.h"
|
|---|
| 42 | #include "MLogManip.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "MPedestalCam.h"
|
|---|
| 45 | #include "MRawRunHeader.h"
|
|---|
| 46 | #include "MMcFadcHeader.hxx"
|
|---|
| 47 |
|
|---|
| 48 | ClassImp(MMcPedestalCopy);
|
|---|
| 49 |
|
|---|
| 50 | MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
|
|---|
| 51 | {
|
|---|
| 52 | fName = name ? name : "MMcPedestalCopy";
|
|---|
| 53 | fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
|
|---|
| 54 |
|
|---|
| 55 | //
|
|---|
| 56 | // This is not needed here using MReadMarsFile because for the
|
|---|
| 57 | // RunHeader tree the auto scheme is disabled by default
|
|---|
| 58 | //
|
|---|
| 59 | AddToBranchList("MMcFadcHeader.fPedesMean");
|
|---|
| 60 | AddToBranchList("MMcFadcHeader.fElecNoise");
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | Bool_t MMcPedestalCopy::PreProcess(MParList *pList)
|
|---|
| 64 | {
|
|---|
| 65 | MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 66 | if (run)
|
|---|
| 67 | if (run->GetRunType() != kRTMonteCarlo)
|
|---|
| 68 | {
|
|---|
| 69 | *fLog << warn << dbginf << "MMcPedestalCopy is for Monte Carlo files only... removing this task from list." << endl;
|
|---|
| 70 | return kSKIP;
|
|---|
| 71 | }
|
|---|
| 72 | else
|
|---|
| 73 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
|---|
| 74 |
|
|---|
| 75 | const MMcFadcHeader *mcped = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
|---|
| 76 | if (!mcped)
|
|---|
| 77 | {
|
|---|
| 78 | *fLog << warn << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
|---|
| 79 | return kFALSE;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
|---|
| 83 | if (!pedcam)
|
|---|
| 84 | return kFALSE;
|
|---|
| 85 |
|
|---|
| 86 | const int num = mcped->GetNumPixel();
|
|---|
| 87 |
|
|---|
| 88 | pedcam->InitSize(num);
|
|---|
| 89 |
|
|---|
| 90 | *fLog << "Pixels: " << num << endl;
|
|---|
| 91 |
|
|---|
| 92 | for (int i=0; i<num; i++)
|
|---|
| 93 | {
|
|---|
| 94 | MPedestalPix &pix = (*pedcam)[i];
|
|---|
| 95 |
|
|---|
| 96 | const Float_t pedest = mcped->GetPedestal(i);
|
|---|
| 97 | const Float_t pedrms = mcped->GetPedestalRms(i);
|
|---|
| 98 |
|
|---|
| 99 | const Float_t sigma = pedest*sqrt(num);
|
|---|
| 100 | const Float_t sigrms = sigma/sqrt(num*2);
|
|---|
| 101 |
|
|---|
| 102 | pix.SetPedestal(pedest, sigma);
|
|---|
| 103 | pix.SetPedestalRms(pedrms, sigrms);
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | return kTRUE;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|