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)
21 { //see tpc numbering doc
23 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
24 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealNPads","Slicerow")
25 <<"Wrong slicerow "<<slicerow<<ENDLOG;
29 const Float_t k1=0.293878;// == 10/6*tan(10)
30 const Float_t k2=0.440817;// == 15/6*tan(10)
31 const Int_t NRowLow=AliL3Transform::GetNRowLow();
32 const Int_t NRowUp1=AliL3Transform::GetNRowUp1();
34 if(slicerow==0) return 68;
35 else if(slicerow<NRowLow){
36 Double_t dummy=slicerow/3+33.67;
37 return (2*Int_t(dummy));
40 Int_t rowup=slicerow-NRowLow;
42 Double_t dummy=k1*rowup+37.75;
43 return (2*Int_t(dummy));
47 Double_t dummy=k2*(rowup-NRowUp1+56.66);
48 return (2*Int_t(dummy));
52 Double_t AliL3TPCMapping::GetRealX(Int_t slicerow)
53 { //see tpc numbering doc
54 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
55 LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealX","Slicerow")
56 <<"Wrong slicerow "<<slicerow<<ENDLOG;
60 const Int_t NRowLow=AliL3Transform::GetNRowLow();
61 const Int_t NRowUp1=AliL3Transform::GetNRowUp1();
64 return (85.225+0.75*slicerow);
67 Int_t rowup=slicerow-NRowLow;
73 return (1.5*(rowup-NRowUp1)+199.35);
77 Double_t AliL3TPCMapping::GetRealY(Int_t slicerow, Int_t pad)
78 { //see tpc numbering doc
79 if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){
80 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","Slicerow")
81 <<"Wrong slicerow "<<slicerow<<ENDLOG;
85 Int_t npads=GetRealNPads(slicerow);
86 if(pad<0 || pad >= npads){
87 LOG(AliL3Log::kError,"AliL3Transform::GetRealY","pad")
88 <<"Wrong pad "<<pad<<" npads " <<npads<<ENDLOG;
92 const Int_t NRowLow=AliL3Transform::GetNRowLow();
95 return (0.4*pad+0.2-0.2*npads);
96 //== (pad-0.5*(npads-1))*fPadPitchWidthLow;
100 return (0.6*pad+0.3-0.3*npads);
101 // == (pad-0.5*(npads-1))*fPadPitchWidthUp;
107 #include "TPCMapping.h"
109 TPCMapping::TPCMapping(char* file){
110 fin = new ifstream();
115 TPCMapping::~TPCMapping(){
119 void TPCMapping::open(){
122 void TPCMapping::isOpen(){
124 void TPCMapping::read(){
125 for(int i = 0; i < 5504 ; i++){
126 for(int j = 0 ; j < 8 ; j++){
127 *fin >> fIRORC[i][j];
130 fsizeoffIRORC = 5504;
133 void TPCMapping::read(int* listofRCUs, int numofRCU){
135 for(int i = 0; i < 5504 ; i++){
136 for(int j = 0 ; j < 8 ; j++){
137 *fin >> fIRORC[pos][j];
139 for(int j = 0 ; j < numofRCU ; j++){
140 if( fIRORC[pos][5] == listofRCUs[j]){
149 void TPCMapping::print(){
150 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
151 for(int i = 0; i < fsizeoffIRORC ; i++){
155 void TPCMapping::print(int start, int end){
156 cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
157 for(int i = start; i <= end ; i++){
161 void TPCMapping::print(int index){
163 getIndex(index) << "\t|" <<
164 getPadrow(index) << "\t|" <<
165 getPad(index) << "\t|" <<
166 getConnector(index) << "\t|" <<
167 getPin(index) << "\t|" <<
168 getFEC(index) << "\t|" <<
169 getFECchannel(index) << "\t|" <<
170 getFECconnector(index) << "\t|" <<
171 getAltroChannel(index) << "\t|" <<
172 getAltro(index) << "\t|" << endl;
174 int TPCMapping::getIndex(int index){
175 //COLUMN 0 -> INDEX (0 - 9983)
178 retval = fIRORC[index][0];
181 cout << "ERROR: Array Empty!" << endl;
185 int TPCMapping::getPadrow(int index){
186 //COLUMN 1 -> PADROW (0 - 95)
189 retval = fIRORC[index][1];
192 cout << "ERROR: Array Empty!" << endl;
196 int TPCMapping::getPad(int index){
197 //COLUMN 2 -> PAD (0 - (Np-1))
200 retval = fIRORC[index][2];
203 cout << "ERROR: Array Empty!" << endl;
207 int TPCMapping::getConnector(int index){
208 //COLUMN 3 -> Connector (1 - 468)
211 retval = fIRORC[index][3];
214 cout << "ERROR: Array Empty!" << endl;
218 int TPCMapping::getPin(int index){
219 //COLUMN 4 -> Pin (0 - 22)
222 retval = fIRORC[index][4];
225 cout << "ERROR: Array Empty!" << endl;
229 int TPCMapping::getFEC(int index){
230 //COLUMN 5 -> FEC (0 - 77)
233 retval = fIRORC[index][5];
236 cout << "ERROR: Array Empty!" << endl;
240 int TPCMapping::getFECchannel(int index){
241 //COLUMN 6 -> FEC Channel (0 - 127)
244 retval = fIRORC[index][6];
247 cout << "ERROR: Array Empty!" << endl;
251 int TPCMapping::getFECconnector(int index){
252 //COLUMN 7 -> FEC Connector (0 - 5)
255 retval = fIRORC[index][7];
258 cout << "ERROR: Array Empty!" << endl;
263 int TPCMapping::getAltroChannel(int index){
264 // every the channel to Altro ordering is 0,1,2,3,4,5,6,7,16,15,14,13,12,11,10,9,8
266 int channel = getFECchannel(index);
268 if( (channel/8)%2 == 0 ){ //every even block hast to be changed
271 retval = (channel/8)*8 + 7-channel%8; //Blocknumber + reversed internel Number
273 if( (channel/16)%2 != 0){
275 if( (channel/8)%2 == 0 )
282 cout << "ERROR: Array Empty!" << endl;
286 int TPCMapping::getAltro(int index){
288 int channel = getFECchannel(index);
293 cout << "ERROR: Array Empty!" << endl;
298 int TPCMapping::getPadsperRow(int row){
299 //IRORC Formula !!!!!!!!!!!!!!!!!!!!!!!!!
304 retval = 2*((int)(row/3.0+33.67));
308 void TPCMapping::myprint(){
311 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
313 for(int j = 0; j < 512 ; j++){
314 // cout << "j: " << j << " fec " << (j/128+29) << " channel: " << j%128 << endl;
317 for(int i = 0; i < fsizeoffIRORC ; i++){
318 if((getFEC(i) == FEC) && (getAltroChannel(i) == channel)) {
319 cout << j << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
320 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
321 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
322 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
327 void TPCMapping::myprint1(){
330 cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl;
332 for(int j = 0; j < 95 ; j++){
333 for(int k = 0; k < getPadsperRow(j) ; k++){
334 for(int i = 0; i < fsizeoffIRORC ; i++){
335 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
336 cout << j << "\t" << k << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" <<
337 getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" <<
338 getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" <<
339 getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl;
345 void TPCMapping::myprint2(){
350 for(int j = 0; j < 95 ; j++){
351 for(int i = 0; i < fsizeoffIRORC ; i++){
352 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) ){
357 cout << rownum << "\t" << j << "\t";
358 for(int k = 0; k < getPadsperRow(j) ; k++){
359 for(int i = 0; i < fsizeoffIRORC ; i++){
360 if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) {
361 cout << getAltroChannel(i)+(32-getFEC(i))*128 << "\t";
362 // cout << getAltroChannel(i) << "\t";