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