AliPHOSCalibrationData added
[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//_________________________________________________________________________
19// Short description
20//
21//*-- Author : (SUBATECH)
22//////////////////////////////////////////////////////////////////////////////
23
24// --- ROOT system ---
25#include "TArrayS.h"
26#include "TH2S.h"
27
28// --- Standard library ---
21cd0c07 29
f74edaba 30// --- AliRoot header files ---
31#include "AliPHOSGeometry.h"
32#include "AliPHOSConTableDB.h"
33
34ClassImp(AliPHOSConTableDB)
35
36
37//____________________________________________________________________________
38 AliPHOSConTableDB::AliPHOSConTableDB():TNamed("AliPHOSConTableDB","Beamtest2002")
39{
40 fNcrInProto = 0 ;
41 fProtoRaws = 0 ;
42 fProtoColumns = 0 ;
43 fRawOffset = 0 ;
44 fColOffset = 0 ;
45 fGeom = 0;
46 fAbsIdMap = 0 ;
47}
48
49//____________________________________________________________________________
50 AliPHOSConTableDB::AliPHOSConTableDB(const char * title):TNamed("AliPHOSConTableDB",title)
51{
52 fNcrInProto = 0 ;
53 fProtoRaws = 0 ;
54 fProtoColumns = 0 ;
55 fRawOffset = 0 ;
56 fColOffset = 0 ;
57
58 fGeom = AliPHOSGeometry::GetInstance("GPS2","") ;
59
60}
61
62//____________________________________________________________________________
63 AliPHOSConTableDB::~AliPHOSConTableDB()
64{
65 if(fAbsIdMap)
66 delete [] fAbsIdMap ;
67}
68
69//____________________________________________________________________________
70void AliPHOSConTableDB::BuildDB(void)
71{
72 //Make a map between Protopype cristalls and PHOS crystalls
73 //assuming, that prototype is centered in the third module of the PHOS
74 fNcrInProto =fProtoRaws*fProtoColumns ;
75 if(!fNcrInProto){
21cd0c07 76 Error("BuildDB", "configuratio of prototype is not known!!!\n Specify number of raws and columns in prototype") ;
f74edaba 77 return ;
78 }
79 fRawOffset = (fGeom->GetNPhi() - fProtoRaws)/2 ;
80 fColOffset = (fGeom->GetNZ() - fProtoColumns )/ 2 ;
81 fAbsIdMap = new TArrayS(fNcrInProto) ;
82 for(Int_t raw =0; raw < fProtoRaws; raw ++){
83 for(Int_t col = 0; col < fProtoColumns ; col ++){
84 Int_t rawId = col*fProtoRaws + raw ;
85 Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
86 rel[2]=raw + fRawOffset ;
87 rel[3]=col + fColOffset ;
88 Int_t absId ;
89 fGeom->RelToAbsNumbering(rel,absId) ;
90 fAbsIdMap->AddAt(static_cast<UInt_t>(absId),rawId) ;
91 }
92 }
93
94}
95//____________________________________________________________________________
96void AliPHOSConTableDB::PlotProtoMap(Option_t * opt)
97{
98 //Visualyse connection table
99
100 TH2S * hMapProto = new TH2S("hMap","Map of Prototype ids",
101 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
102 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
103 TH2S * hMapPHOS = new TH2S("hMapPHOS","Map of PHOS ids",
104 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
105 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
106 TH2C * hMapBox = new TH2C("hMapBox","Map of Prototype ids",
107 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
108 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
109 for(Int_t raw =0; raw <fGeom->GetNPhi() ; raw ++)
110 for(Int_t col = 0; col <fGeom->GetNZ() ; col ++)
111 hMapBox->SetBinContent(raw+1,col+1,1) ;
112
113 for(Int_t raw =0; raw < fProtoRaws; raw ++){
114 for(Int_t col = 0; col < fProtoColumns ; col ++){
115 Int_t rawId = col*fProtoRaws + raw ;
116 Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
117 rel[2]=raw + fRawOffset ;
118 rel[3]=col + fColOffset ;
119 hMapProto->SetBinContent(rel[2]+1,rel[3]+1,rawId);
120 Int_t absId ;
121 fGeom->RelToAbsNumbering(rel,absId) ;
122 hMapPHOS->SetBinContent(rel[2]+1,rel[3]+1,absId) ;
123 }
124 }
125
126
127 if(strstr(opt,"Zoom")||strstr(opt,"zoom")){
128 static_cast<TAxis *>(hMapBox->GetXaxis())->SetRange(fRawOffset+1,fGeom->GetNPhi()-fRawOffset) ;
129 static_cast<TAxis *>(hMapBox->GetYaxis())->SetRange(fColOffset+1,fGeom->GetNZ()-fColOffset) ;
130 }
131 hMapBox->Draw("box") ;
132 if(strstr(opt,"PHOS"))
133 hMapPHOS->Draw("textsame") ;
134 else
135 hMapProto->Draw("textsame") ;
136
137}
138//____________________________________________________________________________
139Int_t AliPHOSConTableDB::Raw2AbsId(Int_t rawId){
140 //converts numbering of modules in prototipe into
141 //numbering in PHOS
142 if(rawId >= 0 && rawId<fNcrInProto)
143 return fAbsIdMap->At(rawId) ;
144 else
145 return 0 ;
146}
147//____________________________________________________________________________
148void AliPHOSConTableDB::Print(Option_t * option)const {
149
21cd0c07 150 TString message ;
151 message = " %s %s\n" ;
152 message += "PHOS Geometry configured for " ;
f74edaba 153 if(fGeom)
21cd0c07 154 message += "%s %s \n" ;
f74edaba 155 else
21cd0c07 156 message += " null \n" ;
157
158 Info("Print", message.Data(), GetName(), GetTitle(), fGeom->GetName(), fGeom->GetTitle() ) ;
159
160 message = "-------Prototype parameters--------\n" ;
161 message += " number of columns: %d" ;
162 message += " number of raws: %d" ;
163 message += " centered in third PHOS module with offsets: " ;
164 message += " raw: %d of %d\n" ;
165 message += " col: %d of %d\n" ;
166 message += "------------------------------------" ;
167
168 Info("Print", message.Data(), fProtoColumns, fProtoRaws, fRawOffset, fGeom->GetNPhi(), fColOffset,fGeom->GetNZ() );
f74edaba 169}