]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - FMD/AliFMDBaseDA.h
Added scripts
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.h
... / ...
CommitLineData
1// -*- mode: C++ -*-
2#ifndef ALIFMDBASEDA_H
3#define ALIFMDBASEDA_H
4
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
6 * reserved.
7 *
8 * See cxx source for full Copyright notice
9 */
10//
11// This class provides a base interface for the Detector Algorithms
12// (DA) of the FMD. At least three implementations are needed:
13// AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA . These classes
14// will provide the calibration data for the AliFMDPreprocessor to be
15// used in the shuttle. The input for this class are raw data
16// (AliRawReader) and the output is a comma-separated file
17// (std::ofstream) that contains the values defined in the
18// implementations of this class.
19//
20// Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
21//
22
23#include "TNamed.h"
24#include "TObjArray.h"
25#include "TClonesArray.h"
26#include "TFile.h"
27#include "iostream"
28#include "fstream"
29#include "TString.h"
30#include "AliRawReader.h"
31#include "AliFMDDigit.h"
32#include "AliFMDParameters.h"
33#include "TArrayS.h"
34class TDirectory;
35class AliFMDRawReader;
36class TH2;
37
38class AliFMDBaseDA: public TNamed
39{
40public:
41 /**
42 * Constructor
43 *
44 */
45 AliFMDBaseDA() ;
46 /**
47 * Copy constructor
48 *
49 * @param baseDA
50 */
51 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
52 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
53 /**
54 * Destructor
55 *
56 */
57 ~AliFMDBaseDA() ;
58 /**
59 * Run this DA
60 *
61 * @param fmdReader Raw input reader
62 */
63 void Run(AliRawReader* fmdReader);
64 /**
65 * Set whether to save diagnostics
66 *
67 * @param save If true, will output diagnostics file
68 */
69 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
70 /**
71 * Set whether to make summary histograms to be published to AMORE
72 *
73 * @param save If true, will generate summary QA histograms
74 */
75 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
76 /**
77 * Set the number of requried events
78 *
79 * @param nEvents Number of event we need
80 */
81 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
82 /**
83 * Get the number of required events
84 *
85 *
86 * @return number of required events
87 */
88 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
89 /**
90 * Get list of summary histograms
91 *
92 * @return Array of summary histograms or null if not defined
93 */
94 const TObjArray& GetSummaries() const { return fSummaries; }
95 /**
96 * Check if we saw data for detector
97 *
98 * @param det Detector number to check
99 * @return true if the code has seen data from the detector
100 */
101 bool HasSeenDetector(UShort_t d) { return (d == 0 || d > 3) ? false : fSeenDetectors[d-1]; }
102protected:
103 /**
104 * Initialize
105 *
106 */
107 virtual void Init() {};
108 /**
109 * Fill channels
110 *
111 */
112 virtual void FillChannels(AliFMDDigit* ) {};
113 /**
114 * Analyse a single strip result
115 *
116 */
117 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
118 /**
119 * Write header to output file
120 *
121 */
122 virtual void WriteHeaderToFile() {};
123 /**
124 * Add a strip container
125 *
126 */
127 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
128 UShort_t, UShort_t ) {};
129 /**
130 * End of event
131 *
132 */
133 virtual void FinishEvent() {};
134 /**
135 * End of run
136 *
137 */
138 virtual void Terminate(TFile* ) {};
139 /**
140 * Current event number
141 *
142 *
143 * @return
144 */
145 Int_t GetCurrentEvent() const {return fCurrentEvent;}
146 /**
147 * Rotate a set of files. @a base is the basic name of the files.
148 * If the file @a base.max exists it is removed.
149 * If the file @a base.n exists (where n < max) it is renamed to @a
150 * base.(n-1).
151 * If the file @a base exists, it is renamed to @a base.1
152 *
153 * @param base Base name of the files
154 * @param max Maximum number to keep (minus one for the current).
155 */
156 void Rotate(const char* base, int max) const;
157 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
158 //Char_t* fDiagnosticsFilename;
159 TString fDiagnosticsFilename; // name of diagnostics file
160 std::ofstream fOutputFile; // output file
161 std::ofstream fConditionsFile; // conditions file
162 Bool_t fSaveHistograms; // save hists or not
163 Bool_t fMakeSummaries; // save hists or not
164 TObjArray fDetectorArray; // array indiced by detector
165 /**
166 * Ge the half-ring index
167 *
168 * @param UShort_t
169 * @param Char_t
170 * @param UShort_t
171 *
172 * @return
173 */
174 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
175 /**
176 * Get the pulse size
177 *
178 * @param det Detector number
179 * @param ring Rin identifier
180 * @param board Board number
181 *
182 * @return Pulse step size
183 */
184 Int_t GetPulseSize(UShort_t det ,
185 Char_t ring,
186 UShort_t board)
187 {
188 return fPulseSize.At(GetHalfringIndex(det,ring,board));
189 }
190 /**
191 * Get number of events per pulse size
192 *
193 * @param det Detector number
194 * @param ring Rin identifier
195 * @param board Board number
196 *
197 * @return number of events per Pulse size
198 */
199 Int_t GetPulseLength(UShort_t det,
200 Char_t ring,
201 UShort_t board)
202 {
203 return fPulseLength.At(GetHalfringIndex(det,ring,board));
204 }
205
206 /**
207 * Get the detector path in diagnositcs file
208 *
209 * @param det Detector number
210 * @param full If true, return full path
211 *
212 * @return Path to detector
213 */
214 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
215 /**
216 * Get the ring path in diagnositcs file
217 *
218 * @param det Detector number
219 * @param ring Ring identifier
220 * @param full If true, return full path
221 *
222 * @return Path to ring
223 */
224 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
225 /**
226 * Get the sector path in diagnositcs file
227 *
228 * @param det Detector number
229 * @param ring Ring identifier
230 * @param sec Sector number
231 * @param full If true, return full path
232 *
233 * @return Path to sector
234 */
235 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
236 Bool_t full=kTRUE) const;
237 /**
238 * Get the strip path in diagnositcs file
239 *
240 * @param det Detector number
241 * @param ring Ring identifier
242 * @param sec Sector number
243 * @param str Strip number
244 * @param full If true, return full path
245 *
246 * @return Path to strip
247 */
248 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
249 UShort_t str, Bool_t full=kTRUE) const;
250
251
252
253 TArrayS fPulseSize; // Pulse size for gain calib
254 TArrayS fPulseLength; // Pulse length for gain calib
255
256 Bool_t fSeenDetectors[3]; // Detectors seen so far
257private:
258 /**
259 * Write conditions file
260 *
261 * @param fmdReader Raw input
262 */
263 void WriteConditionsData(AliFMDRawReader* fmdReader);
264 /**
265 * Set the current event
266 *
267 * @param currentEvent
268 */
269 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
270 /**
271 * Initialize container
272 *
273 * @param dir Directory to make containers in
274 */
275 void InitContainer(TDirectory* dir);
276 Int_t fRequiredEvents; // number of events required for this calib
277 Int_t fCurrentEvent; // the current event
278protected:
279 UInt_t fRunno; // Current run number
280 /**
281 * Utility function for defining summary histograms
282 *
283 * @param det Detector
284 * @param ring Ring identifier
285 * @param prefix Histogram prefix
286 * @param title Histogram title
287 */
288 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
289 UShort_t det, Char_t ring);
290 virtual void MakeSummary(UShort_t, Char_t) { }
291 TObjArray fSummaries;
292
293 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
294
295};
296#endif
297