source: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc@ 1131

Last change on this file since 1131 was 1131, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.3 KB
Line 
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// This task looks for the ìnformation about FADC pedestals in //
29// MMcFadcHeader and translates it to the pedestal values in //
30// MPedestalCam //
31// //
32// Input Containers: //
33// MMcFadcHeader //
34// //
35// Output Containers: //
36// MPedestalCam //
37// //
38/////////////////////////////////////////////////////////////////////////////
39
40#include "MMcPedestalCopy.h"
41
42#include "MParList.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MPedestalCam.h"
48#include "MRawRunHeader.h"
49#include "MMcFadcHeader.hxx"
50
51ClassImp(MMcPedestalCopy);
52
53MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
54{
55 fName = name ? name : "MMcPedestalCopy";
56 fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
57
58 //
59 // This is not needed here using MReadMarsFile because for the
60 // RunHeader tree the auto scheme is disabled by default
61 //
62 AddToBranchList("MMcFadcHeader.fPedesMean");
63 AddToBranchList("MMcFadcHeader.fElecNoise");
64}
65
66Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
67{
68 MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
69 if (!run)
70 {
71 *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
72 return kTRUE;
73 }
74
75 return run->GetRunType() == kRTMonteCarlo;
76}
77
78Bool_t MMcPedestalCopy::PreProcess(MParList *pList)
79{
80 if (!CheckRunType(pList))
81 {
82 *fLog << warn << dbginf << " MMcPedestalCopy is for Monte Carlo files only... ";
83 *fLog << "removing task from list." << endl;
84 return kSKIP;
85 }
86
87 fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
88 if (!fPedCam)
89 return kFALSE;
90
91 fMcPed = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
92 if (!fMcPed)
93 {
94 *fLog << warn << dbginf << "MMcFadcHeader not found... aborting." << endl;
95 return kFALSE;
96 }
97
98 return kTRUE;
99}
100
101Bool_t MMcPedestalCopy::ReInit(MParList *pList)
102{
103 if (!CheckRunType(pList))
104 return kFALSE;
105
106 const int num = fMcPed->GetNumPixel();
107
108 fPedCam->InitSize(num);
109
110 for (int i=0; i<num; i++)
111 {
112 MPedestalPix &pix = (*fPedCam)[i];
113
114 // Here one should compute the Pedestal taking into account how
115 // the MC makes the transformation analogic-digital for the FADC.
116
117 const Float_t pedest = fMcPed->GetPedestal(i);
118 const Float_t pedrms = pedest/sqrt(num);
119
120 const Float_t sigma = fMcPed->GetPedestalRms(i);
121 const Float_t sigrms = sigma/sqrt(num*2);
122
123 pix.SetPedestal(pedest, sigma);
124 pix.SetPedestalRms(pedrms, sigrms);
125 }
126
127 return kTRUE;
128}
129
Note: See TracBrowser for help on using the repository browser.