]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCclusterer.cxx
Density effect added (Yu.Belikov)
[u/mrichter/AliRoot.git] / TPC / AliTPCclusterer.cxx
index aeb503fd5cda486403d3b9d54faf0c97f98a6a29..e511bdfcdee50e8e09f67671ebe79c99f98adfa1 100644 (file)
 #include "AliTPCcluster.h"
 #include <TObjArray.h>
 #include <TFile.h>
-#include "AliTPCClustersArray.h"
-#include "AliTPCClustersRow.h"
 #include "AliDigits.h"
 #include "AliSimDigits.h"
 #include "AliTPCParam.h"
-#include <Riostream.h>
+#include "AliTPCClustersRow.h"
 #include <TTree.h>
-#include "AliRunLoader.h"
-#include "AliLoader.h"
+
+ClassImp(AliTPCclusterer)
+
+AliTPCclusterer::AliTPCclusterer(const AliTPCParam *par) { 
+//-------------------------------------------------------
+//  The main constructor
+//-------------------------------------------------------
+  fPar=par;
+}
 
 void AliTPCclusterer::FindPeaks(Int_t k,Int_t max,
 AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) {
@@ -87,76 +92,54 @@ AliTPCcluster &c) {
 }
 
 //_____________________________________________________________________________
-void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, AliLoader *of, Int_t eventn)
-{
+Int_t AliTPCclusterer::Digits2Clusters(TTree *dTree, TTree *cTree) {
   //-----------------------------------------------------------------
   // This is a simple cluster finder.
   //-----------------------------------------------------------------
-  AliRunLoader* rl = (AliRunLoader*)of->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName);
-  rl->GetEvent(eventn);
-  TDirectory *savedir=gDirectory; 
-
-  if (of->TreeR() == 0x0) of->MakeTree("R");
-  
-  
-  if (of == 0x0) 
-   {
-     cerr<<"AliTPC::Digits2Clusters(): output file not open !\n";
-     return;
-   }
-
-  const Int_t kMAXZ=par->GetMaxTBin()+2;
-
-  
-  TTree *t = (TTree *)of->TreeD();
-
-  if (!t) {
-    cerr<<"Input tree with digits not found"<<endl;
-    return;
+  TBranch *branch=dTree->GetBranch("Segment");
+  if (!branch) {
+     Error("Digits2Cluster","Can't get the branch !");
+     return 1;
   }
-
   AliSimDigits digarr, *dummy=&digarr;
-  t->GetBranch("Segment")->SetAddress(&dummy);
-  Stat_t nentries = t->GetEntries();
-
-  cout<<"Got "<<nentries<<" from TreeD"<<endl;
-
-//  ((AliTPCParam*)par)->Write(par->GetTitle());
+  branch->SetAddress(&dummy);
   
-  AliTPCClustersArray carray;
-  carray.Setup(par);
-  carray.SetClusterType("AliTPCcluster");
-
-  TTree* treeR = of->TreeR();
-  carray.MakeTree(treeR);
-
+  AliTPCClustersRow ddd,*clrow=&ddd;
+  clrow->SetClass("AliTPCcluster"); clrow->SetArray(1);
+  cTree->Branch("Segment","AliTPCClustersRow",&clrow,32000,200);    
 
+  const Int_t kMAXZ=fPar->GetMaxTBin()+2;
 
   Int_t nclusters=0;
 
-  for (Int_t n=0; n<nentries; n++) 
-   {
+  Int_t nentries = (Int_t)dTree->GetEntries();
+  for (Int_t n=0; n<nentries; n++) {
    
     Int_t sec, row;
-    t->GetEvent(n);
+    dTree->GetEvent(n);
 
-    if (!par->AdjustSectorRow(digarr.GetID(),sec,row)) {
-       cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
+    if (!fPar->AdjustSectorRow(digarr.GetID(),sec,row)) {
+       Error("Digits2Clusters","!nvalid segment ID ! %d",digarr.GetID());
        continue;
     }
 
-    AliTPCClustersRow *clrow=carray.CreateRow(sec,row);
+    clrow=new AliTPCClustersRow();
+
+    clrow->SetClass("AliTPCcluster"); clrow->SetArray(1);
+    clrow->SetID(digarr.GetID());
+
+    cTree->GetBranch("Segment")->SetAddress(&clrow);
 
-    Float_t rx=par->GetPadRowRadii(sec,row);
+    Float_t rx=fPar->GetPadRowRadii(sec,row);
 
     Int_t npads, sign;
     {
-       const Int_t kNIS=par->GetNInnerSector(), kNOS=par->GetNOuterSector();
+       const Int_t kNIS=fPar->GetNInnerSector(), kNOS=fPar->GetNOuterSector();
        if (sec < kNIS) {
-          npads = par->GetNPadsLow(row);
+          npads = fPar->GetNPadsLow(row);
           sign = (sec < kNIS/2) ? 1 : -1;
        } else {
-          npads = par->GetNPadsUp(row);
+          npads = fPar->GetNPadsUp(row);
           sign = ((sec-kNIS) < kNOS/2) ? 1 : -1;
        }
     }
@@ -170,7 +153,7 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, AliLoader *of, Int
     digarr.First();
     do {
        Short_t dig=digarr.CurrentDigit();
-       if (dig<=par->GetZeroSup()) continue;
+       if (dig<=fPar->GetZeroSup()) continue;
        Int_t j=digarr.CurrentRow()+1, i=digarr.CurrentColumn()+1;
        bins[i*kMAXZ+j].SetQ(dig);
        bins[i*kMAXZ+j].SetMask(1);
@@ -218,25 +201,25 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, AliLoader *of, Int
          c.SetZ(c.GetZ()/c.GetQ());
 
          Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
-         Float_t w=par->GetPadPitchWidth(sec);
+         Float_t w=fPar->GetPadPitchWidth(sec);
          c.SetSigmaY2((s2 + 1./12.)*w*w);
          if (s2 != 0.) {
           c.SetSigmaY2(c.GetSigmaY2()*0.108);
-          if (sec<par->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
+          if (sec<fPar->GetNInnerSector()) c.SetSigmaY2(c.GetSigmaY2()*2.07);
          }
 
          s2 = c.GetSigmaZ2()/c.GetQ() - c.GetZ()*c.GetZ();
-         w=par->GetZWidth();
+         w=fPar->GetZWidth();
          c.SetSigmaZ2((s2 + 1./12.)*w*w);
          if (s2 != 0.) {
           c.SetSigmaZ2(c.GetSigmaZ2()*0.169);
-          if (sec<par->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
+          if (sec<fPar->GetNInnerSector()) c.SetSigmaZ2(c.GetSigmaZ2()*1.77);
          }
 
-         c.SetY((c.GetY() - 0.5 - 0.5*npads)*par->GetPadPitchWidth(sec));
-         c.SetZ(par->GetZWidth()*(c.GetZ()-1)); 
-         c.SetZ(c.GetZ() - 3.*par->GetZSigma()); // PASA delay 
-         c.SetZ(sign*(par->GetZLength() - c.GetZ()));
+         c.SetY((c.GetY() - 0.5 - 0.5*npads)*fPar->GetPadPitchWidth(sec));
+         c.SetZ(fPar->GetZWidth()*(c.GetZ()-1)); 
+         c.SetZ(c.GetZ() - 3.*fPar->GetZSigma()); // PASA delay 
+         c.SetZ(sign*(fPar->GetZLength() - c.GetZ()));
 
          if (rx<230./250.*TMath::Abs(c.GetZ())) continue;
 
@@ -254,23 +237,17 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, AliLoader *of, Int
          clrow->InsertCluster(&c); ncl++;
       }
     }
-    carray.StoreRow(sec,row);
-    carray.ClearRow(sec,row);
+    cTree->Fill();
 
-    //cerr<<"sector, row, compressed digits, clusters: "
-    //<<sec<<' '<<row<<' '<<digarr.GetSize()<<' '<<ncl<<"                  \r";
+    delete clrow;
 
     nclusters+=ncl;
 
     delete[] bins;  
   }
 
-  cerr<<"Number of found clusters : "<<nclusters<<"                        \n";
-
-  of->WriteRecPoints("OVERWRITE");
-  
-  savedir->cd();
+  Info("Digits2Cluster","Number of found clusters : %d",nclusters);
 
-//  delete t;  //Thanks to Mariana Bondila
+  return 0;
 }