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