/* $Id$ */
-// Clusterizer class developped by A. Zinchenko (Dubna)
+// -------------------------------
+// Class AliMUONClusterFinderAZ
+// -------------------------------
+// Clusterizer class based on the Expectation-Maximization algorithm
+// Author: Alexander Zinchenko, JINR Dubna
#include <stdlib.h>
#include <Riostream.h>
-#include <TROOT.h>
-#include <TCanvas.h>
-#include <TLine.h>
-#include <TTree.h>
#include <TH2.h>
-#include <TView.h>
-#include <TStyle.h>
#include <TMinuit.h>
#include <TMatrixD.h>
+#include <TRandom.h>
+#include <TROOT.h>
#include "AliMUONClusterFinderAZ.h"
-#include "AliHeader.h"
-#include "AliRun.h"
-#include "AliMUON.h"
-#include "AliMUONChamber.h"
+#include "AliMUONClusterDrawAZ.h"
+#include "AliMUONVGeometryDESegmentation.h"
+#include "AliMUONGeometryModuleTransformer.h"
+#include "AliMUONGeometrySegmentation.h"
#include "AliMUONDigit.h"
-#include "AliMUONHit.h"
-#include "AliMUONChamber.h"
#include "AliMUONRawCluster.h"
#include "AliMUONClusterInput.h"
#include "AliMUONPixel.h"
-#include "AliMC.h"
-#include "AliMUONLoader.h"
+#include "AliMUONMathieson.h"
#include "AliLog.h"
+/// \cond CLASSIMP
ClassImp(AliMUONClusterFinderAZ)
+/// \endcond
const Double_t AliMUONClusterFinderAZ::fgkCouplMin = 1.e-3; // threshold on coupling
+ const Double_t AliMUONClusterFinderAZ::fgkZeroSuppression = 6; // average zero suppression value
+ const Double_t AliMUONClusterFinderAZ::fgkSaturation = 3000; // average saturation level
AliMUONClusterFinderAZ* AliMUONClusterFinderAZ::fgClusterFinder = 0x0;
TMinuit* AliMUONClusterFinderAZ::fgMinuit = 0x0;
//FILE *lun1 = fopen("nxny.dat","w");
//_____________________________________________________________________________
-AliMUONClusterFinderAZ::AliMUONClusterFinderAZ(Bool_t draw, Int_t iReco)
- : AliMUONClusterFinderVS()
+AliMUONClusterFinderAZ::AliMUONClusterFinderAZ(Bool_t draw)
+ : AliMUONClusterFinderVS(),
+ fZpad(0),
+ fNpar(0),
+ fQtot(0),
+ fReco(1),
+ fCathBeg(0),
+ fDraw(0x0),
+ fPixArray(0x0),
+ fnCoupled(0),
+ fDebug(0)
{
-// Constructor
- for (Int_t i=0; i<4; i++) {fHist[i] = 0;}
- //fMuonDigits = 0;
- fSegmentation[1] = fSegmentation[0] = 0;
- //AZ fgClusterFinder = 0x0;
- //AZ fgMinuit = 0x0;
- if (!fgClusterFinder) fgClusterFinder = this;
+/// Constructor
+ fnPads[0]=fnPads[1]=0;
+
+ for (Int_t i=0; i<7; i++)
+ for (Int_t j=0; j<fgkDim; j++)
+ fXyq[i][j]= 9999.;
+
+ for (Int_t i=0; i<4; i++)
+ for (Int_t j=0; j<fgkDim; j++)
+ fPadIJ[i][j]=-1;
+
+ for (Int_t i=0; i<2; i++)
+ for (Int_t j=0; j<fgkDim; j++)
+ fUsed[i][j] = 0;
+
+ fSegmentation[1] = fSegmentation[0] = 0x0;
+
+ fPadBeg[0] = fPadBeg[1] = 0;
+
if (!fgMinuit) fgMinuit = new TMinuit(8);
- fDraw = draw;
- fReco = iReco;
+ if (!fgClusterFinder) fgClusterFinder = this;
fPixArray = new TObjArray(20);
- fDebug = 0; //0;
- if (draw) fDebug = 1;
-}
-
-//_____________________________________________________________________________
-AliMUONClusterFinderAZ::AliMUONClusterFinderAZ(const AliMUONClusterFinderAZ& rhs)
- : AliMUONClusterFinderVS(rhs)
-{
-// Protected copy constructor
- AliFatal("Not implemented.");
+ if (draw) {
+ fDebug = 1;
+ fReco = 0;
+ fDraw = new AliMUONClusterDrawAZ(this);
+ }
+ cout << " *** Running AZ cluster finder *** " << endl;
}
//_____________________________________________________________________________
AliMUONClusterFinderAZ::~AliMUONClusterFinderAZ()
{
- // Destructor
+/// Destructor
delete fgMinuit; fgMinuit = 0; delete fPixArray; fPixArray = 0;
+ delete fDraw;
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::FindRawClusters()
{
-// To provide the same interface as in AliMUONClusterFinderVS
+/// To provide the same interface as in AliMUONClusterFinderVS
- ResetRawClusters(); //AZ
- EventLoop (gAlice->GetHeader()->GetEvent(), AliMUONClusterInput::Instance()->Chamber());
+ ResetRawClusters();
+ EventLoop (fEvtNumber, fInput->Chamber());
}
//_____________________________________________________________________________
-void AliMUONClusterFinderAZ::EventLoop(Int_t nev=0, Int_t ch=0)
+void AliMUONClusterFinderAZ::EventLoop(Int_t nev, Int_t ch)
{
-// Loop over digits
+/// Loop over digits
- static Int_t nev0 = -1, ch0 = -1;
- if (fDraw) {
- // Find requested event and chamber
- if (nev < nev0) return;
- else if (nev == nev0 && ch < ch0) return;
- }
- nev0 = nev;
- ch0 = ch;
-
- AliMUON *pMuon = (AliMUON*) gAlice->GetModule("MUON");
- AliMUONChamber *iChamber = &(pMuon->Chamber(ch));
- //fSegmentation[0] = iChamber->SegmentationModel(1);
- //fSegmentation[1] = iChamber->SegmentationModel(2);
- fResponse = iChamber->ResponseModel();
- fSegmentation[0] = AliMUONClusterInput::Instance()->Segmentation2(0);
- fSegmentation[1] = AliMUONClusterInput::Instance()->Segmentation2(1);
- //AZ fResponse = AliMUONClusterInput::Instance()->Response();
+ if (fDraw && !fDraw->FindEvCh(nev, ch)) return;
+
+ fSegmentation[0] = (AliMUONVGeometryDESegmentation*) fInput->
+ Segmentation2(0)->GetDESegmentation(fInput->DetElemId());
+ fSegmentation[1] = (AliMUONVGeometryDESegmentation*) fInput->
+ Segmentation2(1)->GetDESegmentation(fInput->DetElemId());
- Int_t ndigits[2]={9,9}, nShown[2]={0};
- for (Int_t i=0; i<2; i++) {
- for (Int_t j=0; j<fgkDim; j++) {fUsed[i][j]=kFALSE;}
+ Int_t ndigits[2] = {9,9}, nShown[2] = {0};
+ if (fReco != 2) { // skip initialization for the combined cluster / track
+ fCathBeg = fPadBeg[0] = fPadBeg[1] = 0;
+ for (Int_t i = 0; i < 2; i++) {
+ for (Int_t j = 0; j < fgkDim; j++) { fUsed[i][j] = kFALSE; }
+ }
}
next:
- if (ndigits[0] == nShown[0] && ndigits[1] == nShown[1]) {
- // No more clusters
- if (fReco) return;
- //AZ ch0++;
- return; // next chamber
- }
+ if (fReco == 2 && (nShown[0] || nShown[1])) return; // only one precluster for the combined finder
+ if (ndigits[0] == nShown[0] && ndigits[1] == nShown[1]) return;
+
Float_t xpad, ypad, zpad, zpad0;
Bool_t first = kTRUE;
if (fDebug) cout << " *** Event # " << nev << " chamber: " << ch << endl;
fnPads[0] = fnPads[1] = 0;
- for (Int_t i=0; i<fgkDim; i++) {fPadIJ[1][i] = 0;}
+ for (Int_t i = 0; i < fgkDim; i++) fPadIJ[1][i] = 0;
- for (Int_t iii = 0; iii<2; iii++) {
+ for (Int_t iii = fCathBeg; iii < 2; iii++) {
Int_t cath = TMath::Odd(iii);
- ndigits[cath] = AliMUONClusterInput::Instance()->NDigits(cath); //AZ
+ ndigits[cath] = fInput->NDigits(cath);
if (!ndigits[0] && !ndigits[1]) return;
if (ndigits[cath] == 0) continue;
if (fDebug) cout << " ndigits: " << ndigits[cath] << " " << cath << endl;
Int_t digit;
Bool_t eEOC = kTRUE; // end-of-cluster
- for (digit = 0; digit < ndigits[cath]; digit++) {
+ for (digit = fPadBeg[cath]; digit < ndigits[cath]; digit++) {
mdig = AliMUONClusterInput::Instance()->Digit(cath,digit);
if (first) {
// Find first unused pad
if (fUsed[cath][digit]) continue;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad0);
+ //if (!fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad0)) {
+ if (!fSegmentation[cath]->HasPad(mdig->PadX(), mdig->PadY())) {
+ // Handle "non-existing" pads
+ fUsed[cath][digit] = kTRUE;
+ continue;
+ }
+ fSegmentation[cath]->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad0);
} else {
if (fUsed[cath][digit]) continue;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad);
- if (TMath::Abs(zpad-zpad0) > 0.1) continue; // different slats
+ //if (!fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad)) {
+ if (!fSegmentation[cath]->HasPad(mdig->PadX(), mdig->PadY())) {
+ // Handle "non-existing" pads
+ fUsed[cath][digit] = kTRUE;
+ continue;
+ }
+ fSegmentation[cath]->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
+ //if (TMath::Abs(zpad-zpad0) > 0.1) continue; // different slats
// Find a pad overlapping with the cluster
if (!Overlap(cath,mdig)) continue;
}
// Add pad - recursive call
AddPad(cath,digit);
//AZ !!!!!! Temporary fix of St1 overlap regions !!!!!!!!
+ /*
if (cath && ch < 2) {
Int_t npads = fnPads[0] + fnPads[1] - 1;
Int_t cath1 = fPadIJ[0][npads];
Int_t idig = TMath::Nint (fXyq[5][npads]);
mdig = AliMUONClusterInput::Instance()->Digit(cath1,idig);
- fSegmentation[cath1]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad);
+ //fSegmentation[cath1]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad);
+ fSegmentation[cath1]->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
if (TMath::Abs(zpad-zpad0) > 0.1) zpad0 = zpad;
}
+ */
eEOC = kFALSE;
if (digit >= 0) break;
}
} // for (Int_t iii = 0;
fZpad = zpad0;
- if (fDraw) DrawCluster(nev0, ch0);
+ if (fDraw) fDraw->DrawCluster();
// Use MLEM for cluster finder
Int_t nMax = 1, localMax[100], maxPos[100];
if (CheckPrecluster(nShown)) {
BuildPixArray();
- if (fnPads[0]+fnPads[1] > 50) nMax = FindLocalMaxima(localMax, maxVal);
+ //*
+ if (fnPads[0]+fnPads[1] > 50) nMax = FindLocalMaxima(fPixArray, localMax, maxVal);
if (nMax > 1) TMath::Sort(nMax, maxVal, maxPos, kTRUE); // in decreasing order
Int_t iSimple = 0, nInX = -1, nInY;
PadsInXandY(nInX, nInY);
if (fDebug) cout << "Pads in X and Y: " << nInX << " " << nInY << endl;
- if (nMax == 1 && nInX < 4 && nInY < 4) iSimple = 0; //1; // simple cluster
+ if (nMax == 1 && nInX < 4 && nInY < 4) iSimple = 1; //1; // simple cluster
+ //*/
+ /* For test
+ Int_t iSimple = 0, nInX = -1, nInY;
+ PadsInXandY(nInX, nInY);
+ if (fDebug) cout << "Pads in X and Y: " << nInX << " " << nInY << endl;
+ if (nMax == 1 && nInX < 4 && nInY < 4) iSimple = 1; //1; // simple cluster
+ if (!iSimple) nMax = FindLocalMaxima(fPixArray, localMax, maxVal);
+ nMax = 1;
+ if (nMax > 1) TMath::Sort(nMax, maxVal, maxPos, kTRUE); // in decreasing order
+ */
for (Int_t i=0; i<nMax; i++) {
if (nMax > 1) FindCluster(localMax, maxPos[i]);
- if (!MainLoop(iSimple)) cout << " MainLoop failed " << endl;
+ MainLoop(iSimple);
if (i < nMax-1) {
for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
if (fPadIJ[1][j] == 0) continue; // pad charge was not modified
fXyq[2][j] = fXyq[6][j]; // use backup charge value
}
}
- }
- }
- if (fReco || Next(nev0, ch0)) goto next;
-}
-
-//_____________________________________________________________________________
-void AliMUONClusterFinderAZ::DrawCluster(Int_t nev0, Int_t ch0)
-{
- // Draw preclusters
- TCanvas *c1 = 0;
- TView *view = 0;
- TH2F *hist = 0;
- Double_t p1[3]={0}, p2[3];
- if (!gPad) {
- c1 = new TCanvas("c1","Clusters",0,0,600,700);
- //c1->SetFillColor(10);
- c1->Divide(1,2);
- new TCanvas("c2","Mlem",700,0,600,350);
- } else {
- c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
- }
-
- Int_t ntracks = 0;
-
- // Get pointer to Alice detectors
- AliMUON *muon = (AliMUON*) gAlice->GetModule("MUON");
- if (!muon) return;
-
- //Loaders
- AliRunLoader *rl = AliRunLoader::GetRunLoader();
- AliLoader *gime = rl->GetLoader("MUONLoader");
- AliMUONData *data = ((AliMUONLoader*)gime)->GetMUONData();
-
- gime->LoadHits("READ");
- TTree *treeH = gime->TreeH();
- ntracks = (Int_t) treeH->GetEntries();
- cout << " nev " << nev0 << " ntracks " << ntracks << endl;
- gime->LoadRecPoints("READ");
- TTree *treeR = data->TreeR();
- if (treeR) {
- data->SetTreeAddress("RC");
- data->GetRawClusters();
- }
-
- TLine *line[99]={0};
- Int_t nLine = 0;
- char hName[4];
- for (Int_t cath = 0; cath<2; cath++) {
- // Build histograms
- if (fHist[cath*2]) {fHist[cath*2]->Delete(); fHist[cath*2] = 0;}
- if (fHist[cath*2+1]) {fHist[cath*2+1]->Delete(); fHist[cath*2+1] = 0;}
- if (fnPads[cath] == 0) continue; // cluster on one cathode only
- Float_t wxMin=999, wxMax=0, wyMin=999, wyMax=0;
- Int_t minDx=0, maxDx=0, minDy=0, maxDy=0;
- for (Int_t i=0; i<fnPads[0]+fnPads[1]; i++) {
- if (fPadIJ[0][i] != cath) continue;
- if (fXyq[3][i] < wxMin) {wxMin = fXyq[3][i]; minDx = i;}
- if (fXyq[3][i] > wxMax) {wxMax = fXyq[3][i]; maxDx = i;}
- if (fXyq[4][i] < wyMin) {wyMin = fXyq[4][i]; minDy = i;}
- if (fXyq[4][i] > wyMax) {wyMax = fXyq[4][i]; maxDy = i;}
- }
- cout << minDx << maxDx << minDy << maxDy << endl;
- Int_t nx, ny, padSize;
- Float_t xmin=9999, xmax=-9999, ymin=9999, ymax=-9999;
- if (TMath::Nint(fXyq[3][minDx]*1000) == TMath::Nint(fXyq[3][maxDx]*1000) &&
- TMath::Nint(fXyq[4][minDy]*1000) == TMath::Nint(fXyq[4][maxDy]*1000)) {
- // the same segmentation
- cout << " Same" << endl;
- cout << fXyq[3][minDx] << " " << fXyq[3][maxDx] << " " << fXyq[4][minDy] << " " << fXyq[4][maxDy] << endl;
- for (Int_t i=0; i<fnPads[0]+fnPads[1]; i++) {
- if (fPadIJ[0][i] != cath) continue;
- if (fXyq[0][i] < xmin) xmin = fXyq[0][i];
- if (fXyq[0][i] > xmax) xmax = fXyq[0][i];
- if (fXyq[1][i] < ymin) ymin = fXyq[1][i];
- if (fXyq[1][i] > ymax) ymax = fXyq[1][i];
- }
- xmin -= fXyq[3][minDx]; xmax += fXyq[3][minDx];
- ymin -= fXyq[4][minDy]; ymax += fXyq[4][minDy];
- nx = TMath::Nint ((xmax-xmin)/wxMin/2);
- ny = TMath::Nint ((ymax-ymin)/wyMin/2);
- cout << xmin << " " << xmax << " " << nx << " " << ymin << " " << ymax << " " << ny << endl;
- sprintf(hName,"h%d",cath*2);
- fHist[cath*2] = new TH2F(hName,"cluster",nx,xmin,xmax,ny,ymin,ymax);
- //cout << fHist[cath*2] << " " << fnPads[cath] << endl;
- for (Int_t i=0; i<fnPads[0]+fnPads[1]; i++) {
- if (fPadIJ[0][i] != cath) continue;
- fHist[cath*2]->Fill(fXyq[0][i],fXyq[1][i],fXyq[2][i]);
- //cout << fXyq[0][i] << fXyq[1][i] << fXyq[2][i] << endl;
- }
- } else {
- // different segmentation in the cluster
- cout << " Different" << endl;
- cout << fXyq[3][minDx] << " " << fXyq[3][maxDx] << " " << fXyq[4][minDy] << " " << fXyq[4][maxDy] << endl;
- Int_t nOK = 0;
- Int_t indx, locMin, locMax;
- if (TMath::Nint(fXyq[3][minDx]*1000) != TMath::Nint(fXyq[3][maxDx]*1000)) {
- // different segmentation along x
- indx = 0;
- locMin = minDx;
- locMax = maxDx;
- } else {
- // different segmentation along y
- indx = 1;
- locMin = minDy;
- locMax = maxDy;
- }
- Int_t loc = locMin;
- for (Int_t i=0; i<2; i++) {
- // loop over different pad sizes
- if (i>0) loc = locMax;
- padSize = TMath::Nint(fXyq[indx+3][loc]*1000);
- xmin = 9999; xmax = -9999; ymin = 9999; ymax = -9999;
- for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
- if (fPadIJ[0][j] != cath) continue;
- if (TMath::Nint(fXyq[indx+3][j]*1000) != padSize) continue;
- nOK++;
- xmin = TMath::Min (xmin,fXyq[0][j]);
- xmax = TMath::Max (xmax,fXyq[0][j]);
- ymin = TMath::Min (ymin,fXyq[1][j]);
- ymax = TMath::Max (ymax,fXyq[1][j]);
- }
- xmin -= fXyq[3][loc]; xmax += fXyq[3][loc];
- ymin -= fXyq[4][loc]; ymax += fXyq[4][loc];
- nx = TMath::Nint ((xmax-xmin)/fXyq[3][loc]/2);
- ny = TMath::Nint ((ymax-ymin)/fXyq[4][loc]/2);
- sprintf(hName,"h%d",cath*2+i);
- fHist[cath*2+i] = new TH2F(hName,"cluster",nx,xmin,xmax,ny,ymin,ymax);
- for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
- if (fPadIJ[0][j] != cath) continue;
- if (TMath::Nint(fXyq[indx+3][j]*1000) != padSize) continue;
- fHist[cath*2+i]->Fill(fXyq[0][j],fXyq[1][j],fXyq[2][j]);
- }
- } // for (Int_t i=0;
- if (nOK != fnPads[cath]) cout << " *** Too many segmentations: nPads, nOK " << fnPads[cath] << " " << nOK << endl;
- } // if (TMath::Nint(fXyq[3][minDx]*1000)
- } // for (Int_t cath = 0;
-
- // Draw histograms and coordinates
- for (Int_t cath=0; cath<2; cath++) {
- if (cath == 0) ModifyHistos();
- if (fnPads[cath] == 0) continue; // cluster on one cathode only
- if (fDraw) {
- c1->cd(cath+1);
- gPad->SetTheta(55);
- gPad->SetPhi(30);
- Double_t x, y, x0, y0, r1=999, r2=0;
- if (fHist[cath*2+1]) {
- //
- x0 = fHist[cath*2]->GetXaxis()->GetXmin() - 1000*TMath::Cos(30*TMath::Pi()/180);
- y0 = fHist[cath*2]->GetYaxis()->GetXmin() - 1000*TMath::Sin(30*TMath::Pi()/180);
- r1 = 0;
- Int_t ihist=cath*2;
- for (Int_t iy=1; iy<=fHist[ihist]->GetNbinsY(); iy++) {
- y = fHist[ihist]->GetYaxis()->GetBinCenter(iy)
- + fHist[ihist]->GetYaxis()->GetBinWidth(iy);
- for (Int_t ix=1; ix<=fHist[ihist]->GetNbinsX(); ix++) {
- if (fHist[ihist]->GetCellContent(ix,iy) > 0.1) {
- x = fHist[ihist]->GetXaxis()->GetBinCenter(ix)
- + fHist[ihist]->GetXaxis()->GetBinWidth(ix);
- r1 = TMath::Max (r1,TMath::Sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0)));
- }
- }
- }
- ihist = cath*2 + 1 ;
- for (Int_t iy=1; iy<=fHist[ihist]->GetNbinsY(); iy++) {
- y = fHist[ihist]->GetYaxis()->GetBinCenter(iy)
- + fHist[ihist]->GetYaxis()->GetBinWidth(iy);
- for (Int_t ix=1; ix<=fHist[ihist]->GetNbinsX(); ix++) {
- if (fHist[ihist]->GetCellContent(ix,iy) > 0.1) {
- x = fHist[ihist]->GetXaxis()->GetBinCenter(ix)
- + fHist[ihist]->GetXaxis()->GetBinWidth(ix);
- r2 = TMath::Max (r2,TMath::Sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0)));
- }
- }
- }
- cout << r1 << " " << r2 << endl;
- } // if (fHist[cath*2+1])
- if (r1 > r2) {
- //fHist[cath*2]->Draw("lego1");
- fHist[cath*2]->Draw("lego1Fb");
- //if (fHist[cath*2+1]) fHist[cath*2+1]->Draw("lego1SameAxisBb");
- if (fHist[cath*2+1]) fHist[cath*2+1]->Draw("lego1SameAxisBbFb");
- } else {
- //fHist[cath*2+1]->Draw("lego1");
- fHist[cath*2+1]->Draw("lego1Fb");
- //fHist[cath*2]->Draw("lego1SameAxisBb");
- fHist[cath*2]->Draw("lego1SameAxisFbBb");
- }
- c1->Update();
- } // if (fDraw)
- } // for (Int_t cath = 0;
-
- // Draw generated hits
- Double_t xNDC[6];
- hist = fHist[0] ? fHist[0] : fHist[2];
- p2[2] = hist->GetMaximum();
- view = 0;
- if (c1) view = c1->Pad()->GetView();
- cout << " *** GEANT hits *** " << endl;
- fnMu = 0;
- Int_t ix, iy, iok;
- for (Int_t i=0; i<ntracks; i++) {
- treeH->GetEvent(i);
- for (AliMUONHit* mHit=(AliMUONHit*)muon->FirstHit(-1);
- mHit;
- mHit=(AliMUONHit*)muon->NextHit()) {
- if (mHit->Chamber() != ch0+1) continue; // chamber number
- if (TMath::Abs(mHit->Z()-fZpad) > 1) continue; // different slat
- p2[0] = p1[0] = mHit->X(); // x-pos of hit
- p2[1] = p1[1] = mHit->Y(); // y-pos
- if (p1[0] < hist->GetXaxis()->GetXmin() ||
- p1[0] > hist->GetXaxis()->GetXmax()) continue;
- if (p1[1] < hist->GetYaxis()->GetXmin() ||
- p1[1] > hist->GetYaxis()->GetXmax()) continue;
- // Check if track comes thru pads with signal
- iok = 0;
- for (Int_t ihist=0; ihist<4; ihist++) {
- if (!fHist[ihist]) continue;
- ix = fHist[ihist]->GetXaxis()->FindBin(p1[0]);
- iy = fHist[ihist]->GetYaxis()->FindBin(p1[1]);
- if (fHist[ihist]->GetCellContent(ix,iy) > 0.5) {iok = 1; break;}
- }
- if (!iok) continue;
- gStyle->SetLineColor(1);
- if (TMath::Abs((Int_t)mHit->Particle()) == 13) {
- gStyle->SetLineColor(4);
- if (fnMu < 2) {
- fxyMu[fnMu][0] = p1[0];
- fxyMu[fnMu++][1] = p1[1];
- }
- }
- if (fDebug) printf(" X=%10.4f, Y=%10.4f, Z=%10.4f\n",p1[0],p1[1],mHit->Z());
- if (view) {
- // Take into account track angles
- p2[0] += mHit->Tlength() * TMath::Sin(mHit->Theta()/180*TMath::Pi())
- * TMath::Cos(mHit->Phi()/180*TMath::Pi()) / 2;
- p2[1] += mHit->Tlength() * TMath::Sin(mHit->Theta()/180*TMath::Pi())
- * TMath::Sin(mHit->Phi()/180*TMath::Pi()) / 2;
- view->WCtoNDC(p1, &xNDC[0]);
- view->WCtoNDC(p2, &xNDC[3]);
- for (Int_t ipad=1; ipad<3; ipad++) {
- c1->cd(ipad);
- //c1->DrawLine(xpad[0],xpad[1],xpad[3],xpad[4]);
- line[nLine] = new TLine(xNDC[0],xNDC[1],xNDC[3],xNDC[4]);
- line[nLine++]->Draw();
- }
- }
- } // for (AliMUONHit* mHit=
- } // for (Int_t i=0; i<ntracks;
-
- // Draw reconstructed coordinates
- TClonesArray *listMUONrawclust = data->RawClusters(ch0);
- AliMUONRawCluster *mRaw;
- gStyle->SetLineColor(3);
- cout << " *** Reconstructed hits *** " << endl;
- if (listMUONrawclust) {
- for (Int_t i=0; i<listMUONrawclust ->GetEntries(); i++) {
- mRaw = (AliMUONRawCluster*)listMUONrawclust ->UncheckedAt(i);
- if (TMath::Abs(mRaw->GetZ(0)-fZpad) > 1) continue; // different slat
- p2[0] = p1[0] = mRaw->GetX(0); // x-pos of hit
- p2[1] = p1[1] = mRaw->GetY(0); // y-pos
- if (p1[0] < hist->GetXaxis()->GetXmin() ||
- p1[0] > hist->GetXaxis()->GetXmax()) continue;
- if (p1[1] < hist->GetYaxis()->GetXmin() ||
- p1[1] > hist->GetYaxis()->GetXmax()) continue;
- /*
- treeD->GetEvent(cath);
- cout << mRaw->fMultiplicity[0] << mRaw->fMultiplicity[1] << endl;
- for (Int_t j=0; j<mRaw->fMultiplicity[cath]; j++) {
- Int_t digit = mRaw->fIndexMap[j][cath];
- cout << ((AliMUONDigit*)fMuonDigits->UncheckedAt(digit))->Signal() << endl;
- }
- */
- // Check if track comes thru pads with signal
- iok = 0;
- for (Int_t ihist=0; ihist<4; ihist++) {
- if (!fHist[ihist]) continue;
- ix = fHist[ihist]->GetXaxis()->FindBin(p1[0]);
- iy = fHist[ihist]->GetYaxis()->FindBin(p1[1]);
- if (fHist[ihist]->GetCellContent(ix,iy) > 0.5) {iok = 1; break;}
- }
- if (!iok) continue;
- if (fDebug) printf(" X=%10.4f, Y=%10.4f, Z=%10.4f\n",p1[0],p1[1],mRaw->GetZ(0));
- if (view) {
- view->WCtoNDC(p1, &xNDC[0]);
- view->WCtoNDC(p2, &xNDC[3]);
- for (Int_t ipad=1; ipad<3; ipad++) {
- c1->cd(ipad);
- line[nLine] = new TLine(xNDC[0],xNDC[1],xNDC[3],xNDC[4]);
- line[nLine++]->Draw();
- }
- }
- } // for (Int_t i=0; i<listMUONrawclust ->GetEntries();
- } // if (listMUONrawclust)
- c1->Update();
-}
-
-//_____________________________________________________________________________
-Int_t AliMUONClusterFinderAZ::Next(Int_t &nev0, Int_t &ch0)
-{
- // What to do next?
- // File
- FILE *lun = 0;
- //lun = fopen("pull.dat","w");
-
- for (Int_t i=0; i<fnMu; i++) {
- // Check again if muon come thru the used pads (due to extra splitting)
- for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
- if (TMath::Abs(fxyMu[i][0]-fXyq[0][j])<fXyq[3][j] &&
- TMath::Abs(fxyMu[i][1]-fXyq[1][j])<fXyq[4][j]) {
- if (fDebug) printf("%12.3e %12.3e %12.3e %12.3e\n",fxyMu[i][2],fxyMu[i][3],fxyMu[i][4],fxyMu[i][5]);
- if (lun) fprintf(lun,"%4d %2d %12.3e %12.3e %12.3e %12.3e\n",nev0,ch0,fxyMu[i][2],fxyMu[i][3],fxyMu[i][4],fxyMu[i][5]);
- break;
- }
- }
- } // for (Int_t i=0; i<fnMu;
-
- // What's next?
- char command[8];
- cout << " What is next? " << endl;
- command[0] = ' ';
- gets(command);
- if (command[0] == 'n' || command[0] == 'N') {nev0++; ch0 = 0; } // next event
- else if (command[0] == 'q' || command[0] == 'Q') { if (lun) fclose(lun); } // exit display
- else if (command[0] == 'c' || command[0] == 'C') sscanf(command+1,"%d",&ch0); // new chamber
- else if (command[0] == 'e' || command[0] == 'E') { sscanf(command+1,"%d",&nev0); ch0 = 0; } // new event
- else return 1; // Next precluster
- return 0;
-}
-
-
-//_____________________________________________________________________________
-void AliMUONClusterFinderAZ::ModifyHistos(void)
-{
- // Modify histograms to bring them to (approximately) the same size
- Int_t nhist = 0;
- Float_t hlim[4][4], hbin[4][4]; // first index - xmin, xmax, ymin, ymax
-
- Float_t binMin[4] = {999,999,999,999};
-
- for (Int_t i = 0; i < 4; i++) {
- if (!fHist[i]) {
- hlim[0][i] = hlim[2][i] = 999;
- hlim[1][i] = hlim[3][i] = -999;
- continue;
- }
- hlim[0][i] = fHist[i]->GetXaxis()->GetXmin(); // xmin
- hlim[1][i] = fHist[i]->GetXaxis()->GetXmax(); // xmax
- hlim[2][i] = fHist[i]->GetYaxis()->GetXmin(); // ymin
- hlim[3][i] = fHist[i]->GetYaxis()->GetXmax(); // ymax
- hbin[0][i] = hbin[1][i] = fHist[i]->GetXaxis()->GetBinWidth(1);
- hbin[2][i] = hbin[3][i] = fHist[i]->GetYaxis()->GetBinWidth(1);
- binMin[0] = TMath::Min(binMin[0],hbin[0][i]);
- binMin[2] = TMath::Min(binMin[2],hbin[2][i]);
- nhist++;
- }
- binMin[1] = binMin[0];
- binMin[3] = binMin[2];
- cout << " Nhist: " << nhist << endl;
-
- // Adjust histo limits for cathode with different segmentation
- for (Int_t i = 0; i < 4; i+=2) {
- if (!fHist[i+1]) continue;
- Int_t imin, imax, i1 = i + 1;
- for (Int_t lim = 0; lim < 4; lim++) {
- while (1) {
- if (hlim[lim][i] < hlim[lim][i1]) {
- imin = i;
- imax = i1;
- } else {
- imin = i1;
- imax = i;
- }
- if (TMath::Abs(hlim[lim][imin]-hlim[lim][imax])<0.01*binMin[lim]) break;
- if (lim == 0 || lim == 2) {
- // find lower limit
- hlim[lim][imax] -= hbin[lim][imax];
- } else {
- // find upper limit
- hlim[lim][imin] += hbin[lim][imin];
- }
- } // while (1)
- }
- }
-
-
- Int_t imnmx = 0, nExtra = 0;
- for (Int_t lim = 0; lim < 4; lim++) {
- if (lim == 0 || lim == 2) imnmx = TMath::LocMin(4,hlim[lim]); // find lower limit
- else imnmx = TMath::LocMax(4,hlim[lim]); // find upper limit
-
- // Adjust histogram limit
- for (Int_t i = 0; i < 4; i++) {
- if (!fHist[i]) continue;
- nExtra = TMath::Nint ((hlim[lim][imnmx]-hlim[lim][i]) / hbin[lim][i]);
- hlim[lim][i] += nExtra * hbin[lim][i];
- }
- }
-
- // Rebuild histograms
- TH2F *hist = 0;
- Int_t nx, ny;
- Double_t x, y, cont, cmax=0;
- char hName[4];
- for (Int_t ihist=0; ihist<4; ihist++) {
- if (!fHist[ihist]) continue;
- nx = TMath::Nint((hlim[1][ihist]-hlim[0][ihist])/hbin[0][ihist]);
- ny = TMath::Nint((hlim[3][ihist]-hlim[2][ihist])/hbin[2][ihist]);
- cout << ihist << " " << hlim[0][ihist] << " " << hlim[1][ihist] << " " << nx;
- cout << " " << hlim[2][ihist] << " " << hlim[3][ihist] << " " << ny << endl;
- sprintf(hName,"hh%d",ihist);
- hist = new TH2F(hName,"hist",nx,hlim[0][ihist],hlim[1][ihist],ny,hlim[2][ihist],hlim[3][ihist]);
- for (Int_t i=1; i<=fHist[ihist]->GetNbinsX(); i++) {
- x = fHist[ihist]->GetXaxis()->GetBinCenter(i);
- for (Int_t j=1; j<=fHist[ihist]->GetNbinsY(); j++) {
- y = fHist[ihist]->GetYaxis()->GetBinCenter(j);
- cont = fHist[ihist]->GetCellContent(i,j);
- hist->Fill(x,y,cont);
- }
- }
- cmax = TMath::Max (cmax,hist->GetMaximum());
- sprintf(hName,"%s%d",fHist[ihist]->GetName(),ihist);
- fHist[ihist]->Delete();
- fHist[ihist] = new TH2F(*hist);
- fHist[ihist]->SetName(hName);
- fHist[ihist]->SetNdivisions(505,"Z");
- hist->Delete();
- }
- if (fDebug) printf("%f \n",cmax);
-
- for (Int_t ihist=0; ihist<4; ihist++) {
- if (!fHist[ihist]) continue;
- fHist[ihist]->SetMaximum(cmax);
- fHist[ihist]->SetMinimum(0);
+ } // for (Int_t i=0; i<nMax;
+ if (nMax > 1) ((TH2D*) gROOT->FindObject("anode"))->Delete();
+ TH2D *mlem = (TH2D*) gROOT->FindObject("mlem");
+ if (mlem) mlem->Delete();
}
+ if (!fDraw || fDraw->Next()) goto next;
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AddPad(Int_t cath, Int_t digit)
{
- // Add pad to the cluster
- //AZ AliMUONDigit *mdig = (AliMUONDigit*)fMuonDigits->UncheckedAt(digit);
- AliMUONDigit *mdig = AliMUONClusterInput::Instance()->Digit(cath,digit); //AZ
+/// Add pad to the cluster
+
+ AliMUONDigit *mdig = fInput->Digit(cath,digit);
- Int_t charge = mdig->Signal();
+ Float_t charge = mdig->Signal();
// get the center of the pad
- Float_t xpad, ypad, zpad0; //, zpad;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad0);
-
- Int_t isec = fSegmentation[cath]->Sector(fInput->DetElemId(),mdig->PadX(), mdig->PadY());
+ Float_t xpad, ypad, zpad0;
+ //if (!fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad0)) { // Handle "non-existing" pads
+ if (!fSegmentation[cath]->HasPad(mdig->PadX(), mdig->PadY())) {
+ fUsed[cath][digit] = kTRUE;
+ return;
+ }
+ fSegmentation[cath]->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad0);
+ Int_t isec = fSegmentation[cath]->Sector(mdig->PadX(), mdig->PadY());
Int_t nPads = fnPads[0] + fnPads[1];
fXyq[0][nPads] = xpad;
fXyq[1][nPads] = ypad;
fXyq[2][nPads] = charge;
- fXyq[3][nPads] = fSegmentation[cath]->Dpx(fInput->DetElemId(),isec)/2;
- fXyq[4][nPads] = fSegmentation[cath]->Dpy(fInput->DetElemId(),isec)/2;
+ fXyq[3][nPads] = fSegmentation[cath]->Dpx(isec)/2;
+ fXyq[4][nPads] = fSegmentation[cath]->Dpy(isec)/2;
fXyq[5][nPads] = digit;
fXyq[6][nPads] = 0;
fPadIJ[0][nPads] = cath;
fPadIJ[1][nPads] = 0;
+ fPadIJ[2][nPads] = mdig->PadX();
+ fPadIJ[3][nPads] = mdig->PadY();
fUsed[cath][digit] = kTRUE;
- if (fDebug) printf(" bbb %d %d %f %f %f %f %f %d\n", nPads, cath, xpad, ypad, zpad0, fXyq[3][nPads]*2, fXyq[4][nPads]*2, charge);
+ if (fDebug) printf(" bbb %d %d %f %f %f %f %f %f %3d %3d \n", nPads, cath,
+ xpad, ypad, zpad0, fXyq[3][nPads]*2, fXyq[4][nPads]*2,
+ charge, mdig->PadX(), mdig->PadY());
fnPads[cath]++;
// Check neighbours
Int_t nn, ix, iy, xList[10], yList[10];
AliMUONDigit *mdig1;
- //AZ Int_t ndigits = fMuonDigits->GetEntriesFast();
- Int_t ndigits = AliMUONClusterInput::Instance()->NDigits(cath); //AZ
- fSegmentation[cath]->Neighbours(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),&nn,xList,yList);
- for (Int_t in=0; in<nn; in++) {
- ix=xList[in];
- iy=yList[in];
+ Int_t ndigits = fInput->NDigits(cath);
+ fSegmentation[cath]->Neighbours(mdig->PadX(), mdig->PadY(), &nn, xList, yList);
+ for (Int_t in = 0; in < nn; in++) {
+ ix = xList[in];
+ iy = yList[in];
for (Int_t digit1 = 0; digit1 < ndigits; digit1++) {
if (digit1 == digit) continue;
- //AZ mdig1 = (AliMUONDigit*)fMuonDigits->UncheckedAt(digit1);
- mdig1 = AliMUONClusterInput::Instance()->Digit(cath,digit1); //AZ
- //AZobsolete if (mdig1->Cathode() != cath) continue;
+ mdig1 = fInput->Digit(cath,digit1);
if (!fUsed[cath][digit1] && mdig1->PadX() == ix && mdig1->PadY() == iy) {
- //AZ--- temporary fix on edges
- //fSegmentation[cath]->GetPadC(mdig1->PadX(), mdig1->PadY(), xpad, ypad, zpad);
- //if (TMath::Abs(zpad-zpad0) > 0.5) continue;
- //AZ---
fUsed[cath][digit1] = kTRUE;
// Add pad - recursive call
AddPad(cath,digit1);
}
} //for (Int_t digit1 = 0;
- } // for (Int_t in=0;
+ } // for (Int_t in = 0;
}
//_____________________________________________________________________________
Bool_t AliMUONClusterFinderAZ::Overlap(Int_t cath, AliMUONDigit *mdig)
{
- // Check if the pad from one cathode overlaps with a pad
- // in the precluster on the other cathode
+/// Check if the pad from one cathode overlaps with a pad
+/// in the precluster on the other cathode
Float_t xpad, ypad, zpad;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),xpad,ypad,zpad);
- Int_t isec = fSegmentation[cath]->Sector(fInput->DetElemId(),mdig->PadX(), mdig->PadY());
+ fSegmentation[cath]->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
+ Int_t isec = fSegmentation[cath]->Sector(mdig->PadX(), mdig->PadY());
Float_t xy1[4], xy12[4];
- xy1[0] = xpad - fSegmentation[cath]->Dpx(fInput->DetElemId(),isec)/2;
- xy1[1] = xy1[0] + fSegmentation[cath]->Dpx(fInput->DetElemId(),isec);
- xy1[2] = ypad - fSegmentation[cath]->Dpy(fInput->DetElemId(),isec)/2;
- xy1[3] = xy1[2] + fSegmentation[cath]->Dpy(fInput->DetElemId(),isec);
+ xy1[0] = xpad - fSegmentation[cath]->Dpx(isec)/2;
+ xy1[1] = xy1[0] + fSegmentation[cath]->Dpx(isec);
+ xy1[2] = ypad - fSegmentation[cath]->Dpy(isec)/2;
+ xy1[3] = xy1[2] + fSegmentation[cath]->Dpy(isec);
//cout << " ok " << fnPads[0]+fnPads[1] << xy1[0] << xy1[1] << xy1[2] << xy1[3] << endl;
Int_t cath1 = TMath::Even(cath);
//_____________________________________________________________________________
Bool_t AliMUONClusterFinderAZ::Overlap(Float_t *xy1, Int_t iPad, Float_t *xy12, Int_t iSkip)
{
- // Check if the pads xy1 and iPad overlap and return overlap area
+/// Check if the pads xy1 and iPad overlap and return overlap area
Float_t xy2[4];
xy2[0] = fXyq[0][iPad] - fXyq[3][iPad];
return kTRUE;
}
-//_____________________________________________________________________________
-/*
-Bool_t AliMUONClusterFinderAZ::Overlap(Int_t i, Int_t j, Float_t *xy12, Int_t iSkip)
-{
- // Check if the pads i and j overlap and return overlap area
-
- Float_t xy1[4], xy2[4];
- return Overlap(xy1, xy2, xy12, iSkip);
-}
-*/
//_____________________________________________________________________________
Bool_t AliMUONClusterFinderAZ::CheckPrecluster(Int_t *nShown)
{
- // Check precluster in order to attempt to simplify it (mostly for
- // two-cathode preclusters)
+/// Check precluster in order to attempt to simplify it (mostly for
+/// two-cathode preclusters)
Int_t i1, i2, cath=0, digit=0;
Float_t xy1[4], xy12[4];
}
// If pads have the same size take average of pads on both cathodes
- Int_t sameSize = (fnPads[0] && fnPads[1]) ? 1 : 0;
+ //Int_t sameSize = (fnPads[0] && fnPads[1]) ? 1 : 0;
+ Int_t sameSize = 0; //AZ - 17-01-06
+
if (sameSize) {
Double_t xSize = -1, ySize = 0;
for (Int_t i=0; i<npad; i++) {
}
} // if (sameSize)
if (sameSize && fnPads[0] == 1 && fnPads[1] == 1) sameSize = 0; //AZ
+ // Handle shift by half a pad in Station 1
+ if (sameSize) {
+ Int_t cath0 = fPadIJ[0][0];
+ for (Int_t i = 1; i < npad; i++) {
+ if (fPadIJ[0][i] == cath0) continue;
+ Double_t dx = TMath::Abs ((fXyq[0][i] - fXyq[0][0]) / fXyq[3][i] / 2);
+ Int_t idx = (Int_t) TMath::Abs ((fXyq[0][i] - fXyq[0][0]) / fXyq[3][i] / 2);
+ if (TMath::Abs (dx - idx) > 0.001) sameSize = 0;
+ break;
+ }
+ } // if (sameSize)
+
if (sameSize && (fnPads[0] >= 2 || fnPads[1] >= 2)) {
nShown[0] += fnPads[0];
nShown[1] += fnPads[1];
// Flag that the digit from the other cathode
if (cath && div == 1) fXyq[5][fnPads[0]] = -fXyq[5][i] - 1;
// If low pad charge take the other equal to 0
- if (div == 1 && fXyq[2][fnPads[0]] < fResponse->ZeroSuppression() + 1.5*3) div = 2;
+ //if (div == 1 && fXyq[2][fnPads[0]] < fgkZeroSuppression + 1.5*3) div = 2;
fXyq[2][fnPads[0]] /= div;
fXyq[0][fnPads[0]] = fXyq[0][i];
fXyq[1][fnPads[0]] = fXyq[1][i];
+ fPadIJ[2][fnPads[0]] = fPadIJ[2][i];
+ fPadIJ[3][fnPads[0]] = fPadIJ[3][i];
fPadIJ[0][fnPads[0]++] = 0;
}
} // if (sameSize)
for (Int_t i=0; i<npad; i++) {
if (flags[i]) continue;
nFlags ++;
- if (fDebug) cout << i << " " << fPadIJ[0][i] << endl;
+ if (fDebug) cout << i << " " << fPadIJ[0][i] << " " << fXyq[0][i] << " " << fXyq[1][i] << endl;
}
if (fDebug && nFlags) cout << " nFlags = " << nFlags << endl;
//if (nFlags > 2 || (Float_t)nFlags / npad > 0.2) { // why 2 ??? - empirical choice
- if (nFlags > 1) {
+ if (nFlags > 0) {
for (Int_t i=0; i<npad; i++) {
if (flags[i]) continue;
digit = TMath::Nint (fXyq[5][i]);
cath = fPadIJ[0][i];
+ // Check for edge effect (missing pads on the other cathode)
+ Int_t cath1 = TMath::Even(cath), ix, iy;
+ ix = iy = 0;
+ //if (!fSegmentation[cath1]->GetPadI(fInput->DetElemId(),fXyq[0][i],fXyq[1][i],fZpad,ix,iy)) continue;
+ if (!fSegmentation[cath1]->HasPad(fXyq[0][i], fXyq[1][i], fZpad)) continue;
+ if (nFlags == 1 && fXyq[2][i] < fgkZeroSuppression * 3) continue;
fUsed[cath][digit] = kFALSE; // release pad
fXyq[2][i] = -2;
fnPads[cath]--;
}
+ if (fDraw) fDraw->UpdateCluster(npad);
} // if (nFlags > 2)
// Check correlations of cathode charges
for (Int_t i=0; i<npad; i++) {
cath = fPadIJ[0][i];
if (fXyq[2][i] > 0) sum[cath] += fXyq[2][i];
- //AZ if (fXyq[2][i] > fResponse->MaxAdc()-1) over[cath] = 0;
- if (fXyq[2][i] > fResponse->Saturation()-1) over[cath] = 0;
+ if (fXyq[2][i] > fgkSaturation-1) over[cath] = 0;
}
if (fDebug) cout << " Total charge: " << sum[0] << " " << sum[1] << endl;
if ((over[0] || over[1]) && TMath::Abs(sum[0]-sum[1])/(sum[0]+sum[1])*2 > 1) { // 3 times difference
if (fDebug) cout << " Release " << endl;
// Big difference
- cath = sum[0]>sum[1] ? 0 : 1;
- Int_t imax = 0;
- Double_t cmax=-1;
+ cath = sum[0] > sum[1] ? 0 : 1;
+ Int_t imax = 0, imin = 0;
+ Double_t cmax = -1, cmin = 9999, dxMin = 0, dyMin = 0;
Double_t *dist = new Double_t[npad];
- for (Int_t i=0; i<npad; i++) {
- if (fPadIJ[0][i] != cath) continue;
+ for (Int_t i = 0; i < npad; i++) {
+ if (fPadIJ[0][i] != cath || fXyq[2][i] < 0) continue;
+ if (fXyq[2][i] < cmin) {
+ cmin = fXyq[2][i];
+ imin = i;
+ }
if (fXyq[2][i] < cmax) continue;
cmax = fXyq[2][i];
imax = i;
}
// Arrange pads according to their distance to the max,
// normalized to the pad size
- for (Int_t i=0; i<npad; i++) {
+ for (Int_t i = 0; i < npad; i++) {
dist[i] = 0;
- if (fPadIJ[0][i] != cath) continue;
+ if (fPadIJ[0][i] != cath || fXyq[2][i] < 0) continue;
if (i == imax) continue;
- if (fXyq[2][i] < 0) continue;
- dist[i] = (fXyq[0][i]-fXyq[0][imax])*(fXyq[0][i]-fXyq[0][imax])/
- fXyq[3][imax]/fXyq[3][imax]/4;
- dist[i] += (fXyq[1][i]-fXyq[1][imax])*(fXyq[1][i]-fXyq[1][imax])/
- fXyq[4][imax]/fXyq[4][imax]/4;
- dist[i] = TMath::Sqrt (dist[i]);
+ Double_t dx = (fXyq[0][i] - fXyq[0][imax]) / fXyq[3][imax] / 2;
+ Double_t dy = (fXyq[1][i] - fXyq[1][imax]) / fXyq[4][imax] / 2;
+ dist[i] = TMath::Sqrt (dx * dx + dy * dy);
+ if (i == imin) {
+ cmin = dist[i] + 0.001; // distance to the pad with minimum charge
+ dxMin = dx;
+ dyMin = dy;
+ }
}
TMath::Sort(npad, dist, flags, kFALSE); // in increasing order
Int_t indx;
Double_t xmax = -1;
- for (Int_t i=0; i<npad; i++) {
+ for (Int_t i = 0; i < npad; i++) {
indx = flags[i];
- if (fPadIJ[0][indx] != cath) continue;
- if (fXyq[2][indx] < 0) continue;
- if (fXyq[2][indx] <= cmax || TMath::Abs(dist[indx]-xmax)<1.e-3) {
+ if (fPadIJ[0][indx] != cath || fXyq[2][indx] < 0) continue;
+ if (dist[indx] > cmin) {
+ // Farther than the minimum pad
+ Double_t dx = (fXyq[0][indx] - fXyq[0][imax]) / fXyq[3][imax] / 2;
+ Double_t dy = (fXyq[1][indx] - fXyq[1][imax]) / fXyq[4][imax] / 2;
+ dx *= dxMin;
+ dy *= dyMin;
+ if (dx >= 0 && dy >= 0) continue;
+ if (TMath::Abs(dx) > TMath::Abs(dy) && dx >= 0) continue;
+ if (TMath::Abs(dy) > TMath::Abs(dx) && dy >= 0) continue;
+ }
+ if (fXyq[2][indx] <= cmax || TMath::Abs(dist[indx]-xmax) < 1.e-3) {
// Release pads
- if (TMath::Abs(dist[indx]-xmax)<1.e-3)
+ if (TMath::Abs(dist[indx]-xmax) < 1.e-3)
cmax = TMath::Max((Double_t)(fXyq[2][indx]),cmax);
else cmax = fXyq[2][indx];
xmax = dist[indx];
fUsed[cath][digit] = kFALSE;
fXyq[2][indx] = -2;
fnPads[cath]--;
- // xmax = dist[i]; // Bug?
- } else {
- // Check pad overlaps once more
- for (Int_t i=0; i<npad; i++) flags[i] = 0;
- for (Int_t i=0; i<npad; i++) {
- if (fXyq[2][i] < 0) continue;
- if (fPadIJ[0][i] != i1) continue;
- xy1[0] = fXyq[0][i] - fXyq[3][i];
- xy1[1] = fXyq[0][i] + fXyq[3][i];
- xy1[2] = fXyq[1][i] - fXyq[4][i];
- xy1[3] = fXyq[1][i] + fXyq[4][i];
- for (Int_t j=0; j<npad; j++) {
- if (fXyq[2][j] < 0) continue;
- if (fPadIJ[0][j] != i2) continue;
- if (!Overlap(xy1, j, xy12, 0)) continue;
- flags[i] = flags[j] = 1; // mark overlapped pads
- } // for (Int_t j=0;
- } // for (Int_t i=0;
- nFlags=0;
- for (Int_t i=0; i<npad; i++) {
- if (fXyq[2][i] < 0 || flags[i]) continue;
- nFlags ++;
- }
- if (nFlags == fnPads[0] + fnPads[1]) {
- // No overlap
- for (Int_t i=0; i<npad; i++) {
- if (fXyq[2][i] < 0 || fPadIJ[0][i] != cath) continue;
- fXyq[2][i] = -2;
- fnPads[cath]--;
- }
- }
- break;
+ }
+ } // for (Int_t i = 0; i < npad;
+
+ // Check pad overlaps once more
+ for (Int_t j = 0; j < npad; j++) flags[j] = 0;
+ for (Int_t k = 0; k < npad; k++) {
+ if (fXyq[2][k] < 0 || fPadIJ[0][k] != i1) continue;
+ xy1[0] = fXyq[0][k] - fXyq[3][k];
+ xy1[1] = fXyq[0][k] + fXyq[3][k];
+ xy1[2] = fXyq[1][k] - fXyq[4][k];
+ xy1[3] = fXyq[1][k] + fXyq[4][k];
+ for (Int_t j = 0; j < npad; j++) {
+ if (fXyq[2][j] < 0) continue;
+ if (fPadIJ[0][j] != i2) continue;
+ if (!Overlap(xy1, j, xy12, 0)) continue;
+ flags[k] = flags[j] = 1; // mark overlapped pads
+ } // for (Int_t j = 0;
+ } // for (Int_t k = 0;
+ nFlags = 0;
+ for (Int_t j = 0; j < npad; j++) {
+ if (fXyq[2][j] < 0 || flags[j]) continue;
+ nFlags ++;
+ }
+ if (nFlags == fnPads[0] + fnPads[1]) {
+ // No overlap
+ for (Int_t j = 0; j < npad; j++) {
+ if (fXyq[2][j] < 0 || fPadIJ[0][j] != cath) continue;
+ fXyq[2][j] = -2;
+ fnPads[cath]--;
}
- }
+ }
delete [] dist; dist = 0;
+ if (fDraw) fDraw->UpdateCluster(npad);
} // TMath::Abs(sum[0]-sum[1])...
} // if (fnPads[0] && fnPads[1])
delete [] flags; flags = 0;
for (Int_t j=end; j>beg; j--) {
if (fXyq[2][j] < 0) continue;
end = j - 1;
- for (Int_t j1=0; j1<2; j1++) {
+ for (Int_t j1=0; j1<4; j1++) {
padij = fPadIJ[j1][beg];
fPadIJ[j1][beg] = fPadIJ[j1][j];
fPadIJ[j1][j] = padij;
beg++;
} // while
npad = fnPads[0] + fnPads[1];
- if (npad > 500) { cout << " ***** Too large cluster. Give up. " << npad << endl; return kFALSE; }
+ if (npad > 500) {
+ AliWarning(Form(" *** Too large cluster. Give up. %d ", npad));
+ return kFALSE;
+ }
// Back up charge value
- for (Int_t j=0; j<npad; j++) fXyq[6][j] = fXyq[2][j];
+ for (Int_t j = 0; j < npad; j++) fXyq[6][j] = fXyq[2][j];
return kTRUE;
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::BuildPixArray()
{
- // Build pixel array for MLEM method
+/// Build pixel array for MLEM method
Int_t nPix=0, i1, i2;
Float_t xy1[4], xy12[4];
nPix++;
}
} else { // two-cathode precluster
- for (Int_t i=0; i<npad; i++) {
+ i1 = fPadIJ[0][0];
+ i2 = TMath::Even (i1);
+ for (Int_t i = 0; i < npad; i++) {
if (fPadIJ[0][i] != i1) continue;
xy1[0] = fXyq[0][i] - fXyq[3][i];
xy1[1] = fXyq[0][i] + fXyq[3][i];
xy1[2] = fXyq[1][i] - fXyq[4][i];
xy1[3] = fXyq[1][i] + fXyq[4][i];
- for (Int_t j=0; j<npad; j++) {
+ for (Int_t j = 1; j < npad; j++) {
if (fPadIJ[0][j] != i2) continue;
if (!Overlap(xy1, j, xy12, 1)) continue;
pixPtr = new AliMUONPixel();
} // for (Int_t i=0;
} // else
- Float_t wxmin=999, wymin=999;
- for (Int_t i=0; i<npad; i++) {
- //if (fPadIJ[0][i] == i1) wymin = TMath::Min (wymin,fXyq[4][i]);
- //if (fPadIJ[0][i] == i2) wxmin = TMath::Min (wxmin,fXyq[3][i]);
- wymin = TMath::Min (wymin,fXyq[4][i]);
- wxmin = TMath::Min (wxmin,fXyq[3][i]);
+ Float_t xPadMin = 999, yPadMin = 999;
+ for (Int_t i = 0; i < npad; i++) {
+ xPadMin = TMath::Min (xPadMin, fXyq[3][i]);
+ yPadMin = TMath::Min (yPadMin, fXyq[4][i]);
+ }
+ if (fDebug) cout << xPadMin << " " << yPadMin << endl;
+
+ Float_t wxmin = 999, wymin = 999;
+ for (Int_t i = 0; i < nPix; i++) {
+ pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
+ wxmin = TMath::Min ((Double_t)wxmin, pixPtr->Size(0));
+ wymin = TMath::Min ((Double_t)wymin, pixPtr->Size(1));
}
if (fDebug) cout << wxmin << " " << wymin << endl;
+ wxmin = TMath::Abs (wxmin - xPadMin/2) > 0.001 ? xPadMin : xPadMin / 2;
+ wymin = TMath::Abs (wymin - yPadMin/2) > 0.001 ? yPadMin : yPadMin / 2;
+ //wxmin = xPadMin; wymin = yPadMin;
// Check if small pixel X-size
AdjustPixel(wxmin, 0);
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AdjustPixel(Float_t width, Int_t ixy)
{
- // Check if some pixels have small size (adjust if necessary)
+/// Check if some pixels have small size (adjust if necessary)
AliMUONPixel *pixPtr, *pixPtr1 = 0;
Int_t ixy1 = TMath::Even(ixy);
if (TMath::Abs(pixPtr1->Coord(ixy1)-pixPtr->Coord(ixy1)) > 1.e-4) continue; // different rows/columns
if (TMath::Abs(pixPtr1->Coord(ixy)-pixPtr->Coord(ixy)) < 2*width) {
// merge
- //AZ-problem in slats for new segment. pixPtr->SetCoord(ixy, (pixPtr->Coord(ixy)+pixPtr1->Coord(ixy))/2);
Double_t tmp = pixPtr->Coord(ixy) + pixPtr1->Size(ixy) *
TMath::Sign (1., pixPtr1->Coord(ixy) - pixPtr->Coord(ixy));
pixPtr->SetCoord(ixy, tmp);
if (fDebug) cout << " Edge ..." << endl;
for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
//if (fPadIJ[0][j] != ixy1) continue;
- if (TMath::Abs(pixPtr->Coord(ixy1)-fXyq[ixy1][j]) > 1.e-4) continue;
+ //???-check if (TMath::Abs(pixPtr->Coord(ixy1)-fXyq[ixy1][j]) > 1.e-4) continue;
if (pixPtr->Coord(ixy) < fXyq[ixy][j])
//pixPtr->Shift(ixy, -pixPtr->Size(ixy));
pixPtr->Shift(ixy, pixPtr->Size(ixy)-width);
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AdjustPixel(Float_t wxmin, Float_t wymin)
{
- // Check if some pixels have large size (adjust if necessary)
+/// Check if some pixels have large size (adjust if necessary)
- Int_t nx, ny;
- Int_t nPix = fPixArray->GetEntriesFast();
- AliMUONPixel *pixPtr, *pixPtr1, pix;
+ Int_t n1[2], n2[2], iOK = 1, nPix = fPixArray->GetEntriesFast();
+ AliMUONPixel *pixPtr, pix;
+ Double_t xy0[2] = {9999, 9999}, wxy[2], dist[2] = {0};
// Check if large pixel size
- for (Int_t i=0; i<nPix; i++) {
+ for (Int_t i = 0; i < nPix; i++) {
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
if (pixPtr->Charge() < 1) continue; // discarded pixel
- if (pixPtr->Size(0)-wxmin > 1.e-4 || pixPtr->Size(1)-wymin > 1.e-4) {
- if (fDebug) cout << " Different " << pixPtr->Size(0) << " " << wxmin << " " << pixPtr->Size(1) << " " << wymin << endl;
- pix = *pixPtr;
- nx = TMath::Nint (pix.Size(0)/wxmin);
- ny = TMath::Nint (pix.Size(1)/wymin);
- pix.Shift(0, -pix.Size(0)-wxmin);
- pix.Shift(1, -pix.Size(1)-wymin);
- pix.SetSize(0, wxmin);
- pix.SetSize(1, wymin);
- for (Int_t ii=0; ii<nx; ii++) {
- pix.Shift(0, wxmin*2);
- for (Int_t jj=0; jj<ny; jj++) {
- pix.Shift(1, wymin*2);
- pixPtr1 = new AliMUONPixel(pix);
- fPixArray->Add((TObject*)pixPtr1);
- }
+ if (pixPtr->Size(0) - wxmin < 1.e-4) {
+ if (xy0[0] > 9998) xy0[0] = pixPtr->Coord(0); // position of a "normal" pixel
+ if (pixPtr->Size(1) - wymin < 1.e-4) {
+ if (xy0[1] > 9998) xy0[1] = pixPtr->Coord(1); // position of a "normal" pixel
+ continue;
+ } else iOK = 0; // large pixel
+ } else {
+ iOK = 0; // large pixel
+ if (xy0[1] > 9998 && pixPtr->Size(1) - wymin < 1.e-4) xy0[1] = pixPtr->Coord(1); // "normal" pixel
+ }
+ if (xy0[0] < 9998 && xy0[1] < 9998) break;
+ }
+ if (iOK) return;
+
+ wxy[0] = wxmin;
+ wxy[1] = wymin;
+ //cout << xy0[0] << " " << xy0[1] << endl;
+ for (Int_t i = 0; i < nPix; i++) {
+ pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
+ if (pixPtr->Charge() < 1) continue; // discarded pixel
+ n1[0] = n1[1] = 999;
+ n2[0] = n2[1] = 1;
+ for (Int_t j = 0; j < 2; j++) {
+ if (pixPtr->Size(j) - wxy[j] < 1.e-4) continue;
+ dist[j] = (pixPtr->Coord(j) - xy0[j]) / wxy[j] / 2; // normalized distance to "normal" pixel
+ n2[j] = TMath::Nint (pixPtr->Size(j) / wxy[j]);
+ n1[j] = n2[j] == 1 ? TMath::Nint(dist[j]) : (Int_t)dist[j];
+ }
+ if (n1[0] > 998 && n1[1] > 998) continue;
+ if (fDebug) cout << " Different " << pixPtr->Size(0) << " " << wxy[0] << " "
+ << pixPtr->Size(1) << " " << wxy[1] <<endl;
+
+ if (n2[0] > 2 || n2[1] > 2) {
+ //cout << n2[0] << " " << n2[1] << endl;
+ if (n2[0] > 2 && n1[0] < 999) n1[0]--;
+ if (n2[1] > 2 && n1[1] < 999) n1[1]--;
+ }
+ //cout << n1[0] << " " << n2[0] << " " << n1[1] << " " << n2[1] << endl;
+ pix = *pixPtr;
+ pix.SetSize(0, wxy[0]); pix.SetSize(1, wxy[1]);
+ //pixPtr->Print();
+ for (Int_t ii = 0; ii < n2[0]; ii++) {
+ if (n1[0] < 999) pix.SetCoord(0, xy0[0] + (n1[0] + TMath::Sign(1.,dist[0]) * ii) * 2 * wxy[0]);
+ for (Int_t jj = 0; jj < n2[1]; jj++) {
+ if (n1[1] < 999) pix.SetCoord(1, xy0[1] + (n1[1] + TMath::Sign(1.,dist[1]) * jj) * 2 * wxy[1]);
+ fPixArray->Add(new AliMUONPixel(pix));
+ //pix.Print();
}
- pixPtr->SetCharge(0);
}
- } // for (Int_t i=0; i<nPix;
- return;
+ pixPtr->SetCharge(0);
+ } // for (Int_t i = 0; i < nPix;
}
//_____________________________________________________________________________
Bool_t AliMUONClusterFinderAZ::MainLoop(Int_t iSimple)
{
- // Repeat MLEM algorithm until pixel size becomes sufficiently small
+/// Repeat MLEM algorithm until pixel size becomes sufficiently small
TH2D *mlem;
Double_t *coef = 0, *probi = 0;
AddVirtualPad(); // add virtual pads if necessary
Int_t npadTot = fnPads[0] + fnPads[1], npadOK = 0;
- for (Int_t i=0; i<npadTot; i++) if (fPadIJ[1][i] == 0) npadOK++;
+ for (Int_t i = 0; i < npadTot; i++) if (fPadIJ[1][i] == 0) npadOK++;
+ if (fDraw) fDraw->ResetMuon();
while (1) {
indx = j*nPix;
if (fPadIJ[1][j] == 0) {
cath = fPadIJ[0][j];
- fSegmentation[cath]->GetPadI(fInput->DetElemId(),fXyq[0][j],fXyq[1][j],fZpad,ix,iy);
- fSegmentation[cath]->SetPad(fInput->DetElemId(),ix,iy);
+ ix = fPadIJ[2][j];
+ iy = fPadIJ[3][j];
+ fSegmentation[cath]->SetPad(ix, iy);
/*
fSegmentation[cath]->Neighbours(fInput->DetElemId(),ix,iy,&nn,xList,yList);
if (nn != 4) {
indx1 = indx + ipix;
if (fPadIJ[1][j] < 0) { coef[indx1] = 0; continue; }
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(ipix);
- fSegmentation[cath]->SetHit(fInput->DetElemId(),pixPtr->Coord(0),pixPtr->Coord(1),fZpad);
- coef[indx1] = fResponse->IntXY(fInput->DetElemId(),fSegmentation[cath]);
+ fSegmentation[cath]->SetHit(pixPtr->Coord(0), pixPtr->Coord(1), fZpad);
+ coef[indx1] = fInput->Mathieson()->IntXY(fInput->DetElemId(),fInput->Segmentation2(cath));
probi[ipix] += coef[indx1];
} // for (Int_t ipix=0;
} // for (Int_t j=0;
Double_t xylim[4] = {999, 999, 999, 999};
for (Int_t ipix=0; ipix<nPix; ipix++) {
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(ipix);
+ //cout << ipix+1; pixPtr->Print();
for (Int_t i=0; i<4; i++)
xylim[i] = TMath::Min (xylim[i], (i%2 ? -1 : 1)*pixPtr->Coord(i/2));
- //cout << ipix+1; pixPtr->Print();
}
for (Int_t i=0; i<4; i++) {
xylim[i] -= pixPtr->Size(i/2); if (fDebug) cout << (i%2 ? -1 : 1)*xylim[i] << " "; }
// Adjust histogram to approximately the same limits as for the pads
// (for good presentation)
- //*
- Float_t xypads[4];
- if (fHist[0]) {
- xypads[0] = fHist[0]->GetXaxis()->GetXmin();
- xypads[1] = -fHist[0]->GetXaxis()->GetXmax();
- xypads[2] = fHist[0]->GetYaxis()->GetXmin();
- xypads[3] = -fHist[0]->GetYaxis()->GetXmax();
- for (Int_t i=0; i<4; i++) {
- while(1) {
- if (xylim[i] < xypads[i]) break;
- xylim[i] -= 2*pixPtr->Size(i/2);
- }
- }
- } // if (fHist[0])
- //*/
+ if (fDraw) fDraw->AdjustHist(xylim, pixPtr);
+
Int_t nx = TMath::Nint ((-xylim[1]-xylim[0])/pixPtr->Size(0)/2);
Int_t ny = TMath::Nint ((-xylim[3]-xylim[2])/pixPtr->Size(1)/2);
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(ipix);
mlem->Fill(pixPtr->Coord(0),pixPtr->Coord(1),pixPtr->Charge());
}
- //gPad->GetCanvas()->cd(3);
- if (fDraw) {
- ((TCanvas*)gROOT->FindObject("c2"))->cd();
- gPad->SetTheta(55);
- gPad->SetPhi(30);
- //mlem->SetFillColor(19);
- mlem->Draw("lego1Fb");
- gPad->Update();
- gets((char*)&ix);
- }
+ if (fDraw) fDraw->DrawHist("c2", mlem);
// Check if the total charge of pixels is too low
Double_t qTot = 0;
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
qTot += pixPtr->Charge();
}
- //AZif (qTot < 1.e-4 || npadOK < 3 && qTot < 50) {
if (qTot < 1.e-4 || npadOK < 3 && qTot < 7) {
delete [] coef; delete [] probi; coef = 0; probi = 0;
fPixArray->Delete();
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
sum1 += pixPtr->Charge()*coef[j*nPix+i];
}
- //AZsum1 = TMath::Min (sum1,(Double_t)fResponse->MaxAdc());
- sum1 = TMath::Min (sum1,(Double_t)fResponse->Saturation());
+ sum1 = TMath::Min (sum1,fgkSaturation);
x = fXyq[0][j];
y = fXyq[1][j];
cath = fPadIJ[0][j];
if (iSimple) {
// Simple cluster - skip further passes thru EM-procedure
- fxyMu[0][6] = fxyMu[1][6] = 9999;
Simple();
delete [] coef; delete [] probi; coef = 0; probi = 0;
fPixArray->Delete();
// if (probi[i] < 1.9) pixPtr->SetCharge(-charge);
//}
//AZ else if (probi[i] < cmax*0.9) pixPtr->SetCharge(-charge);
- else if (probi[i] < cmax*0.8) pixPtr->SetCharge(-charge);
+ //18-01-06 else if (probi[i] < cmax*0.8) pixPtr->SetCharge(-charge);
//cout << i << " " << pixPtr->Coord(0) << " " << pixPtr->Coord(1) << " " << charge << " " << probi[i] << endl;
}
// Move charge of removed pixels to their nearest neighbour (to keep total charge the same)
iy = mlem->GetYaxis()->FindBin(pixPtr->Coord(1));
mlem->SetBinContent(ix, iy, pixPtr->Charge());
}
- if (fDraw) {
- ((TCanvas*)gROOT->FindObject("c2"))->cd();
- gPad->SetTheta(55);
- gPad->SetPhi(30);
- mlem->Draw("lego1Fb");
- gPad->Update();
- }
+ if (fDraw) fDraw->DrawHist("c2", mlem);
- fxyMu[0][6] = fxyMu[1][6] = 9999;
// Try to split into clusters
Bool_t ok = kTRUE;
if (mlem->GetSum() < 1) ok = kFALSE;
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Mlem(Double_t *coef, Double_t *probi, Int_t nIter)
{
- // Use MLEM to find pixel charges
+/// Use MLEM to find pixel charges
Int_t nPix = fPixArray->GetEntriesFast();
Int_t npad = fnPads[0] + fnPads[1];
pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(i);
sum1 += pixPtr->Charge()*coef[indx1+i];
} // for (Int_t i=0;
- //AZ if (fXyq[2][j] > fResponse->MaxAdc()-1 && sum1 > fResponse->MaxAdc()) { probi1[ipix] -= coef[indx]; continue; } // correct for pad charge overflows
- if (fXyq[2][j] > fResponse->Saturation()-1 && sum1 > fResponse->Saturation()) { probi1[ipix] -= coef[indx]; continue; } // correct for pad charge overflows
+ if (fXyq[2][j] > fgkSaturation-1 && sum1 > fXyq[2][j]) { probi1[ipix] -= coef[indx]; continue; } // correct for pad charge overflows
//cout << sum1 << " " << fXyq[2][j] << " " << coef[j*nPix+ipix] << endl;
if (coef[indx] > 1.e-6) sum += fXyq[2][j]*coef[indx]/sum1;
} // for (Int_t j=0;
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::FindCOG(TH2D *mlem, Double_t *xyc)
{
- // Calculate position of the center-of-gravity around the maximum pixel
+/// Calculate position of the center-of-gravity around the maximum pixel
Int_t ixmax, iymax, ix, nsumx=0, nsumy=0, nsum=0;
Int_t i1 = -9, j1 = -9;
Double_t x, y, cont, xq=0, yq=0, qq=0;
for (Int_t i=TMath::Max(1,iymax-1); i<=TMath::Min(ny,iymax+1); i++) {
- //for (Int_t i=TMath::Max(1,iymax-9); i<=TMath::Min(ny,iymax+9); i++) {
y = mlem->GetYaxis()->GetBinCenter(i);
for (Int_t j=TMath::Max(1,ixmax-1); j<=TMath::Min(nx,ixmax+1); j++) {
- //for (Int_t j=TMath::Max(1,ixmax-9); j<=TMath::Min(nx,ixmax+9); j++) {
cont = mlem->GetCellContent(j,i);
if (cont < thresh) continue;
if (i != i1) {i1 = i; nsumy++;}
//_____________________________________________________________________________
Int_t AliMUONClusterFinderAZ::FindNearest(AliMUONPixel *pixPtr0)
{
- // Find the pixel nearest to the given one
- // (algorithm may be not very efficient)
+/// Find the pixel nearest to the given one
+/// (algorithm may be not very efficient)
Int_t nPix = fPixArray->GetEntriesFast(), imin = 0;
Double_t rmin = 99999, dx = 0, dy = 0, r = 0;
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Split(TH2D *mlem, Double_t *coef)
{
- // The main steering function to work with clusters of pixels in anode
- // plane (find clusters, decouple them from each other, merge them (if
- // necessary), pick up coupled pads, call the fitting function)
+/// The main steering function to work with clusters of pixels in anode
+/// plane (find clusters, decouple them from each other, merge them (if
+/// necessary), pick up coupled pads, call the fitting function)
Int_t nx = mlem->GetNbinsX();
Int_t ny = mlem->GetNbinsY();
// Exclude pads with overflows
for (Int_t j=0; j<npad; j++) {
- //AZ if (fXyq[2][j] > fResponse->MaxAdc()-1) fPadIJ[1][j] = -5;
- if (fXyq[2][j] > fResponse->Saturation()-1) fPadIJ[1][j] = -5;
+ if (fXyq[2][j] > fgkSaturation-1) fPadIJ[1][j] = -5;
else fPadIJ[1][j] = 0;
}
Merge(nForFit, nCoupled, clustNumb, clustFit, clusters, aijcluclu, aijclupad);
} else {
// Do the fit
- nfit = Fit(nForFit, clustFit, clusters, parOk);
+ nfit = Fit(0, nForFit, clustFit, clusters, parOk);
}
// Subtract the fitted charges from pads with strong coupling and/or
} // while (nCoupled > 0)
} // for (Int_t igroup=0; igroup<nclust;
- //delete aij_clu; aij_clu = 0; delete aijclupad; aijclupad = 0;
aijcluclu->Delete(); aijclupad->Delete();
for (Int_t iclust=0; iclust<nclust; iclust++) {
pix = clusters[iclust];
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AddBin(TH2D *mlem, Int_t ic, Int_t jc, Int_t mode, Bool_t *used, TObjArray *pix)
{
- // Add a bin to the cluster
+/// Add a bin to the cluster
Int_t nx = mlem->GetNbinsX();
Int_t ny = mlem->GetNbinsY();
//_____________________________________________________________________________
TObject* AliMUONClusterFinderAZ::BinToPix(TH2D *mlem, Int_t jc, Int_t ic)
{
- // Translate histogram bin to pixel
+/// Translate histogram bin to pixel
Double_t yc = mlem->GetYaxis()->GetBinCenter(ic);
Double_t xc = mlem->GetXaxis()->GetBinCenter(jc);
Int_t nPix = fPixArray->GetEntriesFast();
- AliMUONPixel *pixPtr;
+ AliMUONPixel *pixPtr = NULL;
// Compare pixel and bin positions
for (Int_t i=0; i<nPix; i++) {
if (pixPtr->Charge() < 0.5) continue;
if (TMath::Abs(pixPtr->Coord(0)-xc)<1.e-4 && TMath::Abs(pixPtr->Coord(1)-yc)<1.e-4) return (TObject*) pixPtr;
}
- AliWarning(Form(" Something wrong ??? %f %f ", xc, yc));
+ AliError(Form(" Something wrong ??? %f %f ", xc, yc));
return NULL;
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AddCluster(Int_t ic, Int_t nclust, TMatrixD *aijcluclu, Bool_t *used, Int_t *clustNumb, Int_t &nCoupled)
{
- // Add a cluster to the group of coupled clusters
+/// Add a cluster to the group of coupled clusters
for (Int_t i=0; i<nclust; i++) {
if (used[i]) continue;
//_____________________________________________________________________________
Double_t AliMUONClusterFinderAZ::MinGroupCoupl(Int_t nCoupled, Int_t *clustNumb, TMatrixD *aijcluclu, Int_t *minGroup)
{
- // Find group of clusters with minimum coupling to all the others
+/// Find group of clusters with minimum coupling to all the others
Int_t i123max = TMath::Min(3,nCoupled/2);
Int_t indx, indx1, indx2, indx3, nTot = 0;
//_____________________________________________________________________________
Int_t AliMUONClusterFinderAZ::SelectPad(Int_t nCoupled, Int_t nForFit, Int_t *clustNumb, Int_t *clustFit, TMatrixD *aijclupad)
{
- // Select pads for fit. If too many coupled clusters, find pads giving
- // the strongest coupling with the rest of clusters and exclude them from the fit.
+/// Select pads for fit. If too many coupled clusters, find pads giving
+/// the strongest coupling with the rest of clusters and exclude them from the fit.
Int_t npad = fnPads[0] + fnPads[1];
Double_t *padpix = 0;
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Merge(Int_t nForFit, Int_t nCoupled, Int_t *clustNumb, Int_t *clustFit, TObjArray **clusters, TMatrixD *aijcluclu, TMatrixD *aijclupad)
{
- // Merge the group of clusters with the one having the strongest coupling with them
+/// Merge the group of clusters with the one having the strongest coupling with them
Int_t indx, indx1, npxclu, npxclu1, imax=0;
TObjArray *pix, *pix1;
}
//_____________________________________________________________________________
-Int_t AliMUONClusterFinderAZ::Fit(Int_t nfit, Int_t *clustFit, TObjArray **clusters, Double_t *parOk)
+Int_t AliMUONClusterFinderAZ::Fit(Int_t iSimple, Int_t nfit, Int_t *clustFit, TObjArray **clusters, Double_t *parOk)
{
- // Find selected clusters to selected pad charges
+/// Find selected clusters to selected pad charges
TH2D *mlem = (TH2D*) gROOT->FindObject("mlem");
- //Int_t nx = mlem->GetNbinsX();
- //Int_t ny = mlem->GetNbinsY();
Double_t xmin = mlem->GetXaxis()->GetXmin() - mlem->GetXaxis()->GetBinWidth(1);
Double_t xmax = mlem->GetXaxis()->GetXmax() + mlem->GetXaxis()->GetBinWidth(1);
Double_t ymin = mlem->GetYaxis()->GetXmin() - mlem->GetYaxis()->GetBinWidth(1);
Double_t ymax = mlem->GetYaxis()->GetXmax() + mlem->GetYaxis()->GetBinWidth(1);
- //Double_t qmin = 0, qmax = 1;
Double_t step[3]={0.01,0.002,0.02}, xPad = 0, yPad = 99999;
- Double_t qPad[2] = {0}, xyqPad[2] = {0};
// Number of pads to use and number of virtual pads
- Int_t npads = 0, nVirtual = 0;
+ Int_t npads = 0, nVirtual = 0, nfit0 = nfit;
for (Int_t i=0; i<fnPads[0]+fnPads[1]; i++) {
- if (fPadIJ[1][i] == -9 || fPadIJ[1][i] == 1) {
- if (fPadIJ[0][i]) xyqPad[1] += fXyq[0][i] * fXyq[2][i];
- else xyqPad[0] += fXyq[1][i] * fXyq[2][i];
- qPad[fPadIJ[0][i]] += fXyq[2][i];
- }
if (fXyq[3][i] < 0) nVirtual++;
if (fPadIJ[1][i] != 1) continue;
- if (fXyq[3][i] > 0) npads++;
- if (yPad > 9999) { xPad = fXyq[0][i]; yPad = fXyq[1][i]; }
- //if (fPadIJ[0][i]) xPad = fXyq[0][i];
+ if (fXyq[3][i] > 0) {
+ npads++;
+ if (yPad > 9999) {
+ xPad = fXyq[0][i];
+ yPad = fXyq[1][i];
+ } else {
+ if (fXyq[4][i] < fXyq[3][i]) yPad = fXyq[1][i];
+ else xPad = fXyq[0][i];
+ }
+ }
}
if (fDebug) {
for (Int_t i=0; i<nfit; i++) {cout << i+1 << " " << clustFit[i] << " ";}
fNpar = 0;
fQtot = 0;
if (npads < 2) return 0;
-
- Int_t digit = 0, nfit0 = nfit;
+
+ Int_t digit = 0;
AliMUONDigit *mdig = 0;
Int_t tracks[3] = {-1, -1, -1};
for (Int_t cath=0; cath<2; cath++) {
tracks[1] = mdig->Track(0);
}
}
- //AZif (mdig->Track(1)) {
if (mdig->Track(1) >= 0 && mdig->Track(1) != tracks[1]) {
if (tracks[2] < 0) tracks[2] = mdig->Track(1);
else tracks[2] = TMath::Min (tracks[2], mdig->Track(1));
// Get number of pads in X and Y
Int_t nInX = 0, nInY;
PadsInXandY(nInX, nInY);
+ //cout << " nInX and Y: " << nInX << " " << nInY << endl;
+
+ Int_t nfitMax = 3;
+ nfitMax = TMath::Min (nfitMax, (npads + 1) / 3);
+ if (nfitMax > 1) {
+ if (nInX < 3 && nInY < 3 || nInX == 3 && nInY < 3 || nInX < 3 && nInY == 3) nfitMax = 1; // not enough pads in each direction
+ }
+ if (nfit > nfitMax) nfit = nfitMax;
// Take cluster maxima as fitting seeds
TObjArray *pix;
AliMUONPixel *pixPtr;
Int_t npxclu;
Double_t cont, cmax = 0, xseed = 0, yseed = 0, errOk[8], qq = 0;
- Double_t xyseed[3][2], qseed[3], xy_Cand[3][2] = {{0},{0}}, sig_Cand[3][2] = {{0},{0}};
+ Double_t xyseed[3][2], qseed[3], xyCand[3][2] = {{0},{0}}, sigCand[3][2] = {{0},{0}};
- for (Int_t ifit=1; ifit<=nfit; ifit++) {
+ for (Int_t ifit=1; ifit<=nfit0; ifit++) {
cmax = 0;
pix = clusters[clustFit[ifit-1]];
npxclu = pix->GetEntriesFast();
}
qq += cont;
/*
- xy_Cand[ifit-1][0] += pixPtr->Coord(0) * cont;
- xy_Cand[ifit-1][1] += pixPtr->Coord(1) * cont;
- sig_Cand[ifit-1][0] += pixPtr->Coord(0) * pixPtr->Coord(0) * cont;
- sig_Cand[ifit-1][1] += pixPtr->Coord(1) * pixPtr->Coord(1) * cont;
+ xyCand[ifit-1][0] += pixPtr->Coord(0) * cont;
+ xyCand[ifit-1][1] += pixPtr->Coord(1) * cont;
+ sigCand[ifit-1][0] += pixPtr->Coord(0) * pixPtr->Coord(0) * cont;
+ sigCand[ifit-1][1] += pixPtr->Coord(1) * pixPtr->Coord(1) * cont;
*/
- xy_Cand[0][0] += pixPtr->Coord(0) * cont;
- xy_Cand[0][1] += pixPtr->Coord(1) * cont;
- sig_Cand[0][0] += pixPtr->Coord(0) * pixPtr->Coord(0) * cont;
- sig_Cand[0][1] += pixPtr->Coord(1) * pixPtr->Coord(1) * cont;
+ xyCand[0][0] += pixPtr->Coord(0) * cont;
+ xyCand[0][1] += pixPtr->Coord(1) * cont;
+ sigCand[0][0] += pixPtr->Coord(0) * pixPtr->Coord(0) * cont;
+ sigCand[0][1] += pixPtr->Coord(1) * pixPtr->Coord(1) * cont;
}
xyseed[ifit-1][0] = xseed;
xyseed[ifit-1][1] = yseed;
qseed[ifit-1] = cmax;
/*
- xy_Cand[ifit-1][0] /= qq; // <x>
- xy_Cand[ifit-1][1] /= qq; // <y>
- sig_Cand[ifit-1][0] = sig_Cand[ifit-1][0]/qq - xy_Cand[ifit-1][0]*xy_Cand[ifit-1][0]; // <x^2> - <x>^2
- sig_Cand[ifit-1][0] = sig_Cand[ifit-1][0] > 0 ? TMath::Sqrt (sig_Cand[ifit-1][0]) : 0;
- sig_Cand[ifit-1][1] = sig_Cand[ifit-1][1]/qq - xy_Cand[ifit-1][1]*xy_Cand[ifit-1][1]; // <y^2> - <y>^2
- sig_Cand[ifit-1][1] = sig_Cand[ifit-1][1] > 0 ? TMath::Sqrt (sig_Cand[ifit-1][1]) : 0;
- cout << xy_Cand[ifit-1][0] << " " << xy_Cand[ifit-1][1] << " " << sig_Cand[ifit-1][0] << " " << sig_Cand[ifit-1][1] << endl;
+ xyCand[ifit-1][0] /= qq; // <x>
+ xyCand[ifit-1][1] /= qq; // <y>
+ sigCand[ifit-1][0] = sigCand[ifit-1][0]/qq - xyCand[ifit-1][0]*xyCand[ifit-1][0]; // <x^2> - <x>^2
+ sigCand[ifit-1][0] = sigCand[ifit-1][0] > 0 ? TMath::Sqrt (sigCand[ifit-1][0]) : 0;
+ sigCand[ifit-1][1] = sigCand[ifit-1][1]/qq - xyCand[ifit-1][1]*xyCand[ifit-1][1]; // <y^2> - <y>^2
+ sigCand[ifit-1][1] = sigCand[ifit-1][1] > 0 ? TMath::Sqrt (sigCand[ifit-1][1]) : 0;
+ cout << xyCand[ifit-1][0] << " " << xyCand[ifit-1][1] << " " << sigCand[ifit-1][0] << " " << sigCand[ifit-1][1] << endl;
*/
} // for (Int_t ifit=1;
- xy_Cand[0][0] /= qq; // <x>
- xy_Cand[0][1] /= qq; // <y>
- sig_Cand[0][0] = sig_Cand[0][0]/qq - xy_Cand[0][0]*xy_Cand[0][0]; // <x^2> - <x>^2
- sig_Cand[0][0] = sig_Cand[0][0] > 0 ? TMath::Sqrt (sig_Cand[0][0]) : 0;
- sig_Cand[0][1] = sig_Cand[0][1]/qq - xy_Cand[0][1]*xy_Cand[0][1]; // <y^2> - <y>^2
- sig_Cand[0][1] = sig_Cand[0][1] > 0 ? TMath::Sqrt (sig_Cand[0][1]) : 0;
- if (fDebug) cout << xy_Cand[0][0] << " " << xy_Cand[0][1] << " " << sig_Cand[0][0] << " " << sig_Cand[0][1] << endl;
+ xyCand[0][0] /= qq; // <x>
+ xyCand[0][1] /= qq; // <y>
+ sigCand[0][0] = sigCand[0][0]/qq - xyCand[0][0]*xyCand[0][0]; // <x^2> - <x>^2
+ sigCand[0][0] = sigCand[0][0] > 0 ? TMath::Sqrt (sigCand[0][0]) : 0;
+ sigCand[0][1] = sigCand[0][1]/qq - xyCand[0][1]*xyCand[0][1]; // <y^2> - <y>^2
+ sigCand[0][1] = sigCand[0][1] > 0 ? TMath::Sqrt (sigCand[0][1]) : 0;
+ if (fDebug) cout << xyCand[0][0] << " " << xyCand[0][1] << " " << sigCand[0][0] << " " << sigCand[0][1] << endl;
- Int_t nDof, maxSeed[3];
+ Int_t nDof, maxSeed[3], nMax = 0;
Double_t fmin, chi2o = 9999, chi2n;
- // Try to fit with one-track hypothesis, then 2-track. If chi2/dof is
- // lower, try 3-track (if number of pads is sufficient).
-
- TMath::Sort(nfit, qseed, maxSeed, kTRUE); // in decreasing order
- nfit = TMath::Min (nfit, (npads + 1) / 3);
- if (nfit > 1) {
- if (nInX < 3 && nInY < 3 || nInX == 3 && nInY < 3 || nInX < 3 && nInY == 3) nfit = 1; // not enough pads in each direction
- }
- //if (nfit > 1) nfit --;
- // One pad per direction
- //if (nInX == 1) { step[0] /= 1; xyseed[0][0] = xPad; }
- //if (nInY == 1) { step[1] /= 1; xyseed[0][1] = yPad; }
+ TMath::Sort(nfit0, qseed, maxSeed, kTRUE); // in decreasing order
+ /*
+ Int_t itmp[100], localMax[100];
+ Double_t maxVal[100];
+ if (!iSimple && nfit < nfitMax) {
+ // Try to split pixel cluster according to local maxima
+ Int_t nfit1 = nfit;
+ for (Int_t iclus = 0; iclus < nfit1; iclus++) {
+ nMax = FindLocalMaxima (clusters[clustFit[maxSeed[iclus]]], localMax, maxVal);
+ TH2D *hist = (TH2D*) gROOT->FindObject("anode1");
+ if (nMax == 1) { hist->Delete(); continue; }
+ // Add extra fitting seeds from local maxima
+ Int_t ixseed = hist->GetXaxis()->FindBin(xyseed[maxSeed[iclus]][0]);
+ Int_t iyseed = hist->GetYaxis()->FindBin(xyseed[maxSeed[iclus]][1]);
+ Int_t nx = hist->GetNbinsX();
+ TMath::Sort(nMax, maxVal, itmp, kTRUE); // in decreasing order
+ for (Int_t j = 0; j < nMax; j++) {
+ Int_t iyc = localMax[itmp[j]] / nx + 1;
+ Int_t ixc = localMax[itmp[j]] % nx + 1;
+ if (ixc == ixseed && iyc == iyseed) continue; // local max already taken for seeding
+ xyseed[nfit][0] = hist->GetXaxis()->GetBinCenter(ixc);
+ xyseed[nfit][1] = hist->GetYaxis()->GetBinCenter(iyc);
+ qseed[nfit] = maxVal[itmp[j]];
+ maxSeed[nfit] = nfit++;
+ if (nfit >= nfitMax) break;
+ }
+ hist->Delete();
+ if (nfit >= nfitMax) break;
+ } // for (Int_t iclus = 0;
+ //nfit0 = nfit;
+ //TMath::Sort(nfit0, qseed, maxSeed, kTRUE); // in decreasing order
+ } //if (!iSimple && nfit < nfitMax)
+ */
- Double_t *gin = 0, func0, func1, param[8], param0[2][8], deriv[2][8], step0[8];
+ Double_t *gin = 0, func0, func1, param[8], step0[8];
+ Double_t param0[2][8]={{0},{0}}, deriv[2][8]={{0},{0}};
Double_t shift[8], stepMax, derMax, parmin[8], parmax[8], func2[2], shift0;
Double_t delta[8], scMax, dder[8], estim, shiftSave = 0;
Int_t min, max, nCall = 0, memory[8] = {0}, nLoop, idMax = 0, iestMax = 0, nFail;
Double_t rad, dist[3] = {0};
+ // Try to fit with one-track hypothesis, then 2-track. If chi2/dof is
+ // lower, try 3-track (if number of pads is sufficient).
for (Int_t iseed=0; iseed<nfit; iseed++) {
if (iseed) { for (Int_t j=0; j<fNpar; j++) param[j] = parOk[j]; } // for bounded params
for (Int_t j=0; j<3; j++) step0[fNpar+j] = shift[fNpar+j] = step[j];
- param[fNpar] = xyseed[maxSeed[iseed]][0];
+ if (nfit == 1) param[fNpar] = xyCand[0][0]; // take COG
+ else param[fNpar] = xyseed[maxSeed[iseed]][0];
parmin[fNpar] = xmin;
parmax[fNpar++] = xmax;
- param[fNpar] = xyseed[maxSeed[iseed]][1];
+ if (nfit == 1) param[fNpar] = xyCand[0][1]; // take COG
+ else param[fNpar] = xyseed[maxSeed[iseed]][1];
parmin[fNpar] = ymin;
parmax[fNpar++] = ymax;
if (fNpar > 2) {
parmin[fNpar] = 0;
parmax[fNpar++] = 1;
}
+ if (iseed) { for (Int_t j=0; j<fNpar; j++) param0[1][j] = 0; }
// Try new algorithm
min = nLoop = 1; stepMax = func2[1] = derMax = 999999; nFail = 0;
deriv[max][j] = (func1 - func0) / delta[j] * 10; // first derivative
//cout << j << " " << deriv[max][j] << endl;
dder[j] = param0[0][j] != param0[1][j] ? (deriv[0][j] - deriv[1][j]) /
- (param0[0][j] - param0[1][j]) : 0; // second derivative
+ (param0[0][j] - param0[1][j]) : 0; // second derivative
}
param[fNpar-1] -= delta[fNpar-1] / 10;
if (nCall > 2000) break;
// Save parameters and errors
- if (nInX == 1 && qPad[1] > 1) {
+ if (nInX == 1) {
// One pad per direction
- xPad = xyqPad[1] / qPad[1]; // take COG for this case
for (Int_t i=0; i<fNpar; i++) if (i == 0 || i == 2 || i == 5) param0[min][i] = xPad;
}
- if (nInY == 1 && qPad[0] > 1) {
+ if (nInY == 1) {
// One pad per direction
- yPad = xyqPad[0] / qPad[0]; // take COG for this case
for (Int_t i=0; i<fNpar; i++) if (i == 1 || i == 3 || i == 6) param0[min][i] = yPad;
}
for (Int_t i=0; i<fNpar; i++) {
parOk[i] = param0[min][i];
- errOk[i] = fmin;
+ //errOk[i] = fmin;
+ errOk[i] = chi2n;
// Bounded params
parOk[i] = TMath::Max (parOk[i], parmin[i]);
parOk[i] = TMath::Min (parOk[i], parmax[i]);
if (fDebug) {
for (Int_t i=0; i<fNpar; i++) {
- //if (i == 4 || i == 7) continue;
if (i == 4 || i == 7) {
if (i == 7 || i == 4 && fNpar < 7) cout << parOk[i] << endl;
else cout << parOk[i] * (1-parOk[7]) << endl;
}
}
- Int_t indx, imax;
+ Int_t indx;
fnPads[1] -= nVirtual;
- if (fReco) {
+ if (!fDraw) {
Double_t coef = 0;
+ if (iSimple) fnCoupled = 0;
//for (Int_t j=0; j<nfit; j++) {
for (Int_t j=nfit-1; j>=0; j--) {
indx = j<2 ? j*2 : j*2+1;
coef = TMath::Max (coef, 0.);
if (nfit == 3 && j < 2) coef = j==1 ? coef*parOk[indx+2] : coef - parOk[7];
coef = TMath::Max (coef, 0.);
- AddRawCluster (parOk[indx], parOk[indx+1], coef*fQtot, errOk[indx], nfit0+10*nfit, tracks,
- //sig_Cand[maxSeed[j]][0], sig_Cand[maxSeed[j]][1]);
- //sig_Cand[0][0], sig_Cand[0][1], dist[j]);
- sig_Cand[0][0], sig_Cand[0][1], dist[TMath::LocMin(nfit,dist)]);
+ AddRawCluster (parOk[indx], parOk[indx+1], coef*fQtot, errOk[indx], nfit0+10*nfit+100*nMax+10000*fnCoupled, tracks,
+ //sigCand[maxSeed[j]][0], sigCand[maxSeed[j]][1]);
+ //sigCand[0][0], sigCand[0][1], dist[j]);
+ sigCand[0][0], sigCand[0][1], dist[TMath::LocMin(nfit,dist)]);
}
- return nfit;
- }
- for (Int_t i=0; i<fnMu; i++) {
- cmax = fxyMu[i][6];
- for (Int_t j=0; j<nfit; j++) {
- indx = j<2 ? j*2 : j*2+1;
- rad = (fxyMu[i][0]-parOk[indx])*(fxyMu[i][0]-parOk[indx]) +
- (fxyMu[i][1]-parOk[indx+1])*(fxyMu[i][1]-parOk[indx+1]);
- if (rad < cmax) {
- cmax = rad;
- imax = indx;
- fxyMu[i][6] = cmax;
- fxyMu[i][2] = parOk[imax] - fxyMu[i][0];
- fxyMu[i][4] = parOk[imax+1] - fxyMu[i][1];
- fxyMu[i][3] = errOk[imax];
- fxyMu[i][5] = errOk[imax+1];
- }
- }
- }
+ } else fDraw->FillMuon(nfit, parOk, errOk);
return nfit;
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Fcn1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
{
- // Fit for one track
- //AZ for Muinuit AliMUONClusterFinderAZ& c = *(AliMUONClusterFinderAZ::fgClusterFinder);
+/// Fit for one track
+/// AZ for Muinuit AliMUONClusterFinderAZ& c = *(AliMUONClusterFinderAZ::fgClusterFinder);
+
AliMUONClusterFinderAZ& c = *this; //AZ
Int_t cath, ix, iy, indx, npads=0;
cath = c.fPadIJ[0][j];
if (c.fXyq[3][j] > 0) npads++; // exclude virtual pads
qTot += c.fXyq[2][j];
- c.fSegmentation[cath]->GetPadI(fInput->DetElemId(),c.fXyq[0][j],c.fXyq[1][j],c.fZpad,ix,iy);
- c.fSegmentation[cath]->SetPad(fInput->DetElemId(),ix,iy);
+ ix = c.fPadIJ[2][j];
+ iy = c.fPadIJ[3][j];
+ c.fSegmentation[cath]->SetPad(ix, iy);
charge = 0;
for (Int_t i=c.fNpar/3; i>=0; i--) { // sum over tracks
indx = i<2 ? 2*i : 2*i+1;
- c.fSegmentation[cath]->SetHit(fInput->DetElemId(),par[indx],par[indx+1],c.fZpad);
- //charge += c.fResponse->IntXY(fInput->DetElemId(),c.fSegmentation[cath])*par[icl*3+2];
+ c.fSegmentation[cath]->SetHit(par[indx], par[indx+1], c.fZpad);
if (c.fNpar == 2) coef = 1;
else coef = i==c.fNpar/3 ? par[indx+2] : 1-coef;
coef = TMath::Max (coef, 0.);
if (c.fNpar == 8 && i < 2) coef = i==1 ? coef*par[indx+2] : coef - par[7];
coef = TMath::Max (coef, 0.);
- charge += c.fResponse->IntXY(fInput->DetElemId(),c.fSegmentation[cath])*coef;
+ charge += c.fInput->Mathieson()->IntXY(fInput->DetElemId(), c.fInput->Segmentation2(cath))*coef;
}
charge *= c.fQtot;
- //if (c.fXyq[2][j] > c.fResponse->MaxAdc()-1 && charge >
- // c.fResponse->MaxAdc()) charge = c.fResponse->MaxAdc();
delta = charge - c.fXyq[2][j];
delta *= delta;
delta /= c.fXyq[2][j];
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::UpdatePads(Int_t /*nfit*/, Double_t *par)
{
- // Subtract the fitted charges from pads with strong coupling
+/// Subtract the fitted charges from pads with strong coupling
Int_t cath, ix, iy, indx;
Double_t charge, coef=0;
if (fPadIJ[1][j] != -1) continue;
if (fNpar != 0) {
cath = fPadIJ[0][j];
- fSegmentation[cath]->GetPadI(fInput->DetElemId(),fXyq[0][j],fXyq[1][j],fZpad,ix,iy);
- fSegmentation[cath]->SetPad(fInput->DetElemId(),ix,iy);
+ ix = fPadIJ[2][j];
+ iy = fPadIJ[3][j];
+ fSegmentation[cath]->SetPad(ix, iy);
charge = 0;
for (Int_t i=fNpar/3; i>=0; i--) { // sum over tracks
indx = i<2 ? 2*i : 2*i+1;
- fSegmentation[cath]->SetHit(fInput->DetElemId(),par[indx],par[indx+1],fZpad);
+ fSegmentation[cath]->SetHit(par[indx], par[indx+1], fZpad);
if (fNpar == 2) coef = 1;
else coef = i==fNpar/3 ? par[indx+2] : 1-coef;
coef = TMath::Max (coef, 0.);
if (fNpar == 8 && i < 2) coef = i==1 ? coef*par[indx+2] : coef - par[7];
coef = TMath::Max (coef, 0.);
- charge += fResponse->IntXY(fInput->DetElemId(),fSegmentation[cath])*coef;
+ charge += fInput->Mathieson()->IntXY(fInput->DetElemId(),fInput->Segmentation2(cath))*coef;
}
charge *= fQtot;
fXyq[2][j] -= charge;
} // if (fNpar != 0)
- if (fXyq[2][j] > fResponse->ZeroSuppression()) fPadIJ[1][j] = 0; // return pad for further using
+ if (fXyq[2][j] > fgkZeroSuppression) fPadIJ[1][j] = 0; // return pad for further using
} // for (Int_t j=0;
}
//_____________________________________________________________________________
-Bool_t AliMUONClusterFinderAZ::TestTrack(Int_t /*t*/) const {
-// Test if track was user selected
+Bool_t AliMUONClusterFinderAZ::TestTrack(Int_t /*t*/) const
+{
+/// Test if track was user selected
+
return kTRUE;
/*
if (fTrack[0]==-1 || fTrack[1]==-1) {
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AddRawCluster(Double_t x, Double_t y, Double_t qTot, Double_t fmin, Int_t nfit, Int_t *tracks, Double_t /*sigx*/, Double_t /*sigy*/, Double_t /*dist*/)
{
- //
- // Add a raw cluster copy to the list
- //
+/// Add a raw cluster copy to the list
+
if (qTot <= 0.501) return;
AliMUONRawCluster cnew;
- AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
- pMUON=0; //AZ
- //pMUON->AddRawCluster(fInput->Chamber(),c);
Int_t cath, npads[2] = {0}, nover[2] = {0};
for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
if (fPadIJ[1][j] == -9) nover[cath]++;
if (fPadIJ[1][j] != 1 && fPadIJ[1][j] != -9) continue;
cnew.SetMultiplicity(cath,cnew.GetMultiplicity(cath)+1);
- if (fXyq[2][j] > cnew.GetPeakSignal(cath)) cnew.SetPeakSignal(cath,TMath::Nint (fXyq[2][j]));
+ if (fXyq[2][j] > cnew.GetPeakSignal(cath)) cnew.SetPeakSignal(cath,fXyq[2][j]);
//cnew.SetCharge(cath,cnew.GetCharge(cath) + TMath::Nint (fXyq[2][j]));
cnew.SetContrib(npads[cath],cath,fXyq[2][j]);
- cnew.SetIndex(npads[cath],cath,TMath::Nint (fXyq[5][j])+10000*fInput->DetElemId());
+ cnew.SetIndex(npads[cath],cath,TMath::Nint (fXyq[5][j]));
+ cnew.SetDetElemId(fInput->DetElemId());
npads[cath]++;
}
cnew.SetClusterType(nover[0] + nover[1] * 100);
for (Int_t j=0; j<3; j++) cnew.SetTrack(j,tracks[j]);
+ Double_t xg, yg, zg;
for (cath=0; cath<2; cath++) {
- cnew.SetX(cath, x);
- cnew.SetY(cath, y);
- cnew.SetZ(cath, fZpad);
+ // Perform local-to-global transformation
+ fInput->Segmentation2(cath)->GetTransformer()->Local2Global(fInput->DetElemId(), x, y, fZpad, xg, yg, zg);
+ cnew.SetX(cath, xg);
+ cnew.SetY(cath, yg);
+ cnew.SetZ(cath, zg);
cnew.SetCharge(cath, TMath::Nint(qTot));
//cnew.SetPeakSignal(cath,20);
//cnew.SetMultiplicity(cath, 5);
cnew.SetGhost(nfit); //cnew.SetX(1,sigx); cnew.SetY(1,sigy); cnew.SetZ(1,dist);
//cnew.fClusterType=cnew.PhysicsContribution();
- //AZ pMUON->GetMUONData()->AddRawCluster(AliMUONClusterInput::Instance()->Chamber(),cnew);
- new((*fRawClusters)[fNRawClusters++]) AliMUONRawCluster(cnew); //AZ
- if (fDebug) cout << fNRawClusters << " " << AliMUONClusterInput::Instance()->Chamber() << endl;
+ new((*fRawClusters)[fNRawClusters++]) AliMUONRawCluster(cnew);
+ if (fDebug) cout << fNRawClusters << " " << fInput->Chamber() << endl;
//fNPeaks++;
}
//_____________________________________________________________________________
-Int_t AliMUONClusterFinderAZ::FindLocalMaxima(Int_t *localMax, Double_t *maxVal)
+Int_t AliMUONClusterFinderAZ::FindLocalMaxima(TObjArray *pixArray, Int_t *localMax, Double_t *maxVal)
{
- // Find local maxima in pixel space for large preclusters in order to
- // try to split them into smaller pieces (to speed up the MLEM procedure)
+/// Find local maxima in pixel space for large preclusters in order to
+/// try to split them into smaller pieces (to speed up the MLEM procedure)
+/// or to find additional fitting seeds if clusters were not completely resolved
- TH2D *hist = (TH2D*) gROOT->FindObject("anode");
- if (hist) hist->Delete();
+ TH2D *hist = NULL;
+ //if (pixArray == fPixArray) hist = (TH2D*) gROOT->FindObject("anode");
+ //else { hist = (TH2D*) gROOT->FindObject("anode1"); cout << hist << endl; }
+ //if (hist) hist->Delete();
Double_t xylim[4] = {999, 999, 999, 999};
- Int_t nPix = fPixArray->GetEntriesFast();
+ Int_t nPix = pixArray->GetEntriesFast();
AliMUONPixel *pixPtr = 0;
for (Int_t ipix=0; ipix<nPix; ipix++) {
- pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(ipix);
+ pixPtr = (AliMUONPixel*) pixArray->UncheckedAt(ipix);
for (Int_t i=0; i<4; i++)
xylim[i] = TMath::Min (xylim[i], (i%2 ? -1 : 1)*pixPtr->Coord(i/2));
}
Int_t nx = TMath::Nint ((-xylim[1]-xylim[0])/pixPtr->Size(0)/2);
Int_t ny = TMath::Nint ((-xylim[3]-xylim[2])/pixPtr->Size(1)/2);
- hist = new TH2D("anode","anode",nx,xylim[0],-xylim[1],ny,xylim[2],-xylim[3]);
+ if (pixArray == fPixArray) hist = new TH2D("anode","anode",nx,xylim[0],-xylim[1],ny,xylim[2],-xylim[3]);
+ else hist = new TH2D("anode1","anode1",nx,xylim[0],-xylim[1],ny,xylim[2],-xylim[3]);
for (Int_t ipix=0; ipix<nPix; ipix++) {
- pixPtr = (AliMUONPixel*) fPixArray->UncheckedAt(ipix);
+ pixPtr = (AliMUONPixel*) pixArray->UncheckedAt(ipix);
hist->Fill(pixPtr->Coord(0), pixPtr->Coord(1), pixPtr->Charge());
}
- if (fDraw) {
- ((TCanvas*)gROOT->FindObject("c2"))->cd();
- gPad->SetTheta(55);
- gPad->SetPhi(30);
- hist->Draw("lego1Fb");
- gPad->Update();
- int ia;
- cin >> ia;
- }
+ if (fDraw && pixArray == fPixArray) fDraw->DrawHist("c2", hist);
Int_t nMax = 0, indx;
Int_t *isLocalMax = new Int_t[ny*nx];
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::FlagLocalMax(TH2D *hist, Int_t i, Int_t j, Int_t *isLocalMax)
{
- // Flag pixels (whether or not local maxima)
+/// Flag pixels (whether or not local maxima)
Int_t nx = hist->GetNbinsX();
Int_t ny = hist->GetNbinsY();
Int_t cont = TMath::Nint (hist->GetCellContent(j,i));
- Int_t cont1 = 0;
+ Int_t cont1 = 0, indx = (i-1)*nx+j-1, indx1 = 0, indx2 = 0;
for (Int_t i1=i-1; i1<i+2; i1++) {
if (i1 < 1 || i1 > ny) continue;
+ indx1 = (i1 - 1) * nx;
for (Int_t j1=j-1; j1<j+2; j1++) {
if (j1 < 1 || j1 > nx) continue;
if (i == i1 && j == j1) continue;
+ indx2 = indx1 + j1 - 1;
cont1 = TMath::Nint (hist->GetCellContent(j1,i1));
- if (cont < cont1) { isLocalMax[(i-1)*nx+j-1] = -1; return; }
- else if (cont > cont1) isLocalMax[(i1-1)*nx+j1-1] = -1;
+ if (cont < cont1) { isLocalMax[indx] = -1; return; }
+ else if (cont > cont1) isLocalMax[indx2] = -1;
else { // the same charge
- isLocalMax[(i-1)*nx+j-1] = 1;
- if (isLocalMax[(i1-1)*nx+j1-1] == 0) {
+ isLocalMax[indx] = 1;
+ if (isLocalMax[indx2] == 0) {
FlagLocalMax(hist, i1, j1, isLocalMax);
- if (isLocalMax[(i1-1)*nx+j1-1] < 0) { isLocalMax[(i-1)*nx+j-1] = -1; return; }
- else isLocalMax[(i1-1)*nx+j1-1] = -1;
+ if (isLocalMax[indx2] < 0) { isLocalMax[indx] = -1; return; }
+ else isLocalMax[indx2] = -1;
}
}
}
}
- isLocalMax[(i-1)*nx+j-1] = 1; // local maximum
+ isLocalMax[indx] = 1; // local maximum
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::FindCluster(Int_t *localMax, Int_t iMax)
{
- // Find pixel cluster around local maximum #iMax and pick up pads
- // overlapping with it
+/// Find pixel cluster around local maximum \a iMax and pick up pads
+/// overlapping with it
TH2D *hist = (TH2D*) gROOT->FindObject("anode");
Int_t nx = hist->GetNbinsX();
delete [] used; used = 0;
}
-//_____________________________________________________________________________
-AliMUONClusterFinderAZ&
-AliMUONClusterFinderAZ::operator=(const AliMUONClusterFinderAZ& rhs)
-{
-// Protected assignement operator
-
- if (this == &rhs) return *this;
-
- AliFatal("Not implemented.");
-
- return *this;
-}
-
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::AddVirtualPad()
{
- // Add virtual pad (with small charge) to improve fit for some
- // clusters (when pad with max charge is at the extreme of the cluster)
+/// Add virtual pad (with small charge) to improve fit for some
+/// clusters (when pad with max charge is at the extreme of the cluster)
// Get number of pads in X and Y-directions
Int_t nInX = -1, nInY;
PadsInXandY(nInX, nInY);
//return;
- //nInY = npady[0];
- //nInX = npadx[1] ? npadx[1] : npadx[0];
- // Add virtual pads only if number of pads per direction == 2
- //if (!npadx[1] && npady[0] != 2 && npadx[0] != 2) return 0; // one-sided
- //if (npadx[1] && npady[0] != 2 && npadx[1] != 2) return 0;
+ // Add virtual pad only if number of pads per direction == 2
if (nInX != 2 && nInY != 2) return;
// Find pads with max charge
}
// Check for mirrors (side X on cathode 0)
Bool_t mirror = kFALSE;
- if (maxpad[0][0] >= 0 && maxpad[1][0] >= 0)
+ if (maxpad[0][0] >= 0 && maxpad[1][0] >= 0) {
mirror = fXyq[3][maxpad[0][0]] < fXyq[4][maxpad[0][0]];
+ if (!mirror && TMath::Abs(fXyq[3][maxpad[0][0]]-fXyq[3][maxpad[1][0]]) < 0.001) {
+ // Special case when pads on both cathodes have the same size
+ Int_t yud[2] = {0};
+ for (Int_t j = 0; j < fnPads[0]+fnPads[1]; j++) {
+ cath = fPadIJ[0][j];
+ if (j == maxpad[cath][0]) continue;
+ if (fPadIJ[2][j] != fPadIJ[2][maxpad[cath][0]]) continue;
+ if (fPadIJ[3][j] + 1 == fPadIJ[3][maxpad[cath][0]] ||
+ fPadIJ[3][j] - 1 == fPadIJ[3][maxpad[cath][0]]) yud[cath]++;
+ }
+ if (!yud[0]) mirror = kTRUE; // take the other cathode
+ } // if (!mirror &&...
+ } // if (maxpad[0][0] >= 0 && maxpad[1][0] >= 0)
// Find neughbours of pads with max charges
Int_t nn, xList[10], yList[10], ix0, iy0, ix, iy, neighb;
if (maxpad[1][0] >= 0) {
if (!mirror) {
if (!cath && nInY != 2) continue;
- //AZ if (cath && nInX != 2) continue;
if (cath && nInX != 2 && (maxpad[0][0] >= 0 || nInY != 2)) continue;
} else {
if (!cath && nInX != 2) continue;
}
}
- Int_t iAddX = 0, iAddY = 0, ix1 = 0, iy1 = 0, iMuon = 0, iPad = 0;
+ Int_t iAddX = 0, iAddY = 0, ix1 = 0, iy1 = 0, iPad = 0;
if (maxpad[0][0] < 0) iPad = 1;
- // This part of code to take care of edge effect (problems in MC)
- Float_t spr_x = fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
- Float_t spr_y = fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
- Double_t rmin = 9999, rad2;
- Int_t border = 0, iYlow = 0;
-
- if (!fReco) {
- for (Int_t i=0; i<2; i++) {
- rad2 = (fXyq[0][maxpad[iPad][0]]-fxyMu[i][0]) * (fXyq[0][maxpad[iPad][0]]-fxyMu[i][0]);
- rad2 += (fXyq[1][maxpad[iPad][0]]-fxyMu[i][1]) * (fXyq[1][maxpad[iPad][0]]-fxyMu[i][1]);
- if (rad2 < rmin) { iMuon = i; rmin = rad2; }
- }
- fSegmentation[cath]->FirstPad(fInput->DetElemId(),(Float_t)fxyMu[iMuon][0], (Float_t)fxyMu[iMuon][1], fZpad, spr_x, spr_y);
- if (fSegmentation[cath]->Sector(fInput->DetElemId(),fSegmentation[cath]->Ix(),fSegmentation[cath]->Iy()) <= 0) {
- fSegmentation[cath]->NextPad(fInput->DetElemId());
- border = 1;
- iYlow = fSegmentation[cath]->Iy();
- }
- }
-
for (iPad=0; iPad<2; iPad++) {
+ if (maxpad[cath][iPad] < 0) continue;
if (iPad && !iAddX && !iAddY) break;
if (iPad && fXyq[2][maxpad[cath][1]] / sigmax[cath] < 0.5) break;
Int_t neighbx = 0, neighby = 0;
- fSegmentation[cath]->GetPadI(fInput->DetElemId(),fXyq[0][maxpad[cath][iPad]],fXyq[1][maxpad[cath][iPad]],fZpad,ix0,iy0);
- fSegmentation[cath]->Neighbours(fInput->DetElemId(),ix0,iy0,&nn,xList,yList);
- Float_t zpad; //, xpad, ypad;
+ ix0 = fPadIJ[2][maxpad[cath][iPad]];
+ iy0 = fPadIJ[3][maxpad[cath][iPad]];
+ fSegmentation[cath]->Neighbours(ix0, iy0, &nn, xList, yList);
+ Float_t zpad;
for (Int_t j=0; j<nn; j++) {
- /*
- if (border && yList[j] < iYlow) { xList[j] = yList[j] = 0; continue; }
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),xList[j],yList[j],xpad,ypad,zpad);
- if (TMath::Abs(xpad) < 1 && TMath::Abs(ypad) < 1)
- { xList[j] = yList[j] = 0; continue; } // strange case (something with pad mapping)
- */
- if (TMath::Abs(xList[j]-ix0) == 1 || TMath::Abs(xList[j]*ix0) == 1) neighbx++;
- if (TMath::Abs(yList[j]-iy0) == 1 || TMath::Abs(yList[j]*iy0) == 1) neighby++;
+ if (TMath::Abs(xList[j]-ix0) == 1 || xList[j]*ix0 == -1) neighbx++;
+ if (TMath::Abs(yList[j]-iy0) == 1 || yList[j]*iy0 == -1) neighby++;
}
if (!mirror) {
if (cath) neighb = neighbx;
for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
if (fPadIJ[0][j] != cath) continue;
- fSegmentation[cath]->GetPadI(fInput->DetElemId(),fXyq[0][j],fXyq[1][j],fZpad,ix,iy);
+ ix = fPadIJ[2][j];
+ iy = fPadIJ[3][j];
if (iy == iy0 && ix == ix0) continue;
for (Int_t k=0; k<nn; k++) {
if (xList[k] != ix || yList[k] != iy) continue;
if (!mirror) {
if ((!cath || maxpad[0][0] < 0) &&
- (TMath::Abs(iy-iy0) == 1 || TMath::Abs(iy*iy0) == 1)) {
+ (TMath::Abs(iy-iy0) == 1 || iy*iy0 == -1)) {
+ if (!iPad && TMath::Abs(ix-ix0) == 1 || ix*ix0 == -1) ix1 = xList[k]; //19-12-05
xList[k] = yList[k] = 0;
neighb--;
break;
}
if ((cath || maxpad[1][0] < 0) &&
- (TMath::Abs(ix-ix0) == 1 || TMath::Abs(ix*ix0) == 1)) {
+ (TMath::Abs(ix-ix0) == 1 || ix*ix0 == -1)) {
+ if (!iPad) ix1 = xList[k]; //19-12-05
xList[k] = yList[k] = 0;
neighb--;
}
} else {
if ((!cath || maxpad[0][0] < 0) &&
- (TMath::Abs(ix-ix0) == 1 || TMath::Abs(ix*ix0) == 1)) {
+ (TMath::Abs(ix-ix0) == 1 || ix*ix0 == -1)) {
+ if (!iPad) ix1 = xList[k]; //19-12-05
xList[k] = yList[k] = 0;
neighb--;
break;
}
if ((cath || maxpad[1][0] < 0) &&
- (TMath::Abs(iy-iy0) == 1 || TMath::Abs(iy*iy0) == 1)) {
+ (TMath::Abs(iy-iy0) == 1 || iy*iy0 == -1)) {
xList[k] = yList[k] = 0;
neighb--;
}
fPadIJ[1][npads] = 0;
ix = xList[j];
iy = yList[j];
- if (TMath::Abs(ix-ix0) == 1 || TMath::Abs(ix*ix0) == 1) {
+ if (TMath::Abs(ix-ix0) == 1 || ix*ix0 == -1) {
if (iy != iy0) continue; // new segmentation - check
if (nInX != 2) continue; // new
if (!mirror) {
if (!cath && maxpad[1][0] >= 0) continue;
- //if (maxpad[1][0] < 0 && nInX != 2) continue;
} else {
if (cath && maxpad[0][0] >= 0) continue;
- //if (maxpad[0][0] < 0 && nInX != 2) continue;
}
if (iPad && !iAddX) continue;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),ix,iy,fXyq[0][npads],fXyq[1][npads],zpad);
+ fSegmentation[cath]->GetPadC(ix, iy, fXyq[0][npads], fXyq[1][npads], zpad);
+ if (fXyq[0][npads] > 1.e+5) continue; // temporary fix
+ if (ix == ix1) continue; //19-12-05
if (ix1 == ix0) continue;
- //if (iPad && ix1 == ix0) continue;
- //if (iPad && TMath::Abs(fXyq[0][npads]-fXyq[0][iAddX]) < fXyq[3][iAddX]) continue;
- //if (TMath::Abs(fXyq[0][npads]) < 1 && TMath::Abs(fXyq[1][npads]) < 1) continue; // strange case (something with pad mapping)
if (maxpad[1][0] < 0 || mirror && maxpad[0][0] >= 0) {
if (!iPad) fXyq[2][npads] = TMath::Min (sigmax[0]/100, 5.);
else fXyq[2][npads] = TMath::Min (aamax[0]/100, 5.);
else fXyq[2][npads] = TMath::Min (aamax[1]/100, 5.);
}
fXyq[2][npads] = TMath::Max (fXyq[2][npads], (float)1);
- //fXyq[2][npads] = 1;
- //isec = fSegmentation[cath]->Sector(fInput->DetElemId(),ix, iy);
- //fXyq[3][npads] = fSegmentation[cath]->Dpx(fInput->DetElemId(),isec)/2;
fXyq[3][npads] = -2; // flag
+ fPadIJ[2][npads] = ix;
+ fPadIJ[3][npads] = iy;
fnPads[1]++;
iAddX = npads;
- if (fDebug) cout << " ***** Add virtual pad in X ***** " << fXyq[2][npads]
- << " " << fXyq[0][npads] << " " << fXyq[1][npads] << endl;
+ if (fDebug) printf(" ***** Add virtual pad in X ***** %f %f %f %3d %3d \n", fXyq[2][npads],
+ fXyq[0][npads], fXyq[1][npads], ix, iy);
ix1 = ix0;
continue;
}
if (TMath::Abs(iy-iy0) == 1 || TMath::Abs(iy*iy0) == 1) {
if (ix != ix0) continue; // new segmentation - check
if (iPad && !iAddY) continue;
- fSegmentation[cath]->GetPadC(fInput->DetElemId(),ix,iy,fXyq[0][npads],fXyq[1][npads],zpad);
+ fSegmentation[cath]->GetPadC(ix, iy, fXyq[0][npads], fXyq[1][npads], zpad);
if (iy1 == iy0) continue;
//if (iPad && iy1 == iy0) continue;
- //if (iPad && TMath::Abs(fXyq[1][npads]-fXyq[1][iAddY]) < fXyq[4][iAddY]) continue;
- //if (TMath::Abs(fXyq[0][npads]) < 1 && TMath::Abs(fXyq[1][npads]) < 1) continue; // strange case (something with pad mapping)
if (maxpad[0][0] < 0 || mirror && maxpad[1][0] >= 0) {
- if (!iPad) fXyq[2][npads] = TMath::Min (sigmax[1]/20, 5.);
- else fXyq[2][npads] = TMath::Min (aamax[1]/20, 5.);
+ if (!iPad) fXyq[2][npads] = TMath::Min (sigmax[1]/15, fgkZeroSuppression);
+ else fXyq[2][npads] = TMath::Min (aamax[1]/15, fgkZeroSuppression);
}
else {
- if (!iPad) fXyq[2][npads] = TMath::Min (sigmax[0]/20, 5.);
- else fXyq[2][npads] = TMath::Min (aamax[0]/20, 5.);
+ if (!iPad) fXyq[2][npads] = TMath::Min (sigmax[0]/15, fgkZeroSuppression);
+ else fXyq[2][npads] = TMath::Min (aamax[0]/15, fgkZeroSuppression);
}
fXyq[2][npads] = TMath::Max (fXyq[2][npads], (float)1);
- //isec = fSegmentation[cath]->Sector(fInput->DetElemId(),ix, iy);
- //fXyq[4][npads] = fSegmentation[cath]->Dpy(isec)/2;
fXyq[3][npads] = -2; // flag
+ fPadIJ[2][npads] = ix;
+ fPadIJ[3][npads] = iy;
fnPads[1]++;
iAddY = npads;
- if (fDebug) cout << " ***** Add virtual pad in Y ***** " << fXyq[2][npads]
- << " " << fXyq[0][npads] << " " << fXyq[1][npads] << endl;
+ if (fDebug) printf(" ***** Add virtual pad in Y ***** %f %f %f %3d %3d \n", fXyq[2][npads],
+ fXyq[0][npads], fXyq[1][npads], ix, iy);
iy1 = iy0;
}
} // for (Int_t j=0; j<nn;
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::PadsInXandY(Int_t &nInX, Int_t &nInY)
{
- // Find number of pads in X and Y-directions (excluding virtual ones and
- // overflows)
+/// Find number of pads in X and Y-directions (excluding virtual ones and
+/// overflows)
static Int_t nXsaved = 0, nYsaved = 0;
nXsaved = nYsaved = 0;
//if (nInX >= 0) {nInX = nXsaved; nInY = nYsaved; return; }
- Double_t xlow[2] = {9999,9999}, xhig[2] = {-9999,-9999};
- Double_t ylow[2] = {9999,9999}, yhig[2] = {-9999,-9999};
- Int_t nx, ny, cath, npadx[2] = {0}, npady[2] = {0};
- for (Int_t j=0; j<fnPads[0]+fnPads[1]; j++) {
- //if (fPadIJ[1][j] != 0) continue;
- //if (fXyq[3][j] < 0) continue; // virtual pad
+ Float_t *xPad0 = NULL, *yPad0 = NULL, *xPad1 = NULL, *yPad1 = NULL;
+ Float_t wMinX[2] = {99, 99}, wMinY[2] = {99, 99};
+ Int_t *nPad0 = NULL, *nPad1 = NULL;
+ Int_t nPads = fnPads[0] + fnPads[1];
+ if (fnPads[0]) {
+ xPad0 = new Float_t[nPads];
+ yPad0 = new Float_t[nPads];
+ nPad0 = new Int_t[nPads];
+ }
+ if (fnPads[1]) {
+ xPad1 = new Float_t[nPads];
+ yPad1 = new Float_t[nPads];
+ nPad1 = new Int_t[nPads];
+ }
+ Int_t n0 = 0, n1 = 0, cath, npadx[2] = {1, 1}, npady[2] = {1, 1};
+ for (Int_t j = 0; j < nPads; j++) {
if (nInX < 0 && fPadIJ[1][j] != 0) continue; // before fit
else if (nInX == 0 && fPadIJ[1][j] != 1) continue; // fit - exclude overflows
else if (nInX > 0 && fPadIJ[1][j] != 1 && fPadIJ[1][j] != -9) continue; // exclude non-marked
- //AZif (fXyq[2][j] > fResponse->MaxAdc()-1) continue;
- if (nInX <= 0 && fXyq[2][j] > fResponse->Saturation()-1) continue; // skip overflows
+ if (nInX <= 0 && fXyq[2][j] > fgkSaturation-1) continue; // skip overflows
cath = fPadIJ[0][j];
- nx = ny = 0;
- if (fXyq[0][j] < xlow[cath]-0.001) { xlow[cath] = fXyq[0][j]; nx++; }
- if (fXyq[1][j] < ylow[cath]-0.001) { ylow[cath] = fXyq[1][j]; ny++; }
- if (fXyq[0][j] > xhig[cath]+0.001) { xhig[cath] = fXyq[0][j]; nx++; }
- if (fXyq[1][j] > yhig[cath]+0.001) { yhig[cath] = fXyq[1][j]; ny++; }
- if (nx % 2 || !npadx[cath]) npadx[cath]++;
- if (ny % 2 || !npady[cath]) npady[cath]++;
+ if (fXyq[3][j] > 0) { // exclude virtual pads
+ wMinX[cath] = TMath::Min (wMinX[cath], fXyq[3][j]);
+ wMinY[cath] = TMath::Min (wMinY[cath], fXyq[4][j]);
+ //20-12-05 }
+ if (cath) { xPad1[n1] = fXyq[0][j]; yPad1[n1++] = fXyq[1][j]; }
+ else { xPad0[n0] = fXyq[0][j]; yPad0[n0++] = fXyq[1][j]; }
+ }
+ }
+
+ // Sort
+ if (n0) {
+ TMath::Sort (n0, xPad0, nPad0); // in X
+ for (Int_t i = 1; i < n0; i++)
+ if (xPad0[nPad0[i]] - xPad0[nPad0[i-1]] < -0.01) npadx[0]++;
+ TMath::Sort (n0, yPad0, nPad0); // in Y
+ for (Int_t i = 1; i < n0; i++)
+ if (yPad0[nPad0[i]] - yPad0[nPad0[i-1]] < -0.01) npady[0]++;
}
- //nInY = nYsaved == npady[0] ? npady[0] : npady[1];
- //nInX = nXsaved == npadx[1] ? npadx[1] : npadx[0];
- nInY = TMath::Max (npady[0], npady[1]);
- nInX = TMath::Max (npadx[0], npadx[1]);
- //nInY = npady[0] > 0 ? npady[0] : npady[1];
- //nInX = npadx[1] > 0 ? npadx[1] : npadx[0];
+
+ if (n1) {
+ TMath::Sort (n1, xPad1, nPad1); // in X
+ for (Int_t i = 1; i < n1; i++)
+ if (xPad1[nPad1[i]] - xPad1[nPad1[i-1]] < -0.01) npadx[1]++;
+ TMath::Sort (n1, yPad1, nPad1); // in Y
+ for (Int_t i = 1; i < n1; i++)
+ if (yPad1[nPad1[i]] - yPad1[nPad1[i-1]] < -0.01) npady[1]++;
+ }
+ if (fnPads[0]) { delete [] xPad0; delete [] yPad0; delete [] nPad0; }
+ if (fnPads[1]) { delete [] xPad1; delete [] yPad1; delete [] nPad1; }
+ if (TMath::Abs (wMinY[0] - wMinY[1]) < 1.e-3) nInY = TMath::Max (npady[0], npady[1]);
+ else nInY = wMinY[0] < wMinY[1] ? npady[0] : npady[1];
+ if (TMath::Abs (wMinX[0] - wMinX[1]) < 1.e-3) nInX = TMath::Max (npadx[0], npadx[1]);
+ else nInX = wMinX[0] < wMinX[1] ? npadx[0] : npadx[1];
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Simple()
{
- // Process simple cluster (small number of pads) without EM-procedure
+/// Process simple cluster (small number of pads) without EM-procedure
- Int_t nForFit = 1, clustFit[1] = {1}, nfit;
+ Int_t nForFit = 1, clustFit[1] = {0}, nfit;
Double_t parOk[3] = {0.};
TObjArray *clusters[1];
- clusters[1] = fPixArray;
- for (Int_t i=0; i<fnPads[0]+fnPads[1]; i++) fPadIJ[1][i] = 1;
-
- nfit = Fit(nForFit, clustFit, clusters, parOk);
+ clusters[0] = fPixArray;
+ for (Int_t i = 0; i < fnPads[0]+fnPads[1]; i++) {
+ if (fXyq[2][i] > fgkSaturation-1) fPadIJ[1][i] = -9;
+ else fPadIJ[1][i] = 1;
+ }
+ nfit = Fit(1, nForFit, clustFit, clusters, parOk);
}
//_____________________________________________________________________________
void AliMUONClusterFinderAZ::Errors(AliMUONRawCluster *clus)
{
- // Correct reconstructed coordinates for some clusters and evaluate errors
+/// Correct reconstructed coordinates for some clusters and evaluate errors
Double_t qTot = clus->GetCharge(0), fmin = clus->GetChi2(0);
Double_t xreco = clus->GetX(0), yreco = clus->GetY(0), zreco = clus->GetZ(0);
for (Int_t cath = 0; cath < 2; cath++) {
if (maxdig[cath] < 0) continue;
mdig = fInput->Digit(cath,maxdig[cath]);
- isec = fSegmentation[cath]->Sector(fInput->DetElemId(),mdig->PadX(), mdig->PadY());
- wx[cath] = fSegmentation[cath]->Dpx(fInput->DetElemId(),isec);
- wy[cath] = fSegmentation[cath]->Dpy(fInput->DetElemId(),isec);
- fSegmentation[cath]->GetPadI(fInput->DetElemId(),xreco, yreco, zreco, ix, iy);
- isec = fSegmentation[cath]->Sector(fInput->DetElemId(),ix,iy);
+ isec = fSegmentation[cath]->Sector(mdig->PadX(), mdig->PadY());
+ wx[cath] = fSegmentation[cath]->Dpx(isec);
+ wy[cath] = fSegmentation[cath]->Dpy(isec);
+ fSegmentation[cath]->GetPadI(xreco, yreco, zreco, ix, iy);
+ isec = fSegmentation[cath]->Sector(ix, iy);
if (isec > 0) {
- fSegmentation[cath]->GetPadC(fInput->DetElemId(), ix, iy, xpad, ypad, zpad);
+ fSegmentation[cath]->GetPadC(ix, iy, xpad, ypad, zpad);
dxc[cath] = xreco - xpad;
dyc[cath] = yreco - ypad;
}
for (Int_t cath = 0; cath < 2; cath++) {
if (maxdig[cath] < 0) continue;
mdig = fInput->Digit(cath,maxdig[cath]);
- fSegmentation[cath]->Neighbours(fInput->DetElemId(),mdig->PadX(),mdig->PadY(),&nn,xList,yList);
- isec = fSegmentation[cath]->Sector(fInput->DetElemId(),mdig->PadX(), mdig->PadY());
- //*??
- Float_t spr_x = fResponse->SigmaIntegration() * fResponse->ChargeSpreadX();
- Float_t spr_y = fResponse->SigmaIntegration() * fResponse->ChargeSpreadY();
- //fSegmentation[cath]->FirstPad(fInput->DetElemId(),muons[ihit][1], muons[ihit][2], muons[ihit][3], spr_x, spr_y);
- fSegmentation[cath]->FirstPad(fInput->DetElemId(),xreco, yreco, zreco, spr_x, spr_y);
+ fSegmentation[cath]->Neighbours(mdig->PadX(), mdig->PadY(), &nn, xList, yList);
+ isec = fSegmentation[cath]->Sector(mdig->PadX(), mdig->PadY());
+ /*??
+ Float_t sprX = fResponse->SigmaIntegration() * fResponse->ChargeSpreadX();
+ Float_t sprY = fResponse->SigmaIntegration() * fResponse->ChargeSpreadY();
+ //fSegmentation[cath]->FirstPad(fInput->DetElemId(),muons[ihit][1], muons[ihit][2], muons[ihit][3], sprX, sprY);
+ //fSegmentation[cath]->FirstPad(fInput->DetElemId(),xreco, yreco, zreco, sprX, sprY);
+ fSegmentation[cath]->FirstPad(xreco, yreco, zreco, sprX, sprY);
Int_t border = 0;
- if (fSegmentation[cath]->Sector(fInput->DetElemId(),fSegmentation[cath]->Ix(),fSegmentation[cath]->Iy()) <= 0) {
- fSegmentation[cath]->NextPad(fInput->DetElemId());
+ //if (fSegmentation[cath]->Sector(fInput->DetElemId(),fSegmentation[cath]->Ix(),fSegmentation[cath]->Iy()) <= 0) {
+ if (fSegmentation[cath]->Sector(fSegmentation[cath]->Ix(), fSegmentation[cath]->Iy()) <= 0) {
+ //fSegmentation[cath]->NextPad(fInput->DetElemId());
+ fSegmentation[cath]->NextPad();
border = 1;
}
- //*/
+ */
for (Int_t j=0; j<nn; j++) {
- if (border && yList[j] < fSegmentation[cath]->Iy()) continue;
- fSegmentation[cath]->GetPadC (fInput->DetElemId(), xList[j], yList[j], xpad, ypad, zpad);
+ //if (border && yList[j] < fSegmentation[cath]->Iy()) continue;
+ fSegmentation[cath]->GetPadC(xList[j], yList[j], xpad, ypad, zpad);
//cout << ch << " " << xList[j] << " " << yList[j] << " " << border << " " << x << " " << y << " " << xpad << " " << ypad << endl;
if (TMath::Abs(xpad) < 1 && TMath::Abs(ypad) < 1) continue;
if (xList[j] == mdig->PadX()-1 || mdig->PadX() == 1 &&
//errY = 0.01;
//errX = TMath::Max (errX, 0.144);
clus->SetX(0, xreco); clus->SetY(0, yreco);
- clus->SetX(1, errX); clus->SetY(1, errY);
+ clus->SetErrX(errX); clus->SetErrY(errY);
}
//_____________________________________________________________________________
Double_t dyc, Double_t /*dxc*/, Double_t qtot,
Double_t &yrec, Double_t &xrec, Double_t &erry, Double_t &errx)
{
- // Correct reconstructed coordinates for some clusters and evaluate errors
+/// Correct reconstructed coordinates for some clusters and evaluate errors
erry = 0.01;
errx = 0.144;