AliITSpList::AliITSpList(Int_t imax,Int_t jmax):
fNi(imax),
fNj(jmax),
-fa(0),
+fa(new AliITSpListItem[imax*jmax]),
fEntries(0){
// Standard constructor
// Inputs:
// 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;
}
//______________________________________________________________________
// 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){
// 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--;
}
//______________________________________________________________________
}
//______________________________________________________________________
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) {
// 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;
}
//______________________________________________________________________
// 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;
}
//______________________________________________________________________
// 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;
}
//______________________________________________________________________
// 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");}
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
findex(-1),
fTsignal(0.0),
fNoise(0.0),
-fSignalAfterElect(0.0){
+fSignalAfterElect(0.0),
+fUsed(kFALSE){
// Default constructor
// Inputs:
// none.
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
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
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
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
#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$ */
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);}
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;};
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);