]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
TCLonesArray of AliITSpListItem objects replaced with an array of AliITSpListItem
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 May 2008 16:07:36 +0000 (16:07 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 May 2008 16:07:36 +0000 (16:07 +0000)
ITS/AliITSpList.cxx
ITS/AliITSpList.h
ITS/AliITSpListItem.cxx
ITS/AliITSpListItem.h

index 837552a5a1d55c5ea39b5c5165a60dfd772025d0..024683a6cb6a4077c1f1ba7ea60d859263a043f2 100644 (file)
@@ -50,7 +50,7 @@ fEntries(0){
 AliITSpList::AliITSpList(Int_t imax,Int_t jmax):
 fNi(imax),
 fNj(jmax),
-fa(0),
+fa(new AliITSpListItem[imax*jmax]),
 fEntries(0){
     // Standard constructor
     // Inputs:
@@ -60,27 +60,15 @@ fEntries(0){
     // Return:
     //    A setup AliITSpList class.
 
-    fa = new TClonesArray("AliITSpListItem",fNi*fNj);
 }
 //______________________________________________________________________
 AliITSpList::~AliITSpList(){
     // Default destructor
-    // Inputs:
-    //    none.
-    // Outputs:
-    //    none.
-    // Return:
-    //    a properly destroyed class
 
-  if(fa){
-    fa->Delete();
-    delete fa;
-    fa = 0;
-  }
-    fNi = 0;
-    fNj = 0;
-
-    fEntries = 0;
+  delete [] fa;
+  fNi = 0;
+  fNj = 0;
+  fEntries = 0;
 }
 
 //______________________________________________________________________
@@ -92,9 +80,8 @@ void AliITSpList::ClearMap(){
     //    none.
     // Return:
     //    A zeroed AliITSpList class.
-
-    fa->Delete();
-    fEntries = 0;
+  for(Int_t i=0; i<fEntries; i++)(fa[i]).MarkUnused();
+  fEntries = 0;
 }
 //______________________________________________________________________
 void AliITSpList::DeleteHit(Int_t i,Int_t j){
@@ -107,10 +94,7 @@ void AliITSpList::DeleteHit(Int_t i,Int_t j){
     // Return:
     //    none.
     Int_t k = GetIndex(i,j);
-
-    if(fa->At(k)!=0){
-      fa->RemoveAt(k);
-    } // end for i && if
+    if((fa[k]).IsUsed())(fa[k]).MarkUnused();
     if(k==fEntries-1) fEntries--;
 }
 //______________________________________________________________________
@@ -129,10 +113,12 @@ AliITSpList& AliITSpList::operator=(const AliITSpList &source){
 }
 //______________________________________________________________________
 AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source),
-fNi(source.fNi),fNj(source.fNj),fa(0),fEntries(source.fEntries){
+fNi(source.fNi),
+fNj(source.fNj),
+fa(new AliITSpListItem[fNi*fNj]),
+fEntries(source.fEntries){
     // Copy constructor
-
-  fa = new TClonesArray(*(source.fa));
+  for(Int_t i=0; i<fEntries; i++)(fa[i]).Build(source.fa[i]);
 }
 //______________________________________________________________________
 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
@@ -147,12 +133,9 @@ void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
     // Return:
     //    none.
     Int_t index = pl->GetIndex();
-    TClonesArray &rfa = *fa;
-    if( fa->At( index ) == 0 ) { // most create AliITSpListItem
-      new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0);
-    } // end if
-    ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
+    AliITSpListItem &lit = fa[index];
+    if(!lit.IsUsed())lit.Build(-2,-1,pl->GetModule(),index,0.);
+    lit.AddTo(fileIndex,pl);
     if(index>=fEntries) fEntries = index +1;
 }
 //______________________________________________________________________
@@ -174,12 +157,13 @@ void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
     //    none.
     Int_t index = GetIndex(i,j);
     if (index<0) return;
-    TClonesArray &rfa = *fa;
-    if(GetpListItem(index)==0){ // must create AliITSpListItem
-      new(rfa[index])AliITSpListItem(trk,ht,mod,index,signal);
-    }else{ // AliITSpListItem exists, just add signal to it.
-        GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
-    } // end if
+    AliITSpListItem &lit = fa[index];
+    if(!lit.IsUsed()){
+      lit.Build(trk,ht,mod,index,signal);
+    }
+    else {
+      lit.AddSignal(trk,ht,mod,index,signal);
+    }
     if(index>=fEntries) fEntries = index +1;
 }
 //______________________________________________________________________
@@ -196,12 +180,14 @@ void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
     // Return:
     //    none.
     Int_t index = GetIndex(i,j);
-    TClonesArray &rfa = *fa;
-    if(GetpListItem(index)==0){ // most create AliITSpListItem
-      new(rfa[index]) AliITSpListItem(mod,index,noise);
-    }else{ // AliITSpListItem exists, just add signal to it.
-        GetpListItem(index)->AddNoise(mod,index,noise);
-    } // end if
+    if (index<0) return;
+    AliITSpListItem &lit = fa[index];
+    if(!lit.IsUsed()){
+      lit.Build(mod,index,noise);
+    }
+    else {
+      lit.AddNoise(mod,index,noise);
+    } 
     if(index>=fEntries) fEntries = index +1;
 }
 //______________________________________________________________________
index f0846677dba81a613a9ad24162e3520673168816..37be74a34d153cd38786e21e06292dbd19b8aeb8 100644 (file)
@@ -107,16 +107,14 @@ class AliITSpList: public AliITSMap {
     // tests hit status.
     virtual FlagType TestHit(Int_t i,Int_t j){if(GetpListItem(i,j)==0) return kEmpty;
     else if(GetSignal(i,j)<=0) return kUnused; else return kUsed;}
-    // Returns the pointer to the TClonesArray of pList Items
-    TClonesArray * GetpListItems(){return fa;}
     // returns the pList Item stored in the TClonesArray
-    AliITSpListItem* GetpListItem(Int_t index){
-       if(fa!=0)return (AliITSpListItem*) (fa->At(index));
-       else return 0;}
+    AliITSpListItem* GetpListItem(Int_t index) { if((fa[index]).IsUsed())
+      return &(fa[index]);
+      else return NULL;}
     // returns the pList Item stored in the TObject array
     AliITSpListItem* GetpListItem(Int_t i,Int_t j) const {
-       if(fa!=0)return (AliITSpListItem*) (fa->At(GetIndex(i,j)));
-       else return 0;}
+      if((fa[GetIndex(i,j)]).IsUsed())return &(fa[GetIndex(i,j)]);
+      else return NULL; }
 
     // Fill pList from digits. Not functional yet
     virtual void FillMap(){NotImplemented("FillMap");}
@@ -138,9 +136,9 @@ class AliITSpList: public AliITSMap {
          Warning(method,"This method is not implemented for this class");}
 // data members
     Int_t     fNi,fNj;   // The max index in i,j.
-    TClonesArray *fa;       // array of pList items
+    AliITSpListItem *fa;       // array of pList items
     Int_t     fEntries; // keepts track of the number of non-zero entries.
 
-    ClassDef(AliITSpList,4) // list of signals and track numbers
+    ClassDef(AliITSpList,5) // list of signals and track numbers
 };     
 #endif
index b5222acbb0f76df211eefac74ad1c71cf57b6a7f..362fb1432666151f9e632647ca7b21de93a2d2d1 100644 (file)
@@ -31,7 +31,8 @@ fmodule(-1),
 findex(-1),
 fTsignal(0.0),
 fNoise(0.0),
-fSignalAfterElect(0.0){
+fSignalAfterElect(0.0),
+fUsed(kFALSE){
     // Default constructor
     // Inputs:
     //    none.
@@ -52,7 +53,8 @@ fmodule(module),
 findex(index),
 fTsignal(0.0),
 fNoise(noise),
-fSignalAfterElect(0.0){
+fSignalAfterElect(0.0),
+fUsed(kTRUE){
     // Standard noise constructor
     // Inputs:
     //    Int_t module   The module where this noise occurred
@@ -76,7 +78,8 @@ fmodule(module),
 findex(index),
 fTsignal(signal),
 fNoise(0.0),
-fSignalAfterElect(0.0){
+fSignalAfterElect(0.0),
+fUsed(kTRUE){
     // Standard signal constructor
     // Inputs:
     //    Int_t track     The track number which produced this signal
@@ -98,6 +101,61 @@ fSignalAfterElect(0.0){
         this->fHits[i]   = -1;
     } // end if i
 }
+
+//______________________________________________________________________
+void AliITSpListItem::Build(Int_t module,Int_t index,Double_t noise){
+  // this method resets all the data members and initializes the
+  // object as in the constructor which has the same arguments
+  fmodule = module;
+  findex = index;
+  fTsignal = 0.;
+  fNoise = noise;
+  fSignalAfterElect = 0.;
+  fUsed = kTRUE;
+  for(Int_t i=0;i<this->fgksize;i++){
+    this->fTrack[i]  = -2;
+    this->fSignal[i] = 0.0;
+    this->fHits[i]   = -1;
+  } 
+}
+
+//______________________________________________________________________
+void AliITSpListItem::Build(Int_t track,Int_t hit,Int_t module,Int_t index,Double_t signal){
+  // this method resets all the data members and initializes the
+  // object as in the constructor which has the same arguments
+  fmodule = module;
+  findex = index;
+  fTsignal = signal;
+  fNoise = 0.;
+  fSignalAfterElect = 0.;
+  fUsed = kTRUE;
+  this->fTrack[0]  = track;
+  this->fHits[0]   = hit;
+  this->fSignal[0] = signal;
+  for(Int_t i=1;i<this->fgksize;i++){
+    this->fTrack[i]  = -2;
+    this->fSignal[i] = 0.0;
+    this->fHits[i]   = -1;
+  } 
+}
+
+//______________________________________________________________________
+void AliITSpListItem::Build(const AliITSpListItem &source){
+  // this method resets all the data members and initializes the
+  // object as in the constructor which has the same arguments
+  fmodule = source.fmodule;
+  findex = source.findex;
+  fTsignal = source.fTsignal;
+  fNoise = source.fNoise;
+  fSignalAfterElect = source.fSignalAfterElect;
+  fUsed = source.fUsed;
+  for(Int_t i=0;i<this->fgksize;i++){
+    this->fTrack[i]  = source.fTrack[i];
+    this->fSignal[i] = source.fSignal[i];
+    this->fHits[i]   = source.fHits[i];
+  }
+}
+
 //______________________________________________________________________
 AliITSpListItem::~AliITSpListItem(){
     // Destructor
@@ -130,7 +188,8 @@ fmodule(source.fmodule),
 findex(source.findex),
 fTsignal(source.fTsignal),
 fNoise(source.fNoise),
-fSignalAfterElect(source.fSignalAfterElect){
+fSignalAfterElect(source.fSignalAfterElect),
+fUsed(source.fUsed){
     // Copy operator
     // Inputs:
     //    AliITSpListItem &source   A AliITSpListItem Object
index 616837f5f94507c94ccc08f99c205fbde3517485..8217fb1fd9d45fdc994c264e26e7ad64c0a6d9e9 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef ALIITSPLISTITEM_H
 #define ALIITSPLISTITEM_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice     */
 
 /* $Id$ */
@@ -21,8 +21,12 @@ class AliITSpListItem: public TObject {
     virtual ~AliITSpListItem();
     // Copy Oporator
     AliITSpListItem(const AliITSpListItem &source);
-    // = Opoerator
+    // = Operator
     virtual AliITSpListItem& operator=(const AliITSpListItem &source);
+    // Building methods: they set completely the status of the object
+    void Build(Int_t module,Int_t index,Double_t noise);
+    void Build(Int_t track,Int_t hit,Int_t module,Int_t index,Double_t signal);
+    void Build(const AliITSpListItem &source);
     // Returns the signal value in the list of signals
     virtual Double_t GetSignal(Int_t i) const {
                            return ( (i>=0&&i<fgksize) ? fSignal[i] : 0.0);}
@@ -68,7 +72,10 @@ class AliITSpListItem: public TObject {
     void Read(istream *is);
     virtual void Print(Option_t *option="") const {TObject::Print(option);}
     virtual Int_t Read(const char *name) {return TObject::Read(name);}
-
+    // Check if the item is used or marked as unused
+    Bool_t IsUsed() const {return fUsed;}
+    // Mark the object as unused
+    void MarkUnused()  {fUsed = kFALSE;}
     // Returns max size of array for for Tracks, Hits, and signals.
     static Int_t GetMaxKept() {return fgksize;};
 
@@ -82,8 +89,9 @@ class AliITSpListItem: public TObject {
     Double_t fTsignal;        // Total signal (no noise)
     Double_t fNoise;          // Total noise, coupling, ...
     Double_t fSignalAfterElect; // Signal after electronics
+    Bool_t fUsed;              //! kTRUE if the item is built and in use
 
-    ClassDef(AliITSpListItem,3) // Item list of signals and track numbers
+    ClassDef(AliITSpListItem,4) // Item list of signals and track numbers
 };     
 // Input and output functions for standard C++ input/output.
 ostream & operator<<(ostream &os,AliITSpListItem &source);