+//---------------------------------------------------------------------------
+void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- (variable in [0,47])
+ // in:
+ // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
+ // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
+ // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
+ // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
+ // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
+ //
+
+ eqId[0] = Geant2DDL(vol);
+ eqId[1] = Geant2TRM(vol);
+ eqId[2] = Geant2TDC(vol);
+ eqId[3] = Geant2Chain(vol);
+ eqId[4] = Geant2Channel(vol);
+
+}
+
+//---------------------------------------------------------------------------
+Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- (variable in [0,47])
+ // in:
+ // nDDL (variable in [0;71]) -> number of the DDL
+ //
+
+
+ Int_t iDDL = -1;
+
+ if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
+ printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
+ return iDDL;
+ }
+ if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
+ printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
+ return iDDL;
+ }
+ if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
+ printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
+ return iDDL;
+ }
+ if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
+ printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
+ if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
+ printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
+ if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
+ printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
+ return iDDL;
+ }
+
+ Int_t nSector = vol[0];
+ Int_t nPlate = vol[1];
+ Int_t nStrip = vol[2];
+ Int_t nPadX = vol[4];
+
+ if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
+ iDDL = 0;
+ else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
+ iDDL = 1;
+ else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
+ iDDL = 2;
+ else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
+ iDDL = 3;
+
+ return 4*nSector+iDDL;
+
+}
+
+//---------------------------------------------------------------------------
+Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- (variable in [0,47])
+ // in:
+ // nTRM (variable in [3;12]) -> number of the TRM slot
+ //
+
+ Int_t nTRM = -1;
+
+ if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
+ printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
+ return nTRM;
+ }
+ if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
+ printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
+ return nTRM;
+ }
+ if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
+ printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
+ return nTRM;
+ }
+ if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
+ printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
+ return nTRM;
+ }
+ if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
+ printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
+ return nTRM;
+ }
+
+ if ( vol[3]>=AliTOFGeometry::NpadZ() )
+ {
+ printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
+ return nTRM;
+ }
+
+ Int_t nPlate = vol[1];
+ Int_t nStrip = vol[2];
+
+ Int_t iDDL = Geant2DDL(vol)%4;
+
+ switch (iDDL) {
+
+ case 0:
+
+ if (nPlate==0) {
+ if (nStrip<= 4) nTRM = 4;
+ else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
+ else if (nStrip> 9 && nStrip<=14) nTRM = 6;
+ else if (nStrip>14) nTRM = 7;
+ }
+ else if (nPlate==1) {
+ if (nStrip== 0) nTRM = 7;
+ else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
+ else if (nStrip> 5 && nStrip<=10) nTRM = 9;
+ else if (nStrip>10 && nStrip<=15) nTRM = 10;
+ else if (nStrip>15) nTRM = 11;
+ }
+ else if (nPlate==2) {
+ if (nStrip<= 1) nTRM = 11;
+ else if (nStrip> 1 && nStrip< 7) nTRM = 12;
+ }
+
+ break;
+ case 1:
+
+ if (nPlate==0) {
+ if (nStrip== 0) nTRM = 3;
+ else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
+ else if (nStrip> 5 && nStrip<=10) nTRM = 5;
+ else if (nStrip>10 && nStrip<=15) nTRM = 6;
+ else if (nStrip>15) nTRM = 7;
+ }
+ else if (nPlate==1) {
+ if (nStrip<=1) nTRM = 7;
+ else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
+ else if (nStrip> 6 && nStrip<=11) nTRM = 9;
+ else if (nStrip>11 && nStrip<=16) nTRM = 10;
+ else if (nStrip>16) nTRM = 11;
+ }
+ else if (nPlate==2) {
+ if (nStrip<= 2) nTRM = 11;
+ else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
+ }
+
+ break;
+ case 2:
+
+ if (nPlate==4) {
+ if (nStrip>=14) nTRM = 4;
+ else if (nStrip<14 && nStrip>= 9) nTRM = 5;
+ else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
+ else if (nStrip< 4) nTRM = 7;
+ }
+ else if (nPlate==3) {
+ if (nStrip==18) nTRM = 7;
+ else if (nStrip<18 && nStrip>=13) nTRM = 8;
+ else if (nStrip<13 && nStrip>= 8) nTRM = 9;
+ else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
+ else if (nStrip< 3) nTRM = 11;
+ }
+ else if (nPlate==2) {
+ if (nStrip>=13) nTRM = 11;
+ else if (nStrip<13 && nStrip>= 8) nTRM = 12;
+ }
+
+ break;
+ case 3:
+
+ if (nPlate==4) {
+ if (nStrip==18) nTRM = 3;
+ else if (nStrip<18 && nStrip>=13) nTRM = 4;
+ else if (nStrip<13 && nStrip>= 8) nTRM = 5;
+ else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
+ else if (nStrip< 3) nTRM = 7;
+ }
+ else if (nPlate==3) {
+ if (nStrip>=17) nTRM = 7;
+ else if (nStrip<17 && nStrip>=12) nTRM = 8;
+ else if (nStrip<12 && nStrip>= 7) nTRM = 9;
+ else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
+ else if (nStrip< 2) nTRM = 11;
+ }
+ else if (nPlate==2) {
+ if (nStrip>=12) nTRM = 11;
+ else if (nStrip <12 && nStrip>= 7) nTRM = 12;
+ }
+
+ break;
+
+ }
+
+ return nTRM;
+
+}
+
+//---------------------------------------------------------------------------
+Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- (variable in [0,47])
+ // in:
+ // nTDC (variable in [0;14]) -> number of the TDC
+ //
+
+ Int_t nTDC = -1;
+
+ if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
+ printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
+ return nTDC;
+ }
+ if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
+ printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
+ return nTDC;
+ }
+ if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
+ printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
+ return nTDC;
+ }
+ if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
+ printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
+ if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
+ printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
+ if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
+ printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
+ return nTDC;
+ }
+
+ Int_t nPlate = vol[1];
+ Int_t nStrip = vol[2];
+ Int_t iPadX = vol[4];
+
+ Int_t iDDL = Geant2DDL(vol)%4;
+
+ switch (iDDL) {
+
+ case 0:
+
+ if (nPlate==0) {
+ if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
+ else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
+ else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
+ else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
+ }
+ else if (nPlate==1) {
+ if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
+ else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
+ else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
+ else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
+ else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
+ }
+ else if (nPlate==2) {
+ if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
+ else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
+ }
+
+ break;
+ case 1:
+
+ if (nPlate==0) {
+ if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
+ else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
+ else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
+ else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
+ else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
+ }
+ else if (nPlate==1) {
+ if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
+ else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
+ else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
+ else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
+ else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
+ }
+ else if (nPlate==2) {
+ if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
+ else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
+ }
+
+ break;
+ case 2:
+
+ if (nPlate==4) {
+ if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
+ else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
+ else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
+ else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
+ }
+ else if (nPlate==3) {
+ if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
+ else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
+ else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
+ else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
+ else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
+ }
+ else if (nPlate==2) {
+ if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
+ else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
+ }
+
+ break;
+ case 3:
+
+ if (nPlate==4) {
+ if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
+ else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
+ else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
+ else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
+ else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
+ }
+ else if (nPlate==3) {
+ if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
+ else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
+ else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
+ else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
+ else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
+ }
+ else if (nPlate==2) {
+ if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
+ else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
+ }
+
+ break;
+
+ }
+
+ return nTDC;
+
+}
+
+//---------------------------------------------------------------------------
+Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- variable in [0,47])
+ // in:
+ // nChain (variable in [0; 1]) -> number of the TRM chain
+ //
+
+ Int_t nChain = -1;
+
+ if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
+ printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
+ return nChain;
+ }
+ if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
+ printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
+ return nChain;
+ }
+ if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
+ printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
+ return nChain;
+ }
+ if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
+ printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
+ if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
+ printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
+ if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
+ printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
+ return nChain;
+ }
+
+ Int_t iPadX = vol[4];
+
+ if (iPadX<12 || iPadX>=36) nChain = 0;
+ else nChain = 1;
+
+ return nChain;
+
+}
+
+//---------------------------------------------------------------------------
+Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
+{
+ //
+ // To convert:
+ // nSector number -vol[0]- (variable in [0,17])
+ // nPlate number -vol[1]- (variable in [0, 5])
+ // nStrip number -vol[2]- (variable in [0,14/18])
+ // nPadZ number -vol[3]- (variable in [0, 1])
+ // nPadX number -vol[4]- (variable in [0,47])
+ // in:
+ // nChannel (variable in [0; 7]) -> number of the TDC channel
+ //
+
+ Int_t nChannel = -1;
+
+ if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
+ printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
+ return nChannel;
+ }
+ if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
+ printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
+ return nChannel;
+ }
+ if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
+ printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
+ return nChannel;
+ }
+ if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
+ printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
+ if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
+ printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
+ if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
+ printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
+ return nChannel;
+ }
+
+ Int_t iPadZ = vol[3];
+ Int_t iPadX = vol[4];
+
+ Int_t iDDL = Geant2DDL(vol)%4;
+
+ switch (iDDL) {
+
+ case 0:
+ nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
+ break;
+ case 1:
+ nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
+ break;
+ case 2:
+ nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
+ break;
+ case 3:
+ nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
+ break;
+ }
+
+ return nChannel;
+
+}
+
+//____________________________________________________________________________
+void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
+{
+ //
+ // Converts raw data to digits for TOF
+ //
+
+ TStopwatch stopwatch;
+ stopwatch.Start();
+
+ //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
+ //digitsTree->Branch("TOF", &fDigits);
+ TClonesArray &aDigits = *digitsArray;
+
+ Int_t inholes = 0;
+
+ Clear();
+ SetRawReader(rawReader);
+
+ //ofstream ftxt;
+ //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
+
+ TClonesArray staticRawData("AliTOFrawData",10000);
+ staticRawData.Clear();
+ TClonesArray * clonesRawData = &staticRawData;
+
+ Int_t dummy = -1;
+ Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+ Int_t digit[4];
+
+ const Int_t kMaxNumberOfTracksPerDigit = 3;
+ Int_t tracks[kMaxNumberOfTracksPerDigit];
+ for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
+ tracks[ii] = -1;
+ Int_t last = -1;
+
+ Int_t indexDDL = 0;
+ Int_t iRawData = 0;
+ AliTOFrawData *tofRawDatum = 0;
+ for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+
+ rawReader->Reset();
+ if (fNewDecoderVersion) {
+ AliInfo("Using New Decoder \n");
+ LoadRawDataBuffers(indexDDL, 0);
+ }
+ else
+ LoadRawData(indexDDL);
+
+ clonesRawData = GetRawData();
+ if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
+ for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+ tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+ //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+ if (tofRawDatum->GetTOF()==-1) continue;
+
+ EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+ tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padz
+ detectorIndex[4] = dummy;//padx
+
+ digit[0] = tofRawDatum->GetTOF();
+ digit[1] = tofRawDatum->GetTOT();
+ digit[2] = tofRawDatum->GetTOT();
+ digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padx
+ detectorIndex[4] = dummy;//padz
+
+ // Do not reconstruct anything in the holes
+ if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
+ if (detectorIndex[1]==2) { // plate with holes
+ inholes++;
+ continue;
+ }
+ }
+
+ last = digitsArray->GetEntriesFast();
+ new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
+ /*
+ if (fVerbose==2) {
+ if (indexDDL<10) ftxt << " " << indexDDL;
+ else ftxt << " " << indexDDL;
+ if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
+ else ftxt << " " << tofRawDatum->GetTRM();
+ ftxt << " " << tofRawDatum->GetTRMchain();
+ if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
+ else ftxt << " " << tofRawDatum->GetTDC();
+ ftxt << " " << tofRawDatum->GetTDCchannel();
+
+ if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
+ else ftxt << " -> " << detectorIndex[0];
+ ftxt << " " << detectorIndex[1];
+ if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
+ else ftxt << " " << detectorIndex[2];
+ ftxt << " " << detectorIndex[4];
+ if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
+ else ftxt << " " << detectorIndex[3];
+
+ if (digit[1]<10)ftxt << " " << digit[1];
+ else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
+ else ftxt << " " << digit[1];
+ if (digit[0]<10) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
+ else ftxt << " " << digit[3] << endl;
+ }
+ */
+ AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
+ last,
+ detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
+ digit[0], digit[1], digit[3]));
+
+ tofRawDatum = 0;
+ } // loop on tofRawData array
+
+ clonesRawData->Clear();
+
+ } // DDL Loop
+
+ //if (fVerbose==2) ftxt.close();
+
+
+ if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
+
+ Int_t nDigits = digitsArray->GetEntries();
+ AliDebug(1, Form("Got %d TOF digits", nDigits));
+ AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
+}
+
+//____________________________________________________________________________
+void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
+{
+ //
+ // Converts raw data to sdigits for TOF
+ //
+
+ TStopwatch stopwatch;
+ stopwatch.Start();
+
+ Int_t inholes = 0;
+
+ //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
+ TClonesArray &aSDigits = *sdigitsArray;
+
+ Clear();
+ SetRawReader(rawReader);
+
+ //ofstream ftxt;
+ //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
+
+ TClonesArray staticRawData("AliTOFrawData",10000);
+ staticRawData.Clear();
+ TClonesArray * clonesRawData = &staticRawData;
+
+ Int_t dummy = -1;
+ Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+ Int_t digit[2];
+ Int_t track = -1;
+ Int_t last = -1;
+
+ Int_t indexDDL = 0;
+ Int_t iRawData = 0;
+ AliTOFrawData *tofRawDatum = 0;
+ for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+
+ rawReader->Reset();
+ if (fNewDecoderVersion) {
+ AliInfo("Using New Decoder \n");
+ LoadRawDataBuffers(indexDDL, 0);
+ }
+ else
+ LoadRawData(indexDDL);
+
+ clonesRawData = GetRawData();
+ if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
+ for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+ tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+ //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+ if (tofRawDatum->GetTOF()==-1) continue;
+
+ EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+ tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padz
+ detectorIndex[4] = dummy;//padx
+
+ digit[0] = tofRawDatum->GetTOF();
+ digit[1] = tofRawDatum->GetTOT();
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padx
+ detectorIndex[4] = dummy;//padz
+
+ // Do not reconstruct anything in the holes
+ if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
+ if (detectorIndex[1]==2) { // plate with holes
+ inholes++;
+ continue;
+ }
+ }
+
+ last = sdigitsArray->GetEntriesFast();
+ new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
+ /*
+ if (fVerbose==2) {
+ if (indexDDL<10) ftxt << " " << indexDDL;
+ else ftxt << " " << indexDDL;
+ if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
+ else ftxt << " " << tofRawDatum->GetTRM();
+ ftxt << " " << tofRawDatum->GetTRMchain();
+ if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
+ else ftxt << " " << tofRawDatum->GetTDC();
+ ftxt << " " << tofRawDatum->GetTDCchannel();
+
+ if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
+ else ftxt << " -> " << detectorIndex[0];
+ ftxt << " " << detectorIndex[1];
+ if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
+ else ftxt << " " << detectorIndex[2];
+ ftxt << " " << detectorIndex[4];
+ if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
+ else ftxt << " " << detectorIndex[3];
+
+ if (digit[1]<10)ftxt << " " << digit[1];
+ else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
+ else ftxt << " " << digit[1];
+ if (digit[0]<10) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
+ else ftxt << " " << digit[3] << endl;
+ }
+ */
+ AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
+ last,
+ detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
+ digit[0], digit[1], digit[3]));
+
+ tofRawDatum = 0;
+ } // while loop
+
+ clonesRawData->Clear();
+
+ } // DDL Loop
+
+ //if (fVerbose==2) ftxt.close();
+
+ if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
+
+ Int_t nSDigits = sdigitsArray->GetEntries();
+ AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
+ AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
+}