1 #ifndef ALITRDMCMSIMNEW_H
2 #define ALITRDMCMSIMNEW_H
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 <TClonesArray.h>
20 class AliTRDtrapConfig;
26 class AliTRDmcmSim : public TObject {
29 virtual ~AliTRDmcmSim();
31 void Init( Int_t cha, Int_t rob, Int_t mcm, Bool_t newEvent = kFALSE ); // Initialize MCM by the position parameters
32 void Reset(); // clears filter registers and internal data
34 Bool_t LoadMCM(AliRunLoader *runloader, Int_t det, Int_t rob, Int_t mcm);
35 void NoiseTest(Int_t nsamples, Int_t mean, Int_t sigma, Int_t inputGain = 1, Int_t inputTail = 2);
37 void SetData(Int_t iadc, Int_t *adc); // Set ADC data with array
38 void SetData(Int_t iadc, Int_t it, Int_t adc ); // Set ADC data
39 void SetData(AliTRDarrayADC *adcArray); // Set ADC data from adcArray
40 void SetDataPedestal(Int_t iadc ); // Fill ADC data with pedestal values
42 Int_t GetDetector() const { return fDetector; }; // Returns Chamber ID (0-539)
43 Int_t GetRobPos() const { return fRobPos; }; // Returns ROB position (0-7)
44 Int_t GetMcmPos() const { return fMcmPos; }; // Returns MCM position (0-17) (16,17 are mergers)
45 Int_t GetRow() const { return fRow; }; // Returns Row number on chamber where the MCM is sitting
46 Int_t GetCol( Int_t iadc ); // Get corresponding column (0-143) from for ADC channel iadc = [0:20]
47 // for the ADC/Col mapping, see: http://wiki.kip.uni-heidelberg.de/ti/TRD/index.php/Image:ROB_MCM_numbering.pdf
49 void WriteData(AliTRDarrayADC *digits);
51 Int_t ProduceRawStream( UInt_t *buf, Int_t bufsize, UInt_t iEv = 0 ); // Produce raw data stream - Read data format
52 Int_t ProduceTrackletStream( UInt_t *buf, Int_t bufsize ); // produce the tracklet stream for this MCM
54 // different stages of processing in the TRAP
55 void Filter(); // Apply digital filters for existing data (according to configuration)
56 void ZSMapping(); // Do ZS mapping for existing data
57 void Tracklet(); // Run tracklet preprocessor and perform tracklet fit
59 // apply individual filters to all channels and timebins
60 void FilterPedestal(); // Apply pedestal filter
61 void FilterGain(); // Apply gain filter
62 void FilterTail(); // Apply tail filter
64 // filter initialization (resets internal registers)
65 void FilterPedestalInit();
66 void FilterGainInit();
67 void FilterTailInit(Int_t baseline); //??? automatic baseline??
69 // feed single sample to individual filter
70 // this changes the internal registers
71 // all filters operate on 12-bit values!
72 UShort_t FilterPedestalNextSample(Int_t adc, Int_t timebin, UShort_t value);
73 UShort_t FilterGainNextSample(Int_t adc, UShort_t value);
74 UShort_t FilterTailNextSample(Int_t adc, UShort_t value);
76 // tracklet calculation
77 void AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label);
79 void TrackletSelection();
82 TClonesArray* GetTrackletArray() { return fTrackletArray; }
85 void Print(Option_t* option="") const; // print stored data to stdout
86 void Draw(Option_t *option =""); // draw data (ADC data, hits and tracklets)
87 void DumpData( char *f, char *target ); // Dump data stored (only for debugging)
90 Bool_t CheckInitialized(); // Check whether the class is initialized
92 Bool_t fInitialized; // Status whether the class is initialized or not
93 Int_t fMaxTracklets; // maximum number of tracklet-words submitted per mcm **new** //???
94 Int_t fDetector; // Chamber ID
95 Int_t fRobPos; // ROB Position on chamber
96 Int_t fMcmPos; // MCM Position on chamber
97 Int_t fRow; // Pad row number (0-11 or 0-15) of the MCM on chamber
98 Int_t fNADC; // Number of ADC (usually 21) //??? static const
99 Int_t fNTimeBin; // Number of Timebins (variable) //??? why stored here? taken from TRAPconfig
100 Int_t **fADCR; // Array with MCM ADC values (Raw, 12 bit)
101 Int_t **fADCF; // Array with MCM ADC values (Filtered, 12 bit)
102 UInt_t *fMCMT; // tracklet word for one mcm/trap-chip **new** //??? needed?
103 TClonesArray *fTrackletArray; // Array of AliTRDtrackletMCM which contains MC information in addition to the tracklet word
104 Int_t **fZSM; // Zero suppression map
105 Int_t *fZSM1Dim; // Zero suppression map (1 dimensional projection)
107 static const Int_t fgkAddDigits = 2; // additional digits used for internal representation
108 // all internal data as after data control block (i.e. 12 bit), s. TRAP manual
109 static const Int_t fgkNCPU = 4; // Number of CPUs in the TRAP
110 Int_t fFitPtr[fgkNCPU]; // pointer to the tracklet to be calculated by CPU i
111 static const Int_t fgkNHitsMC = 100; // maximum number of hits for which MC information is kept
114 AliTRDfeeParam *fFeeParam; // FEE parameters
115 AliTRDtrapConfig *fTrapConfig; // TRAP config
116 AliTRDSimParam *fSimParam; // Simulation parameters
117 AliTRDcalibDB *fCal; // Calibration interface
118 AliTRDgeometry *fGeo; // Geometry
120 // internal filter registers
121 UInt_t* fPedAcc; // Accumulator for pedestal filter
122 UInt_t* fGainCounterA; // Counter for values above FGTA in the gain filter
123 UInt_t* fGainCounterB; // Counter for values above FGTB in the gain filter
124 UShort_t* fTailAmplLong; // Amplitude of the long component in the tail filter
125 UShort_t* fTailAmplShort; // Amplitude of the short component in the tail filter
128 // individual hits can be stored as MC info
135 } fHits[fgkNHitsMC]; // Array of detected hits (only available in MC)
136 Int_t fNHits; // Number of detected hits
138 // tracklet calculation
148 } *fFitReg; // pointer to the 18 fit registers
151 void Sort2(UShort_t idx1i, UShort_t idx2i, UShort_t val1i, UShort_t val2i,
152 UShort_t *idx1o, UShort_t *idx2o, UShort_t *val1o, UShort_t *val2o);
153 void Sort3(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i,
154 UShort_t val1i, UShort_t val2i, UShort_t val3i,
155 UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o,
156 UShort_t *val1o, UShort_t *val2o, UShort_t *val3o);
157 void Sort6To4(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i,
158 UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i,
159 UShort_t *idx1o, UShort_t *idx2o, UShort_t *idx3o, UShort_t *idx4o,
160 UShort_t *val1o, UShort_t *val2o, UShort_t *val3o, UShort_t *val4o);
161 void Sort6To2Worst(UShort_t idx1i, UShort_t idx2i, UShort_t idx3i, UShort_t idx4i, UShort_t idx5i, UShort_t idx6i,
162 UShort_t val1i, UShort_t val2i, UShort_t val3i, UShort_t val4i, UShort_t val5i, UShort_t val6i,
163 UShort_t *idx5o, UShort_t *idx6o);
165 UInt_t AddUintClipping(UInt_t a, UInt_t b, UInt_t nbits); // Add a and b (unsigned) with clipping to the maximum value representable by nbits
168 AliTRDmcmSim(const AliTRDmcmSim &m); // not implemented
169 AliTRDmcmSim &operator=(const AliTRDmcmSim &m); // not implemented
172 ClassDef(AliTRDmcmSim,4)