]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSConTableDB.cxx
Mods for Mac OS X
[u/mrichter/AliRoot.git] / PHOS / AliPHOSConTableDB.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 // Class provides correspondence between "raw numbers" i.e. number of crustall 
20 // in prototype and PHOT AbsId numer, used in reconstruction.
21 // First it calculates correspondence automatically, assuming, that 
22 // prototype, having N raws and M columns is situated in the center 
23 // of middle (third) PHOS module. Then this correspondence can be edited 
24 // manually. One can convert Raw->AbsId and visa versa AbsId->RawId.
25 //
26 //*-- Author :  D.Peressounko ("RRC Kurchatov Institute") 
27 //////////////////////////////////////////////////////////////////////////////
28
29 // --- ROOT system ---
30 #include "TArrayS.h"
31 #include "TH2S.h"
32
33 // --- Standard library ---
34
35 // --- AliRoot header files ---
36 #include "AliLog.h"
37 #include "AliPHOSGeometry.h"
38 #include "AliPHOSConTableDB.h"
39
40 ClassImp(AliPHOSConTableDB)
41
42
43 //____________________________________________________________________________ 
44   AliPHOSConTableDB::AliPHOSConTableDB():TNamed("AliPHOSConTableDB","Beamtest2002") 
45 {
46 //default constructor, nothing created.
47   fNcrInProto = 0 ;
48   fProtoRaws = 0 ;
49   fProtoColumns = 0 ;
50   fRawOffset = 0 ;
51   fColOffset = 0 ;
52   fGeom = 0;
53   fAbsIdMap = 0 ;
54   fRawIdMap = 0 ;
55 }
56
57 //____________________________________________________________________________ 
58   AliPHOSConTableDB::AliPHOSConTableDB(const char * title):TNamed("AliPHOSConTableDB",title) 
59 {
60  //Normally used constructor 
61   fNcrInProto = 0 ;
62   fProtoRaws = 0 ;
63   fProtoColumns = 0 ;
64   fRawOffset = 0 ;
65   fColOffset = 0 ;
66   fAbsIdMap = 0 ;
67   fRawIdMap = 0 ;
68
69   fGeom = AliPHOSGeometry::GetInstance("IHEP","") ;
70
71 }
72
73 //____________________________________________________________________________ 
74 AliPHOSConTableDB::AliPHOSConTableDB(const AliPHOSConTableDB& cdb):TNamed(cdb.GetName(), cdb.GetTitle()) 
75 {
76   //Copy constructor
77   
78   fProtoRaws=cdb.fProtoRaws ;        //  Parameters
79   fProtoColumns=cdb.fProtoColumns ;     //  used to calculate
80   fRawOffset=cdb.fRawOffset ;        //  correspondance
81   fColOffset=cdb.fColOffset ;        //  map
82   fNcrInProto=cdb.fNcrInProto ;       //Number of channels in prototype
83   fMinAbsId=cdb.fMinAbsId ;         //Minimal AbsId, corresponding to some prototype cristall.
84   fMaxAbsId=cdb.fMaxAbsId ;         //Maximal AbsId, corresponding to some prototype cristall
85   fAbsIdMap=new TArrayS(*(cdb.fAbsIdMap)) ;         //Map of correspondance between Raw and PHOS ID
86   fRawIdMap=new TArrayS(*(cdb.fRawIdMap)) ;         //Map of correspondance between AbsId and Raw
87 }
88
89 //____________________________________________________________________________ 
90   AliPHOSConTableDB::~AliPHOSConTableDB()
91 {
92   if(fAbsIdMap)
93     delete fAbsIdMap ;
94   if(fRawIdMap)
95     delete fRawIdMap ;
96 }
97
98 //____________________________________________________________________________ 
99 void  AliPHOSConTableDB::BuildDB(void)
100
101   //Make a map between Protopype cristalls and PHOS crystalls
102   //assuming, that prototype is centered in the third module of the PHOS
103   fNcrInProto =fProtoRaws*fProtoColumns ;
104   if(!fNcrInProto){
105     AliError(Form("configuratio of prototype is not known!!!\n Specify number of raws and columns in prototype"));
106     return ;
107   }
108   fRawOffset = (fGeom->GetNPhi() - fProtoRaws)/2 ;
109   fColOffset = (fGeom->GetNZ() - fProtoColumns )/ 2 ;
110   fAbsIdMap = new TArrayS(fNcrInProto) ;
111   fMinAbsId = fGeom->GetNCristalsInModule()*2 +
112     fRawOffset*fGeom->GetNZ()+fColOffset+1 ;
113   fMaxAbsId = fGeom->GetNCristalsInModule()*2 +
114     (fRawOffset + fProtoRaws)*fGeom->GetNZ()- 
115      fColOffset ;
116   fRawIdMap = new TArrayS(fMaxAbsId-fMinAbsId+1) ;
117   for(Int_t raw =0; raw < fProtoRaws ; raw ++){
118     for(Int_t col = 0; col < fProtoColumns ; col ++){
119       Int_t rawId = raw*fProtoColumns + col ;
120       Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
121       rel[2]=raw + fRawOffset+1 ;
122       rel[3]=col + fColOffset+1 ;
123       Int_t absId ;
124       fGeom->RelToAbsNumbering(rel,absId) ;
125       fAbsIdMap->AddAt(static_cast<UInt_t>(absId),rawId) ;
126       fRawIdMap->AddAt(static_cast<UInt_t>(rawId),absId-fMinAbsId) ;
127     }
128   }
129
130 }
131 //____________________________________________________________________________ 
132 void AliPHOSConTableDB::PlotProtoMap(Option_t * opt)
133 {
134   //Visualyse connection table
135
136   TH2S * hMapProto = new TH2S("hMap","Map of Prototype ids",
137                               fGeom->GetNPhi(),0,fGeom->GetNPhi(),
138                               fGeom->GetNZ(),0,fGeom->GetNZ()) ;
139   TH2S * hMapPHOS = new TH2S("hMapPHOS","Map of PHOS ids",
140                              fGeom->GetNPhi(),0,fGeom->GetNPhi(),
141                              fGeom->GetNZ(),0,fGeom->GetNZ()) ;
142   TH2C * hMapBox = new TH2C("hMapBox","Map of Prototype ids",
143                               fGeom->GetNPhi(),0,fGeom->GetNPhi(),
144                               fGeom->GetNZ(),0,fGeom->GetNZ()) ; 
145   for(Int_t raw =0; raw <fGeom->GetNPhi() ; raw ++)
146     for(Int_t col = 0; col <fGeom->GetNZ() ; col ++)
147       hMapBox->SetBinContent(raw+1,col+1,1) ;
148   
149   for(Int_t raw =0; raw < fProtoRaws; raw ++){
150     for(Int_t col = 0; col < fProtoColumns ; col ++){
151       Int_t rawId = col*fProtoRaws + raw ;
152       Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
153       rel[2]=raw + fRawOffset ;
154       rel[3]=col + fColOffset ;
155       hMapProto->SetBinContent(rel[2]+1,rel[3]+1,rawId);
156       Int_t absId ;
157       fGeom->RelToAbsNumbering(rel,absId) ;
158       hMapPHOS->SetBinContent(rel[2]+1,rel[3]+1,absId) ;
159     }
160   }
161
162
163   if(strstr(opt,"Zoom")||strstr(opt,"zoom")){
164     static_cast<TAxis *>(hMapBox->GetXaxis())->SetRange(fRawOffset+1,fGeom->GetNPhi()-fRawOffset) ;
165     static_cast<TAxis *>(hMapBox->GetYaxis())->SetRange(fColOffset+1,fGeom->GetNZ()-fColOffset) ;    
166   }
167    hMapBox->Draw("box") ;
168    if(strstr(opt,"PHOS"))
169      hMapPHOS->Draw("textsame") ;
170    else
171      hMapProto->Draw("textsame") ;
172
173
174 //____________________________________________________________________________ 
175 Int_t AliPHOSConTableDB::AbsId2Raw(Int_t absId)const{
176   //converts numbering of modules in PHOS into
177   //numbering in prototype
178   if(absId >= fMinAbsId && absId<=fMaxAbsId){    
179     return fRawIdMap->At(absId-fMinAbsId) ;
180   }
181   else
182     return -1 ;
183 }
184 //____________________________________________________________________________ 
185 Int_t AliPHOSConTableDB::Raw2AbsId(Int_t rawId)const{
186   //converts numbering of modules in prototipe into
187   //numbering in PHOS
188   if(rawId >= 0 && rawId<fNcrInProto)
189     return fAbsIdMap->At(rawId) ;
190   else
191     return 0 ;
192 }
193 //____________________________________________________________________________ 
194 void AliPHOSConTableDB::Print()const {
195 //prints configuraion
196
197   TString message ; 
198   message  = " %s %s\n" ;
199   message += "PHOS Geometry configured for " ; 
200   if(fGeom)
201     message += "%s %s \n" ;
202   else
203     message += " null \n"  ;
204
205   AliInfo(Form(message.Data(), GetName(), GetTitle(), fGeom->GetName(), fGeom->GetTitle() )) ; 
206
207   message  = "\n-------Prototype parameters--------\n" ;
208   message += "    number of columns: %d \n" ; 
209   message += "    number of raws:    %d \n" ;
210   message += "    centered in third PHOS module with offsets: \n " ;
211   message += "    raw: %d of %d\n" ;
212   message += "    col: %d of %d\n" ; 
213   message += "------------------------------------ \n" ;
214
215   AliInfo(Form(message.Data(), fProtoColumns, fProtoRaws, fRawOffset, fGeom->GetNPhi(), fColOffset,fGeom->GetNZ() ));   
216 }
217 //____________________________________________________________________________
218 AliPHOSConTableDB& AliPHOSConTableDB::operator=(const AliPHOSConTableDB& cdb){
219 //Operator for coding convetion
220   fGeom=cdb.fGeom ;   //! PHOS geometry class
221   fProtoRaws=cdb.fProtoRaws ;        //  Parameters
222   fProtoColumns=cdb.fProtoColumns ;     //  used to calculate
223   fRawOffset=cdb.fRawOffset ;        //  correspondance
224   fColOffset=cdb.fColOffset ;        //  map
225   fNcrInProto=cdb.fNcrInProto ;       //Number of channels in prototype
226   fMinAbsId=cdb.fMinAbsId ;         //Minimal AbsId, corresponding to some prototype cristall.
227   fMaxAbsId=cdb.fMaxAbsId ;         //Maximal AbsId, corresponding to some prototype cristall
228   fAbsIdMap=new TArrayS(*(cdb.fAbsIdMap)) ;         //Map of correspondance between Raw and PHOS ID
229   fRawIdMap=new TArrayS(*(cdb.fRawIdMap)) ;         //Map of correspondance between AbsId and Raw
230   return *this ;
231 }
232
233
234