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

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