+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliRICHDigitizer::Sdi2Dig(TClonesArray *pSdiLst,TObjArray *pDigLst)
+{
+// Converts list of sdigits to 7 lists of digits, one per each chamber
+// Arguments: pSDigLst - list of all sdigits
+// pDigLst - list of 7 lists of digits
+// Returns: none
+
+ TClonesArray *pLst[7]; Int_t iCnt[7];
+
+ for(Int_t i=0;i<7;i++){
+ pLst[i]=(TClonesArray*)(*pDigLst)[i];
+ iCnt[i]=pLst[i]->GetEntries(); //in principle those lists should be empty
+ }
+
+ pSdiLst->Sort();
+
+ Int_t iPad=-1,iCh=-1,iNdigPad=-1,aTids[3]={-1,-1,-1}; Float_t q=-1;
+ for(Int_t i=0;i<pSdiLst->GetEntries();i++){ //sdigits loop (sorted)
+ AliRICHDigit *pSdig=(AliRICHDigit*)pSdiLst->At(i); //take current sdigit
+ if(pSdig->Pad()==iPad){ //if the same pad
+ q+=pSdig->Q(); //sum up charge
+ iNdigPad++; if(iNdigPad<=3) aTids[iNdigPad-1]=pSdig->GetTrack(0); //collect TID
+ continue;
+ }
+ if(i!=0 && AliRICHDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliRICHDigit(iPad,(Int_t)q,aTids); //do not create digit for the very first sdigit
+ iPad=pSdig->Pad(); iCh=AliRICHDigit::A2C(iPad); //new sdigit comes, reset collectors
+ iNdigPad=1;
+ aTids[0]=pSdig->GetTrack(0);aTids[1]=aTids[2]=-1;
+ q=pSdig->Q();
+ }//sdigits loop (sorted)
+
+ if(AliRICHDigit::IsOverTh(q)) new((*pLst[iCh])[iCnt[iCh]++]) AliRICHDigit(iPad,(Int_t)q,aTids); //add the last one, in case of empty sdigits list q=-1
+ //so digit is not created
+}//Sdi2Dig()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++