]>
Commit | Line | Data |
---|---|---|
ab9f7002 | 1 | #ifndef ALITRDMCMSIM_H |
2 | #define ALITRDMCMSIM_H | |
dfd03fc3 | 3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
8 | /////////////////////////////////////////////////////// | |
9 | // // | |
10 | // Multi Chip Module Simulation Class // | |
11 | // // | |
12 | /////////////////////////////////////////////////////// | |
13 | ||
14 | #include <TObject.h> | |
40bd6ee4 | 15 | #include "AliTRDCommonParam.h" |
16 | #include "AliTRDcalibDB.h" | |
ab9f7002 | 17 | |
18 | class TClonesArray; | |
4ff7ed2b | 19 | class TH2F; |
dfd03fc3 | 20 | |
b0a41e80 | 21 | class AliRunLoader; |
dfd03fc3 | 22 | class AliTRDfeeParam; |
ecf39416 | 23 | class AliTRDSimParam; |
b0a41e80 | 24 | class AliTRDtrapConfig; |
ecf39416 | 25 | class AliTRDcalibDB; |
dfd03fc3 | 26 | class AliTRDgeometry; |
1d93b218 | 27 | class AliTRDpadPlane; |
b65e5048 | 28 | class AliTRDarrayADC; |
40bd6ee4 | 29 | class AliTRDdigitsManager; |
dfd03fc3 | 30 | |
31 | class AliTRDmcmSim : public TObject { | |
dfd03fc3 | 32 | public: |
ecf39416 | 33 | AliTRDmcmSim(); |
34 | virtual ~AliTRDmcmSim(); | |
dfd03fc3 | 35 | |
b0a41e80 | 36 | void Init( Int_t cha, Int_t rob, Int_t mcm, Bool_t newEvent = kFALSE ); // Initialize MCM by the position parameters |
37 | void Reset(); // clears filter registers and internal data | |
4ff7ed2b | 38 | void SetNTimebins(Int_t ntimebins); |
b0a41e80 | 39 | |
ab9f7002 | 40 | Bool_t LoadMCM(AliRunLoader* const runloader, Int_t det, Int_t rob, Int_t mcm); |
b0a41e80 | 41 | void NoiseTest(Int_t nsamples, Int_t mean, Int_t sigma, Int_t inputGain = 1, Int_t inputTail = 2); |
dfd03fc3 | 42 | |
36dc3337 | 43 | Int_t GetDataRaw(Int_t iadc, Int_t timebin) const { return (fADCR[iadc][timebin] >> 2); } // Get unfiltered ADC data |
44 | Int_t GetDataFiltered(Int_t iadc, Int_t timebin) const { return (fADCF[iadc][timebin] >> 2); } // Get filtered ADC data | |
dfd03fc3 | 45 | void SetData(Int_t iadc, Int_t *adc); // Set ADC data with array |
ecf39416 | 46 | void SetData(Int_t iadc, Int_t it, Int_t adc ); // Set ADC data |
40bd6ee4 | 47 | void SetData(AliTRDarrayADC *adcArray, |
48 | AliTRDdigitsManager *digitsManager = 0x0); // Set ADC data from adcArray | |
dfd03fc3 | 49 | void SetDataPedestal(Int_t iadc ); // Fill ADC data with pedestal values |
40bd6ee4 | 50 | static void SetApplyCut(Bool_t applyCut) { fgApplyCut = applyCut; } |
dfd03fc3 | 51 | |
4ff7ed2b | 52 | static Float_t GetChargeNorm() { return fgChargeNorm; } |
53 | static void SetChargeNorm(Float_t chargenorm) { fgChargeNorm = chargenorm; } | |
54 | ||
55 | static Int_t GetAddBaseline() { return fgAddBaseline; } | |
56 | static void SetAddBaseline(Int_t baseline) { fgAddBaseline = baseline; } | |
57 | ||
b0a41e80 | 58 | Int_t GetDetector() const { return fDetector; }; // Returns Chamber ID (0-539) |
0c349049 | 59 | Int_t GetRobPos() const { return fRobPos; }; // Returns ROB position (0-7) |
60 | Int_t GetMcmPos() const { return fMcmPos; }; // Returns MCM position (0-17) (16,17 are mergers) | |
61 | Int_t GetRow() const { return fRow; }; // Returns Row number on chamber where the MCM is sitting | |
ecf39416 | 62 | Int_t GetCol( Int_t iadc ); // Get corresponding column (0-143) from for ADC channel iadc = [0:20] |
63 | // for the ADC/Col mapping, see: http://wiki.kip.uni-heidelberg.de/ti/TRD/index.php/Image:ROB_MCM_numbering.pdf | |
40bd6ee4 | 64 | static Bool_t GetApplyCut() { return fgApplyCut; } |
dfd03fc3 | 65 | |
4ff7ed2b | 66 | void WriteData(AliTRDarrayADC *digits); |
67 | Bool_t StoreTracklets(); // Stores tracklets via runloader | |
1d93b218 | 68 | |
b0a41e80 | 69 | Int_t ProduceRawStream( UInt_t *buf, Int_t bufsize, UInt_t iEv = 0 ); // Produce raw data stream - Read data format |
1d93b218 | 70 | Int_t ProduceTrackletStream( UInt_t *buf, Int_t bufsize ); // produce the tracklet stream for this MCM |
b0a41e80 | 71 | |
72 | // different stages of processing in the TRAP | |
73 | void Filter(); // Apply digital filters for existing data (according to configuration) | |
ecf39416 | 74 | void ZSMapping(); // Do ZS mapping for existing data |
b0a41e80 | 75 | void Tracklet(); // Run tracklet preprocessor and perform tracklet fit |
dfd03fc3 | 76 | |
b0a41e80 | 77 | // apply individual filters to all channels and timebins |
78 | void FilterPedestal(); // Apply pedestal filter | |
79 | void FilterGain(); // Apply gain filter | |
80 | void FilterTail(); // Apply tail filter | |
dfd03fc3 | 81 | |
b0a41e80 | 82 | // filter initialization (resets internal registers) |
83 | void FilterPedestalInit(); | |
84 | void FilterGainInit(); | |
85 | void FilterTailInit(Int_t baseline); //??? automatic baseline?? | |
ecf39416 | 86 | |
b0a41e80 | 87 | // feed single sample to individual filter |
88 | // this changes the internal registers | |
89 | // all filters operate on 12-bit values! | |
90 | UShort_t FilterPedestalNextSample(Int_t adc, Int_t timebin, UShort_t value); | |
91 | UShort_t FilterGainNextSample(Int_t adc, UShort_t value); | |
92 | UShort_t FilterTailNextSample(Int_t adc, UShort_t value); | |
1d93b218 | 93 | |
b0a41e80 | 94 | // tracklet calculation |
95 | void AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label); | |
96 | void CalcFitreg(); | |
97 | void TrackletSelection(); | |
98 | void FitTracklet(); | |
1d93b218 | 99 | |
4ff7ed2b | 100 | static Int_t GetPIDNBinsQ0() { return fgPidNBinsQ0; } |
101 | static Int_t GetPIDNBinsQ1() { return fgPidNBinsQ1; } | |
102 | static Int_t GetPID(Float_t q0, Float_t q1); | |
103 | ||
104 | static void SetPIDlut(TH2F *lut); | |
105 | static void SetPIDlut(Int_t *lut, Int_t nbinsq0, Int_t nbinsq1); | |
106 | static void SetPIDlutDefault(); | |
107 | ||
ab9f7002 | 108 | TClonesArray* GetTrackletArray() const { return fTrackletArray; } |
dfd03fc3 | 109 | |
b0a41e80 | 110 | // data display |
ab9f7002 | 111 | void Print(Option_t* const option="") const; // print stored data to stdout |
112 | void Draw(Option_t* const option =""); // draw data (ADC data, hits and tracklets) | |
36dc3337 | 113 | void DumpData( const char *const f, const char *const target ); // Dump data stored (only for debugging) |
dfd03fc3 | 114 | |
b0a41e80 | 115 | protected: |
116 | Bool_t CheckInitialized(); // Check whether the class is initialized | |
117 | ||
118 | Bool_t fInitialized; // Status whether the class is initialized or not | |
119 | Int_t fMaxTracklets; // maximum number of tracklet-words submitted per mcm **new** //??? | |
120 | Int_t fDetector; // Chamber ID | |
121 | Int_t fRobPos; // ROB Position on chamber | |
122 | Int_t fMcmPos; // MCM Position on chamber | |
123 | Int_t fRow; // Pad row number (0-11 or 0-15) of the MCM on chamber | |
124 | Int_t fNADC; // Number of ADC (usually 21) //??? static const | |
125 | Int_t fNTimeBin; // Number of Timebins (variable) //??? why stored here? taken from TRAPconfig | |
126 | Int_t **fADCR; // Array with MCM ADC values (Raw, 12 bit) | |
127 | Int_t **fADCF; // Array with MCM ADC values (Filtered, 12 bit) | |
128 | UInt_t *fMCMT; // tracklet word for one mcm/trap-chip **new** //??? needed? | |
129 | TClonesArray *fTrackletArray; // Array of AliTRDtrackletMCM which contains MC information in addition to the tracklet word | |
130 | Int_t **fZSM; // Zero suppression map | |
131 | Int_t *fZSM1Dim; // Zero suppression map (1 dimensional projection) | |
dfd03fc3 | 132 | |
b0a41e80 | 133 | static const Int_t fgkAddDigits = 2; // additional digits used for internal representation |
134 | // all internal data as after data control block (i.e. 12 bit), s. TRAP manual | |
135 | static const Int_t fgkNCPU = 4; // Number of CPUs in the TRAP | |
136 | Int_t fFitPtr[fgkNCPU]; // pointer to the tracklet to be calculated by CPU i | |
137 | static const Int_t fgkNHitsMC = 100; // maximum number of hits for which MC information is kept | |
dfd03fc3 | 138 | |
b0a41e80 | 139 | // Parameter classes |
140 | AliTRDfeeParam *fFeeParam; // FEE parameters | |
141 | AliTRDtrapConfig *fTrapConfig; // TRAP config | |
142 | AliTRDSimParam *fSimParam; // Simulation parameters | |
40bd6ee4 | 143 | AliTRDCommonParam *fCommonParam; // common parameters |
b0a41e80 | 144 | AliTRDcalibDB *fCal; // Calibration interface |
145 | AliTRDgeometry *fGeo; // Geometry | |
146 | ||
40bd6ee4 | 147 | AliTRDdigitsManager *fDigitsManager; // pointer to digits manager used for MC label calculation |
148 | ||
b0a41e80 | 149 | // internal filter registers |
150 | UInt_t* fPedAcc; // Accumulator for pedestal filter | |
151 | UInt_t* fGainCounterA; // Counter for values above FGTA in the gain filter | |
152 | UInt_t* fGainCounterB; // Counter for values above FGTB in the gain filter | |
153 | UShort_t* fTailAmplLong; // Amplitude of the long component in the tail filter | |
154 | UShort_t* fTailAmplShort; // Amplitude of the short component in the tail filter | |
155 | ||
156 | // hit detection | |
157 | // individual hits can be stored as MC info | |
ab9f7002 | 158 | struct Hit_t { // Array of detected hits (only available in MC) |
159 | Int_t fChannel; // ADC channel of the hit | |
160 | Int_t fTimebin; // timebin of the hit | |
161 | Int_t fQtot; // total charge of the hit | |
162 | Int_t fYpos; // calculated y-position | |
163 | Int_t fLabel; // label (only in MC) | |
164 | } fHits[fgkNHitsMC]; | |
b0a41e80 | 165 | Int_t fNHits; // Number of detected hits |
166 | ||
167 | // tracklet calculation | |
ab9f7002 | 168 | struct FitReg_t { // pointer to the 18 fit registers |
169 | Int_t fNhits; // number of hits | |
170 | UInt_t fQ0; // charge accumulated in first window | |
171 | UInt_t fQ1; // charge accumulated in second window | |
172 | UInt_t fSumX; // sum x | |
173 | Int_t fSumY; // sum y | |
174 | UInt_t fSumX2; // sum x**2 | |
175 | UInt_t fSumY2; // sum y**2 | |
176 | Int_t fSumXY; // sum x*y | |
177 | } *fFitReg; | |
b0a41e80 | 178 | |
179 | //??? cleaning up | |
180 | void Sort2(UShort_t idx1i, UShort_t idx2i, UShort_t val1i, UShort_t val2i, | |
ab9f7002 | 181 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *val1o, UShort_t *val2o) const; |
b0a41e80 | 182 | void Sort3(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, |
183 | UShort_t val1i, UShort_t val2i, UShort_t val3i, | |
184 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o, | |
185 | UShort_t *val1o, UShort_t *val2o, UShort_t *val3o); | |
186 | void Sort6To4(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i, | |
187 | UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i, | |
188 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o, UShort_t *idx4o, | |
189 | UShort_t *val1o, UShort_t *val2o, UShort_t *val3o, UShort_t *val4o); | |
190 | void Sort6To2Worst(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i, | |
191 | UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i, | |
192 | UShort_t *idx5o, UShort_t *idx6o); | |
193 | ||
ab9f7002 | 194 | UInt_t AddUintClipping(UInt_t a, UInt_t b, UInt_t nbits) const; // Add a and b (unsigned) with clipping to the maximum value representable by nbits |
b0a41e80 | 195 | |
196 | private: | |
197 | AliTRDmcmSim(const AliTRDmcmSim &m); // not implemented | |
198 | AliTRDmcmSim &operator=(const AliTRDmcmSim &m); // not implemented | |
199 | ||
36dc3337 | 200 | static Bool_t fgApplyCut; // apply cut on deflection length |
4ff7ed2b | 201 | |
36dc3337 | 202 | static Int_t fgAddBaseline; // add baseline to the ADC values |
4ff7ed2b | 203 | |
36dc3337 | 204 | static Float_t fgChargeNorm; // normalization factor for charge (for PID) |
205 | static Int_t fgPidNBinsQ0; // number of bins in the PID LUT for Q0 | |
206 | static Int_t fgPidNBinsQ1; // number of bins in the PID LUT for Q1 | |
207 | static Int_t fgPidLutDefault[40][50]; // the default PID LUT | |
208 | static Int_t *fgPidLut; // pointer to user defined PID LUT | |
209 | static Bool_t fgPidLutDelete; // owns the LUT | |
b0a41e80 | 210 | |
211 | ClassDef(AliTRDmcmSim,4) | |
dfd03fc3 | 212 | }; |
213 | ||
214 | #endif |