Obsolete files
[u/mrichter/AliRoot.git] / ITS / AliITSLoader.cxx
CommitLineData
9edefa04 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$ */
17
18#include <TClass.h>
19
aacedc3e 20#include "AliITSdigit.h"
88cb7938 21#include "AliITSLoader.h"
7d62fb64 22#include "AliRunLoader.h"
13033bec 23#include "AliLog.h"
88cb7938 24
aacedc3e 25///////////////////////////////////////////////////////////////////////////
eeac5f9f 26// Loader for ITS
27// it manages the I/O for:
28// raw clusters, primary vertices
29// V0 and cascade
30// and tracks propagated to the origin
aacedc3e 31//////////////////////////////////////////////////////////////////////////
88cb7938 32const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
33const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
34const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
566abf75 35const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
36const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
88cb7938 37ClassImp(AliITSLoader)
38
aacedc3e 39/**********************************************************************/
e56160b8 40 AliITSLoader::AliITSLoader():AliLoader(),
41fITSpid(0),
42fGeom(0){
eeac5f9f 43 // Default constructor
aacedc3e 44}
45/*********************************************************************/
46AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
e56160b8 47AliLoader(name,topfoldername),
48fITSpid(0),
49fGeom(0){
50 //Constructor
aacedc3e 51 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
52 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
53 "Raw Clusters");
54 fDataLoaders->Add(rawClustersDataLoader);
55 rawClustersDataLoader->SetEventFolder(fEventFolder);
56 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
57
58 AliDataLoader* backTracksDataLoader = new AliDataLoader(
59 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
60 "Back Propagated Tracks");
61 fDataLoaders->Add(backTracksDataLoader);
62 backTracksDataLoader->SetEventFolder(fEventFolder);
63 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 64
aacedc3e 65 AliDataLoader* vertexDataLoader = new AliDataLoader(
66 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
67 "Primary Vertices","O");
68 fDataLoaders->Add(vertexDataLoader);
69 vertexDataLoader->SetEventFolder(fEventFolder);
70 vertexDataLoader->SetFolder(GetDetectorDataFolder());
71
72 AliDataLoader* v0DataLoader = new AliDataLoader(
73 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
74 fDataLoaders->Add(v0DataLoader);
75 v0DataLoader->SetEventFolder(fEventFolder);
76 v0DataLoader->SetFolder(GetDetectorDataFolder());
77
78 AliDataLoader* cascadeDataLoader = new AliDataLoader(
79 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
80 "Cascades");
81 fDataLoaders->Add(cascadeDataLoader);
82 cascadeDataLoader->SetEventFolder(fEventFolder);
83 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 84}
aacedc3e 85/**********************************************************************/
86AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
e56160b8 87 AliLoader(name,topfolder),
88fITSpid(0),
89fGeom(0){
aacedc3e 90 //ctor
91 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
92 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
93 "Raw Clusters");
94 fDataLoaders->Add(rawClustersDataLoader);
95 rawClustersDataLoader->SetEventFolder(fEventFolder);
96 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 97
aacedc3e 98 AliDataLoader* backTracksDataLoader = new AliDataLoader(
99 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
100 "Back Propagated Tracks");
101 fDataLoaders->Add(backTracksDataLoader);
102 backTracksDataLoader->SetEventFolder(fEventFolder);
103 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
104
105 AliDataLoader* vertexDataLoader = new AliDataLoader(
106 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
107 "Primary Vertices","O");
108 fDataLoaders->Add(vertexDataLoader);
109 vertexDataLoader->SetEventFolder(fEventFolder);
110 vertexDataLoader->SetFolder(GetDetectorDataFolder());
111
112 AliDataLoader* v0DataLoader = new AliDataLoader(
113 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
114 fDataLoaders->Add(v0DataLoader);
115 v0DataLoader->SetEventFolder(fEventFolder);
116 v0DataLoader->SetFolder(GetDetectorDataFolder());
117
118 AliDataLoader* cascadeDataLoader = new AliDataLoader(
119 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
120 "Cascades");
121 fDataLoaders->Add(cascadeDataLoader);
122 cascadeDataLoader->SetEventFolder(fEventFolder);
123 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
88cb7938 124}
e62c1aea 125
e62c1aea 126
aacedc3e 127/**********************************************************************/
128AliITSLoader::~AliITSLoader(){
129 //destructor
130 AliDataLoader* dl = 0;
131 UnloadRawClusters();
132 dl = GetRawClLoader();
133 fDataLoaders->Remove(dl);
88cb7938 134
aacedc3e 135 UnloadBackTracks();
136 dl = GetBackTracksDataLoader();
137 fDataLoaders->Remove(dl);
138
139 UnloadVertices();
140 dl = GetVertexDataLoader();
141 fDataLoaders->Remove(dl);
142
143 UnloadV0s();
144 dl = GetV0DataLoader();
145 fDataLoaders->Remove(dl);
146
147 UnloadCascades();
148 dl = GetCascadeDataLoader();
149 fDataLoaders->Remove(dl);
e56160b8 150
8e50d897 151 if(fGeom)delete fGeom;
023ae34b 152 fGeom = 0;
88cb7938 153}
7d62fb64 154/*
aacedc3e 155//----------------------------------------------------------------------
156AliITS* AliITSLoader::GetITS(){
157 // Returns the pointer to the ITS, kept on the file. A short cut metthod
158 // Inputs:
159 // none.
160 // Outputs:
161 // none.
162 // Returns:
163 // Returns a pointer to the ITS, if not found returns 0.
164 AliITS *its;
566abf75 165
aacedc3e 166 if(gAlice){
167 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
168 GetDetectorName().Data()));
169 if(its) return its;
170 } // end if gAlice
171 AliRunLoader *rl=0;
172 rl = GetRunLoader();
173 if(!rl) return 0;
174 AliRun *ar=0;
175 ar = rl->GetAliRun();
176 if(!ar) return 0;
177 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
178 return its;
88cb7938 179}
aacedc3e 180//----------------------------------------------------------------------
181void AliITSLoader::SetupDigits(AliITS *its){
182 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
183 // Inputs:
184 // AliITS *its Pointer to the ITS
185 // Outputs:
186 // none.
187 // Return:
188 // none.
88cb7938 189
aacedc3e 190 its->SetTreeAddressD(TreeD());
191}
7d62fb64 192*/
aacedc3e 193//----------------------------------------------------------------------
194void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
195 const Char_t **digclass){
196 // Sets up digPerDet to store ITS Digits.
197 // Inputs:
198 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
199 // Int_t n The size of the TObjArray and digclass array
200 // Char_t **digclass Array of digit class names
201 // Outputs:
202 // TObjArray *digPerDet Setup and linked to the tree of digits
203 // Return:
204 // none.
205 Int_t i,m;
206 TClonesArray *cl = 0;
207 TTree *td = 0;
208 TBranch *br = 0;
209 Char_t branch[13];
210 const Char_t *det[3] = {"SPD","SDD","SSD"};
211
212 if(!digPerDet){
213 Error("SetUpDigits","TObject Array digPerDet does not exist");
214 return;
215 } // end if
216 m = digPerDet->GetSize();
217 if(m<n){
218 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
219 " at least that of n=%d",digPerDet,n);
220 } // end if
221 if(m<3){
222 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
223 digPerDet);
224 return;
225 } // end if
226 td = TreeD();
227 for(i=0;i<n;i++){
228 if(digPerDet->At(i)==0){ // set up TClones Array
229 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
230 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
231 else sprintf(branch,"ITSDigits%d",i+1);
232 br = td->GetBranch(branch);
233 br->SetAddress(&((*digPerDet)[i]));
234 continue; // do next one.
235 } // end if
236 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
237 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
238 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
239 "zeroed or filled with TClonesArrays",i,digPerDet);
240 return;
241 } // end if
242 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
243 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
244 "derived from AliITSdigit",i,digPerDet->At(i));
245 } // end if
246 cl->Clear();
247 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
248 else sprintf(branch,"ITSDigits%d",i+1);
249 br = td->GetBranch(branch);
250 br->SetAddress(&((*digPerDet)[i]));
251 continue;
252 } // end for i
253}
254//---------------------------------------------------------------------
255AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
256 Int_t digit){
257 // Gets the digit for for a specific detector type and module.
258 // To be used in conjustion with Setupdigits(AliITS *its).
259 // Inputs:
260 // TObjArray *digPereDet Pointer to the Array of digits
261 // Int_t module Module number
262 // Int_t digit Digit number
263 // Outputs:
264 // none.
265 // Return:
266 // returns the pointer to the digit. if zero then last digit for that
267 // module.
268
269 if(digPerDet==0){
270 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
271 digPerDet,module,digit);
272 return 0;
273 } // end if
274 return 0;
275}
7d62fb64 276/*
aacedc3e 277//---------------------------------------------------------------------
278AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
279 // Gets the digit for for a specific detector type and module.
280 // To be used in conjustion with Setupdigits(AliITS *its).
281 // Inputs:
282 // AliITS *its Pointer to the ITS
283 // Int_t module Module number
284 // Int_t digit Digit number
285 // Outputs:
286 // none.
287 // Return:
288 // returns the pointer to the digit. if zero then last digit for that
289 // module.
290 //AliITSDetType *idtype;
291 AliITSgeom *geom = its->GetITSgeom();
292 Int_t idet = geom->GetModuleType(module);
293 TClonesArray *digits;
294
295 its->ResetDigits();
296 TreeD()->GetEvent(module);
297 digits = its->DigitsAddress(idet);
298 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
299 return (AliITSdigit*) digits->At(digit);
300 } // end if
301 return 0;
302}
7d62fb64 303*/
aacedc3e 304//----------------------------------------------------------------------
88cb7938 305void AliITSLoader::MakeTree(Option_t *opt){
aacedc3e 306 // invokes AliLoader::MakeTree + specific ITS tree(s)
307 // Valid options: H,S,D,R,T and C (C=raw clusters)
308 AliLoader::MakeTree(opt);
309 const char *oC = strstr(opt,"C");
310 if (oC) MakeRawClustersContainer();
311
312 const char *oB = strstr(opt,"B");
313 if (oB) MakeBackTracksContainer();
314
315 const char *oV0 = strstr(opt,"V0");
316 if (oV0) MakeV0Container();
317
318 const char *oX = strstr(opt,"X");
319 if (oX) MakeCascadeContainer();
88cb7938 320}
7d62fb64 321
322//----------------------------------------------------------------------
8e50d897 323AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
7d62fb64 324 // retrieves the ITS geometry from file
8e50d897 325 if(fGeom && !force)return fGeom;
326 if(fGeom && force){
327 delete fGeom;
328 fGeom = 0;
329 }
7d62fb64 330 AliRunLoader *runLoader = GetRunLoader();
8e50d897 331 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
7d62fb64 332 if (!runLoader->GetAliRun()) {
333 Error("GetITSgeom", "couldn't get AliRun object");
334 return NULL;
335 }
336
8e50d897 337 TDirectory *curdir = gDirectory;
7d62fb64 338 runLoader->CdGAFile();
8e50d897 339 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
340 curdir->cd();
341 if(!fGeom){
7d62fb64 342 Error("GetITSgeom","no ITS geometry available");
343 return NULL;
344 }
64f311fe 345 AliDebug(1,"AliITSgeom object has been fetched from galice.root file");
8e50d897 346 return fGeom;
7d62fb64 347}
023ae34b 348//______________________________________________________________________
349void AliITSLoader::SetITSgeom(AliITSgeom *geom){
350 // Replaces the AliITSgeom object read from file with the one
351 // given.
352 // Inputs:
353 // AliITSgeom *geom The AliITSgeom object to replace the one
354 // read from the file
355 // Outputs:
356 // none.
357 // Return:
358 // none.
359
360 if(fGeom==geom) return; // Same do nothing
361 if(fGeom) {
362 delete fGeom;
363 fGeom=0;
364 }// end if
365 fGeom=geom;
366}
7d62fb64 367