]>
Commit | Line | Data |
---|---|---|
d3da6dc4 | 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 | **************************************************************************/ | |
423554a3 | 15 | //. |
16 | // HMPID base class to reconstruct an event | |
17 | //. | |
18 | //. | |
19 | //. | |
d3da6dc4 | 20 | #include "AliHMPIDReconstructor.h" //class header |
21 | #include "AliHMPID.h" //Reconstruct() | |
a1d55ff3 | 22 | #include "AliHMPIDCluster.h" //Dig2Clu() |
9ebbddd4 | 23 | #include "AliHMPIDPid.h" //FillEsd() |
24 | #include "AliHMPIDParam.h" //FillEsd() | |
a0e5c1b9 | 25 | #include <AliCDBEntry.h> //ctor |
26 | #include <AliCDBManager.h> //ctor | |
555a0dbf | 27 | #include <AliESDEvent.h> //FillEsd() |
a0e5c1b9 | 28 | #include <AliRawReader.h> //Reconstruct() for raw digits |
65201c45 | 29 | #include <AliLog.h> // |
d76c31f4 | 30 | #include "AliHMPIDRawStream.h" //ConvertDigits() |
b4b2d95f | 31 | #include "AliHMPIDRecoParamV1.h" //ctor |
3fde2969 | 32 | #include <TVirtualFitter.h> |
d3da6dc4 | 33 | ClassImp(AliHMPIDReconstructor) |
34 | ||
aed5907d | 35 | Int_t AliHMPIDReconstructor::fgStreamLevel = 0; // stream (debug) level |
36 | ||
94b1fbfa | 37 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
ab1d3801 | 38 | AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fDaqSig(0),fDig(0),fClu(0) |
94b1fbfa | 39 | { |
40 | // | |
41 | //ctor | |
42 | // | |
909bfbdc | 43 | AliHMPIDParam::Instance(); //geometry loaded for reconstruction |
451299f3 | 44 | |
ae5a42aa | 45 | fClu=new TObjArray(AliHMPIDParam::kMaxCh+1); fClu->SetOwner(kTRUE); |
46 | fDig=new TObjArray(AliHMPIDParam::kMaxCh+1); fDig->SetOwner(kTRUE); | |
9cc1a411 | 47 | |
ae5a42aa | 48 | for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ |
56c73976 | 49 | fDig->AddAt(new TClonesArray("AliHMPIDDigit",24000),i); |
50 | TClonesArray *pClus = new TClonesArray("AliHMPIDCluster",24000); | |
611e810d | 51 | pClus->SetUniqueID(i); |
52 | fClu->AddAt(pClus,i); | |
94b1fbfa | 53 | } |
451299f3 | 54 | |
9cc1a411 | 55 | AliCDBEntry *pDaqSigEnt =AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig"); //contains TObjArray of TObjArray 14 TMatrixF sigmas values for pads |
56 | if(!pDaqSigEnt) AliFatal("No pedestals from DAQ!"); | |
57 | fDaqSig = (TObjArray*)pDaqSigEnt->GetObject(); | |
58 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){ //chambers loop | |
4f9a834e | 59 | AliDebug(1,Form("DaqSigCut successfully loaded for chamber %i -> %i ",iCh,(Int_t)fDaqSig->At(iCh)->GetUniqueID())); |
a0e5c1b9 | 60 | } |
94b1fbfa | 61 | }//AliHMPIDReconstructor |
d3da6dc4 | 62 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
54104a7c | 63 | void AliHMPIDReconstructor::Dig2Clu(TObjArray *pDigAll,TObjArray *pCluAll,Int_t *pUserCut,Bool_t isTryUnfold) |
d3da6dc4 | 64 | { |
65 | // Finds all clusters for a given digits list provided not empty. Currently digits list is a list of all digits for a single chamber. | |
66 | // Puts all found clusters in separate lists, one per clusters. | |
3c6274c1 | 67 | // Arguments: pDigAll - list of digits for all chambers |
68 | // pCluAll - list of clusters for all chambers | |
d3da6dc4 | 69 | // isTryUnfold - flag to choose between CoG and Mathieson fitting |
70 | // Returns: none | |
3fde2969 | 71 | |
ae5a42aa | 72 | TMatrixF padMap(AliHMPIDParam::kMinPx,AliHMPIDParam::kMaxPcx,AliHMPIDParam::kMinPy,AliHMPIDParam::kMaxPcy); //pads map for single chamber 0..159 x 0..143 |
3c6274c1 | 73 | |
ae5a42aa | 74 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){ //chambers loop |
3c6274c1 | 75 | TClonesArray *pDigCur=(TClonesArray*)pDigAll->At(iCh); //get list of digits for current chamber |
76 | if(pDigCur->GetEntriesFast()==0) continue; //no digits for current chamber | |
d3da6dc4 | 77 | |
3c6274c1 | 78 | padMap=(Float_t)-1; //reset map to -1 (means no digit for this pad) |
79 | TClonesArray *pCluCur=(TClonesArray*)pCluAll->At(iCh); //get list of clusters for current chamber | |
80 | ||
81 | for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){ //digits loop to fill pads map | |
82 | AliHMPIDDigit *pDig= (AliHMPIDDigit*)pDigCur->At(iDig); //get current digit | |
83 | padMap( pDig->PadChX(), pDig->PadChY() )=iDig; //fill the map, (padx,pady) cell takes digit index | |
84 | }//digits loop to fill digits map | |
85 | ||
86 | AliHMPIDCluster clu; //tmp cluster to be used as current | |
3c6274c1 | 87 | for(Int_t iDig=0;iDig<pDigCur->GetEntriesFast();iDig++){ //digits loop for current chamber |
88 | AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCur->At(iDig); //take current digit | |
89 | if(!(pDig=UseDig(pDig->PadChX(),pDig->PadChY(),pDigCur,&padMap))) continue; //this digit is already taken in FormClu(), go after next digit | |
90 | FormClu(&clu,pDig,pDigCur,&padMap); //form cluster starting from this digit by recursion | |
54104a7c | 91 | clu.Solve(pCluCur,pUserCut,isTryUnfold); //solve this cluster and add all unfolded clusters to provided list |
3c6274c1 | 92 | clu.Reset(); //empty current cluster |
93 | }//digits loop for current chamber | |
94 | }//chambers loop | |
d3da6dc4 | 95 | }//Dig2Clu() |
96 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
97 | void AliHMPIDReconstructor::FormClu(AliHMPIDCluster *pClu,AliHMPIDDigit *pDig,TClonesArray *pDigLst,TMatrixF *pDigMap) | |
98 | { | |
a1d55ff3 | 99 | // Forms the initial cluster as a combination of all adjascent digits. Starts from the given digit then calls itself recursevly for all neighbours. |
d3da6dc4 | 100 | // Arguments: pClu - pointer to cluster being formed |
a1d55ff3 | 101 | // Returns: none |
d3da6dc4 | 102 | pClu->DigAdd(pDig);//take this digit in cluster |
103 | ||
3c6274c1 | 104 | Int_t cnt=0,cx[4],cy[4]; |
d3da6dc4 | 105 | |
ae5a42aa | 106 | if(pDig->PadPcX() != AliHMPIDParam::kMinPx){cx[cnt]=pDig->PadChX()-1; cy[cnt]=pDig->PadChY() ;cnt++;} //left |
107 | if(pDig->PadPcX() != AliHMPIDParam::kMaxPx){cx[cnt]=pDig->PadChX()+1; cy[cnt]=pDig->PadChY() ;cnt++;} //right | |
108 | if(pDig->PadPcY() != AliHMPIDParam::kMinPy){cx[cnt]=pDig->PadChX() ; cy[cnt]=pDig->PadChY()-1;cnt++;} //down | |
109 | if(pDig->PadPcY() != AliHMPIDParam::kMaxPy){cx[cnt]=pDig->PadChX() ; cy[cnt]=pDig->PadChY()+1;cnt++;} //up | |
d3da6dc4 | 110 | |
a1d55ff3 | 111 | for (Int_t i=0;i<cnt;i++){//neighbours loop |
3c6274c1 | 112 | if((pDig=UseDig(cx[i],cy[i],pDigLst,pDigMap))) FormClu(pClu,pDig,pDigLst,pDigMap); //check if this neighbour pad fired and mark it as taken |
a1d55ff3 | 113 | }//neighbours loop |
d3da6dc4 | 114 | }//FormClu() |
115 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
94b1fbfa | 116 | void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const |
d3da6dc4 | 117 | { |
118 | //Invoked by AliReconstruction to convert digits to clusters i.e. reconstruct simulated data | |
94b1fbfa | 119 | //Arguments: pDigTree - pointer to Digit tree |
120 | // pCluTree - poitner to Cluster tree | |
d3da6dc4 | 121 | // Returns: none |
122 | AliDebug(1,"Start."); | |
ae5a42aa | 123 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) { |
56c73976 | 124 | pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),7); |
94b1fbfa | 125 | pDigTree->SetBranchAddress(Form("HMPID%d",iCh),&((*fDig)[iCh])); |
126 | } | |
ab1d3801 | 127 | |
07cd858e | 128 | Int_t pUserCut[7]; |
ab1d3801 | 129 | |
130 | if(AliHMPIDReconstructor::GetRecoParam()) { | |
131 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) { | |
132 | pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh); | |
b4b2d95f | 133 | AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh])); |
ab1d3801 | 134 | } |
135 | } | |
136 | else { | |
137 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) { | |
138 | pUserCut[iCh] = 4; // minimal requirement for sigma cut | |
139 | AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh])); | |
b4b2d95f | 140 | AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!")); |
ab1d3801 | 141 | } |
142 | } | |
3fde2969 | 143 | TVirtualFitter* fitter = TVirtualFitter::GetFitter(); |
144 | delete fitter; | |
145 | fitter = TVirtualFitter::Fitter(0,3*6); // create a new fitter to avoid interferrence with others | |
94b1fbfa | 146 | pDigTree->GetEntry(0); |
ab1d3801 | 147 | Dig2Clu(fDig,fClu,pUserCut); //cluster finder |
94b1fbfa | 148 | pCluTree->Fill(); //fill tree for current event |
3fde2969 | 149 | delete fitter; |
ae5a42aa | 150 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){ |
94b1fbfa | 151 | fDig->At(iCh)->Clear(); |
152 | fClu->At(iCh)->Clear(); | |
153 | } | |
d3da6dc4 | 154 | |
70c97c60 | 155 | |
d3da6dc4 | 156 | AliDebug(1,"Stop."); |
157 | }//Reconstruct(for simulated digits) | |
a1d55ff3 | 158 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
94b1fbfa | 159 | void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)const |
160 | { | |
161 | //Invoked by AliReconstruction to convert raw digits from DDL files to digits | |
162 | //Arguments: pRR - ALICE raw reader pointer | |
163 | // pDigTree - pointer to Digit tree | |
164 | // Returns: none | |
165 | AliDebug(1,"Start."); | |
21f61e25 | 166 | // Int_t digcnt=0; |
167 | ||
56c73976 | 168 | Int_t iDigCnt[7]={0,0,0,0,0,0,0}; |
21f61e25 | 169 | |
56c73976 | 170 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){ |
171 | pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh])); | |
172 | } | |
21f61e25 | 173 | |
07cd858e | 174 | Int_t pUserCut[7]; |
ab1d3801 | 175 | |
176 | if(AliHMPIDReconstructor::GetRecoParam()) { | |
177 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) { | |
178 | pUserCut[iCh] = AliHMPIDReconstructor::GetRecoParam()->GetHmpUserCut(iCh); | |
b4b2d95f | 179 | AliDebug(1,Form("UserCut successfully loaded (from AliHMPIDRecoParamV1) for chamber %i -> %i ",iCh,pUserCut[iCh])); |
ab1d3801 | 180 | } |
181 | } | |
182 | else { | |
183 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) { | |
184 | pUserCut[iCh] = 4; // minimal requirement for sigma cut | |
185 | AliDebug(1,Form("UserCut loaded from defaults for chamber %i -> %i ",iCh,pUserCut[iCh])); | |
b4b2d95f | 186 | AliDebug(1,Form("Cannot get AliHMPIDRecoParamV1!")); |
ab1d3801 | 187 | } |
188 | } | |
189 | ||
56c73976 | 190 | AliHMPIDRawStream stream(pRR); |
191 | ||
192 | while(stream.Next()) | |
193 | { | |
194 | Int_t ch = AliHMPIDParam::DDL2C(stream.GetDDLNumber()); | |
195 | for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) { | |
196 | AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]); | |
ab1d3801 | 197 | if(!IsDigSurvive(pUserCut,&dig)) continue; |
56c73976 | 198 | new((*((TClonesArray*)fDig->At(ch)))[iDigCnt[ch]++]) AliHMPIDDigit(dig); //add this digit to the tmp list |
21f61e25 | 199 | } |
21f61e25 | 200 | } |
56c73976 | 201 | |
94b1fbfa | 202 | pDigTree->Fill(); |
21f61e25 | 203 | |
ae5a42aa | 204 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear(); |
21f61e25 | 205 | |
70c97c60 | 206 | |
94b1fbfa | 207 | AliDebug(1,"Stop."); |
208 | }//Reconstruct digits from raw digits | |
209 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |