]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUReconstructor.cxx
Added new class AliITSUClusterPix. Clusters are stored in local frame,
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUReconstructor.cxx
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: AliITSUReconstructor.cxx 58442 2012-09-04 17:17:06Z masera $ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // class for ITS reconstruction                                              //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "Riostream.h"
25 #include "AliITSUReconstructor.h"
26 #include "AliRun.h"
27 #include "AliRawReader.h"
28 #include "AliESDEvent.h"
29
30 #include "AliTracker.h"
31 #include "AliITStrackerMI.h"
32
33 #include "AliITSUGeomTGeo.h"
34 #include "AliITSUSegmentationPix.h"
35 #include "AliITSUDigitPix.h"
36 #include "AliITSUClusterizer.h"
37 #include "AliITSUClusterPix.h"
38
39 ClassImp(AliITSUReconstructor)
40
41 //___________________________________________________________________________
42 AliITSUReconstructor::AliITSUReconstructor() 
43 :  AliReconstructor()
44   ,fGM(0)
45   ,fClusterFinders(0)
46   ,fRecPoints(0)
47 {
48   // Default constructor
49
50 }
51
52 //___________________________________________________________________________
53 AliITSUReconstructor::~AliITSUReconstructor()
54 {
55   // destructor
56   //
57   if (!fGM) return; // was not initialized
58   //
59   // same cluster finders and recpoint arrays might be attached to different layers
60   for (int i=fGM->GetNLayers();i--;) {
61     TObject* clFinder = fClusterFinders.At(i);
62     if (clFinder) {
63       while (fClusterFinders.Remove(clFinder)) {}
64       delete clFinder;
65     }
66     //
67     TObject* arrRP = fRecPoints.At(i);
68     if (arrRP) {
69       while (fRecPoints.Remove(arrRP)) {}
70       delete arrRP;
71     }
72   }
73   //
74   delete fGM;
75
76
77 //______________________________________________________________________
78 void AliITSUReconstructor::Init() 
79 {
80   // Initalize this constructor 
81   if (fGM) AliFatal("was already done, something is wrong...");
82   //
83   fGM = new AliITSUGeomTGeo(kTRUE,kTRUE);
84   AliITSUClusterPix::SetGeom(fGM);
85   //  
86   AliITSUClusterizer* clusPIX = 0;
87   TClonesArray* rpArrayPix = 0;
88   //
89   for (int ilr=fGM->GetNLayers();ilr--;) {
90     int tpDet = fGM->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
91     if (tpDet == AliITSUGeomTGeo::kDetTypePix) {
92       if (!clusPIX)    clusPIX    = new AliITSUClusterizer();
93       if (!rpArrayPix) rpArrayPix = new TClonesArray(AliITSUClusterPix::Class());
94       //
95       fClusterFinders.AddAtAndExpand(clusPIX, ilr);
96       fRecPoints.AddAtAndExpand(rpArrayPix, ilr);
97       //
98       // to expand the buffers to max.size
99       clusPIX->SetSegmentation((AliITSUSegmentationPix*)fGM->GetSegmentation(ilr)); 
100       continue;
101     }
102     else {
103       AliFatal(Form("ClusterFinder for detector type %d is not defined",tpDet));
104     }
105   }
106   //
107   return;
108
109 }
110
111 //_____________________________________________________________________________
112 void AliITSUReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
113 {
114   // reconstruct clusters
115   if (!digitsTree || !clustersTree) return;
116   AliDebug(1,"ITSU Cluster finder (from digits tree) is initiated here \n");
117   //
118   // At the moment only pixel digits
119   TClonesArray *digArrPix = 0;
120   digitsTree->SetBranchAddress("ITSDigitsPix",&digArrPix);
121   //
122   // a new tree is created for each event: add each layer as separate branch
123   TBranch *lrBranch[fGM->GetNLayers()];
124   TClonesArray *rpClones[fGM->GetNLayers()];
125   //
126   for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
127     rpClones[ilr] = (TClonesArray*)fRecPoints.At(ilr);
128     int tp = fGM->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
129     if (tp==AliITSUGeomTGeo::kDetTypePix) {
130       lrBranch[ilr] = clustersTree->Bronch(Form("ITSRecPoints%d",ilr),"TClonesArray",&rpClones[ilr]);
131     }
132     else {
133       AliFatal(Form("Detector type %d is not defined",tp));
134     }
135   }
136   //
137   AliITSUClusterizer* clFinder = 0;
138   //
139   for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
140     //
141     rpClones[ilr]->Clear();
142     clFinder = (AliITSUClusterizer*)fClusterFinders[ilr];
143     clFinder->SetSegmentation((AliITSUSegmentationPix*)fGM->GetSegmentation(ilr));
144     clFinder->SetClusters(rpClones[ilr]);
145     clFinder->SetRecoParam(GetRecoParam()); // RS: Do we need to set it for every event?
146     //
147     int modF=fGM->GetFirstModIndex(ilr);
148     int modL=fGM->GetLastModIndex(ilr)+1;
149     for (int imod=modF;imod<modL;imod++) {
150       digitsTree->GetEntry(imod);   
151       int ndig  = digArrPix->GetEntries();
152       if (!ndig) continue;
153       clFinder->SetVolID(imod);
154       clFinder->SetDigits(digArrPix);
155       clFinder->Clusterize();
156     }
157     //
158     AliITSUClusterPix::SetSortMode( AliITSUClusterPix::SortModeTrkID());
159     rpClones[ilr]->Sort();
160     AliDebug(1,Form(" -> Lr%d : %d Cluster",ilr,rpClones[ilr]->GetEntries()));
161     lrBranch[ilr]->Fill();
162   }
163   clustersTree->SetEntries();
164   //
165 }
166
167 //_____________________________________________________________________________
168 AliTracker* AliITSUReconstructor::CreateTracker() const
169 {
170   // create a ITS tracker
171
172   AliDebug(1,"ITSU tracking initialization will be done here\n");
173  
174   return 0;
175
176   /* // from Current ITS
177   Int_t trackerOpt = GetRecoParam()->GetTracker();
178   AliTracker* tracker;    
179   if (trackerOpt==1) {
180     tracker = new AliITStrackerMI(0);
181     AliITStrackerMI *mit=(AliITStrackerMI*)tracker;
182     mit->SetDetTypeRec(fDetTypeRec);
183   }  
184   else if (trackerOpt==2) {
185     tracker = new AliITStrackerV2(0);
186   }
187   else {
188     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
189     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
190     sat->SetDetTypeRec(fDetTypeRec);
191     if(GetRecoParam()->GetTrackerSAOnly()) sat->SetSAFlag(kTRUE);
192     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
193     if(GetRecoParam()->GetInwardFindingSA()){
194       sat->SetInwardFinding();
195       sat->SetInnerStartLayer(GetRecoParam()->GetInnerStartLayerSA());
196     }else{
197       sat->SetOutwardFinding();
198       sat->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
199     }
200     sat->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());
201   }
202
203   return tracker;
204   */
205   
206 }
207
208 //_____________________________________________________________________________
209 AliVertexer* AliITSUReconstructor::CreateVertexer() const
210 {
211   // create a ITS vertexer
212   // to be implemented for the upgrade
213
214   AliDebug(1,"ITSU vertexer should be initiated here\n");
215   return 0;
216
217 }
218
219 //_____________________________________________________________________________
220 AliTrackleter* AliITSUReconstructor::CreateMultFinder() const
221 {
222   // create the SPD trackeleter for mult. reconstruction
223   // to be implemented for the upgrade
224
225   AliDebug(1,"ITSU MultFinder  should be initiated here\n");
226   return 0;
227
228 }
229
230 //_____________________________________________________________________________
231 AliTracker* AliITSUReconstructor::CreateTrackleter() const
232 {
233   // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
234   // to be implemented for the upgrade
235
236   AliDebug(1,"ITSU Trackleter  should be initiated here\n");
237   return 0;
238
239 }
240