]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSConTableDB.cxx
change fMaxiparent to 150
[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 ---
29#include <iostream.h>
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){
76 cout << "configuratio of prototype is not known!!!" << endl ;
77 cout << "specify number of raws and columns in prototype" << endl ;
78 return ;
79 }
80 fRawOffset = (fGeom->GetNPhi() - fProtoRaws)/2 ;
81 fColOffset = (fGeom->GetNZ() - fProtoColumns )/ 2 ;
82 fAbsIdMap = new TArrayS(fNcrInProto) ;
83 for(Int_t raw =0; raw < fProtoRaws; raw ++){
84 for(Int_t col = 0; col < fProtoColumns ; col ++){
85 Int_t rawId = col*fProtoRaws + raw ;
86 Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
87 rel[2]=raw + fRawOffset ;
88 rel[3]=col + fColOffset ;
89 Int_t absId ;
90 fGeom->RelToAbsNumbering(rel,absId) ;
91 fAbsIdMap->AddAt(static_cast<UInt_t>(absId),rawId) ;
92 }
93 }
94
95}
96//____________________________________________________________________________
97void AliPHOSConTableDB::PlotProtoMap(Option_t * opt)
98{
99 //Visualyse connection table
100
101 TH2S * hMapProto = new TH2S("hMap","Map of Prototype ids",
102 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
103 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
104 TH2S * hMapPHOS = new TH2S("hMapPHOS","Map of PHOS ids",
105 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
106 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
107 TH2C * hMapBox = new TH2C("hMapBox","Map of Prototype ids",
108 fGeom->GetNPhi(),0,fGeom->GetNPhi(),
109 fGeom->GetNZ(),0,fGeom->GetNZ()) ;
110 for(Int_t raw =0; raw <fGeom->GetNPhi() ; raw ++)
111 for(Int_t col = 0; col <fGeom->GetNZ() ; col ++)
112 hMapBox->SetBinContent(raw+1,col+1,1) ;
113
114 for(Int_t raw =0; raw < fProtoRaws; raw ++){
115 for(Int_t col = 0; col < fProtoColumns ; col ++){
116 Int_t rawId = col*fProtoRaws + raw ;
117 Int_t rel[4] = {3,0,0,0} ; //We assume, that we deal with third module
118 rel[2]=raw + fRawOffset ;
119 rel[3]=col + fColOffset ;
120 hMapProto->SetBinContent(rel[2]+1,rel[3]+1,rawId);
121 Int_t absId ;
122 fGeom->RelToAbsNumbering(rel,absId) ;
123 hMapPHOS->SetBinContent(rel[2]+1,rel[3]+1,absId) ;
124 }
125 }
126
127
128 if(strstr(opt,"Zoom")||strstr(opt,"zoom")){
129 static_cast<TAxis *>(hMapBox->GetXaxis())->SetRange(fRawOffset+1,fGeom->GetNPhi()-fRawOffset) ;
130 static_cast<TAxis *>(hMapBox->GetYaxis())->SetRange(fColOffset+1,fGeom->GetNZ()-fColOffset) ;
131 }
132 hMapBox->Draw("box") ;
133 if(strstr(opt,"PHOS"))
134 hMapPHOS->Draw("textsame") ;
135 else
136 hMapProto->Draw("textsame") ;
137
138}
139//____________________________________________________________________________
140Int_t AliPHOSConTableDB::Raw2AbsId(Int_t rawId){
141 //converts numbering of modules in prototipe into
142 //numbering in PHOS
143 if(rawId >= 0 && rawId<fNcrInProto)
144 return fAbsIdMap->At(rawId) ;
145 else
146 return 0 ;
147}
148//____________________________________________________________________________
149void AliPHOSConTableDB::Print(Option_t * option)const {
150
151 cout << GetName() << " " << GetTitle() << endl ;
152 cout << "PHOS Geometry configured for " ;
153 if(fGeom)
154 cout << fGeom->GetName() << " " << fGeom->GetTitle() << endl ;
155 else
156 cout << " null " << endl ;
157 cout << "-------Prototype parameters--------" << endl ;
158 cout << " number of columns: " << fProtoColumns << endl ;
159 cout << " number of raws: " << fProtoRaws << endl ;
160 cout << " centered in third PHOS module with offsets: " <<endl ;
161 cout << " raw: " << fRawOffset << " of " << fGeom->GetNPhi() << endl ;
162 cout << " col: " << fColOffset << " of " << fGeom->GetNZ() << endl ;
163 cout << "------------------------------------" << endl ;
164}