]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUReconstructor.cxx
Made reco interface to belong to AliITSUReconstruct, can be borrowed by
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUReconstructor.cxx
CommitLineData
b69620f8 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"
3d4dc3e2 26#include "AliITSURecoDet.h"
b69620f8 27#include "AliRun.h"
28#include "AliRawReader.h"
29#include "AliESDEvent.h"
30
31#include "AliTracker.h"
dde91d5d 32#include "AliITSUTrackerGlo.h"
b69620f8 33
34#include "AliITSUGeomTGeo.h"
35#include "AliITSUSegmentationPix.h"
36#include "AliITSUDigitPix.h"
37#include "AliITSUClusterizer.h"
5e375bb4 38#include "AliITSUClusterPix.h"
889b1493 39#include "AliMagF.h"
b69620f8 40
41ClassImp(AliITSUReconstructor)
42
43//___________________________________________________________________________
44AliITSUReconstructor::AliITSUReconstructor()
45: AliReconstructor()
889b1493 46 ,fGeom(0)
3d4dc3e2 47 ,fITS(0)
b69620f8 48 ,fClusterFinders(0)
889b1493 49 ,fClusters(0)
b69620f8 50{
51 // Default constructor
52
53}
54
55//___________________________________________________________________________
56AliITSUReconstructor::~AliITSUReconstructor()
57{
58 // destructor
59 //
889b1493 60 if (!fGeom) return; // was not initialized
b69620f8 61 //
62 // same cluster finders and recpoint arrays might be attached to different layers
889b1493 63 for (int i=fGeom->GetNLayers();i--;) {
b69620f8 64 TObject* clFinder = fClusterFinders.At(i);
65 if (clFinder) {
66 while (fClusterFinders.Remove(clFinder)) {}
67 delete clFinder;
68 }
69 //
44785f3e 70 delete fClusters[i];
b69620f8 71 }
44785f3e 72 delete[] fClusters;
b69620f8 73 //
3d4dc3e2 74 delete fITS;
889b1493 75 delete fGeom;
b69620f8 76}
77
78//______________________________________________________________________
79void AliITSUReconstructor::Init()
80{
3d4dc3e2 81 // Initalize this reconstructor
82 // Note: fITS cannot be initialized here since it requires RecoParams (not available ar
83 // the moment of reconstructors initialization)
84 //
889b1493 85 AliInfo("Initializing");
86 if (fGeom) AliFatal("was already done, something is wrong...");
b69620f8 87 //
889b1493 88 fGeom = new AliITSUGeomTGeo(kTRUE,kTRUE);
89 AliITSUClusterPix::SetGeom(fGeom);
b69620f8 90 //
91 AliITSUClusterizer* clusPIX = 0;
889b1493 92 fClusters = new TClonesArray*[fGeom->GetNLayers()];
b69620f8 93 //
889b1493 94 for (int ilr=fGeom->GetNLayers();ilr--;) {
95 fClusters[ilr] = 0;
96 int tpDet = fGeom->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
b69620f8 97 if (tpDet == AliITSUGeomTGeo::kDetTypePix) {
98 if (!clusPIX) clusPIX = new AliITSUClusterizer();
b69620f8 99 fClusterFinders.AddAtAndExpand(clusPIX, ilr);
889b1493 100 fClusters[ilr] = new TClonesArray(AliITSUClusterPix::Class());
b69620f8 101 //
546d00d8 102 // to expand the buffers to max.size
889b1493 103 clusPIX->SetSegmentation((AliITSUSegmentationPix*)fGeom->GetSegmentation(ilr));
b69620f8 104 continue;
105 }
106 else {
107 AliFatal(Form("ClusterFinder for detector type %d is not defined",tpDet));
108 }
109 }
110 //
111 return;
b69620f8 112}
113
114//_____________________________________________________________________________
115void AliITSUReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
116{
1f9b6041 117 // reconstruct clusters. If clustersTree is provided, write the tree
118 if (!digitsTree) return;
b69620f8 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
889b1493 126 TBranch *lrBranch[fGeom->GetNLayers()];
b69620f8 127 //
889b1493 128 for (int ilr=0;ilr<fGeom->GetNLayers();ilr++) {
44785f3e 129 lrBranch[ilr] = 0;
1f9b6041 130 if (clustersTree) { // do we write clusters tree?
889b1493 131 int tp = fGeom->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
1f9b6041 132 if (tp==AliITSUGeomTGeo::kDetTypePix) {
889b1493 133 lrBranch[ilr] = clustersTree->Bronch(Form("ITSRecPoints%d",ilr),"TClonesArray",&fClusters[ilr]);
1f9b6041 134 }
135 else {
136 AliFatal(Form("Detector type %d is not defined",tp));
137 }
b69620f8 138 }
139 }
140 //
141 AliITSUClusterizer* clFinder = 0;
889b1493 142 AliMagF* field = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
143 double bz = 0;
144 if (field == 0) AliError("Cannot get magnetic field from TGeoGlobalMagField");
145 else bz = field->SolenoidField();
b69620f8 146 //
889b1493 147 for (int ilr=0;ilr<fGeom->GetNLayers();ilr++) {
b69620f8 148 //
889b1493 149 fClusters[ilr]->Clear();
b69620f8 150 clFinder = (AliITSUClusterizer*)fClusterFinders[ilr];
889b1493 151 clFinder->SetSegmentation((AliITSUSegmentationPix*)fGeom->GetSegmentation(ilr));
152 clFinder->SetLayerID(ilr);
153 clFinder->SetClusters(fClusters[ilr]);
5e375bb4 154 clFinder->SetRecoParam(GetRecoParam()); // RS: Do we need to set it for every event?
889b1493 155 clFinder->PrepareLorentzAngleCorrection(bz);
b69620f8 156 //
889b1493 157 int modF=fGeom->GetFirstModIndex(ilr);
158 int modL=fGeom->GetLastModIndex(ilr)+1;
b69620f8 159 for (int imod=modF;imod<modL;imod++) {
160 digitsTree->GetEntry(imod);
161 int ndig = digArrPix->GetEntries();
162 if (!ndig) continue;
163 clFinder->SetVolID(imod);
164 clFinder->SetDigits(digArrPix);
165 clFinder->Clusterize();
166 }
167 //
1f9b6041 168 AliITSUClusterPix::SetSortMode( AliITSUClusterPix::SortModeIdTrkYZ());
889b1493 169 fClusters[ilr]->Sort();
170 AliDebug(1,Form(" -> Lr%d : %d Cluster",ilr,fClusters[ilr]->GetEntries()));
1f9b6041 171 if (clustersTree) lrBranch[ilr]->Fill();
b69620f8 172 }
1f9b6041 173 if (clustersTree) clustersTree->SetEntries();
b69620f8 174 //
175}
176
177//_____________________________________________________________________________
178AliTracker* AliITSUReconstructor::CreateTracker() const
179{
180 // create a ITS tracker
dde91d5d 181 AliITSUTrackerGlo* tracker = new AliITSUTrackerGlo((AliITSUReconstructor*)this);
b69620f8 182
b69620f8 183 return tracker;
dde91d5d 184
b69620f8 185}
186
187//_____________________________________________________________________________
188AliVertexer* AliITSUReconstructor::CreateVertexer() const
189{
190 // create a ITS vertexer
191 // to be implemented for the upgrade
192
193 AliDebug(1,"ITSU vertexer should be initiated here\n");
194 return 0;
195
196}
197
198//_____________________________________________________________________________
199AliTrackleter* AliITSUReconstructor::CreateMultFinder() const
200{
201 // create the SPD trackeleter for mult. reconstruction
202 // to be implemented for the upgrade
203
204 AliDebug(1,"ITSU MultFinder should be initiated here\n");
205 return 0;
206
207}
208
209//_____________________________________________________________________________
210AliTracker* AliITSUReconstructor::CreateTrackleter() const
211{
212 // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
213 // to be implemented for the upgrade
214
215 AliDebug(1,"ITSU Trackleter should be initiated here\n");
216 return 0;
217
218}
219
889b1493 220//_____________________________________________________________________________
221Int_t AliITSUReconstructor::LoadClusters(TTree* treeRP)
222{
223 // read clusters from the tree, if it is provided
224 if (!treeRP) return 0;
225 for (int ilr=fGeom->GetNLayers();ilr--;) {
226 if (!fClusters[ilr]) AliFatal(Form("Clusters array for layer %d is not defined",ilr));
227 TBranch* br = treeRP->GetBranch(Form("ITSRecPoints%d",ilr));
228 if (!br) AliFatal(Form("Provided cluster tree does not contain branch for layer %d",ilr));
229 br->SetAddress(&fClusters[ilr]);
230 }
231 treeRP->GetEntry(0); // we are still in 1 ev/tree mode...
232 return 1;
233}
3d4dc3e2 234
235//_____________________________________________________________________________
236AliITSURecoDet* AliITSUReconstructor::GetITSInterface()
237{
238 // Create reco oriented interface to geometry
239 if (fITS) return fITS;
240 //
241 fITS = new AliITSURecoDet(fGeom,"ITSURecoInterface");
242 int nLr = fITS->GetNLayersActive();
243 for (int ilr=nLr;ilr--;) fITS->GetLayerActive(ilr)->SetClusters(GetClusters(ilr));
244 return fITS;
245}