]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCclusterer.cxx
Set finite validity (one run) to TPC/Calib/AltroConfig OCDB entries
[u/mrichter/AliRoot.git] / TPC / AliTPCclusterer.cxx
index e7a0be29a2a1f8f1faf8bb08d2470466c6081529..f9849ebe3c337167299db15c1a61bde1bb502e3a 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.7  2001/10/21 19:04:55  hristov
-Several patches were done to adapt the barel reconstruction to the multi-event case. Some memory leaks were corrected. (Yu.Belikov)
-
-Revision 1.6  2001/08/30 09:28:48  hristov
-TTree names are explicitly set via SetName(name) and then Write() is called
-
-Revision 1.5  2001/07/20 14:32:44  kowal2
-Processing of many events possible now
-
-Revision 1.4  2001/04/17 08:06:27  hristov
-Possibility to define the magnetic field in the reconstruction (Yu.Belikov)
-
-Revision 1.3  2000/10/05 16:14:01  kowal2
-Forward declarations.
-
-Revision 1.2  2000/06/30 12:07:50  kowal2
-Updated from the TPC-PreRelease branch
-
-Revision 1.1.2.1  2000/06/25 08:53:55  kowal2
-Splitted from AliTPCtracking
-
-*/
+/* $Id$ */
 
 //-------------------------------------------------------
 //          Implementation of the TPC clusterer
@@ -48,14 +25,35 @@ Splitted from AliTPCtracking
 #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 <iostream.h>
+#include "AliTPCClustersRow.h"
 #include <TTree.h>
 
+ClassImp(AliTPCclusterer)
+
+
+//____________________________________________________
+AliTPCclusterer::AliTPCclusterer(const AliTPCclusterer &param)
+                :TObject(),
+                 fPar(0)
+{
+  //
+  // dummy
+  //
+  fPar = param.fPar;
+}
+//-----------------------------------------------------
+AliTPCclusterer & AliTPCclusterer::operator =(const AliTPCclusterer & param)
+{
+  //
+  // assignment operator - dummy
+  //
+    fPar = param.fPar;
+  return (*this);
+}
+//____________________________________________________
 void AliTPCclusterer::FindPeaks(Int_t k,Int_t max,
 AliBin *b,Int_t *idx,UInt_t *msk,Int_t& n) {
   //find local maxima
@@ -108,71 +106,54 @@ AliTPCcluster &c) {
 }
 
 //_____________________________________________________________________________
-void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, TFile *of, Int_t eventn)
-{
+Int_t AliTPCclusterer::Digits2Clusters(TTree *dTree, TTree *cTree) {
   //-----------------------------------------------------------------
   // This is a simple cluster finder.
   //-----------------------------------------------------------------
-  TDirectory *savedir=gDirectory; 
-
-  if (!of->IsOpen()) {
-     cerr<<"AliTPC::Digits2Clusters(): output file not open !\n";
-     return;
-  }
-
-  const Int_t kMAXZ=par->GetMaxTBin()+2;
-
-  char  dname[100];
-  char   cname[100];
-  if (eventn==-1) {
-
-    // for backward compatibility
-    
-    sprintf(dname,"TreeD_75x40_100x60_150x60");
-    sprintf(cname,"TreeC_TPC");
-  }
-  else {
-    sprintf(dname,"TreeD_75x40_100x60_150x60_%d",eventn);
-    sprintf(cname,"TreeC_TPC_%d",eventn);
+  TBranch *branch=dTree->GetBranch("Segment");
+  if (!branch) {
+     Error("Digits2Cluster","Can't get the branch !");
+     return 1;
   }
-  TTree *t = (TTree *)gDirectory->Get(dname);
-
   AliSimDigits digarr, *dummy=&digarr;
-  t->GetBranch("Segment")->SetAddress(&dummy);
-  Stat_t nentries = t->GetEntries();
-
-  of->cd();
-
-  ((AliTPCParam*)par)->Write(par->GetTitle());
-  AliTPCClustersArray carray;
-  carray.Setup(par);
-  carray.SetClusterType("AliTPCcluster");
-  carray.MakeTree();
-
+  branch->SetAddress(&dummy);
+  
+  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;
 
+  Int_t nentries = (Int_t)dTree->GetEntries();
   for (Int_t n=0; n<nentries; n++) {
-    t->GetEvent(n);
+   
     Int_t sec, row;
-    if (!par->AdjustSectorRow(digarr.GetID(),sec,row)) {
-       cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
+    dTree->GetEvent(n);
+
+    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();
 
-    Float_t rx=par->GetPadRowRadii(sec,row);
+    clrow->SetClass("AliTPCcluster"); clrow->SetArray(1);
+    clrow->SetID(digarr.GetID());
+
+    cTree->GetBranch("Segment")->SetAddress(&clrow);
+
+    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;
        }
     }
@@ -186,7 +167,7 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, TFile *of, Int_t e
     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);
@@ -234,25 +215,25 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, TFile *of, Int_t e
          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(sec) - c.GetZ()));
 
          if (rx<230./250.*TMath::Abs(c.GetZ())) continue;
 
@@ -270,23 +251,17 @@ void AliTPCclusterer::Digits2Clusters(const AliTPCParam *par, TFile *of, Int_t e
          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";
-
-  carray.GetTree()->SetName(cname);
-  carray.GetTree()->Write();
-  savedir->cd();
+  Info("Digits2Cluster","Number of found clusters : %d",nclusters);
 
-  delete t;  //Thanks to Mariana Bondila
+  return 0;
 }