]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSVertexerPPZ.cxx
Adding the AliAnalysisGUI class which is the main class that controls the GUI.
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerPPZ.cxx
index 5db663b5f5f7a42b25e6dbb5e9dda2682bf756a5..63c16e7203911550b7ad393b3310ca2ed5a49752 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 #include <AliITSVertexerPPZ.h>
-#include <Riostream.h>
 #include <TArrayF.h>
-#include <TDirectory.h>
 #include <TH1F.h>
-#include <TMath.h>
 #include <TObjArray.h>
 #include <TTree.h>
 #include <TClonesArray.h>
-#include "AliRun.h"
-#include "AliITS.h"
+#include "AliITSDetTypeRec.h"
 #include "AliITSgeom.h"
 #include "AliITSLoader.h"
 #include "AliITSRecPoint.h"
@@ -40,46 +36,62 @@ ClassImp(AliITSVertexerPPZ)
 
 
 //______________________________________________________________________
-AliITSVertexerPPZ::AliITSVertexerPPZ():AliITSVertexer() {
+AliITSVertexerPPZ::AliITSVertexerPPZ():AliITSVertexer(),
+fFirstL1(0),
+fLastL1(0),
+fFirstL2(0),
+fLastL2(0),
+fDiffPhiMax(0),
+fX0(0),
+fY0(0),
+fZFound(0),
+fZsig(0),
+fWindow(0){
   // Default Constructor
 
   SetDiffPhiMax(0);
-  fX0 = 0.;
-  fY0 = 0.;
   SetFirstLayerModules(0);
   SetSecondLayerModules(0);
-  fZFound = 0;
-  fZsig = 0.;
-  fITS = 0;
+  //fITS = 0;
   SetWindow(0);
 }
 
-AliITSVertexerPPZ::AliITSVertexerPPZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn) {
+AliITSVertexerPPZ::AliITSVertexerPPZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn),
+fFirstL1(0),
+fLastL1(0),
+fFirstL2(0),
+fLastL2(0),
+fDiffPhiMax(0),
+fX0(x0),
+fY0(y0),
+fZFound(0),
+fZsig(0),
+fWindow(0) {
   // Standard constructor
   SetDiffPhiMax();
   fX0 = x0;
   fY0 = y0;
   SetFirstLayerModules();
   SetSecondLayerModules();
-  fZFound = 0;
-  fZsig = 0.;
-  fITS = 0;
+  //fITS = 0;
   SetWindow();
 }
 
 //______________________________________________________________________
 AliITSVertexerPPZ::~AliITSVertexerPPZ() {
   // Default Destructor
-  fITS = 0;
+  //fITS = 0;
 }
 
 //________________________________________________________
 void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zval) {
-  Float_t DeltaVal = hist->GetBinWidth(1)*fWindow; // max window in Z for searching
+
+  //Evaluation of Z
+  Float_t deltaVal = hist->GetBinWidth(1)*fWindow; // max window in Z for searching
   fZFound=0;
   fZsig=0;
-  Int_t N=0;
-  Int_t NbinNotZero=0;
+  Int_t nN=0;
+  Int_t nbinNotZero=0;
   Float_t totst = 0.;
   Float_t totst2 = 0.;
   Float_t curz = 0.;
@@ -88,27 +100,27 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
     if(cont!=0)curz = hist->GetBinLowEdge(i)+0.5*hist->GetBinWidth(i);
     totst+=cont;
     totst2+=cont*cont;
-    N++;
-    if(cont!=0)NbinNotZero++;
+    nN++;
+    if(cont!=0)nbinNotZero++;
   }
-  if(NbinNotZero==0){fZFound=-100; fZsig=-100; return;}
-  if(NbinNotZero==1){
+  if(nbinNotZero==0){fZFound=-100; fZsig=-100; return;}
+  if(nbinNotZero==1){
     fZFound = curz;
     fZsig=0;
-    fCurrentVertex = new AliITSVertex(fZFound,fZsig,NbinNotZero);
+    fCurrentVertex = new AliESDVertex(fZFound,fZsig,nbinNotZero);
     return;
   }
-  Float_t errsq = totst2/(N-1)-totst*totst/N/(N-1);
+  Float_t errsq = totst2/(nN-1)-totst*totst/nN/(nN-1);
   if(errsq>=0){
   totst2=TMath::Sqrt(errsq);
   }
   else {
-    Error("EvalZ","Negative variance: %d - %12.7f - %12.7f",N,totst2,totst);
+    Error("EvalZ","Negative variance: %d - %12.7f - %12.7f",nN,totst2,totst);
     fZFound=-100; 
     fZsig=-100;
     return;
   }
-  totst /= N;
+  totst /= nN;
   Float_t cut = totst+totst2*2.;
   if(fDebug>1)cout<<"totst, totst2, cut: "<<totst<<", "<<totst2<<", "<<cut<<endl;
   Float_t val1=hist->GetBinLowEdge(sepa); 
@@ -128,15 +140,15 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
     }
   }
   val2+=hist->GetBinWidth(1);
-  if((val2-val1)>DeltaVal){
-    val1 = zmax-DeltaVal/2.;
-    val2 = zmax+DeltaVal/2.;
+  if((val2-val1)>deltaVal){
+    val1 = zmax-deltaVal/2.;
+    val2 = zmax+deltaVal/2.;
     if(fDebug>0)cout<<"val1 and val2 recomputed\n";
   }
   if(fDebug>0)cout<<"Values for Z finding: "<<val1<<" "<<val2<<" "<<val2-val1<<endl;
   fZFound=0;
   fZsig=0;
-  N=0;
+  nN=0;
   for(Int_t i=0; i<ncoinc; i++){
     Float_t z=zval->At(i);
     if(z<val1)continue;
@@ -149,71 +161,72 @@ void  AliITSVertexerPPZ::EvalZ(TH1F *hist,Int_t sepa, Int_t ncoinc, TArrayF *zva
     fZFound+=z*wei;
     fZsig+=wei;
     */
-    N++;
+    nN++;
   }
-  if(N<1){fZFound=-110; fZsig=-110; return;}
-  if(N==1){
+  if(nN<1){fZFound=-110; fZsig=-110; return;}
+  if(nN==1){
     fZsig = 0;
-    fCurrentVertex = new AliITSVertex(fZFound,fZsig,N);
+    fCurrentVertex = new AliESDVertex(fZFound,fZsig,nN);
     return;
   }
-  errsq = (fZsig/(N-1)-fZFound*fZFound/N/(N-1))/N;
+  errsq = (fZsig/(nN-1)-fZFound*fZFound/nN/(nN-1))/nN;
   if(errsq>=0.){
     fZsig=TMath::Sqrt(errsq);
   }
   else {
-    Error("evalZ","Negative variance: %d - %12.7f %12.7f",N,fZsig,fZFound);
+    Error("evalZ","Negative variance: %d - %12.7f %12.7f",nN,fZsig,fZFound);
     fZsig=0;
   }
-  fZFound=fZFound/N;
+  fZFound=fZFound/nN;
   /* weights defined by the curvature
   fZsig=1./fZsig;
   fZFound*=fZsig;
   fZsig = TMath::Sqrt(fZsig);
   */
-  fCurrentVertex = new AliITSVertex(fZFound,fZsig,N);
+  fCurrentVertex = new AliESDVertex(fZFound,fZsig,nN);
 }
 
 //______________________________________________________________________
-AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
-  // Defines the AliITSVertex for the current event
+AliESDVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
+  // Defines the AliESDVertex for the current event
   fCurrentVertex = 0;
   fZFound = -999;
   fZsig = -999;
   AliRunLoader *rl =AliRunLoader::GetRunLoader();
-  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
-  if(!fITS)  {
-    fITS = (AliITS*)gAlice->GetModule("ITS");
-    if(!fITS) {
-      Error("FindVertexForCurrentEvent","AliITS object was not found");
-      return fCurrentVertex;
-    }
-  }
-  fITS->SetTreeAddress();
-  AliITSgeom *geom = fITS->GetITSgeom();
+  AliITSLoader* iTSloader = (AliITSLoader*)rl->GetLoader("ITSLoader");
+  TDirectory * olddir = gDirectory;
+  rl->CdGAFile();
+  AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+  olddir->cd(); 
+
+  AliITSDetTypeRec detTypeRec;
+
   if(!geom) {
     Error("FindVertexForCurrentEvent","ITS geometry is not defined");
     return fCurrentVertex;
   }
-  TTree *TR=0;
-  TClonesArray *ITSrec  = 0;
+  TTree *tR=0;
+  TClonesArray *itsRec  = 0;
   Float_t lc[3]; for(Int_t ii=0; ii<3; ii++) lc[ii]=0.;
   Float_t gc[3]; for(Int_t ii=0; ii<3; ii++) gc[ii]=0.;
   Float_t lc2[3]; for(Int_t ii=0; ii<3; ii++) lc2[ii]=0.;
   Float_t gc2[3]; for(Int_t ii=0; ii<3; ii++) gc2[ii]=0.;
 
-  TR = ITSloader->TreeR();
-  if(!TR){
+  tR = iTSloader->TreeR();
+  if(!tR){
     Error("FindVertexForCurrentEvent","TreeR not found");
     return fCurrentVertex;
   }
-  ITSrec  = fITS->RecPoints();  // uses slow points or fast points if slow are
+  detTypeRec.SetTreeAddressR(tR);
+  itsRec = detTypeRec.RecPoints();
   // missing
-  TBranch *branch = TR->GetBranch("ITSRecPoints");
+  // TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
+  TBranch *branch;
+  branch = tR->GetBranch("ITSRecPoints");
   if(!branch){ 
-    branch = TR->GetBranch("ITSRecPointsF");
-    //   Warning("FindVertexForCurrentEvent","Using Fast points");
+    branch = tR->GetBranch("ITSRecPointsF");
   }
+  //}
   if(!branch){
    Error("FindVertexForCurrentEvent","branch for ITS rec points not found");
    return fCurrentVertex;
@@ -224,17 +237,17 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
   Int_t firipixe=0;
   for(Int_t module= fFirstL1; module<=fLastL1;module++){
     branch->GetEvent(module);
-    Int_t nrecp1 = ITSrec->GetEntries();
+    Int_t nrecp1 = itsRec->GetEntries();
     for(Int_t i=0; i<nrecp1;i++){
-      AliITSRecPoint *current = (AliITSRecPoint*)ITSrec->At(i);
-      lc[0]=current->GetX();
-      lc[2]=current->GetZ();
+      AliITSRecPoint *current = (AliITSRecPoint*)itsRec->At(i);
+      lc[0]=current->GetDetLocalX();
+      lc[2]=current->GetDetLocalZ();
       geom->LtoG(module,lc,gc);
       zave+=gc[2];
       zave2+=gc[2]*gc[2];
       firipixe++;
     }
-    fITS->ResetRecPoints();
+    detTypeRec.ResetRecPoints();
   }
   if(firipixe>1){
     rmszav=TMath::Sqrt(zave2/(firipixe-1)-zave*zave/firipixe/(firipixe-1));
@@ -263,14 +276,14 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
   for(Int_t module= fFirstL1; module<=fLastL1;module++){
     if(fDebug>0)cout<<"processing module   "<<module<<"                  \r";
     branch->GetEvent(module);
-    Int_t nrecp1 = ITSrec->GetEntries();
+    Int_t nrecp1 = itsRec->GetEntries();
     TObjArray *poiL1 = new TObjArray(nrecp1);
-    for(Int_t i=0; i<nrecp1;i++)poiL1->AddAt(ITSrec->At(i),i);
-    fITS->ResetRecPoints();
+    for(Int_t i=0; i<nrecp1;i++)poiL1->AddAt(itsRec->At(i),i);
+    detTypeRec.ResetRecPoints();
     for(Int_t i=0; i<nrecp1;i++){
       AliITSRecPoint *current = (AliITSRecPoint*)poiL1->At(i);
-      lc[0]=current->GetX();
-      lc[2]=current->GetZ();
+      lc[0]=current->GetDetLocalX();
+      lc[2]=current->GetDetLocalZ();
       geom->LtoG(module,lc,gc);
       gc[0]-=fX0;
       gc[1]-=fY0;
@@ -280,11 +293,11 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
       if(fDebug>1)cout<<"module "<<module<<" "<<gc[0]<<" "<<gc[1]<<" "<<gc[2]<<" "<<phi1<<"     \n";
       for(Int_t modul2=fFirstL2; modul2<=fLastL2; modul2++){
        branch->GetEvent(modul2);
-       Int_t nrecp2 = ITSrec->GetEntries();
+       Int_t nrecp2 = itsRec->GetEntries();
        for(Int_t j=0; j<nrecp2;j++){
-         AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(j);
-         lc2[0]=recp->GetX();
-         lc2[2]=recp->GetZ();
+         AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j);
+         lc2[0]=recp->GetDetLocalX();
+         lc2[2]=recp->GetDetLocalZ();
          geom->LtoG(modul2,lc2,gc2);
          gc2[0]-=fX0;
          gc2[1]-=fY0;
@@ -312,7 +325,7 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
            }
          }
        }
-       fITS->ResetRecPoints();
+       detTypeRec.ResetRecPoints();
       }
     }
     delete poiL1;
@@ -331,6 +344,7 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
     //    fCurrentVertex->SetName(name);
     fCurrentVertex->SetTitle("vertexer: PPZ");
   }
+
   return fCurrentVertex;
 }
 
@@ -338,8 +352,8 @@ AliITSVertex* AliITSVertexerPPZ::FindVertexForCurrentEvent(Int_t evnumber){
 void AliITSVertexerPPZ::FindVertices(){
   // computes the vertices of the events in the range FirstEvent - LastEvent
   AliRunLoader *rl = AliRunLoader::GetRunLoader();
-  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
-  ITSloader->ReloadRecPoints();
+  AliITSLoader* iTSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
+  iTSloader->ReloadRecPoints();
   for(Int_t i=fFirstEvent;i<=fLastEvent;i++){
     cout<<"Processing event "<<i<<endl;
     rl->GetEvent(i);