3 // Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
7 #include "AliL3Logging.h"
8 #include "AliL3Transform.h"
9 #include "AliL3TPCMapping.h"
15 //generated from Ulis txt file with read-roc.sh
16 #include "AliL3TPCMapping-iroc.generated"
17 #include "AliL3TPCMapping-oroc.generated"
20 Int_t AliL3TPCMapping::GetRealNPads(Int_t slicerow)
22 //see tpc numbering doc
24 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
25 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealNPads","Slicerow")
26 <<"Wrong slicerow "<<slicerow<<ENDLOG;
30 const Float_t k1=0.293878;// == 10/6*tan(10)
31 const Float_t k2=0.440817;// == 15/6*tan(10)
32 const Int_t knRowLow=AliL3Transform::GetNRowLow();
33 const Int_t knRowUp1=AliL3Transform::GetNRowUp1();
35 if(slicerow==0) return 68;
36 else if(slicerow<knRowLow){
37 Double_t dummy=slicerow/3+33.67;
38 return (2*Int_t(dummy));
41 Int_t rowup=slicerow-knRowLow;
43 Double_t dummy=k1*rowup+37.75;
44 return (2*Int_t(dummy));
48 Double_t dummy=k2*(rowup-knRowUp1+56.66);
49 return (2*Int_t(dummy));
53 Double_t AliL3TPCMapping::GetRealX(Int_t slicerow)
55 //see tpc numbering doc
56 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
57 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealX","Slicerow")
58 <<"Wrong slicerow "<<slicerow<<ENDLOG;
62 const Int_t knRowLow=AliL3Transform::GetNRowLow();
63 const Int_t knRowUp1=AliL3Transform::GetNRowUp1();
65 if(slicerow<knRowLow){
66 return (85.225+0.75*slicerow);
69 Int_t rowup=slicerow-knRowLow;
75 return (1.5*(rowup-knRowUp1)+199.35);
79 Double_t AliL3TPCMapping::GetRealY(Int_t slicerow, Int_t pad)
81 //see tpc numbering doc
82 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
83 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","Slicerow")
84 <<"Wrong slicerow "<<slicerow<<ENDLOG;
88 Int_t npads=GetRealNPads(slicerow);
89 if(pad<0 || pad >= npads){
90 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","pad")
91 <<"Wrong pad "<<pad<<" npads " <<npads<<ENDLOG;
95 const Int_t knRowLow=AliL3Transform::GetNRowLow();
97 if(slicerow<knRowLow){
98 return (0.4*pad+0.2-0.2*npads);
99 //== (pad-0.5*(npads-1))*fPadPitchWidthLow;
103 return (0.6*pad+0.3-0.3*npads);
104 // == (pad-0.5*(npads-1))*fPadPitchWidthUp;
110 #include "TPCMapping.h"
112 TPCMapping::TPCMapping(char* file){
114 fin = new ifstream();
119 TPCMapping::~TPCMapping(){
124 void TPCMapping::open(){
128 void TPCMapping::isOpen(){
131 void TPCMapping::read(){
133 for(int i = 0; i < 5504 ; i++){
134 for(int j = 0 ; j < 8 ; j++){
135 *fin >> fIRORC[i][j];
138 fsizeoffIRORC = 5504;
141 void TPCMapping::read(int* listofRCUs, int numofRCU){
144 for(int i = 0; i < 5504 ; i++){
145 for(int j = 0 ; j < 8 ; j++){
146 *fin >> fIRORC[pos][j];
148 for(int j = 0 ; j < numofRCU ; j++){
149 if( fIRORC[pos][5] == listofRCUs[j]){
158 void TPCMapping::print(){
160 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
161 for(int i = 0; i < fsizeoffIRORC ; i++){
165 void TPCMapping::print(int start, int end){
167 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
168 for(int i = start; i <= end ; i++){
172 void TPCMapping::print(int index){
175 getIndex(index) << "\t|" <<
176 getPadrow(index) << "\t|" <<
177 getPad(index) << "\t|" <<
178 getConnector(index) << "\t|" <<
179 getPin(index) << "\t|" <<
180 getFEC(index) << "\t|" <<
181 getFECchannel(index) << "\t|" <<
182 getFECconnector(index) << "\t|" <<
183 getAltroChannel(index) << "\t|" <<
184 getAltro(index) << "\t|" << endl;
186 int TPCMapping::getIndex(int index){
187 //COLUMN 0 -> INDEX (0 - 9983)
190 retval = fIRORC[index][0];
193 cout << "ERROR: Array Empty!" << endl;
197 int TPCMapping::getPadrow(int index){
198 //COLUMN 1 -> PADROW (0 - 95)
201 retval = fIRORC[index][1];
204 cout << "ERROR: Array Empty!" << endl;
208 int TPCMapping::getPad(int index){
209 //COLUMN 2 -> PAD (0 - (Np-1))
212 retval = fIRORC[index][2];
215 cout << "ERROR: Array Empty!" << endl;
219 int TPCMapping::getConnector(int index){
220 //COLUMN 3 -> Connector (1 - 468)
223 retval = fIRORC[index][3];
226 cout << "ERROR: Array Empty!" << endl;
230 int TPCMapping::getPin(int index){
231 //COLUMN 4 -> Pin (0 - 22)
234 retval = fIRORC[index][4];
237 cout << "ERROR: Array Empty!" << endl;
241 int TPCMapping::getFEC(int index){
242 //COLUMN 5 -> FEC (0 - 77)
245 retval = fIRORC[index][5];
248 cout << "ERROR: Array Empty!" << endl;
252 int TPCMapping::getFECchannel(int index){
253 //COLUMN 6 -> FEC Channel (0 - 127)
256 retval = fIRORC[index][6];
259 cout << "ERROR: Array Empty!" << endl;
263 int TPCMapping::getFECconnector(int index){
264 //COLUMN 7 -> FEC Connector (0 - 5)
267 retval = fIRORC[index][7];
270 cout << "ERROR: Array Empty!" << endl;
275 int TPCMapping::getAltroChannel(int index){
276 // every the channel to Altro ordering is 0,1,2,3,4,5,6,7,16,15,14,13,12,11,10,9,8
278 int channel = getFECchannel(index);
280 if( (channel/8)%2 == 0 ){ //every even block hast to be changed
283 retval = (channel/8)*8 + 7-channel%8; //Blocknumber + reversed internel Number
285 if( (channel/16)%2 != 0){
287 if( (channel/8)%2 == 0 )
294 cout << "ERROR: Array Empty!" << endl;
298 int TPCMapping::getAltro(int index){
301 int channel = getFECchannel(index);
306 cout << "ERROR: Array Empty!" << endl;
311 int TPCMapping::getPadsperRow(int row){
312 //IRORC Formula !!!!!!!!!!!!!!!!!!!!!!!!!
317 retval = 2*((int)(row/3.0+33.67));
321 void TPCMapping::myprint(){
325 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
327 for(int j = 0; j < 512 ; j++){
328 // cout << "j: " << j << " fec " << (j/128+29) << " channel: " << j%128 << endl;
331 for(int i = 0; i < fsizeoffIRORC ; i++){
332 if((getFEC(i) == FEC) && (getAltroChannel(i) == channel)) {
333 cout << j << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
334 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
335 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
336 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
341 void TPCMapping::myprint1(){
345 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
347 for(int j = 0; j < 95 ; j++){
348 for(int k = 0; k < getPadsperRow(j) ; k++){
349 for(int i = 0; i < fsizeoffIRORC ; i++){
350 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
351 cout << j << "\t" << k << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
352 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
353 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
354 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
360 void TPCMapping::myprint2(){
366 for(int j = 0; j < 95 ; j++){
367 for(int i = 0; i < fsizeoffIRORC ; i++){
368 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) ){
373 cout << rownum << "\t" << j << "\t";
374 for(int k = 0; k < getPadsperRow(j) ; k++){
375 for(int i = 0; i < fsizeoffIRORC ; i++){
376 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
377 cout << getAltroChannel(i)+(32-getFEC(i))*128 << "\t";
378 // cout << getAltroChannel(i) << "\t";