]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSConTableDB.cxx
Polishing to fulfill coding conventions
[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 "AliPHOSGeometry.h"
37 #include "AliPHOSConTableDB.h"
38
39 ClassImp(AliPHOSConTableDB)
40
41
42 //____________________________________________________________________________ 
43   AliPHOSConTableDB::AliPHOSConTableDB():TNamed("AliPHOSConTableDB","Beamtest2002") 
44 {
45 //default constructor, nothing created.
46   fNcrInProto = 0 ;
47   fProtoRaws = 0 ;
48   fProtoColumns = 0 ;
49   fRawOffset = 0 ;
50   fColOffset = 0 ;
51   fGeom = 0;
52   fAbsIdMap = 0 ;
53   fRawIdMap = 0 ;
54 }
55
56 //____________________________________________________________________________ 
57   AliPHOSConTableDB::AliPHOSConTableDB(const char * title):TNamed("AliPHOSConTableDB",title) 
58 {
59  //Normally used constructor 
60   fNcrInProto = 0 ;
61   fProtoRaws = 0 ;
62   fProtoColumns = 0 ;
63   fRawOffset = 0 ;
64   fColOffset = 0 ;
65   fAbsIdMap = 0 ;
66   fRawIdMap = 0 ;
67
68   fGeom = AliPHOSGeometry::GetInstance("IHEP","") ;
69
70 }
71 //____________________________________________________________________________ 
72   AliPHOSConTableDB::AliPHOSConTableDB(const AliPHOSConTableDB* cdb){
73 //Copy constructor
74
75   fProtoRaws=cdb->fProtoRaws ;        //  Parameters
76   fProtoColumns=cdb->fProtoColumns ;     //  used to calculate
77   fRawOffset=cdb->fRawOffset ;        //  correspondance
78   fColOffset=cdb->fColOffset ;        //  map
79   fNcrInProto=cdb->fNcrInProto ;       //Number of channels in prototype
80   fMinAbsId=cdb->fMinAbsId ;         //Minimal AbsId, corresponding to some prototype cristall.
81   fMaxAbsId=cdb->fMaxAbsId ;         //Maximal AbsId, corresponding to some prototype cristall
82   fAbsIdMap=new TArrayS(*(cdb->fAbsIdMap)) ;         //Map of correspondance between Raw and PHOS ID
83   fRawIdMap=new TArrayS(*(cdb->fRawIdMap)) ;         //Map of correspondance between AbsId and Raw
84
85 }
86 //____________________________________________________________________________ 
87   AliPHOSConTableDB::~AliPHOSConTableDB()
88 {
89   if(fAbsIdMap)
90     delete [] fAbsIdMap ;
91   if(fRawIdMap)
92     delete [] fRawIdMap ;
93 }
94
95 //____________________________________________________________________________ 
96 void  AliPHOSConTableDB::BuildDB(void)
97
98   //Make a map between Protopype cristalls and PHOS crystalls
99   //assuming, that prototype is centered in the third module of the PHOS
100   fNcrInProto =fProtoRaws*fProtoColumns ;
101   if(!fNcrInProto){
102     Error("BuildDB", "configuratio of prototype is not known!!!\n Specify number of raws and columns in prototype") ;
103     return ;
104   }
105   fRawOffset = (fGeom->GetNPhi() - fProtoRaws)/2 ;
106   fColOffset = (fGeom->GetNZ() - fProtoColumns )/ 2 ;
107   fAbsIdMap = new TArrayS(fNcrInProto) ;
108   fMinAbsId = fGeom->GetNCristalsInModule()*2 +
109     fRawOffset*fGeom->GetNZ()+fColOffset+1 ;
110   fMaxAbsId = fGeom->GetNCristalsInModule()*2 +
111     (fRawOffset + fProtoRaws)*fGeom->GetNZ()- 
112      fColOffset ;
113   fRawIdMap = new TArrayS(fMaxAbsId-fMinAbsId+1) ;
114   for(Int_t raw =0; raw < fProtoRaws ; raw ++){
115     for(Int_t col = 0; col < fProtoColumns ; col ++){
116       Int_t rawId = raw*fProtoColumns + col ;
117       Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
118       rel[2]=raw + fRawOffset+1 ;
119       rel[3]=col + fColOffset+1 ;
120       Int_t absId ;
121       fGeom->RelToAbsNumbering(rel,absId) ;
122       fAbsIdMap->AddAt(static_cast<UInt_t>(absId),rawId) ;
123       fRawIdMap->AddAt(static_cast<UInt_t>(rawId),absId-fMinAbsId) ;
124     }
125   }
126
127 }
128 //____________________________________________________________________________ 
129 void AliPHOSConTableDB::PlotProtoMap(Option_t * opt)
130 {
131   //Visualyse connection table
132
133   TH2S * hMapProto = new TH2S("hMap","Map of Prototype ids",
134                               fGeom->GetNPhi(),0,fGeom->GetNPhi(),
135                               fGeom->GetNZ(),0,fGeom->GetNZ()) ;
136   TH2S * hMapPHOS = new TH2S("hMapPHOS","Map of PHOS ids",
137                              fGeom->GetNPhi(),0,fGeom->GetNPhi(),
138                              fGeom->GetNZ(),0,fGeom->GetNZ()) ;
139   TH2C * hMapBox = new TH2C("hMapBox","Map of Prototype ids",
140                               fGeom->GetNPhi(),0,fGeom->GetNPhi(),
141                               fGeom->GetNZ(),0,fGeom->GetNZ()) ; 
142   for(Int_t raw =0; raw <fGeom->GetNPhi() ; raw ++)
143     for(Int_t col = 0; col <fGeom->GetNZ() ; col ++)
144       hMapBox->SetBinContent(raw+1,col+1,1) ;
145   
146   for(Int_t raw =0; raw < fProtoRaws; raw ++){
147     for(Int_t col = 0; col < fProtoColumns ; col ++){
148       Int_t rawId = col*fProtoRaws + raw ;
149       Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
150       rel[2]=raw + fRawOffset ;
151       rel[3]=col + fColOffset ;
152       hMapProto->SetBinContent(rel[2]+1,rel[3]+1,rawId);
153       Int_t absId ;
154       fGeom->RelToAbsNumbering(rel,absId) ;
155       hMapPHOS->SetBinContent(rel[2]+1,rel[3]+1,absId) ;
156     }
157   }
158
159
160   if(strstr(opt,"Zoom")||strstr(opt,"zoom")){
161     static_cast<TAxis *>(hMapBox->GetXaxis())->SetRange(fRawOffset+1,fGeom->GetNPhi()-fRawOffset) ;
162     static_cast<TAxis *>(hMapBox->GetYaxis())->SetRange(fColOffset+1,fGeom->GetNZ()-fColOffset) ;    
163   }
164    hMapBox->Draw("box") ;
165    if(strstr(opt,"PHOS"))
166      hMapPHOS->Draw("textsame") ;
167    else
168      hMapProto->Draw("textsame") ;
169
170
171 //____________________________________________________________________________ 
172 Int_t AliPHOSConTableDB::AbsId2Raw(Int_t absId)const{
173   //converts numbering of modules in PHOS into
174   //numbering in prototype
175   if(absId >= fMinAbsId && absId<=fMaxAbsId){    
176     return fRawIdMap->At(absId-fMinAbsId) ;
177   }
178   else
179     return -1 ;
180 }
181 //____________________________________________________________________________ 
182 Int_t AliPHOSConTableDB::Raw2AbsId(Int_t rawId)const{
183   //converts numbering of modules in prototipe into
184   //numbering in PHOS
185   if(rawId >= 0 && rawId<fNcrInProto)
186     return fAbsIdMap->At(rawId) ;
187   else
188     return 0 ;
189 }
190 //____________________________________________________________________________ 
191 void AliPHOSConTableDB::Print(Option_t * option)const {
192 //prints configuraion
193
194   TString message ; 
195   message  = " %s %s\n" ;
196   message += "PHOS Geometry configured for " ; 
197   if(fGeom)
198     message += "%s %s \n" ;
199   else
200     message += " null \n"  ;
201
202   Info("Print", message.Data(), GetName(), GetTitle(), fGeom->GetName(), fGeom->GetTitle() ) ; 
203
204   message  = "-------Prototype parameters--------\n" ;
205   message += "    number of columns: %d" ; 
206   message += "    number of raws:    %d" ;
207   message += "    centered in third PHOS module with offsets: " ;
208   message += "    raw: %d of %d\n" ;
209   message += "    col: %d of %d\n" ; 
210   message += "------------------------------------" ;
211
212   Info("Print", message.Data(), fProtoColumns, fProtoRaws, fRawOffset, fGeom->GetNPhi(), fColOffset,fGeom->GetNZ() );   
213 }
214 //____________________________________________________________________________
215 AliPHOSConTableDB& AliPHOSConTableDB::operator=(const AliPHOSConTableDB& cdb){
216 //Operator for coding convetion
217   fGeom=cdb.fGeom ;   //! PHOS geometry class
218   fProtoRaws=cdb.fProtoRaws ;        //  Parameters
219   fProtoColumns=cdb.fProtoColumns ;     //  used to calculate
220   fRawOffset=cdb.fRawOffset ;        //  correspondance
221   fColOffset=cdb.fColOffset ;        //  map
222   fNcrInProto=cdb.fNcrInProto ;       //Number of channels in prototype
223   fMinAbsId=cdb.fMinAbsId ;         //Minimal AbsId, corresponding to some prototype cristall.
224   fMaxAbsId=cdb.fMaxAbsId ;         //Maximal AbsId, corresponding to some prototype cristall
225   fAbsIdMap=new TArrayS(*(cdb.fAbsIdMap)) ;         //Map of correspondance between Raw and PHOS ID
226   fRawIdMap=new TArrayS(*(cdb.fRawIdMap)) ;         //Map of correspondance between AbsId and Raw
227   return *this ;
228 }
229
230
231