Coding conventions fixed.
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.h
CommitLineData
d3da6dc4 1#ifndef AliHMPIDParam_h
2#define AliHMPIDParam_h
3010c308 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
d3da6dc4 5
3010c308 6/* $Id$ */
7
8#include <TMath.h>
d3da6dc4 9#include <TNamed.h> //base class
10#include <TGeoManager.h> //Instance()
268f57b1 11#include <TGeoMatrix.h> //Instance()
d3da6dc4 12#include <TVector3.h> //Lors2Mars() Mars2Lors()
13
d3da6dc4 14// Class providing all the needed parametrised information
15// to construct the geometry, to define segmentation and to provide response model
16// In future will also provide all the staff needed for alignment and calibration
17
18class AliHMPIDParam :public TNamed
19{
20public:
21//ctor&dtor
606697a8 22 virtual ~AliHMPIDParam() {if (fgInstance){for(Int_t i=0;i<7;i++){delete fM[i];fM[i] = 0x0;};fgInstance=0;}}
1d6047fb 23
24 void Print(Option_t *opt="") const; //print current parametrization
25
d3da6dc4 26 static inline AliHMPIDParam* Instance(); //pointer to AliHMPIDParam singleton
58fc9564 27 static inline AliHMPIDParam* InstanceNoGeo(); //pointer to AliHMPIDParam singleton without geometry.root for MOOD, displays, ...
ae5a42aa 28//geo info
29 enum EChamberData{kMinCh=0,kMaxCh=6,kMinPc=0,kMaxPc=5}; //Segmenation
30 enum EPadxData{kPadPcX=80,kMinPx=0,kMaxPx=79,kMaxPcx=159}; //Segmentation structure along x
31 enum EPadyData{kPadPcY=48,kMinPy=0,kMaxPy=47,kMaxPcy=143}; //Segmentation structure along y
32
a8ff381e 33 static Float_t SizePadX ( ) {return fgCellX; } //pad size x, [cm]
34 static Float_t SizePadY ( ) {return fgCellY; } //pad size y, [cm]
ae5a42aa 35
a8ff381e 36 static Float_t SizePcX ( ) {return fgPcX; } // PC size x
37 static Float_t SizePcY ( ) {return fgPcY; } // PC size y
38 static Float_t MaxPcX (Int_t iPc ) {return fgkMaxPcX[iPc]; } // PC limits
39 static Float_t MaxPcY (Int_t iPc ) {return fgkMaxPcY[iPc]; } // PC limits
40 static Float_t MinPcX (Int_t iPc ) {return fgkMinPcX[iPc]; } // PC limits
41 static Float_t MinPcY (Int_t iPc ) {return fgkMinPcY[iPc]; } // PC limits
42 static Int_t Nsig ( ) {return fgSigmas; } //Getter n. sigmas for noise
43 static Float_t SizeAllX ( ) {return fgAllX; } //all PCs size x, [cm]
44 static Float_t SizeAllY ( ) {return fgAllY; } //all PCs size y, [cm]
ae5a42aa 45
a8ff381e 46 static Float_t LorsX (Int_t pc,Int_t padx ) {return (padx +0.5)*SizePadX()+fgkMinPcX[pc]; } //center of the pad x, [cm]
ae5a42aa 47
a8ff381e 48 static Float_t LorsY (Int_t pc,Int_t pady ) {return (pady +0.5)*SizePadY()+fgkMinPcY[pc]; } //center of the pad y, [cm]
ae5a42aa 49
a8ff381e 50 inline static void Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py); //(x,y)->(pc,px,py)
ae5a42aa 51
a8ff381e 52 static Int_t Abs (Int_t ch,Int_t pc,Int_t x,Int_t y) {return ch*100000000+pc*1000000+x*1000+y; } //(ch,pc,padx,pady)-> abs pad
56c73976 53 static Int_t DDL2C (Int_t ddl ) {return ddl/2; } //ddl -> chamber
a8ff381e 54 static Int_t A2C (Int_t pad ) {return pad/100000000; } //abs pad -> chamber
55 static Int_t A2P (Int_t pad ) {return pad%100000000/1000000; } //abs pad -> pc
56 static Int_t A2X (Int_t pad ) {return pad%1000000/1000; } //abs pad -> pad X
57 static Int_t A2Y (Int_t pad ) {return pad%1000; } //abs pad -> pad Y
ae5a42aa 58
a8ff381e 59 static Bool_t IsOverTh (Float_t q ) {return q >= fgSigmas; } //is digit over threshold?
60
b38ac33a 61 Double_t GetRefIdx ( )const{return fRadNmean; } //refractive index of freon
62 Bool_t GetInstType ( )const{return fgInstanceType; } //return if the instance is from geom or ideal
a8ff381e 63
64 inline static Bool_t IsInDead(Float_t x,Float_t y ); //is the point in dead area?
65 static Bool_t IsInside (Float_t x,Float_t y,Float_t d=0) {return x>-d&&y>-d&&x<fgkMaxPcX[kMaxPc]+d&&y<fgkMaxPcY[kMaxPc]+d; } //is point inside chamber boundaries?
ae5a42aa 66
a8ff381e 67 Double_t MeanIdxRad ()const {return 1.29204;} //<--TEMPORAR--> to be removed in future. Mean ref index C6F14
ae5a42aa 68 Double_t MeanIdxWin ()const {return 1.57819;} //<--TEMPORAR--> to be removed in future. Mean ref index quartz
69 Float_t DistCut ()const {return 1.0;} //<--TEMPORAR--> to be removed in future. Cut for MIP-TRACK residual
70 Float_t QCut ()const {return 100;} //<--TEMPORAR--> to be removed in future. Separation PHOTON-MIP charge
71 Float_t MultCut ()const {return 200;} //<--TEMPORAR--> to be removed in future. Multiplicity cut to activate WEIGHT procedure
72
a8ff381e 73 Double_t RadThick ()const {return 1.5;} //<--TEMPORAR--> to be removed in future. Radiator thickness
74 Double_t WinThick ()const {return 0.5;} //<--TEMPORAR--> to be removed in future. Window thickness
75 Double_t GapThick ()const {return 8.0;} //<--TEMPORAR--> to be removed in future. Proximity gap thickness
76 Double_t WinIdx ()const {return 1.5787;} //<--TEMPORAR--> to be removed in future. Mean refractive index of WIN material (SiO2)
77 Double_t GapIdx ()const {return 1.0005;} //<--TEMPORAR--> to be removed in future. Mean refractive index of GAP material (CH4)
ae5a42aa 78
d3da6dc4 79 static Int_t Stack(Int_t evt=-1,Int_t tid=-1); //Print stack info for event and tid
80 static Int_t StackCount(Int_t pid,Int_t evt); //Counts stack particles of given sort in given event
1d4857c5 81 static void IdealPosition(Int_t iCh,TGeoHMatrix *m); //ideal position of given chamber
82 //trasformation methodes
d3da6dc4 83 void Lors2Mars (Int_t c,Float_t x,Float_t y,Double_t *m,Int_t pl=kPc)const{Double_t z=0; switch(pl){case kPc:z=8.0;break; case kAnod:z=7.806;break; case kRad:z=-1.25; break;} Double_t l[3]={x-fX,y-fY,z}; fM[c]->LocalToMaster(l,m); }
84 TVector3 Lors2Mars (Int_t c,Float_t x,Float_t y, Int_t pl=kPc)const{Double_t m[3];Lors2Mars(c,x,y,m,pl); return TVector3(m); }//MRS->LRS
59d9d4b3 85 void Mars2Lors (Int_t c,Double_t *m,Float_t &x ,Float_t &y )const{Double_t l[3];fM[c]->MasterToLocal(m,l);x=l[0]+fX;y=l[1]+fY;}//MRS->LRS
86568433 86 void Mars2LorsVec(Int_t c,Double_t *m,Float_t &th,Float_t &ph )const{Double_t l[3]; fM[c]->MasterToLocalVect(m,l);
87 Float_t pt=TMath::Sqrt(l[0]*l[0]+l[1]*l[1]);
88 th=TMath::ATan(pt/l[2]);
89 ph=TMath::ATan2(l[1],l[0]);}
d3da6dc4 90 TVector3 Norm (Int_t c )const{Double_t n[3]; Norm(c,n); return TVector3(n); }//norm
91 void Norm (Int_t c,Double_t *n )const{Double_t l[3]={0,0,1};fM[c]->LocalToMasterVect(l,n); }//norm
59d9d4b3 92 void Point (Int_t c,Double_t *p,Int_t plane )const{Lors2Mars(c,0,0,p,plane);} //point of given chamber plane
58fc9564 93
b38ac33a 94 void SetRefIdx (Double_t refRadIdx ) {fRadNmean = refRadIdx;} //set refractive index of freon
95 void SetSigmas (Int_t sigmas ) {fgSigmas = sigmas;} //set sigma cut
96 void SetInstanceType(Bool_t inst ) {fgInstanceType = inst;} //kTRUE if from geomatry kFALSE if from ideal geometry
3278403b 97 //For PID
98 Double_t SigLoc (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to cathode segmetation
99 Double_t SigGeom (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to unknown photon origin
100 Double_t SigCrom (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to unknonw photon energy
101 Double_t Sigma2 (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh );//photon candidate sigma^2
a8ff381e 102
d3da6dc4 103 enum EPlaneId {kPc,kRad,kAnod}; //3 planes in chamber
a8ff381e 104 enum ETrackingFlags {kMipDistCut=-9,kMipQdcCut=-5,kNoPhotAccept=-11}; //flags for Reconstruction
ae5a42aa 105
d3da6dc4 106protected:
ae5a42aa 107 static /*const*/ Float_t fgkMinPcX[6]; //limits PC
108 static /*const*/ Float_t fgkMinPcY[6]; //limits PC
109 static /*const*/ Float_t fgkMaxPcX[6]; //limits PC
110 static /*const*/ Float_t fgkMaxPcY[6];
111
b38ac33a 112 static Int_t fgSigmas; //sigma Cut
113 static Bool_t fgInstanceType; //kTRUE if from geomatry kFALSE if from ideal geometry
114
115 static Float_t fgCellX, fgCellY, fgPcX, fgPcY, fgAllX, fgAllY; //definition of HMPID geometric parameters
58fc9564 116 AliHMPIDParam(Bool_t noGeo); //default ctor is protected to enforce it to be singleton
ae5a42aa 117
d3da6dc4 118 static AliHMPIDParam *fgInstance; //static pointer to instance of AliHMPIDParam singleton
ae5a42aa 119
423554a3 120 TGeoHMatrix *fM[7]; //pointers to matrices defining HMPID chambers rotations-translations
121 Float_t fX; //x shift of LORS with respect to rotated MARS
122 Float_t fY; //y shift of LORS with respect to rotated MARS
a8ff381e 123 Double_t fRadNmean; //C6F14 mean index as a running parameter
58fc9564 124
8f05fd11 125private:
126 AliHMPIDParam(const AliHMPIDParam& r); //dummy copy constructor
127 AliHMPIDParam &operator=(const AliHMPIDParam& r); //dummy assignment operator
128
d3da6dc4 129 ClassDef(AliHMPIDParam,0) //HMPID main parameters class
130};
cf7e313e 131
d3da6dc4 132//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
133AliHMPIDParam* AliHMPIDParam::Instance()
134{
135// Return pointer to the AliHMPIDParam singleton.
136// Arguments: none
137// Returns: pointer to the instance of AliHMPIDParam or 0 if no geometry
58fc9564 138 if(!fgInstance) new AliHMPIDParam(kFALSE); //default setting for reconstruction, if no geometry.root -> AliFatal
139 return fgInstance;
140}//Instance()
141//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
142AliHMPIDParam* AliHMPIDParam::InstanceNoGeo()
143{
144// Return pointer to the AliHMPIDParam singleton without the geometry.root.
145// Arguments: none
146// Returns: pointer to the instance of AliHMPIDParam or 0 if no geometry
147 if(!fgInstance) new AliHMPIDParam(kTRUE); //to avoid AliFatal, for MOOD and displays, use ideal geometry parameters
d3da6dc4 148 return fgInstance;
149}//Instance()
150//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ae5a42aa 151Bool_t AliHMPIDParam::IsInDead(Float_t x,Float_t y)
152{
153// Check is the current point is outside of sensitive area or in dead zones
154// Arguments: x,y -position
155// Returns: 1 if not in sensitive zone
156 for(Int_t iPc=0;iPc<6;iPc++)
157 if(x>=fgkMinPcX[iPc] && x<=fgkMaxPcX[iPc] && y>=fgkMinPcY[iPc] && y<=fgkMaxPcY [iPc]) return kFALSE; //in current pc
158
159 return kTRUE;
160}
161//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162void AliHMPIDParam::Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py)
163{
164// Check the pad of given position
165// Arguments: x,y- position [cm] in LORS; pc,px,py- pad where to store the result
166// Returns: none
167 pc=px=py=-1;
168 if (x>fgkMinPcX[0] && x<fgkMaxPcX[0]) {pc=0; px=Int_t( x / SizePadX());}//PC 0 or 2 or 4
169 else if(x>fgkMinPcX[1] && x<fgkMaxPcX[1]) {pc=1; px=Int_t((x-fgkMinPcX[1]) / SizePadX());}//PC 1 or 3 or 5
170 else return;
171 if (y>fgkMinPcY[0] && y<fgkMaxPcY[0]) { py=Int_t( y / SizePadY());}//PC 0 or 1
172 else if(y>fgkMinPcY[2] && y<fgkMaxPcY[2]) {pc+=2;py=Int_t((y-fgkMinPcY[2]) / SizePadY());}//PC 2 or 3
173 else if(y>fgkMinPcY[4] && y<fgkMaxPcY[4]) {pc+=4;py=Int_t((y-fgkMinPcY[4]) / SizePadY());}//PC 4 or 5
174 else return;
175}
d3da6dc4 176#endif