]>
Commit | Line | Data |
---|---|---|
121a60bd | 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 | ||
0422a446 | 16 | #include "AliRICHReconstructor.h" //class header |
17 | #include <AliRawReader.h> //Reconstruct(...) | |
18 | #include "AliRICHv1.h" //Reconstruct(...) | |
19 | #include <AliRun.h> //ConvertDigits uses gAlice | |
20 | #include <TMinuit.h> //Dig2Clu() | |
121a60bd | 21 | ClassImp(AliRICHReconstructor) |
22 | ||
0422a446 | 23 | void AliRICHReconstructor::Reconstruct(AliRunLoader *pAL,AliRawReader* pRR)const |
24 | { | |
25 | ||
26 | AliLoader *pRL=pAL->GetDetectorLoader("RICH"); | |
27 | AliRICH *pRich=(AliRICH*)pAL->GetAliRun()->GetDetector("RICH"); | |
28 | ||
29 | AliRICHDigit dig; //tmp digit, raw digit will be converted to it | |
30 | TClonesArray *pDigList=new TClonesArray("AliRICHDigit"); Int_t iDigCnt=0; //tmp list of digits for single chamber only | |
31 | ||
32 | Int_t iEvtN=0; | |
33 | while(pRR->NextEvent()){//events loop | |
34 | pAL->GetEvent(iEvtN++); | |
35 | pRL->MakeTree("R"); pRich->MakeBranch("R"); | |
36 | ||
37 | for(Int_t iChN=1;iChN<=7;iChN++){//chambers loop | |
38 | pRR->Select(AliRICHDigit::kRichRawId,2*iChN-2,2*iChN-1);//select only DDL files for the current chamber | |
39 | UInt_t w32=0; | |
40 | while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files) | |
41 | UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13 | |
42 | dig.Raw2Dig(ddl,w32); | |
43 | AliDebug(1,Form("Ch=%i DDL=%i raw=0x%x digit=(%3i,%3i,%3i,%3i) Q=%5.2f",iChN,ddl,w32,dig.Chamber(),dig.Sector(),dig.PadX(),dig.PadY(),dig.Qdc())); | |
44 | new((*pDigList)[iDigCnt++]) AliRICHDigit(dig); //add this digit to the tmp list | |
45 | }//raw records loop | |
46 | if(iDigCnt) Dig2Clu(pDigList,pRich->Clusters(iChN));//cluster finder for the current chamber if any digits present | |
47 | pRR->Reset(); | |
48 | pDigList->Delete(); iDigCnt=0;//clean up list of digits for the current chamber | |
49 | }//chambers loop | |
50 | pRL->TreeR()->Fill(); //fill tree for current event | |
51 | pRL->WriteRecPoints("OVERWRITE");//write out clusters for current event | |
52 | pRich->ClustersReset(); | |
53 | }//events loop | |
54 | pRL->UnloadRecPoints(); | |
55 | }//Reconstruct raw data | |
56 | //__________________________________________________________________________________________________ | |
57 | void AliRICHReconstructor::Dig2Clu(TClonesArray *pDigList,TClonesArray *pCluList)const | |
58 | { | |
59 | //Finds all clusters for a given digits list provided not empty. Currently digits list provided is a list of all digits for a single chamber. | |
60 | //Puts all found clusters in the given clusters list. | |
61 | //Arguments: pDigList - list of digits provided not empty | |
62 | // Returns: none | |
63 | TMatrixF digMap(1,AliRICHParam::NpadsX(),1,AliRICHParam::NpadsY()); digMap=(Float_t)-1; //digit map for one chamber reseted to -1 | |
64 | for(Int_t iDigN=0 ; iDigN < pDigList->GetEntriesFast() ; iDigN++){ //digits loop to fill digits map | |
65 | AliRICHDigit *pDig= (AliRICHDigit*)pDigList->At(iDigN); | |
66 | digMap( pDig->PadX(), pDig->PadY() )=iDigN; //(padx,pady) cell takes digit number | |
67 | } | |
68 | ||
69 | AliRICHCluster clu; Int_t iCluCnt=0; //tmp cluster and cluster counter | |
70 | ||
71 | for(Int_t iDigN=0;iDigN<pDigList->GetEntriesFast();iDigN++){//digits loop | |
72 | AliRICHDigit *pDig=(AliRICHDigit*)pDigList->At(iDigN); | |
73 | if(!(pDig=UseDig(pDig->PadX(),pDig->PadY(),pDigList,&digMap))) continue; //this digit is already taken in FormCluster(), go after next digit | |
74 | FormCluster(&clu,pDig,pDigList,&digMap); //form cluster starting from this digit | |
75 | TMinuit *pMinuit=clu.Solve(); //solve this cluster | |
76 | ||
77 | if(pMinuit){//means cluster is solved into local maxima number of clusters, so add all of them in loop | |
78 | Double_t x=-1,y=-1,q=-1;TString str; Double_t b1,b2,b3; Int_t iErrFlg;//tmp to withdraw resulting parameters | |
79 | for(Int_t i=0;i<clu.Nlocmax();i++){//take resulting parameters | |
80 | pMinuit->mnpout(3*i ,str, x, b1, b2, b3, iErrFlg); | |
81 | pMinuit->mnpout(3*i+1,str, y, b1, b2, b3, iErrFlg); | |
82 | pMinuit->mnpout(3*i+2,str, q, b1, b2, b3, iErrFlg); | |
83 | clu.Set(x,y,(Int_t)q); | |
84 | new((*pCluList)[iCluCnt++]) AliRICHCluster(clu); | |
85 | } | |
86 | delete pMinuit; | |
87 | }else//means cluster is solved as simple center of gravity cluster, add it | |
88 | new((*pCluList)[iCluCnt++]) AliRICHCluster(clu); | |
89 | clu.Reset();//make current cluster empty | |
90 | }//digits loop | |
91 | }//Dig2Clu() | |
92 | //__________________________________________________________________________________________________ | |
93 | void AliRICHReconstructor::FormCluster(AliRICHCluster *pClu,AliRICHDigit *pDig,TClonesArray *pDigList,TMatrixF *pDigMap)const | |
94 | { | |
95 | //Forms the initial cluster as a sum of all adjascent digits. Starts from the given digit | |
96 | //then calls itself recursevly for all neighbours. | |
97 | //Arguments: pClu - pointer to cluster being formed | |
98 | // Returns: none | |
99 | pClu->AddDigit(pDig);//take this digit in cluster and mark it as taken | |
100 | ||
101 | Int_t x[4],y[4]; | |
102 | ||
103 | Int_t iNnei=AliRICHParam::PadNeighbours(pDig->PadX(),pDig->PadY(),x,y);//returns in x,y all possible neighbours of the given one | |
104 | for (Int_t i=0;i<iNnei;i++) | |
105 | if((pDig=UseDig(x[i],y[i],pDigList,pDigMap))) FormCluster(pClu,pDig,pDigList,pDigMap); | |
106 | }//FormCluster() |