source: trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.h@ 7981

Last change on this file since 7981 was 7194, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.1 KB
Line 
1#ifndef MARS_MExtractTimeAndChargeDigitalFilter
2#define MARS_MExtractTimeAndChargeDigitalFilter
3
4#ifndef MARS_MExtractTimeAndCharge
5#include "MExtractTimeAndCharge.h"
6#endif
7
8#ifndef MARS_MArrayF
9#include "MArrayF.h"
10#endif
11
12#ifndef MARS_MArrayI
13#include "MArrayI.h"
14#endif
15
16class TH1F;
17class TH2F;
18class MPedestalPix;
19class MCalibrationPattern;
20
21class MExtractTimeAndChargeDigitalFilter : public MExtractTimeAndCharge
22{
23private:
24 static const Byte_t fgHiGainFirst; //! Default for fHiGainFirst (now set to: 0)
25 static const Byte_t fgHiGainLast; //! Default for fHiGainLast (now set to:14)
26 static const Byte_t fgLoGainFirst; //! Default for fLoGainFirst (now set to: 3)
27 static const Byte_t fgLoGainLast; //! Default for fLoGainLast (now set to:14)
28 static const Int_t fgWindowSizeHiGain; //! Default for fWindowSizeHiGain (now set to: 6)
29 static const Int_t fgWindowSizeLoGain; //! Default for fWindowSizeLoGain (now set to: 6)
30 static const Int_t fgBinningResolutionHiGain; //! Default for fBinningResolutionHiGain (now set to: 10)
31 static const Int_t fgBinningResolutionLoGain; //! Default for fBinningResolutionLoGain (now set to: 10)
32 static const Int_t fgSignalStartBinHiGain; //! Default for fSignalStartBinHiGain (now set to: 4)
33 static const Int_t fgSignalStartBinLoGain; //! Default for fSignalStartBinLoGain (now set to: 4)
34 static const TString fgNameWeightsFile; //! "cosmics_weights.dat"
35 static const Float_t fgOffsetLoGain; //! Default for fOffsetLoGain (now set to 1.7)
36 static const Float_t fgLoGainStartShift; //! Default for fLoGainStartShift (now set to -1.8)
37
38 MCalibrationPattern *fCalibPattern; //! Calibration DM pattern
39
40 MArrayF fHiGainSignal; //! Need fast access to the signals in a float way
41 MArrayF fLoGainSignal; //! Store them in separate arrays
42
43 MArrayI fArrBinningResHiGain; //! helping arrays to hold binningres * i
44 MArrayI fArrBinningResLoGain; //! helping arrays to hold binningres * i
45 MArrayI fArrBinningResHalfHiGain; //! helping arrays to hold binningres * i + binningreshalf
46 MArrayI fArrBinningResHalfLoGain; //! helping arrays to hold binningres * i + binningreshalf
47
48 Float_t fTimeShiftHiGain; // Time shift from when on to apply the filter
49 Float_t fTimeShiftLoGain; // Time shift from when on to apply the filter
50
51 Int_t fSignalStartBinHiGain; //! Start bin from when on to apply weights
52 Int_t fSignalStartBinLoGain; //! Start bin from when on to apply weights
53
54 Int_t fBinningResolutionHiGain; // Number of weights per bin High-Gain
55 Int_t fBinningResolutionHalfHiGain; // Half Number of weights per bin High-Gain
56 Int_t fBinningResolutionLoGain; // Number of weights per bin Low-Gain
57 Int_t fBinningResolutionHalfLoGain; // Half Number of weights per bin Low-Gain
58
59 MArrayF fAmpWeightsHiGain; //! Amplitude weights High-Gain (from weights file)
60 MArrayF fTimeWeightsHiGain; //! Time weights High-Gain (from weights file)
61 MArrayF fAmpWeightsLoGain; //! Amplitude weights Low-Gain (from weights file)
62 MArrayF fTimeWeightsLoGain; //! Time weights Low-Gain (from weights file)
63
64 TString fNameWeightsFile; // Name of the weights file
65 Bool_t fAutomaticWeights; // Flag whether weight should be determined automatically
66 TString fNameWeightsFileSet; //! Flag if weights have alreayd been set
67 Int_t fRandomIter; //! Counter used to randomize weights for noise calculation
68
69 // MExtractTimeAndChargeDigitalFilter
70 void CalcBinningResArrays();
71 Int_t GetAutomaticWeights();
72 Bool_t GetWeights();
73 Int_t ReadWeightsFile(TString filename, TString path="");
74 TString CompileWeightFileName(TString path, const TString &name) const;
75
76 // MExtractTimeAndCharge
77 Bool_t InitArrays();
78
79 // MTask
80 Int_t PreProcess(MParList *pList);
81 Int_t Process();
82
83protected:
84 // MParContainer
85 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
86
87public:
88 MExtractTimeAndChargeDigitalFilter(const char *name=NULL, const char *title=NULL);
89 ~MExtractTimeAndChargeDigitalFilter() { }
90
91 Bool_t WriteWeightsFile(TString filename,
92 TH1F *shapehi, TH2F *autocorrhi,
93 TH1F *shapelo=NULL, TH2F *autocorrlo=NULL );
94
95
96 void SetNameWeightsFile(TString s="") { s.ReplaceAll("\015", ""); // This is a fix for TEnv files edited with windows editors
97 fNameWeightsFile = s; fNameWeightsFileSet=""; }
98 void EnableAutomaticWeights(Bool_t b=kTRUE) { fAutomaticWeights = b; }
99
100 void SetBinningResolution(const Int_t rh=fgBinningResolutionHiGain, const Int_t rl=fgBinningResolutionLoGain) {
101 fBinningResolutionHiGain = rh & ~1;
102 fBinningResolutionHalfHiGain = fBinningResolutionHiGain/2;
103 fBinningResolutionLoGain = rl & ~1;
104 fBinningResolutionHalfLoGain = fBinningResolutionLoGain/2;
105 }
106
107 void SetSignalStartBin( const Int_t sh=fgSignalStartBinHiGain, const Int_t sl=fgSignalStartBinLoGain) {
108 fSignalStartBinHiGain = sh;
109 fSignalStartBinLoGain = sl;
110 }
111
112 void SetWindowSize( Int_t windowh=fgWindowSizeHiGain, Int_t windowl=fgWindowSizeLoGain);
113
114 const char* GetNameWeightsFile() const { return fNameWeightsFile.Data(); }
115
116 void Print(Option_t *o="") const; //*MENU*
117
118 void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
119 Float_t &time, Float_t &dtime,
120 Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
121 void FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum, Float_t &dsum,
122 Float_t &time, Float_t &dtime,
123 Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
124
125 ClassDef(MExtractTimeAndChargeDigitalFilter, 2) // Hendrik's digital filter
126};
127
128#endif
Note: See TracBrowser for help on using the repository browser.