]>
Commit | Line | Data |
---|---|---|
0fe8fa07 | 1 | // ************************************************************************** |
2 | // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | // * * | |
4 | // * Author: The ALICE Off-line Project. * | |
5 | // * Contributors are mentioned in the code where appropriate. * | |
6 | // * * | |
7 | // * Permission to use, copy, modify and distribute this software and its * | |
8 | // * documentation strictly for non-commercial purposes is hereby granted * | |
9 | // * without fee, provided that the above copyright notice appears in all * | |
10 | // * copies and that both the copyright notice and this permission notice * | |
11 | // * appear in the supporting documentation. The authors make no claims * | |
12 | // * about the suitability of this software for any purpose. It is * | |
13 | // * provided "as is" without express or implied warranty. * | |
14 | // ************************************************************************** | |
15 | ||
db910db9 | 16 | #include "AliRICHCluster.h" //class header |
17 | #include <TMinuit.h> //Solve() | |
18 | #include <AliStack.h> //FindCfm(), Solve() | |
19 | #include <TParticle.h> //FindCfm() | |
20 | #include <TClonesArray.h> //Solve() Test() | |
21 | ||
0fe8fa07 | 22 | ClassImp(AliRICHCluster) |
23 | //__________________________________________________________________________________________________ | |
db910db9 | 24 | void AliRICHCluster::CoG() |
0fe8fa07 | 25 | { |
db910db9 | 26 | // Calculates naive cluster position as a center of gravity of its digits. |
27 | // Arguments: none | |
28 | // Returns: shape of the cluster i.e. the box which fully contains the cluster | |
29 | if(fDigs==0) return; //no digits in this cluster | |
30 | fX=fY=0; //set cluster position to (0,0) to start to collect contributions | |
31 | for(Int_t iDig=0;iDig<fDigs->GetEntriesFast();iDig++){//digits loop | |
32 | AliRICHDigit *pDig=(AliRICHDigit*)fDigs->At(iDig); //get pointer to next digit | |
33 | TVector pad=pDig->Pad(); Double_t q=pDig->Qdc(); //get pad adn QDC of this digit | |
34 | TVector2 x2=AliRICHParam::Pad2Loc(pad); //calculate center of the pad in LORS | |
35 | fX += x2.X()*q;fY +=x2.Y()*q; //sum up digit centers weighted by QDC | |
36 | }//digits loop | |
37 | fX/=fQdc;fY/=fQdc; //final center of gravity | |
0422a446 | 38 | |
db910db9 | 39 | TVector2 center = AliRICHParam::Pad2Loc(AliRICHParam::Loc2Pad(TVector2(fX,fY)));//center of the pad containing calculated cluster position |
40 | fX += AliRICHParam::CogCorr(fX-center.X()); //correct cluster position for sinoid | |
0422a446 | 41 | |
db910db9 | 42 | fStatus=kCoG; |
43 | }//CoG() | |
0422a446 | 44 | //__________________________________________________________________________________________________ |
db910db9 | 45 | void AliRICHCluster::FitFunc(Int_t &iNpars, Double_t *, Double_t &chi2, Double_t *par, Int_t ) |
0422a446 | 46 | { |
db910db9 | 47 | // Cluster fit function |
48 | // par[0]=x par[1]=y par[2]=q for the first Mathieson shape | |
49 | // par[3]=x par[4]=y par[5]=q for the second Mathieson shape and so on up to iNpars/3 Mathieson shapes | |
50 | // We need to calculate QpadExp - QpadMathieson summup over all pads of the cluster | |
51 | // Here QpadExp is a actual charge of the pad, QpadMathieson is calculated charge of the pad induced by all Mathiesons | |
52 | // Arguments: iNpars - number of parameters which is number of local maxima of cluster * 3 | |
53 | // chi2 - function result to be minimised | |
54 | // par - parameters array of size iNpars | |
55 | // Returns: none | |
0422a446 | 56 | AliRICHCluster *pClu=(AliRICHCluster*)gMinuit->GetObjectFit(); |
57 | Int_t iNmathiesons = iNpars/3; | |
58 | ||
59 | TVector2 curMathiesonPos; | |
60 | chi2 = 0; | |
db910db9 | 61 | for(Int_t i=0;i<pClu->Size();i++){ //loop on all pads of the cluster |
62 | TVector pad = pClu->Dig(i)->Pad(); | |
63 | Double_t dQpadExp = pClu->Dig(i)->Qdc(); | |
64 | Double_t dQpadMathieson = 0; | |
65 | for(Int_t j=0;j<iNmathiesons;j++){ //Mathiesons loop as all of them may contribute to this pad | |
66 | curMathiesonPos.Set(par[3*j],par[3*j+1]); //get position of current Mathieson | |
67 | dQpadMathieson += par[3*j+2]*AliRICHParam::FracQdc(curMathiesonPos,pad); //sums up contributions to the current pad from all Mathiesons | |
0422a446 | 68 | } |
db910db9 | 69 | chi2 += TMath::Power((dQpadMathieson-dQpadExp),2); // |
70 | } //loop on all pads of the cluster | |
71 | }//FitFunction() | |
0422a446 | 72 | //__________________________________________________________________________________________________ |
db910db9 | 73 | void AliRICHCluster::Print(Option_t* opt)const |
0422a446 | 74 | { |
db910db9 | 75 | //Print current cluster |
76 | const char *status=0; | |
77 | switch(fStatus){ | |
78 | case kFormed: status="formed" ;break; | |
79 | case kUnfolded: status="unfolded" ;break; | |
80 | case kCoG: status="coged" ;break; | |
81 | case kEmpty: status="empty" ;break; | |
82 | } | |
db910db9 | 83 | Printf("%s cs=%2i, Size=%2i (x=%7.3f cm,y=%7.3f cm,Q=%4i qdc), %s", |
0bb890db | 84 | opt,fCham,Size(),fX,fY,fQdc,status); |
85 | for(Int_t i=0;i<Size();i++) Dig(i)->Print(); | |
db910db9 | 86 | }//Print() |
87 | //__________________________________________________________________________________________________ | |
88 | Int_t AliRICHCluster::Solve(TClonesArray *pCluLst,Bool_t isTryUnfold) | |
89 | { | |
90 | //This methode is invoked when the cluster is formed to solve it. Solve the cluster means to try to unfold the cluster | |
91 | //into the local maxima number of clusters. This methode is invoked by AliRICHRconstructor::Dig2Clu() on cluster by cluster basis. | |
92 | //At this point, cluster contains a list of digits, cluster charge and size is precalculated in AddDigit(), position is preset to (-1,-1) in ctor, | |
93 | //status is preset to kFormed in AddDigit(), chamber-sector info is preseted to actual values in AddDigit() | |
94 | //Method first finds number of local maxima and if it's more then one tries to unfold this cluster into local maxima number of clusters | |
95 | //Arguments: pCluLst - cluster list pointer where to add new cluster(s) | |
96 | // isTryUnfold - flag to switch on/off unfolding | |
97 | // Returns: number of local maxima of original cluster | |
98 | ||
99 | //Phase 0. Initialise TMinuit | |
100 | const Int_t kMaxLocMax=6; //max allowed number of loc max for fitting | |
101 | TMinuit *pMinuit = new TMinuit(3*kMaxLocMax); //init MINUIT with this number of parameters (3 params per mathieson) | |
102 | pMinuit->SetObjectFit((TObject*)this); pMinuit->SetFCN(AliRICHCluster::FitFunc); //set fit function | |
103 | Double_t aArg=-1,parStart,parStep,parLow,parHigh; Int_t iErrFlg; //tmp vars for TMinuit | |
104 | pMinuit->mnexcm("SET PRI",&aArg,1,iErrFlg); //suspend all printout from TMinuit | |
105 | pMinuit->mnexcm("SET NOW",&aArg,0,iErrFlg); //suspend all warning printout from TMinuit | |
106 | //Phase 1. Find number of local maxima. Strategy is to check if the current pad has QDC more then all neigbours | |
0422a446 | 107 | Int_t iLocMaxCnt=0; |
db910db9 | 108 | for(Int_t iDig1=0;iDig1<Size();iDig1++) { //first digits loop |
109 | AliRICHDigit *pDig1 = Dig(iDig1); //take next digit | |
110 | Int_t iHowManyMoreCnt = 0; //counts how many neighbouring pads has QDC more then current one | |
111 | for(Int_t iDig2=0;iDig2<Size();iDig2++) { //loop on all digits again | |
db910db9 | 112 | if(iDig1==iDig2) continue; //the same digit, no need to compare |
3e6840d4 | 113 | AliRICHDigit *pDig2 = Dig(iDig2); //take second digit to compare with the first one |
0422a446 | 114 | Int_t dist = TMath::Sign(Int_t(pDig1->PadX()-pDig2->PadX()),1)+TMath::Sign(Int_t(pDig1->PadY()-pDig2->PadY()),1);//distance between pads |
db910db9 | 115 | if(dist==1) //means dig2 is a neighbour of dig1 |
116 | if(pDig2->Qdc()>=pDig1->Qdc()) iHowManyMoreCnt++; //count number of pads with Q more then Q of current pad | |
0422a446 | 117 | }//second digits loop |
3e6840d4 | 118 | if(iHowManyMoreCnt==0&&iLocMaxCnt<kMaxLocMax){ //this pad has Q more then any neighbour so it's local maximum |
db910db9 | 119 | TVector2 x2=AliRICHParam::Pad2Loc(pDig1->Pad()); //take pad center position and use it as parameter for current Mathienson shape |
0422a446 | 120 | pMinuit->mnparm(3*iLocMaxCnt ,Form("x%i",iLocMaxCnt),parStart=x2.X() ,parStep=0.01,parLow=0,parHigh=0,iErrFlg); |
121 | pMinuit->mnparm(3*iLocMaxCnt+1,Form("y%i",iLocMaxCnt),parStart=x2.Y() ,parStep=0.01,parLow=0,parHigh=0,iErrFlg); | |
db910db9 | 122 | pMinuit->mnparm(3*iLocMaxCnt+2,Form("q%i",iLocMaxCnt),parStart=pDig1->Qdc(),parStep=0.01,parLow=0,parHigh=0,iErrFlg); |
0422a446 | 123 | iLocMaxCnt++; |
124 | }//if this pad is local maximum | |
125 | }//first digits loop | |
db910db9 | 126 | //Phase 2. Fit loc max number of Mathiesons or add this current cluster to the list |
127 | Int_t iCluCnt=pCluLst->GetEntriesFast(); //get current number of clusters already stored in the list by previous operations | |
3e6840d4 | 128 | if(isTryUnfold==kTRUE && iLocMaxCnt<kMaxLocMax){ //resonable number of local maxima to fit and user requested it |
db910db9 | 129 | pMinuit->mnexcm("MIGRAD" ,&aArg,0,iErrFlg); //start fitting |
3eb8b116 | 130 | if (!iErrFlg) { // Only if MIGRAD converged normally |
131 | Double_t fitX,fitY,fitQ,d1,d2,d3; TString sName; //vars to get results from TMinuit | |
132 | for(Int_t i=0;i<iLocMaxCnt;i++){//local maxima loop | |
133 | pMinuit->mnpout(3*i ,sName, fitX, d1 , d2, d3, iErrFlg); | |
134 | pMinuit->mnpout(3*i+1 ,sName, fitY, d1 , d2, d3, iErrFlg); | |
135 | pMinuit->mnpout(3*i+2 ,sName, fitQ, d1 , d2, d3, iErrFlg); | |
136 | if (TMath::Abs(fitQ)>2147483647.0) { | |
137 | //PH 2147483647 is the max. integer | |
138 | //PH This apparently is a problem which needs investigation | |
139 | AliWarning(Form("Too big or too small fitQ %f",fitQ)); | |
140 | fitQ = TMath::Sign((Double_t)2147483647,fitQ); | |
141 | } | |
142 | new ((*pCluLst)[iCluCnt++]) AliRICHCluster(C(),fitX,fitY,(Int_t)fitQ); //add new unfolded clusters | |
143 | }//local maxima loop | |
144 | } | |
db910db9 | 145 | }else{//do not unfold since number of loc max is unresonably high or user's baned unfolding |
146 | CoG(); | |
147 | new ((*pCluLst)[iCluCnt++]) AliRICHCluster(*this); //add this raw cluster | |
0422a446 | 148 | } |
db910db9 | 149 | delete pMinuit; |
150 | return iLocMaxCnt; | |
151 | }//Solve() | |
0422a446 | 152 | //__________________________________________________________________________________________________ |
db910db9 | 153 | void AliRICHCluster::Test(Double_t x,Double_t y,Double_t e,Bool_t isTryUnfold) |
0422a446 | 154 | { |
155 | //This is to test all cluster functionality | |
db910db9 | 156 | //Uses AddDigit() to add a predifined pad structure and then calls Solve |
157 | TVector2 hitX2(x,y); | |
158 | Int_t iQtot=AliRICHParam::TotQdc(hitX2,e); | |
0422a446 | 159 | if(iQtot==0){ |
160 | Printf("Provided hit position out of sensitive area"); | |
161 | return; | |
162 | } | |
163 | TVector area=AliRICHParam::Loc2Area(hitX2); | |
164 | TVector pad(2); | |
db910db9 | 165 | AliRICHCluster clu; |
0422a446 | 166 | for(pad[1]=area[1];pad[1]<=area[3];pad[1]++){//affected pads loop first y |
167 | for(pad[0]=area[0];pad[0]<=area[2];pad[0]++){//then x | |
168 | Double_t dQpad=iQtot*AliRICHParam::FracQdc(hitX2,pad);//charge fraction from Mathieson centered at x to pad | |
92830e91 | 169 | clu.DigAdd(new AliRICHDigit(pad,dQpad)); |
0422a446 | 170 | }//affected pads loop |
171 | } | |
92830e91 | 172 | clu.CoG(); clu.Print("Initial cluster:"); |
db910db9 | 173 | TClonesArray *pCluLst=new TClonesArray("AliRICHCluster",1); |
174 | clu.Solve(pCluLst,isTryUnfold); | |
2a92c3fe | 175 | Printf("Initial hit : (%.2f,%.2f) Qtot=%i E=%.2f eV",x,y,iQtot,e*1e9); |
db910db9 | 176 | ((AliRICHCluster *)pCluLst->At(0))->Print("Solved cluster:"); |
177 | ||
178 | delete pCluLst; clu.Reset(); | |
0422a446 | 179 | }//Test() |
db910db9 | 180 | //__________________________________________________________________________________________________ |
181 | void AliRICHCluster::Test() | |
182 | { | |
183 | //Test cluster builder by a number of predefined digit patterns | |
184 | //Arguments: none | |
185 | // Returns: none | |
186 | AliRICHCluster clu; Int_t ch,padx,pady,qdc; TClonesArray *pCluLst=new TClonesArray("AliRICHCluster",10); | |
187 | Printf("2 digits vertical cluster"); | |
0bb890db | 188 | clu.DigAdd(new AliRICHDigit(AliRICHDigit::P2A(ch=1,padx=3,pady=3),qdc=101)); |
189 | clu.DigAdd(new AliRICHDigit(AliRICHDigit::P2A(ch=1,padx=3,pady=4),qdc=202)); | |
190 | ||
191 | clu.Print("Formed cluster:"); | |
192 | clu.Solve(pCluLst,kTRUE); | |
193 | pCluLst->Print(); | |
db910db9 | 194 | delete pCluLst; |
195 | } |