]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDmcmSim.h
Include D0->4prong by default
[u/mrichter/AliRoot.git] / TRD / AliTRDmcmSim.h
CommitLineData
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>
ab9f7002 15
16class TClonesArray;
dfd03fc3 17
b0a41e80 18class AliRunLoader;
dfd03fc3 19class AliTRDfeeParam;
ecf39416 20class AliTRDSimParam;
b0a41e80 21class AliTRDtrapConfig;
ecf39416 22class AliTRDcalibDB;
dfd03fc3 23class AliTRDgeometry;
1d93b218 24class AliTRDpadPlane;
b65e5048 25class AliTRDarrayADC;
dfd03fc3 26
27class AliTRDmcmSim : public TObject {
dfd03fc3 28 public:
ecf39416 29 AliTRDmcmSim();
30 virtual ~AliTRDmcmSim();
dfd03fc3 31
b0a41e80 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
34
ab9f7002 35 Bool_t LoadMCM(AliRunLoader* const runloader, Int_t det, Int_t rob, Int_t mcm);
b0a41e80 36 void NoiseTest(Int_t nsamples, Int_t mean, Int_t sigma, Int_t inputGain = 1, Int_t inputTail = 2);
dfd03fc3 37
dfd03fc3 38 void SetData(Int_t iadc, Int_t *adc); // Set ADC data with array
ecf39416 39 void SetData(Int_t iadc, Int_t it, Int_t adc ); // Set ADC data
b0a41e80 40 void SetData(AliTRDarrayADC *adcArray); // Set ADC data from adcArray
dfd03fc3 41 void SetDataPedestal(Int_t iadc ); // Fill ADC data with pedestal values
42
b0a41e80 43 Int_t GetDetector() const { return fDetector; }; // Returns Chamber ID (0-539)
0c349049 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
ecf39416 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
dfd03fc3 49
b0a41e80 50 void WriteData(AliTRDarrayADC *digits);
1d93b218 51
b0a41e80 52 Int_t ProduceRawStream( UInt_t *buf, Int_t bufsize, UInt_t iEv = 0 ); // Produce raw data stream - Read data format
1d93b218 53 Int_t ProduceTrackletStream( UInt_t *buf, Int_t bufsize ); // produce the tracklet stream for this MCM
b0a41e80 54
55 // different stages of processing in the TRAP
56 void Filter(); // Apply digital filters for existing data (according to configuration)
ecf39416 57 void ZSMapping(); // Do ZS mapping for existing data
b0a41e80 58 void Tracklet(); // Run tracklet preprocessor and perform tracklet fit
dfd03fc3 59
b0a41e80 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
dfd03fc3 64
b0a41e80 65 // filter initialization (resets internal registers)
66 void FilterPedestalInit();
67 void FilterGainInit();
68 void FilterTailInit(Int_t baseline); //??? automatic baseline??
ecf39416 69
b0a41e80 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);
1d93b218 76
b0a41e80 77 // tracklet calculation
78 void AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label);
79 void CalcFitreg();
80 void TrackletSelection();
81 void FitTracklet();
1d93b218 82
ab9f7002 83 TClonesArray* GetTrackletArray() const { return fTrackletArray; }
dfd03fc3 84
b0a41e80 85 // data display
ab9f7002 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)
b0a41e80 88 void DumpData( char *f, char *target ); // Dump data stored (only for debugging)
dfd03fc3 89
b0a41e80 90 protected:
91 Bool_t CheckInitialized(); // Check whether the class is initialized
92
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)
dfd03fc3 107
b0a41e80 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
dfd03fc3 113
b0a41e80 114 // Parameter classes
115 AliTRDfeeParam *fFeeParam; // FEE parameters
116 AliTRDtrapConfig *fTrapConfig; // TRAP config
117 AliTRDSimParam *fSimParam; // Simulation parameters
118 AliTRDcalibDB *fCal; // Calibration interface
119 AliTRDgeometry *fGeo; // Geometry
120
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
127
128 // hit detection
129 // individual hits can be stored as MC info
ab9f7002 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)
136 } fHits[fgkNHitsMC];
b0a41e80 137 Int_t fNHits; // Number of detected hits
138
139 // tracklet calculation
ab9f7002 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
149 } *fFitReg;
b0a41e80 150
151 //??? cleaning up
152 void Sort2(UShort_t idx1i, UShort_t idx2i, UShort_t val1i, UShort_t val2i,
ab9f7002 153 UShort_t *idx1o, UShort_t *idx2o, UShort_t *val1o, UShort_t *val2o) const;
b0a41e80 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);
165
ab9f7002 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
b0a41e80 167
168 private:
169 AliTRDmcmSim(const AliTRDmcmSim &m); // not implemented
170 AliTRDmcmSim &operator=(const AliTRDmcmSim &m); // not implemented
171
172
173 ClassDef(AliTRDmcmSim,4)
dfd03fc3 174};
175
176#endif