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 |
|
---|
51 | ClassImp(MMcPedestalCopy);
|
---|
52 |
|
---|
53 | MMcPedestalCopy::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 |
|
---|
66 | Bool_t MMcPedestalCopy::PreProcess(MParList *pList)
|
---|
67 | {
|
---|
68 | ReInit(pList);
|
---|
69 |
|
---|
70 | return kTRUE;
|
---|
71 | }
|
---|
72 |
|
---|
73 | Bool_t MMcPedestalCopy::ReInit(MParList *pList)
|
---|
74 | {
|
---|
75 | MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
76 | if (run)
|
---|
77 | {
|
---|
78 | if (run->GetRunType() != kRTMonteCarlo)
|
---|
79 | {
|
---|
80 | *fLog << warn << dbginf << "MMcPedestalCopy is for Monte Carlo files only... removing this task from list." << endl;
|
---|
81 | return kSKIP;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | else
|
---|
85 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
---|
86 |
|
---|
87 |
|
---|
88 | const MMcFadcHeader *mcped = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
---|
89 | if (!mcped)
|
---|
90 | {
|
---|
91 | *fLog << warn << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
---|
96 | if (!pedcam)
|
---|
97 | return kFALSE;
|
---|
98 |
|
---|
99 | const int num = mcped->GetNumPixel();
|
---|
100 |
|
---|
101 | pedcam->InitSize(num);
|
---|
102 |
|
---|
103 | *fLog << "Pixels: " << num << endl;
|
---|
104 |
|
---|
105 | for (int i=0; i<num; i++)
|
---|
106 | {
|
---|
107 | MPedestalPix &pix = (*pedcam)[i];
|
---|
108 |
|
---|
109 | // Here one should compute the Pedestal taking into account how
|
---|
110 | // the MC makes the transformation analogic-digital for the FADC.
|
---|
111 |
|
---|
112 | const Float_t pedest = mcped->GetPedestal(i);
|
---|
113 | const Float_t pedrms = pedest/sqrt(num);
|
---|
114 |
|
---|
115 | const Float_t sigma = mcped->GetPedestalRms(i);
|
---|
116 | const Float_t sigrms = sigma/sqrt(num*2);
|
---|
117 |
|
---|
118 | pix.SetPedestal(pedest, sigma);
|
---|
119 | pix.SetPedestalRms(pedrms, sigrms);
|
---|
120 | }
|
---|
121 |
|
---|
122 | return kTRUE;
|
---|
123 | }
|
---|
124 |
|
---|