]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSConTableDB.cxx
Coding violations corrected
[u/mrichter/AliRoot.git] / PHOS / AliPHOSConTableDB.cxx
CommitLineData
f74edaba 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//_________________________________________________________________________
cd228525 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.
f74edaba 25//
cd228525 26//*-- Author : D.Peressounko ("RRC Kurchatov Institute")
f74edaba 27//////////////////////////////////////////////////////////////////////////////
28
29// --- ROOT system ---
30#include "TArrayS.h"
31#include "TH2S.h"
32
33// --- Standard library ---
21cd0c07 34
f74edaba 35// --- AliRoot header files ---
351dd634 36#include "AliLog.h"
f74edaba 37#include "AliPHOSGeometry.h"
38#include "AliPHOSConTableDB.h"
39
40ClassImp(AliPHOSConTableDB)
41
42
43//____________________________________________________________________________
44 AliPHOSConTableDB::AliPHOSConTableDB():TNamed("AliPHOSConTableDB","Beamtest2002")
45{
cd228525 46//default constructor, nothing created.
f74edaba 47 fNcrInProto = 0 ;
48 fProtoRaws = 0 ;
49 fProtoColumns = 0 ;
50 fRawOffset = 0 ;
51 fColOffset = 0 ;
52 fGeom = 0;
53 fAbsIdMap = 0 ;
503394a6 54 fRawIdMap = 0 ;
f74edaba 55}
56
57//____________________________________________________________________________
58 AliPHOSConTableDB::AliPHOSConTableDB(const char * title):TNamed("AliPHOSConTableDB",title)
59{
cd228525 60 //Normally used constructor
f74edaba 61 fNcrInProto = 0 ;
62 fProtoRaws = 0 ;
63 fProtoColumns = 0 ;
64 fRawOffset = 0 ;
65 fColOffset = 0 ;
503394a6 66 fAbsIdMap = 0 ;
67 fRawIdMap = 0 ;
f74edaba 68
cd228525 69 fGeom = AliPHOSGeometry::GetInstance("IHEP","") ;
f74edaba 70
71}
72
540e818b 73//____________________________________________________________________________
74AliPHOSConTableDB::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
cd228525 87}
540e818b 88
f74edaba 89//____________________________________________________________________________
90 AliPHOSConTableDB::~AliPHOSConTableDB()
91{
92 if(fAbsIdMap)
48cebc3e 93 delete fAbsIdMap ;
503394a6 94 if(fRawIdMap)
48cebc3e 95 delete fRawIdMap ;
f74edaba 96}
97
98//____________________________________________________________________________
99void 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){
351dd634 105 AliError(Form("configuratio of prototype is not known!!!\n Specify number of raws and columns in prototype"));
f74edaba 106 return ;
107 }
108 fRawOffset = (fGeom->GetNPhi() - fProtoRaws)/2 ;
109 fColOffset = (fGeom->GetNZ() - fProtoColumns )/ 2 ;
110 fAbsIdMap = new TArrayS(fNcrInProto) ;
503394a6 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 ++){
f74edaba 118 for(Int_t col = 0; col < fProtoColumns ; col ++){
503394a6 119 Int_t rawId = raw*fProtoColumns + col ;
f74edaba 120 Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
503394a6 121 rel[2]=raw + fRawOffset+1 ;
122 rel[3]=col + fColOffset+1 ;
f74edaba 123 Int_t absId ;
124 fGeom->RelToAbsNumbering(rel,absId) ;
125 fAbsIdMap->AddAt(static_cast<UInt_t>(absId),rawId) ;
503394a6 126 fRawIdMap->AddAt(static_cast<UInt_t>(rawId),absId-fMinAbsId) ;
f74edaba 127 }
128 }
129
130}
131//____________________________________________________________________________
132void 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//____________________________________________________________________________
cd228525 175Int_t AliPHOSConTableDB::AbsId2Raw(Int_t absId)const{
503394a6 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//____________________________________________________________________________
cd228525 185Int_t AliPHOSConTableDB::Raw2AbsId(Int_t rawId)const{
f74edaba 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//____________________________________________________________________________
e957fea8 194void AliPHOSConTableDB::Print()const {
cd228525 195//prints configuraion
f74edaba 196
21cd0c07 197 TString message ;
198 message = " %s %s\n" ;
199 message += "PHOS Geometry configured for " ;
f74edaba 200 if(fGeom)
21cd0c07 201 message += "%s %s \n" ;
f74edaba 202 else
21cd0c07 203 message += " null \n" ;
204
351dd634 205 AliInfo(Form(message.Data(), GetName(), GetTitle(), fGeom->GetName(), fGeom->GetTitle() )) ;
21cd0c07 206
48cebc3e 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 " ;
21cd0c07 211 message += " raw: %d of %d\n" ;
212 message += " col: %d of %d\n" ;
48cebc3e 213 message += "------------------------------------ \n" ;
21cd0c07 214
351dd634 215 AliInfo(Form(message.Data(), fProtoColumns, fProtoRaws, fRawOffset, fGeom->GetNPhi(), fColOffset,fGeom->GetNZ() ));
f74edaba 216}
cd228525 217//____________________________________________________________________________
218AliPHOSConTableDB& 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