]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUReconstructor.cxx
Possibility to not create RecPoints tree, using clusters directly in the reco.
[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. If clustersTree is provided, write the tree
115   if (!digitsTree) 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     if (clustersTree) { // do we write clusters tree?
129       int tp = fGM->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
130       if (tp==AliITSUGeomTGeo::kDetTypePix) {
131         lrBranch[ilr] = clustersTree->Bronch(Form("ITSRecPoints%d",ilr),"TClonesArray",&rpClones[ilr]);
132       }
133       else {
134         AliFatal(Form("Detector type %d is not defined",tp));
135       }
136     }
137   }
138   //
139   AliITSUClusterizer* clFinder = 0;
140   //
141   for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
142     //
143     rpClones[ilr]->Clear();
144     clFinder = (AliITSUClusterizer*)fClusterFinders[ilr];
145     clFinder->SetSegmentation((AliITSUSegmentationPix*)fGM->GetSegmentation(ilr));
146     clFinder->SetClusters(rpClones[ilr]);
147     clFinder->SetRecoParam(GetRecoParam()); // RS: Do we need to set it for every event?
148     //
149     int modF=fGM->GetFirstModIndex(ilr);
150     int modL=fGM->GetLastModIndex(ilr)+1;
151     for (int imod=modF;imod<modL;imod++) {
152       digitsTree->GetEntry(imod);   
153       int ndig  = digArrPix->GetEntries();
154       if (!ndig) continue;
155       clFinder->SetVolID(imod);
156       clFinder->SetDigits(digArrPix);
157       clFinder->Clusterize();
158     }
159     //
160     AliITSUClusterPix::SetSortMode( AliITSUClusterPix::SortModeIdTrkYZ());
161     rpClones[ilr]->Sort();
162     AliDebug(1,Form(" -> Lr%d : %d Cluster",ilr,rpClones[ilr]->GetEntries()));
163     if (clustersTree) lrBranch[ilr]->Fill();
164   }
165   if (clustersTree) clustersTree->SetEntries();
166   //
167 }
168
169 //_____________________________________________________________________________
170 AliTracker* AliITSUReconstructor::CreateTracker() const
171 {
172   // create a ITS tracker
173
174   AliDebug(1,"ITSU tracking initialization will be done here\n");
175  
176   return 0;
177
178   /* // from Current ITS
179   Int_t trackerOpt = GetRecoParam()->GetTracker();
180   AliTracker* tracker;    
181   if (trackerOpt==1) {
182     tracker = new AliITStrackerMI(0);
183     AliITStrackerMI *mit=(AliITStrackerMI*)tracker;
184     mit->SetDetTypeRec(fDetTypeRec);
185   }  
186   else if (trackerOpt==2) {
187     tracker = new AliITStrackerV2(0);
188   }
189   else {
190     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
191     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
192     sat->SetDetTypeRec(fDetTypeRec);
193     if(GetRecoParam()->GetTrackerSAOnly()) sat->SetSAFlag(kTRUE);
194     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
195     if(GetRecoParam()->GetInwardFindingSA()){
196       sat->SetInwardFinding();
197       sat->SetInnerStartLayer(GetRecoParam()->GetInnerStartLayerSA());
198     }else{
199       sat->SetOutwardFinding();
200       sat->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
201     }
202     sat->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());
203   }
204
205   return tracker;
206   */
207   
208 }
209
210 //_____________________________________________________________________________
211 AliVertexer* AliITSUReconstructor::CreateVertexer() const
212 {
213   // create a ITS vertexer
214   // to be implemented for the upgrade
215
216   AliDebug(1,"ITSU vertexer should be initiated here\n");
217   return 0;
218
219 }
220
221 //_____________________________________________________________________________
222 AliTrackleter* AliITSUReconstructor::CreateMultFinder() const
223 {
224   // create the SPD trackeleter for mult. reconstruction
225   // to be implemented for the upgrade
226
227   AliDebug(1,"ITSU MultFinder  should be initiated here\n");
228   return 0;
229
230 }
231
232 //_____________________________________________________________________________
233 AliTracker* AliITSUReconstructor::CreateTrackleter() const
234 {
235   // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
236   // to be implemented for the upgrade
237
238   AliDebug(1,"ITSU Trackleter  should be initiated here\n");
239   return 0;
240
241 }
242