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