source: trunk/MagicSoft/Mars/manalysis/MMcPedestalNSB.cc@ 1112

Last change on this file since 1112 was 1097, checked in by blanch, 23 years ago
New class which adds to the pedestal rms the contribution from the diffuse NSB
  • Property svn:executable set to *
File size: 4.6 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): 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
51ClassImp(MMcPedestalNSB);
52
53MMcPedestalNSB::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
65Bool_t MMcPedestalNSB::PreProcess(MParList *pList)
66{
67 MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
68 if (run)
69 {
70 if (run->GetRunType() != kRTMonteCarlo){
71 *fLog << dbginf << "This task is only for Monte Carlo files, therefore the RunType should be "<<kRTMonteCarlo<<" and it is: "<<run->GetRunType()<<" ... aborting"<<endl;
72 return kFALSE;
73 }
74 }
75 else
76 {
77 *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
78 return kFALSE;
79 }
80
81 const MMcFadcHeader *mcped = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
82
83 if (!mcped)
84 {
85 *fLog << dbginf << "MMcFadcHeader not found... aborting." << endl;
86 return kFALSE;
87 }
88
89 MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
90 if (mcrun)
91 {
92 if (fdnsb_pixel >= 0 && fdnsb_pixel != mcrun->GetNumPheFromDNSB()){
93 *fLog<< dbginf <<endl<< "The MC file has been generated with diffuse nsb : "<<mcrun->GetNumPheFromDNSB()<<" but you set up the diffuse NSB to :"<<fdnsb_pixel<<endl;
94 fdnsb_pixel = fdnsb_pixel*50.0/15.0;
95 }
96 else
97 fdnsb_pixel = mcrun->GetNumPheFromDNSB()*50.0/15.0;
98 }
99 else
100 {
101 if (fdnsb_pixel < 0 ){
102 *fLog << dbginf << "MMcRunHeader not found... aborting." << endl;
103 return kFALSE;
104 }
105 else {
106 *fLog<< dbginf <<endl<< "The MC file has been generated with diffuse nsb : "<<mcrun->GetNumPheFromDNSB()<<" but you set up the diffuse NSB to :"<<fdnsb_pixel<<endl;
107 fdnsb_pixel = fdnsb_pixel*50.0/15.0;
108 }
109 }
110
111 MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
112 if (!pedcam)
113 return kFALSE;
114
115 const int num = mcped->GetNumPixel();
116
117 pedcam->InitSize(num);
118
119 for (int i=0; i<num; i++)
120 {
121 MPedestalPix &pix = (*pedcam)[i];
122
123 const Float_t pedrms = mcped->GetPedestalRms(i);
124
125 const Float_t sigrms = pedrms/sqrt(run->GetNumSamplesHiGain()*2);
126
127 if (i<397) // Central Pixels
128 {
129 pix.SetPedestalRms(sqrt(pedrms*pedrms+fdnsb_pixel*mcped->GetAmplitud()*mcped->GetAmplitud()), sigrms);
130 }
131 else
132 {
133 pix.SetPedestalRms(sqrt(pedrms*pedrms+fdnsb_pixel*mcped->GetAmplitud()*mcped->GetAmplitud()*4), sigrms);
134 }
135
136 }
137
138 return kTRUE;
139}
140
141
142
Note: See TracBrowser for help on using the repository browser.