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 **************************************************************************/
16 /* $Id: AliITSUReconstructor.cxx 58442 2012-09-04 17:17:06Z masera $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for ITS reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "Riostream.h"
25 #include "AliITSUReconstructor.h"
27 #include "AliRawReader.h"
28 #include "AliESDEvent.h"
30 #include "AliTracker.h"
31 #include "AliITStrackerMI.h"
33 #include "AliITSUGeomTGeo.h"
34 #include "AliITSUSegmentationPix.h"
35 #include "AliITSUDigitPix.h"
36 #include "AliITSUClusterizer.h"
37 #include "AliITSUClusterPix.h"
39 ClassImp(AliITSUReconstructor)
41 //___________________________________________________________________________
42 AliITSUReconstructor::AliITSUReconstructor()
48 // Default constructor
52 //___________________________________________________________________________
53 AliITSUReconstructor::~AliITSUReconstructor()
57 if (!fGM) return; // was not initialized
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);
63 while (fClusterFinders.Remove(clFinder)) {}
67 TObject* arrRP = fRecPoints.At(i);
69 while (fRecPoints.Remove(arrRP)) {}
77 //______________________________________________________________________
78 void AliITSUReconstructor::Init()
80 // Initalize this constructor
81 if (fGM) AliFatal("was already done, something is wrong...");
83 fGM = new AliITSUGeomTGeo(kTRUE,kTRUE);
84 AliITSUClusterPix::SetGeom(fGM);
86 AliITSUClusterizer* clusPIX = 0;
87 TClonesArray* rpArrayPix = 0;
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());
95 fClusterFinders.AddAtAndExpand(clusPIX, ilr);
96 fRecPoints.AddAtAndExpand(rpArrayPix, ilr);
98 // to expand the buffers to max.size
99 clusPIX->SetSegmentation((AliITSUSegmentationPix*)fGM->GetSegmentation(ilr));
103 AliFatal(Form("ClusterFinder for detector type %d is not defined",tpDet));
111 //_____________________________________________________________________________
112 void AliITSUReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
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");
118 // At the moment only pixel digits
119 TClonesArray *digArrPix = 0;
120 digitsTree->SetBranchAddress("ITSDigitsPix",&digArrPix);
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()];
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]);
134 AliFatal(Form("Detector type %d is not defined",tp));
139 AliITSUClusterizer* clFinder = 0;
141 for (int ilr=0;ilr<fGM->GetNLayers();ilr++) {
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?
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();
155 clFinder->SetVolID(imod);
156 clFinder->SetDigits(digArrPix);
157 clFinder->Clusterize();
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();
165 if (clustersTree) clustersTree->SetEntries();
169 //_____________________________________________________________________________
170 AliTracker* AliITSUReconstructor::CreateTracker() const
172 // create a ITS tracker
174 AliDebug(1,"ITSU tracking initialization will be done here\n");
178 /* // from Current ITS
179 Int_t trackerOpt = GetRecoParam()->GetTracker();
182 tracker = new AliITStrackerMI(0);
183 AliITStrackerMI *mit=(AliITStrackerMI*)tracker;
184 mit->SetDetTypeRec(fDetTypeRec);
186 else if (trackerOpt==2) {
187 tracker = new AliITStrackerV2(0);
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());
199 sat->SetOutwardFinding();
200 sat->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
202 sat->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());
210 //_____________________________________________________________________________
211 AliVertexer* AliITSUReconstructor::CreateVertexer() const
213 // create a ITS vertexer
214 // to be implemented for the upgrade
216 AliDebug(1,"ITSU vertexer should be initiated here\n");
221 //_____________________________________________________________________________
222 AliTrackleter* AliITSUReconstructor::CreateMultFinder() const
224 // create the SPD trackeleter for mult. reconstruction
225 // to be implemented for the upgrade
227 AliDebug(1,"ITSU MultFinder should be initiated here\n");
232 //_____________________________________________________________________________
233 AliTracker* AliITSUReconstructor::CreateTrackleter() const
235 // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
236 // to be implemented for the upgrade
238 AliDebug(1,"ITSU Trackleter should be initiated here\n");