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>
21 #include "AliITSdigit.h"
22 #include "AliITSLoader.h"
23 #include "AliRunLoader.h"
24 #include "AliITSInitGeometry.h"
27 ///////////////////////////////////////////////////////////////////////////
29 // it manages the I/O for:
30 // raw clusters, primary vertices
32 // and tracks propagated to the origin
33 //////////////////////////////////////////////////////////////////////////
34 const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
35 const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
36 const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
37 const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
38 const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
39 ClassImp(AliITSLoader)
41 /**********************************************************************/
42 AliITSLoader::AliITSLoader():AliLoader(),
45 // Default constructor
47 /*********************************************************************/
48 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
49 AliLoader(name,topfoldername),
53 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
54 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
56 fDataLoaders->Add(rawClustersDataLoader);
57 rawClustersDataLoader->SetEventFolder(fEventFolder);
58 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
60 AliDataLoader* backTracksDataLoader = new AliDataLoader(
61 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
62 "Back Propagated Tracks");
63 fDataLoaders->Add(backTracksDataLoader);
64 backTracksDataLoader->SetEventFolder(fEventFolder);
65 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
67 AliDataLoader* vertexDataLoader = new AliDataLoader(
68 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
69 "Primary Vertices","O");
70 fDataLoaders->Add(vertexDataLoader);
71 vertexDataLoader->SetEventFolder(fEventFolder);
72 vertexDataLoader->SetFolder(GetDetectorDataFolder());
74 AliDataLoader* v0DataLoader = new AliDataLoader(
75 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
76 fDataLoaders->Add(v0DataLoader);
77 v0DataLoader->SetEventFolder(fEventFolder);
78 v0DataLoader->SetFolder(GetDetectorDataFolder());
80 AliDataLoader* cascadeDataLoader = new AliDataLoader(
81 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
83 fDataLoaders->Add(cascadeDataLoader);
84 cascadeDataLoader->SetEventFolder(fEventFolder);
85 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
87 /**********************************************************************/
88 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
89 AliLoader(name,topfolder),
93 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
94 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
96 fDataLoaders->Add(rawClustersDataLoader);
97 rawClustersDataLoader->SetEventFolder(fEventFolder);
98 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
100 AliDataLoader* backTracksDataLoader = new AliDataLoader(
101 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
102 "Back Propagated Tracks");
103 fDataLoaders->Add(backTracksDataLoader);
104 backTracksDataLoader->SetEventFolder(fEventFolder);
105 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
107 AliDataLoader* vertexDataLoader = new AliDataLoader(
108 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
109 "Primary Vertices","O");
110 fDataLoaders->Add(vertexDataLoader);
111 vertexDataLoader->SetEventFolder(fEventFolder);
112 vertexDataLoader->SetFolder(GetDetectorDataFolder());
114 AliDataLoader* v0DataLoader = new AliDataLoader(
115 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
116 fDataLoaders->Add(v0DataLoader);
117 v0DataLoader->SetEventFolder(fEventFolder);
118 v0DataLoader->SetFolder(GetDetectorDataFolder());
120 AliDataLoader* cascadeDataLoader = new AliDataLoader(
121 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
123 fDataLoaders->Add(cascadeDataLoader);
124 cascadeDataLoader->SetEventFolder(fEventFolder);
125 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
129 /**********************************************************************/
130 AliITSLoader::~AliITSLoader(){
132 AliDataLoader* dl = 0;
134 dl = GetRawClLoader();
135 fDataLoaders->Remove(dl);
138 dl = GetBackTracksDataLoader();
139 fDataLoaders->Remove(dl);
142 dl = GetVertexDataLoader();
143 fDataLoaders->Remove(dl);
146 dl = GetV0DataLoader();
147 fDataLoaders->Remove(dl);
150 dl = GetCascadeDataLoader();
151 fDataLoaders->Remove(dl);
153 if(fGeom)delete fGeom;
157 //----------------------------------------------------------------------
158 AliITS* AliITSLoader::GetITS(){
159 // Returns the pointer to the ITS, kept on the file. A short cut metthod
165 // Returns a pointer to the ITS, if not found returns 0.
169 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
170 GetDetectorName().Data()));
177 ar = rl->GetAliRun();
179 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
182 //----------------------------------------------------------------------
183 void AliITSLoader::SetupDigits(AliITS *its){
184 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
186 // AliITS *its Pointer to the ITS
192 its->SetTreeAddressD(TreeD());
195 //----------------------------------------------------------------------
196 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
197 const Char_t **digclass){
198 // Sets up digPerDet to store ITS Digits.
200 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
201 // Int_t n The size of the TObjArray and digclass array
202 // Char_t **digclass Array of digit class names
204 // TObjArray *digPerDet Setup and linked to the tree of digits
208 TClonesArray *cl = 0;
212 const Char_t *det[3] = {"SPD","SDD","SSD"};
215 Error("SetUpDigits","TObject Array digPerDet does not exist");
218 m = digPerDet->GetSize();
220 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
221 " at least that of n=%d",digPerDet,n);
224 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
230 if(digPerDet->At(i)==0){ // set up TClones Array
231 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
232 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
233 else sprintf(branch,"ITSDigits%d",i+1);
234 br = td->GetBranch(branch);
235 br->SetAddress(&((*digPerDet)[i]));
236 continue; // do next one.
238 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
239 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
240 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
241 "zeroed or filled with TClonesArrays",i,digPerDet);
244 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
245 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
246 "derived from AliITSdigit",i,digPerDet->At(i));
249 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
250 else sprintf(branch,"ITSDigits%d",i+1);
251 br = td->GetBranch(branch);
252 br->SetAddress(&((*digPerDet)[i]));
256 //---------------------------------------------------------------------
257 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
259 // Gets the digit for for a specific detector type and module.
260 // To be used in conjustion with Setupdigits(AliITS *its).
262 // TObjArray *digPereDet Pointer to the Array of digits
263 // Int_t module Module number
264 // Int_t digit Digit number
268 // returns the pointer to the digit. if zero then last digit for that
272 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
273 digPerDet,module,digit);
279 //---------------------------------------------------------------------
280 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
281 // Gets the digit for for a specific detector type and module.
282 // To be used in conjustion with Setupdigits(AliITS *its).
284 // AliITS *its Pointer to the ITS
285 // Int_t module Module number
286 // Int_t digit Digit number
290 // returns the pointer to the digit. if zero then last digit for that
292 //AliITSDetType *idtype;
293 AliITSgeom *geom = its->GetITSgeom();
294 Int_t idet = geom->GetModuleType(module);
295 TClonesArray *digits;
298 TreeD()->GetEvent(module);
299 digits = its->DigitsAddress(idet);
300 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
301 return (AliITSdigit*) digits->At(digit);
306 //----------------------------------------------------------------------
307 void AliITSLoader::MakeTree(Option_t *opt){
308 // invokes AliLoader::MakeTree + specific ITS tree(s)
309 // Valid options: H,S,D,R,T and C (C=raw clusters)
310 AliLoader::MakeTree(opt);
311 const char *oC = strstr(opt,"C");
312 if (oC) MakeRawClustersContainer();
314 const char *oB = strstr(opt,"B");
315 if (oB) MakeBackTracksContainer();
317 const char *oV0 = strstr(opt,"V0");
318 if (oV0) MakeV0Container();
320 const char *oX = strstr(opt,"X");
321 if (oX) MakeCascadeContainer();
324 //----------------------------------------------------------------------
325 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
326 // retrieves the ITS geometry from file
327 if(fGeom && !force)return fGeom;
332 AliITSInitGeometry initgeom;
333 fGeom = initgeom.CreateAliITSgeom();
334 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
335 AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
338 //______________________________________________________________________
339 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
340 // Replaces the AliITSgeom object read from file with the one
343 // AliITSgeom *geom The AliITSgeom object to replace the one
344 // read from the file
350 if(fGeom==geom) return; // Same do nothing