+Bool_t AliITSRawStreamSPD::GetHminTHchipPresent(UInt_t chip) const {
+ if (chip<10) return ((( fCalHeadWord[7]>>(16+chip)) & 0x00000001) == 1);
+ else return kFALSE;
+}
+UInt_t AliITSRawStreamSPD::GetFOHnumDacs() const {
+ return (fCalHeadLen-37)/2;
+}
+UInt_t AliITSRawStreamSPD::GetFOHdacIndex(UInt_t index) const {
+ if (index>=GetFOHnumDacs()) {
+ TString errMess = Form("Only %d DACs in this run, returning 0",GetFOHnumDacs());
+ AliError(errMess.Data());
+ return 0;
+ }
+ return fCalHeadWord[7+index*2];
+}
+UInt_t AliITSRawStreamSPD::GetFOHdacValue(UInt_t index) const {
+ if (index>=GetFOHnumDacs()) {
+ TString errMess = Form("Only %d DACs in this run, returning 0",GetFOHnumDacs());
+ AliError(errMess.Data());
+ return 0;
+ }
+ return fCalHeadWord[7+1+index*2];
+}
+UInt_t AliITSRawStreamSPD::GetFOHchipCount(UInt_t hs, UInt_t chip) const {
+ if (hs<6 && chip<10) {
+ if (chip%2==0) {
+ return ((fCalHeadWord[7 + GetFOHnumDacs()*2 + (hs*10 + chip)/2] >> 16) & 0x0000ffff);
+ }
+ else {
+ return (fCalHeadWord[7 + GetFOHnumDacs()*2 + (hs*10 + chip)/2] & 0x0000ffff);
+ }
+ }
+ else return 0;
+}
+//__________________________________________________________________________
+Int_t AliITSRawStreamSPD::GetModuleNumber(UInt_t iDDL, UInt_t iModule) {
+ if (iDDL<20 && iModule<12) return fgkDDLModuleMap[iDDL][iModule];
+ else return 240;
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::OfflineToOnline(UInt_t module, UInt_t colM, UInt_t rowM, UInt_t& eq, UInt_t& hs, UInt_t& chip, UInt_t& col, UInt_t& row) {
+ // converts offline coordinates to online
+ eq = GetOnlineEqIdFromOffline(module);
+ hs = GetOnlineHSFromOffline(module);
+ chip = GetOnlineChipFromOffline(module,colM);
+ col = GetOnlineColFromOffline(module,colM);
+ row = GetOnlineRowFromOffline(module,rowM);
+ if (eq>=20 || hs>=6 || chip>=10 || col>=32 || row>=256) return kFALSE;
+ else return kTRUE;
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::OnlineToOffline(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row, UInt_t& module, UInt_t& colM, UInt_t& rowM) {
+ // converts online coordinates to offline
+ module = GetOfflineModuleFromOnline(eq,hs,chip);
+ colM = GetOfflineColFromOnline(eq,hs,chip,col);
+ rowM = GetOfflineRowFromOnline(eq,hs,chip,row);
+ if (module>=240 || colM>=160 || rowM>=256) return kFALSE;
+ else return kTRUE;
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOnlineEqIdFromOffline(UInt_t module) {
+ // offline->online (eq)
+ for (UInt_t eqId=0; eqId<20; eqId++) {
+ for (UInt_t iModule=0; iModule<12; iModule++) {
+ if (GetModuleNumber(eqId,iModule)==(Int_t)module) return eqId;
+ }
+ }
+ return 20; // error
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOnlineHSFromOffline(UInt_t module) {
+ // offline->online (hs)
+ for (UInt_t eqId=0; eqId<20; eqId++) {
+ for (UInt_t iModule=0; iModule<12; iModule++) {
+ if (GetModuleNumber(eqId,iModule)==(Int_t)module) return iModule/2;
+ }
+ }
+ return 6; // error
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOnlineChipFromOffline(UInt_t module, UInt_t colM) {
+ // offline->online (chip)
+ for (UInt_t eq=0; eq<20; eq++) {
+ for (UInt_t iModule=0; iModule<12; iModule++) {
+ if (GetModuleNumber(eq,iModule)==(Int_t)module) {
+ if (module<80) {
+ if (eq<10) { // side A
+ return (159-colM)/32 + 5*(iModule%2);
+ }
+ else { // side C
+ return colM/32 + 5*(iModule%2);
+ }
+ }
+ else if (module<240) {
+ if (eq<10) { // side A
+ return colM/32 + 5*(iModule%2);
+ }
+ else { // side C
+ return (159-colM)/32 + 5*(iModule%2);
+ }
+ }
+ }
+ }
+ }
+ return 10; // error
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOnlineColFromOffline(UInt_t module, UInt_t colM) {
+ // offline->online (col)
+ if (module<80) { // inner layer
+ return colM%32;
+ }
+ else if (module<240) { // outer layer
+ return colM%32;
+ }
+ return 32; // error
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOnlineRowFromOffline(UInt_t module, UInt_t rowM) {
+ // offline->online (row)
+ if (module<80) { // inner layer
+ return (255-rowM);
+ }
+ else if (module<240) { // outer layer
+ return (255-rowM);
+ }
+ return 256; // error
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {
+ // online->offline (module)
+ if (eqId<20 && hs<6 && chip<10) return fgkDDLModuleMap[eqId][hs*2+chip/5];
+ else return 240;
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {
+ // online->offline (chip key: 0-1199)
+ if (eqId<20 && hs<6 && chip<10) {
+ UInt_t module = GetOfflineModuleFromOnline(eqId,hs,chip);
+ UInt_t chipInModule = ( chip>4 ? chip-5 : chip );
+ if(eqId>9) chipInModule = 4 - chipInModule; // side C only
+ return (module*5 + chipInModule);
+ } else return 1200;
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col) {
+ // online->offline (col)
+ if (eqId>=20 || hs>=6 || chip>=10 || col>=32) return 160; // error
+ UInt_t offset = 32 * (chip % 5);
+ if (hs<2) {
+ if (eqId<10) {
+ return 159 - (31-col + offset); // inner layer, side A
+ }
+ else {
+ return col + offset; // inner layer, side C
+ }
+ }
+ else {
+ if (eqId<10) {
+ return (col + offset); // outer layer, side A
+ }
+ else {
+ return 159 - (31-col + offset); // outer layer, side C
+ }
+ }
+}
+//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row) {
+ // online->offline (row)
+ if (eqId>=20 || hs>=6 || chip>=10 || row>=256) return 256; // error
+ return 255-row;
+}
+