+ TObjArray * aECARecPoints = emcalLoader->RecPoints() ;
+
+ if (fGeom==0)
+ AliFatal("Did not get geometry from EMCALLoader");
+
+ aECARecPoints->Clear();
+
+ //Start with pseudoclusters, if option
+ if(strstr(option,"pseudo")) {
+ TClonesArray * digits = emcalLoader->Digits() ;
+ TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone());
+
+ TIter nextdigit(digitsC) ;
+ AliEMCALDigit * digit;
+
+ AliEMCALRecPoint * recPoint = 0 ;
+ int ineb=0;
+ nextdigit.Reset();
+
+ // PseudoClusterization starts
+ while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
+ recPoint = 0 ;
+ TArrayI clusterECAdigitslist(1000); // what is this
+
+ if(fGeom->CheckAbsCellId(digit->GetId()) ) { //Is this an EMCAL digit? Just maing sure...
+ Int_t iDigitInECACluster = 0; // start a new Tower RecPoint
+ if(fNumberOfECAClusters >= aECARecPoints->GetSize()) aECARecPoints->Expand(2*fNumberOfECAClusters+1) ;
+ AliEMCALRecPoint * rp = new AliEMCALRecPoint("") ;
+ aECARecPoints->AddAt(rp, fNumberOfECAClusters) ;
+ recPoint = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(fNumberOfECAClusters)) ;
+ fNumberOfECAClusters++ ;
+
+ recPoint->SetClusterType(AliESDCaloCluster::kPseudoCluster);
+
+ recPoint->AddDigit(*digit, digit->GetAmp()) ;
+ clusterECAdigitslist[iDigitInECACluster] = digit->GetIndexInList() ;
+ iDigitInECACluster++ ;
+ digitsC->Remove(digit) ;
+ AliDebug(1,Form("MakePseudoClusters: OK id = %d, adc = %f \n", digit->GetId(), digit->GetAmp()));
+ nextdigit.Reset(); // will start from beggining
+
+ AliEMCALDigit * digitN = 0; // digi neighbor
+ Int_t index = 0 ;
+
+ // Find the neighbours
+ while (index < iDigitInECACluster){ // scan over digits already in cluster
+ digit = (AliEMCALDigit*)digits->At(clusterECAdigitslist[index]);
+ index++ ;
+ while ( (digitN = (AliEMCALDigit *)nextdigit())) { // scan over the reduced list of digits
+ ineb = AreInGroup(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
+ switch (ineb ) {
+ case 0 : // not a neighbour
+ break ;
+ case 1 : // are neighbours
+ recPoint->AddDigit(*digitN, digitN->GetAmp() ) ;
+ clusterECAdigitslist[iDigitInECACluster] = digitN->GetIndexInList() ;
+ iDigitInECACluster++ ;
+ digitsC->Remove(digitN) ;
+ break ;
+ case 2 : // different SM
+ break ;
+ case 3 : // different Tower group
+ break ;
+ } // switch
+ } // scan over the reduced list of digits
+ } // scan over digits already in cluster
+ nextdigit.Reset() ; // will start from beggining
+ }
+ }
+ if(recPoint)
+ AliDebug(1,Form("MakeClusters: cl.e %f \n", recPoint->GetEnergy()));
+ //if(recPoint) cout << "cl.e " << recPoint->GetEnergy() << endl;
+ delete digitsC ;
+ }