]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUReconstructor.cxx
clusterizer,reconstructor + many fixes (Magnus,Stefan)
[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
38 ClassImp(AliITSUReconstructor)
39
40 //___________________________________________________________________________
41 AliITSUReconstructor::AliITSUReconstructor() 
42 :  AliReconstructor()
43   ,fGM(0)
44   ,fSegmArr(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   fSegmArr.Delete();
76
77
78 //______________________________________________________________________
79 void AliITSUReconstructor::Init() 
80 {
81   // 
82   // Initalize this constructor 
83   if (fGM) AliFatal("was already done, something is wrong...");
84   //
85   fGM = new AliITSUGeomTGeo(kTRUE);
86   AliITSUSegmentationPix::LoadSegmentations(&fSegmArr, AliITSUGeomTGeo::GetITSsegmentationFileName());
87   //  
88   AliITSUClusterizer* clusPIX = 0;
89   TClonesArray* rpArrayPix = 0;
90   //
91   for (int ilr=fGM->GetNLayers();ilr--;) {
92     int tp = fGM->GetLayerDetTypeID(ilr);
93     int tpDet = tp/AliITSUGeomTGeo::kMaxSegmPerDetType;
94     if (tpDet == AliITSUGeomTGeo::kDetTypePix) {
95       if (!clusPIX)    clusPIX    = new AliITSUClusterizer();
96       if (!rpArrayPix) rpArrayPix = new TClonesArray(AliCluster::Class());
97       //
98       fClusterFinders.AddAtAndExpand(clusPIX, ilr);
99       fRecPoints.AddAtAndExpand(rpArrayPix, ilr);
100       //
101       AliITSUSegmentationPix* sg = (AliITSUSegmentationPix*)fSegmArr.At(tp);
102       clusPIX->SetSegmentation(sg); // to expand the buffers to max.size
103       continue;
104     }
105     else {
106       AliFatal(Form("ClusterFinder for detector type %d is not defined",tpDet));
107     }
108   }
109   //
110   return;
111
112 }
113
114 //_____________________________________________________________________________
115 void AliITSUReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
116 {
117   // reconstruct clusters
118   if (!digitsTree || !clustersTree) return;
119   AliDebug(1,"ITSU Cluster finder (from digits tree) is initiated here \n");
120   //
121   // At the moment only pixel digits
122   TClonesArray *digArrPix = 0;
123   digitsTree->SetBranchAddress("ITSDigitsPix",&digArrPix);
124   //
125   // a new tree is created for each event: add each layer as separate branch
126   TBranch *lrBranch[fGM->GetNLayers()];
127   TClonesArray *rpClones[fGM->GetNLayers()];
128   //
129   for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
130     rpClones[ilr] = (TClonesArray*)fRecPoints.At(ilr);
131     int tp = fGM->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
132     if (tp==AliITSUGeomTGeo::kDetTypePix) {
133       lrBranch[ilr] = clustersTree->Bronch(Form("ITSRecPoints%d",ilr),"TClonesArray",&rpClones[ilr]);
134     }
135     else {
136       AliFatal(Form("Detector type %d is not defined",tp));
137     }
138   }
139   //
140   AliITSUClusterizer* clFinder = 0;
141   //
142   for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
143     //
144     int tp = fGM->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
145     AliITSUSegmentationPix* segm = (AliITSUSegmentationPix*)fSegmArr.At(tp);
146     //
147     clFinder = (AliITSUClusterizer*)fClusterFinders[ilr];
148     clFinder->SetSegmentation(segm);
149     clFinder->SetClusters(rpClones[ilr]);
150     //
151     int modF=fGM->GetFirstModIndex(ilr);
152     int modL=fGM->GetLastModIndex(ilr)+1;
153     for (int imod=modF;imod<modL;imod++) {
154       digitsTree->GetEntry(imod);   
155       int ndig  = digArrPix->GetEntries();
156       if (!ndig) continue;
157       clFinder->SetVolID(imod);
158       clFinder->SetDigits(digArrPix);
159       clFinder->Clusterize();
160     }
161     //
162     AliDebug(1,Form(" -> Lr%d : %d Cluster",ilr,rpClones[ilr]->GetEntries()));
163     lrBranch[ilr]->Fill();
164     rpClones[ilr]->Clear();
165   }
166   clustersTree->SetEntries();
167   //
168 }
169
170 //_____________________________________________________________________________
171 AliTracker* AliITSUReconstructor::CreateTracker() const
172 {
173   // create a ITS tracker
174
175   AliDebug(1,"ITSU tracking initialization will be done here\n");
176  
177   return 0;
178
179   /* // from Current ITS
180   Int_t trackerOpt = GetRecoParam()->GetTracker();
181   AliTracker* tracker;    
182   if (trackerOpt==1) {
183     tracker = new AliITStrackerMI(0);
184     AliITStrackerMI *mit=(AliITStrackerMI*)tracker;
185     mit->SetDetTypeRec(fDetTypeRec);
186   }  
187   else if (trackerOpt==2) {
188     tracker = new AliITStrackerV2(0);
189   }
190   else {
191     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
192     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
193     sat->SetDetTypeRec(fDetTypeRec);
194     if(GetRecoParam()->GetTrackerSAOnly()) sat->SetSAFlag(kTRUE);
195     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
196     if(GetRecoParam()->GetInwardFindingSA()){
197       sat->SetInwardFinding();
198       sat->SetInnerStartLayer(GetRecoParam()->GetInnerStartLayerSA());
199     }else{
200       sat->SetOutwardFinding();
201       sat->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
202     }
203     sat->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());
204   }
205
206   return tracker;
207   */
208   
209 }
210
211 //_____________________________________________________________________________
212 AliVertexer* AliITSUReconstructor::CreateVertexer() const
213 {
214   // create a ITS vertexer
215   // to be implemented for the upgrade
216
217   AliDebug(1,"ITSU vertexer should be initiated here\n");
218   return 0;
219
220 }
221
222 //_____________________________________________________________________________
223 AliTrackleter* AliITSUReconstructor::CreateMultFinder() const
224 {
225   // create the SPD trackeleter for mult. reconstruction
226   // to be implemented for the upgrade
227
228   AliDebug(1,"ITSU MultFinder  should be initiated here\n");
229   return 0;
230
231 }
232
233 //_____________________________________________________________________________
234 AliTracker* AliITSUReconstructor::CreateTrackleter() const
235 {
236   // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
237   // to be implemented for the upgrade
238
239   AliDebug(1,"ITSU Trackleter  should be initiated here\n");
240   return 0;
241
242 }
243