]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsimulationSDD.h
One instance of AliITSresponse per sensor - AliITSresponse objects read/stored from...
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSDD.h
1 #ifndef ALIITSSIMULATIONSDD_H
2 #define ALIITSSIMULATIONSDD_H
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 // Simulation class for SDD                               //
10 ////////////////////////////////////////////////////////////
11
12 #include <TNtuple.h>
13 #include <TArrayF.h>
14
15 #include "AliITSsimulation.h"
16
17 class TH1F;
18 class TFile;
19 class TVector;
20 class TArrayI;
21 class TArrayF;
22 class AliITS;
23 class AliITSpList;
24 class AliITSMap;
25 class AliITSMapA1;
26 class AliITSMapA2;
27 class AliITSetfSDD;
28 class AliITSsegmentationSDD;
29 class AliITSInStream;
30 class AliITSresponse;
31 class AliITSresponseSDD;
32
33 class AliITSsimulationSDD : public AliITSsimulation {
34   public:
35     AliITSsimulationSDD(); // default constructor
36     //Standard Constructor
37     AliITSsimulationSDD(AliITSDetTypeSim* dettyp);
38     // Copy opporator
39     AliITSsimulationSDD(AliITSsimulationSDD &source);
40     virtual ~AliITSsimulationSDD(); // Destructor
41     // = opporator
42     AliITSsimulationSDD& operator=(const AliITSsimulationSDD &source);
43     virtual AliITSsimulation& operator=(const AliITSsimulation &source);
44     // Initilize variables for this simulation
45     void Init();
46
47     // Get a pointer to the segmentation object
48     virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(1);}
49     // set pointer to segmentation object
50     virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(1,seg);}
51
52     // set the scale size factor for the smples in FFT
53     virtual void SetScaleFourier(Int_t scale=4) {fScaleSize=scale;}
54     Int_t ScaleFourier() const {return fScaleSize;} // returns the scale factor
55     // set perpendicular tracks flag
56     virtual void SetPerpendTracksFlag(Bool_t flag=kFALSE) {fFlag=flag;}
57     // returns perpendicular track flag.
58     Bool_t PerpendTracksFlag() const {return fFlag;} 
59     // set crosstalk flag
60     virtual void SetCrosstalkFlag(Bool_t flag=kFALSE) {fCrosstalkFlag=flag;}
61     // return crosstalk flag
62     Bool_t CrosstalkFlag() const {return fCrosstalkFlag;}
63     // set compression parameters for 2D or 1D via response functions
64     void SetCompressParam();
65     // retrieve compression parameters for 2D or 1D
66     void CompressionParam(Int_t i, Int_t &db, Int_t &tl, Int_t &th);
67     // retrieve compression parameters for 2D or 1D
68     void CompressionParam(Int_t i, Int_t &db, Int_t &tl);
69
70     virtual Int_t Convert10to8(Int_t signal) const;//10 to 8 bit SDD compresion
71     virtual void ZeroSuppression(const char *opt); // Apply zero suppresion
72     virtual void Init2D();   // initiilzes 2D compresion algorithm
73     virtual void Compress2D(); // Applies 2D compresion algorithm
74     virtual void Init1D();   // initilizes 1D compresion algorithm
75     virtual void Compress1D(); // Applies 1D compresion algorithm
76     virtual void StoreAllDigits(); // if No compresion run this.
77     virtual void ReadBaseline();  // read baseline values from a file
78     // returns baseline and noise for a given anode i.
79     virtual void GetAnodeBaseline(Int_t i,Double_t &baseline,Double_t &noise) const;
80     // local implementation of ITS->AddDigit. Specific for SDD
81     virtual void AddDigit(Int_t i, Int_t j, Int_t signal);
82     // Finds clulsters of signals. Use with regards to Compresion algorithms
83     virtual void  FindCluster(Int_t i, Int_t j,Int_t signal,
84                               Int_t minval,Bool_t &cond);
85
86     // get parameters for 1D - this could be changed when we get more
87     // input from Torino after they have a look at the code 
88     virtual Int_t Tolerance(Int_t i) const {return fTol[i];}//returns tolerance
89     virtual Int_t Disable(Int_t i)  const {return fT2[i];}//high threshold  2D
90     // Set the output file name - for 1D encoding 
91     virtual void SetFileName(const char *filnam) {fFileName=filnam;}
92
93     // add baseline, noise, electronics and ADC saturation effects
94     void ChargeToSignal(Int_t mod,Bool_t bAddNoise=kFALSE);
95     // add dead channels
96     void ApplyDeadChannels(Int_t mod);
97     // add crosstalk effect
98     void ApplyCrosstalk(Int_t mod);
99     
100     // create maps to build the lists of tracks for each summable digit
101     void InitSimulationModule( Int_t module, Int_t event );
102     // clear maps
103     void ClearMaps();
104     // Summable Digitses a SDD module
105     void SDigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev);
106     // Add Summable digits to module maps.
107     Bool_t AddSDigitsToModule( TClonesArray *pItemArray, Int_t mask );
108     // digitize module from the sum of summable digits.
109     void FinishSDigitiseModule();
110     // Writes summable digits
111     void WriteSDigits();
112     // Introduces electronics effects and does zero-suppresion if required
113     void FinishDigits();
114     // Digitses a SDD module
115     void DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev);
116     // Spread charge in a SDD module
117     void HitsToAnalogDigits(AliITSmodule *mod);
118     // Sorts tracks for the 3 most highly contributed one to be added to digit.
119     //void SortTracks(Int_t *tracks,Float_t *charges,Int_t *hits
120     //                Int_t ntracks);
121     // collects and returns the fired SDD cells (uses AliITSMapA2...).
122     //void ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,TObjArray *list,
123     //            TClonesArray *padr);
124
125     // Creates histograms of maps for debugging
126     void CreateHistograms(Int_t scale);
127     // Fills histograms of maps for debugging
128     void FillHistograms();
129     // Resets histograms of maps for debugging
130     void ResetHistograms();
131     // Get the pointer to the array of histograms
132     TObjArray*  GetHistArray() {return fHis;}
133     // create a separate tree for background monitoring (2D) 
134     virtual  void  MakeTreeB(Option_t *option="B") 
135         { if(strstr(option,"B"))
136             fTreeB = new TNtuple("ntuple", "2D backgr","nz:nl:nh:low:anode");}
137     // presently a dummy routine use TreeB() instead
138     void GetTreeB(Int_t) { }
139     // Return pointer to TreeB
140     TNtuple *TreeB() {return fTreeB;}
141     void WriteToFile(TFile *fp);// Writes the histograms to a file
142     // Get's histogram of a particular anode.
143     TH1F *GetAnode(Int_t wing, Int_t anode);
144
145     // Sets the check noise flag.
146     void SetCheckNoise(Bool_t check=kFALSE) {fCheckNoise=check;}
147     // Returns the noise value
148     Float_t GetNoise();
149     // sets DoFFT value.
150     void SetDoFFT(Int_t doFFT=1) {fDoFFT=doFFT;}
151
152     // Print SSD simulation Parameters
153     virtual void PrintStatus() const;
154
155   private:
156     // Variables and pointers for local use only. Not Streamed out.
157     AliITS         *fITS;          //! local pointer to ITS
158     AliITSMapA2    *fHitMap2;      //! local pointer to map of signals
159     AliITSMapA2    *fHitSigMap2;   //! local pointer to map of signals
160     AliITSMapA2    *fHitNoiMap2;   //! local pointer to map of signals
161     AliITSInStream *fStream;       //! input file stream
162     AliITSetfSDD   *fElectronics;  //! local pointer to electronics simulation
163     Double_t       *fInZR;         //! [fScaleSize*fMaxNofSamples] input of the
164                                    // real part of FFT
165     Double_t       *fInZI;         //! [fScaleSize*fMaxNofSamples] 
166                                    // input of the imaginary part of FFT
167     Double_t       *fOutZR;        //! [fScaleSize*fMaxNofSamples] 
168                                    // output of the real part of FFT
169     Double_t       *fOutZI;        //! [fScaleSize*fMaxNofSamples] 
170                                    // output of the imaginary part of FFT
171     Bool_t         *fAnodeFire;     //! [#of anodes] Flag if there is a signal
172
173     TObjArray *fHis;          // just in case for histogramming
174     TArrayI    fD;            // decrease values for baseline eq.
175     TArrayI    fT1;           // low thresholds
176     TArrayI    fT2;           // high thresholds(2D) or disable (1D) 
177     TArrayI    fTol;          // tolerance
178     TArrayF    fBaseline;     // Baseline
179     TArrayF    fNoise;        // Noise value
180     TNtuple   *fTreeB;        // Background info tree for 2D
181     TString    fParam;        // Compresion algorithm options
182     TString    fFileName;     // File name for possible options above
183     Bool_t     fFlag;         // Flag used to simulate perpendicular tracks
184     Bool_t     fCheckNoise;   // Flag used to check the simulated noise
185     Bool_t     fCrosstalkFlag; // Flag used to apply the crosstalk effect
186     Int_t      fDoFFT;        // Flag used to switch off electronics when 0
187     Int_t      fNofMaps;      // Number of anodes used ( 1-2*nanodes per wing )
188     Int_t      fMaxNofSamples;// Number of time samples
189     Int_t      fScaleSize;    // scale size factor for the samples in FFT
190
191     ClassDef(AliITSsimulationSDD,1)  // Simulation of SDD clusters
192
193 };
194 #endif