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

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