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 | // MMcPedestalNSB //
|
---|
28 | // //
|
---|
29 | // Input Containers: //
|
---|
30 | // MMcFadcHeader //
|
---|
31 | // MMcRunHeader //
|
---|
32 | // MRawRunHeader //
|
---|
33 | // //
|
---|
34 | // Output Containers: //
|
---|
35 | // MPedestalCam //
|
---|
36 | // //
|
---|
37 | /////////////////////////////////////////////////////////////////////////////
|
---|
38 |
|
---|
39 | #include "MMcPedestalNSB.h"
|
---|
40 |
|
---|
41 | #include "MParList.h"
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MPedestalCam.h"
|
---|
47 | #include "MRawRunHeader.h"
|
---|
48 | #include "MMcRunHeader.hxx"
|
---|
49 | #include "MMcFadcHeader.hxx"
|
---|
50 |
|
---|
51 | ClassImp(MMcPedestalNSB);
|
---|
52 |
|
---|
53 | MMcPedestalNSB::MMcPedestalNSB(const float difnsb,
|
---|
54 | const char *name, const char *title)
|
---|
55 | {
|
---|
56 | fName = name ? name : "MMcPedestalNSB";
|
---|
57 | fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
|
---|
58 |
|
---|
59 | AddToBranchList("fPedestalMean");
|
---|
60 | AddToBranchList("fElecNoise");
|
---|
61 |
|
---|
62 | fdnsb_pixel = difnsb;
|
---|
63 | }
|
---|
64 |
|
---|
65 | Bool_t MMcPedestalNSB::PreProcess(MParList *pList)
|
---|
66 | {
|
---|
67 | MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
68 | if (!run)
|
---|
69 | {
|
---|
70 | *fLog << err << dbginf << "MRawRunHeader not found... aborting." << endl;
|
---|
71 | return kFALSE;
|
---|
72 | }
|
---|
73 |
|
---|
74 | if (run->GetRunType() != kRTMonteCarlo)
|
---|
75 | {
|
---|
76 | *fLog << warn << dbginf << "Warning - MMcPedestalNSB is for Monte Carlo files only... removing this task from list." << endl;
|
---|
77 | return kSKIP;
|
---|
78 | }
|
---|
79 |
|
---|
80 | const MMcFadcHeader *mcped = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
---|
81 | if (!mcped)
|
---|
82 | {
|
---|
83 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
84 | return kFALSE;
|
---|
85 | }
|
---|
86 |
|
---|
87 | MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
|
---|
88 | if (!mcrun && fdnsb_pixel < 0)
|
---|
89 | {
|
---|
90 | *fLog << err << dbginf << "Using the default argument of MMcPedestalNSB::MMcPedestalNSB() ";
|
---|
91 | *fLog << "only allowed if MMcRunHeader is available... aborting." << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | if (mcrun)
|
---|
96 | {
|
---|
97 | if (fdnsb_pixel >= 0 && fdnsb_pixel != mcrun->GetNumPheFromDNSB())
|
---|
98 | {
|
---|
99 | *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrun->GetNumPheFromDNSB();
|
---|
100 | *fLog <<" but you set up the diffuse NSB to " << fdnsb_pixel << endl;
|
---|
101 | }
|
---|
102 |
|
---|
103 | fdnsb_pixel = mcrun->GetNumPheFromDNSB();
|
---|
104 | }
|
---|
105 |
|
---|
106 | fdnsb_pixel *= 50.0/15.0;
|
---|
107 |
|
---|
108 | MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
---|
109 | if (!pedcam)
|
---|
110 | return kFALSE;
|
---|
111 |
|
---|
112 | const int num = mcped->GetNumPixel();
|
---|
113 |
|
---|
114 | pedcam->InitSize(num);
|
---|
115 |
|
---|
116 | for (int i=0; i<num; i++)
|
---|
117 | {
|
---|
118 | MPedestalPix &pix = (*pedcam)[i];
|
---|
119 |
|
---|
120 | const Float_t pedrms = mcped->GetPedestalRms(i);
|
---|
121 | const Float_t sigrms = pedrms/sqrt(run->GetNumSamplesHiGain()*2);
|
---|
122 | const Float_t ampl = mcped->GetAmplitud();
|
---|
123 |
|
---|
124 | //
|
---|
125 | // check for central pixel (i<397)
|
---|
126 | //
|
---|
127 |
|
---|
128 | const Double_t value = pedrms*pedrms + fdnsb_pixel*ampl*ampl;
|
---|
129 |
|
---|
130 | pix.SetPedestalRms(sqrt(i<397 ? value : value*4), sigrms);
|
---|
131 | }
|
---|
132 |
|
---|
133 | return kTRUE;
|
---|
134 | }
|
---|