]>
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 | ||
ce4786b9 | 14 | #include <iostream> |
ab9f7002 | 15 | |
ce4786b9 | 16 | class TObject; |
ab9f7002 | 17 | class TClonesArray; |
4ff7ed2b | 18 | class TH2F; |
dfd03fc3 | 19 | |
b0a41e80 | 20 | class AliRunLoader; |
dfd03fc3 | 21 | class AliTRDfeeParam; |
b0a41e80 | 22 | class AliTRDtrapConfig; |
b65e5048 | 23 | class AliTRDarrayADC; |
ce4786b9 | 24 | class AliTRDarrayDictionary; |
40bd6ee4 | 25 | class AliTRDdigitsManager; |
dfd03fc3 | 26 | |
27 | class AliTRDmcmSim : public TObject { | |
dfd03fc3 | 28 | public: |
ecf39416 | 29 | AliTRDmcmSim(); |
30 | virtual ~AliTRDmcmSim(); | |
dfd03fc3 | 31 | |
ce4786b9 | 32 | void Init(Int_t det, Int_t rob, Int_t mcm, Bool_t newEvent = kFALSE); |
33 | // Initialize MCM by the position parameters | |
34 | ||
35 | void Reset(); | |
36 | // clears filter registers and internal data | |
b0a41e80 | 37 | |
ab9f7002 | 38 | Bool_t LoadMCM(AliRunLoader* const runloader, Int_t det, Int_t rob, Int_t mcm); |
ce4786b9 | 39 | |
b0a41e80 | 40 | void NoiseTest(Int_t nsamples, Int_t mean, Int_t sigma, Int_t inputGain = 1, Int_t inputTail = 2); |
dfd03fc3 | 41 | |
ce4786b9 | 42 | Int_t GetDataRaw(Int_t iadc, Int_t timebin) const { return (fADCR[iadc][timebin] >> 2); } |
43 | // Get unfiltered ADC data | |
44 | Int_t GetDataFiltered(Int_t iadc, Int_t timebin) const { return (fADCF[iadc][timebin] >> 2); } | |
45 | // Get filtered ADC data | |
46 | ||
dfd03fc3 | 47 | void SetData(Int_t iadc, Int_t *adc); // Set ADC data with array |
ce4786b9 | 48 | void SetData(Int_t iadc, Int_t it, Int_t adc); // Set ADC data |
40bd6ee4 | 49 | void SetData(AliTRDarrayADC *adcArray, |
50 | AliTRDdigitsManager *digitsManager = 0x0); // Set ADC data from adcArray | |
ce4786b9 | 51 | void SetDataPedestal(Int_t iadc); // Fill ADC data with pedestal values |
dfd03fc3 | 52 | |
ce4786b9 | 53 | static Bool_t GetApplyCut() { return fgApplyCut; } |
54 | static void SetApplyCut(Bool_t applyCut) { fgApplyCut = applyCut; } | |
4ff7ed2b | 55 | |
ce4786b9 | 56 | static Int_t GetAddBaseline() { return fgAddBaseline; } |
57 | static void SetAddBaseline(Int_t baseline) { fgAddBaseline = baseline; } | |
58 | // Additional baseline which is added for the processing | |
59 | // in the TRAP and removed when writing back the data. | |
60 | // This is needed to run with TRAP parameters set for a | |
61 | // different baseline but it will not change the baseline | |
62 | // of the output. | |
4ff7ed2b | 63 | |
b0a41e80 | 64 | Int_t GetDetector() const { return fDetector; }; // Returns Chamber ID (0-539) |
ce4786b9 | 65 | Int_t GetRobPos() const { return fRobPos; }; // Returns ROB position (0-7) |
66 | Int_t GetMcmPos() const { return fMcmPos; }; // Returns MCM position (0-17) (16,17 are mergers) | |
67 | Int_t GetRow() const { return fRow; }; // Returns Row number on chamber where the MCM is sitting | |
68 | Int_t GetCol( Int_t iadc ); // Get corresponding column (0-143) from for ADC channel iadc = [0:20] | |
ecf39416 | 69 | // for the ADC/Col mapping, see: http://wiki.kip.uni-heidelberg.de/ti/TRD/index.php/Image:ROB_MCM_numbering.pdf |
dfd03fc3 | 70 | |
4ff7ed2b | 71 | void WriteData(AliTRDarrayADC *digits); |
72 | Bool_t StoreTracklets(); // Stores tracklets via runloader | |
1d93b218 | 73 | |
ce4786b9 | 74 | Int_t ProduceRawStream( UInt_t *buf, Int_t bufsize, UInt_t iEv = 0 ) const; // Produce raw data stream - Real data format |
1d93b218 | 75 | Int_t ProduceTrackletStream( UInt_t *buf, Int_t bufsize ); // produce the tracklet stream for this MCM |
b0a41e80 | 76 | |
77 | // different stages of processing in the TRAP | |
78 | void Filter(); // Apply digital filters for existing data (according to configuration) | |
ecf39416 | 79 | void ZSMapping(); // Do ZS mapping for existing data |
b0a41e80 | 80 | void Tracklet(); // Run tracklet preprocessor and perform tracklet fit |
dfd03fc3 | 81 | |
b0a41e80 | 82 | // apply individual filters to all channels and timebins |
83 | void FilterPedestal(); // Apply pedestal filter | |
84 | void FilterGain(); // Apply gain filter | |
85 | void FilterTail(); // Apply tail filter | |
dfd03fc3 | 86 | |
b0a41e80 | 87 | // filter initialization (resets internal registers) |
ce4786b9 | 88 | void FilterPedestalInit(Int_t baseline = 10); |
b0a41e80 | 89 | void FilterGainInit(); |
ce4786b9 | 90 | void FilterTailInit(Int_t baseline = -1); |
ecf39416 | 91 | |
b0a41e80 | 92 | // feed single sample to individual filter |
93 | // this changes the internal registers | |
ce4786b9 | 94 | // all filters operate on (10+2)-bit values! |
b0a41e80 | 95 | UShort_t FilterPedestalNextSample(Int_t adc, Int_t timebin, UShort_t value); |
96 | UShort_t FilterGainNextSample(Int_t adc, UShort_t value); | |
97 | UShort_t FilterTailNextSample(Int_t adc, UShort_t value); | |
1d93b218 | 98 | |
b0a41e80 | 99 | // tracklet calculation |
100 | void AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label); | |
101 | void CalcFitreg(); | |
102 | void TrackletSelection(); | |
103 | void FitTracklet(); | |
1d93b218 | 104 | |
ce4786b9 | 105 | Int_t GetNHits() const { return fNHits; } |
106 | Bool_t GetHit(Int_t index, Int_t &channel, Int_t &timebin, Int_t &qtot, Int_t &ypos, Float_t &y, Int_t &label) const; | |
ab9f7002 | 107 | TClonesArray* GetTrackletArray() const { return fTrackletArray; } |
dfd03fc3 | 108 | |
b0a41e80 | 109 | // data display |
ab9f7002 | 110 | void Print(Option_t* const option="") const; // print stored data to stdout |
111 | void Draw(Option_t* const option =""); // draw data (ADC data, hits and tracklets) | |
ce4786b9 | 112 | |
113 | friend std::ostream& operator<<(std::ostream &os, const AliTRDmcmSim &mcm); // data output using ostream (e.g. cout << mcm;) | |
59f78ad5 | 114 | static ostream& Cfdat(ostream &os); // manipulator to activate cfdat output |
115 | static ostream& Raw (ostream &os); // manipulator to activate raw output | |
116 | static ostream& Text (ostream &os); // manipulator to activate text output | |
dfd03fc3 | 117 | |
b0a41e80 | 118 | protected: |
ce4786b9 | 119 | Bool_t CheckInitialized() const; // Check whether the class is initialized |
b0a41e80 | 120 | |
ce4786b9 | 121 | void SetNTimebins(Int_t ntimebins); // allocate data arrays corr. to the no. of timebins |
122 | ||
123 | static const Int_t fgkFormatIndex; // index for format settings in stream | |
124 | ||
125 | static const Int_t fgkNADC; // Number of ADC | |
126 | static const Int_t fgkMaxTracklets = 4; // maximum number of tracklet-words submitted per MCM (one per CPU) | |
127 | static const Int_t fgkAddDigits = 2; // additional digits used for internal representation of ADC data | |
128 | // all internal data as after data control block (i.e. 12 bit), s. TRAP manual | |
129 | static const Int_t fgkNCPU = 4; // Number of CPUs in the TRAP | |
130 | static const Int_t fgkNHitsMC = 100; // maximum number of hits for which MC information is kept | |
131 | ||
132 | static const UShort_t fgkFPshifts[4]; // shifts for pedestal filter | |
133 | ||
134 | ||
135 | Bool_t fInitialized; // memory is allocated if initialized | |
136 | Int_t fDetector; // Chamber ID | |
b0a41e80 | 137 | Int_t fRobPos; // ROB Position on chamber |
138 | Int_t fMcmPos; // MCM Position on chamber | |
139 | Int_t fRow; // Pad row number (0-11 or 0-15) of the MCM on chamber | |
ce4786b9 | 140 | Int_t fNTimeBin; // Number of timebins currently allocated |
b0a41e80 | 141 | Int_t **fADCR; // Array with MCM ADC values (Raw, 12 bit) |
142 | Int_t **fADCF; // Array with MCM ADC values (Filtered, 12 bit) | |
ce4786b9 | 143 | UInt_t *fMCMT; // tracklet word for one mcm/trap-chip |
b0a41e80 | 144 | TClonesArray *fTrackletArray; // Array of AliTRDtrackletMCM which contains MC information in addition to the tracklet word |
ce4786b9 | 145 | Int_t *fZSMap; // Zero suppression map (1 dimensional projection) |
dfd03fc3 | 146 | |
b0a41e80 | 147 | Int_t fFitPtr[fgkNCPU]; // pointer to the tracklet to be calculated by CPU i |
dfd03fc3 | 148 | |
b0a41e80 | 149 | // Parameter classes |
150 | AliTRDfeeParam *fFeeParam; // FEE parameters | |
151 | AliTRDtrapConfig *fTrapConfig; // TRAP config | |
b0a41e80 | 152 | |
40bd6ee4 | 153 | AliTRDdigitsManager *fDigitsManager; // pointer to digits manager used for MC label calculation |
ce4786b9 | 154 | AliTRDarrayDictionary* fDict[3]; // pointers to label dictionaries |
155 | ||
40bd6ee4 | 156 | |
b0a41e80 | 157 | // internal filter registers |
158 | UInt_t* fPedAcc; // Accumulator for pedestal filter | |
159 | UInt_t* fGainCounterA; // Counter for values above FGTA in the gain filter | |
160 | UInt_t* fGainCounterB; // Counter for values above FGTB in the gain filter | |
161 | UShort_t* fTailAmplLong; // Amplitude of the long component in the tail filter | |
162 | UShort_t* fTailAmplShort; // Amplitude of the short component in the tail filter | |
163 | ||
164 | // hit detection | |
165 | // individual hits can be stored as MC info | |
ab9f7002 | 166 | struct Hit_t { // Array of detected hits (only available in MC) |
167 | Int_t fChannel; // ADC channel of the hit | |
168 | Int_t fTimebin; // timebin of the hit | |
169 | Int_t fQtot; // total charge of the hit | |
170 | Int_t fYpos; // calculated y-position | |
171 | Int_t fLabel; // label (only in MC) | |
172 | } fHits[fgkNHitsMC]; | |
b0a41e80 | 173 | Int_t fNHits; // Number of detected hits |
174 | ||
175 | // tracklet calculation | |
ab9f7002 | 176 | struct FitReg_t { // pointer to the 18 fit registers |
ce4786b9 | 177 | Int_t fNhits; // number of hits |
ab9f7002 | 178 | UInt_t fQ0; // charge accumulated in first window |
179 | UInt_t fQ1; // charge accumulated in second window | |
180 | UInt_t fSumX; // sum x | |
ce4786b9 | 181 | Int_t fSumY; // sum y |
ab9f7002 | 182 | UInt_t fSumX2; // sum x**2 |
183 | UInt_t fSumY2; // sum y**2 | |
ce4786b9 | 184 | Int_t fSumXY; // sum x*y |
ab9f7002 | 185 | } *fFitReg; |
b0a41e80 | 186 | |
ce4786b9 | 187 | // Sort functions as in TRAP |
b0a41e80 | 188 | void Sort2(UShort_t idx1i, UShort_t idx2i, UShort_t val1i, UShort_t val2i, |
ab9f7002 | 189 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *val1o, UShort_t *val2o) const; |
b0a41e80 | 190 | void Sort3(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, |
191 | UShort_t val1i, UShort_t val2i, UShort_t val3i, | |
192 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o, | |
193 | UShort_t *val1o, UShort_t *val2o, UShort_t *val3o); | |
194 | void Sort6To4(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i, | |
195 | UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i, | |
196 | UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o, UShort_t *idx4o, | |
197 | UShort_t *val1o, UShort_t *val2o, UShort_t *val3o, UShort_t *val4o); | |
198 | void Sort6To2Worst(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i, | |
199 | UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i, | |
200 | UShort_t *idx5o, UShort_t *idx6o); | |
201 | ||
ce4786b9 | 202 | UInt_t AddUintClipping(UInt_t a, UInt_t b, UInt_t nbits) const; |
203 | // Add a and b (unsigned) with clipping to the maximum value representable by nbits | |
b0a41e80 | 204 | |
205 | private: | |
206 | AliTRDmcmSim(const AliTRDmcmSim &m); // not implemented | |
207 | AliTRDmcmSim &operator=(const AliTRDmcmSim &m); // not implemented | |
208 | ||
36dc3337 | 209 | static Bool_t fgApplyCut; // apply cut on deflection length |
4ff7ed2b | 210 | |
36dc3337 | 211 | static Int_t fgAddBaseline; // add baseline to the ADC values |
4ff7ed2b | 212 | |
ce4786b9 | 213 | ClassDef(AliTRDmcmSim,6) |
dfd03fc3 | 214 | }; |
215 | ||
ce4786b9 | 216 | std::ostream& operator<<(std::ostream& os, const AliTRDmcmSim& mcm); |
217 | ||
dfd03fc3 | 218 | #endif |