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