X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=HLT%2FTPCLib%2FAliHLTTPCFileHandler.cxx;h=ce952c37105d056865ffe5864b392ca36bdd88a7;hp=cbf89bbd5730e37af5bd2c466f984e5360f1c1dc;hb=2f7aeadf3ffb58264132932054e540e62ad655f1;hpb=a6c02c859086baa09c104eba8886e2970781e516 diff --git a/HLT/TPCLib/AliHLTTPCFileHandler.cxx b/HLT/TPCLib/AliHLTTPCFileHandler.cxx index cbf89bbd573..ce952c37105 100644 --- a/HLT/TPCLib/AliHLTTPCFileHandler.cxx +++ b/HLT/TPCLib/AliHLTTPCFileHandler.cxx @@ -1,37 +1,69 @@ // @(#) $Id$ - -// Author: Uli Frankenfeld , Anders Vestbo , C. Loizides -//*-- Copyright © ALICE HLT Group - -#include "AliHLTTPCStandardIncludes.h" +// Original: AliHLTFileHandler.cxx,v 1.49 2005/06/23 17:46:55 hristov + +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * * + * Primary Authors: U. Frankenfeld, A. Vestbo, C. Loizides * + * Matthias Richter * + * for The ALICE HLT Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTTPCFileHandler.cxx + @author U. Frankenfeld, A. Vestbo, C. Loizides, maintained by + Matthias Richter + @date + @brief file input for the TPC tracking code before migration to the + HLT component framework + +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + */ +#include #include #include #include -#ifdef use_newio #include -#endif +#include +#include +#include #include #include #include #include #include #include +#include "AliCDBManager.h" +#include "AliCDBEntry.h" #include "AliHLTTPCLogging.h" #include "AliHLTTPCTransform.h" -#include "AliHLTTPCMemHandler.h" #include "AliHLTTPCDigitData.h" -#include "AliHLTTPCTrackSegmentData.h" +//#include "AliHLTTPCTrackSegmentData.h" #include "AliHLTTPCSpacePointData.h" -#include "AliHLTTPCTrackArray.h" +//#include "AliHLTTPCTrackArray.h" #include "AliHLTTPCFileHandler.h" +#include "AliHLTTPCMapping.h" +#include "AliHLTAltroEncoder.h" #if __GNUC__ >= 3 using namespace std; #endif -/** \class AliHLTTPCFileHandler +/**
 //_____________________________________________________________
 // AliHLTTPCFileHandler
@@ -71,6 +103,34 @@ using namespace std;
 
 ClassImp(AliHLTTPCFileHandler)
 
+AliHLTTPCFileHandler::AliHLTTPCFileHandler(Bool_t b)
+  :
+  fInAli(NULL),
+  fUseRunLoader(kFALSE),
+  fParam(NULL),
+  fDigits(NULL),
+  fDigitsTree(NULL),
+  fMC(NULL),
+  fIndexCreated(kFALSE),
+  fUseStaticIndex(b)
+{
+  //Default constructor
+
+  for(Int_t i=0;iDelete();
-#endif
   fDigitsTree=0;
 
   for(Int_t i=0;iGet(cdbEntry);
+    if (pEntry==NULL || 
+	pEntry->GetObject()==NULL ||
+	(fParam=dynamic_cast(pEntry->GetObject()))==NULL) {
+      LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::SetAliInput","File")
+	<<"can not load AliTPCParam object from OCDB entry " << cdbEntry <CdGAFile();
   fParam = (AliTPCParam*)gFile->Get("75x40_100x60_150x60");
   if(!fParam){
@@ -238,31 +276,12 @@ Bool_t AliHLTTPCFileHandler::SetAliInput()
       <<"which might not be what you want!"<GetName()<IsOpen()){
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::SetAliInput","File Open")
-      <<"Ali File "<GetName()<<" does not exist"<Get(AliHLTTPCTransform::GetParamName());
-  if(!fParam){
-    LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::SetAliInput","File")
-      <<"No TPC parameters found in \""<GetName()
-      <<"\", creating standard parameters "
-      <<"which might not be what you want!"<GetName()<GetName()<IsOpen()) fInAli->Close();
-#endif
 
   delete fInAli;
   fInAli = 0;
@@ -349,7 +340,6 @@ Bool_t AliHLTTPCFileHandler::IsDigit(Int_t event)
     <<"Pointer to fInAli = 0x0 "<GetLoader("TPCLoader");
   if(!tpcLoader){
     LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandlerNewIO::IsDigit","File")
@@ -359,11 +349,6 @@ Bool_t AliHLTTPCFileHandler::IsDigit(Int_t event)
   fInAli->GetEvent(event);
   tpcLoader->LoadDigits();
   TTree *t=tpcLoader->TreeD();
-#else
-  Char_t name[1024];
-  sprintf(name,"TreeD_%s_%d",AliHLTTPCTransform::GetParamName(),event);
-  TTree *t=(TTree*)fInAli->Get(name);
-#endif
   if(t){
     LOG(AliHLTTPCLog::kInformational,"AliHLTTPCFileHandlerNewIO::IsDigit","File Type")
     <<"Found Digit Tree -> Use Fast Cluster Finder"<GetEntries(); n++) {
       Int_t sector, row;
       Int_t lslice,lrow;
@@ -429,14 +415,21 @@ Bool_t AliHLTTPCFileHandler::CreateIndex()
 	  <=0 && lslice=0 && lrowIsOpen()){
-    LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliDigits2Memory","File")
-    <<"No Input avalible: TFile not opened"<GetEntries();
@@ -492,26 +477,46 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliDigits2Memory(UInt_t & nrow,Int
     LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliDigits2Memory","ndigits")
       <<"No TPC digits (entries==0)!"<0) {
+      if (size<=*pTgtSize) {
+	data=reinterpret_cast(tgtBuffer);
+      } else {
+      }
+    } else {
+      data=reinterpret_cast(Allocate(size));
+    }
     AliHLTTPCDigitRowData *tempPt = data;
+    if (data) {
+    if (pTgtSize) *pTgtSize=size;
     for(Int_t r=fRowMin;r<=fRowMax;r++){
       tempPt->fRow = r;
       tempPt->fNDigit = 0;
       tempPt++;
     }
+    }
     return data;
   }
 
   Int_t * ndigits = new Int_t[fRowMax+1];
   Float_t xyz[3];
 
-  for(Int_t r=fRowMin;r<=fRowMax;r++){
+  // The digits of the current event have been indexed: all digits are organized in
+  // rows, all digits of one row are stored in a AliSimDigits object (fDigit) which
+  // are stored in the digit tree.
+  // The index map relates the AliSimDigits objects in the tree to dedicated pad rows
+  // in the TPC
+  // This loop filters the pad rows according to the slice no set via Init
+  assert(fRowMaxGetEvent(n);
       fParam->AdjustSectorRow(fDigits->GetID(),sector,row);
       AliHLTTPCTransform::Sector2Slice(lslice,lrow,sector,row);
+//       LOG(AliHLTTPCLog::kInformational,"AliHLTTPCFileHandler::AliDigits2Memory","Digits")
+// 	<< "Sector "<First();
-      do {
+      for (bool bHaveData=fDigits->First();
+	   bHaveData;
+	   bHaveData=fDigits->Next()) {
 	time=fDigits->CurrentRow();
 	pad=fDigits->CurrentColumn();
 	dig = fDigits->GetDigit(time,pad);
 	if(dig <= fParam->GetZeroSup()) continue;
 	if(dig >= AliHLTTPCTransform::GetADCSat())
 	  dig = AliHLTTPCTransform::GetADCSat();
-      
+
+	// if we switch to AliTPCTransform, this maybe needs to be 
+	// adjusted as well
 	AliHLTTPCTransform::Raw2Local(xyz,sector,row,pad,time);
 	//	if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2]))
 	//	  continue; // why 230???
@@ -536,28 +544,52 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliDigits2Memory(UInt_t & nrow,Int
 	ndigits[lrow]++; //for this row only
 	ndigitcount++;   //total number of digits to be published
 
-      } while (fDigits->Next());
+      }
       //cout << lrow << " " << ndigits[lrow] << " - " << ndigitcount << endl;
     }
-    nrows++;
+    //see comment below//nrows++;
   }
-
-  Int_t size = sizeof(AliHLTTPCDigitData)*ndigitcount
+  // Matthias 05.11.2007
+  // The question is whether we should always return a AliHLTTPCDigitRowData
+  // for each row, even the empty ones or only for the ones filled with data.
+  // the AliHLTTPCDigitReaderUnpacked as the counnterpart so far assumes 
+  // empty RawData structs for empty rows. But some of the code here implies
+  // the latter approach, e.g. the count of nrows in the loop above (now
+  // commented). At least the two loops were not consistent, it's fixed now.
+  nrows=fRowMax-fRowMin+1;
+
+  UInt_t bufferSize = sizeof(AliHLTTPCDigitData)*ndigitcount
     + nrows*sizeof(AliHLTTPCDigitRowData);
 
   LOG(AliHLTTPCLog::kDebug,"AliHLTTPCFileHandler::AliDigits2Memory","Digits")
-    <0) {
+    if (bufferSize<=*pTgtSize) {
+      data=reinterpret_cast(tgtBuffer);
+    } else {
+    }
+  } else if (bufferSize>0) {
+    data=reinterpret_cast(Allocate(bufferSize));
+  }
+  if (pTgtSize) *pTgtSize=bufferSize;
+  if (data==NULL) {
+    delete [] ndigits;
+    return NULL;
+  }
   nrow = (UInt_t)nrows;
   AliHLTTPCDigitRowData *tempPt = data;
+  memset(data, 0, bufferSize);
 
-  for(Int_t r=fRowMin;r<=fRowMax;r++){
+  for(Int_t r=fRowMin;r<=fRowMax && rfRow = r;
+
+    AliHLTTPCTransform::Slice2Sector(fSlice,r,sector,row);
+    tempPt->fRow = row;
     tempPt->fNDigit = 0;
 
     if(n!=-1){//data on that row
+      Int_t lslice,lrow;
       fDigitsTree->GetEvent(n);
       fParam->AdjustSectorRow(fDigits->GetID(),sector,row);
       AliHLTTPCTransform::Sector2Slice(lslice,lrow,sector,row);
@@ -567,11 +599,14 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliDigits2Memory(UInt_t & nrow,Int
 	continue;
       }
 
+      // set the correct row no and digit count
+      tempPt->fRow = row;
       tempPt->fNDigit = ndigits[lrow];
 
       Int_t localcount=0;
-      fDigits->First();
-      do {
+      for (bool bHaveData=fDigits->First();
+	   bHaveData;
+	   bHaveData=fDigits->Next()) {
 	time=fDigits->CurrentRow();
 	pad=fDigits->CurrentColumn();
 	dig = fDigits->GetDigit(time,pad);
@@ -592,24 +627,106 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliDigits2Memory(UInt_t & nrow,Int
 	tempPt->fDigitData[localcount].fCharge=dig;
 	tempPt->fDigitData[localcount].fPad=pad;
 	tempPt->fDigitData[localcount].fTime=time;
-#ifdef do_mc
 	tempPt->fDigitData[localcount].fTrackID[0] = fDigits->GetTrackID(time,pad,0);
 	tempPt->fDigitData[localcount].fTrackID[1] = fDigits->GetTrackID(time,pad,1);
 	tempPt->fDigitData[localcount].fTrackID[2] = fDigits->GetTrackID(time,pad,2);
-#endif
 	localcount++;
-      } while (fDigits->Next());
+      }
     }
+
     Byte_t *tmp = (Byte_t*)tempPt;
-    Int_t size = sizeof(AliHLTTPCDigitRowData)
-                                      + ndigits[lrow]*sizeof(AliHLTTPCDigitData);
-    tmp += size;
+    Int_t blockSize = sizeof(AliHLTTPCDigitRowData)
+      + tempPt->fNDigit*sizeof(AliHLTTPCDigitData);
+    tmp += blockSize;
     tempPt = (AliHLTTPCDigitRowData*)tmp;
   }
+  assert((Byte_t*)tempPt==((Byte_t*)data)+bufferSize);
   delete [] ndigits;
   return data;
 }
 
+int AliHLTTPCFileHandler::AliDigits2Altro(Int_t event, Byte_t* tgtBuffer, UInt_t tgtSize)
+{
+  //Read data from AliROOT file into memory, and store it in the ALTRO data format
+  //in the provided buffer 
+  //Returns: size of the encoded data in bytes
+  int iResult=0;
+
+  if(!fInAli){
+    LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliDigits2Altro","File")
+    <<"No Input avalible: Pointer to fInAli == NULL"<=0;r++){
+    Int_t n=fIndex[fSlice][r];
+
+    Int_t row=0;
+    Int_t rowOffset=0;
+    AliHLTTPCTransform::Slice2Sector(fSlice,r,sector,row);
+    AliHLTTPCTransform::Slice2Sector(fSlice,AliHLTTPCTransform::GetFirstRow(fPatch),sector,rowOffset);
+
+    if(n!=-1){//data on that row
+      Int_t lslice,lrow;
+      fDigitsTree->GetEvent(n);
+      fParam->AdjustSectorRow(fDigits->GetID(),sector,row);
+      AliHLTTPCTransform::Sector2Slice(lslice,lrow,sector,row);
+      if(lrow!=r){
+	LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliDigits2Altro","Row")
+	  <First();
+      do {
+	time=fDigits->CurrentRow();
+	pad=fDigits->CurrentColumn();
+	dig = fDigits->GetDigit(time,pad);
+	if (dig <= fParam->GetZeroSup()) continue;
+	if(dig >= AliHLTTPCTransform::GetADCSat())
+	  dig = AliHLTTPCTransform::GetADCSat();
+	
+	channelAddress=mapper.GetHwAddress(row-rowOffset, pad);
+	iResult=encoder.AddChannelSignal(dig, time, channelAddress);
+      } while (fDigits->Next() && iResult>=0);
+      if (iResult>=0 && channelAddress>=0) {
+	iResult=encoder.SetChannel(channelAddress);
+      }
+    }
+  }
+
+  if (iResult>=0) {
+    iResult=(encoder.GetTotal40bitWords()*5)/4;
+  }
+
+  return iResult;
+}
+
 AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nrow,Int_t event,Bool_t eventmerge)
 {
   //Read data from AliROOT file into memory, and store it in the HLT data format.
@@ -626,13 +743,6 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nro
     <<"No Input avalible: Pointer to TFile == NULL"<IsOpen()){
-    LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliAltroDigits2Memory","File")
-    <<"No Input avalible: TFile not opened"<= 1024)
     {
       LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliAltroDigits2Memory","TrackIDs")
@@ -641,16 +751,10 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nro
     }
   delete fDigits;
   fDigits=0;
-#ifdef use_newio 
   /* Dont understand why we have to do 
      reload the tree, but otherwise the code crashes */
   fDigitsTree=0;
   if(!GetDigitsTree(event)) return 0;
-#else
-  if(!fDigitsTree){
-    if(!GetDigitsTree(event)) return 0;
-  }
-#endif
 
   UShort_t dig;
   Int_t time,pad,sector,row;
@@ -676,7 +780,7 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nro
   Int_t zerosupval=AliHLTTPCTransform::GetZeroSup();
   Float_t xyz[3];
 
-  for(Int_t r=fRowMin;r<=fRowMax;r++){
+  for(Int_t r=fRowMin;r<=fRowMax && rfDigitData[localcount].fCharge=dig;
 	  tempPt->fDigitData[localcount].fPad=pad;
 	  tempPt->fDigitData[localcount].fTime=time;
-#ifdef do_mc
 	  tempPt->fDigitData[localcount].fTrackID[0] = (fDigits->GetTrackIDFast(time,pad,0)-2);
 	  tempPt->fDigitData[localcount].fTrackID[1] = (fDigits->GetTrackIDFast(time,pad,1)-2);
 	  tempPt->fDigitData[localcount].fTrackID[2] = (fDigits->GetTrackIDFast(time,pad,2)-2);
@@ -954,15 +1057,13 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nro
 	      tempPt->fDigitData[localcount].fTrackID[1] += ((event&0x3ff)<<22);
 	      tempPt->fDigitData[localcount].fTrackID[2] += ((event&0x3ff)<<22);
 	    }
-#endif
 	  localcount++;
 	}
       }
     }
     Byte_t *tmp = (Byte_t*)tempPt;
-    Int_t size = sizeof(AliHLTTPCDigitRowData)
+    tmp += sizeof(AliHLTTPCDigitRowData)
       + ndigits[r]*sizeof(AliHLTTPCDigitData);
-    tmp += size;
     tempPt = (AliHLTTPCDigitRowData*)tmp;
   }
   delete [] ndigits;
@@ -972,7 +1073,6 @@ AliHLTTPCDigitRowData * AliHLTTPCFileHandler::AliAltroDigits2Memory(UInt_t & nro
 Bool_t AliHLTTPCFileHandler::GetDigitsTree(Int_t event)
 {
   //Connects to the TPC digit tree in the AliROOT file.
-#ifdef use_newio
   AliLoader* tpcLoader = fInAli->GetLoader("TPCLoader");
   if(!tpcLoader){
     LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::GetDigitsTree","File")
@@ -982,12 +1082,6 @@ Bool_t AliHLTTPCFileHandler::GetDigitsTree(Int_t event)
   fInAli->GetEvent(event);
   tpcLoader->LoadDigits();
   fDigitsTree = tpcLoader->TreeD();
-#else  
-  fInAli->cd();
-  Char_t dname[100];
-  sprintf(dname,"TreeD_%s_%d",AliHLTTPCTransform::GetParamName(),event);
-  fDigitsTree = (TTree*)fInAli->Get(dname);
-#endif
   if(!fDigitsTree) 
     {
       LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::GetDigitsTree","Digits Tree")
@@ -1000,7 +1094,7 @@ Bool_t AliHLTTPCFileHandler::GetDigitsTree(Int_t event)
   else return kTRUE;
 }
 
-void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_t *new_digitsfile)
+void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_t *newDigitsfile)
 {
   //Write the data stored in rowPt, into a new AliROOT file.
   //The data is stored in the AliROOT format 
@@ -1023,7 +1117,6 @@ void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_
       return;
     }
 
-#ifdef use_newio
   //Get the original digitstree:
   AliLoader* tpcLoader = fInAli->GetLoader("TPCLoader");
   if(!tpcLoader){
@@ -1032,13 +1125,13 @@ void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_
     return;
   }
   tpcLoader->LoadDigits();
-  TTree *t=tpcLoader->TreeD();
+  TTree *treeD=tpcLoader->TreeD();
 
-  AliTPCDigitsArray *old_array = new AliTPCDigitsArray();
-  old_array->Setup(fParam);
-  old_array->SetClass("AliSimDigits");
+  AliTPCDigitsArray *oldArray = new AliTPCDigitsArray();
+  oldArray->Setup(fParam);
+  oldArray->SetClass("AliSimDigits");
 
-  Bool_t ok = old_array->ConnectTree(t);
+  Bool_t ok = oldArray->ConnectTree(treeD);
   if(!ok)
     {
       LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliDigits2RootFile","File")
@@ -1046,7 +1139,7 @@ void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_
       return;
     }
 
-  tpcLoader->SetDigitsFileName(new_digitsfile);
+  tpcLoader->SetDigitsFileName(newDigitsfile);
   tpcLoader->MakeDigitsContainer();
     
   //setup a new one, or connect it to the existing one:
@@ -1054,68 +1147,6 @@ void AliHLTTPCFileHandler::AliDigits2RootFile(AliHLTTPCDigitRowData *rowPt,Char_
   arr->SetClass("AliSimDigits");
   arr->Setup(fParam);
   arr->MakeTree(tpcLoader->TreeD());
-#else
-  
-  //Get the original digitstree:
-  Char_t dname[100];
-  sprintf(dname,"TreeD_%s_0",AliHLTTPCTransform::GetParamName());
-
-  fInAli->cd();
-  AliTPCDigitsArray *old_array = new AliTPCDigitsArray();
-  old_array->Setup(fParam);
-  old_array->SetClass("AliSimDigits");
-
-  Bool_t ok = old_array->ConnectTree(dname);
-  if(!ok)
-    {
-      LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliDigits2RootFile","File")
-	<<"No digits tree object." <AccessPathName(new_digitsfile))
-    {
-      LOG(AliHLTTPCLog::kInformational,"AliHLTTPCFileHandler::AliDigits2RootFile","File")
-	<<"Creating new file "<Write(fParam->GetTitle());
-    }
-  else
-    {
-      create = kFALSE;
-      digFile = TFile::Open(new_digitsfile,"UPDATE");
-      
-    }
-  if(!digFile->IsOpen())
-    {
-      LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliDigits2RootFile","Rootfile")
-	<<"Error opening rootfile "<cd();
-    
-  //setup a new one, or connect it to the existing one:
-  AliTPCDigitsArray *arr = new AliTPCDigitsArray(); 
-  arr->SetClass("AliSimDigits");
-  arr->Setup(fParam);
-  if(create)
-    arr->MakeTree();
-  else
-    {
-      Bool_t ok = arr->ConnectTree(dname);
-      if(!ok)
-	{
-	  LOG(AliHLTTPCLog::kError,"AliHLTTPCFileHandler::AliDigits2RootFile","Rootfile")
-	    <<"No digits tree object in existing file"<LoadRow(sector,row);
+      AliSimDigits *oldDig = (AliSimDigits*)oldArray->LoadRow(sector,row);
       AliSimDigits * dig = (AliSimDigits*)arr->CreateRow(sector,row);
-      old_dig->ExpandBuffer();
-      old_dig->ExpandTrackBuffer();
+      oldDig->ExpandBuffer();
+      oldDig->ExpandTrackBuffer();
       dig->ExpandBuffer();
       dig->ExpandTrackBuffer();
       
-      if(!old_dig)
+      if(!oldDig)
 	LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliDigits2RootFile","Data")
 	  <<"No padrow " << sector << " " << row <GetTrackIDFast(time,pad,t);
+	      Int_t label = oldDig->GetTrackIDFast(time,pad,track);
 	      if(label > 1)
-		trackID[t] = label - 2;
+		trackID[track] = label - 2;
 	      else if(label==0)
-		trackID[t] = -2;
+		trackID[track] = -2;
 	      else
-		trackID[t] = -1;
+		trackID[track] = -1;
 	    }
 	  
 	  dig->SetDigitFast(charge,time,pad);
 	  
-	  for(Int_t t=0; t<3; t++)
-	    ((AliSimDigits*)dig)->SetTrackIDFast(trackID[t],time,pad,t);
+	  for(Int_t track=0; track<3; track++)
+	    ((AliSimDigits*)dig)->SetTrackIDFast(trackID[track],time,pad,track);
 	  
 	}
       //cout<<"Wrote "<StoreRow(sector,row);
       arr->ClearRow(sector,row);  
-      old_array->ClearRow(sector,row);
+      oldArray->ClearRow(sector,row);
     }
 
   char treeName[100];
   sprintf(treeName,"TreeD_%s_0",fParam->GetTitle());
   
-#ifdef use_newio
   arr->GetTree()->SetName(treeName);
   arr->GetTree()->AutoSave();
   tpcLoader->WriteDigits("OVERWRITE");
-#else
-  digFile->cd();
-  arr->GetTree()->SetName(treeName);
-  arr->GetTree()->AutoSave();
-  digFile->Close();
-#endif
   delete arr;
-  delete old_array;
+  delete oldArray;
 }
 
 ///////////////////////////////////////// Point IO  
@@ -1221,16 +1245,8 @@ AliHLTTPCSpacePointData * AliHLTTPCFileHandler::AliPoints2Memory(UInt_t & npoint
     <<"No Input avalible: no object fInAli"<IsOpen()){
-    LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliPoints2Memory","File")
-    <<"No Input avalible: TFile not opend"<GetLoader("TPCLoader");
   if(!tpcLoader){
     LOG(AliHLTTPCLog::kWarning,"AliHLTTPCFileHandler::AliPoints2Memory","File")
@@ -1244,16 +1260,6 @@ AliHLTTPCSpacePointData * AliHLTTPCFileHandler::AliPoints2Memory(UInt_t & npoint
   carray.Setup(fParam);
   carray.SetClusterType("AliTPCcluster");
   Bool_t clusterok = carray.ConnectTree(tpcLoader->TreeR());
-#else
-  fInAli->cd();
-  
-  Char_t cname[100];
-  sprintf(cname,"TreeC_TPC_%d",eventn);
-  AliTPCClustersArray carray;
-  carray.Setup(fParam);
-  carray.SetClusterType("AliTPCcluster");
-  Bool_t clusterok = carray.ConnectTree(cname);
-#endif
 
   if(!clusterok) return 0;
 
@@ -1293,8 +1299,8 @@ AliHLTTPCSpacePointData * AliHLTTPCFileHandler::AliPoints2Memory(UInt_t & npoint
     Int_t row = rows[i];
     Int_t sector = sects[i];
     AliHLTTPCTransform::Sector2Slice(lslice,lrow,sector,row);
-    Int_t entries_in_row = clusterrow[i]->GetArray()->GetEntriesFast();
-    for(Int_t j = 0;jGetArray()->GetEntriesFast();
+    for(Int_t j = 0;jGetZ();
       data[n].fY = c->GetY();