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): Oscar Blanch 11/2001 < mailto:blanch@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MMcPedestalNSBAdd //
|
---|
28 | // //
|
---|
29 | // This Task adds the contribution of the diffuse NSB to the FADC //
|
---|
30 | // pedestals. We assume that NSB introduces larger fluctuation but does //
|
---|
31 | // not change the mean value. //
|
---|
32 | // To be precise we add quadratically to the rms that is already in //
|
---|
33 | // MPedestalCam the NSB contribution. //
|
---|
34 | // The number of photons from the diffuse NSB follows a poisson //
|
---|
35 | // distribution with expected mean value X, then its standard desviation //
|
---|
36 | // is sqrt(X). //
|
---|
37 | // X is the number of phe per ns so we have to convert in FADC counts per //
|
---|
38 | // slice: //
|
---|
39 | // //
|
---|
40 | // Y=sqrt(X*FADC_time/Number_of_slice*pixel_size)*Amp_single_phe_response //
|
---|
41 | // //
|
---|
42 | // Input Containers: //
|
---|
43 | // MMcFadcHeader //
|
---|
44 | // MMcRunHeader //
|
---|
45 | // MRawRunHeader //
|
---|
46 | // //
|
---|
47 | // Output Containers: //
|
---|
48 | // MPedestalCam //
|
---|
49 | // //
|
---|
50 | /////////////////////////////////////////////////////////////////////////////
|
---|
51 |
|
---|
52 | #include "MMcPedestalNSBAdd.h"
|
---|
53 |
|
---|
54 | #include "MParList.h"
|
---|
55 |
|
---|
56 | #include "MLog.h"
|
---|
57 | #include "MLogManip.h"
|
---|
58 |
|
---|
59 | #include "MPedestalCam.h"
|
---|
60 | #include "MRawRunHeader.h"
|
---|
61 | #include "MMcRunHeader.hxx"
|
---|
62 | #include "MMcFadcHeader.hxx"
|
---|
63 | #include "MGeomCam.h"
|
---|
64 | #include "MGeomPix.h"
|
---|
65 |
|
---|
66 | ClassImp(MMcPedestalNSBAdd);
|
---|
67 |
|
---|
68 | // --------------------------------------------------------------------------
|
---|
69 | //
|
---|
70 | // Default constructor.
|
---|
71 | //
|
---|
72 | MMcPedestalNSBAdd::MMcPedestalNSBAdd(const Float_t difnsb,
|
---|
73 | const char *name, const char *title)
|
---|
74 | {
|
---|
75 | fName = name ? name : "MMcPedestalNSBAdd";
|
---|
76 | fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
|
---|
77 |
|
---|
78 | //
|
---|
79 | // This is not needed here using MReadMarsFile because for the
|
---|
80 | // RunHeader tree the auto scheme is disabled by default
|
---|
81 | //
|
---|
82 | AddToBranchList("fPedesMean");
|
---|
83 | AddToBranchList("fElecNoise");
|
---|
84 |
|
---|
85 | fDnsbPixel=difnsb;
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // The PreProcess does nothing since the process does not exist and
|
---|
91 | // therefore it does not need any pointer or files already initialysed
|
---|
92 |
|
---|
93 | Bool_t MMcPedestalNSBAdd::PreProcess(MParList *pList)
|
---|
94 | {
|
---|
95 |
|
---|
96 | // FIX ME , ReInit should be called automatically. When it is
|
---|
97 | // implemented then this line should be removed.
|
---|
98 |
|
---|
99 | ReInit(pList);
|
---|
100 |
|
---|
101 | return kTRUE;
|
---|
102 | }
|
---|
103 |
|
---|
104 | // --------------------------------------------------------------------------
|
---|
105 | //
|
---|
106 | // This function is called each time MReadTree::Notify is called, which
|
---|
107 | // happens when it changes the file to read from.
|
---|
108 | // Here we add the contribution from NSB to the pedestals.
|
---|
109 | // The ReInit searches for the following input containers:
|
---|
110 | // - MRawRunHeader
|
---|
111 | // - MMcRunHeader
|
---|
112 | // - MMcFacdHeader
|
---|
113 | // - MGeomCam
|
---|
114 | //
|
---|
115 | // The following output containers are also searched and created if
|
---|
116 | // they were not found:
|
---|
117 | // - MPedestalCam
|
---|
118 | //
|
---|
119 | Bool_t MMcPedestalNSBAdd::ReInit(MParList *pList)
|
---|
120 | {
|
---|
121 |
|
---|
122 | MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
123 | if (runheader)
|
---|
124 | {
|
---|
125 | if (runheader->GetRunType() != kRTMonteCarlo)
|
---|
126 | {
|
---|
127 | *fLog << warn << dbginf << "Warning - MMcPedestalNSB is for Monte Carlo files only... removing this task from list." << endl;
|
---|
128 | return kSKIP;
|
---|
129 | }
|
---|
130 | }
|
---|
131 | else
|
---|
132 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
---|
133 |
|
---|
134 |
|
---|
135 | MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
---|
136 | if (!fadc)
|
---|
137 | {
|
---|
138 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
139 | return kFALSE;
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
|
---|
144 | if (!mcrunheader && fDnsbPixel < 0 )
|
---|
145 | {
|
---|
146 | *fLog << err << dbginf << "Using the default argument of MMcPedestalNSB::MMcPedestalNSB() ";
|
---|
147 | *fLog << "only allowed if MMcRunHeader is available... aborting." << endl;
|
---|
148 | return kFALSE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | if (mcrunheader)
|
---|
152 | {
|
---|
153 | if (fDnsbPixel >= 0 && fDnsbPixel != mcrunheader->GetNumPheFromDNSB())
|
---|
154 | {
|
---|
155 | *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrunheader->GetNumPheFromDNSB();
|
---|
156 | *fLog <<" but you set up the diffuse NSB to " << fDnsbPixel << endl;
|
---|
157 | }
|
---|
158 | else
|
---|
159 | fDnsbPixel = mcrunheader->GetNumPheFromDNSB();
|
---|
160 | }
|
---|
161 |
|
---|
162 | fDnsbPixel *= 50.0/15.0;
|
---|
163 |
|
---|
164 |
|
---|
165 | MGeomCam *geometry = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
166 | if (!geometry)
|
---|
167 | {
|
---|
168 | *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
|
---|
169 | return kFALSE;
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | MPedestalCam *pedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
---|
174 | if (!pedestals)
|
---|
175 | return kFALSE;
|
---|
176 |
|
---|
177 |
|
---|
178 | const int num = fadc->GetNumPixel();
|
---|
179 |
|
---|
180 | pedestals->InitSize(num);
|
---|
181 |
|
---|
182 | const Float_t size0 = (*geometry)[0].GetR()*(*geometry)[0].GetR();
|
---|
183 |
|
---|
184 | for (int i=0; i<num; i++)
|
---|
185 | {
|
---|
186 | MPedestalPix &pix = (*pedestals)[i];
|
---|
187 | MGeomPix &pixgeom = (*geometry)[i];
|
---|
188 |
|
---|
189 | const Float_t pedrms = pix.GetSigma();
|
---|
190 | const Float_t size = pixgeom.GetR()*pixgeom.GetR()/size0;
|
---|
191 |
|
---|
192 | const Float_t ampl = fadc->GetAmplitud();
|
---|
193 |
|
---|
194 | pix.SetSigma(sqrt(pedrms*pedrms + fDnsbPixel*ampl*ampl*size));
|
---|
195 | }
|
---|
196 |
|
---|
197 | return kTRUE;
|
---|
198 | }
|
---|
199 |
|
---|