1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // ITSupgrade base class to reconstruct an event
23 #include "TObjArray.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
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"
47 ClassImp(AliITSUpgradeReconstructor)
49 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 AliITSUpgradeReconstructor::AliITSUpgradeReconstructor():
51 AliITSReconstructor(),
60 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
62 fDigits = new TObjArray(6);
67 }//AliITSReconstructor
68 //-----------------------------------------------------------------------
69 AliITSUpgradeReconstructor::~AliITSUpgradeReconstructor(){
83 //_________________________________________________________________
84 void AliITSUpgradeReconstructor::Init() {
85 // Initalize this constructor bet getting/creating the objects
86 // nesseary for a proper ITS reconstruction.
96 //___________________________________________________________________________
97 void AliITSUpgradeReconstructor::SetTreeAddressD(TTree* const treeD){
99 // Set branch address for the tree of digits.
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);
113 sprintf(branchname,"ITSDigits%d",i+1);
115 branch = treeD->GetBranch(branchname);
116 if (branch) branch->SetAddress(&((*fDigits)[i]));
120 //__________________________________________________________________
121 void AliITSUpgradeReconstructor::SetTreeAddressR(TTree* const treeR){
122 // Set branch address for the Reconstructed points Trees.
124 // TTree *treeR Tree containing the RecPoints.
129 Char_t namedet[30]="ITS";
133 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
137 sprintf(branchname,"%sRecPoints",namedet);
138 branch = treeR->GetBranch(branchname);
141 branch->SetAddress(&fRecPoints);
144 sprintf(branchname,"%sRecPointsF",namedet);
145 branch = treeR->GetBranch(branchname);
147 branch->SetAddress(&fRecPoints);
152 //_________________________________________________________________________
153 TBranch* AliITSUpgradeReconstructor::MakeBranchInTree(TTree* const tree,
154 const char* name, const char *classname,
155 void* address,Int_t size,Int_t splitlevel)
158 // Makes branch in given tree and diverts them to a separate file
164 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
167 TBranch *branch = tree->GetBranch(name);
172 branch = tree->Branch(name,classname,address,size,splitlevel);
175 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
180 //________________________________________________________________________
183 void AliITSUpgradeReconstructor::MakeBranch(TTree* tree, Option_t* option){
185 //Creates branches for clusters and recpoints
186 Bool_t cR = (strstr(option,"R")!=0);
187 Bool_t cRF = (strstr(option,"RF")!=0);
191 if(cR) MakeBranchR(tree);
192 if(cRF) MakeBranchRF(tree);
196 //_________________________________________________________________
197 void AliITSUpgradeReconstructor::MakeBranchR(TTree *treeR, Option_t *opt){
198 //Creates tree branches for recpoints
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.
206 Bool_t oFast= (strstr(opt,"Fast")!=0);
207 Char_t detname[30] = "ITS";
210 sprintf(branchname,"%sRecPointsF",detname);
212 sprintf(branchname,"%sRecPoints",detname);
215 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
217 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
220 //_____________________________________________________________________
221 void AliITSUpgradeReconstructor::ResetDigits(){
222 // Reset number of digits and the digits array for the ITS detector.
225 for(Int_t i=0;i<6;i++){
229 //____________________________________________________________________
230 void AliITSUpgradeReconstructor::ResetDigits(Int_t branch){
231 // Reset number of digits and the digits array for this branch.
233 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
236 //________________________________________________________________
237 void AliITSUpgradeReconstructor::AddRecPoint(const AliITSRecPoint &r){
238 // Add a reconstructed space point to the list
240 // const AliITSRecPoint &r RecPoint class to be added to the tree
241 // of reconstructed points TreeR.
247 TClonesArray &lrecp = *fRecPoints;
248 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
251 //___________________________________________________________________
252 void AliITSUpgradeReconstructor::DigitsToRecPoints(TTree *treeD,TTree *treeR){
253 AliITSsegmentationUpgrade *segmentation2 = 0x0;
254 AliITSRecPoint recpnt;
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
266 for(Int_t ilayer=0; ilayer < 6 ;ilayer ++){
267 TClonesArray *pArrDig= (TClonesArray*)digList->At(ilayer);
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());
279 for(UInt_t nClu = 0; nClu < clf -> GetClusterCount(ilayer); nClu++){
280 UShort_t charge = clf->GetCharge(ilayer, nClu);
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);
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]);
301 Double_t xzl2[2]={0.,0.};
302 Double_t XpixC2,ZpixC2=0.;
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();//
321 phiclu1deg=180.*phiclu1rad/TMath::Pi();// in deg
322 Int_t ladder;// virtual segmentation starting from the cluster phi
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)
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)
334 yclu1=xclu1*phi_trk; // tracking system coordinate: r*phi
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
350 //_______________________________________________________________________________________________________________
351 AliTracker* AliITSUpgradeReconstructor::CreateTracker() const
353 // create a ITS tracker
354 // Int_t trackerOpt = GetRecoParam()->GetTracker();
355 // AliTracker* tracker;
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());
365 trackUp->SetOutwardFinding();
366 trackUp->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
368 trackUp->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());