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 **************************************************************************/
18 #include <TClonesArray.h>
20 #include <TGeoManager.h>
23 #include "AliITSdigit.h"
24 #include "AliITSLoader.h"
25 #include "AliRunLoader.h"
26 #include "AliObjectLoader.h"
27 #include "AliITSInitGeometry.h"
30 ///////////////////////////////////////////////////////////////////////////
32 // it manages the I/O for:
33 // raw clusters, primary vertices
35 // and tracks propagated to the origin
36 ClassImp(AliITSLoader)
38 /**********************************************************************/
39 AliITSLoader::AliITSLoader():AliLoader(),
41 // Default constructor
43 /*********************************************************************/
44 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
45 AliLoader(name,topfoldername),
48 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
49 fDetectorName + ".RawCl.root",GetDefaultRawClustersContainerName(),
51 fDataLoaders->Add(rawClustersDataLoader);
52 rawClustersDataLoader->SetEventFolder(fEventFolder);
53 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
55 AliDataLoader* backTracksDataLoader = new AliDataLoader(
56 fDetectorName + ".BackTracks.root",GetDefaultBackTracksContainerName(),
57 "Back Propagated Tracks");
58 fDataLoaders->Add(backTracksDataLoader);
59 backTracksDataLoader->SetEventFolder(fEventFolder);
60 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
62 AliDataLoader* vertexDataLoader = new AliDataLoader(
63 fDetectorName + ".Vertex.root",GetDefaultVerticesContainerName(),
64 "Primary Vertices","O");
65 fDataLoaders->Add(vertexDataLoader);
66 vertexDataLoader->SetEventFolder(fEventFolder);
67 vertexDataLoader->SetFolder(GetDetectorDataFolder());
69 AliDataLoader* v0DataLoader = new AliDataLoader(
70 fDetectorName + ".V0s.root",GetDefaultV0ContainerName(),"V0 Vertices");
71 fDataLoaders->Add(v0DataLoader);
72 v0DataLoader->SetEventFolder(fEventFolder);
73 v0DataLoader->SetFolder(GetDetectorDataFolder());
75 AliDataLoader* cascadeDataLoader = new AliDataLoader(
76 fDetectorName + ".Cascades.root",GetDefaultCascadeContainerName(),
78 fDataLoaders->Add(cascadeDataLoader);
79 cascadeDataLoader->SetEventFolder(fEventFolder);
80 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
82 /**********************************************************************/
83 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
84 AliLoader(name,topfolder),
87 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
88 fDetectorName + ".RawCl.root",GetDefaultRawClustersContainerName(),
90 fDataLoaders->Add(rawClustersDataLoader);
91 rawClustersDataLoader->SetEventFolder(fEventFolder);
92 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
94 AliDataLoader* backTracksDataLoader = new AliDataLoader(
95 fDetectorName + ".BackTracks.root",GetDefaultBackTracksContainerName(),
96 "Back Propagated Tracks");
97 fDataLoaders->Add(backTracksDataLoader);
98 backTracksDataLoader->SetEventFolder(fEventFolder);
99 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
101 AliDataLoader* vertexDataLoader = new AliDataLoader(
102 fDetectorName + ".Vertex.root",GetDefaultVerticesContainerName(),
103 "Primary Vertices","O");
104 fDataLoaders->Add(vertexDataLoader);
105 vertexDataLoader->SetEventFolder(fEventFolder);
106 vertexDataLoader->SetFolder(GetDetectorDataFolder());
108 AliDataLoader* v0DataLoader = new AliDataLoader(
109 fDetectorName + ".V0.root",GetDefaultV0ContainerName(),"V0 Vertices");
110 fDataLoaders->Add(v0DataLoader);
111 v0DataLoader->SetEventFolder(fEventFolder);
112 v0DataLoader->SetFolder(GetDetectorDataFolder());
114 AliDataLoader* cascadeDataLoader = new AliDataLoader(
115 fDetectorName + ".Cascade.root",GetDefaultCascadeContainerName(),
117 fDataLoaders->Add(cascadeDataLoader);
118 cascadeDataLoader->SetEventFolder(fEventFolder);
119 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
123 /**********************************************************************/
124 AliITSLoader::~AliITSLoader(){
126 AliDataLoader* dl = 0;
128 dl = GetRawClLoader();
129 fDataLoaders->Remove(dl);
132 dl = GetBackTracksDataLoader();
133 fDataLoaders->Remove(dl);
136 dl = GetVertexDataLoader();
137 fDataLoaders->Remove(dl);
140 dl = GetV0DataLoader();
141 fDataLoaders->Remove(dl);
144 dl = GetCascadeDataLoader();
145 fDataLoaders->Remove(dl);
147 if(fGeom)delete fGeom;
151 //----------------------------------------------------------------------
152 AliITS* AliITSLoader::GetITS(){
153 // Returns the pointer to the ITS, kept on the file. A short cut metthod
159 // Returns a pointer to the ITS, if not found returns 0.
163 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
164 GetDetectorName().Data()));
171 ar = rl->GetAliRun();
173 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
176 //----------------------------------------------------------------------
177 void AliITSLoader::SetupDigits(AliITS *its){
178 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
180 // AliITS *its Pointer to the ITS
186 its->SetTreeAddressD(TreeD());
189 //----------------------------------------------------------------------
190 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
191 const Char_t **digclass){
192 // Sets up digPerDet to store ITS Digits.
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
198 // TObjArray *digPerDet Setup and linked to the tree of digits
202 TClonesArray *cl = 0;
206 const Char_t *det[3] = {"SPD","SDD","SSD"};
209 Error("SetUpDigits","TObject Array digPerDet does not exist");
212 m = digPerDet->GetSize();
214 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
215 " at least that of n=%d",digPerDet,n);
218 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
224 if(digPerDet->At(i)==0){ // set up TClones Array
225 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
226 if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
227 else snprintf(branch,13,"ITSDigits%d",i+1);
228 br = td->GetBranch(branch);
229 br->SetAddress(&((*digPerDet)[i]));
230 continue; // do next one.
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);
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));
243 if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
244 else snprintf(branch,13,"ITSDigits%d",i+1);
245 br = td->GetBranch(branch);
246 br->SetAddress(&((*digPerDet)[i]));
250 //---------------------------------------------------------------------
251 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
253 // Gets the digit for for a specific detector type and module.
254 // To be used in conjustion with Setupdigits(AliITS *its).
256 // TObjArray *digPereDet Pointer to the Array of digits
257 // Int_t module Module number
258 // Int_t digit Digit number
262 // returns the pointer to the digit. if zero then last digit for that
266 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
267 digPerDet,module,digit);
273 //---------------------------------------------------------------------
274 AliITSdigit * 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).
278 // AliITS *its Pointer to the ITS
279 // Int_t module Module number
280 // Int_t digit Digit number
284 // returns the pointer to the digit. if zero then last digit for that
286 //AliITSDetType *idtype;
287 AliITSgeom *geom = its->GetITSgeom();
288 Int_t idet = geom->GetModuleType(module);
289 TClonesArray *digits;
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);
300 //----------------------------------------------------------------------
301 void AliITSLoader::MakeTree(Option_t *opt){
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();
308 const char *oB = strstr(opt,"B");
309 if (oB) MakeBackTracksContainer();
311 const char *oV0 = strstr(opt,"V0");
312 if (oV0) MakeV0Container();
314 const char *oX = strstr(opt,"X");
315 if (oX) MakeCascadeContainer();
318 //----------------------------------------------------------------------
319 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
320 // retrieves the ITS geometry from file
321 if(fGeom && !force)return fGeom;
327 AliError("gGeoManager is a null pointer - ITS geometry not built");
330 AliITSInitGeometry initgeom;
331 fGeom = initgeom.CreateAliITSgeom();
332 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
333 AliDebug(1,Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
336 //______________________________________________________________________
337 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
338 // Replaces the AliITSgeom object read from file with the one
341 // AliITSgeom *geom The AliITSgeom object to replace the one
342 // read from the file
348 if(fGeom==geom) return; // Same do nothing
356 const TString& AliITSLoader::GetDefaultRawClustersContainerName() {
357 //default for Raw Clusters container name
358 static const TString kDefaultRawClustersContainerName = "TreeC";
359 return kDefaultRawClustersContainerName;
362 const TString& AliITSLoader::GetDefaultBackTracksContainerName() {
363 //default for Back propag. tracks container name
364 static const TString kDefaultBackTracksContainerName = "TreeB";
365 return kDefaultBackTracksContainerName;
368 const TString& AliITSLoader::GetDefaultVerticesContainerName() {
369 //default for primary vertices container name
370 static const TString kDefaultVerticesContainerName = "Vertex";
371 return kDefaultVerticesContainerName;
374 const TString& AliITSLoader::GetDefaultV0ContainerName() {
375 //default for V0 container name
376 static const TString kDefaultV0ContainerName = "V0";
377 return kDefaultV0ContainerName;
380 const TString& AliITSLoader::GetDefaultCascadeContainerName() {
381 //default fo cascade container name
382 static const TString kDefaultCascadeContainerName = "Cascade";
383 return kDefaultCascadeContainerName;