1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: PixelMapBuilder.hh 2805 2008-10-10 09:44:23Z naumov $ |
---|
3 | // A.Thea created Apr, 15 2004 |
---|
4 | |
---|
5 | #ifndef __PIXELMAPBUILDER_HH__ |
---|
6 | #define __PIXELMAPBUILDER_HH__ |
---|
7 | |
---|
8 | #include "euso.hh" |
---|
9 | #include "DiffusePhotonsOnPupil.hh" |
---|
10 | #include "EsafConfigurable.hh" |
---|
11 | #include "EsafMsgSource.hh" |
---|
12 | #include "TString.h" |
---|
13 | #include "TFile.h" |
---|
14 | #include "TH2F.h" |
---|
15 | |
---|
16 | #include <vector> |
---|
17 | |
---|
18 | class EusoDetector; |
---|
19 | class VirtualDetectorTransportManager; |
---|
20 | class EusoElectronics; |
---|
21 | class TTree; |
---|
22 | class TChain; |
---|
23 | class TCanvas; |
---|
24 | class EGViewer; |
---|
25 | |
---|
26 | //////////////////////////////////////////////////////////////////////////////// |
---|
27 | // // |
---|
28 | // PixelMapBuilder // |
---|
29 | // // |
---|
30 | //////////////////////////////////////////////////////////////////////////////// |
---|
31 | |
---|
32 | class PixelMapBuilder: public EsafConfigurable, public EsafMsgSource { |
---|
33 | public: |
---|
34 | // ctor |
---|
35 | PixelMapBuilder(); |
---|
36 | |
---|
37 | // dtor |
---|
38 | virtual ~PixelMapBuilder(); |
---|
39 | |
---|
40 | void SetNphotons( Int_t n) { fNphotons = n; } |
---|
41 | Int_t GetNphotons() { return fNphotons; } |
---|
42 | |
---|
43 | Bool_t OpenRoot( const char* name, Bool_t write = kFALSE ); |
---|
44 | Bool_t AddToChain( const char* name); |
---|
45 | Bool_t OpenChain( const char* name); |
---|
46 | Bool_t OpenChain( const char** name, Int_t n ); |
---|
47 | Bool_t CloseRoot(); |
---|
48 | |
---|
49 | enum { kBufEmpty = -1}; |
---|
50 | struct Hit { |
---|
51 | Int_t fUID; |
---|
52 | Float_t fTheta; |
---|
53 | Float_t fPhi; |
---|
54 | Float_t fLambda; |
---|
55 | |
---|
56 | }; |
---|
57 | |
---|
58 | class Header : public TObject { |
---|
59 | public: |
---|
60 | Header() : fNpixels(0), fNtracked(0), fNhits(0), fFoV(0), fFullFoV(0) {} |
---|
61 | Int_t fNpixels; |
---|
62 | Int_t fNtracked; |
---|
63 | Int_t fNhits; |
---|
64 | Float_t fFoV; |
---|
65 | Float_t fFullFoV; |
---|
66 | |
---|
67 | ClassDef(Header,1) |
---|
68 | }; |
---|
69 | |
---|
70 | Bool_t MakePhotonsFile( const char* name, Long_t n ); |
---|
71 | Bool_t MakeMap( const char* hits, const char* mapfile); |
---|
72 | |
---|
73 | size_t BufferEntries() { return fThetaFOVBuffer.size(); } |
---|
74 | size_t BufEntrySize(Int_t i) {return fThetaFOVBuffer[i].size(); } |
---|
75 | Float_t GetNsigma() const { return fNsigma; } |
---|
76 | Int_t GetBufIndex() const { return fBufIndex; } |
---|
77 | Int_t GetHitsThreshold() const { return fHitsThreshold; } |
---|
78 | Long_t GetMaxBufSize() { return fMaxBufSize; } |
---|
79 | Long_t GetBufferSize() { return fBufferSize; } |
---|
80 | Float_t GetFoV() { return fFoV; } |
---|
81 | Float_t GetFullFoV() { return fFullFoV; } |
---|
82 | Int_t MapSize() { return fMapTheta.GetSize(); } |
---|
83 | |
---|
84 | //setters |
---|
85 | void SetNsigma(Float_t t) { fNsigma = t; } |
---|
86 | void SetHitsThreshold( Int_t t ) { fHitsThreshold = t; } |
---|
87 | void SetFoV( Float_t fov) { fFoV = fov <= fFullFoV ? fov : fFullFoV; } |
---|
88 | void SetFullFoV( Float_t fov ) { fFullFoV = fov; } |
---|
89 | |
---|
90 | void SetMaxBufSize( Long_t size ) { fMaxBufSize = size; } |
---|
91 | void SetDisplay( EGViewer* display ) { fDisplay = display; } |
---|
92 | |
---|
93 | Bool_t Fit(Int_t uid, Option_t *option); |
---|
94 | TCanvas *DrawHistPad() const; |
---|
95 | void DumpHit() const; |
---|
96 | |
---|
97 | void SetSaveHistograms( const char* name =0 ) { fFitHistsFileName = name ? name : ""; } |
---|
98 | void WriteMap(const char* name) ; |
---|
99 | //private: |
---|
100 | |
---|
101 | |
---|
102 | // objects for the map creation |
---|
103 | DiffusePhotonsOnPupil fPupil; // photons generator |
---|
104 | |
---|
105 | EusoDetector *fDetector; // detector |
---|
106 | VirtualDetectorTransportManager *fTransporter; // photons transporter |
---|
107 | EusoElectronics *fElectronics; // electronics |
---|
108 | |
---|
109 | // common part |
---|
110 | TString fHitsRootFileName; |
---|
111 | TFile *fHitsRootFile; // output file |
---|
112 | TTree *fHitsTree; // ttree containing the hits on the pixels |
---|
113 | |
---|
114 | TChain *fHitsChain; // Chain for multiple file processing |
---|
115 | Long64_t fNphotons; // total number of photons |
---|
116 | |
---|
117 | TString fFitHistsFileName; |
---|
118 | TFile* fFitHistsFile; |
---|
119 | TTree* fFitHistsTree; |
---|
120 | |
---|
121 | // build the map |
---|
122 | void TrackPhotons(); |
---|
123 | |
---|
124 | Hit fHit; |
---|
125 | Header *fHeader; |
---|
126 | |
---|
127 | Int_t UidToIndex( Int_t uid ) { return uid-1-fBufIndex; } |
---|
128 | Bool_t FillPixelsBuffer(Int_t first); |
---|
129 | Bool_t CheckPixelInBuffer(Int_t first); |
---|
130 | Bool_t ClearPixelsBuffers(); |
---|
131 | Bool_t InitFit(); |
---|
132 | Bool_t ClearFit(); |
---|
133 | void ComputeMap(Int_t first, Int_t last, const char* opt); |
---|
134 | |
---|
135 | void OptimizeBuffer(); |
---|
136 | |
---|
137 | Long_t fBufIndex; // index |
---|
138 | Long_t fBufferSize; // size of the buffers |
---|
139 | Long_t fMaxBufSize; // max buffer size |
---|
140 | vector< vector<Float_t> > fThetaFOVBuffer; // |
---|
141 | vector< vector<Float_t> > fPhiFOVBuffer; // |
---|
142 | |
---|
143 | // fitting |
---|
144 | Int_t fHitsThreshold; // min number of hits per channel |
---|
145 | Int_t fNbins; // bins of th and ph histos |
---|
146 | Int_t fNbinsFit; // bins in fDetail |
---|
147 | Float_t fNsigma; // number of sigma to limit fit at |
---|
148 | |
---|
149 | Float_t fFoV; // fov used for the input photons |
---|
150 | Float_t fFullFoV; // detector's field of view |
---|
151 | |
---|
152 | |
---|
153 | Int_t fFitUID; // uid of the last fitted pixel |
---|
154 | TArrayF fMapTheta; |
---|
155 | TArrayF fMapThetaRMS; |
---|
156 | TArrayF fMapPhi; |
---|
157 | TArrayF fMapPhiRMS; |
---|
158 | |
---|
159 | TArrayI fMapIndex; // pixel content. size = Npixles+1 (status) |
---|
160 | |
---|
161 | TH1F *fH1FitTheta; // histograms for fitting theta |
---|
162 | TH1F *fH1FitPhi; // histograms for fitting phi |
---|
163 | TH2F *fH2FitThetaPhi; // |
---|
164 | |
---|
165 | TH2F *fH2ThetaPhi; // full fov histogram for peak location |
---|
166 | |
---|
167 | |
---|
168 | EGViewer* fDisplay; // |
---|
169 | ClassDef(PixelMapBuilder,0) |
---|
170 | EsafConfigClass(Tools,PixelMapBuilder) |
---|
171 | }; |
---|
172 | |
---|
173 | #endif /* __PIXELMAPBUILDER_HH__ */ |
---|
174 | |
---|