]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMapA2.cxx
bug fixed
[u/mrichter/AliRoot.git] / ITS / AliITSMapA2.cxx
index 9aa03fbf765836f8d04e74767ad20f98faca0f78..e65b6a3b4e937d2de5b512e634ffb5b270cd1dd8 100644 (file)
 
 #include <TH1.h>
 #include <TObjArray.h>
-#include <TMath.h>
 
 #include "AliITSMapA2.h"
 #include "AliITSsegmentation.h"
-#include "AliITSresponse.h"
 #include "AliITSdigit.h"
 
+////////////////////////////////////////////////////////////////////////
+//  Map Class for ITS. Implementation A2. In this implementation, the //
+// 2 dimensional (iz,ix) map is filled with Double precision floating //
+// point values. Since this class is derived for AliITSMapA1 it also  //
+// has all of the functionality of that class as well. For each       //
+// cell a corresponding TObject, a hit, can also be stored.           //
+//  The detector geometry is accessed via the that detectors          //
+// segmentation class and stored here for conveniance.                //
+////////////////////////////////////////////////////////////////////////
 
 ClassImp(AliITSMapA2)
 
-AliITSMapA2::AliITSMapA2()
-{
-  // default constructor
-  fSegmentation = 0;
-  fNpz=0;
-  fNpx=0;
-  fMaxIndex=0;         
-  
-  fHitMapD = 0;
-  fObjects = 0;
-  fNobjects = 0;
-  fMapThresholdD=0.;
-}
-
-  AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg)
-{
-  //constructor
-  fScaleSizeZ=1;
-  fScaleSizeX=1;
-  fSegmentation = seg;
-  fNpz=fSegmentation->Npz();
-  fNpx=fSegmentation->Npx();
-  fMaxIndex=fNpz*fNpx+fNpx;             // 2 halves of detector
-  
-  fHitMapD = new Double_t[fMaxIndex];
-  fMapThresholdD=0.;
-  fObjects = 0;
-  fNobjects = 0;
-  ClearMap();
-}
-//--------------------------------------
-  AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, Int_t scalesizeX, Int_t scalesizeZ)
-{
-  //constructor
-  fSegmentation = seg;
-  fScaleSizeX=scalesizeX;
-  fScaleSizeZ=scalesizeZ;
-  fNpz=fScaleSizeZ*fSegmentation->Npz();
-  fNpx=fScaleSizeX*fSegmentation->Npx();
-  fMaxIndex=fNpz*fNpx+fNpx;             // 2 halves of detector
-  
-  fHitMapD = new Double_t[fMaxIndex];
-  fMapThresholdD=0.;
-  fObjects = 0;
-  fNobjects = 0;
-  ClearMap();
-}
-
-//--------------------------------------
-AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, Double_t thresh)
-{
-  //constructor
-  fNobjects = 0;
-  fScaleSizeZ=1;
-  fScaleSizeX=1;
-  fSegmentation = seg;
-  fNpz=fSegmentation->Npz();
-  fNpx=fSegmentation->Npx();
-  fMaxIndex=fNpz*fNpx+fNpx;             // 2 halves of detector
-  
-  fHitMapD = new Double_t[fMaxIndex];
-  fObjects =  obj;
-  if (fObjects) fNobjects = fObjects->GetEntriesFast();
-  fMapThresholdD = thresh;
-  ClearMap();
-}
-//--------------------------------------
-
-
-AliITSMapA2::~AliITSMapA2()
-{
-  //destructor
-  if (fHitMapD) delete[] fHitMapD;
-}
-//--------------------------------------
+//______________________________________________________________________
+AliITSMapA2::AliITSMapA2():
+fHitMapD(0),
+fMapThresholdD(0),
+fScaleSizeX(0),
+fScaleSizeZ(0){
+    // default constructor
+
+    fSegmentation  = 0;
+    fNpz           = 0;
+    fNpx           = 0;
+    fMaxIndex      = 0;
+    fObjects       = 0;
+    fNobjects      = 0;
+}
+//______________________________________________________________________
+AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg):
+fHitMapD(0),
+fMapThresholdD(0),
+fScaleSizeX(1),
+fScaleSizeZ(1){
+    //constructor
+
+    fSegmentation  = seg;
+    fNpz           = fSegmentation->Npz();
+    fNpx           = fSegmentation->Npx();
+    fMaxIndex      = fNpz*fNpx+fNpx;       // 2 halves of detector
+    fHitMapD       = new Double_t[fMaxIndex+1];
+    fObjects       = 0;
+    fNobjects      = 0;
+    ClearMap();
+}
+//______________________________________________________________________
+AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
+                        Int_t scalesizeX, Int_t scalesizeZ):
+fHitMapD(0),
+fMapThresholdD(0),
+fScaleSizeX(scalesizeX),
+fScaleSizeZ(scalesizeZ){
+    //constructor
+
+    fSegmentation  = seg;
+    fNpz           = fScaleSizeZ*fSegmentation->Npz();
+    fNpx           = fScaleSizeX*fSegmentation->Npx();
+    fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector
+    fHitMapD       = new Double_t[fMaxIndex+1];
+    fObjects       = 0;
+    fNobjects      = 0;
+    ClearMap();
+}
+//______________________________________________________________________
+AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, 
+                        Double_t thresh):
+fHitMapD(0),
+fMapThresholdD(thresh),
+fScaleSizeX(1),
+fScaleSizeZ(1){
+    //constructor
+
+    fNobjects      = 0;
+    fSegmentation  = seg;
+    fNpz           = fSegmentation->Npz();
+    fNpx           = fSegmentation->Npx();
+    fMaxIndex      = fNpz*fNpx+fNpx;             // 2 halves of detector  
+    fHitMapD       = new Double_t[fMaxIndex+1];
+    fObjects       =  obj;
+    if (fObjects) fNobjects = fObjects->GetEntriesFast();
+    ClearMap();
+}
+//______________________________________________________________________
+AliITSMapA2::~AliITSMapA2(){
+    //destructor
+
+    if (fHitMapD) delete[] fHitMapD;
+}
+//______________________________________________________________________
+AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source) : AliITSMapA1(source),
+fHitMapD(source.fHitMapD),
+fMapThresholdD(source.fMapThresholdD),
+fScaleSizeX(source.fScaleSizeX),
+fScaleSizeZ(source.fScaleSizeZ){
+    //     Copy Constructor 
+
+}
+//______________________________________________________________________
+AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) {
+    //    Assignment operator
+  this->~AliITSMapA2();
+  new(this) AliITSMapA2(source);
+  return *this;
 
-//__________________________________________________________________________
-AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
-  //     Copy Constructor 
-  if(&source == this) return;
-  this->fMapThresholdD = source.fMapThresholdD;
-  this->fScaleSizeX = source.fScaleSizeX;
-  this->fScaleSizeZ = source.fScaleSizeZ;
-  this->fHitMapD = source.fHitMapD;
-  return;
 }
 
-//_________________________________________________________________________
-AliITSMapA2& 
-  AliITSMapA2::operator=(const AliITSMapA2 &source) {
-  //    Assignment operator
-  if(&source == this) return *this;
-  this->fMapThresholdD = source.fMapThresholdD;
-  this->fScaleSizeX = source.fScaleSizeX;
-  this->fScaleSizeZ = source.fScaleSizeZ;
-  this->fHitMapD = source.fHitMapD;
-  return *this;
-}
+//______________________________________________________________________
+void AliITSMapA2::ClearMap(){
+    //clear array
 
-//_________________________________________________________________________
-void AliITSMapA2::ClearMap()
-{
-  //clear array
-  memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
+    memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
 }
-
-//--------------------------------------
-void  AliITSMapA2::FillMap()
-{
-  
-  // fills signal map from digits - apply a threshold for signal
-  
-  if (!fObjects) return; 
+//______________________________________________________________________
+void  AliITSMapA2::FillMap(){
+    // fills signal map from digits - apply a threshold for signal
   
-  Int_t ndigits = fObjects->GetEntriesFast();
-  if (!ndigits) return;
-  
-  AliITSdigit *dig;
-  for (Int_t ndig=0; ndig<ndigits; ndig++) {
-    dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
-    Double_t signal = (Double_t)(dig->fSignal);
-    if (signal > fMapThresholdD) SetHit(dig->fCoord1,dig->fCoord2,signal);
-  }
-}
+    if (!fObjects) return;
 
-//--------------------------------------
-void  AliITSMapA2::SetHit(Int_t iz, Int_t ix, Double_t signal)
-{
-  // set signal at a certain position in array
-  fHitMapD[CheckedIndex(iz, ix)]=signal;
-  
-}
+    Int_t ndigits = fObjects->GetEntriesFast();
+    if (!ndigits) return;
 
-//--------------------------------------
-void AliITSMapA2::DeleteHit(Int_t iz, Int_t ix)
-{
-  //set the entry value to zero
-  fHitMapD[CheckedIndex(iz, ix)]=0;
+    AliITSdigit *dig;
+    for (Int_t ndig=0; ndig<ndigits; ndig++) {
+       dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
+       Double_t signal = (Double_t)(dig->GetSignal());
+       if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
+    } // end for ndig
 }
-
-//--------------------------------------
-void AliITSMapA2::FlagHit(Int_t iz, Int_t ix)
-{
+//______________________________________________________________________
+void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
   //flag an entry
-  fHitMapD[CheckedIndex(iz, ix)]=
-    -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
-  
-}
 
-//--------------------------------------
-Int_t AliITSMapA2::GetHitIndex(Int_t iz, Int_t ix)
-{
-  //return the index of an entry in array 
-  return CheckedIndex(iz, ix);
+    fHitMapD[CheckedIndex(iz, ix)]=
+                -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
 }
-
-//--------------------------------------
-TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy)
-{
-  
+//______________________________________________________________________
+TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy) const {
   //return a pointer to the 1D histogram
-  if (fObjects) {
-    
-    return fObjects->UncheckedAt(i); 
-    
-  } else return NULL;
-  
-}
 
-//--------------------------------------
-Double_t AliITSMapA2::GetSignal(Int_t iz, Int_t ix)
-{
-  //get signal in a cell 
-  Int_t index=GetHitIndex(iz,ix);
-  return (index <0) ? 0. : fHitMapD[CheckedIndex(iz, ix)];
+    dummy = 0; // added to remove unused variable warning.
+    if (fObjects) {
+       return fObjects->UncheckedAt(i);
+    } else return NULL;
 }
+//______________________________________________________________________
+Double_t AliITSMapA2::GetSignal(Int_t index) const {
+    //get signal in a cell 
 
-//--------------------------------------
-Double_t AliITSMapA2::GetSignal(Int_t index)
-{
-  //get signal in a cell 
-  if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
-  else return 0.;
+    if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
+    else return 0.;
 }
-//--------------------------------------
-FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix)
-{
-  // check if the entry has already been flagged
+//______________________________________________________________________
+FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
+    // check if the entry has already been flagged
 
     if (CheckedIndex(iz, ix) < 0) return kEmpty;
     Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
     
     if (inf <= -1000) {
-      return kUsed;
+       return kUsed;
     } else if (inf == 0) {
-      return kEmpty;
+       return kEmpty;
     } else {
-      return kUnused;
-    }
+       return kUnused;
+    } // end if inf...
 }
+//______________________________________________________________________
+void  AliITSMapA2::FillMapFromHist(){
+    // fills map from 1D histograms
 
-//--------------------------------------
-void  AliITSMapA2::FillMapFromHist()
-{
-  
-  // fills map from 1D histograms
-  
-  if (!fObjects) return; 
-  
-  // an example
-  for( Int_t i=0; i<fNobjects; i++) {
-    TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
-    Int_t nsamples = hist->GetNbinsX();
-    for( Int_t j=0; j<nsamples; j++) {
-      Double_t signal = (Double_t)(hist->GetBinContent(j+1));
-      if (signal > fMapThresholdD) SetHit(i,j,signal);
-    }
-  }
-  
+    if (!fObjects) return;
+
+    // an example
+    for( Int_t i=0; i<fNobjects; i++) {
+       TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
+       Int_t nsamples = hist->GetNbinsX();
+       for( Int_t j=0; j<nsamples; j++) {
+           Double_t signal = (Double_t)(hist->GetBinContent(j+1));
+           if (signal > fMapThresholdD) SetHit(i,j,signal);
+       } // end for j
+    } // end for i
 }
-//--------------------------------------
-void  AliITSMapA2::FillHist()
-{
-  
-  // fill 1D histograms from map
-  if (!fObjects || fScaleSizeX != 1) return; 
-  
-  // an example
-  for( Int_t i=0; i<fNobjects; i++) {
-    TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
-    for( Int_t j=0; j<fNpx; j++) {
-      Double_t signal=GetSignal(i,j);
-      if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
-    }
-  }
-  
+//______________________________________________________________________
+void  AliITSMapA2::FillHist(){
+    // fill 1D histograms from map
+
+    if (!fObjects || fScaleSizeX != 1) return;
+
+    // an example
+    for( Int_t i=0; i<fNobjects; i++) {
+       TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
+       for( Int_t j=0; j<fNpx; j++) {
+           Double_t signal=GetSignal(i,j);
+           if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
+       } // end for j
+    } // end for i
 }
-//--------------------------------------
-void  AliITSMapA2::ResetHist()
-{
-  //
-  // Reset histograms 
-  //
-  
-  if (!fObjects) return; 
-  
-  for( Int_t i=0; i<fNobjects; i++) {
-    if ((*fObjects)[i])    ((TH1F*)(*fObjects)[i])->Reset();
-  }
-  
+//______________________________________________________________________
+void  AliITSMapA2::ResetHist(){
+    // Reset histograms
+
+    if (!fObjects) return;
+
+    for( Int_t i=0; i<fNobjects; i++) {
+       if ((*fObjects)[i])    ((TH1F*)(*fObjects)[i])->Reset();
+    } // end for i
 }
+//______________________________________________________________________
+void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
+    // Addes sig to cell iz. equivalent to the very common
+    // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
+
 
+    Int_t index=GetHitIndex(iz,ix);
+    if(index<0) return;
+    fHitMapD[CheckedIndex(iz, ix)] += sig;    
+}