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