]>
Commit | Line | Data |
---|---|---|
1d9af2d5 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //. | |
19 | // ITSupgrade base class to reconstruct an event | |
20 | //. | |
21 | //. | |
22 | //. | |
23 | #include "TObjArray.h" | |
24 | #include "TTree.h" | |
25 | #include "AliITSRecPoint.h" | |
26 | #include "AliITSReconstructor.h" | |
27 | #include "AliITSupgrade.h" | |
28 | #include "AliITSUpgradeReconstructor.h" //class header | |
29 | #include "AliITSDetTypeRec.h" | |
30 | #include "AliITS.h" //Reconstruct() | |
31 | #include "AliCDBEntry.h" //ctor | |
32 | #include "AliCDBManager.h" //ctor | |
33 | #include "AliESDEvent.h" //FillEsd() | |
34 | #include "AliRawReader.h" //Reconstruct() for raw digits | |
35 | #include "AliRun.h" | |
36 | #include "AliLog.h" // | |
37 | #include "AliITSRawStream.h" //ConvertDigits() | |
38 | #include "AliRunLoader.h" | |
39 | #include "AliDataLoader.h" | |
40 | #include "AliITSLoader.h" | |
41 | #include "AliITSsegmentationUpgrade.h" | |
42 | #include "AliITSUpgradeClusterFinder.h" | |
43 | #include "AliITStrackerUpgrade.h" | |
44 | #include "AliStack.h" | |
45 | #include "TFile.h" | |
46 | #include "TNtupleD.h" | |
47 | ClassImp(AliITSUpgradeReconstructor) | |
48 | ||
49 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
50 | AliITSUpgradeReconstructor::AliITSUpgradeReconstructor(): | |
51 | AliITSReconstructor(), | |
52 | fRecPoints(0), | |
53 | fNRecPoints(0), | |
54 | fDigits(0) | |
55 | ||
56 | { | |
57 | // | |
58 | //ctor | |
59 | // | |
60 | fRecPoints = new TClonesArray("AliITSRecPoint",3000); | |
61 | fNRecPoints = 0; | |
62 | fDigits = new TObjArray(6); | |
63 | ||
64 | ||
65 | ||
66 | ||
67 | }//AliITSReconstructor | |
68 | //----------------------------------------------------------------------- | |
69 | AliITSUpgradeReconstructor::~AliITSUpgradeReconstructor(){ | |
70 | //Destructor | |
71 | if(fDigits){ | |
72 | fDigits->Delete(); | |
73 | delete fDigits; | |
74 | fDigits=0; | |
75 | } | |
76 | if(fRecPoints){ | |
77 | fRecPoints->Delete(); | |
78 | delete fRecPoints; | |
79 | fRecPoints=0; | |
80 | } | |
81 | } | |
82 | ||
83 | //_________________________________________________________________ | |
84 | void AliITSUpgradeReconstructor::Init() { | |
85 | // Initalize this constructor bet getting/creating the objects | |
86 | // nesseary for a proper ITS reconstruction. | |
87 | // Inputs: | |
88 | // none. | |
89 | // Output: | |
90 | // none. | |
91 | // Return: | |
92 | // none. | |
93 | return; | |
94 | } | |
95 | ||
96 | //___________________________________________________________________________ | |
97 | void AliITSUpgradeReconstructor::SetTreeAddressD(TTree* const treeD){ | |
98 | ||
99 | // Set branch address for the tree of digits. | |
100 | ||
101 | TBranch *branch; | |
102 | Int_t i; | |
103 | char branchname[30]; | |
104 | if(!treeD) return; | |
105 | if (fDigits == 0x0) fDigits = new TObjArray(6); | |
106 | for (i=0; i<6; i++) { | |
107 | if(!(fDigits->At(i))) { | |
108 | fDigits->AddAt(new TClonesArray("AliITSDigitUpgrade",1000),i); | |
109 | } | |
110 | else{ | |
111 | ResetDigits(i); | |
112 | } | |
113 | sprintf(branchname,"ITSDigits%d",i+1); | |
114 | if (fDigits) { | |
115 | branch = treeD->GetBranch(branchname); | |
116 | if (branch) branch->SetAddress(&((*fDigits)[i])); | |
117 | } | |
118 | } | |
119 | } | |
120 | //__________________________________________________________________ | |
121 | void AliITSUpgradeReconstructor::SetTreeAddressR(TTree* const treeR){ | |
122 | // Set branch address for the Reconstructed points Trees. | |
123 | // Inputs: | |
124 | // TTree *treeR Tree containing the RecPoints. | |
125 | // Outputs: | |
126 | // none. | |
127 | // Return: | |
128 | char branchname[30]; | |
129 | Char_t namedet[30]="ITS"; | |
130 | ||
131 | if(!treeR) return; | |
132 | if(fRecPoints==0x0){ | |
133 | fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
134 | } | |
135 | ||
136 | TBranch *branch; | |
137 | sprintf(branchname,"%sRecPoints",namedet); | |
138 | branch = treeR->GetBranch(branchname); | |
139 | ||
140 | if (branch) { | |
141 | branch->SetAddress(&fRecPoints); | |
142 | } | |
143 | else { | |
144 | sprintf(branchname,"%sRecPointsF",namedet); | |
145 | branch = treeR->GetBranch(branchname); | |
146 | if (branch) { | |
147 | branch->SetAddress(&fRecPoints); | |
148 | } | |
149 | } | |
150 | ||
151 | } | |
152 | //_________________________________________________________________________ | |
153 | TBranch* AliITSUpgradeReconstructor::MakeBranchInTree(TTree* const tree, | |
154 | const char* name, const char *classname, | |
155 | void* address,Int_t size,Int_t splitlevel) | |
156 | { | |
157 | // | |
158 | // Makes branch in given tree and diverts them to a separate file | |
159 | // | |
160 | // | |
161 | // | |
162 | ||
163 | if (tree == 0x0) { | |
164 | Error("MakeBranchInTree","Making Branch %s Tree is NULL",name); | |
165 | return 0x0; | |
166 | } | |
167 | TBranch *branch = tree->GetBranch(name); | |
168 | if (branch) { | |
169 | return branch; | |
170 | } | |
171 | if (classname){ | |
172 | branch = tree->Branch(name,classname,address,size,splitlevel); | |
173 | } | |
174 | else { | |
175 | branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel); | |
176 | } | |
177 | ||
178 | return branch; | |
179 | } | |
180 | //________________________________________________________________________ | |
181 | ||
182 | ||
183 | void AliITSUpgradeReconstructor::MakeBranch(TTree* tree, Option_t* option){ | |
184 | ||
185 | //Creates branches for clusters and recpoints | |
186 | Bool_t cR = (strstr(option,"R")!=0); | |
187 | Bool_t cRF = (strstr(option,"RF")!=0); | |
188 | ||
189 | if(cRF)cR = kFALSE; | |
190 | ||
191 | if(cR) MakeBranchR(tree); | |
192 | if(cRF) MakeBranchRF(tree); | |
193 | ||
194 | } | |
195 | ||
196 | //_________________________________________________________________ | |
197 | void AliITSUpgradeReconstructor::MakeBranchR(TTree *treeR, Option_t *opt){ | |
198 | //Creates tree branches for recpoints | |
199 | // Inputs: | |
200 | // cont char *file File name where RecPoints branch is to be written | |
201 | // to. If blank it write the SDigits to the same | |
202 | // file in which the Hits were found. | |
203 | ||
204 | Int_t buffsz = 4000; | |
205 | char branchname[30]; | |
206 | Bool_t oFast= (strstr(opt,"Fast")!=0); | |
207 | Char_t detname[30] = "ITS"; | |
208 | ||
209 | if(oFast){ | |
210 | sprintf(branchname,"%sRecPointsF",detname); | |
211 | } else { | |
212 | sprintf(branchname,"%sRecPoints",detname); | |
213 | } | |
214 | ||
215 | if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
216 | if (treeR) | |
217 | MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99); | |
218 | } | |
219 | ||
220 | //_____________________________________________________________________ | |
221 | void AliITSUpgradeReconstructor::ResetDigits(){ | |
222 | // Reset number of digits and the digits array for the ITS detector. | |
223 | ||
224 | if(!fDigits) return; | |
225 | for(Int_t i=0;i<6;i++){ | |
226 | ResetDigits(i); | |
227 | } | |
228 | } | |
229 | //____________________________________________________________________ | |
230 | void AliITSUpgradeReconstructor::ResetDigits(Int_t branch){ | |
231 | // Reset number of digits and the digits array for this branch. | |
232 | ||
233 | if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear(); | |
234 | ||
235 | } | |
236 | //________________________________________________________________ | |
237 | void AliITSUpgradeReconstructor::AddRecPoint(const AliITSRecPoint &r){ | |
238 | // Add a reconstructed space point to the list | |
239 | // Inputs: | |
240 | // const AliITSRecPoint &r RecPoint class to be added to the tree | |
241 | // of reconstructed points TreeR. | |
242 | // Outputs: | |
243 | // none. | |
244 | // Return: | |
245 | // none. | |
246 | ||
247 | TClonesArray &lrecp = *fRecPoints; | |
248 | new(lrecp[fNRecPoints++]) AliITSRecPoint(r); | |
249 | } | |
250 | ||
251 | //___________________________________________________________________ | |
252 | void AliITSUpgradeReconstructor::DigitsToRecPoints(TTree *treeD,TTree *treeR){ | |
253 | AliITSsegmentationUpgrade *segmentation2 = 0x0; | |
254 | AliITSRecPoint recpnt; | |
255 | if(!segmentation2) | |
256 | segmentation2 = new AliITSsegmentationUpgrade(); | |
257 | AliITSUpgradeClusterFinder *clf = new AliITSUpgradeClusterFinder(); | |
258 | TObjArray *digList= new TObjArray(6); | |
259 | for(Int_t il=0; il<6; il ++) digList->AddAt(new TClonesArray("AliITSDigitUpgrade"),il); | |
260 | for(Int_t ilayer=0; ilayer<6; ilayer ++) { | |
261 | treeD->SetBranchAddress(Form("Layer%d",ilayer),&(*digList)[ilayer]); | |
262 | //treeD->GetListOfLeaves()->Print(); | |
263 | }//loop layer per tbranch | |
264 | treeD->GetEntry(0); | |
265 | ||
266 | for(Int_t ilayer=0; ilayer < 6 ;ilayer ++){ | |
267 | TClonesArray *pArrDig= (TClonesArray*)digList->At(ilayer); | |
268 | clf->StartEvent(); | |
269 | for(Int_t ientr =0; ientr < pArrDig->GetEntries() ; ientr++){ | |
270 | AliITSDigitUpgrade *dig = (AliITSDigitUpgrade*)pArrDig->At(ientr); | |
271 | Int_t colz=dig->GetzPixelNumber(); | |
272 | Int_t rowx=dig->GetxPixelNumber(); | |
273 | Double_t hitcharge= (dig->GetNelectrons()); | |
274 | clf->ProcessHitOnline(ilayer,colz, rowx,(Short_t)hitcharge,dig->GetTracks()); | |
275 | ||
276 | ||
277 | }//ientr | |
278 | clf->FinishEvent(); | |
279 | for(UInt_t nClu = 0; nClu < clf -> GetClusterCount(ilayer); nClu++){ | |
280 | UShort_t charge = clf->GetCharge(ilayer, nClu); | |
281 | recpnt.SetQ(charge); | |
282 | recpnt.SetLayer(ilayer); | |
283 | Int_t *lab=clf->GetLabels(ilayer,nClu); | |
284 | for(Int_t l=0; l<3; l++) { | |
285 | recpnt.SetLabel(lab[l],l); | |
286 | } | |
287 | if(clf->GetClusterSize(ilayer,nClu)==2){ | |
288 | printf("\n\n CLUSTER LABELS (size %i) \n",clf->GetClusterSize(ilayer,nClu)); | |
289 | for(Int_t i=0; i<10; i++ ){ | |
290 | printf(" %i ",lab[i]); | |
291 | } | |
292 | printf("\n\n"); | |
293 | } | |
294 | ||
295 | ||
296 | ||
297 | Bool_t check2; | |
298 | Double_t xcheck2=0.; | |
299 | Double_t ycheck2=0.; | |
300 | Double_t zcheck2=0.; | |
301 | Double_t xzl2[2]={0.,0.}; | |
302 | Double_t XpixC2,ZpixC2=0.; | |
303 | ||
304 | XpixC2 = clf-> GetClusterMeanRow(ilayer, nClu); | |
305 | ZpixC2 = clf-> GetClusterMeanCol(ilayer, nClu); | |
306 | xzl2[0] = XpixC2*(segmentation2->GetCellSizeX(ilayer))+0.5*(segmentation2-> GetCellSizeX(ilayer)); | |
307 | xzl2[1] = ZpixC2*(segmentation2->GetCellSizeZ(ilayer))+0.5*(segmentation2->GetCellSizeZ(ilayer))-(segmentation2->GetHalfLength(ilayer)); | |
308 | check2 = segmentation2->DetToGlobal(ilayer,xzl2[0], xzl2[1],xcheck2,ycheck2,zcheck2); | |
309 | recpnt.SetType(clf->GetClusterType(ilayer,nClu )); | |
310 | // recpnt.SetLocalCoord(xzl2[0],xzl2[1]); //temporary solution (no LocalToTrack Matrix) | |
311 | //from global to tracking system coordinate | |
312 | // global coordinate -> local coordinate getting alpha angle of the recpoint | |
313 | Float_t xclg = xcheck2;//upgrade clusters global coordinate ( ITS official: GetX tracking coordinate) | |
314 | Float_t yclg = ycheck2; | |
315 | Float_t zclg = zcheck2; | |
316 | Double_t phiclu1rad, phiclu1deg; | |
317 | phiclu1rad=TMath::ATan2(yclg,xclg);//cluster phi angle (rad) | |
318 | if (phiclu1rad<0) phiclu1rad+=TMath::TwoPi();//from 0 to 360 | |
319 | else if (phiclu1rad>=TMath::TwoPi()) phiclu1rad-=TMath::TwoPi();// | |
320 | ||
321 | phiclu1deg=180.*phiclu1rad/TMath::Pi();// in deg | |
322 | Int_t ladder;// virtual segmentation starting from the cluster phi | |
323 | ||
324 | ladder=(Int_t)phiclu1deg/18;// in which ladder the cluster is | |
325 | Double_t alpha= (ladder*18.+9.)*TMath::Pi()/180.;//angle at the center of the ladder (rad) | |
326 | ||
327 | //alpha rotation | |
328 | Float_t xclu1_tr = xclg*TMath::Cos(alpha)-yclg*TMath::Sin(alpha); | |
329 | Float_t yclu1 = yclg*TMath::Cos(alpha)+xclg*TMath::Sin(alpha); | |
330 | Float_t xclu1 = TMath::Sqrt(xclu1_tr*xclu1_tr+yclu1*yclu1); | |
331 | Float_t zclu1 = zclg; | |
332 | Double_t phi_trk= (phiclu1rad-alpha);// cluster angle in the rotated system (rad) | |
333 | ||
334 | yclu1=xclu1*phi_trk; // tracking system coordinate: r*phi | |
335 | recpnt.SetX(0.); | |
336 | recpnt.SetY(yclu1); | |
337 | recpnt.SetZ(zclu1); | |
338 | // | |
339 | Double_t xsize, zsize; | |
340 | segmentation2->GetSegmentation(ilayer,xsize, zsize); | |
341 | recpnt.SetSigmaY2(xsize/TMath::Sqrt(12)*xsize/TMath::Sqrt(12)); | |
342 | recpnt.SetSigmaZ2(zsize/TMath::Sqrt(12)*zsize/TMath::Sqrt(12)); | |
343 | TClonesArray &lrecp = *fRecPoints; | |
344 | new(lrecp[fNRecPoints++]) AliITSRecPoint(recpnt); | |
345 | }//cluster list entries | |
346 | treeR->Fill(); | |
347 | ResetRecPoints(); | |
348 | }//ilayer | |
349 | } | |
350 | //_______________________________________________________________________________________________________________ | |
351 | AliTracker* AliITSUpgradeReconstructor::CreateTracker() const | |
352 | { | |
353 | // create a ITS tracker | |
354 | // Int_t trackerOpt = GetRecoParam()->GetTracker(); | |
355 | // AliTracker* tracker; | |
356 | ||
357 | // tracker = new AliITStrackerUpgrade(); | |
358 | AliITStrackerUpgrade *trackUp = new AliITStrackerUpgrade(); | |
359 | if(GetRecoParam()->GetTrackerSAOnly()) trackUp->SetSAFlag(kTRUE); | |
360 | if(trackUp->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n"); | |
361 | if(GetRecoParam()->GetInwardFindingSA()){ | |
362 | trackUp->SetInwardFinding(); | |
363 | trackUp->SetInnerStartLayer(GetRecoParam()->GetInnerStartLayerSA()); | |
364 | }else{ | |
365 | trackUp->SetOutwardFinding(); | |
366 | trackUp->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA()); | |
367 | } | |
368 | trackUp->SetMinNPoints(GetRecoParam()->GetMinNPointsSA()); | |
369 | return trackUp; | |
370 | } | |
371 | ||
372 | ||
373 |