Reordering cuts to go faster
[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"
25#include "TClonesArray.h"
26#include "TFile.h"
27#include "iostream"
28#include "fstream"
a7e41e8d 29#include "TString.h"
a3b36d36 30#include "AliRawReader.h"
31#include "AliFMDDigit.h"
32#include "AliFMDParameters.h"
427e8f99 33#include "TArrayS.h"
e9c06036 34class TDirectory;
3effc6e7 35class AliFMDRawReader;
2a082c96 36class TH2;
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;}
6cf6e7a0 70 /**
2a082c96 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 /**
6cf6e7a0 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 */
101 bool HasSeenDetector(UShort_t d) { return (d == 0 || d > 3) ? false : fSeenDetectors[d-1]; }
e9c06036 102protected:
6cf6e7a0 103 /**
104 * Initialize
105 *
106 */
26be6417 107 virtual void Init() {};
6cf6e7a0 108 /**
109 * Fill channels
110 *
111 */
26be6417 112 virtual void FillChannels(AliFMDDigit* ) {};
6cf6e7a0 113 /**
114 * Analyse a single strip result
115 *
116 */
2a082c96 117 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
6cf6e7a0 118 /**
119 * Write header to output file
120 *
121 */
26be6417 122 virtual void WriteHeaderToFile() {};
6cf6e7a0 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 */
26be6417 133 virtual void FinishEvent() {};
6cf6e7a0 134 /**
135 * End of run
136 *
137 */
f7f0b643 138 virtual void Terminate(TFile* ) {};
6cf6e7a0 139 /**
140 * Current event number
141 *
142 *
143 * @return
144 */
c5569fbc 145 Int_t GetCurrentEvent() const {return fCurrentEvent;}
6cf6e7a0 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;
c5569fbc 157 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
a7e41e8d 158 //Char_t* fDiagnosticsFilename;
c5569fbc 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
2a082c96 163 Bool_t fMakeSummaries; // save hists or not
c5569fbc 164 TObjArray fDetectorArray; // array indiced by detector
6cf6e7a0 165 /**
166 * Ge the half-ring index
167 *
168 * @param UShort_t
169 * @param Char_t
170 * @param UShort_t
171 *
172 * @return
173 */
c5569fbc 174 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
6cf6e7a0 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 */
427e8f99 184 Int_t GetPulseSize(UShort_t det ,
185 Char_t ring,
6cf6e7a0 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 */
427e8f99 199 Int_t GetPulseLength(UShort_t det,
200 Char_t ring,
6cf6e7a0 201 UShort_t board)
202 {
203 return fPulseLength.At(GetHalfringIndex(det,ring,board));
204 }
427e8f99 205
6cf6e7a0 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 */
e9c06036 214 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
6cf6e7a0 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 */
e9c06036 224 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
6cf6e7a0 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 */
e9c06036 235 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
236 Bool_t full=kTRUE) const;
6cf6e7a0 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 */
e9c06036 248 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
249 UShort_t str, Bool_t full=kTRUE) const;
a3b36d36 250
f7f0b643 251
252
c5569fbc 253 TArrayS fPulseSize; // Pulse size for gain calib
254 TArrayS fPulseLength; // Pulse length for gain calib
427e8f99 255
c5569fbc 256 Bool_t fSeenDetectors[3]; // Detectors seen so far
e9c06036 257private:
6cf6e7a0 258 /**
259 * Write conditions file
260 *
261 * @param fmdReader Raw input
262 */
3effc6e7 263 void WriteConditionsData(AliFMDRawReader* fmdReader);
6cf6e7a0 264 /**
265 * Set the current event
266 *
267 * @param currentEvent
268 */
a3b36d36 269 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
6cf6e7a0 270 /**
271 * Initialize container
272 *
273 * @param dir Directory to make containers in
274 */
e9c06036 275 void InitContainer(TDirectory* dir);
c5569fbc 276 Int_t fRequiredEvents; // number of events required for this calib
277 Int_t fCurrentEvent; // the current event
6cf6e7a0 278protected:
279 UInt_t fRunno; // Current run number
2a082c96 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;
427e8f99 292
6cf6e7a0 293 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
a3b36d36 294
295};
296#endif
297