]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
updated
authorkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 Apr 2008 10:32:41 +0000 (10:32 +0000)
committerkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 Apr 2008 10:32:41 +0000 (10:32 +0000)
TPC/AliTPCclustererKr.cxx

index 352d819b4af29a8a7b69eeab66ba4cb8ebae1518..f8c8740360fbcd0d14c43b869d27019419bf2b32 100644 (file)
 /* $Id: AliTPCclustererKr.cxx,v 1.7 2008/02/06 17:24:53 matyja Exp $ */\r
 \r
 //-----------------------------------------------------------------\r
-//           Implementation of the TPC cluster class\r
+//           Implementation of the TPC Kr cluster class\r
 //\r
 // Origin: Adam Matyja, INP PAN, adam.matyja@ifj.edu.pl\r
 //-----------------------------------------------------------------\r
 \r
+/*\r
+Instruction - how to use that:\r
+There are two macros prepared. One is for preparing clusters from MC \r
+samples:  FindKrClusters.C. The output is kept in TPC.RecPoints.root.\r
+The other macro is prepared for data analysis: FindKrClustersRaw.C. \r
+The output is created for each processed file in root file named adc.root. \r
+For each data subsample the same named file is created. So be careful \r
+do not overwrite them. \r
+\r
+*\r
+**** MC ****\r
+*\r
+\r
+To run clusterizaton for MC type:\r
+.x FindKrClusters.C\r
+\r
+If you don't want to use the standard selection criteria then you \r
+have to do following:\r
+\r
+// load the standard setup\r
+AliRunLoader* rl = AliRunLoader::Open("galice.root");\r
+AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");\r
+tpcl->LoadDigits();\r
+rl->LoadgAlice();\r
+gAlice=rl->GetAliRun();\r
+TDirectory *cwd = gDirectory;\r
+AliTPCv4 *tpc = (AliTPCv4*)gAlice->GetDetector("TPC");\r
+Int_t ver = tpc->IsVersion();\r
+rl->CdGAFile();\r
+AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");\r
+AliTPCDigitsArray *digarr=new AliTPCDigitsArray;\r
+digarr->Setup(param);\r
+cwd->cd();\r
+\r
+//loop over events\r
+Int_t nevmax=rl->GetNumberOfEvents();\r
+for(Int_t nev=0;nev<nevmax ;nev++){\r
+  rl->GetEvent(nev);\r
+  TTree* input_tree= tpcl->TreeD();//load tree with digits\r
+  digarr->ConnectTree(input_tree);\r
+  TTree *output_tree =tpcl->TreeR();//load output tree\r
+\r
+  AliTPCclustererKr *clusters = new AliTPCclustererKr();\r
+  clusters->SetParam(param);\r
+  clusters->SetInput(input_tree);\r
+  clusters->SetOutput(output_tree);\r
+  clusters->SetDigArr(digarr);\r
+  \r
+//If you want to change the cluster finder parameters for MC there are \r
+//several of them:\r
+\r
+//1. signal threshold (everything below the given number is treated as 0)\r
+  clusters->SetMinAdc(3);\r
+\r
+//2. number of neighbouring timebins to be considered\r
+  clusters->SetMinTimeBins(2);\r
+\r
+//3. distance of the cluster center to the center of a pad in pad-padrow plane \r
+//(in cm). Remenber that this is still quantified by pad size.\r
+  clusters->SetMaxPadRangeCm(2.5);\r
+\r
+//4. distance of the cluster center to the center of a padrow in pad-padrow \r
+//plane (in cm). Remenber that this is still quantified by pad size.\r
+  clusters->SetMaxRowRangeCm(3.5);\r
+\r
+//5. distance of the cluster center to the max time bin on a pad (in tackts)\r
+//ie. fabs(centerT - time)<7\r
+  clusters->SetMaxTimeRange(7);\r
+\r
+//6. cut reduce peak at 0. There are noises which appear mostly as two \r
+//timebins on one pad.\r
+  clusters->SetValueToSize(3.5);\r
+\r
+\r
+  clusters->finderIO();\r
+  tpcl->WriteRecPoints("OVERWRITE");\r
+}\r
+delete rl;//cleans everything\r
+\r
+*\r
+********* DATA *********\r
+*\r
+\r
+To run clusterizaton for DATA for file named raw_data.root type:\r
+.x FindKrClustersRaw.C("raw_data.root")\r
+\r
+If you want to change some criteria do the following:\r
+\r
+//\r
+// remove Altro warnings\r
+//\r
+AliLog::SetClassDebugLevel("AliTPCRawStream",-5);\r
+AliLog::SetClassDebugLevel("AliRawReaderDate",-5);\r
+AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);\r
+AliLog::SetModuleDebugLevel("RAW",-5);\r
+\r
+//\r
+// Get database with noises\r
+//\r
+//  char *ocdbpath = gSystem->Getenv("OCDB_PATH");\r
+char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";\r
+if (ocdbpath==0){\r
+ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";\r
+}\r
+AliCDBManager * man = AliCDBManager::Instance();\r
+man->SetDefaultStorage(ocdbpath);\r
+man->SetRun(0);\r
+AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();\r
+AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();\r
+\r
+//define tree\r
+TFile *hfile=new TFile("adc.root","RECREATE","ADC file");\r
+// Create a ROOT Tree\r
+TTree *mytree = new TTree("Kr","Krypton cluster tree");\r
+\r
+//define infput file\r
+const char *fileName="data.root";\r
+AliRawReader *reader = new AliRawReaderRoot(fileName);\r
+//AliRawReader *reader = new AliRawReaderDate(fileName);\r
+reader->Reset();\r
+AliAltroRawStreamFast* stream = new AliAltroRawStreamFast(reader);\r
+stream->SelectRawData("TPC");\r
+\r
+//one general output\r
+AliTPCclustererKr *clusters = new AliTPCclustererKr();\r
+clusters->SetOutput(mytree);\r
+clusters->SetRecoParam(0);//standard reco parameters\r
+AliTPCParamSR *param=new AliTPCParamSR();\r
+clusters->SetParam(param);//TPC parameters(sectors, timebins, etc.)\r
+\r
+//set cluster finder parameters (from data):\r
+//1. zero suppression parameter\r
+  clusters->SetZeroSup(param->GetZeroSup());\r
+\r
+//2. first bin\r
+  clusters->SetFirstBin(60);\r
+\r
+//3. last bin\r
+  clusters->SetLastBin(950);\r
+\r
+//4. maximal noise\r
+  clusters->SetMaxNoiseAbs(2);\r
+\r
+//5. maximal amount of sigma of noise\r
+  clusters->SetMaxNoiseSigma(3);\r
+\r
+//The remaining parameters are the same paramters as for MC (see MC section \r
+//points 1-6)\r
+  clusters->SetMinAdc(3);\r
+  clusters->SetMinTimeBins(2);\r
+  clusters->SetMaxPadRangeCm(2.5);\r
+  clusters->SetMaxRowRangeCm(3.5);\r
+  clusters->SetMaxTimeRange(7);\r
+  clusters->SetValueToSize(3.5);\r
+\r
+while (reader->NextEvent()) {\r
+  clusters->FinderIO(reader);\r
+}\r
+\r
+hfile->Write();\r
+hfile->Close();\r
+delete stream;\r
+\r
+\r
+*/\r
+\r
 #include "AliTPCclustererKr.h"\r
 #include "AliTPCclusterKr.h"\r
-#include <vector>\r
+//#include <vector>\r
 #include <list>\r
 #include "TObject.h"\r
 #include "AliPadMax.h"\r
 #include "AliTPCvtpr.h"\r
 #include "AliTPCClustersRow.h"\r
 #include "TTree.h"\r
+#include "TH1F.h"\r
+#include "TH2F.h"\r
 \r
 //used in raw data finder\r
 #include "AliTPCROC.h"\r
@@ -71,7 +239,12 @@ AliTPCclustererKr::AliTPCclustererKr()
   fMaxTimeRange(7),\r
   fValueToSize(3.5),\r
   fMaxPadRangeCm(2.5),\r
-  fMaxRowRangeCm(3.5)\r
+  fMaxRowRangeCm(3.5),\r
+  fDebugLevel(-1),\r
+  fHistoRow(0),\r
+  fHistoPad(0),\r
+  fHistoTime(0),\r
+  fHistoRowPad(0)\r
 {\r
 //\r
 // default constructor\r
@@ -100,7 +273,12 @@ AliTPCclustererKr::AliTPCclustererKr(const AliTPCclustererKr &param)
   fMaxTimeRange(7),\r
   fValueToSize(3.5),\r
   fMaxPadRangeCm(2.5),\r
-  fMaxRowRangeCm(3.5)\r
+  fMaxRowRangeCm(3.5),\r
+  fDebugLevel(-1),\r
+  fHistoRow(0),\r
+  fHistoPad(0),\r
+  fHistoTime(0),\r
+  fHistoRowPad(0)\r
 {\r
 //\r
 // copy constructor\r
@@ -126,10 +304,19 @@ AliTPCclustererKr::AliTPCclustererKr(const AliTPCclustererKr &param)
   fValueToSize  = param.fValueToSize;\r
   fMaxPadRangeCm = param.fMaxPadRangeCm;\r
   fMaxRowRangeCm = param.fMaxRowRangeCm;\r
+  fDebugLevel = param.fDebugLevel;\r
+  fHistoRow    = param.fHistoRow   ;\r
+  fHistoPad    = param.fHistoPad  ;\r
+  fHistoTime   = param.fHistoTime;\r
+  fHistoRowPad = param.fHistoRowPad;\r
+\r
 } \r
 \r
 AliTPCclustererKr & AliTPCclustererKr::operator = (const AliTPCclustererKr & param)\r
 {\r
+  //\r
+  // assignment operator\r
+  //\r
   fParam = param.fParam;\r
   fRecoParam = param.fRecoParam;\r
   fIsOldRCUFormat = param.fIsOldRCUFormat;\r
@@ -151,6 +338,11 @@ AliTPCclustererKr & AliTPCclustererKr::operator = (const AliTPCclustererKr & par
   fValueToSize  = param.fValueToSize;\r
   fMaxPadRangeCm = param.fMaxPadRangeCm;\r
   fMaxRowRangeCm = param.fMaxRowRangeCm;\r
+  fDebugLevel = param.fDebugLevel;\r
+  fHistoRow    = param.fHistoRow   ;\r
+  fHistoPad    = param.fHistoPad  ;\r
+  fHistoTime   = param.fHistoTime;\r
+  fHistoRowPad = param.fHistoRowPad;\r
   return (*this);\r
 }\r
 \r
@@ -163,6 +355,9 @@ AliTPCclustererKr::~AliTPCclustererKr()
 \r
 void AliTPCclustererKr::SetRecoParam(AliTPCRecoParam *recoParam)\r
 {\r
+  //\r
+  // set reconstruction parameters\r
+  //\r
   if (recoParam) {\r
     fRecoParam = recoParam;\r
   }else{\r
@@ -228,8 +423,6 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
   //\r
   // fParam must be defined before\r
 \r
-  // consider noiceROC or not\r
-\r
   if(rawReader)fRawData=kTRUE; //set flag to data\r
 \r
   if (!fOutput) {\r
@@ -290,6 +483,7 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
     //\r
     // Load the raw data for corresponding DDLs\r
     //\r
+    //fIsOldRCUFormat=kTRUE;\r
     rawReader->Reset();\r
     input.SetOldRCUFormat(fIsOldRCUFormat);\r
     rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);\r
@@ -314,8 +508,39 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
       if (input.GetSector() != iSec)\r
        AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",iSec,input.GetSector()));\r
       \r
-      //check row consistency\r
       Short_t iRow = input.GetRow();\r
+      Short_t iPad = input.GetPad();\r
+      Short_t iTimeBin = input.GetTime();\r
+\r
+      if(fDebugLevel==72){\r
+       fHistoRow->Fill(iRow);\r
+       fHistoPad->Fill(iPad);\r
+       fHistoTime->Fill(iTimeBin);\r
+       fHistoRowPad->Fill(iPad,iRow);\r
+      }else if(fDebugLevel>=0&&fDebugLevel<72){\r
+       if(iSec==fDebugLevel){\r
+         fHistoRow->Fill(iRow);\r
+         fHistoPad->Fill(iPad);\r
+         fHistoTime->Fill(iTimeBin);\r
+         fHistoRowPad->Fill(iPad,iRow);\r
+       }\r
+      }else if(fDebugLevel==73){\r
+       if(iSec<36){\r
+         fHistoRow->Fill(iRow);\r
+         fHistoPad->Fill(iPad);\r
+         fHistoTime->Fill(iTimeBin);\r
+         fHistoRowPad->Fill(iPad,iRow);\r
+       }\r
+      }else if(fDebugLevel==74){\r
+       if(iSec>=36){\r
+         fHistoRow->Fill(iRow);\r
+         fHistoPad->Fill(iPad);\r
+         fHistoTime->Fill(iTimeBin);\r
+         fHistoRowPad->Fill(iPad,iRow);\r
+       }\r
+      }\r
+\r
+      //check row consistency\r
       if (iRow < 0 || iRow >= nRows){\r
        AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",\r
                      iRow, 0, nRows -1));\r
@@ -323,7 +548,6 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
       }\r
 \r
       //check pad consistency\r
-      Short_t iPad = input.GetPad();\r
       if (iPad < 0 || iPad >= (Short_t)(roc->GetNPads(iSec,iRow))) {\r
        AliError(Form("Pad index (%d) outside the range (%d -> %d) !",\r
                      iPad, 0, roc->GetNPads(iSec,iRow) ));\r
@@ -331,7 +555,6 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
       }\r
 \r
       //check time consistency\r
-      Short_t iTimeBin = input.GetTime();\r
       if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){\r
        //cout<<iTimeBin<<endl;\r
        continue;\r
@@ -350,8 +573,10 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader)
       }\r
       if (!noiseROC) continue;\r
       Double_t noiseOnPad = noiseROC->GetValue(iRow,iPad);//noise on given pad and row in sector\r
-      if (noiseOnPad > fMaxNoiseAbs) continue; // consider noisy pad as dead\r
-      \r
+      if (noiseOnPad > fMaxNoiseAbs){\r
+       digarr->GetRow(iSec,iRow)->SetDigitFast(0,iTimeBin,iPad);\r
+       continue; // consider noisy pad as dead\r
+      }\r
       if(signal <= fMaxNoiseSigma * noiseOnPad){\r
        digarr->GetRow(iSec,iRow)->SetDigitFast(0,iTimeBin,iPad);\r
        continue;\r
@@ -389,14 +614,15 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
   for(Short_t iSec=0; iSec<nTotalSector; ++iSec){\r
     \r
     //vector of maxima for each sector\r
-    std::vector<AliPadMax*> maximaInSector;\r
-    \r
+    //std::vector<AliPadMax*> maximaInSector;\r
+    TObjArray *maximaInSector=new TObjArray();//to store AliPadMax*\r
+\r
     //\r
     //  looking for the maxima on the pad\r
     //\r
 \r
-    const Short_t nRows=fParam->GetNRow(iSec);//number of rows in sector\r
-    for(Short_t iRow=0; iRow<nRows; ++iRow){\r
+    const Short_t kNRows=fParam->GetNRow(iSec);//number of rows in sector\r
+    for(Short_t iRow=0; iRow<kNRows; ++iRow){\r
       AliSimDigits *digrow;\r
       if(fRawData){\r
        digrow = (AliSimDigits*)fDigarr->GetRow(iSec,iRow);//real data\r
@@ -405,9 +631,9 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
       }\r
       if(digrow){//if pointer exist\r
        digrow->ExpandBuffer(); //decrunch\r
-       const Short_t nPads = digrow->GetNCols();  // number of pads\r
-       const Short_t nTime = digrow->GetNRows(); // number of timebins\r
-       for(Short_t iPad=0;iPad<nPads;iPad++){\r
+       const Short_t kNPads = digrow->GetNCols();  // number of pads\r
+       const Short_t kNTime = digrow->GetNRows(); // number of timebins\r
+       for(Short_t iPad=0;iPad<kNPads;iPad++){\r
          \r
          Short_t timeBinMax=-1;//timebin of maximum \r
          Short_t valueMaximum=-1;//value of maximum in adc\r
@@ -416,7 +642,7 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
          bool ifIncreaseBegin=true;//flag - check if increasing started\r
          bool ifMaximum=false;//flag - check if it could be maximum\r
 \r
-         for(Short_t iTimeBin=0;iTimeBin<nTime;iTimeBin++){\r
+         for(Short_t iTimeBin=0;iTimeBin<kNTime;iTimeBin++){\r
            Short_t adc = digrow->GetDigitFast(iTimeBin,iPad);\r
            if(adc<fMinAdc){//standard was 3\r
              if(ifMaximum){\r
@@ -442,7 +668,8 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
                                                      increaseBegin,\r
                                                      iTimeBin-1,\r
                                                      sumAdc);\r
-               maximaInSector.push_back(oneMaximum);\r
+               //maximaInSector.push_back(oneMaximum);\r
+               maximaInSector->AddLast(oneMaximum);\r
                \r
                timeBinMax=-1;\r
                valueMaximum=-1;\r
@@ -465,7 +692,7 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
              ifMaximum=true;\r
            }\r
            sumAdc+=adc;\r
-           if(iTimeBin==nTime-1 && ifMaximum && nTime-increaseBegin>fMinTimeBins){//on the edge\r
+           if(iTimeBin==kNTime-1 && ifMaximum && kNTime-increaseBegin>fMinTimeBins){//on the edge\r
              //at least 3 timebins\r
              //insert maximum, default values and set flags\r
              Double_t xCord,yCord;\r
@@ -480,8 +707,9 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
                                                    increaseBegin,\r
                                                    iTimeBin-1,\r
                                                    sumAdc);\r
-             maximaInSector.push_back(oneMaximum);\r
-             \r
+             //maximaInSector.push_back(oneMaximum);\r
+             maximaInSector->AddLast(oneMaximum);\r
+               \r
              timeBinMax=-1;\r
              valueMaximum=-1;\r
              increaseBegin=-1;\r
@@ -497,7 +725,12 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
 //     cout<<"Pointer does not exist!!"<<endl;\r
       }//end if poiner exists\r
     }//end loop over rows\r
-    \r
+\r
+    //    cout<<"EF" <<maximaInSector->GetEntriesFast()<<" E "<<maximaInSector->GetEntries()<<" "<<maximaInSector->GetLast()<<endl;\r
+    maximaInSector->Compress();\r
+    // GetEntriesFast() - liczba wejsc w array of maxima\r
+    //cout<<"EF" <<maximaInSector->GetEntriesFast()<<" E"<<maximaInSector->GetEntries()<<endl;\r
+\r
     //\r
     // Making clusters\r
     //\r
@@ -510,107 +743,124 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
     Double_t maxX=0;\r
     Double_t maxY=0;\r
     \r
-    for( std::vector<AliPadMax*>::iterator mp1  = maximaInSector.begin();\r
-        mp1 != maximaInSector.end(); ++mp1 ) {\r
-      \r
+//    for( std::vector<AliPadMax*>::iterator mp1  = maximaInSector.begin();\r
+//      mp1 != maximaInSector.end(); ++mp1 ) {\r
+    for(Int_t it1 = 0; it1 < maximaInSector->GetEntriesFast(); ++it1 ) {\r
+\r
+      AliPadMax *mp1=(AliPadMax *)maximaInSector->At(it1);\r
       AliTPCclusterKr *tmp=new AliTPCclusterKr();\r
       \r
       Short_t nUsedPads=1;\r
       Int_t clusterValue=0;\r
-      clusterValue+=(*mp1)->GetSum();\r
+      clusterValue+=(mp1)->GetSum();\r
       list<Short_t> nUsedRows;\r
-      nUsedRows.push_back((*mp1)->GetRow());\r
+      nUsedRows.push_back((mp1)->GetRow());\r
 \r
-      maxDig      =(*mp1)->GetAdc() ;\r
-      maxSumAdc   =(*mp1)->GetSum() ;\r
-      maxTimeBin  =(*mp1)->GetTime();\r
-      maxPad      =(*mp1)->GetPad() ;\r
-      maxRow      =(*mp1)->GetRow() ;\r
-      maxX        =(*mp1)->GetX();\r
-      maxY        =(*mp1)->GetY();\r
+      maxDig      =(mp1)->GetAdc() ;\r
+      maxSumAdc   =(mp1)->GetSum() ;\r
+      maxTimeBin  =(mp1)->GetTime();\r
+      maxPad      =(mp1)->GetPad() ;\r
+      maxRow      =(mp1)->GetRow() ;\r
+      maxX        =(mp1)->GetX();\r
+      maxY        =(mp1)->GetY();\r
 \r
       AliSimDigits *digrowTmp;\r
       if(fRawData){\r
-       digrowTmp = (AliSimDigits*)fDigarr->GetRow(iSec,(*mp1)->GetRow());\r
+       digrowTmp = (AliSimDigits*)fDigarr->GetRow(iSec,(mp1)->GetRow());\r
       }else{\r
-       digrowTmp = (AliSimDigits*)fDigarr->LoadRow(iSec,(*mp1)->GetRow());\r
+       digrowTmp = (AliSimDigits*)fDigarr->LoadRow(iSec,(mp1)->GetRow());\r
       }\r
 \r
       digrowTmp->ExpandBuffer(); //decrunch\r
 \r
-      for(Short_t itb=(*mp1)->GetBegin(); itb<((*mp1)->GetEnd())+1; itb++){\r
-       Short_t adcTmp = digrowTmp->GetDigitFast(itb,(*mp1)->GetPad());\r
-       AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(*mp1)->GetPad(),(*mp1)->GetRow(),(*mp1)->GetX(),(*mp1)->GetY(),itb);\r
-       tmp->fCluster.push_back(vtpr);\r
-\r
+      for(Short_t itb=(mp1)->GetBegin(); itb<((mp1)->GetEnd())+1; itb++){\r
+       Short_t adcTmp = digrowTmp->GetDigitFast(itb,(mp1)->GetPad());\r
+       AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(mp1)->GetPad(),(mp1)->GetRow(),(mp1)->GetX(),(mp1)->GetY(),itb);\r
+       //tmp->fCluster.push_back(vtpr);\r
+       tmp->AddDigitToCluster(vtpr);\r
       }\r
       tmp->SetCenter();//set centr of the cluster\r
       \r
-      maximaInSector.erase(mp1);\r
-      mp1--;\r
-      \r
-      for( std::vector<AliPadMax*>::iterator mp2  = maximaInSector.begin();\r
-          mp2 != maximaInSector.end(); ++mp2 ) {\r
+      //maximaInSector.erase(mp1);\r
+      //mp1--;\r
+      //cout<<maximaInSector->GetEntriesFast()<<" ";\r
+      maximaInSector->RemoveAt(it1);\r
+      maximaInSector->Compress();\r
+      it1--;\r
+      //     cout<<maximaInSector->GetEntriesFast()<<" "<<endl;\r
+\r
+//      for( std::vector<AliPadMax*>::iterator mp2  = maximaInSector.begin();\r
+//        mp2 != maximaInSector.end(); ++mp2 ) {\r
+      for(Int_t it2 = 0; it2 < maximaInSector->GetEntriesFast(); ++it2 ) {\r
+       AliPadMax *mp2=(AliPadMax *)maximaInSector->At(it2);\r
+\r
 //     if(abs(maxRow - (*mp2)->GetRow()) < fMaxRowRange && //3\r
 //         abs(maxPad - (*mp2)->GetPad()) < fMaxPadRange && //4\r
          \r
-       if(TMath::Abs(tmp->GetCenterX() - (*mp2)->GetX()) < fMaxPadRangeCm &&\r
-          TMath::Abs(tmp->GetCenterY() - (*mp2)->GetY()) < fMaxRowRangeCm &&\r
-          TMath::Abs(tmp->GetCenterT() - (*mp2)->GetT()) < fMaxTimeRange){//7\r
+       if(TMath::Abs(tmp->GetCenterX() - (mp2)->GetX()) < fMaxPadRangeCm &&\r
+          TMath::Abs(tmp->GetCenterY() - (mp2)->GetY()) < fMaxRowRangeCm &&\r
+          TMath::Abs(tmp->GetCenterT() - (mp2)->GetT()) < fMaxTimeRange){//7\r
          \r
-         clusterValue+=(*mp2)->GetSum();\r
+         clusterValue+=(mp2)->GetSum();\r
 \r
          nUsedPads++;\r
-         nUsedRows.push_back((*mp2)->GetRow());\r
+         nUsedRows.push_back((mp2)->GetRow());\r
 \r
          AliSimDigits *digrowTmp1;\r
          if(fRawData){\r
-           digrowTmp1 = (AliSimDigits*)fDigarr->GetRow(iSec,(*mp2)->GetRow());\r
+           digrowTmp1 = (AliSimDigits*)fDigarr->GetRow(iSec,(mp2)->GetRow());\r
          }else{\r
-           digrowTmp1 = (AliSimDigits*)fDigarr->LoadRow(iSec,(*mp2)->GetRow());\r
+           digrowTmp1 = (AliSimDigits*)fDigarr->LoadRow(iSec,(mp2)->GetRow());\r
          }\r
          digrowTmp1->ExpandBuffer(); //decrunch\r
          \r
-         for(Short_t itb=(*mp2)->GetBegin(); itb<(*mp2)->GetEnd()+1; itb++){\r
-           Short_t adcTmp = digrowTmp1->GetDigitFast(itb,(*mp2)->GetPad());\r
-           AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(*mp2)->GetPad(),(*mp2)->GetRow(),(*mp2)->GetX(),(*mp2)->GetY(),itb);\r
-           tmp->fCluster.push_back(vtpr);\r
+         for(Short_t itb=(mp2)->GetBegin(); itb<(mp2)->GetEnd()+1; itb++){\r
+           Short_t adcTmp = digrowTmp1->GetDigitFast(itb,(mp2)->GetPad());\r
+           AliTPCvtpr *vtpr=new AliTPCvtpr(adcTmp,itb,(mp2)->GetPad(),(mp2)->GetRow(),(mp2)->GetX(),(mp2)->GetY(),itb);\r
+           //tmp->fCluster.push_back(vtpr);\r
+           tmp->AddDigitToCluster(vtpr);\r
          }\r
          \r
-         tmp->SetCenter();//set centr of the cluster\r
+         tmp->SetCenter();//set center of the cluster\r
 \r
          //which one is bigger\r
-         if( (*mp2)->GetAdc() > maxDig ){\r
-           maxDig      =(*mp2)->GetAdc() ;\r
-           maxSumAdc   =(*mp2)->GetSum() ;\r
-           maxTimeBin  =(*mp2)->GetTime();\r
-           maxPad      =(*mp2)->GetPad() ;\r
-           maxRow      =(*mp2)->GetRow() ;\r
-           maxX        =(*mp2)->GetX() ;\r
-           maxY        =(*mp2)->GetY() ;\r
-         } else if ( (*mp2)->GetAdc() == maxDig ){\r
-           if( (*mp2)->GetSum() > maxSumAdc){\r
-             maxDig      =(*mp2)->GetAdc() ;\r
-             maxSumAdc   =(*mp2)->GetSum() ;\r
-             maxTimeBin  =(*mp2)->GetTime();\r
-             maxPad      =(*mp2)->GetPad() ;\r
-             maxRow      =(*mp2)->GetRow() ;\r
-             maxX        =(*mp2)->GetX() ;\r
-             maxY        =(*mp2)->GetY() ;\r
+         if( (mp2)->GetAdc() > maxDig ){\r
+           maxDig      =(mp2)->GetAdc() ;\r
+           maxSumAdc   =(mp2)->GetSum() ;\r
+           maxTimeBin  =(mp2)->GetTime();\r
+           maxPad      =(mp2)->GetPad() ;\r
+           maxRow      =(mp2)->GetRow() ;\r
+           maxX        =(mp2)->GetX() ;\r
+           maxY        =(mp2)->GetY() ;\r
+         } else if ( (mp2)->GetAdc() == maxDig ){\r
+           if( (mp2)->GetSum() > maxSumAdc){\r
+             maxDig      =(mp2)->GetAdc() ;\r
+             maxSumAdc   =(mp2)->GetSum() ;\r
+             maxTimeBin  =(mp2)->GetTime();\r
+             maxPad      =(mp2)->GetPad() ;\r
+             maxRow      =(mp2)->GetRow() ;\r
+             maxX        =(mp2)->GetX() ;\r
+             maxY        =(mp2)->GetY() ;\r
            }\r
          }\r
-         maximaInSector.erase(mp2);\r
-         mp2--;\r
+         maximaInSector->RemoveAt(it2);\r
+         maximaInSector->Compress();\r
+         it2--;\r
+\r
+         //maximaInSector.erase(mp2);\r
+         //mp2--;\r
        }\r
       }//inside loop\r
-      \r
+\r
+      tmp->SetSize();\r
       //through out ADC=6,7 on 1 pad, 2 tb and ADC=12 on 2 pads,2 tb\r
       //if(nUsedPads==1 && clusterValue/tmp->fCluster.size()<3.6)continue;\r
       //if(nUsedPads==2 && clusterValue/tmp->fCluster.size()<3.1)continue;\r
 \r
       //through out clusters on the edge and noise\r
-      if(clusterValue/tmp->fCluster.size()<fValueToSize)continue;\r
-      \r
+      //if(clusterValue/tmp->fCluster.size()<fValueToSize)continue;\r
+      if(clusterValue/(tmp->GetSize())<fValueToSize)continue;\r
+\r
       tmp->SetADCcluster(clusterValue);\r
       tmp->SetNPads(nUsedPads);\r
       tmp->SetMax(AliTPCvtpr(maxDig,maxTimeBin,maxPad,maxRow,maxX,maxY,maxTimeBin));\r
@@ -624,6 +874,7 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
 \r
       clusterCounter++;\r
       \r
+\r
       //save each cluster into file\r
 \r
       AliTPCClustersRow *clrow= new AliTPCClustersRow();\r
@@ -638,7 +889,6 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
       \r
       fOutput->Fill(); \r
       delete clrow;\r
-\r
       //end of save each cluster into file adc.root\r
     }//outer loop\r
 \r
@@ -652,6 +902,9 @@ Int_t AliTPCclustererKr::FindClusterKrIO()
 \r
 \r
 void AliTPCclustererKr::GetXY(Short_t sec,Short_t row,Short_t pad,Double_t& xGlob,Double_t& yGlob){\r
+  //\r
+  //gives global XY coordinate of the pad\r
+  //\r
 \r
   Double_t yLocal = fParam->GetPadRowRadii(sec,row);//radius of row in sector in cm\r
 \r
@@ -659,13 +912,24 @@ void AliTPCclustererKr::GetXY(Short_t sec,Short_t row,Short_t pad,Double_t& xGlo
   Float_t padXSize;\r
   if(sec<fParam->GetNInnerSector())padXSize=0.4;\r
   else padXSize=0.6;\r
-  Double_t xLocal=(pad+0.5-padmax)*padXSize;//x-value of the center of pad\r
+  Double_t xLocal=(pad+0.5-padmax/2.)*padXSize;//x-value of the center of pad\r
 \r
   Float_t sin,cos;\r
   fParam->AdjustCosSin((Int_t)sec,cos,sin);//return sinus and cosinus of the sector\r
 \r
-  xGlob =  xLocal * cos + yLocal * sin;\r
-  yGlob = -xLocal * sin + yLocal * cos;\r
+  Double_t xGlob1 =  xLocal * cos + yLocal * sin;\r
+  Double_t yGlob1 = -xLocal * sin + yLocal * cos;\r
+\r
+\r
+  Double_t rot=0;\r
+  rot=TMath::Pi()/2.;\r
+\r
+  xGlob =  xGlob1 * TMath::Cos(rot) + yGlob1 * TMath::Sin(rot);\r
+  yGlob = -xGlob1 * TMath::Sin(rot) + yGlob1 * TMath::Cos(rot);\r
+\r
+   yGlob=-1*yGlob;\r
+   if(sec<18||(sec>=36&&sec<54)) xGlob =-1*xGlob;\r
+\r
 \r
   return;\r
 }\r