X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=RALICE%2FAliCalorimeter.cxx;h=23d2d0324665e022d73124651d77508e27d49760;hb=c661714403c94ca462146067742a71f84a533d07;hp=6548be65071e96e5c501a3c9aa72796095d0ed03;hpb=1c01b4f8f320d56f005be7b75122808a22c8328e;p=u%2Fmrichter%2FAliRoot.git diff --git a/RALICE/AliCalorimeter.cxx b/RALICE/AliCalorimeter.cxx index 6548be65071..23d2d032466 100644 --- a/RALICE/AliCalorimeter.cxx +++ b/RALICE/AliCalorimeter.cxx @@ -62,7 +62,7 @@ ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O -AliCalorimeter::AliCalorimeter() : TNamed() +AliCalorimeter::AliCalorimeter() : AliDevice() { // Default constructor, all parameters set to 0. // Create a calorimeter module matrix with fixed row and column size. @@ -80,7 +80,6 @@ AliCalorimeter::AliCalorimeter() : TNamed() fVetos=0; fAttributes=0; fPositions=0; - SetName("Unspecified"); } /////////////////////////////////////////////////////////////////////////// AliCalorimeter::~AliCalorimeter() @@ -123,7 +122,7 @@ AliCalorimeter::~AliCalorimeter() } } /////////////////////////////////////////////////////////////////////////// -AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TNamed() +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". @@ -161,11 +160,9 @@ AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) : TNamed() fHclusters=0; fVetos=0; - - SetName("Unspecified"); } /////////////////////////////////////////////////////////////////////////// -AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TNamed(c) +AliCalorimeter::AliCalorimeter(const AliCalorimeter& c) : AliDevice(c) { // Copy constructor fClusters=0; @@ -192,7 +189,7 @@ AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TNamed(c) { 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); } } @@ -224,19 +221,6 @@ AliCalorimeter::AliCalorimeter(AliCalorimeter& c) : TNamed(c) } } - 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++) { @@ -249,6 +233,7 @@ Int_t AliCalorimeter::GetNrows() { // 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; } @@ -257,6 +242,7 @@ Int_t AliCalorimeter::GetNcolumns() { // 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; } @@ -273,39 +259,44 @@ void AliCalorimeter::SetSignal(Int_t row,Int_t col,Float_t 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) // initialise for a new module + AliCalmodule* mx=GetModule(row,col); + if (mx) // Existing module + { + mx->SetSignal(sig); + } + else // Initialise for a new module { - m=new AliCalmodule(); - m->SetRow(row); - m->SetColumn(col); + 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(sig); } /////////////////////////////////////////////////////////////////////////// void AliCalorimeter::AddSignal(Int_t row, Int_t col, Float_t sig) @@ -358,42 +349,44 @@ void AliCalorimeter::AddSignal(AliCalmodule* mod) 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(sig); + mx->AddSignal(sig); } } /////////////////////////////////////////////////////////////////////////// @@ -412,7 +405,11 @@ void AliCalorimeter::Reset(Int_t row,Int_t col) } 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) @@ -436,6 +433,8 @@ void AliCalorimeter::Reset(Int_t mode) return; } + AliDevice::Reset(mode); + if (fClusters) { delete fClusters; @@ -678,7 +677,7 @@ void AliCalorimeter::SetDead(Int_t row,Int_t col) { if (i!=row || j!=col) // No increase of edge value for the 'dead' module itself { - AliAttribObj* a=(AliAttribObj*)fAttributes->At(i-1); + a=(AliAttribObj*)fAttributes->At(i-1); if (a) { a->IncreaseEdgeValue(j); @@ -690,7 +689,7 @@ void AliCalorimeter::SetDead(Int_t row,Int_t col) fAttributes->AddAt(a,i-1); } - AliCalmodule* m=GetModule(i,j); + m=GetModule(i,j); if (m) m->IncreaseEdgeValue(); } } @@ -744,7 +743,7 @@ void AliCalorimeter::SetAlive(Int_t row,Int_t col) AliAttribObj* a=(AliAttribObj*)fAttributes->At(i-1); if (a) a->DecreaseEdgeValue(j); } - AliCalmodule* m=GetModule(i,j); + m=GetModule(i,j); if (m) m->DecreaseEdgeValue(); } } @@ -1141,8 +1140,6 @@ AliPosition* AliCalorimeter::GetPosition(Int_t row,Int_t col) return 0; } - if (!fPositions && !fMatrix) return 0; - AliPositionObj* po=0; if (fPositions) po=(AliPositionObj*)fPositions->GetObject(row,col); if (po) return po; @@ -1172,14 +1169,12 @@ Float_t AliCalorimeter::GetClusteredSignal(Int_t row,Int_t col) 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) @@ -1205,6 +1200,14 @@ 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(); @@ -1213,31 +1216,26 @@ void AliCalorimeter::Group(Int_t n,Int_t mode) 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; iGetRow(); // 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.) { @@ -1256,20 +1254,10 @@ void AliCalorimeter::Group(Int_t n,Int_t mode) } } } - - // Delete the temp. array - if (ordered) - { - for (Int_t j=0; jGetMaxRow(); 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; } @@ -1321,25 +1323,25 @@ void AliCalorimeter::SortM(AliCalmodule** ordered,Int_t& nord) 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. @@ -1366,45 +1368,8 @@ void AliCalorimeter::SortA(AliCalmodule** ordered,Int_t& nord) // 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) @@ -1444,7 +1409,7 @@ 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; @@ -1452,7 +1417,7 @@ Int_t AliCalorimeter::GetNclusters() 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 @@ -1471,23 +1436,13 @@ AliCalcluster* AliCalorimeter::GetCluster(Int_t j) } } /////////////////////////////////////////////////////////////////////////// -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) @@ -1496,6 +1451,7 @@ 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; } @@ -1511,6 +1467,8 @@ TH2F* AliCalorimeter::DrawModules(Float_t thresh,Int_t mode) Int_t nrows=fNrows; Int_t ncols=fNcolumns; + if (!fMatrix) LoadMatrix(); + if (fMatrix && !nrows && !ncols) { nrows=fMatrix->GetMaxRow(); @@ -1561,6 +1519,8 @@ TH2F* AliCalorimeter::DrawClusters(Float_t thresh) Int_t nrows=fNrows; Int_t ncols=fNcolumns; + if (!fMatrix) LoadMatrix(); + if (fMatrix && !nrows && !ncols) { nrows=fMatrix->GetMaxRow(); @@ -1602,6 +1562,8 @@ void AliCalorimeter::Ungroup() { // Set the module signals back to the non-clustered situation + if (!fMatrix) LoadMatrix(); + if (!fMatrix) return; Int_t nsig=GetNsignals(); @@ -1632,7 +1594,7 @@ void AliCalorimeter::AddVetoSignal(AliSignal& s) 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; @@ -1640,7 +1602,7 @@ Int_t AliCalorimeter::GetNvetos() 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 @@ -1657,7 +1619,7 @@ AliSignal* AliCalorimeter::GetVetoSignal(Int_t i) } } /////////////////////////////////////////////////////////////////////////// -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. @@ -1668,18 +1630,42 @@ void AliCalorimeter::SetSwapMode(Int_t swap) } 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; } /////////////////////////////////////////////////////////////////////////// -TObject* AliCalorimeter::Clone(char* name) +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 current object and provide the pointer to the copy. // This memberfunction enables automatic creation of new objects of the