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@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
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 | #include "MMcPedestalCopy.h"
|
---|
41 |
|
---|
42 | #include "MParList.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MPedestalPix.h"
|
---|
48 | #include "MPedestalCam.h"
|
---|
49 |
|
---|
50 | #include "MRawRunHeader.h"
|
---|
51 | #include "MMcRunHeader.hxx"
|
---|
52 | #include "MMcFadcHeader.hxx"
|
---|
53 |
|
---|
54 | ClassImp(MMcPedestalCopy);
|
---|
55 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | MMcPedestalCopy::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 | //
|
---|
77 | Bool_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 for the runtype.
|
---|
92 | // Search for MPedestalCam and MMcFadcHeader.
|
---|
93 | //
|
---|
94 | Bool_t MMcPedestalCopy::ReInit(MParList *pList)
|
---|
95 | {
|
---|
96 | //
|
---|
97 | // If it is no MC file skip this function...
|
---|
98 | //
|
---|
99 | if (!CheckRunType(pList))
|
---|
100 | return kTRUE;
|
---|
101 |
|
---|
102 | //
|
---|
103 | // Now check the existance of all necessary containers. This has
|
---|
104 | // to be done only if this is a MC file.
|
---|
105 | //
|
---|
106 | MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
---|
107 | if (!pedcam)
|
---|
108 | return kFALSE;
|
---|
109 |
|
---|
110 | MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
|
---|
111 | if (!mcrun)
|
---|
112 | *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
|
---|
113 |
|
---|
114 | MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
---|
115 | if (!fadc)
|
---|
116 | {
|
---|
117 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
118 | return kFALSE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | const int num = pedcam->GetSize();
|
---|
122 |
|
---|
123 | const Bool_t camver70 = mcrun && mcrun->GetCamVersion()>=70;
|
---|
124 |
|
---|
125 | for (int i=0; i<num; i++)
|
---|
126 | {
|
---|
127 | MPedestalPix &pix = (*pedcam)[i];
|
---|
128 |
|
---|
129 | // Here one should compute the Pedestal taking into account how
|
---|
130 | // the MC makes the transformation analogic-digital for the FADC.
|
---|
131 | // This is done only once per file -> not time critical.
|
---|
132 |
|
---|
133 | const Float_t pedest = fadc->GetPedestal(i);
|
---|
134 | const Float_t sigma = camver70 ? fadc->GetPedestalRmsHigh(i) : fadc->GetElecNoise(i);
|
---|
135 |
|
---|
136 | pix.Set(pedest, sigma);
|
---|
137 | }
|
---|
138 |
|
---|
139 | if (camver70)
|
---|
140 | pedcam->SetReadyToSave();
|
---|
141 |
|
---|
142 | return kTRUE;
|
---|
143 | }
|
---|