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