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

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