ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O
-AliCalorimeter::AliCalorimeter() : TObject()
+AliCalorimeter::AliCalorimeter() : AliDevice()
{
// Default constructor, all parameters set to 0.
// Create a calorimeter module matrix with fixed row and column size.
fVetos=0;
fAttributes=0;
fPositions=0;
- fName="Unspecified AliCalorimeter";
}
///////////////////////////////////////////////////////////////////////////
AliCalorimeter::~AliCalorimeter()
}
}
///////////////////////////////////////////////////////////////////////////
-AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TObject()
+AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : AliDevice()
{
// Create a calorimeter module matrix with fixed row and column size.
// The modules at the edges are automatically marked as "edge modules".
fHclusters=0;
fVetos=0;
-
- fName="Unspecified AliCalorimeter";
}
///////////////////////////////////////////////////////////////////////////
-AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TObject(c)
+AliCalorimeter::AliCalorimeter(const AliCalorimeter& c) : AliDevice(c)
{
// Copy constructor
fClusters=0;
fNrows=c.fNrows;
fNcolumns=c.fNcolumns;
- fName=c.fName;
fSwap=c.fSwap;
{
for (Int_t icol=1; icol<=ncols; icol++)
{
- AliPosition* p=c.GetPosition(irow,icol);
+ AliPosition* p=(AliPosition*)(c.fPositions->GetObject(irow,icol));
if (p) SetPosition(irow,icol,*p);
}
}
}
}
- n=c.GetNsignals();
- if (n)
- {
- fMatrix=new AliObjMatrix();
- fMatrix->SetOwner();
- fMatrix->SetSwapMode(fSwap);
- for (Int_t im=1; im<=n; im++)
- {
- AliCalmodule* m=c.GetModule(im);
- if (m) fMatrix->EnterObject(m->GetRow(),m->GetColumn(),new AliCalmodule(*m));
- }
- }
-
n=c.GetNvetos();
for (Int_t iv=1; iv<=n; iv++)
{
{
// Provide the number of rows for the calorimeter module matrix
Int_t nrows=fNrows;
+ if (!fMatrix) LoadMatrix();
if (fMatrix && !nrows) nrows=fMatrix->GetMaxRow();
return nrows;
}
{
// Provide the number of columns for the calorimeter module matrix
Int_t ncols=fNcolumns;
+ if (!fMatrix) LoadMatrix();
if (fMatrix && !ncols) ncols=fMatrix->GetMaxColumn();
return ncols;
}
if (fNrows && fNcolumns) cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
return;
}
-
+
+ if (!fMatrix) LoadMatrix();
+
if (!fMatrix)
{
fMatrix=new AliObjMatrix();
- fMatrix->SetOwner();
fMatrix->SetSwapMode(fSwap);
}
- AliCalmodule* m=GetModule(row,col);
- if (!m) // initialise for a new module
+ AliCalmodule* mx=GetModule(row,col);
+ if (mx) // Existing module
{
- m=new AliCalmodule();
+ mx->SetSignal(sig);
+ }
+ else // Initialise for a new module
+ {
+ AliCalmodule m;
+ m.SetRow(row);
+ m.SetColumn(col);
+ m.SetSignal(sig);
AliPosition* r=0;
if (fPositions) r=(AliPositionObj*)fPositions->GetObject(row,col);
- if (r) m->SetPosition(*r);
+ if (r) m.SetPosition(*r);
if (fAttributes)
{
AliAttribObj* a=0;
if (row <= fAttributes->GetSize()) a=(AliAttribObj*)fAttributes->At(row-1);
if (a)
{
- if (a->GetGainFlag(col)) m->SetGain(a->GetGain(col));
- if (a->GetOffsetFlag(col)) m->SetOffset(a->GetOffset(col));
- if (a->GetDeadValue(col)) m->SetDead();
- if (a->GetEdgeValue(col)) m->SetEdgeValue(a->GetEdgeValue(col));
+ if (a->GetGainFlag(col)) m.SetGain(a->GetGain(col));
+ if (a->GetOffsetFlag(col)) m.SetOffset(a->GetOffset(col));
+ if (a->GetDeadValue(col)) m.SetDead();
+ if (a->GetEdgeValue(col)) m.SetEdgeValue(a->GetEdgeValue(col));
}
}
- fMatrix->EnterObject(row,col,m);
+ AddHit(m);
+ fMatrix->EnterObject(row,col,fHits->Last());
}
-
- m->SetSignal(row,col,sig);
}
///////////////////////////////////////////////////////////////////////////
void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig)
}
else
{
- m->AddSignal(row,col,sig);
+ m->AddSignal(sig);
}
}
///////////////////////////////////////////////////////////////////////////
if (fNrows && fNcolumns) cout << " Nrows,Ncols = " << fNrows << "," << fNcolumns << endl;
return;
}
+
+ if (!fMatrix) LoadMatrix();
if (!fMatrix)
{
fMatrix=new AliObjMatrix();
- fMatrix->SetOwner();
fMatrix->SetSwapMode(fSwap);
}
- AliCalmodule* m=GetModule(row,col);
- if (!m) // No module existed yet at this position
+ AliCalmodule* mx=GetModule(row,col);
+ if (!mx) // No module existed yet at this position
{
- m=new AliCalmodule(*mod);
+ AliCalmodule m(*mod);
AliPosition* r=0;
if (fPositions) r=(AliPositionObj*)fPositions->GetObject(row,col);
- if (r) m->SetPosition(*r);
+ if (r) m.SetPosition(*r);
// Don't take the dead and edge attributes from this module,
// but from the calorimeter dbase, if present.
- m->SetEdgeOff();
- m->SetAlive();
+ m.SetEdgeOff();
+ m.SetAlive();
if (fAttributes)
{
AliAttribObj* a=0;
if (row <= fAttributes->GetSize()) a=(AliAttribObj*)fAttributes->At(row-1);
if (a)
{
- if (a->GetGainFlag(col)) m->SetGain(a->GetGain(col));
- if (a->GetOffsetFlag(col)) m->SetOffset(a->GetOffset(col));
- if (a->GetDeadValue(col)) m->SetDead();
- if (a->GetEdgeValue(col)) m->SetEdgeValue(a->GetEdgeValue(col));
+ if (a->GetGainFlag(col)) m.SetGain(a->GetGain(col));
+ if (a->GetOffsetFlag(col)) m.SetOffset(a->GetOffset(col));
+ if (a->GetDeadValue(col)) m.SetDead();
+ if (a->GetEdgeValue(col)) m.SetEdgeValue(a->GetEdgeValue(col));
}
}
- fMatrix->EnterObject(row,col,m);
+ AddHit(m);
+ fMatrix->EnterObject(row,col,fHits->Last());
}
else
{
- m->AddSignal(row,col,sig);
+ mx->AddSignal(sig);
}
}
///////////////////////////////////////////////////////////////////////////
}
AliCalmodule* m=GetModule(row,col);
- if (m) fMatrix->RemoveObject(row,col);
+ if (m)
+ {
+ RemoveHit(m);
+ fMatrix->RemoveObject(row,col);
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliCalorimeter::Reset(Int_t mode)
return;
}
+ AliDevice::Reset(mode);
+
if (fClusters)
{
delete fClusters;
return 0;
}
- if (!fPositions && !fMatrix) return 0;
-
AliPositionObj* po=0;
if (fPositions) po=(AliPositionObj*)fPositions->GetObject(row,col);
if (po) return po;
return sig;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNsignals()
+Int_t AliCalorimeter::GetNsignals() const
{
// Provide the number of modules that contain a signal
// Note : The number of modules marked 'dead' but which had a signal
// are included.
- Int_t nsig=0;
- if (fMatrix) nsig=fMatrix->GetNobjects();
- return nsig;
+ return GetNhits();
}
///////////////////////////////////////////////////////////////////////////
void AliCalorimeter::Group(Int_t n,Int_t mode)
mode=1;
}
+ if (fClusters)
+ {
+ delete fClusters;
+ fClusters=0;
+ }
+
+ if (!fMatrix) LoadMatrix();
+
if (!fMatrix) return;
Int_t nsignals=GetNsignals();
if (GetNclusters() > 0) Ungroup(); // Restore unclustered situation if needed
// Order the modules with decreasing signal
- AliCalmodule** ordered=new AliCalmodule*[nsignals]; // temp. array for ordered modules
+ if (mode==1) SortM();
+ if (mode==2) SortA();
+
Int_t nord=0;
- if (mode==1) SortM(ordered,nord);
- if (mode==2) SortA(ordered,nord);
+ if (fOrdered) nord=fOrdered->GetEntries();
// Clustering of modules. Start with the highest signal.
- if (fClusters)
- {
- delete fClusters;
- fClusters=0;
- }
fClusters=new TObjArray();
fClusters->SetOwner();
Int_t row=0;
Int_t col=0;
AliCalcluster* c=0;
- AliCalmodule* m=0;
for (Int_t i=0; i<nord; i++)
{
- row=ordered[i]->GetRow(); // row number of cluster center
- col=ordered[i]->GetColumn(); // column number of cluster center
-
- m=(AliCalmodule*)fMatrix->GetObject(row,col);
+ AliCalmodule* m=(AliCalmodule*)fOrdered->At(i);
if (!m) continue;
+ row=m->GetRow(); // row number of cluster center
+ col=m->GetColumn(); // column number of cluster center
+
// only use modules not yet used in a cluster
if (m->GetClusteredSignal() > 0.)
{
}
}
}
-
- // Delete the temp. array
- if (ordered)
- {
- for (Int_t j=0; j<nord; j++)
- {
- ordered[j]=0;
- }
- delete [] ordered;
- }
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SortM(AliCalmodule** ordered,Int_t& nord)
+void AliCalorimeter::SortM()
{
// Order the modules with decreasing signal by looping over the (row,col) grid
// of the matrix.
// ---------------
// * In case of a very high occupancy, there might be a slight effect on the
// cluster signals depending on the geometrical location in the detector matrix.
-
+
+ if (fOrdered)
+ {
+ delete fOrdered;
+ fOrdered=0;
+ }
+
Int_t nrows=fMatrix->GetMaxRow();
Int_t ncols=fMatrix->GetMaxColumn();
Float_t signal=0.;
- nord=0;
+ Int_t nord=0;
for (Int_t irow=1; irow<=nrows; irow++) // loop over all modules of the matrix
{
for (Int_t icol=1; icol<=ncols; icol++)
{
- signal=GetSignal(irow,icol,1); // get the gain etc... corrected signal
- if (signal <= 0.) continue; // only take alive modules with a signal
+ AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(irow,icol);
+ if (!m) continue;
+
+ signal=m->GetSignal(1,1); // get the gain etc... corrected signal
+ if (signal <= 0.) continue; // only take alive modules with a signal
if (nord == 0) // store the first module with a signal at the first ordered position
{
+ if (!fOrdered)
+ {
+ Int_t nhits=GetNhits();
+ fOrdered=new TObjArray(nhits);
+ }
nord++;
- ordered[nord-1]=(AliCalmodule*)fMatrix->GetObject(irow,icol);
+ fOrdered->AddAt(m,nord-1);
continue;
}
if (j == nord) // module has smallest signal seen so far
{
nord++;
- ordered[j]=(AliCalmodule*)fMatrix->GetObject(irow,icol); // add module at the end
+ fOrdered->AddAt(m,j); // add module at the end
break; // go for next matrix module
}
- if (signal < ordered[j]->GetSignal(1,1)) continue;
+ if (signal < ((AliCalmodule*)fOrdered->At(j))->GetSignal(1,1)) continue;
nord++;
for (Int_t k=nord-1; k>j; k--) // create empty position
{
- ordered[k]=ordered[k-1];
+ fOrdered->AddAt(fOrdered->At(k-1),k);
}
- ordered[j]=(AliCalmodule*)fMatrix->GetObject(irow,icol); // put module at empty position
+ fOrdered->AddAt(m,j); // put module at empty position
break; // go for next matrix module
}
}
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SortA(AliCalmodule** ordered,Int_t& nord)
+void AliCalorimeter::SortA()
{
// Order the modules with decreasing signal by looping over the linear array
// of fired modules.
// of the resulting cluster signal.
// * This method might produce results depending on the filling
// order of the matrix modules.
-
- Int_t nmods=0;
- if (fMatrix) nmods=fMatrix->GetNobjects();
- nord=0;
- for (Int_t i=1; i<=nmods; i++) // loop over all fired modules of the matrix
- {
- AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(i);
-
- if (!m) continue;
- if (m->GetDeadValue()) continue; // only take alive modules with a signal
-
- if (nord == 0) // store the first module with a signal at the first ordered position
- {
- nord++;
- ordered[nord-1]=m;
- continue;
- }
-
- for (Int_t j=0; j<=nord; j++) // put module in the right ordered position
- {
- if (j == nord) // module has smallest signal seen so far
- {
- nord++;
- ordered[j]=m; // add module at the end
- break; // go for next matrix module
- }
-
- if (m->GetSignal(1,1) < ordered[j]->GetSignal(1,1)) continue;
-
- nord++;
- for (Int_t k=nord-1; k>j; k--) // create empty position
- {
- ordered[k]=ordered[k-1];
- }
- ordered[j]=m; // put module at empty position
- break; // go for next matrix module
- }
- }
+ SortHits();
}
///////////////////////////////////////////////////////////////////////////
void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n)
}
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNclusters()
+Int_t AliCalorimeter::GetNclusters() const
{
// Provide the number of clusters
Int_t nclu=0;
return nclu;
}
///////////////////////////////////////////////////////////////////////////
-AliCalcluster* AliCalorimeter::GetCluster(Int_t j)
+AliCalcluster* AliCalorimeter::GetCluster(Int_t j) const
{
// Provide cluster number j
// Note : j=1 denotes the first cluster
}
}
///////////////////////////////////////////////////////////////////////////
-AliCalmodule* AliCalorimeter::GetModule(Int_t j)
+AliCalmodule* AliCalorimeter::GetModule(Int_t j) const
{
// Provide 'fired' module number j
// Note : j=1 denotes the first 'fired' module
- if (!fMatrix) return 0;
-
- if ((j >= 1) && (j <= GetNsignals()))
- {
- return (AliCalmodule*)fMatrix->GetObject(j);
- }
- else
- {
- cout << " *AliCalorimeter::GetModule* module number : " << j
- << " out of range ==> 0 returned." << endl;
- return 0;
- }
+ AliCalmodule* m=(AliCalmodule*)GetHit(j);
+ return m;
}
///////////////////////////////////////////////////////////////////////////
AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col)
// Note : first module is at (1,1).
AliCalmodule* m=0;
+ if (!fMatrix) LoadMatrix();
if (fMatrix) m=(AliCalmodule*)fMatrix->GetObject(row,col);
return m;
}
Int_t nrows=fNrows;
Int_t ncols=fNcolumns;
+ if (!fMatrix) LoadMatrix();
+
if (fMatrix && !nrows && !ncols)
{
nrows=fMatrix->GetMaxRow();
Int_t nmods=GetNsignals();
- Float_t row,col,signal;
+ Int_t row,col;
+ Float_t signal;
Int_t dead;
for (Int_t i=1; i<=nmods; i++)
{
AliCalmodule* m=(AliCalmodule*)fMatrix->GetObject(i);
if (m)
{
- row=float(m->GetRow());
- col=float(m->GetColumn());
+ row=m->GetRow();
+ col=m->GetColumn();
dead=m->GetDeadValue();
signal=0;
if (!dead) signal=GetSignal(row,col,mode);
- if (signal>thresh) fHmodules->Fill(col,row,signal);
+ if (signal>thresh) fHmodules->Fill(float(col),float(row),signal);
}
}
Int_t nrows=fNrows;
Int_t ncols=fNcolumns;
+ if (!fMatrix) LoadMatrix();
+
if (fMatrix && !nrows && !ncols)
{
nrows=fMatrix->GetMaxRow();
}
AliCalcluster* c;
- Float_t row,col,signal;
+ Int_t row,col;
+ Float_t signal;
for (Int_t i=0; i<GetNclusters(); i++)
{
c=(AliCalcluster*)fClusters->At(i);
if (c)
{
- row=float(c->GetRow());
- col=float(c->GetColumn());
+ row=c->GetRow();
+ col=c->GetColumn();
signal=c->GetSignal();
- if (signal>thresh) fHclusters->Fill(col,row,signal);
+ if (signal>thresh) fHclusters->Fill(float(col),float(row),signal);
}
}
{
// Set the module signals back to the non-clustered situation
+ if (!fMatrix) LoadMatrix();
+
if (!fMatrix) return;
Int_t nsig=GetNsignals();
fVetos->Add(sx);
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetNvetos()
+Int_t AliCalorimeter::GetNvetos() const
{
// Provide the number of veto signals associated to the calorimeter.
Int_t nvetos=0;
return nvetos;
}
///////////////////////////////////////////////////////////////////////////
-AliSignal* AliCalorimeter::GetVetoSignal(Int_t i)
+AliSignal* AliCalorimeter::GetVetoSignal(Int_t i) const
{
// Provide access to the i-th veto signal of this calorimeter
// Note : The first hit corresponds to i=1
}
}
///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SetName(TString name)
-{
-// Set the name of the calorimeter system.
- fName=name;
-}
-///////////////////////////////////////////////////////////////////////////
-TString AliCalorimeter::GetName()
-{
-// Provide the name of the calorimeter system.
- return fName;
-}
-///////////////////////////////////////////////////////////////////////////
-void AliCalorimeter::SetSwapMode(Int_t swap)
+void AliCalorimeter::SetMatrixSwapMode(Int_t swap)
{
// Set the swap mode for the module and position matrices.
// At invokation of this memberfunction the default argument is swap=1.
}
else
{
- cout << " *AliCalorimeter::SetSwapMode* Invalid argument : swap = " << swap << endl;
+ cout << " *AliCalorimeter::SetMatrixSwapMode* Invalid argument : swap = " << swap << endl;
}
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliCalorimeter::GetSwapMode()
+Int_t AliCalorimeter::GetMatrixSwapMode() const
{
// Provide the swap mode for the module and position matrices.
// For further details see the documentation of AliObjMatrix.
return fSwap;
}
///////////////////////////////////////////////////////////////////////////
-AliCalorimeter* AliCalorimeter::MakeCopy(AliCalorimeter& c)
+void AliCalorimeter::LoadMatrix()
+{
+// Load the matrix lookup table of module pointers from the linear hit array.
+ Int_t nhits=GetNhits();
+
+ if (!nhits) return;
+
+ fMatrix=new AliObjMatrix();
+ fMatrix->SetSwapMode(fSwap);
+
+ Int_t row=0;
+ Int_t col=0;
+ for (Int_t i=1; i<=nhits; i++)
+ {
+ AliCalmodule* m=(AliCalmodule*)GetHit(i);
+ if (m)
+ {
+ row=m->GetRow();
+ col=m->GetColumn();
+ fMatrix->EnterObject(row,col,m);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliCalorimeter::Clone(const char* name) const
{
-// Make a deep copy of the input object and provide the pointer to the copy.
+// Make a deep copy of the current object and provide the pointer to the copy.
// This memberfunction enables automatic creation of new objects of the
-// correct type depending on the argument type, a feature which may be very useful
+// correct type depending on the object type, a feature which may be very useful
// for containers like AliEvent when adding objects in case the
// container owns the objects.
- AliCalorimeter* cal=new AliCalorimeter(c);
+ AliCalorimeter* cal=new AliCalorimeter(*this);
+ if (name)
+ {
+ if (strlen(name)) cal->SetName(name);
+ }
return cal;
}
///////////////////////////////////////////////////////////////////////////