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