]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUSimulation.h
Fix in the rolling shutter implementation: in general it is impossible to have the
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSimulation.h
1 #ifndef ALIITSUSIMULATION_H
2 #define ALIITSUSIMULATION_H
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Author: The ALICE Off-line Project.                                    *
7  * Contributors are mentioned in the code where appropriate.              *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 #include <TObject.h>
19 #include "AliITSUSensMap.h"
20 #include "AliITSsegmentation.h"
21 #include "AliMathBase.h"
22
23 class AliITSCalibration;
24 class AliITSUSimuParam;
25 class AliITSUModule;
26 class TRandom;
27 class TSegCollection;
28 class AliITSUParamList;
29
30 // This is the base class for ITS detector signal simulations. Data members
31 // include are a pointer to the detectors specific response and segmentation
32 // classes. See the detector specific implementations for the propper code.
33 // The detector-specific implementations are responsible for processing detector type, 
34 // which still may have different segmentations!
35 // Note: the detector specific objects (segmentation, calib, etc.) are not owned
36 // by the object but set externaly
37
38 class AliITSUSimulation : public TObject 
39 {
40  public:
41   enum {kMaxROCycleAccept=126};             // flag for read-out cycle to discard
42   //
43   AliITSUSimulation();
44   AliITSUSimulation(AliITSUSimuParam* sim, AliITSUSensMap* map);
45   virtual ~AliITSUSimulation() {} 
46   AliITSUSimulation(const AliITSUSimulation &source);
47   AliITSUSimulation& operator=(const AliITSUSimulation &source);
48   virtual void Init() = 0;
49   //
50   void UpdateMapSignal(UInt_t col,UInt_t row, Int_t trk,Int_t ht,Double_t signal, Int_t roCycle=0);
51   void UpdateMapNoise(UInt_t col,UInt_t row, Double_t noise, Int_t roCycle=0);
52   virtual void InitSimulationModule(AliITSUModule* mod, Int_t ev, AliITSsegmentation* seg, AliITSUParamList* resp);
53   //
54   // Hits -> SDigits
55   virtual void SDigitiseModule() = 0;
56   virtual void FinishSDigitiseModule() = 0;
57   virtual Bool_t AddSDigitsToModule( TSeqCollection *pItemArray, Int_t mask );
58   //
59   // Hits -> Digits
60   virtual void DigitiseModule() = 0;
61   virtual void CreateFastRecPoints(AliITSUModule *,Int_t,TRandom *,TClonesArray* /*recp*/) {}
62   //
63   // readout phase (strobe, timing etc) generation
64   virtual void GenerateReadOutCycleOffset() {}
65   //
66   AliITSCalibration*  GetCalibDead()                   const {return fCalibDead;}
67   AliITSCalibration*  GetCalibNoisy()                  const {return fCalibNoisy;}
68   AliITSsegmentation* GetSegmentation()                const {return fSeg;}
69   AliITSUSimuParam*   GetSimuParam()                   const {return fSimuParam;}
70   AliITSUSensMap*     GetMap()                         const {return fSensMap;}
71   AliITSUModule*      GetModule()                      const {return fModule;}
72   AliITSUParamList*   GetResponseParam()               const {return fResponseParam;}
73   Int_t               GetEvent()                       const {return fEvent;}
74   Bool_t              GetDebug(Int_t level=1)          const {return fDebug>=level;}
75   
76   //
77   void SetCalibDead(AliITSCalibration *calib)              {fCalibDead = calib;}
78   void SetCalibNoisy(AliITSCalibration *calib)             {fCalibNoisy = calib;}
79   void SetSegmentation(AliITSsegmentation *seg)            {fSeg = seg; if (seg&&fSensMap) fSensMap->SetDimensions(seg->Npz(),seg->Npx(),2*kMaxROCycleAccept);}
80   void SetSimuParam(AliITSUSimuParam *sp)                  {fSimuParam = sp;}
81   virtual void SetResponseParam(AliITSUParamList* resp)    {fResponseParam = resp;}
82   void SetMap(AliITSUSensMap *p)                           {fSensMap = p;}
83   void SetModule(AliITSUModule* mod)                       {fModule=mod;} 
84   void SetEvent(Int_t evnt)                                {fEvent=evnt;} 
85   void SetDebug(Int_t level=5)                             {fDebug=level;}
86   void SetNoDebug()                                        {fDebug=0;}
87   void ClearMap()                                          {fSensMap->Clear();}
88   //
89   static  Int_t GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &ind);
90   //
91   static  Double_t GausInt1D(Double_t sig,Double_t a,Double_t b);
92   static  Double_t GausInt2D(Double_t sig0,Double_t a0,Double_t b0,
93                              Double_t sig1,Double_t a1,Double_t b1);
94   //
95  protected:
96   AliITSsegmentation  *fSeg;            //! segmentation
97   AliITSCalibration   *fCalibDead;      //! dead channels
98   AliITSCalibration   *fCalibNoisy;     //! noisy channels
99   AliITSUSensMap      *fSensMap;        //! sensor map for hits manipulations
100   AliITSUSimuParam    *fSimuParam;      //! simulation parameters
101   AliITSUParamList    *fResponseParam;  //! response parameterization data
102   AliITSUModule       *fModule;         //! module being processed
103   Int_t                fEvent;          //! event number being processed
104   Int_t                fDebug;          //!  debug flag
105
106   ClassDef(AliITSUSimulation,1)       // Simulation base class 
107     
108 };
109
110 //_____________________________________________________________________________
111 inline Double_t AliITSUSimulation::GausInt1D(Double_t sig,Double_t a,Double_t b)
112 {
113   // calculate gaussian integral from a to b (with respecto to mean)
114   const Double_t kRoot2 = 1.414213562; // Sqrt(2).
115   double sp = 1.0/(sig*kRoot2);
116   return 0.5*TMath::Abs( AliMathBase::ErfcFast(sp*a) - AliMathBase::ErfcFast(sp*b) );
117 }
118
119 //_____________________________________________________________________________
120 inline Double_t AliITSUSimulation::GausInt2D(Double_t sig0,Double_t a0,Double_t b0,
121                                              Double_t sig1,Double_t a1,Double_t b1)
122 {
123   // calculate gaussian 2D integral from x0 to x1 (with respect to mean)
124   const Double_t kRoot2 = 1.414213562; // Sqrt(2).
125   double sp0 = 1.0/(sig0*kRoot2);
126   double sp1 = 1.0/(sig1*kRoot2);
127   return 0.25*TMath::Abs( (AliMathBase::ErfcFast(sp0*a0) - AliMathBase::ErfcFast(sp0*b0)) *
128                           (AliMathBase::ErfcFast(sp1*a1) - AliMathBase::ErfcFast(sp1*b1)));
129 }
130
131 #endif